@atom.io/spa 0.0.8 → 0.0.9

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 (151) hide show
  1. package/README.md +169 -25
  2. package/README.mdx +62 -15
  3. package/dist/astro-application.d.ts +1 -1
  4. package/dist/astro-client.d.ts +1 -1
  5. package/dist/astro-client.d.ts.map +1 -1
  6. package/dist/astro-client.js +5 -4
  7. package/dist/astro-client.js.map +1 -1
  8. package/dist/astro-resumability-client.d.ts +1 -1
  9. package/dist/astro-server.js +4 -4
  10. package/dist/astro-server.js.map +1 -1
  11. package/dist/{astro-shared-83hxw7-M.js → astro-shared-DBwINQav.js} +2 -2
  12. package/dist/{astro-shared-83hxw7-M.js.map → astro-shared-DBwINQav.js.map} +1 -1
  13. package/dist/{astro-shared-DZp1x8RQ.d.ts → astro-shared-KxK9OUSj.d.ts} +2 -2
  14. package/dist/{astro-shared-DZp1x8RQ.d.ts.map → astro-shared-KxK9OUSj.d.ts.map} +1 -1
  15. package/dist/astro.d.ts +1 -1
  16. package/dist/astro.js +1 -1
  17. package/dist/{capabilities-DNcnGRv_.d.ts → capabilities-ChgSs6bp.d.ts} +34 -6
  18. package/dist/capabilities-ChgSs6bp.d.ts.map +1 -0
  19. package/dist/client.min.js +1 -1
  20. package/dist/core-DD2giR6E.js +451 -0
  21. package/dist/core-DD2giR6E.js.map +1 -0
  22. package/dist/development/astro-client.js +5 -4
  23. package/dist/development/astro-client.js.map +1 -1
  24. package/dist/development/astro-server.js +4 -4
  25. package/dist/development/astro-server.js.map +1 -1
  26. package/dist/development/{astro-shared-83hxw7-M.js → astro-shared-DBwINQav.js} +2 -2
  27. package/dist/development/{astro-shared-83hxw7-M.js.map → astro-shared-DBwINQav.js.map} +1 -1
  28. package/dist/development/astro.js +1 -1
  29. package/dist/development/core-DrUd8x25.js +465 -0
  30. package/dist/development/core-DrUd8x25.js.map +1 -0
  31. package/dist/development/{dom-DQ0M3rLL.js → dom-BRFv7FP_.js} +150 -35
  32. package/dist/development/dom-BRFv7FP_.js.map +1 -0
  33. package/dist/development/floating.js +2 -6
  34. package/dist/development/floating.js.map +1 -1
  35. package/dist/development/hot.js +164 -0
  36. package/dist/development/hot.js.map +1 -0
  37. package/dist/development/identity-DwB8MTM1.js +121 -0
  38. package/dist/development/identity-DwB8MTM1.js.map +1 -0
  39. package/dist/development/index.js +5 -5
  40. package/dist/development/jsx-runtime-BGDPK50B.js +49 -0
  41. package/dist/development/jsx-runtime-BGDPK50B.js.map +1 -0
  42. package/dist/development/jsx-runtime.js +1 -25
  43. package/dist/development/konva.js +12 -5
  44. package/dist/development/konva.js.map +1 -1
  45. package/dist/development/motion.js +3 -20
  46. package/dist/development/motion.js.map +1 -1
  47. package/dist/development/renderer.js +41 -40
  48. package/dist/development/renderer.js.map +1 -1
  49. package/dist/development/{server-renderer-DCLoMdOX.js → server-renderer-u1-c5PGd.js} +8 -18
  50. package/dist/development/server-renderer-u1-c5PGd.js.map +1 -0
  51. package/dist/development/server.js +1 -1
  52. package/dist/{src-Bme1kz2b.js → development/src-CB7ruwRs.js} +3 -3
  53. package/dist/development/src-CB7ruwRs.js.map +1 -0
  54. package/dist/development/three.js +20 -19
  55. package/dist/development/three.js.map +1 -1
  56. package/dist/development/vite-WUiz1ju6.js +545 -0
  57. package/dist/development/vite-WUiz1ju6.js.map +1 -0
  58. package/dist/development/vite.js +1 -1
  59. package/dist/{dom-D8g3roX9.js → dom--HZvmgqd.js} +139 -32
  60. package/dist/dom--HZvmgqd.js.map +1 -0
  61. package/dist/floating.d.ts +1 -1
  62. package/dist/floating.d.ts.map +1 -1
  63. package/dist/floating.js +2 -6
  64. package/dist/floating.js.map +1 -1
  65. package/dist/hot.d.ts +15 -0
  66. package/dist/hot.d.ts.map +1 -0
  67. package/dist/hot.js +19 -0
  68. package/dist/hot.js.map +1 -0
  69. package/dist/identity-oFU5p-Qj.js +121 -0
  70. package/dist/identity-oFU5p-Qj.js.map +1 -0
  71. package/dist/{index-BFnXIfOj.d.ts → index-DdA39aMv.d.ts} +4 -4
  72. package/dist/{index-BFnXIfOj.d.ts.map → index-DdA39aMv.d.ts.map} +1 -1
  73. package/dist/index.d.ts +4 -4
  74. package/dist/index.js +5 -5
  75. package/dist/jsx-runtime-BGDPK50B.js +49 -0
  76. package/dist/jsx-runtime-BGDPK50B.js.map +1 -0
  77. package/dist/{jsx-runtime-DQnpyT_g.d.ts → jsx-runtime-CCvcEosg.d.ts} +14 -9
  78. package/dist/jsx-runtime-CCvcEosg.d.ts.map +1 -0
  79. package/dist/jsx-runtime.d.ts +1 -1
  80. package/dist/jsx-runtime.js +1 -25
  81. package/dist/konva.d.ts +46 -9
  82. package/dist/konva.d.ts.map +1 -1
  83. package/dist/konva.js +12 -5
  84. package/dist/konva.js.map +1 -1
  85. package/dist/motion.d.ts +1 -1
  86. package/dist/motion.js +3 -20
  87. package/dist/motion.js.map +1 -1
  88. package/dist/renderer.d.ts +1 -1
  89. package/dist/renderer.d.ts.map +1 -1
  90. package/dist/renderer.js +39 -40
  91. package/dist/renderer.js.map +1 -1
  92. package/dist/{server-renderer-D0rsFL_-.js → server-renderer-BYFDmqnM.js} +8 -18
  93. package/dist/server-renderer-BYFDmqnM.js.map +1 -0
  94. package/dist/server.d.ts +1 -1
  95. package/dist/server.js +1 -1
  96. package/dist/size.json +12 -12
  97. package/dist/{development/src-DoQgCX-O.js → src-B2W_TA_X.js} +3 -3
  98. package/dist/src-B2W_TA_X.js.map +1 -0
  99. package/dist/three.d.ts +3 -3
  100. package/dist/three.d.ts.map +1 -1
  101. package/dist/three.js +20 -19
  102. package/dist/three.js.map +1 -1
  103. package/dist/vite-WUiz1ju6.js +545 -0
  104. package/dist/vite-WUiz1ju6.js.map +1 -0
  105. package/dist/vite.d.ts.map +1 -1
  106. package/dist/vite.js +1 -1
  107. package/package.json +16 -9
  108. package/src/astro-client.ts +3 -2
  109. package/src/astro-server.ts +2 -2
  110. package/src/capabilities.ts +48 -21
  111. package/src/compiler-hmr.ts +297 -0
  112. package/src/compiler.ts +127 -25
  113. package/src/core.ts +282 -33
  114. package/src/dom-forms.ts +127 -0
  115. package/src/dom.ts +116 -52
  116. package/src/floating.ts +2 -6
  117. package/src/hot.ts +190 -0
  118. package/src/identity.ts +39 -0
  119. package/src/index.ts +2 -0
  120. package/src/jsx-runtime.ts +6 -26
  121. package/src/jsx-types.d.ts +8 -3
  122. package/src/konva.ts +66 -10
  123. package/src/presence.ts +11 -23
  124. package/src/props.ts +55 -0
  125. package/src/renderer.ts +91 -71
  126. package/src/server-renderer.ts +18 -13
  127. package/src/three.ts +23 -24
  128. package/src/use-loadable.ts +2 -2
  129. package/src/vite.ts +44 -4
  130. package/dist/capabilities-DNcnGRv_.d.ts.map +0 -1
  131. package/dist/capabilities-nOIitQ-_.js +0 -65
  132. package/dist/capabilities-nOIitQ-_.js.map +0 -1
  133. package/dist/core-B4rJ0xdc.js +0 -268
  134. package/dist/core-B4rJ0xdc.js.map +0 -1
  135. package/dist/development/capabilities-nOIitQ-_.js +0 -65
  136. package/dist/development/capabilities-nOIitQ-_.js.map +0 -1
  137. package/dist/development/core-BHA7I1nf.js +0 -271
  138. package/dist/development/core-BHA7I1nf.js.map +0 -1
  139. package/dist/development/dom-DQ0M3rLL.js.map +0 -1
  140. package/dist/development/jsx-runtime.js.map +0 -1
  141. package/dist/development/server-renderer-DCLoMdOX.js.map +0 -1
  142. package/dist/development/src-DoQgCX-O.js.map +0 -1
  143. package/dist/development/vite-Bmyb6P5w.js +0 -265
  144. package/dist/development/vite-Bmyb6P5w.js.map +0 -1
  145. package/dist/dom-D8g3roX9.js.map +0 -1
  146. package/dist/jsx-runtime-DQnpyT_g.d.ts.map +0 -1
  147. package/dist/jsx-runtime.js.map +0 -1
  148. package/dist/server-renderer-D0rsFL_-.js.map +0 -1
  149. package/dist/src-Bme1kz2b.js.map +0 -1
  150. package/dist/vite-Bmyb6P5w.js +0 -265
  151. package/dist/vite-Bmyb6P5w.js.map +0 -1
@@ -0,0 +1,121 @@
1
+ import { _ as scopeCapabilities, c as isPresent } from "./core-DrUd8x25.js";
2
+ import { packCanonical } from "atom.io/foundations/canonical";
3
+ // src/capabilities.ts
4
+ function capabilityNamespace(key) {
5
+ const colon = key.indexOf(`:`);
6
+ if (colon < 0) return void 0;
7
+ const namespace = key.slice(0, colon);
8
+ return /^(xml|xmlns|xlink)$/.test(namespace) ? void 0 : namespace;
9
+ }
10
+ function requireCapability(capabilities, namespace) {
11
+ const capability = capabilities.get(namespace);
12
+ if (!capability) throw new Error(`spa: capability "${namespace}" is not registered for this root`);
13
+ return capability;
14
+ }
15
+ function validateCapabilities(scope, props) {
16
+ const capabilities = scopeCapabilities(scope);
17
+ for (const key of Object.keys(props)) {
18
+ const namespace = capabilityNamespace(key);
19
+ if (namespace) requireCapability(capabilities, namespace);
20
+ }
21
+ }
22
+ /** Separate framework properties from native attributes and own their bindings. */
23
+ function capabilityProps(scope, target, read, applyNative) {
24
+ const root = scope._root;
25
+ const bindings = /* @__PURE__ */ new Map();
26
+ let handlers;
27
+ const event = (handler) => {
28
+ const cache = handlers ??= /* @__PURE__ */ new WeakMap();
29
+ let wrapped = cache.get(handler);
30
+ if (!wrapped) {
31
+ wrapped = function(...args) {
32
+ if (!root._presence || isPresent(scope)) return handler.apply(this, args);
33
+ };
34
+ cache.set(handler, wrapped);
35
+ }
36
+ return wrapped;
37
+ };
38
+ if (root._presence) root._presence.target(scope, target);
39
+ else (scope._targets ??= /* @__PURE__ */ new Set()).add(target);
40
+ const cleanup = () => {
41
+ const errors = [];
42
+ for (const binding of [...bindings.values()].reverse()) try {
43
+ binding.dispose();
44
+ } catch (error) {
45
+ errors.push(error);
46
+ }
47
+ bindings.clear();
48
+ if (errors.length) throw new AggregateError(errors);
49
+ };
50
+ scope._cleanups.add(cleanup);
51
+ return (props) => {
52
+ const capabilities = scopeCapabilities(scope);
53
+ const native = {};
54
+ const groups = /* @__PURE__ */ new Map();
55
+ for (const key of Object.keys(props)) {
56
+ const namespace = capabilityNamespace(key);
57
+ if (!namespace) {
58
+ const value = props[key];
59
+ native[key] = key.startsWith(`on`) && typeof value === `function` ? event(value) : value;
60
+ continue;
61
+ }
62
+ const capability = requireCapability(capabilities, namespace);
63
+ const group = groups.get(capability) ?? {};
64
+ group[key.slice(namespace.length + 1)] = props[key];
65
+ groups.set(capability, group);
66
+ }
67
+ const previousStyle = applyNative?.(native);
68
+ for (const [capability, values] of groups) {
69
+ let binding = bindings.get(capability);
70
+ if (!binding) {
71
+ binding = capability.attach(target, scope);
72
+ bindings.set(capability, binding);
73
+ root._presence?.bind(scope, binding, read ?? (() => props), capability.namespace);
74
+ }
75
+ if (previousStyle !== void 0) binding.update(values, previousStyle);
76
+ else binding.update(values);
77
+ }
78
+ for (const [capability, binding] of bindings) if (!groups.has(capability)) {
79
+ bindings.delete(capability);
80
+ root._presence?.unbind(binding);
81
+ binding.dispose();
82
+ }
83
+ return native;
84
+ };
85
+ }
86
+ // src/identity.ts
87
+ function childProps(value) {
88
+ return value?.props;
89
+ }
90
+ function hasKey(value) {
91
+ if (Array.isArray(value)) return value.some(hasKey);
92
+ const props = childProps(value);
93
+ return props !== void 0 && Object.hasOwn(props, `key`);
94
+ }
95
+ /** Direct output opts into key tracking when it first mounts. */
96
+ function trackKeys(value) {
97
+ return hasKey(value) ? () => value : value;
98
+ }
99
+ function identifyChildren(output, duplicate = `spa: duplicate key`) {
100
+ const values = [output].flat(Infinity);
101
+ const seen = /* @__PURE__ */ new Set();
102
+ return values.map((value, index) => {
103
+ const key = childProps(value)?.[`key`];
104
+ if (key === void 0) return {
105
+ value,
106
+ key,
107
+ id: index
108
+ };
109
+ const id = packCanonical(key);
110
+ if (seen.has(id)) throw new Error(duplicate);
111
+ seen.add(id);
112
+ return {
113
+ value,
114
+ key,
115
+ id
116
+ };
117
+ });
118
+ }
119
+ export { validateCapabilities as a, capabilityProps as i, trackKeys as n, capabilityNamespace as r, identifyChildren as t };
120
+
121
+ //# sourceMappingURL=identity-DwB8MTM1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-DwB8MTM1.js","names":[],"sources":["../../src/capabilities.ts","../../src/identity.ts"],"sourcesContent":["import type { Cleanup, Root, Scope } from \"./core.ts\"\nimport { isPresent, scopeCapabilities } 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\t/** Inline CSS before native style replacement, for restoring capability-owned values. */\n\tupdate(props: Record<string, unknown>, previousStyle?: string): void\n\tdispose(): void\n}\nexport interface Capability {\n\tnamespace: string\n\t/** Prepare a synchronous update batch and return its commit callback. */\n\tbeforeUpdate?(root: Root): Cleanup\n\tpresence?(root: Root): PresenceCoordinator\n\tscheduleFrame?(callback: (time: number) => void): Cleanup\n\t/** SPA supplies ownership for integrations that measure after mount or report async errors. */\n\tattach(target: CapabilityTarget, scope?: Scope): CapabilityBinding\n}\ntype EventHandler = (this: unknown, ...args: unknown[]) => unknown\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}\nfunction requireCapability(\n\tcapabilities: Map<string, Capability>,\n\tnamespace: string,\n) {\n\tconst capability = capabilities.get(namespace)\n\tif (!capability)\n\t\tthrow new Error(\n\t\t\t`spa: capability \"${namespace}\" is not registered for this root`,\n\t\t)\n\treturn capability\n}\nexport function validateCapabilities(\n\tscope: Scope,\n\tprops: Record<string, unknown>,\n): void {\n\tconst capabilities = scopeCapabilities(scope)\n\tfor (const key of Object.keys(props)) {\n\t\tconst namespace = capabilityNamespace(key)\n\t\tif (namespace) requireCapability(capabilities, namespace)\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\tapplyNative?: (props: Record<string, any>) => string | undefined,\n): (props: Record<string, any>) => Record<string, any> {\n\tconst root = scope._root\n\tconst bindings = new Map<Capability, CapabilityBinding>()\n\tlet handlers: WeakMap<EventHandler, EventHandler> | undefined\n\tconst event = (handler: EventHandler) => {\n\t\tconst cache = (handlers ??= new WeakMap())\n\t\tlet wrapped = cache.get(handler)\n\t\tif (!wrapped) {\n\t\t\twrapped = function (this: unknown, ...args: unknown[]) {\n\t\t\t\t// Presence may activate after this listener mounts.\n\t\t\t\tif (!root._presence || isPresent(scope)) return handler.apply(this, args)\n\t\t\t}\n\t\t\tcache.set(handler, wrapped)\n\t\t}\n\t\treturn wrapped\n\t}\n\n\tif (root._presence) root._presence.target(scope, target)\n\telse (scope._targets ??= new Set()).add(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\tconst capabilities = scopeCapabilities(scope)\n\t\tconst native: Record<string, any> = {}\n\t\tconst groups = new Map<Capability, 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? event(value)\n\t\t\t\t\t\t: value\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst capability = requireCapability(capabilities, namespace)\n\t\t\tconst group = groups.get(capability) ?? {}\n\t\t\tgroup[key.slice(namespace.length + 1)] = props[key]\n\t\t\tgroups.set(capability, group)\n\t\t}\n\t\tconst previousStyle = applyNative?.(native)\n\t\tfor (const [capability, values] of groups) {\n\t\t\tlet binding = bindings.get(capability)\n\t\t\tif (!binding) {\n\t\t\t\tbinding = capability.attach(target, scope)\n\t\t\t\tbindings.set(capability, binding)\n\t\t\t\troot._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\tcapability.namespace,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (previousStyle !== undefined) binding.update(values, previousStyle)\n\t\t\telse binding.update(values)\n\t\t}\n\t\tfor (const [capability, binding] of bindings)\n\t\t\tif (!groups.has(capability)) {\n\t\t\t\tbindings.delete(capability)\n\t\t\t\troot._presence?.unbind(binding)\n\t\t\t\tbinding.dispose()\n\t\t\t}\n\t\treturn native\n\t}\n}\n","import type { Canonical } from \"atom.io/foundations/canonical\"\nimport { packCanonical } from \"atom.io/foundations/canonical\"\n\nimport type { Children, SpaElement } from \"./core.ts\"\n\ntype Props = SpaElement[`props`]\ntype Key = Canonical | undefined\ntype Identity = string | number\n\nfunction childProps(value: Children): Props | undefined {\n\treturn (value as SpaElement | null)?.props\n}\n\nfunction hasKey(value: Children): boolean {\n\tif (Array.isArray(value)) return value.some(hasKey)\n\tconst props = childProps(value)\n\treturn props !== undefined && Object.hasOwn(props, `key`)\n}\n\n/** Direct output opts into key tracking when it first mounts. */\nexport function trackKeys(value: Children): Children {\n\treturn hasKey(value) ? () => value : value\n}\n\nexport function identifyChildren(\n\toutput: Children,\n\tduplicate = `spa: duplicate key`,\n): { value: Children; key: Key; id: Identity }[] {\n\tconst values = ([output] as unknown[]).flat(Infinity) as Children[]\n\tconst seen = new Set<string>()\n\treturn values.map((value, index) => {\n\t\tconst key: Key = childProps(value)?.[`key`]\n\t\tif (key === undefined) return { value, key, id: index }\n\t\tconst id = packCanonical(key)\n\t\tif (seen.has(id)) throw new Error(duplicate)\n\t\tseen.add(id)\n\t\treturn { value, key, id }\n\t})\n}\n"],"mappings":";;;AA+BA,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,SAAS,kBACR,cACA,WACC;CACD,MAAM,aAAa,aAAa,IAAI,SAAS;CAC7C,IAAI,CAAC,YACJ,MAAM,IAAI,MACT,oBAAoB,UAAU,kCAC/B;CACD,OAAO;AACR;AACA,SAAgB,qBACf,OACA,OACO;CACP,MAAM,eAAe,kBAAkB,KAAK;CAC5C,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EACrC,MAAM,YAAY,oBAAoB,GAAG;EACzC,IAAI,WAAW,kBAAkB,cAAc,SAAS;CACzD;AACD;;AAGA,SAAgB,gBACf,OACA,QACA,MACA,aACsD;CACtD,MAAM,OAAO,MAAM;CACnB,MAAM,2BAAW,IAAI,IAAmC;CACxD,IAAI;CACJ,MAAM,SAAS,YAA0B;EACxC,MAAM,QAAS,6BAAa,IAAI,QAAQ;EACxC,IAAI,UAAU,MAAM,IAAI,OAAO;EAC/B,IAAI,CAAC,SAAS;GACb,UAAU,SAAyB,GAAG,MAAiB;IAEtD,IAAI,CAAC,KAAK,aAAa,UAAU,KAAK,GAAG,OAAO,QAAQ,MAAM,MAAM,IAAI;GACzE;GACA,MAAM,IAAI,SAAS,OAAO;EAC3B;EACA,OAAO;CACR;CAEA,IAAI,KAAK,WAAW,KAAK,UAAU,OAAO,OAAO,MAAM;MAClD,CAAC,MAAM,6BAAa,IAAI,IAAI,EAAA,CAAG,IAAI,MAAM;CAC9C,MAAM,gBAAyB;EAC9B,MAAM,SAAoB,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AAK,WAAW,OAAO,OAAO;GAC9B,QAAQ,QAAQ;EACjB;EACD,OAAO;CACR;AACD;;ACnIA,SAAS,WAAW,OAAoC;CACvD,OAAQ,OAA6B;AACtC;AAEA,SAAS,OAAO,OAA0B;CACzC,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,MAAM;CAClD,MAAM,QAAQ,WAAW,KAAK;CAC9B,OAAO,UAAU,KAAA,KAAa,OAAO,OAAO,OAAO,KAAK;AACzD;;AAGA,SAAgB,UAAU,OAA2B;CACpD,OAAO,OAAO,KAAK,UAAU,QAAQ;AACtC;AAEA,SAAgB,iBACf,QACA,YAAY,sBACoC;CAChD,MAAM,SAAU,CAAC,MAAM,CAAC,CAAe,KAAK,QAAQ;CACpD,MAAM,uBAAO,IAAI,IAAY;CAC7B,OAAO,OAAO,KAAK,OAAO,UAAU;EACnC,MAAM,MAAW,WAAW,KAAK,CAAC,GAAG;EACrC,IAAI,QAAQ,KAAA,GAAW,OAAO;GAAE;GAAO;GAAK,IAAI;EAAM;EACtD,MAAM,KAAK,cAAc,GAAG;EAC5B,IAAI,KAAK,IAAI,EAAE,GAAG,MAAM,IAAI,MAAM,SAAS;EAC3C,KAAK,IAAI,EAAE;EACX,OAAO;GAAE;GAAO;GAAK;EAAG;CACzB,CAAC;AACF"}
@@ -1,5 +1,5 @@
1
- import { _ as useRef, b as useTimeline, c as onCleanup, g as useId, h as useGetter, l as onMount, m as useDisposal, v as useSetter, x as useTransaction, y as useStore } from "./core-BHA7I1nf.js";
2
- import { Fragment } from "./jsx-runtime.js";
3
- import { n as render, t as hydrate } from "./dom-DQ0M3rLL.js";
4
- import { t as useLoadable } from "./src-DoQgCX-O.js";
5
- export { Fragment, hydrate, onCleanup, onMount, render, useDisposal, useGetter, useId, useLoadable, useRef, useSetter, useStore, useTimeline, useTransaction };
1
+ import { C as useSetter, E as useTransaction, S as useRef, T as useTimeline, b as useGetter, d as onCommit, f as onMount, t as RootBoundary, u as onCleanup, w as useStore, x as useId, y as useDisposal } from "./core-DrUd8x25.js";
2
+ import { n as render, t as hydrate } from "./dom-BRFv7FP_.js";
3
+ import { t as Fragment } from "./jsx-runtime-BGDPK50B.js";
4
+ import { t as useLoadable } from "./src-CB7ruwRs.js";
5
+ export { Fragment, RootBoundary as Root, hydrate, onCleanup, onCommit, onMount, render, useDisposal, useGetter, useId, useLoadable, useRef, useSetter, useStore, useTimeline, useTransaction };
@@ -0,0 +1,49 @@
1
+ // src/props.ts
2
+ function liveProps(values, fixedKey) {
3
+ const source = (name) => values().reverse().find((props) => Object.hasOwn(props, name));
4
+ const has = (_, name) => fixedKey && name === `key` ? fixedKey.present : source(name) !== void 0;
5
+ return new Proxy({}, {
6
+ has,
7
+ get(_, name) {
8
+ if (fixedKey && name === `key`) return fixedKey.value;
9
+ const props = source(name);
10
+ return props && Reflect.get(props, name);
11
+ },
12
+ ownKeys() {
13
+ const keys = new Set(values().flatMap(Object.keys));
14
+ if (fixedKey?.present) keys.add(`key`);
15
+ else if (fixedKey) keys.delete(`key`);
16
+ return [...keys];
17
+ },
18
+ getOwnPropertyDescriptor(_, name) {
19
+ if (has(_, name)) return {
20
+ enumerable: true,
21
+ configurable: true
22
+ };
23
+ }
24
+ });
25
+ }
26
+ /** Preserve lazy props and spread precedence, including keys added by later updates. */
27
+ function merge(...sources) {
28
+ return liveProps(() => sources.map((source) => (typeof source === `function` ? source() : source) ?? {}));
29
+ }
30
+ /** Expose the first key while leaving data props live, including through spreads. */
31
+ function instanceProps(read, key) {
32
+ return liveProps(() => [read()], {
33
+ value: key,
34
+ present: key !== void 0 || Object.hasOwn(read(), `key`)
35
+ });
36
+ }
37
+ // src/jsx-runtime.ts
38
+ const Fragment = (props) => props.children;
39
+ function jsx(type, props, key) {
40
+ return {
41
+ type,
42
+ props: key === void 0 ? props ?? {} : merge(props ?? {}, { key })
43
+ };
44
+ }
45
+ const jsxs = jsx;
46
+ const jsxDEV = jsx;
47
+ export { instanceProps as a, jsxs as i, jsx as n, merge as o, jsxDEV as r, Fragment as t };
48
+
49
+ //# sourceMappingURL=jsx-runtime-BGDPK50B.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime-BGDPK50B.js","names":[],"sources":["../../src/props.ts","../../src/jsx-runtime.ts"],"sourcesContent":["import type { Canonical } from \"atom.io/foundations/canonical\"\n\nimport type { SpaElement } from \"./core.ts\"\n\ntype Props = SpaElement[`props`]\ntype FixedKey = { value: Canonical | undefined; present: boolean }\n\nfunction liveProps(values: () => Props[], fixedKey?: FixedKey): Props {\n\tconst source = (name: PropertyKey) =>\n\t\tvalues()\n\t\t\t.reverse()\n\t\t\t.find((props) => Object.hasOwn(props, name))\n\tconst has = (_: Props, name: PropertyKey): boolean =>\n\t\tfixedKey && name === `key` ? fixedKey.present : source(name) !== undefined\n\treturn new Proxy(\n\t\t{},\n\t\t{\n\t\t\thas,\n\t\t\tget(_, name) {\n\t\t\t\tif (fixedKey && name === `key`) return fixedKey.value\n\t\t\t\tconst props = source(name)\n\t\t\t\treturn props && Reflect.get(props, name)\n\t\t\t},\n\t\t\townKeys() {\n\t\t\t\tconst keys = new Set(values().flatMap(Object.keys))\n\t\t\t\tif (fixedKey?.present) keys.add(`key`)\n\t\t\t\telse if (fixedKey) keys.delete(`key`)\n\t\t\t\treturn [...keys]\n\t\t\t},\n\t\t\tgetOwnPropertyDescriptor(_, name) {\n\t\t\t\tif (has(_, name)) return { enumerable: true, configurable: true }\n\t\t\t},\n\t\t},\n\t)\n}\n\n/** Preserve lazy props and spread precedence, including keys added by later updates. */\nexport function merge(...sources: (Props | (() => Props))[]): Props {\n\treturn liveProps(() =>\n\t\tsources.map(\n\t\t\t(source) => (typeof source === `function` ? source() : source) ?? {},\n\t\t),\n\t)\n}\n\n/** Expose the first key while leaving data props live, including through spreads. */\nexport function instanceProps(\n\tread: () => Props,\n\tkey: Canonical | undefined,\n): Props {\n\treturn liveProps(() => [read()], {\n\t\tvalue: key,\n\t\tpresent: key !== undefined || Object.hasOwn(read(), `key`),\n\t})\n}\n","import type { Canonical } from \"atom.io/foundations/canonical\"\n\nimport type { Children, Component, SpaElement } from \"./core.ts\"\nimport type { HTMLAttributes, NativeElements } from \"./jsx-types.d.ts\"\nimport { merge } from \"./props.ts\"\n\nexport type {\n\tAriaAttributes,\n\tDOMAttributes,\n\tEventAttributes,\n\tEventHandler,\n\tHTMLAttributes,\n\tRef,\n\tSVGAttributes,\n\tTargetedEvent,\n} from \"./jsx-types.d.ts\"\nexport { merge } from \"./props.ts\"\n\n/** Optional integrations augment attributes without changing element identity. */\n// oxlint-disable-next-line typescript/no-empty-interface -- Optional integrations augment this declaration.\nexport interface CapabilityAttributes<Kind extends string = string> {}\n\nexport const Fragment = (props: { children?: Children }): Children =>\n\tprops.children\nexport function jsx(\n\ttype: SpaElement[`type`],\n\tprops: SpaElement[`props`] | null,\n\tkey?: Canonical,\n): SpaElement {\n\treturn {\n\t\ttype,\n\t\tprops: key === undefined ? (props ?? {}) : merge(props ?? {}, { key }),\n\t}\n}\nexport const jsxs = jsx\nexport const jsxDEV = jsx\n\nexport namespace JSX {\n\texport type Element = SpaElement\n\texport type ElementType = keyof IntrinsicElements | Component\n\texport interface ElementChildrenAttribute {\n\t\tchildren: {}\n\t}\n\texport interface IntrinsicAttributes {\n\t\tkey?: Canonical | undefined\n\t}\n\t/** Augment this interface to declare attributes for registered custom elements. */\n\texport interface IntrinsicElements extends NativeElements {\n\t\t[tag: `${string}-${string}`]: HTMLAttributes<HTMLElement>\n\t}\n}\n"],"mappings":";AAOA,SAAS,UAAU,QAAuB,UAA4B;CACrE,MAAM,UAAU,SACf,OAAO,CAAC,CACN,QAAQ,CAAC,CACT,MAAM,UAAU,OAAO,OAAO,OAAO,IAAI,CAAC;CAC7C,MAAM,OAAO,GAAU,SACtB,YAAY,SAAS,QAAQ,SAAS,UAAU,OAAO,IAAI,MAAM,KAAA;CAClE,OAAO,IAAI,MACV,CAAC,GACD;EACC;EACA,IAAI,GAAG,MAAM;GACZ,IAAI,YAAY,SAAS,OAAO,OAAO,SAAS;GAChD,MAAM,QAAQ,OAAO,IAAI;GACzB,OAAO,SAAS,QAAQ,IAAI,OAAO,IAAI;EACxC;EACA,UAAU;GACT,MAAM,OAAO,IAAI,IAAI,OAAO,CAAC,CAAC,QAAQ,OAAO,IAAI,CAAC;GAClD,IAAI,UAAU,SAAS,KAAK,IAAI,KAAK;QAChC,IAAI,UAAU,KAAK,OAAO,KAAK;GACpC,OAAO,CAAC,GAAG,IAAI;EAChB;EACA,yBAAyB,GAAG,MAAM;GACjC,IAAI,IAAI,GAAG,IAAI,GAAG,OAAO;IAAE,YAAY;IAAM,cAAc;GAAK;EACjE;CACD,CACD;AACD;;AAGA,SAAgB,MAAM,GAAG,SAA2C;CACnE,OAAO,gBACN,QAAQ,KACN,YAAY,OAAO,WAAW,aAAa,OAAO,IAAI,WAAW,CAAC,CACpE,CACD;AACD;;AAGA,SAAgB,cACf,MACA,KACQ;CACR,OAAO,gBAAgB,CAAC,KAAK,CAAC,GAAG;EAChC,OAAO;EACP,SAAS,QAAQ,KAAA,KAAa,OAAO,OAAO,KAAK,GAAG,KAAK;CAC1D,CAAC;AACF;;AChCA,MAAa,YAAY,UACxB,MAAM;AACP,SAAgB,IACf,MACA,OACA,KACa;CACb,OAAO;EACN;EACA,OAAO,QAAQ,KAAA,IAAa,SAAS,CAAC,IAAK,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC;CACtE;AACD;AACA,MAAa,OAAO;AACpB,MAAa,SAAS"}
@@ -1,25 +1 @@
1
- // src/jsx-runtime.ts
2
- const Fragment = (props) => props.children;
3
- function jsx(type, props, key) {
4
- return {
5
- type,
6
- props: key === void 0 ? props ?? {} : merge(props ?? {}, { key })
7
- };
8
- }
9
- const jsxs = jsx;
10
- const jsxDEV = jsx;
11
- /** Preserve lazy props and spread precedence, including keys added by later updates. */
12
- function merge(...sources) {
13
- const values = () => sources.map((source) => (typeof source === `function` ? source() : source) ?? {});
14
- return new Proxy({}, {
15
- get: (_, key) => values().reverse().find((source) => Object.hasOwn(source, key))?.[key],
16
- ownKeys: () => [...new Set(values().flatMap(Object.keys))],
17
- getOwnPropertyDescriptor: (_, key) => values().some((source) => Object.hasOwn(source, key)) ? {
18
- enumerable: true,
19
- configurable: true
20
- } : void 0
21
- });
22
- }
23
- export { Fragment, jsx, jsxDEV, jsxs, merge };
24
-
25
- //# sourceMappingURL=jsx-runtime.js.map
1
+ export { t as Fragment, n as jsx, r as jsxDEV, i as jsxs, o as merge } from "./jsx-runtime-BGDPK50B.js";
@@ -1,6 +1,6 @@
1
- import { n as capabilityProps } from "./capabilities-nOIitQ-_.js";
2
- import { c as onCleanup, l as onMount, u as owner } from "./core-BHA7I1nf.js";
3
- import { jsx } from "./jsx-runtime.js";
1
+ import { i as capabilityProps } from "./identity-DwB8MTM1.js";
2
+ import { f as onMount, p as owner, u as onCleanup } from "./core-DrUd8x25.js";
3
+ import { n as jsx } from "./jsx-runtime-BGDPK50B.js";
4
4
  import { bindScene, createSceneRenderer, sceneComponent } from "./renderer.js";
5
5
  import Konva from "konva";
6
6
  // src/konva.ts
@@ -66,11 +66,18 @@ const renderer = createSceneRenderer({
66
66
  children(parent, children) {
67
67
  if (children.length && !(parent instanceof Konva.Container)) throw new Error(`spa/konva: shapes cannot contain children`);
68
68
  if (parent instanceof Konva.Container) {
69
- for (const child of [...parent.getChildren()]) if (!children.includes(child)) child.remove();
69
+ const current = parent.getChildren();
70
+ if (current.length === children.length && children.every((child, index) => child === current[index])) return;
71
+ const wanted = new Set(children);
72
+ for (const child of [...current]) if (!wanted.has(child)) child.remove();
70
73
  children.forEach((child, index) => {
71
74
  if (child.getParent() !== parent) parent.add(child);
72
- child.zIndex(index);
75
+ if (parent instanceof Konva.Stage && child.zIndex() !== index) child.zIndex(index);
73
76
  });
77
+ if (!(parent instanceof Konva.Stage)) {
78
+ parent.children = [...children];
79
+ parent._setChildrenIndices();
80
+ }
74
81
  }
75
82
  },
76
83
  destroy(node) {
@@ -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 { Children, SpaElement } 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?: Children\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): SpaElement {\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,OAAO,SAAS,IAAI;GAChD,IAAI,MAAM,MAAM,KAAK,GAAG,OAAO,MAAM,IAAI;EAC1C,OAAO,KAAK,QAAQ,KAAK,MAAM,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gB;GACf,MAAM,IAAI;GACV,MAAM,QAAQ;EACf,CAAC;EACD,MAAM,cAAc,gBACnB,OACA;GACC,MAAM;GACN,MAAM;GACN,UAAU;IACT,OAAO,YAAY,KAAK;GACzB;GACA,OAAO,OAAO,UAAU;IACvB,MAAM,GAAG,OAAO,QAAQ;IACxB,aAAa;KACZ,MAAM,IAAI,OAAO,QAAQ;IAC1B;GACD;GACA,OAAO,QAAQ,MAAM,QAAQ,GAAG;GAChC,QAAQ,KAAK,UAAU;IACtB,MAAM,QAAQ,KAAK,KAAK;GACzB;EACD,UACO,EAAE,GAAG,MAAM,EACnB;EACA,IAAI,WAAgC,CAAC;EACrC,iBACQ,EAAE,GAAG,MAAM,KACjB,QAAQ;GACR,MAAM,OAAO,YAAY,GAAG;GAC5B,WAAW,OAAO,MAAM,QAAQ;GAChC,WAAW;EACZ,CACD;EACA,MAAM,MAAM,KAAK;EACjB,gBAAgB,MAAM,MAAM,IAAI,CAAC;EACjC,SAAS,YAAY,MAAM,UAAU,KAAK;CAC3C,CAAC;CACD,OAAO,IAAI,OAAO,EACjB,MAAM,YAAmC;EACxC,YAAY;CACb,EACD,CAAC;AACF;AACA,MAAa,QACZ,eAAsD,OAAO;AAC9D,MAAa,QACZ,eAA0D,OAAO;AAClE,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,SACZ,eAAwD,QAAQ;AACjE,MAAa,UACZ,eAA0D,SAAS;AACpE,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,OAAO,eAAoD,MAAM;AAC9E,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 { Children, SpaElement } 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 InteractionEvent = MouseEvent | TouchEvent | PointerEvent\ninterface Events {\n\tonClick: MouseEvent\n\tonDblClick: MouseEvent\n\tonMouseDown: MouseEvent\n\tonMouseUp: MouseEvent\n\tonMouseMove: MouseEvent\n\tonMouseEnter: MouseEvent\n\tonMouseLeave: MouseEvent\n\tonMouseOver: MouseEvent\n\tonMouseOut: MouseEvent\n\tonContextMenu: PointerEvent\n\tonWheel: WheelEvent\n\tonPointerDown: PointerEvent\n\tonPointerUp: PointerEvent\n\tonPointerMove: PointerEvent\n\tonPointerEnter: PointerEvent\n\tonPointerLeave: PointerEvent\n\tonPointerOver: PointerEvent\n\tonPointerOut: PointerEvent\n\tonPointerCancel: PointerEvent\n\tonPointerClick: PointerEvent\n\tonPointerDblClick: PointerEvent\n\tonGotPointerCapture: PointerEvent\n\tonLostPointerCapture: PointerEvent\n\tonTouchStart: TouchEvent\n\tonTouchMove: TouchEvent\n\tonTouchEnd: TouchEvent\n\tonTouchCancel: TouchEvent\n\tonTap: TouchEvent\n\tonDblTap: TouchEvent\n\tonDragStart: InteractionEvent\n\tonDragMove: InteractionEvent\n\tonDragEnd: InteractionEvent\n\tonTransformStart: InteractionEvent\n\tonTransform: InteractionEvent\n\tonTransformEnd: InteractionEvent | undefined\n}\ntype Config<C> = {\n\t[K in keyof C as string extends K ? never : number extends K ? never : K]: C[K]\n}\ntype Props<C, N extends Konva.Node> = Config<C> & {\n\t[K in keyof Events]?:\n\t\t| ((\n\t\t\t\tevent: Omit<Konva.KonvaEventObject<Events[K]>, `currentTarget`> & {\n\t\t\t\t\treadonly currentTarget: N\n\t\t\t\t},\n\t\t ) => void)\n\t\t| undefined\n} & CapabilityAttributes<`konva`> & {\n\t\tchildren?: Children\n\t\tref?: (node: N | null) => 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\tconst current = parent.getChildren()\n\t\t\tif (\n\t\t\t\tcurrent.length === children.length &&\n\t\t\t\tchildren.every((child, index) => child === current[index])\n\t\t\t)\n\t\t\t\treturn\n\t\t\tconst wanted = new Set(children)\n\t\t\tfor (const child of [...current]) if (!wanted.has(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\t// Layer zIndex also updates the Stage's canvas order.\n\t\t\t\tif (parent instanceof Konva.Stage && child.zIndex() !== index)\n\t\t\t\t\tchild.zIndex(index)\n\t\t\t})\n\t\t\tif (!(parent instanceof Konva.Stage)) {\n\t\t\t\tparent.children = [...children]\n\t\t\t\tparent._setChildrenIndices()\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<Config<Konva.StageConfig>, `container`>, Konva.Stage> & {\n\t\twidth?: number\n\t\theight?: number\n\t},\n): SpaElement {\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,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AAU;EACzB,CAAC;EACD,gBAAgB;GACf,MAAM,IAAI;GACV,MAAM,QAAQ;EACf,CAAC;EACD,MAAM,cAAc,gBACnB,OACA;GACC,MAAM;GACN,MAAM;GACN,UAAU;IACT,OAAO,YAAY,KAAK;GACzB;GACA,OAAO,OAAO,UAAU;IACvB,MAAM,GAAG,OAAO,QAAQ;IACxB,aAAa;KACZ,MAAM,IAAI,OAAO,QAAQ;IAC1B;GACD;GACA,OAAO,QAAQ,MAAM,QAAQ,GAAG;GAChC,QAAQ,KAAK,UAAU;IACtB,MAAM,QAAQ,KAAK,KAAK;GACzB;EACD,UACO,EAAE,GAAG,MAAM,EACnB;EACA,IAAI,WAAgC,CAAC;EACrC,iBACQ,EAAE,GAAG,MAAM,KACjB,QAAQ;GACR,MAAM,OAAO,YAAY,GAAG;GAC5B,WAAW,OAAO,MAAM,QAAQ;GAChC,WAAW;EACZ,CACD;EACA,MAAM,MAAM,KAAK;EACjB,gBAAgB,MAAM,MAAM,IAAI,CAAC;EACjC,SAAS,YAAY,MAAM,UAAU,KAAK;CAC3C,CAAC;CACD,OAAO,IAAI,OAAO,EACjB,MAAM,YAAmC;EACxC,YAAY;CACb,EACD,CAAC;AACF;AACA,MAAa,QACZ,eAAsD,OAAO;AAC9D,MAAa,QACZ,eAA0D,OAAO;AAClE,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,SACZ,eAAwD,QAAQ;AACjE,MAAa,UACZ,eAA0D,SAAS;AACpE,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,QACZ,eAAsD,OAAO;AAC9D,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,OAAO,eAAoD,MAAM;AAC9E,MAAa,cACZ,eACC,aACD"}
@@ -1,4 +1,4 @@
1
- import { S as within, a as invalidate, i as fail, l as onMount, o as isPresent, p as untrack, r as dispose } from "./core-BHA7I1nf.js";
1
+ import { D as within, c as isPresent, f as onMount, h as reportScopeError, i as dispose, o as fail, s as invalidate, v as untrack } from "./core-DrUd8x25.js";
2
2
  import { acquireProjectionNode, animate, cancelFrame, frame, handOffElementState, hover, keyframes, motionValue, press, readStyleValue, styleEffect, visualElementStore } from "motion";
3
3
  // src/motion-layout.ts
4
4
  let serial = 0;
@@ -397,7 +397,6 @@ function animateTween(value, goal, transition, interrupted) {
397
397
  /** Optional coordinator: only imported by integrations that support retention. */
398
398
  function createPresence(root) {
399
399
  const releases = /* @__PURE__ */ new Map();
400
- const handlers = /* @__PURE__ */ new WeakMap();
401
400
  const groups = /* @__PURE__ */ new Map();
402
401
  const sessions = /* @__PURE__ */ new Set();
403
402
  const active = /* @__PURE__ */ new Map();
@@ -430,14 +429,6 @@ function createPresence(root) {
430
429
  for (let at = scope; at; at = at._parent) if (at === parent) return true;
431
430
  return false;
432
431
  };
433
- const report = (error) => {
434
- if (root._dead) return;
435
- try {
436
- fail(root, error);
437
- } catch (failure) {
438
- root.error(failure);
439
- }
440
- };
441
432
  const finish = () => {
442
433
  for (const group of [...groups.values()]) {
443
434
  if (group.scope._dead || group.sessions.some((session) => !session.done)) continue;
@@ -446,7 +437,7 @@ function createPresence(root) {
446
437
  try {
447
438
  group.done();
448
439
  } catch (error) {
449
- report(error);
440
+ if (!root._dead) reportScopeError(group.scope, error);
450
441
  }
451
442
  }
452
443
  };
@@ -485,14 +476,6 @@ function createPresence(root) {
485
476
  unbind(binding) {
486
477
  releases.get(binding)?.();
487
478
  },
488
- event(scope, handler) {
489
- const cached = handlers.get(scope) ?? /* @__PURE__ */ new WeakMap();
490
- handlers.set(scope, cached);
491
- if (!cached.has(handler)) cached.set(handler, function(...args) {
492
- if (isPresent(scope)) return handler.apply(this, args);
493
- });
494
- return cached.get(handler);
495
- },
496
479
  collection(scopeOf, compatible) {
497
480
  let order = [];
498
481
  const exiting = /* @__PURE__ */ new Map();
@@ -561,7 +544,7 @@ function createPresence(root) {
561
544
  held.done = true;
562
545
  finish();
563
546
  }, (error) => {
564
- if (!held.cancelled) report(error);
547
+ if (!held.cancelled && !root._dead) reportScopeError(held.scope, error);
565
548
  });
566
549
  }
567
550
  collected.push(session);