Skip to content

Commit 832b7e9

Browse files
committed
Eli comments
1 parent 18d1c4b commit 832b7e9

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

docs/tasks/includes/_js-setup.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
This is how to set up your code to use the JavaScript library:
22

33
```js
4-
const version = '0.24.2';
4+
const version = '0.27.1';
55
const sampleImage = '<IMAGE_URL>';
66

77
import { createC2pa } from 'https://cdn.jsdelivr.net/npm/c2pa@${version}/+esm';
@@ -14,4 +14,31 @@ import { createC2pa } from 'https://cdn.jsdelivr.net/npm/c2pa@${version}/+esm';
1414
workerSrc:
1515
'https://cdn.jsdelivr.net/npm/c2pa@${version}/dist/c2pa.worker.min.js',
1616
});
17+
```
18+
19+
If you installed the package locally, for example from npm, then its simply:
20+
21+
```js
22+
import { createC2pa } from 'c2pa';
23+
```
24+
25+
Additionally, the `wasmSrc` and `workerSrc` objects need to available as static assets that can be fetched at runtime. The best way to do that depends on the build system. For example, using [Vite](https://vite.dev/guide/assets#explicit-url-imports), as shown in the [minimal-ts-vite example](https://github.com/contentauth/c2pa-js/blob/main/examples/minimal-ts-vite/examples/active-manifest/main.ts):
26+
27+
28+
```js
29+
import wasmSrc from 'c2pa/dist/assets/wasm/toolkit_bg.wasm?url';
30+
import workerSrc from 'c2pa/dist/c2pa.worker.js?url';
31+
import { parseISO } from 'date-fns';
32+
33+
(async () => {
34+
let output: string[] = [];
35+
36+
const c2pa = await createC2pa({
37+
wasmSrc,
38+
workerSrc,
39+
});
40+
41+
...
42+
43+
})();
1744
```

0 commit comments

Comments
 (0)