Skip to content

Commit 1b4da94

Browse files
authored
Merge pull request #180 from contentauth/no-sandbox
Change code sandboxes
2 parents caa410d + ee279bf commit 1b4da94

File tree

14 files changed

+141
-34
lines changed

14 files changed

+141
-34
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
.docusaurus
99
.cache-loader
1010
/docs/js-sdk/api
11+
/docs/js-sdk/examples/quickstart/*.ts
12+
/docs/js-sdk/examples/view-manifest/*.ts
13+
/docs/js-sdk/examples/view-manifest/*.html
1114
/docs/c2patool/*.md
1215
/docs/c2patool/docs/*.md
1316
/docs/c2pa-node/*.md

docs/js-sdk/examples/.gitkeep

Whitespace-only changes.

docs/js-sdk/examples/quickstart/.gitkeep

Whitespace-only changes.

docs/js-sdk/examples/view-manifest/.gitkeep

Whitespace-only changes.

docs/js-sdk/getting-started/overview.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ The JavaScript library uses several modern browser technologies, including:
2525

2626
The JavaScript library is a monorepo containing the following packages intended for client use:
2727

28-
- [**c2pa**](https://opensource.contentauthenticity.org/docs/js-sdk/api/c2pa) is the main package used for loading and verifying manifests. This package runs all of the processing
29-
logic on the client using a [WebAssembly](https://webassembly.org/) module and exposes a [TypeScript](https://www.typescriptlang.org/)-compatible API for easy integration.
28+
- [**c2pa**](https://opensource.contentauthenticity.org/docs/js-sdk/api/c2pa) is the main package used for loading and verifying manifests. This package runs all of the processing logic on the client using a [WebAssembly](https://webassembly.org/) module and exposes a [TypeScript](https://www.typescriptlang.org/)-compatible API for easy integration.
3029
- **c2pa-wc** provides UI components designed with input from the C2PA UX working group. It enables users to get up and running with standard UI patterns quickly and easily in any front-end environment.
3130
- **@contentauth/react** provides a hooks interface for React components to quickly get manifest and thumbnail data in your React app.
3231

@@ -59,7 +58,7 @@ Because of these requirements, **the library is not supported on any version of
5958
![CAI JavaScript library browser support](../../../static/img/caniuse.png)
6059

6160
:::info
62-
This chart is accurate as of June, 2024. For the most up-to-date browser support information, see [caniuse.com](https://caniuse.com/wasm,webworkers,cryptography,typedarrays,fetch).
61+
This chart is accurate as of December, 2024. For the most up-to-date browser support information, see [caniuse.com](https://caniuse.com/wasm,webworkers,cryptography,typedarrays,fetch).
6362
:::
6463

6564
## Debugging
@@ -72,7 +71,7 @@ To view debug messages in the console, use your browser's inspector, go to the C
7271
localStorage.debug = 'c2pa:*';
7372
```
7473

75-
The debuging information includes millisecond timing differences so you can get an idea of how long different events take.
74+
The debugging information includes millisecond timing differences so you can get an idea of how long different events take.
7675

7776
:::note
7877
Debug calls and statements are stripped out of minified production builds to reduce file size.

docs/js-sdk/getting-started/quick-start.mdx

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ title: Quick start
55

66
import Tabs from '@theme/Tabs';
77
import TabItem from '@theme/TabItem';
8-
import Sandbox from '../../../src/components/Sandbox';
98

109
## Prerequisites
1110

@@ -37,19 +36,17 @@ The quickest way to get up and running is to use a CDN such as [jsDelivr](https:
3736
Static assets include the following, as seen in the config passed to [`createC2pa`](../../js-sdk/api/c2pa.createc2pa):
3837

3938
```js
39+
const version = '0.24.2';
4040
{
4141
wasmSrc: `https://cdn.jsdelivr.net/npm/c2pa@${version}/dist/assets/wasm/toolkit_bg.wasm`,
4242
workerSrc: `https://cdn.jsdelivr.net/npm/c2pa@${version}/dist/c2pa.worker.min.js`,
4343
}
4444
```
4545

4646
:::caution
47-
The version numbers provided in the CDN URLs _must_ match in all of the places you reference the
48-
library. To make it easy, use a variable that provides the version as shown in the example.
47+
The version numbers provided in the CDN URLs _must_ be the same in all of the places you reference the library. To make it easy, use a variable that provides the version as shown in the example.
4948
:::
5049

51-
<Sandbox file="/examples/cdn/main.ts" displayType="preview" />
52-
5350
### Using a package manager
5451

5552
You can also bring in the library with a package manager, such as `npm`, `pnpm`, or `yarn`. This way, all of the client side code is hosted with your app and there are no external dependencies. For example, using `npm`:
@@ -71,24 +68,30 @@ Be sure to configure your server to send proper `Content-Type` headers for these
7168

7269
Examples for common build systems are shown below. They are also available in the [c2pa-js-examples repository](https://github.com/contentauth/c2pa-js-examples).
7370

74-
export const ExampleLink = ({ example }) => {
75-
const linkText = `examples/${example}`;
76-
const link = `https://github.com/contentauth/c2pa-js/tree/main/${linkText}`;
77-
return (
78-
<div className="example-link">
79-
An example project is available here: <a href={link}>{linkText}</a>
80-
</div>
81-
);
82-
};
71+
import CodeBlock from '@theme/CodeBlock';
72+
import ViteExample from '!!raw-loader!../examples/quickstart/vite-main.ts';
73+
import RollupExample from '!!raw-loader!../examples/quickstart/rollup-main.ts';
74+
import WebPackExample from '!!raw-loader!../examples/quickstart/webpack-main.ts';
8375

8476
<Tabs lazy>
85-
<TabItem value="vite" label="Vite" default>
86-
<Sandbox file="/examples/quick-start/main.ts" />
87-
</TabItem>
88-
<TabItem value="rollup" label="Rollup">
89-
<Sandbox example="minimal-ts-rollup" file="/src/main.ts" browserPath="/" />
90-
</TabItem>
91-
<TabItem value="webpack" label="Webpack">
92-
<Sandbox example="minimal-ts-webpack" file="/src/main.ts" browserPath="/" />
93-
</TabItem>
77+
<TabItem value="vite" label="Vite" default>
78+
79+
This example is from [c2pa-js-examples/minimal-ts-vite/](https://github.com/contentauth/c2pa-js-examples/blob/main/minimal-ts-vite/). To view and execute this example in a live [code sandbox](https://codesandbox.io/docs/learn/legacy-sandboxes/overview), see [Code Sandbox: Vite example](../guides/sandbox-qs-vite.mdx).
80+
81+
<CodeBlock language="ts">{ViteExample}</CodeBlock>
82+
</TabItem>
83+
84+
<TabItem value="rollup" label="Rollup">
85+
86+
This example is from [c2pa-js-examples/minimal-ts-rollup/](https://github.com/contentauth/c2pa-js-examples/blob/main/minimal-ts-rollup/). To view and execute this example in a live [code sandbox](https://codesandbox.io/docs/learn/legacy-sandboxes/overview), see [Code Sandbox: Rollup example](../guides/sandbox-qs-rollup.mdx).
87+
88+
<CodeBlock language="ts">{RollupExample}</CodeBlock>
89+
</TabItem>
90+
91+
<TabItem value="webpack" label="Webpack">
92+
93+
This example is from [c2pa-js-examples/minimal-ts-webpack/](https://github.com/contentauth/c2pa-js-examples/blob/main/minimal-ts-webpack/). To view and execute this example in a live [code sandbox](https://codesandbox.io/docs/learn/legacy-sandboxes/overview), see [Code Sandbox: Webpack example](../guides/sandbox-qs-webpack.mdx).
94+
95+
<CodeBlock language="ts">{WebPackExample}</CodeBlock>
96+
</TabItem>
9497
</Tabs>

docs/js-sdk/guides/hosting.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ examples of configuring popular build systems, see the [Quick start guide](../ge
4242

4343
To host the library yourself, expose the static asset files with the following response headers to avoid errors with some browsers:
4444

45-
- `c2pa/dist/assets/wasm/toolkit_bg.wasm`: Serve with `Content-Type: application/wasm` reponse header.
45+
- `c2pa/dist/assets/wasm/toolkit_bg.wasm`: Serve with `Content-Type: application/wasm` response header.
4646
- `c2pa/dist/c2pa.worker.min.js`: Serve with `Content-Type: text/javascript` response header.
4747

4848
Then pass these URLs to the `createC2pa` function; for example:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: sandbox-rollup
3+
title: 'Code Sandbox: Rollup example'
4+
hide_table_of_contents: true
5+
---
6+
7+
import Sandbox from '../../../src/components/Sandbox';
8+
9+
The source code for this example is in the [c2pa-js-examples repo](https://github.com/contentauth/c2pa-js-examples/tree/main/minimal-ts-rollup).
10+
11+
<Sandbox file="../examples/quickstart/rollup-main.ts" browserPath="/" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: sandbox-vite
3+
title: 'Code Sandbox: Vite example'
4+
hide_table_of_contents: true
5+
---
6+
7+
import Sandbox from '../../../src/components/Sandbox';
8+
9+
The source code for this example is in the [c2pa-js-examples repo](https://github.com/contentauth/c2pa-js-examples/blob/main/minimal-ts-vite/).
10+
11+
<Sandbox file="../examples/quickstart/vite-main.ts" browserPath="/" />
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: sandbox-webpack
3+
title: 'Code Sandbox: Webpack example'
4+
hide_table_of_contents: true
5+
---
6+
7+
import Sandbox from '../../../src/components/Sandbox';
8+
9+
The source code for this example is in the [c2pa-js-examples repo](https://github.com/contentauth/c2pa-js-examples/tree/main/minimal-ts-webpack).
10+
11+
<Sandbox file="../examples/quickstart/webpack-main.ts" browserPath="/" />

0 commit comments

Comments
 (0)