@wardic/object 0.0.0-stage → 1.3.1

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.
@@ -0,0 +1,90 @@
1
+ /**
2
+ * A plain object's values for Wardic: where each key it animates starts (the property's own value), and
3
+ * the ports core reads an Environment's values through, with no style, no layout to measure and no
4
+ * variables. A key the object doesn't have, or whose value is neither a number nor a string, is an
5
+ * error naming it: Wardic writes no property the object didn't have.
6
+ *
7
+ * @example
8
+ * import * as ObjectValues from "@wardic/object/ObjectValues"
9
+ *
10
+ * const links = ObjectValues.startLinksOf({ opacity: 1 })
11
+ * links.ownValue("opacity") // Option.some(1)
12
+ */
13
+ // `@wardic/object/ObjectValues` (#882; ADR-0073, *Amendment (#882)*, Q5): core's `OwnValues`,
14
+ // `MeasuredPairs` and `VariableValues` ports, and a Subject's start links for core's Imperative track.
15
+ import * as BaseValue from "@wardic/core/BaseValue";
16
+ import * as Bool from "effect/Boolean";
17
+ import * as Option from "effect/Option";
18
+ import * as Predicate from "effect/Predicate";
19
+ /** Whether `name` is a class's own: a name, not `Object`'s. */
20
+ const isClassName = (name) => Bool.and(Predicate.isString(name), Bool.and(name !== "", name !== "Object"));
21
+ /** What `subject` is called in an error: its class's name, else "the object". */
22
+ const nameOf = (subject) => Option.fromNullishOr(subject.constructor).pipe(Option.map((made) => made.name), Option.filter(isClassName), Option.match({ onNone: () => "the object", onSome: (name) => `a ${name}` }));
23
+ /** `subject`'s own value for `key`: a number or a string, else an error naming the key. */
24
+ const ownValueOf = (subject, key) => {
25
+ const value = subject[key];
26
+ if (Bool.or(Predicate.isNumber(value), Predicate.isString(value)))
27
+ return Option.some(value);
28
+ if (Predicate.isUndefined(value)) {
29
+ throw new Error(`wardic.animate: ${nameOf(subject)} has no "${key}" to animate. Give a key it has, a number or a string; Wardic adds no property to an object.`);
30
+ }
31
+ throw new Error(`wardic.animate: ${nameOf(subject)}'s "${key}" is ${typeof value}, which can't be animated: a key's value is a number or a string.`);
32
+ };
33
+ /** `raw` in the shape of `like`: a number for a number, a string for a string; none otherwise. */
34
+ const valueLike = (raw, like) => {
35
+ if (Predicate.isNumber(like)) {
36
+ if (Predicate.isNumber(raw))
37
+ return Option.some(raw);
38
+ return Option.none();
39
+ }
40
+ if (Predicate.isString(raw))
41
+ return Option.some(raw);
42
+ return Option.none();
43
+ };
44
+ /** No style: a plain object has none. */
45
+ const noStyle = () => Option.none();
46
+ /**
47
+ * Base-value links on `read`: each key starts from what `read` gives for it when the animation
48
+ * starts, an error it throws naming the key; there's no style to start from. Another Environment of
49
+ * objects reads its own way: `@wardic/three`'s finds a key on a mesh's material.
50
+ */
51
+ // ADR-0022.
52
+ // #883 (ADR-0073, *Amendment (#883)*, Q1): the start links `makeWith`'s Environments share.
53
+ export const startLinksWith = (read) => (subject) => {
54
+ const ownValue = (key) => read(subject, key);
55
+ const linksFor = (like) => ({
56
+ style: noStyle,
57
+ own: (key) => Option.flatMap(ownValue(key), (raw) => valueLike(raw, like)),
58
+ });
59
+ const startLinkOf = (key, like) => BaseValue.start(key, linksFor(like));
60
+ return { ownValue, linksFor, startLinkOf };
61
+ };
62
+ /**
63
+ * `subject`'s Base-value links: each key starts from its own value, the property as it is
64
+ * when the animation starts; there's no style to start from.
65
+ */
66
+ // ADR-0022.
67
+ export const startLinksOf = /*#__PURE__*/ startLinksWith(ownValueOf);
68
+ /** No record: a plain object's binding gives no style. */
69
+ const NO_RECORD = {};
70
+ /** The Own values port: values in the shape of their targets, and no style. */
71
+ export const ownValues = {
72
+ valueLike,
73
+ styleValueOf: () => Option.none(),
74
+ recordOf: () => NO_RECORD,
75
+ };
76
+ /** No Measured pairs: an object has no layout to measure a value in. */
77
+ const NO_PAIRS = {};
78
+ /** The Measured pairs port: none. */
79
+ export const measuredPairs = {
80
+ needs: () => false,
81
+ measure: () => NO_PAIRS,
82
+ };
83
+ /** No Variable values' Key rule. */
84
+ const NO_VARIABLES = { name: "no variable values", blend: () => Option.none() };
85
+ /** The Variable values port: none. */
86
+ export const variableValues = {
87
+ isValue: () => false,
88
+ values: () => NO_VARIABLES,
89
+ };
90
+ //# sourceMappingURL=ObjectValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectValues.js","sourceRoot":"","sources":["../src/ObjectValues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,8FAA8F;AAC9F,uGAAuG;AACvG,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AAMnD,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAE7C,+DAA+D;AAC/D,MAAM,WAAW,GAAG,CAAC,IAAa,EAAkB,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,EAAE,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAA;AAEnI,iFAAiF;AACjF,MAAM,MAAM,GAAG,CAAC,OAAe,EAAU,EAAE,CACzC,MAAM,CAAC,aAAa,CAAE,OAAkE,CAAC,WAAW,CAAC,CAAC,IAAI,CACxG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAC/B,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAC1B,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,CAC5E,CAAA;AAEH,2FAA2F;AAC3F,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,GAAW,EAAkC,EAAE;IAClF,MAAM,KAAK,GAAI,OAA6C,CAAC,GAAG,CAAC,CAAA;IACjE,IAAI,IAAI,CAAC,E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yB;IAClD,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK;IACpB,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY;CAC3B,CAAA"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Refresh frames the host pumps: Wardic's frames are the host loop's, so its writes land in the frame
3
+ * that draws them (a scene's **Host loop**: three's `setAnimationLoop`, an XR session's, a game loop).
4
+ * The host calls {@link PumpedFrames.frame} once a frame, before it renders, with the frame's time in
5
+ * ms, and a loop that draws only on demand asks {@link PumpedFrames.wantsFrame} whether Wardic wants
6
+ * another.
7
+ *
8
+ * @example
9
+ * import * as PumpedFrames from "@wardic/object/PumpedFrames"
10
+ *
11
+ * const frames = PumpedFrames.make()
12
+ * renderer.setAnimationLoop((time) => {
13
+ * frames.frame(time)
14
+ * renderer.render(scene, camera)
15
+ * })
16
+ */
17
+ import * as RefreshFrameSource from "@wardic/core/RefreshFrameSource";
18
+ import type * as Layer from "effect/Layer";
19
+ /** A callback a frame runs, with its time in ms: its own handle, as `cancelFrame` takes it. */
20
+ type Callback = (timestampMs: number) => void;
21
+ /** Refresh frames the host pumps: core's frame source, and what the host calls. */
22
+ export interface PumpedFrames extends RefreshFrameSource.Shape<Callback> {
23
+ /**
24
+ * Run the frame: every callback asked for before it, with `time` in ms, on the same timebase as
25
+ * `now`. Call it once a frame, before rendering.
26
+ */
27
+ readonly frame: (time: number) => void;
28
+ /** Whether a callback waits for the next frame: what a loop that draws on demand checks to go on. */
29
+ readonly wantsFrame: () => boolean;
30
+ }
31
+ /**
32
+ * Frames the host pumps. `now` is the host's steady clock on its frames' timebase, `performance.now()`
33
+ * when left out; core's Clock reads it to time a frame whose time repeats the one before.
34
+ */
35
+ export declare const make: (now?: () => number) => PumpedFrames;
36
+ /** `frames` as the Environment's Refresh frame source. */
37
+ export declare const layer: (frames: PumpedFrames) => Layer.Layer<RefreshFrameSource.RefreshFrameSource>;
38
+ export {};
39
+ //# sourceMappingURL=PumpedFrames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PumpedFrames.d.ts","sourceRoot":"","sources":["../src/PumpedFrames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,kBAAkB,MAAM,iCAAiC,CAAA;AACrE,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAE1C,+FAA+F;AAC/F,KAAK,QAAQ,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;AAE7C,mFAAmF;AACnF,MAAM,WAAW,YAAa,SAAQ,kBAAkB,CAAC,KAAK,CAAC,QAAQ,CAAC;IACtE;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,qGAAqG;IACrG,QAAQ,CAAC,UAAU,EAAE,MAAM,OAAO,CAAA;CACnC;AAOD;;;GAGG;AACH,eAAO,MAAM,IAAI,SAAS,MAAM,MAAM,KAA6B,YAqBlE,CAAA;AAED,0DAA0D;AAC1D,eAAO,MAAM,KAAK,WAAY,YAAY,KAAG,KAAK,CAAC,KAAK,CAAC,kBAAkB,CAAC,kBAAkB,CAAiE,CAAA"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Refresh frames the host pumps: Wardic's frames are the host loop's, so its writes land in the frame
3
+ * that draws them (a scene's **Host loop**: three's `setAnimationLoop`, an XR session's, a game loop).
4
+ * The host calls {@link PumpedFrames.frame} once a frame, before it renders, with the frame's time in
5
+ * ms, and a loop that draws only on demand asks {@link PumpedFrames.wantsFrame} whether Wardic wants
6
+ * another.
7
+ *
8
+ * @example
9
+ * import * as PumpedFrames from "@wardic/object/PumpedFrames"
10
+ *
11
+ * const frames = PumpedFrames.make()
12
+ * renderer.setAnimationLoop((time) => {
13
+ * frames.frame(time)
14
+ * renderer.render(scene, camera)
15
+ * })
16
+ */
17
+ // `@wardic/object/PumpedFrames` (#882, ADR-0068 decision 5; ADR-0073, *Amendment (#882)*, Q4): core's
18
+ // `RefreshFrameSource`, keeping its three rules. The canvas note's P1 prototyped it, and P5 found frames
19
+ // pumped before the render never a frame late, where window rAF is whenever the scene's loop asked first.
20
+ import * as RefreshFrameSource from "@wardic/core/RefreshFrameSource";
21
+ /**
22
+ * Frames the host pumps. `now` is the host's steady clock on its frames' timebase, `performance.now()`
23
+ * when left out; core's Clock reads it to time a frame whose time repeats the one before.
24
+ */
25
+ export const make = (now = () => performance.now()) => {
26
+ // This frame's callbacks and the next's, swapped each frame: nothing allocated a frame.
27
+ let queue = [];
28
+ let running = [];
29
+ const requestFrame = (callback) => {
30
+ queue.push(callback);
31
+ return callback;
32
+ };
33
+ const cancelFrame = (handle) => {
34
+ const at = queue.indexOf(handle);
35
+ if (at >= 0)
36
+ queue.splice(at, 1);
37
+ };
38
+ const frame = (time) => {
39
+ // A callback asked for while this frame's run waits for the next (the source's third rule).
40
+ const due = queue;
41
+ queue = running;
42
+ running = due;
43
+ for (let i = 0; i < due.length; i++)
44
+ due[i](time);
45
+ due.length = 0;
46
+ };
47
+ return { requestFrame, cancelFrame, now, frame, wantsFrame: () => queue.length > 0 };
48
+ };
49
+ /** `frames` as the Environment's Refresh frame source. */
50
+ export const layer = (frames) => RefreshFrameSource.layer(frames);
51
+ //# sourceMappingURL=PumpedFrames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PumpedFrames.js","sourceRoot":"","sources":["../src/PumpedFrames.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,sGAAsG;AACtG,yGAAyG;AACzG,0GAA0G;AAC1G,OAAO,KAAK,kBAAkB,MAAM,iCAAiC,CAAA;AAsBrE;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,GAAiB,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAgB,EAAE;IAChF,wFAAwF;IACxF,IAAI,KAAK,GAAoB,EAAE,CAAA;IAC/B,IAAI,OAAO,GAAoB,EAAE,CAAA;IACjC,MAAM,YAAY,GAAG,CAAC,QAAkB,EAAY,EAAE;QACpD,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACpB,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAA;IACD,MAAM,WAAW,GAAG,CAAC,MAAgB,EAAQ,EAAE;QAC7C,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAChC,IAAI,EAAE,IAAI,CAAC;YAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IAClC,CAAC,CAAA;IACD,MAAM,KAAK,GAAG,CAAC,IAAY,EAAQ,EAAE;QACnC,4FAA4F;QAC5F,MAAM,GAAG,GAAG,KAAK,CAAA;QACjB,KAAK,GAAG,OAAO,CAAA;QACf,OAAO,GAAG,GAAG,CAAA;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;YAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACjD,GAAG,CAAC,MAAM,GAAG,CAAC,CAAA;IAChB,CAAC,CAAA;IACD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAA;AACtF,CAAC,CAAA;AAED,0DAA0D;AAC1D,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAoB,EAAsD,EAAE,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAkC,CAAC,CAAA"}
@@ -0,0 +1,148 @@
1
+ import type * as Renderer from "@wardic/core/Renderer";
2
+ import type * as Batch from "@wardic/core/Batch";
3
+ import * as ReducedMotion from "@wardic/core/ReducedMotion";
4
+ import type * as Config from "@wardic/core/unstable/Config";
5
+ import * as FlushGate from "@wardic/core/unstable/FlushGate";
6
+ import type * as OwnValues from "@wardic/core/unstable/OwnValues";
7
+ import type * as Spine from "@wardic/core/unstable/Spine";
8
+ import * as FrameEffects from "@wardic/core/unstable/FrameEffects";
9
+ import * as Imperative from "@wardic/core/unstable/Imperative";
10
+ import * as WardicServices from "@wardic/core/unstable/WardicServices";
11
+ import * as Layer from "effect/Layer";
12
+ import * as AtomRegistry from "effect/reactivity/AtomRegistry";
13
+ import * as ObjectBatch from "./ObjectBatch.ts";
14
+ import * as PumpedFrames from "./PumpedFrames.ts";
15
+ /** A key of `T` Wardic animates: one whose value is a number or a string. */
16
+ export type AnimatableKey<T> = {
17
+ readonly [K in keyof T]-?: T[K] extends number | string ? K : never;
18
+ }[keyof T] & string;
19
+ /**
20
+ * A target for `T`: each of its animatable keys a value or keyframes; a transition, with an entry
21
+ * under any of those keys, which `animate`'s options are laid over field by field; and a Transition
22
+ * end, its values set once the object lands.
23
+ */
24
+ export type ObjectTarget<T> = {
25
+ readonly [K in AnimatableKey<T>]?: T[K] | Config.WardicKeyframes<T[K]>;
26
+ } & {
27
+ /** How it gets there: a spring, a tween or an inertia, with an entry under any of `T`'s keys it animates. */
28
+ readonly transition?: Config.WardicTransitionFor<AnimatableKey<T>> | undefined;
29
+ readonly transitionEnd?: {
30
+ readonly [K in AnimatableKey<T>]?: T[K];
31
+ } | undefined;
32
+ };
33
+ /** A Segment of objects, `[subject, target, options?]`: an object, or a list of them. Motion's. */
34
+ export type ObjectSegment = readonly [subject: object | ReadonlyArray<object>, target: Readonly<Record<string, number | string | Config.WardicKeyframes<number | string>>>] | readonly [subject: object | ReadonlyArray<object>, target: Readonly<Record<string, number | string | Config.WardicKeyframes<number | string>>>, options: Imperative.WardicSegmentOptions];
35
+ /** A Segment of a Batch, `[batch, target, options?]`: every member, or a member's handle, `batch.at(i)`. */
36
+ export type ObjectBatchSegment = readonly [batch: ObjectBatch.ObjectBatch<any, any> | ObjectBatch.Member<any, any>, target: Readonly<Record<string, ObjectBatch.SegmentValue>>] | readonly [batch: ObjectBatch.ObjectBatch<any, any> | ObjectBatch.Member<any, any>, target: Readonly<Record<string, ObjectBatch.SegmentValue>>, options: Imperative.WardicSegmentOptions];
37
+ /** A sequence of objects: Segments of objects and of Batches, function Segments and labels. Motion's `AnimationSequence`. */
38
+ export type ObjectSequence = ReadonlyArray<Imperative.WardicSequenceLabel | ObjectSegment | ObjectBatchSegment | Imperative.WardicFunctionSegment>;
39
+ /**
40
+ * `animate(subject, target, options?)` animates an object, or each of a list of them, to `target`;
41
+ * `animate(sequence, options?)` plays a sequence. Either returns its Playback controls. Motion's.
42
+ * The options' transition takes an entry under any of the keys the Subject animates: a Batch's, its keys.
43
+ */
44
+ export interface ObjectAnimate {
45
+ <T extends object>(batch: ObjectBatch.ObjectBatch<T> | ObjectBatch.Member<T>, target: ObjectBatch.Target<T>, options?: Imperative.WardicAnimateOptionsFor<ObjectBatch.NumberKey<T>>): Imperative.WardicPlaybackControls;
46
+ <T extends object>(subject: T | ReadonlyArray<T>, target: ObjectTarget<T>, options?: Imperative.WardicAnimateOptionsFor<AnimatableKey<T>>): Imperative.WardicPlaybackControls;
47
+ (sequence: ObjectSequence, options?: Imperative.WardicSequenceOptions): Imperative.WardicPlaybackControls;
48
+ }
49
+ /** A runtime's options. */
50
+ export interface Options {
51
+ /**
52
+ * Whether reduced motion applies (`"user"`, the default: the user's preference where the host
53
+ * reports one, through `matchMedia`, else never; `"always"`; `"never"`). Under it, a transform's
54
+ * keys (`x`, `rotate`, `scale`…) snap to their targets after their delay, and other keys animate.
55
+ */
56
+ readonly reducedMotion?: ReducedMotion.Config | undefined;
57
+ /** Land every animation on its next frame: for tests and screenshots, and a user who turned motion off. */
58
+ readonly skipAnimations?: boolean | undefined;
59
+ /** The `AtomRegistry` Live values are shared through: the page's, so a DOM value can drive an object's. */
60
+ readonly registry?: AtomRegistry.AtomRegistry | undefined;
61
+ /** The host's steady clock on its frames' timebase: `performance.now()` when left out. */
62
+ readonly now?: (() => number) | undefined;
63
+ }
64
+ /**
65
+ * What a binding's ward runs on, to move this runtime's Subjects as a ward moves an element: what
66
+ * `animate` runs on, where a Subject starts, and its Frame effects. Unstable: for `@wardic/solid`'s
67
+ * Stage ward and the Stages built on it.
68
+ */
69
+ export interface StageEnvironment extends Imperative.AnimateEnv {
70
+ /** Where each key of a Subject starts: its Environment's Base-value links. */
71
+ readonly startLinksOf: (subject: object) => Spine.StartLinks;
72
+ /** Its Frame effects: what `afterWrites` adds to, and how one asks for a frame. */
73
+ readonly frameEffects: Pick<FrameEffects.FrameEffects, "add" | "request">;
74
+ }
75
+ /** A runtime: what animates objects on one Host loop. */
76
+ export interface WardicObject {
77
+ readonly animate: ObjectAnimate;
78
+ /**
79
+ * A Batch of `objects`: one run for all of them, on the keys of its first `animate` (or `keys`).
80
+ * `animate(batch, target)` moves every member; `animate(batch.at(i), target)` member `i`.
81
+ */
82
+ readonly batch: <T extends object>(objects: ReadonlyArray<T>, options?: ObjectBatch.Options<T>) => ObjectBatch.ObjectBatch<T>;
83
+ /**
84
+ * Run `effect` at the end of each frame from now on, after Wardic's writes for it and the effects
85
+ * added before it, with the frame's time in ms: an app's own code before the render. Returns its remover.
86
+ */
87
+ readonly afterWrites: (effect: (time: number) => void) => () => void;
88
+ /** Run the frame, `time` in ms: Wardic's writes for it, then `afterWrites`' effects. Call it once a frame, before rendering. */
89
+ readonly frame: (time: number) => void;
90
+ /** Whether Wardic wants another frame: what a loop that draws on demand checks to go on. */
91
+ readonly wantsFrame: () => boolean;
92
+ /** Stop every animation, and end the runtime. */
93
+ readonly dispose: () => void;
94
+ /** What a binding's ward runs on, for this runtime's Subjects. Unstable: `@wardic/solid`'s Stage ward's. */
95
+ readonly stageEnvironment: StageEnvironment;
96
+ }
97
+ /**
98
+ * A Batch of something that isn't a list of Subjects, an `InstancedMesh`'s instances: a handle per
99
+ * member, and how they're drawn and read.
100
+ */
101
+ export interface BatchSource {
102
+ /** Its members, in order: what the writer and the read are given for each. */
103
+ readonly members: ReadonlyArray<object>;
104
+ /** How its members are drawn. */
105
+ readonly writer: Batch.Writer<object>;
106
+ /** How it reads a member's key before the Batch moves it. */
107
+ readonly read: (subject: object, key: string) => unknown;
108
+ }
109
+ /**
110
+ * What an Environment of objects gives the runtime: how its Subjects are written and read, which of its
111
+ * keys are positional, how a Batch of them is drawn, and any Layers of its own. `OBJECTS` is plain
112
+ * objects'; `@wardic/three` gives three's.
113
+ */
114
+ export interface Environment {
115
+ /** Its writer: Wardic's values onto a Subject, once a frame. */
116
+ readonly renderer: Layer.Layer<Renderer.Renderer>;
117
+ /** What its Flush gate reads of a Subject. */
118
+ readonly gate: FlushGate.GateEnvironment;
119
+ /** A plain Subject's Base-value links: where each key it animates starts. */
120
+ readonly startLinksOf: (subject: object) => Spine.StartLinks;
121
+ /** Its values in the shape of their targets. */
122
+ readonly ownValues: OwnValues.Shape;
123
+ /** Which of its keys reduced motion snaps. */
124
+ readonly positionalKeys: Layer.Layer<ReducedMotion.PositionalKeys>;
125
+ /** How a Batch of its Subjects is drawn. */
126
+ readonly batchWriter: Batch.Writer<object>;
127
+ /** How a Batch reads a member's key before it moves it. */
128
+ readonly batchRead: (subject: object, key: string) => unknown;
129
+ /**
130
+ * A Batch of `given`, something other than a list (an `InstancedMesh`): its members, drawn and read
131
+ * its own way. `undefined` for anything it doesn't make a Batch of.
132
+ */
133
+ readonly batchSource?: ((given: object) => BatchSource | undefined) | undefined;
134
+ /** Layers of its own: its `UnitScale`, say. */
135
+ readonly layers?: Layer.Layer<never> | undefined;
136
+ }
137
+ /** Plain objects' Environment: each key the object's own property. */
138
+ export declare const OBJECTS: Environment;
139
+ /**
140
+ * The Environment's services, on `frames`: the Effect form, for an app that runs Wardic's Effects
141
+ * itself. `make` builds its runtime on it; `environment` is plain objects' unless given.
142
+ */
143
+ export declare const layer: (frames: PumpedFrames.PumpedFrames, options?: Options, environment?: Environment) => Layer.Layer<WardicServices.WardicServices>;
144
+ /** A runtime on frames the host pumps, for plain objects: `frame(time)` once a frame, before it renders. */
145
+ export declare const make: (options?: Options) => WardicObject;
146
+ /** A runtime on frames the host pumps, for `environment`'s objects: what `@wardic/three` builds on. */
147
+ export declare const makeWith: (environment: Environment, options?: Options) => WardicObject;
148
+ //# sourceMappingURL=WardicObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WardicObject.d.ts","sourceRoot":"","sources":["../src/WardicObject.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAChD,OAAO,KAAK,aAAa,MAAM,4BAA4B,CAAA;AAE3D,OAAO,KAAK,KAAK,MAAM,MAAM,8BAA8B,CAAA;AAC3D,OAAO,KAAK,SAAS,MAAM,iCAAiC,CAAA;AAC5D,OAAO,KAAK,KAAK,SAAS,MAAM,iCAAiC,CAAA;AACjE,OAAO,KAAK,KAAK,KAAK,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAA;AAElE,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAA;AAE9D,OAAO,KAAK,cAAc,MAAM,sCAAsC,CAAA;AAQtE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAKrC,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAA;AAG9D,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAG/C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD,6EAA6E;AAC7E,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,KAAK;CAAE,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAA;AAExH;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,QAAQ,EAAE,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,C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AAK,CAAC,GAAG,SAAS,CAAA;CACjD;AAED,sEAAsE;AACtE,eAAO,MAAM,OAAO,EAAE,WAQrB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,WAAY,YAAY,CAAC,YAAY,YAAW,OAAO,gBAAoB,WAAW,KAAa,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAoB3J,CAAA;AAiDH,4GAA4G;AAC5G,eAAO,MAAM,IAAI,aAAa,OAAO,KAAQ,YAA0C,CAAA;AAEvF,uGAAuG;AACvG,eAAO,MAAM,QAAQ,gBAAiB,WAAW,YAAW,OAAO,KAAQ,YA8D1E,CAAA"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Wardic for any object's properties: Motion's `animate` on plain objects (a three.js mesh's material,
3
+ * a camera, a uniforms object, a Canvas 2D sprite, a plain `{ x, y }`), on frames the host pumps. One
4
+ * runtime per Host loop: `make` builds it, the host calls `frame(time)` once a frame before it renders,
5
+ * and `dispose` ends it.
6
+ *
7
+ * - **Keys** are an object's own properties, by name: `animate(sprite, { x: 100 })` writes `sprite.x`.
8
+ * Each starts from the property's value when the animation starts. A key the object doesn't have,
9
+ * or whose value is neither a number nor a string, is an error naming it.
10
+ * - **Values** are numbers, and strings with a unit or of numbers (`"10px"`, `"0 0 4px"`). An array in
11
+ * a target is keyframes, as Motion's.
12
+ * - **Transitions** are Motion's by a key's name when a key gives none: a spring for a transform's
13
+ * (`x`, `rotate`, `scale`…), a 0.3 s ease for any other.
14
+ * - **The controls** are the DOM's: awaitable, with `stop`, `cancel`, `complete`, `pause`, `play`,
15
+ * `speed`, `time` and `duration`. A later `animate` of a key takes it over, keeping its velocity.
16
+ *
17
+ * @example
18
+ * import * as WardicObject from "@wardic/object/WardicObject"
19
+ *
20
+ * const wardic = WardicObject.make()
21
+ * renderer.setAnimationLoop((time) => {
22
+ * wardic.frame(time)
23
+ * renderer.render(scene, camera)
24
+ * })
25
+ * await wardic.animate(material, { opacity: 0 }, { duration: 0.4 })
26
+ */
27
+ // `@wardic/object/WardicObject` (#882; ADR-0068 decisions 2 and 5, ADR-0069 decision 21; ADR-0073,
28
+ // *Amendment (#882)*, Q4–Q6): core's Imperative track (`@wardic/core/unstable/Imperative`) over plain
29
+ // objects, on `PumpedFrames`, with core's Frame effects at each frame's end (`afterWrites`). Its Batches
30
+ // are PR 3's (`ObjectBatch`).
31
+ import * as Announcer from "@wardic/core/Announcer";
32
+ import * as Clock from "@wardic/core/Clock";
33
+ import * as DefaultTransition from "@wardic/core/DefaultTransition";
34
+ import * as FrameLoop from "@wardic/core/FrameLoop";
35
+ import * as InputFeed from "@wardic/core/InputFeed";
36
+ import * as InterpolatorRegistry from "@wardic/core/InterpolatorRegistry";
37
+ import * as Probe from "@wardic/core/Probe";
38
+ import * as ReducedMotion from "@wardic/core/ReducedMotion";
39
+ import * as UnitScale from "@wardic/core/UnitScale";
40
+ import * as FlushGate from "@wardic/core/unstable/FlushGate";
41
+ import * as FrameEffects from "@wardic/core/unstable/FrameEffects";
42
+ import * as BatchCalls from "@wardic/core/unstable/BatchCalls";
43
+ import * as Imperative from "@wardic/core/unstable/Imperative";
44
+ import * as Report from "@wardic/core/unstable/Report";
45
+ import * as WardicServices from "@wardic/core/unstable/WardicServices";
46
+ import * as Arr from "effect/Array";
47
+ import * as Bool from "effect/Boolean";
48
+ import * as Cause from "effect/Cause";
49
+ import * as Context from "effect/Context";
50
+ import * as Effect from "effect/Effect";
51
+ import { constUndefined } from "effect/Function";
52
+ import * as Iter from "effect/Iterable";
53
+ import * as Layer from "effect/Layer";
54
+ import * as ManagedRuntime from "effect/ManagedRuntime";
55
+ import * as Option from "effect/Option";
56
+ import * as Predicate from "effect/Predicate";
57
+ import * as Atom from "effect/reactivity/Atom";
58
+ import * as AtomRegistry from "effect/reactivity/AtomRegistry";
59
+ import * as Stream from "effect/Stream";
60
+ import * as UndefinedOr from "effect/UndefinedOr";
61
+ import * as ObjectBatch from "./ObjectBatch.js";
62
+ import * as ObjectRenderer from "./ObjectRenderer.js";
63
+ import * as ObjectValues from "./ObjectValues.js";
64
+ import * as PumpedFrames from "./PumpedFrames.js";
65
+ /** The user's reduced-motion query, where the host has `matchMedia`; none in Node or a worker. */
66
+ const reducedMotionQuery = () => UndefinedOr.match(globalThis.matchMedia, {
67
+ onUndefined: constUndefined,
68
+ onDefined: (matchMedia) => matchMedia("(prefers-reduced-motion: reduce)"),
69
+ });
70
+ /** Whether `query` says the user prefers reduced motion, now. */
71
+ const prefersOf = (query) => UndefinedOr.match(query, { onUndefined: () => false, onDefined: (given) => given.matches });
72
+ /** A box of nothing: an object has no layout to measure. */
73
+ const ZERO_BOUNDS = { x: 0, y: 0, width: 0, height: 0, top: 0, right: 0, bottom: 0, left: 0 };
74
+ /** The Probe of an Environment with no layout: nothing to measure, observe or intersect; the user's preference as the host reports it. */
75
+ const probeLayer = (query) => Layer.succeed(Probe.Probe, {
76
+ measure: () => Effect.succeed(ZERO_BOUNDS),
77
+ viewport: Atom.make({ width: 0, height: 0 }),
78
+ prefersReducedMotion: Atom.make(prefersOf(query)),
79
+ visible: Atom.make(true),
80
+ observeResize: () => Stream.never,
81
+ observeIntersection: () => InputFeed.empty,
82
+ });
83
+ /** Plain objects' Environment: each key the object's own property. */
84
+ export const OBJECTS = {
85
+ renderer: ObjectRenderer.layer,
86
+ gate: ObjectRenderer.GATE,
87
+ startLinksOf: ObjectValues.startLinksOf,
88
+ ownValues: ObjectValues.ownValues,
89
+ positionalKeys: ReducedMotion.transformsOnly,
90
+ batchWriter: ObjectBatch.writer,
91
+ batchRead: ObjectBatch.read,
92
+ };
93
+ /**
94
+ * The Environment's services, on `frames`: the Effect form, for an app that runs Wardic's Effects
95
+ * itself. `make` builds its runtime on it; `environment` is plain objects' unless given.
96
+ */
97
+ export const layer = (frames, options = {}, environment = OBJECTS) => FrameLoop.layer.pipe(Layer.provideMerge(Layer.mergeAll(Clock.layer.pipe(Layer.provideMerge(PumpedFrames.layer(frames))), environment.renderer, probeLayer(reducedMotionQuery()), InterpolatorRegistry.layer, environment.positionalKeys, DefaultTransition.layerByKey, Announcer.layerSilent, UndefinedOr.match(environment.layers, { onUndefined: () => Layer.empty, onDefined: (given) => given }))), Layer.provideMerge(UndefinedOr.match(options.registry, {
98
+ onUndefined: () => AtomRegistry.layer,
99
+ onDefined: (registry) => Layer.succeed(AtomRegistry.AtomRegistry, registry),
100
+ })));
101
+ /** The runtime's Flush gate: an object's properties, written once a frame. */
102
+ class Gate extends Context.Service()("@wardic/object/WardicObject/Gate") {
103
+ }
104
+ /** The gate on `edges`, built with its runtime's services and ended with its Scope. */
105
+ const gateLayerOf = (edges) => Layer.effect(Gate)(Effect.gen(function* () {
106
+ // An object has no framework to batch a flush's hooks in.
107
+ const gate = FlushGate.makeFlushGate(yield* WardicServices.makeRunner(), { batch: (apply) => apply() }, edges);
108
+ yield* Effect.addFinalizer(() => Effect.sync(gate.dispose));
109
+ return gate;
110
+ }));
111
+ /** What `given` names as an object: itself, an error for anything that isn't one. */
112
+ const objectOf = (given) => {
113
+ if (Predicate.isObject(given))
114
+ return given;
115
+ throw new Error(`wardic.animate: ${String(given)} isn't an object to animate. Give an object, or a list of them.`);
116
+ };
117
+ /** The objects `given` names: an object, or each of a list of them. */
118
+ const resolve = (given) => {
119
+ if (Arr.isArray(given))
120
+ return Arr.map(given, objectOf);
121
+ return [objectOf(given)];
122
+ };
123
+ /** An object of a Batch given to `animate` itself: an error naming its handle. */
124
+ const memberGiven = (subjects) => {
125
+ const member = Option.match(Arr.findFirst(Arr.map(subjects, ObjectBatch.memberOf), Predicate.isNotUndefined), { onNone: () => "?", onSome: String });
126
+ throw new Error(`wardic.animate: an object given is member ${member} of a Batch, whose run draws it: animate it through its Batch, batch.at(${member})`);
127
+ };
128
+ /** The object Environment's Batches: `ObjectBatch`'s handles; a member object is reached through them alone. */
129
+ const BATCHES = {
130
+ entryOf: ObjectBatch.entryOf,
131
+ hasMembers: (subjects) => Arr.some(subjects, (subject) => Predicate.isNotUndefined(ObjectBatch.memberOf(subject))),
132
+ callPartsOf: memberGiven,
133
+ segmentSubjectsOf: memberGiven,
134
+ sequencePartsOf: (compiled) => BatchCalls.sequencePartsOf(compiled),
135
+ };
136
+ /** An Environment's ports into core's track: its Subjects any object, each starting where the Environment reads it. */
137
+ const portsOf = (environment) => ({
138
+ subjects: { resolve, startLinksOf: environment.startLinksOf },
139
+ batches: BATCHES,
140
+ });
141
+ /** A runtime on frames the host pumps, for plain objects: `frame(time)` once a frame, before it renders. */
142
+ export const make = (options = {}) => makeWith(OBJECTS, options);
143
+ /** A runtime on frames the host pumps, for `environment`'s objects: what `@wardic/three` builds on. */
144
+ export const makeWith = (environment, options = {}) => {
145
+ const frames = PumpedFrames.make(options.now);
146
+ const runtime = ManagedRuntime.make(gateLayerOf(environment.gate).pipe(Layer.provideMerge(layer(frames, options, environment))));
147
+ const { gate, positionalKeys, defaultTransition } = runtime.runSync(Effect.all({ gate: Gate, positionalKeys: ReducedMotion.PositionalKeys, defaultTransition: DefaultTransition.DefaultTransition }));
148
+ const config = UndefinedOr.match(options.reducedMotion, { onUndefined: () => "user", onDefined: (given) => given });
149
+ const skip = options.skipAnimations === true;
150
+ const query = reducedMotionQuery();
151
+ const env = {
152
+ runtime,
153
+ gate,
154
+ reducedMotion: () => ReducedMotion.applies(config, prefersOf(query)),
155
+ skipAnimations: () => skip,
156
+ positionalKeys,
157
+ defaultTransition,
158
+ ownValues: environment.ownValues,
159
+ measuredPairs: ObjectValues.measuredPairs,
160
+ variableValues: ObjectValues.variableValues,
161
+ };
162
+ // Its animations in flight, stopped as it ends.
163
+ const live = new Set();
164
+ const watch = {
165
+ started: (controls) => void live.add(controls),
166
+ ended: (controls) => void live.delete(controls),
167
+ };
168
+ const animate = Imperative.make(env, portsOf(environment), constUndefined, watch);
169
+ const effects = FrameEffects.make({
170
+ // The host asks `wantsFrame()`: a request is counted there.
171
+ requestFrame: constUndefined,
172
+ report: (defect) => void runtime.runFork(Report.failure("wardic.afterWrites: an effect failed", Cause.die(defect))),
173
+ });
174
+ const frame = (time) => {
175
+ frames.frame(time);
176
+ effects.run(time);
177
+ };
178
+ const dispose = () => {
179
+ Iter.forEach(Arr.fromIterable(live), (controls) => controls.stop());
180
+ void runtime.dispose();
181
+ };
182
+ const batchContext = { runFork: runtime.runFork, positionalKeys, defaultTransition, unitScale: runtime.runSync(UnitScale.UnitScale), writer: environment.batchWriter, read: environment.batchRead };
183
+ /** What the Environment makes a Batch of `given`, a Batch's source other than a list: `undefined` where it makes none. */
184
+ const sourceOf = (given) => {
185
+ if (!Predicate.isObject(given) || Predicate.isUndefined(environment.batchSource))
186
+ return undefined;
187
+ return environment.batchSource(given);
188
+ };
189
+ /** A Batch of a list of Subjects, or of what the Environment's `batchSource` makes one of. */
190
+ const batch = (given, options) => {
191
+ if (Arr.isArray(given))
192
+ return ObjectBatch.make(batchContext, given, options);
193
+ const source = sourceOf(given);
194
+ if (Predicate.isUndefined(source))
195
+ throw new Error("wardic.batch: a Batch is made of a list of objects, and it was given something else. Give a list: wardic.batch([a, b, c]).");
196
+ return ObjectBatch.make({ ...batchContext, writer: source.writer, read: source.read }, source.members, options);
197
+ };
198
+ return {
199
+ animate,
200
+ batch,
201
+ afterWrites: effects.add,
202
+ frame,
203
+ wantsFrame: () => Bool.or(frames.wantsFrame(), effects.requested()),
204
+ dispose,
205
+ stageEnvironment: { ...env, startLinksOf: environment.startLinksOf, frameEffects: effects },
206
+ };
207
+ };
208
+ //# sourceMappingURL=WardicObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WardicObject.js","sourceRoot":"","sources":["../src/WardicObject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,mGAAmG;AACnG,sGAAsG;AACtG,yGAAyG;AACzG,8BAA8B;AAC9B,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,iBAAiB,MAAM,g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,EAAE,EAAE,GAAG,GAAG,EAAE,YAAY,EAAE,WAAW,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE;KAC5F,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @wardic/object — Wardic for any object's properties, renderer-agnostic: Motion's `animate` on plain
3
+ * objects, on frames the host pumps, the base for canvas and WebGL. The root re-exports each module as
4
+ * a namespace; code imports the subpath, `import * as WardicObject from "@wardic/object/WardicObject"`.
5
+ */
6
+ export * as ObjectBatch from "./ObjectBatch.ts";
7
+ export * as ObjectRenderer from "./ObjectRenderer.ts";
8
+ export * as ObjectValues from "./ObjectValues.ts";
9
+ export * as PumpedFrames from "./PumpedFrames.ts";
10
+ export * as WardicObject from "./WardicObject.ts";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @wardic/object — Wardic for any object's properties, renderer-agnostic: Motion's `animate` on plain
3
+ * objects, on frames the host pumps, the base for canvas and WebGL. The root re-exports each module as
4
+ * a namespace; code imports the subpath, `import * as WardicObject from "@wardic/object/WardicObject"`.
5
+ */
6
+ // #882 (ADR-0068 decision 2; ADR-0073, *Amendment (#882)*): its modules named as ADR-0041 names an
7
+ // Environment's. Shipped from 1.3 (#564), with `@wardic/three`.
8
+ export * as ObjectBatch from "./ObjectBatch.js";
9
+ export * as ObjectRenderer from "./ObjectRenderer.js";
10
+ export * as ObjectValues from "./ObjectValues.js";
11
+ export * as PumpedFrames from "./PumpedFrames.js";
12
+ export * as WardicObject from "./WardicObject.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,mGAAmG;AACnG,gEAAgE;AAChE,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA"}