@atom.io/spa 0.0.5 → 0.0.6

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 (90) hide show
  1. package/README.md +104 -5
  2. package/README.mdx +36 -0
  3. package/dist/astro-application.d.ts +1 -1
  4. package/dist/astro-client.d.ts +1 -1
  5. package/dist/astro-client.js +1 -1
  6. package/dist/astro-request-DRKvDjsO.js.map +1 -1
  7. package/dist/astro-resumability-client.d.ts +1 -1
  8. package/dist/astro-server.js +1 -1
  9. package/dist/{astro-shared-DHIpjNIG.d.ts → astro-shared-B9wvGIkk.d.ts} +2 -2
  10. package/dist/{astro-shared-DHIpjNIG.d.ts.map → astro-shared-B9wvGIkk.d.ts.map} +1 -1
  11. package/dist/astro.d.ts +1 -1
  12. package/dist/astro.js +1 -1
  13. package/dist/{capabilities-BCtBG-ni.d.ts → capabilities-_zOwNJ-2.d.ts} +5 -3
  14. package/dist/{capabilities-BCtBG-ni.d.ts.map → capabilities-_zOwNJ-2.d.ts.map} +1 -1
  15. package/dist/{capabilities-BkQ2i0vV.js → capabilities-nOIitQ-_.js} +6 -4
  16. package/dist/capabilities-nOIitQ-_.js.map +1 -0
  17. package/dist/client.min.js +1 -1
  18. package/dist/development/astro-client.js +1 -1
  19. package/dist/development/astro-request-DRKvDjsO.js.map +1 -1
  20. package/dist/development/astro-server.js +1 -1
  21. package/dist/development/astro.js +1 -1
  22. package/dist/development/{capabilities-BkQ2i0vV.js → capabilities-nOIitQ-_.js} +6 -4
  23. package/dist/development/capabilities-nOIitQ-_.js.map +1 -0
  24. package/dist/development/{dom-BytVV6Rp.js → dom-BWy4dDss.js} +10 -9
  25. package/dist/development/{dom-BytVV6Rp.js.map → dom-BWy4dDss.js.map} +1 -1
  26. package/dist/development/floating.js +148 -0
  27. package/dist/development/floating.js.map +1 -0
  28. package/dist/development/index.js +1 -1
  29. package/dist/development/jsx-runtime.js +2 -2
  30. package/dist/development/jsx-runtime.js.map +1 -1
  31. package/dist/development/konva.js +1 -1
  32. package/dist/development/motion.js +6 -1
  33. package/dist/development/motion.js.map +1 -1
  34. package/dist/development/renderer.js +1 -1
  35. package/dist/development/{server-renderer-CUQXh9oF.js → server-renderer-C7lGVhpo.js} +2 -2
  36. package/dist/development/{server-renderer-CUQXh9oF.js.map → server-renderer-C7lGVhpo.js.map} +1 -1
  37. package/dist/development/server.js +1 -1
  38. package/dist/development/three.js +11 -8
  39. package/dist/development/three.js.map +1 -1
  40. package/dist/{vite-CSHoxzXU.js → development/vite-Bmyb6P5w.js} +32 -7
  41. package/dist/development/vite-Bmyb6P5w.js.map +1 -0
  42. package/dist/development/vite.js +1 -1
  43. package/dist/{dom-B5OxgHkr.js → dom-BrPrxO97.js} +10 -9
  44. package/dist/{dom-B5OxgHkr.js.map → dom-BrPrxO97.js.map} +1 -1
  45. package/dist/floating.d.ts +16 -0
  46. package/dist/floating.d.ts.map +1 -0
  47. package/dist/floating.js +148 -0
  48. package/dist/floating.js.map +1 -0
  49. package/dist/{index-DufwkB6W.d.ts → index-BFIjI7gF.d.ts} +3 -3
  50. package/dist/{index-DufwkB6W.d.ts.map → index-BFIjI7gF.d.ts.map} +1 -1
  51. package/dist/index.d.ts +3 -3
  52. package/dist/index.js +1 -1
  53. package/dist/{jsx-runtime-DMDVr7A5.d.ts → jsx-runtime-BhiCZOYZ.d.ts} +2 -2
  54. package/dist/{jsx-runtime-DMDVr7A5.d.ts.map → jsx-runtime-BhiCZOYZ.d.ts.map} +1 -1
  55. package/dist/jsx-runtime.d.ts +1 -1
  56. package/dist/jsx-runtime.js +2 -2
  57. package/dist/jsx-runtime.js.map +1 -1
  58. package/dist/konva.d.ts +3 -3
  59. package/dist/konva.js +1 -1
  60. package/dist/motion.d.ts +1 -1
  61. package/dist/motion.d.ts.map +1 -1
  62. package/dist/motion.js +6 -1
  63. package/dist/motion.js.map +1 -1
  64. package/dist/renderer.d.ts +1 -1
  65. package/dist/renderer.js +1 -1
  66. package/dist/{server-renderer-DcU55e6s.js → server-renderer-D-uRg04V.js} +2 -2
  67. package/dist/{server-renderer-DcU55e6s.js.map → server-renderer-D-uRg04V.js.map} +1 -1
  68. package/dist/server.d.ts +1 -1
  69. package/dist/server.js +1 -1
  70. package/dist/size.json +12 -12
  71. package/dist/three.d.ts +3 -3
  72. package/dist/three.js +11 -8
  73. package/dist/three.js.map +1 -1
  74. package/dist/{development/vite-CSHoxzXU.js → vite-Bmyb6P5w.js} +32 -7
  75. package/dist/vite-Bmyb6P5w.js.map +1 -0
  76. package/dist/vite.js +1 -1
  77. package/package.json +14 -2
  78. package/src/astro-request.ts +1 -1
  79. package/src/capabilities.ts +9 -4
  80. package/src/compiler.ts +28 -9
  81. package/src/dom.ts +12 -11
  82. package/src/floating.ts +234 -0
  83. package/src/jsx-runtime.ts +4 -1
  84. package/src/motion.ts +11 -1
  85. package/src/presence.ts +1 -1
  86. package/src/three-events.ts +14 -10
  87. package/dist/capabilities-BkQ2i0vV.js.map +0 -1
  88. package/dist/development/capabilities-BkQ2i0vV.js.map +0 -1
  89. package/dist/development/vite-CSHoxzXU.js.map +0 -1
  90. package/dist/vite-CSHoxzXU.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"server-renderer-DcU55e6s.js","names":[],"sources":["../src/server-renderer.ts"],"sourcesContent":["import type { ReadableToken } from \"atom.io\"\n\nimport { capabilityNamespace, validateCapabilities } from \"./capabilities.ts\"\nimport type { Children, RootOptions, Scope, SpaElement } from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tplain,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment } from \"./jsx-runtime.ts\"\n\nconst escape = (value: unknown): string =>\n\tString(value).replace(\n\t\t/[&<>\"']/g,\n\t\t(char) =>\n\t\t\t({ \"&\": `&amp;`, \"<\": `&lt;`, \">\": `&gt;`, '\"': `&quot;`, \"'\": `&#39;` })[\n\t\t\t\tchar\n\t\t\t]!,\n\t)\nconst voidTags =\n\t/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/\nconst booleans = new Set(\n\t`allowfullscreen async autofocus autoplay checked controls credentialless default defer disabled disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected shadowrootclonable shadowrootdelegatesfocus shadowrootserializable`.split(\n\t\t` `,\n\t),\n)\nfunction stringify(\n\tvalue: Children,\n\towner: Scope,\n\tnamespace = `html`,\n\tselectValue?: string | number,\n): string {\n\tif (typeof value === `function`) {\n\t\tconst values = ([untrack(value)] as unknown[]).flat(Infinity) as Children[]\n\t\tconst keys = new Set<unknown>()\n\t\treturn (\n\t\t\t`<!--{-->` +\n\t\t\tvalues\n\t\t\t\t.map((child, index) => {\n\t\t\t\t\tconst explicit = (child as SpaElement | null)?.props?.[`key`]\n\t\t\t\t\tconst key = explicit == null ? index : String(explicit)\n\t\t\t\t\tif (keys.has(key)) throw new Error(`spa: duplicate key`)\n\t\t\t\t\tkeys.add(key)\n\t\t\t\t\treturn `<!--[-->${within(owner, () => stringify(child, createScope(owner), namespace, selectValue))}<!--]-->`\n\t\t\t\t})\n\t\t\t\t.join(``) +\n\t\t\t`<!--}-->`\n\t\t)\n\t}\n\tif (Array.isArray(value))\n\t\treturn value\n\t\t\t.map((child) => stringify(child, owner, namespace, selectValue))\n\t\t\t.join(``)\n\tif (value == null || typeof value === `boolean`) return ``\n\tif (typeof value !== `object`) return `<!--t-->${escape(value)}`\n\tif (!(`type` in value) || !(`props` in value))\n\t\tthrow new TypeError(`spa: invalid child`)\n\tconst { type, props } = value\n\tif (!type || type === Fragment)\n\t\treturn stringify(() => props[`children`], owner, namespace, selectValue)\n\tif (typeof type === `function`) {\n\t\tconst childOwner = createScope(owner)\n\t\treturn within(childOwner, () =>\n\t\t\tstringify(\n\t\t\t\tuntrack(() => type(props)),\n\t\t\t\tchildOwner,\n\t\t\t\tnamespace,\n\t\t\t\tselectValue,\n\t\t\t),\n\t\t)\n\t}\n\tif (!/^[A-Za-z][\\w.:-]*$/.test(type)) throw new Error(`spa: invalid tag`)\n\tif (type === `astro-slot`)\n\t\treturn `<astro-slot${props[`name`] ? ` name=\"${escape(props[`name`])}\"` : ``}>${props[`innerHTML`] ?? ``}</astro-slot>`\n\tconst ns = type === `svg` ? `svg` : namespace\n\tvalidateCapabilities(owner, props)\n\tlet attrs = ``\n\tlet textValue: string | number | undefined\n\tfor (let key of Object.keys(props)) {\n\t\tif (\n\t\t\tcapabilityNamespace(key) !== undefined ||\n\t\t\tkey === `children` ||\n\t\t\tkey === `ref` ||\n\t\t\tkey === `key` ||\n\t\t\tkey.startsWith(`on`)\n\t\t)\n\t\t\tcontinue\n\t\tif (\n\t\t\t/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(\n\t\t\t\tkey,\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(`spa: owned content`)\n\t\tlet attribute = props[key]\n\t\tif (ns === `html`) {\n\t\t\tif (key === `defaultValue` && (type === `input` || type === `textarea`)) {\n\t\t\t\tif (props[`value`] != null) continue\n\t\t\t\tkey = `value`\n\t\t\t} else if (key === `defaultChecked` && type === `input`) {\n\t\t\t\tif (props[`checked`] != null) continue\n\t\t\t\tkey = `checked`\n\t\t\t}\n\t\t}\n\t\tif (key === `className`) key = `class`\n\t\tif (key === `htmlFor`) key = `for`\n\t\tif (!/^[^\\s\"'<>/=]+$/.test(key)) throw new Error(`spa: invalid attribute`)\n\t\tif (key === `value` && (type === `select` || type === `textarea`)) {\n\t\t\ttextValue = attribute ?? textValue\n\t\t\tcontinue\n\t\t}\n\t\tif (key === `style` && attribute != null && typeof attribute !== `string`)\n\t\t\tthrow new TypeError(`spa: CSS string required`)\n\t\tconst boolean =\n\t\t\tns === `html` &&\n\t\t\t(booleans.has(key.toLowerCase()) ||\n\t\t\t\t(/^(capture|download|hidden)$/.test(key) &&\n\t\t\t\t\ttypeof attribute === `boolean`))\n\t\tif (attribute == null || (boolean && !attribute)) continue\n\t\tattrs += boolean ? ` ${key}=\"\"` : ` ${key}=\"${escape(attribute)}\"`\n\t}\n\tif (\n\t\ttype === `option` &&\n\t\tselectValue !== undefined &&\n\t\tString(props[`value`]) === String(selectValue)\n\t)\n\t\tattrs += ` selected=\"\"`\n\tif (ns === `html` && voidTags.test(type)) return `<${type}${attrs}>`\n\tif (ns === `html` && /^(textarea|title|style|script)$/.test(type)) {\n\t\tlet text = plain(\n\t\t\ttype === `textarea` ? (textValue ?? props[`children`]) : props[`children`],\n\t\t)\n\t\tif (type === `textarea` && text.startsWith(`\\n`)) text = `\\n${text}`\n\t\tif (/^(script|style)$/.test(type) && new RegExp(`</${type}`, `i`).test(text))\n\t\t\tthrow new Error(`spa: unsafe raw text`)\n\t\treturn `<${type}${attrs}>${/^(script|style)$/.test(type) ? text : escape(text)}</${type}>`\n\t}\n\tconst children = stringify(\n\t\t() => props[`children`],\n\t\towner,\n\t\ttype === `foreignObject` ? `html` : ns,\n\t\ttype === `select` ? textValue : selectValue,\n\t)\n\treturn `<${type}${attrs}>${children}</${type}>`\n}\n\nexport function renderToStringWithReads(\n\tsetup: () => Children,\n\toptions: RootOptions = {},\n\tonRead?: (value: unknown, token: ReadableToken<unknown>) => void,\n): string {\n\tconst root = createRoot(options, true)\n\troot._onRead = onRead\n\tif (/--|[<>]/.test(root._prefix)) throw new Error(`spa: invalid idPrefix`)\n\ttry {\n\t\treturn `<!--w:${root._prefix}-->${within(root, () => stringify(untrack(setup), root))}<!--/w-->`\n\t} finally {\n\t\tdispose(root)\n\t}\n}\n"],"mappings":";;;;AAcA,MAAM,UAAU,UACf,OAAO,KAAK,CAAC,CAAC,QACb,aACC,UACC;CAAE,KAAK;CAAS,KAAK;CAAQ,KAAK;CAAQ,MAAK;CAAU,KAAK;AAAQ,EAAA,CACtE,KAEH;AACD,MAAM,WACL;AACD,MAAM,WAAW,IAAI,IACpB,qVAAqV,MACpV,GACD,CACD;AACA,SAAS,UACR,OACA,OACA,YAAY,QACZ,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OAAO,UAAU,kCAAkC,KAAK,IAAI,GAAG;EAClE,IAAI,OAAO,MACV,SAAS,aAAc,aAAa,MAAM,cAAe,MAAM,WAChE;EACA,IAAI,SAAS,cAAc,KAAK,WAAW,IAAI,GAAG,OAAO,KAAK;EAC9D,IAAI,mBAAmB,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK,IAAI,GAC1E,MAAM,IAAI,MAAM,sBAAsB;EACvC,OAAO,IAAI,OAAO,MAAM,GAAG,mBAAmB,KAAK,IAAI,IAAI,OAAO,OAAO,IAAI,EAAE,IAAI,KAAK;CACzF;CACA,MAAM,WAAW,gBACV,MAAM,aACZ,OACA,SAAS,kBAAkB,SAAS,IACpC,SAAS,WAAW,YAAY,WACjC;CACA,OAAO,IAAI,OAAO,MAAM,GAAG,SAAS,IAAI,KAAK;AAC9C;AAEA,SAAgB,wBACf,OACA,UAAuB,CAAC,GACxB,QACS;CACT,MAAM,OAAO,WAAW,SAAS,IAAI;CACrC,KAAK,UAAU;CACf,IAAI,UAAU,KAAK,KAAK,OAAO,GAAG,MAAM,IAAI,MAAM,uBAAuB;CACzE,IAAI;EACH,OAAO,SAAS,KAAK,QAAQ,KAAK,OAAO,YAAY,UAAU,QAAQ,KAAK,GAAG,IAAI,CAAC,EAAE;CACvF,UAAU;EACT,QAAQ,IAAI;CACb;AACD"}
1
+ {"version":3,"file":"server-renderer-D-uRg04V.js","names":[],"sources":["../src/server-renderer.ts"],"sourcesContent":["import type { ReadableToken } from \"atom.io\"\n\nimport { capabilityNamespace, validateCapabilities } from \"./capabilities.ts\"\nimport type { Children, RootOptions, Scope, SpaElement } from \"./core.ts\"\nimport {\n\tcreateRoot,\n\tcreateScope,\n\tdispose,\n\tplain,\n\tuntrack,\n\twithin,\n} from \"./core.ts\"\nimport { Fragment } from \"./jsx-runtime.ts\"\n\nconst escape = (value: unknown): string =>\n\tString(value).replace(\n\t\t/[&<>\"']/g,\n\t\t(char) =>\n\t\t\t({ \"&\": `&amp;`, \"<\": `&lt;`, \">\": `&gt;`, '\"': `&quot;`, \"'\": `&#39;` })[\n\t\t\t\tchar\n\t\t\t]!,\n\t)\nconst voidTags =\n\t/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/\nconst booleans = new Set(\n\t`allowfullscreen async autofocus autoplay checked controls credentialless default defer disabled disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop multiple muted nomodule novalidate open playsinline readonly required reversed selected shadowrootclonable shadowrootdelegatesfocus shadowrootserializable`.split(\n\t\t` `,\n\t),\n)\nfunction stringify(\n\tvalue: Children,\n\towner: Scope,\n\tnamespace = `html`,\n\tselectValue?: string | number,\n): string {\n\tif (typeof value === `function`) {\n\t\tconst values = ([untrack(value)] as unknown[]).flat(Infinity) as Children[]\n\t\tconst keys = new Set<unknown>()\n\t\treturn (\n\t\t\t`<!--{-->` +\n\t\t\tvalues\n\t\t\t\t.map((child, index) => {\n\t\t\t\t\tconst explicit = (child as SpaElement | null)?.props?.[`key`]\n\t\t\t\t\tconst key = explicit == null ? index : String(explicit)\n\t\t\t\t\tif (keys.has(key)) throw new Error(`spa: duplicate key`)\n\t\t\t\t\tkeys.add(key)\n\t\t\t\t\treturn `<!--[-->${within(owner, () => stringify(child, createScope(owner), namespace, selectValue))}<!--]-->`\n\t\t\t\t})\n\t\t\t\t.join(``) +\n\t\t\t`<!--}-->`\n\t\t)\n\t}\n\tif (Array.isArray(value))\n\t\treturn value\n\t\t\t.map((child) => stringify(child, owner, namespace, selectValue))\n\t\t\t.join(``)\n\tif (value == null || typeof value === `boolean`) return ``\n\tif (typeof value !== `object`) return `<!--t-->${escape(value)}`\n\tif (!(`type` in value) || !(`props` in value))\n\t\tthrow new TypeError(`spa: invalid child`)\n\tconst { type, props } = value\n\tif (!type || type === Fragment)\n\t\treturn stringify(() => props[`children`], owner, namespace, selectValue)\n\tif (typeof type === `function`) {\n\t\tconst childOwner = createScope(owner)\n\t\treturn within(childOwner, () =>\n\t\t\tstringify(\n\t\t\t\tuntrack(() => type(props)),\n\t\t\t\tchildOwner,\n\t\t\t\tnamespace,\n\t\t\t\tselectValue,\n\t\t\t),\n\t\t)\n\t}\n\tif (!/^[A-Za-z][\\w.:-]*$/.test(type)) throw new Error(`spa: invalid tag`)\n\tif (type === `astro-slot`)\n\t\treturn `<astro-slot${props[`name`] ? ` name=\"${escape(props[`name`])}\"` : ``}>${props[`innerHTML`] ?? ``}</astro-slot>`\n\tconst ns = type === `svg` ? `svg` : namespace\n\tvalidateCapabilities(owner, props)\n\tlet attrs = ``\n\tlet textValue: string | number | undefined\n\tfor (let key of Object.keys(props)) {\n\t\tif (\n\t\t\tcapabilityNamespace(key) !== undefined ||\n\t\t\tkey === `children` ||\n\t\t\tkey === `ref` ||\n\t\t\tkey === `key` ||\n\t\t\tkey.startsWith(`on`)\n\t\t)\n\t\t\tcontinue\n\t\tif (\n\t\t\t/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(\n\t\t\t\tkey,\n\t\t\t)\n\t\t)\n\t\t\tthrow new Error(`spa: owned content`)\n\t\tlet attribute = props[key]\n\t\tif (ns === `html`) {\n\t\t\tif (key === `defaultValue` && (type === `input` || type === `textarea`)) {\n\t\t\t\tif (props[`value`] != null) continue\n\t\t\t\tkey = `value`\n\t\t\t} else if (key === `defaultChecked` && type === `input`) {\n\t\t\t\tif (props[`checked`] != null) continue\n\t\t\t\tkey = `checked`\n\t\t\t}\n\t\t}\n\t\tif (key === `className`) key = `class`\n\t\tif (key === `htmlFor`) key = `for`\n\t\tif (!/^[^\\s\"'<>/=]+$/.test(key)) throw new Error(`spa: invalid attribute`)\n\t\tif (key === `value` && (type === `select` || type === `textarea`)) {\n\t\t\ttextValue = attribute ?? textValue\n\t\t\tcontinue\n\t\t}\n\t\tif (key === `style` && attribute != null && typeof attribute !== `string`)\n\t\t\tthrow new TypeError(`spa: CSS string required`)\n\t\tconst boolean =\n\t\t\tns === `html` &&\n\t\t\t(booleans.has(key.toLowerCase()) ||\n\t\t\t\t(/^(capture|download|hidden)$/.test(key) &&\n\t\t\t\t\ttypeof attribute === `boolean`))\n\t\tif (attribute == null || (boolean && !attribute)) continue\n\t\tattrs += boolean ? ` ${key}=\"\"` : ` ${key}=\"${escape(attribute)}\"`\n\t}\n\tif (\n\t\ttype === `option` &&\n\t\tselectValue !== undefined &&\n\t\tString(props[`value`]) === String(selectValue)\n\t)\n\t\tattrs += ` selected=\"\"`\n\tif (ns === `html` && voidTags.test(type)) return `<${type}${attrs}>`\n\tif (ns === `html` && /^(textarea|title|style|script)$/.test(type)) {\n\t\tlet text = plain(\n\t\t\ttype === `textarea` ? (textValue ?? props[`children`]) : props[`children`],\n\t\t)\n\t\tif (type === `textarea` && text.startsWith(`\\n`)) text = `\\n${text}`\n\t\tif (/^(script|style)$/.test(type) && new RegExp(`</${type}`, `i`).test(text))\n\t\t\tthrow new Error(`spa: unsafe raw text`)\n\t\treturn `<${type}${attrs}>${/^(script|style)$/.test(type) ? text : escape(text)}</${type}>`\n\t}\n\tconst children = stringify(\n\t\t() => props[`children`],\n\t\towner,\n\t\ttype === `foreignObject` ? `html` : ns,\n\t\ttype === `select` ? textValue : selectValue,\n\t)\n\treturn `<${type}${attrs}>${children}</${type}>`\n}\n\nexport function renderToStringWithReads(\n\tsetup: () => Children,\n\toptions: RootOptions = {},\n\tonRead?: (value: unknown, token: ReadableToken<unknown>) => void,\n): string {\n\tconst root = createRoot(options, true)\n\troot._onRead = onRead\n\tif (/--|[<>]/.test(root._prefix)) throw new Error(`spa: invalid idPrefix`)\n\ttry {\n\t\treturn `<!--w:${root._prefix}-->${within(root, () => stringify(untrack(setup), root))}<!--/w-->`\n\t} finally {\n\t\tdispose(root)\n\t}\n}\n"],"mappings":";;;;AAcA,MAAM,UAAU,UACf,OAAO,KAAK,CAAC,CAAC,QACb,aACC,UACC;CAAE,KAAK;CAAS,KAAK;CAAQ,KAAK;CAAQ,MAAK;CAAU,KAAK;AAAQ,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M,QAAQ,MAAM,OAAO,WAAW,GAE7C,SAAS;CACV,IAAI,OAAO,UAAU,SAAS,KAAK,IAAI,GAAG,OAAO,IAAI,OAAO,MAAM;CAClE,IAAI,OAAO,UAAU,kCAAkC,KAAK,IAAI,GAAG;EAClE,IAAI,OAAO,MACV,SAAS,aAAc,aAAa,MAAM,cAAe,MAAM,WAChE;EACA,IAAI,SAAS,cAAc,KAAK,WAAW,IAAI,GAAG,OAAO,KAAK;EAC9D,IAAI,mBAAmB,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK,QAAQ,GAAG,CAAC,CAAC,KAAK,IAAI,GAC1E,MAAM,IAAI,MAAM,sBAAsB;EACvC,OAAO,IAAI,OAAO,MAAM,GAAG,mBAAmB,KAAK,IAAI,IAAI,OAAO,OAAO,IAAI,EAAE,IAAI,KAAK;CACzF;CACA,MAAM,WAAW,gBACV,MAAM,aACZ,OACA,SAAS,kBAAkB,SAAS,IACpC,SAAS,WAAW,YAAY,WACjC;CACA,OAAO,IAAI,OAAO,MAAM,GAAG,SAAS,IAAI,KAAK;AAC9C;AAEA,SAAgB,wBACf,OACA,UAAuB,CAAC,GACxB,QACS;CACT,MAAM,OAAO,WAAW,SAAS,IAAI;CACrC,KAAK,UAAU;CACf,IAAI,UAAU,KAAK,KAAK,OAAO,GAAG,MAAM,IAAI,MAAM,uBAAuB;CACzE,IAAI;EACH,OAAO,SAAS,KAAK,QAAQ,KAAK,OAAO,YAAY,UAAU,QAAQ,KAAK,GAAG,IAAI,CAAC,EAAE;CACvF,UAAU;EACT,QAAQ,IAAI;CACb;AACD"}
package/dist/server.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { a as Children, s as RootOptions } from "./capabilities-BCtBG-ni.js";
1
+ import { a as Children, s as RootOptions } from "./capabilities-_zOwNJ-2.js";
2
2
  export declare function renderToString(setup: () => Children, options?: RootOptions): string;
3
3
  //# sourceMappingURL=server.d.ts.map
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as renderToStringWithReads } from "./server-renderer-DcU55e6s.js";
1
+ import { t as renderToStringWithReads } from "./server-renderer-D-uRg04V.js";
2
2
  // src/server.ts
3
3
  function renderToString(setup, options = {}) {
4
4
  return renderToStringWithReads(setup, options);
package/dist/size.json CHANGED
@@ -1,24 +1,24 @@
1
1
  [
2
2
  {
3
3
  "name": "spa client",
4
- "raw": 20714,
5
- "minified": 9960,
6
- "gzip": 4218,
7
- "brotli": 3840
4
+ "raw": 21047,
5
+ "minified": 10101,
6
+ "gzip": 4275,
7
+ "brotli": 3887
8
8
  },
9
9
  {
10
10
  "name": "spa + atom.io",
11
- "raw": 109879,
12
- "minified": 53633,
13
- "gzip": 16164,
14
- "brotli": 14636
11
+ "raw": 110212,
12
+ "minified": 53774,
13
+ "gzip": 16223,
14
+ "brotli": 14682
15
15
  },
16
16
  {
17
17
  "name": "spa Astro client",
18
- "raw": 25690,
19
- "minified": 12190,
20
- "gzip": 5027,
21
- "brotli": 4544
18
+ "raw": 26023,
19
+ "minified": 12331,
20
+ "gzip": 5071,
21
+ "brotli": 4585
22
22
  },
23
23
  {
24
24
  "name": "Preact",
package/dist/three.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { a as Children, c as SpaElement } from "./capabilities-BCtBG-ni.js";
1
+ import { a as Children, c as SpaElement } from "./capabilities-_zOwNJ-2.js";
2
2
  import { SceneRenderer } from "./renderer.js";
3
- import "./index-DufwkB6W.js";
4
- import { t as CapabilityAttributes } from "./jsx-runtime-DMDVr7A5.js";
3
+ import "./index-BFIjI7gF.js";
4
+ import { t as CapabilityAttributes } from "./jsx-runtime-BhiCZOYZ.js";
5
5
  import * as THREE from "three";
6
6
  interface ThreePointerEvent<N extends THREE.Object3D = THREE.Object3D> {
7
7
  type: string;
package/dist/three.js CHANGED
@@ -187,14 +187,17 @@ function createThreeEvents(canvas, scene, camera, onError = (error) => {
187
187
  if (event.type === `pointerup`) {
188
188
  const down = pressed.get(event.pointerId);
189
189
  pressed.delete(event.pointerId);
190
- if (down && down.node !== delivery?.node) dispatch(`pointercancel`, down, event);
191
- if (delivery) dispatch(`pointerup`, delivery, event);
192
- if (down && down.node === hit?.node && event.button === 0) dispatch(`click`, hit, event);
193
- captures.delete(event.pointerId);
194
- nativeCapture(event.pointerId);
195
- if (event.pointerType === `touch`) {
196
- hover(event);
197
- last.delete(event.pointerId);
190
+ try {
191
+ if (down && !capture && down.node !== hit?.node) dispatch(`pointercancel`, down, event);
192
+ if (delivery) dispatch(`pointerup`, delivery, event);
193
+ if (down && down.node === hit?.node && event.button === 0) dispatch(`click`, hit, event);
194
+ } finally {
195
+ captures.delete(event.pointerId);
196
+ nativeCapture(event.pointerId);
197
+ if (event.pointerType === `touch`) {
198
+ hover(event);
199
+ last.delete(event.pointerId);
200
+ }
198
201
  }
199
202
  } else if (delivery) dispatch(event.type, delivery, event);
200
203
  } catch (error) {
package/dist/three.js.map CHANGED
@@ -1 +1 @@
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\tif (down && down.node !== delivery?.node)\n\t\t\t\t\tdispatch(`pointercancel`, down, event)\n\t\t\t\tif (delivery) dispatch(`pointerup`, delivery, event)\n\t\t\t\tif (down && down.node === hit?.node && event.button === 0)\n\t\t\t\t\tdispatch(`click`, hit, event)\n\t\t\t\tcaptures.delete(event.pointerId)\n\t\t\t\tnativeCapture(event.pointerId)\n\t\t\t\tif (event.pointerType === `touch`) {\n\t\t\t\t\thover(event)\n\t\t\t\t\tlast.delete(event.pointerId)\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 { fail, isPresent, owner } 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{ geometry: THREE.BufferGeometry; material: THREE.Material }\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 as THREE.Material,\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\tif (props[key])\n\t\t\t\t\thandlers.set(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tlistenThree(\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tkey.slice(2).toLowerCase(),\n\t\t\t\t\t\t\tprops[key] as ThreeEventHandler,\n\t\t\t\t\t\t),\n\t\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\tfor (const child of [...parent.children])\n\t\t\tif (!objects.includes(child)) parent.remove(child)\n\t\tfor (const child of objects) if (child.parent !== parent) parent.add(child)\n\t\tparent.children.splice(0, parent.children.length, ...objects)\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\towned.geometry.dispose()\n\t\t\t\t\towned.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((value, index) => Object.is(value, b[index]))\n\t)\n}\n\nexport interface CanvasProps {\n\tchildren?: Children\n\twidth?: number\n\theight?: number\n\tcamera?: THREE.Camera\n\tonFrame?: (state: {\n\t\tscene: THREE.Scene\n\t\tcamera: THREE.Camera\n\t\trenderer: THREE.WebGLRenderer\n\t\tdelta: number\n\t\ttime: number\n\t}) => 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 webgl = new THREE.WebGLRenderer({ canvas: canvas!, antialias: true })\n\t\tonCleanup(() => {\n\t\t\twebgl.dispose()\n\t\t})\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\tbindScene(\n\t\t\t() => [props.width ?? 800, props.height ?? 600] as const,\n\t\t\t([width, height]) => {\n\t\t\t\twebgl.setSize(width, height)\n\t\t\t\tcamera.aspect = width / height\n\t\t\t\tcamera.updateProjectionMatrix()\n\t\t\t},\n\t\t)\n\t\trenderer.mount(() => props.children, scene)\n\t\tconst scope = owner!\n\t\tconst root = scope._root\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\ttry {\n\t\t\t\t\tfail(root, error)\n\t\t\t\t} catch (failure) {\n\t\t\t\t\troot.error(failure)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tonCleanup(() => {\n\t\t\tevents.dispose()\n\t\t})\n\t\tlet last: number | undefined\n\t\tonSceneFrame((time) => {\n\t\t\tconst active = props.camera ?? camera\n\t\t\tconst delta = last === undefined ? 0 : (time - last) / 1000\n\t\t\tlast = time\n\t\t\tif (isPresent(scope))\n\t\t\t\tprops.onFrame?.({\n\t\t\t\t\tscene,\n\t\t\t\t\tcamera: active,\n\t\t\t\t\trenderer: webgl,\n\t\t\t\t\tdelta,\n\t\t\t\t\ttime: time / 1000,\n\t\t\t\t})\n\t\t\tevents.update()\n\t\t\twebgl.render(scene, active)\n\t\t}, true)\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<ObjectProps<THREE.Mesh>>(`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,IAA0B;CACpE,UAAU,IAAI,MAAM,MAAM;CAC1B,MAAM,WAAW,OAAO,IAAI,IAAI,qBAAK,IAAI,IAAa;CACtD,OAAO,IAAI,MAAM,QAAQ;CACzB,SAAS,IAAI,OAAO;CACpB,aAAa;EACZ,SAAS,OAAO,OAAO;EACvB,IAAI,CAAC,SAAS,MAAM,OAAO,OAAO,IAAI;CACvC;AACD;AACA,SAAgB,YAAY,MAA4B;CACvD,MAAM,SAAoB,CAAC;CAC3B,KAAK,MAAM,WAAW,UACrB,IAAI;EACH,QAAQ,OAAO,IAAI;CACpB,SAAS,OAAO;EACf,OAAO,KAAK,KAAK;CAClB;CAED,UAAU,OAAO,IAAI;CACrB,IAAI,OAAO,QAAQ,MAAM,IAAI,eAAe,MAA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ACxB,OAAO,uBAAuB;EAC/B,CACD;EACA,SAAS,YAAY,MAAM,UAAU,KAAK;EAC1C,MAAM,QAAQ;EACd,MAAM,OAAO,MAAM;EACnB,MAAM,SAAS,kBACd,QACA,aACM,MAAM,UAAU,SACrB,UAAU;GACV,IAAI;IACH,KAAK,MAAM,KAAK;GACjB,SAAS,SAAS;IACjB,KAAK,MAAM,OAAO;GACnB;EACD,CACD;EACA,gBAAgB;GACf,OAAO,QAAQ;EAChB,CAAC;EACD,IAAI;EACJ,cAAc,SAAS;GACtB,MAAM,SAAS,MAAM,UAAU;GAC/B,MAAM,QAAQ,SAAS,KAAA,IAAY,KAAK,OAAO,QAAQ;GACvD,OAAO;GACP,IAAI,UAAU,KAAK,GAClB,MAAM,UAAU;IACf;IACA,QAAQ;IACR,UAAU;IACV;IACA,MAAM,OAAO;GACd,CAAC;GACF,OAAO,OAAO;GACd,MAAM,OAAO,OAAO,MAAM;EAC3B,GAAG,IAAI;CACR,CAAC;CACD,OAAO,IAAI,UAAU,EACpB,MAAM,YAAsC;EAC3C,SAAS;CACV,EACD,CAAC;AACF;AACA,MAAa,QAAQ,eAA4B,OAAO;AACxD,MAAa,OAAO,eAAwC,MAAM;AAClE,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
+ {"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 { fail, isPresent, owner } 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{ geometry: THREE.BufferGeometry; material: THREE.Material }\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 as THREE.Material,\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\tif (props[key])\n\t\t\t\t\thandlers.set(\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tlistenThree(\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tkey.slice(2).toLowerCase(),\n\t\t\t\t\t\t\tprops[key] as ThreeEventHandler,\n\t\t\t\t\t\t),\n\t\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\tfor (const child of [...parent.children])\n\t\t\tif (!objects.includes(child)) parent.remove(child)\n\t\tfor (const child of objects) if (child.parent !== parent) parent.add(child)\n\t\tparent.children.splice(0, parent.children.length, ...objects)\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\towned.geometry.dispose()\n\t\t\t\t\towned.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((value, index) => Object.is(value, b[index]))\n\t)\n}\n\nexport interface CanvasProps {\n\tchildren?: Children\n\twidth?: number\n\theight?: number\n\tcamera?: THREE.Camera\n\tonFrame?: (state: {\n\t\tscene: THREE.Scene\n\t\tcamera: THREE.Camera\n\t\trenderer: THREE.WebGLRenderer\n\t\tdelta: number\n\t\ttime: number\n\t}) => 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 webgl = new THREE.WebGLRenderer({ canvas: canvas!, antialias: true })\n\t\tonCleanup(() => {\n\t\t\twebgl.dispose()\n\t\t})\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\tbindScene(\n\t\t\t() => [props.width ?? 800, props.height ?? 600] as const,\n\t\t\t([width, height]) => {\n\t\t\t\twebgl.setSize(width, height)\n\t\t\t\tcamera.aspect = width / height\n\t\t\t\tcamera.updateProjectionMatrix()\n\t\t\t},\n\t\t)\n\t\trenderer.mount(() => props.children, scene)\n\t\tconst scope = owner!\n\t\tconst root = scope._root\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\ttry {\n\t\t\t\t\tfail(root, error)\n\t\t\t\t} catch (failure) {\n\t\t\t\t\troot.error(failure)\n\t\t\t\t}\n\t\t\t},\n\t\t)\n\t\tonCleanup(() => {\n\t\t\tevents.dispose()\n\t\t})\n\t\tlet last: number | undefined\n\t\tonSceneFrame((time) => {\n\t\t\tconst active = props.camera ?? camera\n\t\t\tconst delta = last === undefined ? 0 : (time - last) / 1000\n\t\t\tlast = time\n\t\t\tif (isPresent(scope))\n\t\t\t\tprops.onFrame?.({\n\t\t\t\t\tscene,\n\t\t\t\t\tcamera: active,\n\t\t\t\t\trenderer: webgl,\n\t\t\t\t\tdelta,\n\t\t\t\t\ttime: time / 1000,\n\t\t\t\t})\n\t\t\tevents.update()\n\t\t\twebgl.render(scene, active)\n\t\t}, true)\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<ObjectProps<THREE.Mesh>>(`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,4BA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G,IAAI;CACR,CAAC;CACD,OAAO,IAAI,UAAU,EACpB,MAAM,YAAsC;EAC3C,SAAS;CACV,EACD,CAAC;AACF;AACA,MAAa,QAAQ,eAA4B,OAAO;AACxD,MAAa,OAAO,eAAwC,MAAM;AAClE,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"}
@@ -132,19 +132,44 @@ function compile(code, filename) {
132
132
  ]);
133
133
  }
134
134
  }
135
+ const component = node.type === `JSXElement` && !tag(node.openingElement.name).startsWith(`"`);
135
136
  const children = [];
137
+ let lazyChildren = false;
136
138
  for (const child of node.children) if (child.type === `JSXText`) {
137
139
  const value = text(decodeJsx(child.value));
138
140
  if (value) children.push([JSON.stringify(value)]);
139
141
  } else if (child.type === `JSXElement` || child.type === `JSXFragment`) children.push([child]);
140
142
  else if (child.type === `JSXExpressionContainer`) {
141
- if (child.expression.type !== `JSXEmptyExpression`) children.push(expression(child.expression));
143
+ if (child.expression.type !== `JSXEmptyExpression`) {
144
+ if (component) {
145
+ children.push([
146
+ `(`,
147
+ child.expression,
148
+ `)`
149
+ ]);
150
+ if (!eager(child.expression, true)) lazyChildren = true;
151
+ } else children.push(expression(child.expression));
152
+ }
142
153
  } else throw new SyntaxError(`${filename}: JSX spread children are unsupported`);
143
- if (children.length) properties.push([`children: `, ...children.length === 1 ? children[0] : [
144
- `[`,
145
- ...join(children, `, `),
146
- `]`
147
- ]]);
154
+ if (children.length) {
155
+ const value = children.length === 1 ? children[0] : [
156
+ `[`,
157
+ ...join(children, `, `),
158
+ `]`
159
+ ];
160
+ if (lazyChildren) {
161
+ const read = uid(`children`);
162
+ properties.push([`get children(){ return ${read}(); }`]);
163
+ chunks.push([
164
+ `((${read}) => ({`,
165
+ ...join(properties, `, `),
166
+ `}))(() => (`,
167
+ ...value,
168
+ `))`
169
+ ]);
170
+ properties = [];
171
+ } else properties.push([`children: `, ...value]);
172
+ }
148
173
  flush();
149
174
  const props = node.type === `JSXElement` && node.openingElement.attributes.some((attr) => attr.type === `JSXSpreadAttribute`) ? [
150
175
  `${merge}(`,
@@ -237,4 +262,4 @@ function spa(options = {}) {
237
262
  }
238
263
  export { spa as t };
239
264
 
240
- //# sourceMappingURL=vite-CSHoxzXU.js.map
265
+ //# sourceMappingURL=vite-Bmyb6P5w.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-Bmyb6P5w.js","names":[],"sources":["../src/compiler.ts","../src/vite.ts"],"sourcesContent":["import { decode } from \"html-entities\"\nimport type { SourceMap } from \"magic-string\"\nimport MagicString from \"magic-string\"\nimport type {\n\tExpression,\n\tJSXElement,\n\tJSXElementName,\n\tJSXFragment,\n\tNode,\n} from \"oxc-parser\"\nimport { parseSync, visitorKeys } from \"oxc-parser\"\n\ntype Part = string | Node\n\nconst decodeJsx = (value: string): string =>\n\tdecode(value, { level: `html4`, scope: `strict` })\n\n/** Match JSX's multiline whitespace rules without reprinting JavaScript. */\nfunction text(value: string): string {\n\tconst lines = value.split(/\\r\\n|\\n|\\r/)\n\tlet last = 0\n\tfor (let i = 0; i < lines.length; i++) if (/[^ \\t]/.test(lines[i])) last = i\n\treturn lines\n\t\t.map((line, i) => {\n\t\t\tline = line.replace(/\\t/g, ` `)\n\t\t\tif (i > 0) line = line.replace(/^ +/, ``)\n\t\t\tif (i < lines.length - 1) line = line.replace(/ +$/, ``)\n\t\t\treturn line && i < last ? `${line} ` : line\n\t\t})\n\t\t.join(``)\n}\n\nfunction eager(node: Node, allowJsx = false): boolean {\n\tif (node.type === `ParenthesizedExpression`)\n\t\treturn eager(node.expression, allowJsx)\n\treturn (\n\t\tnode.type === `Literal` ||\n\t\tnode.type === `FunctionExpression` ||\n\t\tnode.type === `ArrowFunctionExpression` ||\n\t\t(allowJsx && (node.type === `JSXElement` || node.type === `JSXFragment`)) ||\n\t\t(node.type === `TemplateLiteral` && node.expressions.length === 0)\n\t)\n}\n\nexport function compile(\n\tcode: string,\n\tfilename: string,\n): { code: string; map: SourceMap } {\n\tconst parsed = parseSync(filename, code, {\n\t\tlang: `tsx`,\n\t\tpreserveParens: true,\n\t})\n\tif (parsed.errors.length) {\n\t\tconst error = parsed.errors[0]\n\t\tthrow new SyntaxError(\n\t\t\t[`${filename}: ${error.message}`, error.codeframe]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(`\\n`),\n\t\t)\n\t}\n\tconst output = new MagicString(code)\n\tconst parents = new WeakMap<Node, Node>()\n\tconst identifiers = new Set<string>()\n\tconst elements: (JSXElement | JSXFragment)[] = []\n\tconst functions = new Set<Node>()\n\tfunction walk(node: Node, parent?: Node, outerFunction?: Node): void {\n\t\tif (parent) parents.set(node, parent)\n\t\toutput.addSourcemapLocation(node.start)\n\t\toutput.addSourcemapLocation(node.end)\n\t\tif (node.type === `Identifier` || node.type === `JSXIdentifier`)\n\t\t\tidentifiers.add(node.name)\n\t\tif (\n\t\t\t!outerFunction &&\n\t\t\t(node.type === `FunctionDeclaration` ||\n\t\t\t\tnode.type === `FunctionExpression` ||\n\t\t\t\tnode.type === `ArrowFunctionExpression`)\n\t\t)\n\t\t\touterFunction = node\n\t\tif (node.type === `JSXElement` || node.type === `JSXFragment`) {\n\t\t\telements.push(node)\n\t\t\tif (outerFunction) functions.add(outerFunction)\n\t\t}\n\t\tfor (const key of visitorKeys[node.type]) {\n\t\t\tconst value = (node as unknown as Record<string, unknown>)[key]\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (const child of value) if (child) walk(child, node, outerFunction)\n\t\t\t} else if (value) walk(value as Node, node, outerFunction)\n\t\t}\n\t}\n\twalk(parsed.program)\n\tfunction uid(base: string): string {\n\t\tlet name = `_${base}`\n\t\tlet suffix = 1\n\t\twhile (identifiers.has(name)) name = `_${base}${++suffix}`\n\t\tidentifiers.add(name)\n\t\treturn name\n\t}\n\tconst create = uid(`spa`)\n\tconst merge = uid(`props`)\n\tconst join = (parts: Part[][], separator: string): Part[] =>\n\t\tparts.flatMap((part, i) => (i ? [separator, ...part] : part))\n\tconst expression = (node: Expression): Part[] =>\n\t\teager(node, true) ? [`(`, node, `)`] : [`() => (`, node, `)`]\n\tfunction tag(node: JSXElementName): string {\n\t\tif (node.type === `JSXNamespacedName`)\n\t\t\treturn JSON.stringify(`${node.namespace.name}:${node.name.name}`)\n\t\tif (node.type === `JSXMemberExpression`)\n\t\t\treturn code.slice(node.start, node.end)\n\t\treturn /^[a-z]/.test(node.name) || node.name.includes(`-`)\n\t\t\t? JSON.stringify(node.name)\n\t\t\t: node.name\n\t}\n\t/** Rewrite syntax around untouched expression spans, including nested JSX. */\n\tfunction rewrite(node: JSXElement | JSXFragment, parts: Part[]): void {\n\t\tlet cursor = node.start\n\t\tlet replacement = ``\n\t\tfor (const part of parts) {\n\t\t\tif (typeof part === `string`) {\n\t\t\t\treplacement += part\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (cursor < part.start) output.update(cursor, part.start, replacement)\n\t\t\telse output.appendLeft(cursor, replacement)\n\t\t\tcursor = part.end\n\t\t\treplacement = ``\n\t\t}\n\t\t// Every JSX node ends with closing syntax after its last expression span.\n\t\toutput.update(cursor, node.end, replacement)\n\t}\n\tfor (const node of elements) {\n\t\tconst chunks: Part[][] = []\n\t\tlet properties: Part[][] = []\n\t\tconst flush = () => {\n\t\t\tif (properties.length) chunks.push([`{`, ...join(properties, `, `), `}`])\n\t\t\tproperties = []\n\t\t}\n\t\tif (node.type === `JSXElement`) {\n\t\t\tfor (const attribute of node.openingElement.attributes) {\n\t\t\t\tif (attribute.type === `JSXSpreadAttribute`) {\n\t\t\t\t\tflush()\n\t\t\t\t\tchunks.push([`() => (`, attribute.argument, `)`])\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst key = JSON.stringify(\n\t\t\t\t\tattribute.name.type === `JSXNamespacedName`\n\t\t\t\t\t\t? `${attribute.name.namespace.name}:${attribute.name.name.name}`\n\t\t\t\t\t\t: attribute.name.name,\n\t\t\t\t)\n\t\t\t\tconst value = attribute.value\n\t\t\t\tif (!value) properties.push([`${key}: true`])\n\t\t\t\telse if (value.type === `Literal`)\n\t\t\t\t\tproperties.push([`${key}: ${JSON.stringify(decodeJsx(value.value))}`])\n\t\t\t\telse {\n\t\t\t\t\tconst expr =\n\t\t\t\t\t\tvalue.type === `JSXExpressionContainer` ? value.expression : value\n\t\t\t\t\tproperties.push(\n\t\t\t\t\t\tkey === `\"key\"` || eager(expr)\n\t\t\t\t\t\t\t? [`${key}: (`, expr, `)`]\n\t\t\t\t\t\t\t: [`get ${key}(){ return (`, expr, `); }`],\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst component =\n\t\t\tnode.type === `JSXElement` &&\n\t\t\t!tag(node.openingElement.name).startsWith(`\"`)\n\t\tconst children: Part[][] = []\n\t\tlet lazyChildren = false\n\t\tfor (const child of node.children) {\n\t\t\tif (child.type === `JSXText`) {\n\t\t\t\tconst value = text(decodeJsx(child.value))\n\t\t\t\tif (value) children.push([JSON.stringify(value)])\n\t\t\t} else if (child.type === `JSXElement` || child.type === `JSXFragment`)\n\t\t\t\tchildren.push([child])\n\t\t\telse if (child.type === `JSXExpressionContainer`) {\n\t\t\t\tif (child.expression.type !== `JSXEmptyExpression`) {\n\t\t\t\t\tif (component) {\n\t\t\t\t\t\t// Component props expose their declared values, including callbacks.\n\t\t\t\t\t\tchildren.push([`(`, child.expression, `)`])\n\t\t\t\t\t\tif (!eager(child.expression, true)) lazyChildren = true\n\t\t\t\t\t} else children.push(expression(child.expression))\n\t\t\t\t}\n\t\t\t} else\n\t\t\t\tthrow new SyntaxError(`${filename}: JSX spread children are unsupported`)\n\t\t}\n\t\tif (children.length) {\n\t\t\tconst value =\n\t\t\t\tchildren.length === 1 ? children[0] : [`[`, ...join(children, `, `), `]`]\n\t\t\tif (lazyChildren) {\n\t\t\t\t// Capture the computation outside the getter's method scope.\n\t\t\t\tconst read = uid(`children`)\n\t\t\t\tproperties.push([`get children(){ return ${read}(); }`])\n\t\t\t\tchunks.push([\n\t\t\t\t\t`((${read}) => ({`,\n\t\t\t\t\t...join(properties, `, `),\n\t\t\t\t\t`}))(() => (`,\n\t\t\t\t\t...value,\n\t\t\t\t\t`))`,\n\t\t\t\t])\n\t\t\t\tproperties = []\n\t\t\t} else properties.push([`children: `, ...value])\n\t\t}\n\t\tflush()\n\t\tconst spreads =\n\t\t\tnode.type === `JSXElement` &&\n\t\t\tnode.openingElement.attributes.some(\n\t\t\t\t(attr) => attr.type === `JSXSpreadAttribute`,\n\t\t\t)\n\t\tconst props = spreads\n\t\t\t? [`${merge}(`, ...join(chunks, `, `), `)`]\n\t\t\t: (chunks[0] ?? [`{}`])\n\t\trewrite(node, [\n\t\t\t`${create}(${node.type === `JSXElement` ? tag(node.openingElement.name) : `null`}, `,\n\t\t\t...props,\n\t\t\t`)`,\n\t\t])\n\t}\n\tconst components = new Set<string>()\n\tfor (const fn of functions) {\n\t\tlet node = fn\n\t\tlet parent = parents.get(node)\n\t\twhile (parent?.type === `ParenthesizedExpression`) {\n\t\t\tnode = parent\n\t\t\tparent = parents.get(node)\n\t\t}\n\t\tif (fn.type === `FunctionDeclaration` && fn.id) components.add(fn.id.name)\n\t\telse if (\n\t\t\tparent?.type === `VariableDeclarator` &&\n\t\t\tparent.id.type === `Identifier`\n\t\t)\n\t\t\tcomponents.add(parent.id.name)\n\t\telse if (parent?.type === `ExportDefaultDeclaration`) {\n\t\t\tconst name = uid(`Component`)\n\t\t\tif (fn.type === `FunctionDeclaration`) {\n\t\t\t\t// Keep anonymous default function declarations hoisted.\n\t\t\t\tconst token = [\n\t\t\t\t\t...code\n\t\t\t\t\t\t.slice(fn.start, fn.body!.start)\n\t\t\t\t\t\t.matchAll(/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\r\\n]*|\\bfunction\\b|\\*/g),\n\t\t\t\t].find((match) => match[0] === (fn.generator ? `*` : `function`))!\n\t\t\t\toutput.appendLeft(fn.start + token.index + token[0].length, ` ${name}`)\n\t\t\t} else {\n\t\t\t\t// Replace only keywords so intervening comments and annotations survive.\n\t\t\t\tconst prefix = code.slice(parent.start, node.start)\n\t\t\t\tfor (const token of prefix.matchAll(\n\t\t\t\t\t/\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\r\\n]*|\\b(?:export|default)\\b/g,\n\t\t\t\t)) {\n\t\t\t\t\tif (token[0] !== `export` && token[0] !== `default`) continue\n\t\t\t\t\toutput.update(\n\t\t\t\t\t\tparent.start + token.index,\n\t\t\t\t\t\tparent.start + token.index + token[0].length,\n\t\t\t\t\t\ttoken[0] === `export` ? `const ${name} =` : ``,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\toutput.appendLeft(parent.end, `;\\nexport default ${name};`)\n\t\t\t}\n\t\t\tcomponents.add(name)\n\t\t}\n\t}\n\tif (elements.length) {\n\t\t// Keep hashbangs and directive prologues ahead of generated imports.\n\t\tlet position = parsed.program.hashbang?.end ?? 0\n\t\tfor (const statement of parsed.program.body) {\n\t\t\tif (statement.type !== `ExpressionStatement` || !statement.directive) break\n\t\t\tposition = statement.end\n\t\t}\n\t\toutput.appendLeft(\n\t\t\tposition,\n\t\t\t`\\nimport { jsx as ${create}, merge as ${merge} } from \"@atom.io/spa/jsx-runtime\";\\n`,\n\t\t)\n\t\tfor (const component of components)\n\t\t\toutput.append(`\\n;${component}.spa = true;`)\n\t}\n\treturn {\n\t\tcode: output.toString(),\n\t\tmap: output.generateMap({\n\t\t\tsource: filename,\n\t\t\tincludeContent: true,\n\t\t\thires: true,\n\t\t}),\n\t}\n}\n","import type { Plugin } from \"vite\"\n\nimport { compile } from \"./compiler.ts\"\n\nexport interface SpaPluginOptions {\n\tinclude?: RegExp\n}\nexport default function spa(options: SpaPluginOptions = {}): Plugin {\n\tconst include = options.include ?? /\\.[jt]sx$/\n\tconst matches = (id: string): boolean => {\n\t\tinclude.lastIndex = 0\n\t\treturn !id.includes(`/node_modules/`) && include.test(id.split(`?`)[0])\n\t}\n\treturn {\n\t\tname: `spa`,\n\t\tenforce: `pre`,\n\t\tconfig() {\n\t\t\treturn {\n\t\t\t\tresolve: { dedupe: [`@atom.io/spa`, `atom.io`] },\n\t\t\t\toptimizeDeps: { exclude: [`@atom.io/spa`, `atom.io`] },\n\t\t\t}\n\t\t},\n\t\tconfigEnvironment: {\n\t\t\torder: `post`,\n\t\t\thandler(_name, config) {\n\t\t\t\t// Astro and its adapters force renderer entries into the optimizer.\n\t\t\t\t// Vite processes explicit includes even when their package is excluded.\n\t\t\t\t// Keep the renderer, hooks, and store in one unbundled module graph.\n\t\t\t\tif (config.optimizeDeps?.include) {\n\t\t\t\t\tconfig.optimizeDeps.include = config.optimizeDeps.include.filter(\n\t\t\t\t\t\t(id) => !/^(@atom\\.io\\/spa|atom\\.io)(\\/|$)/.test(id),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\ttransform(code, id) {\n\t\t\tif (!matches(id)) return\n\t\t\treturn compile(code, id)\n\t\t},\n\t\t// A reload disposes the whole document. No state-preserving HMR is promised.\n\t\thandleHotUpdate({ server, file }) {\n\t\t\tif (matches(file)) {\n\t\t\t\tserver.ws.send({ type: `full-reload` })\n\t\t\t\treturn []\n\t\t\t}\n\t\t},\n\t}\n}\n"],"mappings":";;;;AAcA,MAAM,aAAa,UAClB,OAAO,OAAO;CAAE,OAAO;CAAS,OAAO;AAAS,CAAC;;AAGlD,SAAS,KAAK,OAAuB;CACpC,MAAM,QAAQ,MAAM,MAAM,YAAY;CACtC,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,IAAI,S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K,EAAE,MAAM,cAAc,CAAC;IACtC,OAAO,CAAC;GACT;EACD;CACD;AACD"}
package/dist/vite.js CHANGED
@@ -1 +1 @@
1
- export { t as default } from "./vite-CSHoxzXU.js";
1
+ export { t as default } from "./vite-Bmyb6P5w.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atom.io/spa",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "An atom.io-driven JSX renderer.",
5
5
  "homepage": "https://atom.io.fyi/docs/spa",
6
6
  "repository": {
@@ -84,6 +84,11 @@
84
84
  "development": "./dist/development/motion.js",
85
85
  "import": "./dist/motion.js"
86
86
  },
87
+ "./floating": {
88
+ "types": "./dist/floating.d.ts",
89
+ "development": "./dist/development/floating.js",
90
+ "import": "./dist/floating.js"
91
+ },
87
92
  "./astro-resumability-client": {
88
93
  "types": "./dist/astro-resumability-client.d.ts",
89
94
  "development": "./dist/development/astro-resumability-client.js",
@@ -108,12 +113,13 @@
108
113
  },
109
114
  "devDependencies": {
110
115
  "@breakage/changesets": "0.1.0",
116
+ "@floating-ui/dom": "1.8.0",
111
117
  "@jridgewell/trace-mapping": "0.3.31",
112
118
  "@types/node": "26.6.6",
113
119
  "@types/three": "0.187.0",
114
120
  "@vitest/coverage-v8": "5.1.0",
115
121
  "astro": "7.4.7",
116
- "atom.io": "0.54.6",
122
+ "atom.io": "0.54.7",
117
123
  "breakage": "0.10.2",
118
124
  "esbuild": "0.28.2",
119
125
  "eslint": "10.14.0",
@@ -131,6 +137,7 @@
131
137
  "vitest": "5.1.0"
132
138
  },
133
139
  "peerDependencies": {
140
+ "@floating-ui/dom": "^1.8.0",
134
141
  "@types/three": "^0.187.0",
135
142
  "astro": "^7.4.2",
136
143
  "atom.io": "^0.54.4",
@@ -141,6 +148,9 @@
141
148
  "vite": "^8.3.5"
142
149
  },
143
150
  "peerDependenciesMeta": {
151
+ "@floating-ui/dom": {
152
+ "optional": true
153
+ },
144
154
  "@types/three": {
145
155
  "optional": true
146
156
  },
@@ -190,6 +200,8 @@
190
200
  "bench:compiler": "node scripts/compiler-benchmark.ts",
191
201
  "example:motion": "vite --config examples/motion/vite.config.ts",
192
202
  "test:browser:motion": "node scripts/motion-browser-test.mjs",
203
+ "example:floating": "vite --config examples/floating/vite.config.ts",
204
+ "test:browser:floating": "node scripts/floating-browser-test.mjs",
193
205
  "test:browser:resumption": "astro build --root __tests__/resumption && node scripts/resumption-browser-test.mjs && node scripts/resumption-browser-test.mjs --dev"
194
206
  }
195
207
  }
@@ -61,7 +61,7 @@ export function requestApplication(
61
61
  return app
62
62
  }
63
63
  /** Install definitions imported after an earlier island started this request. */
64
- export function syncDefinitions(store: RootStore): void {
64
+ function syncDefinitions(store: RootStore): void {
65
65
  const source = IMPLICIT.STORE
66
66
  for (const field of [
67
67
  `families`,
@@ -13,14 +13,16 @@ export interface CapabilityTarget {
13
13
  export interface CapabilityBinding {
14
14
  exit?(props: Record<string, unknown>): ExitHandle | undefined
15
15
  resume?(): void
16
- update(props: Record<string, unknown>): void
16
+ /** Inline CSS before native style replacement, for restoring capability-owned values. */
17
+ update(props: Record<string, unknown>, previousStyle?: string): void
17
18
  dispose(): void
18
19
  }
19
20
  export interface Capability {
20
21
  namespace: string
21
22
  presence?(root: Root): PresenceCoordinator
22
23
  scheduleFrame?(callback: (time: number) => void): Cleanup
23
- attach(target: CapabilityTarget): CapabilityBinding
24
+ /** SPA supplies ownership for integrations that measure after mount or report async errors. */
25
+ attach(target: CapabilityTarget, scope?: Scope): CapabilityBinding
24
26
  }
25
27
 
26
28
  export function capabilityNamespace(key: string): string | undefined {
@@ -47,6 +49,7 @@ export function capabilityProps(
47
49
  scope: Scope,
48
50
  target: CapabilityTarget,
49
51
  read?: () => Record<string, any>,
52
+ applyNative?: (props: Record<string, any>) => string | undefined,
50
53
  ): (props: Record<string, any>) => Record<string, any> {
51
54
  const bindings = new Map<string, CapabilityBinding>()
52
55
 
@@ -82,10 +85,11 @@ export function capabilityProps(
82
85
  group[key.slice(namespace.length + 1)] = props[key]
83
86
  groups.set(namespace, group)
84
87
  }
88
+ const previousStyle = applyNative?.(native)
85
89
  for (const [namespace, values] of groups) {
86
90
  let binding = bindings.get(namespace)
87
91
  if (!binding) {
88
- binding = scope._root._capabilities.get(namespace)!.attach(target)
92
+ binding = scope._root._capabilities.get(namespace)!.attach(target, scope)
89
93
  bindings.set(namespace, binding)
90
94
  scope._root._presence?.bind(
91
95
  scope,
@@ -94,7 +98,8 @@ export function capabilityProps(
94
98
  namespace,
95
99
  )
96
100
  }
97
- binding.update(values)
101
+ if (previousStyle !== undefined) binding.update(values, previousStyle)
102
+ else binding.update(values)
98
103
  }
99
104
  for (const [namespace, binding] of bindings)
100
105
  if (!groups.has(namespace)) {
package/src/compiler.ts CHANGED
@@ -161,7 +161,11 @@ export function compile(
161
161
  }
162
162
  }
163
163
  }
164
+ const component =
165
+ node.type === `JSXElement` &&
166
+ !tag(node.openingElement.name).startsWith(`"`)
164
167
  const children: Part[][] = []
168
+ let lazyChildren = false
165
169
  for (const child of node.children) {
166
170
  if (child.type === `JSXText`) {
167
171
  const value = text(decodeJsx(child.value))
@@ -169,18 +173,33 @@ export function compile(
169
173
  } else if (child.type === `JSXElement` || child.type === `JSXFragment`)
170
174
  children.push([child])
171
175
  else if (child.type === `JSXExpressionContainer`) {
172
- if (child.expression.type !== `JSXEmptyExpression`)
173
- children.push(expression(child.expression))
176
+ if (child.expression.type !== `JSXEmptyExpression`) {
177
+ if (component) {
178
+ // Component props expose their declared values, including callbacks.
179
+ children.push([`(`, child.expression, `)`])
180
+ if (!eager(child.expression, true)) lazyChildren = true
181
+ } else children.push(expression(child.expression))
182
+ }
174
183
  } else
175
184
  throw new SyntaxError(`${filename}: JSX spread children are unsupported`)
176
185
  }
177
- if (children.length)
178
- properties.push([
179
- `children: `,
180
- ...(children.length === 1
181
- ? children[0]
182
- : [`[`, ...join(children, `, `), `]`]),
183
- ])
186
+ if (children.length) {
187
+ const value =
188
+ children.length === 1 ? children[0] : [`[`, ...join(children, `, `), `]`]
189
+ if (lazyChildren) {
190
+ // Capture the computation outside the getter's method scope.
191
+ const read = uid(`children`)
192
+ properties.push([`get children(){ return ${read}(); }`])
193
+ chunks.push([
194
+ `((${read}) => ({`,
195
+ ...join(properties, `, `),
196
+ `}))(() => (`,
197
+ ...value,
198
+ `))`,
199
+ ])
200
+ properties = []
201
+ } else properties.push([`children: `, ...value])
202
+ }
184
203
  flush()
185
204
  const spreads =
186
205
  node.type === `JSXElement` &&