@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
@@ -1,9 +1,105 @@
1
- import { n as capabilityProps } from "./capabilities-nOIitQ-_.js";
2
- import { S as within, a as invalidate, d as plain, i as fail, n as createScope, p as untrack, r as dispose, s as observe, t as createRoot } from "./core-BHA7I1nf.js";
3
- import { Fragment, merge } from "./jsx-runtime.js";
1
+ import { i as capabilityProps, n as trackKeys, t as identifyChildren } from "./identity-DwB8MTM1.js";
2
+ import { D as within, a as enqueue, c as isPresent, i as dispose, l as observe, m as plain, n as createRoot, o as fail, r as createScope, s as invalidate, v as untrack } from "./core-DrUd8x25.js";
3
+ import { hotRoot, trackRoot } from "./hot.js";
4
+ import { a as instanceProps, t as Fragment } from "./jsx-runtime-BGDPK50B.js";
5
+ // src/dom-forms.ts
6
+ const changes = /* @__PURE__ */ new WeakMap();
7
+ const requests = /* @__PURE__ */ new WeakMap();
8
+ const events = [
9
+ `input`,
10
+ `change`,
11
+ `click`
12
+ ];
13
+ const wake = () => {};
14
+ /** Keep native input events, using per-edit change semantics for text/range controls. */
15
+ function changeHandler(handler) {
16
+ let wrapped = changes.get(handler);
17
+ if (!wrapped) {
18
+ wrapped = (event) => {
19
+ const target = event.target;
20
+ const editing = target?.localName === `textarea` || target?.localName === `input` && !/^(checkbox|radio|file)$/.test(target.type);
21
+ if (event.type === (editing ? `input` : `change`)) handler.call(event.currentTarget, event);
22
+ };
23
+ changes.set(handler, wrapped);
24
+ }
25
+ return wrapped;
26
+ }
27
+ function controlValue(control, value) {
28
+ if (control.localName === `input` && control.type === `number` && typeof value === `number` && control.value !== `` && Number(control.value) === value) return;
29
+ if (control.value !== String(value)) control.value = String(value);
30
+ if (control.localName === `select`) {
31
+ const select = control;
32
+ if (select.selectedIndex < 0) {
33
+ const first = [...select.options].find((option) => !option.disabled);
34
+ if (first) first.selected = true;
35
+ }
36
+ }
37
+ }
38
+ function requestRestore(control) {
39
+ requests.get(control)?.();
40
+ if (control.localName !== `input` || control.type !== `radio`) return;
41
+ const input = control;
42
+ for (const peer of input.getRootNode().querySelectorAll(`input`)) if (peer !== input && peer.type === `radio` && peer.name === input.name && peer.form === input.form) requests.get(peer)?.();
43
+ }
44
+ /** Restore controlled fields after event handlers and all queued option/prop updates. */
45
+ function bindForm(control, props, scope) {
46
+ let active;
47
+ let timer;
48
+ const restore = () => {
49
+ if (!isPresent(scope)) return true;
50
+ const value = props[`value`];
51
+ const checked = control.localName === `input` ? props[`checked`] : void 0;
52
+ if (active?.eventPhase) return value == null && checked == null;
53
+ if (value != null) controlValue(control, value);
54
+ if (checked != null) {
55
+ const input = control;
56
+ if (input.checked !== Boolean(checked)) input.checked = Boolean(checked);
57
+ }
58
+ return true;
59
+ };
60
+ const finish = () => {
61
+ active = void 0;
62
+ clearTimeout(timer);
63
+ enqueue(scope, wake);
64
+ };
65
+ const capture = (event) => {
66
+ if (event.type === `click` && !/^(checkbox|radio)$/.test(control.type)) return;
67
+ active = event;
68
+ clearTimeout(timer);
69
+ timer = setTimeout(() => {
70
+ requestRestore(control);
71
+ }, 0);
72
+ };
73
+ const root = scope._root;
74
+ if (!root._forms) {
75
+ root._forms = /* @__PURE__ */ new Set();
76
+ const end = (event) => {
77
+ const target = event.target;
78
+ if (event.type === `click` || event.type === `input` && /^(checkbox|radio)$/.test(target.type)) return;
79
+ requestRestore(target);
80
+ };
81
+ for (const event of events) root._host.addEventListener(event, end);
82
+ root._cleanups.add(() => {
83
+ for (const event of events) root._host.removeEventListener(event, end);
84
+ });
85
+ }
86
+ const forms = root._forms;
87
+ forms.add(restore);
88
+ requests.set(control, finish);
89
+ for (const event of events) control.addEventListener(event, capture, true);
90
+ scope._cleanups.add(() => {
91
+ clearTimeout(timer);
92
+ forms.delete(restore);
93
+ requests.delete(control);
94
+ for (const event of events) control.removeEventListener(event, capture, true);
95
+ });
96
+ }
4
97
  // src/dom.ts
5
98
  const HTML = `http://www.w3.org/1999/xhtml`;
6
99
  const SVG = `http://www.w3.org/2000/svg`;
100
+ function compatible(record, child) {
101
+ return typeof record._value === typeof child && record._value?.type === child?.type;
102
+ }
7
103
  function finish(cursor) {
8
104
  if (cursor?.node) {
9
105
  cursor.report(null, cursor.node);
@@ -42,68 +138,73 @@ function property(element, key, value, previous) {
42
138
  if (key.startsWith(`on`)) {
43
139
  const capture = /(?<!Pointer)Capture$/.test(key);
44
140
  const event = key.slice(2, capture ? -7 : void 0).toLowerCase().replace(`doubleclick`, `dblclick`);
45
- if (previous) element.removeEventListener(event, previous, capture);
141
+ const events = event === `change` ? [`input`, `change`] : [event === `focus` ? `focusin` : event === `blur` ? `focusout` : event];
142
+ if (previous) for (const name of events) element.removeEventListener(name, event === `change` ? changeHandler(previous) : previous, capture);
46
143
  if (value != null) {
47
144
  if (typeof value !== `function`) throw new Error(`spa: event handler`);
48
- element.addEventListener(event, value, capture);
145
+ for (const name of events) element.addEventListener(name, event === `change` ? changeHandler(value) : value, capture);
49
146
  }
50
147
  return;
51
148
  }
52
149
  if (key === `className`) key = `class`;
53
150
  if (key === `htmlFor`) key = `for`;
54
151
  if (key === `style` && value != null && typeof value !== `string`) throw new Error(`spa: CSS string required`);
152
+ if (element.namespaceURI === SVG && key === `focusable` && typeof value === `boolean`) value = String(value);
55
153
  if (element.namespaceURI === HTML && key in element && !/^(style|form|list)$/.test(key)) {
56
154
  const target = element;
57
- target[key] = value ?? (typeof target[key] === `boolean` ? false : ``);
155
+ if (key === `value` && /^(input|textarea|select)$/.test(element.localName) && value != null) controlValue(target, value);
156
+ else target[key] = value ?? (typeof target[key] === `boolean` ? false : ``);
157
+ if (value == null) element.removeAttribute(key);
58
158
  } else if (value == null || value === false && !/^(aria-|data-)/.test(key)) element.removeAttribute(key);
59
159
  else element.setAttribute(key, value === true && !/^(aria-|data-)/.test(key) ? `` : String(value));
60
160
  }
61
- function mount(value, parent, before, owner, namespace, cursor, source = () => value) {
161
+ function mount(value, parent, before, owner, namespace, cursor, source = () => value, initialKey) {
62
162
  if (typeof value === `function`) {
63
- comment(`{`, parent, before, owner, cursor);
163
+ const begin = comment(`{`, parent, before, owner, cursor);
64
164
  let end = null;
65
165
  let records = /* @__PURE__ */ new Map();
66
- const presence = owner._root._presence?.collection((record) => record._scope, (record, child) => typeof record._value === typeof child && record._value?.type === child?.type);
166
+ let presence;
67
167
  const retire = (record, key, eligible, index) => {
68
168
  if (presence) presence.remove(record, key, eligible, index, () => {});
69
169
  else dispose(record._scope);
70
170
  };
71
171
  let initial = cursor;
72
- observe(owner, () => source()(), (next) => {
73
- const values = [next].flat(Infinity);
172
+ observe(owner, () => identifyChildren(source()()), (values) => {
173
+ presence ??= owner._root._presence?.collection((record) => record._scope, compatible);
74
174
  const kept = /* @__PURE__ */ new Map();
175
+ let previous;
75
176
  const focus = parent.ownerDocument.activeElement;
76
177
  for (let index = 0; index < values.length; index++) {
77
- const child = values[index];
78
- const vnode = child;
79
- const explicit = vnode?.props?.[`key`];
80
- const key = explicit == null ? index : String(explicit);
81
- if (kept.has(key)) throw new Error(`spa: duplicate key`);
82
- let record = records.get(key);
83
- if (record && (typeof record._value !== typeof child || record._value?.type !== vnode?.type)) {
84
- retire(record, key, child == null || typeof child === `boolean`, [...records.keys()].indexOf(key));
178
+ const { value: child, key, id } = values[index];
179
+ let record = records.get(id);
180
+ if (record && !compatible(record, child)) {
181
+ retire(record, id, child == null || typeof child === `boolean`, record._index);
85
182
  record = void 0;
86
183
  }
87
- record ??= presence?.take(key, child);
184
+ record ??= presence?.take(id, child);
88
185
  if (!record) {
186
+ const at = previous ? previous._end.nextSibling : begin.nextSibling;
89
187
  const childOwner = createScope(owner);
90
188
  record = {
189
+ _index: index,
91
190
  _value: child,
92
191
  _scope: childOwner,
93
- _start: comment(`[`, parent, end ?? before, childOwner, initial),
192
+ _start: comment(`[`, parent, at, childOwner, initial),
94
193
  _end: null
95
194
  };
96
195
  const held = record;
97
- mount(child, parent, end ?? before, childOwner, namespace, initial, () => held._value);
98
- record._end = comment(`]`, parent, end ?? before, childOwner, initial);
196
+ mount(child, parent, at, childOwner, namespace, initial, () => held._value, key);
197
+ record._end = comment(`]`, parent, at, childOwner, initial);
99
198
  } else {
100
199
  record._value = child;
101
200
  owner._root._presence?.resume(record._scope);
102
201
  invalidate(record._scope);
103
202
  }
104
- kept.set(key, record);
203
+ record._index = index;
204
+ previous = record;
205
+ kept.set(id, record);
105
206
  }
106
- for (const [key, record] of records) if (!kept.has(key)) retire(record, key, true, [...records.keys()].indexOf(key));
207
+ for (const [key, record] of records) if (!kept.has(key)) retire(record, key, true, record._index);
107
208
  if (!initial) {
108
209
  let at = end ?? before;
109
210
  const rendered = presence?.merge([...kept.values()]) ?? [...kept.values()];
@@ -140,18 +241,23 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
140
241
  }
141
242
  if (!(`type` in value) || !(`props` in value)) throw new Error(`spa: invalid child`);
142
243
  const vnode = value;
143
- const props = merge(() => source().props);
244
+ const props = instanceProps(() => source().props, initialKey);
144
245
  if (!vnode.type || vnode.type === Fragment) {
145
246
  mount(() => props[`children`], parent, before, owner, namespace, cursor);
146
247
  return;
147
248
  }
148
249
  if (typeof vnode.type === `function`) {
149
250
  const childOwner = createScope(owner);
150
- mount(within(childOwner, () => untrack(() => vnode.type(props))), parent, before, childOwner, namespace, cursor);
251
+ const output = within(childOwner, () => untrack(() => vnode.type(props)));
252
+ mount(trackKeys(output), parent, before, childOwner, namespace, cursor);
151
253
  return;
152
254
  }
153
255
  const ns = vnode.type === `svg` ? SVG : namespace;
154
256
  const element = take(parent.ownerDocument.createElementNS(ns, vnode.type), parent, before, owner, cursor);
257
+ if (ns === HTML && /^(input|textarea|select)$/.test(vnode.type)) bindForm(element, props, owner);
258
+ if (ns === HTML && (props[`autoFocus`] || props[`autofocus`])) owner._root._mounts.push(() => {
259
+ if (!owner._dead) element.focus();
260
+ });
155
261
  if (vnode.type === `astro-slot`) {
156
262
  if (!cursor) element.innerHTML = props[`innerHTML`] ?? ``;
157
263
  } else if (ns === HTML && /^(textarea|title|style|script)$/.test(vnode.type)) observe(owner, () => plain(vnode.type === `textarea` ? props[`value`] ?? props[`children`] : props[`children`]), (text) => {
@@ -189,11 +295,11 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
189
295
  if (ref) owner._root._mounts.unshift(() => {
190
296
  if (!owner._dead) {
191
297
  owner._cleanups.add(() => ref(null));
192
- ref(element);
298
+ within(owner, () => ref(element));
193
299
  }
194
300
  });
195
301
  }
196
- function start(setup, host, options, hydrating) {
302
+ function start(setup, host, options, hydrating, before = null) {
197
303
  let reported = false;
198
304
  const cursor = hydrating ? {
199
305
  node: host.firstChild,
@@ -211,13 +317,15 @@ function start(setup, host, options, hydrating) {
211
317
  const marker = cursor?.node;
212
318
  const prefix = marker?.nodeType === 8 && marker.nodeValue?.startsWith(`w:`) ? marker.nodeValue.slice(2) : void 0;
213
319
  const root = createRoot(options);
320
+ root._host = host;
214
321
  if (prefix !== void 0 && options.idPrefix === void 0) root._prefix = prefix;
322
+ trackRoot(root);
215
323
  try {
216
- comment(`w:${root._prefix}`, host, null, root, cursor);
324
+ comment(`w:${root._prefix}`, host, before, root, cursor);
217
325
  within(root, () => {
218
- mount(untrack(setup), host, null, root, host.namespaceURI === SVG ? SVG : HTML, cursor);
326
+ mount(trackKeys(untrack(setup)), host, before, root, host.namespaceURI === SVG ? SVG : HTML, cursor);
219
327
  });
220
- comment(`/w`, host, null, root, cursor);
328
+ comment(`/w`, host, before, root, cursor);
221
329
  finish(cursor);
222
330
  root.flush();
223
331
  } catch (error) {
@@ -231,11 +339,18 @@ function start(setup, host, options, hydrating) {
231
339
  };
232
340
  }
233
341
  function render(setup, host, options = {}) {
234
- return start(setup, host, options, false);
342
+ return hotRoot((next, before) => start(setup, host, next, false, before), options, host);
235
343
  }
236
344
  function hydrate(setup, host, options = {}) {
237
- return start(setup, host, options, true);
345
+ {
346
+ let initial = true;
347
+ return hotRoot((next, before) => {
348
+ const current = start(setup, host, next, initial, before);
349
+ initial = false;
350
+ return current;
351
+ }, options, host);
352
+ }
238
353
  }
239
354
  export { render as n, hydrate as t };
240
355
 
241
- //# sourceMappingURL=dom-DQ0M3rLL.js.map
356
+ //# sourceMappingURL=dom-BRFv7FP_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-BRFv7FP_.js","names":[],"sources":["../../src/dom-forms.ts","../../src/dom.ts"],"sourcesContent":["import type { Scope } from \"./core.ts\"\nimport { enqueue, isPresent } from \"./core.ts\"\n\ntype Control = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement\nconst changes = new WeakMap<EventListener, EventListener>()\nconst requests = new WeakMap<Element, () => void>()\nconst events = [`input`, `change`, `click`]\nconst wake = () => {}\n\n/** Keep native input events, using per-edit change semantics for text/range controls. */\nexport function changeHandler(handler: EventListener): EventListener {\n\tlet wrapped = changes.get(handler)\n\tif (!wrapped) {\n\t\twrapped = (event) => {\n\t\t\tconst target = event.target as Control | null\n\t\t\tconst editing =\n\t\t\t\ttarget?.localName === `textarea` ||\n\t\t\t\t(target?.localName === `input` &&\n\t\t\t\t\t!/^(checkbox|radio|file)$/.test(target.type))\n\t\t\tif (event.type === (editing ? `input` : `change`))\n\t\t\t\thandler.call(event.currentTarget, event)\n\t\t}\n\t\tchanges.set(handler, wrapped)\n\t}\n\treturn wrapped\n}\n\nexport function controlValue(control: Control, value: string | number): void {\n\tif (\n\t\tcontrol.localName === `input` &&\n\t\tcontrol.type === `number` &&\n\t\ttypeof value === `number` &&\n\t\tcontrol.value !== `` &&\n\t\tNumber(control.value) === value\n\t)\n\t\treturn\n\tif (control.value !== String(value)) control.value = String(value)\n\tif (control.localName === `select`) {\n\t\tconst select = control as HTMLSelectElement\n\t\tif (select.selectedIndex < 0) {\n\t\t\tconst first = [...select.options].find((option) => !option.disabled)\n\t\t\tif (first) first.selected = true\n\t\t}\n\t}\n}\n\nfunction requestRestore(control: Control): void {\n\trequests.get(control)?.()\n\tif (control.localName !== `input` || control.type !== `radio`) return\n\tconst input = control as HTMLInputElement\n\tfor (const peer of (\n\t\tinput.getRootNode() as ParentNode\n\t).querySelectorAll<HTMLInputElement>(`input`)) {\n\t\tif (\n\t\t\tpeer !== input &&\n\t\t\tpeer.type === `radio` &&\n\t\t\tpeer.name === input.name &&\n\t\t\tpeer.form === input.form\n\t\t)\n\t\t\trequests.get(peer)?.()\n\t}\n}\n\n/** Restore controlled fields after event handlers and all queued option/prop updates. */\nexport function bindForm(\n\tcontrol: Control,\n\tprops: Record<string, any>,\n\tscope: Scope,\n): void {\n\tlet active: Event | undefined\n\tlet timer: ReturnType<typeof setTimeout> | undefined\n\tconst restore = () => {\n\t\tif (!isPresent(scope)) return true\n\t\tconst value = props[`value`]\n\t\tconst checked = control.localName === `input` ? props[`checked`] : undefined\n\t\tif (active?.eventPhase) return value == null && checked == null\n\t\tif (value != null) controlValue(control, value)\n\t\tif (checked != null) {\n\t\t\tconst input = control as HTMLInputElement\n\t\t\tif (input.checked !== Boolean(checked)) input.checked = Boolean(checked)\n\t\t}\n\t\treturn true\n\t}\n\tconst finish = () => {\n\t\tactive = undefined\n\t\tclearTimeout(timer)\n\t\tenqueue(scope, wake)\n\t}\n\tconst capture = (event: Event) => {\n\t\tif (event.type === `click` && !/^(checkbox|radio)$/.test(control.type))\n\t\t\treturn\n\t\tactive = event\n\t\tclearTimeout(timer)\n\t\t// A stopped native event never reaches the root's bubble listener.\n\t\ttimer = setTimeout(() => {\n\t\t\trequestRestore(control)\n\t\t}, 0)\n\t}\n\tconst root = scope._root\n\tif (!root._forms) {\n\t\troot._forms = new Set()\n\t\tconst end = (event: Event) => {\n\t\t\tconst target = event.target as Control\n\t\t\t// Checkbox/radio change follows click and input; its handlers must see the edit.\n\t\t\tif (\n\t\t\t\tevent.type === `click` ||\n\t\t\t\t(event.type === `input` && /^(checkbox|radio)$/.test(target.type))\n\t\t\t)\n\t\t\t\treturn\n\t\t\trequestRestore(target)\n\t\t}\n\t\tfor (const event of events) root._host!.addEventListener(event, end)\n\t\troot._cleanups.add(() => {\n\t\t\tfor (const event of events) root._host!.removeEventListener(event, end)\n\t\t})\n\t}\n\tconst forms = root._forms\n\tforms.add(restore)\n\trequests.set(control, finish)\n\tfor (const event of events) control.addEventListener(event, capture, true)\n\tscope._cleanups.add(() => {\n\t\tclearTimeout(timer)\n\t\tforms.delete(restore)\n\t\trequests.delete(control)\n\t\tfor (const event of events) control.removeEventListener(event, capture, true)\n\t})\n}\n","import type { Canonical } from \"atom.io/foundations/canonical\"\n\nimport { capabilityProps } from \"./capabilities.ts\"\nimport type {\n\tAccessor,\n\tChildren,\n\tRootOptions,\n\tScope,\n\tSpaElement,\n} 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 { bindForm, changeHandler, controlValue } from \"./dom-forms.ts\"\nimport { hotRoot, trackRoot } from \"./hot.ts\"\nimport { identifyChildren, trackKeys } from \"./identity.ts\"\nimport { Fragment } from \"./jsx-runtime.ts\"\nimport type { PresenceCollection } from \"./presence.ts\"\nimport { instanceProps } from \"./props.ts\"\n\nconst HTML = `http://www.w3.org/1999/xhtml`\nconst SVG = `http://www.w3.org/2000/svg`\ntype Cursor = {\n\tnode: Node | null\n\treport(expected: Node | null, found: Node | null): void\n}\ntype RecordNode = {\n\t_value: Children\n\t_scope: Scope\n\t_start: Node\n\t_end: Node\n\t_index: number\n}\nfunction compatible(record: RecordNode, child: Children): boolean {\n\treturn (\n\t\ttypeof record._value === typeof child &&\n\t\t(record._value as SpaElement | null)?.type ===\n\t\t\t(child as SpaElement | null)?.type\n\t)\n}\n\nfunction finish(cursor?: Cursor): void {\n\tif (cursor?.node) {\n\t\tcursor.report(null, cursor.node)\n\t\twhile (cursor.node) {\n\t\t\tconst node: Node = cursor.node\n\t\t\tcursor.node = node.nextSibling\n\t\t\t;(node as ChildNode).remove()\n\t\t}\n\t}\n}\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\tcursor.report(node, found)\n\t\t\tparent.insertBefore(node, found)\n\t\t\tcursor.node = found?.nextSibling ?? null\n\t\t\t;(found as ChildNode | null)?.remove()\n\t\t} else {\n\t\t\tnode = found\n\t\t\tcursor.node = found.nextSibling\n\t\t}\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\tconst events =\n\t\t\tevent === `change`\n\t\t\t\t? [`input`, `change`]\n\t\t\t\t: [event === `focus` ? `focusin` : event === `blur` ? `focusout` : event]\n\t\tif (previous)\n\t\t\tfor (const name of events)\n\t\t\t\telement.removeEventListener(\n\t\t\t\t\tname,\n\t\t\t\t\tevent === `change` ? changeHandler(previous) : previous,\n\t\t\t\t\tcapture,\n\t\t\t\t)\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\tfor (const name of events)\n\t\t\t\telement.addEventListener(\n\t\t\t\t\tname,\n\t\t\t\t\tevent === `change` ? changeHandler(value) : value,\n\t\t\t\t\tcapture,\n\t\t\t\t)\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 === SVG &&\n\t\tkey === `focusable` &&\n\t\ttypeof value === `boolean`\n\t)\n\t\tvalue = String(value)\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\tif (\n\t\t\tkey === `value` &&\n\t\t\t/^(input|textarea|select)$/.test(element.localName) &&\n\t\t\tvalue != null\n\t\t)\n\t\t\tcontrolValue(target, value)\n\t\telse target[key] = value ?? (typeof target[key] === `boolean` ? false : ``)\n\t\tif (value == null) element.removeAttribute(key)\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: Children,\n\tparent: Node,\n\tbefore: Node | null,\n\towner: Scope,\n\tnamespace: string,\n\tcursor?: Cursor,\n\tsource = () => value,\n\tinitialKey?: Canonical,\n): void {\n\tif (typeof value === `function`) {\n\t\tconst begin = comment(`{`, parent, before, owner, cursor)\n\t\tlet end: Node | null = null\n\t\tlet records = new Map<string | number, RecordNode>()\n\t\tlet presence: PresenceCollection<RecordNode, Children> | undefined\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() => identifyChildren((source() as () => Children)()),\n\t\t\t(values) => {\n\t\t\t\tpresence ??= owner._root._presence?.collection(\n\t\t\t\t\t(record: RecordNode) => record._scope,\n\t\t\t\t\tcompatible,\n\t\t\t\t)\n\t\t\t\tconst kept = new Map<string | number, RecordNode>()\n\t\t\t\tlet previous: RecordNode | undefined\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 { value: child, key, id } = values[index]\n\t\t\t\t\tlet record = records.get(id)\n\t\t\t\t\tif (record && !compatible(record, child)) {\n\t\t\t\t\t\tretire(\n\t\t\t\t\t\t\trecord,\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tchild == null || typeof child === `boolean`,\n\t\t\t\t\t\t\trecord._index,\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(id, child)\n\t\t\t\t\tif (!record) {\n\t\t\t\t\t\tconst at = previous ? previous._end.nextSibling : begin.nextSibling\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_index: index,\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, at, 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\tat,\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\tkey,\n\t\t\t\t\t\t)\n\t\t\t\t\t\trecord._end = comment(`]`, parent, at, childOwner, initial)\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\trecord._index = index\n\t\t\t\t\tprevious = record\n\t\t\t\t\tkept.set(id, 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)) retire(record, key, true, record._index)\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 SpaElement\n\tconst props = instanceProps(() => (source() as SpaElement).props, initialKey)\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(trackKeys(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 (ns === HTML && /^(input|textarea|select)$/.test(vnode.type))\n\t\tbindForm(element as HTMLInputElement, props, owner)\n\tif (ns === HTML && (props[`autoFocus`] || props[`autofocus`])) {\n\t\towner._root._mounts!.push(() => {\n\t\t\tif (!owner._dead) (element as HTMLElement).focus()\n\t\t})\n\t}\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\n\t\t\t? { node: element.firstChild, report: cursor.report }\n\t\t\t: 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\tfinish(children)\n\t}\n\tlet previous: Record<string, any> = {}\n\tconst nativeProps = capabilityProps(\n\t\towner,\n\t\t{ kind: `dom`, node: element },\n\t\t() => ({ ...props }),\n\t\t(next) => {\n\t\t\tconst previousStyle =\n\t\t\t\tprevious[`style`] !== next[`style`]\n\t\t\t\t\t? (element.getAttribute(`style`) ?? ``)\n\t\t\t\t\t: undefined\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\treturn previousStyle\n\t\t},\n\t)\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(owner, () => ({ ...props }), nativeProps)\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\twithin(owner, () => ref(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: () => Children,\n\thost: Element,\n\toptions: RootOptions,\n\thydrating: boolean,\n\tbefore: Node | null = null,\n): SpaRoot {\n\tlet reported = false\n\tconst cursor: Cursor | undefined = hydrating\n\t\t? {\n\t\t\t\tnode: host.firstChild,\n\t\t\t\treport(expected, found) {\n\t\t\t\t\tif (!reported) {\n\t\t\t\t\t\treported = true\n\t\t\t\t\t\t// eslint-disable-next-line no-console -- Recoverable degradation must remain human-readable in production.\n\t\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t\t`spa: hydration mismatch. Repairing server HTML to match the browser view; replaced nodes may lose focus or unsaved input.`,\n\t\t\t\t\t\t\t{ host, expected, found },\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t: undefined\n\tconst marker = cursor?.node\n\tconst prefix =\n\t\tmarker?.nodeType === 8 && marker.nodeValue?.startsWith(`w:`)\n\t\t\t? marker.nodeValue.slice(2)\n\t\t\t: undefined\n\tconst root = createRoot(options)\n\troot._host = host\n\tif (prefix !== undefined && options.idPrefix === undefined)\n\t\troot._prefix = prefix\n\tif (import.meta.env.DEV) trackRoot(root)\n\ttry {\n\t\tcomment(`w:${root._prefix}`, host, before, root, cursor)\n\t\twithin(root, () => {\n\t\t\tmount(\n\t\t\t\ttrackKeys(untrack(setup)),\n\t\t\t\thost,\n\t\t\t\tbefore,\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, before, root, cursor)\n\t\tfinish(cursor)\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: () => Children,\n\thost: Element,\n\toptions: RootOptions = {},\n): SpaRoot {\n\tif (import.meta.env.DEV)\n\t\treturn hotRoot(\n\t\t\t(next, before) => start(setup, host, next, false, before),\n\t\t\toptions,\n\t\t\thost,\n\t\t)\n\treturn start(setup, host, options, false)\n}\nexport function hydrate(\n\tsetup: () => Children,\n\thost: Element,\n\toptions: RootOptions = {},\n): SpaRoot {\n\tif (import.meta.env.DEV) {\n\t\tlet initial = true\n\t\treturn hotRoot(\n\t\t\t(next, before) => {\n\t\t\t\tconst current = start(setup, host, next, initial, before)\n\t\t\t\tinitial = false\n\t\t\t\treturn current\n\t\t\t},\n\t\t\toptions,\n\t\t\thost,\n\t\t)\n\t}\n\treturn start(setup, host, options, true)\n}\n"],"mappings":";;;;;AAIA,MAAM,0BAAU,IAAI,QAAsC;AAC1D,MAAM,2BAAW,IAAI,QAA6B;AAClD,MAAM,SAAS;CAAC;CAAS;CAAU;AAAO;AAC1C,MAAM,aAAa,CAAC;;AAGpB,SAAgB,cAAc,SAAuC;CACpE,IAAI,UAAU,QAAQ,IAAI,OAAO;CACjC,IAAI,CAAC,SAAS;EACb,WAAW,UAAU;GACpB,MAAM,SAAS,MAAM;GACrB,MAAM,UACL,QAAQ,cAAc,cACrB,QAAQ,cAAc,WACtB,CAAC,0BAA0B,KAAK,OAAO,IAAI;GAC7C,IAAI,MAAM,UAAU,UAAU,UAAU,WACvC,QAAQ,KAAK,MAAM,eAAe,KAAK;EACzC;EACA,QAAQ,IAAI,SAAS,OAAO;CAC7B;CACA,OAAO;AACR;AAEA,SAAgB,aAAa,SAAkB,OAA8B;CAC5E,IACC,QAAQ,cAAc,WACtB,QAAQ,SAAS,YACjB,OAAO,UAAU,YACjB,QAAQ,UAAU,MAClB,OAAO,QAAQ,KAAK,MAAM,OAE1B;CACD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AU,QAAQ,KAAK,CAAC,GACxB,MACA,QACA,MACA,KAAK,iBAAiB,MAAM,MAAM,MAClC,MACD;EACD,CAAC;EACD,QAAQ,MAAM,MAAM,QAAQ,MAAM,MAAM;EACxC,OAAO,MAAM;EACb,KAAK,MAAM;CACZ,SAAS,OAAO;EACf,KAAK,MAAM,KAAK;CACjB;CACA,OAAO;EACN,eAAe;GACd,QAAQ,IAAI;EACb;EACA,OAAO,KAAK;CACb;AACD;AACA,SAAgB,OACf,OACA,MACA,UAAuB,CAAC,GACd;CAET,OAAO,SACL,MAAM,WAAW,MAAM,OAAO,MAAM,MAAM,OAAO,MAAM,GACxD,SACA,IACD;AAEF;AACA,SAAgB,QACf,OACA,MACA,UAAuB,CAAC,GACd;CACe;EACxB,IAAI,UAAU;EACd,OAAO,SACL,MAAM,WAAW;GACjB,MAAM,UAAU,MAAM,OAAO,MAAM,MAAM,SAAS,MAAM;GACxD,UAAU;GACV,OAAO;EACR,GACA,SACA,IACD;CACD;AAED"}
@@ -1,4 +1,4 @@
1
- import { S as within, i as fail, l as onMount } from "./core-BHA7I1nf.js";
1
+ import { D as within, f as onMount, h as reportScopeError } from "./core-DrUd8x25.js";
2
2
  import { autoUpdate, computePosition } from "@floating-ui/dom";
3
3
  // src/floating.ts
4
4
  const allowed = /* @__PURE__ */ new Set([
@@ -58,11 +58,7 @@ function attach(target, scope) {
58
58
  });
59
59
  return;
60
60
  }
61
- try {
62
- fail(scope._root, error);
63
- } catch (failure) {
64
- scope._root.error(failure);
65
- }
61
+ reportScopeError(scope, error);
66
62
  };
67
63
  const updatePosition = () => {
68
64
  const anchor = reference;
@@ -1 +1 @@
1
- {"version":3,"file":"floating.js","names":[],"sources":["../../src/floating.ts"],"sourcesContent":["import type {\n\tAutoUpdateOptions,\n\tMiddleware,\n\tPlacement,\n\tReferenceElement,\n\tStrategy,\n} from \"@floating-ui/dom\"\nimport { autoUpdate, computePosition } from \"@floating-ui/dom\"\n\nimport type {\n\tCapability,\n\tCapabilityBinding,\n\tCapabilityTarget,\n} from \"./capabilities.ts\"\nimport type { Scope } from \"./core.ts\"\nimport { fail, onMount, within } from \"./core.ts\"\n\nexport interface FloatingAttributes<Kind extends string = `dom`> {\n\t[`floating:reference`]?: Kind extends `dom` ? ReferenceElement | null : never\n\t[`floating:placement`]?: Kind extends `dom` ? Placement : never\n\t[`floating:strategy`]?: Kind extends `dom` ? Strategy : never\n\t[`floating:middleware`]?: Kind extends `dom` ? readonly Middleware[] : never\n\t[`floating:enabled`]?: Kind extends `dom` ? boolean : never\n\t[`floating:autoUpdate`]?: Kind extends `dom`\n\t\t? boolean | AutoUpdateOptions\n\t\t: never\n}\n\n// eslint-disable-next-line quotes -- TypeScript module augmentation requires a string literal.\ndeclare module \"@atom.io/spa/jsx-runtime\" {\n\t// oxlint-disable-next-line typescript/no-empty-interface -- Declaration merging supplies optional floating attributes.\n\tinterface CapabilityAttributes<\n\t\tKind extends string,\n\t> extends FloatingAttributes<Kind> {}\n}\n\ninterface FloatingProps {\n\treference?: ReferenceElement | null\n\tplacement?: Placement\n\tstrategy?: Strategy\n\tmiddleware?: readonly Middleware[]\n\tenabled?: boolean\n\tautoUpdate?: boolean | AutoUpdateOptions\n}\nconst allowed = new Set([\n\t`reference`,\n\t`placement`,\n\t`strategy`,\n\t`middleware`,\n\t`enabled`,\n\t`autoUpdate`,\n])\nconst observerKeys = [\n\t`ancestorScroll`,\n\t`ancestorResize`,\n\t`elementResize`,\n\t`layoutShift`,\n\t`animationFrame`,\n] as const\nconst ownedStyles = [\n\t`position`,\n\t`left`,\n\t`top`,\n\t`translate`,\n\t`visibility`,\n] as const\n\nfunction attach(target: CapabilityTarget, scope?: Scope): CapabilityBinding {\n\tconst element = target.node as HTMLElement\n\tif (\n\t\ttarget.kind !== `dom` ||\n\t\telement?.namespaceURI !== `http://www.w3.org/1999/xhtml`\n\t)\n\t\tthrow new Error(`spa/floating: floating elements must be HTML elements`)\n\tlet props: FloatingProps = {}\n\tlet dead = false\n\tlet mounted = false\n\tlet generation = 0\n\tlet request = 0\n\tlet stop: (() => void) | undefined\n\tlet reference: ReferenceElement | undefined\n\tlet observing: boolean | AutoUpdateOptions | undefined\n\tlet original: Map<string, { value: string; priority: string }> | undefined\n\tlet positioned = false\n\tlet translation = ``\n\n\tconst restore = () => {\n\t\tif (!original) return\n\t\tfor (const [key, style] of original) {\n\t\t\tif (style.value)\n\t\t\t\telement.style.setProperty(key, style.value, style.priority)\n\t\t\telse element.style.removeProperty(key)\n\t\t}\n\t\toriginal = undefined\n\t\tpositioned = false\n\t\ttranslation = ``\n\t}\n\tconst disconnect = () => {\n\t\t++generation\n\t\tstop?.()\n\t\tstop = undefined\n\t\treference = undefined\n\t}\n\tconst report = (error: unknown) => {\n\t\tif (!scope) {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error\n\t\t\t})\n\t\t\treturn\n\t\t}\n\t\ttry {\n\t\t\tfail(scope._root, error)\n\t\t} catch (failure) {\n\t\t\tscope._root.error(failure)\n\t\t}\n\t}\n\tconst updatePosition = () => {\n\t\tconst anchor = reference\n\t\tif (dead || !anchor) return\n\t\tconst currentGeneration = generation\n\t\tconst currentRequest = ++request\n\t\tvoid computePosition(anchor, element, {\n\t\t\tplacement: props.placement ?? `bottom`,\n\t\t\tstrategy: props.strategy ?? `absolute`,\n\t\t\tmiddleware: props.middleware ? [...props.middleware] : [],\n\t\t}).then(\n\t\t\t({ x, y }) => {\n\t\t\t\tif (\n\t\t\t\t\tdead ||\n\t\t\t\t\tgeneration !== currentGeneration ||\n\t\t\t\t\tcurrentRequest !== request\n\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\ttranslation = `${x}px ${y}px`\n\t\t\t\telement.style.setProperty(`translate`, translation)\n\t\t\t\tif (!positioned) {\n\t\t\t\t\tpositioned = true\n\t\t\t\t\tconst visibility = original!.get(`visibility`)!\n\t\t\t\t\tif (visibility.value)\n\t\t\t\t\t\telement.style.setProperty(\n\t\t\t\t\t\t\t`visibility`,\n\t\t\t\t\t\t\tvisibility.value,\n\t\t\t\t\t\t\tvisibility.priority,\n\t\t\t\t\t\t)\n\t\t\t\t\telse element.style.removeProperty(`visibility`)\n\t\t\t\t}\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tif (\n\t\t\t\t\t!dead &&\n\t\t\t\t\tgeneration === currentGeneration &&\n\t\t\t\t\tcurrentRequest === request\n\t\t\t\t)\n\t\t\t\t\treport(error)\n\t\t\t},\n\t\t)\n\t}\n\tconst connect = () => {\n\t\tif (dead || !mounted) return\n\t\tconst nextReference =\n\t\t\tprops.enabled === false ? undefined : (props.reference ?? undefined)\n\t\tconst nextObserving = props.autoUpdate ?? true\n\t\tconst optionsChanged =\n\t\t\ttypeof nextObserving !== typeof observing ||\n\t\t\t(typeof nextObserving === `object` && typeof observing === `object`\n\t\t\t\t? observerKeys.some(\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t\tnextObserving[key] !== (observing as AutoUpdateOptions)[key],\n\t\t\t\t\t)\n\t\t\t\t: nextObserving !== observing)\n\t\tconst reconnect = nextReference !== reference || optionsChanged\n\t\tif (reconnect) disconnect()\n\t\tif (!nextReference) {\n\t\t\trestore()\n\t\t\treturn\n\t\t}\n\t\toriginal ??= new Map(\n\t\t\townedStyles.map((key) => [\n\t\t\t\tkey,\n\t\t\t\t{\n\t\t\t\t\tvalue: element.style.getPropertyValue(key),\n\t\t\t\t\tpriority: element.style.getPropertyPriority(key),\n\t\t\t\t},\n\t\t\t]),\n\t\t)\n\t\telement.style.setProperty(`position`, props.strategy ?? `absolute`)\n\t\telement.style.setProperty(`left`, `0px`)\n\t\telement.style.setProperty(`top`, `0px`)\n\t\tif (positioned) element.style.setProperty(`translate`, translation)\n\t\telse element.style.setProperty(`visibility`, `hidden`, `important`)\n\t\treference = nextReference\n\t\tobserving =\n\t\t\ttypeof nextObserving === `object` ? { ...nextObserving } : nextObserving\n\t\tif (reconnect && nextObserving !== false) {\n\t\t\tstop = autoUpdate(\n\t\t\t\tnextReference,\n\t\t\t\telement,\n\t\t\t\tupdatePosition,\n\t\t\t\ttypeof nextObserving === `object` ? nextObserving : undefined,\n\t\t\t)\n\t\t} else updatePosition()\n\t}\n\tconst mount = () => {\n\t\tif (dead) return\n\t\tmounted = true\n\t\tconnect()\n\t}\n\tif (scope)\n\t\twithin(scope, () => {\n\t\t\tonMount(mount)\n\t\t})\n\telse queueMicrotask(mount)\n\treturn {\n\t\tupdate(next) {\n\t\t\tif (dead) return\n\t\t\tfor (const key of Object.keys(next))\n\t\t\t\tif (!allowed.has(key))\n\t\t\t\t\tthrow new Error(`spa/floating: unknown property floating:${key}`)\n\t\t\tprops = next\n\t\t\tconnect()\n\t\t},\n\t\tdispose() {\n\t\t\tif (dead) return\n\t\t\tdead = true\n\t\t\tdisconnect()\n\t\t\trestore()\n\t\t},\n\t}\n}\n\n/** Position HTML overlays using CSS translate, leaving transform available to Motion. */\nexport function floatingCapability(): Capability {\n\treturn { namespace: `floating`, attach }\n}\n"],"mappings":";;;AA4CA,MAAM,0BAAU,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AACD,MAAM,eAAe;CACpB;CACA;CACA;CACA;CACA;AACD;AACA,MAAM,cAAc;CACnB;CACA;CACA;CACA;CACA;AACD;AAEA,SAAS,OAAO,QAA0B,OAAkC;CAC3E,MAAM,UAAU,OAAO;CACvB,IACC,OAAO,SAAS,SAChB,SAAS,iBAAiB,gCAE1B,MAAM,IAAI,MAAM,uDAAuD;CACxE,IAAI,QAAuB,CAAC;CAC5B,IAAI,OAAO;CACX,IAAI,UAAU;CACd,IAAI,aAAa;CACjB,IAAI,UAAU;CACd,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,aAAa;CACjB,IAAI,cAAc;CAElB,MAAM,gBAAgB;EACrB,IAAI,CAAC,UAAU;EACf,KAAK,MAAM,CAAC,KAAK,UAAU,UAC1B,IAAI,MAAM,OACT,QAAQ,MAAM,YAAY,KA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O;EAAE,WAAW;EAAY;CAAO;AACxC"}
1
+ {"version":3,"file":"floating.js","names":[],"sources":["../../src/floating.ts"],"sourcesContent":["import type {\n\tAutoUpdateOptions,\n\tMiddleware,\n\tPlacement,\n\tReferenceElement,\n\tStrategy,\n} from \"@floating-ui/dom\"\nimport { autoUpdate, computePosition } from \"@floating-ui/dom\"\n\nimport type {\n\tCapability,\n\tCapabilityBinding,\n\tCapabilityTarget,\n} from \"./capabilities.ts\"\nimport type { Scope } from \"./core.ts\"\nimport { onMount, reportScopeError, within } from \"./core.ts\"\n\nexport interface FloatingAttributes<Kind extends string = `dom`> {\n\t[`floating:reference`]?: Kind extends `dom` ? ReferenceElement | null : never\n\t[`floating:placement`]?: Kind extends `dom` ? Placement : never\n\t[`floating:strategy`]?: Kind extends `dom` ? Strategy : never\n\t[`floating:middleware`]?: Kind extends `dom` ? readonly Middleware[] : never\n\t[`floating:enabled`]?: Kind extends `dom` ? boolean : never\n\t[`floating:autoUpdate`]?: Kind extends `dom`\n\t\t? boolean | AutoUpdateOptions\n\t\t: never\n}\n\n// eslint-disable-next-line quotes -- TypeScript module augmentation requires a string literal.\ndeclare module \"@atom.io/spa/jsx-runtime\" {\n\t// oxlint-disable-next-line typescript/no-empty-interface -- Declaration merging supplies optional floating attributes.\n\tinterface CapabilityAttributes<\n\t\tKind extends string,\n\t> extends FloatingAttributes<Kind> {}\n}\n\ninterface FloatingProps {\n\treference?: ReferenceElement | null\n\tplacement?: Placement\n\tstrategy?: Strategy\n\tmiddleware?: readonly Middleware[]\n\tenabled?: boolean\n\tautoUpdate?: boolean | AutoUpdateOptions\n}\nconst allowed = new Set([\n\t`reference`,\n\t`placement`,\n\t`strategy`,\n\t`middleware`,\n\t`enabled`,\n\t`autoUpdate`,\n])\nconst observerKeys = [\n\t`ancestorScroll`,\n\t`ancestorResize`,\n\t`elementResize`,\n\t`layoutShift`,\n\t`animationFrame`,\n] as const\nconst ownedStyles = [\n\t`position`,\n\t`left`,\n\t`top`,\n\t`translate`,\n\t`visibility`,\n] as const\n\nfunction attach(target: CapabilityTarget, scope?: Scope): CapabilityBinding {\n\tconst element = target.node as HTMLElement\n\tif (\n\t\ttarget.kind !== `dom` ||\n\t\telement?.namespaceURI !== `http://www.w3.org/1999/xhtml`\n\t)\n\t\tthrow new Error(`spa/floating: floating elements must be HTML elements`)\n\tlet props: FloatingProps = {}\n\tlet dead = false\n\tlet mounted = false\n\tlet generation = 0\n\tlet request = 0\n\tlet stop: (() => void) | undefined\n\tlet reference: ReferenceElement | undefined\n\tlet observing: boolean | AutoUpdateOptions | undefined\n\tlet original: Map<string, { value: string; priority: string }> | undefined\n\tlet positioned = false\n\tlet translation = ``\n\n\tconst restore = () => {\n\t\tif (!original) return\n\t\tfor (const [key, style] of original) {\n\t\t\tif (style.value)\n\t\t\t\telement.style.setProperty(key, style.value, style.priority)\n\t\t\telse element.style.removeProperty(key)\n\t\t}\n\t\toriginal = undefined\n\t\tpositioned = false\n\t\ttranslation = ``\n\t}\n\tconst disconnect = () => {\n\t\t++generation\n\t\tstop?.()\n\t\tstop = undefined\n\t\treference = undefined\n\t}\n\tconst report = (error: unknown) => {\n\t\tif (!scope) {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error\n\t\t\t})\n\t\t\treturn\n\t\t}\n\t\treportScopeError(scope, error)\n\t}\n\tconst updatePosition = () => {\n\t\tconst anchor = reference\n\t\tif (dead || !anchor) return\n\t\tconst currentGeneration = generation\n\t\tconst currentRequest = ++request\n\t\tvoid computePosition(anchor, element, {\n\t\t\tplacement: props.placement ?? `bottom`,\n\t\t\tstrategy: props.strategy ?? `absolute`,\n\t\t\tmiddleware: props.middleware ? [...props.middleware] : [],\n\t\t}).then(\n\t\t\t({ x, y }) => {\n\t\t\t\tif (\n\t\t\t\t\tdead ||\n\t\t\t\t\tgeneration !== currentGeneration ||\n\t\t\t\t\tcurrentRequest !== request\n\t\t\t\t)\n\t\t\t\t\treturn\n\t\t\t\ttranslation = `${x}px ${y}px`\n\t\t\t\telement.style.setProperty(`translate`, translation)\n\t\t\t\tif (!positioned) {\n\t\t\t\t\tpositioned = true\n\t\t\t\t\tconst visibility = original!.get(`visibility`)!\n\t\t\t\t\tif (visibility.value)\n\t\t\t\t\t\telement.style.setProperty(\n\t\t\t\t\t\t\t`visibility`,\n\t\t\t\t\t\t\tvisibility.value,\n\t\t\t\t\t\t\tvisibility.priority,\n\t\t\t\t\t\t)\n\t\t\t\t\telse element.style.removeProperty(`visibility`)\n\t\t\t\t}\n\t\t\t},\n\t\t\t(error: unknown) => {\n\t\t\t\tif (\n\t\t\t\t\t!dead &&\n\t\t\t\t\tgeneration === currentGeneration &&\n\t\t\t\t\tcurrentRequest === request\n\t\t\t\t)\n\t\t\t\t\treport(error)\n\t\t\t},\n\t\t)\n\t}\n\tconst connect = () => {\n\t\tif (dead || !mounted) return\n\t\tconst nextReference =\n\t\t\tprops.enabled === false ? undefined : (props.reference ?? undefined)\n\t\tconst nextObserving = props.autoUpdate ?? true\n\t\tconst optionsChanged =\n\t\t\ttypeof nextObserving !== typeof observing ||\n\t\t\t(typeof nextObserving === `object` && typeof observing === `object`\n\t\t\t\t? observerKeys.some(\n\t\t\t\t\t\t(key) =>\n\t\t\t\t\t\t\tnextObserving[key] !== (observing as AutoUpdateOptions)[key],\n\t\t\t\t\t)\n\t\t\t\t: nextObserving !== observing)\n\t\tconst reconnect = nextReference !== reference || optionsChanged\n\t\tif (reconnect) disconnect()\n\t\tif (!nextReference) {\n\t\t\trestore()\n\t\t\treturn\n\t\t}\n\t\toriginal ??= new Map(\n\t\t\townedStyles.map((key) => [\n\t\t\t\tkey,\n\t\t\t\t{\n\t\t\t\t\tvalue: element.style.getPropertyValue(key),\n\t\t\t\t\tpriority: element.style.getPropertyPriority(key),\n\t\t\t\t},\n\t\t\t]),\n\t\t)\n\t\telement.style.setProperty(`position`, props.strategy ?? `absolute`)\n\t\telement.style.setProperty(`left`, `0px`)\n\t\telement.style.setProperty(`top`, `0px`)\n\t\tif (positioned) element.style.setProperty(`translate`, translation)\n\t\telse element.style.setProperty(`visibility`, `hidden`, `important`)\n\t\treference = nextReference\n\t\tobserving =\n\t\t\ttypeof nextObserving === `object` ? { ...nextObserving } : nextObserving\n\t\tif (reconnect && nextObserving !== false) {\n\t\t\tstop = autoUpdate(\n\t\t\t\tnextReference,\n\t\t\t\telement,\n\t\t\t\tupdatePosition,\n\t\t\t\ttypeof nextObserving === `object` ? nextObserving : undefined,\n\t\t\t)\n\t\t} else updatePosition()\n\t}\n\tconst mount = () => {\n\t\tif (dead) return\n\t\tmounted = true\n\t\tconnect()\n\t}\n\tif (scope)\n\t\twithin(scope, () => {\n\t\t\tonMount(mount)\n\t\t})\n\telse queueMicrotask(mount)\n\treturn {\n\t\tupdate(next) {\n\t\t\tif (dead) return\n\t\t\tfor (const key of Object.keys(next))\n\t\t\t\tif (!allowed.has(key))\n\t\t\t\t\tthrow new Error(`spa/floating: unknown property floating:${key}`)\n\t\t\tprops = next\n\t\t\tconnect()\n\t\t},\n\t\tdispose() {\n\t\t\tif (dead) return\n\t\t\tdead = true\n\t\t\tdisconnect()\n\t\t\trestore()\n\t\t},\n\t}\n}\n\n/** Position HTML overlays using CSS translate, leaving transform available to Motion. */\nexport function floatingCapability(): Capability {\n\treturn { namespace: `floating`, attach }\n}\n"],"mappings":";;;AA4CA,MAAM,0BAAU,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AACD,MAAM,eAAe;CACpB;CACA;CACA;CACA;CACA;AACD;AACA,MAAM,cAAc;CACnB;CACA;CACA;CACA;CACA;AACD;AAEA,SAAS,OAAO,QAA0B,OAAkC;CAC3E,MAAM,UAAU,OAAO;CACvB,IACC,OAAO,SAAS,SAChB,SAAS,iBAAiB,gCAE1B,MAAM,IAAI,MAAM,uDAAuD;CACxE,IAAI,QAAuB,CAAC;CAC5B,IAAI,OAAO;CACX,IAAI,UAAU;CACd,IAAI,aAAa;CACjB,IAAI,UAAU;CACd,IAAI;CACJ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;GACR,QAAQ;EACT;EACA,UAAU;GACT,IAAI,MAAM;GACV,OAAO;GACP,WAAW;GACX,QAAQ;EACT;CACD;AACD;;AAGA,SAAgB,qBAAiC;CAChD,OAAO;EAAE,WAAW;EAAY;CAAO;AACxC"}
@@ -0,0 +1,164 @@
1
+ import { p as owner, u as onCleanup } from "./core-DrUd8x25.js";
2
+ import { IMPLICIT } from "atom.io/internal";
3
+ // src/hot.ts
4
+ function createHotRuntime() {
5
+ const components = /* @__PURE__ */ new Map();
6
+ const roots = /* @__PURE__ */ new WeakMap();
7
+ const views = /* @__PURE__ */ new Set();
8
+ let mounting;
9
+ function track(root) {
10
+ if (mounting) {
11
+ roots.set(root, mounting);
12
+ mounting.options.idPrefix ??= root._prefix;
13
+ }
14
+ }
15
+ function onDispose(cleanup) {
16
+ const view = roots.get(owner._root);
17
+ onCleanup(() => {
18
+ if (!view?.refreshing) cleanup();
19
+ });
20
+ }
21
+ function register(id, name, implementation) {
22
+ const key = JSON.stringify([id, name]);
23
+ let record = components.get(key);
24
+ if (record) record.current = implementation;
25
+ else {
26
+ const created = {
27
+ current: implementation,
28
+ proxy: null
29
+ };
30
+ created.proxy = Object.assign((props) => {
31
+ if (owner) {
32
+ const root = owner._root;
33
+ const view = roots.get(root) ?? mounting;
34
+ if (view) {
35
+ roots.set(root, view);
36
+ view.options.idPrefix ??= root._prefix;
37
+ view.modules.add(id);
38
+ }
39
+ }
40
+ return created.current(props);
41
+ }, { spa: true });
42
+ record = created;
43
+ components.set(key, record);
44
+ }
45
+ return record.proxy;
46
+ }
47
+ function manage(factory, options, host) {
48
+ const settings = {
49
+ ...options,
50
+ store: options.store ?? IMPLICIT.STORE
51
+ };
52
+ const anchor = host?.ownerDocument.createComment(`spa-hot`);
53
+ let current;
54
+ let errorNode;
55
+ let disposed = false;
56
+ const placeAnchor = () => {
57
+ if (!anchor || anchor.parentNode) return;
58
+ let inside = false;
59
+ for (const node of [...host.childNodes]) {
60
+ if (node.nodeType === 8 && node.nodeValue === `w:${settings.idPrefix}`) inside = true;
61
+ if (inside && node.nodeType === 8 && node.nodeValue === `/w`) {
62
+ host.insertBefore(anchor, node.nextSibling);
63
+ return;
64
+ }
65
+ }
66
+ host.append(anchor);
67
+ };
68
+ const boot = () => {
69
+ const previous = mounting;
70
+ mounting = view;
71
+ try {
72
+ current = factory(settings, anchor?.parentNode ? anchor : null);
73
+ } finally {
74
+ mounting = previous;
75
+ }
76
+ };
77
+ const view = {
78
+ modules: /* @__PURE__ */ new Set(),
79
+ options: settings,
80
+ refreshing: false,
81
+ refresh() {
82
+ view.refreshing = true;
83
+ try {
84
+ placeAnchor();
85
+ current.dispose();
86
+ errorNode?.remove();
87
+ boot();
88
+ } finally {
89
+ view.refreshing = false;
90
+ }
91
+ },
92
+ report(error) {
93
+ const target = host ?? (typeof document === `undefined` ? void 0 : document.body);
94
+ if (target) {
95
+ errorNode = target.ownerDocument.createElement(`pre`);
96
+ errorNode.setAttribute(`data-spa-hot-error`, ``);
97
+ errorNode.textContent = `SPA hot refresh failed: ${String(error)}`;
98
+ target.insertBefore(errorNode, anchor?.parentNode ? anchor : null);
99
+ }
100
+ options.onError?.(error);
101
+ }
102
+ };
103
+ views.add(view);
104
+ try {
105
+ boot();
106
+ } catch (error) {
107
+ views.delete(view);
108
+ throw error;
109
+ }
110
+ if (view.modules.size) placeAnchor();
111
+ return {
112
+ flush() {
113
+ current.flush();
114
+ },
115
+ dispose() {
116
+ if (disposed) return;
117
+ disposed = true;
118
+ views.delete(view);
119
+ errorNode?.remove();
120
+ anchor?.remove();
121
+ current.dispose();
122
+ }
123
+ };
124
+ }
125
+ function refreshViews(id) {
126
+ for (const view of [...views]) {
127
+ if (!views.has(view) || !view.modules.has(id)) continue;
128
+ try {
129
+ view.refresh();
130
+ } catch (error) {
131
+ view.report(error);
132
+ }
133
+ }
134
+ }
135
+ return {
136
+ register,
137
+ root: manage,
138
+ refresh: refreshViews,
139
+ track,
140
+ onDispose
141
+ };
142
+ }
143
+ const runtime = createHotRuntime();
144
+ /** Development protocol used by the Vite transform. */
145
+ function registerComponent(id, name, implementation) {
146
+ return runtime ? runtime.register(id, name, implementation) : implementation;
147
+ }
148
+ function refresh(id) {
149
+ runtime?.refresh(id);
150
+ }
151
+ function trackRoot(root) {
152
+ runtime?.track(root);
153
+ }
154
+ /** Release root lifetime resources, retaining them through development remounts. */
155
+ function onRootDispose(cleanup) {
156
+ if (runtime) runtime.onDispose(cleanup);
157
+ else onCleanup(cleanup);
158
+ }
159
+ function hotRoot(factory, options, host) {
160
+ return runtime ? runtime.root(factory, options, host) : factory(options, null);
161
+ }
162
+ export { hotRoot, onRootDispose, refresh, registerComponent, trackRoot };
163
+
164
+ //# sourceMappingURL=hot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hot.js","names":[],"sources":["../../src/hot.ts"],"sourcesContent":["import { IMPLICIT } from \"atom.io/internal\"\n\nimport type { Component, Root, RootOptions } from \"./core.ts\"\nimport { onCleanup, owner } from \"./core.ts\"\n\ninterface Handle {\n\tdispose(): void\n\tflush(): void\n}\ntype Factory = (options: RootOptions, before: Node | null) => Handle\ninterface View {\n\tmodules: Set<string>\n\toptions: RootOptions\n\trefreshing: boolean\n\trefresh(): void\n\treport(error: unknown): void\n}\n\nfunction createHotRuntime() {\n\tconst components = new Map<string, { current: Component; proxy: Component }>()\n\tconst roots = new WeakMap<Root, View>()\n\tconst views = new Set<View>()\n\tlet mounting: View | undefined\n\tfunction track(root: Root): void {\n\t\tif (mounting) {\n\t\t\troots.set(root, mounting)\n\t\t\tmounting.options.idPrefix ??= root._prefix\n\t\t}\n\t}\n\tfunction onDispose(cleanup: () => void): void {\n\t\tconst view = roots.get(owner!._root)\n\t\tonCleanup(() => {\n\t\t\tif (!view?.refreshing) cleanup()\n\t\t})\n\t}\n\tfunction register<T extends Component>(\n\t\tid: string,\n\t\tname: string,\n\t\timplementation: T,\n\t): T {\n\t\tconst key = JSON.stringify([id, name])\n\t\tlet record = components.get(key)\n\t\tif (record) record.current = implementation\n\t\telse {\n\t\t\tconst created = {\n\t\t\t\tcurrent: implementation as Component,\n\t\t\t\tproxy: null! as Component,\n\t\t\t}\n\t\t\tcreated.proxy = Object.assign(\n\t\t\t\t(props: Record<string, any>) => {\n\t\t\t\t\tif (owner) {\n\t\t\t\t\t\tconst root = owner._root\n\t\t\t\t\t\tconst view = roots.get(root) ?? mounting\n\t\t\t\t\t\tif (view) {\n\t\t\t\t\t\t\troots.set(root, view)\n\t\t\t\t\t\t\tview.options.idPrefix ??= root._prefix\n\t\t\t\t\t\t\tview.modules.add(id)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn created.current(props)\n\t\t\t\t},\n\t\t\t\t{ spa: true },\n\t\t\t)\n\t\t\trecord = created\n\t\t\tcomponents.set(key, record)\n\t\t}\n\t\treturn record.proxy as T\n\t}\n\tfunction manage(\n\t\tfactory: Factory,\n\t\toptions: RootOptions,\n\t\thost?: Element,\n\t): Handle {\n\t\tconst settings = { ...options, store: options.store ?? IMPLICIT.STORE }\n\t\tconst anchor = host?.ownerDocument.createComment(`spa-hot`)\n\t\tlet current: Handle\n\t\tlet errorNode: HTMLElement | undefined\n\t\tlet disposed = false\n\t\tconst placeAnchor = () => {\n\t\t\tif (!anchor || anchor.parentNode) return\n\t\t\tlet inside = false\n\t\t\tfor (const node of [...host!.childNodes]) {\n\t\t\t\tif (node.nodeType === 8 && node.nodeValue === `w:${settings.idPrefix}`)\n\t\t\t\t\tinside = true\n\t\t\t\tif (inside && node.nodeType === 8 && node.nodeValue === `/w`) {\n\t\t\t\t\thost!.insertBefore(anchor, node.nextSibling)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\thost!.append(anchor)\n\t\t}\n\t\tconst boot = () => {\n\t\t\tconst previous = mounting\n\t\t\tmounting = view\n\t\t\ttry {\n\t\t\t\tcurrent = factory(settings, anchor?.parentNode ? anchor : null)\n\t\t\t} finally {\n\t\t\t\tmounting = previous\n\t\t\t}\n\t\t}\n\t\tconst view: View = {\n\t\t\tmodules: new Set(),\n\t\t\toptions: settings,\n\t\t\trefreshing: false,\n\t\t\trefresh() {\n\t\t\t\tview.refreshing = true\n\t\t\t\ttry {\n\t\t\t\t\tplaceAnchor()\n\t\t\t\t\tcurrent.dispose()\n\t\t\t\t\terrorNode?.remove()\n\t\t\t\t\tboot()\n\t\t\t\t} finally {\n\t\t\t\t\tview.refreshing = false\n\t\t\t\t}\n\t\t\t},\n\t\t\treport(error) {\n\t\t\t\tconst target =\n\t\t\t\t\thost ?? (typeof document === `undefined` ? undefined : document.body)\n\t\t\t\tif (target) {\n\t\t\t\t\terrorNode = target.ownerDocument.createElement(`pre`)\n\t\t\t\t\terrorNode.setAttribute(`data-spa-hot-error`, ``)\n\t\t\t\t\terrorNode.textContent = `SPA hot refresh failed: ${String(error)}`\n\t\t\t\t\ttarget.insertBefore(errorNode, anchor?.parentNode ? anchor : null)\n\t\t\t\t}\n\t\t\t\toptions.onError?.(error)\n\t\t\t},\n\t\t}\n\t\tviews.add(view)\n\t\ttry {\n\t\t\tboot()\n\t\t} catch (error) {\n\t\t\tviews.delete(view)\n\t\t\tthrow error\n\t\t}\n\t\tif (view.modules.size) placeAnchor()\n\t\treturn {\n\t\t\tflush() {\n\t\t\t\tcurrent.flush()\n\t\t\t},\n\t\t\tdispose() {\n\t\t\t\tif (disposed) return\n\t\t\t\tdisposed = true\n\t\t\t\tviews.delete(view)\n\t\t\t\terrorNode?.remove()\n\t\t\t\tanchor?.remove()\n\t\t\t\tcurrent.dispose()\n\t\t\t},\n\t\t}\n\t}\n\tfunction refreshViews(id: string): void {\n\t\tfor (const view of [...views]) {\n\t\t\tif (!views.has(view) || !view.modules.has(id)) continue\n\t\t\ttry {\n\t\t\t\tview.refresh()\n\t\t\t} catch (error) {\n\t\t\t\tview.report(error)\n\t\t\t}\n\t\t}\n\t}\n\treturn { register, root: manage, refresh: refreshViews, track, onDispose }\n}\n\nconst runtime = import.meta.env.DEV ? createHotRuntime() : undefined\n\n/** Development protocol used by the Vite transform. */\nexport function registerComponent<T extends Component>(\n\tid: string,\n\tname: string,\n\timplementation: T,\n): T {\n\treturn runtime ? runtime.register(id, name, implementation) : implementation\n}\nexport function refresh(id: string): void {\n\truntime?.refresh(id)\n}\nexport function trackRoot(root: Root): void {\n\truntime?.track(root)\n}\n/** Release root lifetime resources, retaining them through development remounts. */\nexport function onRootDispose(cleanup: () => void): void {\n\tif (runtime) runtime.onDispose(cleanup)\n\telse onCleanup(cleanup)\n}\nexport function hotRoot(\n\tfactory: Factory,\n\toptions: RootOptions,\n\thost?: Element,\n): Handle {\n\treturn runtime ? runtime.root(factory, options, host) : factory(options, null)\n}\n"],"mappings":";;;AAkBA,SAAS,mBAAmB;CAC3B,MAAM,6BAAa,IAAI,IAAsD;CAC7E,MAAM,wBAAQ,IAAI,QAAoB;CACtC,MAAM,wBAAQ,IAAI,IAAU;CAC5B,IAAI;CACJ,SAAS,MAAM,MAAkB;EAChC,IAAI,UAAU;GACb,MAAM,IAAI,MAAM,QAAQ;GACxB,SAAS,QAAQ,aAAa,KAAK;EACpC;CACD;CACA,SAAS,UAAU,SAA2B;EAC7C,MAAM,OAAO,MAAM,IAAI,MAAO,KAAK;EACnC,gBAAgB;GACf,IAAI,CAAC,MAAM,YAAY,QAAQ;EAChC,CAAC;CACF;CACA,SAAS,SACR,IACA,MACA,gBACI;EACJ,MAAM,MAAM,KAAK,UAAU,CAAC,IAAI,IAAI,CAAC;EACrC,IAAI,SAAS,WAAW,IAAI,GAAG;EAC/B,IAAI,QAAQ,OAAO,UAAU;OACxB;GACJ,MAAM,UAAU;IACf,SAAS;IACT,OAAO;GACR;GACA,QAAQ,QAAQ,OAAO,QACrB,UAA+B;IAC/B,IAAI,OAAO;KACV,MAAM,OAAO,MAAM;KACnB,MAAM,OAAO,MAAM,IAAI,IAAI,KAAK;KAChC,IAAI,MAAM;MACT,MAAM,IAAI,MAAM,IAAI;MACpB,KAAK,QAAQ,aAAa,KAAK;MA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