@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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 the Wardic contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # @wardic/object
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Wardic for any object's properties: Motion's `animate` on plain objects, on frames your loop pumps. It's the base for canvas and WebGL, under any library that draws them.
4
+
5
+ ```ts
6
+ import * as WardicObject from "@wardic/object/WardicObject"
7
+
8
+ const wardic = WardicObject.make()
9
+ renderer.setAnimationLoop((time) => {
10
+ wardic.frame(time) // Wardic's writes for this frame, before it's drawn
11
+ renderer.render(scene, camera)
12
+ })
13
+
14
+ await wardic.animate(material, { opacity: 0 }, { duration: 0.4 })
15
+ wardic.animate(sprite, { x: 100, rotate: 90 }, { type: "spring", bounce: 0.3 })
16
+ ```
17
+
18
+ - **Keys** are an object's own properties, by name. Each starts from its value when the animation starts.
19
+ - **Values** are numbers, and strings with a unit or of numbers.
20
+ - **Transitions** are Motion's by a key's name when none is given: a spring for a transform's key, an ease for any other.
21
+ - **The controls** are awaitable, with `stop`, `cancel`, `complete`, `pause`, `play`, `speed`, `time` and `duration`.
22
+ - **`afterWrites(fn)`** runs your own code each frame, after Wardic's writes and before the render.
23
+ - **`wantsFrame()`** says whether Wardic wants another frame, for a loop that draws on demand.
24
+
25
+ ## Many objects at once
26
+
27
+ A Batch moves many objects on the same keys as one run: hundreds of sprites, a chart's points, a grid of meshes. A new target turns each member toward it at the speed it has, for a fraction of what an animation per object costs.
28
+
29
+ ```ts
30
+ const dots = wardic.batch(sprites) // its keys: its first animate's, or `keys`
31
+ wardic.animate(dots, { x: (i) => i * 12, y: [0, 40] }, { delay: (rank) => rank * 0.01 })
32
+ wardic.animate(dots.at(3), { y: 0 }) // one member
33
+ dots.get(3, "y") // its value as drawn
34
+ ```
35
+
36
+ - **Each key** is a number, two stops (its first and its target), or a function of a member's index and the count that gives them.
37
+ - **Its members** are reached through it: an object of a Batch given to `animate` itself is an error.
38
+ - **A sequence** can hold a Segment of a Batch, `[dots, { opacity: [0, 1] }]`, or of a member, `[dots.at(0), …]`.
39
+
40
+ Every module is in [its reference](https://wardic.dev/reference/object). `@wardic/three` builds three.js's runtime on it ([the 3D guide](https://wardic.dev/guides/3d)).
41
+
42
+ Shipped from Wardic 1.3 (#564), versioned with `@wardic/core`, `@wardic/dom`, `@wardic/test`, `@wardic/foldkit` and `@wardic/three`.
@@ -0,0 +1,145 @@
1
+ # Third-party notices
2
+
3
+ Wardic follows the API of [Motion](https://motion.dev) for React, and parts of its source are ported from Motion's: rewritten in Wardic's own style, keeping Motion's algorithms, formulas and constants so the results match. Motion is MIT licensed, and its notice follows.
4
+
5
+ ## Motion
6
+
7
+ https://github.com/motiondivision/motion
8
+
9
+ Ported from Motion's source:
10
+
11
+ - `@wardic/core`:
12
+ - `Box` and `Projection`: the projection geometry (`motion-dom`'s `projection/geometry`: `models`, `delta-calc`, `delta-apply`, `applyTreeDeltas`);
13
+ - `Spring`: the solver for a spring's stiffness and damping from its duration and bounce (`findSpring`);
14
+ - `Velocity`: a gesture's velocity from its points (`getVelocity`);
15
+ - `Reorder`: moving an item, and the axis a list runs on (`moveItem`, `detectAxis`);
16
+ - `AutoScroll`: scrolling a container while an item is dragged near its edge (`autoScrollIfNeeded`).
17
+ - `@wardic/dom`:
18
+ - the projection transform (`buildProjectionTransform`);
19
+ - the scroll offsets (`render/dom/scroll/offsets`).
20
+
21
+ ```
22
+ The MIT License (MIT)
23
+
24
+ Copyright (c) 2024 [Motion](https://motion.dev) B.V.
25
+
26
+ Permission is hereby granted, free of charge, to any person obtaining a copy
27
+ of this software and associated documentation files (the "Software"), to deal
28
+ in the Software without restriction, including without limitation the rights
29
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
30
+ copies of the Software, and to permit persons to whom the Software is
31
+ furnished to do so, subject to the following conditions:
32
+
33
+ The above copyright notice and this permission notice shall be included in all
34
+ copies or substantial portions of the Software.
35
+
36
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
39
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
40
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42
+ SOFTWARE.
43
+ ```
44
+
45
+ ## Manrope
46
+
47
+ https://github.com/googlefonts/manrope
48
+
49
+ The docs site serves Manrope for its headings (`site/public/fonts/manrope-latin.woff2`, its variable weights 600 to 800, Latin only, with its licence beside it as `OFL.txt`), and Wardic's wordmark is "wardic" set in Manrope ExtraBold and outlined (`brand/`, and the docs header's logo, `site/src/components/logo-paths.ts`). Manrope is licensed under the SIL Open Font License, Version 1.1.
50
+
51
+ ```
52
+ Copyright 2018 The Manrope Project Authors (https://github.com/googlefonts/manrope)
53
+
54
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
55
+ This license is copied below, and is also available with a FAQ at:
56
+ http://scripts.sil.org/OFL
57
+
58
+
59
+ -----------------------------------------------------------
60
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
61
+ -----------------------------------------------------------
62
+
63
+ PREAMBLE
64
+ The goals of the Open Font License (OFL) are to stimulate worldwide
65
+ development of collaborative font projects, to support the font creation
66
+ efforts of academic and linguistic communities, and to provide a free and
67
+ open framework in which fonts may be shared and improved in partnership
68
+ with others.
69
+
70
+ The OFL allows the licensed fonts to be used, studied, modified and
71
+ redistributed freely as long as they are not sold by themselves. The
72
+ fonts, including any derivative works, can be bundled, embedded,
73
+ redistributed and/or sold with any software provided that any reserved
74
+ names are not used by derivative works. The fonts and derivatives,
75
+ however, cannot be released under any other type of license. The
76
+ requirement for fonts to remain under this license does not apply
77
+ to any document created using the fonts or their derivatives.
78
+
79
+ DEFINITIONS
80
+ "Font Software" refers to the set of files released by the Copyright
81
+ Holder(s) under this license and clearly marked as such. This may
82
+ include source files, build scripts and documentation.
83
+
84
+ "Reserved Font Name" refers to any names specified as such after the
85
+ copyright statement(s).
86
+
87
+ "Original Version" refers to the collection of Font Software components as
88
+ distributed by the Copyright Holder(s).
89
+
90
+ "Modified Version" refers to any derivative made by adding to, deleting,
91
+ or substituting -- in part or in whole -- any of the components of the
92
+ Original Version, by changing formats or by porting the Font Software to a
93
+ new environment.
94
+
95
+ "Author" refers to any designer, engineer, programmer, technical
96
+ writer or other person who contributed to the Font Software.
97
+
98
+ PERMISSION & CONDITIONS
99
+ Permission is hereby granted, free of charge, to any person obtaining
100
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
101
+ redistribute, and sell modified and unmodified copies of the Font
102
+ Software, subject to the following conditions:
103
+
104
+ 1) Neither the Font Software nor any of its individual components,
105
+ in Original or Modified Versions, may be sold by itself.
106
+
107
+ 2) Original or Modified Versions of the Font Software may be bundled,
108
+ redistributed and/or sold with any software, provided that each copy
109
+ contains the above copyright notice and this license. These can be
110
+ included either as stand-alone text files, human-readable headers or
111
+ in the appropriate machine-readable metadata fields within text or
112
+ binary files as long as those fields can be easily viewed by the user.
113
+
114
+ 3) No Modified Version of the Font Software may use the Reserved Font
115
+ Name(s) unless explicit written permission is granted by the corresponding
116
+ Copyright Holder. This restriction only applies to the primary font name as
117
+ presented to the users.
118
+
119
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
120
+ Software shall not be used to promote, endorse or advertise any
121
+ Modified Version, except to acknowledge the contribution(s) of the
122
+ Copyright Holder(s) and the Author(s) or with their explicit written
123
+ permission.
124
+
125
+ 5) The Font Software, modified or unmodified, in part or in whole,
126
+ must be distributed entirely under this license, and must not be
127
+ distributed under any other license. The requirement for fonts to
128
+ remain under this license does not apply to any document created
129
+ using the Font Software.
130
+
131
+ TERMINATION
132
+ This license becomes null and void if any of the above conditions are
133
+ not met.
134
+
135
+ DISCLAIMER
136
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
137
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
138
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
139
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
140
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
141
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
142
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
143
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
144
+ OTHER DEALINGS IN THE FONT SOFTWARE.
145
+ ```
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Many objects animated on the same keys as one run (a **Batch**): hundreds of sprites, a chart's points,
3
+ * a grid of meshes that move together. `wardic.batch(objects)` makes one; `animate(batch, target)` moves
4
+ * every member, each key's value a number, two stops (its first and its target), or a function of a
5
+ * member's index and the count; `animate(batch.at(i), target)` moves member `i`. A new target turns each
6
+ * member toward it at the speed it has, for a fraction of what an animation per object costs.
7
+ *
8
+ * - **Its keys** are fixed by its first `animate` (or `keys` when it's made). Each member starts from
9
+ * its own values for them, numbers each.
10
+ * - **Its members** are reached through it: an object of a Batch given to `animate` itself is an error.
11
+ *
12
+ * @example
13
+ * const swarm = wardic.batch(sprites)
14
+ * wardic.animate(swarm, { x: (i) => i * 12, y: [0, 40] }, { type: "spring", delay: stagger(0.01) })
15
+ * wardic.animate(swarm.at(3), { y: 0 })
16
+ */
17
+ import * as Batch from "@wardic/core/Batch";
18
+ import type * as DefaultTransition from "@wardic/core/DefaultTransition";
19
+ import type * as FrameLoop from "@wardic/core/FrameLoop";
20
+ import type * as ReducedMotion from "@wardic/core/ReducedMotion";
21
+ import type * as UnitScale from "@wardic/core/UnitScale";
22
+ import type * as Imperative from "@wardic/core/unstable/Imperative";
23
+ import type * as Effect from "effect/Effect";
24
+ import type * as Fiber from "effect/Fiber";
25
+ /** A stop of a Batch's `animate`: a number for every member, or a function of a member's index and the count. */
26
+ export type Stop = number | ((i: number, n: number) => number);
27
+ /** A key of `T` a Batch animates: one whose value is a number. */
28
+ export type NumberKey<T> = {
29
+ readonly [K in keyof T]-?: T[K] extends number ? K : never;
30
+ }[keyof T] & string;
31
+ /** A Batch's targets for an `animate` call: each key a stop, two (its first and its target), or a function giving them. */
32
+ export type Target<T, Key extends string = NumberKey<T>> = {
33
+ readonly [K in Key]?: Stop | readonly [Stop, Stop] | ((i: number, n: number) => number | readonly [number, number]);
34
+ };
35
+ /** A Batch's key in a sequence's Segment of it: a number, `null` for where it is, stops of them, or a function giving them. */
36
+ export type SegmentValue = number | null | ReadonlyArray<number | null> | ((i: number, n: number) => number | null | ReadonlyArray<number | null>);
37
+ /** A member's handle: `animate` and a sequence's Segment move member `i` alone. */
38
+ export interface Member<T extends object, Key extends string = NumberKey<T>> {
39
+ readonly i: number;
40
+ readonly batch: ObjectBatch<T, Key>;
41
+ }
42
+ /** A Batch of objects `T`. */
43
+ export interface ObjectBatch<T extends object, Key extends string = NumberKey<T>> {
44
+ /** Its members, in order. */
45
+ readonly members: ReadonlyArray<T>;
46
+ /** Member `i`'s handle, for `animate` and a sequence's Segment. */
47
+ readonly at: (i: number) => Member<T, Key>;
48
+ /** Member `i`'s value for `key` now: as drawn, once the Batch has moved; its own before. */
49
+ readonly get: (i: number, key: Key) => number;
50
+ /** Member `i`'s velocity for `key` now, per second: 0 before the Batch has moved. */
51
+ readonly velocity: (i: number, key: Key) => number;
52
+ }
53
+ /** `wardic.batch`'s options. */
54
+ export interface Options<T, Key extends string = NumberKey<T>> {
55
+ /** Its keys, fixed now: else its first `animate`'s, or its first Segment's. */
56
+ readonly keys?: ReadonlyArray<Key> | undefined;
57
+ }
58
+ /** What a runtime gives its Batches: its fork, and its Environment's Positional keys and Default transitions. */
59
+ export interface Context {
60
+ readonly runFork: <A, E>(effect: Effect.Effect<A, E, FrameLoop.FrameLoop>) => Fiber.Fiber<A, E>;
61
+ /** The Environment's unit scale: each key's units for its Batches' rest thresholds. */
62
+ readonly unitScale: UnitScale.Rule;
63
+ /** How the Environment draws a Batch's members: plain objects' {@link writer}, or another Environment's. */
64
+ readonly writer: Batch.Writer<object>;
65
+ /** How it reads a member's key before the Batch moves it: plain objects' {@link read}, the property. */
66
+ readonly read: (subject: object, key: string) => unknown;
67
+ readonly positionalKeys: ReducedMotion.PositionalKeys["Service"];
68
+ readonly defaultTransition: DefaultTransition.DefaultTransition["Service"];
69
+ }
70
+ /** The property writer for a Batch's keys: each member's values onto its properties, by name. */
71
+ export declare const writer: Batch.Writer<object>;
72
+ /** A plain object's key, as a Batch reads it before moving it: the property. */
73
+ export declare const read: (subject: object, key: string) => unknown;
74
+ /** The Batch or member handle `given` is, for `animate`: `undefined` for anything else. */
75
+ export declare const entryOf: (given: unknown) => Imperative.BatchEntry | undefined;
76
+ /** `object`'s member number in a Batch, or `undefined` when it's no Batch's. */
77
+ export declare const memberOf: (object: object) => number | undefined;
78
+ /** A Batch of `objects` for a runtime, its keys `options.keys`, else its first call's. */
79
+ export declare const make: <T extends object>(context: Context, objects: ReadonlyArray<T>, options?: Options<T>) => ObjectBatch<T>;
80
+ //# sourceMappingURL=ObjectBatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectBatch.d.ts","sourceRoot":"","sources":["../src/ObjectBatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,KAAK,iBAAiB,MAAM,gCAAgC,CAAA;AACxE,OAAO,KAAK,KAAK,SAAS,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,KAAK,aAAa,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,KAAK,SAAS,MAAM,wBAAwB,CAAA;AAExD,OAAO,KAAK,KAAK,UAAU,MAAM,kCAAkC,CAAA;AAGnE,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAK1C,iHAAiH;AACjH,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,CAAA;A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,SAAS,CAAC,CAAA;CAC3E;AAED,iGAAiG;AAEjG,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,CAMvC,CAAA;AAED,gFAAgF;AAChF,eAAO,MAAM,IAAI,YAAa,MAAM,OAAO,MAAM,KAAG,OAA8D,CAAA;AAUlH,2FAA2F;AAC3F,eAAO,MAAM,OAAO,UAAW,OAAO,KAAG,UAAU,CAAC,UAAU,GAAG,SAGhE,CAAA;AAED,gFAAgF;AAChF,eAAO,MAAM,QAAQ,WAAY,MAAM,KAAG,MAAM,GAAG,SAAgC,CAAA;AAUnF,0FAA0F;AAC1F,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,MAAM,WAAW,OAAO,WAAW,aAAa,CAAC,CAAC,CAAC,YAAW,OAAO,CAAC,CAAC,CAAC,KAAQ,WAAW,CAAC,CAAC,CA0I3H,CAAA"}
@@ -0,0 +1,191 @@
1
+ /**
2
+ * Many objects animated on the same keys as one run (a **Batch**): hundreds of sprites, a chart's points,
3
+ * a grid of meshes that move together. `wardic.batch(objects)` makes one; `animate(batch, target)` moves
4
+ * every member, each key's value a number, two stops (its first and its target), or a function of a
5
+ * member's index and the count; `animate(batch.at(i), target)` moves member `i`. A new target turns each
6
+ * member toward it at the speed it has, for a fraction of what an animation per object costs.
7
+ *
8
+ * - **Its keys** are fixed by its first `animate` (or `keys` when it's made). Each member starts from
9
+ * its own values for them, numbers each.
10
+ * - **Its members** are reached through it: an object of a Batch given to `animate` itself is an error.
11
+ *
12
+ * @example
13
+ * const swarm = wardic.batch(sprites)
14
+ * wardic.animate(swarm, { x: (i) => i * 12, y: [0, 40] }, { type: "spring", delay: stagger(0.01) })
15
+ * wardic.animate(swarm.at(3), { y: 0 })
16
+ */
17
+ // `@wardic/object/ObjectBatch` (#882; ADR-0069 decisions 10–18, ADR-0073, *Amendment (#882)*, PR 3): core's
18
+ // Batch with a property writer, its calls core's `BatchCalls`, the DOM's. Its keys at its first call or
19
+ // `keys` (the DOM's keyed `createBatch`'s rule, #665's PR 3a); a member object animated itself is an error
20
+ // until a driver's hold (ADR-0069 decision 17) comes with `@wardic/three`.
21
+ import * as Batch from "@wardic/core/Batch";
22
+ import * as BatchCalls from "@wardic/core/unstable/BatchCalls";
23
+ import * as Arr from "effect/Array";
24
+ import * as Predicate from "effect/Predicate";
25
+ import * as Rec from "effect/Record";
26
+ import * as UndefinedOr from "effect/UndefinedOr";
27
+ /** The property writer for a Batch's keys: each member's values onto its properties, by name. */
28
+ // Per frame: a plain loop over the keys, nothing allocated.
29
+ export const writer = {
30
+ writes: () => true,
31
+ forKeys: (keys) => (subject, positions, base) => {
32
+ const object = subject;
33
+ for (let k = 0; k < keys.length; k++)
34
+ object[keys[k]] = positions[base + k];
35
+ },
36
+ };
37
+ /** A plain object's key, as a Batch reads it before moving it: the property. */
38
+ export const read = (subject, key) => subject[key];
39
+ /** Each Batch's and member handle's entry, so `animate` knows them. */
40
+ // Module state (#460, Q7): held weakly by the handle, so it goes with it.
41
+ const ENTRIES = new WeakMap();
42
+ /** Each member object's place in its Batch, so `animate` of it itself is an error naming its handle. */
43
+ // Module state (#460, Q7): held weakly by the object.
44
+ const MEMBERS = new WeakMap();
45
+ /** The Batch or member handle `given` is, for `animate`: `undefined` for anything else. */
46
+ export const entryOf = (given) => {
47
+ if (!Predicate.isObject(given))
48
+ return undefined;
49
+ return ENTRIES.get(given);
50
+ };
51
+ /** `object`'s member number in a Batch, or `undefined` when it's no Batch's. */
52
+ export const memberOf = (object) => MEMBERS.get(object);
53
+ /** A Batch call's error, naming what it got. */
54
+ const fail = (message) => {
55
+ throw new Error(`wardic.batch: ${message}`);
56
+ };
57
+ /** `values`' keys that it gives: a target's or a Segment's. */
58
+ const givenKeys = (values) => Arr.filter(Rec.keys(values), (key) => Predicate.isNotUndefined(values[key]));
59
+ /** A Batch of `objects` for a runtime, its keys `options.keys`, else its first call's. */
60
+ export const make = (context, objects, options = {}) => {
61
+ let keys = [];
62
+ let keyIndex = new Map();
63
+ let batch;
64
+ // Each member's slot in the core Batch, by its number.
65
+ let slots = [];
66
+ const memberAt = [];
67
+ const count = () => objects.length;
68
+ const all = Arr.makeBy(objects.length, (i) => i);
69
+ const planning = () => ({
70
+ keys,
71
+ positionalKeys: context.positionalKeys,
72
+ defaultFor: (k, target) => context.defaultTransition.transitionFor(keys[k], target),
73
+ fail,
74
+ });
75
+ const bySlot = { indexOf: (slot) => memberAt[slot], count, nameOf: (slot) => `member ${memberAt[slot]}` };
76
+ const byMember = { indexOf: (i) => i, count, nameOf: (i) => `member ${i}` };
77
+ /** Member `i`'s start on the Batch's keys: its own values, numbers each, else an error naming it. */
78
+ const startOf = (object, i) => Rec.fromEntries(Arr.map(keys, (key) => {
79
+ const value = context.read(object, key);
80
+ if (!Predicate.isNumber(value))
81
+ fail(`member ${i}'s "${key}" is ${JSON.stringify(value)}: a Batch's keys are numbers on each of its objects`);
82
+ return [key, value];
83
+ }));
84
+ /** The core Batch, made on `given` keys at its first need, each member entered at its own values. */
85
+ const made = (given) => {
86
+ if (Predicate.isNotUndefined(batch))
87
+ return batch;
88
+ keys = given;
89
+ keyIndex = new Map(Arr.map(keys, (key, k) => [key, k]));
90
+ const transition = Rec.fromEntries(Arr.map(keys, (key) => [key, context.defaultTransition.transitionFor(key, 1)]));
91
+ const created = Batch.make({ keys, writer: context.writer, transition, unitScale: context.unitScale });
92
+ slots = Arr.map(objects, (object, i) => {
93
+ const slot = Batch.enter(created, object, startOf(object, i));
94
+ memberAt[slot] = i;
95
+ return slot;
96
+ });
97
+ batch = created;
98
+ return created;
99
+ };
100
+ /** `given`'s keys, each one of the Batch's, else an error naming it and the way to give more. */
101
+ const checked = (given) => Arr.forEach(given, (key) => {
102
+ if (keyIndex.has(key))
103
+ return;
104
+ fail(`"${key}" isn't one of its keys (${keys.join(", ")}): a Batch's keys are its first animate's, so give them all as \`keys\` when it's made, wardic.batch(objects, { keys })`);
105
+ });
106
+ /** Its run on the Frame loop, while a member moves. */
107
+ const wake = (running) => {
108
+ if (Batch.isMoving(running))
109
+ void context.runFork(Batch.run(running));
110
+ };
111
+ /** A driven change's controls, as an `animate` call's track. */
112
+ const controlsOf = (running, animation) => ({
113
+ run: () => {
114
+ Batch.play(animation);
115
+ wake(running);
116
+ },
117
+ stop: () => {
118
+ Batch.stop(animation);
119
+ wake(running);
120
+ },
121
+ cancel: () => {
122
+ Batch.cancel(animation);
123
+ wake(running);
124
+ },
125
+ duration: () => Batch.durationOf(animation),
126
+ });
127
+ /** The slots `named` members hold, every member's when it names none. */
128
+ const slotsOf = (named) => Arr.map(UndefinedOr.match(named, { onUndefined: () => all, onDefined: (given) => given }), (i) => slots[i]);
129
+ const binding = {
130
+ track: (call) => {
131
+ const given = call.target;
132
+ const running = made(givenKeys(given));
133
+ checked(givenKeys(given));
134
+ const moving = slotsOf(call.members);
135
+ const { toOf, fromOf } = BatchCalls.callTargets(planning(), keyIndex, bySlot, moving, given);
136
+ return controlsOf(running, Batch.animate(running, moving, toOf, BatchCalls.animateOptions(planning(), call, toOf, fromOf)));
137
+ },
138
+ namedOf: (entry) => UndefinedOr.map(entry.member, (i) => [i]),
139
+ segmentOf: (named, target) => {
140
+ made(givenKeys(target));
141
+ const moving = UndefinedOr.match(named, { onUndefined: () => all, onDefined: (given) => given });
142
+ return { subjects: Arr.map(moving, (i) => memberEntries[i]), values: BatchCalls.segmentValues(planning(), (key) => keyIndex.has(key), byMember, moving, target) };
143
+ },
144
+ sequenceTrack: (call) => {
145
+ const running = made(keys);
146
+ const moving = [];
147
+ const animations = [];
148
+ Arr.forEach(call.members, (i, n) => {
149
+ const slot = slots[i];
150
+ moving.push(slot);
151
+ animations[slot] = call.animations[n];
152
+ });
153
+ const keyframesOf = BatchCalls.keyframesFor(planning(), call, (slot) => UndefinedOr.getOrThrow(animations[slot]));
154
+ return controlsOf(running, Batch.keyframes(running, moving, keyframesOf, BatchCalls.keyframesOptions(call)));
155
+ },
156
+ };
157
+ const memberEntries = Arr.map(objects, (_, i) => ({ binding, member: i }));
158
+ const handles = [];
159
+ const handle = {
160
+ members: objects,
161
+ at: (i) => {
162
+ const known = handles[i];
163
+ if (Predicate.isNotUndefined(known))
164
+ return known;
165
+ if (Predicate.isUndefined(objects[i]))
166
+ fail(`it has ${objects.length} members: there's no member ${i}`);
167
+ const made = { i, batch: handle };
168
+ ENTRIES.set(made, memberEntries[i]);
169
+ handles[i] = made;
170
+ return made;
171
+ },
172
+ get: (i, key) => UndefinedOr.match(batch, {
173
+ onUndefined: () => context.read(objects[i], key),
174
+ onDefined: (running) => Batch.get(running, slots[i], key),
175
+ }),
176
+ velocity: (i, key) => UndefinedOr.match(batch, {
177
+ onUndefined: () => 0,
178
+ onDefined: (running) => Batch.velocity(running, slots[i], key),
179
+ }),
180
+ };
181
+ ENTRIES.set(handle, { binding, member: undefined });
182
+ Arr.forEach(objects, (object, i) => {
183
+ if (Predicate.isNotUndefined(MEMBERS.get(object)))
184
+ fail(`member ${i} is already a member of a Batch: an object is one Batch's`);
185
+ MEMBERS.set(object, i);
186
+ });
187
+ if (Predicate.isNotUndefined(options.keys))
188
+ made(options.keys);
189
+ return handle;
190
+ };
191
+ //# sourceMappingURL=ObjectBatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectBatch.js","sourceRoot":"","sources":["../src/ObjectBatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,4GAA4G;AAC5G,wGAAwG;AACxG,2GAA2G;AAC3G,2EAA2E;AAC3E,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAK3C,OAAO,KAAK,UAAU,MAAM,kCAAkC,CAAA;AAG9D,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAGnC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAA;AACpC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AAuDjD,iGAAiG;AACjG,4DAA4D;AAC5D,MAAM,CA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= value`), once a frame, in the frame that computed them. `layer` is what
4
+ * `WardicObject` provides; `GATE` is what its Flush gate reads of an object.
5
+ *
6
+ * @example
7
+ * import * as ObjectRenderer from "@wardic/object/ObjectRenderer"
8
+ *
9
+ * ObjectRenderer.commit(material, { opacity: 0.5 }) // material.opacity === 0.5
10
+ */
11
+ import * as Renderer from "@wardic/core/Renderer";
12
+ import type * as FlushGate from "@wardic/core/unstable/FlushGate";
13
+ import * as Layer from "effect/Layer";
14
+ /** A plain object's patch: its values as they are, one property each. */
15
+ export declare const project: (values: Readonly<Record<string, unknown>>) => Renderer.Patch;
16
+ /** `patch` written onto `target`'s properties: each key's value, a key the gate puts back with nothing saved left as it is. */
17
+ export declare const commit: (target: unknown, patch: Renderer.Patch) => void;
18
+ /** The Flush gate's reads of an object: nothing saved before a write, and a template key no object has. */
19
+ export declare const GATE: FlushGate.GateEnvironment;
20
+ /** The property writer as the Environment's `Renderer`. */
21
+ export declare const layer: Layer.Layer<Renderer.Renderer>;
22
+ //# sourceMappingURL=ObjectRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectRenderer.d.ts","sourceRoot":"","sources":["../src/ObjectRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,KAAK,SAAS,MAAM,iCAAiC,CAAA;AACjE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAQrC,yEAAyE;AACzE,eAAO,MAAM,OAAO,WAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAG,QAAQ,CAAC,KAAiC,CAAA;AAE9G,+HAA+H;AAE/H,eAAO,MAAM,MAAM,WAAY,OAAO,SAAS,QAAQ,CAAC,KAAK,KAAG,IAO/D,CAAA;AAED,2GAA2G;AAC3G,eAAO,MAAM,IAAI,EAAE,SAAS,CAAC,eAAgG,CAAA;AAE7H,2DAA2D;AAC3D,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAuE,CAAA"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The property writer: Wardic's values written onto a plain object's properties, by their names, as
3
+ * they are (`object[key] = value`), once a frame, in the frame that computed them. `layer` is what
4
+ * `WardicObject` provides; `GATE` is what its Flush gate reads of an object.
5
+ *
6
+ * @example
7
+ * import * as ObjectRenderer from "@wardic/object/ObjectRenderer"
8
+ *
9
+ * ObjectRenderer.commit(material, { opacity: 0.5 }) // material.opacity === 0.5
10
+ */
11
+ // `@wardic/object/ObjectRenderer` (#882, ADR-0068 decision 2; ADR-0073, *Amendment (#882)*, Q5): core's
12
+ // `Renderer`, as ADR-0041 names an Environment's implementations. No grouping: `x` is the property `x`
13
+ // (three's keys are `@wardic/three`'s, step 2).
14
+ import * as Renderer from "@wardic/core/Renderer";
15
+ import * as Layer from "effect/Layer";
16
+ /**
17
+ * What the gate saves of a property before its first write, to put back if the key ever drops out:
18
+ * nothing. A plain object's values stay where Wardic leaves them, so a commit skips a key given this.
19
+ */
20
+ const NOTHING_SAVED = "";
21
+ /** A plain object's patch: its values as they are, one property each. */
22
+ export const project = (values) => values;
23
+ /** `patch` written onto `target`'s properties: each key's value, a key the gate puts back with nothing saved left as it is. */
24
+ // Per frame: a plain loop over the patch's keys.
25
+ export const commit = (target, patch) => {
26
+ const object = target;
27
+ for (const key in patch) {
28
+ const value = patch[key];
29
+ if (value === NOTHING_SAVED)
30
+ continue;
31
+ object[key] = value;
32
+ }
33
+ };
34
+ /** The Flush gate's reads of an object: nothing saved before a write, and a template key no object has. */
35
+ export const GATE = { valueBeforeOf: () => NOTHING_SAVED, templateKey: "@wardic/object/template" };
36
+ /** The property writer as the Environment's `Renderer`. */
37
+ export const layer = /*#__PURE__*/ Layer.succeed(Renderer.Renderer, { project, commit });
38
+ //# sourceMappingURL=ObjectRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectRenderer.js","sourceRoot":"","sources":["../src/ObjectRenderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wGAAwG;AACxG,uGAAuG;AACvG,gDAAgD;AAChD,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AAEjD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC;;;GAGG;AACH,MAAM,aAAa,GAAG,EAAE,CAAA;AAExB,yEAAyE;AACzE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAyC,EAAkB,EAAE,CAAC,MAAwB,CAAA;AAE9G,+HAA+H;AAC/H,iDAAiD;AACjD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAe,EAAE,KAAqB,EAAQ,EAAE;IACrE,MAAM,MAAM,GAAG,MAAiC,CAAA;IAChD,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;QACxB,IAAI,KAAK,KAAK,aAAa;YAAE,SAAQ;QACrC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACrB,CAAC;AACH,CAAC,CAAA;AAED,2GAA2G;AAC3G,MAAM,CAAC,MAAM,IAAI,GAA8B,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC,aAAa,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAA;AAE7H,2DAA2D;AAC3D,MAAM,CAAC,MAAM,KAAK,GAAmC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA"}
@@ -0,0 +1,23 @@
1
+ import type * as MeasuredPairs from "@wardic/core/unstable/MeasuredPairs";
2
+ import type * as OwnValues from "@wardic/core/unstable/OwnValues";
3
+ import type * as Spine from "@wardic/core/unstable/Spine";
4
+ import type * as VariableValues from "@wardic/core/unstable/VariableValues";
5
+ import * as Option from "effect/Option";
6
+ /**
7
+ * Base-value links on `read`: each key starts from what `read` gives for it when the animation
8
+ * starts, an error it throws naming the key; there's no style to start from. Another Environment of
9
+ * objects reads its own way: `@wardic/three`'s finds a key on a mesh's material.
10
+ */
11
+ export declare const startLinksWith: (read: (subject: object, key: string) => Option.Option<number | string>) => (subject: object) => Spine.StartLinks;
12
+ /**
13
+ * `subject`'s Base-value links: each key starts from its own value, the property as it is
14
+ * when the animation starts; there's no style to start from.
15
+ */
16
+ export declare const startLinksOf: (subject: object) => Spine.StartLinks;
17
+ /** The Own values port: values in the shape of their targets, and no style. */
18
+ export declare const ownValues: OwnValues.Shape;
19
+ /** The Measured pairs port: none. */
20
+ export declare const measuredPairs: MeasuredPairs.Shape;
21
+ /** The Variable values port: none. */
22
+ export declare const variableValues: VariableValues.Shape;
23
+ //# sourceMappingURL=ObjectValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectValues.d.ts","sourceRoot":"","sources":["../src/ObjectValues.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,aAAa,MAAM,qCAAqC,CAAA;AACzE,OAAO,KAAK,KAAK,SAAS,MAAM,iCAAiC,CAAA;AACjE,OAAO,KAAK,KAAK,KAAK,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,KAAK,cAAc,MAAM,sCAAsC,CAAA;AAE3E,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAqCvC;;;;GAIG;AAGH,eAAO,MAAM,cAAc,SAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,eAAe,MAAM,KAAG,KAAK,CAAC,UAQlI,CAAA;AAED;;;GAGG;AAEH,eAAO,MAAM,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,KAAK,CAAC,UAAqD,CAAA;AAK3G,+EAA+E;AAC/E,eAAO,MAAM,SAAS,EAAE,SAAS,CAAC,KAIjC,CAAA;AAKD,qCAAqC;AACrC,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,KAGzC,CAAA;AAKD,sCAAsC;AACtC,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,KAG3C,CAAA"}