@atom.io/spa 0.0.9 → 0.0.10

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 (86) hide show
  1. package/README.md +30 -10
  2. package/README.mdx +16 -5
  3. package/dist/BrandMarkScene-CBYk-RJ2.js +140 -0
  4. package/dist/BrandMarkScene-CBYk-RJ2.js.map +1 -0
  5. package/dist/astro-client.js +1 -1
  6. package/dist/astro-server.js +1 -1
  7. package/dist/brand-css.d.ts +2 -0
  8. package/dist/brand-model.d.ts +32 -0
  9. package/dist/brand-model.d.ts.map +1 -0
  10. package/dist/brand-model.js +120 -0
  11. package/dist/brand-model.js.map +1 -0
  12. package/dist/brand.css +37 -0
  13. package/dist/brand.d.ts +13 -0
  14. package/dist/brand.d.ts.map +1 -0
  15. package/dist/brand.js +94 -0
  16. package/dist/brand.js.map +1 -0
  17. package/dist/client.min.js +1 -1
  18. package/dist/development/BrandMarkScene-BDdC7K5M.js +140 -0
  19. package/dist/development/BrandMarkScene-BDdC7K5M.js.map +1 -0
  20. package/dist/development/astro-client.js +1 -1
  21. package/dist/development/astro-server.js +1 -1
  22. package/dist/development/brand-model.js +120 -0
  23. package/dist/development/brand-model.js.map +1 -0
  24. package/dist/development/brand.css +37 -0
  25. package/dist/development/brand.js +94 -0
  26. package/dist/development/brand.js.map +1 -0
  27. package/dist/development/{dom-BRFv7FP_.js → dom-CEVtlaav.js} +4 -3
  28. package/dist/development/dom-CEVtlaav.js.map +1 -0
  29. package/dist/development/floating.js.map +1 -1
  30. package/dist/development/hot.js +2 -2
  31. package/dist/development/hot.js.map +1 -1
  32. package/dist/development/{identity-DwB8MTM1.js → identity-B8wTFkyW.js} +2 -2
  33. package/dist/development/{identity-DwB8MTM1.js.map → identity-B8wTFkyW.js.map} +1 -1
  34. package/dist/development/index.js +1 -1
  35. package/dist/development/konva.js +1 -1
  36. package/dist/development/motion.js +38 -19
  37. package/dist/development/motion.js.map +1 -1
  38. package/dist/development/renderer.js +1 -1
  39. package/dist/development/{server-renderer-u1-c5PGd.js → server-renderer-zAqEL1g1.js} +2 -2
  40. package/dist/development/{server-renderer-u1-c5PGd.js.map → server-renderer-zAqEL1g1.js.map} +1 -1
  41. package/dist/development/server.js +1 -1
  42. package/dist/development/three-CsZ6Od1C.js +527 -0
  43. package/dist/development/three-CsZ6Od1C.js.map +1 -0
  44. package/dist/development/three.js +1 -509
  45. package/dist/{dom--HZvmgqd.js → dom-DUpa3Sj2.js} +4 -3
  46. package/dist/dom-DUpa3Sj2.js.map +1 -0
  47. package/dist/floating.js.map +1 -1
  48. package/dist/hot.d.ts.map +1 -1
  49. package/dist/hot.js.map +1 -1
  50. package/dist/{identity-oFU5p-Qj.js → identity-ByJswZtF.js} +2 -2
  51. package/dist/{identity-oFU5p-Qj.js.map → identity-ByJswZtF.js.map} +1 -1
  52. package/dist/index-DdA39aMv.d.ts.map +1 -1
  53. package/dist/index.js +1 -1
  54. package/dist/konva.js +1 -1
  55. package/dist/motion.d.ts +2 -0
  56. package/dist/motion.d.ts.map +1 -1
  57. package/dist/motion.js +38 -19
  58. package/dist/motion.js.map +1 -1
  59. package/dist/renderer.js +1 -1
  60. package/dist/{server-renderer-BYFDmqnM.js → server-renderer-D7CdyOMo.js} +2 -2
  61. package/dist/{server-renderer-BYFDmqnM.js.map → server-renderer-D7CdyOMo.js.map} +1 -1
  62. package/dist/server.js +1 -1
  63. package/dist/size.json +12 -12
  64. package/dist/three-DcYxRXPW.js +527 -0
  65. package/dist/three-DcYxRXPW.js.map +1 -0
  66. package/dist/three.d.ts +21 -0
  67. package/dist/three.d.ts.map +1 -1
  68. package/dist/three.js +1 -509
  69. package/package.json +39 -19
  70. package/src/BrandMark.module.css +25 -0
  71. package/src/BrandMark.tsx +106 -0
  72. package/src/BrandMarkScene.module.css +10 -0
  73. package/src/BrandMarkScene.tsx +116 -0
  74. package/src/brand-css.d.ts +2 -0
  75. package/src/brand-model.ts +177 -0
  76. package/src/brand.ts +3 -0
  77. package/src/dom.ts +8 -1
  78. package/src/hot.ts +3 -2
  79. package/src/lasertag.d.ts +1 -0
  80. package/src/motion-layout.ts +55 -26
  81. package/src/motion.ts +3 -0
  82. package/src/three.ts +69 -22
  83. package/dist/development/dom-BRFv7FP_.js.map +0 -1
  84. package/dist/development/three.js.map +0 -1
  85. package/dist/dom--HZvmgqd.js.map +0 -1
  86. package/dist/three.js.map +0 -1
package/src/hot.ts CHANGED
@@ -47,7 +47,7 @@ function createHotRuntime() {
47
47
  proxy: null! as Component,
48
48
  }
49
49
  created.proxy = Object.assign(
50
- (props: Record<string, any>) => {
50
+ (...args: Parameters<Component>) => {
51
51
  if (owner) {
52
52
  const root = owner._root
53
53
  const view = roots.get(root) ?? mounting
@@ -57,7 +57,8 @@ function createHotRuntime() {
57
57
  view.modules.add(id)
58
58
  }
59
59
  }
60
- return created.current(props)
60
+ // Compiled JSX mount helpers can take options after their first argument.
61
+ return created.current(...args)
61
62
  },
62
63
  { spa: true },
63
64
  )
@@ -0,0 +1 @@
1
+ import "lasertag/css-modules"
@@ -14,6 +14,7 @@ interface Props {
14
14
  id?: string | number
15
15
  group?: string | number
16
16
  scroll?: boolean
17
+ root?: boolean
17
18
  transition?: MotionLayoutTransition
18
19
  }
19
20
  interface LayoutController {
@@ -29,7 +30,9 @@ interface Entry {
29
30
  dead: boolean
30
31
  node?: IProjectionNode | undefined
31
32
  release?: Cleanup | undefined
32
- refreshStyles?: Cleanup | undefined
33
+ beginStyles?: Cleanup | undefined
34
+ measureStyles?: Cleanup | undefined
35
+ endStyles?: Cleanup | undefined
33
36
  captureStyles?: Cleanup | undefined
34
37
  identity?: string
35
38
  size?: string
@@ -73,7 +76,11 @@ export function createLayoutController(
73
76
  const detach = entry.release
74
77
  entry.release = undefined
75
78
  entry.node = undefined
76
- entry.refreshStyles = entry.captureStyles = undefined
79
+ entry.beginStyles =
80
+ entry.measureStyles =
81
+ entry.endStyles =
82
+ entry.captureStyles =
83
+ undefined
77
84
  detach?.()
78
85
  }
79
86
  const configure = (entry: Entry) => {
@@ -97,6 +104,7 @@ export function createLayoutController(
97
104
  }
98
105
  entry.node!.setOptions({
99
106
  layoutScroll: entry.props.scroll ?? false,
107
+ layoutRoot: entry.props.root ?? false,
100
108
  animationType:
101
109
  typeof entry.props.animate === `string` ? entry.props.animate : `both`,
102
110
  animate: entry.props.animate !== false && !reduced(),
@@ -154,34 +162,36 @@ export function createLayoutController(
154
162
  let visibility = ``
155
163
  let pointerEvents = ``
156
164
  let transform = ``
165
+ let rendered = ``
157
166
  const transformTemplate = (_: unknown, projected: string) =>
158
167
  `${projected === `none` ? `` : projected} ${transform}`.trim()
159
168
  entry.captureStyles = () => {
160
169
  style.cssText = element.style.cssText
161
170
  }
162
- entry.refreshStyles = () => {
171
+ entry.beginStyles = () => {
163
172
  // Resolve authored CSS against today's dimensions, without reading back
164
173
  // the opacity and percentage origins written by projection itself.
165
- const rendered = element.style.cssText
174
+ rendered = element.style.cssText
166
175
  for (const name of styleNames) restore(name)
167
- try {
168
- const authored = getComputedStyle(element)
169
- opacity = authored.opacity || `1`
170
- visibility = authored.visibility
171
- pointerEvents = authored.pointerEvents
172
- transform = authored.transform
173
- if (!visual.values.has(`opacity`))
174
- node.latestValues[`opacity`] = Number(opacity)
175
- const origin = authored.transformOrigin.split(` `)
176
- for (const [key, value] of [
177
- [`originX`, parseFloat(origin[0]) / (element.offsetWidth || 1)],
178
- [`originY`, parseFloat(origin[1]) / (element.offsetHeight || 1)],
179
- ] as const)
180
- if (!visual.values.has(key) && Number.isFinite(value))
181
- node.latestValues[key] = value
182
- } finally {
183
- element.style.cssText = rendered
184
- }
176
+ }
177
+ entry.measureStyles = () => {
178
+ const authored = getComputedStyle(element)
179
+ opacity = authored.opacity || `1`
180
+ visibility = authored.visibility
181
+ pointerEvents = authored.pointerEvents
182
+ transform = authored.transform
183
+ if (!visual.values.has(`opacity`))
184
+ node.latestValues[`opacity`] = Number(opacity)
185
+ const origin = authored.transformOrigin.split(` `)
186
+ const width = element.offsetWidth,
187
+ height = element.offsetHeight
188
+ entry.size = `${width}:${height}`
189
+ for (const [key, value] of [
190
+ [`originX`, parseFloat(origin[0]) / (width || 1)],
191
+ [`originY`, parseFloat(origin[1]) / (height || 1)],
192
+ ] as const)
193
+ if (!visual.values.has(key) && Number.isFinite(value))
194
+ node.latestValues[key] = value
185
195
  // Motion-owned transforms compose in projection; return to authored
186
196
  // transforms if that Motion binding is subsequently removed.
187
197
  const template =
@@ -199,6 +209,9 @@ export function createLayoutController(
199
209
  visual.update(next, null)
200
210
  }
201
211
  }
212
+ entry.endStyles = () => {
213
+ element.style.cssText = rendered
214
+ }
202
215
  const applyProjectionStyles = node.applyProjectionStyles
203
216
  node.applyProjectionStyles = (targetStyle, styleProp) => {
204
217
  applyProjectionStyles.call(node, targetStyle, {
@@ -238,14 +251,29 @@ export function createLayoutController(
238
251
  }
239
252
  observer?.observe(element)
240
253
  }
241
- entry.refreshStyles!()
242
- configure(entry)
243
- entry.size = `${element.offsetWidth}:${element.offsetHeight}`
254
+ }
255
+ const prepareAll = () => {
256
+ const active = ordered()
257
+ for (const entry of active) prepare(entry)
258
+ const begun: Entry[] = []
259
+ try {
260
+ // Strip every projection before reading any authored style or dimension.
261
+ // Interleaving these phases forces a layout for each registered element.
262
+ for (const entry of active) {
263
+ begun.push(entry)
264
+ entry.beginStyles!()
265
+ }
266
+ for (const entry of active) entry.measureStyles!()
267
+ } finally {
268
+ for (const entry of begun) entry.endStyles!()
269
+ }
270
+ for (const entry of active) configure(entry)
271
+ return active
244
272
  }
245
273
  const commit = () => {
246
274
  try {
247
275
  if (dead) return
248
- for (const entry of ordered()) prepare(entry)
276
+ prepareAll()
249
277
  const roots = new Set(
250
278
  [...entries].flatMap((entry) =>
251
279
  entry.node ? [entry.node.root ?? entry.node] : [],
@@ -314,6 +342,7 @@ export function createLayoutController(
314
342
  commit,
315
343
  beforeUpdate(): Cleanup {
316
344
  updating = true
345
+ // Snapshot the rendered projection; resolve authored styles once after the DOM changes.
317
346
  for (const entry of ordered()) {
318
347
  prepare(entry)
319
348
  entry.node!.willUpdate()
package/src/motion.ts CHANGED
@@ -113,6 +113,8 @@ export interface MotionAttributes<Kind extends string = `dom`> {
113
113
  [`motion:layoutId`]?: Kind extends `dom` ? string | number : never
114
114
  [`motion:layoutGroup`]?: Kind extends `dom` ? string | number : never
115
115
  [`motion:layoutScroll`]?: Kind extends `dom` ? boolean : never
116
+ /** Measure descendants relative to this instantly positioned layout ancestor. */
117
+ [`motion:layoutRoot`]?: Kind extends `dom` ? boolean : never
116
118
  [`motion:layoutTransition`]?: Kind extends `dom`
117
119
  ? MotionLayoutTransition
118
120
  : never
@@ -166,6 +168,7 @@ const layoutKeys = {
166
168
  layoutId: `id`,
167
169
  layoutGroup: `group`,
168
170
  layoutScroll: `scroll`,
171
+ layoutRoot: `root`,
169
172
  layoutTransition: `transition`,
170
173
  } as const
171
174
  function equal(a: unknown, b: unknown): boolean {
package/src/three.ts CHANGED
@@ -42,8 +42,12 @@ export interface ObjectProps<N extends THREE.Object3D = THREE.Object3D>
42
42
  const constructors = {
43
43
  Group: THREE.Group,
44
44
  Mesh: THREE.Mesh,
45
+ LineSegments: THREE.LineSegments,
46
+ BufferGeometry: THREE.BufferGeometry,
47
+ LineBasicMaterial: THREE.LineBasicMaterial,
45
48
  PerspectiveCamera: THREE.PerspectiveCamera,
46
49
  AmbientLight: THREE.AmbientLight,
50
+ PointLight: THREE.PointLight,
47
51
  DirectionalLight: THREE.DirectionalLight,
48
52
  BoxGeometry: THREE.BoxGeometry,
49
53
  SphereGeometry: THREE.SphereGeometry,
@@ -52,8 +56,8 @@ const constructors = {
52
56
  MeshBasicMaterial: THREE.MeshBasicMaterial,
53
57
  MeshNormalMaterial: THREE.MeshNormalMaterial,
54
58
  }
55
- const meshDefaults = new WeakMap<
56
- THREE.Mesh,
59
+ const drawableDefaults = new WeakMap<
60
+ THREE.Mesh | THREE.LineSegments,
57
61
  {
58
62
  geometry: THREE.BufferGeometry
59
63
  material: THREE.Material | THREE.Material[]
@@ -61,8 +65,8 @@ const meshDefaults = new WeakMap<
61
65
  ownsMaterial: boolean
62
66
  }
63
67
  >()
64
- const borrowedMeshDefaults = new WeakMap<
65
- THREE.Mesh,
68
+ const borrowedDrawableDefaults = new WeakMap<
69
+ THREE.Mesh | THREE.LineSegments,
66
70
  {
67
71
  geometry: THREE.BufferGeometry
68
72
  material: THREE.Material | THREE.Material[]
@@ -113,9 +117,9 @@ const renderer = createSceneRenderer<Resource>({
113
117
  const Constructor = constructors[type as keyof typeof constructors]
114
118
  if (!Constructor) throw new Error(`spa/three: unknown node ${type}`)
115
119
  const node = new (Constructor as any)(...(props[`args`] ?? [])) as Resource
116
- // Mesh's implicit resources are replaced by owned JSX resources below.
117
- if (node instanceof THREE.Mesh)
118
- meshDefaults.set(node, {
120
+ // Drawables' implicit resources are replaced by owned JSX resources below.
121
+ if (node instanceof THREE.Mesh || node instanceof THREE.LineSegments)
122
+ drawableDefaults.set(node, {
119
123
  geometry: node.geometry,
120
124
  material: node.material,
121
125
  ownsGeometry: props[`args`]?.[0] === undefined,
@@ -198,9 +202,14 @@ const renderer = createSceneRenderer<Resource>({
198
202
  const resources = children.filter(
199
203
  (child) => !(child instanceof THREE.Object3D),
200
204
  )
201
- if (resources.length && !(parent instanceof THREE.Mesh))
202
- throw new Error(`spa/three: geometry and material require a Mesh parent`)
203
- if (parent instanceof THREE.Mesh) {
205
+ if (
206
+ resources.length &&
207
+ !(parent instanceof THREE.Mesh || parent instanceof THREE.LineSegments)
208
+ )
209
+ throw new Error(
210
+ `spa/three: geometry and material require a Mesh or LineSegments parent`,
211
+ )
212
+ if (parent instanceof THREE.Mesh || parent instanceof THREE.LineSegments) {
204
213
  const geometries = resources.filter(
205
214
  (child) => child instanceof THREE.BufferGeometry,
206
215
  )
@@ -215,13 +224,13 @@ const renderer = createSceneRenderer<Resource>({
215
224
  )
216
225
  if (activeGeometries.length > 1 || activeMaterials.length > 1)
217
226
  throw new Error(
218
- `spa/three: each Mesh accepts one geometry and one material`,
227
+ `spa/three: each ${parent instanceof THREE.Mesh ? `Mesh` : `LineSegments`} accepts one geometry and one material`,
219
228
  )
220
- const owned = meshDefaults.get(parent)
221
- let baseline = owned ?? borrowedMeshDefaults.get(parent)
229
+ const owned = drawableDefaults.get(parent)
230
+ let baseline = owned ?? borrowedDrawableDefaults.get(parent)
222
231
  if (!baseline) {
223
232
  baseline = { geometry: parent.geometry, material: parent.material }
224
- borrowedMeshDefaults.set(parent, baseline)
233
+ borrowedDrawableDefaults.set(parent, baseline)
225
234
  }
226
235
  // Retention owns outgoing resources without occupying incoming attachment slots.
227
236
  parent.geometry =
@@ -234,7 +243,8 @@ const renderer = createSceneRenderer<Resource>({
234
243
  materials.find((material) => material === parent.material) ??
235
244
  materials.at(-1) ??
236
245
  baseline.material
237
- if (!owned && children.length === 0) borrowedMeshDefaults.delete(parent)
246
+ if (!owned && children.length === 0)
247
+ borrowedDrawableDefaults.delete(parent)
238
248
  }
239
249
  },
240
250
  destroy(node) {
@@ -244,8 +254,8 @@ const renderer = createSceneRenderer<Resource>({
244
254
  forgetThree(node)
245
255
  } finally {
246
256
  node.removeFromParent()
247
- if (node instanceof THREE.Mesh) {
248
- const owned = meshDefaults.get(node)!
257
+ if (node instanceof THREE.Mesh || node instanceof THREE.LineSegments) {
258
+ const owned = drawableDefaults.get(node)!
249
259
  if (owned.ownsGeometry) owned.geometry.dispose()
250
260
  if (owned.ownsMaterial) (owned.material as THREE.Material).dispose()
251
261
  }
@@ -287,12 +297,16 @@ export interface CanvasProps {
287
297
  createRenderer?: (
288
298
  options: THREE.WebGLRendererParameters,
289
299
  ) => THREE.WebGLRenderer
300
+ /** Handle renderer creation failure locally, for example by offering an accessible fallback. */
301
+ onError?: (error: unknown) => void
290
302
  /** A fixed ratio, or a device-pixel-ratio clamp. Defaults to 1. */
291
303
  dpr?: number | readonly [min: number, max: number]
292
304
  /** Runs after sizing and scene mounting, before the first draw. May return cleanup. */
293
305
  onCreated?: (state: CanvasState) => void | (() => void)
294
306
  /** Supplied cameras keep their projection; update it explicitly here if desired. */
295
307
  onResize?: (state: CanvasResizeState) => void
308
+ /** Skip an idle GPU draw. Frame callbacks and pointer updates still run. */
309
+ renderWhen?: () => boolean
296
310
  onFrame?: (state: CanvasState & { delta: number; time: number }) => void
297
311
  }
298
312
  /** Browser-only scene boundary. The camera prop is borrowed and never disposed. */
@@ -304,9 +318,16 @@ export function Canvas(props: CanvasProps): SpaElement {
304
318
  ...props.rendererOptions,
305
319
  canvas: canvas!,
306
320
  }
307
- const webgl = props.createRenderer
308
- ? props.createRenderer(parameters)
309
- : new THREE.WebGLRenderer(parameters)
321
+ let webgl: THREE.WebGLRenderer
322
+ try {
323
+ webgl = props.createRenderer
324
+ ? props.createRenderer(parameters)
325
+ : new THREE.WebGLRenderer(parameters)
326
+ } catch (error) {
327
+ if (!props.onError) throw error
328
+ props.onError(error)
329
+ return
330
+ }
310
331
  onCleanup(() => {
311
332
  webgl.dispose()
312
333
  })
@@ -388,7 +409,9 @@ export function Canvas(props: CanvasProps): SpaElement {
388
409
  const active = props.camera ?? camera
389
410
  const delta = last === undefined ? 0 : (time - last) / 1000
390
411
  last = time
391
- if (isPresent(scope))
412
+ const present = isPresent(scope)
413
+ const draw = !present || (props.renderWhen?.() ?? true)
414
+ if (present)
392
415
  props.onFrame?.({
393
416
  scene,
394
417
  camera: active,
@@ -397,7 +420,7 @@ export function Canvas(props: CanvasProps): SpaElement {
397
420
  time: time / 1000,
398
421
  })
399
422
  events.update()
400
- webgl.render(scene, active)
423
+ if (draw) webgl.render(scene, active)
401
424
  }, true)
402
425
  })
403
426
  })
@@ -434,6 +457,14 @@ export const DirectionalLight = sceneComponent<
434
457
  intensity?: number
435
458
  }
436
459
  >(`DirectionalLight`)
460
+ export const PointLight = sceneComponent<
461
+ ObjectProps<THREE.PointLight> & {
462
+ color?: THREE.ColorRepresentation
463
+ intensity?: number
464
+ distance?: number
465
+ decay?: number
466
+ }
467
+ >(`PointLight`)
437
468
  export const BoxGeometry = sceneComponent<{
438
469
  args?: ConstructorParameters<typeof THREE.BoxGeometry>
439
470
  ref?: (node: THREE.BoxGeometry | null) => void
@@ -465,3 +496,19 @@ export const MeshNormalMaterial = sceneComponent<
465
496
  }
466
497
  >(`MeshNormalMaterial`)
467
498
  export { renderer as threeRenderer }
499
+
500
+ /** Batched line geometry, with the same attachment and ownership rules as Mesh. */
501
+ export const LineSegments = sceneComponent<
502
+ ObjectProps<THREE.LineSegments> & {
503
+ args?: ConstructorParameters<typeof THREE.LineSegments>
504
+ frustumCulled?: boolean
505
+ }
506
+ >(`LineSegments`)
507
+ export const BufferGeometry = sceneComponent<{
508
+ ref?: (node: THREE.BufferGeometry | null) => void
509
+ }>(`BufferGeometry`)
510
+ export const LineBasicMaterial = sceneComponent<
511
+ THREE.LineBasicMaterialParameters & {
512
+ ref?: (node: THREE.LineBasicMaterial | null) => void
513
+ }
514
+ >(`LineBasicMaterial`)
@@ -1 +0,0 @@
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;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AAW;CACf,MAAM,SAA6B,YAChC;EACA,MAAM,KAAK;EACX,OAAO,UAAU,OAAO;GACvB,IAAI,CAAC,UAAU;IACd,WAAW;IAEX,QAAQ,KACP,6HACA;KAAE;KAAM;KAAU;IAAM,CACzB;GACD;EACD;CACD,IACC,KAAA;CACH,MAAM,SAAS,QAAQ;CACvB,MAAM,SACL,QAAQ,aAAa,KAAK,OAAO,WAAW,WAAW,IAAI,IACxD,OAAO,UAAU,MAAM,CAAC,IACxB,KAAA;CACJ,MAAM,OAAO,WAAW,OAAO;CAC/B,KAAK,QAAQ;CACb,IAAI,WAAW,KAAA,KAAa,QAAQ,aAAa,KAAA,GAChD,KAAK,UAAU;CACS,UAAU,IAAI;CACvC,IAAI;EACH,QAAQ,KAAK,KAAK,WAAW,MAAM,QAAQ,MAAM,MAAM;EACvD,OAAO,YAAY;GAClB,MACC,UAAU,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 +0,0 @@
1
- {"version":3,"file":"three.js","names":[],"sources":["../../src/three-events.ts","../../src/three.ts"],"sourcesContent":["import * as THREE from \"three\"\n\nexport interface ThreePointerEvent<N extends THREE.Object3D = THREE.Object3D> {\n\ttype: string\n\tnativeEvent: PointerEvent\n\ttarget: THREE.Object3D\n\tcurrentTarget: N\n\tintersection: THREE.Intersection\n\tray: THREE.Ray\n\tpointerId: number\n\tbutton: number\n\tbuttons: number\n\tclientX: number\n\tclientY: number\n\tstopPropagation(): void\n\tpreventDefault(): void\n\tsetPointerCapture(): void\n\treleasePointerCapture(): void\n\thasPointerCapture(): boolean\n}\nexport type ThreeEventHandler<N extends THREE.Object3D = THREE.Object3D> = (\n\tevent: ThreePointerEvent<N>,\n) => void\nexport interface ThreeEventAttributes<\n\tN extends THREE.Object3D = THREE.Object3D,\n> {\n\tonPointerDown?: ThreeEventHandler<N>\n\tonPointerUp?: ThreeEventHandler<N>\n\tonPointerMove?: ThreeEventHandler<N>\n\tonPointerEnter?: ThreeEventHandler<N>\n\tonPointerLeave?: ThreeEventHandler<N>\n\tonPointerOver?: ThreeEventHandler<N>\n\tonPointerOut?: ThreeEventHandler<N>\n\tonPointerCancel?: ThreeEventHandler<N>\n\tonClick?: ThreeEventHandler<N>\n}\ntype Hit = { node: THREE.Object3D; intersection: THREE.Intersection }\ntype Handler = ThreeEventHandler\nconst suspended = new WeakSet<THREE.Object3D>()\nexport function suspendThree(node: THREE.Object3D): () => void {\n\tsuspended.add(node)\n\tfor (const manager of managers) manager.remove(node)\n\treturn () => {\n\t\tsuspended.delete(node)\n\t}\n}\nconst listeners = new WeakMap<THREE.Object3D, Map<string, Set<Handler>>>()\nconst managers = new Set<{ remove(node: THREE.Object3D): void }>()\n\nexport function listenThree(\n\tnode: THREE.Object3D,\n\ttype: string,\n\thandler: Handler,\n): () => void {\n\tconst events = listeners.get(node) ?? new Map<string, Set<Handler>>()\n\tlisteners.set(node, events)\n\tconst handlers = events.get(type) ?? new Set<Handler>()\n\tevents.set(type, handlers)\n\thandlers.add(handler)\n\treturn () => {\n\t\thandlers.delete(handler)\n\t\tif (!handlers.size) events.delete(type)\n\t}\n}\nexport function forgetThree(node: THREE.Object3D): void {\n\tconst errors: unknown[] = []\n\tfor (const manager of managers) {\n\t\ttry {\n\t\t\tmanager.remove(node)\n\t\t} catch (error) {\n\t\t\terrors.push(error)\n\t\t}\n\t}\n\tlisteners.delete(node)\n\tif (errors.length) throw new AggregateError(errors)\n}\n\nexport interface ThreeEventManager {\n\tupdate(): void\n\t/** Release hover, press, and capture state for a removed subtree. */\n\tremove(node: THREE.Object3D): void\n\tdispose(): void\n}\n\n/** Attach raycast pointer routing to a canvas; usable with borrowed scene roots. */\nexport function createThreeEvents(\n\tcanvas: HTMLCanvasElement,\n\tscene: THREE.Object3D,\n\tcamera: () => THREE.Camera,\n\tonError: (error: unknown) => void = (error) => {\n\t\tthrow error\n\t},\n): ThreeEventManager {\n\tconst raycaster = new THREE.Raycaster()\n\tconst pointer = new THREE.Vector2()\n\tconst hovering = new Map<number, Hit>()\n\tconst pressed = new Map<number, Hit>()\n\tconst captures = new Map<number, Hit>()\n\tconst last = new Map<number, PointerEvent>()\n\tlet dead = false\n\tconst path = (node: THREE.Object3D) => {\n\t\tconst nodes: THREE.Object3D[] = []\n\t\tfor (let at: THREE.Object3D | null = node; at; at = at.parent) {\n\t\t\tnodes.push(at)\n\t\t\tif (at === scene) return nodes\n\t\t}\n\t\treturn []\n\t}\n\tconst contains = (node: THREE.Object3D, child: THREE.Object3D) => {\n\t\tfor (let at: THREE.Object3D | null = child; at; at = at.parent)\n\t\t\tif (at === node) return true\n\t\treturn false\n\t}\n\tconst eligible = (intersection: THREE.Intersection) => {\n\t\tconst nodes = path(intersection.object)\n\t\tif (\n\t\t\t!nodes.length ||\n\t\t\tnodes.some((node) => !node.visible || suspended.has(node))\n\t\t)\n\t\t\treturn false\n\t\tconst material = (intersection.object as THREE.Mesh).material\n\t\treturn (\n\t\t\t!material ||\n\t\t\t(Array.isArray(material)\n\t\t\t\t? material[intersection.face?.materialIndex ?? 0]?.visible !== false\n\t\t\t\t: material.visible)\n\t\t)\n\t}\n\tconst pick = (event: PointerEvent): Hit | undefined => {\n\t\tconst bounds = canvas.getBoundingClientRect()\n\t\tif (!bounds.width || !bounds.height) return undefined\n\t\tconst active = camera()\n\t\tscene.updateWorldMatrix(true, true)\n\t\tactive.updateWorldMatrix(true, false)\n\t\tpointer.set(\n\t\t\t((event.clientX - bounds.left) / bounds.width) * 2 - 1,\n\t\t\t1 - ((event.clientY - bounds.top) / bounds.height) * 2,\n\t\t)\n\t\traycaster.layers.mask = active.layers.mask\n\t\traycaster.setFromCamera(pointer, active)\n\t\tif (\n\t\t\tevent.clientX < bounds.left ||\n\t\t\tevent.clientX > bounds.right ||\n\t\t\tevent.clientY < bounds.top ||\n\t\t\tevent.clientY > bounds.bottom\n\t\t)\n\t\t\treturn undefined\n\t\tconst intersection = raycaster.intersectObject(scene, true).find(eligible)\n\t\treturn intersection ? { node: intersection.object, intersection } : undefined\n\t}\n\tconst nativeCapture = (id: number) => {\n\t\tif (canvas.hasPointerCapture?.(id)) canvas.releasePointerCapture(id)\n\t}\n\tconst dispatch = (\n\t\ttype: string,\n\t\thit: Hit,\n\t\tnativeEvent: PointerEvent,\n\t\tnodes = path(hit.node),\n\t) => {\n\t\tlet stopped = false\n\t\tfor (const node of nodes) {\n\t\t\tif (dead) break\n\t\t\tconst event: ThreePointerEvent = {\n\t\t\t\ttype,\n\t\t\t\tnativeEvent,\n\t\t\t\ttarget: hit.node,\n\t\t\t\tcurrentTarget: node,\n\t\t\t\tintersection: hit.intersection,\n\t\t\t\tray: raycaster.ray.clone(),\n\t\t\t\tpointerId: nativeEvent.pointerId,\n\t\t\t\tbutton: nativeEvent.button,\n\t\t\t\tbuttons: nativeEvent.buttons,\n\t\t\t\tclientX: nativeEvent.clientX,\n\t\t\t\tclientY: nativeEvent.clientY,\n\t\t\t\tstopPropagation() {\n\t\t\t\t\tstopped = true\n\t\t\t\t},\n\t\t\t\tpreventDefault() {\n\t\t\t\t\tnativeEvent.preventDefault()\n\t\t\t\t},\n\t\t\t\tsetPointerCapture() {\n\t\t\t\t\tcanvas.setPointerCapture(nativeEvent.pointerId)\n\t\t\t\t\tcaptures.set(nativeEvent.pointerId, {\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tintersection: hit.intersection,\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\treleasePointerCapture() {\n\t\t\t\t\tif (captures.get(nativeEvent.pointerId)?.node === node) {\n\t\t\t\t\t\tcaptures.delete(nativeEvent.pointerId)\n\t\t\t\t\t\tnativeCapture(nativeEvent.pointerId)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\thasPointerCapture() {\n\t\t\t\t\treturn captures.get(nativeEvent.pointerId)?.node === node\n\t\t\t\t},\n\t\t\t}\n\t\t\tfor (const handler of [...(listeners.get(node)?.get(type) ?? [])])\n\t\t\t\tif (!dead && listeners.get(node)?.get(type)?.has(handler)) handler(event)\n\t\t\tif (stopped) break\n\t\t}\n\t}\n\tconst hover = (event: PointerEvent, next?: Hit) => {\n\t\tconst previous = hovering.get(event.pointerId)\n\t\tif (previous?.node === next?.node) {\n\t\t\tif (next) hovering.set(event.pointerId, next)\n\t\t\treturn\n\t\t}\n\t\tconst oldPath = previous ? path(previous.node) : []\n\t\tconst newPath = next ? path(next.node) : []\n\t\t// Publish state first so handlers may remove nodes or dispose this manager safely.\n\t\tif (next) hovering.set(event.pointerId, next)\n\t\telse hovering.delete(event.pointerId)\n\t\tif (previous) {\n\t\t\tdispatch(`pointerout`, previous, event)\n\t\t\tfor (const node of oldPath)\n\t\t\t\tif (!newPath.includes(node))\n\t\t\t\t\tdispatch(`pointerleave`, previous, event, [node])\n\t\t}\n\t\tif (next && path(next.node).length) {\n\t\t\tdispatch(`pointerover`, next, event)\n\t\t\tfor (const node of newPath.reverse())\n\t\t\t\tif (!oldPath.includes(node))\n\t\t\t\t\tdispatch(`pointerenter`, next, event, [node])\n\t\t}\n\t}\n\tconst cancel = (event: PointerEvent) => {\n\t\tconst hit = captures.get(event.pointerId) ?? pressed.get(event.pointerId)\n\t\tcaptures.delete(event.pointerId)\n\t\tpressed.delete(event.pointerId)\n\t\ttry {\n\t\t\tif (hit) dispatch(`pointercancel`, hit, event)\n\t\t} finally {\n\t\t\tnativeCapture(event.pointerId)\n\t\t}\n\t}\n\tconst handle = (event: PointerEvent) => {\n\t\ttry {\n\t\t\tif (event.type === `lostpointercapture`) {\n\t\t\t\tcancel(event)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (event.type === `pointercancel`) {\n\t\t\t\tcancel(event)\n\t\t\t\thover(event)\n\t\t\t\tlast.delete(event.pointerId)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (event.type === `pointerleave`) {\n\t\t\t\tlast.set(event.pointerId, event)\n\t\t\t\thover(event)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlast.set(event.pointerId, event)\n\t\t\tconst hit = pick(event)\n\t\t\thover(event, hit)\n\t\t\tif (dead) return\n\t\t\tconst capture = captures.get(event.pointerId)\n\t\t\tif (capture && hit && contains(capture.node, hit.node))\n\t\t\t\tcapture.intersection = hit.intersection\n\t\t\tconst delivery = capture ?? hit\n\t\t\tif (event.type === `pointerdown`) {\n\t\t\t\tif (hit) {\n\t\t\t\t\tpressed.set(event.pointerId, hit)\n\t\t\t\t\tcanvas.setPointerCapture?.(event.pointerId)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (event.type === `pointerup`) {\n\t\t\t\tconst down = pressed.get(event.pointerId)\n\t\t\t\tpressed.delete(event.pointerId)\n\t\t\t\ttry {\n\t\t\t\t\t// Capture may belong to an ancestor of the original hit.\n\t\t\t\t\tif (down && !capture && down.node !== hit?.node)\n\t\t\t\t\t\tdispatch(`pointercancel`, down, event)\n\t\t\t\t\tif (delivery) dispatch(`pointerup`, delivery, event)\n\t\t\t\t\tif (down && down.node === hit?.node && event.button === 0)\n\t\t\t\t\t\tdispatch(`click`, hit, event)\n\t\t\t\t} finally {\n\t\t\t\t\tcaptures.delete(event.pointerId)\n\t\t\t\t\tnativeCapture(event.pointerId)\n\t\t\t\t\tif (event.pointerType === `touch`) {\n\t\t\t\t\t\thover(event)\n\t\t\t\t\t\tlast.delete(event.pointerId)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (delivery) dispatch(event.type, delivery, event)\n\t\t} catch (error) {\n\t\t\tonError(error)\n\t\t}\n\t}\n\tconst events = [\n\t\t`pointerdown`,\n\t\t`pointerup`,\n\t\t`pointermove`,\n\t\t`pointerleave`,\n\t\t`pointercancel`,\n\t\t`lostpointercapture`,\n\t] as const\n\tfor (const type of events) canvas.addEventListener(type, handle)\n\tconst manager = {\n\t\t/** Re-pick stationary pointers after camera, geometry, or transforms change. */\n\t\tupdate() {\n\t\t\tif (dead) return\n\t\t\ttry {\n\t\t\t\tfor (const event of last.values())\n\t\t\t\t\tif (event.type !== `pointerleave`) hover(event, pick(event))\n\t\t\t} catch (error) {\n\t\t\t\tonError(error)\n\t\t\t}\n\t\t},\n\t\tremove(node: THREE.Object3D) {\n\t\t\tconst errors: unknown[] = []\n\t\t\tfor (const [id, hit] of hovering)\n\t\t\t\tif (contains(node, hit.node)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\thover(last.get(id)!)\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tfor (const [id, hit] of [...pressed, ...captures])\n\t\t\t\tif (contains(node, hit.node)) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcancel(last.get(id)!)\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tif (errors.length) throw new AggregateError(errors)\n\t\t},\n\t\tdispose() {\n\t\t\tif (dead) return\n\t\t\tdead = true\n\t\t\tfor (const type of events) canvas.removeEventListener(type, handle)\n\t\t\tfor (const id of new Set([...pressed.keys(), ...captures.keys()]))\n\t\t\t\tnativeCapture(id)\n\t\t\thovering.clear()\n\t\t\tpressed.clear()\n\t\t\tcaptures.clear()\n\t\t\tlast.clear()\n\t\t\tmanagers.delete(manager)\n\t\t},\n\t}\n\tmanagers.add(manager)\n\treturn manager\n}\n","import { isPresent, owner, reportScopeError, within } from \"./core.ts\"\nimport type { ThreeEventAttributes, ThreeEventHandler } from \"./three-events.ts\"\nimport {\n\tcreateThreeEvents,\n\tforgetThree,\n\tlistenThree,\n\tsuspendThree,\n} from \"./three-events.ts\"\n\nexport type {\n\tThreeEventAttributes,\n\tThreeEventHandler,\n\tThreeEventManager,\n\tThreePointerEvent,\n} from \"./three-events.ts\"\nexport { createThreeEvents } from \"./three-events.ts\"\nimport * as THREE from \"three\"\n\nimport type { Children, SpaElement } from \"./index.ts\"\nimport { onCleanup, onMount } from \"./index.ts\"\nimport type { CapabilityAttributes } from \"./jsx-runtime.ts\"\nimport { jsx } from \"./jsx-runtime.ts\"\nimport {\n\tbindScene,\n\tcreateSceneRenderer,\n\tonSceneFrame,\n\tsceneComponent,\n} from \"./renderer.ts\"\n\ntype Resource = THREE.Object3D | THREE.BufferGeometry | THREE.Material\ntype Vector3 = readonly [number, number, number]\nexport interface ObjectProps<N extends THREE.Object3D = THREE.Object3D>\n\textends CapabilityAttributes<`three`>, ThreeEventAttributes<N> {\n\tchildren?: Children\n\tposition?: Vector3\n\trotation?: Vector3\n\tscale?: Vector3 | number\n\tvisible?: boolean\n\tname?: string\n\tref?: (object: N | null) => void\n}\nconst constructors = {\n\tGroup: THREE.Group,\n\tMesh: THREE.Mesh,\n\tPerspectiveCamera: THREE.PerspectiveCamera,\n\tAmbientLight: THREE.AmbientLight,\n\tDirectionalLight: THREE.DirectionalLight,\n\tBoxGeometry: THREE.BoxGeometry,\n\tSphereGeometry: THREE.SphereGeometry,\n\tPlaneGeometry: THREE.PlaneGeometry,\n\tMeshStandardMaterial: THREE.MeshStandardMaterial,\n\tMeshBasicMaterial: THREE.MeshBasicMaterial,\n\tMeshNormalMaterial: THREE.MeshNormalMaterial,\n}\nconst meshDefaults = new WeakMap<\n\tTHREE.Mesh,\n\t{\n\t\tgeometry: THREE.BufferGeometry\n\t\tmaterial: THREE.Material | THREE.Material[]\n\t\townsGeometry: boolean\n\t\townsMaterial: boolean\n\t}\n>()\nconst borrowedMeshDefaults = new WeakMap<\n\tTHREE.Mesh,\n\t{\n\t\tgeometry: THREE.BufferGeometry\n\t\tmaterial: THREE.Material | THREE.Material[]\n\t}\n>()\nconst constructorArgs = new WeakMap<Resource, unknown[]>()\nconst eventHandlers = new WeakMap<Resource, Map<string, () => void>>()\nconst defaults = new WeakMap<Resource, Map<string, any>>()\nfunction writeProperty(node: Resource, key: string, value: any): void {\n\tconst target = node as any\n\tif (!(key in target)) throw new Error(`spa/three: unknown property ${key}`)\n\tconst current = target[key]\n\tif (current?.isColor) current.set(value)\n\telse if (Array.isArray(value) && typeof current?.set === `function`)\n\t\tcurrent.set(...value)\n\telse if (key === `scale` && typeof value === `number`) current.setScalar(value)\n\telse if (current?.copy && value?.constructor === current.constructor)\n\t\tcurrent.copy(value)\n\telse target[key] = value\n\tif (node instanceof THREE.PerspectiveCamera) node.updateProjectionMatrix()\n}\nconst renderer = createSceneRenderer<Resource>({\n\ttarget(node) {\n\t\treturn {\n\t\t\tkind: `three`,\n\t\t\tnode,\n\t\t\t...(node instanceof THREE.Object3D\n\t\t\t\t? {\n\t\t\t\t\t\tsuspend: () => suspendThree(node),\n\t\t\t\t\t\tlisten: (type: string, listener: () => void) =>\n\t\t\t\t\t\t\tlistenThree(node, type, listener),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t\tread(key) {\n\t\t\t\tconst value = (node as any)[key]\n\t\t\t\treturn value?.isColor\n\t\t\t\t\t? value.getStyle()\n\t\t\t\t\t: value?.isVector3 || value?.isEuler\n\t\t\t\t\t\t? [value.x, value.y, value.z]\n\t\t\t\t\t\t: value\n\t\t\t},\n\t\t\twrite(key, value) {\n\t\t\t\twriteProperty(node, key, value)\n\t\t\t},\n\t\t}\n\t},\n\tcreate(type, props) {\n\t\tconst Constructor = constructors[type as keyof typeof constructors]\n\t\tif (!Constructor) throw new Error(`spa/three: unknown node ${type}`)\n\t\tconst node = new (Constructor as any)(...(props[`args`] ?? [])) as Resource\n\t\t// Mesh's implicit resources are replaced by owned JSX resources below.\n\t\tif (node instanceof THREE.Mesh)\n\t\t\tmeshDefaults.set(node, {\n\t\t\t\tgeometry: node.geometry,\n\t\t\t\tmaterial: node.material,\n\t\t\t\townsGeometry: props[`args`]?.[0] === undefined,\n\t\t\t\townsMaterial: props[`args`]?.[1] === undefined,\n\t\t\t})\n\t\tconstructorArgs.set(node, [...(props[`args`] ?? [])])\n\t\tdefaults.set(node, new Map())\n\t\teventHandlers.set(node, new Map())\n\t\treturn node\n\t},\n\tupdate(node, props, previous) {\n\t\tif (!equalArgs(constructorArgs.get(node)!, props[`args`]))\n\t\t\tthrow new Error(\n\t\t\t\t`spa/three: change the component key to replace constructor args`,\n\t\t\t)\n\t\tconst target = node as any\n\t\tconst saved = defaults.get(node)!\n\t\tfor (const key of new Set([\n\t\t\t...Object.keys(previous),\n\t\t\t...Object.keys(props),\n\t\t])) {\n\t\t\tif (\n\t\t\t\t/^(key|children|ref|args)$/.test(key) ||\n\t\t\t\tObject.is(props[key], previous[key])\n\t\t\t)\n\t\t\t\tcontinue\n\t\t\tif (key.startsWith(`on`)) {\n\t\t\t\tif (\n\t\t\t\t\t!(node instanceof THREE.Object3D) ||\n\t\t\t\t\t!/^on(Pointer(Down|Up|Move|Enter|Leave|Over|Out|Cancel)|Click)$/.test(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(`spa/three: unknown event ${key}`)\n\t\t\t\tconst handlers = eventHandlers.get(node)!\n\t\t\t\thandlers.get(key)?.()\n\t\t\t\thandlers.delete(key)\n\t\t\t\tconst handler = props[key] as ThreeEventHandler | undefined\n\t\t\t\tif (handler) {\n\t\t\t\t\tconst scope = owner!\n\t\t\t\t\thandlers.set(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tlistenThree(node, key.slice(2).toLowerCase(), (event) => {\n\t\t\t\t\t\t\twithin(scope, () => {\n\t\t\t\t\t\t\t\thandler(event)\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!(key in target)) throw new Error(`spa/three: unknown property ${key}`)\n\t\t\tconst current = target[key]\n\t\t\tif (!saved.has(key))\n\t\t\t\tsaved.set(key, current?.clone ? current.clone() : current)\n\t\t\tconst value = props[key] === undefined ? saved.get(key) : props[key]\n\t\t\twriteProperty(node, key, value)\n\t\t}\n\t\tif (node instanceof THREE.PerspectiveCamera) node.updateProjectionMatrix()\n\t},\n\tchildren(parent, children, activeChildren) {\n\t\tif (!(parent instanceof THREE.Object3D)) {\n\t\t\tif (children.length)\n\t\t\t\tthrow new Error(`spa/three: resources cannot contain children`)\n\t\t\treturn\n\t\t}\n\t\tconst objects = children.filter(\n\t\t\t(child): child is THREE.Object3D => child instanceof THREE.Object3D,\n\t\t)\n\t\tif (\n\t\t\tparent.children.length !== objects.length ||\n\t\t\tobjects.some((child, index) => child !== parent.children[index])\n\t\t) {\n\t\t\tconst wanted = new Set(objects)\n\t\t\tfor (const child of [...parent.children])\n\t\t\t\tif (!wanted.has(child)) parent.remove(child)\n\t\t\tfor (const child of objects) if (child.parent !== parent) parent.add(child)\n\t\t\tparent.children.splice(0, parent.children.length, ...objects)\n\t\t}\n\t\tconst resources = children.filter(\n\t\t\t(child) => !(child instanceof THREE.Object3D),\n\t\t)\n\t\tif (resources.length && !(parent instanceof THREE.Mesh))\n\t\t\tthrow new Error(`spa/three: geometry and material require a Mesh parent`)\n\t\tif (parent instanceof THREE.Mesh) {\n\t\t\tconst geometries = resources.filter(\n\t\t\t\t(child) => child instanceof THREE.BufferGeometry,\n\t\t\t)\n\t\t\tconst materials = resources.filter(\n\t\t\t\t(child) => child instanceof THREE.Material,\n\t\t\t)\n\t\t\tconst activeGeometries = activeChildren.filter(\n\t\t\t\t(child) => child instanceof THREE.BufferGeometry,\n\t\t\t)\n\t\t\tconst activeMaterials = activeChildren.filter(\n\t\t\t\t(child) => child instanceof THREE.Material,\n\t\t\t)\n\t\t\tif (activeGeometries.length > 1 || activeMaterials.length > 1)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`spa/three: each Mesh accepts one geometry and one material`,\n\t\t\t\t)\n\t\t\tconst owned = meshDefaults.get(parent)\n\t\t\tlet baseline = owned ?? borrowedMeshDefaults.get(parent)\n\t\t\tif (!baseline) {\n\t\t\t\tbaseline = { geometry: parent.geometry, material: parent.material }\n\t\t\t\tborrowedMeshDefaults.set(parent, baseline)\n\t\t\t}\n\t\t\t// Retention owns outgoing resources without occupying incoming attachment slots.\n\t\t\tparent.geometry =\n\t\t\t\tactiveGeometries[0] ??\n\t\t\t\tgeometries.find((geometry) => geometry === parent.geometry) ??\n\t\t\t\tgeometries.at(-1) ??\n\t\t\t\tbaseline.geometry\n\t\t\tparent.material =\n\t\t\t\tactiveMaterials[0] ??\n\t\t\t\tmaterials.find((material) => material === parent.material) ??\n\t\t\t\tmaterials.at(-1) ??\n\t\t\t\tbaseline.material\n\t\t\tif (!owned && children.length === 0) borrowedMeshDefaults.delete(parent)\n\t\t}\n\t},\n\tdestroy(node) {\n\t\teventHandlers.get(node)!.clear()\n\t\tif (node instanceof THREE.Object3D) {\n\t\t\ttry {\n\t\t\t\tforgetThree(node)\n\t\t\t} finally {\n\t\t\t\tnode.removeFromParent()\n\t\t\t\tif (node instanceof THREE.Mesh) {\n\t\t\t\t\tconst owned = meshDefaults.get(node)!\n\t\t\t\t\tif (owned.ownsGeometry) owned.geometry.dispose()\n\t\t\t\t\tif (owned.ownsMaterial) (owned.material as THREE.Material).dispose()\n\t\t\t\t}\n\t\t\t}\n\t\t} else node.dispose()\n\t},\n})\nfunction equalArgs(a: unknown[], b: unknown[] = []): boolean {\n\treturn (\n\t\ta.length === b.length &&\n\t\ta.every(\n\t\t\t(value, index) =>\n\t\t\t\tObject.is(value, b[index]) ||\n\t\t\t\t(Array.isArray(value) &&\n\t\t\t\t\tArray.isArray(b[index]) &&\n\t\t\t\t\tequalArgs(value, b[index])),\n\t\t)\n\t)\n}\n\nexport interface CanvasState {\n\tscene: THREE.Scene\n\tcamera: THREE.Camera\n\trenderer: THREE.WebGLRenderer\n}\nexport interface CanvasResizeState extends CanvasState {\n\twidth: number\n\theight: number\n\tdpr: number\n}\nexport interface CanvasProps {\n\tchildren?: Children\n\twidth?: number\n\theight?: number\n\tcamera?: THREE.Camera\n\t/** Constructor-time options. Canvas always supplies its own DOM canvas. */\n\trendererOptions?: Omit<THREE.WebGLRendererParameters, `canvas`>\n\t/** The returned renderer belongs exclusively to Canvas and is disposed with it. */\n\tcreateRenderer?: (\n\t\toptions: THREE.WebGLRendererParameters,\n\t) => THREE.WebGLRenderer\n\t/** A fixed ratio, or a device-pixel-ratio clamp. Defaults to 1. */\n\tdpr?: number | readonly [min: number, max: number]\n\t/** Runs after sizing and scene mounting, before the first draw. May return cleanup. */\n\tonCreated?: (state: CanvasState) => void | (() => void)\n\t/** Supplied cameras keep their projection; update it explicitly here if desired. */\n\tonResize?: (state: CanvasResizeState) => void\n\tonFrame?: (state: CanvasState & { delta: number; time: number }) => void\n}\n/** Browser-only scene boundary. The camera prop is borrowed and never disposed. */\nexport function Canvas(props: CanvasProps): SpaElement {\n\tlet canvas: HTMLCanvasElement | null = null\n\tonMount(() => {\n\t\tconst parameters: THREE.WebGLRendererParameters = {\n\t\t\tantialias: true,\n\t\t\t...props.rendererOptions,\n\t\t\tcanvas: canvas!,\n\t\t}\n\t\tconst webgl = props.createRenderer\n\t\t\t? props.createRenderer(parameters)\n\t\t\t: new THREE.WebGLRenderer(parameters)\n\t\tonCleanup(() => {\n\t\t\twebgl.dispose()\n\t\t})\n\t\tif (webgl.domElement !== canvas)\n\t\t\tthrow new Error(`spa/three: renderer must use the supplied Canvas element`)\n\t\tconst scene = new THREE.Scene()\n\t\tconst camera = new THREE.PerspectiveCamera(50, 1, 0.1, 1000)\n\t\tcamera.position.z = 5\n\t\tconst view = canvas.ownerDocument.defaultView!\n\t\tconst size = () => ({\n\t\t\twidth: props.width ?? 800,\n\t\t\theight: props.height ?? 600,\n\t\t\tdpr: props.dpr ?? 1,\n\t\t\tactive: props.camera ?? camera,\n\t\t})\n\t\tconst resize = ({ width, height, dpr, active }: ReturnType<typeof size>) => {\n\t\t\tconst range = typeof dpr === `number` ? [dpr, dpr] : dpr\n\t\t\tif (\n\t\t\t\t![width, height, ...range].every(\n\t\t\t\t\t(value) => Number.isFinite(value) && value > 0,\n\t\t\t\t) ||\n\t\t\t\trange[0] > range[1]\n\t\t\t)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`spa/three: dimensions and DPR must be positive with an ordered DPR range`,\n\t\t\t\t)\n\t\t\tconst ratio = Math.max(\n\t\t\t\trange[0],\n\t\t\t\tMath.min(range[1], view.devicePixelRatio || 1),\n\t\t\t)\n\t\t\twebgl.setPixelRatio(ratio)\n\t\t\twebgl.setSize(width, height)\n\t\t\tcamera.aspect = width / height\n\t\t\tcamera.updateProjectionMatrix()\n\t\t\tprops.onResize?.({\n\t\t\t\tscene,\n\t\t\t\tcamera: active,\n\t\t\t\trenderer: webgl,\n\t\t\t\twidth,\n\t\t\t\theight,\n\t\t\t\tdpr: ratio,\n\t\t\t})\n\t\t}\n\t\tbindScene(size, resize)\n\t\tconst scope = owner!\n\t\tconst resized = () => {\n\t\t\ttry {\n\t\t\t\tresize(size())\n\t\t\t} catch (error) {\n\t\t\t\treportScopeError(scope, error)\n\t\t\t}\n\t\t}\n\t\tview.addEventListener(`resize`, resized)\n\t\tonCleanup(() => {\n\t\t\tview.removeEventListener(`resize`, resized)\n\t\t})\n\t\trenderer.mount(() => props.children, scene)\n\t\tconst events = createThreeEvents(\n\t\t\tcanvas,\n\t\t\tscene,\n\t\t\t() => props.camera ?? camera,\n\t\t\t(error) => {\n\t\t\t\treportScopeError(scope, error)\n\t\t\t},\n\t\t)\n\t\tonCleanup(() => {\n\t\t\tevents.dispose()\n\t\t})\n\t\t// Scene mounting queues child refs and mount hooks; setup must follow them.\n\t\tonMount(() => {\n\t\t\tconst cleanup = props.onCreated?.({\n\t\t\t\tscene,\n\t\t\t\tcamera: props.camera ?? camera,\n\t\t\t\trenderer: webgl,\n\t\t\t})\n\t\t\tif (cleanup) onCleanup(cleanup)\n\t\t\tlet last: number | undefined\n\t\t\tonSceneFrame((time) => {\n\t\t\t\tconst active = props.camera ?? camera\n\t\t\t\tconst delta = last === undefined ? 0 : (time - last) / 1000\n\t\t\t\tlast = time\n\t\t\t\tif (isPresent(scope))\n\t\t\t\t\tprops.onFrame?.({\n\t\t\t\t\t\tscene,\n\t\t\t\t\t\tcamera: active,\n\t\t\t\t\t\trenderer: webgl,\n\t\t\t\t\t\tdelta,\n\t\t\t\t\t\ttime: time / 1000,\n\t\t\t\t\t})\n\t\t\t\tevents.update()\n\t\t\t\twebgl.render(scene, active)\n\t\t\t}, true)\n\t\t})\n\t})\n\treturn jsx(`canvas`, {\n\t\tref: (element: HTMLCanvasElement | null) => {\n\t\t\tcanvas = element\n\t\t},\n\t})\n}\nexport const Group = sceneComponent<ObjectProps>(`Group`)\nexport const Mesh = sceneComponent<\n\tObjectProps<THREE.Mesh> & {\n\t\targs?: ConstructorParameters<typeof THREE.Mesh>\n\t}\n>(`Mesh`)\nexport const PerspectiveCamera = sceneComponent<\n\tObjectProps<THREE.PerspectiveCamera> & {\n\t\targs?: ConstructorParameters<typeof THREE.PerspectiveCamera>\n\t\tfov?: number\n\t\taspect?: number\n\t\tnear?: number\n\t\tfar?: number\n\t}\n>(`PerspectiveCamera`)\nexport const AmbientLight = sceneComponent<\n\tObjectProps<THREE.Light> & {\n\t\tcolor?: THREE.ColorRepresentation\n\t\tintensity?: number\n\t}\n>(`AmbientLight`)\nexport const DirectionalLight = sceneComponent<\n\tObjectProps<THREE.Light> & {\n\t\tcolor?: THREE.ColorRepresentation\n\t\tintensity?: number\n\t}\n>(`DirectionalLight`)\nexport const BoxGeometry = sceneComponent<{\n\targs?: ConstructorParameters<typeof THREE.BoxGeometry>\n\tref?: (node: THREE.BoxGeometry | null) => void\n}>(`BoxGeometry`)\nexport const SphereGeometry = sceneComponent<{\n\targs?: ConstructorParameters<typeof THREE.SphereGeometry>\n\tref?: (node: THREE.SphereGeometry | null) => void\n}>(`SphereGeometry`)\nexport const PlaneGeometry = sceneComponent<{\n\targs?: ConstructorParameters<typeof THREE.PlaneGeometry>\n\tref?: (node: THREE.PlaneGeometry | null) => void\n}>(`PlaneGeometry`)\nexport const MeshStandardMaterial = sceneComponent<\n\tTHREE.MeshStandardMaterialParameters &\n\t\tCapabilityAttributes<`three`> & {\n\t\t\tref?: (node: THREE.MeshStandardMaterial | null) => void\n\t\t}\n>(`MeshStandardMaterial`)\nexport const MeshBasicMaterial = sceneComponent<\n\tTHREE.MeshBasicMaterialParameters &\n\t\tCapabilityAttributes<`three`> & {\n\t\t\tref?: (node: THREE.MeshBasicMaterial | null) => void\n\t\t}\n>(`MeshBasicMaterial`)\nexport const MeshNormalMaterial = sceneComponent<\n\tTHREE.MeshNormalMaterialParameters &\n\t\tCapabilityAttributes<`three`> & {\n\t\t\tref?: (node: THREE.MeshNormalMaterial | null) => void\n\t\t}\n>(`MeshNormalMaterial`)\nexport { renderer as threeRenderer }\n"],"mappings":";;;;;AAsCA,MAAM,4BAAY,IAAI,QAAwB;AAC9C,SAAgB,aAAa,MAAkC;CAC9D,UAAU,IAAI,IAAI;CAClB,KAAK,MAAM,WAAW,UAAU,QAAQ,OAAO,IAAI;CACnD,aAAa;EACZ,UAAU,OAAO,IAAI;CACtB;AACD;AACA,MAAM,4BAAY,IAAI,QAAmD;AACzE,MAAM,2BAAW,IAAI,IAA4C;AAEjE,SAAgB,YACf,MACA,MACA,SACa;CACb,MAAM,SAAS,UAAU,IAAI,IAAI,qBAAK,IAAI,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AO,MAAM;GAC3B,GAAG,IAAI;EACR,CAAC;CACF,CAAC;CACD,OAAO,IAAI,UAAU,EACpB,MAAM,YAAsC;EAC3C,SAAS;CACV,EACD,CAAC;AACF;AACA,MAAa,QAAQ,eAA4B,OAAO;AACxD,MAAa,OAAO,eAIlB,MAAM;AACR,MAAa,oBAAoB,eAQ/B,mBAAmB;AACrB,MAAa,eAAe,eAK1B,cAAc;AAChB,MAAa,mBAAmB,eAK9B,kBAAkB;AACpB,MAAa,cAAc,eAGxB,aAAa;AAChB,MAAa,iBAAiB,eAG3B,gBAAgB;AACnB,MAAa,gBAAgB,eAG1B,eAAe;AAClB,MAAa,uBAAuB,eAKlC,sBAAsB;AACxB,MAAa,oBAAoB,eAK/B,mBAAmB;AACrB,MAAa,qBAAqB,eAKhC,oBAAoB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dom--HZvmgqd.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;C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