@ghia/native 0.0.0 → 0.11.0
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/LICENSE +201 -0
- package/browser.mjs +7 -0
- package/dist/aria.d.ts +72 -0
- package/dist/aria.d.ts.map +1 -0
- package/dist/aria.js +2 -0
- package/dist/aria.js.map +1 -0
- package/dist/automation/client.d.ts +243 -0
- package/dist/automation/client.d.ts.map +1 -0
- package/dist/automation/client.js +801 -0
- package/dist/automation/client.js.map +1 -0
- package/dist/automation/index.d.ts +5 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +4 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/protocol.d.ts +309 -0
- package/dist/automation/protocol.d.ts.map +1 -0
- package/dist/automation/protocol.js +320 -0
- package/dist/automation/protocol.js.map +1 -0
- package/dist/blob-images.d.ts +32 -0
- package/dist/blob-images.d.ts.map +1 -0
- package/dist/blob-images.js +55 -0
- package/dist/blob-images.js.map +1 -0
- package/dist/bounds.d.ts +61 -0
- package/dist/bounds.d.ts.map +1 -0
- package/dist/bounds.js +85 -0
- package/dist/bounds.js.map +1 -0
- package/dist/clipboard-global.d.ts +11 -0
- package/dist/clipboard-global.d.ts.map +1 -0
- package/dist/clipboard-global.js +2 -0
- package/dist/clipboard-global.js.map +1 -0
- package/dist/clipboard.d.ts +19 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +41 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/cpu-throttle.d.ts +6 -0
- package/dist/cpu-throttle.d.ts.map +1 -0
- package/dist/cpu-throttle.js +42 -0
- package/dist/cpu-throttle.js.map +1 -0
- package/dist/events/data-transfer.d.ts +23 -0
- package/dist/events/data-transfer.d.ts.map +1 -0
- package/dist/events/data-transfer.js +97 -0
- package/dist/events/data-transfer.js.map +1 -0
- package/dist/events/dispatch.d.ts +144 -0
- package/dist/events/dispatch.d.ts.map +1 -0
- package/dist/events/dispatch.js +241 -0
- package/dist/events/dispatch.js.map +1 -0
- package/dist/events/drag.d.ts +21 -0
- package/dist/events/drag.d.ts.map +1 -0
- package/dist/events/drag.js +111 -0
- package/dist/events/drag.js.map +1 -0
- package/dist/events/event-props.d.ts +19 -0
- package/dist/events/event-props.d.ts.map +1 -0
- package/dist/events/event-props.js +104 -0
- package/dist/events/event-props.js.map +1 -0
- package/dist/events/keyboard-defaults.d.ts +18 -0
- package/dist/events/keyboard-defaults.d.ts.map +1 -0
- package/dist/events/keyboard-defaults.js +121 -0
- package/dist/events/keyboard-defaults.js.map +1 -0
- package/dist/events/listeners.d.ts +18 -0
- package/dist/events/listeners.d.ts.map +1 -0
- package/dist/events/listeners.js +49 -0
- package/dist/events/listeners.js.map +1 -0
- package/dist/events/route.d.ts +17 -0
- package/dist/events/route.d.ts.map +1 -0
- package/dist/events/route.js +36 -0
- package/dist/events/route.js.map +1 -0
- package/dist/events/types.d.ts +269 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +2 -0
- package/dist/events/types.js.map +1 -0
- package/dist/events/window-target.d.ts +120 -0
- package/dist/events/window-target.d.ts.map +1 -0
- package/dist/events/window-target.js +311 -0
- package/dist/events/window-target.js.map +1 -0
- package/dist/eyedropper.d.ts +33 -0
- package/dist/eyedropper.d.ts.map +1 -0
- package/dist/eyedropper.js +66 -0
- package/dist/eyedropper.js.map +1 -0
- package/dist/focus.d.ts +18 -0
- package/dist/focus.d.ts.map +1 -0
- package/dist/focus.js +26 -0
- package/dist/focus.js.map +1 -0
- package/dist/fonts.d.ts +12 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +17 -0
- package/dist/fonts.js.map +1 -0
- package/dist/forms.d.ts +10 -0
- package/dist/forms.d.ts.map +1 -0
- package/dist/forms.js +9 -0
- package/dist/forms.js.map +1 -0
- package/dist/host-runtime.d.ts +108 -0
- package/dist/host-runtime.d.ts.map +1 -0
- package/dist/host-runtime.js +213 -0
- package/dist/host-runtime.js.map +1 -0
- package/dist/host.d.ts +2403 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +30 -0
- package/dist/host.js.map +1 -0
- package/dist/idle-gc.d.ts +36 -0
- package/dist/idle-gc.d.ts.map +1 -0
- package/dist/idle-gc.js +70 -0
- package/dist/idle-gc.js.map +1 -0
- package/dist/keyframes.d.ts +108 -0
- package/dist/keyframes.d.ts.map +1 -0
- package/dist/keyframes.js +107 -0
- package/dist/keyframes.js.map +1 -0
- package/dist/layout-animation.d.ts +38 -0
- package/dist/layout-animation.d.ts.map +1 -0
- package/dist/layout-animation.js +41 -0
- package/dist/layout-animation.js.map +1 -0
- package/dist/match-media.d.ts +62 -0
- package/dist/match-media.d.ts.map +1 -0
- package/dist/match-media.js +272 -0
- package/dist/match-media.js.map +1 -0
- package/dist/media-query.d.ts +21 -0
- package/dist/media-query.d.ts.map +1 -0
- package/dist/media-query.js +599 -0
- package/dist/media-query.js.map +1 -0
- package/dist/motion-bindings.d.ts +36 -0
- package/dist/motion-bindings.d.ts.map +1 -0
- package/dist/motion-bindings.js +107 -0
- package/dist/motion-bindings.js.map +1 -0
- package/dist/motion-config.d.ts +20 -0
- package/dist/motion-config.d.ts.map +1 -0
- package/dist/motion-config.js +51 -0
- package/dist/motion-config.js.map +1 -0
- package/dist/motion-span.d.ts +57 -0
- package/dist/motion-span.d.ts.map +1 -0
- package/dist/motion-span.js +150 -0
- package/dist/motion-span.js.map +1 -0
- package/dist/motion-value.d.ts +269 -0
- package/dist/motion-value.d.ts.map +1 -0
- package/dist/motion-value.js +941 -0
- package/dist/motion-value.js.map +1 -0
- package/dist/motion-variants.d.ts +190 -0
- package/dist/motion-variants.d.ts.map +1 -0
- package/dist/motion-variants.js +249 -0
- package/dist/motion-variants.js.map +1 -0
- package/dist/mutations.d.ts +65 -0
- package/dist/mutations.d.ts.map +1 -0
- package/dist/mutations.js +320 -0
- package/dist/mutations.js.map +1 -0
- package/dist/nativeview.d.ts +10 -0
- package/dist/nativeview.d.ts.map +1 -0
- package/dist/nativeview.js +92 -0
- package/dist/nativeview.js.map +1 -0
- package/dist/observers.d.ts +92 -0
- package/dist/observers.d.ts.map +1 -0
- package/dist/observers.js +579 -0
- package/dist/observers.js.map +1 -0
- package/dist/presence.d.ts +63 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +54 -0
- package/dist/presence.js.map +1 -0
- package/dist/renderer-state.d.ts +155 -0
- package/dist/renderer-state.d.ts.map +1 -0
- package/dist/renderer-state.js +302 -0
- package/dist/renderer-state.js.map +1 -0
- package/dist/reorder.d.ts +63 -0
- package/dist/reorder.d.ts.map +1 -0
- package/dist/reorder.js +303 -0
- package/dist/reorder.js.map +1 -0
- package/dist/runtime.d.ts +23 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +157 -0
- package/dist/runtime.js.map +1 -0
- package/dist/screen.d.ts +8 -0
- package/dist/screen.d.ts.map +1 -0
- package/dist/screen.js +16 -0
- package/dist/screen.js.map +1 -0
- package/dist/scroll.d.ts +79 -0
- package/dist/scroll.d.ts.map +1 -0
- package/dist/scroll.js +170 -0
- package/dist/scroll.js.map +1 -0
- package/dist/style-images.d.ts +20 -0
- package/dist/style-images.d.ts.map +1 -0
- package/dist/style-images.js +57 -0
- package/dist/style-images.js.map +1 -0
- package/dist/svg.d.ts +16 -0
- package/dist/svg.d.ts.map +1 -0
- package/dist/svg.js +119 -0
- package/dist/svg.js.map +1 -0
- package/dist/testing.d.ts +811 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +1187 -0
- package/dist/testing.js.map +1 -0
- package/dist/text-match.d.ts +8 -0
- package/dist/text-match.d.ts.map +1 -0
- package/dist/text-match.js +10 -0
- package/dist/text-match.js.map +1 -0
- package/dist/text-selection.d.ts +34 -0
- package/dist/text-selection.d.ts.map +1 -0
- package/dist/text-selection.js +23 -0
- package/dist/text-selection.js.map +1 -0
- package/dist/universal-style.d.ts +22 -0
- package/dist/universal-style.d.ts.map +1 -0
- package/dist/universal-style.js +58 -0
- package/dist/universal-style.js.map +1 -0
- package/dist/web-animations.d.ts +300 -0
- package/dist/web-animations.d.ts.map +1 -0
- package/dist/web-animations.js +1032 -0
- package/dist/web-animations.js.map +1 -0
- package/dist/webview.d.ts +39 -0
- package/dist/webview.d.ts.map +1 -0
- package/dist/webview.js +26 -0
- package/dist/webview.js.map +1 -0
- package/gpuix-native.darwin-arm64.node +4 -0
- package/index.cjs +789 -0
- package/index.d.ts +2603 -0
- package/index.js +729 -0
- package/package.json +96 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-bindings.d.ts","sourceRoot":"","sources":["../js/motion-bindings.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAG5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACnC,QAAQ,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAA;CAC5B,CAAA;AAED,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,cAAc,CAAA;IAC9B,uDAAuD;IACvD,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC1C,8FAA8F;IAC9F,cAAc,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAA;CAClC;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC/B;IAAE,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,SAAS,CAAA;CAAE,CAezF;AAID;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAS/D;AAaD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,iBAAiB,EACvB,SAAS,EAAE,IAAI,CAAC,gBAAgB,EAAE,eAAe,CAAC,EAClD,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,SAAS;AAC7C,uEAAuE;AACvE,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI,CA0BN;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAO1F;AAED,qDAAqD;AACrD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAG/D"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/// Style entries that are motion values do not travel as style: they bind the
|
|
2
|
+
/// value to the element's window and go to native as the `motionValues`
|
|
3
|
+
/// custom prop, which samples them every frame. The framework adapters share
|
|
4
|
+
/// this; each owns a `MotionBindingHost` on its root.
|
|
5
|
+
import { assertSpanMotionValues } from "./motion-span.js";
|
|
6
|
+
import { isMotionValue } from "./motion-value.js";
|
|
7
|
+
export function splitMotionStyle(style) {
|
|
8
|
+
if (style == null)
|
|
9
|
+
return { style: undefined, motionValues: undefined };
|
|
10
|
+
let motionValues;
|
|
11
|
+
const plain = {};
|
|
12
|
+
for (const key of Object.keys(style)) {
|
|
13
|
+
const value = Reflect.get(style, key);
|
|
14
|
+
if (isMotionValue(value)) {
|
|
15
|
+
motionValues ??= {};
|
|
16
|
+
motionValues[key] = value;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
plain[key] = value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// Untouched when it holds no motion value, so the common style is not copied.
|
|
23
|
+
return { style: (motionValues ? plain : style), motionValues };
|
|
24
|
+
}
|
|
25
|
+
const MOTION_TRANSFORM_WIRE_NAMES = { scale: "motionScale", rotate: "motionRotate" };
|
|
26
|
+
/**
|
|
27
|
+
* The style of a motion component: its static `scale` and `rotate` are Motion's, which native knows
|
|
28
|
+
* under other names so that they do not meet the CSS properties. A motion value keeps its key, which
|
|
29
|
+
* native reads as Motion's too.
|
|
30
|
+
*/
|
|
31
|
+
export function motionComponentStyle(style) {
|
|
32
|
+
if (typeof style !== "object" || style === null)
|
|
33
|
+
return style;
|
|
34
|
+
if (!Object.hasOwn(style, "scale") && !Object.hasOwn(style, "rotate"))
|
|
35
|
+
return style;
|
|
36
|
+
const renamed = {};
|
|
37
|
+
for (const key of Object.keys(style)) {
|
|
38
|
+
const value = Reflect.get(style, key);
|
|
39
|
+
renamed[isMotionValue(value) ? key : (MOTION_TRANSFORM_WIRE_NAMES[key] ?? key)] = value;
|
|
40
|
+
}
|
|
41
|
+
return renamed;
|
|
42
|
+
}
|
|
43
|
+
function sameBindings(left, right) {
|
|
44
|
+
if (left === right)
|
|
45
|
+
return true;
|
|
46
|
+
if (!left || !right)
|
|
47
|
+
return false;
|
|
48
|
+
const keys = Object.keys(left);
|
|
49
|
+
if (keys.length !== Object.keys(right).length)
|
|
50
|
+
return false;
|
|
51
|
+
return keys.every((key) => left[key] === right[key]);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Brings the element's binding in line with its style. New values are bound
|
|
55
|
+
* before the old are released, and the release waits for the batch that
|
|
56
|
+
* rebinds the element, so a value shared by both is never freed in between.
|
|
57
|
+
*/
|
|
58
|
+
export function syncMotionBindings(host, mutations, id, next,
|
|
59
|
+
/** The element type: a span can only bind what an inline box shows. */
|
|
60
|
+
type) {
|
|
61
|
+
if (type === "span")
|
|
62
|
+
assertSpanMotionValues(next);
|
|
63
|
+
const previous = host.motionBindings.get(id);
|
|
64
|
+
if (sameBindings(previous?.values, next))
|
|
65
|
+
return;
|
|
66
|
+
if (!next) {
|
|
67
|
+
if (previous)
|
|
68
|
+
host.motionReleases.push(...previous.releases);
|
|
69
|
+
host.motionBindings.delete(id);
|
|
70
|
+
mutations.setCustomProp(id, "motionValues", null);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const binding = { values: next, releases: [] };
|
|
74
|
+
const ids = {};
|
|
75
|
+
try {
|
|
76
|
+
for (const [property, value] of Object.entries(next)) {
|
|
77
|
+
binding.releases.push(value.bind(host.nativeRenderer));
|
|
78
|
+
ids[property] = value.id;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
for (const release of binding.releases)
|
|
83
|
+
release();
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
if (previous)
|
|
87
|
+
host.motionReleases.push(...previous.releases);
|
|
88
|
+
host.motionBindings.set(id, binding);
|
|
89
|
+
mutations.setCustomProp(id, "motionValues", ids);
|
|
90
|
+
}
|
|
91
|
+
/** Queues the releases of the elements that are going away, without running them. */
|
|
92
|
+
export function retireMotionBindings(host, ids) {
|
|
93
|
+
for (const id of ids) {
|
|
94
|
+
const binding = host.motionBindings.get(id);
|
|
95
|
+
if (!binding)
|
|
96
|
+
continue;
|
|
97
|
+
host.motionBindings.delete(id);
|
|
98
|
+
host.motionReleases.push(...binding.releases);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** Runs once the mutation batch has been applied. */
|
|
102
|
+
export function runMotionReleases(host) {
|
|
103
|
+
const releases = host.motionReleases.splice(0);
|
|
104
|
+
for (const release of releases)
|
|
105
|
+
release();
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=motion-bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-bindings.js","sourceRoot":"","sources":["../js/motion-bindings.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,wEAAwE;AACxE,6EAA6E;AAC7E,sDAAsD;AAGtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAgBjD,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,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAC9B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC/C,CAAC;AACH,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,iBAAiB,CAAC,IAAuB;IACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAC9C,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,OAAO,EAAE,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { MotionTransition } from "./host.js";
|
|
2
|
+
export type ReducedMotionSetting = "user" | "always" | "never";
|
|
3
|
+
export type MotionConfigValue = {
|
|
4
|
+
/** Used by a `motion.*` component that has no `transition` of its own. */
|
|
5
|
+
transition?: MotionTransition;
|
|
6
|
+
reducedMotion?: ReducedMotionSetting;
|
|
7
|
+
};
|
|
8
|
+
/** A nested config only overrides what it sets. */
|
|
9
|
+
export declare function mergeMotionConfig(parent: MotionConfigValue | undefined, own: MotionConfigValue): MotionConfigValue;
|
|
10
|
+
/** `prefersReduced` is the OS setting; `"never"` is the default, as in Framer. */
|
|
11
|
+
export declare function isReducedMotion(setting: ReducedMotionSetting | undefined, prefersReduced: boolean): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Makes `animate()` jump on the motion values `style` binds to `width`,
|
|
14
|
+
* `height`, `top`, `right`, `bottom` or `left`. Returns the release. A value
|
|
15
|
+
* bound to padding, opacity, a colour and the like keeps animating, and so
|
|
16
|
+
* does one that no element binds. Framer leaves a bare `animate(mv)` alone;
|
|
17
|
+
* gpuix reduces it so a bound size or inset follows the setting.
|
|
18
|
+
*/
|
|
19
|
+
export declare function reduceMotionValues(style: unknown): () => void;
|
|
20
|
+
//# sourceMappingURL=motion-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-config.d.ts","sourceRoot":"","sources":["../js/motion-config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAGjD,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAA;AAE9D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,0EAA0E;IAC1E,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,aAAa,CAAC,EAAE,oBAAoB,CAAA;CACrC,CAAA;AAED,mDAAmD;AACnD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,iBAAiB,GAAG,SAAS,EACrC,GAAG,EAAE,iBAAiB,GACrB,iBAAiB,CAKnB;AAED,kFAAkF;AAClF,wBAAgB,eAAe,CAC7B,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,cAAc,EAAE,OAAO,GACtB,OAAO,CAUT;AAKD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,IAAI,CAW7D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// What `MotionConfig` means to the adapters, shared by React and Solid: the
|
|
2
|
+
/// reduced-motion setting, how nested configs combine, and the reduction of
|
|
3
|
+
/// motion values that an element binds to `width`, `height` or an inset.
|
|
4
|
+
import { isMotionValue } from "./motion-value.js";
|
|
5
|
+
/** A nested config only overrides what it sets. */
|
|
6
|
+
export function mergeMotionConfig(parent, own) {
|
|
7
|
+
const merged = { ...parent };
|
|
8
|
+
if (own.transition !== undefined)
|
|
9
|
+
merged.transition = own.transition;
|
|
10
|
+
if (own.reducedMotion !== undefined)
|
|
11
|
+
merged.reducedMotion = own.reducedMotion;
|
|
12
|
+
return merged;
|
|
13
|
+
}
|
|
14
|
+
/** `prefersReduced` is the OS setting; `"never"` is the default, as in Framer. */
|
|
15
|
+
export function isReducedMotion(setting, prefersReduced) {
|
|
16
|
+
switch (setting) {
|
|
17
|
+
case "always":
|
|
18
|
+
return true;
|
|
19
|
+
case "user":
|
|
20
|
+
return prefersReduced;
|
|
21
|
+
case "never":
|
|
22
|
+
case undefined:
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** Style keys whose animation reduced motion replaces with a jump. Mirrors `AnimProp::is_positional`. */
|
|
27
|
+
const REDUCED_STYLE_KEYS = new Set(["width", "height", "top", "right", "bottom", "left"]);
|
|
28
|
+
/**
|
|
29
|
+
* Makes `animate()` jump on the motion values `style` binds to `width`,
|
|
30
|
+
* `height`, `top`, `right`, `bottom` or `left`. Returns the release. A value
|
|
31
|
+
* bound to padding, opacity, a colour and the like keeps animating, and so
|
|
32
|
+
* does one that no element binds. Framer leaves a bare `animate(mv)` alone;
|
|
33
|
+
* gpuix reduces it so a bound size or inset follows the setting.
|
|
34
|
+
*/
|
|
35
|
+
export function reduceMotionValues(style) {
|
|
36
|
+
if (typeof style !== "object" || style === null)
|
|
37
|
+
return () => { };
|
|
38
|
+
const releases = [];
|
|
39
|
+
for (const key of Object.keys(style)) {
|
|
40
|
+
if (!REDUCED_STYLE_KEYS.has(key))
|
|
41
|
+
continue;
|
|
42
|
+
const value = Reflect.get(style, key);
|
|
43
|
+
if (isMotionValue(value))
|
|
44
|
+
releases.push(value.reduceMotion());
|
|
45
|
+
}
|
|
46
|
+
return () => {
|
|
47
|
+
for (const release of releases)
|
|
48
|
+
release();
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=motion-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-config.js","sourceRoot":"","sources":["../js/motion-config.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AAGzE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAUjD,mDAAmD;AACnD,MAAM,UAAU,iBAAiB,CAC/B,MAAqC,EACrC,GAAsB;IAEtB,MAAM,MAAM,GAAsB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AO,GAAG,EAAE;QACV,KAAK,MAAM,OAAO,IAAI,QAAQ;YAAE,OAAO,EAAE,CAAA;IAC3C,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { LayoutDrag, MotionLayoutProps, MotionStyle } from "./host.js";
|
|
2
|
+
import type { MotionTargetScope, MotionAnimation, MotionAnimationTarget, MotionVariants, MotionViewport } from "./motion-variants.js";
|
|
3
|
+
import type { MotionValue } from "./motion-value.js";
|
|
4
|
+
/**
|
|
5
|
+
* What CSS lets an inline box show, and gpuix's inline model draws: the paragraph reads these
|
|
6
|
+
* from the style sampled for the frame, and lays itself out again when one changes the width of
|
|
7
|
+
* the text or the space along the line. Mirrors `Scope::InlineBox`.
|
|
8
|
+
*/
|
|
9
|
+
declare const MOTION_SPAN_KEYS: readonly ["opacity", "color", "backgroundColor", "textDecorationColor", "outlineColor", "outlineWidth", "outlineOffset", "borderColor", "borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor", "borderWidth", "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth", "borderRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "padding", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "margin", "marginTop", "marginRight", "marginBottom", "marginLeft", "fontSize", "fontWeight", "fontVariationSettings", "lineHeight", "textUnderlineOffset", "textDecorationThickness"];
|
|
10
|
+
export type MotionSpanKey = (typeof MOTION_SPAN_KEYS)[number];
|
|
11
|
+
/**
|
|
12
|
+
* Framer's transform keys. A transform does not apply to a non-atomic inline box in CSS, so
|
|
13
|
+
* they are accepted, as Framer accepts them on any element, and have no effect.
|
|
14
|
+
*/
|
|
15
|
+
declare const IGNORED_STYLE_KEYS: readonly ["transform", "x", "y", "z", "translateX", "translateY", "translateZ", "scale", "scaleX", "scaleY", "scaleZ", "rotate", "rotateX", "rotateY", "rotateZ", "skew", "skewX", "skewY", "originX", "originY", "originZ", "transformPerspective"];
|
|
16
|
+
export type MotionSpanTransformStyle = {
|
|
17
|
+
[Key in (typeof IGNORED_STYLE_KEYS)[number]]?: number | string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* What a `motion.span` can animate: colours and the opacity they are painted with, the font of its
|
|
21
|
+
* text, its padding, margin, border and outline, the corners of its background and the lines drawn
|
|
22
|
+
* over its text. Width, height, position and the like are not a span's. The transform keys are
|
|
23
|
+
* accepted and do nothing, as a transform does nothing to a non-atomic inline box.
|
|
24
|
+
*/
|
|
25
|
+
export type MotionSpanStyle = Pick<MotionStyle, MotionSpanKey> & MotionSpanTransformStyle;
|
|
26
|
+
export type MotionSpanVariant = MotionAnimationTarget<MotionSpanStyle>;
|
|
27
|
+
export type MotionSpanVariants = MotionVariants<MotionSpanStyle>;
|
|
28
|
+
/** What a span animates to while a gesture is on it, with the transition that animation plays with. */
|
|
29
|
+
export type MotionSpanGestureTarget = MotionAnimationTarget<MotionSpanStyle>;
|
|
30
|
+
export type MotionSpanViewport = MotionViewport;
|
|
31
|
+
/** The animation props of a `motion.span`. */
|
|
32
|
+
export type MotionSpanAnimation = MotionAnimation<MotionSpanStyle>;
|
|
33
|
+
declare const IGNORED_PROP_NAMES: readonly ["layout", "layoutId", "layoutDependency", "layoutScroll", "layoutRoot", "layoutDrag", "onLayoutAnimationStart", "onLayoutAnimationComplete", "onLayoutMeasure", "drag", "dragConstraints", "dragElastic", "dragMomentum", "dragTransition", "dragControls", "dragListener", "dragSnapToOrigin", "dragPropagation", "dragDirectionLock", "onDirectionLock", "onDragTransitionEnd", "whileDrag"];
|
|
34
|
+
/** The props a `motion.span` takes and ignores. */
|
|
35
|
+
export declare const IGNORED_SPAN_PROPS: readonly string[];
|
|
36
|
+
/**
|
|
37
|
+
* Framer's layout and drag props. A layout animation moves a box with a transform and a drag moves it
|
|
38
|
+
* the same way, which does nothing to a non-atomic inline box, so a `motion.span` takes them and they
|
|
39
|
+
* have no effect: no layout animation runs and no callback of one is called.
|
|
40
|
+
*/
|
|
41
|
+
export type MotionSpanIgnoredProps = {
|
|
42
|
+
[Prop in Exclude<(typeof IGNORED_PROP_NAMES)[number], "layout" | "layoutId" | "layoutDrag">]?: unknown;
|
|
43
|
+
} & {
|
|
44
|
+
layout?: MotionLayoutProps["layout"];
|
|
45
|
+
layoutId?: string;
|
|
46
|
+
layoutDrag?: LayoutDrag;
|
|
47
|
+
};
|
|
48
|
+
/** `props` without the ones a span ignores, which must not reach the host as the props of an element. */
|
|
49
|
+
export declare function withoutIgnoredSpanProps<Props extends object>(props: Props): Props;
|
|
50
|
+
/** `style` without the transform keys, which a span ignores whatever they hold, a motion value too. */
|
|
51
|
+
export declare function withoutIgnoredSpanStyle<Style>(style: Style): Style;
|
|
52
|
+
/** Throws for a motion value bound to a property a span cannot show, naming it. */
|
|
53
|
+
export declare function assertSpanMotionValues(values: Record<string, MotionValue> | undefined): void;
|
|
54
|
+
/** A span's targets hold the keys it shows and the transform keys it ignores. */
|
|
55
|
+
export declare const SPAN_SCOPE: MotionTargetScope;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=motion-span.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-span.d.ts","sourceRoot":"","sources":["../js/motion-span.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAoB,MAAM,WAAW,CAAA;AAC7F,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,qBAAqB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrI,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD;;;;GAIG;AACH,QAAA,MAAM,gBAAgB,wqBAuCZ,CAAA;AAEV,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE7D;;;GAGG;AACH,QAAA,MAAM,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AE,KAAK,GAAG,KAAK,CAQlE;AAED,mFAAmF;AACnF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,SAAS,GAAG,IAAI,CAQ5F;AAaD,iFAAiF;AACjF,eAAO,MAAM,UAAU,EAAE,iBAIxB,CAAA"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/// What `motion.span` means to the adapters, shared by React and Solid: the
|
|
2
|
+
/// properties an inline span can animate and the props that have no effect on a box a
|
|
3
|
+
/// paragraph paints. Its variants and gestures are `motion-variants.ts`'s.
|
|
4
|
+
/**
|
|
5
|
+
* What CSS lets an inline box show, and gpuix's inline model draws: the paragraph reads these
|
|
6
|
+
* from the style sampled for the frame, and lays itself out again when one changes the width of
|
|
7
|
+
* the text or the space along the line. Mirrors `Scope::InlineBox`.
|
|
8
|
+
*/
|
|
9
|
+
const MOTION_SPAN_KEYS = [
|
|
10
|
+
"opacity",
|
|
11
|
+
"color",
|
|
12
|
+
"backgroundColor",
|
|
13
|
+
"textDecorationColor",
|
|
14
|
+
"outlineColor",
|
|
15
|
+
"outlineWidth",
|
|
16
|
+
"outlineOffset",
|
|
17
|
+
"borderColor",
|
|
18
|
+
"borderTopColor",
|
|
19
|
+
"borderRightColor",
|
|
20
|
+
"borderBottomColor",
|
|
21
|
+
"borderLeftColor",
|
|
22
|
+
"borderWidth",
|
|
23
|
+
"borderTopWidth",
|
|
24
|
+
"borderRightWidth",
|
|
25
|
+
"borderBottomWidth",
|
|
26
|
+
"borderLeftWidth",
|
|
27
|
+
"borderRadius",
|
|
28
|
+
"borderTopLeftRadius",
|
|
29
|
+
"borderTopRightRadius",
|
|
30
|
+
"borderBottomLeftRadius",
|
|
31
|
+
"borderBottomRightRadius",
|
|
32
|
+
"padding",
|
|
33
|
+
"paddingTop",
|
|
34
|
+
"paddingRight",
|
|
35
|
+
"paddingBottom",
|
|
36
|
+
"paddingLeft",
|
|
37
|
+
"margin",
|
|
38
|
+
"marginTop",
|
|
39
|
+
"marginRight",
|
|
40
|
+
"marginBottom",
|
|
41
|
+
"marginLeft",
|
|
42
|
+
"fontSize",
|
|
43
|
+
"fontWeight",
|
|
44
|
+
"fontVariationSettings",
|
|
45
|
+
"lineHeight",
|
|
46
|
+
"textUnderlineOffset",
|
|
47
|
+
"textDecorationThickness",
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* Framer's transform keys. A transform does not apply to a non-atomic inline box in CSS, so
|
|
51
|
+
* they are accepted, as Framer accepts them on any element, and have no effect.
|
|
52
|
+
*/
|
|
53
|
+
const IGNORED_STYLE_KEYS = [
|
|
54
|
+
"transform",
|
|
55
|
+
"x",
|
|
56
|
+
"y",
|
|
57
|
+
"z",
|
|
58
|
+
"translateX",
|
|
59
|
+
"translateY",
|
|
60
|
+
"translateZ",
|
|
61
|
+
"scale",
|
|
62
|
+
"scaleX",
|
|
63
|
+
"scaleY",
|
|
64
|
+
"scaleZ",
|
|
65
|
+
"rotate",
|
|
66
|
+
"rotateX",
|
|
67
|
+
"rotateY",
|
|
68
|
+
"rotateZ",
|
|
69
|
+
"skew",
|
|
70
|
+
"skewX",
|
|
71
|
+
"skewY",
|
|
72
|
+
"originX",
|
|
73
|
+
"originY",
|
|
74
|
+
"originZ",
|
|
75
|
+
"transformPerspective",
|
|
76
|
+
];
|
|
77
|
+
const LAYOUT_PROPS = [
|
|
78
|
+
"layout",
|
|
79
|
+
"layoutId",
|
|
80
|
+
"layoutDependency",
|
|
81
|
+
"layoutScroll",
|
|
82
|
+
"layoutRoot",
|
|
83
|
+
"layoutDrag",
|
|
84
|
+
"onLayoutAnimationStart",
|
|
85
|
+
"onLayoutAnimationComplete",
|
|
86
|
+
"onLayoutMeasure",
|
|
87
|
+
];
|
|
88
|
+
const DRAG_PROPS = [
|
|
89
|
+
"drag",
|
|
90
|
+
"dragConstraints",
|
|
91
|
+
"dragElastic",
|
|
92
|
+
"dragMomentum",
|
|
93
|
+
"dragTransition",
|
|
94
|
+
"dragControls",
|
|
95
|
+
"dragListener",
|
|
96
|
+
"dragSnapToOrigin",
|
|
97
|
+
"dragPropagation",
|
|
98
|
+
"dragDirectionLock",
|
|
99
|
+
"onDirectionLock",
|
|
100
|
+
"onDragTransitionEnd",
|
|
101
|
+
"whileDrag",
|
|
102
|
+
];
|
|
103
|
+
const IGNORED_PROP_NAMES = [...LAYOUT_PROPS, ...DRAG_PROPS];
|
|
104
|
+
/** The props a `motion.span` takes and ignores. */
|
|
105
|
+
export const IGNORED_SPAN_PROPS = IGNORED_PROP_NAMES;
|
|
106
|
+
/** `props` without the ones a span ignores, which must not reach the host as the props of an element. */
|
|
107
|
+
export function withoutIgnoredSpanProps(props) {
|
|
108
|
+
const kept = {};
|
|
109
|
+
for (const key of Object.keys(props)) {
|
|
110
|
+
if (!IGNORED_SPAN_PROPS.includes(key))
|
|
111
|
+
kept[key] = Reflect.get(props, key);
|
|
112
|
+
}
|
|
113
|
+
return kept;
|
|
114
|
+
}
|
|
115
|
+
/** `style` without the transform keys, which a span ignores whatever they hold, a motion value too. */
|
|
116
|
+
export function withoutIgnoredSpanStyle(style) {
|
|
117
|
+
if (typeof style !== "object" || style === null)
|
|
118
|
+
return style;
|
|
119
|
+
if (!IGNORED_STYLE_KEYS.some((key) => Object.hasOwn(style, key)))
|
|
120
|
+
return style;
|
|
121
|
+
const kept = {};
|
|
122
|
+
for (const key of Object.keys(style)) {
|
|
123
|
+
if (!IGNORED_STYLE_KEYS.includes(key))
|
|
124
|
+
kept[key] = Reflect.get(style, key);
|
|
125
|
+
}
|
|
126
|
+
return kept;
|
|
127
|
+
}
|
|
128
|
+
/** Throws for a motion value bound to a property a span cannot show, naming it. */
|
|
129
|
+
export function assertSpanMotionValues(values) {
|
|
130
|
+
for (const key of Object.keys(values ?? {})) {
|
|
131
|
+
if (!MOTION_SPAN_KEYS.includes(key)) {
|
|
132
|
+
throw new Error(`A span cannot take a motion value in style.${key}: an inline box can only show ${MOTION_SPAN_KEYS.join(", ")}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function assertSpanStyle(where, style) {
|
|
137
|
+
for (const key of Object.keys(style)) {
|
|
138
|
+
const known = MOTION_SPAN_KEYS.includes(key) || IGNORED_STYLE_KEYS.includes(key);
|
|
139
|
+
if (!known) {
|
|
140
|
+
throw new Error(`motion.span cannot animate "${key}" in ${where}: an inline box can only show ${MOTION_SPAN_KEYS.join(", ")}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** A span's targets hold the keys it shows and the transform keys it ignores. */
|
|
145
|
+
export const SPAN_SCOPE = {
|
|
146
|
+
component: "motion.span",
|
|
147
|
+
check: assertSpanStyle,
|
|
148
|
+
shown: (style) => withoutIgnoredSpanStyle(style),
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=motion-span.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-span.js","sourceRoot":"","sources":["../js/motion-span.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,sFAAsF;AACtF,2EAA2E;AAM3E;;;;GAIG;AACH,MAAM,gBAAgB,GAAG;IACvB,SAAS;IACT,OAAO;IACP,iBAAiB;IACjB,qBAAqB;IACrB,cAAc;IACd,cAAc;IACd,eAAe;IACf,aAAa;IACb,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,iBAAiB;IACjB,aAAa;IACb,gBAAgB;IAChB,kBAAkB;IAClB,mBAAmB;IACnB,iBAAiB;IACjB,cAAc;IACd,qBAAqB;IACrB,sBAAsB;IACtB,wBAAwB;IACxB,yBAAyB;IACzB,SAAS;IACT,YAAY;IACZ,cAAc;IACd,eAAe;IACf,aAAa;IACb,QAAQ;IACR,WAAW;IACX,aAAa;IACb,cAAc;IACd,YAAY;IACZ,UAAU;IACV,YAAY;IACZ,uBAAuB;IACvB,YAAY;IACZ,qBAAqB;IACrB,yBAAyB;CACjB,CAAA;AAIV;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