@sealpixel/element 1.0.0-rc.10 → 1.0.0-rc.12

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 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,44 @@
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
+ loadProxy(...args: Parameters<Renderer['loadProxy']>): Promise<import("@sealpixel/core").LoadedSource>;
32
+ loadProxyEncoded(...args: Parameters<Renderer['loadProxyEncoded']>): 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
+ }
44
+ //# sourceMappingURL=fallback-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fallback-renderer.d.ts","sourceRoot":"","sources":["../src/fallback-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAkC,MAAM,iBAAiB,CAAC;AAQhF;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAiB,YAAW,QAAQ;IAS7C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAT3B,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,8EAA8E;IAC9E,OAAO,CAAC,MAAM,CAAiB;gBAGZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,QAAQ;IAO3C,IAAI;;;;IAGJ,IAAI,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAG1C,SAAS,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAGpD,gBAAgB,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAGlE,MAAM,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAG9C,MAAM,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAG9C,QAAQ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAGlD,MAAM;IAGN,QAAQ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAGlD,OAAO;IAQP,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,KAAK;IAmBb,OAAO,CAAC,aAAa,CA0BnB;IAEF,OAAO,CAAC,MAAM;CAIf"}
@@ -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
+ loadProxy(...args) {
39
+ return this.call((r) => r.loadProxy(...args));
40
+ }
41
+ loadProxyEncoded(...args) {
42
+ return this.call((r) => r.loadProxyEncoded(...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,CAA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,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACpD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;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"}
package/dist/index.d.ts CHANGED
@@ -14,7 +14,9 @@ export { allPlugins, defaultPlugins };
14
14
  * with or without options; options never reach the renderer, and neither does
15
15
  * a plugin without operations (`assist`), so those are ignored in the
16
16
  * comparison. A custom plugin list needs a custom worker (see
17
- * `startSealpixelWorker`), so it falls back to rendering inline.
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.
18
20
  */
19
21
  export declare function createDefaultRenderer(plugins?: readonly AnyPlugin[]): Renderer;
20
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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,EAAoB,MAAM,oBAAoB,CAAC;AAElF,OAAO,sBAAsB,CAAC;AAE9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAEtC;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,SAAS,SAAS,EAAmB,GAAG,QAAQ,CAe9F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,SAAS,EAAkB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAoB,MAAM,oBAAoB,CAAC;AAElF,OAAO,sBAAsB,CAAC;AAG9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAEtC;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,SAAS,SAAS,EAAmB,GAAG,QAAQ,CAkB9F"}
package/dist/index.js CHANGED
@@ -4,10 +4,11 @@
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';
7
+ import { InlineRenderer } from '@sealpixel/core';
8
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
  /**
@@ -15,23 +16,28 @@ export { allPlugins, defaultPlugins };
15
16
  * with or without options; options never reach the renderer, and neither does
16
17
  * a plugin without operations (`assist`), so those are ignored in the
17
18
  * comparison. A custom plugin list needs a custom worker (see
18
- * `startSealpixelWorker`), so it falls back to rendering inline.
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.
19
22
  */
20
23
  export function createDefaultRenderer(plugins = defaultPlugins) {
21
24
  const wanted = renderingPlugins(plugins);
22
25
  const bundled = renderingPlugins(defaultPlugins);
23
26
  const sameAsDefault = wanted.length === bundled.length &&
24
27
  wanted.every((p, i) => p.id === bundled[i]?.id && p.version === bundled[i]?.version);
28
+ const inline = () => new InlineRenderer({ plugins, maxClientMegapixels: 16, proxyMaxSide: 2048 });
25
29
  if (sameAsDefault && typeof Worker !== 'undefined') {
26
30
  try {
27
31
  const worker = new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });
28
- 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);
29
35
  }
30
36
  catch {
31
37
  // fall through to inline
32
38
  }
33
39
  }
34
- return new InlineRenderer({ plugins, maxClientMegapixels: 16, proxyMaxSide: 2048 });
40
+ return inline();
35
41
  }
36
42
  SealpixelEditor.defaultRendererFactory ??= createDefaultRenderer;
37
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,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,sBAAsB,CAAC;AAE9B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;AAEtC;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAAgC,cAAc;IAClF,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;IACjD,MAAM,aAAa,GACjB,MAAM,CAAC,MAA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;IAClF,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;IACjD,MAAM,aAAa,GACjB,MAAM,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;QAChC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IAClG,IAAI,aAAa,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QACnD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;YACvF,sEAAsE;YACtE,oEAAoE;YACpE,OAAO,IAAI,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9C,CAAC;QAAC,MAAM,CAAC;YACP,yBAAyB;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,MAAM,EAAE,CAAC;AAClB,CAAC;AAED,eAAe,CAAC,sBAAsB,KAAK,qBAAqB,CAAC"}
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"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sealpixel/element",
3
- "version": "1.0.0-rc.10",
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.12",
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,10 +28,10 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "dependencies": {
31
- "@sealpixel/core": "1.0.0-rc.10",
32
- "@sealpixel/plugins": "1.0.0-rc.10",
33
- "@sealpixel/ui": "1.0.0-rc.10",
34
- "@sealpixel/wasm": "1.0.0-rc.10"
31
+ "@sealpixel/core": "1.0.0-rc.12",
32
+ "@sealpixel/plugins": "1.0.0-rc.12",
33
+ "@sealpixel/ui": "1.0.0-rc.12",
34
+ "@sealpixel/wasm": "1.0.0-rc.12"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@sealpixel/config": "0.0.0",