@atom.io/spa 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +254 -6
- package/README.mdx +83 -1
- package/dist/astro-application.d.ts +1 -1
- package/dist/astro-application.js +2 -2
- package/dist/astro-application.js.map +1 -1
- package/dist/astro-client.d.ts +1 -1
- package/dist/astro-client.js +6 -3
- package/dist/astro-client.js.map +1 -1
- package/dist/astro-server.js +2 -1
- 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-BkWvVZWZ.d.ts} +4 -2
- package/dist/astro-shared-BkWvVZWZ.d.ts.map +1 -0
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +1 -1
- package/dist/capabilities-BkQ2i0vV.js +63 -0
- package/dist/capabilities-BkQ2i0vV.js.map +1 -0
- package/dist/capabilities-CFP-HIuY.d.ts +115 -0
- package/dist/capabilities-CFP-HIuY.d.ts.map +1 -0
- package/dist/client.min.js +1 -1
- package/dist/{core-Dvqm7w2y.js → core-DCmqLZQP.js} +23 -4
- package/dist/core-DCmqLZQP.js.map +1 -0
- package/dist/development/astro-application.js +2 -2
- package/dist/development/astro-application.js.map +1 -1
- package/dist/development/astro-client.js +6 -3
- package/dist/development/astro-client.js.map +1 -1
- package/dist/development/astro-server.js +2 -1
- 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/capabilities-BkQ2i0vV.js +63 -0
- package/dist/development/capabilities-BkQ2i0vV.js.map +1 -0
- package/dist/development/{core-DB3sQz4h.js → core-p9vciX9C.js} +23 -4
- package/dist/development/core-p9vciX9C.js.map +1 -0
- package/dist/development/{dom-D9cY6l1R.js → dom-Ci1XvbVJ.js} +21 -7
- package/dist/development/dom-Ci1XvbVJ.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 +143 -0
- package/dist/development/konva.js.map +1 -0
- package/dist/development/motion.js +601 -0
- package/dist/development/motion.js.map +1 -0
- package/dist/development/renderer.js +190 -0
- package/dist/development/renderer.js.map +1 -0
- package/dist/development/server.js +4 -2
- package/dist/development/server.js.map +1 -1
- package/dist/development/src-DG0xjuS5.js +38 -0
- package/dist/development/src-DG0xjuS5.js.map +1 -0
- package/dist/development/three.js +452 -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-dHQM0O7Q.js} +21 -7
- package/dist/dom-dHQM0O7Q.js.map +1 -0
- package/dist/index-CJJXcKaw.d.ts +24 -0
- package/dist/index-CJJXcKaw.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-CREZYKDC.d.ts} +6 -4
- package/dist/jsx-runtime-CREZYKDC.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 +143 -0
- package/dist/konva.js.map +1 -0
- package/dist/motion.d.ts +45 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +601 -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 +190 -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 +4 -2
- package/dist/server.js.map +1 -1
- package/dist/size.json +16 -16
- package/dist/src-DCQa6qxs.js +38 -0
- package/dist/src-DCQa6qxs.js.map +1 -0
- package/dist/three.d.ts +110 -0
- package/dist/three.d.ts.map +1 -0
- package/dist/three.js +452 -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 +62 -15
- package/src/astro-application.ts +2 -2
- 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 +107 -0
- package/src/compiler.ts +251 -178
- package/src/core.ts +38 -2
- package/src/dom.ts +38 -4
- 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 +186 -0
- package/src/motion-tween.ts +106 -0
- package/src/motion.ts +519 -0
- package/src/presence.ts +324 -0
- package/src/renderer.ts +278 -0
- package/src/server.ts +3 -0
- package/src/three-events.ts +342 -0
- package/src/three.ts +373 -0
- package/dist/astro-shared-DkZaqX7L.d.ts.map +0 -1
- package/dist/core-BhiA9fFi.d.ts +0 -44
- 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-CQchIQ_-.js +0 -126
- package/dist/development/vite-CQchIQ_-.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-CQchIQ_-.js +0 -126
- package/dist/vite-CQchIQ_-.js.map +0 -1
package/dist/konva.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { n as capabilityProps } from "./capabilities-BkQ2i0vV.js";
|
|
2
|
+
import { c as onCleanup, l as onMount, u as owner } from "./core-DCmqLZQP.js";
|
|
3
|
+
import { jsx } from "./jsx-runtime.js";
|
|
4
|
+
import { bindScene, createSceneRenderer, sceneComponent } from "./renderer.js";
|
|
5
|
+
import Konva from "konva";
|
|
6
|
+
// src/konva.ts
|
|
7
|
+
const constructors = {
|
|
8
|
+
Layer: Konva.Layer,
|
|
9
|
+
Group: Konva.Group,
|
|
10
|
+
Rect: Konva.Rect,
|
|
11
|
+
Circle: Konva.Circle,
|
|
12
|
+
Ellipse: Konva.Ellipse,
|
|
13
|
+
Line: Konva.Line,
|
|
14
|
+
Text: Konva.Text,
|
|
15
|
+
Image: Konva.Image,
|
|
16
|
+
Path: Konva.Path,
|
|
17
|
+
Star: Konva.Star,
|
|
18
|
+
Transformer: Konva.Transformer
|
|
19
|
+
};
|
|
20
|
+
function suspendNode(node) {
|
|
21
|
+
const listening = node.listening();
|
|
22
|
+
const draggable = node.draggable();
|
|
23
|
+
node.listening(false);
|
|
24
|
+
node.draggable(false);
|
|
25
|
+
return () => {
|
|
26
|
+
node.listening(listening);
|
|
27
|
+
node.draggable(draggable);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function updateNode(node, props, previous) {
|
|
31
|
+
for (const key of /* @__PURE__ */ new Set([...Object.keys(previous), ...Object.keys(props)])) {
|
|
32
|
+
if (/^(key|children|ref)$/.test(key) || Object.is(props[key], previous[key])) continue;
|
|
33
|
+
if (key.startsWith(`on`)) {
|
|
34
|
+
const event = key.slice(2).toLowerCase();
|
|
35
|
+
if (previous[key]) node.off(event, previous[key]);
|
|
36
|
+
if (props[key]) node.on(event, props[key]);
|
|
37
|
+
} else node.setAttr(key, props[key]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const renderer = createSceneRenderer({
|
|
41
|
+
target(node) {
|
|
42
|
+
return {
|
|
43
|
+
kind: `konva`,
|
|
44
|
+
node,
|
|
45
|
+
suspend() {
|
|
46
|
+
return suspendNode(node);
|
|
47
|
+
},
|
|
48
|
+
read: (key) => node.getAttr(key),
|
|
49
|
+
write: (key, value) => {
|
|
50
|
+
node.setAttr(key, value);
|
|
51
|
+
},
|
|
52
|
+
listen(event, listener) {
|
|
53
|
+
node.on(event, listener);
|
|
54
|
+
return () => {
|
|
55
|
+
node.off(event, listener);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
create(type) {
|
|
61
|
+
const Constructor = constructors[type];
|
|
62
|
+
if (!Constructor) throw new Error(`spa/konva: unknown node ${type}`);
|
|
63
|
+
return new Constructor({});
|
|
64
|
+
},
|
|
65
|
+
update: updateNode,
|
|
66
|
+
children(parent, children) {
|
|
67
|
+
if (children.length && !(parent instanceof Konva.Container)) throw new Error(`spa/konva: shapes cannot contain children`);
|
|
68
|
+
if (parent instanceof Konva.Container) {
|
|
69
|
+
for (const child of [...parent.getChildren()]) if (!children.includes(child)) child.remove();
|
|
70
|
+
children.forEach((child, index) => {
|
|
71
|
+
if (child.getParent() !== parent) parent.add(child);
|
|
72
|
+
child.zIndex(index);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
destroy(node) {
|
|
77
|
+
node.off();
|
|
78
|
+
node.destroy();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
/** A DOM boundary owning a Konva stage and its scene subtree. */
|
|
82
|
+
function Stage(props) {
|
|
83
|
+
let container = null;
|
|
84
|
+
onMount(() => {
|
|
85
|
+
const surface = container.ownerDocument.createElement(`div`);
|
|
86
|
+
container.append(surface);
|
|
87
|
+
onCleanup(() => {
|
|
88
|
+
surface.remove();
|
|
89
|
+
});
|
|
90
|
+
const stage = new Konva.Stage({
|
|
91
|
+
container: surface,
|
|
92
|
+
width: props.width ?? 300,
|
|
93
|
+
height: props.height ?? 150
|
|
94
|
+
});
|
|
95
|
+
onCleanup(() => {
|
|
96
|
+
stage.off();
|
|
97
|
+
stage.destroy();
|
|
98
|
+
});
|
|
99
|
+
const nativeProps = capabilityProps(owner, {
|
|
100
|
+
kind: `konva`,
|
|
101
|
+
node: stage,
|
|
102
|
+
suspend() {
|
|
103
|
+
return suspendNode(stage);
|
|
104
|
+
},
|
|
105
|
+
listen(event, listener) {
|
|
106
|
+
stage.on(event, listener);
|
|
107
|
+
return () => {
|
|
108
|
+
stage.off(event, listener);
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
read: (key) => stage.getAttr(key),
|
|
112
|
+
write: (key, value) => {
|
|
113
|
+
stage.setAttr(key, value);
|
|
114
|
+
}
|
|
115
|
+
}, () => ({ ...props }));
|
|
116
|
+
let previous = {};
|
|
117
|
+
bindScene(() => ({ ...props }), (all) => {
|
|
118
|
+
const next = nativeProps(all);
|
|
119
|
+
updateNode(stage, next, previous);
|
|
120
|
+
previous = next;
|
|
121
|
+
});
|
|
122
|
+
props.ref?.(stage);
|
|
123
|
+
onCleanup(() => props.ref?.(null));
|
|
124
|
+
renderer.mount(() => props.children, stage);
|
|
125
|
+
});
|
|
126
|
+
return jsx(`div`, { ref: (element) => {
|
|
127
|
+
container = element;
|
|
128
|
+
} });
|
|
129
|
+
}
|
|
130
|
+
const Layer = sceneComponent(`Layer`);
|
|
131
|
+
const Group = sceneComponent(`Group`);
|
|
132
|
+
const Rect = sceneComponent(`Rect`);
|
|
133
|
+
const Circle = sceneComponent(`Circle`);
|
|
134
|
+
const Ellipse = sceneComponent(`Ellipse`);
|
|
135
|
+
const Line = sceneComponent(`Line`);
|
|
136
|
+
const Text = sceneComponent(`Text`);
|
|
137
|
+
const Image = sceneComponent(`Image`);
|
|
138
|
+
const Path = sceneComponent(`Path`);
|
|
139
|
+
const Star = sceneComponent(`Star`);
|
|
140
|
+
const Transformer = sceneComponent(`Transformer`);
|
|
141
|
+
export { Circle, Ellipse, Group, Image, Layer, Line, Path, Rect, Stage, Star, Text, Transformer, renderer as konvaRenderer };
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=konva.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"konva.js","names":[],"sources":["../src/konva.ts"],"sourcesContent":["import Konva from \"konva\"\n\nimport { capabilityProps } from \"./capabilities.ts\"\nimport { owner } from \"./core.ts\"\nimport type { Child, VNode } from \"./index.ts\"\nimport { onCleanup, onMount } from \"./index.ts\"\nimport type { CapabilityAttributes } from \"./jsx-runtime.ts\"\nimport { jsx } from \"./jsx-runtime.ts\"\nimport { bindScene, createSceneRenderer, sceneComponent } from \"./renderer.ts\"\n\ntype Props<C, N> = C &\n\tCapabilityAttributes<`konva`> & {\n\t\tchildren?: Child\n\t\tref?: (node: N | null) => void\n\t\tonClick?: (event: Konva.KonvaEventObject<MouseEvent>) => void\n\t\tonPointerDown?: (event: Konva.KonvaEventObject<PointerEvent>) => void\n\t\tonDragMove?: (event: Konva.KonvaEventObject<DragEvent>) => void\n\t\tonDragEnd?: (event: Konva.KonvaEventObject<DragEvent>) => void\n\t}\nconst constructors = {\n\tLayer: Konva.Layer,\n\tGroup: Konva.Group,\n\tRect: Konva.Rect,\n\tCircle: Konva.Circle,\n\tEllipse: Konva.Ellipse,\n\tLine: Konva.Line,\n\tText: Konva.Text,\n\tImage: Konva.Image,\n\tPath: Konva.Path,\n\tStar: Konva.Star,\n\tTransformer: Konva.Transformer,\n}\nfunction suspendNode(node: Konva.Node): () => void {\n\tconst listening = node.listening()\n\tconst draggable = node.draggable()\n\tnode.listening(false)\n\t// The public setter clears both pending and active native drag records.\n\tnode.draggable(false)\n\treturn () => {\n\t\tnode.listening(listening)\n\t\tnode.draggable(draggable)\n\t}\n}\nfunction updateNode(\n\tnode: Konva.Node,\n\tprops: Record<string, any>,\n\tprevious: Record<string, any>,\n): void {\n\tfor (const key of new Set([...Object.keys(previous), ...Object.keys(props)])) {\n\t\tif (/^(key|children|ref)$/.test(key) || Object.is(props[key], previous[key]))\n\t\t\tcontinue\n\t\tif (key.startsWith(`on`)) {\n\t\t\tconst event = key.slice(2).toLowerCase()\n\t\t\tif (previous[key]) node.off(event, previous[key])\n\t\t\tif (props[key]) node.on(event, props[key])\n\t\t} else node.setAttr(key, props[key])\n\t}\n}\nconst renderer = createSceneRenderer<Konva.Node>({\n\ttarget(node) {\n\t\treturn {\n\t\t\tkind: `konva`,\n\t\t\tnode,\n\t\t\tsuspend() {\n\t\t\t\treturn suspendNode(node)\n\t\t\t},\n\t\t\tread: (key) => node.getAttr(key),\n\t\t\twrite: (key, value) => {\n\t\t\t\tnode.setAttr(key, value)\n\t\t\t},\n\t\t\tlisten(event, listener) {\n\t\t\t\tnode.on(event, listener)\n\t\t\t\treturn () => {\n\t\t\t\t\tnode.off(event, listener)\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t},\n\tcreate(type) {\n\t\tconst Constructor = constructors[type as keyof typeof constructors]\n\t\tif (!Constructor) throw new Error(`spa/konva: unknown node ${type}`)\n\t\treturn new Constructor({} as any)\n\t},\n\tupdate: updateNode,\n\tchildren(parent, children) {\n\t\tif (children.length && !(parent instanceof Konva.Container))\n\t\t\tthrow new Error(`spa/konva: shapes cannot contain children`)\n\t\tif (parent instanceof Konva.Container) {\n\t\t\tfor (const child of [...parent.getChildren()])\n\t\t\t\tif (!children.includes(child)) child.remove()\n\t\t\tchildren.forEach((child, index) => {\n\t\t\t\tif (child.getParent() !== parent) parent.add(child as any)\n\t\t\t\tchild.zIndex(index)\n\t\t\t})\n\t\t}\n\t},\n\tdestroy(node) {\n\t\tnode.off()\n\t\tnode.destroy()\n\t},\n})\n\n/** A DOM boundary owning a Konva stage and its scene subtree. */\nexport function Stage(\n\tprops: Props<Omit<Konva.StageConfig, `container`>, Konva.Stage> & {\n\t\twidth?: number\n\t\theight?: number\n\t},\n): VNode {\n\tlet container: HTMLDivElement | null = null\n\tonMount(() => {\n\t\t// Konva clears its container; preserve SPA's markers in the outer element.\n\t\tconst surface = container!.ownerDocument.createElement(`div`)\n\t\tcontainer!.append(surface)\n\t\tonCleanup(() => {\n\t\t\tsurface.remove()\n\t\t})\n\t\tconst stage = new Konva.Stage({\n\t\t\tcontainer: surface,\n\t\t\twidth: props.width ?? 300,\n\t\t\theight: props.height ?? 150,\n\t\t})\n\t\tonCleanup(() => {\n\t\t\tstage.off()\n\t\t\tstage.destroy()\n\t\t})\n\t\tconst nativeProps = capabilityProps(\n\t\t\towner!,\n\t\t\t{\n\t\t\t\tkind: `konva`,\n\t\t\t\tnode: stage,\n\t\t\t\tsuspend() {\n\t\t\t\t\treturn suspendNode(stage)\n\t\t\t\t},\n\t\t\t\tlisten(event, listener) {\n\t\t\t\t\tstage.on(event, listener)\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tstage.off(event, listener)\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tread: (key) => stage.getAttr(key),\n\t\t\t\twrite: (key, value) => {\n\t\t\t\t\tstage.setAttr(key, value)\n\t\t\t\t},\n\t\t\t},\n\t\t\t() => ({ ...props }),\n\t\t)\n\t\tlet previous: Record<string, any> = {}\n\t\tbindScene(\n\t\t\t() => ({ ...props }),\n\t\t\t(all) => {\n\t\t\t\tconst next = nativeProps(all)\n\t\t\t\tupdateNode(stage, next, previous)\n\t\t\t\tprevious = next\n\t\t\t},\n\t\t)\n\t\tprops.ref?.(stage)\n\t\tonCleanup(() => props.ref?.(null))\n\t\trenderer.mount(() => props.children, stage)\n\t})\n\treturn jsx(`div`, {\n\t\tref: (element: HTMLDivElement | null) => {\n\t\t\tcontainer = element\n\t\t},\n\t})\n}\nexport const Layer =\n\tsceneComponent<Props<Konva.LayerConfig, Konva.Layer>>(`Layer`)\nexport const Group =\n\tsceneComponent<Props<Konva.ContainerConfig, Konva.Group>>(`Group`)\nexport const Rect = sceneComponent<Props<Konva.RectConfig, Konva.Rect>>(`Rect`)\nexport const Circle =\n\tsceneComponent<Props<Konva.CircleConfig, Konva.Circle>>(`Circle`)\nexport const Ellipse =\n\tsceneComponent<Props<Konva.EllipseConfig, Konva.Ellipse>>(`Ellipse`)\nexport const Line = sceneComponent<Props<Konva.LineConfig, Konva.Line>>(`Line`)\nexport const Text = sceneComponent<Props<Konva.TextConfig, Konva.Text>>(`Text`)\nexport const Image =\n\tsceneComponent<Props<Konva.ImageConfig, Konva.Image>>(`Image`)\nexport const Path = sceneComponent<Props<Konva.PathConfig, Konva.Path>>(`Path`)\nexport const Star = sceneComponent<Props<Konva.StarConfig, Konva.Star>>(`Star`)\nexport const Transformer =\n\tsceneComponent<Props<Konva.TransformerConfig, Konva.Transformer>>(\n\t\t`Transformer`,\n\t)\nexport { renderer as konvaRenderer }\n"],"mappings":"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"}
|
package/dist/motion.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { t as Capability } from "./capabilities-CFP-HIuY.js";
|
|
2
|
+
export type MotionScalar = number | string;
|
|
3
|
+
export type MotionDOMTarget = Partial<Record<keyof CSSStyleDeclaration | `x` | `y` | `z` | `scale` | `scaleX` | `scaleY` | `rotate` | `rotateX` | `rotateY` | `rotateZ` | `skewX` | `skewY` | `--${string}`, MotionScalar>>;
|
|
4
|
+
export interface MotionThreeTarget {
|
|
5
|
+
position?: readonly [number, number, number];
|
|
6
|
+
rotation?: readonly [number, number, number];
|
|
7
|
+
scale?: number | readonly [number, number, number];
|
|
8
|
+
opacity?: number;
|
|
9
|
+
intensity?: number;
|
|
10
|
+
color?: string;
|
|
11
|
+
}
|
|
12
|
+
export type MotionTarget<Kind extends string> = Kind extends `dom` ? MotionDOMTarget : Kind extends `three` ? MotionThreeTarget : Record<string, MotionScalar>;
|
|
13
|
+
/** Supported transition options; keep public declarations independent of optional peer types. */
|
|
14
|
+
export interface MotionTransition {
|
|
15
|
+
type?: `spring` | `tween`;
|
|
16
|
+
stiffness?: number;
|
|
17
|
+
damping?: number;
|
|
18
|
+
mass?: number;
|
|
19
|
+
velocity?: number;
|
|
20
|
+
restSpeed?: number;
|
|
21
|
+
restDelta?: number;
|
|
22
|
+
bounce?: number;
|
|
23
|
+
visualDuration?: number;
|
|
24
|
+
duration?: number;
|
|
25
|
+
delay?: number;
|
|
26
|
+
ease?: `linear` | `easeIn` | `easeOut` | `easeInOut` | `circIn` | `circOut` | `circInOut` | `backIn` | `backOut` | `backInOut` | readonly [number, number, number, number];
|
|
27
|
+
}
|
|
28
|
+
export interface MotionAttributes<Kind extends string = `dom`> {
|
|
29
|
+
[`motion:initial`]?: MotionTarget<Kind> | false;
|
|
30
|
+
[`motion:animate`]?: MotionTarget<Kind>;
|
|
31
|
+
[`motion:exit`]?: MotionTarget<Kind>;
|
|
32
|
+
[`motion:transition`]?: MotionTransition;
|
|
33
|
+
[`motion:whileHover`]?: MotionTarget<Kind>;
|
|
34
|
+
[`motion:whileTap`]?: MotionTarget<Kind>;
|
|
35
|
+
}
|
|
36
|
+
declare module "@atom.io/spa/jsx-runtime" {
|
|
37
|
+
interface CapabilityAttributes<Kind extends string> extends MotionAttributes<Kind> {}
|
|
38
|
+
}
|
|
39
|
+
export interface MotionCapabilityOptions {
|
|
40
|
+
/** Respect the user's reduced-motion preference by default. */
|
|
41
|
+
reducedMotion?: `user` | `always` | `never`;
|
|
42
|
+
}
|
|
43
|
+
/** Explicit, root-scoped motion:* integration. Importing it never registers globally. */
|
|
44
|
+
export declare function motionCapability(options?: MotionCapabilityOptions): Capability;
|
|
45
|
+
//# sourceMappingURL=motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.d.ts","names":[],"sources":["../src/motion.ts"],"mappings":";YAoBY;YACA,kBAAkB,QAC7B,aACS,0JAcR;iBAGe;EAChB;EACA;EACA;EACA;EACA;EACA;;YAEW,aAAa,uBAAuB,qBAC7C,kBACA,uBACC,oBACA,eAAe;;iBAEF;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAagB,iBAAiB;GAChC,oBAAoB,aAAa;GACjC,oBAAoB,aAAa;GACjC,iBAAiB,aAAa;GAC9B,uBAAuB;GACvB,uBAAuB,aAAa;GACpC,qBAAqB,aAAa;;;YAMzB,qBACT,6BACS,iBAAiB;;iBAGX;;EAEhB;;;wBAmZe,iBACf,UAAS,0BACP"}
|