Skip to content

Commit fc70ba5

Browse files
committed
Add library exports for programmatic usage
Add library exports for programmatic usage Add library entry point (src/lib.ts) that exports utilities for programmatic consumption. This allows using splat-transform as a library, not just as a CLI tool.
1 parent 1cfba84 commit fc70ba5

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
dist
3+
lib
34
.DS_Store
45
scenes/

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
"typescript"
1414
],
1515
"license": "MIT",
16+
"main": "./dist/lib.js",
17+
"module": "./dist/lib.js",
18+
"types": "./dist/lib.d.ts",
19+
"exports": {
20+
".": {
21+
"types": "./dist/lib.d.ts",
22+
"import": "./dist/lib.js"
23+
}
24+
},
1625
"bin": {
1726
"splat-transform": "bin/cli.mjs"
1827
},

rollup.config.mjs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,27 @@ const application = {
1919
cache: false
2020
};
2121

22+
const library = {
23+
input: 'src/lib.ts',
24+
output: {
25+
dir: 'dist',
26+
format: 'esm',
27+
sourcemap: true
28+
},
29+
external: ['webgpu'],
30+
plugins: [
31+
typescript({
32+
tsconfig: './tsconfig.json',
33+
declaration: true,
34+
declarationDir: './dist'
35+
}),
36+
resolve(),
37+
json()
38+
],
39+
cache: false
40+
};
41+
2242
export default [
23-
application
43+
application,
44+
library
2445
];

src/lib.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Library exports for programmatic use of @playcanvas/splat-transform
3+
*/
4+
5+
export { Column, DataTable } from './data-table';
6+
export type { TypedArray } from './data-table';
7+
8+
export { transform } from './transform';
9+
export { generateOrdering } from './ordering';
10+
11+
export { readPly } from './readers/read-ply';
12+
export type { PlyData } from './readers/read-ply';
13+
export { writePly } from './writers/write-ply';
14+
15+
export { readKsplat } from './readers/read-ksplat';
16+
export { readLcc } from './readers/read-lcc';
17+
export { readMjs } from './readers/read-mjs';
18+
export { readSog } from './readers/read-sog';
19+
export { readSplat } from './readers/read-splat';
20+
export { readSpz } from './readers/read-spz';
21+
export { isCompressedPly, decompressPly } from './readers/decompress-ply';
22+
23+
export { writeCsv } from './writers/write-csv';
24+
export { writeHtml } from './writers/write-html';
25+
export { writeLod } from './writers/write-lod';
26+
export { writeSog } from './writers/write-sog';
27+
export { writeCompressedPly } from './writers/write-compressed-ply';
28+
export { CompressedChunk } from './writers/compressed-chunk';

0 commit comments

Comments
 (0)