@atom.io/spa 0.0.0 → 0.0.2
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 +201 -6
- package/README.mdx +62 -1
- package/dist/astro-application.d.ts +1 -1
- package/dist/astro-client.d.ts +1 -1
- package/dist/astro-client.js +7 -4
- package/dist/astro-client.js.map +1 -1
- package/dist/astro-server.js +4 -3
- package/dist/astro-server.js.map +1 -1
- package/dist/astro-shared-BT45auwR.js.map +1 -1
- package/dist/{astro-shared-DkZaqX7L.d.ts → astro-shared-DyzbUi6c.d.ts} +4 -2
- package/dist/astro-shared-DyzbUi6c.d.ts.map +1 -0
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +1 -1
- package/dist/{core-Dvqm7w2y.js → capabilities-BuZUQpiD.js} +64 -2
- package/dist/capabilities-BuZUQpiD.js.map +1 -0
- package/dist/{core-BhiA9fFi.d.ts → capabilities-yC9TsHDI.d.ts} +20 -2
- package/dist/capabilities-yC9TsHDI.d.ts.map +1 -0
- package/dist/client.min.js +1 -1
- package/dist/development/astro-client.js +7 -4
- package/dist/development/astro-client.js.map +1 -1
- package/dist/development/astro-server.js +4 -3
- package/dist/development/astro-server.js.map +1 -1
- package/dist/development/astro-shared-BT45auwR.js.map +1 -1
- package/dist/development/astro.js +1 -1
- package/dist/development/{core-DB3sQz4h.js → capabilities-DhOJmeoJ.js} +64 -2
- package/dist/development/capabilities-DhOJmeoJ.js.map +1 -0
- package/dist/development/{dom-D9cY6l1R.js → dom-BKc6V_Kz.js} +8 -3
- package/dist/development/dom-BKc6V_Kz.js.map +1 -0
- package/dist/development/index.js +3 -38
- package/dist/development/jsx-runtime.js.map +1 -1
- package/dist/development/konva.js +121 -0
- package/dist/development/konva.js.map +1 -0
- package/dist/development/motion.js +217 -0
- package/dist/development/motion.js.map +1 -0
- package/dist/development/renderer.js +177 -0
- package/dist/development/renderer.js.map +1 -0
- package/dist/development/server.js +17 -7
- package/dist/development/server.js.map +1 -1
- package/dist/development/src-Dh-d6w4y.js +38 -0
- package/dist/development/src-Dh-d6w4y.js.map +1 -0
- package/dist/development/three.js +438 -0
- package/dist/development/three.js.map +1 -0
- package/dist/development/vite-CSHoxzXU.js +240 -0
- package/dist/development/vite-CSHoxzXU.js.map +1 -0
- package/dist/development/vite.js +1 -1
- package/dist/{dom-BR9o9wZW.js → dom-B2rm8o2L.js} +8 -3
- package/dist/dom-B2rm8o2L.js.map +1 -0
- package/dist/index-BdwxmSKg.d.ts +24 -0
- package/dist/index-BdwxmSKg.d.ts.map +1 -0
- package/dist/index.d.ts +4 -24
- package/dist/index.js +3 -38
- package/dist/{jsx-runtime-BzGV18VO.d.ts → jsx-runtime-CZU7F8Qz.d.ts} +6 -4
- package/dist/jsx-runtime-CZU7F8Qz.d.ts.map +1 -0
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/konva.d.ts +32 -0
- package/dist/konva.d.ts.map +1 -0
- package/dist/konva.js +121 -0
- package/dist/konva.js.map +1 -0
- package/dist/motion.d.ts +44 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +217 -0
- package/dist/motion.js.map +1 -0
- package/dist/renderer.d.ts +24 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +177 -0
- package/dist/renderer.js.map +1 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +17 -7
- package/dist/server.js.map +1 -1
- package/dist/size.json +16 -16
- package/dist/src-BZxX4xbU.js +38 -0
- package/dist/src-BZxX4xbU.js.map +1 -0
- package/dist/three.d.ts +110 -0
- package/dist/three.d.ts.map +1 -0
- package/dist/three.js +438 -0
- package/dist/three.js.map +1 -0
- package/dist/vite-CSHoxzXU.js +240 -0
- package/dist/vite-CSHoxzXU.js.map +1 -0
- package/dist/vite.js +1 -1
- package/package.json +176 -131
- package/src/astro-client.ts +1 -0
- package/src/astro-server.ts +1 -0
- package/src/astro-shared.ts +3 -0
- package/src/capabilities.ts +88 -0
- package/src/compiler.ts +251 -177
- package/src/core.ts +11 -0
- package/src/dom.ts +4 -1
- package/src/index.ts +5 -0
- package/src/jsx-runtime.ts +4 -0
- package/src/jsx-types.d.ts +3 -1
- package/src/konva.ts +159 -0
- package/src/motion.ts +406 -0
- package/src/renderer.ts +241 -0
- package/src/server.ts +21 -13
- package/src/three-events.ts +330 -0
- package/src/three.ts +350 -0
- package/dist/astro-shared-DkZaqX7L.d.ts.map +0 -1
- package/dist/core-BhiA9fFi.d.ts.map +0 -1
- package/dist/core-Dvqm7w2y.js.map +0 -1
- package/dist/development/core-DB3sQz4h.js.map +0 -1
- package/dist/development/dom-D9cY6l1R.js.map +0 -1
- package/dist/development/index.js.map +0 -1
- package/dist/development/vite-BadrFSIM.js +0 -126
- package/dist/development/vite-BadrFSIM.js.map +0 -1
- package/dist/dom-BR9o9wZW.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jsx-runtime-BzGV18VO.d.ts.map +0 -1
- package/dist/vite-BadrFSIM.js +0 -126
- package/dist/vite-BadrFSIM.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 3,
|
|
361
|
+
The hard budget is under 3,800 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 3.7 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
|
|
|
@@ -368,6 +368,7 @@ pnpm --filter @atom.io/spa cov
|
|
|
368
368
|
pnpm --filter @atom.io/spa-devtools cov
|
|
369
369
|
pnpm exec turbo run test:breakage:peers --filter=@atom.io/spa --filter=@atom.io/spa-devtools
|
|
370
370
|
pnpm --filter @atom.io/spa test:production
|
|
371
|
+
pnpm --filter @atom.io/spa test:optional-peers
|
|
371
372
|
pnpm --filter @atom.io/spa exec playwright install chromium
|
|
372
373
|
pnpm --filter @atom.io/spa test:browser
|
|
373
374
|
pnpm --filter @atom.io/spa size
|
|
@@ -389,14 +390,208 @@ Sizes are exact minified and level-9 gzip JavaScript byte counts. Declarations,
|
|
|
389
390
|
|
|
390
391
|
| Recipe | Entry | Minified JS | Gzip JS |
|
|
391
392
|
| -------------------------------- | --------------------------------- | ----------: | -------: |
|
|
392
|
-
| Family app with refs and history | `tonnage-recipes/family-app.ts` |
|
|
393
|
-
| Async interactive client app | `tonnage-recipes/async-app.ts` |
|
|
394
|
-
| Interactive client app | `tonnage-recipes/client-app.ts` |
|
|
395
|
-
| Hydrated interactive app | `tonnage-recipes/hydrated-app.ts` |
|
|
396
|
-
| Interactive Astro island | `tonnage-recipes/astro-island.ts` |
|
|
393
|
+
| Family app with refs and history | `tonnage-recipes/family-app.ts` | 62,395 B | 18,504 B |
|
|
394
|
+
| Async interactive client app | `tonnage-recipes/async-app.ts` | 40,808 B | 12,714 B |
|
|
395
|
+
| Interactive client app | `tonnage-recipes/client-app.ts` | 40,470 B | 12,559 B |
|
|
396
|
+
| Hydrated interactive app | `tonnage-recipes/hydrated-app.ts` | 40,471 B | 12,560 B |
|
|
397
|
+
| Interactive Astro island | `tonnage-recipes/astro-island.ts` | 46,849 B | 14,513 B |
|
|
397
398
|
|
|
398
399
|
Report maintained with [tonnage](https://github.com/jeremybanka/tonnage).
|
|
399
400
|
|
|
400
401
|
## License
|
|
401
402
|
|
|
402
403
|
MPL-2.0 or later. See [LICENSE](./LICENSE).
|
|
404
|
+
|
|
405
|
+
## Optional graphics and motion
|
|
406
|
+
|
|
407
|
+
SPA includes Konva, Three.js, and Motion integrations behind separate entrypoints. Install only the engines you use. Konva, three, @types/three, and motion are optional peers; the main runtime and JSX declarations work without them installed. Importing the base entrypoint does not load any animation or graphics engine, and each integration's bundle excludes the other engines. These boundaries are verified with isolated consumer and bundle checks.
|
|
408
|
+
|
|
409
|
+
### Konva
|
|
410
|
+
|
|
411
|
+
Import Stage, Layer, Group, Rect, Circle, Ellipse, Line, Text, Image, Path, Star, and Transformer from @atom.io/spa/konva. Stage renders a DOM container and creates its native stage after browser mounting. Compiled atom reads update native attributes; keyed children preserve node identity. Native configuration attributes and onClick, onPointerDown, onDragMove, and onDragEnd handlers are supported. Refs receive native nodes and null on cleanup. Removal destroys owned nodes and listeners.
|
|
412
|
+
|
|
413
|
+
```tsx
|
|
414
|
+
import type { VNode } from "@atom.io/spa"
|
|
415
|
+
import { useSetter, useValue } from "@atom.io/spa"
|
|
416
|
+
import { Circle, Layer, Stage } from "@atom.io/spa/konva"
|
|
417
|
+
import { atom } from "atom.io"
|
|
418
|
+
|
|
419
|
+
const pointAtom = atom<{ x: number; y: number }>({
|
|
420
|
+
key: `point`,
|
|
421
|
+
default: { x: 100, y: 100 },
|
|
422
|
+
})
|
|
423
|
+
export function Editor(): VNode {
|
|
424
|
+
const point = useValue(pointAtom)
|
|
425
|
+
const setPoint = useSetter(pointAtom)
|
|
426
|
+
return (
|
|
427
|
+
<Stage width={800} height={600}>
|
|
428
|
+
<Layer>
|
|
429
|
+
<Circle
|
|
430
|
+
x={point().x}
|
|
431
|
+
y={point().y}
|
|
432
|
+
radius={25}
|
|
433
|
+
fill="coral"
|
|
434
|
+
draggable
|
|
435
|
+
onDragEnd={(event) => {
|
|
436
|
+
setPoint({ x: event.target.x(), y: event.target.y() })
|
|
437
|
+
}}
|
|
438
|
+
/>
|
|
439
|
+
</Layer>
|
|
440
|
+
</Stage>
|
|
441
|
+
)
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Konva owns hit testing, dragging, and draw batching. Write drag results back into atoms to keep document state synchronized. The exported konvaRenderer can also render into a borrowed container dedicated to its scene children.
|
|
447
|
+
|
|
448
|
+
### Three.js
|
|
449
|
+
|
|
450
|
+
Import Canvas, Group, Mesh, PerspectiveCamera, AmbientLight, DirectionalLight, BoxGeometry, SphereGeometry, PlaneGeometry, MeshStandardMaterial, MeshBasicMaterial, and MeshNormalMaterial from @atom.io/spa/three. Canvas creates a WebGL renderer after browser mounting. Geometry and material children attach to their Mesh, with one of each supported. Position and rotation accept three-number tuples; scale also accepts a scalar.
|
|
451
|
+
|
|
452
|
+
```tsx
|
|
453
|
+
import type { VNode } from "@atom.io/spa"
|
|
454
|
+
import { useValue } from "@atom.io/spa"
|
|
455
|
+
import {
|
|
456
|
+
AmbientLight,
|
|
457
|
+
BoxGeometry,
|
|
458
|
+
Canvas,
|
|
459
|
+
DirectionalLight,
|
|
460
|
+
Mesh,
|
|
461
|
+
MeshStandardMaterial,
|
|
462
|
+
} from "@atom.io/spa/three"
|
|
463
|
+
import { atom } from "atom.io"
|
|
464
|
+
|
|
465
|
+
const colorAtom = atom<string>({ key: `color`, default: `coral` })
|
|
466
|
+
export function Scene(): VNode {
|
|
467
|
+
const color = useValue(colorAtom)
|
|
468
|
+
return (
|
|
469
|
+
<Canvas width={800} height={600}>
|
|
470
|
+
<AmbientLight intensity={0.5} />
|
|
471
|
+
<DirectionalLight position={[3, 3, 3]} />
|
|
472
|
+
<Mesh rotation={[0.3, 0.5, 0]}>
|
|
473
|
+
<BoxGeometry args={[1, 1, 1]} />
|
|
474
|
+
<MeshStandardMaterial color={color()} />
|
|
475
|
+
</Mesh>
|
|
476
|
+
</Canvas>
|
|
477
|
+
)
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
Constructor args are fixed for an instance. To change them, replace the resource with a new key in a reactive child collection. Refs expose native objects. Owned geometries and materials are disposed on removal; textures passed through material properties remain borrowed. Canvas stops drawing and disposes its renderer on removal. The exported threeRenderer renders into a borrowed parent dedicated to its children without creating a WebGL renderer.
|
|
483
|
+
|
|
484
|
+
Canvas defaults to a perspective camera at z = 5. Its optional camera prop borrows an external camera; a PerspectiveCamera child does not automatically become active. Width and height update the renderer and default camera. Canvas renders continuously and accepts an onFrame callback with scene, camera, renderer, delta seconds, and timestamp seconds. Controls, asset loading, and drawing on demand are outside this initial API.
|
|
485
|
+
|
|
486
|
+
### Three.js pointer events
|
|
487
|
+
|
|
488
|
+
Mesh and group components accept onPointerDown, onPointerUp, onPointerMove, onPointerEnter, onPointerLeave, onPointerOver, onPointerOut, onPointerCancel, and onClick handlers. Canvas converts CSS pointer coordinates into a ray through the current camera, updates world matrices, and picks the nearest visible object on the camera's layers. That object occludes objects behind it even when it has no handlers. Three.js material sidedness controls which surfaces can be picked.
|
|
489
|
+
|
|
490
|
+
Events bubble from the picked object through its scene ancestors; stopPropagation stops ancestor delivery. Enter and leave notifications describe each ancestor's hover boundary without repeating when moving between its children. Hover is tracked per pointer and re-evaluated each frame, so moving objects and cameras update hover even when the pointer stays still. Hidden ancestry and hidden materials are excluded.
|
|
491
|
+
|
|
492
|
+
A ThreePointerEvent exposes nativeEvent, target (the receiving leaf or captured object), currentTarget (the handler's object), intersection, ray, pointerId, button, buttons, clientX, clientY, preventDefault, stopPropagation, and setPointerCapture/releasePointerCapture/hasPointerCapture methods scoped to that handler's object. Capturing on a group retargets subsequent events to that group. Off-object captured events retain the capture's last intersection; use the current ray for drag-plane calculations. A primary-button click is emitted only when press and release pick the same leaf.
|
|
493
|
+
|
|
494
|
+
Canvas retains native pointer delivery during a press. Releasing outside a pressed object cancels it unless a scene object explicitly captured the pointer; captured objects still receive the release outside the canvas. Pointer cancellation, browser capture loss, subtree removal, and Canvas disposal clear interaction state and release native capture. Cleanup continues if removal callbacks fail. Borrowed scenes can use createThreeEvents directly, call update after changing the scene, remove to release a subtree's interaction state, and dispose when the surface is released.
|
|
495
|
+
|
|
496
|
+
### Declarative motion capabilities
|
|
497
|
+
|
|
498
|
+
Import motionCapability from @atom.io/spa/motion and register it explicitly in render or hydrate options. Importing that entrypoint also supplies JSX type augmentation. Registration belongs to one root, is inherited by its scene subtrees, and never modifies a global registry. Astro islands can set their component's capabilities property to the same array; the integration supplies it to both server rendering and browser hydration.
|
|
499
|
+
|
|
500
|
+
```tsx
|
|
501
|
+
import { render } from "@atom.io/spa"
|
|
502
|
+
import { motionCapability } from "@atom.io/spa/motion"
|
|
503
|
+
|
|
504
|
+
import { MotionPanel } from "./motion.spa.tsx"
|
|
505
|
+
|
|
506
|
+
render(() => <MotionPanel />, document.getElementById(`app`)!, {
|
|
507
|
+
capabilities: [motionCapability()],
|
|
508
|
+
})
|
|
509
|
+
|
|
510
|
+
```
|
|
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.
|
|
513
|
+
|
|
514
|
+
```tsx
|
|
515
|
+
import type { VNode } from "@atom.io/spa"
|
|
516
|
+
import { useSetter, useValue } from "@atom.io/spa"
|
|
517
|
+
import { atom } from "atom.io"
|
|
518
|
+
|
|
519
|
+
const targetXAtom = atom<number>({ key: `targetX`, default: 0 })
|
|
520
|
+
export function MotionPanel(): VNode {
|
|
521
|
+
const x = useValue(targetXAtom)
|
|
522
|
+
const setX = useSetter(targetXAtom)
|
|
523
|
+
return (
|
|
524
|
+
<section>
|
|
525
|
+
<button
|
|
526
|
+
onClick={() => {
|
|
527
|
+
setX((value) => (value === 0 ? 200 : 0))
|
|
528
|
+
}}
|
|
529
|
+
>
|
|
530
|
+
Move
|
|
531
|
+
</button>
|
|
532
|
+
<sliding-panel
|
|
533
|
+
style="display: block; width: 120px; padding: 16px; background: coral"
|
|
534
|
+
motion:initial={{ opacity: 0, x: -100 }}
|
|
535
|
+
motion:animate={{ opacity: 1, x: x() }}
|
|
536
|
+
motion:transition={{ type: `spring`, stiffness: 180, damping: 22 }}
|
|
537
|
+
motion:whileHover={{ scale: 1.05 }}
|
|
538
|
+
motion:whileTap={{ scale: 0.95 }}
|
|
539
|
+
>
|
|
540
|
+
Motion, with your own markup.
|
|
541
|
+
</sliding-panel>
|
|
542
|
+
</section>
|
|
543
|
+
)
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
```
|
|
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, exit/presence retention, and variant propagation are outside this initial API.
|
|
549
|
+
|
|
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
|
+
|
|
552
|
+
The same attributes animate numeric Konva properties and colors, or Three.js position, rotation, scale, light/material color, opacity, and intensity. Three.js rotation uses Euler components, not quaternion interpolation. DOM hover and tap use Motion's gesture handling; Konva gestures use native pointer events. Three.js gestures use the same raycast event layer as ordinary scene pointer handlers.
|
|
553
|
+
|
|
554
|
+
```tsx
|
|
555
|
+
import type { VNode } from "@atom.io/spa"
|
|
556
|
+
import { useValue } from "@atom.io/spa"
|
|
557
|
+
import {
|
|
558
|
+
BoxGeometry,
|
|
559
|
+
Canvas,
|
|
560
|
+
Mesh,
|
|
561
|
+
MeshNormalMaterial,
|
|
562
|
+
} from "@atom.io/spa/three"
|
|
563
|
+
import { atom } from "atom.io"
|
|
564
|
+
|
|
565
|
+
const targetXAtom = atom<number>({
|
|
566
|
+
key: `targetX`,
|
|
567
|
+
default: 1,
|
|
568
|
+
})
|
|
569
|
+
// Mount under a root with capabilities: [motionCapability()].
|
|
570
|
+
export function SpringCube(): VNode {
|
|
571
|
+
const x = useValue(targetXAtom)
|
|
572
|
+
return (
|
|
573
|
+
<Canvas>
|
|
574
|
+
<Mesh
|
|
575
|
+
motion:initial={{ position: [-1, 0, 0], scale: 0 }}
|
|
576
|
+
motion:animate={{ position: [x(), 0, 0], scale: 1 }}
|
|
577
|
+
motion:transition={{ type: `spring`, stiffness: 180, damping: 22 }}
|
|
578
|
+
motion:whileHover={{ scale: 1.2 }}
|
|
579
|
+
motion:whileTap={{ scale: 0.8 }}
|
|
580
|
+
onPointerDown={(event) => {
|
|
581
|
+
event.setPointerCapture()
|
|
582
|
+
}}
|
|
583
|
+
>
|
|
584
|
+
<BoxGeometry />
|
|
585
|
+
<MeshNormalMaterial />
|
|
586
|
+
</Mesh>
|
|
587
|
+
</Canvas>
|
|
588
|
+
)
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
```
|
|
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; its capability dispatch adds approximately 350 bytes of gzip to the previous complete client surface.
|
|
594
|
+
|
|
595
|
+
### Renderer extensions
|
|
596
|
+
|
|
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.
|
package/README.mdx
CHANGED
|
@@ -11,6 +11,11 @@ import AstroConfig from "./exhibits/astro.config.ts" with { type: "code" };
|
|
|
11
11
|
import AsyncAstro from "./exhibits/async-astro.spa.tsx" with { type: "code" };
|
|
12
12
|
import Counter from "./exhibits/Counter.spa.tsx" with { type: "code" };
|
|
13
13
|
import Verify from "./exhibits/verify.sh" with { type: "code" };
|
|
14
|
+
import KonvaExample from "./exhibits/konva.spa.tsx" with { type: "code" };
|
|
15
|
+
import ThreeExample from "./exhibits/three.spa.tsx" with { type: "code" };
|
|
16
|
+
import MotionPanel from "./exhibits/motion.spa.tsx" with { type: "code" };
|
|
17
|
+
import MotionMain from "./exhibits/motion-main.tsx" with { type: "code" };
|
|
18
|
+
import MotionThree from "./exhibits/motion-three.spa.tsx" with { type: "code" };
|
|
14
19
|
|
|
15
20
|
<p align="center">
|
|
16
21
|
<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" />
|
|
@@ -131,7 +136,7 @@ The checked Astro fixture demonstrates default/named slots and custom independen
|
|
|
131
136
|
|
|
132
137
|
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.
|
|
133
138
|
|
|
134
|
-
The hard budget is under 3,
|
|
139
|
+
The hard budget is under 3,800 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 3.7 kB with gzip; dist/size.json records the exact build measurements. Actual application bundles add atom.io and compiler-generated application code.
|
|
135
140
|
|
|
136
141
|
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.
|
|
137
142
|
|
|
@@ -148,3 +153,59 @@ Tonnage measures combined browser bundles containing SPA and atom.io, with share
|
|
|
148
153
|
## License
|
|
149
154
|
|
|
150
155
|
MPL-2.0 or later. See [LICENSE](./LICENSE).
|
|
156
|
+
|
|
157
|
+
## Optional graphics and motion
|
|
158
|
+
|
|
159
|
+
SPA includes Konva, Three.js, and Motion integrations behind separate entrypoints. Install only the engines you use. Konva, three, @types/three, and motion are optional peers; the main runtime and JSX declarations work without them installed. Importing the base entrypoint does not load any animation or graphics engine, and each integration's bundle excludes the other engines. These boundaries are verified with isolated consumer and bundle checks.
|
|
160
|
+
|
|
161
|
+
### Konva
|
|
162
|
+
|
|
163
|
+
Import Stage, Layer, Group, Rect, Circle, Ellipse, Line, Text, Image, Path, Star, and Transformer from @atom.io/spa/konva. Stage renders a DOM container and creates its native stage after browser mounting. Compiled atom reads update native attributes; keyed children preserve node identity. Native configuration attributes and onClick, onPointerDown, onDragMove, and onDragEnd handlers are supported. Refs receive native nodes and null on cleanup. Removal destroys owned nodes and listeners.
|
|
164
|
+
|
|
165
|
+
<KonvaExample />
|
|
166
|
+
|
|
167
|
+
Konva owns hit testing, dragging, and draw batching. Write drag results back into atoms to keep document state synchronized. The exported konvaRenderer can also render into a borrowed container dedicated to its scene children.
|
|
168
|
+
|
|
169
|
+
### Three.js
|
|
170
|
+
|
|
171
|
+
Import Canvas, Group, Mesh, PerspectiveCamera, AmbientLight, DirectionalLight, BoxGeometry, SphereGeometry, PlaneGeometry, MeshStandardMaterial, MeshBasicMaterial, and MeshNormalMaterial from @atom.io/spa/three. Canvas creates a WebGL renderer after browser mounting. Geometry and material children attach to their Mesh, with one of each supported. Position and rotation accept three-number tuples; scale also accepts a scalar.
|
|
172
|
+
|
|
173
|
+
<ThreeExample />
|
|
174
|
+
|
|
175
|
+
Constructor args are fixed for an instance. To change them, replace the resource with a new key in a reactive child collection. Refs expose native objects. Owned geometries and materials are disposed on removal; textures passed through material properties remain borrowed. Canvas stops drawing and disposes its renderer on removal. The exported threeRenderer renders into a borrowed parent dedicated to its children without creating a WebGL renderer.
|
|
176
|
+
|
|
177
|
+
Canvas defaults to a perspective camera at z = 5. Its optional camera prop borrows an external camera; a PerspectiveCamera child does not automatically become active. Width and height update the renderer and default camera. Canvas renders continuously and accepts an onFrame callback with scene, camera, renderer, delta seconds, and timestamp seconds. Controls, asset loading, and drawing on demand are outside this initial API.
|
|
178
|
+
|
|
179
|
+
### Three.js pointer events
|
|
180
|
+
|
|
181
|
+
Mesh and group components accept onPointerDown, onPointerUp, onPointerMove, onPointerEnter, onPointerLeave, onPointerOver, onPointerOut, onPointerCancel, and onClick handlers. Canvas converts CSS pointer coordinates into a ray through the current camera, updates world matrices, and picks the nearest visible object on the camera's layers. That object occludes objects behind it even when it has no handlers. Three.js material sidedness controls which surfaces can be picked.
|
|
182
|
+
|
|
183
|
+
Events bubble from the picked object through its scene ancestors; stopPropagation stops ancestor delivery. Enter and leave notifications describe each ancestor's hover boundary without repeating when moving between its children. Hover is tracked per pointer and re-evaluated each frame, so moving objects and cameras update hover even when the pointer stays still. Hidden ancestry and hidden materials are excluded.
|
|
184
|
+
|
|
185
|
+
A ThreePointerEvent exposes nativeEvent, target (the receiving leaf or captured object), currentTarget (the handler's object), intersection, ray, pointerId, button, buttons, clientX, clientY, preventDefault, stopPropagation, and setPointerCapture/releasePointerCapture/hasPointerCapture methods scoped to that handler's object. Capturing on a group retargets subsequent events to that group. Off-object captured events retain the capture's last intersection; use the current ray for drag-plane calculations. A primary-button click is emitted only when press and release pick the same leaf.
|
|
186
|
+
|
|
187
|
+
Canvas retains native pointer delivery during a press. Releasing outside a pressed object cancels it unless a scene object explicitly captured the pointer; captured objects still receive the release outside the canvas. Pointer cancellation, browser capture loss, subtree removal, and Canvas disposal clear interaction state and release native capture. Cleanup continues if removal callbacks fail. Borrowed scenes can use createThreeEvents directly, call update after changing the scene, remove to release a subtree's interaction state, and dispose when the surface is released.
|
|
188
|
+
|
|
189
|
+
### Declarative motion capabilities
|
|
190
|
+
|
|
191
|
+
Import motionCapability from @atom.io/spa/motion and register it explicitly in render or hydrate options. Importing that entrypoint also supplies JSX type augmentation. Registration belongs to one root, is inherited by its scene subtrees, and never modifies a global registry. Astro islands can set their component's capabilities property to the same array; the integration supplies it to both server rendering and browser hydration.
|
|
192
|
+
|
|
193
|
+
<MotionMain />
|
|
194
|
+
|
|
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
|
+
|
|
197
|
+
<MotionPanel />
|
|
198
|
+
|
|
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, exit/presence retention, and variant propagation are outside this initial API.
|
|
200
|
+
|
|
201
|
+
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
|
+
The same attributes animate numeric Konva properties and colors, or Three.js position, rotation, scale, light/material color, opacity, and intensity. Three.js rotation uses Euler components, not quaternion interpolation. DOM hover and tap use Motion's gesture handling; Konva gestures use native pointer events. Three.js gestures use the same raycast event layer as ordinary scene pointer handlers.
|
|
204
|
+
|
|
205
|
+
<MotionThree />
|
|
206
|
+
|
|
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; its capability dispatch adds approximately 350 bytes of gzip to the previous complete client surface.
|
|
208
|
+
|
|
209
|
+
### Renderer extensions
|
|
210
|
+
|
|
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.
|
package/dist/astro-client.d.ts
CHANGED
package/dist/astro-client.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { s as onCleanup, y as useValue } from "./core-Dvqm7w2y.js";
|
|
2
|
-
import { n as render, t as hydrate } from "./dom-BR9o9wZW.js";
|
|
3
|
-
import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
|
|
4
1
|
import { browserApplication } from "./astro-application.js";
|
|
2
|
+
import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
|
|
5
3
|
import { n as islandStore, t as island } from "./astro-shared-BT45auwR.js";
|
|
4
|
+
import { S as useValue, u as onCleanup } from "./capabilities-BuZUQpiD.js";
|
|
5
|
+
import { n as render, t as hydrate } from "./dom-B2rm8o2L.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();
|
|
@@ -65,7 +65,10 @@ var astro_client_default = (element) => async (component, props, slots, { client
|
|
|
65
65
|
return () => island(component, value().props, value().slots);
|
|
66
66
|
};
|
|
67
67
|
if (replace) element.replaceChildren();
|
|
68
|
-
const root = (replace ? render : hydrate)(mount, element, {
|
|
68
|
+
const root = (replace ? render : hydrate)(mount, element, {
|
|
69
|
+
store,
|
|
70
|
+
capabilities: component.capabilities ?? []
|
|
71
|
+
});
|
|
69
72
|
lifetime.context.onCleanup(root.dispose);
|
|
70
73
|
update = (next) => {
|
|
71
74
|
setIntoStore(store, state, next);
|
package/dist/astro-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro-client.js","names":[],"sources":["../src/astro-client.ts"],"sourcesContent":["import type { RegularAtomFamilyToken } from \"atom.io\"\nimport type { RootStore } from \"atom.io/internal\"\nimport {\n\tcreateRegularAtomFamily,\n\tdisposeFromStore,\n\tfindInStore,\n\tIMPLICIT,\n\tsetIntoStore,\n} from \"atom.io/internal\"\n\nimport { browserApplication } from \"./astro-application.ts\"\nimport { failPreparation, storeContext } from \"./astro-context.ts\"\nimport type { Island } from \"./astro-shared.ts\"\nimport { island, islandStore } from \"./astro-shared.ts\"\nimport { onCleanup, useValue } from \"./core.ts\"\nimport { hydrate, render } from \"./dom.ts\"\n\ntype Props = Record<string, any>\ntype Slots = Record<string, string>\ntype Hydrator = (\n\tcomponent: Island,\n\tprops: Props,\n\tslots: Slots,\n\tmetadata: { client: string },\n) => Promise<void>\nconst roots = new WeakMap<\n\tElement,\n\t{\n\t\tcomponent: Island\n\t\tready: Promise<void>\n\t\tupdate(props: Props, slots: Slots): void\n\t\tdispose(): void\n\t}\n>()\ntype State = { props: Props; slots: Slots }\nconst states = new WeakMap<RootStore, RegularAtomFamilyToken<State, number>>()\nlet serial = 0\n\nexport default (element: HTMLElement): Hydrator =>\n\tasync (component, props, slots, { client }) => {\n\t\tconst previous = roots.get(element)\n\t\tif (previous?.component === component) {\n\t\t\tprevious.update(props, slots)\n\t\t\treturn previous.ready\n\t\t}\n\t\tprevious?.dispose()\n\t\tconst shared = !component.createStore && !component.isolate\n\t\tconst application = shared\n\t\t\t? browserApplication(element.ownerDocument)\n\t\t\t: undefined\n\t\tif (application && client === `only`) application.canResume = false\n\t\tconst lifetime = storeContext(element, application)\n\t\tconst initial = { props, slots }\n\t\tlet current = initial\n\t\tlet update: ((value: State) => void) | undefined\n\t\tlet disposed = false\n\t\tconst dispose = () => {\n\t\t\tif (disposed) return\n\t\t\tdisposed = true\n\t\t\telement.removeEventListener(`astro:unmount`, dispose)\n\t\t\troots.delete(element)\n\t\t\tlifetime.dispose()\n\t\t}\n\t\t// Publish the pending owner before invoking user code. Repeated hydration\n\t\t// calls update its props and share its preparation rather than racing stores.\n\t\tconst ready = Promise.resolve().then(async () => {\n\t\t\tif (lifetime.context.signal.aborted) return\n\t\t\tlet mounting = false\n\t\t\ttry {\n\t\t\t\tconst store = await Promise.race([\n\t\t\t\t\tislandStore(\n\t\t\t\t\t\tcomponent,\n\t\t\t\t\t\tprops,\n\t\t\t\t\t\tlifetime.context,\n\t\t\t\t\t\tshared ? IMPLICIT.STORE : undefined,\n\t\t\t\t\t),\n\t\t\t\t\tlifetime.cancelled,\n\t\t\t\t])\n\t\t\t\tif (lifetime.context.signal.aborted) return\n\t\t\t\tmounting = true\n\t\t\t\tconst replace =\n\t\t\t\t\tclient === `only` ||\n\t\t\t\t\tprevious !== undefined ||\n\t\t\t\t\tapplication?.canResume === false\n\t\t\t\t// Astro leaves this sentinel on islands inserted by ClientRouter.\n\t\t\t\tconst sentinel = element.lastChild\n\t\t\t\tif (sentinel?.nodeType === 8 && sentinel.nodeValue === `astro:end`)\n\t\t\t\t\tsentinel.remove()\n\t\t\t\tlet family = states.get(store!)\n\t\t\t\tif (!family) {\n\t\t\t\t\tfamily = createRegularAtomFamily<State, number, never>(store!, {\n\t\t\t\t\t\tkey: `🔍 spa islands`,\n\t\t\t\t\t\tdefault: { props: {}, slots: {} },\n\t\t\t\t\t})\n\t\t\t\t\tstates.set(store!, family)\n\t\t\t\t}\n\t\t\t\tconst state = findInStore(store!, family, serial++)\n\t\t\t\tsetIntoStore(store!, state, replace ? current : initial)\n\t\t\t\tlifetime.context.onCleanup(() => {\n\t\t\t\t\tdisposeFromStore(store!, state)\n\t\t\t\t})\n\t\t\t\tconst mount = () => {\n\t\t\t\t\tonCleanup(dispose)\n\t\t\t\t\tconst value = useValue(state)\n\t\t\t\t\treturn () => island(component, value().props, value().slots)\n\t\t\t\t}\n\t\t\t\tif (replace) element.replaceChildren()\n\t\t\t\tconst root = (replace ? render : hydrate)(mount, element, {\n\t\t\t\t\tstore: store!,\n\t\t\t\t})\n\t\t\t\tlifetime.context.onCleanup(root.dispose)\n\t\t\t\tupdate = (next) => {\n\t\t\t\t\tsetIntoStore(store!, state, next)\n\t\t\t\t\troot.flush()\n\t\t\t\t}\n\t\t\t\t// Match the existing SSR tree before applying a structural prop update\n\t\t\t\t// that arrived while its store was still being prepared.\n\t\t\t\tif (!replace && current !== initial) update(current)\n\t\t\t} catch (error) {\n\t\t\t\tif (lifetime.context.signal.aborted && !mounting) return\n\t\t\t\tfailPreparation(error, dispose)\n\t\t\t}\n\t\t})\n\t\troots.set(element, {\n\t\t\tcomponent,\n\t\t\tready,\n\t\t\tupdate(nextProps, nextSlots) {\n\t\t\t\tcurrent = { props: nextProps, slots: nextSlots }\n\t\t\t\tupdate?.(current)\n\t\t\t},\n\t\t\tdispose,\n\t\t})\n\t\telement.addEventListener(`astro:unmount`, dispose, { once: true })\n\t\tlifetime.context.onCleanup(dispose)\n\t\treturn ready\n\t}\n"],"mappings":";;;;;;;AAyBA,MAAM,wBAAQ,IAAI,QAQhB;AAEF,MAAM,yBAAS,IAAI,QAA0D;AAC7E,IA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AI,OAAQ,MAAM;GAC1B;GACA,MAAM,QAAQ,YAAY,OAAQ,QAAQ,QAAQ;GAClD,aAAa,OAAQ,OAAO,UAAU,UAAU,OAAO;GACvD,SAAS,QAAQ,gBAAgB;IAChC,iBAAiB,OAAQ,KAAK;GAC/B,CAAC;GACD,MAAM,cAAc;IACnB,UAAU,OAAO;IACjB,MAAM,QAAQ,SAAS,KAAK;IAC5B,aAAa,OAAO,WAAW,MAAM,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,KAAK;GAC5D;GACA,IAAI,SAAS,QAAQ,gBAAgB;GACrC,MAAM,QAAQ,UAAU,SAAS,QAAA,CAAS,OAAO,SAAS,
|
|
1
|
+
{"version":3,"file":"astro-client.js","names":[],"sources":["../src/astro-client.ts"],"sourcesContent":["import type { RegularAtomFamilyToken } from \"atom.io\"\nimport type { RootStore } from \"atom.io/internal\"\nimport {\n\tcreateRegularAtomFamily,\n\tdisposeFromStore,\n\tfindInStore,\n\tIMPLICIT,\n\tsetIntoStore,\n} from \"atom.io/internal\"\n\nimport { browserApplication } from \"./astro-application.ts\"\nimport { failPreparation, storeContext } from \"./astro-context.ts\"\nimport type { Island } from \"./astro-shared.ts\"\nimport { island, islandStore } from \"./astro-shared.ts\"\nimport { onCleanup, useValue } from \"./core.ts\"\nimport { hydrate, render } from \"./dom.ts\"\n\ntype Props = Record<string, any>\ntype Slots = Record<string, string>\ntype Hydrator = (\n\tcomponent: Island,\n\tprops: Props,\n\tslots: Slots,\n\tmetadata: { client: string },\n) => Promise<void>\nconst roots = new WeakMap<\n\tElement,\n\t{\n\t\tcomponent: Island\n\t\tready: Promise<void>\n\t\tupdate(props: Props, slots: Slots): void\n\t\tdispose(): void\n\t}\n>()\ntype State = { props: Props; slots: Slots }\nconst states = new WeakMap<RootStore, RegularAtomFamilyToken<State, number>>()\nlet serial = 0\n\nexport default (element: HTMLElement): Hydrator =>\n\tasync (component, props, slots, { client }) => {\n\t\tconst previous = roots.get(element)\n\t\tif (previous?.component === component) {\n\t\t\tprevious.update(props, slots)\n\t\t\treturn previous.ready\n\t\t}\n\t\tprevious?.dispose()\n\t\tconst shared = !component.createStore && !component.isolate\n\t\tconst application = shared\n\t\t\t? browserApplication(element.ownerDocument)\n\t\t\t: undefined\n\t\tif (application && client === `only`) application.canResume = false\n\t\tconst lifetime = storeContext(element, application)\n\t\tconst initial = { props, slots }\n\t\tlet current = initial\n\t\tlet update: ((value: State) => void) | undefined\n\t\tlet disposed = false\n\t\tconst dispose = () => {\n\t\t\tif (disposed) return\n\t\t\tdisposed = true\n\t\t\telement.removeEventListener(`astro:unmount`, dispose)\n\t\t\troots.delete(element)\n\t\t\tlifetime.dispose()\n\t\t}\n\t\t// Publish the pending owner before invoking user code. Repeated hydration\n\t\t// calls update its props and share its preparation rather than racing stores.\n\t\tconst ready = Promise.resolve().then(async () => {\n\t\t\tif (lifetime.context.signal.aborted) return\n\t\t\tlet mounting = false\n\t\t\ttry {\n\t\t\t\tconst store = await Promise.race([\n\t\t\t\t\tislandStore(\n\t\t\t\t\t\tcomponent,\n\t\t\t\t\t\tprops,\n\t\t\t\t\t\tlifetime.context,\n\t\t\t\t\t\tshared ? IMPLICIT.STORE : undefined,\n\t\t\t\t\t),\n\t\t\t\t\tlifetime.cancelled,\n\t\t\t\t])\n\t\t\t\tif (lifetime.context.signal.aborted) return\n\t\t\t\tmounting = true\n\t\t\t\tconst replace =\n\t\t\t\t\tclient === `only` ||\n\t\t\t\t\tprevious !== undefined ||\n\t\t\t\t\tapplication?.canResume === false\n\t\t\t\t// Astro leaves this sentinel on islands inserted by ClientRouter.\n\t\t\t\tconst sentinel = element.lastChild\n\t\t\t\tif (sentinel?.nodeType === 8 && sentinel.nodeValue === `astro:end`)\n\t\t\t\t\tsentinel.remove()\n\t\t\t\tlet family = states.get(store!)\n\t\t\t\tif (!family) {\n\t\t\t\t\tfamily = createRegularAtomFamily<State, number, never>(store!, {\n\t\t\t\t\t\tkey: `🔍 spa islands`,\n\t\t\t\t\t\tdefault: { props: {}, slots: {} },\n\t\t\t\t\t})\n\t\t\t\t\tstates.set(store!, family)\n\t\t\t\t}\n\t\t\t\tconst state = findInStore(store!, family, serial++)\n\t\t\t\tsetIntoStore(store!, state, replace ? current : initial)\n\t\t\t\tlifetime.context.onCleanup(() => {\n\t\t\t\t\tdisposeFromStore(store!, state)\n\t\t\t\t})\n\t\t\t\tconst mount = () => {\n\t\t\t\t\tonCleanup(dispose)\n\t\t\t\t\tconst value = useValue(state)\n\t\t\t\t\treturn () => island(component, value().props, value().slots)\n\t\t\t\t}\n\t\t\t\tif (replace) element.replaceChildren()\n\t\t\t\tconst root = (replace ? render : hydrate)(mount, element, {\n\t\t\t\t\tstore: store!,\n\t\t\t\t\tcapabilities: component.capabilities ?? [],\n\t\t\t\t})\n\t\t\t\tlifetime.context.onCleanup(root.dispose)\n\t\t\t\tupdate = (next) => {\n\t\t\t\t\tsetIntoStore(store!, state, next)\n\t\t\t\t\troot.flush()\n\t\t\t\t}\n\t\t\t\t// Match the existing SSR tree before applying a structural prop update\n\t\t\t\t// that arrived while its store was still being prepared.\n\t\t\t\tif (!replace && current !== initial) update(current)\n\t\t\t} catch (error) {\n\t\t\t\tif (lifetime.context.signal.aborted && !mounting) return\n\t\t\t\tfailPreparation(error, dispose)\n\t\t\t}\n\t\t})\n\t\troots.set(element, {\n\t\t\tcomponent,\n\t\t\tready,\n\t\t\tupdate(nextProps, nextSlots) {\n\t\t\t\tcurrent = { props: nextProps, slots: nextSlots }\n\t\t\t\tupdate?.(current)\n\t\t\t},\n\t\t\tdispose,\n\t\t})\n\t\telement.addEventListener(`astro:unmount`, dispose, { once: true })\n\t\tlifetime.context.onCleanup(dispose)\n\t\treturn ready\n\t}\n"],"mappings":";;;;;;;AAyBA,MAAM,wBAAQ,IAAI,QAQhB;AAEF,MAAM,yBAAS,IAAI,QAA0D;AAC7E,IAAI,SAAS;AAEb,IAAA,wBAAgB,YACf,OAAO,WAAW,OAAO,OAAO,EAAE,aAAa;CAC9C,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Aa,OAAQ,OAAO,UAAU,UAAU,OAAO;GACvD,SAAS,QAAQ,gBAAgB;IAChC,iBAAiB,OAAQ,KAAK;GAC/B,CAAC;GACD,MAAM,cAAc;IACnB,UAAU,OAAO;IACjB,MAAM,QAAQ,SAAS,KAAK;IAC5B,aAAa,OAAO,WAAW,MAAM,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,KAAK;GAC5D;GACA,IAAI,SAAS,QAAQ,gBAAgB;GACrC,MAAM,QAAQ,UAAU,SAAS,QAAA,CAAS,OAAO,SAAS;IAClD;IACP,cAAc,UAAU,gBAAgB,CAAC;GAC1C,CAAC;GACD,SAAS,QAAQ,UAAU,KAAK,OAAO;GACvC,UAAU,SAAS;IAClB,aAAa,OAAQ,OAAO,IAAI;IAChC,KAAK,MAAM;GACZ;GAGA,IAAI,CAAC,WAAW,YAAY,SAAS,OAAO,OAAO;EACpD,SAAS,OAAO;GACf,IAAI,SAAS,QAAQ,OAAO,WAAW,CAAC,UAAU;GAClD,gBAAgB,OAAO,OAAO;EAC/B;CACD,CAAC;CACD,MAAM,IAAI,SAAS;EAClB;EACA;EACA,OAAO,WAAW,WAAW;GAC5B,UAAU;IAAE,OAAO;IAAW,OAAO;GAAU;GAC/C,SAAS,OAAO;EACjB;EACA;CACD,CAAC;CACD,QAAQ,iBAAiB,iBAAiB,SAAS,EAAE,MAAM,KAAK,CAAC;CACjE,SAAS,QAAQ,UAAU,OAAO;CAClC,OAAO;AACR"}
|
package/dist/astro-server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { renderToString } from "./server.js";
|
|
2
1
|
import { n as failPreparation, r as storeContext } from "./astro-context-OdlexHR4.js";
|
|
3
|
-
import { n as islandStore, t as island } from "./astro-shared-BT45auwR.js";
|
|
4
2
|
import { t as requestApplication } from "./astro-request-DRKvDjsO.js";
|
|
3
|
+
import { n as islandStore, t as island } from "./astro-shared-BT45auwR.js";
|
|
4
|
+
import { renderToString } from "./server.js";
|
|
5
5
|
// src/astro-server.ts
|
|
6
6
|
const renderer = {
|
|
7
7
|
name: `spa`,
|
|
@@ -16,7 +16,8 @@ const renderer = {
|
|
|
16
16
|
const store = await islandStore(component, props, lifetime.context, shared?.store);
|
|
17
17
|
return { html: renderToString(() => () => island(component, props, slots), {
|
|
18
18
|
store,
|
|
19
|
-
idPrefix: crypto.randomUUID()
|
|
19
|
+
idPrefix: crypto.randomUUID(),
|
|
20
|
+
capabilities: component.capabilities ?? []
|
|
20
21
|
}) };
|
|
21
22
|
} catch (error) {
|
|
22
23
|
failPreparation(error, lifetime.dispose);
|
package/dist/astro-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro-server.js","names":[],"sources":["../src/astro-server.ts"],"sourcesContent":["/* oxlint-disable typescript/require-await -- Astro requires async renderer callbacks, even for synchronous rendering. */\nimport type { NamedSSRLoadedRendererValue } from \"astro\"\n\nimport { failPreparation, storeContext } from \"./astro-context.ts\"\nimport { requestApplication } from \"./astro-request.ts\"\nimport type { Island } from \"./astro-shared.ts\"\nimport { island, islandStore } from \"./astro-shared.ts\"\nimport { renderToString } from \"./server.ts\"\n\nconst renderer: NamedSSRLoadedRendererValue = {\n\tname: `spa`,\n\tasync check(component: Island) {\n\t\treturn component?.spa === true\n\t},\n\tasync renderToStaticMarkup(component: Island, props, slots) {\n\t\tconst request = (this as unknown as { result?: { request: Request } }).result\n\t\t\t?.request\n\t\tconst shared =\n\t\t\t!component.createStore && !component.isolate && request\n\t\t\t\t? requestApplication(request)\n\t\t\t\t: undefined\n\t\tconst lifetime = storeContext(undefined, shared?.application)\n\t\ttry {\n\t\t\tconst store = await islandStore(\n\t\t\t\tcomponent,\n\t\t\t\tprops,\n\t\t\t\tlifetime.context,\n\t\t\t\tshared?.store,\n\t\t\t)\n\t\t\treturn {\n\t\t\t\thtml: renderToString(() => () => island(component, props, slots), {\n\t\t\t\t\tstore,\n\t\t\t\t\tidPrefix: crypto.randomUUID(),\n\t\t\t\t}),\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfailPreparation(error, lifetime.dispose)\n\t\t} finally {\n\t\t\tlifetime.dispose()\n\t\t}\n\t},\n}\nexport default renderer\n"],"mappings":";;;;;AASA,MAAM,WAAwC;CAC7C,MAAM;CACN,MAAM,MAAM,WAAmB;EAC9B,OAAO,WAAW,QAAQ;CAC3B;CACA,MAAM,qBAAqB,WAAmB,OAAO,OAAO;EAC3D,MAAM,UAAW,KAAsD,QACpE;EACH,MAAM,SACL,CAAC,UAAU,eAAe,CAAC,UAAU,WAAW,UAC7C,mBAAmB,OAAO,IAC1B,KAAA;EACJ,MAAM,WAAW,aAAa,KAAA,GAAW,QAAQ,WAAW;EAC5D,IAAI;GACH,MAAM,QAAQ,MAAM,YACnB,WACA,OACA,SAAS,SACT,QAAQ,KACT;GACA,OAAO,EACN,MAAM,2BAA2B,OAAO,WAAW,OAAO,KAAK,GAAG;IACjE;IACA,UAAU,OAAO,WAAW;
|
|
1
|
+
{"version":3,"file":"astro-server.js","names":[],"sources":["../src/astro-server.ts"],"sourcesContent":["/* oxlint-disable typescript/require-await -- Astro requires async renderer callbacks, even for synchronous rendering. */\nimport type { NamedSSRLoadedRendererValue } from \"astro\"\n\nimport { failPreparation, storeContext } from \"./astro-context.ts\"\nimport { requestApplication } from \"./astro-request.ts\"\nimport type { Island } from \"./astro-shared.ts\"\nimport { island, islandStore } from \"./astro-shared.ts\"\nimport { renderToString } from \"./server.ts\"\n\nconst renderer: NamedSSRLoadedRendererValue = {\n\tname: `spa`,\n\tasync check(component: Island) {\n\t\treturn component?.spa === true\n\t},\n\tasync renderToStaticMarkup(component: Island, props, slots) {\n\t\tconst request = (this as unknown as { result?: { request: Request } }).result\n\t\t\t?.request\n\t\tconst shared =\n\t\t\t!component.createStore && !component.isolate && request\n\t\t\t\t? requestApplication(request)\n\t\t\t\t: undefined\n\t\tconst lifetime = storeContext(undefined, shared?.application)\n\t\ttry {\n\t\t\tconst store = await islandStore(\n\t\t\t\tcomponent,\n\t\t\t\tprops,\n\t\t\t\tlifetime.context,\n\t\t\t\tshared?.store,\n\t\t\t)\n\t\t\treturn {\n\t\t\t\thtml: renderToString(() => () => island(component, props, slots), {\n\t\t\t\t\tstore,\n\t\t\t\t\tidPrefix: crypto.randomUUID(),\n\t\t\t\t\tcapabilities: component.capabilities ?? [],\n\t\t\t\t}),\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfailPreparation(error, lifetime.dispose)\n\t\t} finally {\n\t\t\tlifetime.dispose()\n\t\t}\n\t},\n}\nexport default renderer\n"],"mappings":";;;;;AASA,MAAM,WAAwC;CAC7C,MAAM;CACN,MAAM,MAAM,WAAmB;EAC9B,OAAO,WAAW,QAAQ;CAC3B;CACA,MAAM,qBAAqB,WAAmB,OAAO,OAAO;EAC3D,MAAM,UAAW,KAAsD,QACpE;EACH,MAAM,SACL,CAAC,UAAU,eAAe,CAAC,UAAU,WAAW,UAC7C,mBAAmB,OAAO,IAC1B,KAAA;EACJ,MAAM,WAAW,aAAa,KAAA,GAAW,QAAQ,WAAW;EAC5D,IAAI;GACH,MAAM,QAAQ,MAAM,YACnB,WACA,OACA,SAAS,SACT,QAAQ,KACT;GACA,OAAO,EACN,MAAM,2BAA2B,OAAO,WAAW,OAAO,KAAK,GAAG;IACjE;IACA,UAAU,OAAO,WAAW;IAC5B,cAAc,UAAU,gBAAgB,CAAC;GAC1C,CAAC,EACF;EACD,SAAS,OAAO;GACf,gBAAgB,OAAO,SAAS,OAAO;EACxC,UAAU;GACT,SAAS,QAAQ;EAClB;CACD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro-shared-BT45auwR.js","names":[],"sources":["../src/astro-shared.ts"],"sourcesContent":["import type { RootStore } from \"atom.io/internal\"\nimport { IMPLICIT, Store } from \"atom.io/internal\"\n\nimport type { Component, VNode } from \"./core.ts\"\nimport { jsx } from \"./jsx-runtime.ts\"\n\nexport interface AstroApplicationContext {\n\t/** Whether the application still represents its initial server snapshot. */\n\treadonly canResume: boolean\n\treadonly signal: AbortSignal\n\tonCleanup(cleanup: () => void): void\n\t/** Initialize a resource once for this application lifetime. */\n\tget<T>(key: unknown, initialize: () => T): T\n}\nexport interface AstroStoreContext {\n\t/** Shared across default islands; private for explicitly isolated islands. */\n\tapplication: AstroApplicationContext\n\t/** The browser island host; undefined during server rendering. */\n\telement: HTMLElement | undefined\n\t/** Aborted when preparation is cancelled or the island is released. */\n\tsignal: AbortSignal\n\t/** Release resources even if preparation or rendering fails. */\n\tonCleanup(cleanup: () => void): void\n}\nexport type AstroStoreFactory<P = Record<string, any>> = (\n\tprops: P,\n\tcontext: AstroStoreContext,\n) => RootStore | Promise<RootStore>\nexport type AstroStorePreparation<P = Record<string, any>> = (\n\tstore: RootStore,\n\tprops: P,\n\tcontext: AstroStoreContext,\n) => void | Promise<void>\nexport type Island<P = any> = Component<P> & {\n\tspa?: boolean\n\t/** Opt into a private island store instead of the shared application store. */\n\tisolate?: boolean\n\tcreateStore?: AstroStoreFactory<P>\n\tprepareStore?: AstroStorePreparation<P>\n}\nexport async function islandStore(\n\tcomponent: Island,\n\tprops: Record<string, any>,\n\tcontext: AstroStoreContext,\n\tshared?: RootStore,\n): Promise<RootStore> {\n\tconst store = await (component.createStore?.(props, context) ??\n\t\tshared ??\n\t\t(new Store(\n\t\t\t{ name: `spa-island`, lifespan: `ephemeral`, isProduction: true },\n\t\t\tIMPLICIT.STORE,\n\t\t) as RootStore))\n\tcontext.signal.throwIfAborted()\n\tawait component.prepareStore?.(store, props, context)\n\tcontext.signal.throwIfAborted()\n\treturn store\n}\nexport function island(\n\tcomponent: Island,\n\tprops: Record<string, any>,\n\tslots: Record<string, string>,\n): VNode {\n\tconst children = Object.fromEntries(\n\t\tObject.entries(slots).map(([name, html]) => [\n\t\t\tname,\n\t\t\tjsx(`astro-slot`, {\n\t\t\t\tkey: html,\n\t\t\t\tname: name === `default` ? undefined : name,\n\t\t\t\tinnerHTML: html,\n\t\t\t}),\n\t\t]),\n\t)\n\treturn jsx(component, {\n\t\t...props,\n\t\tslots: children,\n\t\tchildren: children[`default`],\n\t})\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"astro-shared-BT45auwR.js","names":[],"sources":["../src/astro-shared.ts"],"sourcesContent":["import type { RootStore } from \"atom.io/internal\"\nimport { IMPLICIT, Store } from \"atom.io/internal\"\n\nimport type { Capability } from \"./capabilities.ts\"\nimport type { Component, VNode } from \"./core.ts\"\nimport { jsx } from \"./jsx-runtime.ts\"\n\nexport interface AstroApplicationContext {\n\t/** Whether the application still represents its initial server snapshot. */\n\treadonly canResume: boolean\n\treadonly signal: AbortSignal\n\tonCleanup(cleanup: () => void): void\n\t/** Initialize a resource once for this application lifetime. */\n\tget<T>(key: unknown, initialize: () => T): T\n}\nexport interface AstroStoreContext {\n\t/** Shared across default islands; private for explicitly isolated islands. */\n\tapplication: AstroApplicationContext\n\t/** The browser island host; undefined during server rendering. */\n\telement: HTMLElement | undefined\n\t/** Aborted when preparation is cancelled or the island is released. */\n\tsignal: AbortSignal\n\t/** Release resources even if preparation or rendering fails. */\n\tonCleanup(cleanup: () => void): void\n}\nexport type AstroStoreFactory<P = Record<string, any>> = (\n\tprops: P,\n\tcontext: AstroStoreContext,\n) => RootStore | Promise<RootStore>\nexport type AstroStorePreparation<P = Record<string, any>> = (\n\tstore: RootStore,\n\tprops: P,\n\tcontext: AstroStoreContext,\n) => void | Promise<void>\nexport type Island<P = any> = Component<P> & {\n\tspa?: boolean\n\t/** Capabilities are scoped to this island root on the server and client. */\n\tcapabilities?: readonly Capability[]\n\t/** Opt into a private island store instead of the shared application store. */\n\tisolate?: boolean\n\tcreateStore?: AstroStoreFactory<P>\n\tprepareStore?: AstroStorePreparation<P>\n}\nexport async function islandStore(\n\tcomponent: Island,\n\tprops: Record<string, any>,\n\tcontext: AstroStoreContext,\n\tshared?: RootStore,\n): Promise<RootStore> {\n\tconst store = await (component.createStore?.(props, context) ??\n\t\tshared ??\n\t\t(new Store(\n\t\t\t{ name: `spa-island`, lifespan: `ephemeral`, isProduction: true },\n\t\t\tIMPLICIT.STORE,\n\t\t) as RootStore))\n\tcontext.signal.throwIfAborted()\n\tawait component.prepareStore?.(store, props, context)\n\tcontext.signal.throwIfAborted()\n\treturn store\n}\nexport function island(\n\tcomponent: Island,\n\tprops: Record<string, any>,\n\tslots: Record<string, string>,\n): VNode {\n\tconst children = Object.fromEntries(\n\t\tObject.entries(slots).map(([name, html]) => [\n\t\t\tname,\n\t\t\tjsx(`astro-slot`, {\n\t\t\t\tkey: html,\n\t\t\t\tname: name === `default` ? undefined : name,\n\t\t\t\tinnerHTML: html,\n\t\t\t}),\n\t\t]),\n\t)\n\treturn jsx(component, {\n\t\t...props,\n\t\tslots: children,\n\t\tchildren: children[`default`],\n\t})\n}\n"],"mappings":";;;AA2CA,eAAsB,YACrB,WACA,OACA,SACA,QACqB;CACrB,MAAM,QAAQ,OAAO,UAAU,cAAc,OAAO,OAAO,KAC1D,UACC,IAAI,MACJ;EAAE,MAAM;EAAc,UAAU;EAAa,cAAc;CAAK,GAChE,SAAS,KACV;CACD,QAAQ,OAAO,eAAe;CAC9B,MAAM,UAAU,eAAe,OAAO,OAAO,OAAO;CACpD,QAAQ,OAAO,eAAe;CAC9B,OAAO;AACR;AACA,SAAgB,OACf,WACA,OACA,OACQ;CACR,MAAM,WAAW,OAAO,YACvB,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAC3C,MACA,IAAI,cAAc;EACjB,KAAK;EACL,MAAM,SAAS,YAAY,KAAA,IAAY;EACvC,WAAW;CACZ,CAAC,CACF,CAAC,CACF;CACA,OAAO,IAAI,WAAW;EACrB,GAAG;EACH,OAAO;EACP,UAAU,SAAS;CACpB,CAAC;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as Component, t as Capability } from "./capabilities-yC9TsHDI.js";
|
|
2
2
|
import { RootStore } from "atom.io/internal";
|
|
3
3
|
interface AstroApplicationContext {
|
|
4
4
|
/** Whether the application still represents its initial server snapshot. */
|
|
@@ -22,10 +22,12 @@ type AstroStoreFactory<P = Record<string, any>> = (props: P, context: AstroStore
|
|
|
22
22
|
type AstroStorePreparation<P = Record<string, any>> = (store: RootStore, props: P, context: AstroStoreContext) => void | Promise<void>;
|
|
23
23
|
type Island<P = any> = Component<P> & {
|
|
24
24
|
spa?: boolean;
|
|
25
|
+
/** Capabilities are scoped to this island root on the server and client. */
|
|
26
|
+
capabilities?: readonly Capability[];
|
|
25
27
|
/** Opt into a private island store instead of the shared application store. */
|
|
26
28
|
isolate?: boolean;
|
|
27
29
|
createStore?: AstroStoreFactory<P>;
|
|
28
30
|
prepareStore?: AstroStorePreparation<P>;
|
|
29
31
|
};
|
|
30
32
|
export { Island as a, AstroStorePreparation as i, AstroStoreContext as n, AstroStoreFactory as r, AstroApplicationContext as t };
|
|
31
|
-
//# sourceMappingURL=astro-shared-
|
|
33
|
+
//# sourceMappingURL=astro-shared-DyzbUi6c.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-shared-DyzbUi6c.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
|
-
import { a as Island, i as AstroStorePreparation, n as AstroStoreContext, r as AstroStoreFactory, t as AstroApplicationContext } from "./astro-shared-DkZaqX7L.js";
|
|
2
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-DyzbUi6c.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
|
@@ -71,7 +71,13 @@ function enqueue(scope, run) {
|
|
|
71
71
|
root._queue.add(run);
|
|
72
72
|
}
|
|
73
73
|
function createRoot(options = {}, server = false) {
|
|
74
|
+
const capabilities = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const capability of options.capabilities ?? []) {
|
|
76
|
+
if (capabilities.has(capability.namespace)) throw new Error(`spa: duplicate capability ${capability.namespace}`);
|
|
77
|
+
capabilities.set(capability.namespace, capability);
|
|
78
|
+
}
|
|
74
79
|
const root = {
|
|
80
|
+
_capabilities: capabilities,
|
|
75
81
|
_store: options.store ?? IMPLICIT.STORE,
|
|
76
82
|
_prefix: options.idPrefix ?? `w${serial++}`,
|
|
77
83
|
_id: 0,
|
|
@@ -226,6 +232,62 @@ function plain(value) {
|
|
|
226
232
|
if (value == null || typeof value === `boolean`) return ``;
|
|
227
233
|
return String(value);
|
|
228
234
|
}
|
|
229
|
-
|
|
235
|
+
// src/capabilities.ts
|
|
236
|
+
function capabilityNamespace(key) {
|
|
237
|
+
const colon = key.indexOf(`:`);
|
|
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
|
+
};
|
|
290
|
+
}
|
|
291
|
+
export { within as C, useValue as S, useRef as _, createScope as a, useTimeline as b, invalidate as c, onMount as d, owner as f, useId as g, untrack as h, createRoot as i, observe as l, resolveStateToken as m, capabilityProps as n, dispose as o, plain as p, validateCapabilities as r, fail as s, capabilityNamespace as t, onCleanup as u, useSetter as v, useTransaction as x, useStore as y };
|
|
230
292
|
|
|
231
|
-
//# sourceMappingURL=
|
|
293
|
+
//# sourceMappingURL=capabilities-BuZUQpiD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities-BuZUQpiD.js","names":[],"sources":["../src/core.ts","../src/capabilities.ts"],"sourcesContent":["import type {\n\tReadableFamilyToken,\n\tReadableToken,\n\tRegularAtomFamilyToken,\n\tRegularAtomToken,\n\tSetter,\n\tTimelineFamilyToken,\n\tTimelineManageable,\n\tTimelineToken,\n\tTransactionToken,\n\tViewOf,\n\tWritableFamilyToken,\n\tWritableToken,\n} from \"atom.io\"\nimport type { Canonical } from \"atom.io/foundations/canonical\"\nimport type { RootStore } from \"atom.io/internal\"\nimport {\n\tactUponStore,\n\tclearTimelineInStore,\n\tfindInStore,\n\tfindTimelineInStore,\n\tgetFromStore,\n\tgetTimelineTransactionAtHead,\n\tIMPLICIT,\n\tinspectTimelineInStore,\n\tsetIntoStore,\n\tsubscribeToState,\n\tsubscribeToTimeline,\n\ttimeTravel,\n\ttimeTravelTransactionGroupInStore,\n} from \"atom.io/internal\"\n\nimport type { Capability } from \"./capabilities.ts\"\n\nexport type Cleanup = () => void\n// A callable interface permits the recursive Child union. A type alias does not.\n/* oxlint-disable typescript/prefer-function-type -- A callable interface is required for recursive Child. */\nexport interface Accessor<T> {\n\t(): T\n}\n/* oxlint-enable typescript/prefer-function-type */\nexport type Component<P = any> = (props: P) => Child\nexport interface VNode {\n\ttype: string | Component | null\n\tprops: Record<string, any>\n}\nexport type Child =\n\t| VNode\n\t| string\n\t| number\n\t| bigint\n\t| boolean\n\t| null\n\t| undefined\n\t| readonly Child[]\n\t| Accessor<Child>\nexport interface RootOptions {\n\tcapabilities?: readonly Capability[]\n\tstore?: RootStore\n\tidPrefix?: string\n\tonError?: (error: unknown) => void\n}\nexport interface Scope {\n\t_root: Root\n\t_parent?: Scope | undefined\n\t_cleanups: Set<Cleanup | Scope>\n\t_updates: Cleanup[]\n\t_dead: boolean\n}\nexport interface Root extends Scope {\n\t_capabilities: Map<string, Capability>\n\t_store: RootStore\n\t_prefix: string\n\t_id: number\n\t_queue: Set<Cleanup>\n\t_mounts: Cleanup[] | undefined\n\tflush: Cleanup\n\terror: (error: unknown) => void\n}\n\nexport let owner: Scope | undefined\ntype Subscribe = (notify: Cleanup) => Cleanup\nlet tracking: ((subscribe: Subscribe) => void) | undefined\nlet serial = 0\n\nexport function within<T>(scope: Scope, run: () => T): T {\n\tconst previous = owner\n\towner = scope\n\ttry {\n\t\treturn run()\n\t} finally {\n\t\towner = previous\n\t}\n}\nexport function untrack<T>(run: () => T): T {\n\tconst previous = tracking\n\ttracking = undefined\n\ttry {\n\t\treturn run()\n\t} finally {\n\t\ttracking = previous\n\t}\n}\nexport function createScope(parent?: Scope): Scope {\n\tconst child: Scope = {\n\t\t_root: parent?._root as Root,\n\t\t_parent: parent,\n\t\t_cleanups: new Set(),\n\t\t_updates: [],\n\t\t_dead: false,\n\t}\n\tparent?._cleanups.add(child)\n\treturn child\n}\nexport function fail(scope: Scope, error: unknown): never {\n\ttry {\n\t\tdispose(scope)\n\t} catch (cleanup) {\n\t\tthrow new AggregateError([error, cleanup])\n\t}\n\tthrow error\n}\nexport function dispose(scope: Scope): void {\n\tif (scope._dead) return\n\tscope._dead = true\n\tconst errors: unknown[] = []\n\tfor (const cleanup of [...scope._cleanups].reverse()) {\n\t\ttry {\n\t\t\ttypeof cleanup === `function` ? cleanup() : dispose(cleanup)\n\t\t} catch (error) {\n\t\t\terrors.push(error)\n\t\t}\n\t}\n\tscope._parent?._cleanups.delete(scope)\n\tscope._cleanups.clear()\n\tscope._updates.length = 0\n\tif (errors.length) throw new AggregateError(errors)\n}\nexport function invalidate(scope: Scope): void {\n\tfor (const run of scope._updates) enqueue(scope, run)\n\tfor (const child of scope._cleanups)\n\t\tif (typeof child !== `function`) invalidate(child)\n}\nfunction enqueue(scope: Scope, run: Cleanup): void {\n\tif (scope._dead) return\n\tconst root = scope._root\n\tif (!root._queue.size)\n\t\tqueueMicrotask(() => {\n\t\t\ttry {\n\t\t\t\troot.flush()\n\t\t\t} catch (error) {\n\t\t\t\troot.error(error)\n\t\t\t}\n\t\t})\n\troot._queue.add(run)\n}\nexport function createRoot(options: RootOptions = {}, server = false): Root {\n\tconst capabilities = new Map<string, Capability>()\n\tfor (const capability of options.capabilities ?? []) {\n\t\tif (capabilities.has(capability.namespace))\n\t\t\tthrow new Error(`spa: duplicate capability ${capability.namespace}`)\n\t\tcapabilities.set(capability.namespace, capability)\n\t}\n\tconst root = {\n\t\t_capabilities: capabilities,\n\t\t_store: options.store ?? IMPLICIT.STORE,\n\t\t_prefix: options.idPrefix ?? `w${serial++}`,\n\t\t_id: 0,\n\t\t...createScope(),\n\t\t_queue: new Set(),\n\t\t_mounts: server ? undefined : [],\n\t} as unknown as Root\n\troot._root = root\n\troot.error =\n\t\toptions.onError ??\n\t\t((error) => {\n\t\t\tthrow error\n\t\t})\n\troot.flush = () => {\n\t\ttry {\n\t\t\tlet passes = 0\n\t\t\twhile (root._queue.size || root._mounts!.length) {\n\t\t\t\tif (import.meta.env.DEV && ++passes > 100)\n\t\t\t\t\tthrow new Error(`spa: update loop`)\n\t\t\t\tfor (const run of [...root._queue]) if (root._queue.delete(run)) run()\n\t\t\t\tfor (const run of root._mounts!.splice(0)) run()\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfail(root, error)\n\t\t}\n\t}\n\treturn root\n}\n/** Return the atom.io store selected by the current root. */\nexport function useStore(): RootStore {\n\treturn owner!._root._store\n}\nexport function onCleanup(cleanup: Cleanup): void {\n\towner!._cleanups.add(cleanup)\n}\nexport function onMount(run: Cleanup): void {\n\tconst scope = owner!\n\tscope._root._mounts?.push(() => {\n\t\tif (!scope._dead)\n\t\t\twithin(scope, () => {\n\t\t\t\tuntrack(run)\n\t\t\t})\n\t})\n}\nexport function useId(): string {\n\tconst root = owner!._root\n\treturn `${root._prefix}-${root._id++}`\n}\n\nexport function observe<T>(\n\tscope: Scope,\n\tread: Accessor<T>,\n\tapply: (value: T) => void,\n): void {\n\tconst subscriptions = new Map<Subscribe, Cleanup>()\n\tconst run = () => {\n\t\tif (scope._dead) return\n\t\tconst used = new Set<Subscribe>()\n\t\tconst previous = tracking\n\t\ttracking = (subscribe) => {\n\t\t\tused.add(subscribe)\n\t\t\tif (!subscriptions.has(subscribe))\n\t\t\t\tsubscriptions.set(\n\t\t\t\t\tsubscribe,\n\t\t\t\t\tsubscribe(() => {\n\t\t\t\t\t\tenqueue(scope, run)\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t}\n\t\tlet value: T\n\t\ttry {\n\t\t\tvalue = within(scope, read)\n\t\t} finally {\n\t\t\ttracking = previous\n\t\t\tfor (const [subscribe, unsubscribe] of subscriptions)\n\t\t\t\tif (!used.has(subscribe)) {\n\t\t\t\t\tunsubscribe()\n\t\t\t\t\tsubscriptions.delete(subscribe)\n\t\t\t\t}\n\t\t}\n\t\tuntrack(() => {\n\t\t\tapply(value)\n\t\t})\n\t}\n\tscope._updates.push(run)\n\tscope._cleanups.add(() => {\n\t\tscope._root._queue.delete(run)\n\t\tfor (const unsubscribe of subscriptions.values()) unsubscribe()\n\t})\n\trun()\n}\n\n/** Resolve a fixed family key in the current owner's store. */\nexport function resolveStateToken(token: any, key?: Canonical): any {\n\tconst store = owner!._root._store\n\treturn token.type.endsWith(`_family`) ? findInStore(store, token, key!) : token\n}\n\n/** Capture a token for this instance. Change the component key to change its token. */\nexport function useValue<T, E = never>(\n\ttoken: ReadableToken<T, any, E>,\n): Accessor<ViewOf<T | E>>\nexport function useValue<T, K extends Canonical, E = never>(\n\tfamily: ReadableFamilyToken<T, K, E>,\n\tkey: NoInfer<K>,\n): Accessor<ViewOf<T | E>>\nexport function useValue(token: any, key?: Canonical): Accessor<any> {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\tconst subscribe: Subscribe = (notify) =>\n\t\tsubscribeToState(store, token, `spa:${serial++}`, notify)\n\treturn () => {\n\t\tconst value = getFromStore(store, token)\n\t\ttracking?.(subscribe)\n\t\treturn value\n\t}\n}\nexport function useSetter<T>(\n\ttoken: WritableToken<T, any, any>,\n): (value: T | Setter<T>) => void\nexport function useSetter<T, K extends Canonical>(\n\tfamily: WritableFamilyToken<T, K, any>,\n\tkey: NoInfer<K>,\n): (value: T | Setter<T>) => void\nexport function useSetter(token: any, key?: Canonical): (value: any) => void {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\treturn (value) => {\n\t\tsetIntoStore(store, token, value)\n\t}\n}\nexport function useTransaction<F extends (...args: any[]) => any>(\n\ttoken: TransactionToken<F>,\n): (...args: Parameters<F>) => ReturnType<F> {\n\treturn actUponStore(owner!._root._store, token, `spa:${serial++}`)\n}\n\nconst refs = new WeakMap<RootStore, Map<string, object>>()\nexport function useRef<E extends Element>(\n\ttoken: RegularAtomToken<E | null>,\n): (element: E | null) => void\nexport function useRef<E extends Element, K extends Canonical>(\n\tfamily: RegularAtomFamilyToken<E | null, K>,\n\tkey: NoInfer<K>,\n): (element: E | null) => void\nexport function useRef<E extends Element>(\n\ttoken: any,\n\tkey?: Canonical,\n): (element: E | null) => void {\n\ttoken = resolveStateToken(token, key)\n\tconst store = owner!._root._store\n\tconst owners = refs.get(store) ?? new Map<string, object>()\n\trefs.set(store, owners)\n\tconst identity = {}\n\tlet held: E | null = null\n\treturn (element) => {\n\t\tif (element) {\n\t\t\theld = element\n\t\t\towners.set(token.key, identity)\n\t\t\tsetIntoStore(store, token, element)\n\t\t} else if (owners.get(token.key) === identity) {\n\t\t\towners.delete(token.key)\n\t\t\tif (getFromStore(store, token) === held) setIntoStore(store, token, null)\n\t\t\theld = null\n\t\t}\n\t}\n}\nexport interface TimelineValue {\n\tat: number\n\tlength: number\n\tundo(): void\n\tredo(): void\n\tclear(): void\n\tundoTransaction?: Cleanup\n\tredoTransaction?: Cleanup\n}\nexport function useTimeline<M extends TimelineManageable>(\n\ttoken: TimelineToken<M>,\n): Accessor<TimelineValue>\nexport function useTimeline<K extends Canonical, M extends TimelineManageable>(\n\tfamily: TimelineFamilyToken<K, M>,\n\tkey: NoInfer<K>,\n): Accessor<TimelineValue>\nexport function useTimeline(\n\ttoken: any,\n\tkey?: Canonical,\n): Accessor<TimelineValue> {\n\tconst store = owner!._root._store\n\tif (token.type === `timeline_family`)\n\t\ttoken = findTimelineInStore(store, token, key!)\n\tconst subscribe: Subscribe = (notify) =>\n\t\tsubscribeToTimeline(store, token, `spa:${serial++}`, notify)\n\tconst controls = {\n\t\tundo: () => {\n\t\t\ttimeTravel(store, `undo`, token)\n\t\t},\n\t\tredo: () => {\n\t\t\ttimeTravel(store, `redo`, token)\n\t\t},\n\t\tclear: () => {\n\t\t\tclearTimelineInStore(store, token)\n\t\t},\n\t}\n\treturn () => {\n\t\tconst value: TimelineValue = {\n\t\t\t...inspectTimelineInStore(store, token),\n\t\t\t...controls,\n\t\t}\n\t\ttracking?.(subscribe)\n\t\tfor (const direction of [`undo`, `redo`] as const) {\n\t\t\tconst group = getTimelineTransactionAtHead(\n\t\t\t\tstore.timelines.get(token.key)!,\n\t\t\t\tdirection,\n\t\t\t)\n\t\t\tif (group)\n\t\t\t\tvalue[`${direction}Transaction`] = () =>\n\t\t\t\t\ttimeTravelTransactionGroupInStore(store, direction, group)\n\t\t}\n\t\treturn value\n\t}\n}\n\nexport function plain(value: Child): string {\n\tif (typeof value === `function`) return plain(value())\n\tif (Array.isArray(value)) return value.map(plain).join(``)\n\tif (value == null || typeof value === `boolean`) return ``\n\tif (import.meta.env.DEV && typeof value === `object`)\n\t\tthrow new Error(`spa: text required`)\n\t// oxlint-disable-next-line typescript/no-base-to-string -- Valid text children are primitives here; development rejects malformed object children.\n\treturn String(value)\n}\n","import type { Cleanup, Scope } from \"./core.ts\"\n\n/** Native renderers expose property access without importing capability engines. */\nexport interface CapabilityTarget {\n\tkind: string\n\tnode: unknown\n\tread?(key: string): unknown\n\twrite?(key: string, value: unknown): void\n\tlisten?(event: string, listener: () => void): Cleanup\n}\nexport interface CapabilityBinding {\n\tupdate(props: Record<string, unknown>): void\n\tdispose(): void\n}\nexport interface Capability {\n\tnamespace: string\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): (props: Record<string, any>) => Record<string, any> {\n\tconst bindings = new Map<string, CapabilityBinding>()\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\tnative[key] = props[key]\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}\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\tbinding.dispose()\n\t\t\t}\n\t\treturn native\n\t}\n}\n"],"mappings":";;AAgFA,IAAW;AAEX,IAAI;AACJ,IAAI,SAAS;AAEb,SAAgB,OAAU,OAAc,KAAiB;CACxD,MAAM,WAAW;CACjB,QAAQ;CACR,IAAI;EACH,OAAO,IAAI;CACZ,UAAU;EACT,QAAQ;CACT;AACD;AACA,SAAgB,QAAW,KAAiB;CAC3C,MAAM,WAAW;CACjB,WAAW,KAAA;CACX,IAAI;EACH,OAAO,IAAI;CACZ,UAAU;EACT,WAAW;CACZ;AACD;AACA,SAAgB,YAAY,QAAuB;CAClD,MAAM,QAAe;EACpB,OAAO,QAAQ;EACf,SAAS;EACT,2BAAW,IAAI,IAAI;EACnB,UAAU,CAAC;EACX,OAAO;CACR;CACA,QAAQ,UAAU,IAAI,KAAK;CAC3B,OAAO;AACR;AACA,SAAgB,KAAK,OAAc,OAAuB;CACzD,IAAI;EACH,QAAQ,KAAK;CACd,SAAS,SAAS;EACjB,MAAM,IAAI,eAAe,CAAC,OAAO,OAAO,CAAC;CAC1C;CACA,MAAM;AACP;AACA,SAAgB,QAAQ,OAAoB;CAC3C,IAAI,MAAM,OAAO;CACjB,MAAM,QAAQ;CACd,MAAM,SAAoB,CAAC;CAC3B,KAAK,MAAM,WA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