@atom.io/spa 0.0.3 → 0.0.4
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 +89 -45
- package/README.mdx +11 -6
- package/dist/astro-application.d.ts +1 -1
- package/dist/astro-client.d.ts +1 -1
- package/dist/astro-client.js +4 -4
- package/dist/astro-client.js.map +1 -1
- package/dist/{astro-shared-BkWvVZWZ.d.ts → astro-shared-CYSRrRr8.d.ts} +2 -2
- package/dist/{astro-shared-BkWvVZWZ.d.ts.map → astro-shared-CYSRrRr8.d.ts.map} +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/{capabilities-CFP-HIuY.d.ts → capabilities-D3HObAIy.d.ts} +13 -11
- package/dist/{capabilities-CFP-HIuY.d.ts.map → capabilities-D3HObAIy.d.ts.map} +1 -1
- package/dist/client.min.js +1 -1
- package/dist/{core-DCmqLZQP.js → core-Bl1Ec1hY.js} +28 -22
- package/dist/core-Bl1Ec1hY.js.map +1 -0
- package/dist/development/astro-client.js +4 -4
- package/dist/development/astro-client.js.map +1 -1
- package/dist/development/{core-p9vciX9C.js → core-DZFaOyTO.js} +28 -22
- package/dist/development/core-DZFaOyTO.js.map +1 -0
- package/dist/development/{dom-Ci1XvbVJ.js → dom-Dwa2SFTn.js} +2 -2
- package/dist/development/{dom-Ci1XvbVJ.js.map → dom-Dwa2SFTn.js.map} +1 -1
- package/dist/development/index.js +4 -4
- package/dist/development/konva.js +1 -1
- package/dist/development/motion.js +1 -1
- package/dist/development/renderer.js +1 -1
- package/dist/development/server.js +1 -1
- package/dist/development/{src-DG0xjuS5.js → src-BUtG4BgX.js} +4 -4
- package/dist/development/src-BUtG4BgX.js.map +1 -0
- package/dist/development/three.js +1 -1
- package/dist/{dom-dHQM0O7Q.js → dom-Cfj3GtQK.js} +2 -2
- package/dist/{dom-dHQM0O7Q.js.map → dom-Cfj3GtQK.js.map} +1 -1
- package/dist/{index-CJJXcKaw.d.ts → index-YRZ79lN5.d.ts} +3 -3
- package/dist/{index-CJJXcKaw.d.ts.map → index-YRZ79lN5.d.ts.map} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/{jsx-runtime-CREZYKDC.d.ts → jsx-runtime-Q-UBV97Y.d.ts} +2 -2
- package/dist/{jsx-runtime-CREZYKDC.d.ts.map → jsx-runtime-Q-UBV97Y.d.ts.map} +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/konva.d.ts +3 -3
- package/dist/konva.js +1 -1
- package/dist/motion.d.ts +1 -1
- package/dist/motion.js +1 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.js +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/size.json +8 -8
- package/dist/{src-DCQa6qxs.js → src-DvkUMuNW.js} +4 -4
- package/dist/src-DvkUMuNW.js.map +1 -0
- package/dist/three.d.ts +3 -3
- package/dist/three.js +1 -1
- package/package.json +3 -3
- package/src/astro-client.ts +3 -3
- package/src/core.ts +39 -39
- package/src/index.ts +2 -2
- package/src/use-loadable.ts +3 -3
- package/dist/core-DCmqLZQP.js.map +0 -1
- package/dist/development/core-p9vciX9C.js.map +0 -1
- package/dist/development/src-DG0xjuS5.js.map +0 -1
- package/dist/src-DCQa6qxs.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The npm package is named @atom.io/spa. Its browser runtime, Vite compiler, serve
|
|
|
10
10
|
|
|
11
11
|
```tsx
|
|
12
12
|
import type { VNode } from "@atom.io/spa"
|
|
13
|
-
import { useId, useRef, useSetter
|
|
13
|
+
import { useGetter, useId, useRef, useSetter } from "@atom.io/spa"
|
|
14
14
|
import { atom } from "atom.io"
|
|
15
15
|
|
|
16
16
|
const pointAtom = atom<{ x: number; y: number }>({
|
|
@@ -23,7 +23,7 @@ const circleAtom = atom<SVGCircleElement | null>({
|
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
export function PointEditor(): VNode {
|
|
26
|
-
const
|
|
26
|
+
const getPoint = useGetter(pointAtom)
|
|
27
27
|
const setPoint = useSetter(pointAtom)
|
|
28
28
|
const circle = useRef(circleAtom)
|
|
29
29
|
const id = useId()
|
|
@@ -31,10 +31,10 @@ export function PointEditor(): VNode {
|
|
|
31
31
|
<section aria-labelledby={id}>
|
|
32
32
|
<h2 id={id}>Point</h2>
|
|
33
33
|
<svg viewBox="0 0 100 100">
|
|
34
|
-
<circle ref={circle} cx={
|
|
34
|
+
<circle ref={circle} cx={getPoint().x} cy={getPoint().y} r="3" />
|
|
35
35
|
</svg>
|
|
36
36
|
<output>
|
|
37
|
-
{
|
|
37
|
+
{getPoint().x}, {getPoint().y}
|
|
38
38
|
</output>
|
|
39
39
|
<button
|
|
40
40
|
onClick={() => {
|
|
@@ -49,7 +49,7 @@ export function PointEditor(): VNode {
|
|
|
49
49
|
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
The
|
|
52
|
+
Name the getter and setter after the atom: pointAtom uses getPoint and setPoint. The getPoint getter returns the current object. Each JSX attribute reads its coordinate when evaluated. Both bindings depend on the point atom, and unchanged primitive results skip DOM writes. Reads during setup are snapshots; reads in event handlers are current and untracked. Shared derived state belongs in atom.io selectors.
|
|
53
53
|
|
|
54
54
|
## Vite
|
|
55
55
|
|
|
@@ -95,9 +95,9 @@ The development plugin keeps SPA and atom.io outside dependency prebundling so r
|
|
|
95
95
|
| API | Contract |
|
|
96
96
|
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
97
97
|
| useLoadable(token, fallback?) | Return a tracked accessor for loading, last-observed values, and handled errors. |
|
|
98
|
-
|
|
|
98
|
+
| useGetter(token) | Return a live accessor for an atom or selector, bound to this instance's store. |
|
|
99
99
|
| useSetter(token) | Return a stable atom.io writer. |
|
|
100
|
-
| useTimeline(token) | Return
|
|
100
|
+
| useTimeline(token) | Return a stable object with getCursor/getLength readers, undo/redo/clear commands, and transaction-group controls. |
|
|
101
101
|
| useTransaction(token) | Bind an atom.io transaction, preserving its arguments and result. |
|
|
102
102
|
| useRef(token) | Return an attachment callback for a nullable element atom. Clear it only while this attachment still owns the reference. |
|
|
103
103
|
| useId() | Allocate an instance-stable ID using the root's prefix. |
|
|
@@ -107,6 +107,55 @@ The development plugin keeps SPA and atom.io outside dependency prebundling so r
|
|
|
107
107
|
|
|
108
108
|
Call setup helpers synchronously during component setup or owned mount callbacks. Capture their results for event handlers. Tokens are fixed for an instance; use an application key in a reactive child expression to replace a component when its token changes. Component props stay live when read through the props object; destructuring during setup takes a snapshot.
|
|
109
109
|
|
|
110
|
+
useTimeline returns a TimelineControls object whose methods can be destructured during setup. getCursor and getLength read the current cursor position and recorded checkpoint count; calls inside JSX subscribe the computation, while calls during setup or in event handlers are untracked. undo, redo, and clear are stable commands. history.getTransaction() is a tracked reader that returns an object with optional undo and redo callbacks for the adjacent transaction groups. At a cursor between transactions, both callbacks may be present and target different groups. A missing callback means no transaction group is available in that direction; the reader returns an empty object when neither is available. Calling a returned callback travels its captured group across participating timelines where it remains at the relevant history head, leaving diverged timelines unchanged. Use history.getTransaction().undo?.() or history.getTransaction().redo?.() to retrieve and invoke the current action together.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import type { VNode } from "@atom.io/spa"
|
|
114
|
+
import { useGetter, useTimeline, useTransaction } from "@atom.io/spa"
|
|
115
|
+
import { atom, timeline, transaction } from "atom.io"
|
|
116
|
+
|
|
117
|
+
const countAtom = atom<number>({ key: `count`, default: 0 })
|
|
118
|
+
const historyTimeline = timeline({ key: `history`, scope: [countAtom] })
|
|
119
|
+
const incrementTransaction = transaction<() => void>({
|
|
120
|
+
key: `increment`,
|
|
121
|
+
do: ({ get, set }) => {
|
|
122
|
+
set(countAtom, get(countAtom) + 1)
|
|
123
|
+
},
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
export function TimelineExample(): VNode {
|
|
127
|
+
const getCount = useGetter(countAtom)
|
|
128
|
+
const increment = useTransaction(incrementTransaction)
|
|
129
|
+
const history = useTimeline(historyTimeline)
|
|
130
|
+
return (
|
|
131
|
+
<section>
|
|
132
|
+
<output>
|
|
133
|
+
Count: {getCount()} (history: {history.getCursor()}/{history.getLength()}
|
|
134
|
+
)
|
|
135
|
+
</output>
|
|
136
|
+
<button onClick={increment}>Increment</button>
|
|
137
|
+
<button
|
|
138
|
+
disabled={history.getTransaction().undo === undefined}
|
|
139
|
+
onClick={() => {
|
|
140
|
+
history.getTransaction().undo?.()
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
Undo transaction
|
|
144
|
+
</button>
|
|
145
|
+
<button
|
|
146
|
+
disabled={history.getTransaction().redo === undefined}
|
|
147
|
+
onClick={() => {
|
|
148
|
+
history.getTransaction().redo?.()
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
Redo transaction
|
|
152
|
+
</button>
|
|
153
|
+
</section>
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
|
|
110
159
|
Arrays support keyed components and elements. Reordering preserves instances and nodes; removed ranges release subscriptions, events, refs, and cleanup callbacks. Application keys must be unique among siblings. Explicit keys are compared as strings; unkeyed positions occupy a separate namespace. Unkeyed arrays use positions. A key identifies a row in a reactive child collection; it is not an independent reactive binding.
|
|
111
160
|
|
|
112
161
|
HTML and SVG use native DOM properties and attributes, plus className/htmlFor aliases. Events use onClick/onInput-style names, with Capture suffixes and onDoubleClick support. Styles are CSS strings. Mutable atom values still invalidate their consumers; project primitive fields for precise DOM writes. Refs attach once per element instance.
|
|
@@ -140,15 +189,15 @@ export function InspectCount(): VNode {
|
|
|
140
189
|
|
|
141
190
|
```
|
|
142
191
|
|
|
143
|
-
Capture the store during component setup or an owned onMount callback, then pass it to store-aware atom.io operations or integrations. Getting the store creates no subscription. Direct reads such as getFromStore do not participate in SPA's dependency tracking;
|
|
192
|
+
Capture the store during component setup or an owned onMount callback, then pass it to store-aware atom.io operations or integrations. Getting the store creates no subscription. Direct reads such as getFromStore do not participate in SPA's dependency tracking; useGetter and useLoadable provide tracked reads. The returned object is a store, not a Silo or a new wrapper.
|
|
144
193
|
|
|
145
194
|
## Families
|
|
146
195
|
|
|
147
|
-
|
|
196
|
+
useGetter, useSetter, useRef, and useTimeline accept a family token followed by its key. useLoadable accepts a family, key, and optional fallback. Keys retain their declared types, including tuples, numbers, booleans, and null. Members resolve in the component's store, so isolated roots can use the same family tokens independently.
|
|
148
197
|
|
|
149
198
|
```tsx
|
|
150
199
|
import type { VNode } from "@atom.io/spa"
|
|
151
|
-
import { useRef, useSetter, useTimeline
|
|
200
|
+
import { useGetter, useRef, useSetter, useTimeline } from "@atom.io/spa"
|
|
152
201
|
import { atomFamily, scopeFamily, timelineFamily } from "atom.io"
|
|
153
202
|
|
|
154
203
|
const countAtoms = atomFamily<number, string>({ key: `count`, default: 0 })
|
|
@@ -162,7 +211,7 @@ const historyTimelines = timelineFamily<string>({
|
|
|
162
211
|
})
|
|
163
212
|
|
|
164
213
|
export function FamilyCounter(props: { id: string }): VNode {
|
|
165
|
-
const
|
|
214
|
+
const getCount = useGetter(countAtoms, props.id)
|
|
166
215
|
const setCount = useSetter(countAtoms, props.id)
|
|
167
216
|
const ref = useRef(buttonAtoms, props.id)
|
|
168
217
|
const history = useTimeline(historyTimelines, props.id)
|
|
@@ -174,14 +223,9 @@ export function FamilyCounter(props: { id: string }): VNode {
|
|
|
174
223
|
setCount((value) => value + 1)
|
|
175
224
|
}}
|
|
176
225
|
>
|
|
177
|
-
{
|
|
226
|
+
{getCount()}
|
|
178
227
|
</button>
|
|
179
|
-
<button
|
|
180
|
-
disabled={history().at === 0}
|
|
181
|
-
onClick={() => {
|
|
182
|
-
history().undo()
|
|
183
|
-
}}
|
|
184
|
-
>
|
|
228
|
+
<button disabled={history.getCursor() === 0} onClick={history.undo}>
|
|
185
229
|
Undo
|
|
186
230
|
</button>
|
|
187
231
|
</section>
|
|
@@ -304,7 +348,7 @@ AstroApplicationContext, AstroStoreContext, AstroStoreFactory, AstroStorePrepara
|
|
|
304
348
|
|
|
305
349
|
```tsx
|
|
306
350
|
import type { Child, VNode } from "@atom.io/spa"
|
|
307
|
-
import { onCleanup, useId, useSetter
|
|
351
|
+
import { onCleanup, useGetter, useId, useSetter } from "@atom.io/spa"
|
|
308
352
|
import { atom, Silo } from "atom.io"
|
|
309
353
|
import { IMPLICIT } from "atom.io/internal"
|
|
310
354
|
|
|
@@ -314,7 +358,7 @@ export default function Counter(props: {
|
|
|
314
358
|
children?: Child
|
|
315
359
|
slots?: Record<string, Child>
|
|
316
360
|
}): VNode {
|
|
317
|
-
const
|
|
361
|
+
const getCount = useGetter(countAtom)
|
|
318
362
|
const setCount = useSetter(countAtom)
|
|
319
363
|
const id = useId()
|
|
320
364
|
onCleanup(() => {
|
|
@@ -330,7 +374,7 @@ export default function Counter(props: {
|
|
|
330
374
|
setCount((value) => value + 1)
|
|
331
375
|
}}
|
|
332
376
|
>
|
|
333
|
-
{
|
|
377
|
+
{getCount()}
|
|
334
378
|
</button>
|
|
335
379
|
</section>
|
|
336
380
|
)
|
|
@@ -380,7 +424,7 @@ pnpm --filter @atom.io/spa readme:check
|
|
|
380
424
|
|
|
381
425
|
Breakage exercises the packed package in isolated, locked peer environments, including the coordinated atom.io workspace candidate. Until the first published release, Breakage reports a first-release baseline; these checks establish compatibility with the declared peers rather than a previous spa release. Coverage gates require 100% of statements, branches, functions, and lines across the package source.
|
|
382
426
|
|
|
383
|
-
Tonnage measures combined browser bundles containing SPA and atom.io, with shared modules counted once and unused exports removed. The synchronous recipes include atom creation,
|
|
427
|
+
Tonnage measures combined browser bundles containing SPA and atom.io, with shared modules counted once and unused exports removed. The synchronous recipes include atom creation, useGetter, useSetter, and JSX; the client recipe adds render, the hydration recipe adds hydrate, and the Astro recipe adds the browser island adapter. The async recipe uses useLoadable with render and useSetter. The family recipe includes keyed state, refs, and timeline controls, plus atomFamily, timelineFamily, and scopeFamily. SPA declares atom.io as a peer dependency; these consumer-app measurements include it in every total. Application components, Astro scheduling code, CSS, declarations, and source maps are excluded. The full-client gzip budget above remains a separate, SPA-only audit.
|
|
384
428
|
|
|
385
429
|
## Browser serving sizes including atom.io
|
|
386
430
|
|
|
@@ -390,11 +434,11 @@ Sizes are exact minified and level-9 gzip JavaScript byte counts. Declarations,
|
|
|
390
434
|
|
|
391
435
|
| Recipe | Entry | Minified JS | Gzip JS |
|
|
392
436
|
| -------------------------------- | --------------------------------- | ----------: | -------: |
|
|
393
|
-
| Family app with refs and history | `tonnage-recipes/family-app.ts` | 63,
|
|
394
|
-
| Async interactive client app | `tonnage-recipes/async-app.ts` | 42,121 B | 13,
|
|
395
|
-
| Interactive client app | `tonnage-recipes/client-app.ts` | 41,
|
|
396
|
-
| Hydrated interactive app | `tonnage-recipes/hydrated-app.ts` | 41,
|
|
397
|
-
| Interactive Astro island | `tonnage-recipes/astro-island.ts` | 48,
|
|
437
|
+
| Family app with refs and history | `tonnage-recipes/family-app.ts` | 63,696 B | 18,887 B |
|
|
438
|
+
| Async interactive client app | `tonnage-recipes/async-app.ts` | 42,121 B | 13,142 B |
|
|
439
|
+
| Interactive client app | `tonnage-recipes/client-app.ts` | 41,784 B | 12,981 B |
|
|
440
|
+
| Hydrated interactive app | `tonnage-recipes/hydrated-app.ts` | 41,785 B | 12,981 B |
|
|
441
|
+
| Interactive Astro island | `tonnage-recipes/astro-island.ts` | 48,153 B | 14,977 B |
|
|
398
442
|
|
|
399
443
|
Report maintained with [tonnage](https://github.com/jeremybanka/tonnage).
|
|
400
444
|
|
|
@@ -412,7 +456,7 @@ Import Stage, Layer, Group, Rect, Circle, Ellipse, Line, Text, Image, Path, Star
|
|
|
412
456
|
|
|
413
457
|
```tsx
|
|
414
458
|
import type { VNode } from "@atom.io/spa"
|
|
415
|
-
import {
|
|
459
|
+
import { useGetter, useSetter } from "@atom.io/spa"
|
|
416
460
|
import { Circle, Layer, Stage } from "@atom.io/spa/konva"
|
|
417
461
|
import { atom } from "atom.io"
|
|
418
462
|
|
|
@@ -421,14 +465,14 @@ const pointAtom = atom<{ x: number; y: number }>({
|
|
|
421
465
|
default: { x: 100, y: 100 },
|
|
422
466
|
})
|
|
423
467
|
export function Editor(): VNode {
|
|
424
|
-
const
|
|
468
|
+
const getPoint = useGetter(pointAtom)
|
|
425
469
|
const setPoint = useSetter(pointAtom)
|
|
426
470
|
return (
|
|
427
471
|
<Stage width={800} height={600}>
|
|
428
472
|
<Layer>
|
|
429
473
|
<Circle
|
|
430
|
-
x={
|
|
431
|
-
y={
|
|
474
|
+
x={getPoint().x}
|
|
475
|
+
y={getPoint().y}
|
|
432
476
|
radius={25}
|
|
433
477
|
fill="coral"
|
|
434
478
|
draggable
|
|
@@ -451,7 +495,7 @@ Import Canvas, Group, Mesh, PerspectiveCamera, AmbientLight, DirectionalLight, B
|
|
|
451
495
|
|
|
452
496
|
```tsx
|
|
453
497
|
import type { VNode } from "@atom.io/spa"
|
|
454
|
-
import {
|
|
498
|
+
import { useGetter } from "@atom.io/spa"
|
|
455
499
|
import {
|
|
456
500
|
AmbientLight,
|
|
457
501
|
BoxGeometry,
|
|
@@ -464,14 +508,14 @@ import { atom } from "atom.io"
|
|
|
464
508
|
|
|
465
509
|
const colorAtom = atom<string>({ key: `color`, default: `coral` })
|
|
466
510
|
export function Scene(): VNode {
|
|
467
|
-
const
|
|
511
|
+
const getColor = useGetter(colorAtom)
|
|
468
512
|
return (
|
|
469
513
|
<Canvas width={800} height={600}>
|
|
470
514
|
<AmbientLight intensity={0.5} />
|
|
471
515
|
<DirectionalLight position={[3, 3, 3]} />
|
|
472
516
|
<Mesh rotation={[0.3, 0.5, 0]}>
|
|
473
517
|
<BoxGeometry args={[1, 1, 1]} />
|
|
474
|
-
<MeshStandardMaterial color={
|
|
518
|
+
<MeshStandardMaterial color={getColor()} />
|
|
475
519
|
</Mesh>
|
|
476
520
|
</Canvas>
|
|
477
521
|
)
|
|
@@ -513,18 +557,18 @@ Use motion:initial, motion:animate, motion:exit, motion:transition, motion:while
|
|
|
513
557
|
|
|
514
558
|
```tsx
|
|
515
559
|
import type { VNode } from "@atom.io/spa"
|
|
516
|
-
import {
|
|
560
|
+
import { useGetter, useSetter } from "@atom.io/spa"
|
|
517
561
|
import { atom } from "atom.io"
|
|
518
562
|
|
|
519
563
|
const targetXAtom = atom<number>({ key: `targetX`, default: 0 })
|
|
520
564
|
export function MotionPanel(): VNode {
|
|
521
|
-
const
|
|
522
|
-
const
|
|
565
|
+
const getTargetX = useGetter(targetXAtom)
|
|
566
|
+
const setTargetX = useSetter(targetXAtom)
|
|
523
567
|
return (
|
|
524
568
|
<section>
|
|
525
569
|
<button
|
|
526
570
|
onClick={() => {
|
|
527
|
-
|
|
571
|
+
setTargetX((value) => (value === 0 ? 200 : 0))
|
|
528
572
|
}}
|
|
529
573
|
>
|
|
530
574
|
Move
|
|
@@ -532,7 +576,7 @@ export function MotionPanel(): VNode {
|
|
|
532
576
|
<sliding-panel
|
|
533
577
|
style="display: block; width: 120px; padding: 16px; background: coral"
|
|
534
578
|
motion:initial={{ opacity: 0, x: -100 }}
|
|
535
|
-
motion:animate={{ opacity: 1, x:
|
|
579
|
+
motion:animate={{ opacity: 1, x: getTargetX() }}
|
|
536
580
|
motion:transition={{ type: `spring`, stiffness: 180, damping: 22 }}
|
|
537
581
|
motion:whileHover={{ scale: 1.05 }}
|
|
538
582
|
motion:whileTap={{ scale: 0.95 }}
|
|
@@ -553,7 +597,7 @@ The same attributes animate numeric Konva properties and colors, or Three.js pos
|
|
|
553
597
|
|
|
554
598
|
```tsx
|
|
555
599
|
import type { VNode } from "@atom.io/spa"
|
|
556
|
-
import {
|
|
600
|
+
import { useGetter } from "@atom.io/spa"
|
|
557
601
|
import {
|
|
558
602
|
BoxGeometry,
|
|
559
603
|
Canvas,
|
|
@@ -568,12 +612,12 @@ const targetXAtom = atom<number>({
|
|
|
568
612
|
})
|
|
569
613
|
// Mount under a root with capabilities: [motionCapability()].
|
|
570
614
|
export function SpringCube(): VNode {
|
|
571
|
-
const
|
|
615
|
+
const getTargetX = useGetter(targetXAtom)
|
|
572
616
|
return (
|
|
573
617
|
<Canvas>
|
|
574
618
|
<Mesh
|
|
575
619
|
motion:initial={{ position: [-1, 0, 0], scale: 0 }}
|
|
576
|
-
motion:animate={{ position: [
|
|
620
|
+
motion:animate={{ position: [getTargetX(), 0, 0], scale: 1 }}
|
|
577
621
|
motion:transition={{ type: `spring`, stiffness: 180, damping: 22 }}
|
|
578
622
|
motion:whileHover={{ scale: 1.2 }}
|
|
579
623
|
motion:whileTap={{ scale: 0.8 }}
|
|
@@ -598,12 +642,12 @@ Declare motion:exit on an element, custom tag, Konva node, or Three.js scene nod
|
|
|
598
642
|
|
|
599
643
|
```tsx
|
|
600
644
|
import type { VNode } from "@atom.io/spa"
|
|
601
|
-
import {
|
|
645
|
+
import { useGetter, useSetter } from "@atom.io/spa"
|
|
602
646
|
import { atom } from "atom.io"
|
|
603
647
|
|
|
604
648
|
const visibleAtom = atom<boolean>({ key: `visible`, default: true })
|
|
605
649
|
export function DismissiblePanel(): VNode {
|
|
606
|
-
const
|
|
650
|
+
const getVisible = useGetter(visibleAtom)
|
|
607
651
|
const setVisible = useSetter(visibleAtom)
|
|
608
652
|
return (
|
|
609
653
|
<section>
|
|
@@ -614,7 +658,7 @@ export function DismissiblePanel(): VNode {
|
|
|
614
658
|
>
|
|
615
659
|
Toggle panel
|
|
616
660
|
</button>
|
|
617
|
-
{
|
|
661
|
+
{getVisible() && (
|
|
618
662
|
<sliding-panel
|
|
619
663
|
key="panel"
|
|
620
664
|
motion:initial={{ opacity: 0, y: 12 }}
|
package/README.mdx
CHANGED
|
@@ -2,6 +2,7 @@ import { Tonnage } from "tonnage";
|
|
|
2
2
|
import config from "./tonnage.config.ts";
|
|
3
3
|
import StoreExample from "./exhibits/store.tsx" with { type: "code" };
|
|
4
4
|
import Families from "./exhibits/families.tsx" with { type: "code" };
|
|
5
|
+
import TimelineExample from "./exhibits/timeline.tsx" with { type: "code" };
|
|
5
6
|
import LoadableExample from "./exhibits/loadable.tsx" with { type: "code" };
|
|
6
7
|
import Point from "./exhibits/point.tsx" with { type: "code" };
|
|
7
8
|
import ViteConfig from "./exhibits/vite.config.ts" with { type: "code" };
|
|
@@ -32,7 +33,7 @@ The npm package is named @atom.io/spa. Its browser runtime, Vite compiler, serve
|
|
|
32
33
|
|
|
33
34
|
<Point />
|
|
34
35
|
|
|
35
|
-
The
|
|
36
|
+
Name the getter and setter after the atom: pointAtom uses getPoint and setPoint. The getPoint getter returns the current object. Each JSX attribute reads its coordinate when evaluated. Both bindings depend on the point atom, and unchanged primitive results skip DOM writes. Reads during setup are snapshots; reads in event handlers are current and untracked. Shared derived state belongs in atom.io selectors.
|
|
36
37
|
|
|
37
38
|
## Vite
|
|
38
39
|
|
|
@@ -51,9 +52,9 @@ The development plugin keeps SPA and atom.io outside dependency prebundling so r
|
|
|
51
52
|
| API | Contract |
|
|
52
53
|
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
53
54
|
| useLoadable(token, fallback?) | Return a tracked accessor for loading, last-observed values, and handled errors. |
|
|
54
|
-
|
|
|
55
|
+
| useGetter(token) | Return a live accessor for an atom or selector, bound to this instance's store. |
|
|
55
56
|
| useSetter(token) | Return a stable atom.io writer. |
|
|
56
|
-
| useTimeline(token) | Return
|
|
57
|
+
| useTimeline(token) | Return a stable object with getCursor/getLength readers, undo/redo/clear commands, and transaction-group controls. |
|
|
57
58
|
| useTransaction(token) | Bind an atom.io transaction, preserving its arguments and result. |
|
|
58
59
|
| useRef(token) | Return an attachment callback for a nullable element atom. Clear it only while this attachment still owns the reference. |
|
|
59
60
|
| useId() | Allocate an instance-stable ID using the root's prefix. |
|
|
@@ -63,6 +64,10 @@ The development plugin keeps SPA and atom.io outside dependency prebundling so r
|
|
|
63
64
|
|
|
64
65
|
Call setup helpers synchronously during component setup or owned mount callbacks. Capture their results for event handlers. Tokens are fixed for an instance; use an application key in a reactive child expression to replace a component when its token changes. Component props stay live when read through the props object; destructuring during setup takes a snapshot.
|
|
65
66
|
|
|
67
|
+
useTimeline returns a TimelineControls object whose methods can be destructured during setup. getCursor and getLength read the current cursor position and recorded checkpoint count; calls inside JSX subscribe the computation, while calls during setup or in event handlers are untracked. undo, redo, and clear are stable commands. history.getTransaction() is a tracked reader that returns an object with optional undo and redo callbacks for the adjacent transaction groups. At a cursor between transactions, both callbacks may be present and target different groups. A missing callback means no transaction group is available in that direction; the reader returns an empty object when neither is available. Calling a returned callback travels its captured group across participating timelines where it remains at the relevant history head, leaving diverged timelines unchanged. Use history.getTransaction().undo?.() or history.getTransaction().redo?.() to retrieve and invoke the current action together.
|
|
68
|
+
|
|
69
|
+
<TimelineExample />
|
|
70
|
+
|
|
66
71
|
Arrays support keyed components and elements. Reordering preserves instances and nodes; removed ranges release subscriptions, events, refs, and cleanup callbacks. Application keys must be unique among siblings. Explicit keys are compared as strings; unkeyed positions occupy a separate namespace. Unkeyed arrays use positions. A key identifies a row in a reactive child collection; it is not an independent reactive binding.
|
|
67
72
|
|
|
68
73
|
HTML and SVG use native DOM properties and attributes, plus className/htmlFor aliases. Events use onClick/onInput-style names, with Capture suffixes and onDoubleClick support. Styles are CSS strings. Mutable atom values still invalidate their consumers; project primitive fields for precise DOM writes. Refs attach once per element instance.
|
|
@@ -75,11 +80,11 @@ useStore returns the current root's atom.io RootStore directly. It is the same o
|
|
|
75
80
|
|
|
76
81
|
<StoreExample />
|
|
77
82
|
|
|
78
|
-
Capture the store during component setup or an owned onMount callback, then pass it to store-aware atom.io operations or integrations. Getting the store creates no subscription. Direct reads such as getFromStore do not participate in SPA's dependency tracking;
|
|
83
|
+
Capture the store during component setup or an owned onMount callback, then pass it to store-aware atom.io operations or integrations. Getting the store creates no subscription. Direct reads such as getFromStore do not participate in SPA's dependency tracking; useGetter and useLoadable provide tracked reads. The returned object is a store, not a Silo or a new wrapper.
|
|
79
84
|
|
|
80
85
|
## Families
|
|
81
86
|
|
|
82
|
-
|
|
87
|
+
useGetter, useSetter, useRef, and useTimeline accept a family token followed by its key. useLoadable accepts a family, key, and optional fallback. Keys retain their declared types, including tuples, numbers, booleans, and null. Members resolve in the component's store, so isolated roots can use the same family tokens independently.
|
|
83
88
|
|
|
84
89
|
<Families />
|
|
85
90
|
|
|
@@ -147,7 +152,7 @@ Build output includes the minified audit entrypoint and machine-readable dist/si
|
|
|
147
152
|
|
|
148
153
|
Breakage exercises the packed package in isolated, locked peer environments, including the coordinated atom.io workspace candidate. Until the first published release, Breakage reports a first-release baseline; these checks establish compatibility with the declared peers rather than a previous spa release. Coverage gates require 100% of statements, branches, functions, and lines across the package source.
|
|
149
154
|
|
|
150
|
-
Tonnage measures combined browser bundles containing SPA and atom.io, with shared modules counted once and unused exports removed. The synchronous recipes include atom creation,
|
|
155
|
+
Tonnage measures combined browser bundles containing SPA and atom.io, with shared modules counted once and unused exports removed. The synchronous recipes include atom creation, useGetter, useSetter, and JSX; the client recipe adds render, the hydration recipe adds hydrate, and the Astro recipe adds the browser island adapter. The async recipe uses useLoadable with render and useSetter. The family recipe includes keyed state, refs, and timeline controls, plus atomFamily, timelineFamily, and scopeFamily. SPA declares atom.io as a peer dependency; these consumer-app measurements include it in every total. Application components, Astro scheduling code, CSS, declarations, and source maps are excluded. The full-client gzip budget above remains a separate, SPA-only audit.
|
|
151
156
|
|
|
152
157
|
<Tonnage config={config} />
|
|
153
158
|
|
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 { c as onCleanup, m as useGetter } from "./core-Bl1Ec1hY.js";
|
|
5
|
+
import { n as render, t as hydrate } from "./dom-Cfj3GtQK.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();
|
|
@@ -61,8 +61,8 @@ var astro_client_default = (element) => async (component, props, slots, { client
|
|
|
61
61
|
});
|
|
62
62
|
const mount = () => {
|
|
63
63
|
onCleanup(dispose);
|
|
64
|
-
const
|
|
65
|
-
return () => island(component,
|
|
64
|
+
const getState = useGetter(state);
|
|
65
|
+
return () => island(component, getState().props, getState().slots);
|
|
66
66
|
};
|
|
67
67
|
if (replace) element.replaceChildren();
|
|
68
68
|
const root = (replace ? render : hydrate)(mount, element, {
|
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,
|
|
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, useGetter } 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 getState = useGetter(state)\n\t\t\t\t\treturn () => island(component, getState().props, getState().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,MAAM,WAAW,MAAM,IAAI,OAAO;CAClC,IAAI,UAAU,cAAc,WAAW;EACtC,SAAS,OAAO,OAAO,KAAK;EAC5B,OAAO,SAAS;CACjB;CACA,UAAU,QAAQ;CAClB,MAAM,SAAS,CAAC,UAAU,eAAe,CAAC,UAAU;CACpD,MAAM,cAAc,SACjB,mBAAmB,QAAQ,aAAa,IACxC,KAAA;CACH,IAAI,eAAe,WAAW,QAAQ,YAAY,YAAY;CAC9D,MAAM,WAAW,aAAa,SAAS,WAAW;CAClD,MAAM,UAAU;EAAE;EAAO;CAAM;CAC/B,IAAI,UAAU;CACd,IAAI;CACJ,IAAI,WAAW;CACf,MAAM,gBAAgB;EACrB,IAAI,UAAU;EACd,WAAW;EACX,QAAQ,oBAAoB,iBAAiB,OAAO;EACpD,MAAM,OAAO,OAAO;EACpB,SAAS,QAAQ;CAClB;CAGA,MAAM,QAAQ,QAAQ,QAAQ,CAAC,CAAC,KAAK,YAAY;EAChD,IAAI,SAAS,QAAQ,OAAO,SAAS;EACrC,IAAI,WAAW;EACf,IAAI;GACH,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAChC,YACC,WACA,OACA,SAAS,SACT,SAAS,SAAS,QAAQ,KAAA,CAC3B,GACA,SAAS,SACV,CAAC;GACD,IAAI,SAAS,QAAQ,OAAO,SAAS;GACrC,WAAW;GACX,MAAM,UACL,WAAW,UACX,aAAa,KAAA,KACb,aAAa,cAAc;GAE5B,MAAM,WAAW,QAAQ;GACzB,IAAI,UAAU,aAAa,KAAK,SAAS,cAAc,aACtD,SAAS,OAAO;GACjB,IAAI,SAAS,OAAO,IAAI,KAAM;GAC9B,IAAI,CAAC,QAAQ;IACZ,SAAS,wBAA8C,OAAQ;KAC9D,KAAK;KACL,SAAS;MAAE,OAAO,CAAC;MAAG,OAAO,CAAC;KAAE;IACjC,CAAC;IACD,OAAO,IAAI,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,WAAW,UAAU,KAAK;IAChC,aAAa,OAAO,WAAW,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,KAAK;GAClE;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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as Component, t as Capability } from "./capabilities-
|
|
1
|
+
import { o as Component, t as Capability } from "./capabilities-D3HObAIy.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-CYSRrRr8.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro-shared-
|
|
1
|
+
{"version":3,"file":"astro-shared-CYSRrRr8.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-CYSRrRr8.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 };
|
|
@@ -72,24 +72,26 @@ declare function onCleanup(cleanup: Cleanup): void;
|
|
|
72
72
|
declare function onMount(run: Cleanup): void;
|
|
73
73
|
declare function useId(): string;
|
|
74
74
|
/** Capture a token for this instance. Change the component key to change its token. */
|
|
75
|
-
declare function
|
|
76
|
-
declare function
|
|
75
|
+
declare function useGetter<T, E = never>(token: ReadableToken<T, any, E>): Accessor<ViewOf<T | E>>;
|
|
76
|
+
declare function useGetter<T, K extends Canonical, E = never>(family: ReadableFamilyToken<T, K, E>, key: NoInfer<K>): Accessor<ViewOf<T | E>>;
|
|
77
77
|
declare function useSetter<T>(token: WritableToken<T, any, any>): (value: T | Setter<T>) => void;
|
|
78
78
|
declare function useSetter<T, K extends Canonical>(family: WritableFamilyToken<T, K, any>, key: NoInfer<K>): (value: T | Setter<T>) => void;
|
|
79
79
|
declare function useTransaction<F extends (...args: any[]) => any>(token: TransactionToken<F>): (...args: Parameters<F>) => ReturnType<F>;
|
|
80
80
|
declare function useRef<E extends Element>(token: RegularAtomToken<E | null>): (element: E | null) => void;
|
|
81
81
|
declare function useRef<E extends Element, K extends Canonical>(family: RegularAtomFamilyToken<E | null, K>, key: NoInfer<K>): (element: E | null) => void;
|
|
82
|
-
interface
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
interface TimelineControls {
|
|
83
|
+
getCursor(): number;
|
|
84
|
+
getLength(): number;
|
|
85
85
|
undo(): void;
|
|
86
86
|
redo(): void;
|
|
87
87
|
clear(): void;
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
getTransaction(): {
|
|
89
|
+
undo?: Cleanup;
|
|
90
|
+
redo?: Cleanup;
|
|
91
|
+
};
|
|
90
92
|
}
|
|
91
|
-
declare function useTimeline<M extends TimelineManageable>(token: TimelineToken<M>):
|
|
92
|
-
declare function useTimeline<K extends Canonical, M extends TimelineManageable>(family: TimelineFamilyToken<K, M>, key: NoInfer<K>):
|
|
93
|
+
declare function useTimeline<M extends TimelineManageable>(token: TimelineToken<M>): TimelineControls;
|
|
94
|
+
declare function useTimeline<K extends Canonical, M extends TimelineManageable>(family: TimelineFamilyToken<K, M>, key: NoInfer<K>): TimelineControls;
|
|
93
95
|
/** Native renderers expose property access without importing capability engines. */
|
|
94
96
|
interface CapabilityTarget {
|
|
95
97
|
kind: string;
|
|
@@ -111,5 +113,5 @@ interface Capability {
|
|
|
111
113
|
scheduleFrame?(callback: (time: number) => void): Cleanup;
|
|
112
114
|
attach(target: CapabilityTarget): CapabilityBinding;
|
|
113
115
|
}
|
|
114
|
-
export {
|
|
115
|
-
//# sourceMappingURL=capabilities-
|
|
116
|
+
export { useTimeline as _, Child as a, TimelineControls as c, onMount as d, useGetter as f, useStore as g, useSetter as h, Accessor as i, VNode as l, useRef as m, CapabilityBinding as n, Component as o, useId as p, CapabilityTarget as r, RootOptions as s, Capability as t, onCleanup as u, useTransaction as v };
|
|
117
|
+
//# sourceMappingURL=capabilities-D3HObAIy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities-
|
|
1
|
+
{"version":3,"file":"capabilities-D3HObAIy.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,UAAU,GAAG,WAC5B,OAAO,cAAc,QAAQ,KAC3B,SAAS,OAAO,IAAI;iBACP,UAAU,GAAG,UAAU,WAAW,WACjD,QAAQ,oBAAoB,GAAG,GAAG,IAClC,KAAK,QAAQ,KACX,SAAS,OAAO,IAAI;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;IAAoB,OAAO;IAAS,OAAO;;;iBAE5B,YAAY,UAAU,oBACrC,OAAO,cAAc,KACnB;iBACa,YAAY,UAAU,WAAW,UAAU,oBAC1D,QAAQ,oBAAoB,GAAG,IAC/B,KAAK,QAAQ,KACX;;UCzWc;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,
|
|
1
|
+
import{IMPLICIT as e,actUponStore as t,clearTimelineInStore as n,findInStore as r,findTimelineInStore as i,getFromStore as a,getTimelineTransactionAtHead as o,setIntoStore as s,subscribeToState as c,subscribeToTimeline as l,timeTravel as u,timeTravelTransactionGroupInStore as d,withdraw as f,withdraw as p}from"atom.io/internal";var m,h,g=0;function _(e,t){let n=m;m=e;try{return t()}finally{m=n}}function v(e){let t=h;h=void 0;try{return e()}finally{h=t}}function y(e){let t={_root:e?._root,_parent:e,_cleanups:new Set,_updates:[],_dead:!1};return e?._cleanups.add(t),t}function b(e,t){try{x(e)}catch(e){throw AggregateError([t,e])}throw t}function x(e){if(e._dead)return;e._dead=!0;let t=[];try{e._root._presence?.forget(e)}catch(e){t.push(e)}for(let n of[...e._cleanups].reverse())try{typeof n==`function`?n():x(n)}catch(e){t.push(e)}if(e._parent?._cleanups.delete(e),e._cleanups.clear(),e._updates.length=0,t.length)throw AggregateError(t)}function S(e){for(let t of e._updates)C(e,t);for(let t of e._cleanups)typeof t!=`function`&&S(t)}function C(e,t){if(!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=>c(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=>{s(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),s(n,e,t)):r.get(e.key)===i&&(r.delete(e.key),a(n,e)===o&&s(n,e,null),o=null)}}function I(e,t){let r=m._root._store,a=e.type===`timeline_family`?i(r,e,t):e,s=e=>l(r,a,`spa:${g++}`,e),c=()=>{let e=f(r,a);return h?.(s),e};return{getCursor:()=>c().at,getLength:()=>c().history.length,undo:()=>{u(r,`undo`,a)},redo:()=>{u(r,`redo`,a)},clear:()=>{n(r,a)},getTransaction:()=>{let e=c(),t={};for(let n of[`undo`,`redo`]){let i=o(e,n);i&&(t[n]=()=>{d(r,n,i)})}return t}}}function 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,j as useGetter,O as useId,ne as useLoadable,F as useRef,M as useSetter,T as useStore,I as useTimeline,N as useTransaction};
|