@rezi-ui/core 0.1.0-alpha.24 → 0.1.0-alpha.26
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 +3 -2
- package/dist/animation/easing.d.ts +7 -0
- package/dist/animation/easing.d.ts.map +1 -0
- package/dist/animation/easing.js +23 -0
- package/dist/animation/easing.js.map +1 -0
- package/dist/animation/interpolate.d.ts +10 -0
- package/dist/animation/interpolate.d.ts.map +1 -0
- package/dist/animation/interpolate.js +26 -0
- package/dist/animation/interpolate.js.map +1 -0
- package/dist/animation/spring.d.ts +18 -0
- package/dist/animation/spring.d.ts.map +1 -0
- package/dist/animation/spring.js +84 -0
- package/dist/animation/spring.js.map +1 -0
- package/dist/animation/timeline.d.ts +27 -0
- package/dist/animation/timeline.d.ts.map +1 -0
- package/dist/animation/timeline.js +90 -0
- package/dist/animation/timeline.js.map +1 -0
- package/dist/animation/types.d.ts +71 -0
- package/dist/animation/types.d.ts.map +1 -0
- package/dist/animation/types.js +8 -0
- package/dist/animation/types.js.map +1 -0
- package/dist/app/createApp.d.ts.map +1 -1
- package/dist/app/createApp.js +42 -0
- package/dist/app/createApp.js.map +1 -1
- package/dist/app/inspectorOverlayHelper.d.ts.map +1 -1
- package/dist/app/inspectorOverlayHelper.js +6 -0
- package/dist/app/inspectorOverlayHelper.js.map +1 -1
- package/dist/app/widgetRenderer.d.ts +14 -0
- package/dist/app/widgetRenderer.d.ts.map +1 -1
- package/dist/app/widgetRenderer.js +325 -12
- package/dist/app/widgetRenderer.js.map +1 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/renderer/renderToDrawlist/renderTree.d.ts +2 -1
- package/dist/renderer/renderToDrawlist/renderTree.d.ts.map +1 -1
- package/dist/renderer/renderToDrawlist/renderTree.js +13 -3
- package/dist/renderer/renderToDrawlist/renderTree.js.map +1 -1
- package/dist/renderer/renderToDrawlist/simpleVNode.d.ts +4 -0
- package/dist/renderer/renderToDrawlist/simpleVNode.d.ts.map +1 -1
- package/dist/renderer/renderToDrawlist/simpleVNode.js +68 -2
- package/dist/renderer/renderToDrawlist/simpleVNode.js.map +1 -1
- package/dist/renderer/renderToDrawlist/textStyle.d.ts +4 -0
- package/dist/renderer/renderToDrawlist/textStyle.d.ts.map +1 -1
- package/dist/renderer/renderToDrawlist/textStyle.js +43 -0
- package/dist/renderer/renderToDrawlist/textStyle.js.map +1 -1
- package/dist/renderer/renderToDrawlist/types.d.ts +4 -0
- package/dist/renderer/renderToDrawlist/types.d.ts.map +1 -1
- package/dist/renderer/renderToDrawlist/widgets/collections.d.ts.map +1 -1
- package/dist/renderer/renderToDrawlist/widgets/collections.js +107 -23
- package/dist/renderer/renderToDrawlist/widgets/collections.js.map +1 -1
- package/dist/renderer/renderToDrawlist/widgets/containers.d.ts +1 -1
- package/dist/renderer/renderToDrawlist/widgets/containers.d.ts.map +1 -1
- package/dist/renderer/renderToDrawlist/widgets/containers.js +6 -3
- package/dist/renderer/renderToDrawlist/widgets/containers.js.map +1 -1
- package/dist/renderer/renderToDrawlist/widgets/editors.d.ts.map +1 -1
- package/dist/renderer/renderToDrawlist/widgets/editors.js +90 -3
- package/dist/renderer/renderToDrawlist/widgets/editors.js.map +1 -1
- package/dist/renderer/renderToDrawlist.d.ts.map +1 -1
- package/dist/renderer/renderToDrawlist.js +1 -1
- package/dist/renderer/renderToDrawlist.js.map +1 -1
- package/dist/router/integration.d.ts +1 -0
- package/dist/router/integration.d.ts.map +1 -1
- package/dist/router/integration.js +64 -4
- package/dist/router/integration.js.map +1 -1
- package/dist/router/keybindings.d.ts +11 -1
- package/dist/router/keybindings.d.ts.map +1 -1
- package/dist/router/keybindings.js +10 -3
- package/dist/router/keybindings.js.map +1 -1
- package/dist/runtime/commit.d.ts.map +1 -1
- package/dist/runtime/commit.js +32 -0
- package/dist/runtime/commit.js.map +1 -1
- package/dist/runtime/localState.d.ts +12 -0
- package/dist/runtime/localState.d.ts.map +1 -1
- package/dist/runtime/localState.js +6 -0
- package/dist/runtime/localState.js.map +1 -1
- package/dist/runtime/router/types.d.ts +1 -0
- package/dist/runtime/router/types.d.ts.map +1 -1
- package/dist/runtime/router/virtualList.d.ts.map +1 -1
- package/dist/runtime/router/virtualList.js +8 -7
- package/dist/runtime/router/virtualList.js.map +1 -1
- package/dist/theme/defaultTheme.d.ts.map +1 -1
- package/dist/theme/defaultTheme.js +11 -0
- package/dist/theme/defaultTheme.js.map +1 -1
- package/dist/widgets/codeEditorSyntax.d.ts +11 -0
- package/dist/widgets/codeEditorSyntax.d.ts.map +1 -0
- package/dist/widgets/codeEditorSyntax.js +950 -0
- package/dist/widgets/codeEditorSyntax.js.map +1 -0
- package/dist/widgets/composition.d.ts +237 -0
- package/dist/widgets/composition.d.ts.map +1 -1
- package/dist/widgets/composition.js +849 -0
- package/dist/widgets/composition.js.map +1 -1
- package/dist/widgets/types.d.ts +69 -1
- package/dist/widgets/types.d.ts.map +1 -1
- package/dist/widgets/ui.d.ts +1 -0
- package/dist/widgets/ui.d.ts.map +1 -1
- package/dist/widgets/ui.js +1 -0
- package/dist/widgets/ui.js.map +1 -1
- package/dist/widgets/virtualList.d.ts +11 -4
- package/dist/widgets/virtualList.d.ts.map +1 -1
- package/dist/widgets/virtualList.js +51 -38
- package/dist/widgets/virtualList.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Runtime-agnostic TypeScript core for Rezi:
|
|
4
4
|
|
|
5
5
|
- widget constructors (`ui.*`)
|
|
6
|
+
- declarative animation hooks (`useTransition`, `useSpring`, `useSequence`, `useStagger`)
|
|
7
|
+
- box transition props (`transition`, `opacity`)
|
|
6
8
|
- reconciliation + layout + focus + routing
|
|
7
9
|
- drawlist building (ZRDL) and event batch parsing (ZREV)
|
|
8
10
|
|
|
9
11
|
Most applications should use the Node backend package (`@rezi-ui/node`), which depends on this package.
|
|
10
12
|
|
|
11
|
-
Docs: `https://
|
|
12
|
-
|
|
13
|
+
Docs: `https://rezitui.dev/docs`
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/animation/easing.ts — Easing curve helpers.
|
|
3
|
+
*/
|
|
4
|
+
import type { EasingFunction, EasingInput } from "./types.js";
|
|
5
|
+
/** Resolve user-provided easing value to a safe function. */
|
|
6
|
+
export declare function resolveEasing(input: EasingInput | undefined): EasingFunction;
|
|
7
|
+
//# sourceMappingURL=easing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"easing.d.ts","sourceRoot":"","sources":["../../src/animation/easing.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAc,MAAM,YAAY,CAAC;AAY1E,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,cAAc,CAM5E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/animation/easing.ts — Easing curve helpers.
|
|
3
|
+
*/
|
|
4
|
+
import { clamp01 } from "./interpolate.js";
|
|
5
|
+
const EASING_PRESETS = Object.freeze({
|
|
6
|
+
linear: (t) => t,
|
|
7
|
+
easeInQuad: (t) => t * t,
|
|
8
|
+
easeOutQuad: (t) => 1 - (1 - t) * (1 - t),
|
|
9
|
+
easeInOutQuad: (t) => (t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2),
|
|
10
|
+
easeInCubic: (t) => t * t * t,
|
|
11
|
+
easeOutCubic: (t) => 1 - (1 - t) ** 3,
|
|
12
|
+
easeInOutCubic: (t) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2),
|
|
13
|
+
});
|
|
14
|
+
/** Resolve user-provided easing value to a safe function. */
|
|
15
|
+
export function resolveEasing(input) {
|
|
16
|
+
if (typeof input === "function") {
|
|
17
|
+
return (t) => clamp01(input(clamp01(t)));
|
|
18
|
+
}
|
|
19
|
+
if (!input)
|
|
20
|
+
return EASING_PRESETS.linear;
|
|
21
|
+
return EASING_PRESETS[input] ?? EASING_PRESETS.linear;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=easing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"easing.js","sourceRoot":"","sources":["../../src/animation/easing.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAG3C,MAAM,cAAc,GAAiD,MAAM,CAAC,MAAM,CAAC;IACjF,MAAM,EAAE,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC;IAChC,UAAU,EAAE,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC;IACxC,WAAW,EAAE,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACzD,aAAa,EAAE,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvF,WAAW,EAAE,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC7C,YAAY,EAAE,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IACrD,cAAc,EAAE,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;CAC7F,CAAC,CAAC;AAEH,6DAA6D;AAC7D,MAAM,UAAU,aAAa,CAAC,KAA8B;IAC1D,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,CAAS,EAAU,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,CAAC,KAAK;QAAE,OAAO,cAAc,CAAC,MAAM,CAAC;IACzC,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,MAAM,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/animation/interpolate.ts — Primitive interpolation helpers.
|
|
3
|
+
*/
|
|
4
|
+
/** Clamp a number into [0, 1]. */
|
|
5
|
+
export declare function clamp01(value: number): number;
|
|
6
|
+
/** Clamp an animation duration to a safe, non-negative integer in milliseconds. */
|
|
7
|
+
export declare function normalizeDurationMs(durationMs: number | undefined, fallbackMs: number): number;
|
|
8
|
+
/** Linear interpolation between two numeric values. */
|
|
9
|
+
export declare function interpolateNumber(from: number, to: number, t: number): number;
|
|
10
|
+
//# sourceMappingURL=interpolate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolate.d.ts","sourceRoot":"","sources":["../../src/animation/interpolate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,kCAAkC;AAClC,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAI9F;AAED,uDAAuD;AACvD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/animation/interpolate.ts — Primitive interpolation helpers.
|
|
3
|
+
*/
|
|
4
|
+
/** Clamp a number into [0, 1]. */
|
|
5
|
+
export function clamp01(value) {
|
|
6
|
+
if (!Number.isFinite(value))
|
|
7
|
+
return 0;
|
|
8
|
+
if (value <= 0)
|
|
9
|
+
return 0;
|
|
10
|
+
if (value >= 1)
|
|
11
|
+
return 1;
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
/** Clamp an animation duration to a safe, non-negative integer in milliseconds. */
|
|
15
|
+
export function normalizeDurationMs(durationMs, fallbackMs) {
|
|
16
|
+
if (durationMs === undefined)
|
|
17
|
+
return fallbackMs;
|
|
18
|
+
if (!Number.isFinite(durationMs))
|
|
19
|
+
return fallbackMs;
|
|
20
|
+
return Math.max(0, Math.trunc(durationMs));
|
|
21
|
+
}
|
|
22
|
+
/** Linear interpolation between two numeric values. */
|
|
23
|
+
export function interpolateNumber(from, to, t) {
|
|
24
|
+
return from + (to - from) * clamp01(t);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=interpolate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolate.js","sourceRoot":"","sources":["../../src/animation/interpolate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,kCAAkC;AAClC,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtC,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACzB,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IACzB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,UAA8B,EAAE,UAAkB;IACpF,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC;IAChD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IACpD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,EAAU,EAAE,CAAS;IACnE,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/animation/spring.ts — Spring simulation utilities.
|
|
3
|
+
*/
|
|
4
|
+
import type { NormalizedSpringConfig, SpringConfig } from "./types.js";
|
|
5
|
+
export type { NormalizedSpringConfig };
|
|
6
|
+
export type SpringState = Readonly<{
|
|
7
|
+
value: number;
|
|
8
|
+
velocity: number;
|
|
9
|
+
}>;
|
|
10
|
+
export type SpringStepResult = Readonly<{
|
|
11
|
+
value: number;
|
|
12
|
+
velocity: number;
|
|
13
|
+
done: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function normalizeSpringConfig(config: SpringConfig | undefined): NormalizedSpringConfig;
|
|
16
|
+
export declare function isSpringAtRest(value: number, target: number, velocity: number, config: NormalizedSpringConfig): boolean;
|
|
17
|
+
export declare function stepSpring(state: SpringState, target: number, dtSeconds: number, config: NormalizedSpringConfig): SpringStepResult;
|
|
18
|
+
//# sourceMappingURL=spring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spring.d.ts","sourceRoot":"","sources":["../../src/animation/spring.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEvE,YAAY,EAAE,sBAAsB,EAAE,CAAC;AAEvC,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC,CAAC;AAWH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,sBAAsB,CAmC9F;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAET;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,sBAAsB,GAC7B,gBAAgB,CA4ClB"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/animation/spring.ts — Spring simulation utilities.
|
|
3
|
+
*/
|
|
4
|
+
const DEFAULT_SPRING_CONFIG = Object.freeze({
|
|
5
|
+
stiffness: 170,
|
|
6
|
+
damping: 26,
|
|
7
|
+
mass: 1,
|
|
8
|
+
restDelta: 0.001,
|
|
9
|
+
restSpeed: 0.001,
|
|
10
|
+
maxDeltaMs: 32,
|
|
11
|
+
});
|
|
12
|
+
export function normalizeSpringConfig(config) {
|
|
13
|
+
if (!config)
|
|
14
|
+
return DEFAULT_SPRING_CONFIG;
|
|
15
|
+
const stiffness = typeof config.stiffness === "number" && Number.isFinite(config.stiffness)
|
|
16
|
+
? Math.max(0, config.stiffness)
|
|
17
|
+
: DEFAULT_SPRING_CONFIG.stiffness;
|
|
18
|
+
const damping = typeof config.damping === "number" && Number.isFinite(config.damping)
|
|
19
|
+
? Math.max(0, config.damping)
|
|
20
|
+
: DEFAULT_SPRING_CONFIG.damping;
|
|
21
|
+
const mass = typeof config.mass === "number" && Number.isFinite(config.mass)
|
|
22
|
+
? Math.max(0.0001, config.mass)
|
|
23
|
+
: DEFAULT_SPRING_CONFIG.mass;
|
|
24
|
+
const restDelta = typeof config.restDelta === "number" && Number.isFinite(config.restDelta)
|
|
25
|
+
? Math.max(0, config.restDelta)
|
|
26
|
+
: DEFAULT_SPRING_CONFIG.restDelta;
|
|
27
|
+
const restSpeed = typeof config.restSpeed === "number" && Number.isFinite(config.restSpeed)
|
|
28
|
+
? Math.max(0, config.restSpeed)
|
|
29
|
+
: DEFAULT_SPRING_CONFIG.restSpeed;
|
|
30
|
+
const maxDeltaMs = typeof config.maxDeltaMs === "number" && Number.isFinite(config.maxDeltaMs)
|
|
31
|
+
? Math.max(1, Math.trunc(config.maxDeltaMs))
|
|
32
|
+
: DEFAULT_SPRING_CONFIG.maxDeltaMs;
|
|
33
|
+
return Object.freeze({
|
|
34
|
+
stiffness,
|
|
35
|
+
damping,
|
|
36
|
+
mass,
|
|
37
|
+
restDelta,
|
|
38
|
+
restSpeed,
|
|
39
|
+
maxDeltaMs,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export function isSpringAtRest(value, target, velocity, config) {
|
|
43
|
+
return Math.abs(velocity) <= config.restSpeed && Math.abs(target - value) <= config.restDelta;
|
|
44
|
+
}
|
|
45
|
+
export function stepSpring(state, target, dtSeconds, config) {
|
|
46
|
+
if (!Number.isFinite(state.value) ||
|
|
47
|
+
!Number.isFinite(state.velocity) ||
|
|
48
|
+
!Number.isFinite(target) ||
|
|
49
|
+
!Number.isFinite(dtSeconds) ||
|
|
50
|
+
dtSeconds <= 0) {
|
|
51
|
+
return Object.freeze({
|
|
52
|
+
value: target,
|
|
53
|
+
velocity: 0,
|
|
54
|
+
done: true,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (config.stiffness <= 0 || config.mass <= 0) {
|
|
58
|
+
return Object.freeze({
|
|
59
|
+
value: target,
|
|
60
|
+
velocity: 0,
|
|
61
|
+
done: true,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const displacement = state.value - target;
|
|
65
|
+
const springForce = -config.stiffness * displacement;
|
|
66
|
+
const dampingForce = -config.damping * state.velocity;
|
|
67
|
+
const acceleration = (springForce + dampingForce) / config.mass;
|
|
68
|
+
const nextVelocity = state.velocity + acceleration * dtSeconds;
|
|
69
|
+
const nextValue = state.value + nextVelocity * dtSeconds;
|
|
70
|
+
const done = isSpringAtRest(nextValue, target, nextVelocity, config);
|
|
71
|
+
if (done) {
|
|
72
|
+
return Object.freeze({
|
|
73
|
+
value: target,
|
|
74
|
+
velocity: 0,
|
|
75
|
+
done: true,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return Object.freeze({
|
|
79
|
+
value: nextValue,
|
|
80
|
+
velocity: nextVelocity,
|
|
81
|
+
done: false,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=spring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spring.js","sourceRoot":"","sources":["../../src/animation/spring.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiBH,MAAM,qBAAqB,GAA2B,MAAM,CAAC,MAAM,CAAC;IAClE,SAAS,EAAE,GAAG;IACd,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,CAAC;IACP,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,EAAE;CACf,CAAC,CAAC;AAEH,MAAM,UAAU,qBAAqB,CAAC,MAAgC;IACpE,IAAI,CAAC,MAAM;QAAE,OAAO,qBAAqB,CAAC;IAC1C,MAAM,SAAS,GACb,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,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G,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;IAC1C,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,YAAY,CAAC;IACrD,MAAM,YAAY,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC;IACtD,MAAM,YAAY,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;IAChE,MAAM,YAAY,GAAG,KAAK,CAAC,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC;IAC/D,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,GAAG,YAAY,GAAG,SAAS,CAAC;IACzD,MAAM,IAAI,GAAG,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IAErE,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,CAAC;YACX,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,YAAY;QACtB,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/animation/timeline.ts — Sequence timeline helpers.
|
|
3
|
+
*/
|
|
4
|
+
import type { EasingFunction, EasingInput, SequenceKeyframe } from "./types.js";
|
|
5
|
+
type SequenceSegment = Readonly<{
|
|
6
|
+
from: number;
|
|
7
|
+
to: number;
|
|
8
|
+
durationMs: number;
|
|
9
|
+
easing: EasingFunction;
|
|
10
|
+
}>;
|
|
11
|
+
export type NormalizedSequence = Readonly<{
|
|
12
|
+
initialValue: number;
|
|
13
|
+
finalValue: number;
|
|
14
|
+
segments: readonly SequenceSegment[];
|
|
15
|
+
totalDurationMs: number;
|
|
16
|
+
}>;
|
|
17
|
+
export type SequenceSample = Readonly<{
|
|
18
|
+
value: number;
|
|
19
|
+
done: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function normalizeSequence(keyframes: readonly SequenceKeyframe[], defaults?: Readonly<{
|
|
22
|
+
duration?: number;
|
|
23
|
+
easing?: EasingInput;
|
|
24
|
+
}>): NormalizedSequence;
|
|
25
|
+
export declare function sampleSequence(sequence: NormalizedSequence, elapsedMs: number, loop: boolean): SequenceSample;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=timeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/animation/timeline.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEhF,KAAK,eAAe,GAAG,QAAQ,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,cAAc,CAAC;CACxB,CAAC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IACrC,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACf,CAAC,CAAC;AAgBH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,gBAAgB,EAAE,EACtC,QAAQ,GAAE,QAAQ,CAAC;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAM,GACnE,kBAAkB,CA4CpB;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,kBAAkB,EAC5B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,GACZ,cAAc,CAwChB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/animation/timeline.ts — Sequence timeline helpers.
|
|
3
|
+
*/
|
|
4
|
+
import { resolveEasing } from "./easing.js";
|
|
5
|
+
import { clamp01, interpolateNumber, normalizeDurationMs } from "./interpolate.js";
|
|
6
|
+
const DEFAULT_SEQUENCE_SEGMENT_DURATION_MS = 160;
|
|
7
|
+
function readKeyframeValue(frame) {
|
|
8
|
+
return typeof frame === "number" ? frame : frame.value;
|
|
9
|
+
}
|
|
10
|
+
function readKeyframeDuration(frame) {
|
|
11
|
+
return typeof frame === "number" ? undefined : frame.duration;
|
|
12
|
+
}
|
|
13
|
+
function readKeyframeEasing(frame) {
|
|
14
|
+
return typeof frame === "number" ? undefined : frame.easing;
|
|
15
|
+
}
|
|
16
|
+
export function normalizeSequence(keyframes, defaults = {}) {
|
|
17
|
+
if (keyframes.length === 0) {
|
|
18
|
+
return Object.freeze({
|
|
19
|
+
initialValue: 0,
|
|
20
|
+
finalValue: 0,
|
|
21
|
+
segments: Object.freeze([]),
|
|
22
|
+
totalDurationMs: 0,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const values = [];
|
|
26
|
+
for (const frame of keyframes) {
|
|
27
|
+
values.push(readKeyframeValue(frame));
|
|
28
|
+
}
|
|
29
|
+
const segments = [];
|
|
30
|
+
let totalDurationMs = 0;
|
|
31
|
+
const fallbackDurationMs = normalizeDurationMs(defaults.duration, DEFAULT_SEQUENCE_SEGMENT_DURATION_MS);
|
|
32
|
+
for (let i = 0; i < keyframes.length - 1; i++) {
|
|
33
|
+
const frame = keyframes[i];
|
|
34
|
+
if (frame === undefined)
|
|
35
|
+
continue;
|
|
36
|
+
const durationMs = normalizeDurationMs(readKeyframeDuration(frame), fallbackDurationMs);
|
|
37
|
+
const easingInput = readKeyframeEasing(frame) ?? defaults.easing;
|
|
38
|
+
segments.push(Object.freeze({
|
|
39
|
+
from: values[i] ?? 0,
|
|
40
|
+
to: values[i + 1] ?? 0,
|
|
41
|
+
durationMs,
|
|
42
|
+
easing: resolveEasing(easingInput),
|
|
43
|
+
}));
|
|
44
|
+
totalDurationMs += durationMs;
|
|
45
|
+
}
|
|
46
|
+
return Object.freeze({
|
|
47
|
+
initialValue: values[0] ?? 0,
|
|
48
|
+
finalValue: values[values.length - 1] ?? 0,
|
|
49
|
+
segments: Object.freeze(segments),
|
|
50
|
+
totalDurationMs,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export function sampleSequence(sequence, elapsedMs, loop) {
|
|
54
|
+
if (!Number.isFinite(elapsedMs) || sequence.segments.length === 0) {
|
|
55
|
+
return Object.freeze({
|
|
56
|
+
value: sequence.initialValue,
|
|
57
|
+
done: true,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const total = sequence.totalDurationMs;
|
|
61
|
+
if (total <= 0) {
|
|
62
|
+
return Object.freeze({
|
|
63
|
+
value: sequence.finalValue,
|
|
64
|
+
done: true,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const normalizedElapsedMs = loop
|
|
68
|
+
? ((Math.max(0, elapsedMs) % total) + total) % total
|
|
69
|
+
: Math.max(0, elapsedMs);
|
|
70
|
+
let cursor = 0;
|
|
71
|
+
for (let i = 0; i < sequence.segments.length; i++) {
|
|
72
|
+
const seg = sequence.segments[i];
|
|
73
|
+
if (!seg)
|
|
74
|
+
continue;
|
|
75
|
+
const segEnd = cursor + seg.durationMs;
|
|
76
|
+
if (normalizedElapsedMs <= segEnd || i === sequence.segments.length - 1) {
|
|
77
|
+
const localT = seg.durationMs <= 0 ? 1 : clamp01((normalizedElapsedMs - cursor) / seg.durationMs);
|
|
78
|
+
return Object.freeze({
|
|
79
|
+
value: interpolateNumber(seg.from, seg.to, seg.easing(localT)),
|
|
80
|
+
done: !loop && elapsedMs >= total,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
cursor = segEnd;
|
|
84
|
+
}
|
|
85
|
+
return Object.freeze({
|
|
86
|
+
value: sequence.finalValue,
|
|
87
|
+
done: true,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=timeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../src/animation/timeline.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAsBnF,MAAM,oCAAoC,GAAG,GAAG,CAAC;AAEjD,SAAS,iBAAiB,CAAC,KAAuB;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;AACzD,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAuB;IACnD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;AAChE,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAuB;IACjD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,SAAsC,EACtC,WAAkE,EAAE;IAEpE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,MAAM,CAAC,MAAM,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AK,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxE,MAAM,MAAM,GACV,GAAG,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,mBAAmB,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;YACrF,OAAO,MAAM,CAAC,MAAM,CAAC;gBACnB,KAAK,EAAE,iBAAiB,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAC9D,IAAI,EAAE,CAAC,IAAI,IAAI,SAAS,IAAI,KAAK;aAClC,CAAC,CAAC;QACL,CAAC;QACD,MAAM,GAAG,MAAM,CAAC;IAClB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK,EAAE,QAAQ,CAAC,UAAU;QAC1B,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* packages/core/src/animation/types.ts — Core animation API types.
|
|
3
|
+
*
|
|
4
|
+
* Why: Centralize animation configs so hooks and renderer transitions share
|
|
5
|
+
* consistent behavior and defaults.
|
|
6
|
+
*/
|
|
7
|
+
/** Easing function input/output in [0..1]. */
|
|
8
|
+
export type EasingFunction = (t: number) => number;
|
|
9
|
+
/** Built-in easing presets for declarative animation hooks. */
|
|
10
|
+
export type EasingName = "linear" | "easeInQuad" | "easeOutQuad" | "easeInOutQuad" | "easeInCubic" | "easeOutCubic" | "easeInOutCubic";
|
|
11
|
+
/** Easing value accepted by transition APIs. */
|
|
12
|
+
export type EasingInput = EasingName | EasingFunction;
|
|
13
|
+
/** Time-based interpolation configuration. */
|
|
14
|
+
export type TransitionConfig = Readonly<{
|
|
15
|
+
/** Transition duration in milliseconds. */
|
|
16
|
+
duration?: number;
|
|
17
|
+
/** Easing curve name or custom easing function. */
|
|
18
|
+
easing?: EasingInput;
|
|
19
|
+
}>;
|
|
20
|
+
/** Spring simulation configuration. */
|
|
21
|
+
export type SpringConfig = Readonly<{
|
|
22
|
+
/** Hooke spring constant. Larger values snap faster. */
|
|
23
|
+
stiffness?: number;
|
|
24
|
+
/** Velocity damping factor. Larger values reduce oscillation. */
|
|
25
|
+
damping?: number;
|
|
26
|
+
/** Mass term. Higher values move more slowly. */
|
|
27
|
+
mass?: number;
|
|
28
|
+
/** Position threshold for settling. */
|
|
29
|
+
restDelta?: number;
|
|
30
|
+
/** Velocity threshold for settling. */
|
|
31
|
+
restSpeed?: number;
|
|
32
|
+
/** Maximum integration step in milliseconds. */
|
|
33
|
+
maxDeltaMs?: number;
|
|
34
|
+
}>;
|
|
35
|
+
/** Internal normalized spring config with defaults applied. */
|
|
36
|
+
export type NormalizedSpringConfig = Readonly<{
|
|
37
|
+
stiffness: number;
|
|
38
|
+
damping: number;
|
|
39
|
+
mass: number;
|
|
40
|
+
restDelta: number;
|
|
41
|
+
restSpeed: number;
|
|
42
|
+
maxDeltaMs: number;
|
|
43
|
+
}>;
|
|
44
|
+
/** Sequence keyframe input for `useSequence`. */
|
|
45
|
+
export type SequenceKeyframe = number | Readonly<{
|
|
46
|
+
/** Keyframe numeric value. */
|
|
47
|
+
value: number;
|
|
48
|
+
/** Segment duration (ms) to the next keyframe. */
|
|
49
|
+
duration?: number;
|
|
50
|
+
/** Easing used for the segment to the next keyframe. */
|
|
51
|
+
easing?: EasingInput;
|
|
52
|
+
}>;
|
|
53
|
+
/** Sequence timeline configuration. */
|
|
54
|
+
export type SequenceConfig = Readonly<{
|
|
55
|
+
/** Default per-segment duration in milliseconds. */
|
|
56
|
+
duration?: number;
|
|
57
|
+
/** Default easing for segments without per-keyframe easing. */
|
|
58
|
+
easing?: EasingInput;
|
|
59
|
+
/** Loop sequence timeline when it reaches the end. */
|
|
60
|
+
loop?: boolean;
|
|
61
|
+
}>;
|
|
62
|
+
/** Staggered list animation configuration. */
|
|
63
|
+
export type StaggerConfig = Readonly<{
|
|
64
|
+
/** Delay between each item start in milliseconds. */
|
|
65
|
+
delay?: number;
|
|
66
|
+
/** Duration for each item in milliseconds. */
|
|
67
|
+
duration?: number;
|
|
68
|
+
/** Easing curve applied to each item's local progress. */
|
|
69
|
+
easing?: EasingInput;
|
|
70
|
+
}>;
|
|
71
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/animation/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,8CAA8C;AAC9C,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAEnD,+DAA+D;AAC/D,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,YAAY,GACZ,aAAa,GACb,eAAe,GACf,aAAa,GACb,cAAc,GACd,gBAAgB,CAAC;AAErB,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,cAAc,CAAC;AAEtD,8CAA8C;AAC9C,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC,CAAC;AAEH,uCAAuC;AACvC,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEH,+DAA+D;AAC/D,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH,iDAAiD;AACjD,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,QAAQ,CAAC;IACP,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC,CAAC;AAEP,uCAAuC;AACvC,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,sDAAsD;IACtD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC,CAAC;AAEH,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/animation/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createApp.d.ts","sourceRoot":"","sources":["../../src/app/createApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OA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C;CACjC,CAAC,CAAC;AAEH,KAAK,qBAAqB,CAAC,CAAC,IAAI,oBAAoB,GAClD,QAAQ,CAAC;IACP,YAAY,EAAE,CAAC,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC,CAAC;AAEL,KAAK,0BAA0B,GAAG,oBAAoB,GACpD,QAAQ,CAAC;IACP,MAAM,EAAE,SAAS,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACrC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC,CAAC;AAEL;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,0BAA0B,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AACxF,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/app/createApp.js
CHANGED
|
@@ -122,6 +122,13 @@ function readBackendDrawlistVersionMarker(backend) {
|
|
|
122
122
|
}
|
|
123
123
|
return value;
|
|
124
124
|
}
|
|
125
|
+
function monotonicNowMs() {
|
|
126
|
+
const perf = globalThis.performance;
|
|
127
|
+
const perfNow = perf?.now;
|
|
128
|
+
if (typeof perfNow === "function")
|
|
129
|
+
return perfNow.call(perf);
|
|
130
|
+
return Date.now();
|
|
131
|
+
}
|
|
125
132
|
async function loadTerminalProfile(backend) {
|
|
126
133
|
try {
|
|
127
134
|
if (typeof backend.getTerminalProfile === "function") {
|
|
@@ -1109,6 +1116,7 @@ export function createApp(opts) {
|
|
|
1109
1116
|
// First-frame/bootstrap safety is handled inside submitFrame(): it falls back
|
|
1110
1117
|
// to full pipeline when committedRoot or layoutTree is null.
|
|
1111
1118
|
const pendingDirtyFlags = dirtyFlags;
|
|
1119
|
+
const frameNowMs = monotonicNowMs();
|
|
1112
1120
|
const plan = {
|
|
1113
1121
|
commit: (pendingDirtyFlags & DIRTY_VIEW) !== 0,
|
|
1114
1122
|
layout: (pendingDirtyFlags & DIRTY_LAYOUT) !== 0,
|
|
@@ -1116,6 +1124,7 @@ export function createApp(opts) {
|
|
|
1116
1124
|
// already explicitly dirty; otherwise interactive state updates can render a
|
|
1117
1125
|
// newly-committed tree against stale layout nodes until the next resize.
|
|
1118
1126
|
checkLayoutStability: (pendingDirtyFlags & DIRTY_LAYOUT) === 0 && (pendingDirtyFlags & DIRTY_VIEW) !== 0,
|
|
1127
|
+
nowMs: frameNowMs,
|
|
1119
1128
|
};
|
|
1120
1129
|
const resilientView = (state) => {
|
|
1121
1130
|
if (topLevelViewError !== null) {
|
|
@@ -1286,6 +1295,39 @@ export function createApp(opts) {
|
|
|
1286
1295
|
mode = "widget";
|
|
1287
1296
|
viewFn = fn;
|
|
1288
1297
|
},
|
|
1298
|
+
replaceView(fn) {
|
|
1299
|
+
assertOperational("replaceView");
|
|
1300
|
+
assertNotReentrant("replaceView");
|
|
1301
|
+
if (routes !== undefined) {
|
|
1302
|
+
throwCode("ZRUI_MODE_CONFLICT", "replaceView: routes are configured in createApp(); screen rendering is managed by router");
|
|
1303
|
+
}
|
|
1304
|
+
if (mode === "raw") {
|
|
1305
|
+
throwCode("ZRUI_MODE_CONFLICT", "replaceView: draw mode already selected");
|
|
1306
|
+
}
|
|
1307
|
+
if (mode === null)
|
|
1308
|
+
mode = "widget";
|
|
1309
|
+
viewFn = fn;
|
|
1310
|
+
topLevelViewError = null;
|
|
1311
|
+
if (sm.state === "Running") {
|
|
1312
|
+
markDirty(DIRTY_VIEW);
|
|
1313
|
+
}
|
|
1314
|
+
},
|
|
1315
|
+
replaceRoutes(nextRoutes) {
|
|
1316
|
+
assertOperational("replaceRoutes");
|
|
1317
|
+
assertNotReentrant("replaceRoutes");
|
|
1318
|
+
if (!routerIntegration || routes === undefined) {
|
|
1319
|
+
throwCode("ZRUI_MODE_CONFLICT", "replaceRoutes: app was created without routes; use replaceView for view-mode apps");
|
|
1320
|
+
}
|
|
1321
|
+
if (mode === "raw") {
|
|
1322
|
+
throwCode("ZRUI_MODE_CONFLICT", "replaceRoutes: draw mode already selected");
|
|
1323
|
+
}
|
|
1324
|
+
const nextRouteKeybindings = routerIntegration.replaceRoutes(nextRoutes);
|
|
1325
|
+
app.keys(nextRouteKeybindings);
|
|
1326
|
+
topLevelViewError = null;
|
|
1327
|
+
if (sm.state === "Running") {
|
|
1328
|
+
markDirty(DIRTY_VIEW);
|
|
1329
|
+
}
|
|
1330
|
+
},
|
|
1289
1331
|
draw(fn) {
|
|
1290
1332
|
assertOperational("draw");
|
|
1291
1333
|
sm.assertOneOf(["Created", "Stopped"], "draw: must be Created or Stopped");
|