@atom.io/spa 0.0.8 → 0.0.10
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 +194 -30
- package/README.mdx +78 -20
- package/dist/BrandMarkScene-CBYk-RJ2.js +140 -0
- package/dist/BrandMarkScene-CBYk-RJ2.js.map +1 -0
- package/dist/astro-application.d.ts +1 -1
- package/dist/astro-client.d.ts +1 -1
- package/dist/astro-client.d.ts.map +1 -1
- package/dist/astro-client.js +5 -4
- package/dist/astro-client.js.map +1 -1
- package/dist/astro-resumability-client.d.ts +1 -1
- package/dist/astro-server.js +4 -4
- package/dist/astro-server.js.map +1 -1
- package/dist/{astro-shared-83hxw7-M.js → astro-shared-DBwINQav.js} +2 -2
- package/dist/{astro-shared-83hxw7-M.js.map → astro-shared-DBwINQav.js.map} +1 -1
- package/dist/{astro-shared-DZp1x8RQ.d.ts → astro-shared-KxK9OUSj.d.ts} +2 -2
- package/dist/{astro-shared-DZp1x8RQ.d.ts.map → astro-shared-KxK9OUSj.d.ts.map} +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +1 -1
- package/dist/brand-css.d.ts +2 -0
- package/dist/brand-model.d.ts +32 -0
- package/dist/brand-model.d.ts.map +1 -0
- package/dist/brand-model.js +120 -0
- package/dist/brand-model.js.map +1 -0
- package/dist/brand.css +37 -0
- package/dist/brand.d.ts +13 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +94 -0
- package/dist/brand.js.map +1 -0
- package/dist/{capabilities-DNcnGRv_.d.ts → capabilities-ChgSs6bp.d.ts} +34 -6
- package/dist/capabilities-ChgSs6bp.d.ts.map +1 -0
- package/dist/client.min.js +1 -1
- package/dist/core-DD2giR6E.js +451 -0
- package/dist/core-DD2giR6E.js.map +1 -0
- package/dist/development/BrandMarkScene-BDdC7K5M.js +140 -0
- package/dist/development/BrandMarkScene-BDdC7K5M.js.map +1 -0
- package/dist/development/astro-client.js +5 -4
- package/dist/development/astro-client.js.map +1 -1
- package/dist/development/astro-server.js +4 -4
- package/dist/development/astro-server.js.map +1 -1
- package/dist/development/{astro-shared-83hxw7-M.js → astro-shared-DBwINQav.js} +2 -2
- package/dist/development/{astro-shared-83hxw7-M.js.map → astro-shared-DBwINQav.js.map} +1 -1
- package/dist/development/astro.js +1 -1
- package/dist/development/brand-model.js +120 -0
- package/dist/development/brand-model.js.map +1 -0
- package/dist/development/brand.css +37 -0
- package/dist/development/brand.js +94 -0
- package/dist/development/brand.js.map +1 -0
- package/dist/development/core-DrUd8x25.js +465 -0
- package/dist/development/core-DrUd8x25.js.map +1 -0
- package/dist/development/{dom-DQ0M3rLL.js → dom-CEVtlaav.js} +152 -36
- package/dist/development/dom-CEVtlaav.js.map +1 -0
- package/dist/development/floating.js +2 -6
- package/dist/development/floating.js.map +1 -1
- package/dist/development/hot.js +164 -0
- package/dist/development/hot.js.map +1 -0
- package/dist/development/identity-B8wTFkyW.js +121 -0
- package/dist/development/identity-B8wTFkyW.js.map +1 -0
- package/dist/development/index.js +5 -5
- package/dist/development/jsx-runtime-BGDPK50B.js +49 -0
- package/dist/development/jsx-runtime-BGDPK50B.js.map +1 -0
- package/dist/development/jsx-runtime.js +1 -25
- package/dist/development/konva.js +12 -5
- package/dist/development/konva.js.map +1 -1
- package/dist/development/motion.js +41 -39
- package/dist/development/motion.js.map +1 -1
- package/dist/development/renderer.js +41 -40
- package/dist/development/renderer.js.map +1 -1
- package/dist/development/{server-renderer-DCLoMdOX.js → server-renderer-zAqEL1g1.js} +8 -18
- package/dist/development/server-renderer-zAqEL1g1.js.map +1 -0
- package/dist/development/server.js +1 -1
- package/dist/{src-Bme1kz2b.js → development/src-CB7ruwRs.js} +3 -3
- package/dist/development/src-CB7ruwRs.js.map +1 -0
- package/dist/development/three-CsZ6Od1C.js +527 -0
- package/dist/development/three-CsZ6Od1C.js.map +1 -0
- package/dist/development/three.js +1 -508
- package/dist/development/vite-WUiz1ju6.js +545 -0
- package/dist/development/vite-WUiz1ju6.js.map +1 -0
- package/dist/development/vite.js +1 -1
- package/dist/{dom-D8g3roX9.js → dom-DUpa3Sj2.js} +141 -33
- package/dist/dom-DUpa3Sj2.js.map +1 -0
- package/dist/floating.d.ts +1 -1
- package/dist/floating.d.ts.map +1 -1
- package/dist/floating.js +2 -6
- package/dist/floating.js.map +1 -1
- package/dist/hot.d.ts +15 -0
- package/dist/hot.d.ts.map +1 -0
- package/dist/hot.js +19 -0
- package/dist/hot.js.map +1 -0
- package/dist/identity-ByJswZtF.js +121 -0
- package/dist/identity-ByJswZtF.js.map +1 -0
- package/dist/{index-BFnXIfOj.d.ts → index-DdA39aMv.d.ts} +4 -4
- package/dist/{index-BFnXIfOj.d.ts.map → index-DdA39aMv.d.ts.map} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/jsx-runtime-BGDPK50B.js +49 -0
- package/dist/jsx-runtime-BGDPK50B.js.map +1 -0
- package/dist/{jsx-runtime-DQnpyT_g.d.ts → jsx-runtime-CCvcEosg.d.ts} +14 -9
- package/dist/jsx-runtime-CCvcEosg.d.ts.map +1 -0
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -25
- package/dist/konva.d.ts +46 -9
- package/dist/konva.d.ts.map +1 -1
- package/dist/konva.js +12 -5
- package/dist/konva.js.map +1 -1
- package/dist/motion.d.ts +3 -1
- package/dist/motion.d.ts.map +1 -1
- package/dist/motion.js +41 -39
- package/dist/motion.js.map +1 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +39 -40
- package/dist/renderer.js.map +1 -1
- package/dist/{server-renderer-D0rsFL_-.js → server-renderer-D7CdyOMo.js} +8 -18
- package/dist/server-renderer-D7CdyOMo.js.map +1 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/size.json +12 -12
- package/dist/{development/src-DoQgCX-O.js → src-B2W_TA_X.js} +3 -3
- package/dist/src-B2W_TA_X.js.map +1 -0
- package/dist/three-DcYxRXPW.js +527 -0
- package/dist/three-DcYxRXPW.js.map +1 -0
- package/dist/three.d.ts +24 -3
- package/dist/three.d.ts.map +1 -1
- package/dist/three.js +1 -508
- package/dist/vite-WUiz1ju6.js +545 -0
- package/dist/vite-WUiz1ju6.js.map +1 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +1 -1
- package/package.json +45 -18
- package/src/BrandMark.module.css +25 -0
- package/src/BrandMark.tsx +106 -0
- package/src/BrandMarkScene.module.css +10 -0
- package/src/BrandMarkScene.tsx +116 -0
- package/src/astro-client.ts +3 -2
- package/src/astro-server.ts +2 -2
- package/src/brand-css.d.ts +2 -0
- package/src/brand-model.ts +177 -0
- package/src/brand.ts +3 -0
- package/src/capabilities.ts +48 -21
- package/src/compiler-hmr.ts +297 -0
- package/src/compiler.ts +127 -25
- package/src/core.ts +282 -33
- package/src/dom-forms.ts +127 -0
- package/src/dom.ts +124 -53
- package/src/floating.ts +2 -6
- package/src/hot.ts +191 -0
- package/src/identity.ts +39 -0
- package/src/index.ts +2 -0
- package/src/jsx-runtime.ts +6 -26
- package/src/jsx-types.d.ts +8 -3
- package/src/konva.ts +66 -10
- package/src/lasertag.d.ts +1 -0
- package/src/motion-layout.ts +55 -26
- package/src/motion.ts +3 -0
- package/src/presence.ts +11 -23
- package/src/props.ts +55 -0
- package/src/renderer.ts +91 -71
- package/src/server-renderer.ts +18 -13
- package/src/three.ts +92 -46
- package/src/use-loadable.ts +2 -2
- package/src/vite.ts +44 -4
- package/dist/capabilities-DNcnGRv_.d.ts.map +0 -1
- package/dist/capabilities-nOIitQ-_.js +0 -65
- package/dist/capabilities-nOIitQ-_.js.map +0 -1
- package/dist/core-B4rJ0xdc.js +0 -268
- package/dist/core-B4rJ0xdc.js.map +0 -1
- package/dist/development/capabilities-nOIitQ-_.js +0 -65
- package/dist/development/capabilities-nOIitQ-_.js.map +0 -1
- package/dist/development/core-BHA7I1nf.js +0 -271
- package/dist/development/core-BHA7I1nf.js.map +0 -1
- package/dist/development/dom-DQ0M3rLL.js.map +0 -1
- package/dist/development/jsx-runtime.js.map +0 -1
- package/dist/development/server-renderer-DCLoMdOX.js.map +0 -1
- package/dist/development/src-DoQgCX-O.js.map +0 -1
- package/dist/development/three.js.map +0 -1
- package/dist/development/vite-Bmyb6P5w.js +0 -265
- package/dist/development/vite-Bmyb6P5w.js.map +0 -1
- package/dist/dom-D8g3roX9.js.map +0 -1
- package/dist/jsx-runtime-DQnpyT_g.d.ts.map +0 -1
- package/dist/jsx-runtime.js.map +0 -1
- package/dist/server-renderer-D0rsFL_-.js.map +0 -1
- package/dist/src-Bme1kz2b.js.map +0 -1
- package/dist/three.js.map +0 -1
- package/dist/vite-Bmyb6P5w.js +0 -265
- package/dist/vite-Bmyb6P5w.js.map +0 -1
package/src/index.ts
CHANGED
package/src/jsx-runtime.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { Canonical } from "atom.io/foundations/canonical"
|
|
2
|
+
|
|
1
3
|
import type { Children, Component, SpaElement } from "./core.ts"
|
|
2
4
|
import type { HTMLAttributes, NativeElements } from "./jsx-types.d.ts"
|
|
5
|
+
import { merge } from "./props.ts"
|
|
3
6
|
|
|
4
7
|
export type {
|
|
5
8
|
AriaAttributes,
|
|
@@ -11,6 +14,7 @@ export type {
|
|
|
11
14
|
SVGAttributes,
|
|
12
15
|
TargetedEvent,
|
|
13
16
|
} from "./jsx-types.d.ts"
|
|
17
|
+
export { merge } from "./props.ts"
|
|
14
18
|
|
|
15
19
|
/** Optional integrations augment attributes without changing element identity. */
|
|
16
20
|
// oxlint-disable-next-line typescript/no-empty-interface -- Optional integrations augment this declaration.
|
|
@@ -21,7 +25,7 @@ export const Fragment = (props: { children?: Children }): Children =>
|
|
|
21
25
|
export function jsx(
|
|
22
26
|
type: SpaElement[`type`],
|
|
23
27
|
props: SpaElement[`props`] | null,
|
|
24
|
-
key?:
|
|
28
|
+
key?: Canonical,
|
|
25
29
|
): SpaElement {
|
|
26
30
|
return {
|
|
27
31
|
type,
|
|
@@ -31,30 +35,6 @@ export function jsx(
|
|
|
31
35
|
export const jsxs = jsx
|
|
32
36
|
export const jsxDEV = jsx
|
|
33
37
|
|
|
34
|
-
/** Preserve lazy props and spread precedence, including keys added by later updates. */
|
|
35
|
-
export function merge(
|
|
36
|
-
...sources: (Record<string, any> | (() => Record<string, any>))[]
|
|
37
|
-
): Record<string, any> {
|
|
38
|
-
const values = () =>
|
|
39
|
-
sources.map(
|
|
40
|
-
(source) => (typeof source === `function` ? source() : source) ?? {},
|
|
41
|
-
)
|
|
42
|
-
return new Proxy(
|
|
43
|
-
{},
|
|
44
|
-
{
|
|
45
|
-
get: (_, key) =>
|
|
46
|
-
values()
|
|
47
|
-
.reverse()
|
|
48
|
-
.find((source) => Object.hasOwn(source, key))?.[key],
|
|
49
|
-
ownKeys: () => [...new Set(values().flatMap(Object.keys))],
|
|
50
|
-
getOwnPropertyDescriptor: (_, key) =>
|
|
51
|
-
values().some((source) => Object.hasOwn(source, key))
|
|
52
|
-
? { enumerable: true, configurable: true }
|
|
53
|
-
: undefined,
|
|
54
|
-
},
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
38
|
export namespace JSX {
|
|
59
39
|
export type Element = SpaElement
|
|
60
40
|
export type ElementType = keyof IntrinsicElements | Component
|
|
@@ -62,7 +42,7 @@ export namespace JSX {
|
|
|
62
42
|
children: {}
|
|
63
43
|
}
|
|
64
44
|
export interface IntrinsicAttributes {
|
|
65
|
-
key?:
|
|
45
|
+
key?: Canonical | undefined
|
|
66
46
|
}
|
|
67
47
|
/** Augment this interface to declare attributes for registered custom elements. */
|
|
68
48
|
export interface IntrinsicElements extends NativeElements {
|
package/src/jsx-types.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import type { Canonical } from "atom.io/foundations/canonical"
|
|
2
|
+
|
|
1
3
|
import type { Children } from "./core.ts"
|
|
2
4
|
import type { CapabilityAttributes } from "./jsx-runtime.ts"
|
|
3
5
|
|
|
4
|
-
/** Native
|
|
6
|
+
/** Native targets are preserved; currentTarget identifies the attached element. */
|
|
5
7
|
export type TargetedEvent<E extends Element, T extends Event = Event> = Omit<
|
|
6
8
|
T,
|
|
7
9
|
`currentTarget`
|
|
8
|
-
> & { readonly currentTarget: E }
|
|
10
|
+
> & { readonly currentTarget: E } & (T extends FocusEvent | MouseEvent
|
|
11
|
+
? { readonly relatedTarget: (EventTarget & Element) | null }
|
|
12
|
+
: {})
|
|
9
13
|
export type EventHandler<E extends Element, T extends Event = Event> = (
|
|
10
14
|
event: TargetedEvent<E, T>,
|
|
11
15
|
) => void
|
|
@@ -201,7 +205,7 @@ export type DOMAttributes<E extends Element> = CapabilityAttributes<`dom`> &
|
|
|
201
205
|
AriaAttributes &
|
|
202
206
|
Attributes<{
|
|
203
207
|
children: Children
|
|
204
|
-
key:
|
|
208
|
+
key: Canonical
|
|
205
209
|
ref: Ref<E>
|
|
206
210
|
id: string
|
|
207
211
|
class: string
|
|
@@ -585,6 +589,7 @@ export type HTMLIntrinsicElements = {
|
|
|
585
589
|
/** SVG uses literal attribute names: e.g. stroke-width, not strokeWidth. */
|
|
586
590
|
export type SVGAttributes<E extends SVGElement = SVGElement> = DOMAttributes<E> &
|
|
587
591
|
Attributes<{
|
|
592
|
+
focusable: Booleanish | `auto`
|
|
588
593
|
lang: string
|
|
589
594
|
[`xml:lang`]: string
|
|
590
595
|
[`xml:space`]: `default` | `preserve`
|
package/src/konva.ts
CHANGED
|
@@ -8,14 +8,58 @@ import type { CapabilityAttributes } from "./jsx-runtime.ts"
|
|
|
8
8
|
import { jsx } from "./jsx-runtime.ts"
|
|
9
9
|
import { bindScene, createSceneRenderer, sceneComponent } from "./renderer.ts"
|
|
10
10
|
|
|
11
|
-
type
|
|
12
|
-
|
|
11
|
+
type InteractionEvent = MouseEvent | TouchEvent | PointerEvent
|
|
12
|
+
interface Events {
|
|
13
|
+
onClick: MouseEvent
|
|
14
|
+
onDblClick: MouseEvent
|
|
15
|
+
onMouseDown: MouseEvent
|
|
16
|
+
onMouseUp: MouseEvent
|
|
17
|
+
onMouseMove: MouseEvent
|
|
18
|
+
onMouseEnter: MouseEvent
|
|
19
|
+
onMouseLeave: MouseEvent
|
|
20
|
+
onMouseOver: MouseEvent
|
|
21
|
+
onMouseOut: MouseEvent
|
|
22
|
+
onContextMenu: PointerEvent
|
|
23
|
+
onWheel: WheelEvent
|
|
24
|
+
onPointerDown: PointerEvent
|
|
25
|
+
onPointerUp: PointerEvent
|
|
26
|
+
onPointerMove: PointerEvent
|
|
27
|
+
onPointerEnter: PointerEvent
|
|
28
|
+
onPointerLeave: PointerEvent
|
|
29
|
+
onPointerOver: PointerEvent
|
|
30
|
+
onPointerOut: PointerEvent
|
|
31
|
+
onPointerCancel: PointerEvent
|
|
32
|
+
onPointerClick: PointerEvent
|
|
33
|
+
onPointerDblClick: PointerEvent
|
|
34
|
+
onGotPointerCapture: PointerEvent
|
|
35
|
+
onLostPointerCapture: PointerEvent
|
|
36
|
+
onTouchStart: TouchEvent
|
|
37
|
+
onTouchMove: TouchEvent
|
|
38
|
+
onTouchEnd: TouchEvent
|
|
39
|
+
onTouchCancel: TouchEvent
|
|
40
|
+
onTap: TouchEvent
|
|
41
|
+
onDblTap: TouchEvent
|
|
42
|
+
onDragStart: InteractionEvent
|
|
43
|
+
onDragMove: InteractionEvent
|
|
44
|
+
onDragEnd: InteractionEvent
|
|
45
|
+
onTransformStart: InteractionEvent
|
|
46
|
+
onTransform: InteractionEvent
|
|
47
|
+
onTransformEnd: InteractionEvent | undefined
|
|
48
|
+
}
|
|
49
|
+
type Config<C> = {
|
|
50
|
+
[K in keyof C as string extends K ? never : number extends K ? never : K]: C[K]
|
|
51
|
+
}
|
|
52
|
+
type Props<C, N extends Konva.Node> = Config<C> & {
|
|
53
|
+
[K in keyof Events]?:
|
|
54
|
+
| ((
|
|
55
|
+
event: Omit<Konva.KonvaEventObject<Events[K]>, `currentTarget`> & {
|
|
56
|
+
readonly currentTarget: N
|
|
57
|
+
},
|
|
58
|
+
) => void)
|
|
59
|
+
| undefined
|
|
60
|
+
} & CapabilityAttributes<`konva`> & {
|
|
13
61
|
children?: Children
|
|
14
62
|
ref?: (node: N | null) => void
|
|
15
|
-
onClick?: (event: Konva.KonvaEventObject<MouseEvent>) => void
|
|
16
|
-
onPointerDown?: (event: Konva.KonvaEventObject<PointerEvent>) => void
|
|
17
|
-
onDragMove?: (event: Konva.KonvaEventObject<DragEvent>) => void
|
|
18
|
-
onDragEnd?: (event: Konva.KonvaEventObject<DragEvent>) => void
|
|
19
63
|
}
|
|
20
64
|
const constructors = {
|
|
21
65
|
Layer: Konva.Layer,
|
|
@@ -86,12 +130,24 @@ const renderer = createSceneRenderer<Konva.Node>({
|
|
|
86
130
|
if (children.length && !(parent instanceof Konva.Container))
|
|
87
131
|
throw new Error(`spa/konva: shapes cannot contain children`)
|
|
88
132
|
if (parent instanceof Konva.Container) {
|
|
89
|
-
|
|
90
|
-
|
|
133
|
+
const current = parent.getChildren()
|
|
134
|
+
if (
|
|
135
|
+
current.length === children.length &&
|
|
136
|
+
children.every((child, index) => child === current[index])
|
|
137
|
+
)
|
|
138
|
+
return
|
|
139
|
+
const wanted = new Set(children)
|
|
140
|
+
for (const child of [...current]) if (!wanted.has(child)) child.remove()
|
|
91
141
|
children.forEach((child, index) => {
|
|
92
142
|
if (child.getParent() !== parent) parent.add(child as any)
|
|
93
|
-
|
|
143
|
+
// Layer zIndex also updates the Stage's canvas order.
|
|
144
|
+
if (parent instanceof Konva.Stage && child.zIndex() !== index)
|
|
145
|
+
child.zIndex(index)
|
|
94
146
|
})
|
|
147
|
+
if (!(parent instanceof Konva.Stage)) {
|
|
148
|
+
parent.children = [...children]
|
|
149
|
+
parent._setChildrenIndices()
|
|
150
|
+
}
|
|
95
151
|
}
|
|
96
152
|
},
|
|
97
153
|
destroy(node) {
|
|
@@ -102,7 +158,7 @@ const renderer = createSceneRenderer<Konva.Node>({
|
|
|
102
158
|
|
|
103
159
|
/** A DOM boundary owning a Konva stage and its scene subtree. */
|
|
104
160
|
export function Stage(
|
|
105
|
-
props: Props<Omit<Konva.StageConfig
|
|
161
|
+
props: Props<Omit<Config<Konva.StageConfig>, `container`>, Konva.Stage> & {
|
|
106
162
|
width?: number
|
|
107
163
|
height?: number
|
|
108
164
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "lasertag/css-modules"
|
package/src/motion-layout.ts
CHANGED
|
@@ -14,6 +14,7 @@ interface Props {
|
|
|
14
14
|
id?: string | number
|
|
15
15
|
group?: string | number
|
|
16
16
|
scroll?: boolean
|
|
17
|
+
root?: boolean
|
|
17
18
|
transition?: MotionLayoutTransition
|
|
18
19
|
}
|
|
19
20
|
interface LayoutController {
|
|
@@ -29,7 +30,9 @@ interface Entry {
|
|
|
29
30
|
dead: boolean
|
|
30
31
|
node?: IProjectionNode | undefined
|
|
31
32
|
release?: Cleanup | undefined
|
|
32
|
-
|
|
33
|
+
beginStyles?: Cleanup | undefined
|
|
34
|
+
measureStyles?: Cleanup | undefined
|
|
35
|
+
endStyles?: Cleanup | undefined
|
|
33
36
|
captureStyles?: Cleanup | undefined
|
|
34
37
|
identity?: string
|
|
35
38
|
size?: string
|
|
@@ -73,7 +76,11 @@ export function createLayoutController(
|
|
|
73
76
|
const detach = entry.release
|
|
74
77
|
entry.release = undefined
|
|
75
78
|
entry.node = undefined
|
|
76
|
-
entry.
|
|
79
|
+
entry.beginStyles =
|
|
80
|
+
entry.measureStyles =
|
|
81
|
+
entry.endStyles =
|
|
82
|
+
entry.captureStyles =
|
|
83
|
+
undefined
|
|
77
84
|
detach?.()
|
|
78
85
|
}
|
|
79
86
|
const configure = (entry: Entry) => {
|
|
@@ -97,6 +104,7 @@ export function createLayoutController(
|
|
|
97
104
|
}
|
|
98
105
|
entry.node!.setOptions({
|
|
99
106
|
layoutScroll: entry.props.scroll ?? false,
|
|
107
|
+
layoutRoot: entry.props.root ?? false,
|
|
100
108
|
animationType:
|
|
101
109
|
typeof entry.props.animate === `string` ? entry.props.animate : `both`,
|
|
102
110
|
animate: entry.props.animate !== false && !reduced(),
|
|
@@ -154,34 +162,36 @@ export function createLayoutController(
|
|
|
154
162
|
let visibility = ``
|
|
155
163
|
let pointerEvents = ``
|
|
156
164
|
let transform = ``
|
|
165
|
+
let rendered = ``
|
|
157
166
|
const transformTemplate = (_: unknown, projected: string) =>
|
|
158
167
|
`${projected === `none` ? `` : projected} ${transform}`.trim()
|
|
159
168
|
entry.captureStyles = () => {
|
|
160
169
|
style.cssText = element.style.cssText
|
|
161
170
|
}
|
|
162
|
-
entry.
|
|
171
|
+
entry.beginStyles = () => {
|
|
163
172
|
// Resolve authored CSS against today's dimensions, without reading back
|
|
164
173
|
// the opacity and percentage origins written by projection itself.
|
|
165
|
-
|
|
174
|
+
rendered = element.style.cssText
|
|
166
175
|
for (const name of styleNames) restore(name)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
176
|
+
}
|
|
177
|
+
entry.measureStyles = () => {
|
|
178
|
+
const authored = getComputedStyle(element)
|
|
179
|
+
opacity = authored.opacity || `1`
|
|
180
|
+
visibility = authored.visibility
|
|
181
|
+
pointerEvents = authored.pointerEvents
|
|
182
|
+
transform = authored.transform
|
|
183
|
+
if (!visual.values.has(`opacity`))
|
|
184
|
+
node.latestValues[`opacity`] = Number(opacity)
|
|
185
|
+
const origin = authored.transformOrigin.split(` `)
|
|
186
|
+
const width = element.offsetWidth,
|
|
187
|
+
height = element.offsetHeight
|
|
188
|
+
entry.size = `${width}:${height}`
|
|
189
|
+
for (const [key, value] of [
|
|
190
|
+
[`originX`, parseFloat(origin[0]) / (width || 1)],
|
|
191
|
+
[`originY`, parseFloat(origin[1]) / (height || 1)],
|
|
192
|
+
] as const)
|
|
193
|
+
if (!visual.values.has(key) && Number.isFinite(value))
|
|
194
|
+
node.latestValues[key] = value
|
|
185
195
|
// Motion-owned transforms compose in projection; return to authored
|
|
186
196
|
// transforms if that Motion binding is subsequently removed.
|
|
187
197
|
const template =
|
|
@@ -199,6 +209,9 @@ export function createLayoutController(
|
|
|
199
209
|
visual.update(next, null)
|
|
200
210
|
}
|
|
201
211
|
}
|
|
212
|
+
entry.endStyles = () => {
|
|
213
|
+
element.style.cssText = rendered
|
|
214
|
+
}
|
|
202
215
|
const applyProjectionStyles = node.applyProjectionStyles
|
|
203
216
|
node.applyProjectionStyles = (targetStyle, styleProp) => {
|
|
204
217
|
applyProjectionStyles.call(node, targetStyle, {
|
|
@@ -238,14 +251,29 @@ export function createLayoutController(
|
|
|
238
251
|
}
|
|
239
252
|
observer?.observe(element)
|
|
240
253
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
254
|
+
}
|
|
255
|
+
const prepareAll = () => {
|
|
256
|
+
const active = ordered()
|
|
257
|
+
for (const entry of active) prepare(entry)
|
|
258
|
+
const begun: Entry[] = []
|
|
259
|
+
try {
|
|
260
|
+
// Strip every projection before reading any authored style or dimension.
|
|
261
|
+
// Interleaving these phases forces a layout for each registered element.
|
|
262
|
+
for (const entry of active) {
|
|
263
|
+
begun.push(entry)
|
|
264
|
+
entry.beginStyles!()
|
|
265
|
+
}
|
|
266
|
+
for (const entry of active) entry.measureStyles!()
|
|
267
|
+
} finally {
|
|
268
|
+
for (const entry of begun) entry.endStyles!()
|
|
269
|
+
}
|
|
270
|
+
for (const entry of active) configure(entry)
|
|
271
|
+
return active
|
|
244
272
|
}
|
|
245
273
|
const commit = () => {
|
|
246
274
|
try {
|
|
247
275
|
if (dead) return
|
|
248
|
-
|
|
276
|
+
prepareAll()
|
|
249
277
|
const roots = new Set(
|
|
250
278
|
[...entries].flatMap((entry) =>
|
|
251
279
|
entry.node ? [entry.node.root ?? entry.node] : [],
|
|
@@ -314,6 +342,7 @@ export function createLayoutController(
|
|
|
314
342
|
commit,
|
|
315
343
|
beforeUpdate(): Cleanup {
|
|
316
344
|
updating = true
|
|
345
|
+
// Snapshot the rendered projection; resolve authored styles once after the DOM changes.
|
|
317
346
|
for (const entry of ordered()) {
|
|
318
347
|
prepare(entry)
|
|
319
348
|
entry.node!.willUpdate()
|
package/src/motion.ts
CHANGED
|
@@ -113,6 +113,8 @@ export interface MotionAttributes<Kind extends string = `dom`> {
|
|
|
113
113
|
[`motion:layoutId`]?: Kind extends `dom` ? string | number : never
|
|
114
114
|
[`motion:layoutGroup`]?: Kind extends `dom` ? string | number : never
|
|
115
115
|
[`motion:layoutScroll`]?: Kind extends `dom` ? boolean : never
|
|
116
|
+
/** Measure descendants relative to this instantly positioned layout ancestor. */
|
|
117
|
+
[`motion:layoutRoot`]?: Kind extends `dom` ? boolean : never
|
|
116
118
|
[`motion:layoutTransition`]?: Kind extends `dom`
|
|
117
119
|
? MotionLayoutTransition
|
|
118
120
|
: never
|
|
@@ -166,6 +168,7 @@ const layoutKeys = {
|
|
|
166
168
|
layoutId: `id`,
|
|
167
169
|
layoutGroup: `group`,
|
|
168
170
|
layoutScroll: `scroll`,
|
|
171
|
+
layoutRoot: `root`,
|
|
169
172
|
layoutTransition: `transition`,
|
|
170
173
|
} as const
|
|
171
174
|
function equal(a: unknown, b: unknown): boolean {
|
package/src/presence.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { CapabilityBinding } from "./capabilities.ts"
|
|
2
2
|
import type { Cleanup, Root, Scope } from "./core.ts"
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
dispose,
|
|
5
|
+
invalidate,
|
|
6
|
+
isPresent,
|
|
7
|
+
reportScopeError,
|
|
8
|
+
untrack,
|
|
9
|
+
} from "./core.ts"
|
|
4
10
|
|
|
5
11
|
export interface ExitHandle {
|
|
6
12
|
finished: Promise<void>
|
|
@@ -15,7 +21,7 @@ export interface PresenceTarget {
|
|
|
15
21
|
node: unknown
|
|
16
22
|
suspend?(): Cleanup
|
|
17
23
|
}
|
|
18
|
-
interface PresenceCollection<T, V> {
|
|
24
|
+
export interface PresenceCollection<T, V> {
|
|
19
25
|
take(key: unknown, value: V): T | undefined
|
|
20
26
|
remove(
|
|
21
27
|
record: T,
|
|
@@ -39,7 +45,6 @@ export interface PresenceCoordinator {
|
|
|
39
45
|
namespace: string,
|
|
40
46
|
): void
|
|
41
47
|
unbind(binding: CapabilityBinding): void
|
|
42
|
-
event(scope: Scope, handler: Function): Function
|
|
43
48
|
remove(scope: Scope, done: Cleanup): boolean
|
|
44
49
|
resume(scope: Scope): void
|
|
45
50
|
forget(scope: Scope): void
|
|
@@ -60,7 +65,6 @@ interface Group {
|
|
|
60
65
|
/** Optional coordinator: only imported by integrations that support retention. */
|
|
61
66
|
export function createPresence(root: Root): PresenceCoordinator {
|
|
62
67
|
const releases = new Map<CapabilityBinding, Cleanup>()
|
|
63
|
-
const handlers = new WeakMap<Scope, WeakMap<Function, Function>>()
|
|
64
68
|
// Groups own absent ranges; sessions can be shared when a parent adopts a child exit.
|
|
65
69
|
const groups = new Map<Scope, Group>()
|
|
66
70
|
const sessions = new Set<Session>()
|
|
@@ -103,14 +107,6 @@ export function createPresence(root: Root): PresenceCoordinator {
|
|
|
103
107
|
if (at === parent) return true
|
|
104
108
|
return false
|
|
105
109
|
}
|
|
106
|
-
const report = (error: unknown) => {
|
|
107
|
-
if (root._dead) return
|
|
108
|
-
try {
|
|
109
|
-
fail(root, error)
|
|
110
|
-
} catch (failure) {
|
|
111
|
-
root.error(failure)
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
110
|
const finish = () => {
|
|
115
111
|
for (const group of [...groups.values()]) {
|
|
116
112
|
if (group.scope._dead || group.sessions.some((session) => !session.done))
|
|
@@ -125,7 +121,7 @@ export function createPresence(root: Root): PresenceCoordinator {
|
|
|
125
121
|
try {
|
|
126
122
|
group.done()
|
|
127
123
|
} catch (error) {
|
|
128
|
-
|
|
124
|
+
if (!root._dead) reportScopeError(group.scope, error)
|
|
129
125
|
}
|
|
130
126
|
}
|
|
131
127
|
}
|
|
@@ -169,15 +165,6 @@ export function createPresence(root: Root): PresenceCoordinator {
|
|
|
169
165
|
unbind(binding) {
|
|
170
166
|
releases.get(binding)?.()
|
|
171
167
|
},
|
|
172
|
-
event(scope, handler) {
|
|
173
|
-
const cached = handlers.get(scope) ?? new WeakMap<Function, Function>()
|
|
174
|
-
handlers.set(scope, cached)
|
|
175
|
-
if (!cached.has(handler))
|
|
176
|
-
cached.set(handler, function (this: unknown, ...args: unknown[]) {
|
|
177
|
-
if (isPresent(scope)) return handler.apply(this, args)
|
|
178
|
-
})
|
|
179
|
-
return cached.get(handler)!
|
|
180
|
-
},
|
|
181
168
|
collection<T, V>(
|
|
182
169
|
scopeOf: (record: T) => Scope,
|
|
183
170
|
compatible: (record: T, value: V) => boolean,
|
|
@@ -257,7 +244,8 @@ export function createPresence(root: Root): PresenceCoordinator {
|
|
|
257
244
|
finish()
|
|
258
245
|
},
|
|
259
246
|
(error) => {
|
|
260
|
-
if (!held.cancelled
|
|
247
|
+
if (!held.cancelled && !root._dead)
|
|
248
|
+
reportScopeError(held.scope, error)
|
|
261
249
|
},
|
|
262
250
|
)
|
|
263
251
|
}
|
package/src/props.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Canonical } from "atom.io/foundations/canonical"
|
|
2
|
+
|
|
3
|
+
import type { SpaElement } from "./core.ts"
|
|
4
|
+
|
|
5
|
+
type Props = SpaElement[`props`]
|
|
6
|
+
type FixedKey = { value: Canonical | undefined; present: boolean }
|
|
7
|
+
|
|
8
|
+
function liveProps(values: () => Props[], fixedKey?: FixedKey): Props {
|
|
9
|
+
const source = (name: PropertyKey) =>
|
|
10
|
+
values()
|
|
11
|
+
.reverse()
|
|
12
|
+
.find((props) => Object.hasOwn(props, name))
|
|
13
|
+
const has = (_: Props, name: PropertyKey): boolean =>
|
|
14
|
+
fixedKey && name === `key` ? fixedKey.present : source(name) !== undefined
|
|
15
|
+
return new Proxy(
|
|
16
|
+
{},
|
|
17
|
+
{
|
|
18
|
+
has,
|
|
19
|
+
get(_, name) {
|
|
20
|
+
if (fixedKey && name === `key`) return fixedKey.value
|
|
21
|
+
const props = source(name)
|
|
22
|
+
return props && Reflect.get(props, name)
|
|
23
|
+
},
|
|
24
|
+
ownKeys() {
|
|
25
|
+
const keys = new Set(values().flatMap(Object.keys))
|
|
26
|
+
if (fixedKey?.present) keys.add(`key`)
|
|
27
|
+
else if (fixedKey) keys.delete(`key`)
|
|
28
|
+
return [...keys]
|
|
29
|
+
},
|
|
30
|
+
getOwnPropertyDescriptor(_, name) {
|
|
31
|
+
if (has(_, name)) return { enumerable: true, configurable: true }
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Preserve lazy props and spread precedence, including keys added by later updates. */
|
|
38
|
+
export function merge(...sources: (Props | (() => Props))[]): Props {
|
|
39
|
+
return liveProps(() =>
|
|
40
|
+
sources.map(
|
|
41
|
+
(source) => (typeof source === `function` ? source() : source) ?? {},
|
|
42
|
+
),
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Expose the first key while leaving data props live, including through spreads. */
|
|
47
|
+
export function instanceProps(
|
|
48
|
+
read: () => Props,
|
|
49
|
+
key: Canonical | undefined,
|
|
50
|
+
): Props {
|
|
51
|
+
return liveProps(() => [read()], {
|
|
52
|
+
value: key,
|
|
53
|
+
present: key !== undefined || Object.hasOwn(read(), `key`),
|
|
54
|
+
})
|
|
55
|
+
}
|