@atom.io/spa 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -10
- package/README.mdx +26 -5
- package/dist/astro-application.d.ts +1 -1
- package/dist/astro-application.js +2 -2
- package/dist/astro-application.js.map +1 -1
- package/dist/astro-client.d.ts +1 -1
- package/dist/astro-client.js +2 -2
- package/dist/{astro-shared-DyzbUi6c.d.ts → astro-shared-BkWvVZWZ.d.ts} +2 -2
- package/dist/{astro-shared-DyzbUi6c.d.ts.map → astro-shared-BkWvVZWZ.d.ts.map} +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/capabilities-BkQ2i0vV.js +63 -0
- package/dist/capabilities-BkQ2i0vV.js.map +1 -0
- package/dist/{capabilities-yC9TsHDI.d.ts → capabilities-CFP-HIuY.d.ts} +54 -1
- package/dist/capabilities-CFP-HIuY.d.ts.map +1 -0
- package/dist/client.min.js +1 -1
- package/dist/{capabilities-BuZUQpiD.js → core-DCmqLZQP.js} +16 -59
- package/dist/core-DCmqLZQP.js.map +1 -0
- package/dist/development/astro-application.js +2 -2
- package/dist/development/astro-application.js.map +1 -1
- package/dist/development/astro-client.js +2 -2
- package/dist/development/capabilities-BkQ2i0vV.js +63 -0
- package/dist/development/capabilities-BkQ2i0vV.js.map +1 -0
- package/dist/development/{capabilities-DhOJmeoJ.js → core-p9vciX9C.js} +16 -59
- package/dist/development/core-p9vciX9C.js.map +1 -0
- package/dist/development/{dom-BKc6V_Kz.js → dom-Ci1XvbVJ.js} +16 -7
- package/dist/development/dom-Ci1XvbVJ.js.map +1 -0
- package/dist/development/index.js +3 -3
- package/dist/development/konva.js +25 -3
- package/dist/development/konva.js.map +1 -1
- package/dist/development/motion.js +392 -8
- package/dist/development/motion.js.map +1 -1
- package/dist/development/renderer.js +23 -10
- package/dist/development/renderer.js.map +1 -1
- package/dist/development/server.js +2 -1
- package/dist/development/server.js.map +1 -1
- package/dist/development/{src-Dh-d6w4y.js → src-DG0xjuS5.js} +2 -2
- package/dist/development/{src-Dh-d6w4y.js.map → src-DG0xjuS5.js.map} +1 -1
- package/dist/development/three.js +24 -10
- package/dist/development/three.js.map +1 -1
- package/dist/{dom-B2rm8o2L.js → dom-dHQM0O7Q.js} +16 -7
- package/dist/dom-dHQM0O7Q.js.map +1 -0
- package/dist/{index-BdwxmSKg.d.ts → index-CJJXcKaw.d.ts} +3 -3
- package/dist/{index-BdwxmSKg.d.ts.map → index-CJJXcKaw.d.ts.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{jsx-runtime-CZU7F8Qz.d.ts → jsx-runtime-CREZYKDC.d.ts} +2 -2
- package/dist/{jsx-runtime-CZU7F8Qz.d.ts.map → jsx-runtime-CREZYKDC.d.ts.map} +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/konva.d.ts +3 -3
- package/dist/konva.d.ts.map +1 -1
- package/dist/konva.js +25 -3
- package/dist/konva.js.map +1 -1
- package/dist/motion.d.ts +2 -1
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +392 -8
- package/dist/motion.js.map +1 -1
- package/dist/renderer.d.ts +3 -3
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +23 -10
- package/dist/renderer.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/dist/size.json +12 -12
- package/dist/{src-BZxX4xbU.js → src-DCQa6qxs.js} +2 -2
- package/dist/{src-BZxX4xbU.js.map → src-DCQa6qxs.js.map} +1 -1
- package/dist/three.d.ts +3 -3
- package/dist/three.d.ts.map +1 -1
- package/dist/three.js +24 -10
- package/dist/three.js.map +1 -1
- package/package.json +8 -6
- package/src/astro-application.ts +2 -2
- package/src/capabilities.ts +21 -2
- package/src/core.ts +27 -2
- package/src/dom.ts +35 -4
- package/src/konva.ts +41 -14
- package/src/motion-tween.ts +106 -0
- package/src/motion.ts +122 -9
- package/src/presence.ts +324 -0
- package/src/renderer.ts +51 -14
- package/src/three-events.ts +13 -1
- package/src/three.ts +38 -15
- package/dist/capabilities-BuZUQpiD.js.map +0 -1
- package/dist/capabilities-yC9TsHDI.d.ts.map +0 -1
- package/dist/development/capabilities-DhOJmeoJ.js.map +0 -1
- package/dist/development/dom-BKc6V_Kz.js.map +0 -1
- package/dist/dom-B2rm8o2L.js.map +0 -1
package/README.md
CHANGED
|
@@ -358,7 +358,7 @@ The checked Astro fixture demonstrates default/named slots and custom independen
|
|
|
358
358
|
|
|
359
359
|
The build audits every browser export, including the JSX runtime, from the built JavaScript. Atom.io is an external peer in the incremental measurement. Compiler, server, and integration code have separate entrypoints. The report also includes the complete client plus atom.io, the Astro client entrypoint, and the installed Preact version under the same bundling/minification settings. These are full exported surfaces, not equivalent application benchmarks.
|
|
360
360
|
|
|
361
|
-
The hard budget is under
|
|
361
|
+
The hard budget is under 4,100 bytes of ordinary level-9 gzip for the complete client export surface. Tsdown builds the package JavaScript and declarations, with separate production and development outputs that each share their runtime across entrypoints. The size audit then bundles the built exports with esbuild, minifies with Oxc, and measures compression using Node's gzip and Brotli implementations. The complete client export surface measures approximately 4.0 kB with gzip; dist/size.json records the exact build measurements. Actual application bundles add atom.io and compiler-generated application code.
|
|
362
362
|
|
|
363
363
|
Build output includes the minified audit entrypoint and machine-readable dist/size.json. These audit files are a bundled measurement; use the package exports in applications so the bundler preserves one runtime instance across entrypoints. Source tests exercise development behavior; the production test executes the audited minified artifact. Chromium checks exercise the actual Astro build, island isolation, hydration, keyed identity, focus/selection, SVG namespaces, and teardown. A fresh-cache Astro development check also covers mount hooks, shared state, and ClientRouter navigation.
|
|
364
364
|
|
|
@@ -390,11 +390,11 @@ Sizes are exact minified and level-9 gzip JavaScript byte counts. Declarations,
|
|
|
390
390
|
|
|
391
391
|
| Recipe | Entry | Minified JS | Gzip JS |
|
|
392
392
|
| -------------------------------- | --------------------------------- | ----------: | -------: |
|
|
393
|
-
| Family app with refs and history | `tonnage-recipes/family-app.ts` |
|
|
394
|
-
| Async interactive client app | `tonnage-recipes/async-app.ts` |
|
|
395
|
-
| Interactive client app | `tonnage-recipes/client-app.ts` |
|
|
396
|
-
| Hydrated interactive app | `tonnage-recipes/hydrated-app.ts` |
|
|
397
|
-
| Interactive Astro island | `tonnage-recipes/astro-island.ts` |
|
|
393
|
+
| Family app with refs and history | `tonnage-recipes/family-app.ts` | 63,717 B | 18,894 B |
|
|
394
|
+
| Async interactive client app | `tonnage-recipes/async-app.ts` | 42,121 B | 13,134 B |
|
|
395
|
+
| Interactive client app | `tonnage-recipes/client-app.ts` | 41,783 B | 12,981 B |
|
|
396
|
+
| Hydrated interactive app | `tonnage-recipes/hydrated-app.ts` | 41,784 B | 12,981 B |
|
|
397
|
+
| Interactive Astro island | `tonnage-recipes/astro-island.ts` | 48,152 B | 14,973 B |
|
|
398
398
|
|
|
399
399
|
Report maintained with [tonnage](https://github.com/jeremybanka/tonnage).
|
|
400
400
|
|
|
@@ -509,7 +509,7 @@ render(() => <MotionPanel />, document.getElementById(`app`)!, {
|
|
|
509
509
|
|
|
510
510
|
```
|
|
511
511
|
|
|
512
|
-
Use motion:initial, motion:animate, motion:transition, motion:whileHover, and motion:whileTap directly on native elements or custom tags. These are framework properties, separate from native attributes: they never become HTML attributes. An unregistered namespace or unsupported motion property produces an error. Standard XML, XMLNS, and XLink attribute namespaces retain their normal behavior.
|
|
512
|
+
Use motion:initial, motion:animate, motion:exit, motion:transition, motion:whileHover, and motion:whileTap directly on native elements or custom tags. These are framework properties, separate from native attributes: they never become HTML attributes. An unregistered namespace or unsupported motion property produces an error. Standard XML, XMLNS, and XLink attribute namespaces retain their normal behavior.
|
|
513
513
|
|
|
514
514
|
```tsx
|
|
515
515
|
import type { VNode } from "@atom.io/spa"
|
|
@@ -545,7 +545,7 @@ export function MotionPanel(): VNode {
|
|
|
545
545
|
|
|
546
546
|
```
|
|
547
547
|
|
|
548
|
-
Motion targets update reactively without rerunning component setup. The target stays in atom.io; intermediate values and velocity remain in Motion. Spring transitions preserve motion-value continuity when retargeted. Duration-based tween transitions are also supported. Set initial to false to begin at the first animate target. DOM targets accept scalar CSS values and independent transforms, including custom CSS properties. Keyframe sequences, layout animation,
|
|
548
|
+
Motion targets update reactively without rerunning component setup. The target stays in atom.io; intermediate values and velocity remain in Motion. Spring transitions preserve motion-value continuity when retargeted. Duration-based tween transitions are also supported. Set initial to false to begin at the first animate target. DOM targets accept scalar CSS values and independent transforms, including custom CSS properties. Keyframe sequences, layout animation, and variant propagation are outside this initial API.
|
|
549
549
|
|
|
550
550
|
Motion respects the user's reduced-motion preference by default, including changes while mounted. The capability's reducedMotion option can be user, always, or never. Owner cleanup stops animations and releases effects, gesture handlers, and media-query listeners. Removing the capability properties releases that node's binding. Avoid assigning the same property through both native attributes/styles and motion targets: motion owns the properties it animates.
|
|
551
551
|
|
|
@@ -590,8 +590,61 @@ export function SpringCube(): VNode {
|
|
|
590
590
|
|
|
591
591
|
```
|
|
592
592
|
|
|
593
|
-
When the motion capability is installed, Canvas draws in Motion's render phase after animated scene values update. Without it, Canvas uses requestAnimationFrame. Both drawing subscriptions and animations end with their owners. The base runtime imports no motion engine
|
|
593
|
+
When the motion capability is installed, Canvas draws in Motion's render phase after animated scene values update. Without it, Canvas uses requestAnimationFrame. Both drawing subscriptions and animations end with their owners. The base runtime imports no motion engine or retention coordinator. Presence hooks add approximately 300 bytes of gzip to the released 3.7 kB client surface; the optional Motion entrypoint owns the retention machinery. The full client budget is 4,100 bytes.
|
|
594
|
+
|
|
595
|
+
### Exit animations and re-entry
|
|
596
|
+
|
|
597
|
+
Declare motion:exit on an element, custom tag, Konva node, or Three.js scene node. Conditional or keyed removal starts that target from its current Motion values. No presence wrapper is required. Register motionCapability as above.
|
|
598
|
+
|
|
599
|
+
```tsx
|
|
600
|
+
import type { VNode } from "@atom.io/spa"
|
|
601
|
+
import { useSetter, useValue } from "@atom.io/spa"
|
|
602
|
+
import { atom } from "atom.io"
|
|
603
|
+
|
|
604
|
+
const visibleAtom = atom<boolean>({ key: `visible`, default: true })
|
|
605
|
+
export function DismissiblePanel(): VNode {
|
|
606
|
+
const visible = useValue(visibleAtom)
|
|
607
|
+
const setVisible = useSetter(visibleAtom)
|
|
608
|
+
return (
|
|
609
|
+
<section>
|
|
610
|
+
<button
|
|
611
|
+
onClick={() => {
|
|
612
|
+
setVisible((value) => !value)
|
|
613
|
+
}}
|
|
614
|
+
>
|
|
615
|
+
Toggle panel
|
|
616
|
+
</button>
|
|
617
|
+
{visible() && (
|
|
618
|
+
<sliding-panel
|
|
619
|
+
key="panel"
|
|
620
|
+
motion:initial={{ opacity: 0, y: 12 }}
|
|
621
|
+
motion:animate={{ opacity: 1, y: 0 }}
|
|
622
|
+
motion:exit={{ opacity: 0, y: -12 }}
|
|
623
|
+
motion:transition={{ type: `spring`, stiffness: 180, damping: 22 }}
|
|
624
|
+
>
|
|
625
|
+
The same instance returns if toggled before its exit completes.
|
|
626
|
+
</sliding-panel>
|
|
627
|
+
)}
|
|
628
|
+
</section>
|
|
629
|
+
)
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
In the repository, the runnable source lives in [examples/motion](https://github.com/jeremybanka/atom.io/tree/main/packages/spa/examples/motion), including its standalone Vite entrypoint and visual recorder. Run the package’s example:motion script to start it locally.
|
|
635
|
+
|
|
636
|
+
Try the [motion sandbox](https://atom.io.fyi/spa-motion-lab) to interrupt a 2s tween at adjustable speeds, inspect rendered positions and velocities, scrub the captured sequence, or export PNG and JSON evidence.
|
|
637
|
+
|
|
638
|
+
SPA retains the entire removed subtree until all its exit targets finish, including independently exiting descendants adopted by an exiting ancestor. Native nodes, scene attachments, refs, subscriptions, renderers, geometries, and materials remain owned until final disposal. When keyed Mesh resources are replaced, the incoming geometry and material attach immediately; outgoing resources remain owned through their exits without occupying those attachment slots. Removing a resource without a replacement keeps it attached until its exit finishes. Replacing resources does not render a crossfade between them. Siblings keep their instances; retained ranges keep their previous position. A target without an exit is removed immediately unless another exit retains its enclosing subtree.
|
|
639
|
+
|
|
640
|
+
Returning the same key and component or element type before disposal cancels the exit and resumes the original instance against the latest props and state. Setup, mount callbacks, and refs do not run again. Motion keeps the current animated values and spring velocity. Moving numeric tweens also preserve velocity, including matching CSS units and scene tuple components: the first 20% of the new duration brakes to rest, then the remaining 80% returns smoothly to the latest animate target. Interrupted tweens begin immediately and use this return curve instead of restarting their authored delay or easing. Fresh tweens keep their authored timing, and zero-duration or reduced-motion updates remain immediate. Discrete and nonnumeric styles retain Motion’s native interpolation. Reusing a key with an incompatible type creates a separate instance; the old generation finishes independently. Keys have meaning within their original child collection. Reordering or reparenting into another collection does not transfer ownership.
|
|
641
|
+
|
|
642
|
+
During exit, reactive attributes, child reconciliation, user events, gestures, and user onSceneFrame/onFrame callbacks pause. Renderer frame infrastructure continues drawing animated scenes. DOM nodes become inert, aria-hidden, and unavailable to pointer input; owned focus is blurred and is not automatically restored on return. Konva nodes stop listening and cancel both pending and active drags, including descendant drags when an ancestor exits. Re-entry restores the authored draggable settings; a fresh press is required to start dragging again. Three.js objects leave picking and release active pointer interaction state. Re-entry restores their prior interaction settings and handlers.
|
|
643
|
+
|
|
644
|
+
Exit props and transition settings are read at logical removal; later state changes do not retarget an exiting subtree. Exits use the same transition as animate, defaulting to a spring. Explicit durations, visualDuration, and delays must be finite and nonnegative; velocity must be finite, bounce must be in the range \[0, 1), and stiffness, damping, mass, restDelta, and restSpeed must be finite and positive so exits can settle. Reduced motion skips retention; enabling it during an exit completes that exit. Server rendering omits capability attributes and never starts exits; hydration attaches them for later removals.
|
|
645
|
+
|
|
646
|
+
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.
|
|
594
647
|
|
|
595
648
|
### Renderer extensions
|
|
596
649
|
|
|
597
|
-
The renderer entrypoint exposes createSceneRenderer, sceneComponent, bindScene, and onSceneFrame for imperative scene adapters. A host supplies creation, property updates, ordered child attachment, and destruction. 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.
|
|
650
|
+
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
|
@@ -15,6 +15,7 @@ import KonvaExample from "./exhibits/konva.spa.tsx" with { type: "code" };
|
|
|
15
15
|
import ThreeExample from "./exhibits/three.spa.tsx" with { type: "code" };
|
|
16
16
|
import MotionPanel from "./exhibits/motion.spa.tsx" with { type: "code" };
|
|
17
17
|
import MotionMain from "./exhibits/motion-main.tsx" with { type: "code" };
|
|
18
|
+
import MotionExit from "./exhibits/motion-exit.spa.tsx" with { type: "code" };
|
|
18
19
|
import MotionThree from "./exhibits/motion-three.spa.tsx" with { type: "code" };
|
|
19
20
|
|
|
20
21
|
<p align="center">
|
|
@@ -136,7 +137,7 @@ The checked Astro fixture demonstrates default/named slots and custom independen
|
|
|
136
137
|
|
|
137
138
|
The build audits every browser export, including the JSX runtime, from the built JavaScript. Atom.io is an external peer in the incremental measurement. Compiler, server, and integration code have separate entrypoints. The report also includes the complete client plus atom.io, the Astro client entrypoint, and the installed Preact version under the same bundling/minification settings. These are full exported surfaces, not equivalent application benchmarks.
|
|
138
139
|
|
|
139
|
-
The hard budget is under
|
|
140
|
+
The hard budget is under 4,100 bytes of ordinary level-9 gzip for the complete client export surface. Tsdown builds the package JavaScript and declarations, with separate production and development outputs that each share their runtime across entrypoints. The size audit then bundles the built exports with esbuild, minifies with Oxc, and measures compression using Node's gzip and Brotli implementations. The complete client export surface measures approximately 4.0 kB with gzip; dist/size.json records the exact build measurements. Actual application bundles add atom.io and compiler-generated application code.
|
|
140
141
|
|
|
141
142
|
Build output includes the minified audit entrypoint and machine-readable dist/size.json. These audit files are a bundled measurement; use the package exports in applications so the bundler preserves one runtime instance across entrypoints. Source tests exercise development behavior; the production test executes the audited minified artifact. Chromium checks exercise the actual Astro build, island isolation, hydration, keyed identity, focus/selection, SVG namespaces, and teardown. A fresh-cache Astro development check also covers mount hooks, shared state, and ClientRouter navigation.
|
|
142
143
|
|
|
@@ -192,11 +193,11 @@ Import motionCapability from @atom.io/spa/motion and register it explicitly in r
|
|
|
192
193
|
|
|
193
194
|
<MotionMain />
|
|
194
195
|
|
|
195
|
-
Use motion:initial, motion:animate, motion:transition, motion:whileHover, and motion:whileTap directly on native elements or custom tags. These are framework properties, separate from native attributes: they never become HTML attributes. An unregistered namespace or unsupported motion property produces an error. Standard XML, XMLNS, and XLink attribute namespaces retain their normal behavior.
|
|
196
|
+
Use motion:initial, motion:animate, motion:exit, motion:transition, motion:whileHover, and motion:whileTap directly on native elements or custom tags. These are framework properties, separate from native attributes: they never become HTML attributes. An unregistered namespace or unsupported motion property produces an error. Standard XML, XMLNS, and XLink attribute namespaces retain their normal behavior.
|
|
196
197
|
|
|
197
198
|
<MotionPanel />
|
|
198
199
|
|
|
199
|
-
Motion targets update reactively without rerunning component setup. The target stays in atom.io; intermediate values and velocity remain in Motion. Spring transitions preserve motion-value continuity when retargeted. Duration-based tween transitions are also supported. Set initial to false to begin at the first animate target. DOM targets accept scalar CSS values and independent transforms, including custom CSS properties. Keyframe sequences, layout animation,
|
|
200
|
+
Motion targets update reactively without rerunning component setup. The target stays in atom.io; intermediate values and velocity remain in Motion. Spring transitions preserve motion-value continuity when retargeted. Duration-based tween transitions are also supported. Set initial to false to begin at the first animate target. DOM targets accept scalar CSS values and independent transforms, including custom CSS properties. Keyframe sequences, layout animation, and variant propagation are outside this initial API.
|
|
200
201
|
|
|
201
202
|
Motion respects the user's reduced-motion preference by default, including changes while mounted. The capability's reducedMotion option can be user, always, or never. Owner cleanup stops animations and releases effects, gesture handlers, and media-query listeners. Removing the capability properties releases that node's binding. Avoid assigning the same property through both native attributes/styles and motion targets: motion owns the properties it animates.
|
|
202
203
|
|
|
@@ -204,8 +205,28 @@ The same attributes animate numeric Konva properties and colors, or Three.js pos
|
|
|
204
205
|
|
|
205
206
|
<MotionThree />
|
|
206
207
|
|
|
207
|
-
When the motion capability is installed, Canvas draws in Motion's render phase after animated scene values update. Without it, Canvas uses requestAnimationFrame. Both drawing subscriptions and animations end with their owners. The base runtime imports no motion engine
|
|
208
|
+
When the motion capability is installed, Canvas draws in Motion's render phase after animated scene values update. Without it, Canvas uses requestAnimationFrame. Both drawing subscriptions and animations end with their owners. The base runtime imports no motion engine or retention coordinator. Presence hooks add approximately 300 bytes of gzip to the released 3.7 kB client surface; the optional Motion entrypoint owns the retention machinery. The full client budget is 4,100 bytes.
|
|
209
|
+
|
|
210
|
+
### Exit animations and re-entry
|
|
211
|
+
|
|
212
|
+
Declare motion:exit on an element, custom tag, Konva node, or Three.js scene node. Conditional or keyed removal starts that target from its current Motion values. No presence wrapper is required. Register motionCapability as above.
|
|
213
|
+
|
|
214
|
+
<MotionExit />
|
|
215
|
+
|
|
216
|
+
In the repository, the runnable source lives in [examples/motion](https://github.com/jeremybanka/atom.io/tree/main/packages/spa/examples/motion), including its standalone Vite entrypoint and visual recorder. Run the package’s example:motion script to start it locally.
|
|
217
|
+
|
|
218
|
+
Try the [motion sandbox](https://atom.io.fyi/spa-motion-lab) to interrupt a 2s tween at adjustable speeds, inspect rendered positions and velocities, scrub the captured sequence, or export PNG and JSON evidence.
|
|
219
|
+
|
|
220
|
+
SPA retains the entire removed subtree until all its exit targets finish, including independently exiting descendants adopted by an exiting ancestor. Native nodes, scene attachments, refs, subscriptions, renderers, geometries, and materials remain owned until final disposal. When keyed Mesh resources are replaced, the incoming geometry and material attach immediately; outgoing resources remain owned through their exits without occupying those attachment slots. Removing a resource without a replacement keeps it attached until its exit finishes. Replacing resources does not render a crossfade between them. Siblings keep their instances; retained ranges keep their previous position. A target without an exit is removed immediately unless another exit retains its enclosing subtree.
|
|
221
|
+
|
|
222
|
+
Returning the same key and component or element type before disposal cancels the exit and resumes the original instance against the latest props and state. Setup, mount callbacks, and refs do not run again. Motion keeps the current animated values and spring velocity. Moving numeric tweens also preserve velocity, including matching CSS units and scene tuple components: the first 20% of the new duration brakes to rest, then the remaining 80% returns smoothly to the latest animate target. Interrupted tweens begin immediately and use this return curve instead of restarting their authored delay or easing. Fresh tweens keep their authored timing, and zero-duration or reduced-motion updates remain immediate. Discrete and nonnumeric styles retain Motion’s native interpolation. Reusing a key with an incompatible type creates a separate instance; the old generation finishes independently. Keys have meaning within their original child collection. Reordering or reparenting into another collection does not transfer ownership.
|
|
223
|
+
|
|
224
|
+
During exit, reactive attributes, child reconciliation, user events, gestures, and user onSceneFrame/onFrame callbacks pause. Renderer frame infrastructure continues drawing animated scenes. DOM nodes become inert, aria-hidden, and unavailable to pointer input; owned focus is blurred and is not automatically restored on return. Konva nodes stop listening and cancel both pending and active drags, including descendant drags when an ancestor exits. Re-entry restores the authored draggable settings; a fresh press is required to start dragging again. Three.js objects leave picking and release active pointer interaction state. Re-entry restores their prior interaction settings and handlers.
|
|
225
|
+
|
|
226
|
+
Exit props and transition settings are read at logical removal; later state changes do not retarget an exiting subtree. Exits use the same transition as animate, defaulting to a spring. Explicit durations, visualDuration, and delays must be finite and nonnegative; velocity must be finite, bounce must be in the range [0, 1), and stiffness, damping, mass, restDelta, and restSpeed must be finite and positive so exits can settle. Reduced motion skips retention; enabling it during an exit completes that exit. Server rendering omits capability attributes and never starts exits; hydration attaches them for later removals.
|
|
227
|
+
|
|
228
|
+
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.
|
|
208
229
|
|
|
209
230
|
### Renderer extensions
|
|
210
231
|
|
|
211
|
-
The renderer entrypoint exposes createSceneRenderer, sceneComponent, bindScene, and onSceneFrame for imperative scene adapters. A host supplies creation, property updates, ordered child attachment, and destruction. 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.
|
|
232
|
+
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,5 +1,5 @@
|
|
|
1
1
|
import { t as applicationContext } from "./astro-context-OdlexHR4.js";
|
|
2
|
-
import { IMPLICIT, withdraw } from "atom.io/internal";
|
|
2
|
+
import { IMPLICIT, subscribeToStateSubject, withdraw } from "atom.io/internal";
|
|
3
3
|
// src/astro-application.ts
|
|
4
4
|
const applications = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
/** Called by the integration's early page script, before island preparation. */
|
|
@@ -21,7 +21,7 @@ function browserApplication(document) {
|
|
|
21
21
|
if (store.valueMap.has(token.key)) changed();
|
|
22
22
|
subscriptions.get(token.key)?.();
|
|
23
23
|
const state = withdraw(store, token);
|
|
24
|
-
subscriptions.set(token.key, state
|
|
24
|
+
subscriptions.set(token.key, subscribeToStateSubject(state, `spa:bootstrap`, changed));
|
|
25
25
|
};
|
|
26
26
|
for (const state of [
|
|
27
27
|
...store.atoms.values(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro-application.js","names":[],"sources":["../src/astro-application.ts"],"sourcesContent":["import type { ReadableToken } from \"atom.io\"\nimport { IMPLICIT, withdraw } from \"atom.io/internal\"\n\nimport { applicationContext } from \"./astro-context.ts\"\n\nconst applications = new WeakMap<\n\tDocument,\n\tReturnType<typeof applicationContext>\n>()\n\n/** Called by the integration's early page script, before island preparation. */\nexport function browserApplication(\n\tdocument: Document,\n): ReturnType<typeof applicationContext> {\n\tlet application = applications.get(document)\n\tif (application) return application\n\tapplication = applicationContext()\n\tconst app = application\n\tconst store = IMPLICIT.STORE\n\tconst originalDefault = store.runDefault\n\tapplications.set(document, app)\n\tconst changed = () => {\n\t\tapp.canResume = false\n\t}\n\tconst internal = (key: string) => key.startsWith(`🔍 spa islands`)\n\tconst subscriptions = new Map<string, () => void>()\n\tconst watch = (token: ReadableToken<unknown, any, any>) => {\n\t\tif (internal(token.key)) return\n\t\tif (store.valueMap.has(token.key)) changed()\n\t\tsubscriptions.get(token.key)?.()\n\t\tconst state = withdraw(store, token)\n\t\tsubscriptions.set(\n\t\t\ttoken.key,\n\t\t\
|
|
1
|
+
{"version":3,"file":"astro-application.js","names":[],"sources":["../src/astro-application.ts"],"sourcesContent":["import type { ReadableToken } from \"atom.io\"\nimport { IMPLICIT, subscribeToStateSubject, withdraw } from \"atom.io/internal\"\n\nimport { applicationContext } from \"./astro-context.ts\"\n\nconst applications = new WeakMap<\n\tDocument,\n\tReturnType<typeof applicationContext>\n>()\n\n/** Called by the integration's early page script, before island preparation. */\nexport function browserApplication(\n\tdocument: Document,\n): ReturnType<typeof applicationContext> {\n\tlet application = applications.get(document)\n\tif (application) return application\n\tapplication = applicationContext()\n\tconst app = application\n\tconst store = IMPLICIT.STORE\n\tconst originalDefault = store.runDefault\n\tapplications.set(document, app)\n\tconst changed = () => {\n\t\tapp.canResume = false\n\t}\n\tconst internal = (key: string) => key.startsWith(`🔍 spa islands`)\n\tconst subscriptions = new Map<string, () => void>()\n\tconst watch = (token: ReadableToken<unknown, any, any>) => {\n\t\tif (internal(token.key)) return\n\t\tif (store.valueMap.has(token.key)) changed()\n\t\tsubscriptions.get(token.key)?.()\n\t\tconst state = withdraw(store, token)\n\t\tsubscriptions.set(\n\t\t\ttoken.key,\n\t\t\tsubscribeToStateSubject(state, `spa:bootstrap`, changed),\n\t\t)\n\t}\n\tfor (const state of [\n\t\t...store.atoms.values(),\n\t\t...store.readonlySelectors.values(),\n\t\t...store.writableSelectors.values(),\n\t])\n\t\twatch(state)\n\tconst removed = (token: ReadableToken<unknown, any, any>) => {\n\t\tif (!internal(token.key)) {\n\t\t\tchanged()\n\t\t\tsubscriptions.get(token.key)?.()\n\t\t\tsubscriptions.delete(token.key)\n\t\t}\n\t}\n\tconst events = [\n\t\tstore.on.atomCreation.subscribe(`spa:bootstrap`, watch),\n\t\tstore.on.selectorCreation.subscribe(`spa:bootstrap`, watch),\n\t\tstore.on.atomDisposal.subscribe(`spa:bootstrap`, removed),\n\t\tstore.on.selectorDisposal.subscribe(`spa:bootstrap`, removed),\n\t\tstore.on.transactionCommit.subscribe(`spa:bootstrap`, changed),\n\t]\n\tdocument.addEventListener(`astro:before-swap`, changed)\n\tconst pagehide = (event: PageTransitionEvent) => {\n\t\tif (!event.persisted) app.dispose()\n\t}\n\tdocument.defaultView?.addEventListener(`pagehide`, pagehide)\n\tapp.onCleanup(() => {\n\t\tfor (const unsubscribe of subscriptions.values()) unsubscribe()\n\t\tfor (const unsubscribe of events) unsubscribe()\n\t\tdocument.removeEventListener(`astro:before-swap`, changed)\n\t\tdocument.defaultView?.removeEventListener(`pagehide`, pagehide)\n\t\tstore.runDefault = originalDefault\n\t\tapplications.delete(document)\n\t})\n\treturn app\n}\n"],"mappings":";;;AAKA,MAAM,+BAAe,IAAI,QAGvB;;AAGF,SAAgB,mBACf,UACwC;CACxC,IAAI,cAAc,aAAa,IAAI,QAAQ;CAC3C,IAAI,aAAa,OAAO;CACxB,cAAc,mBAAmB;CACjC,MAAM,MAAM;CACZ,MAAM,QAAQ,SAAS;CACvB,MAAM,kBAAkB,MAAM;CAC9B,aAAa,IAAI,UAAU,GAAG;CAC9B,MAAM,gBAAgB;EACrB,IAAI,YAAY;CACjB;CACA,MAAM,YAAY,QAAgB,IAAI,WAAW,gBAAgB;CACjE,MAAM,gCAAgB,IAAI,IAAwB;CAClD,MAAM,SAAS,UAA4C;EAC1D,IAAI,SAAS,MAAM,GAAG,GAAG;EACzB,IAAI,MAAM,SAAS,IAAI,MAAM,GAAG,GAAG,QAAQ;EAC3C,cAAc,IAAI,MAAM,GAAG,CAAC,GAAG;EAC/B,MAAM,QAAQ,SAAS,OAAO,KAAK;EACnC,cAAc,IACb,MAAM,KACN,wBAAwB,OAAO,iBAAiB,OAAO,CACxD;CACD;CACA,KAAK,MAAM,SAAS;EACnB,GAAG,MAAM,MAAM,OAAO;EACtB,GAAG,MAAM,kBAAkB,OAAO;EAClC,GAAG,MAAM,kBAAkB,OAAO;CACnC,GACC,MAAM,KAAK;CACZ,MAAM,WAAW,UAA4C;EAC5D,IAAI,CAAC,SAAS,MAAM,GAAG,GAAG;GACzB,QAAQ;GACR,cAAc,IAAI,MAAM,GAAG,CAAC,GAAG;GAC/B,cAAc,OAAO,MAAM,GAAG;EAC/B;CACD;CACA,MAAM,SAAS;EACd,MAAM,GAAG,aAAa,UAAU,iBAAiB,KAAK;EACtD,MAAM,GAAG,iBAAiB,UAAU,iBAAiB,KAAK;EAC1D,MAAM,GAAG,aAAa,UAAU,iBAAiB,OAAO;EACxD,MAAM,GAAG,iBAAiB,UAAU,iBAAiB,OAAO;EAC5D,MAAM,GAAG,kBAAkB,UAAU,iBAAiB,OAAO;CAC9D;CACA,SAAS,iBAAiB,qBAAqB,OAAO;CACtD,MAAM,YAAY,UAA+B;EAChD,IAAI,CAAC,MAAM,WAAW,IAAI,QAAQ;CACnC;CACA,SAAS,aAAa,iBAAiB,YAAY,QAAQ;CAC3D,IAAI,gBAAgB;EACnB,KAAK,MAAM,eAAe,cAAc,OAAO,GAAG,YAAY;EAC9D,KAAK,MAAM,eAAe,QAAQ,YAAY;EAC9C,SAAS,oBAAoB,qBAAqB,OAAO;EACzD,SAAS,aAAa,oBAAoB,YAAY,QAAQ;EAC9D,MAAM,aAAa;EACnB,aAAa,OAAO,QAAQ;CAC7B,CAAC;CACD,OAAO;AACR"}
|
package/dist/astro-client.d.ts
CHANGED
package/dist/astro-client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
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-BT45auwR.js";
|
|
4
|
-
import {
|
|
5
|
-
import { n as render, t as hydrate } from "./dom-
|
|
4
|
+
import { b as useValue, c as onCleanup } from "./core-DCmqLZQP.js";
|
|
5
|
+
import { n as render, t as hydrate } from "./dom-dHQM0O7Q.js";
|
|
6
6
|
import { IMPLICIT, createRegularAtomFamily, disposeFromStore, findInStore, setIntoStore } from "atom.io/internal";
|
|
7
7
|
// src/astro-client.ts
|
|
8
8
|
const roots = /* @__PURE__ */ new WeakMap();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as Component, t as Capability } from "./capabilities-
|
|
1
|
+
import { o as Component, t as Capability } from "./capabilities-CFP-HIuY.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-
|
|
33
|
+
//# sourceMappingURL=astro-shared-BkWvVZWZ.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro-shared-
|
|
1
|
+
{"version":3,"file":"astro-shared-BkWvVZWZ.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-
|
|
2
|
+
import { a as Island, i as AstroStorePreparation, n as AstroStoreContext, r as AstroStoreFactory, t as AstroApplicationContext } from "./astro-shared-BkWvVZWZ.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 };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/capabilities.ts
|
|
2
|
+
function capabilityNamespace(key) {
|
|
3
|
+
const colon = key.indexOf(`:`);
|
|
4
|
+
if (colon < 0) return void 0;
|
|
5
|
+
const namespace = key.slice(0, colon);
|
|
6
|
+
return /^(xml|xmlns|xlink)$/.test(namespace) ? void 0 : namespace;
|
|
7
|
+
}
|
|
8
|
+
function validateCapabilities(scope, props) {
|
|
9
|
+
for (const key of Object.keys(props)) {
|
|
10
|
+
const namespace = capabilityNamespace(key);
|
|
11
|
+
if (namespace && !scope._root._capabilities.has(namespace)) throw new Error(`spa: capability "${namespace}" is not registered for this root`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Separate framework properties from native attributes and own their bindings. */
|
|
15
|
+
function capabilityProps(scope, target, read) {
|
|
16
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
17
|
+
scope._root._presence?.target(scope, target);
|
|
18
|
+
const cleanup = () => {
|
|
19
|
+
const errors = [];
|
|
20
|
+
for (const binding of [...bindings.values()].reverse()) try {
|
|
21
|
+
binding.dispose();
|
|
22
|
+
} catch (error) {
|
|
23
|
+
errors.push(error);
|
|
24
|
+
}
|
|
25
|
+
bindings.clear();
|
|
26
|
+
if (errors.length) throw new AggregateError(errors);
|
|
27
|
+
};
|
|
28
|
+
scope._cleanups.add(cleanup);
|
|
29
|
+
return (props) => {
|
|
30
|
+
validateCapabilities(scope, props);
|
|
31
|
+
const native = {};
|
|
32
|
+
const groups = /* @__PURE__ */ new Map();
|
|
33
|
+
for (const key of Object.keys(props)) {
|
|
34
|
+
const namespace = capabilityNamespace(key);
|
|
35
|
+
if (!namespace) {
|
|
36
|
+
const value = props[key];
|
|
37
|
+
native[key] = key.startsWith(`on`) && typeof value === `function` ? scope._root._presence?.event(scope, value) ?? value : value;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const group = groups.get(namespace) ?? {};
|
|
41
|
+
group[key.slice(namespace.length + 1)] = props[key];
|
|
42
|
+
groups.set(namespace, group);
|
|
43
|
+
}
|
|
44
|
+
for (const [namespace, values] of groups) {
|
|
45
|
+
let binding = bindings.get(namespace);
|
|
46
|
+
if (!binding) {
|
|
47
|
+
binding = scope._root._capabilities.get(namespace).attach(target);
|
|
48
|
+
bindings.set(namespace, binding);
|
|
49
|
+
scope._root._presence?.bind(scope, binding, read ?? (() => props), namespace);
|
|
50
|
+
}
|
|
51
|
+
binding.update(values);
|
|
52
|
+
}
|
|
53
|
+
for (const [namespace, binding] of bindings) if (!groups.has(namespace)) {
|
|
54
|
+
bindings.delete(namespace);
|
|
55
|
+
scope._root._presence?.unbind(binding);
|
|
56
|
+
binding.dispose();
|
|
57
|
+
}
|
|
58
|
+
return native;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export { capabilityProps as n, validateCapabilities as r, capabilityNamespace as t };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=capabilities-BkQ2i0vV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities-BkQ2i0vV.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\tupdate(props: Record<string, unknown>): void\n\tdispose(): void\n}\nexport interface Capability {\n\tnamespace: string\n\tpresence?(root: Root): PresenceCoordinator\n\tscheduleFrame?(callback: (time: number) => void): Cleanup\n\tattach(target: CapabilityTarget): 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): (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\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)\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\tbinding.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":";AAyBA,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,MACsD;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,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,MAAM;IACjE,SAAS,IAAI,WAAW,OAAO;IAC/B,MAAM,MAAM,WAAW,KACtB,OACA,SACA,eAAe,QACf,SACD;GACD;GACA,QAAQ,OAAO,MAAM;EACtB;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,6 +1,34 @@
|
|
|
1
1
|
import { RootStore } from "atom.io/internal";
|
|
2
2
|
import { ReadableFamilyToken, ReadableToken, RegularAtomFamilyToken, RegularAtomToken, Setter, TimelineFamilyToken, TimelineManageable, TimelineToken, TransactionToken, ViewOf, WritableFamilyToken, WritableToken } from "atom.io";
|
|
3
3
|
import { Canonical } from "atom.io/foundations/canonical";
|
|
4
|
+
interface ExitHandle {
|
|
5
|
+
finished: Promise<void>;
|
|
6
|
+
cancel(): void;
|
|
7
|
+
}
|
|
8
|
+
interface ExitParticipant {
|
|
9
|
+
exit(): ExitHandle | undefined;
|
|
10
|
+
resume(): void;
|
|
11
|
+
}
|
|
12
|
+
interface PresenceTarget {
|
|
13
|
+
kind: string;
|
|
14
|
+
node: unknown;
|
|
15
|
+
suspend?(): Cleanup;
|
|
16
|
+
}
|
|
17
|
+
interface PresenceCollection<T, V> {
|
|
18
|
+
take(key: unknown, value: V): T | undefined;
|
|
19
|
+
remove(record: T, key: unknown, eligible: boolean, index: number, done: Cleanup): void;
|
|
20
|
+
merge(records: T[]): T[];
|
|
21
|
+
}
|
|
22
|
+
interface PresenceCoordinator {
|
|
23
|
+
collection<T, V>(scope: (record: T) => Scope, compatible: (record: T, value: V) => boolean): PresenceCollection<T, V>;
|
|
24
|
+
target(scope: Scope, target: PresenceTarget): void;
|
|
25
|
+
bind(scope: Scope, binding: CapabilityBinding, read: () => Record<string, unknown>, namespace: string): void;
|
|
26
|
+
unbind(binding: CapabilityBinding): void;
|
|
27
|
+
event(scope: Scope, handler: Function): Function;
|
|
28
|
+
remove(scope: Scope, done: Cleanup): boolean;
|
|
29
|
+
resume(scope: Scope): void;
|
|
30
|
+
forget(scope: Scope): void;
|
|
31
|
+
}
|
|
4
32
|
type Cleanup = () => void;
|
|
5
33
|
interface Accessor<T> {
|
|
6
34
|
(): T;
|
|
@@ -17,6 +45,27 @@ interface RootOptions {
|
|
|
17
45
|
idPrefix?: string;
|
|
18
46
|
onError?: (error: unknown) => void;
|
|
19
47
|
}
|
|
48
|
+
interface Scope {
|
|
49
|
+
_exiting?: boolean;
|
|
50
|
+
_exits?: Set<ExitParticipant>;
|
|
51
|
+
_targets?: Set<PresenceTarget>;
|
|
52
|
+
_root: Root;
|
|
53
|
+
_parent?: Scope | undefined;
|
|
54
|
+
_cleanups: Set<Cleanup | Scope>;
|
|
55
|
+
_updates: Cleanup[];
|
|
56
|
+
_dead: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface Root extends Scope {
|
|
59
|
+
_presence?: PresenceCoordinator;
|
|
60
|
+
_capabilities: Map<string, Capability>;
|
|
61
|
+
_store: RootStore;
|
|
62
|
+
_prefix: string;
|
|
63
|
+
_id: number;
|
|
64
|
+
_queue: Set<Cleanup>;
|
|
65
|
+
_mounts: Cleanup[] | undefined;
|
|
66
|
+
flush: Cleanup;
|
|
67
|
+
error: (error: unknown) => void;
|
|
68
|
+
}
|
|
20
69
|
/** Return the atom.io store selected by the current root. */
|
|
21
70
|
declare function useStore(): RootStore;
|
|
22
71
|
declare function onCleanup(cleanup: Cleanup): void;
|
|
@@ -45,18 +94,22 @@ declare function useTimeline<K extends Canonical, M extends TimelineManageable>(
|
|
|
45
94
|
interface CapabilityTarget {
|
|
46
95
|
kind: string;
|
|
47
96
|
node: unknown;
|
|
97
|
+
suspend?(): Cleanup;
|
|
48
98
|
read?(key: string): unknown;
|
|
49
99
|
write?(key: string, value: unknown): void;
|
|
50
100
|
listen?(event: string, listener: () => void): Cleanup;
|
|
51
101
|
}
|
|
52
102
|
interface CapabilityBinding {
|
|
103
|
+
exit?(props: Record<string, unknown>): ExitHandle | undefined;
|
|
104
|
+
resume?(): void;
|
|
53
105
|
update(props: Record<string, unknown>): void;
|
|
54
106
|
dispose(): void;
|
|
55
107
|
}
|
|
56
108
|
interface Capability {
|
|
57
109
|
namespace: string;
|
|
110
|
+
presence?(root: Root): PresenceCoordinator;
|
|
58
111
|
scheduleFrame?(callback: (time: number) => void): Cleanup;
|
|
59
112
|
attach(target: CapabilityTarget): CapabilityBinding;
|
|
60
113
|
}
|
|
61
114
|
export { useTransaction as _, Child as a, TimelineValue as c, onMount as d, useId as f, useTimeline as g, useStore as h, Accessor as i, VNode as l, useSetter as m, CapabilityBinding as n, Component as o, useRef as p, CapabilityTarget as r, RootOptions as s, Capability as t, onCleanup as u, useValue as v };
|
|
62
|
-
//# sourceMappingURL=capabilities-
|
|
115
|
+
//# sourceMappingURL=capabilities-CFP-HIuY.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities-CFP-HIuY.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;UAC9B;EAChB,eAAe;EACf,OAAO;;KAEI,QACT,yEAOS,UACT,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;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,SAAS,GAAG,WAC3B,OAAO,cAAc,QAAQ,KAC3B,SAAS,OAAO,IAAI;iBACP,SAAS,GAAG,UAAU,WAAW,WAChD,QAAQ,oBAAoB,GAAG,GAAG,IAClC,KAAK,QAAQ,KACX,SAAS,OAAO,IAAI;iBAYP,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,kBAAkB;EAClB,kBAAkB;;iBAEH,YAAY,UAAU,oBACrC,OAAO,cAAc,KACnB,SAAS;iBACI,YAAY,UAAU,WAAW,UAAU,oBAC1D,QAAQ,oBAAoB,GAAG,IAC/B,KAAK,QAAQ,KACX,SAAS;;UC1WK;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"}
|
package/dist/client.min.js
CHANGED
|
@@ -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,inspectTimelineInStore as s,setIntoStore as c,subscribeToState as l,subscribeToTimeline as u,timeTravel as d,timeTravelTransactionGroupInStore 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=[];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(e
|
|
1
|
+
import{IMPLICIT as e,actUponStore as t,clearTimelineInStore as n,findInStore as r,findTimelineInStore as i,getFromStore as a,getTimelineTransactionAtHead as o,inspectTimelineInStore as s,setIntoStore as c,subscribeToState as l,subscribeToTimeline as u,timeTravel as d,timeTravelTransactionGroupInStore 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(!R(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 O(){let e=m._root;return`${e._prefix}-${e._id++}`}function k(e,t,n){let r=new Map,i=()=>{if(!R(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 A(e,t){let n=m._root._store;return e.type.endsWith(`_family`)?r(n,e,t):e}function j(e,t){e=A(e,t);let n=m._root._store,r=t=>l(n,e,`spa:${g++}`,t);return()=>{let t=a(n,e);return h?.(r),t}}function M(e,t){e=A(e,t);let n=m._root._store;return t=>{c(n,e,t)}}function N(e){return t(m._root._store,e,`spa:${g++}`)}var P=new WeakMap;function F(e,t){e=A(e,t);let n=m._root._store,r=P.get(n)??new Map;P.set(n,r);let i={},o=null;return t=>{t?(o=t,r.set(e.key,i),c(n,e,t)):r.get(e.key)===i&&(r.delete(e.key),a(n,e)===o&&c(n,e,null),o=null)}}function I(e,t){let r=m._root._store;e.type===`timeline_family`&&(e=i(r,e,t));let a=t=>u(r,e,`spa:${g++}`,t),c={undo:()=>{d(r,`undo`,e)},redo:()=>{d(r,`redo`,e)},clear:()=>{n(r,e)}};return()=>{let t={...s(r,e),...c};h?.(a);for(let n of[`undo`,`redo`]){let i=o(r.timelines.get(e.key),n);i&&(t[`${n}Transaction`]=()=>f(r,n,i))}return t}}function L(e){return typeof e==`function`?L(e()):Array.isArray(e)?e.map(L).join(``):e==null||typeof e==`boolean`?``:String(e)}function R(e){for(let t=e;t;t=t._parent)if(t._dead||t._exiting)return!1;return!0}var z=e=>e.children;function B(e,t,n){return{type:e,props:n===void 0?t??{}:U(t??{},{key:n})}}var V=B,H=B;function U(...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 W(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 G(e,t){for(let n of Object.keys(t)){let t=W(n);if(t&&!e._root._capabilities.has(t))throw Error(`spa: capability "${t}" is not registered for this root`)}}function K(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=>{G(e,i);let a={},o=new Map;for(let t of Object.keys(i)){let n=W(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 q=`http://www.w3.org/1999/xhtml`,J=`http://www.w3.org/2000/svg`;function Y(e,t,n,r,i){if(i&&(e.nodeType!==3||e.nodeValue||i.node?.nodeType===3)){let t=i.node;if(!t||t.nodeType!==e.nodeType||t.nodeName!==e.nodeName||t.namespaceURI!==e.namespaceURI||e.nodeType!==1&&t.nodeValue!==e.nodeValue)throw Error(void 0);e=t,i.node=t.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===q&&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;k(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);k(r,o,e=>{let t=String(e);i.nodeValue!==t&&(i.nodeValue=t)});return}let s=e,c=U(()=>o().props);if(!s.type||s.type===z){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`?J: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===q&&/^(textarea|title|style|script)$/.test(s.type))k(r,()=>L(s.type===`textarea`?c.value??c.children:c.children),e=>{u.textContent!==e&&(u.textContent=e)});else{let e=a?{node:u.firstChild}:void 0;if(/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/.test(s.type)&&l===q||Q(()=>c.children,u,null,r,s.type===`foreignObject`?q:l,e),e?.node)throw Error(void 0)}let d=K(r,{kind:`dom`,node:u},()=>({...c})),f={};r._cleanups.add(()=>{for(let e in f)e.startsWith(`on`)&&Z(u,e,null,f[e])}),k(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=r?{node:t.firstChild}:void 0,a=i?.node?.nodeValue?.slice(2);if(r&&(a===void 0||n.idPrefix!==void 0&&a!==n.idPrefix))throw Error(void 0);let o=w(n);a!==void 0&&(o._prefix=a);try{if(X(`w:${o._prefix}`,t,null,o,i),_(o,()=>{Q(v(e),t,null,o,t.namespaceURI===J?J:q,i)}),X(`/w`,t,null,o,i),i?.node)throw Error(void 0);o.flush()}catch(e){b(o,e)}return{dispose:()=>{x(o)},flush:o.flush}}function ee(e,t,n={}){return $(e,t,n,!1)}function te(e,t,n={}){return $(e,t,n,!0)}function ne(...e){let t=m._root._store,[n]=e,r=n.type.endsWith(`_family`),i=A(n,e[1]),a=j(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{z as Fragment,te as hydrate,B as jsx,H as jsxDEV,V as jsxs,U as merge,E as onCleanup,D as onMount,ee as render,O as useId,ne as useLoadable,F as useRef,M as useSetter,T as useStore,I as useTimeline,N as useTransaction,j as useValue};
|
|
@@ -44,6 +44,11 @@ function dispose(scope) {
|
|
|
44
44
|
if (scope._dead) return;
|
|
45
45
|
scope._dead = true;
|
|
46
46
|
const errors = [];
|
|
47
|
+
try {
|
|
48
|
+
scope._root._presence?.forget(scope);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
errors.push(error);
|
|
51
|
+
}
|
|
47
52
|
for (const cleanup of [...scope._cleanups].reverse()) try {
|
|
48
53
|
typeof cleanup === `function` ? cleanup() : dispose(cleanup);
|
|
49
54
|
} catch (error) {
|
|
@@ -59,7 +64,7 @@ function invalidate(scope) {
|
|
|
59
64
|
for (const child of scope._cleanups) if (typeof child !== `function`) invalidate(child);
|
|
60
65
|
}
|
|
61
66
|
function enqueue(scope, run) {
|
|
62
|
-
if (scope
|
|
67
|
+
if (!isPresent(scope)) return;
|
|
63
68
|
const root = scope._root;
|
|
64
69
|
if (!root._queue.size) queueMicrotask(() => {
|
|
65
70
|
try {
|
|
@@ -89,6 +94,10 @@ function createRoot(options = {}, server = false) {
|
|
|
89
94
|
root.error = options.onError ?? ((error) => {
|
|
90
95
|
throw error;
|
|
91
96
|
});
|
|
97
|
+
for (const capability of capabilities.values()) if (capability.presence) {
|
|
98
|
+
if (root._presence) throw new Error(`spa: multiple presence coordinators`);
|
|
99
|
+
root._presence = capability.presence(root);
|
|
100
|
+
}
|
|
92
101
|
root.flush = () => {
|
|
93
102
|
try {
|
|
94
103
|
while (root._queue.size || root._mounts.length) {
|
|
@@ -123,7 +132,7 @@ function useId() {
|
|
|
123
132
|
function observe(scope, read, apply) {
|
|
124
133
|
const subscriptions = /* @__PURE__ */ new Map();
|
|
125
134
|
const run = () => {
|
|
126
|
-
if (scope
|
|
135
|
+
if (!isPresent(scope)) return;
|
|
127
136
|
const used = /* @__PURE__ */ new Set();
|
|
128
137
|
const previous = tracking;
|
|
129
138
|
tracking = (subscribe) => {
|
|
@@ -232,62 +241,10 @@ function plain(value) {
|
|
|
232
241
|
if (value == null || typeof value === `boolean`) return ``;
|
|
233
242
|
return String(value);
|
|
234
243
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (colon < 0) return void 0;
|
|
239
|
-
const namespace = key.slice(0, colon);
|
|
240
|
-
return /^(xml|xmlns|xlink)$/.test(namespace) ? void 0 : namespace;
|
|
241
|
-
}
|
|
242
|
-
function validateCapabilities(scope, props) {
|
|
243
|
-
for (const key of Object.keys(props)) {
|
|
244
|
-
const namespace = capabilityNamespace(key);
|
|
245
|
-
if (namespace && !scope._root._capabilities.has(namespace)) throw new Error(`spa: capability "${namespace}" is not registered for this root`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/** Separate framework properties from native attributes and own their bindings. */
|
|
249
|
-
function capabilityProps(scope, target) {
|
|
250
|
-
const bindings = /* @__PURE__ */ new Map();
|
|
251
|
-
const cleanup = () => {
|
|
252
|
-
const errors = [];
|
|
253
|
-
for (const binding of [...bindings.values()].reverse()) try {
|
|
254
|
-
binding.dispose();
|
|
255
|
-
} catch (error) {
|
|
256
|
-
errors.push(error);
|
|
257
|
-
}
|
|
258
|
-
bindings.clear();
|
|
259
|
-
if (errors.length) throw new AggregateError(errors);
|
|
260
|
-
};
|
|
261
|
-
scope._cleanups.add(cleanup);
|
|
262
|
-
return (props) => {
|
|
263
|
-
validateCapabilities(scope, props);
|
|
264
|
-
const native = {};
|
|
265
|
-
const groups = /* @__PURE__ */ new Map();
|
|
266
|
-
for (const key of Object.keys(props)) {
|
|
267
|
-
const namespace = capabilityNamespace(key);
|
|
268
|
-
if (!namespace) {
|
|
269
|
-
native[key] = props[key];
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
const group = groups.get(namespace) ?? {};
|
|
273
|
-
group[key.slice(namespace.length + 1)] = props[key];
|
|
274
|
-
groups.set(namespace, group);
|
|
275
|
-
}
|
|
276
|
-
for (const [namespace, values] of groups) {
|
|
277
|
-
let binding = bindings.get(namespace);
|
|
278
|
-
if (!binding) {
|
|
279
|
-
binding = scope._root._capabilities.get(namespace).attach(target);
|
|
280
|
-
bindings.set(namespace, binding);
|
|
281
|
-
}
|
|
282
|
-
binding.update(values);
|
|
283
|
-
}
|
|
284
|
-
for (const [namespace, binding] of bindings) if (!groups.has(namespace)) {
|
|
285
|
-
bindings.delete(namespace);
|
|
286
|
-
binding.dispose();
|
|
287
|
-
}
|
|
288
|
-
return native;
|
|
289
|
-
};
|
|
244
|
+
function isPresent(scope) {
|
|
245
|
+
for (let at = scope; at; at = at._parent) if (at._dead || at._exiting) return false;
|
|
246
|
+
return true;
|
|
290
247
|
}
|
|
291
|
-
export {
|
|
248
|
+
export { useStore as _, invalidate as a, useValue as b, onCleanup as c, plain as d, resolveStateToken as f, useSetter as g, useRef as h, fail as i, onMount as l, useId as m, createScope as n, isPresent as o, untrack as p, dispose as r, observe as s, createRoot as t, owner as u, useTimeline as v, within as x, useTransaction as y };
|
|
292
249
|
|
|
293
|
-
//# sourceMappingURL=
|
|
250
|
+
//# sourceMappingURL=core-DCmqLZQP.js.map
|