Skip to content

Commit c5ddef7

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 c5ddef7

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

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.mjs",
17+
"module": "./dist/lib.mjs",
18+
"types": "./dist/lib.d.ts",
19+
"exports": {
20+
".": {
21+
"types": "./dist/lib.d.ts",
22+
"import": "./dist/lib.mjs"
23+
}
24+
},
1625
"bin": {
1726
"splat-transform": "bin/cli.mjs"
1827
},

rollup.config.mjs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@ 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+
entryFileNames: '[name].mjs'
29+
},
30+
external: ['webgpu'],
31+
plugins: [
32+
typescript({
33+
tsconfig: './tsconfig.json',
34+
declaration: true,
35+
declarationDir: './dist'
36+
}),
37+
resolve(),
38+
json()
39+
],
40+
cache: false
41+
};
42+
2243
export default [
23-
application
44+
application,
45+
library
2446
];

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)