@msb235/blits-panel 0.0.0-stage → 0.1.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/CHANGELOG.md +24 -0
- package/LICENSE +21 -0
- package/README.md +73 -2
- package/dist/agent.d.ts +19 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +882 -0
- package/dist/index.js.map +1 -0
- package/dist/mount.d.ts +15 -0
- package/dist/offer.d.ts +15 -0
- package/dist/protocol.d.ts +104 -0
- package/dist/store.d.ts +24 -0
- package/dist/styles.d.ts +2 -0
- package/dist/ui/ChannelPlot.d.ts +14 -0
- package/dist/ui/Panel.d.ts +11 -0
- package/dist/ui/hue.d.ts +1 -0
- package/dist/ui/path.d.ts +12 -0
- package/dist/wire.d.ts +24 -0
- package/package.json +60 -4
package/dist/mount.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AgentOptions } from './agent.js';
|
|
2
|
+
export interface MountOptions extends Omit<AgentOptions, 'ignore'> {
|
|
3
|
+
/**
|
|
4
|
+
* How far back every mix made from now on can scrub, ms, where it names no history of its own;
|
|
5
|
+
* `false` adds none. Default 10 s, unless the app already set `watched().history`, which then
|
|
6
|
+
* stands. A mix made before `mount` keeps what it has.
|
|
7
|
+
*/
|
|
8
|
+
history?: number | false;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Puts the panel on the page: a pill in a corner that opens into a window over every blits mix
|
|
12
|
+
* on it. Call it before the app makes its mixes, so they keep the history scrubbing back needs.
|
|
13
|
+
* Returns what takes it off again, freeing any clock it holds.
|
|
14
|
+
*/
|
|
15
|
+
export declare function mount(opts?: MountOptions): () => void;
|
package/dist/offer.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** What an app can tell any panel on the page about subjects the DOM cannot see. */
|
|
2
|
+
export interface Offer {
|
|
3
|
+
/** The subject under a point in client coordinates. */
|
|
4
|
+
pick?: (x: number, y: number) => unknown;
|
|
5
|
+
/** Where a subject is on screen, in client coordinates. */
|
|
6
|
+
outline?: (subject: unknown) => DOMRect | undefined;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Hands the app's own `pick` and `outline` to whatever panel inspects the page: one `mount()`
|
|
10
|
+
* put there, or the DevTools extension's. Kept on the page's global object, so it reaches a panel
|
|
11
|
+
* bundled apart from the app. A later call replaces an earlier one.
|
|
12
|
+
*/
|
|
13
|
+
export declare function offer(o: Offer): void;
|
|
14
|
+
/** What the app offered, read each time it is needed. */
|
|
15
|
+
export declare function offered(): Offer;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What crosses between the page, where the mixes are, and the panel, which shows them: plain data
|
|
3
|
+
* that survives `structuredClone`, so the two halves can sit in one page or either side of a
|
|
4
|
+
* message channel. Mixes, subjects and voices cross as numbers.
|
|
5
|
+
*/
|
|
6
|
+
export interface MixInfo {
|
|
7
|
+
id: number;
|
|
8
|
+
name: string;
|
|
9
|
+
release: string;
|
|
10
|
+
channels: string[];
|
|
11
|
+
/** What history the mix keeps; null for none. */
|
|
12
|
+
history: {
|
|
13
|
+
ms: number;
|
|
14
|
+
tape: boolean;
|
|
15
|
+
added: boolean;
|
|
16
|
+
} | null;
|
|
17
|
+
}
|
|
18
|
+
export interface SubjectInfo {
|
|
19
|
+
id: number;
|
|
20
|
+
label: string;
|
|
21
|
+
}
|
|
22
|
+
export interface VoiceInfo {
|
|
23
|
+
id: number;
|
|
24
|
+
name: string | null;
|
|
25
|
+
tags: string[];
|
|
26
|
+
state: string;
|
|
27
|
+
/** Its weight on the picked subject, NaN with none picked. */
|
|
28
|
+
weight: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The picked subject in one frame: each numeric part of its pose by a flat key (`x`,
|
|
32
|
+
* `position[1]`, `color.l`), and each voice's weight on it by voice id.
|
|
33
|
+
*/
|
|
34
|
+
export interface Sample {
|
|
35
|
+
now: number;
|
|
36
|
+
values: Record<string, number>;
|
|
37
|
+
weights: Record<number, number>;
|
|
38
|
+
/** The host did not read the subject this frame, so the panel read it. */
|
|
39
|
+
read: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface HoldInfo {
|
|
42
|
+
/** `elsewhere`: something other than this panel holds the clock. */
|
|
43
|
+
state: 'free' | 'held' | 'elsewhere';
|
|
44
|
+
rate: number;
|
|
45
|
+
now: number;
|
|
46
|
+
/** The earliest time a seek reaches; `now` where the mix cannot go back. */
|
|
47
|
+
reach: number;
|
|
48
|
+
}
|
|
49
|
+
export type Event = {
|
|
50
|
+
kind: 'mixes';
|
|
51
|
+
mixes: MixInfo[];
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'picked';
|
|
54
|
+
mix: number | null;
|
|
55
|
+
subject: number | null;
|
|
56
|
+
} | {
|
|
57
|
+
kind: 'subjects';
|
|
58
|
+
subjects: SubjectInfo[];
|
|
59
|
+
} | {
|
|
60
|
+
kind: 'voices';
|
|
61
|
+
voices: VoiceInfo[];
|
|
62
|
+
}
|
|
63
|
+
/** `reset`: forget what was kept, as a new pick or a new mix does, before these. */
|
|
64
|
+
| {
|
|
65
|
+
kind: 'samples';
|
|
66
|
+
samples: Sample[];
|
|
67
|
+
reset: boolean;
|
|
68
|
+
} | {
|
|
69
|
+
kind: 'hold';
|
|
70
|
+
hold: HoldInfo;
|
|
71
|
+
} | {
|
|
72
|
+
kind: 'arming';
|
|
73
|
+
on: boolean;
|
|
74
|
+
};
|
|
75
|
+
export type Command = {
|
|
76
|
+
kind: 'mix';
|
|
77
|
+
id: number | null;
|
|
78
|
+
} | {
|
|
79
|
+
kind: 'subject';
|
|
80
|
+
id: number | null;
|
|
81
|
+
} | {
|
|
82
|
+
kind: 'hold';
|
|
83
|
+
on: boolean;
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'rate';
|
|
86
|
+
rate: number;
|
|
87
|
+
} | {
|
|
88
|
+
kind: 'step';
|
|
89
|
+
ms: number;
|
|
90
|
+
} | {
|
|
91
|
+
kind: 'seek';
|
|
92
|
+
to: number;
|
|
93
|
+
} | {
|
|
94
|
+
kind: 'arm';
|
|
95
|
+
on: boolean;
|
|
96
|
+
} | {
|
|
97
|
+
kind: 'outline';
|
|
98
|
+
subject: number | null;
|
|
99
|
+
};
|
|
100
|
+
/** One side of the seam: events come up from the page, commands go down to it. */
|
|
101
|
+
export interface Source {
|
|
102
|
+
subscribe(fn: (event: Event) => void): () => void;
|
|
103
|
+
send(command: Command): void;
|
|
104
|
+
}
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Sample } from './protocol.js';
|
|
2
|
+
/** How much the plots keep: this much mix time, and never more frames than `cap`. */
|
|
3
|
+
export declare const WINDOW_MS = 10000;
|
|
4
|
+
export declare const CAP = 1200;
|
|
5
|
+
/**
|
|
6
|
+
* The picked subject's samples, by mix time. A sample at the time of the last replaces it, as the
|
|
7
|
+
* frames of a paused mix do; one behind it drops everything after it, as a seek back does.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Samples {
|
|
10
|
+
private readonly windowMs;
|
|
11
|
+
private readonly cap;
|
|
12
|
+
private list;
|
|
13
|
+
constructor(windowMs?: number, cap?: number);
|
|
14
|
+
get length(): number;
|
|
15
|
+
reset(): void;
|
|
16
|
+
push(s: Sample): void;
|
|
17
|
+
/** The times, and each key's values in the same order, NaN where a sample lacks the key. */
|
|
18
|
+
series(): {
|
|
19
|
+
times: number[];
|
|
20
|
+
values: Map<string, number[]>;
|
|
21
|
+
weights: Map<number, number[]>;
|
|
22
|
+
read: boolean[];
|
|
23
|
+
};
|
|
24
|
+
}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Series } from './path.js';
|
|
2
|
+
export interface ChannelPlotProps {
|
|
3
|
+
label: string;
|
|
4
|
+
times: readonly number[];
|
|
5
|
+
series: readonly Series[];
|
|
6
|
+
playhead: number;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Values over time, one line per series, with a playhead: the plot the playground's inspector
|
|
12
|
+
* and the panel both draw.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ChannelPlot({ label, times, series, playhead, width, height, }: ChannelPlotProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { Source } from '../protocol.js';
|
|
3
|
+
export interface PanelProps {
|
|
4
|
+
source: Source;
|
|
5
|
+
/** Fills its container, with no pill and no dragging: for a host such as a DevTools tab. */
|
|
6
|
+
docked?: boolean;
|
|
7
|
+
/** More controls for the top bar, from the host. */
|
|
8
|
+
bar?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/** The panel: a pill in a corner that opens into a window over the page, or docked, the window alone. */
|
|
11
|
+
export declare function Panel({ source, docked, bar }: PanelProps): import("react").JSX.Element;
|
package/dist/ui/hue.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hueColor: (hue: number) => string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Series {
|
|
2
|
+
id: string;
|
|
3
|
+
hue: number;
|
|
4
|
+
/** Overrides the color a hue gives. */
|
|
5
|
+
color?: string;
|
|
6
|
+
values: readonly number[];
|
|
7
|
+
thick?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function rangeOf(series: readonly Series[]): [number, number];
|
|
10
|
+
/** Widens [lo, hi] so `px` pixels of a `size`-pixel axis lie beyond each end. */
|
|
11
|
+
export declare function insetRange([lo, hi]: [number, number], px: number, size: number): [number, number];
|
|
12
|
+
export declare function pathOf(times: readonly number[], values: readonly number[], x: (t: number) => number, y: (v: number) => number): string;
|
package/dist/wire.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Source } from './protocol.js';
|
|
2
|
+
/**
|
|
3
|
+
* One end of a channel that carries strings: a `chrome.runtime.Port`, a window bridge, a
|
|
4
|
+
* `MessagePort`. The panel's two halves talk across one when they are not in the same page.
|
|
5
|
+
*/
|
|
6
|
+
export interface Wire {
|
|
7
|
+
send(text: string): void;
|
|
8
|
+
/** Returns what stops listening. */
|
|
9
|
+
listen(fn: (text: string) => void): () => void;
|
|
10
|
+
}
|
|
11
|
+
/** JSON, keeping the numbers JSON has no word for: NaN and the infinities. */
|
|
12
|
+
export declare function encode(value: unknown): string;
|
|
13
|
+
export declare function decode<T>(text: string): T;
|
|
14
|
+
/**
|
|
15
|
+
* The panel's side of a wire: a `Source` whose events come from `serve` on the other end. Asks
|
|
16
|
+
* the other end for the state as it stands on its first subscriber, so nothing sent before the
|
|
17
|
+
* panel was listening is missed.
|
|
18
|
+
*/
|
|
19
|
+
export declare function wireSource(wire: Wire): Source & {
|
|
20
|
+
refresh(): void;
|
|
21
|
+
close(): void;
|
|
22
|
+
};
|
|
23
|
+
/** The page's side of a wire: hands `source`'s events across and its commands back. */
|
|
24
|
+
export declare function serve(source: Source, wire: Wire): () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@msb235/blits-panel",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "A debugger window for blits: every mix on the page, its voices and subjects, channels plotted over time, and a clock to pause, step and scrub",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"blits",
|
|
7
|
+
"debugger",
|
|
8
|
+
"devtools",
|
|
9
|
+
"animation"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "orochi235",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/orochi235/blits.git",
|
|
16
|
+
"directory": "packages/panel"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/orochi235/blits/tree/main/packages/panel#readme",
|
|
19
|
+
"bugs": "https://github.com/orochi235/blits/issues",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"!dist/.tsbuildinfo",
|
|
34
|
+
"CHANGELOG.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "vite build && tsc -b",
|
|
39
|
+
"prepack": "rm -rf dist && npm run build",
|
|
40
|
+
"smoke": "node scripts/smoke.mjs"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@weasel-js/history": "1.12.0",
|
|
44
|
+
"@weasel-js/theme": "1.12.0",
|
|
45
|
+
"@weasel-js/ui": "1.12.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@msb235/blits": "^0.12.0",
|
|
49
|
+
"react": "^19.3.0",
|
|
50
|
+
"react-dom": "^19.3.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@msb235/blits": "0.12.0",
|
|
54
|
+
"@types/react": "^19.3.0",
|
|
55
|
+
"@types/react-dom": "^19.3.0",
|
|
56
|
+
"@vitejs/plugin-react": "^6.0.0",
|
|
57
|
+
"happy-dom": "21.0.3",
|
|
58
|
+
"react": "^19.3.0",
|
|
59
|
+
"react-dom": "^19.3.0",
|
|
60
|
+
"vite": "^8.0.0"
|
|
61
|
+
}
|
|
62
|
+
}
|