@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
package/README.md CHANGED
@@ -57,6 +57,8 @@ export function PointEditor(): SpaElement {
57
57
 
58
58
  Name the getter and setter after the atom: pointAtom uses getPoint and setPoint. The getPoint getter returns the current object. Each JSX attribute reads its coordinate when evaluated. Both bindings depend on the point atom, and unchanged primitive results skip DOM writes. Reads during setup are snapshots; reads in event handlers are current and untracked. Shared derived state belongs in atom.io selectors.
59
59
 
60
+ Component children follow the same getter contract as named props. A component declaring string children reads a string for both literal text and expression children, including an explicit children attribute. Read props.children inside compiled JSX or a tracked binding for reactive updates; setup reads capture a snapshot. Deliberately function-valued children remain functions, including render callbacks.
61
+
60
62
  ## Astro
61
63
 
62
64
  Register the Astro integration, which compiles .tsx and .jsx components by default:
@@ -454,11 +456,11 @@ Sizes are exact minified and level-9 gzip JavaScript byte counts. Declarations,
454
456
 
455
457
  | Recipe | Entry | Minified JS | Gzip JS |
456
458
  | -------------------------------- | --------------------------------- | ----------: | -------: |
457
- | Family app with refs and history | `tonnage-recipes/family-app.ts` | 64,020 B | 19,088 B |
458
- | Async interactive client app | `tonnage-recipes/async-app.ts` | 42,445 B | 13,332 B |
459
- | Interactive client app | `tonnage-recipes/client-app.ts` | 42,108 B | 13,178 B |
460
- | Hydrated interactive app | `tonnage-recipes/hydrated-app.ts` | 42,109 B | 13,176 B |
461
- | Interactive Astro island | `tonnage-recipes/astro-island.ts` | 48,624 B | 15,226 B |
459
+ | Family app with refs and history | `tonnage-recipes/family-app.ts` | 64,161 B | 19,153 B |
460
+ | Async interactive client app | `tonnage-recipes/async-app.ts` | 42,586 B | 13,386 B |
461
+ | Interactive client app | `tonnage-recipes/client-app.ts` | 42,249 B | 13,236 B |
462
+ | Hydrated interactive app | `tonnage-recipes/hydrated-app.ts` | 42,250 B | 13,234 B |
463
+ | Interactive Astro island | `tonnage-recipes/astro-island.ts` | 48,765 B | 15,286 B |
462
464
 
463
465
  Report maintained with [tonnage](https://github.com/jeremybanka/tonnage).
464
466
 
@@ -709,6 +711,103 @@ Exit props and transition settings are read at logical removal; later state chan
709
711
 
710
712
  Root disposal and fatal errors bypass exits, stop active work, and release resources immediately. Stale animation completions cannot dispose a revived instance. This API covers exit retention and cancellation; layout/pop-layout animation, variants, presence wrappers, and automatic reparenting remain outside its scope.
711
713
 
714
+ ### Floating overlays with Motion
715
+
716
+ The optional @atom.io/spa/floating entrypoint adapts @floating-ui/dom. Install Floating UI and Motion for this example, then register both capabilities on the root:
717
+
718
+ ```sh
719
+ pnpm add @floating-ui/dom motion
720
+
721
+ ```
722
+
723
+ ```tsx
724
+ import { render } from "@atom.io/spa"
725
+ import { floatingCapability } from "@atom.io/spa/floating"
726
+ import { motionCapability } from "@atom.io/spa/motion"
727
+
728
+ import { FloatingDetails } from "./floating.tsx"
729
+
730
+ render(() => <FloatingDetails id="details" />, document.getElementById(`app`)!, {
731
+ capabilities: [floatingCapability(), motionCapability()],
732
+ })
733
+
734
+ ```
735
+
736
+ Floating positions an HTML overlay using CSS translate. Motion can animate x, y, scale, rotation, and opacity on that same element through its separate transform property:
737
+
738
+ ```tsx
739
+ import type { SpaElement } from "@atom.io/spa"
740
+ import { useGetter, useId, useRef, useSetter } from "@atom.io/spa"
741
+ import { flip, offset, shift } from "@floating-ui/dom"
742
+ import { atomFamily } from "atom.io"
743
+
744
+ const floatingOpenAtoms = atomFamily<boolean, string>({
745
+ key: `floatingOpen`,
746
+ default: false,
747
+ })
748
+ const floatingTriggerAtoms = atomFamily<HTMLButtonElement | null, string>({
749
+ key: `floatingTrigger`,
750
+ default: null,
751
+ })
752
+ const middleware = [offset(8), flip(), shift({ padding: 8 })]
753
+
754
+ export function FloatingDetails(props: { id: string }): SpaElement {
755
+ const getOpen = useGetter(floatingOpenAtoms, props.id)
756
+ const setOpen = useSetter(floatingOpenAtoms, props.id)
757
+ const getTrigger = useGetter(floatingTriggerAtoms, props.id)
758
+ const attachTrigger = useRef(floatingTriggerAtoms, props.id)
759
+ const panelId = useId()
760
+ return (
761
+ <>
762
+ <button
763
+ ref={attachTrigger}
764
+ aria-expanded={getOpen()}
765
+ aria-controls={panelId}
766
+ onClick={() => {
767
+ setOpen((value) => !value)
768
+ }}
769
+ >
770
+ Details
771
+ </button>
772
+ {getOpen() && (
773
+ <section
774
+ key="details"
775
+ id={panelId}
776
+ aria-label="Details"
777
+ style="width: 240px; margin: 0"
778
+ floating:reference={getTrigger()}
779
+ floating:placement="bottom-start"
780
+ floating:middleware={middleware}
781
+ motion:initial={{ opacity: 0, y: -4, scale: 0.98 }}
782
+ motion:animate={{ opacity: 1, y: 0, scale: 1 }}
783
+ motion:exit={{ opacity: 0, y: -4, scale: 0.98 }}
784
+ >
785
+ More information about this item.
786
+ </section>
787
+ )}
788
+ </>
789
+ )
790
+ }
791
+
792
+ ```
793
+
794
+ | Attribute | Behavior |
795
+ | ------------------- | --------------------------------------------------------------------------------------------------- |
796
+ | floating:reference | A DOM or virtual reference; null releases positioning. |
797
+ | floating:placement | Floating UI placement, defaulting to bottom. |
798
+ | floating:strategy | absolute or fixed, defaulting to absolute. |
799
+ | floating:middleware | Standard Floating UI middleware such as offset, flip, and shift. |
800
+ | floating:enabled | Defaults to true; set false when a mounted overlay is closed. |
801
+ | floating:autoUpdate | Defaults to true; accepts observer options, or false for positioning only on SPA attribute updates. |
802
+
803
+ The capability waits for mount and ref publication before measuring, hides the overlay until its first position is available, and reconnects observers when its reference or observer options change. Updates from obsolete calculations are ignored. Server rendering omits floating attributes and starts no observers. Virtual references can supply getBoundingClientRect and an optional contextElement, as documented by Floating UI.
804
+
805
+ Give the overlay a fixed width or width: max-content and avoid margins so measurement remains stable. Floating owns position, left, top, and translate while enabled, and temporarily owns visibility until the first measurement. Do not animate translate through Motion or assign those positioning properties through another style writer on the same element. Floating restores original inline values and priorities when disabled, removed, or disposed. Keyboard behavior, focus management, dismissal, and top-layer mounting remain application responsibilities.
806
+
807
+ Reactive inline style changes preserve the current anchor position and Motion values while new measurements are pending. Temporary hiding uses !important until the first position is available, then restores the original inline visibility value and priority.
808
+
809
+ Position updates continue during Motion's retained exits, until physical disposal. If the reference itself moves through transforms, enable animationFrame in floating:autoUpdate. Run the package's example:floating script for a scrollable experiment with same-element scaling and rotation, moving anchors, viewport collisions, positioning strategies, and interrupted exits. Its test:browser:floating script checks actual Chromium geometry in both capability registration orders.
810
+
712
811
  ### Renderer extensions
713
812
 
714
813
  The renderer entrypoint exposes createSceneRenderer, sceneComponent, bindScene, and onSceneFrame for imperative scene adapters. A host supplies creation, property updates, ordered child attachment, and destruction. Its children callback receives the parent, all owned children including retained exits, and the active children in that collection. Single resource slots can use active children for replacement while retaining ownership of outgoing resources. Children of an exiting parent keep their attachments until disposal. An optional target adapter exposes native property access and events to capabilities. The shared renderer supplies reactive bindings, keyed identity, refs, and cleanup. Use mount inside an owned component or mount callback to inherit its store, capabilities, and lifetime, or render with an explicit parent and optional root options to create a standalone scene root. Scene targets must be dedicated to their renderer's children. Scene subtrees do not support text nodes or hydration; their DOM boundaries defer graphics creation until browser mount. Server rendering validates and omits capability attributes without starting animations.
package/README.mdx CHANGED
@@ -23,6 +23,11 @@ import MotionPanel from "./exhibits/motion.tsx" with { type: "code" };
23
23
  import MotionMain from "./exhibits/motion-main.tsx" with { type: "code" };
24
24
  import MotionExit from "./exhibits/motion-exit.tsx" with { type: "code" };
25
25
  import MotionThree from "./exhibits/motion-three.tsx" with { type: "code" };
26
+ import InstallFloating from "./exhibits/install-floating.sh" with {
27
+ type: "code",
28
+ };
29
+ import FloatingMain from "./exhibits/floating-main.tsx" with { type: "code" };
30
+ import FloatingExample from "./exhibits/floating.tsx" with { type: "code" };
26
31
 
27
32
  <p align="center">
28
33
  <img src="https://raw.githubusercontent.com/jeremybanka/atom.io/main/apps/atom.io.fyi/public/spa/icon-512.png" alt="SPA logo" width="160" height="160" />
@@ -48,6 +53,8 @@ For manual setup, see the [Astro](https://atom.io.fyi/docs/spa/astro) and [Vite]
48
53
 
49
54
  Name the getter and setter after the atom: pointAtom uses getPoint and setPoint. The getPoint getter returns the current object. Each JSX attribute reads its coordinate when evaluated. Both bindings depend on the point atom, and unchanged primitive results skip DOM writes. Reads during setup are snapshots; reads in event handlers are current and untracked. Shared derived state belongs in atom.io selectors.
50
55
 
56
+ Component children follow the same getter contract as named props. A component declaring string children reads a string for both literal text and expression children, including an explicit children attribute. Read props.children inside compiled JSX or a tracked binding for reactive updates; setup reads capture a snapshot. Deliberately function-valued children remain functions, including render callbacks.
57
+
51
58
  ## Astro
52
59
 
53
60
  Register the Astro integration, which compiles .tsx and .jsx components by default:
@@ -263,6 +270,35 @@ Exit props and transition settings are read at logical removal; later state chan
263
270
 
264
271
  Root disposal and fatal errors bypass exits, stop active work, and release resources immediately. Stale animation completions cannot dispose a revived instance. This API covers exit retention and cancellation; layout/pop-layout animation, variants, presence wrappers, and automatic reparenting remain outside its scope.
265
272
 
273
+ ### Floating overlays with Motion
274
+
275
+ The optional @atom.io/spa/floating entrypoint adapts @floating-ui/dom. Install Floating UI and Motion for this example, then register both capabilities on the root:
276
+
277
+ <InstallFloating />
278
+
279
+ <FloatingMain />
280
+
281
+ Floating positions an HTML overlay using CSS translate. Motion can animate x, y, scale, rotation, and opacity on that same element through its separate transform property:
282
+
283
+ <FloatingExample />
284
+
285
+ | Attribute | Behavior |
286
+ | ------------------- | --------------------------------------------------------------------------------------------------- |
287
+ | floating:reference | A DOM or virtual reference; null releases positioning. |
288
+ | floating:placement | Floating UI placement, defaulting to bottom. |
289
+ | floating:strategy | absolute or fixed, defaulting to absolute. |
290
+ | floating:middleware | Standard Floating UI middleware such as offset, flip, and shift. |
291
+ | floating:enabled | Defaults to true; set false when a mounted overlay is closed. |
292
+ | floating:autoUpdate | Defaults to true; accepts observer options, or false for positioning only on SPA attribute updates. |
293
+
294
+ The capability waits for mount and ref publication before measuring, hides the overlay until its first position is available, and reconnects observers when its reference or observer options change. Updates from obsolete calculations are ignored. Server rendering omits floating attributes and starts no observers. Virtual references can supply getBoundingClientRect and an optional contextElement, as documented by Floating UI.
295
+
296
+ Give the overlay a fixed width or width: max-content and avoid margins so measurement remains stable. Floating owns position, left, top, and translate while enabled, and temporarily owns visibility until the first measurement. Do not animate translate through Motion or assign those positioning properties through another style writer on the same element. Floating restores original inline values and priorities when disabled, removed, or disposed. Keyboard behavior, focus management, dismissal, and top-layer mounting remain application responsibilities.
297
+
298
+ Reactive inline style changes preserve the current anchor position and Motion values while new measurements are pending. Temporary hiding uses !important until the first position is available, then restores the original inline visibility value and priority.
299
+
300
+ Position updates continue during Motion's retained exits, until physical disposal. If the reference itself moves through transforms, enable animationFrame in floating:autoUpdate. Run the package's example:floating script for a scrollable experiment with same-element scaling and rotation, moving anchors, viewport collisions, positioning strategies, and interrupted exits. Its test:browser:floating script checks actual Chromium geometry in both capability registration orders.
301
+
266
302
  ### Renderer extensions
267
303
 
268
304
  The renderer entrypoint exposes createSceneRenderer, sceneComponent, bindScene, and onSceneFrame for imperative scene adapters. A host supplies creation, property updates, ordered child attachment, and destruction. Its children callback receives the parent, all owned children including retained exits, and the active children in that collection. Single resource slots can use active children for replacement while retaining ownership of outgoing resources. Children of an exiting parent keep their attachments until disposal. An optional target adapter exposes native property access and events to capabilities. The shared renderer supplies reactive bindings, keyed identity, refs, and cleanup. Use mount inside an owned component or mount callback to inherit its store, capabilities, and lifetime, or render with an explicit parent and optional root options to create a standalone scene root. Scene targets must be dedicated to their renderer's children. Scene subtrees do not support text nodes or hydration; their DOM boundaries defer graphics creation until browser mount. Server rendering validates and omits capability attributes without starting animations.
@@ -1,4 +1,4 @@
1
- import { t as AstroApplicationContext } from "./astro-shared-DHIpjNIG.js";
1
+ import { t as AstroApplicationContext } from "./astro-shared-B9wvGIkk.js";
2
2
  type Lifetime = {
3
3
  signal: AbortSignal;
4
4
  onCleanup(cleanup: () => void): () => void;
@@ -1,4 +1,4 @@
1
- import { a as Island, i as AstroStorePreparation } from "./astro-shared-DHIpjNIG.js";
1
+ import { a as Island, i as AstroStorePreparation } from "./astro-shared-B9wvGIkk.js";
2
2
  type Props = Record<string, any>;
3
3
  type Slots = Record<string, string>;
4
4
  type Hydrator = (component: Island, props: Props, slots: Slots, metadata: {
@@ -2,7 +2,7 @@ import { browserApplication } from "./astro-application.js";
2
2
  import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
3
3
  import { n as islandStore, t as island } from "./astro-shared-83hxw7-M.js";
4
4
  import { c as onCleanup, m as useGetter } from "./core-DjFJ0aIJ.js";
5
- import { n as render, t as hydrate } from "./dom-B5OxgHkr.js";
5
+ import { n as render, t as hydrate } from "./dom-BrPrxO97.js";
6
6
  import { IMPLICIT, createRegularAtomFamily, disposeFromStore, findInStore, getFromStore, setIntoStore } from "atom.io/internal";
7
7
  // src/astro-client.ts
8
8
  const roots = /* @__PURE__ */ new WeakMap();
@@ -1 +1 @@
1
- {"version":3,"file":"astro-request-DRKvDjsO.js","names":[],"sources":["../src/astro-request.ts"],"sourcesContent":["import type { RootStore } from \"atom.io/internal\"\nimport { IMPLICIT, Store } from \"atom.io/internal\"\n\nimport { applicationContext } from \"./astro-context.ts\"\n\nconst requests = new WeakMap<Request, ReturnType<typeof createRequest>>()\nfunction createRequest() {\n\tconst application = applicationContext()\n\tlet store: RootStore | undefined\n\treturn {\n\t\tapplication,\n\t\tget store(): RootStore {\n\t\t\tapplication.signal.throwIfAborted()\n\t\t\tif (!store) {\n\t\t\t\tstore = new Store(\n\t\t\t\t\t{ name: `spa-request`, lifespan: `ephemeral`, isProduction: true },\n\t\t\t\t\tIMPLICIT.STORE,\n\t\t\t\t) as RootStore\n\t\t\t\tconst selected = store\n\t\t\t\tapplication.onCleanup(() => {\n\t\t\t\t\tconst errors: unknown[] = []\n\t\t\t\t\tfor (const state of selected.atoms.values()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tstate.cleanup?.()\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor (const resource of selected.miscResources.values()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresource[Symbol.dispose]()\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (errors.length)\n\t\t\t\t\t\tthrow new AggregateError(errors, `spa: request cleanup failed`)\n\t\t\t\t})\n\t\t\t}\n\t\t\tsyncDefinitions(store)\n\t\t\treturn store\n\t\t},\n\t}\n}\nexport function requestApplication(\n\trequest: Request,\n): ReturnType<typeof createRequest> {\n\tlet app = requests.get(request)\n\tif (!app) {\n\t\tapp = createRequest()\n\t\trequests.set(request, app)\n\t\tconst dispose = () => {\n\t\t\tapp!.application.dispose()\n\t\t}\n\t\trequest.signal.addEventListener(`abort`, dispose, { once: true })\n\t\tapp.application.onCleanup(() => {\n\t\t\trequest.signal.removeEventListener(`abort`, dispose)\n\t\t})\n\t\tif (request.signal.aborted) dispose()\n\t}\n\treturn app\n}\n/** Install definitions imported after an earlier island started this request. */\nexport function syncDefinitions(store: RootStore): void {\n\tconst source = IMPLICIT.STORE\n\tfor (const field of [\n\t\t`families`,\n\t\t`atoms`,\n\t\t`readonlySelectors`,\n\t\t`writableSelectors`,\n\t\t`transactions`,\n\t\t`timelineFamilies`,\n\t\t`timelines`,\n\t] as const) {\n\t\tfor (const [key, resource] of source[field]) {\n\t\t\tif (!store[field].has(key)) resource.install(store)\n\t\t}\n\t}\n}\n"],"mappings":";;;AAKA,MAAM,2BAAW,IAAI,QAAmD;AACxE,SAAS,gBAAgB;CACxB,MAAM,cAAc,mBAAmB;CACvC,IAAI;CACJ,OAAO;EACN;EACA,IAAI,QAAmB;GACtB,YAAY,OAAO,eAAe;GAClC,IAAI,CAAC,OAAO;IACX,QAAQ,IAAI,MACX;KAAE,MAAM;KAAe,UAAU;KAAa,cAAc;IAAK,GACjE,SAAS,KACV;IACA,MAAM,WAAW;IACjB,YAAY,gBAAgB;KAC3B,MAAM,SAAoB,CAAC;KAC3B,KAAK,MAAM,SAAS,SAAS,MAAM,OAAO,GACzC,IAAI;MACH,MAAM,UAAU;KACjB,SAAS,OAAO;MACf,OAAO,KAAK,KAAK;KAClB;KAED,KAAK,MAAM,YAAY,SAAS,cAAc,OAAO,GACpD,IAAI;MACH,SAAS,OAAO,QAAQ,CAAC;KAC1B,SAAS,OAAO;MACf,OAAO,KAAK,KAAK;KAClB;KAED,IAAI,OAAO,QACV,MAAM,IAAI,eAAe,QAAQ,6BAA6B;IAChE,CAAC;GACF;GACA,gBAAgB,KAAK;GACrB,OAAO;EACR;CACD;AACD;AACA,SAAgB,mBACf,SACmC;CACnC,IAAI,MAAM,SAAS,IAAI,OAAO;CAC9B,IAAI,CAAC,KAAK;EACT,MAAM,cAAc;EACpB,SAAS,IAAI,SAAS,GAAG;EACzB,MAAM,gBAAgB;GACrB,IAAK,YAAY,QAAQ;EAC1B;EACA,QAAQ,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;EAChE,IAAI,YAAY,gBAAgB;GAC/B,QAAQ,OAAO,oBAAoB,SAAS,OAAO;EACpD,CAAC;EACD,IAAI,QAAQ,OAAO,SAAS,QAAQ;CACrC;CACA,OAAO;AACR;;AAEA,SAAgB,gBAAgB,OAAwB;CACvD,MAAM,SAAS,SAAS;CACxB,KAAK,MAAM,SAAS;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;CACD,GACC,KAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QACpC,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,GAAG,GAAG,SAAS,QAAQ,KAAK;AAGrD"}
1
+ {"version":3,"file":"astro-request-DRKvDjsO.js","names":[],"sources":["../src/astro-request.ts"],"sourcesContent":["import type { RootStore } from \"atom.io/internal\"\nimport { IMPLICIT, Store } from \"atom.io/internal\"\n\nimport { applicationContext } from \"./astro-context.ts\"\n\nconst requests = new WeakMap<Request, ReturnType<typeof createRequest>>()\nfunction createRequest() {\n\tconst application = applicationContext()\n\tlet store: RootStore | undefined\n\treturn {\n\t\tapplication,\n\t\tget store(): RootStore {\n\t\t\tapplication.signal.throwIfAborted()\n\t\t\tif (!store) {\n\t\t\t\tstore = new Store(\n\t\t\t\t\t{ name: `spa-request`, lifespan: `ephemeral`, isProduction: true },\n\t\t\t\t\tIMPLICIT.STORE,\n\t\t\t\t) as RootStore\n\t\t\t\tconst selected = store\n\t\t\t\tapplication.onCleanup(() => {\n\t\t\t\t\tconst errors: unknown[] = []\n\t\t\t\t\tfor (const state of selected.atoms.values()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tstate.cleanup?.()\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor (const resource of selected.miscResources.values()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresource[Symbol.dispose]()\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (errors.length)\n\t\t\t\t\t\tthrow new AggregateError(errors, `spa: request cleanup failed`)\n\t\t\t\t})\n\t\t\t}\n\t\t\tsyncDefinitions(store)\n\t\t\treturn store\n\t\t},\n\t}\n}\nexport function requestApplication(\n\trequest: Request,\n): ReturnType<typeof createRequest> {\n\tlet app = requests.get(request)\n\tif (!app) {\n\t\tapp = createRequest()\n\t\trequests.set(request, app)\n\t\tconst dispose = () => {\n\t\t\tapp!.application.dispose()\n\t\t}\n\t\trequest.signal.addEventListener(`abort`, dispose, { once: true })\n\t\tapp.application.onCleanup(() => {\n\t\t\trequest.signal.removeEventListener(`abort`, dispose)\n\t\t})\n\t\tif (request.signal.aborted) dispose()\n\t}\n\treturn app\n}\n/** Install definitions imported after an earlier island started this request. */\nfunction syncDefinitions(store: RootStore): void {\n\tconst source = IMPLICIT.STORE\n\tfor (const field of [\n\t\t`families`,\n\t\t`atoms`,\n\t\t`readonlySelectors`,\n\t\t`writableSelectors`,\n\t\t`transactions`,\n\t\t`timelineFamilies`,\n\t\t`timelines`,\n\t] as const) {\n\t\tfor (const [key, resource] of source[field]) {\n\t\t\tif (!store[field].has(key)) resource.install(store)\n\t\t}\n\t}\n}\n"],"mappings":";;;AAKA,MAAM,2BAAW,IAAI,QAAmD;AACxE,SAAS,gBAAgB;CACxB,MAAM,cAAc,mBAAmB;CACvC,IAAI;CACJ,OAAO;EACN;EACA,IAAI,QAAmB;GACtB,YAAY,OAAO,eAAe;GAClC,IAAI,CAAC,OAAO;IACX,QAAQ,IAAI,MACX;KAAE,MAAM;KAAe,UAAU;KAAa,cAAc;IAAK,GACjE,SAAS,KACV;IACA,MAAM,WAAW;IACjB,YAAY,gBAAgB;KAC3B,MAAM,SAAoB,CAAC;KAC3B,KAAK,MAAM,SAAS,SAAS,MAAM,OAAO,GACzC,IAAI;MACH,MAAM,UAAU;KACjB,SAAS,OAAO;MACf,OAAO,KAAK,KAAK;KAClB;KAED,KAAK,MAAM,YAAY,SAAS,cAAc,OAAO,GACpD,IAAI;MACH,SAAS,OAAO,QAAQ,CAAC;KAC1B,SAAS,OAAO;MACf,OAAO,KAAK,KAAK;KAClB;KAED,IAAI,OAAO,QACV,MAAM,IAAI,eAAe,QAAQ,6BAA6B;IAChE,CAAC;GACF;GACA,gBAAgB,KAAK;GACrB,OAAO;EACR;CACD;AACD;AACA,SAAgB,mBACf,SACmC;CACnC,IAAI,MAAM,SAAS,IAAI,OAAO;CAC9B,IAAI,CAAC,KAAK;EACT,MAAM,cAAc;EACpB,SAAS,IAAI,SAAS,GAAG;EACzB,MAAM,gBAAgB;GACrB,IAAK,YAAY,QAAQ;EAC1B;EACA,QAAQ,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;EAChE,IAAI,YAAY,gBAAgB;GAC/B,QAAQ,OAAO,oBAAoB,SAAS,OAAO;EACpD,CAAC;EACD,IAAI,QAAQ,OAAO,SAAS,QAAQ;CACrC;CACA,OAAO;AACR;;AAEA,SAAS,gBAAgB,OAAwB;CAChD,MAAM,SAAS,SAAS;CACxB,KAAK,MAAM,SAAS;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;CACD,GACC,KAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QACpC,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,GAAG,GAAG,SAAS,QAAQ,KAAK;AAGrD"}
@@ -1,4 +1,4 @@
1
- import { a as Island } from "./astro-shared-DHIpjNIG.js";
1
+ import { a as Island } from "./astro-shared-B9wvGIkk.js";
2
2
  declare const _default: (element: HTMLElement) => (component: Island, props: {
3
3
  [x: string]: any;
4
4
  }, slots: {
@@ -1,7 +1,7 @@
1
1
  import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
2
2
  import { t as requestApplication } from "./astro-request-DRKvDjsO.js";
3
3
  import { n as islandStore, t as island } from "./astro-shared-83hxw7-M.js";
4
- import { t as renderToStringWithReads } from "./server-renderer-DcU55e6s.js";
4
+ import { t as renderToStringWithReads } from "./server-renderer-D-uRg04V.js";
5
5
  // src/astro-server.ts
6
6
  const createRenderer = (awaitState = false) => ({
7
7
  name: `spa`,
@@ -1,4 +1,4 @@
1
- import { o as Component, t as Capability } from "./capabilities-BCtBG-ni.js";
1
+ import { o as Component, t as Capability } from "./capabilities-_zOwNJ-2.js";
2
2
  import { RootStore } from "atom.io/internal";
3
3
  interface AstroApplicationContext {
4
4
  /** Whether the application still represents its initial server snapshot. */
@@ -30,4 +30,4 @@ type Island<P = any> = Component<P> & {
30
30
  prepareStore?: AstroStorePreparation<P>;
31
31
  };
32
32
  export { Island as a, AstroStorePreparation as i, AstroStoreContext as n, AstroStoreFactory as r, AstroApplicationContext as t };
33
- //# sourceMappingURL=astro-shared-DHIpjNIG.d.ts.map
33
+ //# sourceMappingURL=astro-shared-B9wvGIkk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"astro-shared-DHIpjNIG.d.ts","names":[],"sources":["../src/astro-shared.ts"],"mappings":";;UAOiB;;WAEP;WACA,QAAQ;EACjB,UAAU;;EAEV,IAAI,GAAG,cAAc,kBAAkB,IAAI;;UAE3B;;EAEhB,aAAa;;EAEb,SAAS;;EAET,QAAQ;;EAER,UAAU;;KAEC,kBAAkB,IAAI,wBACjC,OAAO,GACP,SAAS,sBACL,YAAY,QAAQ;KACb,sBAAsB,IAAI,wBACrC,OAAO,WACP,OAAO,GACP,SAAS,6BACE;KACA,OAAO,WAAW,UAAU;EACvC;;EAEA,wBAAwB;;EAExB;EACA,cAAc,kBAAkB;EAChC,eAAe,sBAAsB"}
1
+ {"version":3,"file":"astro-shared-B9wvGIkk.d.ts","names":[],"sources":["../src/astro-shared.ts"],"mappings":";;UAOiB;;WAEP;WACA,QAAQ;EACjB,UAAU;;EAEV,IAAI,GAAG,cAAc,kBAAkB,IAAI;;UAE3B;;EAEhB,aAAa;;EAEb,SAAS;;EAET,QAAQ;;EAER,UAAU;;KAEC,kBAAkB,IAAI,wBACjC,OAAO,GACP,SAAS,sBACL,YAAY,QAAQ;KACb,sBAAsB,IAAI,wBACrC,OAAO,WACP,OAAO,GACP,SAAS,6BACE;KACA,OAAO,WAAW,UAAU;EACvC;;EAEA,wBAAwB;;EAExB;EACA,cAAc,kBAAkB;EAChC,eAAe,sBAAsB"}
package/dist/astro.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SpaPluginOptions } from "./vite.js";
2
- import { a as Island, i as AstroStorePreparation, n as AstroStoreContext, r as AstroStoreFactory, t as AstroApplicationContext } from "./astro-shared-DHIpjNIG.js";
2
+ import { a as Island, i as AstroStorePreparation, n as AstroStoreContext, r as AstroStoreFactory, t as AstroApplicationContext } from "./astro-shared-B9wvGIkk.js";
3
3
  import { AstroIntegration } from "astro";
4
4
  export default function integration(options?: SpaPluginOptions): AstroIntegration;
5
5
  export type { AstroApplicationContext, AstroStoreContext, AstroStoreFactory, AstroStorePreparation, Island };
package/dist/astro.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as spa } from "./vite-CSHoxzXU.js";
1
+ import { t as spa } from "./vite-Bmyb6P5w.js";
2
2
  // src/astro.ts
3
3
  function integration(options = {}) {
4
4
  return {
@@ -107,14 +107,16 @@ interface CapabilityTarget {
107
107
  interface CapabilityBinding {
108
108
  exit?(props: Record<string, unknown>): ExitHandle | undefined;
109
109
  resume?(): void;
110
- update(props: Record<string, unknown>): void;
110
+ /** Inline CSS before native style replacement, for restoring capability-owned values. */
111
+ update(props: Record<string, unknown>, previousStyle?: string): void;
111
112
  dispose(): void;
112
113
  }
113
114
  interface Capability {
114
115
  namespace: string;
115
116
  presence?(root: Root): PresenceCoordinator;
116
117
  scheduleFrame?(callback: (time: number) => void): Cleanup;
117
- attach(target: CapabilityTarget): CapabilityBinding;
118
+ /** SPA supplies ownership for integrations that measure after mount or report async errors. */
119
+ attach(target: CapabilityTarget, scope?: Scope): CapabilityBinding;
118
120
  }
119
121
  export { useTimeline as _, Children as a, SpaElement as c, onMount as d, useGetter as f, useStore as g, useSetter as h, Accessor as i, TimelineControls as l, useRef as m, CapabilityBinding as n, Component as o, useId as p, CapabilityTarget as r, RootOptions as s, Capability as t, onCleanup as u, useTransaction as v };
120
- //# sourceMappingURL=capabilities-BCtBG-ni.d.ts.map
122
+ //# sourceMappingURL=capabilities-_zOwNJ-2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities-BCtBG-ni.d.ts","names":[],"sources":["../src/presence.ts","../src/core.ts","../src/capabilities.ts"],"mappings":";;;UAIiB;EAChB,UAAU;EACV;;UAEgB;EAChB,QAAQ;EACR;;UAEgB;EAChB;EACA;EACA,YAAY;;UAEI,mBAAmB,GAAG;EACtC,KAAK,cAAc,OAAO,IAAI;EAC9B,OACC,QAAQ,GACR,cACA,mBACA,eACA,MAAM;EAEP,MAAM,SAAS,MAAM;;UAEL;EAChB,WAAW,GAAG,GACb,QAAQ,QAAQ,MAAM,OACtB,aAAa,QAAQ,GAAG,OAAO,gBAC7B,mBAAmB,GAAG;EACzB,OAAO,OAAO,OAAO,QAAQ;EAC7B,KACC,OAAO,OACP,SAAS,mBACT,YAAY,yBACZ;EAED,OAAO,SAAS;EAChB,MAAM,OAAO,OAAO,SAAS,WAAW;EACxC,OAAO,OAAO,OAAO,MAAM;EAC3B,OAAO,OAAO;EACd,OAAO,OAAO;;KCLH;UAGK,SAAS;MACrB;;KAGO,UAAU,YAAY,OAAO,MAAM;;UAE9B;EAChB,eAAe;EACf,OAAO;;;KAGI,WACT,8EAOS,aACT,SAAS;UACK;EAChB,wBAAwB;EACxB,QAAQ;EACR;EACA,WAAW;;UAEK;EAChB;EACA,SAAS,IAAI;EACb,WAAW,IAAI;EACf,OAAO;EACP,UAAU;EACV,WAAW,IAAI,UAAU;EACzB,UAAU;EACV;;UAEgB,aAAa;EAC7B,YAAY,gBAAgB,OAAO;EACnC,YAAY;EACZ,eAAe,YAAY;EAC3B,QAAQ;EACR;EACA;EACA,QAAQ,IAAI;EACZ,SAAS;EACT,OAAO;EACP,QAAQ;;;iBA+HO,YAAY;iBAGZ,UAAU,SAAS;iBAGnB,QAAQ,KAAK;iBASb;;iBAuDA,UAAU,GAAG,WAC5B,OAAO,cAAc,QAAQ,KAC3B,SAAS,OAAO,IAAI;iBACP,UAAU,GAAG,UAAU,WAAW,WACjD,QAAQ,oBAAoB,GAAG,GAAG,IAClC,KAAK,QAAQ,KACX,SAAS,OAAO,IAAI;iBAcP,UAAU,GACzB,OAAO,cAAc,gBAClB,OAAO,IAAI,OAAO;iBACN,UAAU,GAAG,UAAU,WACtC,QAAQ,oBAAoB,GAAG,SAC/B,KAAK,QAAQ,MACV,OAAO,IAAI,OAAO;iBAQN,eAAe,cAAc,qBAC5C,OAAO,iBAAiB,SAClB,MAAM,WAAW,OAAO,WAAW;iBAK1B,OAAO,UAAU,SAChC,OAAO,iBAAiB,aACrB,SAAS;iBACG,OAAO,UAAU,SAAS,UAAU,WACnD,QAAQ,uBAAuB,UAAU,IACzC,KAAK,QAAQ,MACV,SAAS;UAuBI;EAChB;EACA;EACA;EACA;EACA;EACA;IAAoB,OAAO;IAAS,OAAO;;;iBAE5B,YAAY,UAAU,oBACrC,OAAO,cAAc,KACnB;iBACa,YAAY,UAAU,WAAW,UAAU,oBAC1D,QAAQ,oBAAoB,GAAG,IAC/B,KAAK,QAAQ,KACX;;UC9Wc;EAChB;EACA;EACA,YAAY;EACZ,MAAM;EACN,OAAO,aAAa;EACpB,QAAQ,eAAe,uBAAuB;;UAE9B;EAChB,MAAM,OAAO,0BAA0B;EACvC;EACA,OAAO,OAAO;EACd;;UAEgB;EAChB;EACA,UAAU,MAAM,OAAO;EACvB,eAAe,WAAW,wBAAwB;EAClD,OAAO,QAAQ,mBAAmB"}
1
+ {"version":3,"file":"capabilities-_zOwNJ-2.d.ts","names":[],"sources":["../src/presence.ts","../src/core.ts","../src/capabilities.ts"],"mappings":";;;UAIiB;EAChB,UAAU;EACV;;UAEgB;EAChB,QAAQ;EACR;;UAEgB;EAChB;EACA;EACA,YAAY;;UAEH,mBAAmB,GAAG;EAC/B,KAAK,cAAc,OAAO,IAAI;EAC9B,OACC,QAAQ,GACR,cACA,mBACA,eACA,MAAM;EAEP,MAAM,SAAS,MAAM;;UAEL;EAChB,WAAW,GAAG,GACb,QAAQ,QAAQ,MAAM,OACtB,aAAa,QAAQ,GAAG,OAAO,gBAC7B,mBAAmB,GAAG;EACzB,OAAO,OAAO,OAAO,QAAQ;EAC7B,KACC,OAAO,OACP,SAAS,mBACT,YAAY,yBACZ;EAED,OAAO,SAAS;EAChB,MAAM,OAAO,OAAO,SAAS,WAAW;EACxC,OAAO,OAAO,OAAO,MAAM;EAC3B,OAAO,OAAO;EACd,OAAO,OAAO;;KCLH;UAGK,SAAS;MACrB;;KAGO,UAAU,YAAY,OAAO,MAAM;;UAE9B;EAChB,eAAe;EACf,OAAO;;;KAGI,WACT,8EAOS,aACT,SAAS;UACK;EAChB,wBAAwB;EACxB,QAAQ;EACR;EACA,WAAW;;UAEK;EAChB;EACA,SAAS,IAAI;EACb,WAAW,IAAI;EACf,OAAO;EACP,UAAU;EACV,WAAW,IAAI,UAAU;EACzB,UAAU;EACV;;UAEgB,aAAa;EAC7B,YAAY,gBAAgB,OAAO;EACnC,YAAY;EACZ,eAAe,YAAY;EAC3B,QAAQ;EACR;EACA;EACA,QAAQ,IAAI;EACZ,SAAS;EACT,OAAO;EACP,QAAQ;;;iBA+HO,YAAY;iBAGZ,UAAU,SAAS;iBAGnB,QAAQ,KAAK;iBASb;;iBAuDA,UAAU,GAAG,WAC5B,OAAO,cAAc,QAAQ,KAC3B,SAAS,OAAO,IAAI;iBACP,UAAU,GAAG,UAAU,WAAW,WACjD,QAAQ,oBAAoB,GAAG,GAAG,IAClC,KAAK,QAAQ,KACX,SAAS,OAAO,IAAI;iBAcP,UAAU,GACzB,OAAO,cAAc,gBAClB,OAAO,IAAI,OAAO;iBACN,UAAU,GAAG,UAAU,WACtC,QAAQ,oBAAoB,GAAG,SAC/B,KAAK,QAAQ,MACV,OAAO,IAAI,OAAO;iBAQN,eAAe,cAAc,qBAC5C,OAAO,iBAAiB,SAClB,MAAM,WAAW,OAAO,WAAW;iBAK1B,OAAO,UAAU,SAChC,OAAO,iBAAiB,aACrB,SAAS;iBACG,OAAO,UAAU,SAAS,UAAU,WACnD,QAAQ,uBAAuB,UAAU,IACzC,KAAK,QAAQ,MACV,SAAS;UAuBI;EAChB;EACA;EACA;EACA;EACA;EACA;IAAoB,OAAO;IAAS,OAAO;;;iBAE5B,YAAY,UAAU,oBACrC,OAAO,cAAc,KACnB;iBACa,YAAY,UAAU,WAAW,UAAU,oBAC1D,QAAQ,oBAAoB,GAAG,IAC/B,KAAK,QAAQ,KACX;;UC9Wc;EAChB;EACA;EACA,YAAY;EACZ,MAAM;EACN,OAAO,aAAa;EACpB,QAAQ,eAAe,uBAAuB;;UAE9B;EAChB,MAAM,OAAO,0BAA0B;EACvC;;EAEA,OAAO,OAAO,yBAAyB;EACvC;;UAEgB;EAChB;EACA,UAAU,MAAM,OAAO;EACvB,eAAe,WAAW,wBAAwB;;EAElD,OAAO,QAAQ,kBAAkB,QAAQ,QAAQ"}
@@ -12,7 +12,7 @@ function validateCapabilities(scope, props) {
12
12
  }
13
13
  }
14
14
  /** Separate framework properties from native attributes and own their bindings. */
15
- function capabilityProps(scope, target, read) {
15
+ function capabilityProps(scope, target, read, applyNative) {
16
16
  const bindings = /* @__PURE__ */ new Map();
17
17
  scope._root._presence?.target(scope, target);
18
18
  const cleanup = () => {
@@ -41,14 +41,16 @@ function capabilityProps(scope, target, read) {
41
41
  group[key.slice(namespace.length + 1)] = props[key];
42
42
  groups.set(namespace, group);
43
43
  }
44
+ const previousStyle = applyNative?.(native);
44
45
  for (const [namespace, values] of groups) {
45
46
  let binding = bindings.get(namespace);
46
47
  if (!binding) {
47
- binding = scope._root._capabilities.get(namespace).attach(target);
48
+ binding = scope._root._capabilities.get(namespace).attach(target, scope);
48
49
  bindings.set(namespace, binding);
49
50
  scope._root._presence?.bind(scope, binding, read ?? (() => props), namespace);
50
51
  }
51
- binding.update(values);
52
+ if (previousStyle !== void 0) binding.update(values, previousStyle);
53
+ else binding.update(values);
52
54
  }
53
55
  for (const [namespace, binding] of bindings) if (!groups.has(namespace)) {
54
56
  bindings.delete(namespace);
@@ -60,4 +62,4 @@ function capabilityProps(scope, target, read) {
60
62
  }
61
63
  export { capabilityProps as n, validateCapabilities as r, capabilityNamespace as t };
62
64
 
63
- //# sourceMappingURL=capabilities-BkQ2i0vV.js.map
65
+ //# sourceMappingURL=capabilities-nOIitQ-_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities-nOIitQ-_.js","names":[],"sources":["../src/capabilities.ts"],"sourcesContent":["import type { Cleanup, Root, Scope } from \"./core.ts\"\nimport type { ExitHandle, PresenceCoordinator } from \"./presence.ts\"\n\n/** Native renderers expose property access without importing capability engines. */\nexport interface CapabilityTarget {\n\tkind: string\n\tnode: unknown\n\tsuspend?(): Cleanup\n\tread?(key: string): unknown\n\twrite?(key: string, value: unknown): void\n\tlisten?(event: string, listener: () => void): Cleanup\n}\nexport interface CapabilityBinding {\n\texit?(props: Record<string, unknown>): ExitHandle | undefined\n\tresume?(): void\n\t/** Inline CSS before native style replacement, for restoring capability-owned values. */\n\tupdate(props: Record<string, unknown>, previousStyle?: string): void\n\tdispose(): void\n}\nexport interface Capability {\n\tnamespace: string\n\tpresence?(root: Root): PresenceCoordinator\n\tscheduleFrame?(callback: (time: number) => void): Cleanup\n\t/** SPA supplies ownership for integrations that measure after mount or report async errors. */\n\tattach(target: CapabilityTarget, scope?: Scope): CapabilityBinding\n}\n\nexport function capabilityNamespace(key: string): string | undefined {\n\tconst colon = key.indexOf(`:`)\n\tif (colon < 0) return undefined\n\tconst namespace = key.slice(0, colon)\n\treturn /^(xml|xmlns|xlink)$/.test(namespace) ? undefined : namespace\n}\nexport function validateCapabilities(\n\tscope: Scope,\n\tprops: Record<string, unknown>,\n): void {\n\tfor (const key of Object.keys(props)) {\n\t\tconst namespace = capabilityNamespace(key)\n\t\tif (namespace && !scope._root._capabilities.has(namespace))\n\t\t\tthrow new Error(\n\t\t\t\t`spa: capability \"${namespace}\" is not registered for this root`,\n\t\t\t)\n\t}\n}\n\n/** Separate framework properties from native attributes and own their bindings. */\nexport function capabilityProps(\n\tscope: Scope,\n\ttarget: CapabilityTarget,\n\tread?: () => Record<string, any>,\n\tapplyNative?: (props: Record<string, any>) => string | undefined,\n): (props: Record<string, any>) => Record<string, any> {\n\tconst bindings = new Map<string, CapabilityBinding>()\n\n\tscope._root._presence?.target(scope, target)\n\tconst cleanup: Cleanup = () => {\n\t\tconst errors: unknown[] = []\n\t\tfor (const binding of [...bindings.values()].reverse()) {\n\t\t\ttry {\n\t\t\t\tbinding.dispose()\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error)\n\t\t\t}\n\t\t}\n\t\tbindings.clear()\n\t\tif (errors.length) throw new AggregateError(errors)\n\t}\n\tscope._cleanups.add(cleanup)\n\treturn (props) => {\n\t\tvalidateCapabilities(scope, props)\n\t\tconst native: Record<string, any> = {}\n\t\tconst groups = new Map<string, Record<string, unknown>>()\n\t\tfor (const key of Object.keys(props)) {\n\t\t\tconst namespace = capabilityNamespace(key)\n\t\t\tif (!namespace) {\n\t\t\t\tconst value = props[key]\n\t\t\t\tnative[key] =\n\t\t\t\t\tkey.startsWith(`on`) && typeof value === `function`\n\t\t\t\t\t\t? (scope._root._presence?.event(scope, value) ?? value)\n\t\t\t\t\t\t: value\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst group = groups.get(namespace) ?? {}\n\t\t\tgroup[key.slice(namespace.length + 1)] = props[key]\n\t\t\tgroups.set(namespace, group)\n\t\t}\n\t\tconst previousStyle = applyNative?.(native)\n\t\tfor (const [namespace, values] of groups) {\n\t\t\tlet binding = bindings.get(namespace)\n\t\t\tif (!binding) {\n\t\t\t\tbinding = scope._root._capabilities.get(namespace)!.attach(target, scope)\n\t\t\t\tbindings.set(namespace, binding)\n\t\t\t\tscope._root._presence?.bind(\n\t\t\t\t\tscope,\n\t\t\t\t\tbinding,\n\t\t\t\t\tread ?? (() => props),\n\t\t\t\t\tnamespace,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (previousStyle !== undefined) binding.update(values, previousStyle)\n\t\t\telse binding.update(values)\n\t\t}\n\t\tfor (const [namespace, binding] of bindings)\n\t\t\tif (!groups.has(namespace)) {\n\t\t\t\tbindings.delete(namespace)\n\t\t\t\tscope._root._presence?.unbind(binding)\n\t\t\t\tbinding.dispose()\n\t\t\t}\n\t\treturn native\n\t}\n}\n"],"mappings":";AA2BA,SAAgB,oBAAoB,KAAiC;CACpE,MAAM,QAAQ,IAAI,QAAQ,GAAG;CAC7B,IAAI,QAAQ,GAAG,OAAO,KAAA;CACtB,MAAM,YAAY,IAAI,MAAM,GAAG,KAAK;CACpC,OAAO,sBAAsB,KAAK,SAAS,IAAI,KAAA,IAAY;AAC5D;AACA,SAAgB,qBACf,OACA,OACO;CACP,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EACrC,MAAM,YAAY,oBAAoB,GAAG;EACzC,IAAI,aAAa,CAAC,MAAM,MAAM,cAAc,IAAI,SAAS,GACxD,MAAM,IAAI,MACT,oBAAoB,UAAU,kCAC/B;CACF;AACD;;AAGA,SAAgB,gBACf,OACA,QACA,MACA,aACsD;CACtD,MAAM,2BAAW,IAAI,IAA+B;CAEpD,MAAM,MAAM,WAAW,OAAO,OAAO,MAAM;CAC3C,MAAM,gBAAyB;EAC9B,MAAM,SAAoB,CAAC;EAC3B,KAAK,MAAM,WAAW,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,CAAC,QAAQ,GACpD,IAAI;GACH,QAAQ,QAAQ;EACjB,SAAS,OAAO;GACf,OAAO,KAAK,KAAK;EAClB;EAED,SAAS,MAAM;EACf,IAAI,OAAO,QAAQ,MAAM,IAAI,eAAe,MAAM;CACnD;CACA,MAAM,UAAU,IAAI,OAAO;CAC3B,QAAQ,UAAU;EACjB,qBAAqB,OAAO,KAAK;EACjC,MAAM,SAA8B,CAAC;EACrC,MAAM,yBAAS,IAAI,IAAqC;EACxD,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;GACrC,MAAM,YAAY,oBAAoB,GAAG;GACzC,IAAI,CAAC,WAAW;IACf,MAAM,QAAQ,MAAM;IACpB,OAAO,OACN,IAAI,WAAW,IAAI,KAAK,OAAO,UAAU,aACrC,MAAM,MAAM,WAAW,MAAM,OAAO,KAAK,KAAK,QAC/C;IACJ;GACD;GACA,MAAM,QAAQ,OAAO,IAAI,SAAS,KAAK,CAAC;GACxC,MAAM,IAAI,MAAM,UAAU,SAAS,CAAC,KAAK,MAAM;GAC/C,OAAO,IAAI,WAAW,KAAK;EAC5B;EACA,MAAM,gBAAgB,cAAc,MAAM;EAC1C,KAAK,MAAM,CAAC,WAAW,WAAW,QAAQ;GACzC,IAAI,UAAU,SAAS,IAAI,SAAS;GACpC,IAAI,CAAC,SAAS;IACb,UAAU,MAAM,MAAM,cAAc,IAAI,SAAS,CAAC,CAAE,OAAO,QAAQ,KAAK;IACxE,SAAS,IAAI,WAAW,OAAO;IAC/B,MAAM,MAAM,WAAW,KACtB,OACA,SACA,eAAe,QACf,SACD;GACD;GACA,IAAI,kBAAkB,KAAA,GAAW,QAAQ,OAAO,QAAQ,aAAa;QAChE,QAAQ,OAAO,MAAM;EAC3B;EACA,KAAK,MAAM,CAAC,WAAW,YAAY,UAClC,IAAI,CAAC,OAAO,IAAI,SAAS,GAAG;GAC3B,SAAS,OAAO,SAAS;GACzB,MAAM,MAAM,WAAW,OAAO,OAAO;GACrC,QAAQ,QAAQ;EACjB;EACD,OAAO;CACR;AACD"}
@@ -1 +1 @@
1
- import{IMPLICIT as e,actUponStore as t,clearTimelineInStore as n,findInStore as r,findTimelineInStore as i,getFromStore as a,getTimelineTransactionAtHead as o,setIntoStore as s,subscribeToState as c,subscribeToTimeline as l,timeTravel as u,timeTravelTransactionGroupInStore as d,withdraw as f,withdraw as p}from"atom.io/internal";var m,h,g=0;function _(e,t){let n=m;m=e;try{return t()}finally{m=n}}function v(e){let t=h;h=void 0;try{return e()}finally{h=t}}function y(e){let t={_root:e?._root,_parent:e,_cleanups:new Set,_updates:[],_dead:!1};return e?._cleanups.add(t),t}function b(e,t){try{x(e)}catch(e){throw AggregateError([t,e])}throw t}function x(e){if(e._dead)return;e._dead=!0;let t=[];try{e._root._presence?.forget(e)}catch(e){t.push(e)}for(let n of[...e._cleanups].reverse())try{typeof n==`function`?n():x(n)}catch(e){t.push(e)}if(e._parent?._cleanups.delete(e),e._cleanups.clear(),e._updates.length=0,t.length)throw AggregateError(t)}function S(e){for(let t of e._updates)C(e,t);for(let t of e._cleanups)typeof t!=`function`&&S(t)}function C(e,t){if(!L(e))return;let n=e._root;n._queue.size||queueMicrotask(()=>{try{n.flush()}catch(e){n.error(e)}}),n._queue.add(t)}function w(t={},n=!1){let r=new Map;for(let e of t.capabilities??[]){if(r.has(e.namespace))throw Error(`spa: duplicate capability ${e.namespace}`);r.set(e.namespace,e)}let i={_capabilities:r,_store:t.store??e.STORE,_prefix:t.idPrefix??`w${g++}`,_id:0,...y(),_queue:new Set,_mounts:n?void 0:[]};i._root=i,i.error=t.onError??(e=>{throw e});for(let e of r.values())if(e.presence){if(i._presence)throw Error(`spa: multiple presence coordinators`);i._presence=e.presence(i)}return i.flush=()=>{try{for(;i._queue.size||i._mounts.length;){for(let e of[...i._queue])i._queue.delete(e)&&e();for(let e of i._mounts.splice(0))e()}}catch(e){b(i,e)}},i}function T(){return m._root._store}function E(e){m._cleanups.add(e)}function D(e){let t=m;t._root._mounts?.push(()=>{t._dead||_(t,()=>{v(e)})})}function ee(){let e=m._root;return`${e._prefix}-${e._id++}`}function O(e,t,n){let r=new Map,i=()=>{if(!L(e))return;let a=new Set,o=h;h=t=>{a.add(t),r.has(t)||r.set(t,t(()=>{C(e,i)}))};let s;try{s=_(e,t)}finally{h=o;for(let[e,t]of r)a.has(e)||(t(),r.delete(e))}v(()=>{n(s)})};e._updates.push(i),e._cleanups.add(()=>{e._root._queue.delete(i);for(let e of r.values())e()}),i()}function k(e,t){let n=m._root._store;return e.type.endsWith(`_family`)?r(n,e,t):e}function A(e,t){e=k(e,t);let n=m._root,r=n._store,i=t=>c(r,e,`spa:${g++}`,t);return()=>{let t=a(r,e);return n._onRead?.(t,e),h?.(i),t}}function j(e,t){e=k(e,t);let n=m._root._store;return t=>{s(n,e,t)}}function M(e){return t(m._root._store,e,`spa:${g++}`)}var N=new WeakMap;function P(e,t){e=k(e,t);let n=m._root._store,r=N.get(n)??new Map;N.set(n,r);let i={},o=null;return t=>{t?(o=t,r.set(e.key,i),s(n,e,t)):r.get(e.key)===i&&(r.delete(e.key),a(n,e)===o&&s(n,e,null),o=null)}}function F(e,t){let r=m._root._store,a=e.type===`timeline_family`?i(r,e,t):e,s=e=>l(r,a,`spa:${g++}`,e),c=()=>{let e=f(r,a);return h?.(s),e};return{getCursor:()=>c().at,getLength:()=>c().history.length,undo:()=>{u(r,`undo`,a)},redo:()=>{u(r,`redo`,a)},clear:()=>{n(r,a)},getTransaction:()=>{let e=c(),t={};for(let n of[`undo`,`redo`]){let i=o(e,n);i&&(t[n]=()=>{d(r,n,i)})}return t}}}function I(e){return typeof e==`function`?I(e()):Array.isArray(e)?e.map(I).join(``):e==null||typeof e==`boolean`?``:String(e)}function L(e){for(let t=e;t;t=t._parent)if(t._dead||t._exiting)return!1;return!0}var R=e=>e.children;function z(e,t,n){return{type:e,props:n===void 0?t??{}:H(t??{},{key:n})}}var B=z,V=z;function H(...e){let t=()=>e.map(e=>(typeof e==`function`?e():e)??{});return new Proxy({},{get:(e,n)=>t().reverse().find(e=>Object.hasOwn(e,n))?.[n],ownKeys:()=>[...new Set(t().flatMap(Object.keys))],getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0})})}function U(e){let t=e.indexOf(`:`);if(t<0)return;let n=e.slice(0,t);return/^(xml|xmlns|xlink)$/.test(n)?void 0:n}function W(e,t){for(let n of Object.keys(t)){let t=U(n);if(t&&!e._root._capabilities.has(t))throw Error(`spa: capability "${t}" is not registered for this root`)}}function G(e,t,n){let r=new Map;return e._root._presence?.target(e,t),e._cleanups.add(()=>{let e=[];for(let t of[...r.values()].reverse())try{t.dispose()}catch(t){e.push(t)}if(r.clear(),e.length)throw AggregateError(e)}),i=>{W(e,i);let a={},o=new Map;for(let t of Object.keys(i)){let n=U(t);if(!n){let n=i[t];a[t]=t.startsWith(`on`)&&typeof n==`function`?e._root._presence?.event(e,n)??n:n;continue}let r=o.get(n)??{};r[t.slice(n.length+1)]=i[t],o.set(n,r)}for(let[a,s]of o){let o=r.get(a);o||(o=e._root._capabilities.get(a).attach(t),r.set(a,o),e._root._presence?.bind(e,o,n??(()=>i),a)),o.update(s)}for(let[t,n]of r)o.has(t)||(r.delete(t),e._root._presence?.unbind(n),n.dispose());return a}}var K=`http://www.w3.org/1999/xhtml`,q=`http://www.w3.org/2000/svg`;function J(e){if(e?.node)for(e.report(null,e.node);e.node;){let t=e.node;e.node=t.nextSibling,t.remove()}}function Y(e,t,n,r,i){if(i&&(e.nodeType!==3||e.nodeValue||i.node?.nodeType===3)){let n=i.node;!n||n.nodeType!==e.nodeType||n.nodeName!==e.nodeName||n.namespaceURI!==e.namespaceURI||e.nodeType!==1&&n.nodeValue!==e.nodeValue?(i.report(e,n),t.insertBefore(e,n),i.node=n?.nextSibling??null,n?.remove()):(e=n,i.node=n.nextSibling)}else t.insertBefore(e,i?i.node:n);return r._cleanups.add(()=>{e.remove()}),e}function X(e,t,n,r,i){return Y(t.ownerDocument.createComment(e),t,n,r,i)}function Z(e,t,n,r){if(!/^(key|children|ref)$/.test(t)&&(t!==`innerHTML`||e.localName!==`astro-slot`)){if(/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(t))throw Error(void 0);if(t.startsWith(`on`)){let i=/(?<!Pointer)Capture$/.test(t),a=t.slice(2,i?-7:void 0).toLowerCase().replace(`doubleclick`,`dblclick`);r&&e.removeEventListener(a,r,i),n!=null&&e.addEventListener(a,n,i)}else if(t===`className`&&(t=`class`),t===`htmlFor`&&(t=`for`),e.namespaceURI===K&&t in e&&!/^(style|form|list)$/.test(t)){let r=e;r[t]=n??(typeof r[t]!=`boolean`&&``)}else n==null||n===!1&&!/^(aria-|data-)/.test(t)?e.removeAttribute(t):e.setAttribute(t,n===!0&&!/^(aria-|data-)/.test(t)?``:String(n))}}function Q(e,t,n,r,i,a,o=()=>e){if(typeof e==`function`){X(`{`,t,n,r,a);let e=null,s=new Map,c=r._root._presence?.collection(e=>e._scope,(e,t)=>typeof e._value==typeof t&&e._value?.type===t?.type),l=(e,t,n,r)=>{c?c.remove(e,t,n,r,()=>{}):x(e._scope)},u=a;O(r,()=>o()(),a=>{let o=[a].flat(1/0),d=new Map,f=t.ownerDocument.activeElement;for(let a=0;a<o.length;a++){let f=o[a],p=f,m=p?.props?.key,h=m==null?a:String(m),g=s.get(h);if(g&&(typeof g._value!=typeof f||g._value?.type!==p?.type)&&(l(g,h,f==null||typeof f==`boolean`,[...s.keys()].indexOf(h)),g=void 0),g??=c?.take(h,f),g)g._value=f,r._root._presence?.resume(g._scope),S(g._scope);else{let a=y(r);g={_value:f,_scope:a,_start:X(`[`,t,e??n,a,u),_end:null};let o=g;Q(f,t,e??n,a,i,u,()=>o._value),g._end=X(`]`,t,e??n,a,u)}d.set(h,g)}for(let[e,t]of s)d.has(e)||l(t,e,!0,[...s.keys()].indexOf(e));if(!u){let r=e??n,i=c?.merge([...d.values()])??[...d.values()];for(let e of i.reverse()){if(e._end.nextSibling!==r){let n=t.ownerDocument.createRange();n.setStartBefore(e._start),n.setEndAfter(e._end),t.insertBefore(n.extractContents(),r)}r=e._start}f?.isConnected&&!f.closest(`[inert]`)&&f!==t.ownerDocument.activeElement&&f.focus({preventScroll:!0})}u=void 0,s=d}),e=X(`}`,t,n,r,a);return}if(Array.isArray(e)){for(let o of e)Q(o,t,n,r,i,a);return}if(e==null||typeof e==`boolean`)return;if(typeof e!=`object`){X(`t`,t,n,r,a);let i=Y(t.ownerDocument.createTextNode(String(e)),t,n,r,a);O(r,o,e=>{let t=String(e);i.nodeValue!==t&&(i.nodeValue=t)});return}let s=e,c=H(()=>o().props);if(!s.type||s.type===R){Q(()=>c.children,t,n,r,i,a);return}if(typeof s.type==`function`){let e=y(r);Q(_(e,()=>v(()=>s.type(c))),t,n,e,i,a);return}let l=s.type===`svg`?q:i,u=Y(t.ownerDocument.createElementNS(l,s.type),t,n,r,a);if(s.type===`astro-slot`)a||(u.innerHTML=c.innerHTML??``);else if(l===K&&/^(textarea|title|style|script)$/.test(s.type))O(r,()=>I(s.type===`textarea`?c.value??c.children:c.children),e=>{u.textContent!==e&&(u.textContent=e)});else{let e=a?{node:u.firstChild,report:a.report}:void 0;/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/.test(s.type)&&l===K||Q(()=>c.children,u,null,r,s.type===`foreignObject`?K:l,e),J(e)}let d=G(r,{kind:`dom`,node:u},()=>({...c})),f={};r._cleanups.add(()=>{for(let e in f)e.startsWith(`on`)&&Z(u,e,null,f[e])}),O(r,()=>({...c}),e=>{let t=d(e);for(let e in{...f,...t})Object.is(f[e],t[e])&&typeof t[e]!=`object`||(Z(u,e,t[e],f[e]),f[e]=t[e]);f=t});let p=v(()=>c.ref);p&&r._root._mounts.unshift(()=>{r._dead||(r._cleanups.add(()=>p(null)),p(u))})}function $(e,t,n,r){let i=!1,a=r?{node:t.firstChild,report(e,n){i||(i=!0,console.warn(`spa: hydration mismatch. Repairing server HTML to match the browser view; replaced nodes may lose focus or unsaved input.`,{host:t,expected:e,found:n}))}}:void 0,o=a?.node,s=o?.nodeType===8&&o.nodeValue?.startsWith(`w:`)?o.nodeValue.slice(2):void 0,c=w(n);s!==void 0&&n.idPrefix===void 0&&(c._prefix=s);try{X(`w:${c._prefix}`,t,null,c,a),_(c,()=>{Q(v(e),t,null,c,t.namespaceURI===q?q:K,a)}),X(`/w`,t,null,c,a),J(a),c.flush()}catch(e){b(c,e)}return{dispose:()=>{x(c)},flush:c.flush}}function te(e,t,n={}){return $(e,t,n,!1)}function ne(e,t,n={}){return $(e,t,n,!0)}function re(...e){let t=m._root._store,[n]=e,r=n.type.endsWith(`_family`),i=k(n,e[1]),a=A(i),o=r?2:1,s=e[o],c=e.length>o,l=c,u=s,d;return()=>{let e=a(),n=e instanceof Promise;if(!n){u=e,l=!0;let n=p(t,i);d=c&&`catch`in n&&n.catch.some(t=>e instanceof t)?e:void 0}return l?d?{loading:n,value:s,error:d}:{loading:n,value:u}:`LOADING`}}export{R as Fragment,ne as hydrate,z as jsx,V as jsxDEV,B as jsxs,H as merge,E as onCleanup,D as onMount,te as render,A as useGetter,ee as useId,re as useLoadable,P as useRef,j as useSetter,T as useStore,F as useTimeline,M as useTransaction};
1
+ import{IMPLICIT as e,actUponStore as t,clearTimelineInStore as n,findInStore as r,findTimelineInStore as i,getFromStore as a,getTimelineTransactionAtHead as o,setIntoStore as s,subscribeToState as c,subscribeToTimeline as l,timeTravel as u,timeTravelTransactionGroupInStore as d,withdraw as f,withdraw as p}from"atom.io/internal";var m,h,g=0;function _(e,t){let n=m;m=e;try{return t()}finally{m=n}}function v(e){let t=h;h=void 0;try{return e()}finally{h=t}}function y(e){let t={_root:e?._root,_parent:e,_cleanups:new Set,_updates:[],_dead:!1};return e?._cleanups.add(t),t}function b(e,t){try{x(e)}catch(e){throw AggregateError([t,e])}throw t}function x(e){if(e._dead)return;e._dead=!0;let t=[];try{e._root._presence?.forget(e)}catch(e){t.push(e)}for(let n of[...e._cleanups].reverse())try{typeof n==`function`?n():x(n)}catch(e){t.push(e)}if(e._parent?._cleanups.delete(e),e._cleanups.clear(),e._updates.length=0,t.length)throw AggregateError(t)}function S(e){for(let t of e._updates)C(e,t);for(let t of e._cleanups)typeof t!=`function`&&S(t)}function C(e,t){if(!L(e))return;let n=e._root;n._queue.size||queueMicrotask(()=>{try{n.flush()}catch(e){n.error(e)}}),n._queue.add(t)}function w(t={},n=!1){let r=new Map;for(let e of t.capabilities??[]){if(r.has(e.namespace))throw Error(`spa: duplicate capability ${e.namespace}`);r.set(e.namespace,e)}let i={_capabilities:r,_store:t.store??e.STORE,_prefix:t.idPrefix??`w${g++}`,_id:0,...y(),_queue:new Set,_mounts:n?void 0:[]};i._root=i,i.error=t.onError??(e=>{throw e});for(let e of r.values())if(e.presence){if(i._presence)throw Error(`spa: multiple presence coordinators`);i._presence=e.presence(i)}return i.flush=()=>{try{for(;i._queue.size||i._mounts.length;){for(let e of[...i._queue])i._queue.delete(e)&&e();for(let e of i._mounts.splice(0))e()}}catch(e){b(i,e)}},i}function T(){return m._root._store}function E(e){m._cleanups.add(e)}function D(e){let t=m;t._root._mounts?.push(()=>{t._dead||_(t,()=>{v(e)})})}function ee(){let e=m._root;return`${e._prefix}-${e._id++}`}function O(e,t,n){let r=new Map,i=()=>{if(!L(e))return;let a=new Set,o=h;h=t=>{a.add(t),r.has(t)||r.set(t,t(()=>{C(e,i)}))};let s;try{s=_(e,t)}finally{h=o;for(let[e,t]of r)a.has(e)||(t(),r.delete(e))}v(()=>{n(s)})};e._updates.push(i),e._cleanups.add(()=>{e._root._queue.delete(i);for(let e of r.values())e()}),i()}function k(e,t){let n=m._root._store;return e.type.endsWith(`_family`)?r(n,e,t):e}function A(e,t){e=k(e,t);let n=m._root,r=n._store,i=t=>c(r,e,`spa:${g++}`,t);return()=>{let t=a(r,e);return n._onRead?.(t,e),h?.(i),t}}function j(e,t){e=k(e,t);let n=m._root._store;return t=>{s(n,e,t)}}function M(e){return t(m._root._store,e,`spa:${g++}`)}var N=new WeakMap;function P(e,t){e=k(e,t);let n=m._root._store,r=N.get(n)??new Map;N.set(n,r);let i={},o=null;return t=>{t?(o=t,r.set(e.key,i),s(n,e,t)):r.get(e.key)===i&&(r.delete(e.key),a(n,e)===o&&s(n,e,null),o=null)}}function F(e,t){let r=m._root._store,a=e.type===`timeline_family`?i(r,e,t):e,s=e=>l(r,a,`spa:${g++}`,e),c=()=>{let e=f(r,a);return h?.(s),e};return{getCursor:()=>c().at,getLength:()=>c().history.length,undo:()=>{u(r,`undo`,a)},redo:()=>{u(r,`redo`,a)},clear:()=>{n(r,a)},getTransaction:()=>{let e=c(),t={};for(let n of[`undo`,`redo`]){let i=o(e,n);i&&(t[n]=()=>{d(r,n,i)})}return t}}}function I(e){return typeof e==`function`?I(e()):Array.isArray(e)?e.map(I).join(``):e==null||typeof e==`boolean`?``:String(e)}function L(e){for(let t=e;t;t=t._parent)if(t._dead||t._exiting)return!1;return!0}var R=e=>e.children;function z(e,t,n){return{type:e,props:n===void 0?t??{}:H(t??{},{key:n})}}var B=z,V=z;function H(...e){let t=()=>e.map(e=>(typeof e==`function`?e():e)??{});return new Proxy({},{get:(e,n)=>t().reverse().find(e=>Object.hasOwn(e,n))?.[n],ownKeys:()=>[...new Set(t().flatMap(Object.keys))],getOwnPropertyDescriptor:(e,n)=>t().some(e=>Object.hasOwn(e,n))?{enumerable:!0,configurable:!0}:void 0})}function U(e){let t=e.indexOf(`:`);if(t<0)return;let n=e.slice(0,t);return/^(xml|xmlns|xlink)$/.test(n)?void 0:n}function W(e,t){for(let n of Object.keys(t)){let t=U(n);if(t&&!e._root._capabilities.has(t))throw Error(`spa: capability "${t}" is not registered for this root`)}}function G(e,t,n,r){let i=new Map;return e._root._presence?.target(e,t),e._cleanups.add(()=>{let e=[];for(let t of[...i.values()].reverse())try{t.dispose()}catch(t){e.push(t)}if(i.clear(),e.length)throw AggregateError(e)}),a=>{W(e,a);let o={},s=new Map;for(let t of Object.keys(a)){let n=U(t);if(!n){let n=a[t];o[t]=t.startsWith(`on`)&&typeof n==`function`?e._root._presence?.event(e,n)??n:n;continue}let r=s.get(n)??{};r[t.slice(n.length+1)]=a[t],s.set(n,r)}let c=r?.(o);for(let[r,o]of s){let s=i.get(r);s||(s=e._root._capabilities.get(r).attach(t,e),i.set(r,s),e._root._presence?.bind(e,s,n??(()=>a),r)),c===void 0?s.update(o):s.update(o,c)}for(let[t,n]of i)s.has(t)||(i.delete(t),e._root._presence?.unbind(n),n.dispose());return o}}var K=`http://www.w3.org/1999/xhtml`,q=`http://www.w3.org/2000/svg`;function J(e){if(e?.node)for(e.report(null,e.node);e.node;){let t=e.node;e.node=t.nextSibling,t.remove()}}function Y(e,t,n,r,i){if(i&&(e.nodeType!==3||e.nodeValue||i.node?.nodeType===3)){let n=i.node;!n||n.nodeType!==e.nodeType||n.nodeName!==e.nodeName||n.namespaceURI!==e.namespaceURI||e.nodeType!==1&&n.nodeValue!==e.nodeValue?(i.report(e,n),t.insertBefore(e,n),i.node=n?.nextSibling??null,n?.remove()):(e=n,i.node=n.nextSibling)}else t.insertBefore(e,i?i.node:n);return r._cleanups.add(()=>{e.remove()}),e}function X(e,t,n,r,i){return Y(t.ownerDocument.createComment(e),t,n,r,i)}function Z(e,t,n,r){if(!/^(key|children|ref)$/.test(t)&&(t!==`innerHTML`||e.localName!==`astro-slot`)){if(/^(innerHTML|outerHTML|textContent|innerText|dangerouslySetInnerHTML)$/.test(t))throw Error(void 0);if(t.startsWith(`on`)){let i=/(?<!Pointer)Capture$/.test(t),a=t.slice(2,i?-7:void 0).toLowerCase().replace(`doubleclick`,`dblclick`);r&&e.removeEventListener(a,r,i),n!=null&&e.addEventListener(a,n,i)}else if(t===`className`&&(t=`class`),t===`htmlFor`&&(t=`for`),e.namespaceURI===K&&t in e&&!/^(style|form|list)$/.test(t)){let r=e;r[t]=n??(typeof r[t]!=`boolean`&&``)}else n==null||n===!1&&!/^(aria-|data-)/.test(t)?e.removeAttribute(t):e.setAttribute(t,n===!0&&!/^(aria-|data-)/.test(t)?``:String(n))}}function Q(e,t,n,r,i,a,o=()=>e){if(typeof e==`function`){X(`{`,t,n,r,a);let e=null,s=new Map,c=r._root._presence?.collection(e=>e._scope,(e,t)=>typeof e._value==typeof t&&e._value?.type===t?.type),l=(e,t,n,r)=>{c?c.remove(e,t,n,r,()=>{}):x(e._scope)},u=a;O(r,()=>o()(),a=>{let o=[a].flat(1/0),d=new Map,f=t.ownerDocument.activeElement;for(let a=0;a<o.length;a++){let f=o[a],p=f,m=p?.props?.key,h=m==null?a:String(m),g=s.get(h);if(g&&(typeof g._value!=typeof f||g._value?.type!==p?.type)&&(l(g,h,f==null||typeof f==`boolean`,[...s.keys()].indexOf(h)),g=void 0),g??=c?.take(h,f),g)g._value=f,r._root._presence?.resume(g._scope),S(g._scope);else{let a=y(r);g={_value:f,_scope:a,_start:X(`[`,t,e??n,a,u),_end:null};let o=g;Q(f,t,e??n,a,i,u,()=>o._value),g._end=X(`]`,t,e??n,a,u)}d.set(h,g)}for(let[e,t]of s)d.has(e)||l(t,e,!0,[...s.keys()].indexOf(e));if(!u){let r=e??n,i=c?.merge([...d.values()])??[...d.values()];for(let e of i.reverse()){if(e._end.nextSibling!==r){let n=t.ownerDocument.createRange();n.setStartBefore(e._start),n.setEndAfter(e._end),t.insertBefore(n.extractContents(),r)}r=e._start}f?.isConnected&&!f.closest(`[inert]`)&&f!==t.ownerDocument.activeElement&&f.focus({preventScroll:!0})}u=void 0,s=d}),e=X(`}`,t,n,r,a);return}if(Array.isArray(e)){for(let o of e)Q(o,t,n,r,i,a);return}if(e==null||typeof e==`boolean`)return;if(typeof e!=`object`){X(`t`,t,n,r,a);let i=Y(t.ownerDocument.createTextNode(String(e)),t,n,r,a);O(r,o,e=>{let t=String(e);i.nodeValue!==t&&(i.nodeValue=t)});return}let s=e,c=H(()=>o().props);if(!s.type||s.type===R){Q(()=>c.children,t,n,r,i,a);return}if(typeof s.type==`function`){let e=y(r);Q(_(e,()=>v(()=>s.type(c))),t,n,e,i,a);return}let l=s.type===`svg`?q:i,u=Y(t.ownerDocument.createElementNS(l,s.type),t,n,r,a);if(s.type===`astro-slot`)a||(u.innerHTML=c.innerHTML??``);else if(l===K&&/^(textarea|title|style|script)$/.test(s.type))O(r,()=>I(s.type===`textarea`?c.value??c.children:c.children),e=>{u.textContent!==e&&(u.textContent=e)});else{let e=a?{node:u.firstChild,report:a.report}:void 0;/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/.test(s.type)&&l===K||Q(()=>c.children,u,null,r,s.type===`foreignObject`?K:l,e),J(e)}let d={},f=G(r,{kind:`dom`,node:u},()=>({...c}),e=>{let t=d.style===e.style?void 0:u.getAttribute(`style`)??``;for(let t in{...d,...e})Object.is(d[t],e[t])&&typeof e[t]!=`object`||(Z(u,t,e[t],d[t]),d[t]=e[t]);return d=e,t});r._cleanups.add(()=>{for(let e in d)e.startsWith(`on`)&&Z(u,e,null,d[e])}),O(r,()=>({...c}),f);let p=v(()=>c.ref);p&&r._root._mounts.unshift(()=>{r._dead||(r._cleanups.add(()=>p(null)),p(u))})}function $(e,t,n,r){let i=!1,a=r?{node:t.firstChild,report(e,n){i||(i=!0,console.warn(`spa: hydration mismatch. Repairing server HTML to match the browser view; replaced nodes may lose focus or unsaved input.`,{host:t,expected:e,found:n}))}}:void 0,o=a?.node,s=o?.nodeType===8&&o.nodeValue?.startsWith(`w:`)?o.nodeValue.slice(2):void 0,c=w(n);s!==void 0&&n.idPrefix===void 0&&(c._prefix=s);try{X(`w:${c._prefix}`,t,null,c,a),_(c,()=>{Q(v(e),t,null,c,t.namespaceURI===q?q:K,a)}),X(`/w`,t,null,c,a),J(a),c.flush()}catch(e){b(c,e)}return{dispose:()=>{x(c)},flush:c.flush}}function te(e,t,n={}){return $(e,t,n,!1)}function ne(e,t,n={}){return $(e,t,n,!0)}function re(...e){let t=m._root._store,[n]=e,r=n.type.endsWith(`_family`),i=k(n,e[1]),a=A(i),o=r?2:1,s=e[o],c=e.length>o,l=c,u=s,d;return()=>{let e=a(),n=e instanceof Promise;if(!n){u=e,l=!0;let n=p(t,i);d=c&&`catch`in n&&n.catch.some(t=>e instanceof t)?e:void 0}return l?d?{loading:n,value:s,error:d}:{loading:n,value:u}:`LOADING`}}export{R as Fragment,ne as hydrate,z as jsx,V as jsxDEV,B as jsxs,H as merge,E as onCleanup,D as onMount,te as render,A as useGetter,ee as useId,re as useLoadable,P as useRef,j as useSetter,T as useStore,F as useTimeline,M as useTransaction};
@@ -2,7 +2,7 @@ import { browserApplication } from "./astro-application.js";
2
2
  import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
3
3
  import { n as islandStore, t as island } from "./astro-shared-83hxw7-M.js";
4
4
  import { c as onCleanup, m as useGetter } from "./core-DxPiKryn.js";
5
- import { n as render, t as hydrate } from "./dom-BytVV6Rp.js";
5
+ import { n as render, t as hydrate } from "./dom-BWy4dDss.js";
6
6
  import { IMPLICIT, createRegularAtomFamily, disposeFromStore, findInStore, getFromStore, setIntoStore } from "atom.io/internal";
7
7
  // src/astro-client.ts
8
8
  const roots = /* @__PURE__ */ new WeakMap();
@@ -1 +1 @@
1
- {"version":3,"file":"astro-request-DRKvDjsO.js","names":[],"sources":["../../src/astro-request.ts"],"sourcesContent":["import type { RootStore } from \"atom.io/internal\"\nimport { IMPLICIT, Store } from \"atom.io/internal\"\n\nimport { applicationContext } from \"./astro-context.ts\"\n\nconst requests = new WeakMap<Request, ReturnType<typeof createRequest>>()\nfunction createRequest() {\n\tconst application = applicationContext()\n\tlet store: RootStore | undefined\n\treturn {\n\t\tapplication,\n\t\tget store(): RootStore {\n\t\t\tapplication.signal.throwIfAborted()\n\t\t\tif (!store) {\n\t\t\t\tstore = new Store(\n\t\t\t\t\t{ name: `spa-request`, lifespan: `ephemeral`, isProduction: true },\n\t\t\t\t\tIMPLICIT.STORE,\n\t\t\t\t) as RootStore\n\t\t\t\tconst selected = store\n\t\t\t\tapplication.onCleanup(() => {\n\t\t\t\t\tconst errors: unknown[] = []\n\t\t\t\t\tfor (const state of selected.atoms.values()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tstate.cleanup?.()\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor (const resource of selected.miscResources.values()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresource[Symbol.dispose]()\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (errors.length)\n\t\t\t\t\t\tthrow new AggregateError(errors, `spa: request cleanup failed`)\n\t\t\t\t})\n\t\t\t}\n\t\t\tsyncDefinitions(store)\n\t\t\treturn store\n\t\t},\n\t}\n}\nexport function requestApplication(\n\trequest: Request,\n): ReturnType<typeof createRequest> {\n\tlet app = requests.get(request)\n\tif (!app) {\n\t\tapp = createRequest()\n\t\trequests.set(request, app)\n\t\tconst dispose = () => {\n\t\t\tapp!.application.dispose()\n\t\t}\n\t\trequest.signal.addEventListener(`abort`, dispose, { once: true })\n\t\tapp.application.onCleanup(() => {\n\t\t\trequest.signal.removeEventListener(`abort`, dispose)\n\t\t})\n\t\tif (request.signal.aborted) dispose()\n\t}\n\treturn app\n}\n/** Install definitions imported after an earlier island started this request. */\nexport function syncDefinitions(store: RootStore): void {\n\tconst source = IMPLICIT.STORE\n\tfor (const field of [\n\t\t`families`,\n\t\t`atoms`,\n\t\t`readonlySelectors`,\n\t\t`writableSelectors`,\n\t\t`transactions`,\n\t\t`timelineFamilies`,\n\t\t`timelines`,\n\t] as const) {\n\t\tfor (const [key, resource] of source[field]) {\n\t\t\tif (!store[field].has(key)) resource.install(store)\n\t\t}\n\t}\n}\n"],"mappings":";;;AAKA,MAAM,2BAAW,IAAI,QAAmD;AACxE,SAAS,gBAAgB;CACxB,MAAM,cAAc,mBAAmB;CACvC,IAAI;CACJ,OAAO;EACN;EACA,IAAI,QAAmB;GACtB,YAAY,OAAO,eAAe;GAClC,IAAI,CAAC,OAAO;IACX,QAAQ,IAAI,MACX;KAAE,MAAM;KAAe,UAAU;KAAa,cAAc;IAAK,GACjE,SAAS,KACV;IACA,MAAM,WAAW;IACjB,YAAY,gBAAgB;KAC3B,MAAM,SAAoB,CAAC;KAC3B,KAAK,MAAM,SAAS,SAAS,MAAM,OAAO,GACzC,IAAI;MACH,MAAM,UAAU;KACjB,SAAS,OAAO;MACf,OAAO,KAAK,KAAK;KAClB;KAED,KAAK,MAAM,YAAY,SAAS,cAAc,OAAO,GACpD,IAAI;MACH,SAAS,OAAO,QAAQ,CAAC;KAC1B,SAAS,OAAO;MACf,OAAO,KAAK,KAAK;KAClB;KAED,IAAI,OAAO,QACV,MAAM,IAAI,eAAe,QAAQ,6BAA6B;IAChE,CAAC;GACF;GACA,gBAAgB,KAAK;GACrB,OAAO;EACR;CACD;AACD;AACA,SAAgB,mBACf,SACmC;CACnC,IAAI,MAAM,SAAS,IAAI,OAAO;CAC9B,IAAI,CAAC,KAAK;EACT,MAAM,cAAc;EACpB,SAAS,IAAI,SAAS,GAAG;EACzB,MAAM,gBAAgB;GACrB,IAAK,YAAY,QAAQ;EAC1B;EACA,QAAQ,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;EAChE,IAAI,YAAY,gBAAgB;GAC/B,QAAQ,OAAO,oBAAoB,SAAS,OAAO;EACpD,CAAC;EACD,IAAI,QAAQ,OAAO,SAAS,QAAQ;CACrC;CACA,OAAO;AACR;;AAEA,SAAgB,gBAAgB,OAAwB;CACvD,MAAM,SAAS,SAAS;CACxB,KAAK,MAAM,SAAS;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;CACD,GACC,KAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QACpC,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,GAAG,GAAG,SAAS,QAAQ,KAAK;AAGrD"}
1
+ {"version":3,"file":"astro-request-DRKvDjsO.js","names":[],"sources":["../../src/astro-request.ts"],"sourcesContent":["import type { RootStore } from \"atom.io/internal\"\nimport { IMPLICIT, Store } from \"atom.io/internal\"\n\nimport { applicationContext } from \"./astro-context.ts\"\n\nconst requests = new WeakMap<Request, ReturnType<typeof createRequest>>()\nfunction createRequest() {\n\tconst application = applicationContext()\n\tlet store: RootStore | undefined\n\treturn {\n\t\tapplication,\n\t\tget store(): RootStore {\n\t\t\tapplication.signal.throwIfAborted()\n\t\t\tif (!store) {\n\t\t\t\tstore = new Store(\n\t\t\t\t\t{ name: `spa-request`, lifespan: `ephemeral`, isProduction: true },\n\t\t\t\t\tIMPLICIT.STORE,\n\t\t\t\t) as RootStore\n\t\t\t\tconst selected = store\n\t\t\t\tapplication.onCleanup(() => {\n\t\t\t\t\tconst errors: unknown[] = []\n\t\t\t\t\tfor (const state of selected.atoms.values()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tstate.cleanup?.()\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfor (const resource of selected.miscResources.values()) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tresource[Symbol.dispose]()\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\terrors.push(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (errors.length)\n\t\t\t\t\t\tthrow new AggregateError(errors, `spa: request cleanup failed`)\n\t\t\t\t})\n\t\t\t}\n\t\t\tsyncDefinitions(store)\n\t\t\treturn store\n\t\t},\n\t}\n}\nexport function requestApplication(\n\trequest: Request,\n): ReturnType<typeof createRequest> {\n\tlet app = requests.get(request)\n\tif (!app) {\n\t\tapp = createRequest()\n\t\trequests.set(request, app)\n\t\tconst dispose = () => {\n\t\t\tapp!.application.dispose()\n\t\t}\n\t\trequest.signal.addEventListener(`abort`, dispose, { once: true })\n\t\tapp.application.onCleanup(() => {\n\t\t\trequest.signal.removeEventListener(`abort`, dispose)\n\t\t})\n\t\tif (request.signal.aborted) dispose()\n\t}\n\treturn app\n}\n/** Install definitions imported after an earlier island started this request. */\nfunction syncDefinitions(store: RootStore): void {\n\tconst source = IMPLICIT.STORE\n\tfor (const field of [\n\t\t`families`,\n\t\t`atoms`,\n\t\t`readonlySelectors`,\n\t\t`writableSelectors`,\n\t\t`transactions`,\n\t\t`timelineFamilies`,\n\t\t`timelines`,\n\t] as const) {\n\t\tfor (const [key, resource] of source[field]) {\n\t\t\tif (!store[field].has(key)) resource.install(store)\n\t\t}\n\t}\n}\n"],"mappings":";;;AAKA,MAAM,2BAAW,IAAI,QAAmD;AACxE,SAAS,gBAAgB;CACxB,MAAM,cAAc,mBAAmB;CACvC,IAAI;CACJ,OAAO;EACN;EACA,IAAI,QAAmB;GACtB,YAAY,OAAO,eAAe;GAClC,IAAI,CAAC,OAAO;IACX,QAAQ,IAAI,MACX;KAAE,MAAM;KAAe,UAAU;KAAa,cAAc;IAAK,GACjE,SAAS,KACV;IACA,MAAM,WAAW;IACjB,YAAY,gBAAgB;KAC3B,MAAM,SAAoB,CAAC;KAC3B,KAAK,MAAM,SAAS,SAAS,MAAM,OAAO,GACzC,IAAI;MACH,MAAM,UAAU;KACjB,SAAS,OAAO;MACf,OAAO,KAAK,KAAK;KAClB;KAED,KAAK,MAAM,YAAY,SAAS,cAAc,OAAO,GACpD,IAAI;MACH,SAAS,OAAO,QAAQ,CAAC;KAC1B,SAAS,OAAO;MACf,OAAO,KAAK,KAAK;KAClB;KAED,IAAI,OAAO,QACV,MAAM,IAAI,eAAe,QAAQ,6BAA6B;IAChE,CAAC;GACF;GACA,gBAAgB,KAAK;GACrB,OAAO;EACR;CACD;AACD;AACA,SAAgB,mBACf,SACmC;CACnC,IAAI,MAAM,SAAS,IAAI,OAAO;CAC9B,IAAI,CAAC,KAAK;EACT,MAAM,cAAc;EACpB,SAAS,IAAI,SAAS,GAAG;EACzB,MAAM,gBAAgB;GACrB,IAAK,YAAY,QAAQ;EAC1B;EACA,QAAQ,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;EAChE,IAAI,YAAY,gBAAgB;GAC/B,QAAQ,OAAO,oBAAoB,SAAS,OAAO;EACpD,CAAC;EACD,IAAI,QAAQ,OAAO,SAAS,QAAQ;CACrC;CACA,OAAO;AACR;;AAEA,SAAS,gBAAgB,OAAwB;CAChD,MAAM,SAAS,SAAS;CACxB,KAAK,MAAM,SAAS;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;CACD,GACC,KAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QACpC,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,GAAG,GAAG,SAAS,QAAQ,KAAK;AAGrD"}
@@ -1,7 +1,7 @@
1
1
  import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
2
2
  import { t as requestApplication } from "./astro-request-DRKvDjsO.js";
3
3
  import { n as islandStore, t as island } from "./astro-shared-83hxw7-M.js";
4
- import { t as renderToStringWithReads } from "./server-renderer-CUQXh9oF.js";
4
+ import { t as renderToStringWithReads } from "./server-renderer-C7lGVhpo.js";
5
5
  // src/astro-server.ts
6
6
  const createRenderer = (awaitState = false) => ({
7
7
  name: `spa`,
@@ -1,4 +1,4 @@
1
- import { t as spa } from "./vite-CSHoxzXU.js";
1
+ import { t as spa } from "./vite-Bmyb6P5w.js";
2
2
  // src/astro.ts
3
3
  function integration(options = {}) {
4
4
  return {
@@ -12,7 +12,7 @@ function validateCapabilities(scope, props) {
12
12
  }
13
13
  }
14
14
  /** Separate framework properties from native attributes and own their bindings. */
15
- function capabilityProps(scope, target, read) {
15
+ function capabilityProps(scope, target, read, applyNative) {
16
16
  const bindings = /* @__PURE__ */ new Map();
17
17
  scope._root._presence?.target(scope, target);
18
18
  const cleanup = () => {
@@ -41,14 +41,16 @@ function capabilityProps(scope, target, read) {
41
41
  group[key.slice(namespace.length + 1)] = props[key];
42
42
  groups.set(namespace, group);
43
43
  }
44
+ const previousStyle = applyNative?.(native);
44
45
  for (const [namespace, values] of groups) {
45
46
  let binding = bindings.get(namespace);
46
47
  if (!binding) {
47
- binding = scope._root._capabilities.get(namespace).attach(target);
48
+ binding = scope._root._capabilities.get(namespace).attach(target, scope);
48
49
  bindings.set(namespace, binding);
49
50
  scope._root._presence?.bind(scope, binding, read ?? (() => props), namespace);
50
51
  }
51
- binding.update(values);
52
+ if (previousStyle !== void 0) binding.update(values, previousStyle);
53
+ else binding.update(values);
52
54
  }
53
55
  for (const [namespace, binding] of bindings) if (!groups.has(namespace)) {
54
56
  bindings.delete(namespace);
@@ -60,4 +62,4 @@ function capabilityProps(scope, target, read) {
60
62
  }
61
63
  export { capabilityProps as n, validateCapabilities as r, capabilityNamespace as t };
62
64
 
63
- //# sourceMappingURL=capabilities-BkQ2i0vV.js.map
65
+ //# sourceMappingURL=capabilities-nOIitQ-_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities-nOIitQ-_.js","names":[],"sources":["../../src/capabilities.ts"],"sourcesContent":["import type { Cleanup, Root, Scope } from \"./core.ts\"\nimport type { ExitHandle, PresenceCoordinator } from \"./presence.ts\"\n\n/** Native renderers expose property access without importing capability engines. */\nexport interface CapabilityTarget {\n\tkind: string\n\tnode: unknown\n\tsuspend?(): Cleanup\n\tread?(key: string): unknown\n\twrite?(key: string, value: unknown): void\n\tlisten?(event: string, listener: () => void): Cleanup\n}\nexport interface CapabilityBinding {\n\texit?(props: Record<string, unknown>): ExitHandle | undefined\n\tresume?(): void\n\t/** Inline CSS before native style replacement, for restoring capability-owned values. */\n\tupdate(props: Record<string, unknown>, previousStyle?: string): void\n\tdispose(): void\n}\nexport interface Capability {\n\tnamespace: string\n\tpresence?(root: Root): PresenceCoordinator\n\tscheduleFrame?(callback: (time: number) => void): Cleanup\n\t/** SPA supplies ownership for integrations that measure after mount or report async errors. */\n\tattach(target: CapabilityTarget, scope?: Scope): CapabilityBinding\n}\n\nexport function capabilityNamespace(key: string): string | undefined {\n\tconst colon = key.indexOf(`:`)\n\tif (colon < 0) return undefined\n\tconst namespace = key.slice(0, colon)\n\treturn /^(xml|xmlns|xlink)$/.test(namespace) ? undefined : namespace\n}\nexport function validateCapabilities(\n\tscope: Scope,\n\tprops: Record<string, unknown>,\n): void {\n\tfor (const key of Object.keys(props)) {\n\t\tconst namespace = capabilityNamespace(key)\n\t\tif (namespace && !scope._root._capabilities.has(namespace))\n\t\t\tthrow new Error(\n\t\t\t\t`spa: capability \"${namespace}\" is not registered for this root`,\n\t\t\t)\n\t}\n}\n\n/** Separate framework properties from native attributes and own their bindings. */\nexport function capabilityProps(\n\tscope: Scope,\n\ttarget: CapabilityTarget,\n\tread?: () => Record<string, any>,\n\tapplyNative?: (props: Record<string, any>) => string | undefined,\n): (props: Record<string, any>) => Record<string, any> {\n\tconst bindings = new Map<string, CapabilityBinding>()\n\n\tscope._root._presence?.target(scope, target)\n\tconst cleanup: Cleanup = () => {\n\t\tconst errors: unknown[] = []\n\t\tfor (const binding of [...bindings.values()].reverse()) {\n\t\t\ttry {\n\t\t\t\tbinding.dispose()\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error)\n\t\t\t}\n\t\t}\n\t\tbindings.clear()\n\t\tif (errors.length) throw new AggregateError(errors)\n\t}\n\tscope._cleanups.add(cleanup)\n\treturn (props) => {\n\t\tvalidateCapabilities(scope, props)\n\t\tconst native: Record<string, any> = {}\n\t\tconst groups = new Map<string, Record<string, unknown>>()\n\t\tfor (const key of Object.keys(props)) {\n\t\t\tconst namespace = capabilityNamespace(key)\n\t\t\tif (!namespace) {\n\t\t\t\tconst value = props[key]\n\t\t\t\tnative[key] =\n\t\t\t\t\tkey.startsWith(`on`) && typeof value === `function`\n\t\t\t\t\t\t? (scope._root._presence?.event(scope, value) ?? value)\n\t\t\t\t\t\t: value\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst group = groups.get(namespace) ?? {}\n\t\t\tgroup[key.slice(namespace.length + 1)] = props[key]\n\t\t\tgroups.set(namespace, group)\n\t\t}\n\t\tconst previousStyle = applyNative?.(native)\n\t\tfor (const [namespace, values] of groups) {\n\t\t\tlet binding = bindings.get(namespace)\n\t\t\tif (!binding) {\n\t\t\t\tbinding = scope._root._capabilities.get(namespace)!.attach(target, scope)\n\t\t\t\tbindings.set(namespace, binding)\n\t\t\t\tscope._root._presence?.bind(\n\t\t\t\t\tscope,\n\t\t\t\t\tbinding,\n\t\t\t\t\tread ?? (() => props),\n\t\t\t\t\tnamespace,\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (previousStyle !== undefined) binding.update(values, previousStyle)\n\t\t\telse binding.update(values)\n\t\t}\n\t\tfor (const [namespace, binding] of bindings)\n\t\t\tif (!groups.has(namespace)) {\n\t\t\t\tbindings.delete(namespace)\n\t\t\t\tscope._root._presence?.unbind(binding)\n\t\t\t\tbinding.dispose()\n\t\t\t}\n\t\treturn native\n\t}\n}\n"],"mappings":";AA2BA,SAAgB,oBAAoB,KAAiC;CACpE,MAAM,QAAQ,IAAI,QAAQ,GAAG;CAC7B,IAAI,QAAQ,GAAG,OAAO,KAAA;CACtB,MAAM,YAAY,IAAI,MAAM,GAAG,KAAK;CACpC,OAAO,sBAAsB,KAAK,SAAS,IAAI,KAAA,IAAY;AAC5D;AACA,SAAgB,qBACf,OACA,OACO;CACP,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;EACrC,MAAM,YAAY,oBAAoB,GAAG;EACzC,IAAI,aAAa,CAAC,MAAM,MAAM,cAAc,IAAI,SAAS,GACxD,MAAM,IAAI,MACT,oBAAoB,UAAU,kCAC/B;CACF;AACD;;AAGA,SAAgB,gBACf,OACA,QACA,MACA,aACsD;CACtD,MAAM,2BAAW,IAAI,IAA+B;CAEpD,MAAM,MAAM,WAAW,OAAO,OAAO,MAAM;CAC3C,MAAM,gBAAyB;EAC9B,MAAM,SAAoB,CAAC;EAC3B,KAAK,MAAM,WAAW,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,CAAC,QAAQ,GACpD,IAAI;GACH,QAAQ,QAAQ;EACjB,SAAS,OAAO;GACf,OAAO,KAAK,KAAK;EAClB;EAED,SAAS,MAAM;EACf,IAAI,OAAO,QAAQ,MAAM,IAAI,eAAe,MAAM;CACnD;CACA,MAAM,UAAU,IAAI,OAAO;CAC3B,QAAQ,UAAU;EACjB,qBAAqB,OAAO,KAAK;EACjC,MAAM,SAA8B,CAAC;EACrC,MAAM,yBAAS,IAAI,IAAqC;EACxD,KAAK,MAAM,OAAO,OAAO,KAAK,KAAK,GAAG;GACrC,MAAM,YAAY,oBAAoB,GAAG;GACzC,IAAI,CAAC,WAAW;IACf,MAAM,QAAQ,MAAM;IACpB,OAAO,OACN,IAAI,WAAW,IAAI,KAAK,OAAO,UAAU,aACrC,MAAM,MAAM,WAAW,MAAM,OAAO,KAAK,KAAK,QAC/C;IACJ;GACD;GACA,MAAM,QAAQ,OAAO,IAAI,SAAS,KAAK,CAAC;GACxC,MAAM,IAAI,MAAM,UAAU,SAAS,CAAC,KAAK,MAAM;GAC/C,OAAO,IAAI,WAAW,KAAK;EAC5B;EACA,MAAM,gBAAgB,cAAc,MAAM;EAC1C,KAAK,MAAM,CAAC,WAAW,WAAW,QAAQ;GACzC,IAAI,UAAU,SAAS,IAAI,SAAS;GACpC,IAAI,CAAC,SAAS;IACb,UAAU,MAAM,MAAM,cAAc,IAAI,SAAS,CAAC,CAAE,OAAO,QAAQ,KAAK;IACxE,SAAS,IAAI,WAAW,OAAO;IAC/B,MAAM,MAAM,WAAW,KACtB,OACA,SACA,eAAe,QACf,SACD;GACD;GACA,IAAI,kBAAkB,KAAA,GAAW,QAAQ,OAAO,QAAQ,aAAa;QAChE,QAAQ,OAAO,MAAM;EAC3B;EACA,KAAK,MAAM,CAAC,WAAW,YAAY,UAClC,IAAI,CAAC,OAAO,IAAI,SAAS,GAAG;GAC3B,SAAS,OAAO,SAAS;GACzB,MAAM,MAAM,WAAW,OAAO,OAAO;GACrC,QAAQ,QAAQ;EACjB;EACD,OAAO;CACR;AACD"}
@@ -1,4 +1,4 @@
1
- import { n as capabilityProps } from "./capabilities-BkQ2i0vV.js";
1
+ import { n as capabilityProps } from "./capabilities-nOIitQ-_.js";
2
2
  import { a as invalidate, d as plain, i as fail, n as createScope, p as untrack, r as dispose, s as observe, t as createRoot, x as within } from "./core-DxPiKryn.js";
3
3
  import { Fragment, merge } from "./jsx-runtime.js";
4
4
  // src/dom.ts
@@ -165,16 +165,12 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
165
165
  if (!/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/.test(vnode.type) || ns !== HTML) mount(() => props[`children`], element, null, owner, vnode.type === `foreignObject` ? HTML : ns, children);
166
166
  finish(children);
167
167
  }
168
+ let previous = {};
168
169
  const nativeProps = capabilityProps(owner, {
169
170
  kind: `dom`,
170
171
  node: element
171
- }, () => ({ ...props }));
172
- let previous = {};
173
- owner._cleanups.add(() => {
174
- for (const key in previous) if (key.startsWith(`on`)) property(element, key, null, previous[key]);
175
- });
176
- observe(owner, () => ({ ...props }), (all) => {
177
- const next = nativeProps(all);
172
+ }, () => ({ ...props }), (next) => {
173
+ const previousStyle = previous[`style`] !== next[`style`] ? element.getAttribute(`style`) ?? `` : void 0;
178
174
  for (const key in {
179
175
  ...previous,
180
176
  ...next
@@ -183,7 +179,12 @@ function mount(value, parent, before, owner, namespace, cursor, source = () => v
183
179
  previous[key] = next[key];
184
180
  }
185
181
  previous = next;
182
+ return previousStyle;
183
+ });
184
+ owner._cleanups.add(() => {
185
+ for (const key in previous) if (key.startsWith(`on`)) property(element, key, null, previous[key]);
186
186
  });
187
+ observe(owner, () => ({ ...props }), nativeProps);
187
188
  const ref = untrack(() => props[`ref`]);
188
189
  if (ref) owner._root._mounts.unshift(() => {
189
190
  if (!owner._dead) {
@@ -237,4 +238,4 @@ function hydrate(setup, host, options = {}) {
237
238
  }
238
239
  export { render as n, hydrate as t };
239
240
 
240
- //# sourceMappingURL=dom-BytVV6Rp.js.map
241
+ //# sourceMappingURL=dom-BWy4dDss.js.map