@atom.io/spa 0.0.2 → 0.0.3

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.
Files changed (87) hide show
  1. package/README.md +63 -10
  2. package/README.mdx +26 -5
  3. package/dist/astro-application.d.ts +1 -1
  4. package/dist/astro-application.js +2 -2
  5. package/dist/astro-application.js.map +1 -1
  6. package/dist/astro-client.d.ts +1 -1
  7. package/dist/astro-client.js +2 -2
  8. package/dist/{astro-shared-DyzbUi6c.d.ts → astro-shared-BkWvVZWZ.d.ts} +2 -2
  9. package/dist/{astro-shared-DyzbUi6c.d.ts.map → astro-shared-BkWvVZWZ.d.ts.map} +1 -1
  10. package/dist/astro.d.ts +1 -1
  11. package/dist/capabilities-BkQ2i0vV.js +63 -0
  12. package/dist/capabilities-BkQ2i0vV.js.map +1 -0
  13. package/dist/{capabilities-yC9TsHDI.d.ts → capabilities-CFP-HIuY.d.ts} +54 -1
  14. package/dist/capabilities-CFP-HIuY.d.ts.map +1 -0
  15. package/dist/client.min.js +1 -1
  16. package/dist/{capabilities-BuZUQpiD.js → core-DCmqLZQP.js} +16 -59
  17. package/dist/core-DCmqLZQP.js.map +1 -0
  18. package/dist/development/astro-application.js +2 -2
  19. package/dist/development/astro-application.js.map +1 -1
  20. package/dist/development/astro-client.js +2 -2
  21. package/dist/development/capabilities-BkQ2i0vV.js +63 -0
  22. package/dist/development/capabilities-BkQ2i0vV.js.map +1 -0
  23. package/dist/development/{capabilities-DhOJmeoJ.js → core-p9vciX9C.js} +16 -59
  24. package/dist/development/core-p9vciX9C.js.map +1 -0
  25. package/dist/development/{dom-BKc6V_Kz.js → dom-Ci1XvbVJ.js} +16 -7
  26. package/dist/development/dom-Ci1XvbVJ.js.map +1 -0
  27. package/dist/development/index.js +3 -3
  28. package/dist/development/konva.js +25 -3
  29. package/dist/development/konva.js.map +1 -1
  30. package/dist/development/motion.js +392 -8
  31. package/dist/development/motion.js.map +1 -1
  32. package/dist/development/renderer.js +23 -10
  33. package/dist/development/renderer.js.map +1 -1
  34. package/dist/development/server.js +2 -1
  35. package/dist/development/server.js.map +1 -1
  36. package/dist/development/{src-Dh-d6w4y.js → src-DG0xjuS5.js} +2 -2
  37. package/dist/development/{src-Dh-d6w4y.js.map → src-DG0xjuS5.js.map} +1 -1
  38. package/dist/development/three.js +24 -10
  39. package/dist/development/three.js.map +1 -1
  40. package/dist/{dom-B2rm8o2L.js → dom-dHQM0O7Q.js} +16 -7
  41. package/dist/dom-dHQM0O7Q.js.map +1 -0
  42. package/dist/{index-BdwxmSKg.d.ts → index-CJJXcKaw.d.ts} +3 -3
  43. package/dist/{index-BdwxmSKg.d.ts.map → index-CJJXcKaw.d.ts.map} +1 -1
  44. package/dist/index.d.ts +3 -3
  45. package/dist/index.js +3 -3
  46. package/dist/{jsx-runtime-CZU7F8Qz.d.ts → jsx-runtime-CREZYKDC.d.ts} +2 -2
  47. package/dist/{jsx-runtime-CZU7F8Qz.d.ts.map → jsx-runtime-CREZYKDC.d.ts.map} +1 -1
  48. package/dist/jsx-runtime.d.ts +1 -1
  49. package/dist/konva.d.ts +3 -3
  50. package/dist/konva.d.ts.map +1 -1
  51. package/dist/konva.js +25 -3
  52. package/dist/konva.js.map +1 -1
  53. package/dist/motion.d.ts +2 -1
  54. package/dist/motion.d.ts.map +1 -1
  55. package/dist/motion.js +392 -8
  56. package/dist/motion.js.map +1 -1
  57. package/dist/renderer.d.ts +3 -3
  58. package/dist/renderer.d.ts.map +1 -1
  59. package/dist/renderer.js +23 -10
  60. package/dist/renderer.js.map +1 -1
  61. package/dist/server.d.ts +1 -1
  62. package/dist/server.js +2 -1
  63. package/dist/server.js.map +1 -1
  64. package/dist/size.json +12 -12
  65. package/dist/{src-BZxX4xbU.js → src-DCQa6qxs.js} +2 -2
  66. package/dist/{src-BZxX4xbU.js.map → src-DCQa6qxs.js.map} +1 -1
  67. package/dist/three.d.ts +3 -3
  68. package/dist/three.d.ts.map +1 -1
  69. package/dist/three.js +24 -10
  70. package/dist/three.js.map +1 -1
  71. package/package.json +8 -6
  72. package/src/astro-application.ts +2 -2
  73. package/src/capabilities.ts +21 -2
  74. package/src/core.ts +27 -2
  75. package/src/dom.ts +35 -4
  76. package/src/konva.ts +41 -14
  77. package/src/motion-tween.ts +106 -0
  78. package/src/motion.ts +122 -9
  79. package/src/presence.ts +324 -0
  80. package/src/renderer.ts +51 -14
  81. package/src/three-events.ts +13 -1
  82. package/src/three.ts +38 -15
  83. package/dist/capabilities-BuZUQpiD.js.map +0 -1
  84. package/dist/capabilities-yC9TsHDI.d.ts.map +0 -1
  85. package/dist/development/capabilities-DhOJmeoJ.js.map +0 -1
  86. package/dist/development/dom-BKc6V_Kz.js.map +0 -1
  87. package/dist/dom-B2rm8o2L.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-DCmqLZQP.js","names":[],"sources":["../src/core.ts"],"sourcesContent":["import type {\n\tReadableFamilyToken,\n\tReadableToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n\tSetter,\n\tTimelineFamilyToken,\n\tTimelineManageable,\n\tTimelineToken,\n\tTransactionToken,\n\tViewOf,\n\tWritableFamilyToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/foundations/canonical\"\nimport type { RootStore } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tclearTimelineInStore,\n\tfindInStore,\n\tfindTimelineInStore,\n\tgetFromStore,\n\tgetTimelineTransactionAtHead,\n\tIMPLICIT,\n\tinspectTimelineInStore,\n\tsetIntoStore,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\ttimeTravel,\n\ttimeTravelTransactionGroupInStore,\n} from \"atom.io/internal\"\n\nimport type { Capability } from \"./capabilities.ts\"\nimport type {\n\tExitParticipant,\n\tPresenceCoordinator,\n\tPresenceTarget,\n} from \"./presence.ts\"\n\nexport type Cleanup = () => void\n// A callable interface permits the recursive Child union. A type alias does not.\n/* oxlint-disable typescript/prefer-function-type -- A callable interface is required for recursive Child. */\nexport interface Accessor<T> {\n\t(): T\n}\n/* oxlint-enable typescript/prefer-function-type */\nexport type Component<P = any> = (props: P) => Child\nexport interface VNode {\n\ttype: string | Component | null\n\tprops: Record<string, any>\n}\nexport type Child =\n\t| VNode\n\t| string\n\t| number\n\t| bigint\n\t| boolean\n\t| null\n\t| undefined\n\t| readonly Child[]\n\t| Accessor<Child>\nexport interface RootOptions {\n\tcapabilities?: readonly Capability[]\n\tstore?: RootStore\n\tidPrefix?: string\n\tonError?: (error: unknown) => void\n}\nexport interface Scope {\n\t_exiting?: boolean\n\t_exits?: Set<ExitParticipant>\n\t_targets?: Set<PresenceTarget>\n\t_root: Root\n\t_parent?: Scope | undefined\n\t_cleanups: Set<Cleanup | Scope>\n\t_updates: Cleanup[]\n\t_dead: boolean\n}\nexport interface Root extends Scope {\n\t_presence?: PresenceCoordinator\n\t_capabilities: Map<string, Capability>\n\t_store: RootStore\n\t_prefix: string\n\t_id: number\n\t_queue: Set<Cleanup>\n\t_mounts: Cleanup[] | undefined\n\tflush: Cleanup\n\terror: (error: unknown) => void\n}\n\nexport let owner: Scope | undefined\ntype Subscribe = (notify: Cleanup) => Cleanup\nlet tracking: ((subscribe: Subscribe) => void) | undefined\nlet serial = 0\n\nexport function within<T>(scope: Scope, run: () => T): T {\n\tconst previous = owner\n\towner = scope\n\ttry {\n\t\treturn run()\n\t} finally {\n\t\towner = previous\n\t}\n}\nexport function untrack<T>(run: () => T): T {\n\tconst previous = tracking\n\ttracking = undefined\n\ttry {\n\t\treturn run()\n\t} finally {\n\t\ttracking = previous\n\t}\n}\nexport function createScope(parent?: Scope): Scope {\n\tconst child: Scope = {\n\t\t_root: parent?._root as Root,\n\t\t_parent: parent,\n\t\t_cleanups: new Set(),\n\t\t_updates: [],\n\t\t_dead: false,\n\t}\n\tparent?._cleanups.add(child)\n\treturn child\n}\nexport function fail(scope: Scope, error: unknown): never {\n\ttry {\n\t\tdispose(scope)\n\t} catch (cleanup) {\n\t\tthrow new AggregateError([error, cleanup])\n\t}\n\tthrow error\n}\nexport function dispose(scope: Scope): void {\n\tif (scope._dead) return\n\tscope._dead = true\n\tconst errors: unknown[] = []\n\ttry {\n\t\tscope._root._presence?.forget(scope)\n\t} catch (error) {\n\t\terrors.push(error)\n\t}\n\tfor (const cleanup of [...scope._cleanups].reverse()) {\n\t\ttry {\n\t\t\ttypeof cleanup === `function` ? cleanup() : dispose(cleanup)\n\t\t} catch (error) {\n\t\t\terrors.push(error)\n\t\t}\n\t}\n\tscope._parent?._cleanups.delete(scope)\n\tscope._cleanups.clear()\n\tscope._updates.length = 0\n\tif (errors.length) throw new AggregateError(errors)\n}\nexport function invalidate(scope: Scope): void {\n\tfor (const run of scope._updates) enqueue(scope, run)\n\tfor (const child of scope._cleanups)\n\t\tif (typeof child !== `function`) invalidate(child)\n}\nfunction enqueue(scope: Scope, run: Cleanup): void {\n\tif (!isPresent(scope)) return\n\tconst root = scope._root\n\tif (!root._queue.size)\n\t\tqueueMicrotask(() => {\n\t\t\ttry {\n\t\t\t\troot.flush()\n\t\t\t} catch (error) {\n\t\t\t\troot.error(error)\n\t\t\t}\n\t\t})\n\troot._queue.add(run)\n}\nexport function createRoot(options: RootOptions = {}, server = false): Root {\n\tconst capabilities = new Map<string, Capability>()\n\tfor (const capability of options.capabilities ?? []) {\n\t\tif (capabilities.has(capability.namespace))\n\t\t\tthrow new Error(`spa: duplicate capability ${capability.namespace}`)\n\t\tcapabilities.set(capability.namespace, capability)\n\t}\n\tconst root = {\n\t\t_capabilities: capabilities,\n\t\t_store: options.store ?? IMPLICIT.STORE,\n\t\t_prefix: options.idPrefix ?? `w${serial++}`,\n\t\t_id: 0,\n\t\t...createScope(),\n\t\t_queue: new Set(),\n\t\t_mounts: server ? undefined : [],\n\t} as unknown as Root\n\troot._root = root\n\troot.error =\n\t\toptions.onError ??\n\t\t((error) => {\n\t\t\tthrow error\n\t\t})\n\tfor (const capability of capabilities.values())\n\t\tif (capability.presence) {\n\t\t\tif (root._presence) throw new Error(`spa: multiple presence coordinators`)\n\t\t\troot._presence = capability.presence(root)\n\t\t}\n\troot.flush = () => {\n\t\ttry {\n\t\t\tlet passes = 0\n\t\t\twhile (root._queue.size || root._mounts!.length) {\n\t\t\t\tif (import.meta.env.DEV && ++passes > 100)\n\t\t\t\t\tthrow new Error(`spa: update loop`)\n\t\t\t\tfor (const run of [...root._queue]) if (root._queue.delete(run)) run()\n\t\t\t\tfor (const run of root._mounts!.splice(0)) run()\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfail(root, error)\n\t\t}\n\t}\n\treturn root\n}\n/** Return the atom.io store selected by the current root. */\nexport function useStore(): RootStore {\n\treturn owner!._root._store\n}\nexport function onCleanup(cleanup: Cleanup): void {\n\towner!._cleanups.add(cleanup)\n}\nexport function onMount(run: Cleanup): void {\n\tconst scope = owner!\n\tscope._root._mounts?.push(() => {\n\t\tif (!scope._dead)\n\t\t\twithin(scope, () => {\n\t\t\t\tuntrack(run)\n\t\t\t})\n\t})\n}\nexport function useId(): string {\n\tconst root = owner!._root\n\treturn `${root._prefix}-${root._id++}`\n}\n\nexport function observe<T>(\n\tscope: Scope,\n\tread: Accessor<T>,\n\tapply: (value: T) => void,\n): void {\n\tconst subscriptions = new Map<Subscribe, Cleanup>()\n\tconst run = () => {\n\t\tif (!isPresent(scope)) return\n\t\tconst used = new Set<Subscribe>()\n\t\tconst previous = tracking\n\t\ttracking = (subscribe) => {\n\t\t\tused.add(subscribe)\n\t\t\tif (!subscriptions.has(subscribe))\n\t\t\t\tsubscriptions.set(\n\t\t\t\t\tsubscribe,\n\t\t\t\t\tsubscribe(() => {\n\t\t\t\t\t\tenqueue(scope, run)\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t}\n\t\tlet value: T\n\t\ttry {\n\t\t\tvalue = within(scope, read)\n\t\t} finally {\n\t\t\ttracking = previous\n\t\t\tfor (const [subscribe, unsubscribe] of subscriptions)\n\t\t\t\tif (!used.has(subscribe)) {\n\t\t\t\t\tunsubscribe()\n\t\t\t\t\tsubscriptions.delete(subscribe)\n\t\t\t\t}\n\t\t}\n\t\tuntrack(() => {\n\t\t\tapply(value)\n\t\t})\n\t}\n\tscope._updates.push(run)\n\tscope._cleanups.add(() => {\n\t\tscope._root._queue.delete(run)\n\t\tfor (const unsubscribe of subscriptions.values()) unsubscribe()\n\t})\n\trun()\n}\n\n/** Resolve a fixed family key in the current owner's store. */\nexport function resolveStateToken(token: any, key?: Canonical): any {\n\tconst store = owner!._root._store\n\treturn token.type.endsWith(`_family`) ? findInStore(store, token, key!) : token\n}\n\n/** Capture a token for this instance. Change the component key to change its token. */\nexport function useValue<T, E = never>(\n\ttoken: ReadableToken<T, any, E>,\n): Accessor<ViewOf<T | E>>\nexport function useValue<T, K extends Canonical, E = never>(\n\tfamily: ReadableFamilyToken<T, K, E>,\n\tkey: NoInfer<K>,\n): Accessor<ViewOf<T | E>>\nexport function useValue(token: any, key?: Canonical): Accessor<any> {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\tconst subscribe: Subscribe = (notify) =>\n\t\tsubscribeToState(store, token, `spa:${serial++}`, notify)\n\treturn () => {\n\t\tconst value = getFromStore(store, token)\n\t\ttracking?.(subscribe)\n\t\treturn value\n\t}\n}\nexport function useSetter<T>(\n\ttoken: WritableToken<T, any, any>,\n): (value: T | Setter<T>) => void\nexport function useSetter<T, K extends Canonical>(\n\tfamily: WritableFamilyToken<T, K, any>,\n\tkey: NoInfer<K>,\n): (value: T | Setter<T>) => void\nexport function useSetter(token: any, key?: Canonical): (value: any) => void {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\treturn (value) => {\n\t\tsetIntoStore(store, token, value)\n\t}\n}\nexport function useTransaction<F extends (...args: any[]) => any>(\n\ttoken: TransactionToken<F>,\n): (...args: Parameters<F>) => ReturnType<F> {\n\treturn actUponStore(owner!._root._store, token, `spa:${serial++}`)\n}\n\nconst refs = new WeakMap<RootStore, Map<string, object>>()\nexport function useRef<E extends Element>(\n\ttoken: RegularAtomToken<E | null>,\n): (element: E | null) => void\nexport function useRef<E extends Element, K extends Canonical>(\n\tfamily: RegularAtomFamilyToken<E | null, K>,\n\tkey: NoInfer<K>,\n): (element: E | null) => void\nexport function useRef<E extends Element>(\n\ttoken: any,\n\tkey?: Canonical,\n): (element: E | null) => void {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\tconst owners = refs.get(store) ?? new Map<string, object>()\n\trefs.set(store, owners)\n\tconst identity = {}\n\tlet held: E | null = null\n\treturn (element) => {\n\t\tif (element) {\n\t\t\theld = element\n\t\t\towners.set(token.key, identity)\n\t\t\tsetIntoStore(store, token, element)\n\t\t} else if (owners.get(token.key) === identity) {\n\t\t\towners.delete(token.key)\n\t\t\tif (getFromStore(store, token) === held) setIntoStore(store, token, null)\n\t\t\theld = null\n\t\t}\n\t}\n}\nexport interface TimelineValue {\n\tat: number\n\tlength: number\n\tundo(): void\n\tredo(): void\n\tclear(): void\n\tundoTransaction?: Cleanup\n\tredoTransaction?: Cleanup\n}\nexport function useTimeline<M extends TimelineManageable>(\n\ttoken: TimelineToken<M>,\n): Accessor<TimelineValue>\nexport function useTimeline<K extends Canonical, M extends TimelineManageable>(\n\tfamily: TimelineFamilyToken<K, M>,\n\tkey: NoInfer<K>,\n): Accessor<TimelineValue>\nexport function useTimeline(\n\ttoken: any,\n\tkey?: Canonical,\n): Accessor<TimelineValue> {\n\tconst store = owner!._root._store\n\tif (token.type === `timeline_family`)\n\t\ttoken = findTimelineInStore(store, token, key!)\n\tconst subscribe: Subscribe = (notify) =>\n\t\tsubscribeToTimeline(store, token, `spa:${serial++}`, notify)\n\tconst controls = {\n\t\tundo: () => {\n\t\t\ttimeTravel(store, `undo`, token)\n\t\t},\n\t\tredo: () => {\n\t\t\ttimeTravel(store, `redo`, token)\n\t\t},\n\t\tclear: () => {\n\t\t\tclearTimelineInStore(store, token)\n\t\t},\n\t}\n\treturn () => {\n\t\tconst value: TimelineValue = {\n\t\t\t...inspectTimelineInStore(store, token),\n\t\t\t...controls,\n\t\t}\n\t\ttracking?.(subscribe)\n\t\tfor (const direction of [`undo`, `redo`] as const) {\n\t\t\tconst group = getTimelineTransactionAtHead(\n\t\t\t\tstore.timelines.get(token.key)!,\n\t\t\t\tdirection,\n\t\t\t)\n\t\t\tif (group)\n\t\t\t\tvalue[`${direction}Transaction`] = () =>\n\t\t\t\t\ttimeTravelTransactionGroupInStore(store, direction, group)\n\t\t}\n\t\treturn value\n\t}\n}\n\nexport function plain(value: Child): string {\n\tif (typeof value === `function`) return plain(value())\n\tif (Array.isArray(value)) return value.map(plain).join(``)\n\tif (value == null || typeof value === `boolean`) return ``\n\tif (import.meta.env.DEV && typeof value === `object`)\n\t\tthrow new Error(`spa: text required`)\n\t// oxlint-disable-next-line typescript/no-base-to-string -- Valid text children are primitives here; development rejects malformed object children.\n\treturn String(value)\n}\n\nexport function isPresent(scope: Scope): boolean {\n\tfor (let at: Scope | undefined = scope; at; at = at._parent)\n\t\tif (at._dead || at._exiting) return false\n\treturn true\n}\n"],"mappings":";;AAyFA,IAAW;AAEX,IAAI;AACJ,IAAI,SAAS;AAEb,SAAgB,OAAU,OAAc,KAAiB;CACxD,MAAM,WAAW;CACjB,QAAQ;CACR,IAAI;EACH,OAAO,IAAI;CACZ,UAAU;EACT,QAAQ;CACT;AACD;AACA,SAAgB,QAAW,KAAiB;CAC3C,MAAM,WAAW;CACjB,WAAW,KAAA;CACX,IAAI;EACH,OAAO,IAAI;CACZ,UAAU;EACT,WAAW;CACZ;AACD;AACA,SAAgB,YAAY,QAAuB;CAClD,MAAM,QAAe;EACpB,OAAO,QAAQ;EACf,SAAS;EACT,2BAAW,IAAI,IAAI;EACnB,UAAU,CAAC;EACX,OAAO;CACR;CACA,QAAQ,UAAU,IAAI,KAAK;CAC3B,OAAO;AACR;AACA,SAAgB,KAAK,OAAc,OAAuB;CACzD,IAAI;EACH,QAAQ,KAAK;CACd,SAAS,SAAS;EACjB,MAAM,I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AAO;CACR;AACD;AAEA,SAAgB,MAAM,OAAsB;CAC3C,IAAI,OAAO,UAAU,YAAY,OAAO,MAAM,MAAM,CAAC;CACrD,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE;CACzD,IAAI,SAAS,QAAQ,OAAO,UAAU,WAAW,OAAO;CAIxD,OAAO,OAAO,KAAK;AACpB;AAEA,SAAgB,UAAU,OAAuB;CAChD,KAAK,IAAI,KAAwB,OAAO,IAAI,KAAK,GAAG,SACnD,IAAI,GAAG,SAAS,GAAG,UAAU,OAAO;CACrC,OAAO;AACR"}
@@ -1,5 +1,5 @@
1
1
  import { t as applicationContext } from "./astro-context-OdlexHR4.js";
2
- import { IMPLICIT, withdraw } from "atom.io/internal";
2
+ import { IMPLICIT, subscribeToStateSubject, withdraw } from "atom.io/internal";
3
3
  // src/astro-application.ts
4
4
  const applications = /* @__PURE__ */ new WeakMap();
5
5
  /** Called by the integration's early page script, before island preparation. */
@@ -21,7 +21,7 @@ function browserApplication(document) {
21
21
  if (store.valueMap.has(token.key)) changed();
22
22
  subscriptions.get(token.key)?.();
23
23
  const state = withdraw(store, token);
24
- subscriptions.set(token.key, state.subject.subscribe(`spa:bootstrap`, changed));
24
+ subscriptions.set(token.key, subscribeToStateSubject(state, `spa:bootstrap`, changed));
25
25
  };
26
26
  for (const state of [
27
27
  ...store.atoms.values(),
@@ -1 +1 @@
1
- {"version":3,"file":"astro-application.js","names":[],"sources":["../../src/astro-application.ts"],"sourcesContent":["import type { ReadableToken } from \"atom.io\"\nimport { IMPLICIT, withdraw } from \"atom.io/internal\"\n\nimport { applicationContext } from \"./astro-context.ts\"\n\nconst applications = new WeakMap<\n\tDocument,\n\tReturnType<typeof applicationContext>\n>()\n\n/** Called by the integration's early page script, before island preparation. */\nexport function browserApplication(\n\tdocument: Document,\n): ReturnType<typeof applicationContext> {\n\tlet application = applications.get(document)\n\tif (application) return application\n\tapplication = applicationContext()\n\tconst app = application\n\tconst store = IMPLICIT.STORE\n\tconst originalDefault = store.runDefault\n\tapplications.set(document, app)\n\tconst changed = () => {\n\t\tapp.canResume = false\n\t}\n\tconst internal = (key: string) => key.startsWith(`🔍 spa islands`)\n\tconst subscriptions = new Map<string, () => void>()\n\tconst watch = (token: ReadableToken<unknown, any, any>) => {\n\t\tif (internal(token.key)) return\n\t\tif (store.valueMap.has(token.key)) changed()\n\t\tsubscriptions.get(token.key)?.()\n\t\tconst state = withdraw(store, token)\n\t\tsubscriptions.set(\n\t\t\ttoken.key,\n\t\t\tstate.subject.subscribe(`spa:bootstrap`, changed),\n\t\t)\n\t}\n\tfor (const state of [\n\t\t...store.atoms.values(),\n\t\t...store.readonlySelectors.values(),\n\t\t...store.writableSelectors.values(),\n\t])\n\t\twatch(state)\n\tconst removed = (token: ReadableToken<unknown, any, any>) => {\n\t\tif (!internal(token.key)) {\n\t\t\tchanged()\n\t\t\tsubscriptions.get(token.key)?.()\n\t\t\tsubscriptions.delete(token.key)\n\t\t}\n\t}\n\tconst events = [\n\t\tstore.on.atomCreation.subscribe(`spa:bootstrap`, watch),\n\t\tstore.on.selectorCreation.subscribe(`spa:bootstrap`, watch),\n\t\tstore.on.atomDisposal.subscribe(`spa:bootstrap`, removed),\n\t\tstore.on.selectorDisposal.subscribe(`spa:bootstrap`, removed),\n\t\tstore.on.transactionCommit.subscribe(`spa:bootstrap`, changed),\n\t]\n\tdocument.addEventListener(`astro:before-swap`, changed)\n\tconst pagehide = (event: PageTransitionEvent) => {\n\t\tif (!event.persisted) app.dispose()\n\t}\n\tdocument.defaultView?.addEventListener(`pagehide`, pagehide)\n\tapp.onCleanup(() => {\n\t\tfor (const unsubscribe of subscriptions.values()) unsubscribe()\n\t\tfor (const unsubscribe of events) unsubscribe()\n\t\tdocument.removeEventListener(`astro:before-swap`, changed)\n\t\tdocument.defaultView?.removeEventListener(`pagehide`, pagehide)\n\t\tstore.runDefault = originalDefault\n\t\tapplications.delete(document)\n\t})\n\tre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,iBAAiB,qBAAqB,OAAO;CACtD,MAAM,YAAY,UAA+B;EAChD,IAAI,CAAC,MAAM,WAAW,IAAI,QAAQ;CACnC;CACA,SAAS,aAAa,iBAAiB,YAAY,QAAQ;CAC3D,IAAI,gBAAgB;EACnB,KAAK,MAAM,eAAe,cAAc,OAAO,GAAG,YAAY;EAC9D,KAAK,MAAM,eAAe,QAAQ,YAAY;EAC9C,SAAS,oBAAoB,qBAAqB,OAAO;EACzD,SAAS,aAAa,oBAAoB,YAAY,QAAQ;EAC9D,MAAM,aAAa;EACnB,aAAa,OAAO,QAAQ;CAC7B,CAAC;CACD,OAAO;AACR"}
1
+ {"version":3,"file":"astro-application.js","names":[],"sources":["../../src/astro-application.ts"],"sourcesContent":["import type { ReadableToken } from \"atom.io\"\nimport { IMPLICIT, subscribeToStateSubject, withdraw } from \"atom.io/internal\"\n\nimport { applicationContext } from \"./astro-context.ts\"\n\nconst applications = new WeakMap<\n\tDocument,\n\tReturnType<typeof applicationContext>\n>()\n\n/** Called by the integration's early page script, before island preparation. */\nexport function browserApplication(\n\tdocument: Document,\n): ReturnType<typeof applicationContext> {\n\tlet application = applications.get(document)\n\tif (application) return application\n\tapplication = applicationContext()\n\tconst app = application\n\tconst store = IMPLICIT.STORE\n\tconst originalDefault = store.runDefault\n\tapplications.set(document, app)\n\tconst changed = () => {\n\t\tapp.canResume = false\n\t}\n\tconst internal = (key: string) => key.startsWith(`🔍 spa islands`)\n\tconst subscriptions = new Map<string, () => void>()\n\tconst watch = (token: ReadableToken<unknown, any, any>) => {\n\t\tif (internal(token.key)) return\n\t\tif (store.valueMap.has(token.key)) changed()\n\t\tsubscriptions.get(token.key)?.()\n\t\tconst state = withdraw(store, token)\n\t\tsubscriptions.set(\n\t\t\ttoken.key,\n\t\t\tsubscribeToStateSubject(state, `spa:bootstrap`, changed),\n\t\t)\n\t}\n\tfor (const state of [\n\t\t...store.atoms.values(),\n\t\t...store.readonlySelectors.values(),\n\t\t...store.writableSelectors.values(),\n\t])\n\t\twatch(state)\n\tconst removed = (token: ReadableToken<unknown, any, any>) => {\n\t\tif (!internal(token.key)) {\n\t\t\tchanged()\n\t\t\tsubscriptions.get(token.key)?.()\n\t\t\tsubscriptions.delete(token.key)\n\t\t}\n\t}\n\tconst events = [\n\t\tstore.on.atomCreation.subscribe(`spa:bootstrap`, watch),\n\t\tstore.on.selectorCreation.subscribe(`spa:bootstrap`, watch),\n\t\tstore.on.atomDisposal.subscribe(`spa:bootstrap`, removed),\n\t\tstore.on.selectorDisposal.subscribe(`spa:bootstrap`, removed),\n\t\tstore.on.transactionCommit.subscribe(`spa:bootstrap`, changed),\n\t]\n\tdocument.addEventListener(`astro:before-swap`, changed)\n\tconst pagehide = (event: PageTransitionEvent) => {\n\t\tif (!event.persisted) app.dispose()\n\t}\n\tdocument.defaultView?.addEventListener(`pagehide`, pagehide)\n\tapp.onCleanup(() => {\n\t\tfor (const unsubscribe of subscriptions.values()) unsubscribe()\n\t\tfor (const unsubscribe of events) unsubscribe()\n\t\tdocument.removeEventListener(`astro:before-swap`, changed)\n\t\tdocument.defaultView?.removeEventListener(`pagehide`, pagehide)\n\t\tstore.runDefault = originalDefault\n\t\tapplications.delete(document)\n\t})\n\treturn app\n}\n"],"mappings":";;;AAKA,MAAM,+BAAe,IAAI,QAGvB;;AAGF,SAAgB,mBACf,UACwC;CACxC,IAAI,cAAc,aAAa,IAAI,QAAQ;CAC3C,IAAI,aAAa,OAAO;CACxB,cAAc,mBAAmB;CACjC,MAAM,MAAM;CACZ,MAAM,QAAQ,SAAS;CACvB,MAAM,kBAAkB,MAAM;CAC9B,aAAa,IAAI,UAAU,GAAG;CAC9B,MAAM,gBAAgB;EACrB,IAAI,YAAY;CACjB;CACA,MAAM,YAAY,QAAgB,IAAI,WAAW,gBAAgB;CACjE,MAAM,gCAAgB,IAAI,IAAwB;CAClD,MAAM,SAAS,UAA4C;EAC1D,IAAI,SAAS,MAAM,GAAG,GAAG;EACzB,IAAI,MAAM,SAAS,IAAI,MAAM,GAAG,GAAG,QAAQ;EAC3C,cAAc,IAAI,MAAM,GAAG,CAAC,GAAG;EAC/B,MAAM,QAAQ,SAAS,OAAO,KAAK;EACnC,cAAc,IACb,MAAM,KACN,wBAAwB,OAAO,iBAAiB,OAAO,CACxD;CACD;CACA,KAAK,MAAM,SAAS;EACnB,GAAG,MAAM,MAAM,OAAO;EACtB,GAAG,MAAM,kBAAkB,OAAO;EAClC,GAAG,MAAM,kBAAkB,OAAO;CACnC,GACC,MAAM,KAAK;CACZ,MAAM,WAAW,UAA4C;EAC5D,IAAI,CAAC,SAAS,MAAM,GAAG,GAAG;GACzB,QAAQ;GACR,cAAc,IAAI,MAAM,GAAG,CAAC,GAAG;GAC/B,cAAc,OAAO,MAAM,GAAG;EAC/B;CACD;CACA,MAAM,SAAS;EACd,MAAM,GAAG,aAAa,UAAU,iBAAiB,KAAK;EACtD,MAAM,GAAG,iBAAiB,UAAU,iBAAiB,KAAK;EAC1D,MAAM,GAAG,aAAa,UAAU,iBAAiB,OAAO;EACxD,MAAM,GAAG,iBAAiB,UAAU,iBAAiB,OAAO;EAC5D,MAAM,GAAG,kBAAkB,UAAU,iBAAiB,OAAO;CAC9D;CACA,SAAS,iBAAiB,qBAAqB,OAAO;CACtD,MAAM,YAAY,UAA+B;EAChD,IAAI,CAAC,MAAM,WAAW,IAAI,QAAQ;CACnC;CACA,SAAS,aAAa,iBAAiB,YAAY,QAAQ;CAC3D,IAAI,gBAAgB;EACnB,KAAK,MAAM,eAAe,cAAc,OAAO,GAAG,YAAY;EAC9D,KAAK,MAAM,eAAe,QAAQ,YAAY;EAC9C,SAAS,oBAAoB,qBAAqB,OAAO;EACzD,SAAS,aAAa,oBAAoB,YAAY,QAAQ;EAC9D,MAAM,aAAa;EACnB,aAAa,OAAO,QAAQ;CAC7B,CAAC;CACD,OAAO;AACR"}
@@ -1,8 +1,8 @@
1
1
  import { browserApplication } from "./astro-application.js";
2
2
  import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
3
3
  import { n as islandStore, t as island } from "./astro-shared-BT45auwR.js";
4
- import { S as useValue, u as onCleanup } from "./capabilities-DhOJmeoJ.js";
5
- import { n as render, t as hydrate } from "./dom-BKc6V_Kz.js";
4
+ import { b as useValue, c as onCleanup } from "./core-p9vciX9C.js";
5
+ import { n as render, t as hydrate } from "./dom-Ci1XvbVJ.js";
6
6
  import { IMPLICIT, createRegularAtomFamily, disposeFromStore, findInStore, setIntoStore } from "atom.io/internal";
7
7
  // src/astro-client.ts
8
8
  const roots = /* @__PURE__ */ new WeakMap();
@@ -0,0 +1,63 @@
1
+ // src/capabilities.ts
2
+ function capabilityNamespace(key) {
3
+ const colon = key.indexOf(`:`);
4
+ if (colon < 0) return void 0;
5
+ const namespace = key.slice(0, colon);
6
+ return /^(xml|xmlns|xlink)$/.test(namespace) ? void 0 : namespace;
7
+ }
8
+ function validateCapabilities(scope, props) {
9
+ for (const key of Object.keys(props)) {
10
+ const namespace = capabilityNamespace(key);
11
+ if (namespace && !scope._root._capabilities.has(namespace)) throw new Error(`spa: capability "${namespace}" is not registered for this root`);
12
+ }
13
+ }
14
+ /** Separate framework properties from native attributes and own their bindings. */
15
+ function capabilityProps(scope, target, read) {
16
+ const bindings = /* @__PURE__ */ new Map();
17
+ scope._root._presence?.target(scope, target);
18
+ const cleanup = () => {
19
+ const errors = [];
20
+ for (const binding of [...bindings.values()].reverse()) try {
21
+ binding.dispose();
22
+ } catch (error) {
23
+ errors.push(error);
24
+ }
25
+ bindings.clear();
26
+ if (errors.length) throw new AggregateError(errors);
27
+ };
28
+ scope._cleanups.add(cleanup);
29
+ return (props) => {
30
+ validateCapabilities(scope, props);
31
+ const native = {};
32
+ const groups = /* @__PURE__ */ new Map();
33
+ for (const key of Object.keys(props)) {
34
+ const namespace = capabilityNamespace(key);
35
+ if (!namespace) {
36
+ const value = props[key];
37
+ native[key] = key.startsWith(`on`) && typeof value === `function` ? scope._root._presence?.event(scope, value) ?? value : value;
38
+ continue;
39
+ }
40
+ const group = groups.get(namespace) ?? {};
41
+ group[key.slice(namespace.length + 1)] = props[key];
42
+ groups.set(namespace, group);
43
+ }
44
+ for (const [namespace, values] of groups) {
45
+ let binding = bindings.get(namespace);
46
+ if (!binding) {
47
+ binding = scope._root._capabilities.get(namespace).attach(target);
48
+ bindings.set(namespace, binding);
49
+ scope._root._presence?.bind(scope, binding, read ?? (() => props), namespace);
50
+ }
51
+ binding.update(values);
52
+ }
53
+ for (const [namespace, binding] of bindings) if (!groups.has(namespace)) {
54
+ bindings.delete(namespace);
55
+ scope._root._presence?.unbind(binding);
56
+ binding.dispose();
57
+ }
58
+ return native;
59
+ };
60
+ }
61
+ export { capabilityProps as n, validateCapabilities as r, capabilityNamespace as t };
62
+
63
+ //# sourceMappingURL=capabilities-BkQ2i0vV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities-BkQ2i0vV.js","names":[],"sources":["../../src/capabilities.ts"],"sourcesContent":["import type { Cleanup, Root, Scope } from \"./core.ts\"\nimport type { ExitHandle, PresenceCoordinator } from \"./presence.ts\"\n\n/** Native renderers expose property access without importing capability engines. */\nexport interface CapabilityTarget {\n\tkind: string\n\tnode: unknown\n\tsuspend?(): Cleanup\n\tread?(key: string): unknown\n\twrite?(key: string, value: unknown): void\n\tlisten?(event: string, listener: () => void): Cleanup\n}\nexport interface CapabilityBinding {\n\texit?(props: Record<string, unknown>): ExitHandle | undefined\n\tresume?(): void\n\tupdate(props: Record<string, unknown>): void\n\tdispose(): void\n}\nexport interface Capability {\n\tnamespace: string\n\tpresence?(root: Root): PresenceCoordinator\n\tscheduleFrame?(callback: (time: number) => void): Cleanup\n\tattach(target: CapabilityTarget): CapabilityBinding\n}\n\nexport function capabilityNamespace(key: string): string | undefined {\n\tconst colon = key.indexOf(`:`)\n\tif (colon < 0) return undefined\n\tconst namespace = key.slice(0, colon)\n\treturn /^(xml|xmlns|xlink)$/.test(namespace) ? undefined : namespace\n}\nexport function validateCapabilities(\n\tscope: Scope,\n\tprops: Record<string, unknown>,\n): void {\n\tfor (const key of Object.keys(props)) {\n\t\tconst namespace = capabilityNamespace(key)\n\t\tif (namespace && !scope._root._capabilities.has(namespace))\n\t\t\tthrow new Error(\n\t\t\t\t`spa: capability \"${namespace}\" is not registered for this root`,\n\t\t\t)\n\t}\n}\n\n/** Separate framework properties from native attributes and own their bindings. */\nexport function capabilityProps(\n\tscope: Scope,\n\ttarget: CapabilityTarget,\n\tread?: () => Record<string, any>,\n): (props: Record<string, any>) => Record<string, any> {\n\tconst bindings = new Map<string, CapabilityBinding>()\n\n\tscope._root._presence?.target(scope, target)\n\tconst cleanup: Cleanup = () => {\n\t\tconst errors: unknown[] = []\n\t\tfor (const binding of [...bindings.values()].reverse()) {\n\t\t\ttry {\n\t\t\t\tbinding.dispose()\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error)\n\t\t\t}\n\t\t}\n\t\tbindings.clear()\n\t\tif (errors.length) throw new AggregateError(errors)\n\t}\n\tscope._cleanups.add(cleanup)\n\treturn (props) => {\n\t\tvalidateCapabilities(scope, props)\n\t\tconst native: Record<string, any> = {}\n\t\tconst groups = new Map<string, Record<string, unknown>>()\n\t\tfor (const key of Object.keys(props)) {\n\t\t\tconst namespace = capabilityNamespace(key)\n\t\t\tif (!namespace) {\n\t\t\t\tconst value = props[key]\n\t\t\t\tnative[key] =\n\t\t\t\t\tkey.startsWith(`on`) && typeof value === `function`\n\t\t\t\t\t\t? (scope._root._presence?.event(scope, value) ?? value)\n\t\t\t\t\t\t: value\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst group = groups.get(namespace) ?? {}\n\t\t\tgroup[key.slice(namespace.length + 1)] = props[key]\n\t\t\tgroups.set(namespace, group)\n\t\t}\n\t\tfor (const [namespace, values] of groups) {\n\t\t\tlet binding = bindings.get(namespace)\n\t\t\tif (!binding) {\n\t\t\t\tbinding = scope._root._capabilities.get(namespace)!.attach(target)\n\t\t\t\tbindings.set(namespace, binding)\n\t\t\t\tscope._root._presence?.bind(\n\t\t\t\t\tscope,\n\t\t\t\t\tbinding,\n\t\t\t\t\tread ?? (() => props),\n\t\t\t\t\tnamespace,\n\t\t\t\t)\n\t\t\t}\n\t\t\tbinding.update(values)\n\t\t}\n\t\tfor (const [namespace, binding] of bindings)\n\t\t\tif (!groups.has(namespace)) {\n\t\t\t\tbindings.delete(namespace)\n\t\t\t\tscope._root._presence?.unbind(binding)\n\t\t\t\tbinding.dispose()\n\t\t\t}\n\t\treturn native\n\t}\n}\n"],"mappings":";AAyBA,SAAgB,oBAAoB,KAAiC;CACpE,MAAM,QAAQ,IAAI,QAAQ,GAAG;CAC7B,IAAI,QAAQ,GAAG,OAAO,KAAA;CACtB,MAAM,YAAY,IAAI,MAAM,GAAG,KAAK;CACpC,OAAO,sBAAsB,KAAK,SAAS,IAAI,KAAA,IAAY;AAC5D;AACA,SAAgB,qBACf,OACA,OACO;CACP,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EACrC,MAAM,YAAY,oBAAoB,GAAG;EACzC,IAAI,aAAa,CAAC,MAAM,MAAM,cAAc,IAAI,SAAS,GACxD,MAAM,IAAI,MACT,oBAAoB,UAAU,kCAC/B;CACF;AACD;;AAGA,SAAgB,gBACf,OACA,QACA,MACsD;CACtD,MAAM,2BAAW,IAAI,IAA+B;CAEpD,MAAM,MAAM,WAAW,OAAO,OAAO,MAAM;CAC3C,MAAM,gBAAyB;EAC9B,MAAM,SAAoB,CAAC;EAC3B,KAAK,MAAM,WAAW,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,CAAC,QAAQ,GACpD,IAAI;GACH,QAAQ,QAAQ;EACjB,SAAS,OAAO;GACf,OAAO,KAAK,KAAK;EAClB;EAED,SAAS,MAAM;EACf,IAAI,OAAO,QAAQ,MAAM,IAAI,eAAe,MAAM;CACnD;CACA,MAAM,UAAU,IAAI,OAAO;CAC3B,QAAQ,UAAU;EACjB,qBAAqB,OAAO,KAAK;EACjC,MAAM,SAA8B,CAAC;EACrC,MAAM,yBAAS,IAAI,IAAqC;EACxD,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;GACrC,MAAM,YAAY,oBAAoB,GAAG;GACzC,IAAI,CAAC,WAAW;IACf,MAAM,QAAQ,MAAM;IACpB,OAAO,OACN,IAAI,WAAW,IAAI,KAAK,OAAO,UAAU,aACrC,MAAM,MAAM,WAAW,MAAM,OAAO,KAAK,KAAK,QAC/C;IACJ;GACD;GACA,MAAM,QAAQ,OAAO,IAAI,SAAS,KAAK,CAAC;GACxC,MAAM,IAAI,MAAM,UAAU,SAAS,CAAC,KAAK,MAAM;GAC/C,OAAO,IAAI,WAAW,KAAK;EAC5B;EACA,KAAK,MAAM,CAAC,WAAW,WAAW,QAAQ;GACzC,IAAI,UAAU,SAAS,IAAI,SAAS;GACpC,IAAI,CAAC,SAAS;IACb,UAAU,MAAM,MAAM,cAAc,IAAI,SAAS,CAAC,CAAE,OAAO,MAAM;IACjE,SAAS,IAAI,WAAW,OAAO;IAC/B,MAAM,MAAM,WAAW,KACtB,OACA,SACA,eAAe,QACf,SACD;GACD;GACA,QAAQ,OAAO,MAAM;EACtB;EACA,KAAK,MAAM,CAAC,WAAW,YAAY,UAClC,IAAI,CAAC,OAAO,IAAI,SAAS,GAAG;GAC3B,SAAS,OAAO,SAAS;GACzB,MAAM,MAAM,WAAW,OAAO,OAAO;GACrC,QAAQ,QAAQ;EACjB;EACD,OAAO;CACR;AACD"}
@@ -44,6 +44,11 @@ function dispose(scope) {
44
44
  if (scope._dead) return;
45
45
  scope._dead = true;
46
46
  const errors = [];
47
+ try {
48
+ scope._root._presence?.forget(scope);
49
+ } catch (error) {
50
+ errors.push(error);
51
+ }
47
52
  for (const cleanup of [...scope._cleanups].reverse()) try {
48
53
  typeof cleanup === `function` ? cleanup() : dispose(cleanup);
49
54
  } catch (error) {
@@ -59,7 +64,7 @@ function invalidate(scope) {
59
64
  for (const child of scope._cleanups) if (typeof child !== `function`) invalidate(child);
60
65
  }
61
66
  function enqueue(scope, run) {
62
- if (scope._dead) return;
67
+ if (!isPresent(scope)) return;
63
68
  const root = scope._root;
64
69
  if (!root._queue.size) queueMicrotask(() => {
65
70
  try {
@@ -89,6 +94,10 @@ function createRoot(options = {}, server = false) {
89
94
  root.error = options.onError ?? ((error) => {
90
95
  throw error;
91
96
  });
97
+ for (const capability of capabilities.values()) if (capability.presence) {
98
+ if (root._presence) throw new Error(`spa: multiple presence coordinators`);
99
+ root._presence = capability.presence(root);
100
+ }
92
101
  root.flush = () => {
93
102
  try {
94
103
  let passes = 0;
@@ -125,7 +134,7 @@ function useId() {
125
134
  function observe(scope, read, apply) {
126
135
  const subscriptions = /* @__PURE__ */ new Map();
127
136
  const run = () => {
128
- if (scope._dead) return;
137
+ if (!isPresent(scope)) return;
129
138
  const used = /* @__PURE__ */ new Set();
130
139
  const previous = tracking;
131
140
  tracking = (subscribe) => {
@@ -235,62 +244,10 @@ function plain(value) {
235
244
  if (typeof value === `object`) throw new Error(`spa: text required`);
236
245
  return String(value);
237
246
  }
238
- // src/capabilities.ts
239
- function capabilityNamespace(key) {
240
- const colon = key.indexOf(`:`);
241
- if (colon < 0) return void 0;
242
- const namespace = key.slice(0, colon);
243
- return /^(xml|xmlns|xlink)$/.test(namespace) ? void 0 : namespace;
244
- }
245
- function validateCapabilities(scope, props) {
246
- for (const key of Object.keys(props)) {
247
- const namespace = capabilityNamespace(key);
248
- if (namespace && !scope._root._capabilities.has(namespace)) throw new Error(`spa: capability "${namespace}" is not registered for this root`);
249
- }
250
- }
251
- /** Separate framework properties from native attributes and own their bindings. */
252
- function capabilityProps(scope, target) {
253
- const bindings = /* @__PURE__ */ new Map();
254
- const cleanup = () => {
255
- const errors = [];
256
- for (const binding of [...bindings.values()].reverse()) try {
257
- binding.dispose();
258
- } catch (error) {
259
- errors.push(error);
260
- }
261
- bindings.clear();
262
- if (errors.length) throw new AggregateError(errors);
263
- };
264
- scope._cleanups.add(cleanup);
265
- return (props) => {
266
- validateCapabilities(scope, props);
267
- const native = {};
268
- const groups = /* @__PURE__ */ new Map();
269
- for (const key of Object.keys(props)) {
270
- const namespace = capabilityNamespace(key);
271
- if (!namespace) {
272
- native[key] = props[key];
273
- continue;
274
- }
275
- const group = groups.get(namespace) ?? {};
276
- group[key.slice(namespace.length + 1)] = props[key];
277
- groups.set(namespace, group);
278
- }
279
- for (const [namespace, values] of groups) {
280
- let binding = bindings.get(namespace);
281
- if (!binding) {
282
- binding = scope._root._capabilities.get(namespace).attach(target);
283
- bindings.set(namespace, binding);
284
- }
285
- binding.update(values);
286
- }
287
- for (const [namespace, binding] of bindings) if (!groups.has(namespace)) {
288
- bindings.delete(namespace);
289
- binding.dispose();
290
- }
291
- return native;
292
- };
247
+ function isPresent(scope) {
248
+ for (let at = scope; at; at = at._parent) if (at._dead || at._exiting) return false;
249
+ return true;
293
250
  }
294
- export { within as C, useValue as S, useRef as _, createScope as a, useTimeline as b, invalidate as c, onMount as d, owner as f, useId as g, untrack as h, createRoot as i, observe as l, resolveStateToken as m, capabilityProps as n, dispose as o, plain as p, validateCapabilities as r, fail as s, capabilityNamespace as t, onCleanup as u, useSetter as v, useTransaction as x, useStore as y };
251
+ export { useStore as _, invalidate as a, useValue as b, onCleanup as c, plain as d, resolveStateToken as f, useSetter as g, useRef as h, fail as i, onMount as l, useId as m, createScope as n, isPresent as o, untrack as p, dispose as r, observe as s, createRoot as t, owner as u, useTimeline as v, within as x, useTransaction as y };
295
252
 
296
- //# sourceMappingURL=capabilities-DhOJmeoJ.js.map
253
+ //# sourceMappingURL=core-p9vciX9C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-p9vciX9C.js","names":[],"sources":["../../src/core.ts"],"sourcesContent":["import type {\n\tReadableFamilyToken,\n\tReadableToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n\tSetter,\n\tTimelineFamilyToken,\n\tTimelineManageable,\n\tTimelineToken,\n\tTransactionToken,\n\tViewOf,\n\tWritableFamilyToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/foundations/canonical\"\nimport type { RootStore } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tclearTimelineInStore,\n\tfindInStore,\n\tfindTimelineInStore,\n\tgetFromStore,\n\tgetTimelineTransactionAtHead,\n\tIMPLICIT,\n\tinspectTimelineInStore,\n\tsetIntoStore,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\ttimeTravel,\n\ttimeTravelTransactionGroupInStore,\n} from \"atom.io/internal\"\n\nimport type { Capability } from \"./capabilities.ts\"\nimport type {\n\tExitParticipant,\n\tPresenceCoordinator,\n\tPresenceTarget,\n} from \"./presence.ts\"\n\nexport type Cleanup = () => void\n// A callable interface permits the recursive Child union. A type alias does not.\n/* oxlint-disable typescript/prefer-function-type -- A callable interface is required for recursive Child. */\nexport interface Accessor<T> {\n\t(): T\n}\n/* oxlint-enable typescript/prefer-function-type */\nexport type Component<P = any> = (props: P) => Child\nexport interface VNode {\n\ttype: string | Component | null\n\tprops: Record<string, any>\n}\nexport type Child =\n\t| VNode\n\t| string\n\t| number\n\t| bigint\n\t| boolean\n\t| null\n\t| undefined\n\t| readonly Child[]\n\t| Accessor<Child>\nexport interface RootOptions {\n\tcapabilities?: readonly Capability[]\n\tstore?: RootStore\n\tidPrefix?: string\n\tonError?: (error: unknown) => void\n}\nexport interface Scope {\n\t_exiting?: boolean\n\t_exits?: Set<ExitParticipant>\n\t_targets?: Set<PresenceTarget>\n\t_root: Root\n\t_parent?: Scope | undefined\n\t_cleanups: Set<Cleanup | Scope>\n\t_updates: Cleanup[]\n\t_dead: boolean\n}\nexport interface Root extends Scope {\n\t_presence?: PresenceCoordinator\n\t_capabilities: Map<string, Capability>\n\t_store: RootStore\n\t_prefix: string\n\t_id: number\n\t_queue: Set<Cleanup>\n\t_mounts: Cleanup[] | undefined\n\tflush: Cleanup\n\terror: (error: unknown) => void\n}\n\nexport let owner: Scope | undefined\ntype Subscribe = (notify: Cleanup) => Cleanup\nlet tracking: ((subscribe: Subscribe) => void) | undefined\nlet serial = 0\n\nexport function within<T>(scope: Scope, run: () => T): T {\n\tconst previous = owner\n\towner = scope\n\ttry {\n\t\treturn run()\n\t} finally {\n\t\towner = previous\n\t}\n}\nexport function untrack<T>(run: () => T): T {\n\tconst previous = tracking\n\ttracking = undefined\n\ttry {\n\t\treturn run()\n\t} finally {\n\t\ttracking = previous\n\t}\n}\nexport function createScope(parent?: Scope): Scope {\n\tconst child: Scope = {\n\t\t_root: parent?._root as Root,\n\t\t_parent: parent,\n\t\t_cleanups: new Set(),\n\t\t_updates: [],\n\t\t_dead: false,\n\t}\n\tparent?._cleanups.add(child)\n\treturn child\n}\nexport function fail(scope: Scope, error: unknown): never {\n\ttry {\n\t\tdispose(scope)\n\t} catch (cleanup) {\n\t\tthrow new AggregateError([error, cleanup])\n\t}\n\tthrow error\n}\nexport function dispose(scope: Scope): void {\n\tif (scope._dead) return\n\tscope._dead = true\n\tconst errors: unknown[] = []\n\ttry {\n\t\tscope._root._presence?.forget(scope)\n\t} catch (error) {\n\t\terrors.push(error)\n\t}\n\tfor (const cleanup of [...scope._cleanups].reverse()) {\n\t\ttry {\n\t\t\ttypeof cleanup === `function` ? cleanup() : dispose(cleanup)\n\t\t} catch (error) {\n\t\t\terrors.push(error)\n\t\t}\n\t}\n\tscope._parent?._cleanups.delete(scope)\n\tscope._cleanups.clear()\n\tscope._updates.length = 0\n\tif (errors.length) throw new AggregateError(errors)\n}\nexport function invalidate(scope: Scope): void {\n\tfor (const run of scope._updates) enqueue(scope, run)\n\tfor (const child of scope._cleanups)\n\t\tif (typeof child !== `function`) invalidate(child)\n}\nfunction enqueue(scope: Scope, run: Cleanup): void {\n\tif (!isPresent(scope)) return\n\tconst root = scope._root\n\tif (!root._queue.size)\n\t\tqueueMicrotask(() => {\n\t\t\ttry {\n\t\t\t\troot.flush()\n\t\t\t} catch (error) {\n\t\t\t\troot.error(error)\n\t\t\t}\n\t\t})\n\troot._queue.add(run)\n}\nexport function createRoot(options: RootOptions = {}, server = false): Root {\n\tconst capabilities = new Map<string, Capability>()\n\tfor (const capability of options.capabilities ?? []) {\n\t\tif (capabilities.has(capability.namespace))\n\t\t\tthrow new Error(`spa: duplicate capability ${capability.namespace}`)\n\t\tcapabilities.set(capability.namespace, capability)\n\t}\n\tconst root = {\n\t\t_capabilities: capabilities,\n\t\t_store: options.store ?? IMPLICIT.STORE,\n\t\t_prefix: options.idPrefix ?? `w${serial++}`,\n\t\t_id: 0,\n\t\t...createScope(),\n\t\t_queue: new Set(),\n\t\t_mounts: server ? undefined : [],\n\t} as unknown as Root\n\troot._root = root\n\troot.error =\n\t\toptions.onError ??\n\t\t((error) => {\n\t\t\tthrow error\n\t\t})\n\tfor (const capability of capabilities.values())\n\t\tif (capability.presence) {\n\t\t\tif (root._presence) throw new Error(`spa: multiple presence coordinators`)\n\t\t\troot._presence = capability.presence(root)\n\t\t}\n\troot.flush = () => {\n\t\ttry {\n\t\t\tlet passes = 0\n\t\t\twhile (root._queue.size || root._mounts!.length) {\n\t\t\t\tif (import.meta.env.DEV && ++passes > 100)\n\t\t\t\t\tthrow new Error(`spa: update loop`)\n\t\t\t\tfor (const run of [...root._queue]) if (root._queue.delete(run)) run()\n\t\t\t\tfor (const run of root._mounts!.splice(0)) run()\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfail(root, error)\n\t\t}\n\t}\n\treturn root\n}\n/** Return the atom.io store selected by the current root. */\nexport function useStore(): RootStore {\n\treturn owner!._root._store\n}\nexport function onCleanup(cleanup: Cleanup): void {\n\towner!._cleanups.add(cleanup)\n}\nexport function onMount(run: Cleanup): void {\n\tconst scope = owner!\n\tscope._root._mounts?.push(() => {\n\t\tif (!scope._dead)\n\t\t\twithin(scope, () => {\n\t\t\t\tuntrack(run)\n\t\t\t})\n\t})\n}\nexport function useId(): string {\n\tconst root = owner!._root\n\treturn `${root._prefix}-${root._id++}`\n}\n\nexport function observe<T>(\n\tscope: Scope,\n\tread: Accessor<T>,\n\tapply: (value: T) => void,\n): void {\n\tconst subscriptions = new Map<Subscribe, Cleanup>()\n\tconst run = () => {\n\t\tif (!isPresent(scope)) return\n\t\tconst used = new Set<Subscribe>()\n\t\tconst previous = tracking\n\t\ttracking = (subscribe) => {\n\t\t\tused.add(subscribe)\n\t\t\tif (!subscriptions.has(subscribe))\n\t\t\t\tsubscriptions.set(\n\t\t\t\t\tsubscribe,\n\t\t\t\t\tsubscribe(() => {\n\t\t\t\t\t\tenqueue(scope, run)\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t}\n\t\tlet value: T\n\t\ttry {\n\t\t\tvalue = within(scope, read)\n\t\t} finally {\n\t\t\ttracking = previous\n\t\t\tfor (const [subscribe, unsubscribe] of subscriptions)\n\t\t\t\tif (!used.has(subscribe)) {\n\t\t\t\t\tunsubscribe()\n\t\t\t\t\tsubscriptions.delete(subscribe)\n\t\t\t\t}\n\t\t}\n\t\tuntrack(() => {\n\t\t\tapply(value)\n\t\t})\n\t}\n\tscope._updates.push(run)\n\tscope._cleanups.add(() => {\n\t\tscope._root._queue.delete(run)\n\t\tfor (const unsubscribe of subscriptions.values()) unsubscribe()\n\t})\n\trun()\n}\n\n/** Resolve a fixed family key in the current owner's store. */\nexport function resolveStateToken(token: any, key?: Canonical): any {\n\tconst store = owner!._root._store\n\treturn token.type.endsWith(`_family`) ? findInStore(store, token, key!) : token\n}\n\n/** Capture a token for this instance. Change the component key to change its token. */\nexport function useValue<T, E = never>(\n\ttoken: ReadableToken<T, any, E>,\n): Accessor<ViewOf<T | E>>\nexport function useValue<T, K extends Canonical, E = never>(\n\tfamily: ReadableFamilyToken<T, K, E>,\n\tkey: NoInfer<K>,\n): Accessor<ViewOf<T | E>>\nexport function useValue(token: any, key?: Canonical): Accessor<any> {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\tconst subscribe: Subscribe = (notify) =>\n\t\tsubscribeToState(store, token, `spa:${serial++}`, notify)\n\treturn () => {\n\t\tconst value = getFromStore(store, token)\n\t\ttracking?.(subscribe)\n\t\treturn value\n\t}\n}\nexport function useSetter<T>(\n\ttoken: WritableToken<T, any, any>,\n): (value: T | Setter<T>) => void\nexport function useSetter<T, K extends Canonical>(\n\tfamily: WritableFamilyToken<T, K, any>,\n\tkey: NoInfer<K>,\n): (value: T | Setter<T>) => void\nexport function useSetter(token: any, key?: Canonical): (value: any) => void {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\treturn (value) => {\n\t\tsetIntoStore(store, token, value)\n\t}\n}\nexport function useTransaction<F extends (...args: any[]) => any>(\n\ttoken: TransactionToken<F>,\n): (...args: Parameters<F>) => ReturnType<F> {\n\treturn actUponStore(owner!._root._store, token, `spa:${serial++}`)\n}\n\nconst refs = new WeakMap<RootStore, Map<string, object>>()\nexport function useRef<E extends Element>(\n\ttoken: RegularAtomToken<E | null>,\n): (element: E | null) => void\nexport function useRef<E extends Element, K extends Canonical>(\n\tfamily: RegularAtomFamilyToken<E | null, K>,\n\tkey: NoInfer<K>,\n): (element: E | null) => void\nexport function useRef<E extends Element>(\n\ttoken: any,\n\tkey?: Canonical,\n): (element: E | null) => void {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\tconst owners = refs.get(store) ?? new Map<string, object>()\n\trefs.set(store, owners)\n\tconst identity = {}\n\tlet held: E | null = null\n\treturn (element) => {\n\t\tif (element) {\n\t\t\theld = element\n\t\t\towners.set(token.key, identity)\n\t\t\tsetIntoStore(store, token, element)\n\t\t} else if (owners.get(token.key) === identity) {\n\t\t\towners.delete(token.key)\n\t\t\tif (getFromStore(store, token) === held) setIntoStore(store, token, null)\n\t\t\theld = null\n\t\t}\n\t}\n}\nexport interface TimelineValue {\n\tat: number\n\tlength: number\n\tundo(): void\n\tredo(): void\n\tclear(): void\n\tundoTransaction?: Cleanup\n\tredoTransaction?: Cleanup\n}\nexport function useTimeline<M extends TimelineManageable>(\n\ttoken: TimelineToken<M>,\n): Accessor<TimelineValue>\nexport function useTimeline<K extends Canonical, M extends TimelineManageable>(\n\tfamily: TimelineFamilyToken<K, M>,\n\tkey: NoInfer<K>,\n): Accessor<TimelineValue>\nexport function useTimeline(\n\ttoken: any,\n\tkey?: Canonical,\n): Accessor<TimelineValue> {\n\tconst store = owner!._root._store\n\tif (token.type === `timeline_family`)\n\t\ttoken = findTimelineInStore(store, token, key!)\n\tconst subscribe: Subscribe = (notify) =>\n\t\tsubscribeToTimeline(store, token, `spa:${serial++}`, notify)\n\tconst controls = {\n\t\tundo: () => {\n\t\t\ttimeTravel(store, `undo`, token)\n\t\t},\n\t\tredo: () => {\n\t\t\ttimeTravel(store, `redo`, token)\n\t\t},\n\t\tclear: () => {\n\t\t\tclearTimelineInStore(store, token)\n\t\t},\n\t}\n\treturn () => {\n\t\tconst value: TimelineValue = {\n\t\t\t...inspectTimelineInStore(store, token),\n\t\t\t...controls,\n\t\t}\n\t\ttracking?.(subscribe)\n\t\tfor (const direction of [`undo`, `redo`] as const) {\n\t\t\tconst group = getTimelineTransactionAtHead(\n\t\t\t\tstore.timelines.get(token.key)!,\n\t\t\t\tdirection,\n\t\t\t)\n\t\t\tif (group)\n\t\t\t\tvalue[`${direction}Transaction`] = () =>\n\t\t\t\t\ttimeTravelTransactionGroupInStore(store, direction, group)\n\t\t}\n\t\treturn value\n\t}\n}\n\nexport function plain(value: Child): string {\n\tif (typeof value === `function`) return plain(value())\n\tif (Array.isArray(value)) return value.map(plain).join(``)\n\tif (value == null || typeof value === `boolean`) return ``\n\tif (import.meta.env.DEV && typeof value === `object`)\n\t\tthrow new Error(`spa: text required`)\n\t// oxlint-disable-next-line typescript/no-base-to-string -- Valid text children are primitives here; development rejects malformed object children.\n\treturn String(value)\n}\n\nexport function isPresent(scope: Scope): boolean {\n\tfor (let at: Scope | undefined = scope; at; at = at._parent)\n\t\tif (at._dead || at._exiting) return false\n\treturn true\n}\n"],"mappings":";;AAyFA,IAAW;AAEX,IAAI;AACJ,IAAI,SAAS;AAEb,SAAgB,OAAU,OAAc,KAAiB;CACxD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Q,oBAAoB,OAAO,OAAO,GAAI;CAC/C,MAAM,aAAwB,WAC7B,oBAAoB,OAAO,OAAO,OAAO,YAAY,MAAM;CAC5D,MAAM,WAAW;EAChB,YAAY;GACX,WAAW,OAAO,QAAQ,KAAK;EAChC;EACA,YAAY;GACX,WAAW,OAAO,QAAQ,KAAK;EAChC;EACA,aAAa;GACZ,qBAAqB,OAAO,KAAK;EAClC;CACD;CACA,aAAa;EACZ,MAAM,QAAuB;GAC5B,GAAG,uBAAuB,OAAO,KAAK;GACtC,GAAG;EACJ;EACA,WAAW,SAAS;EACpB,KAAK,MAAM,aAAa,CAAC,QAAQ,MAAM,GAAY;GAClD,MAAM,QAAQ,6BACb,MAAM,UAAU,IAAI,MAAM,GAAG,GAC7B,SACD;GACA,IAAI,OACH,MAAM,GAAG,UAAU,sBAClB,kCAAkC,OAAO,WAAW,KAAK;EAC5D;EACA,OAAO;CACR;AACD;AAEA,SAAgB,MAAM,OAAsB;CAC3C,IAAI,OAAO,UAAU,YAAY,OAAO,MAAM,MAAM,CAAC;CACrD,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,KAAK,CAAC,CAAC,KAAK,EAAE;CACzD,IAAI,SAAS,QAAQ,OAAO,UAAU,WAAW,OAAO;CACxD,IAA2B,OAAO,UAAU,UAC3C,MAAM,IAAI,MAAM,oBAAoB;CAErC,OAAO,OAAO,KAAK;AACpB;AAEA,SAAgB,UAAU,OAAuB;CAChD,KAAK,IAAI,KAAwB,OAAO,IAAI,KAAK,GAAG,SACnD,IAAI,GAAG,SAAS,GAAG,UAAU,OAAO;CACrC,OAAO;AACR"}
@@ -1,4 +1,5 @@
1
- import { C as within, a as createScope, c as invalidate, h as untrack, i as createRoot, l as observe, n as capabilityProps, o as dispose, p as plain, s as fail } from "./capabilities-DhOJmeoJ.js";
1
+ import { n as capabilityProps } from "./capabilities-BkQ2i0vV.js";
2
+ import { a as invalidate, d as plain, i as fail, n as createScope, p as untrack, r as dispose, s as observe, t as createRoot, x as within } from "./core-p9vciX9C.js";
2
3
  import { Fragment, merge } from "./jsx-runtime.js";
3
4
  // src/dom.ts
4
5
  const HTML = `http://www.w3.org/1999/xhtml`;
@@ -46,6 +47,11 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
46
47
  comment(`{`, parent, before, owner, cursor);
47
48
  let end = null;
48
49
  let records = /* @__PURE__ */ new Map();
50
+ const presence = owner._root._presence?.collection((record) => record._scope, (record, child) => typeof record._value === typeof child && record._value?.type === child?.type);
51
+ const retire = (record, key, eligible, index) => {
52
+ if (presence) presence.remove(record, key, eligible, index, () => {});
53
+ else dispose(record._scope);
54
+ };
49
55
  let initial = cursor;
50
56
  observe(owner, () => source()(), (next) => {
51
57
  const values = [next].flat(Infinity);
@@ -59,9 +65,10 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
59
65
  if (kept.has(key)) throw new Error(`spa: duplicate key`);
60
66
  let record = records.get(key);
61
67
  if (record && (typeof record._value !== typeof child || record._value?.type !== vnode?.type)) {
62
- dispose(record._scope);
68
+ retire(record, key, child == null || typeof child === `boolean`, [...records.keys()].indexOf(key));
63
69
  record = void 0;
64
70
  }
71
+ record ??= presence?.take(key, child);
65
72
  if (!record) {
66
73
  const childOwner = createScope(owner);
67
74
  record = {
@@ -75,14 +82,16 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
75
82
  record._end = comment(`]`, parent, end ?? before, childOwner, initial);
76
83
  } else {
77
84
  record._value = child;
85
+ owner._root._presence?.resume(record._scope);
78
86
  invalidate(record._scope);
79
87
  }
80
88
  kept.set(key, record);
81
89
  }
82
- for (const [key, record] of records) if (!kept.has(key)) dispose(record._scope);
90
+ for (const [key, record] of records) if (!kept.has(key)) retire(record, key, true, [...records.keys()].indexOf(key));
83
91
  if (!initial) {
84
92
  let at = end ?? before;
85
- for (const record of [...kept.values()].reverse()) {
93
+ const rendered = presence?.merge([...kept.values()]) ?? [...kept.values()];
94
+ for (const record of rendered.reverse()) {
86
95
  if (record._end.nextSibling !== at) {
87
96
  const range = parent.ownerDocument.createRange();
88
97
  range.setStartBefore(record._start);
@@ -91,7 +100,7 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
91
100
  }
92
101
  at = record._start;
93
102
  }
94
- if (focus?.isConnected && focus !== parent.ownerDocument.activeElement) focus.focus({ preventScroll: true });
103
+ if (focus?.isConnected && !focus.closest(`[inert]`) && focus !== parent.ownerDocument.activeElement) focus.focus({ preventScroll: true });
95
104
  }
96
105
  initial = void 0;
97
106
  records = kept;
@@ -140,7 +149,7 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
140
149
  const nativeProps = capabilityProps(owner, {
141
150
  kind: `dom`,
142
151
  node: element
143
- });
152
+ }, () => ({ ...props }));
144
153
  let previous = {};
145
154
  owner._cleanups.add(() => {
146
155
  for (const key in previous) if (key.startsWith(`on`)) property(element, key, null, previous[key]);
@@ -196,4 +205,4 @@ function hydrate(setup, host, options = {}) {
196
205
  }
197
206
  export { render as n, hydrate as t };
198
207
 
199
- //# sourceMappingURL=dom-BKc6V_Kz.js.map
208
+ //# sourceMappingURL=dom-Ci1XvbVJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-Ci1XvbVJ.js","names":[],"sources":["../../src/dom.ts"],"sourcesContent":["import { capabilityProps } from \"./capabilities.ts\"\nimport type { Accessor, Child, RootOptions, Scope, VNode } from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tfail,\n\tinvalidate,\n\tobserve,\n\tplain,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment, merge } from \"./jsx-runtime.ts\"\n\nconst HTML = `http://www.w3.org/1999/xhtml`\nconst SVG = `http://www.w3.org/2000/svg`\ntype Cursor = { node: Node | null }\ntype RecordNode = { _value: Child; _scope: Scope; _start: Node; _end: Node }\n\nfunction take(\n\tnode: Node,\n\tparent: Node,\n\tbefore: Node | null,\n\towner: Scope,\n\tcursor?: Cursor,\n): Node {\n\tif (\n\t\tcursor &&\n\t\t!(node.nodeType === 3 && !node.nodeValue && cursor.node?.nodeType !== 3)\n\t) {\n\t\tconst found = cursor.node\n\t\tif (\n\t\t\t!found ||\n\t\t\tfound.nodeType !== node.nodeType ||\n\t\t\tfound.nodeName !== node.nodeName ||\n\t\t\t(found as Element).namespaceURI !== (node as Element).namespaceURI ||\n\t\t\t(node.nodeType !== 1 && found.nodeValue !== node.nodeValue)\n\t\t)\n\t\t\tthrow new Error(\n\t\t\t\timport.meta.env.DEV ? `spa: hydration mismatch` : undefined,\n\t\t\t)\n\t\tnode = found\n\t\tcursor.node = found.nextSibling\n\t} else parent.insertBefore(node, cursor ? cursor.node : before)\n\towner._cleanups.add(() => {\n\t\t;(node as ChildNode).remove()\n\t})\n\treturn node\n}\nfunction comment(\n\tvalue: string,\n\tparent: Node,\n\tbefore: Node | null,\n\towner: Scope,\n\tcursor?: Cursor,\n): Node {\n\treturn take(\n\t\tparent.ownerDocument!.createComment(value),\n\t\tparent,\n\t\tbefore,\n\t\towner,\n\t\tcursor,\n\t)\n}\nfunction property(\n\telement: Element,\n\tkey: string,\n\tvalue: any,\n\tprevious: any,\n): void {\n\tif (/^(key|children|ref)$/.test(key)) return\n\tif (key === `innerHTML` && element.localName === `astro-slot`) return\n\tif (\n\t\t/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(\n\t\t\tkey,\n\t\t)\n\t)\n\t\tthrow new Error(import.meta.env.DEV ? `spa: owned content` : undefined)\n\tif (key.startsWith(`on`)) {\n\t\tconst capture = /(?<!Pointer)Capture$/.test(key)\n\t\tconst event = key\n\t\t\t.slice(2, capture ? -7 : undefined)\n\t\t\t.toLowerCase()\n\t\t\t.replace(`doubleclick`, `dblclick`)\n\t\tif (previous) element.removeEventListener(event, previous, capture)\n\t\tif (value != null) {\n\t\t\tif (import.meta.env.DEV && typeof value !== `function`)\n\t\t\t\tthrow new Error(`spa: event handler`)\n\t\t\telement.addEventListener(event, value, capture)\n\t\t}\n\t\treturn\n\t}\n\tif (key === `className`) key = `class`\n\tif (key === `htmlFor`) key = `for`\n\tif (\n\t\timport.meta.env.DEV &&\n\t\tkey === `style` &&\n\t\tvalue != null &&\n\t\ttypeof value !== `string`\n\t)\n\t\tthrow new Error(`spa: CSS string required`)\n\tif (\n\t\telement.namespaceURI === HTML &&\n\t\tkey in element &&\n\t\t!/^(style|form|list)$/.test(key)\n\t) {\n\t\tconst target = element as any\n\t\ttarget[key] = value ?? (typeof target[key] === `boolean` ? false : ``)\n\t} else if (value == null || (value === false && !/^(aria-|data-)/.test(key)))\n\t\telement.removeAttribute(key)\n\telse\n\t\telement.setAttribute(\n\t\t\tkey,\n\t\t\tvalue === true && !/^(aria-|data-)/.test(key) ? `` : String(value),\n\t\t)\n}\n\nfunction mount(\n\tvalue: Child,\n\tparent: Node,\n\tbefore: Node | null,\n\towner: Scope,\n\tnamespace: string,\n\tcursor?: Cursor,\n\tsource = () => value,\n): void {\n\tif (typeof value === `function`) {\n\t\tcomment(`{`, parent, before, owner, cursor)\n\t\tlet end: Node | null = null\n\t\tlet records = new Map<unknown, RecordNode>()\n\t\tconst presence = owner._root._presence?.collection<RecordNode, Child>(\n\t\t\t(record) => record._scope,\n\t\t\t(record, child) =>\n\t\t\t\ttypeof record._value === typeof child &&\n\t\t\t\t(record._value as VNode | null)?.type === (child as VNode | null)?.type,\n\t\t)\n\t\tconst retire = (\n\t\t\trecord: RecordNode,\n\t\t\tkey: unknown,\n\t\t\teligible: boolean,\n\t\t\tindex: number,\n\t\t) => {\n\t\t\tif (presence) presence.remove(record, key, eligible, index, () => {})\n\t\t\telse dispose(record._scope)\n\t\t}\n\t\tlet initial = cursor\n\t\tobserve(\n\t\t\towner,\n\t\t\t() => (source() as () => Child)(),\n\t\t\t(next) => {\n\t\t\t\tconst values = ([next] as unknown[]).flat(Infinity) as Child[]\n\t\t\t\tconst kept = new Map<unknown, RecordNode>()\n\t\t\t\tconst focus = parent.ownerDocument!.activeElement as HTMLElement | null\n\t\t\t\tfor (let index = 0; index < values.length; index++) {\n\t\t\t\t\tconst child = values[index]\n\t\t\t\t\tconst vnode = child as VNode | null\n\t\t\t\t\tconst explicit = vnode?.props?.[`key`]\n\t\t\t\t\tconst key = explicit == null ? index : String(explicit)\n\t\t\t\t\tif (import.meta.env.DEV && kept.has(key))\n\t\t\t\t\t\tthrow new Error(`spa: duplicate key`)\n\t\t\t\t\tlet record = records.get(key)\n\t\t\t\t\tif (\n\t\t\t\t\t\trecord &&\n\t\t\t\t\t\t(typeof record._value !== typeof child ||\n\t\t\t\t\t\t\t(record._value as VNode | null)?.type !== vnode?.type)\n\t\t\t\t\t) {\n\t\t\t\t\t\tretire(\n\t\t\t\t\t\t\trecord,\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tchild == null || typeof child === `boolean`,\n\t\t\t\t\t\t\t[...records.keys()].indexOf(key),\n\t\t\t\t\t\t)\n\t\t\t\t\t\trecord = undefined\n\t\t\t\t\t}\n\t\t\t\t\trecord ??= presence?.take(key, child)\n\t\t\t\t\tif (!record) {\n\t\t\t\t\t\tconst childOwner = createScope(owner)\n\t\t\t\t\t\trecord = {\n\t\t\t\t\t\t\t_value: child,\n\t\t\t\t\t\t\t_scope: childOwner,\n\t\t\t\t\t\t\t_start: comment(`[`, parent, end ?? before, childOwner, initial),\n\t\t\t\t\t\t\t_end: null!,\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst held = record\n\t\t\t\t\t\tmount(\n\t\t\t\t\t\t\tchild,\n\t\t\t\t\t\t\tparent,\n\t\t\t\t\t\t\tend ?? before,\n\t\t\t\t\t\t\tchildOwner,\n\t\t\t\t\t\t\tnamespace,\n\t\t\t\t\t\t\tinitial,\n\t\t\t\t\t\t\t() => held._value,\n\t\t\t\t\t\t)\n\t\t\t\t\t\trecord._end = comment(\n\t\t\t\t\t\t\t`]`,\n\t\t\t\t\t\t\tparent,\n\t\t\t\t\t\t\tend ?? before,\n\t\t\t\t\t\t\tchildOwner,\n\t\t\t\t\t\t\tinitial,\n\t\t\t\t\t\t)\n\t\t\t\t\t} else {\n\t\t\t\t\t\trecord._value = child\n\t\t\t\t\t\towner._root._presence?.resume(record._scope)\n\t\t\t\t\t\tinvalidate(record._scope)\n\t\t\t\t\t}\n\t\t\t\t\tkept.set(key, record)\n\t\t\t\t}\n\t\t\t\tfor (const [key, record] of records)\n\t\t\t\t\tif (!kept.has(key))\n\t\t\t\t\t\tretire(record, key, true, [...records.keys()].indexOf(key))\n\t\t\t\tif (!initial) {\n\t\t\t\t\tlet at = end ?? before\n\t\t\t\t\tconst rendered = presence?.merge([...kept.values()]) ?? [\n\t\t\t\t\t\t...kept.values(),\n\t\t\t\t\t]\n\t\t\t\t\tfor (const record of rendered.reverse()) {\n\t\t\t\t\t\tif (record._end.nextSibling !== at) {\n\t\t\t\t\t\t\tconst range = parent.ownerDocument!.createRange()\n\t\t\t\t\t\t\trange.setStartBefore(record._start)\n\t\t\t\t\t\t\trange.setEndAfter(record._end)\n\t\t\t\t\t\t\tparent.insertBefore(range.extractContents(), at)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tat = record._start\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tfocus?.isConnected &&\n\t\t\t\t\t\t!focus.closest(`[inert]`) &&\n\t\t\t\t\t\tfocus !== parent.ownerDocument!.activeElement\n\t\t\t\t\t)\n\t\t\t\t\t\tfocus.focus({ preventScroll: true })\n\t\t\t\t}\n\t\t\t\tinitial = undefined\n\t\t\t\trecords = kept\n\t\t\t},\n\t\t)\n\t\tend = comment(`}`, parent, before, owner, cursor)\n\t\treturn\n\t}\n\tif (Array.isArray(value)) {\n\t\tfor (const child of value)\n\t\t\tmount(child, parent, before, owner, namespace, cursor)\n\t\treturn\n\t}\n\tif (value == null || typeof value === `boolean`) return\n\tif (typeof value !== `object`) {\n\t\tcomment(`t`, parent, before, owner, cursor)\n\t\tconst text = take(\n\t\t\tparent.ownerDocument!.createTextNode(String(value)),\n\t\t\tparent,\n\t\t\tbefore,\n\t\t\towner,\n\t\t\tcursor,\n\t\t)\n\t\tobserve(owner, source as Accessor<string | number | bigint>, (next) => {\n\t\t\tconst data = String(next)\n\t\t\tif (text.nodeValue !== data) text.nodeValue = data\n\t\t})\n\t\treturn\n\t}\n\tif (import.meta.env.DEV && (!(`type` in value) || !(`props` in value)))\n\t\tthrow new Error(`spa: invalid child`)\n\tconst vnode = value as VNode\n\tconst props = merge(() => (source() as VNode).props)\n\tif (!vnode.type || vnode.type === Fragment) {\n\t\tmount(() => props[`children`], parent, before, owner, namespace, cursor)\n\t\treturn\n\t}\n\tif (typeof vnode.type === `function`) {\n\t\tconst childOwner = createScope(owner)\n\t\tconst output = within(childOwner, () =>\n\t\t\tuntrack(() => (vnode.type as Function)(props)),\n\t\t)\n\t\tmount(output, parent, before, childOwner, namespace, cursor)\n\t\treturn\n\t}\n\tconst ns = vnode.type === `svg` ? SVG : namespace\n\tconst element = take(\n\t\tparent.ownerDocument!.createElementNS(ns, vnode.type),\n\t\tparent,\n\t\tbefore,\n\t\towner,\n\t\tcursor,\n\t) as Element\n\tif (vnode.type === `astro-slot`) {\n\t\tif (!cursor) element.innerHTML = props[`innerHTML`] ?? ``\n\t} else if (ns === HTML && /^(textarea|title|style|script)$/.test(vnode.type)) {\n\t\tobserve(\n\t\t\towner,\n\t\t\t() =>\n\t\t\t\tplain(\n\t\t\t\t\tvnode.type === `textarea`\n\t\t\t\t\t\t? (props[`value`] ?? props[`children`])\n\t\t\t\t\t\t: props[`children`],\n\t\t\t\t),\n\t\t\t(text) => {\n\t\t\t\tif (element.textContent !== text) element.textContent = text\n\t\t\t},\n\t\t)\n\t} else {\n\t\tconst children = cursor ? { node: element.firstChild } : undefined\n\t\tif (\n\t\t\t!/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/.test(\n\t\t\t\tvnode.type,\n\t\t\t) ||\n\t\t\tns !== HTML\n\t\t)\n\t\t\tmount(\n\t\t\t\t() => props[`children`],\n\t\t\t\telement,\n\t\t\t\tnull,\n\t\t\t\towner,\n\t\t\t\tvnode.type === `foreignObject` ? HTML : ns,\n\t\t\t\tchildren,\n\t\t\t)\n\t\tif (children?.node)\n\t\t\tthrow new Error(\n\t\t\t\timport.meta.env.DEV ? `spa: hydration mismatch` : undefined,\n\t\t\t)\n\t}\n\tconst nativeProps = capabilityProps(\n\t\towner,\n\t\t{ kind: `dom`, node: element },\n\t\t() => ({ ...props }),\n\t)\n\tlet previous: Record<string, any> = {}\n\towner._cleanups.add(() => {\n\t\tfor (const key in previous)\n\t\t\tif (key.startsWith(`on`)) property(element, key, null, previous[key])\n\t})\n\tobserve(\n\t\towner,\n\t\t() => ({ ...props }),\n\t\t(all) => {\n\t\t\tconst next = nativeProps(all)\n\t\t\tfor (const key in { ...previous, ...next })\n\t\t\t\tif (\n\t\t\t\t\t!Object.is(previous[key], next[key]) ||\n\t\t\t\t\ttypeof next[key] === `object`\n\t\t\t\t) {\n\t\t\t\t\tproperty(element, key, next[key], previous[key])\n\t\t\t\t\tprevious[key] = next[key]\n\t\t\t\t}\n\t\t\tprevious = next\n\t\t},\n\t)\n\tconst ref = untrack(() => props[`ref`])\n\tif (ref) {\n\t\towner._root._mounts!.unshift(() => {\n\t\t\tif (!owner._dead) {\n\t\t\t\towner._cleanups.add(() => ref(null))\n\t\t\t\tref(element)\n\t\t\t}\n\t\t})\n\t}\n}\n\nexport interface SpaRoot {\n\tdispose(): void\n\tflush(): void\n}\nfunction start(\n\tsetup: () => Child,\n\thost: Element,\n\toptions: RootOptions,\n\thydrating: boolean,\n): SpaRoot {\n\tconst cursor = hydrating ? { node: host.firstChild } : undefined\n\tconst prefix = cursor?.node?.nodeValue?.slice(2)\n\tif (\n\t\thydrating &&\n\t\t(prefix === undefined ||\n\t\t\t(options.idPrefix !== undefined && prefix !== options.idPrefix))\n\t)\n\t\tthrow new Error(import.meta.env.DEV ? `spa: hydration mismatch` : undefined)\n\tconst root = createRoot(options)\n\tif (prefix !== undefined) root._prefix = prefix\n\ttry {\n\t\tcomment(`w:${root._prefix}`, host, null, root, cursor)\n\t\twithin(root, () => {\n\t\t\tmount(\n\t\t\t\tuntrack(setup),\n\t\t\t\thost,\n\t\t\t\tnull,\n\t\t\t\troot,\n\t\t\t\thost.namespaceURI === SVG ? SVG : HTML,\n\t\t\t\tcursor,\n\t\t\t)\n\t\t})\n\t\tcomment(`/w`, host, null, root, cursor)\n\t\tif (cursor?.node)\n\t\t\tthrow new Error(\n\t\t\t\timport.meta.env.DEV ? `spa: hydration mismatch` : undefined,\n\t\t\t)\n\t\troot.flush()\n\t} catch (error) {\n\t\tfail(root, error)\n\t}\n\treturn {\n\t\tdispose: () => {\n\t\t\tdispose(root)\n\t\t},\n\t\tflush: root.flush,\n\t}\n}\nexport function render(\n\tsetup: () => Child,\n\thost: Element,\n\toptions: RootOptions = {},\n): SpaRoot {\n\treturn start(setup, host, options, false)\n}\nexport function hydrate(\n\tsetup: () => Child,\n\thost: Element,\n\toptions: RootOptions = {},\n): SpaRoot {\n\treturn start(setup, host, options, true)\n}\n"],"mappings":";;;;AAeA,MAAM,OAAO;AACb,MAAM,MAAM;AAIZ,SAAS,KACR,MACA,QACA,QACA,OACA,QACO;CACP,IACC,UACA,EAAE,KAAK,aAAa,KAAK,CAAC,KAAK,aAAa,OAAO,MAAM,aAAa,IACrE;EACD,MAAM,QAAQ,OAAO;EACrB,IACC,CAAC,SACD,MAAM,aAAa,KAAK,YACxB,MAAM,aAAa,KAAK,YACvB,MAAkB,iBAAkB,KAAiB,gBACrD,KAAK,aAAa,KAAK,MAAM,cAAc,KAAK,WAEjD,MAAM,IAAI,MACa,yBACvB;EACD,OAAO;EACP,OAAO,OAAO,MAAM;CACrB,OAAO,OAAO,aAAa,MAAM,SAAS,OAAO,OAAO,MAAM;CAC9D,MAAM,UAAU,UAAU;EACxB,KAAoB,OAAO;CAC7B,CAAC;CACD,OAAO;AACR;AACA,SAAS,QACR,OACA,QACA,QACA,OACA,QACO;CACP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AAM,MAAM,MAAM,MAAM;EACrD,OAAO,YAAY;GAClB,MACC,QAAQ,KAAK,GACb,MACA,MACA,MACA,KAAK,iBAAiB,MAAM,MAAM,MAClC,MACD;EACD,CAAC;EACD,QAAQ,MAAM,MAAM,MAAM,MAAM,MAAM;EACtC,IAAI,QAAQ,MACX,MAAM,IAAI,MACa,yBACvB;EACD,KAAK,MAAM;CACZ,SAAS,OAAO;EACf,KAAK,MAAM,KAAK;CACjB;CACA,OAAO;EACN,eAAe;GACd,QAAQ,IAAI;EACb;EACA,OAAO,KAAK;CACb;AACD;AACA,SAAgB,OACf,OACA,MACA,UAAuB,CAAC,GACd;CACV,OAAO,MAAM,OAAO,MAAM,SAAS,KAAK;AACzC;AACA,SAAgB,QACf,OACA,MACA,UAAuB,CAAC,GACd;CACV,OAAO,MAAM,OAAO,MAAM,SAAS,IAAI;AACxC"}
@@ -1,5 +1,5 @@
1
- import { S as useValue, _ as useRef, b as useTimeline, d as onMount, g as useId, u as onCleanup, v as useSetter, x as useTransaction, y as useStore } from "./capabilities-DhOJmeoJ.js";
1
+ import { _ as useStore, b as useValue, c as onCleanup, g as useSetter, h as useRef, l as onMount, m as useId, v as useTimeline, y as useTransaction } from "./core-p9vciX9C.js";
2
2
  import { Fragment } from "./jsx-runtime.js";
3
- import { n as render, t as hydrate } from "./dom-BKc6V_Kz.js";
4
- import { t as useLoadable } from "./src-Dh-d6w4y.js";
3
+ import { n as render, t as hydrate } from "./dom-Ci1XvbVJ.js";
4
+ import { t as useLoadable } from "./src-DG0xjuS5.js";
5
5
  export { Fragment, hydrate, onCleanup, onMount, render, useId, useLoadable, useRef, useSetter, useStore, useTimeline, useTransaction, useValue };
@@ -1,4 +1,5 @@
1
- import { d as onMount, f as owner, n as capabilityProps, u as onCleanup } from "./capabilities-DhOJmeoJ.js";
1
+ import { n as capabilityProps } from "./capabilities-BkQ2i0vV.js";
2
+ import { c as onCleanup, l as onMount, u as owner } from "./core-p9vciX9C.js";
2
3
  import { jsx } from "./jsx-runtime.js";
3
4
  import { bindScene, createSceneRenderer, sceneComponent } from "./renderer.js";
4
5
  import Konva from "konva";
@@ -16,6 +17,16 @@ const constructors = {
16
17
  Star: Konva.Star,
17
18
  Transformer: Konva.Transformer
18
19
  };
20
+ function suspendNode(node) {
21
+ const listening = node.listening();
22
+ const draggable = node.draggable();
23
+ node.listening(false);
24
+ node.draggable(false);
25
+ return () => {
26
+ node.listening(listening);
27
+ node.draggable(draggable);
28
+ };
29
+ }
19
30
  function updateNode(node, props, previous) {
20
31
  for (const key of /* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(props)])) {
21
32
  if (/^(key|children|ref)$/.test(key) || Object.is(props[key], previous[key])) continue;
@@ -31,6 +42,9 @@ const renderer = createSceneRenderer({
31
42
  return {
32
43
  kind: `konva`,
33
44
  node,
45
+ suspend() {
46
+ return suspendNode(node);
47
+ },
34
48
  read: (key) => node.getAttr(key),
35
49
  write: (key, value) => {
36
50
  node.setAttr(key, value);
@@ -68,8 +82,13 @@ const renderer = createSceneRenderer({
68
82
  function Stage(props) {
69
83
  let container = null;
70
84
  onMount(() => {
85
+ const surface = container.ownerDocument.createElement(`div`);
86
+ container.append(surface);
87
+ onCleanup(() => {
88
+ surface.remove();
89
+ });
71
90
  const stage = new Konva.Stage({
72
- container,
91
+ container: surface,
73
92
  width: props.width ?? 300,
74
93
  height: props.height ?? 150
75
94
  });
@@ -80,6 +99,9 @@ function Stage(props) {
80
99
  const nativeProps = capabilityProps(owner, {
81
100
  kind: `konva`,
82
101
  node: stage,
102
+ suspend() {
103
+ return suspendNode(stage);
104
+ },
83
105
  listen(event, listener) {
84
106
  stage.on(event, listener);
85
107
  return () => {
@@ -90,7 +112,7 @@ function Stage(props) {
90
112
  write: (key, value) => {
91
113
  stage.setAttr(key, value);
92
114
  }
93
- });
115
+ }, () => ({ ...props }));
94
116
  let previous = {};
95
117
  bindScene(() => ({ ...props }), (all) => {
96
118
  const next = nativeProps(all);
@@ -1 +1 @@
1
- {"version":3,"file":"konva.js","names":[],"sources":["../../src/konva.ts"],"sourcesContent":["import Konva from \"konva\"\n\nimport { capabilityProps } from \"./capabilities.ts\"\nimport { owner } from \"./core.ts\"\nimport type { Child, VNode } from \"./index.ts\"\nimport { onCleanup, onMount } from \"./index.ts\"\nimport type { CapabilityAttributes } from \"./jsx-runtime.ts\"\nimport { jsx } from \"./jsx-runtime.ts\"\nimport { bindScene, createSceneRenderer, sceneComponent } from \"./renderer.ts\"\n\ntype Props<C, N> = C &\n\tCapabilityAttributes<`konva`> & {\n\t\tchildren?: Child\n\t\tref?: (node: N | null) => void\n\t\tonClick?: (event: Konva.KonvaEventObject<MouseEvent>) => void\n\t\tonPointerDown?: (event: Konva.KonvaEventObject<PointerEvent>) => void\n\t\tonDragMove?: (event: Konva.KonvaEventObject<DragEvent>) => void\n\t\tonDragEnd?: (event: Konva.KonvaEventObject<DragEvent>) => void\n\t}\nconst constructors = {\n\tLayer: Konva.Layer,\n\tGroup: Konva.Group,\n\tRect: Konva.Rect,\n\tCircle: Konva.Circle,\n\tEllipse: Konva.Ellipse,\n\tLine: Konva.Line,\n\tText: Konva.Text,\n\tImage: Konva.Image,\n\tPath: Konva.Path,\n\tStar: Konva.Star,\n\tTransformer: Konva.Transformer,\n}\nfunction updateNode(\n\tnode: Konva.Node,\n\tprops: Record<string, any>,\n\tprevious: Record<string, any>,\n): void {\n\tfor (const key of new Set([...Object.keys(previous), ...Object.keys(props)])) {\n\t\tif (/^(key|children|ref)$/.test(key) || Object.is(props[key], previous[key]))\n\t\t\tcontinue\n\t\tif (key.startsWith(`on`)) {\n\t\t\tconst event = key.slice(2).toLowerCase()\n\t\t\tif (previous[key]) node.off(event, previous[key])\n\t\t\tif (props[key]) node.on(event, props[key])\n\t\t} else node.setAttr(key, props[key])\n\t}\n}\nconst renderer = createSceneRenderer<Konva.Node>({\n\ttarget(node) {\n\t\treturn {\n\t\t\tkind: `konva`,\n\t\t\tnode,\n\t\t\tread: (key) => node.getAttr(key),\n\t\t\twrite: (key, value) => {\n\t\t\t\tnode.setAttr(key, value)\n\t\t\t},\n\t\t\tlisten(event, listener) {\n\t\t\t\tnode.on(event, listener)\n\t\t\t\treturn () => {\n\t\t\t\t\tnode.off(event, listener)\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t},\n\tcreate(type) {\n\t\tconst Constructor = constructors[type as keyof typeof constructors]\n\t\tif (!Constructor) throw new Error(`spa/konva: unknown node ${type}`)\n\t\treturn new Constructor({} as any)\n\t},\n\tupdate: updateNode,\n\tchildren(parent, children) {\n\t\tif (children.length && !(parent instanceof Konva.Container))\n\t\t\tthrow new Error(`spa/konva: shapes cannot contain children`)\n\t\tif (parent instanceof Konva.Container) {\n\t\t\tfor (const child of [...parent.getChildren()])\n\t\t\t\tif (!children.includes(child)) child.remove()\n\t\t\tchildren.forEach((child, index) => {\n\t\t\t\tif (child.getParent() !== parent) parent.add(child as any)\n\t\t\t\tchild.zIndex(index)\n\t\t\t})\n\t\t}\n\t},\n\tdestroy(node) {\n\t\tnode.off()\n\t\tnode.destroy()\n\t},\n})\n\n/** A DOM boundary owning a Konva stage and its scene subtree. */\nexport function Stage(\n\tprops: Props<Omit<Konva.StageConfig, `container`>, Konva.Stage> & {\n\t\twidth?: number\n\t\theight?: number\n\t},\n): VNode {\n\tlet container: HTMLDivElement | null = null\n\tonMount(() => {\n\t\tconst stage = new Konva.Stage({\n\t\t\tcontainer: container!,\n\t\t\twidth: props.width ?? 300,\n\t\t\theight: props.height ?? 150,\n\t\t})\n\t\tonCleanup(() => {\n\t\t\tstage.off()\n\t\t\tstage.destroy()\n\t\t})\n\t\tconst nativeProps = capabilityProps(owner!, {\n\t\t\tkind: `konva`,\n\t\t\tnode: stage,\n\t\t\tlisten(event, listener) {\n\t\t\t\tstage.on(event, listener)\n\t\t\t\treturn () => {\n\t\t\t\t\tstage.off(event, listener)\n\t\t\t\t}\n\t\t\t},\n\t\t\tread: (key) => stage.getAttr(key),\n\t\t\twrite: (key, value) => {\n\t\t\t\tstage.setAttr(key, value)\n\t\t\t},\n\t\t})\n\t\tlet previous: Record<string, any> = {}\n\t\tbindScene(\n\t\t\t() => ({ ...props }),\n\t\t\t(all) => {\n\t\t\t\tconst next = nativeProps(all)\n\t\t\t\tupdateNode(stage, next, previous)\n\t\t\t\tprevious = next\n\t\t\t},\n\t\t)\n\t\tprops.ref?.(stage)\n\t\tonCleanup(() => props.ref?.(null))\n\t\trenderer.mount(() => props.children, stage)\n\t})\n\treturn jsx(`div`, {\n\t\tref: (element: HTMLDivElement | null) => {\n\t\t\tcontainer = element\n\t\t},\n\t})\n}\nexport const Layer =\n\tsceneComponent<Props<Konva.LayerConfig, Konva.Layer>>(`Layer`)\nexport const Group =\n\tsceneComponent<Props<Konva.ContainerConfig, Konva.Group>>(`Group`)\nexport const Rect = sceneComponent<Props<Konva.RectConfig, Konva.Rect>>(`Rect`)\nexport const Circle =\n\tsceneComponent<Props<Konva.CircleConfig, Konva.Circle>>(`Circle`)\nexport const Ellipse =\n\tsceneComponent<Props<Konva.EllipseConfig, Konva.Ellipse>>(`Ellipse`)\nexport const Line = sceneComponent<Props<Konva.LineConfig, Konva.Line>>(`Line`)\nexport const Text = sceneComponent<Props<Konva.TextConfig, Konva.Text>>(`Text`)\nexport const Image =\n\tsceneComponent<Props<Konva.ImageConfig, Konva.Image>>(`Image`)\nexport const Path = sceneComponent<Props<Konva.PathConfig, Konva.Path>>(`Path`)\nexport const Star = sceneComponent<Props<Konva.StarConfig, Konva.Star>>(`Star`)\nexport const Transformer =\n\tsceneComponent<Props<Konva.TransformerConfig, Konva.Transformer>>(\n\t\t`Transformer`,\n\t)\nexport { renderer as konvaRenderer }\n"],"mappings":";;;;;AAmBA,MAAM,eAAe;CACpB,OAAO,MAAM;CACb,OAAO,MAAM;CACb,MAAM,MAAM;CACZ,QAAQ,MAAM;CACd,SAAS,MAAM;CACf,MAAM,MAAM;CACZ,MAAM,MAAM;CACZ,OAAO,MAAM;CACb,MAAM,MAAM;CACZ,MA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9E,MAAa,QACZ,eAAsD,OAAO;AAC9D,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,cACZ,eACC,aACD"}
1
+ {"version":3,"file":"konva.js","names":[],"sources":["../../src/konva.ts"],"sourcesContent":["import Konva from \"konva\"\n\nimport { capabilityProps } from \"./capabilities.ts\"\nimport { owner } from \"./core.ts\"\nimport type { Child, VNode } from \"./index.ts\"\nimport { onCleanup, onMount } from \"./index.ts\"\nimport type { CapabilityAttributes } from \"./jsx-runtime.ts\"\nimport { jsx } from \"./jsx-runtime.ts\"\nimport { bindScene, createSceneRenderer, sceneComponent } from \"./renderer.ts\"\n\ntype Props<C, N> = C &\n\tCapabilityAttributes<`konva`> & {\n\t\tchildren?: Child\n\t\tref?: (node: N | null) => void\n\t\tonClick?: (event: Konva.KonvaEventObject<MouseEvent>) => void\n\t\tonPointerDown?: (event: Konva.KonvaEventObject<PointerEvent>) => void\n\t\tonDragMove?: (event: Konva.KonvaEventObject<DragEvent>) => void\n\t\tonDragEnd?: (event: Konva.KonvaEventObject<DragEvent>) => void\n\t}\nconst constructors = {\n\tLayer: Konva.Layer,\n\tGroup: Konva.Group,\n\tRect: Konva.Rect,\n\tCircle: Konva.Circle,\n\tEllipse: Konva.Ellipse,\n\tLine: Konva.Line,\n\tText: Konva.Text,\n\tImage: Konva.Image,\n\tPath: Konva.Path,\n\tStar: Konva.Star,\n\tTransformer: Konva.Transformer,\n}\nfunction suspendNode(node: Konva.Node): () => void {\n\tconst listening = node.listening()\n\tconst draggable = node.draggable()\n\tnode.listening(false)\n\t// The public setter clears both pending and active native drag records.\n\tnode.draggable(false)\n\treturn () => {\n\t\tnode.listening(listening)\n\t\tnode.draggable(draggable)\n\t}\n}\nfunction updateNode(\n\tnode: Konva.Node,\n\tprops: Record<string, any>,\n\tprevious: Record<string, any>,\n): void {\n\tfor (const key of new Set([...Object.keys(previous), ...Object.keys(props)])) {\n\t\tif (/^(key|children|ref)$/.test(key) || Object.is(props[key], previous[key]))\n\t\t\tcontinue\n\t\tif (key.startsWith(`on`)) {\n\t\t\tconst event = key.slice(2).toLowerCase()\n\t\t\tif (previous[key]) node.off(event, previous[key])\n\t\t\tif (props[key]) node.on(event, props[key])\n\t\t} else node.setAttr(key, props[key])\n\t}\n}\nconst renderer = createSceneRenderer<Konva.Node>({\n\ttarget(node) {\n\t\treturn {\n\t\t\tkind: `konva`,\n\t\t\tnode,\n\t\t\tsuspend() {\n\t\t\t\treturn suspendNode(node)\n\t\t\t},\n\t\t\tread: (key) => node.getAttr(key),\n\t\t\twrite: (key, value) => {\n\t\t\t\tnode.setAttr(key, value)\n\t\t\t},\n\t\t\tlisten(event, listener) {\n\t\t\t\tnode.on(event, listener)\n\t\t\t\treturn () => {\n\t\t\t\t\tnode.off(event, listener)\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t},\n\tcreate(type) {\n\t\tconst Constructor = constructors[type as keyof typeof constructors]\n\t\tif (!Constructor) throw new Error(`spa/konva: unknown node ${type}`)\n\t\treturn new Constructor({} as any)\n\t},\n\tupdate: updateNode,\n\tchildren(parent, children) {\n\t\tif (children.length && !(parent instanceof Konva.Container))\n\t\t\tthrow new Error(`spa/konva: shapes cannot contain children`)\n\t\tif (parent instanceof Konva.Container) {\n\t\t\tfor (const child of [...parent.getChildren()])\n\t\t\t\tif (!children.includes(child)) child.remove()\n\t\t\tchildren.forEach((child, index) => {\n\t\t\t\tif (child.getParent() !== parent) parent.add(child as any)\n\t\t\t\tchild.zIndex(index)\n\t\t\t})\n\t\t}\n\t},\n\tdestroy(node) {\n\t\tnode.off()\n\t\tnode.destroy()\n\t},\n})\n\n/** A DOM boundary owning a Konva stage and its scene subtree. */\nexport function Stage(\n\tprops: Props<Omit<Konva.StageConfig, `container`>, Konva.Stage> & {\n\t\twidth?: number\n\t\theight?: number\n\t},\n): VNode {\n\tlet container: HTMLDivElement | null = null\n\tonMount(() => {\n\t\t// Konva clears its container; preserve SPA's markers in the outer element.\n\t\tconst surface = container!.ownerDocument.createElement(`div`)\n\t\tcontainer!.append(surface)\n\t\tonCleanup(() => {\n\t\t\tsurface.remove()\n\t\t})\n\t\tconst stage = new Konva.Stage({\n\t\t\tcontainer: surface,\n\t\t\twidth: props.width ?? 300,\n\t\t\theight: props.height ?? 150,\n\t\t})\n\t\tonCleanup(() => {\n\t\t\tstage.off()\n\t\t\tstage.destroy()\n\t\t})\n\t\tconst nativeProps = capabilityProps(\n\t\t\towner!,\n\t\t\t{\n\t\t\t\tkind: `konva`,\n\t\t\t\tnode: stage,\n\t\t\t\tsuspend() {\n\t\t\t\t\treturn suspendNode(stage)\n\t\t\t\t},\n\t\t\t\tlisten(event, listener) {\n\t\t\t\t\tstage.on(event, listener)\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tstage.off(event, listener)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tread: (key) => stage.getAttr(key),\n\t\t\t\twrite: (key, value) => {\n\t\t\t\t\tstage.setAttr(key, value)\n\t\t\t\t},\n\t\t\t},\n\t\t\t() => ({ ...props }),\n\t\t)\n\t\tlet previous: Record<string, any> = {}\n\t\tbindScene(\n\t\t\t() => ({ ...props }),\n\t\t\t(all) => {\n\t\t\t\tconst next = nativeProps(all)\n\t\t\t\tupdateNode(stage, next, previous)\n\t\t\t\tprevious = next\n\t\t\t},\n\t\t)\n\t\tprops.ref?.(stage)\n\t\tonCleanup(() => props.ref?.(null))\n\t\trenderer.mount(() => props.children, stage)\n\t})\n\treturn jsx(`div`, {\n\t\tref: (element: HTMLDivElement | null) => {\n\t\t\tcontainer = element\n\t\t},\n\t})\n}\nexport const Layer =\n\tsceneComponent<Props<Konva.LayerConfig, Konva.Layer>>(`Layer`)\nexport const Group =\n\tsceneComponent<Props<Konva.ContainerConfig, Konva.Group>>(`Group`)\nexport const Rect = sceneComponent<Props<Konva.RectConfig, Konva.Rect>>(`Rect`)\nexport const Circle =\n\tsceneComponent<Props<Konva.CircleConfig, Konva.Circle>>(`Circle`)\nexport const Ellipse =\n\tsceneComponent<Props<Konva.EllipseConfig, Konva.Ellipse>>(`Ellipse`)\nexport const Line = sceneComponent<Props<Konva.LineConfig, Konva.Line>>(`Line`)\nexport const Text = sceneComponent<Props<Konva.TextConfig, Konva.Text>>(`Text`)\nexport const Image =\n\tsceneComponent<Props<Konva.ImageConfig, Konva.Image>>(`Image`)\nexport const Path = sceneComponent<Props<Konva.PathConfig, Konva.Path>>(`Path`)\nexport const Star = sceneComponent<Props<Konva.StarConfig, Konva.Star>>(`Star`)\nexport const Transformer =\n\tsceneComponent<Props<Konva.TransformerConfig, Konva.Transformer>>(\n\t\t`Transformer`,\n\t)\nexport { renderer as konvaRenderer }\n"],"mappings":";;;;;;AAmBA,MAAM,eAAe;CACpB,OAAO,MAAM;CACb,OAAO,MAAM;CACb,MAAM,MAAM;CACZ,QAAQ,MAAM;CACd,SAAS,MAAM;CACf,MAAM,MAAM;CACZ,MAAM,MAAM;CACZ,OAAO,MAAM;CACb,MAAM,MAAM;CACZ,MAAM,MAAM;CACZ,aAAa,MAAM;AACpB;AACA,SAAS,YAAY,MAA8B;CAClD,MAAM,YAAY,KAAK,UAAU;CACjC,MAAM,YAAY,KAAK,UAAU;CACjC,KAAK,UAAU,KAAK;CAEpB,KAAK,UAAU,KAAK;CACpB,aAAa;EACZ,KAAK,UAAU,SAAS;EACxB,KAAK,UAAU,SAAS;CACzB;AACD;AACA,SAAS,WACR,MACA,OACA,UACO;CACP,KAAK,MAAM,uBAAO,IAAI,IAAI,CAAC,GAAG,OAAO,KAAK,QAAQ,GAAG,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC,GAAG;EAC7E,IAAI,uBAAuB,KAAK,GAAG,KAAK,OAAO,GAAG,MAAM,MAAM,SAAS,IAAI,GAC1E;EACD,IAAI,IAAI,WAAW,IAAI,GAAG;GACzB,MAAM,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY;GACvC,IAAI,SAAS,MAAM,KAAK,IAAI,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