@sealpixel/element 1.0.0-rc.2 → 1.0.0-rc.21

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/LICENSE.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **Licensor:** nine feet UG (haftungsbeschränkt), Germany (https://9feet.io)
6
6
 
7
- **Licensed Work:** Sealpixel, in every version the Licensor publishes: the source code, the npm packages under the `@sealpixel` scope and the unscoped `sealpixel` package, the Rust crates, the WebAssembly binaries, the documentation and the example projects. The Licensed Work is (c) 2026 nine feet UG (haftungsbeschränkt).
7
+ **Licensed Work:** Sealpixel, in every version the Licensor publishes: the source code, the npm packages under the `@sealpixel` scope and the unscoped `sealpixel` package, the Rust crates, the WebAssembly binaries, the documentation and the example projects, except the package `@sealpixel/c2pa-sign` and the crate `sealpixel-c2pa-sign`, which are licensed under the Business Source License 1.1 with their own parameters in `packages/c2pa-sign/LICENSE.md`. The Licensed Work is (c) 2026 nine feet UG (haftungsbeschränkt).
8
8
 
9
9
  **Additional Use Grant:** You may make production use of the Licensed Work if you are a Small User. You are a Small User if you are a natural person acting for yourself, or if the organization you act for had less than EUR 1,000,000 of gross revenue in its most recent completed financial year. Revenue is counted across the whole group: the organization, everything that controls it, everything it controls, and everything under common control with it. Where the work is done for a client, the client's revenue decides.
10
10
 
@@ -16,7 +16,7 @@ This Additional Use Grant does not permit offering the Licensed Work, or a work
16
16
 
17
17
  For information about alternative licensing arrangements for the Licensed Work, please visit: https://sealpixel.dev/pricing
18
18
 
19
- Organizations, and anyone who develops with the Licensed Work for an organization, obtain the commercial license this License refers to as developer seats under the Sealpixel Developer Seat License (`LICENSE-COMMERCIAL.md`).
19
+ Organizations, and anyone who develops with the Licensed Work for an organization, obtain the commercial license this License refers to as developer seats under the Sealpixel Developer Seat License, published at https://sealpixel.dev/license#seats and as `LICENSE-COMMERCIAL.md` in the source repository.
20
20
 
21
21
  ## Notice
22
22
 
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # @sealpixel/element
2
2
 
3
- `import "@sealpixel/element"` and use `<sealpixel-editor>`. Includes every first-party plugin and a worker-backed renderer.
3
+ `import "@sealpixel/element"` and use `<sealpixel-editor>`. Includes the default first-party plugins and a worker-backed renderer. Sticker, watermark and assist are outside the default set: set `plugins` to `allPlugins` to install all of them.
@@ -0,0 +1,43 @@
1
+ import { type Renderer } from '@sealpixel/core';
2
+ /**
3
+ * The bundled worker, with the inline renderer as the fallback when the worker
4
+ * never starts.
5
+ *
6
+ * `new Worker()` throws only for a URL it cannot parse. A worker script that
7
+ * does not load (a 404, a Content Security Policy, an import that fails inside
8
+ * it) reports through an `error` event, and a `WorkerRenderer` alone would
9
+ * wait for its answers forever.
10
+ *
11
+ * Until the worker has answered once, it holds no state, so a failure moves
12
+ * every pending call to the inline renderer in the order the calls were made.
13
+ * After that, the worker holds the loaded image and the inline renderer does
14
+ * not, so a failure rejects the pending calls instead.
15
+ */
16
+ export declare class FallbackRenderer implements Renderer {
17
+ private readonly worker;
18
+ private readonly fallback;
19
+ private current;
20
+ private readonly pending;
21
+ private answered;
22
+ private fellBack;
23
+ /** Set when the fallback could not start either; every call fails with it. */
24
+ private broken;
25
+ constructor(worker: Worker, fallback: () => Renderer);
26
+ init(): Promise<{
27
+ coreVersion: string;
28
+ plugins: Record<string, number>;
29
+ }>;
30
+ load(...args: Parameters<Renderer['load']>): Promise<import("@sealpixel/core").LoadedSource>;
31
+ loadWorkingCopy(...args: Parameters<Renderer['loadWorkingCopy']>): Promise<import("@sealpixel/core").LoadedSource>;
32
+ loadWorkingCopyEncoded(...args: Parameters<Renderer['loadWorkingCopyEncoded']>): Promise<import("@sealpixel/core").LoadedSource>;
33
+ render(...args: Parameters<Renderer['render']>): Promise<import("@sealpixel/wasm").RgbaBuffer>;
34
+ export(...args: Parameters<Renderer['export']>): Promise<import("@sealpixel/core").ExportResult>;
35
+ geometry(...args: Parameters<Renderer['geometry']>): Promise<import("@sealpixel/core").Geometry>;
36
+ unload(): Promise<void>;
37
+ putAsset(...args: Parameters<Renderer['putAsset']>): Promise<void>;
38
+ dispose(): void;
39
+ private call;
40
+ private start;
41
+ private onWorkerError;
42
+ private detach;
43
+ }
@@ -0,0 +1,133 @@
1
+ import { SealpixelError, WorkerRenderer } from '@sealpixel/core';
2
+ /**
3
+ * The bundled worker, with the inline renderer as the fallback when the worker
4
+ * never starts.
5
+ *
6
+ * `new Worker()` throws only for a URL it cannot parse. A worker script that
7
+ * does not load (a 404, a Content Security Policy, an import that fails inside
8
+ * it) reports through an `error` event, and a `WorkerRenderer` alone would
9
+ * wait for its answers forever.
10
+ *
11
+ * Until the worker has answered once, it holds no state, so a failure moves
12
+ * every pending call to the inline renderer in the order the calls were made.
13
+ * After that, the worker holds the loaded image and the inline renderer does
14
+ * not, so a failure rejects the pending calls instead.
15
+ */
16
+ export class FallbackRenderer {
17
+ worker;
18
+ fallback;
19
+ current;
20
+ pending = new Set();
21
+ answered = false;
22
+ fellBack = false;
23
+ /** Set when the fallback could not start either; every call fails with it. */
24
+ broken = null;
25
+ constructor(worker, fallback) {
26
+ this.worker = worker;
27
+ this.fallback = fallback;
28
+ this.current = new WorkerRenderer(worker);
29
+ worker.addEventListener('error', this.onWorkerError);
30
+ worker.addEventListener('messageerror', this.onWorkerError);
31
+ }
32
+ init() {
33
+ return this.call((r) => r.init());
34
+ }
35
+ load(...args) {
36
+ return this.call((r) => r.load(...args));
37
+ }
38
+ loadWorkingCopy(...args) {
39
+ return this.call((r) => r.loadWorkingCopy(...args));
40
+ }
41
+ loadWorkingCopyEncoded(...args) {
42
+ return this.call((r) => r.loadWorkingCopyEncoded(...args));
43
+ }
44
+ render(...args) {
45
+ return this.call((r) => r.render(...args));
46
+ }
47
+ export(...args) {
48
+ return this.call((r) => r.export(...args));
49
+ }
50
+ geometry(...args) {
51
+ return this.call((r) => r.geometry(...args));
52
+ }
53
+ unload() {
54
+ return this.call((r) => r.unload());
55
+ }
56
+ putAsset(...args) {
57
+ return this.call((r) => r.putAsset(...args));
58
+ }
59
+ dispose() {
60
+ this.detach();
61
+ this.current.dispose();
62
+ for (const call of this.pending)
63
+ call.reject(new SealpixelError('ABORTED', 'renderer disposed'));
64
+ this.pending.clear();
65
+ }
66
+ call(run) {
67
+ return new Promise((resolve, reject) => {
68
+ if (this.broken !== null) {
69
+ reject(this.broken);
70
+ return;
71
+ }
72
+ const call = { run, resolve: resolve, reject };
73
+ this.pending.add(call);
74
+ this.start(call);
75
+ });
76
+ }
77
+ start(call) {
78
+ const renderer = this.current;
79
+ call.run(renderer).then((value) => {
80
+ // A late answer from a renderer that has been replaced is not this call's answer.
81
+ if (renderer !== this.current || !this.pending.has(call))
82
+ return;
83
+ if (!this.fellBack)
84
+ this.answered = true;
85
+ this.pending.delete(call);
86
+ call.resolve(value);
87
+ }, (error) => {
88
+ if (renderer !== this.current || !this.pending.has(call))
89
+ return;
90
+ if (!this.fellBack)
91
+ this.answered = true;
92
+ this.pending.delete(call);
93
+ call.reject(error);
94
+ });
95
+ }
96
+ onWorkerError = (event) => {
97
+ const reason = event instanceof ErrorEvent && event.message ? `: ${event.message}` : '';
98
+ const failed = this.current;
99
+ if (this.answered) {
100
+ // The worker has the loaded image. Nothing else has it, so the calls
101
+ // waiting on the worker fail, and the session reports the error.
102
+ const error = new SealpixelError('KERNEL_FAILED', `the render worker failed${reason}`);
103
+ for (const call of this.pending)
104
+ call.reject(error);
105
+ this.pending.clear();
106
+ return;
107
+ }
108
+ // The worker never started: nothing is lost by starting over inline.
109
+ console.warn(`[sealpixel] the render worker did not start${reason}; rendering inline`);
110
+ this.detach();
111
+ this.fellBack = true;
112
+ try {
113
+ this.current = this.fallback();
114
+ }
115
+ catch (error) {
116
+ this.broken = error;
117
+ for (const call of this.pending)
118
+ call.reject(error);
119
+ this.pending.clear();
120
+ return;
121
+ }
122
+ finally {
123
+ failed.dispose();
124
+ }
125
+ for (const call of this.pending)
126
+ this.start(call);
127
+ };
128
+ detach() {
129
+ this.worker.removeEventListener('error', this.onWorkerError);
130
+ this.worker.removeEventListener('messageerror', this.onWorkerError);
131
+ }
132
+ }
133
+ //# sourceMappingURL=fallback-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallback-renderer.js","sourceRoot":"","sources":["../src/fallback-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQhF;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,gBAAgB;IASR;IACA;IATX,OAAO,CAAW;IACT,OAAO,GAAG,IAAI,GAAG,EAAQ,CAAC;IACnC,QAAQ,GAAG,KAAK,CAAC;IACjB,QAAQ,GAAG,KAAK,CAAC;IACzB,8EAA8E;IACtE,MAAM,GAAY,IAAI,CAAC;IAE/B,YACmB,MAAc,EACd,QAAwB;QADxB,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAgB;QAEzC,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACrD,MAAM,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,CAAC,GAAG,IAAkC;QACxC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAC3C,CAAC;IACD,eAAe,CAAC,GAAG,IAA6C;QAC9D,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,IA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C;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC,CAAC;IAEM,MAAM;QACZ,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACtE,CAAC;CACF","sourcesContent":["import { type Renderer, SealpixelError, WorkerRenderer } from '@sealpixel/core';\n\ninterface Call {\n run: (renderer: Renderer) => Promise<unknown>;\n resolve: (value: unknown) => void;\n reject: (error: unknown) => void;\n}\n\n/**\n * The bundled worker, with the inline renderer as the fallback when the worker\n * never starts.\n *\n * `new Worker()` throws only for a URL it cannot parse. A worker script that\n * does not load (a 404, a Content Security Policy, an import that fails inside\n * it) reports through an `error` event, and a `WorkerRenderer` alone would\n * wait for its answers forever.\n *\n * Until the worker has answered once, it holds no state, so a failure moves\n * every pending call to the inline renderer in the order the calls were made.\n * After that, the worker holds the loaded image and the inline renderer does\n * not, so a failure rejects the pending calls instead.\n */\nexport class FallbackRenderer implements Renderer {\n private current: Renderer;\n private readonly pending = new Set<Call>();\n private answered = false;\n private fellBack = false;\n /** Set when the fallback could not start either; every call fails with it. */\n private broken: unknown = null;\n\n constructor(\n private readonly worker: Worker,\n private readonly fallback: () => Renderer,\n ) {\n this.current = new WorkerRenderer(worker);\n worker.addEventListener('error', this.onWorkerError);\n worker.addEventListener('messageerror', this.onWorkerError);\n }\n\n init() {\n return this.call((r) => r.init());\n }\n load(...args: Parameters<Renderer['load']>) {\n return this.call((r) => r.load(...args));\n }\n loadWorkingCopy(...args: Parameters<Renderer['loadWorkingCopy']>) {\n return this.call((r) => r.loadWorkingCopy(...args));\n }\n loadWorkingCopyEncoded(...args: Parameters<Renderer['loadWorkingCopyEncoded']>) {\n return this.call((r) => r.loadWorkingCopyEncoded(...args));\n }\n render(...args: Parameters<Renderer['render']>) {\n return this.call((r) => r.render(...args));\n }\n export(...args: Parameters<Renderer['export']>) {\n return this.call((r) => r.export(...args));\n }\n geometry(...args: Parameters<Renderer['geometry']>) {\n return this.call((r) => r.geometry(...args));\n }\n unload() {\n return this.call((r) => r.unload());\n }\n putAsset(...args: Parameters<Renderer['putAsset']>) {\n return this.call((r) => r.putAsset(...args));\n }\n dispose() {\n this.detach();\n this.current.dispose();\n for (const call of this.pending)\n call.reject(new SealpixelError('ABORTED', 'renderer disposed'));\n this.pending.clear();\n }\n\n private call<T>(run: (renderer: Renderer) => Promise<T>): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n if (this.broken !== null) {\n reject(this.broken);\n return;\n }\n const call: Call = { run, resolve: resolve as (value: unknown) => void, reject };\n this.pending.add(call);\n this.start(call);\n });\n }\n\n private start(call: Call): void {\n const renderer = this.current;\n call.run(renderer).then(\n (value) => {\n // A late answer from a renderer that has been replaced is not this call's answer.\n if (renderer !== this.current || !this.pending.has(call)) return;\n if (!this.fellBack) this.answered = true;\n this.pending.delete(call);\n call.resolve(value);\n },\n (error) => {\n if (renderer !== this.current || !this.pending.has(call)) return;\n if (!this.fellBack) this.answered = true;\n this.pending.delete(call);\n call.reject(error);\n },\n );\n }\n\n private onWorkerError = (event: Event) => {\n const reason = event instanceof ErrorEvent && event.message ? `: ${event.message}` : '';\n const failed = this.current;\n if (this.answered) {\n // The worker has the loaded image. Nothing else has it, so the calls\n // waiting on the worker fail, and the session reports the error.\n const error = new SealpixelError('KERNEL_FAILED', `the render worker failed${reason}`);\n for (const call of this.pending) call.reject(error);\n this.pending.clear();\n return;\n }\n // The worker never started: nothing is lost by starting over inline.\n console.warn(`[sealpixel] the render worker did not start${reason}; rendering inline`);\n this.detach();\n this.fellBack = true;\n try {\n this.current = this.fallback();\n } catch (error) {\n this.broken = error;\n for (const call of this.pending) call.reject(error);\n this.pending.clear();\n return;\n } finally {\n failed.dispose();\n }\n for (const call of this.pending) this.start(call);\n };\n\n private detach(): void {\n this.worker.removeEventListener('error', this.onWorkerError);\n this.worker.removeEventListener('messageerror', this.onWorkerError);\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -10,10 +10,12 @@ import '@sealpixel/ui/define';
10
10
  export * from '@sealpixel/ui';
11
11
  export { allPlugins, defaultPlugins };
12
12
  /**
13
- * Starts the bundled worker when the plugin list is the default one, with or
14
- * without options; options never reach the renderer. A custom
15
- * plugin list needs a custom worker (see `startSealpixelWorker`), so it falls
16
- * back to rendering inline.
13
+ * Starts the bundled worker when the plugin list renders like the default one,
14
+ * with or without options; options never reach the renderer, and neither does
15
+ * a plugin without operations (`assist`), so those are ignored in the
16
+ * comparison. A custom plugin list needs a custom worker (see
17
+ * `startSealpixelWorker`), so it falls back to rendering inline. A worker that
18
+ * does not load (a 404, a Content Security Policy, a failing import) also
19
+ * falls back to rendering inline.
17
20
  */
18
21
  export declare function createDefaultRenderer(plugins?: readonly AnyPlugin[]): Renderer;
19
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -4,31 +4,40 @@
4
4
  * `new Worker(new URL(..., import.meta.url), { type: 'module' })` (Vite,
5
5
  * webpack 5, esbuild with the worker plugin, Parcel) emit the worker chunk.
6
6
  */
7
- import { InlineRenderer, WorkerRenderer } from '@sealpixel/core';
8
- import { allPlugins, defaultPlugins } from '@sealpixel/plugins';
7
+ import { InlineRenderer } from '@sealpixel/core';
8
+ import { allPlugins, defaultPlugins, renderingPlugins } from '@sealpixel/plugins';
9
9
  import { SealpixelEditor } from '@sealpixel/ui';
10
10
  import '@sealpixel/ui/define';
11
+ import { FallbackRenderer } from './fallback-renderer.js';
11
12
  export * from '@sealpixel/ui';
12
13
  export { allPlugins, defaultPlugins };
13
14
  /**
14
- * Starts the bundled worker when the plugin list is the default one, with or
15
- * without options; options never reach the renderer. A custom
16
- * plugin list needs a custom worker (see `startSealpixelWorker`), so it falls
17
- * back to rendering inline.
15
+ * Starts the bundled worker when the plugin list renders like the default one,
16
+ * with or without options; options never reach the renderer, and neither does
17
+ * a plugin without operations (`assist`), so those are ignored in the
18
+ * comparison. A custom plugin list needs a custom worker (see
19
+ * `startSealpixelWorker`), so it falls back to rendering inline. A worker that
20
+ * does not load (a 404, a Content Security Policy, a failing import) also
21
+ * falls back to rendering inline.
18
22
  */
19
23
  export function createDefaultRenderer(plugins = defaultPlugins) {
20
- const sameAsDefault = plugins.length === defaultPlugins.length &&
21
- plugins.every((p, i) => p.id === defaultPlugins[i]?.id && p.version === defaultPlugins[i]?.version);
24
+ const wanted = renderingPlugins(plugins);
25
+ const bundled = renderingPlugins(defaultPlugins);
26
+ const sameAsDefault = wanted.length === bundled.length &&
27
+ wanted.every((p, i) => p.id === bundled[i]?.id && p.version === bundled[i]?.version);
28
+ const inline = () => new InlineRenderer({ plugins, maxClientMegapixels: 16, workingCopyMaxSide: 2048 });
22
29
  if (sameAsDefault && typeof Worker !== 'undefined') {
23
30
  try {
24
31
  const worker = new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });
25
- return new WorkerRenderer(worker);
32
+ // A worker that fails to load reports it later, through an event; the
33
+ // renderer then moves to the inline renderer. See FallbackRenderer.
34
+ return new FallbackRenderer(worker, inline);
26
35
  }
27
36
  catch {
28
37
  // fall through to inline
29
38
  }
30
39
  }
31
- return new InlineRenderer({ plugins, maxClientMegapixels: 16, proxyMaxSide: 2048 });
40
+ return inline();
32
41
  }
33
42
  SealpixelEditor.defaultRendererFactory ??= createDefaultRenderer;
34
43
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAkB,cAAc,EAAiB,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,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AC","sourcesContent":["/**\n * `import '@sealpixel/element'` registers `<sealpixel-editor>` and friends with the\n * first-party plugins and a worker-backed renderer. Bundlers that understand\n * `new Worker(new URL(..., import.meta.url), { type: 'module' })` (Vite,\n * webpack 5, esbuild with the worker plugin, Parcel) emit the worker chunk.\n */\nimport { type AnyPlugin, InlineRenderer, type Renderer } from '@sealpixel/core';\nimport { allPlugins, defaultPlugins, renderingPlugins } from '@sealpixel/plugins';\nimport { SealpixelEditor } from '@sealpixel/ui';\nimport '@sealpixel/ui/define';\nimport { FallbackRenderer } from './fallback-renderer.js';\n\nexport * from '@sealpixel/ui';\nexport { allPlugins, defaultPlugins };\n\n/**\n * Starts the bundled worker when the plugin list renders like the default one,\n * with or without options; options never reach the renderer, and neither does\n * a plugin without operations (`assist`), so those are ignored in the\n * comparison. A custom plugin list needs a custom worker (see\n * `startSealpixelWorker`), so it falls back to rendering inline. A worker that\n * does not load (a 404, a Content Security Policy, a failing import) also\n * falls back to rendering inline.\n */\nexport function createDefaultRenderer(plugins: readonly AnyPlugin[] = defaultPlugins): Renderer {\n const wanted = renderingPlugins(plugins);\n const bundled = renderingPlugins(defaultPlugins);\n const sameAsDefault =\n wanted.length === bundled.length &&\n wanted.every((p, i) => p.id === bundled[i]?.id && p.version === bundled[i]?.version);\n const inline = () =>\n new InlineRenderer({ plugins, maxClientMegapixels: 16, workingCopyMaxSide: 2048 });\n if (sameAsDefault && typeof Worker !== 'undefined') {\n try {\n const worker = new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });\n // A worker that fails to load reports it later, through an event; the\n // renderer then moves to the inline renderer. See FallbackRenderer.\n return new FallbackRenderer(worker, inline);\n } catch {\n // fall through to inline\n }\n }\n return inline();\n}\n\nSealpixelEditor.defaultRendererFactory ??= createDefaultRenderer;\n"]}
package/dist/worker.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=worker.d.ts.map
package/dist/worker.js CHANGED
@@ -1,4 +1,4 @@
1
- /** The default render worker: every first-party plugin, loaded by `@sealpixel/element`. */
1
+ /** The default render worker: the default first-party plugins, loaded by `@sealpixel/element`. */
2
2
  import { startSealpixelWorker } from '@sealpixel/core/worker';
3
3
  import { defaultPlugins } from '@sealpixel/plugins';
4
4
  startSealpixelWorker({ plugins: defaultPlugins });
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,oBAAoB,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,oBAAoB,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC","sourcesContent":["/** The default render worker: the default first-party plugins, loaded by `@sealpixel/element`. */\nimport { startSealpixelWorker } from '@sealpixel/core/worker';\nimport { defaultPlugins } from '@sealpixel/plugins';\n\nstartSealpixelWorker({ plugins: defaultPlugins });\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sealpixel/element",
3
- "version": "1.0.0-rc.2",
4
- "description": "Drop-in <sealpixel-editor> with all first-party plugins and a bundled render worker. Import once, use the tag.",
3
+ "version": "1.0.0-rc.21",
4
+ "description": "Drop-in <sealpixel-editor> with the default first-party plugins and a bundled render worker. Import once, use the tag.",
5
5
  "license": "BUSL-1.1",
6
6
  "repository": {
7
7
  "type": "git",
@@ -28,15 +28,15 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "dependencies": {
31
- "@sealpixel/core": "1.0.0-rc.2",
32
- "@sealpixel/plugins": "1.0.0-rc.2",
33
- "@sealpixel/ui": "1.0.0-rc.2",
34
- "@sealpixel/wasm": "1.0.0-rc.2"
31
+ "@sealpixel/core": "1.0.0-rc.21",
32
+ "@sealpixel/plugins": "1.0.0-rc.21",
33
+ "@sealpixel/ui": "1.0.0-rc.21",
34
+ "@sealpixel/wasm": "1.0.0-rc.21"
35
35
  },
36
36
  "devDependencies": {
37
+ "@sealpixel/config": "0.0.0",
37
38
  "@types/node": "^24.0.0",
38
- "typescript": "^5.9.0",
39
- "@sealpixel/config": "0.0.0"
39
+ "typescript": "^6.0.0"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsc -p tsconfig.build.json",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,SAAS,EAAkB,KAAK,QAAQ,EAAkB,MAAM,iBAAiB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,sBAAsB,CAAC;AAE9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAEtC;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,SAAS,SAAS,EAAmB,GAAG,QAAQ,CAe9F"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":""}