@bb-studio/ocio 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/index.js +4 -4
- package/src/ocio-js.d.ts +0 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ The native module links against OpenColorIO C++ and runs the OCIO CPU processor
|
|
|
12
12
|
npm install @bb-studio/ocio
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
The npm package exposes the JavaScript API from `@bb-studio/ocio`
|
|
15
|
+
The npm package exposes the JavaScript API from `@bb-studio/ocio`. `createOCIO()` selects the correct WebAssembly loader for the current runtime and resolves the bundled wasm file automatically.
|
|
16
16
|
|
|
17
17
|
It ships three prebuilt Emscripten artifacts:
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ It ships three prebuilt Emscripten artifacts:
|
|
|
20
20
|
- `dist/ocio-wasm.node.js`
|
|
21
21
|
- `dist/ocio-wasm.wasm`
|
|
22
22
|
|
|
23
|
-
Node.js
|
|
23
|
+
Node.js uses `dist/ocio-wasm.node.js`. Browsers, workers, and other runtimes use `dist/ocio-wasm.js`. Both wrappers load the same `dist/ocio-wasm.wasm` binary. The browser wrapper is built without Node.js runtime branches, so browser bundlers do not see Node.js built-in imports such as `node:module`.
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -17,7 +17,7 @@ export const OptimizationFlags = Object.freeze({
|
|
|
17
17
|
DRAFT: -1
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const DEFAULT_WASM_URL = new URL('../dist/ocio-wasm.wasm', import.meta.url).href;
|
|
21
21
|
const DEFAULT_GPU_SHADER_FUNCTION = 'OCIODisplay';
|
|
22
22
|
const DEFAULT_GPU_RESOURCE_PREFIX = 'ocio';
|
|
23
23
|
const GPU_UNIFORM_TYPES = Object.freeze([
|
|
@@ -82,7 +82,7 @@ function toPositiveInteger(value, name) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
export async function createOCIO(options = {}) {
|
|
85
|
-
const moduleFactory = options.moduleFactory ?? (await import(
|
|
85
|
+
const moduleFactory = options.moduleFactory ?? (await import('#ocio-wasm')).default;
|
|
86
86
|
const userLocateFile = options.locateFile;
|
|
87
87
|
const moduleOptions = {
|
|
88
88
|
...options.moduleOptions,
|
|
@@ -90,8 +90,8 @@ export async function createOCIO(options = {}) {
|
|
|
90
90
|
if (userLocateFile) {
|
|
91
91
|
return userLocateFile(path, prefix);
|
|
92
92
|
}
|
|
93
|
-
if (path
|
|
94
|
-
return
|
|
93
|
+
if (path === 'ocio-wasm.wasm') {
|
|
94
|
+
return DEFAULT_WASM_URL;
|
|
95
95
|
}
|
|
96
96
|
return prefix + path;
|
|
97
97
|
}
|
package/src/ocio-js.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export const OptimizationFlags: Readonly<{
|
|
|
19
19
|
|
|
20
20
|
export interface CreateOCIOOptions {
|
|
21
21
|
moduleFactory?: (options?: unknown) => Promise<unknown>;
|
|
22
|
-
modulePath?: string;
|
|
23
22
|
moduleOptions?: Record<string, unknown>;
|
|
24
23
|
locateFile?: (path: string, prefix: string) => string;
|
|
25
24
|
}
|