@edv4h/usketch-presence-motion 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +26 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/motion-builder.d.ts +77 -0
- package/dist/motion-builder.d.ts.map +1 -0
- package/dist/motion-builder.js +90 -0
- package/dist/motion-builder.js.map +1 -0
- package/dist/motion.d.ts +102 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +190 -0
- package/dist/motion.js.map +1 -0
- package/package.json +39 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 EdV4H
|
|
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,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @edv4h/usketch-presence-motion
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `activity.motion` awareness value from presence activity (#960): one value that
|
|
4
|
+
describes a continuous movement ("the cursor glides to A, selects it, glides to B,
|
|
5
|
+
edits it"), so it costs a single awareness update and every receiver plays it back
|
|
6
|
+
smoothly on its own clock.
|
|
7
|
+
|
|
8
|
+
No dependencies and no React, so a server or a bot can use it as well as the editor.
|
|
9
|
+
|
|
10
|
+
- **Receivers**: `normalizeMotion` (validate untrusted peer data), `sampleMotion`
|
|
11
|
+
(the frame at a time), `createMotionClock` (per-receiver playback clock).
|
|
12
|
+
`@edv4h/usketch-plugin-presence-activity` draws it.
|
|
13
|
+
- **Senders**: `visitShapes` (stops that visit shapes in order),
|
|
14
|
+
`buildMotion` (the motion through those stops), `motionStopTimes` (when the
|
|
15
|
+
cursor reaches each stop, to make each change as it gets there) and
|
|
16
|
+
`motionFinalCursor` (where the cursor rests afterwards).
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { buildMotion, motionStopTimes, visitShapes } from "@edv4h/usketch-presence-motion";
|
|
20
|
+
|
|
21
|
+
const stops = visitShapes(created.map((s) => ({ id: s.id, box: s })));
|
|
22
|
+
const motion = buildMotion({ id: crypto.randomUUID(), stops, from: lastCursor });
|
|
23
|
+
awareness.setLocalStateField("activity", { shapeIds: [], action: "edit", label: "AI", motion });
|
|
24
|
+
motionStopTimes(stops, { from: lastCursor }).forEach((at, i) =>
|
|
25
|
+
setTimeout(() => doc.transact(() => shapes.set(created[i].id, created[i])), at),
|
|
26
|
+
);
|
|
27
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type ActivityFrame, type ActivityKeyframe, type ActivityMotion, type BoundingBox, createMotionClock, MAX_KEYFRAMES, MAX_MOTION_MS, MAX_MOVES_PER_KEYFRAME, type MotionClock, type MotionPoint, motionDuration, normalizeMotion, type ShapeMove, sampleMotion, } from "./motion.js";
|
|
2
|
+
export { type BuildMotionOptions, boxCenter, buildMotion, DEFAULT_MOTION_HOP_MS, DEFAULT_MOTION_TOUR_MS, type MotionStop, type MotionTiming, motionFinalCursor, motionStopTimes, visitShapes, } from "./motion-builder.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,cAAc,EACd,eAAe,EACf,KAAK,SAAS,EACd,YAAY,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,kBAAkB,EACvB,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,iBAAiB,EACjB,eAAe,EACf,WAAW,GACX,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createMotionClock, MAX_KEYFRAMES, MAX_MOTION_MS, MAX_MOVES_PER_KEYFRAME, motionDuration, normalizeMotion, sampleMotion, } from "./motion.js";
|
|
2
|
+
export { boxCenter, buildMotion, DEFAULT_MOTION_HOP_MS, DEFAULT_MOTION_TOUR_MS, motionFinalCursor, motionStopTimes, visitShapes, } from "./motion-builder.js";
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,sBAAsB,EAGtB,cAAc,EACd,eAAe,EAEf,YAAY,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAEN,SAAS,EACT,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EAGtB,iBAAiB,EACjB,eAAe,EACf,WAAW,GACX,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type ActivityMotion, type BoundingBox, type MotionPoint } from "./motion.js";
|
|
2
|
+
/**
|
|
3
|
+
* Sender side of {@link ActivityMotion}: build "the cursor glides from shape to
|
|
4
|
+
* shape, outlining each as it arrives" as one awareness value. The receiver side is
|
|
5
|
+
* `sampleMotion`; this is its counterpart for whoever publishes the motion (a bot,
|
|
6
|
+
* a server-side agent, a scripted demo, a replay).
|
|
7
|
+
*
|
|
8
|
+
* Pure and dependency-free, so a server can use it directly.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* One place the cursor visits; `shapeIds` is the outline set shown on arrival. With
|
|
12
|
+
* `move`, the cursor first goes to the shape's old box and then drags a ghost of it
|
|
13
|
+
* to `move.to` (whose centre should be `cursor`).
|
|
14
|
+
*/
|
|
15
|
+
export interface MotionStop {
|
|
16
|
+
cursor: MotionPoint;
|
|
17
|
+
shapeIds?: string[];
|
|
18
|
+
move?: {
|
|
19
|
+
shapeId: string;
|
|
20
|
+
from: BoundingBox;
|
|
21
|
+
to: BoundingBox;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Default time for one cursor hop between stops. */
|
|
25
|
+
export declare const DEFAULT_MOTION_HOP_MS = 420;
|
|
26
|
+
/**
|
|
27
|
+
* Default cap on a whole tour, so many stops speed up instead of dragging on. (The
|
|
28
|
+
* MCP server's old builder called this `MAX_MOTION_MS`; that name here is the
|
|
29
|
+
* receiver's hard limit, 60 s.)
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_MOTION_TOUR_MS = 2400;
|
|
32
|
+
export interface MotionTiming {
|
|
33
|
+
/** Time for one hop (default {@link DEFAULT_MOTION_HOP_MS}). */
|
|
34
|
+
hopMs?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Cap on the whole tour; hops shrink to fit (default {@link DEFAULT_MOTION_TOUR_MS}).
|
|
37
|
+
* Never more than the receivers' `MAX_MOTION_MS`, which they clamp times to.
|
|
38
|
+
*/
|
|
39
|
+
maxDurationMs?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface BuildMotionOptions extends MotionTiming {
|
|
42
|
+
/** Unique per motion; a new id restarts playback on receivers. */
|
|
43
|
+
id: string;
|
|
44
|
+
stops: readonly MotionStop[];
|
|
45
|
+
/** Where the cursor rests now. Omitted (or null): the tour starts at the first stop. */
|
|
46
|
+
from?: MotionPoint | null;
|
|
47
|
+
/** Action shown with each stop's outline (default `"edit"`). */
|
|
48
|
+
action?: "select" | "edit";
|
|
49
|
+
}
|
|
50
|
+
export declare const boxCenter: (b: BoundingBox) => MotionPoint;
|
|
51
|
+
/**
|
|
52
|
+
* Milliseconds after the start at which the cursor reaches each stop (and its
|
|
53
|
+
* outline appears), in the same order as `stops`. Same timing as
|
|
54
|
+
* {@link buildMotion}, so a sender can make each change in the doc as the cursor
|
|
55
|
+
* gets there instead of all at once.
|
|
56
|
+
*/
|
|
57
|
+
export declare function motionStopTimes(stops: readonly MotionStop[], opts?: MotionTiming & {
|
|
58
|
+
from?: MotionPoint | null;
|
|
59
|
+
}): number[];
|
|
60
|
+
/**
|
|
61
|
+
* Cursor tour through `stops`, starting at `from` if known, else at the first stop.
|
|
62
|
+
* Each stop's `shapeIds` become visible on arrival. Returns `null` when there is
|
|
63
|
+
* nothing to move through.
|
|
64
|
+
*/
|
|
65
|
+
export declare function buildMotion(opts: BuildMotionOptions): ActivityMotion | null;
|
|
66
|
+
/**
|
|
67
|
+
* Stops that visit each shape in order, outlining the shapes visited so far. A shape
|
|
68
|
+
* with a `from` box different from its `box` is dragged there (see `MotionStop.move`).
|
|
69
|
+
*/
|
|
70
|
+
export declare function visitShapes(shapes: ReadonlyArray<{
|
|
71
|
+
id: string;
|
|
72
|
+
box: BoundingBox;
|
|
73
|
+
from?: BoundingBox;
|
|
74
|
+
}>): MotionStop[];
|
|
75
|
+
/** Where the cursor ends up after a motion, if it moves one. */
|
|
76
|
+
export declare function motionFinalCursor(motion: ActivityMotion): MotionPoint | undefined;
|
|
77
|
+
//# sourceMappingURL=motion-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-builder.d.ts","sourceRoot":"","sources":["../src/motion-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,WAAW,EAEhB,KAAK,WAAW,EAChB,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,EAAE,EAAE,WAAW,CAAA;KAAE,CAAC;CAC/D;AAED,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC5B,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACvD,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IAC7B,wFAAwF;IACxF,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,gEAAgE;IAChE,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,SAAS,MAAO,WAAW,KAAG,WAGzC,CAAC;AAqBH;;;;;GAKG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,IAAI,GAAE,YAAY,GAAG;IAAE,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAA;CAAO,GACrD,MAAM,EAAE,CAOV;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,cAAc,GAAG,IAAI,CAsB3E;AAKD;;;GAGG;AACH,wBAAgB,WAAW,CAC1B,MAAM,EAAE,aAAa,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,WAAW,CAAC;IAAC,IAAI,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC,GACzE,UAAU,EAAE,CAQd;AAED,gEAAgE;AAChE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,GAAG,SAAS,CAMjF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { MAX_MOTION_MS, } from "./motion.js";
|
|
2
|
+
/** Default time for one cursor hop between stops. */
|
|
3
|
+
export const DEFAULT_MOTION_HOP_MS = 420;
|
|
4
|
+
/**
|
|
5
|
+
* Default cap on a whole tour, so many stops speed up instead of dragging on. (The
|
|
6
|
+
* MCP server's old builder called this `MAX_MOTION_MS`; that name here is the
|
|
7
|
+
* receiver's hard limit, 60 s.)
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_MOTION_TOUR_MS = 2400;
|
|
10
|
+
export const boxCenter = (b) => ({
|
|
11
|
+
x: b.x + b.width / 2,
|
|
12
|
+
y: b.y + b.height / 2,
|
|
13
|
+
});
|
|
14
|
+
/** Cursor positions of a tour: a moved shape costs two (its old spot, then its new one). */
|
|
15
|
+
const pointCount = (stops) => stops.reduce((n, s) => n + (s.move ? 2 : 1), 0);
|
|
16
|
+
/** A non-negative finite length, else `fallback` (callers may be plain JS). */
|
|
17
|
+
const lengthOr = (v, fallback) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : fallback;
|
|
18
|
+
function hopLength(stops, from, timing) {
|
|
19
|
+
const hopMs = lengthOr(timing.hopMs, DEFAULT_MOTION_HOP_MS);
|
|
20
|
+
const tourMs = Math.min(lengthOr(timing.maxDurationMs, DEFAULT_MOTION_TOUR_MS), MAX_MOTION_MS);
|
|
21
|
+
const hops = pointCount(stops) - (from ? 0 : 1);
|
|
22
|
+
return hops > 0 ? Math.min(hopMs, tourMs / hops) : 0;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Milliseconds after the start at which the cursor reaches each stop (and its
|
|
26
|
+
* outline appears), in the same order as `stops`. Same timing as
|
|
27
|
+
* {@link buildMotion}, so a sender can make each change in the doc as the cursor
|
|
28
|
+
* gets there instead of all at once.
|
|
29
|
+
*/
|
|
30
|
+
export function motionStopTimes(stops, opts = {}) {
|
|
31
|
+
const hop = hopLength(stops, opts.from, opts);
|
|
32
|
+
let step = opts.from ? 1 : 0;
|
|
33
|
+
return stops.map((s) => {
|
|
34
|
+
step += s.move ? 1 : 0;
|
|
35
|
+
return Math.round(step++ * hop);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Cursor tour through `stops`, starting at `from` if known, else at the first stop.
|
|
40
|
+
* Each stop's `shapeIds` become visible on arrival. Returns `null` when there is
|
|
41
|
+
* nothing to move through.
|
|
42
|
+
*/
|
|
43
|
+
export function buildMotion(opts) {
|
|
44
|
+
const { id, stops, from, action = "edit" } = opts;
|
|
45
|
+
if (stops.length === 0)
|
|
46
|
+
return null;
|
|
47
|
+
const hop = hopLength(stops, from, opts);
|
|
48
|
+
const keyframes = [];
|
|
49
|
+
let step = 0;
|
|
50
|
+
const at = () => Math.round(step++ * hop);
|
|
51
|
+
if (from)
|
|
52
|
+
keyframes.push({ at: at(), cursor: from });
|
|
53
|
+
for (const stop of stops) {
|
|
54
|
+
if (stop.move) {
|
|
55
|
+
const { shapeId, from: before } = stop.move;
|
|
56
|
+
keyframes.push({ at: at(), cursor: boxCenter(before), moves: [{ shapeId, box: before }] });
|
|
57
|
+
}
|
|
58
|
+
keyframes.push({
|
|
59
|
+
at: at(),
|
|
60
|
+
cursor: stop.cursor,
|
|
61
|
+
...(stop.shapeIds ? { shapeIds: stop.shapeIds, action } : {}),
|
|
62
|
+
...(stop.move ? { moves: [{ shapeId: stop.move.shapeId, box: stop.move.to }] } : {}),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return { id, keyframes, easing: "ease-in-out" };
|
|
66
|
+
}
|
|
67
|
+
const sameBox = (a, b) => a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
|
|
68
|
+
/**
|
|
69
|
+
* Stops that visit each shape in order, outlining the shapes visited so far. A shape
|
|
70
|
+
* with a `from` box different from its `box` is dragged there (see `MotionStop.move`).
|
|
71
|
+
*/
|
|
72
|
+
export function visitShapes(shapes) {
|
|
73
|
+
return shapes.map((s, i) => ({
|
|
74
|
+
cursor: boxCenter(s.box),
|
|
75
|
+
shapeIds: shapes.slice(0, i + 1).map((v) => v.id),
|
|
76
|
+
...(s.from && !sameBox(s.from, s.box)
|
|
77
|
+
? { move: { shapeId: s.id, from: s.from, to: s.box } }
|
|
78
|
+
: {}),
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
/** Where the cursor ends up after a motion, if it moves one. */
|
|
82
|
+
export function motionFinalCursor(motion) {
|
|
83
|
+
for (let i = motion.keyframes.length - 1; i >= 0; i--) {
|
|
84
|
+
const c = motion.keyframes[i].cursor;
|
|
85
|
+
if (c)
|
|
86
|
+
return c;
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=motion-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
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|
1
|
+
/**
|
|
2
|
+
* A world-space rectangle. Same shape as `BoundingBox` in `@edv4h/usketch-shared`,
|
|
3
|
+
* kept local so this package has no dependencies (servers can use it as is).
|
|
4
|
+
*/
|
|
5
|
+
export interface BoundingBox {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
/** A world-space point (same shape as the awareness `cursor` field). */
|
|
12
|
+
export interface MotionPoint {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* One keyframe of an {@link ActivityMotion}. Every field except `at` is optional and
|
|
18
|
+
* describes one "track"; a keyframe only changes the tracks it sets.
|
|
19
|
+
*
|
|
20
|
+
* - `cursor` / `marquee` are **interpolated** toward the next keyframe that sets them
|
|
21
|
+
* (`marquee: null` ends the rectangle, and is never interpolated into).
|
|
22
|
+
* - `shapeIds` / `action` are **held** until the next keyframe that sets them.
|
|
23
|
+
* - `moves` places a ghost of each listed shape; a shape's ghost is **interpolated**
|
|
24
|
+
* between consecutive keyframes that list it, and is shown only while it is
|
|
25
|
+
* between its first and last such keyframe (the real shape already sits at the
|
|
26
|
+
* destination in the doc, so the ghost replays the trip and then disappears).
|
|
27
|
+
*
|
|
28
|
+
* New tracks can be added later as further optional fields: receivers ignore keys
|
|
29
|
+
* they don't know, so the schema stays backward compatible.
|
|
30
|
+
*/
|
|
31
|
+
export interface ActivityKeyframe {
|
|
32
|
+
/** Milliseconds from the start of the motion. Keyframes are sorted by this. */
|
|
33
|
+
at: number;
|
|
34
|
+
cursor?: MotionPoint;
|
|
35
|
+
shapeIds?: string[];
|
|
36
|
+
marquee?: BoundingBox | null;
|
|
37
|
+
action?: "select" | "edit";
|
|
38
|
+
/** World bounds of shapes being moved, at this instant (see the class comment). */
|
|
39
|
+
moves?: ShapeMove[];
|
|
40
|
+
}
|
|
41
|
+
/** One shape's position in a {@link ActivityKeyframe.moves} track. */
|
|
42
|
+
export interface ShapeMove {
|
|
43
|
+
shapeId: string;
|
|
44
|
+
box: BoundingBox;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A continuous movement — "cursor glides to A, selects it, glides to B, edits it" —
|
|
48
|
+
* expressed as ONE value on the awareness `activity` field, so it costs a single
|
|
49
|
+
* awareness update and every receiver plays it back smoothly at its own frame rate.
|
|
50
|
+
*
|
|
51
|
+
* Receivers start the clock when they first see a given `id` (no clock sync between
|
|
52
|
+
* peers needed), play the keyframes, then hold the final frame until the sender
|
|
53
|
+
* clears `activity`. Publishing a new `id` restarts playback.
|
|
54
|
+
*/
|
|
55
|
+
export interface ActivityMotion {
|
|
56
|
+
/** Unique per motion; a change restarts playback on receivers. */
|
|
57
|
+
id: string;
|
|
58
|
+
keyframes: ActivityKeyframe[];
|
|
59
|
+
/** Easing for interpolated tracks between two keyframes (default `"ease-in-out"`). */
|
|
60
|
+
easing?: "linear" | "ease-in-out";
|
|
61
|
+
}
|
|
62
|
+
/** What a motion looks like at one instant. */
|
|
63
|
+
export interface ActivityFrame {
|
|
64
|
+
cursor?: MotionPoint;
|
|
65
|
+
shapeIds: string[];
|
|
66
|
+
marquee?: BoundingBox;
|
|
67
|
+
action: "select" | "edit";
|
|
68
|
+
/** Ghosts of shapes currently in transit (world bounds). */
|
|
69
|
+
ghosts: ShapeMove[];
|
|
70
|
+
/** `true` once playback has reached the last keyframe (the final frame is held). */
|
|
71
|
+
done: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Upper bounds so a malformed/hostile peer can't make every receiver do unbounded work. */
|
|
74
|
+
export declare const MAX_KEYFRAMES = 256;
|
|
75
|
+
export declare const MAX_MOTION_MS = 60000;
|
|
76
|
+
export declare const MAX_MOVES_PER_KEYFRAME = 64;
|
|
77
|
+
/**
|
|
78
|
+
* Validate a motion received over awareness (untrusted peer data). Drops malformed
|
|
79
|
+
* keyframes and fields, clamps times to `[0, MAX_MOTION_MS]`, caps the keyframe
|
|
80
|
+
* count and sorts by `at`. Returns `null` when nothing playable remains.
|
|
81
|
+
*/
|
|
82
|
+
export declare function normalizeMotion(raw: unknown): ActivityMotion | null;
|
|
83
|
+
/** Total length of a motion in ms (the `at` of its last keyframe). */
|
|
84
|
+
export declare function motionDuration(motion: ActivityMotion): number;
|
|
85
|
+
/**
|
|
86
|
+
* Sample a motion `elapsed` ms after playback started. Pure: same inputs, same
|
|
87
|
+
* frame. Past the end it returns the final frame with `done: true`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function sampleMotion(motion: ActivityMotion, elapsed: number): ActivityFrame;
|
|
90
|
+
/**
|
|
91
|
+
* Per-receiver playback clock: remembers when each participant's current motion was
|
|
92
|
+
* first seen, so `elapsed()` is measured on THIS client's clock (no cross-peer clock
|
|
93
|
+
* sync). Seeing a new motion `id` for a participant restarts its clock.
|
|
94
|
+
*/
|
|
95
|
+
export interface MotionClock {
|
|
96
|
+
/** Elapsed ms of `motionId` for `clientId`, starting its clock if new. */
|
|
97
|
+
elapsed(clientId: number, motionId: string): number;
|
|
98
|
+
/** Forget participants not in `active` (no motion any more / left the board). */
|
|
99
|
+
prune(active: ReadonlySet<number>): void;
|
|
100
|
+
}
|
|
101
|
+
export declare function createMotionClock(now?: () => number): MotionClock;
|
|
102
|
+
//# sourceMappingURL=motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../src/motion.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAED,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,gB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AE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,aAAa,CAsBnF;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC3B,0EAA0E;IAC1E,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IACpD,iFAAiF;IACjF,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CACzC;AAED,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,MAAM,MAAgC,GAAG,WAAW,CAgB1F"}
|
package/dist/motion.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/** Upper bounds so a malformed/hostile peer can't make every receiver do unbounded work. */
|
|
2
|
+
export const MAX_KEYFRAMES = 256;
|
|
3
|
+
export const MAX_MOTION_MS = 60_000;
|
|
4
|
+
export const MAX_MOVES_PER_KEYFRAME = 64;
|
|
5
|
+
const isFiniteNumber = (v) => typeof v === "number" && Number.isFinite(v);
|
|
6
|
+
function readPoint(v) {
|
|
7
|
+
if (!v || typeof v !== "object")
|
|
8
|
+
return undefined;
|
|
9
|
+
const { x, y } = v;
|
|
10
|
+
return isFiniteNumber(x) && isFiniteNumber(y) ? { x, y } : undefined;
|
|
11
|
+
}
|
|
12
|
+
function readBox(v) {
|
|
13
|
+
if (!v || typeof v !== "object")
|
|
14
|
+
return undefined;
|
|
15
|
+
const { x, y, width, height } = v;
|
|
16
|
+
return isFiniteNumber(x) && isFiniteNumber(y) && isFiniteNumber(width) && isFiniteNumber(height)
|
|
17
|
+
? { x, y, width, height }
|
|
18
|
+
: undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Validate a motion received over awareness (untrusted peer data). Drops malformed
|
|
22
|
+
* keyframes and fields, clamps times to `[0, MAX_MOTION_MS]`, caps the keyframe
|
|
23
|
+
* count and sorts by `at`. Returns `null` when nothing playable remains.
|
|
24
|
+
*/
|
|
25
|
+
export function normalizeMotion(raw) {
|
|
26
|
+
if (!raw || typeof raw !== "object")
|
|
27
|
+
return null;
|
|
28
|
+
const { id, keyframes, easing } = raw;
|
|
29
|
+
if (typeof id !== "string" || id === "" || !Array.isArray(keyframes))
|
|
30
|
+
return null;
|
|
31
|
+
const out = [];
|
|
32
|
+
for (const k of keyframes.slice(0, MAX_KEYFRAMES)) {
|
|
33
|
+
if (!k || typeof k !== "object")
|
|
34
|
+
continue;
|
|
35
|
+
const r = k;
|
|
36
|
+
if (!isFiniteNumber(r.at))
|
|
37
|
+
continue;
|
|
38
|
+
const kf = { at: Math.min(Math.max(r.at, 0), MAX_MOTION_MS) };
|
|
39
|
+
const cursor = readPoint(r.cursor);
|
|
40
|
+
if (cursor)
|
|
41
|
+
kf.cursor = cursor;
|
|
42
|
+
if (Array.isArray(r.shapeIds)) {
|
|
43
|
+
kf.shapeIds = r.shapeIds.filter((s) => typeof s === "string");
|
|
44
|
+
}
|
|
45
|
+
if (r.marquee === null)
|
|
46
|
+
kf.marquee = null;
|
|
47
|
+
else {
|
|
48
|
+
const box = readBox(r.marquee);
|
|
49
|
+
if (box)
|
|
50
|
+
kf.marquee = box;
|
|
51
|
+
}
|
|
52
|
+
if (r.action === "select" || r.action === "edit")
|
|
53
|
+
kf.action = r.action;
|
|
54
|
+
if (Array.isArray(r.moves)) {
|
|
55
|
+
const moves = [];
|
|
56
|
+
for (const m of r.moves.slice(0, MAX_MOVES_PER_KEYFRAME)) {
|
|
57
|
+
const shapeId = m?.shapeId;
|
|
58
|
+
const box = readBox(m?.box);
|
|
59
|
+
if (typeof shapeId === "string" && box)
|
|
60
|
+
moves.push({ shapeId, box });
|
|
61
|
+
}
|
|
62
|
+
if (moves.length > 0)
|
|
63
|
+
kf.moves = moves;
|
|
64
|
+
}
|
|
65
|
+
out.push(kf);
|
|
66
|
+
}
|
|
67
|
+
if (out.length === 0)
|
|
68
|
+
return null;
|
|
69
|
+
// Stable sort keeps the sender's order for keyframes sharing the same `at`.
|
|
70
|
+
out.sort((a, b) => a.at - b.at);
|
|
71
|
+
return { id, keyframes: out, easing: easing === "linear" ? "linear" : "ease-in-out" };
|
|
72
|
+
}
|
|
73
|
+
/** Total length of a motion in ms (the `at` of its last keyframe). */
|
|
74
|
+
export function motionDuration(motion) {
|
|
75
|
+
return motion.keyframes.reduce((max, k) => Math.max(max, k.at), 0);
|
|
76
|
+
}
|
|
77
|
+
const lerpBox = (a, b, p) => ({
|
|
78
|
+
x: lerp(a.x, b.x, p),
|
|
79
|
+
y: lerp(a.y, b.y, p),
|
|
80
|
+
width: lerp(a.width, b.width, p),
|
|
81
|
+
height: lerp(a.height, b.height, p),
|
|
82
|
+
});
|
|
83
|
+
const easeInOut = (t) => (t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2);
|
|
84
|
+
const lerp = (a, b, t) => a + (b - a) * t;
|
|
85
|
+
/**
|
|
86
|
+
* Interpolated value of one track at `elapsed`: the last keyframe at/before it that
|
|
87
|
+
* sets the track, blended toward the next one that sets it to a non-null value.
|
|
88
|
+
*/
|
|
89
|
+
function sampleTrack(keyframes, elapsed, pick, blend, ease) {
|
|
90
|
+
let prev;
|
|
91
|
+
let next;
|
|
92
|
+
for (const k of keyframes) {
|
|
93
|
+
if (pick(k) === undefined)
|
|
94
|
+
continue;
|
|
95
|
+
if (k.at <= elapsed)
|
|
96
|
+
prev = k;
|
|
97
|
+
else {
|
|
98
|
+
next = k;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!prev)
|
|
103
|
+
return undefined;
|
|
104
|
+
const a = pick(prev);
|
|
105
|
+
if (a === null || a === undefined)
|
|
106
|
+
return undefined;
|
|
107
|
+
const b = next ? pick(next) : undefined;
|
|
108
|
+
if (!next || b === null || b === undefined || next.at === prev.at)
|
|
109
|
+
return a;
|
|
110
|
+
return blend(a, b, ease((elapsed - prev.at) / (next.at - prev.at)));
|
|
111
|
+
}
|
|
112
|
+
/** Held (step) value of one track at `elapsed`. */
|
|
113
|
+
function holdTrack(keyframes, elapsed, pick) {
|
|
114
|
+
let value;
|
|
115
|
+
for (const k of keyframes) {
|
|
116
|
+
if (k.at > elapsed)
|
|
117
|
+
break;
|
|
118
|
+
const v = pick(k);
|
|
119
|
+
if (v !== undefined)
|
|
120
|
+
value = v;
|
|
121
|
+
}
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Ghost of every shape in the `moves` track that is mid-trip at `elapsed`: past its
|
|
126
|
+
* first keyframe and before its last one, interpolated between the two around it.
|
|
127
|
+
*/
|
|
128
|
+
function sampleGhosts(keyframes, elapsed, ease) {
|
|
129
|
+
const tracks = new Map();
|
|
130
|
+
for (const k of keyframes) {
|
|
131
|
+
for (const m of k.moves ?? []) {
|
|
132
|
+
const track = tracks.get(m.shapeId) ?? [];
|
|
133
|
+
track.push({ at: k.at, box: m.box });
|
|
134
|
+
tracks.set(m.shapeId, track);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const ghosts = [];
|
|
138
|
+
for (const [shapeId, track] of tracks) {
|
|
139
|
+
const last = track[track.length - 1];
|
|
140
|
+
if (elapsed < track[0].at || elapsed >= last.at)
|
|
141
|
+
continue;
|
|
142
|
+
let i = 0;
|
|
143
|
+
while (track[i + 1].at <= elapsed)
|
|
144
|
+
i++;
|
|
145
|
+
const a = track[i];
|
|
146
|
+
const b = track[i + 1];
|
|
147
|
+
const p = b.at === a.at ? 1 : ease((elapsed - a.at) / (b.at - a.at));
|
|
148
|
+
ghosts.push({ shapeId, box: lerpBox(a.box, b.box, p) });
|
|
149
|
+
}
|
|
150
|
+
return ghosts;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Sample a motion `elapsed` ms after playback started. Pure: same inputs, same
|
|
154
|
+
* frame. Past the end it returns the final frame with `done: true`.
|
|
155
|
+
*/
|
|
156
|
+
export function sampleMotion(motion, elapsed) {
|
|
157
|
+
const { keyframes } = motion;
|
|
158
|
+
const t = Math.max(0, elapsed);
|
|
159
|
+
const ease = motion.easing === "linear" ? (x) => x : easeInOut;
|
|
160
|
+
const cursor = sampleTrack(keyframes, t, (k) => k.cursor, (a, b, p) => ({ x: lerp(a.x, b.x, p), y: lerp(a.y, b.y, p) }), ease);
|
|
161
|
+
const marquee = sampleTrack(keyframes, t, (k) => k.marquee, lerpBox, ease);
|
|
162
|
+
return {
|
|
163
|
+
cursor,
|
|
164
|
+
shapeIds: holdTrack(keyframes, t, (k) => k.shapeIds) ?? [],
|
|
165
|
+
marquee,
|
|
166
|
+
action: holdTrack(keyframes, t, (k) => k.action) ?? "edit",
|
|
167
|
+
ghosts: sampleGhosts(keyframes, t, ease),
|
|
168
|
+
done: t >= motionDuration(motion),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export function createMotionClock(now = () => performance.now()) {
|
|
172
|
+
const started = new Map();
|
|
173
|
+
return {
|
|
174
|
+
elapsed(clientId, motionId) {
|
|
175
|
+
const t = now();
|
|
176
|
+
const s = started.get(clientId);
|
|
177
|
+
if (!s || s.id !== motionId) {
|
|
178
|
+
started.set(clientId, { id: motionId, at: t });
|
|
179
|
+
return 0;
|
|
180
|
+
}
|
|
181
|
+
return t - s.at;
|
|
182
|
+
},
|
|
183
|
+
prune(active) {
|
|
184
|
+
for (const id of started.keys())
|
|
185
|
+
if (!active.has(id))
|
|
186
|
+
started.delete(id);
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=motion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.js","sourceRoot":"","sources":["../src/motion.ts"],"names":[],"mappings":"AA8EA,4FAA4F;AAC5F,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AACjC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AACpC,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,MAAM,cAAc,GAAG,CAAC,CAAU,E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CAAC;AACH,CAAC;AAcD,MAAM,UAAU,iBAAiB,CAAC,GAAG,GAAiB,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE;IAC5E,MAAM,OAAO,GAAG,IAAI,GAAG,EAAsC,CAAC;IAC9D,OAAO;QACN,OAAO,CAAC,QAAQ,EAAE,QAAQ;YACzB,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;gBAC7B,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC/C,OAAO,CAAC,CAAC;YACV,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACjB,CAAC;QACD,KAAK,CAAC,MAAM;YACX,KAAK,MAAM,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE;gBAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;oBAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC1E,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edv4h/usketch-presence-motion",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Presence activity motion (#960): the awareness value for a cursor tour across shapes, its receiver-side playback and its sender-side builders. No dependencies.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"source": "./src/index.ts",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"typescript": "7.0.2",
|
|
17
|
+
"vitest": "5.1.1"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/EdV4H/usketch.git",
|
|
30
|
+
"directory": "packages/usketch-presence-motion"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/EdV4H/usketch#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/EdV4H/usketch/issues"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -p tsconfig.json",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"test": "vitest run --passWithNoTests",
|
|
40
|
+
"clean": "rm -rf dist"
|
|
41
|
+
}
|
|
6
42
|
}
|