@atom.io/spa 0.0.1 → 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 (124) hide show
  1. package/README.md +254 -6
  2. package/README.mdx +83 -1
  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 +6 -3
  8. package/dist/astro-client.js.map +1 -1
  9. package/dist/astro-server.js +2 -1
  10. package/dist/astro-server.js.map +1 -1
  11. package/dist/astro-shared-BT45auwR.js.map +1 -1
  12. package/dist/{astro-shared-DkZaqX7L.d.ts → astro-shared-BkWvVZWZ.d.ts} +4 -2
  13. package/dist/astro-shared-BkWvVZWZ.d.ts.map +1 -0
  14. package/dist/astro.d.ts +1 -1
  15. package/dist/astro.js +1 -1
  16. package/dist/capabilities-BkQ2i0vV.js +63 -0
  17. package/dist/capabilities-BkQ2i0vV.js.map +1 -0
  18. package/dist/capabilities-CFP-HIuY.d.ts +115 -0
  19. package/dist/capabilities-CFP-HIuY.d.ts.map +1 -0
  20. package/dist/client.min.js +1 -1
  21. package/dist/{core-Dvqm7w2y.js → core-DCmqLZQP.js} +23 -4
  22. package/dist/core-DCmqLZQP.js.map +1 -0
  23. package/dist/development/astro-application.js +2 -2
  24. package/dist/development/astro-application.js.map +1 -1
  25. package/dist/development/astro-client.js +6 -3
  26. package/dist/development/astro-client.js.map +1 -1
  27. package/dist/development/astro-server.js +2 -1
  28. package/dist/development/astro-server.js.map +1 -1
  29. package/dist/development/astro-shared-BT45auwR.js.map +1 -1
  30. package/dist/development/astro.js +1 -1
  31. package/dist/development/capabilities-BkQ2i0vV.js +63 -0
  32. package/dist/development/capabilities-BkQ2i0vV.js.map +1 -0
  33. package/dist/development/{core-DB3sQz4h.js → core-p9vciX9C.js} +23 -4
  34. package/dist/development/core-p9vciX9C.js.map +1 -0
  35. package/dist/development/{dom-D9cY6l1R.js → dom-Ci1XvbVJ.js} +21 -7
  36. package/dist/development/dom-Ci1XvbVJ.js.map +1 -0
  37. package/dist/development/index.js +3 -38
  38. package/dist/development/jsx-runtime.js.map +1 -1
  39. package/dist/development/konva.js +143 -0
  40. package/dist/development/konva.js.map +1 -0
  41. package/dist/development/motion.js +601 -0
  42. package/dist/development/motion.js.map +1 -0
  43. package/dist/development/renderer.js +190 -0
  44. package/dist/development/renderer.js.map +1 -0
  45. package/dist/development/server.js +4 -2
  46. package/dist/development/server.js.map +1 -1
  47. package/dist/development/src-DG0xjuS5.js +38 -0
  48. package/dist/development/src-DG0xjuS5.js.map +1 -0
  49. package/dist/development/three.js +452 -0
  50. package/dist/development/three.js.map +1 -0
  51. package/dist/development/vite-CSHoxzXU.js +240 -0
  52. package/dist/development/vite-CSHoxzXU.js.map +1 -0
  53. package/dist/development/vite.js +1 -1
  54. package/dist/{dom-BR9o9wZW.js → dom-dHQM0O7Q.js} +21 -7
  55. package/dist/dom-dHQM0O7Q.js.map +1 -0
  56. package/dist/index-CJJXcKaw.d.ts +24 -0
  57. package/dist/index-CJJXcKaw.d.ts.map +1 -0
  58. package/dist/index.d.ts +4 -24
  59. package/dist/index.js +3 -38
  60. package/dist/{jsx-runtime-BzGV18VO.d.ts → jsx-runtime-CREZYKDC.d.ts} +6 -4
  61. package/dist/jsx-runtime-CREZYKDC.d.ts.map +1 -0
  62. package/dist/jsx-runtime.d.ts +2 -2
  63. package/dist/jsx-runtime.js.map +1 -1
  64. package/dist/konva.d.ts +32 -0
  65. package/dist/konva.d.ts.map +1 -0
  66. package/dist/konva.js +143 -0
  67. package/dist/konva.js.map +1 -0
  68. package/dist/motion.d.ts +45 -0
  69. package/dist/motion.d.ts.map +1 -0
  70. package/dist/motion.js +601 -0
  71. package/dist/motion.js.map +1 -0
  72. package/dist/renderer.d.ts +24 -0
  73. package/dist/renderer.d.ts.map +1 -0
  74. package/dist/renderer.js +190 -0
  75. package/dist/renderer.js.map +1 -0
  76. package/dist/server.d.ts +1 -1
  77. package/dist/server.d.ts.map +1 -1
  78. package/dist/server.js +4 -2
  79. package/dist/server.js.map +1 -1
  80. package/dist/size.json +16 -16
  81. package/dist/src-DCQa6qxs.js +38 -0
  82. package/dist/src-DCQa6qxs.js.map +1 -0
  83. package/dist/three.d.ts +110 -0
  84. package/dist/three.d.ts.map +1 -0
  85. package/dist/three.js +452 -0
  86. package/dist/three.js.map +1 -0
  87. package/dist/vite-CSHoxzXU.js +240 -0
  88. package/dist/vite-CSHoxzXU.js.map +1 -0
  89. package/dist/vite.js +1 -1
  90. package/package.json +62 -15
  91. package/src/astro-application.ts +2 -2
  92. package/src/astro-client.ts +1 -0
  93. package/src/astro-server.ts +1 -0
  94. package/src/astro-shared.ts +3 -0
  95. package/src/capabilities.ts +107 -0
  96. package/src/compiler.ts +251 -178
  97. package/src/core.ts +38 -2
  98. package/src/dom.ts +38 -4
  99. package/src/index.ts +5 -0
  100. package/src/jsx-runtime.ts +4 -0
  101. package/src/jsx-types.d.ts +3 -1
  102. package/src/konva.ts +186 -0
  103. package/src/motion-tween.ts +106 -0
  104. package/src/motion.ts +519 -0
  105. package/src/presence.ts +324 -0
  106. package/src/renderer.ts +278 -0
  107. package/src/server.ts +3 -0
  108. package/src/three-events.ts +342 -0
  109. package/src/three.ts +373 -0
  110. package/dist/astro-shared-DkZaqX7L.d.ts.map +0 -1
  111. package/dist/core-BhiA9fFi.d.ts +0 -44
  112. package/dist/core-BhiA9fFi.d.ts.map +0 -1
  113. package/dist/core-Dvqm7w2y.js.map +0 -1
  114. package/dist/development/core-DB3sQz4h.js.map +0 -1
  115. package/dist/development/dom-D9cY6l1R.js.map +0 -1
  116. package/dist/development/index.js.map +0 -1
  117. package/dist/development/vite-CQchIQ_-.js +0 -126
  118. package/dist/development/vite-CQchIQ_-.js.map +0 -1
  119. package/dist/dom-BR9o9wZW.js.map +0 -1
  120. package/dist/index.d.ts.map +0 -1
  121. package/dist/index.js.map +0 -1
  122. package/dist/jsx-runtime-BzGV18VO.d.ts.map +0 -1
  123. package/dist/vite-CQchIQ_-.js +0 -126
  124. package/dist/vite-CQchIQ_-.js.map +0 -1
@@ -0,0 +1,240 @@
1
+ import { decode } from "html-entities";
2
+ import MagicString from "magic-string";
3
+ import { parseSync, visitorKeys } from "oxc-parser";
4
+ // src/compiler.ts
5
+ const decodeJsx = (value) => decode(value, {
6
+ level: `html4`,
7
+ scope: `strict`
8
+ });
9
+ /** Match JSX's multiline whitespace rules without reprinting JavaScript. */
10
+ function text(value) {
11
+ const lines = value.split(/\r\n|\n|\r/);
12
+ let last = 0;
13
+ for (let i = 0; i < lines.length; i++) if (/[^ \t]/.test(lines[i])) last = i;
14
+ return lines.map((line, i) => {
15
+ line = line.replace(/\t/g, ` `);
16
+ if (i > 0) line = line.replace(/^ +/, ``);
17
+ if (i < lines.length - 1) line = line.replace(/ +$/, ``);
18
+ return line && i < last ? `${line} ` : line;
19
+ }).join(``);
20
+ }
21
+ function eager(node, allowJsx = false) {
22
+ if (node.type === `ParenthesizedExpression`) return eager(node.expression, allowJsx);
23
+ return node.type === `Literal` || node.type === `FunctionExpression` || node.type === `ArrowFunctionExpression` || allowJsx && (node.type === `JSXElement` || node.type === `JSXFragment`) || node.type === `TemplateLiteral` && node.expressions.length === 0;
24
+ }
25
+ function compile(code, filename) {
26
+ const parsed = parseSync(filename, code, {
27
+ lang: `tsx`,
28
+ preserveParens: true
29
+ });
30
+ if (parsed.errors.length) {
31
+ const error = parsed.errors[0];
32
+ throw new SyntaxError([`${filename}: ${error.message}`, error.codeframe].filter(Boolean).join(`\n`));
33
+ }
34
+ const output = new MagicString(code);
35
+ const parents = /* @__PURE__ */ new WeakMap();
36
+ const identifiers = /* @__PURE__ */ new Set();
37
+ const elements = [];
38
+ const functions = /* @__PURE__ */ new Set();
39
+ function walk(node, parent, outerFunction) {
40
+ if (parent) parents.set(node, parent);
41
+ output.addSourcemapLocation(node.start);
42
+ output.addSourcemapLocation(node.end);
43
+ if (node.type === `Identifier` || node.type === `JSXIdentifier`) identifiers.add(node.name);
44
+ if (!outerFunction && (node.type === `FunctionDeclaration` || node.type === `FunctionExpression` || node.type === `ArrowFunctionExpression`)) outerFunction = node;
45
+ if (node.type === `JSXElement` || node.type === `JSXFragment`) {
46
+ elements.push(node);
47
+ if (outerFunction) functions.add(outerFunction);
48
+ }
49
+ for (const key of visitorKeys[node.type]) {
50
+ const value = node[key];
51
+ if (Array.isArray(value)) {
52
+ for (const child of value) if (child) walk(child, node, outerFunction);
53
+ } else if (value) walk(value, node, outerFunction);
54
+ }
55
+ }
56
+ walk(parsed.program);
57
+ function uid(base) {
58
+ let name = `_${base}`;
59
+ let suffix = 1;
60
+ while (identifiers.has(name)) name = `_${base}${++suffix}`;
61
+ identifiers.add(name);
62
+ return name;
63
+ }
64
+ const create = uid(`spa`);
65
+ const merge = uid(`props`);
66
+ const join = (parts, separator) => parts.flatMap((part, i) => i ? [separator, ...part] : part);
67
+ const expression = (node) => eager(node, true) ? [
68
+ `(`,
69
+ node,
70
+ `)`
71
+ ] : [
72
+ `() => (`,
73
+ node,
74
+ `)`
75
+ ];
76
+ function tag(node) {
77
+ if (node.type === `JSXNamespacedName`) return JSON.stringify(`${node.namespace.name}:${node.name.name}`);
78
+ if (node.type === `JSXMemberExpression`) return code.slice(node.start, node.end);
79
+ return /^[a-z]/.test(node.name) || node.name.includes(`-`) ? JSON.stringify(node.name) : node.name;
80
+ }
81
+ /** Rewrite syntax around untouched expression spans, including nested JSX. */
82
+ function rewrite(node, parts) {
83
+ let cursor = node.start;
84
+ let replacement = ``;
85
+ for (const part of parts) {
86
+ if (typeof part === `string`) {
87
+ replacement += part;
88
+ continue;
89
+ }
90
+ if (cursor < part.start) output.update(cursor, part.start, replacement);
91
+ else output.appendLeft(cursor, replacement);
92
+ cursor = part.end;
93
+ replacement = ``;
94
+ }
95
+ output.update(cursor, node.end, replacement);
96
+ }
97
+ for (const node of elements) {
98
+ const chunks = [];
99
+ let properties = [];
100
+ const flush = () => {
101
+ if (properties.length) chunks.push([
102
+ `{`,
103
+ ...join(properties, `, `),
104
+ `}`
105
+ ]);
106
+ properties = [];
107
+ };
108
+ if (node.type === `JSXElement`) for (const attribute of node.openingElement.attributes) {
109
+ if (attribute.type === `JSXSpreadAttribute`) {
110
+ flush();
111
+ chunks.push([
112
+ `() => (`,
113
+ attribute.argument,
114
+ `)`
115
+ ]);
116
+ continue;
117
+ }
118
+ const key = JSON.stringify(attribute.name.type === `JSXNamespacedName` ? `${attribute.name.namespace.name}:${attribute.name.name.name}` : attribute.name.name);
119
+ const value = attribute.value;
120
+ if (!value) properties.push([`${key}: true`]);
121
+ else if (value.type === `Literal`) properties.push([`${key}: ${JSON.stringify(decodeJsx(value.value))}`]);
122
+ else {
123
+ const expr = value.type === `JSXExpressionContainer` ? value.expression : value;
124
+ properties.push(key === `"key"` || eager(expr) ? [
125
+ `${key}: (`,
126
+ expr,
127
+ `)`
128
+ ] : [
129
+ `get ${key}(){ return (`,
130
+ expr,
131
+ `); }`
132
+ ]);
133
+ }
134
+ }
135
+ const children = [];
136
+ for (const child of node.children) if (child.type === `JSXText`) {
137
+ const value = text(decodeJsx(child.value));
138
+ if (value) children.push([JSON.stringify(value)]);
139
+ } else if (child.type === `JSXElement` || child.type === `JSXFragment`) children.push([child]);
140
+ else if (child.type === `JSXExpressionContainer`) {
141
+ if (child.expression.type !== `JSXEmptyExpression`) children.push(expression(child.expression));
142
+ } else throw new SyntaxError(`${filename}: JSX spread children are unsupported`);
143
+ if (children.length) properties.push([`children: `, ...children.length === 1 ? children[0] : [
144
+ `[`,
145
+ ...join(children, `, `),
146
+ `]`
147
+ ]]);
148
+ flush();
149
+ const props = node.type === `JSXElement` && node.openingElement.attributes.some((attr) => attr.type === `JSXSpreadAttribute`) ? [
150
+ `${merge}(`,
151
+ ...join(chunks, `, `),
152
+ `)`
153
+ ] : chunks[0] ?? [`{}`];
154
+ rewrite(node, [
155
+ `${create}(${node.type === `JSXElement` ? tag(node.openingElement.name) : `null`}, `,
156
+ ...props,
157
+ `)`
158
+ ]);
159
+ }
160
+ const components = /* @__PURE__ */ new Set();
161
+ for (const fn of functions) {
162
+ let node = fn;
163
+ let parent = parents.get(node);
164
+ while (parent?.type === `ParenthesizedExpression`) {
165
+ node = parent;
166
+ parent = parents.get(node);
167
+ }
168
+ if (fn.type === `FunctionDeclaration` && fn.id) components.add(fn.id.name);
169
+ else if (parent?.type === `VariableDeclarator` && parent.id.type === `Identifier`) components.add(parent.id.name);
170
+ else if (parent?.type === `ExportDefaultDeclaration`) {
171
+ const name = uid(`Component`);
172
+ if (fn.type === `FunctionDeclaration`) {
173
+ const token = [...code.slice(fn.start, fn.body.start).matchAll(/\/\*[\s\S]*?\*\/|\/\/[^\r\n]*|\bfunction\b|\*/g)].find((match) => match[0] === (fn.generator ? `*` : `function`));
174
+ output.appendLeft(fn.start + token.index + token[0].length, ` ${name}`);
175
+ } else {
176
+ const prefix = code.slice(parent.start, node.start);
177
+ for (const token of prefix.matchAll(/\/\*[\s\S]*?\*\/|\/\/[^\r\n]*|\b(?:export|default)\b/g)) {
178
+ if (token[0] !== `export` && token[0] !== `default`) continue;
179
+ output.update(parent.start + token.index, parent.start + token.index + token[0].length, token[0] === `export` ? `const ${name} =` : ``);
180
+ }
181
+ output.appendLeft(parent.end, `;\nexport default ${name};`);
182
+ }
183
+ components.add(name);
184
+ }
185
+ }
186
+ if (elements.length) {
187
+ let position = parsed.program.hashbang?.end ?? 0;
188
+ for (const statement of parsed.program.body) {
189
+ if (statement.type !== `ExpressionStatement` || !statement.directive) break;
190
+ position = statement.end;
191
+ }
192
+ output.appendLeft(position, `\nimport { jsx as ${create}, merge as ${merge} } from "@atom.io/spa/jsx-runtime";\n`);
193
+ for (const component of components) output.append(`\n;${component}.spa = true;`);
194
+ }
195
+ return {
196
+ code: output.toString(),
197
+ map: output.generateMap({
198
+ source: filename,
199
+ includeContent: true,
200
+ hires: true
201
+ })
202
+ };
203
+ }
204
+ // src/vite.ts
205
+ function spa(options = {}) {
206
+ const include = options.include ?? /\.[jt]sx$/;
207
+ const matches = (id) => {
208
+ include.lastIndex = 0;
209
+ return !id.includes(`/node_modules/`) && include.test(id.split(`?`)[0]);
210
+ };
211
+ return {
212
+ name: `spa`,
213
+ enforce: `pre`,
214
+ config() {
215
+ return {
216
+ resolve: { dedupe: [`@atom.io/spa`, `atom.io`] },
217
+ optimizeDeps: { exclude: [`@atom.io/spa`, `atom.io`] }
218
+ };
219
+ },
220
+ configEnvironment: {
221
+ order: `post`,
222
+ handler(_name, config) {
223
+ if (config.optimizeDeps?.include) config.optimizeDeps.include = config.optimizeDeps.include.filter((id) => !/^(@atom\.io\/spa|atom\.io)(\/|$)/.test(id));
224
+ }
225
+ },
226
+ transform(code, id) {
227
+ if (!matches(id)) return;
228
+ return compile(code, id);
229
+ },
230
+ handleHotUpdate({ server, file }) {
231
+ if (matches(file)) {
232
+ server.ws.send({ type: `full-reload` });
233
+ return [];
234
+ }
235
+ }
236
+ };
237
+ }
238
+ export { spa as t };
239
+
240
+ //# sourceMappingURL=vite-CSHoxzXU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-CSHoxzXU.js","names":[],"sources":["../../src/compiler.ts","../../src/vite.ts"],"sourcesContent":["import { decode } from \"html-entities\"\nimport type { SourceMap } from \"magic-string\"\nimport MagicString from \"magic-string\"\nimport type {\n\tExpression,\n\tJSXElement,\n\tJSXElementName,\n\tJSXFragment,\n\tNode,\n} from \"oxc-parser\"\nimport { parseSync, visitorKeys } from \"oxc-parser\"\n\ntype Part = string | Node\n\nconst decodeJsx = (value: string): string =>\n\tdecode(value, { level: `html4`, scope: `strict` })\n\n/** Match JSX's multiline whitespace rules without reprinting JavaScript. */\nfunction text(value: string): string {\n\tconst lines = value.split(/\\r\\n|\\n|\\r/)\n\tlet last = 0\n\tfor (let i = 0; i < lines.length; i++) if (/[^ \\t]/.test(lines[i])) last = i\n\treturn lines\n\t\t.map((line, i) => {\n\t\t\tline = line.replace(/\\t/g, ` `)\n\t\t\tif (i > 0) line = line.replace(/^ +/, ``)\n\t\t\tif (i < lines.length - 1) line = line.replace(/ +$/, ``)\n\t\t\treturn line && i < last ? `${line} ` : line\n\t\t})\n\t\t.join(``)\n}\n\nfunction eager(node: Node, allowJsx = false): boolean {\n\tif (node.type === `ParenthesizedExpression`)\n\t\treturn eager(node.expression, allowJsx)\n\treturn (\n\t\tnode.type === `Literal` ||\n\t\tnode.type === `FunctionExpression` ||\n\t\tnode.type === `ArrowFunctionExpression` ||\n\t\t(allowJsx && (node.type === `JSXElement` || node.type === `JSXFragment`)) ||\n\t\t(node.type === `TemplateLiteral` && node.expressions.length === 0)\n\t)\n}\n\nexport function compile(\n\tcode: string,\n\tfilename: string,\n): { code: string; map: SourceMap } {\n\tconst parsed = parseSync(filename, code, {\n\t\tlang: `tsx`,\n\t\tpreserveParens: true,\n\t})\n\tif (parsed.errors.length) {\n\t\tconst error = parsed.errors[0]\n\t\tthrow new SyntaxError(\n\t\t\t[`${filename}: ${error.message}`, error.codeframe]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(`\\n`),\n\t\t)\n\t}\n\tconst output = new MagicString(code)\n\tconst parents = new WeakMap<Node, Node>()\n\tconst identifiers = new Set<string>()\n\tconst elements: (JSXElement | JSXFragment)[] = []\n\tconst functions = new Set<Node>()\n\tfunction walk(node: Node, parent?: Node, outerFunction?: Node): void {\n\t\tif (parent) parents.set(node, parent)\n\t\toutput.addSourcemapLocation(node.start)\n\t\toutput.addSourcemapLocation(node.end)\n\t\tif (node.type === `Identifier` || node.type === `JSXIdentifier`)\n\t\t\tidentifiers.add(node.name)\n\t\tif (\n\t\t\t!outerFunction &&\n\t\t\t(node.type === `FunctionDeclaration` ||\n\t\t\t\tnode.type === `FunctionExpression` ||\n\t\t\t\tnode.type === `ArrowFunctionExpression`)\n\t\t)\n\t\t\touterFunction = node\n\t\tif (node.type === `JSXElement` || node.type === `JSXFragment`) {\n\t\t\telements.push(node)\n\t\t\tif (outerFunction) functions.add(outerFunction)\n\t\t}\n\t\tfor (const key of visitorKeys[node.type]) {\n\t\t\tconst value = (node as unknown as Record<string, unknown>)[key]\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (const child of value) if (child) walk(child, node, outerFunction)\n\t\t\t} else if (value) walk(value as Node, node, outerFunction)\n\t\t}\n\t}\n\twalk(parsed.program)\n\tfunction uid(base: string): string {\n\t\tlet name = `_${base}`\n\t\tlet suffix = 1\n\t\twhile (identifiers.has(name)) name = `_${base}${++suffix}`\n\t\tidentifiers.add(name)\n\t\treturn name\n\t}\n\tconst create = uid(`spa`)\n\tconst merge = uid(`props`)\n\tconst join = (parts: Part[][], separator: string): Part[] =>\n\t\tparts.flatMap((part, i) => (i ? [separator, ...part] : part))\n\tconst expression = (node: Expression): Part[] =>\n\t\teager(node, true) ? [`(`, node, `)`] : [`() => (`, node, `)`]\n\tfunction tag(node: JSXElementName): string {\n\t\tif (node.type === `JSXNamespacedName`)\n\t\t\treturn JSON.stringify(`${node.namespace.name}:${node.name.name}`)\n\t\tif (node.type === `JSXMemberExpression`)\n\t\t\treturn code.slice(node.start, node.end)\n\t\treturn /^[a-z]/.test(node.name) || node.name.includes(`-`)\n\t\t\t? JSON.stringify(node.name)\n\t\t\t: node.name\n\t}\n\t/** Rewrite syntax around untouched expression spans, including nested JSX. */\n\tfunction rewrite(node: JSXElement | JSXFragment, parts: Part[]): void {\n\t\tlet cursor = node.start\n\t\tlet replacement = ``\n\t\tfor (const part of parts) {\n\t\t\tif (typeof part === `string`) {\n\t\t\t\treplacement += part\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (cursor < part.start) output.update(cursor, part.start, replacement)\n\t\t\telse output.appendLeft(cursor, replacement)\n\t\t\tcursor = part.end\n\t\t\treplacement = ``\n\t\t}\n\t\t// Every JSX node ends with closing syntax after its last expression span.\n\t\toutput.update(cursor, node.end, replacement)\n\t}\n\tfor (const node of elements) {\n\t\tconst chunks: Part[][] = []\n\t\tlet properties: Part[][] = []\n\t\tconst flush = () => {\n\t\t\tif (properties.length) chunks.push([`{`, ...join(properties, `, `), `}`])\n\t\t\tproperties = []\n\t\t}\n\t\tif (node.type === `JSXElement`) {\n\t\t\tfor (const attribute of node.openingElement.attributes) {\n\t\t\t\tif (attribute.type === `JSXSpreadAttribute`) {\n\t\t\t\t\tflush()\n\t\t\t\t\tchunks.push([`() => (`, attribute.argument, `)`])\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst key = JSON.stringify(\n\t\t\t\t\tattribute.name.type === `JSXNamespacedName`\n\t\t\t\t\t\t? `${attribute.name.namespace.name}:${attribute.name.name.name}`\n\t\t\t\t\t\t: attribute.name.name,\n\t\t\t\t)\n\t\t\t\tconst value = attribute.value\n\t\t\t\tif (!value) properties.push([`${key}: true`])\n\t\t\t\telse if (value.type === `Literal`)\n\t\t\t\t\tproperties.push([`${key}: ${JSON.stringify(decodeJsx(value.value))}`])\n\t\t\t\telse {\n\t\t\t\t\tconst expr =\n\t\t\t\t\t\tvalue.type === `JSXExpressionContainer` ? value.expression : value\n\t\t\t\t\tproperties.push(\n\t\t\t\t\t\tkey === `\"key\"` || eager(expr)\n\t\t\t\t\t\t\t? [`${key}: (`, expr, `)`]\n\t\t\t\t\t\t\t: [`get ${key}(){ return (`, expr, `); }`],\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst children: Part[][] = []\n\t\tfor (const child of node.children) {\n\t\t\tif (child.type === `JSXText`) {\n\t\t\t\tconst value = text(decodeJsx(child.value))\n\t\t\t\tif (value) children.push([JSON.stringify(value)])\n\t\t\t} else if (child.type === `JSXElement` || child.type === `JSXFragment`)\n\t\t\t\tchildren.push([child])\n\t\t\telse if (child.type === `JSXExpressionContainer`) {\n\t\t\t\tif (child.expression.type !== `JSXEmptyExpression`)\n\t\t\t\t\tchildren.push(expression(child.expression))\n\t\t\t} else\n\t\t\t\tthrow new SyntaxError(`${filename}: JSX spread children are unsupported`)\n\t\t}\n\t\tif (children.length)\n\t\t\tproperties.push([\n\t\t\t\t`children: `,\n\t\t\t\t...(children.length === 1\n\t\t\t\t\t? children[0]\n\t\t\t\t\t: [`[`, ...join(children, `, `), `]`]),\n\t\t\t])\n\t\tflush()\n\t\tconst spreads =\n\t\t\tnode.type === `JSXElement` &&\n\t\t\tnode.openingElement.attributes.some(\n\t\t\t\t(attr) => attr.type === `JSXSpreadAttribute`,\n\t\t\t)\n\t\tconst props = spreads\n\t\t\t? [`${merge}(`, ...join(chunks, `, `), `)`]\n\t\t\t: (chunks[0] ?? [`{}`])\n\t\trewrite(node, [\n\t\t\t`${create}(${node.type === `JSXElement` ? tag(node.openingElement.name) : `null`}, `,\n\t\t\t...props,\n\t\t\t`)`,\n\t\t])\n\t}\n\tconst components = new Set<string>()\n\tfor (const fn of functions) {\n\t\tlet node = fn\n\t\tlet parent = parents.get(node)\n\t\twhile (parent?.type === `ParenthesizedExpression`) {\n\t\t\tnode = parent\n\t\t\tparent = parents.get(node)\n\t\t}\n\t\tif (fn.type === `FunctionDeclaration` && fn.id) components.add(fn.id.name)\n\t\telse if (\n\t\t\tparent?.type === `VariableDeclarator` &&\n\t\t\tparent.id.type === `Identifier`\n\t\t)\n\t\t\tcomponents.add(parent.id.name)\n\t\telse if (parent?.type === `ExportDefaultDeclaration`) {\n\t\t\tconst name = uid(`Component`)\n\t\t\tif (fn.type === `FunctionDeclaration`) {\n\t\t\t\t// Keep anonymous default function declarations hoisted.\n\t\t\t\tconst token = [\n\t\t\t\t\t...code\n\t\t\t\t\t\t.slice(fn.start, fn.body!.start)\n\t\t\t\t\t\t.matchAll(/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\r\\n]*|\\bfunction\\b|\\*/g),\n\t\t\t\t].find((match) => match[0] === (fn.generator ? `*` : `function`))!\n\t\t\t\toutput.appendLeft(fn.start + token.index + token[0].length, ` ${name}`)\n\t\t\t} else {\n\t\t\t\t// Replace only keywords so intervening comments and annotations survive.\n\t\t\t\tconst prefix = code.slice(parent.start, node.start)\n\t\t\t\tfor (const token of prefix.matchAll(\n\t\t\t\t\t/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\r\\n]*|\\b(?:export|default)\\b/g,\n\t\t\t\t)) {\n\t\t\t\t\tif (token[0] !== `export` && token[0] !== `default`) continue\n\t\t\t\t\toutput.update(\n\t\t\t\t\t\tparent.start + token.index,\n\t\t\t\t\t\tparent.start + token.index + token[0].length,\n\t\t\t\t\t\ttoken[0] === `export` ? `const ${name} =` : ``,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\toutput.appendLeft(parent.end, `;\\nexport default ${name};`)\n\t\t\t}\n\t\t\tcomponents.add(name)\n\t\t}\n\t}\n\tif (elements.length) {\n\t\t// Keep hashbangs and directive prologues ahead of generated imports.\n\t\tlet position = parsed.program.hashbang?.end ?? 0\n\t\tfor (const statement of parsed.program.body) {\n\t\t\tif (statement.type !== `ExpressionStatement` || !statement.directive) break\n\t\t\tposition = statement.end\n\t\t}\n\t\toutput.appendLeft(\n\t\t\tposition,\n\t\t\t`\\nimport { jsx as ${create}, merge as ${merge} } from \"@atom.io/spa/jsx-runtime\";\\n`,\n\t\t)\n\t\tfor (const component of components)\n\t\t\toutput.append(`\\n;${component}.spa = true;`)\n\t}\n\treturn {\n\t\tcode: output.toString(),\n\t\tmap: output.generateMap({\n\t\t\tsource: filename,\n\t\t\tincludeContent: true,\n\t\t\thires: true,\n\t\t}),\n\t}\n}\n","import type { Plugin } from \"vite\"\n\nimport { compile } from \"./compiler.ts\"\n\nexport interface SpaPluginOptions {\n\tinclude?: RegExp\n}\nexport default function spa(options: SpaPluginOptions = {}): Plugin {\n\tconst include = options.include ?? /\\.[jt]sx$/\n\tconst matches = (id: string): boolean => {\n\t\tinclude.lastIndex = 0\n\t\treturn !id.includes(`/node_modules/`) && include.test(id.split(`?`)[0])\n\t}\n\treturn {\n\t\tname: `spa`,\n\t\tenforce: `pre`,\n\t\tconfig() {\n\t\t\treturn {\n\t\t\t\tresolve: { dedupe: [`@atom.io/spa`, `atom.io`] },\n\t\t\t\toptimizeDeps: { exclude: [`@atom.io/spa`, `atom.io`] },\n\t\t\t}\n\t\t},\n\t\tconfigEnvironment: {\n\t\t\torder: `post`,\n\t\t\thandler(_name, config) {\n\t\t\t\t// Astro and its adapters force renderer entries into the optimizer.\n\t\t\t\t// Vite processes explicit includes even when their package is excluded.\n\t\t\t\t// Keep the renderer, hooks, and store in one unbundled module graph.\n\t\t\t\tif (config.optimizeDeps?.include) {\n\t\t\t\t\tconfig.optimizeDeps.include = config.optimizeDeps.include.filter(\n\t\t\t\t\t\t(id) => !/^(@atom\\.io\\/spa|atom\\.io)(\\/|$)/.test(id),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\ttransform(code, id) {\n\t\t\tif (!matches(id)) return\n\t\t\treturn compile(code, id)\n\t\t},\n\t\t// A reload disposes the whole document. No state-preserving HMR is promised.\n\t\thandleHotUpdate({ server, file }) {\n\t\t\tif (matches(file)) {\n\t\t\t\tserver.ws.send({ type: `full-reload` })\n\t\t\t\treturn []\n\t\t\t}\n\t\t},\n\t}\n}\n"],"mappings":";;;;AAcA,MAAM,aAAa,UAClB,OAAO,OAAO;CAAE,OAAO;CAAS,OAAO;AAAS,CAAC;;AAGlD,SAAS,KAAK,OAAuB;CACpC,MAAM,QAAQ,MAAM,MAAM,YAAY;CACtC,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,IAAI,SAAS,KAAK,MAAM,EAAE,GAAG,OAAO;CAC3E,OAAO,MACL,KAAK,MAAM,MAAM;EACjB,OAAO,KAAK,QAAQ,OAAO,GAAG;EAC9B,IAAI,IAAI,GAAG,OAAO,KAAK,QAAQ,OAAO,EAAE;EACxC,IAAI,IAAI,MAAM,SAAS,GAAG,OAAO,KAAK,QAAQ,OAAO,EAAE;EACvD,OAAO,QAAQ,IAAI,OAAO,GAAG,KAAK,KAAK;CACxC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CAAC,gBAAgB,SAAS,EAAE;IAC/C,cAAc,EAAE,SAAS,CAAC,gBAAgB,SAAS,EAAE;GACtD;EACD;EACA,mBAAmB;GAClB,OAAO;GACP,QAAQ,OAAO,QAAQ;IAItB,IAAI,OAAO,cAAc,SACxB,OAAO,aAAa,UAAU,OAAO,aAAa,QAAQ,QACxD,OAAO,CAAC,mCAAmC,KAAK,EAAE,CACpD;GAEF;EACD;EACA,UAAU,MAAM,IAAI;GACnB,IAAI,CAAC,QAAQ,EAAE,GAAG;GAClB,OAAO,QAAQ,MAAM,EAAE;EACxB;EAEA,gBAAgB,EAAE,QAAQ,QAAQ;GACjC,IAAI,QAAQ,IAAI,GAAG;IAClB,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;IACtC,OAAO,CAAC;GACT;EACD;CACD;AACD"}
@@ -1 +1 @@
1
- export { t as default } from "./vite-CQchIQ_-.js";
1
+ export { t as default } from "./vite-CSHoxzXU.js";
@@ -1,4 +1,5 @@
1
- import { a as invalidate, b as within, f as untrack, i as fail, n as createScope, o as observe, r as dispose, t as createRoot, u as plain } from "./core-Dvqm7w2y.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-DCmqLZQP.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`;
@@ -42,6 +43,11 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
42
43
  comment(`{`, parent, before, owner, cursor);
43
44
  let end = null;
44
45
  let records = /* @__PURE__ */ new Map();
46
+ const presence = owner._root._presence?.collection((record) => record._scope, (record, child) => typeof record._value === typeof child && record._value?.type === child?.type);
47
+ const retire = (record, key, eligible, index) => {
48
+ if (presence) presence.remove(record, key, eligible, index, () => {});
49
+ else dispose(record._scope);
50
+ };
45
51
  let initial = cursor;
46
52
  observe(owner, () => source()(), (next) => {
47
53
  const values = [next].flat(Infinity);
@@ -54,9 +60,10 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
54
60
  const key = explicit == null ? index : String(explicit);
55
61
  let record = records.get(key);
56
62
  if (record && (typeof record._value !== typeof child || record._value?.type !== vnode?.type)) {
57
- dispose(record._scope);
63
+ retire(record, key, child == null || typeof child === `boolean`, [...records.keys()].indexOf(key));
58
64
  record = void 0;
59
65
  }
66
+ record ??= presence?.take(key, child);
60
67
  if (!record) {
61
68
  const childOwner = createScope(owner);
62
69
  record = {
@@ -70,14 +77,16 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
70
77
  record._end = comment(`]`, parent, end ?? before, childOwner, initial);
71
78
  } else {
72
79
  record._value = child;
80
+ owner._root._presence?.resume(record._scope);
73
81
  invalidate(record._scope);
74
82
  }
75
83
  kept.set(key, record);
76
84
  }
77
- for (const [key, record] of records) if (!kept.has(key)) dispose(record._scope);
85
+ for (const [key, record] of records) if (!kept.has(key)) retire(record, key, true, [...records.keys()].indexOf(key));
78
86
  if (!initial) {
79
87
  let at = end ?? before;
80
- for (const record of [...kept.values()].reverse()) {
88
+ const rendered = presence?.merge([...kept.values()]) ?? [...kept.values()];
89
+ for (const record of rendered.reverse()) {
81
90
  if (record._end.nextSibling !== at) {
82
91
  const range = parent.ownerDocument.createRange();
83
92
  range.setStartBefore(record._start);
@@ -86,7 +95,7 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
86
95
  }
87
96
  at = record._start;
88
97
  }
89
- if (focus?.isConnected && focus !== parent.ownerDocument.activeElement) focus.focus({ preventScroll: true });
98
+ if (focus?.isConnected && !focus.closest(`[inert]`) && focus !== parent.ownerDocument.activeElement) focus.focus({ preventScroll: true });
90
99
  }
91
100
  initial = void 0;
92
101
  records = kept;
@@ -131,11 +140,16 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
131
140
  if (!/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/.test(vnode.type) || ns !== HTML) mount(() => props[`children`], element, null, owner, vnode.type === `foreignObject` ? HTML : ns, children);
132
141
  if (children?.node) throw new Error(void 0);
133
142
  }
143
+ const nativeProps = capabilityProps(owner, {
144
+ kind: `dom`,
145
+ node: element
146
+ }, () => ({ ...props }));
134
147
  let previous = {};
135
148
  owner._cleanups.add(() => {
136
149
  for (const key in previous) if (key.startsWith(`on`)) property(element, key, null, previous[key]);
137
150
  });
138
- observe(owner, () => ({ ...props }), (next) => {
151
+ observe(owner, () => ({ ...props }), (all) => {
152
+ const next = nativeProps(all);
139
153
  for (const key in {
140
154
  ...previous,
141
155
  ...next
@@ -185,4 +199,4 @@ function hydrate(setup, host, options = {}) {
185
199
  }
186
200
  export { render as n, hydrate as t };
187
201
 
188
- //# sourceMappingURL=dom-BR9o9wZW.js.map
202
+ //# sourceMappingURL=dom-dHQM0O7Q.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-dHQM0O7Q.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,MACyC,KAAA,CACnD;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,OAAO,KACN,OAAO,cAAe,cAAc,KAAK,GACzC,QACA,QACA,OACA,MACD;AACD;AACA,SAAS,SACR,SACA,KACA,OACA,UACO;CACP,IAAI,uBAAuB,KAAK,GAAG,GAAG;CACtC,IAAI,QAAQ,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AAM,SAAS,KAAK;AACzC;AACA,SAAgB,QACf,OACA,MACA,UAAuB,CAAC,GACd;CACV,OAAO,MAAM,OAAO,MAAM,SAAS,IAAI;AACxC"}
@@ -0,0 +1,24 @@
1
+ import { a as Child, i as Accessor, s as RootOptions } from "./capabilities-CFP-HIuY.js";
2
+ import "./jsx-runtime-CREZYKDC.js";
3
+ import { Loadable, ReadableFamilyToken, ReadableToken, ViewOf } from "atom.io";
4
+ import { Canonical } from "atom.io/foundations/canonical";
5
+ interface SpaRoot {
6
+ dispose(): void;
7
+ flush(): void;
8
+ }
9
+ declare function render(setup: () => Child, host: Element, options?: RootOptions): SpaRoot;
10
+ declare function hydrate(setup: () => Child, host: Element, options?: RootOptions): SpaRoot;
11
+ type LoadableValue<T> = {
12
+ loading: boolean;
13
+ value: T;
14
+ };
15
+ declare function useLoadable<T, E>(token: ReadableToken<Loadable<T>, any, E>): Accessor<`LOADING` | LoadableValue<ViewOf<T | E>>>;
16
+ declare function useLoadable<T, K extends Canonical, E>(token: ReadableFamilyToken<Loadable<T>, K, E>, key: NoInfer<K>): Accessor<`LOADING` | LoadableValue<ViewOf<T | E>>>;
17
+ declare function useLoadable<T, E>(token: ReadableToken<Loadable<T>, any, E>, fallback: NoInfer<T>): Accessor<LoadableValue<ViewOf<T>> & {
18
+ error?: E;
19
+ }>;
20
+ declare function useLoadable<T, K extends Canonical, E>(token: ReadableFamilyToken<Loadable<T>, K, E>, key: NoInfer<K>, fallback: NoInfer<T>): Accessor<LoadableValue<ViewOf<T>> & {
21
+ error?: E;
22
+ }>;
23
+ export { render as a, hydrate as i, useLoadable as n, SpaRoot as r, LoadableValue as t };
24
+ //# sourceMappingURL=index-CJJXcKaw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CJJXcKaw.d.ts","names":[],"sources":["../src/dom.ts","../src/use-loadable.ts"],"mappings":";;;;UAqWiB;EAChB;EACA;;iBA8Ce,OACf,aAAa,OACb,MAAM,SACN,UAAS,cACP;iBAGa,QACf,aAAa,OACb,MAAM,SACN,UAAS,cACP;KCrZS,cAAc;EAAO;EAAkB,OAAO;;iBAE1C,YAAY,GAAG,GAC9B,OAAO,cAAc,SAAS,SAAS,KACrC,qBAAqB,cAAc,OAAO,IAAI;iBACjC,YAAY,GAAG,UAAU,WAAW,GACnD,OAAO,oBAAoB,SAAS,IAAI,GAAG,IAC3C,KAAK,QAAQ,KACX,qBAAqB,cAAc,OAAO,IAAI;iBACjC,YAAY,GAAG,GAC9B,OAAO,cAAc,SAAS,SAAS,IACvC,UAAU,QAAQ,KAChB,SAAS,cAAc,OAAO;EAAQ,QAAQ;;iBACjC,YAAY,GAAG,UAAU,WAAW,GACnD,OAAO,oBAAoB,SAAS,IAAI,GAAG,IAC3C,KAAK,QAAQ,IACb,UAAU,QAAQ,KAChB,SAAS,cAAc,OAAO;EAAQ,QAAQ"}
package/dist/index.d.ts CHANGED
@@ -1,24 +1,4 @@
1
- import { a as TimelineValue, c as onMount, d as useSetter, f as useStore, h as useValue, i as RootOptions, l as useId, m as useTransaction, n as Child, o as VNode, p as useTimeline, r as Component, s as onCleanup, t as Accessor, u as useRef } from "./core-BhiA9fFi.js";
2
- import { t as Fragment } from "./jsx-runtime-BzGV18VO.js";
3
- import { Loadable, ReadableFamilyToken, ReadableToken, ViewOf } from "atom.io";
4
- import { Canonical } from "atom.io/foundations/canonical";
5
- interface SpaRoot {
6
- dispose(): void;
7
- flush(): void;
8
- }
9
- export declare function render(setup: () => Child, host: Element, options?: RootOptions): SpaRoot;
10
- export declare function hydrate(setup: () => Child, host: Element, options?: RootOptions): SpaRoot;
11
- type LoadableValue<T> = {
12
- loading: boolean;
13
- value: T;
14
- };
15
- export declare function useLoadable<T, E>(token: ReadableToken<Loadable<T>, any, E>): Accessor<`LOADING` | LoadableValue<ViewOf<T | E>>>;
16
- export declare function useLoadable<T, K extends Canonical, E>(token: ReadableFamilyToken<Loadable<T>, K, E>, key: NoInfer<K>): Accessor<`LOADING` | LoadableValue<ViewOf<T | E>>>;
17
- export declare function useLoadable<T, E>(token: ReadableToken<Loadable<T>, any, E>, fallback: NoInfer<T>): Accessor<LoadableValue<ViewOf<T>> & {
18
- error?: E;
19
- }>;
20
- export declare function useLoadable<T, K extends Canonical, E>(token: ReadableFamilyToken<Loadable<T>, K, E>, key: NoInfer<K>, fallback: NoInfer<T>): Accessor<LoadableValue<ViewOf<T>> & {
21
- error?: E;
22
- }>;
23
- export { type Accessor, type Child, type Component, Fragment, type LoadableValue, type RootOptions, type SpaRoot, type TimelineValue, type VNode, onCleanup, onMount, useId, useRef, useSetter, useStore, useTimeline, useTransaction, useValue };
24
- //# sourceMappingURL=index.d.ts.map
1
+ import { _ as useTransaction, a as Child, c as TimelineValue, d as onMount, f as useId, g as useTimeline, h as useStore, i as Accessor, l as VNode, m as useSetter, n as CapabilityBinding, o as Component, p as useRef, r as CapabilityTarget, s as RootOptions, t as Capability, u as onCleanup, v as useValue } from "./capabilities-CFP-HIuY.js";
2
+ import { a as render, i as hydrate, n as useLoadable, r as SpaRoot, t as LoadableValue } from "./index-CJJXcKaw.js";
3
+ import { n as Fragment } from "./jsx-runtime-CREZYKDC.js";
4
+ export { type Accessor, type Capability, type CapabilityBinding, type CapabilityTarget, type Child, type Component, Fragment, type LoadableValue, type RootOptions, type SpaRoot, type TimelineValue, type VNode, hydrate, onCleanup, onMount, render, useId, useLoadable, useRef, useSetter, useStore, useTimeline, useTransaction, useValue };
package/dist/index.js CHANGED
@@ -1,40 +1,5 @@
1
- import { _ as useTimeline, c as onMount, d as resolveStateToken, g as useStore, h as useSetter, l as owner, m as useRef, p as useId, s as onCleanup, v as useTransaction, y as useValue } from "./core-Dvqm7w2y.js";
2
- import { n as render, t as hydrate } from "./dom-BR9o9wZW.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-DCmqLZQP.js";
3
2
  import { Fragment } from "./jsx-runtime.js";
4
- import { withdraw } from "atom.io/internal";
5
- // src/use-loadable.ts
6
- function useLoadable(...params) {
7
- const store = owner._root._store;
8
- const [token] = params;
9
- const family = token.type.endsWith(`_family`);
10
- const selected = resolveStateToken(token, params[1]);
11
- const read = useValue(selected);
12
- const fallbackIndex = family ? 2 : 1;
13
- const fallback = params[fallbackIndex];
14
- const hasFallback = params.length > fallbackIndex;
15
- let available = hasFallback;
16
- let previous = fallback;
17
- let error;
18
- return () => {
19
- const value = read();
20
- const loading = value instanceof Promise;
21
- if (!loading) {
22
- previous = value;
23
- available = true;
24
- const state = withdraw(store, selected);
25
- error = hasFallback && `catch` in state && state.catch.some((ErrorType) => value instanceof ErrorType) ? value : void 0;
26
- }
27
- if (!available) return `LOADING`;
28
- return error ? {
29
- loading,
30
- value: fallback,
31
- error
32
- } : {
33
- loading,
34
- value: previous
35
- };
36
- };
37
- }
3
+ import { n as render, t as hydrate } from "./dom-dHQM0O7Q.js";
4
+ import { t as useLoadable } from "./src-DCQa6qxs.js";
38
5
  export { Fragment, hydrate, onCleanup, onMount, render, useId, useLoadable, useRef, useSetter, useStore, useTimeline, useTransaction, useValue };
39
-
40
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { n as Child, o as VNode, r as Component } from "./core-BhiA9fFi.js";
1
+ import { a as Child, l as VNode, o as Component } from "./capabilities-CFP-HIuY.js";
2
2
  /** Native events retain their target; only currentTarget is the attached element. */
3
3
  type TargetedEvent<E extends Element, T extends Event = Event> = Omit<T, `currentTarget`> & {
4
4
  readonly currentTarget: E;
@@ -158,7 +158,7 @@ type AriaAttributes = Attributes<{
158
158
  [`aria-valuenow`]: number;
159
159
  [`aria-valuetext`]: string;
160
160
  }>;
161
- type DOMAttributes<E extends Element> = EventAttributes<E> & AriaAttributes & Attributes<{
161
+ type DOMAttributes<E extends Element> = CapabilityAttributes<`dom`> & EventAttributes<E> & AriaAttributes & Attributes<{
162
162
  children: Child;
163
163
  key: string | number;
164
164
  ref: Ref<E>;
@@ -939,6 +939,8 @@ type SVGIntrinsicElements = { [Tag in keyof SVGElementTagNameMap]: SVGAttributes
939
939
  // JSX cannot infer namespace from parents. Shared names (a, script, style,
940
940
  // title) use HTML types; unambiguous SVG tags retain their concrete SVG type.
941
941
  type NativeElements = HTMLIntrinsicElements & Omit<SVGIntrinsicElements, keyof HTMLIntrinsicElements>;
942
+ /** Optional integrations augment attributes without changing element identity. */
943
+ interface CapabilityAttributes<Kind extends string = string> {}
942
944
  declare const Fragment: (props: {
943
945
  children?: Child;
944
946
  }) => Child;
@@ -961,5 +963,5 @@ declare namespace JSX {
961
963
  [tag: `${string}-${string}`]: HTMLAttributes<HTMLElement>;
962
964
  }
963
965
  }
964
- export { jsxs as a, DOMAttributes as c, HTMLAttributes as d, Ref as f, jsxDEV as i, EventAttributes as l, TargetedEvent as m, JSX as n, merge as o, SVGAttributes as p, jsx as r, AriaAttributes as s, Fragment as t, EventHandler as u };
965
- //# sourceMappingURL=jsx-runtime-BzGV18VO.d.ts.map
966
+ export { jsxDEV as a, AriaAttributes as c, EventHandler as d, HTMLAttributes as f, TargetedEvent as h, jsx as i, DOMAttributes as l, SVGAttributes as m, Fragment as n, jsxs as o, Ref as p, JSX as r, merge as s, CapabilityAttributes as t, EventAttributes as u };
967
+ //# sourceMappingURL=jsx-runtime-CREZYKDC.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsx-runtime-CREZYKDC.d.ts","names":[],"sources":["../src/jsx-types.d.ts","../src/jsx-runtime.ts"],"mappings":";;KAIY,cAAc,UAAU,SAAS,UAAU,QAAQ,SAAS,KACvE;WAEc,eAAe;;KAClB,aAAa,UAAU,SAAS,UAAU,QAAQ,UAC7D,OAAO,cAAc,GAAG;KAEb,IAAI,UAAU,YAAY,SAAS;KAE1C,WAAW,QAAQ,WAAW,KAAK,EAAE;;UAGhC;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAEI,UAAU,oBACZ,IACA,WAAW,MACV,gBAAgB,aAAa,WAAW;KACvC,cAAc,UAAU,WAAW,UAAU,mBAC/C,2BACA,UAAU,mBACT,2BACA,UAAU,kBACT,0BACA,UAAU,sBACT,8BACA,UAAU,gBACT,wBACA,UAAU,aACT,qBACA;KACI,gBAAgB,UAAU,cAEpC,WAAW,cAAc,oBAAoB,UAAU,yBACpD,aAAa,GAAG,QAAQ,cAAc,GAAG,IAAI;KAG7C;KACO,iBAAiB;GAC3B;GACA,gBAAgB;GAChB;GACA;GACA;GACA,cAAc;GACd,iBAAiB;GACjB;GACA;GACA;GACA;GACA;GACA,iBAAiB;GACjB;GACA;GACA;GACA,kBAAkB;GAClB;GACA;GACA,kBAAkB;GAClB;GACA,iBAAiB;GACjB,kBAAkB;GAClB,gBAAgB;GAChB,iBAAiB;GACjB;GACA;GACA;GACA;GACA;GACA,eAAe;GACf,mBAAmB;GACnB,yBAAyB;GACzB;GACA;GACA;GACA;GACA,iBAAiB;GACjB,kBAAkB;GAClB;GAWA,kBAAkB;GAClB;GACA;GACA;GACA;GACA;GACA,kBAAkB;GAClB;GACA;GACA;GACA;GACA;GACA;;KAGU,cAAc,UAAU,WAAW,8BAC9C,gBAAgB,KAChB,iBACA;EACC,UAAU;EACV;EACA,KAAK,IAAI;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;QACO;;;KAIJ,YAAY,KAAK,WAAW,QAC/B,WAAW,KAAK,mBAAmB,UAAU,cAC3C,EAAE;KAIM,eAAe,UAAU,cAAc,eAClD,cAAc,KACb;EACC;EACA;EAOA;EACA;EACA;EACA;EACA;EACA;EAQA;EACA;EACA;EACA;EASA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAGE;KACA;KAUA;KACA;EACJ;EACA;EACA;EACA;EACA;EACA;;KAEI;EACJ;EACA;EACA;EACA,aAAa;EACb;EACA;EACA;EACA;EACA;;KAEI;EACJ;EACA;EACA;EACA;EACA,gBAAgB;EAChB;EACA;EACA;;KAEI;EACJ;EACA;EACA;EACA;EACA;;;UAIS;EACT,GAAG;EACH,MAAM;IACL;IACA;IACA;;EAED,OAAO;EACP;IAAQ;IAAc;;EACtB;IAAc;;EACd,QAAQ;IACP;IACA;IACA;IACA,OAAO;IACP;IACA;IACA;IACA;;EAED;IAAU,QAAQ;IAAgB,OAAO;;EACzC;IAAO;;EACP;IAAY;;EACZ;IAAQ,OAAO;;EACf;IAAO;IAAc;;EACrB;IAAW;IAAc;;EACzB;IAAU;IAAe;;EACzB;IACC,QAAQ;IACR;IACA;IACA,OAAO;;EAER;IAAY;IAAmB;IAAc;;EAC7C;IACC;KACC;IACD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAED;IAAQ;;EACR;IACC;IACA;IACA;IACA,QAAQ;IACR;IACA;IACA,gBAAgB;IAChB;IACA;IACA;IACA,OAAO;;EAER;IACC;IACA,aAAa;IACb;IACA;IACA,QAAQ;IACR;IACA;IACA,gBAAgB;IAChB;IACA;IACA;IACA;IACA,OAAO;;EAER,OAAO;IACN;IACA;IACA;IACA;IACA;IACA;IACA,cAAc;IACd;IACA;IACA,QAAQ;IACR;IACA,KAAK;IACL;IACA,KAAK;IACL;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,MAAM;IACN;IACA,OAAO;IACP,OAAO;;EAER;IAAO;IAAc;;EACrB;IAAS;IAAa;IAAiB;;EACvC;IAAM;;EACN;IACC;IACA;IACA,aAAa;IACb;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,gBAAgB;IAChB;IACA;IACA;;EAED;IAAO;;EACP;IACC;IACA;IACA;KACC;IACD;IACA;;EAED;IACC;IACA;IACA;IACA;IACA;IACA;;EAED;IACC;IACA;IACA,QAAQ;IACR;IACA;IACA;IACA,OAAO;;EAER;IAAM;IAAmB;IAAe;;EACxC;IAAY;IAAmB;;EAC/B;IACC;IACA;IACA;IACA,OAAO;;EAER;IAAU;IAAa;IAAiB;IAAc;;EACtD;IAAY;IAAa;;EACzB;IAAK;;EACL;IACC;IACA;IACA;IACA,aAAa;IACb;IACA;IACA;IACA;IACA,gBAAgB;IAChB;IACA;;EAED;IACC;IACA;IACA;IACA;IACA;IACA;IACA;IACA,OAAO;;EAER;IAAQ;;EACR;IACC,QAAQ;IACR;IACA;IACA;IACA;IACA;IACA,OAAO;;EAER;IAAS;IAAkB;IAAe;IAAe;;EACzD;IAAS,aAAa;IAAgB,aAAa;;EACnD,IAAI;EACJ;IACC;IACA;IACA;IACA;;EAED;IACC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAED,IAAI;EACJ;IAAQ;;EACR;IACC;IACA;IACA;IACA;IACA;;EAED,OAAO;IACN;IACA,QAAQ;IACR;IACA;IACA,OAAO;;;KAIG,2BACV,aAAa,wBAAwB,eACrC,sBAAsB,SAErB,kBAAkB,oBAChB,YAAY,kBAAkB;;KAKvB,cAAc,UAAU,aAAa,cAAc,cAAc,KAC5E;EACC;GACC;GACA;EACD;GACC;GACA;GACA,mBAAmB;EACpB;GACC;GACA;EACD;GACC;GACA;GACA;EACD;EACA;EACA;GACC;EACD;GACC,iBAAiB;GACjB;EACD;GACC;GACA,kBAAkB;GAClB;GACA,cAAc;GACd,qBAAqB;GACrB;GACA;GACA;GACA,gBAAgB;GAChB;GACA,mBAAmB;GACnB;GACA;GACA;GACA;EACD;EACA,SAAS;EACT;GACC;GACA;GACA;GACA;GACA,iBAAiB;EAClB;GACC,qBAAqB;GACrB,sBAAsB;GACtB;GACA;GACA,sBAAsB;GACtB,mBAAmB;GACnB,iBAAiB;GACjB;GACA;GACA;EACD;GACC;GACA;GACA;EACD;GACC,iBAAiB;GACjB;;KAGE;EACJ,GAAG;EACH,GAAG;EACH,OAAO;EACP,QAAQ;;KAEJ;EAAe;EAAiB;;KAChC;EAAY;GAAe;;KAC3B,qBAAqB;EAAW;;KAChC,eAAe;EACnB;EACA;EACA,OAAO;EACP,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL;EACA,aAAa;EACb,WAAW;EACX;EACA;EACA;EACA;EACA,MAAM;EACN,IAAI;EACJ,IAAI;EACJ;EACA;;KAEI;EACJ,GAAG;EACH,GAAG;EACH,IAAI;EACJ,IAAI;EACJ,QAAQ;EACR,YAAY;EACZ;;UAES;EACT,GAAG;IACF;IACA;IACA;IACA;IACA;;EAED,SAAS;EACT,eAAe;IACd;IACA;IACA,QAAQ;IACR;;EAED,kBAAkB;IACjB;;EAED;IACC,IAAI;IACJ,IAAI;IACJ,GAAG;IACH;;EAED;IAAY;;EACZ;IACC,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ;;EAED,SAAS;IAAuB;IAAY;IAAa;;EACzD,eAAe;IACd;IACA;IACA;;EAED,qBAAqB;IAAuB;;EAC5C,aAAa;IACZ;IACA;IACA;IACA;IACA;IACA;IACA;;EAED,kBAAkB;IACjB;IACA,OAAO;IACP;IACA;IACA;IACA;IACA;IACA;IACA,eAAe;;EAEhB,mBAAmB;IAClB;IACA;IACA;IACA,kBAAkB;;EAEnB,mBAAmB;IAClB;IACA;IACA;IACA;IACA;;EAED;IAAkB;IAAiB;;EACnC,cAAc;IACb,IAAI;IACJ,IAAI;IACJ,cAAc;;EAEf,SAAS;EACT;IACC;IACA;IACA;IACA;IACA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Ae;;;KAEV,0BACV,aAAa,uBAAuB,cAAc,qBAAqB,SACtE,kBAAkB,mBAAmB,WAAW,iBAAiB;;;KAKxD,iBAAiB,wBAC5B,KAAK,4BAA4B;;UC93BjB,qBAAqB;cAEzB,WAAQ;EAAa,WAAW;MAAU;iBACvC,IACf,MAAM,eACN,OAAO,uBACP,gBACE;cAMU,aAAI;cACJ,eAAM;;iBAGH,SACZ,UAAU,6BAA6B,0BACxC;kBAkBc;OACJ,UAAU;OACV,oBAAoB,oBAAoB;YACnC;IAChB;;YAEgB;IAChB;;;YAGgB,0BAA0B;KACzC,6BAA6B,eAAe"}
@@ -1,2 +1,2 @@
1
- import { a as jsxs, c as DOMAttributes, d as HTMLAttributes, f as Ref, i as jsxDEV, l as EventAttributes, m as TargetedEvent, n as JSX, o as merge, p as SVGAttributes, r as jsx, s as AriaAttributes, t as Fragment, u as EventHandler } from "./jsx-runtime-BzGV18VO.js";
2
- export { type AriaAttributes, type DOMAttributes, type EventAttributes, type EventHandler, Fragment, type HTMLAttributes, JSX, type Ref, type SVGAttributes, type TargetedEvent, jsx, jsxDEV, jsxs, merge };
1
+ import { a as jsxDEV, c as AriaAttributes, d as EventHandler, f as HTMLAttributes, h as TargetedEvent, i as jsx, l as DOMAttributes, m as SVGAttributes, n as Fragment, o as jsxs, p as Ref, r as JSX, s as merge, t as CapabilityAttributes, u as EventAttributes } from "./jsx-runtime-CREZYKDC.js";
2
+ export { type AriaAttributes, CapabilityAttributes, type DOMAttributes, type EventAttributes, type EventHandler, Fragment, type HTMLAttributes, JSX, type Ref, type SVGAttributes, type TargetedEvent, jsx, jsxDEV, jsxs, merge };
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx-runtime.ts"],"sourcesContent":["import type { Child, Component, VNode } from \"./core.ts\"\nimport type { HTMLAttributes, NativeElements } from \"./jsx-types.d.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\"\n\nexport const Fragment = (props: { children?: Child }): Child => props.children\nexport function jsx(\n\ttype: VNode[`type`],\n\tprops: VNode[`props`] | null,\n\tkey?: unknown,\n): VNode {\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\n/** Preserve lazy props and spread precedence, including keys added by later updates. */\nexport function merge(\n\t...sources: (Record<string, any> | (() => Record<string, any>))[]\n): Record<string, any> {\n\tconst values = () =>\n\t\tsources.map(\n\t\t\t(source) => (typeof source === `function` ? source() : source) ?? {},\n\t\t)\n\treturn new Proxy(\n\t\t{},\n\t\t{\n\t\t\tget: (_, key) =>\n\t\t\t\tvalues()\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.find((source) => Object.hasOwn(source, key))?.[key],\n\t\t\townKeys: () => [...new Set(values().flatMap(Object.keys))],\n\t\t\tgetOwnPropertyDescriptor: () => ({ enumerable: true, configurable: true }),\n\t\t},\n\t)\n}\n\nexport namespace JSX {\n\texport type Element = VNode\n\texport type ElementType = keyof IntrinsicElements | Component\n\texport interface ElementChildrenAttribute {\n\t\tchildren: {}\n\t}\n\texport interface IntrinsicAttributes {\n\t\tkey?: string | number\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":";AAcA,MAAa,YAAY,UAAuC,MAAM;AACtE,SAAgB,IACf,MACA,OACA,KACQ;CACR,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;;AAGtB,SAAgB,MACf,GAAG,SACmB;CACtB,MAAM,eACL,QAAQ,KACN,YAAY,OAAO,WAAW,aAAa,OAAO,IAAI,WAAW,CAAC,CACpE;CACD,OAAO,IAAI,MACV,CAAC,GACD;EACC,MAAM,GAAG,QACR,OAAO,CAAC,CACN,QAAQ,CAAC,CACT,MAAM,WAAW,OAAO,OAAO,QAAQ,GAAG,CAAC,CAAC,GAAG;EAClD,eAAe,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,CAAC,QAAQ,OAAO,IAAI,CAAC,CAAC;EACzD,iCAAiC;GAAE,YAAY;GAAM,cAAc;EAAK;CACzE,CACD;AACD"}
1
+ {"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx-runtime.ts"],"sourcesContent":["import type { Child, Component, VNode } from \"./core.ts\"\nimport type { HTMLAttributes, NativeElements } from \"./jsx-types.d.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\"\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?: Child }): Child => props.children\nexport function jsx(\n\ttype: VNode[`type`],\n\tprops: VNode[`props`] | null,\n\tkey?: unknown,\n): VNode {\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\n/** Preserve lazy props and spread precedence, including keys added by later updates. */\nexport function merge(\n\t...sources: (Record<string, any> | (() => Record<string, any>))[]\n): Record<string, any> {\n\tconst values = () =>\n\t\tsources.map(\n\t\t\t(source) => (typeof source === `function` ? source() : source) ?? {},\n\t\t)\n\treturn new Proxy(\n\t\t{},\n\t\t{\n\t\t\tget: (_, key) =>\n\t\t\t\tvalues()\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.find((source) => Object.hasOwn(source, key))?.[key],\n\t\t\townKeys: () => [...new Set(values().flatMap(Object.keys))],\n\t\t\tgetOwnPropertyDescriptor: () => ({ enumerable: true, configurable: true }),\n\t\t},\n\t)\n}\n\nexport namespace JSX {\n\texport type Element = VNode\n\texport type ElementType = keyof IntrinsicElements | Component\n\texport interface ElementChildrenAttribute {\n\t\tchildren: {}\n\t}\n\texport interface IntrinsicAttributes {\n\t\tkey?: string | number\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":";AAkBA,MAAa,YAAY,UAAuC,MAAM;AACtE,SAAgB,IACf,MACA,OACA,KACQ;CACR,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;;AAGtB,SAAgB,MACf,GAAG,SACmB;CACtB,MAAM,eACL,QAAQ,KACN,YAAY,OAAO,WAAW,aAAa,OAAO,IAAI,WAAW,CAAC,CACpE;CACD,OAAO,IAAI,MACV,CAAC,GACD;EACC,MAAM,GAAG,QACR,OAAO,CAAC,CACN,QAAQ,CAAC,CACT,MAAM,WAAW,OAAO,OAAO,QAAQ,GAAG,CAAC,CAAC,GAAG;EAClD,eAAe,CAAC,GAAG,IAAI,IAAI,OAAO,CAAC,CAAC,QAAQ,OAAO,IAAI,CAAC,CAAC;EACzD,iCAAiC;GAAE,YAAY;GAAM,cAAc;EAAK;CACzE,CACD;AACD"}
@@ -0,0 +1,32 @@
1
+ import { a as Child, l as VNode } from "./capabilities-CFP-HIuY.js";
2
+ import { SceneRenderer } from "./renderer.js";
3
+ import "./index-CJJXcKaw.js";
4
+ import { t as CapabilityAttributes } from "./jsx-runtime-CREZYKDC.js";
5
+ import Konva from "konva";
6
+ type Props<C, N> = C & CapabilityAttributes<`konva`> & {
7
+ children?: Child;
8
+ ref?: (node: N | null) => void;
9
+ onClick?: (event: Konva.KonvaEventObject<MouseEvent>) => void;
10
+ onPointerDown?: (event: Konva.KonvaEventObject<PointerEvent>) => void;
11
+ onDragMove?: (event: Konva.KonvaEventObject<DragEvent>) => void;
12
+ onDragEnd?: (event: Konva.KonvaEventObject<DragEvent>) => void;
13
+ };
14
+ declare const renderer: SceneRenderer<import("konva/lib/Node").Node<import("konva/lib/Node").NodeConfig>>;
15
+ /** A DOM boundary owning a Konva stage and its scene subtree. */
16
+ export declare function Stage(props: Props<Omit<Konva.StageConfig, `container`>, Konva.Stage> & {
17
+ width?: number;
18
+ height?: number;
19
+ }): VNode;
20
+ export declare const Layer: (props: Props<import("konva/lib/Layer").LayerConfig, import("konva/lib/Layer").Layer>) => VNode;
21
+ export declare const Group: (props: Props<import("konva/lib/Container").ContainerConfig, import("konva/lib/Group").Group>) => VNode;
22
+ export declare const Rect: (props: Props<import("konva/lib/shapes/Rect").RectConfig, import("konva/lib/shapes/Rect").Rect>) => VNode;
23
+ export declare const Circle: (props: Props<import("konva/lib/shapes/Circle").CircleConfig, import("konva/lib/shapes/Circle").Circle>) => VNode;
24
+ export declare const Ellipse: (props: Props<import("konva/lib/shapes/Ellipse").EllipseConfig, import("konva/lib/shapes/Ellipse").Ellipse>) => VNode;
25
+ export declare const Line: (props: Props<import("konva/lib/shapes/Line").LineConfig, import("konva/lib/shapes/Line").Line<import("konva/lib/shapes/Line").LineConfig>>) => VNode;
26
+ export declare const Text: (props: Props<import("konva/lib/shapes/Text").TextConfig, import("konva/lib/shapes/Text").Text>) => VNode;
27
+ export declare const Image: (props: Props<import("konva/lib/shapes/Image").ImageConfig, import("konva/lib/shapes/Image").Image>) => VNode;
28
+ export declare const Path: (props: Props<import("konva/lib/shapes/Path").PathConfig, import("konva/lib/shapes/Path").Path>) => VNode;
29
+ export declare const Star: (props: Props<import("konva/lib/shapes/Star").StarConfig, import("konva/lib/shapes/Star").Star>) => VNode;
30
+ export declare const Transformer: (props: Props<import("konva/lib/shapes/Transformer").TransformerConfig, import("konva/lib/shapes/Transformer").Transformer>) => VNode;
31
+ export { renderer as konvaRenderer };
32
+ //# sourceMappingURL=konva.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"konva.d.ts","names":["_$__renderer_ts0.SceneRenderer"],"sources":["../src/konva.ts"],"mappings":";;;;;KAUK,MAAM,GAAG,KAAK,IAClB;EACC,WAAW;EACX,OAAO,MAAM;EACb,WAAW,OAAO,MAAM,iBAAiB;EACzC,iBAAiB,OAAO,MAAM,iBAAiB;EAC/C,cAAc,OAAO,MAAM,iBAAiB;EAC5C,aAAa,OAAO,MAAM,iBAAiB;;cAyCvC,UAAAA,uCAAQ,8BAAA;;wBA6CE,MACf,OAAO,MAAM,KAAK,MAAM,2BAA2B,MAAM;EACxD;EACA;IAEC;qBA0DU,QAAK,OAAA,gCAAA,uCAAA,WAAA;qBAEL,QAAK,OAAA,oCAAA,2CAAA,WAAA;qBAEL,OAAI,OAAA,sCAAA,4CAAA,UAAA;qBACJ,SAAM,OAAA,wCAAA,gDAAA,YAAA;qBAEN,UAAO,OAAA,yCAAA,kDAAA,aAAA;qBAEP,OAAI,OAAA,sCAAA,4CAAA,qCAAA,iBAAA;qBACJ,OAAI,OAAA,sCAAA,4CAAA,UAAA;qBACJ,QAAK,OAAA,uCAAA,8CAAA,WAAA;qBAEL,OAAI,OAAA,sCAAA,4CAAA,UAAA;qBACJ,OAAI,OAAA,sCAAA,4CAAA,UAAA;qBACJ,cAAW,OAAA,6CAAA,0DAAA,iBAAA"}