@sealpixel/astro 1.0.0-rc.11 → 1.0.0-rc.13

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/astro
2
2
 
3
- `astro add @sealpixel/astro`, then `<SealpixelEditor src="/photo.jpg" />` from `@sealpixel/astro/SealpixelEditor.astro`, or use the React, Vue or Svelte bindings inside an island. `sealpixel({ renderRoute: true })` injects `/api/sealpixel/render` (needs an SSR adapter).
3
+ `astro add @sealpixel/astro`, then `<SealpixelEditor src="/photo.jpg" />` from `@sealpixel/astro/SealpixelEditor.astro`, or use the React, Vue or Svelte bindings inside an island.
package/dist/index.d.ts CHANGED
@@ -1,19 +1,8 @@
1
1
  import type { AstroIntegration } from 'astro';
2
- export interface SealpixelAstroOptions {
3
- /**
4
- * Inject `POST /api/sealpixel/render` backed by `@sealpixel/server` with the
5
- * first-party plugins and inline sources. Requires an SSR adapter.
6
- */
7
- renderRoute?: boolean | {
8
- path?: string;
9
- cors?: string[] | '*';
10
- maxMegapixels?: number;
11
- };
12
- }
13
2
  /**
14
3
  * `astro add @sealpixel/astro`. Keeps the Sealpixel packages out of Vite's
15
4
  * dependency pre-bundling so `new URL(..., import.meta.url)` for the wasm and
16
- * the worker keep working, and optionally injects the render endpoint.
5
+ * the worker keep working.
17
6
  */
18
- export default function sealpixel(options?: SealpixelAstroOptions): AstroIntegration;
7
+ export default function sealpixel(): AstroIntegration;
19
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1F;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,OAAO,GAAE,qBAA0B,GAAG,gBAAgB,CAiCvF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,IAAI,gBAAgB,CAyBpD"}
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * `astro add @sealpixel/astro`. Keeps the Sealpixel packages out of Vite's
3
3
  * dependency pre-bundling so `new URL(..., import.meta.url)` for the wasm and
4
- * the worker keep working, and optionally injects the render endpoint.
4
+ * the worker keep working.
5
5
  */
6
- export default function sealpixel(options = {}) {
6
+ export default function sealpixel() {
7
7
  return {
8
8
  name: '@sealpixel/astro',
9
9
  hooks: {
10
- 'astro:config:setup': ({ updateConfig, injectRoute }) => {
10
+ 'astro:config:setup': ({ updateConfig }) => {
11
11
  updateConfig({
12
12
  vite: {
13
13
  optimizeDeps: {
@@ -25,14 +25,6 @@ export default function sealpixel(options = {}) {
25
25
  worker: { format: 'es' },
26
26
  },
27
27
  });
28
- if (options.renderRoute) {
29
- const route = typeof options.renderRoute === 'object' ? options.renderRoute : {};
30
- injectRoute({
31
- pattern: route.path ?? '/api/sealpixel/render',
32
- entrypoint: '@sealpixel/astro/render-route',
33
- prerender: false,
34
- });
35
- }
36
28
  },
37
29
  },
38
30
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,UAAiC,EAAE;IACnE,OAAO;QACL,IAAI,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qBACzB;iBACF,CAAC,CAAC;YACL,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sealpixel/astro",
3
- "version": "1.0.0-rc.11",
4
- "description": "Astro integration for the Sealpixel image editor: Vite config for the wasm and worker, a <SealpixelEditor /> component, and an optional /api/sealpixel/render endpoint.",
3
+ "version": "1.0.0-rc.13",
4
+ "description": "Astro integration for the Sealpixel image editor: Vite config for the wasm and worker, and a <SealpixelEditor /> component.",
5
5
  "license": "BUSL-1.1",
6
6
  "repository": {
7
7
  "type": "git",
@@ -23,19 +23,14 @@
23
23
  "default": "./dist/index.js"
24
24
  },
25
25
  "./SealpixelEditor.astro": "./src/components/SealpixelEditor.astro",
26
- "./render-route": {
27
- "types": "./dist/render-route.d.ts",
28
- "default": "./dist/render-route.js"
29
- },
30
26
  "./package.json": "./package.json"
31
27
  },
32
28
  "dependencies": {
33
- "@sealpixel/core": "1.0.0-rc.11",
34
- "@sealpixel/element": "1.0.0-rc.11",
35
- "@sealpixel/plugins": "1.0.0-rc.11",
36
- "@sealpixel/server": "1.0.0-rc.11",
37
- "@sealpixel/ui": "1.0.0-rc.11",
38
- "@sealpixel/wasm": "1.0.0-rc.11"
29
+ "@sealpixel/core": "1.0.0-rc.13",
30
+ "@sealpixel/element": "1.0.0-rc.13",
31
+ "@sealpixel/plugins": "1.0.0-rc.13",
32
+ "@sealpixel/ui": "1.0.0-rc.13",
33
+ "@sealpixel/wasm": "1.0.0-rc.13"
39
34
  },
40
35
  "peerDependencies": {
41
36
  "astro": ">=5.0.0"
@@ -44,10 +39,13 @@
44
39
  "@sealpixel/config": "0.0.0",
45
40
  "@types/node": "^24.0.0",
46
41
  "astro": "^7.0.0",
47
- "typescript": "^6.0.0"
42
+ "happy-dom": "^20.0.0",
43
+ "typescript": "^6.0.0",
44
+ "vitest": "^5.0.0"
48
45
  },
49
46
  "scripts": {
50
47
  "build": "tsc -p tsconfig.build.json",
51
- "typecheck": "tsc -p tsconfig.json --noEmit"
48
+ "typecheck": "tsc -p tsconfig.json --noEmit",
49
+ "test": "vitest run"
52
50
  }
53
51
  }
@@ -1,14 +1,13 @@
1
1
  ---
2
2
  /**
3
3
  * Client-only editor. Props that are plain data (`src` url, `theme`, `locale`,
4
- * `serverEndpoint`, `editLog`) travel as attributes; complex options belong in
5
- * an island using @sealpixel/react, @sealpixel/vue or @sealpixel/svelte.
4
+ * `editLog`) travel as attributes; complex options belong in an island using
5
+ * @sealpixel/react, @sealpixel/vue or @sealpixel/svelte.
6
6
  */
7
7
  interface Props {
8
8
  src?: string;
9
9
  theme?: 'dark' | 'light' | 'auto';
10
10
  locale?: string;
11
- serverEndpoint?: string;
12
11
  editLog?: unknown;
13
12
  /** `{ pluginId: partialOptions }`, serialised into the `plugin-options` attribute. */
14
13
  pluginOptions?: Record<string, unknown>;
@@ -23,7 +22,6 @@ const {
23
22
  src,
24
23
  theme = 'dark',
25
24
  locale = 'en',
26
- serverEndpoint,
27
25
  editLog,
28
26
  pluginOptions,
29
27
  showExport,
@@ -43,7 +41,6 @@ const id = `sealpixel-${Math.random().toString(36).slice(2, 10)}`;
43
41
  style={style}
44
42
  data-src={src}
45
43
  data-locale={locale}
46
- data-server-endpoint={serverEndpoint}
47
44
  data-edit-log={editLog === undefined ? undefined : JSON.stringify(editLog)}
48
45
  plugin-options={pluginOptions === undefined ? undefined : JSON.stringify(pluginOptions)}
49
46
  show-export={showExport}
@@ -54,12 +51,7 @@ const id = `sealpixel-${Math.random().toString(36).slice(2, 10)}`;
54
51
 
55
52
  <script>
56
53
  import '@sealpixel/element';
57
- for (const el of document.querySelectorAll<HTMLElement & { src: unknown; locale: string; serverEndpoint: string | null; defaultEditLog: unknown }>('sealpixel-editor[data-src], sealpixel-editor[data-locale]')) {
58
- if (el.dataset.hydrated) continue;
59
- el.dataset.hydrated = '1';
60
- el.locale = el.dataset.locale ?? 'en';
61
- if (el.dataset.serverEndpoint) el.serverEndpoint = el.dataset.serverEndpoint;
62
- if (el.dataset.editLog) el.defaultEditLog = JSON.parse(el.dataset.editLog);
63
- if (el.dataset.src) el.src = el.dataset.src;
64
- }
54
+ import { startHydration } from './hydrate';
55
+
56
+ startHydration();
65
57
  </script>
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The client script of `SealpixelEditor.astro`. The component renders plain
3
+ * data as `data-*` attributes; this script copies it into the properties that
4
+ * the element reads.
5
+ */
6
+
7
+ type EditorElement = HTMLElement & {
8
+ src: unknown;
9
+ locale: string;
10
+ defaultEditLog: unknown;
11
+ };
12
+
13
+ function hydrateEditors(): void {
14
+ for (const el of document.querySelectorAll<EditorElement>(
15
+ 'sealpixel-editor[data-src], sealpixel-editor[data-locale]',
16
+ )) {
17
+ // A second pass must not reset an editor, for example one that the router kept.
18
+ if (el.hasAttribute('data-hydrated')) continue;
19
+ el.setAttribute('data-hydrated', '1');
20
+ el.locale = el.getAttribute('data-locale') ?? 'en';
21
+ const editLog = el.getAttribute('data-edit-log');
22
+ if (editLog) el.defaultEditLog = JSON.parse(editLog);
23
+ const src = el.getAttribute('data-src');
24
+ if (src) el.src = src;
25
+ }
26
+ }
27
+
28
+ let started = false;
29
+
30
+ /**
31
+ * Hydrates the editors on the page now and after every client-side navigation.
32
+ * A module script runs once per full page load, but the ClientRouter swaps
33
+ * pages without one and fires `astro:page-load` instead.
34
+ */
35
+ export function startHydration(): void {
36
+ hydrateEditors();
37
+ if (started) return;
38
+ started = true;
39
+ document.addEventListener('astro:page-load', hydrateEditors);
40
+ }
@@ -1,11 +0,0 @@
1
- export declare const prerender = false;
2
- export declare function POST({ request }: {
3
- request: Request;
4
- }): Promise<Response>;
5
- export declare function GET({ request }: {
6
- request: Request;
7
- }): Promise<Response>;
8
- export declare function OPTIONS({ request }: {
9
- request: Request;
10
- }): Promise<Response>;
11
- //# sourceMappingURL=render-route.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-route.d.ts","sourceRoot":"","sources":["../src/render-route.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,SAAS,QAAQ,CAAC;AAE/B,wBAAgB,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEzE;AAED,wBAAgB,GAAG,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAExE;AAED,wBAAgB,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE5E"}
@@ -1,24 +0,0 @@
1
- /**
2
- * Astro API route running `@sealpixel/server` in the SSR runtime (Node, Deno,
3
- * Bun, Cloudflare via the fetch handler). Inline sources only; hosts wanting
4
- * S3 sources write their own route with `createSealpixelHandler`.
5
- */
6
- import { defaultPlugins } from '@sealpixel/plugins';
7
- import { createSealpixelHandler, inlineSource } from '@sealpixel/server';
8
- const handler = createSealpixelHandler({
9
- plugins: defaultPlugins,
10
- sources: [inlineSource()],
11
- cors: '*',
12
- limits: { maxMegapixels: Number(process.env['SEALPIXEL_MAX_MEGAPIXELS'] ?? 40) },
13
- });
14
- export const prerender = false;
15
- export function POST({ request }) {
16
- return handler(request);
17
- }
18
- export function GET({ request }) {
19
- return handler(request);
20
- }
21
- export function OPTIONS({ request }) {
22
- return handler(request);
23
- }
24
- //# sourceMappingURL=render-route.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"render-route.js","sourceRoot":"","sources":["../src/render-route.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEzE,MAAM,OAAO,GAAG,sBAAsB,CAAC;IACrC,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,CAAC,YAAY,EAAE,CAAC;IACzB,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,IAAI,EAAE,CAAC,EAAE;CACjF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC;AAE/B,MAAM,UAAU,IAAI,CAAC,EAAE,OAAO,EAAwB;IACpD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,EAAE,OAAO,EAAwB;IACnD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,EAAE,OAAO,EAAwB;IACvD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC"}