@wallarm-org/design-system 4.6.2 → 4.7.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.
Files changed (69) hide show
  1. package/dist/components/AgentAvatar/AgentAvatar.d.ts +45 -0
  2. package/dist/components/AgentAvatar/AgentAvatar.js +544 -0
  3. package/dist/components/AgentAvatar/AgentAvatarGroup.d.ts +12 -0
  4. package/dist/components/AgentAvatar/AgentAvatarGroup.js +25 -0
  5. package/dist/components/AgentAvatar/index.d.ts +4 -0
  6. package/dist/components/AgentAvatar/index.js +3 -0
  7. package/dist/components/AgentAvatar/useBakedLayers.d.ts +9 -0
  8. package/dist/components/AgentAvatar/useBakedLayers.js +75 -0
  9. package/dist/components/AgentAvatar/useCharacter.d.ts +39 -0
  10. package/dist/components/AgentAvatar/useCharacter.js +251 -0
  11. package/dist/components/AgentGlyph/AgentGlyph.d.ts +30 -0
  12. package/dist/components/AgentGlyph/AgentGlyph.js +192 -0
  13. package/dist/components/AgentGlyph/index.d.ts +4 -0
  14. package/dist/components/AgentGlyph/index.js +2 -0
  15. package/dist/components/AgentLookBuilder/index.d.ts +3 -0
  16. package/dist/components/AgentLookBuilder/index.js +2 -0
  17. package/dist/components/AgentLookBuilder/kit.d.ts +36 -0
  18. package/dist/components/AgentLookBuilder/kit.js +30 -0
  19. package/dist/components/Chat/ChatGreeting.d.ts +1 -1
  20. package/dist/components/Chat/ChatGreeting.js +95 -44
  21. package/dist/components/Chat/ChatHeaderTitle.d.ts +1 -1
  22. package/dist/components/Chat/ChatHeaderTitle.js +32 -29
  23. package/dist/components/WallySkeleton/WallySkeleton.js +92 -71
  24. package/dist/index.d.ts +2 -0
  25. package/dist/index.js +2 -0
  26. package/dist/lib/agent-characters/bake.d.ts +40 -0
  27. package/dist/lib/agent-characters/bake.js +220 -0
  28. package/dist/lib/agent-characters/canvas.d.ts +7 -0
  29. package/dist/lib/agent-characters/canvas.js +22 -0
  30. package/dist/lib/agent-characters/char.d.ts +32 -0
  31. package/dist/lib/agent-characters/char.js +375 -0
  32. package/dist/lib/agent-characters/color.d.ts +6 -0
  33. package/dist/lib/agent-characters/color.js +20 -0
  34. package/dist/lib/agent-characters/data.gen.d.ts +106 -0
  35. package/dist/lib/agent-characters/data.gen.js +3854 -0
  36. package/dist/lib/agent-characters/engine.d.ts +206 -0
  37. package/dist/lib/agent-characters/engine.js +1241 -0
  38. package/dist/lib/agent-characters/eyes.d.ts +18 -0
  39. package/dist/lib/agent-characters/eyes.js +132 -0
  40. package/dist/lib/agent-characters/geom.d.ts +23 -0
  41. package/dist/lib/agent-characters/geom.js +109 -0
  42. package/dist/lib/agent-characters/glyph.d.ts +21 -0
  43. package/dist/lib/agent-characters/glyph.js +126 -0
  44. package/dist/lib/agent-characters/look.d.ts +24 -0
  45. package/dist/lib/agent-characters/look.js +68 -0
  46. package/dist/lib/agent-characters/motion.d.ts +73 -0
  47. package/dist/lib/agent-characters/motion.js +1215 -0
  48. package/dist/lib/agent-characters/paths.d.ts +13 -0
  49. package/dist/lib/agent-characters/paths.js +118 -0
  50. package/dist/lib/agent-characters/places.d.ts +76 -0
  51. package/dist/lib/agent-characters/places.js +64 -0
  52. package/dist/lib/agent-characters/propOf.d.ts +7 -0
  53. package/dist/lib/agent-characters/propOf.js +20 -0
  54. package/dist/lib/agent-characters/props.d.ts +4 -0
  55. package/dist/lib/agent-characters/props.js +337 -0
  56. package/dist/lib/agent-characters/queue.d.ts +23 -0
  57. package/dist/lib/agent-characters/queue.js +73 -0
  58. package/dist/lib/agent-characters/runtime.d.ts +69 -0
  59. package/dist/lib/agent-characters/runtime.js +178 -0
  60. package/dist/lib/agent-characters/svg.d.ts +6 -0
  61. package/dist/lib/agent-characters/svg.js +6 -0
  62. package/dist/lib/agent-characters/worker.d.ts +6 -0
  63. package/dist/lib/agent-characters/worker.js +94 -0
  64. package/dist/metadata/components.json +689 -276
  65. package/dist/theme/components/agent-avatar.css +42 -0
  66. package/dist/theme/index.css +1 -0
  67. package/dist/utils/renderSvgNode.d.ts +4 -0
  68. package/dist/utils/renderSvgNode.js +12 -0
  69. package/package.json +2 -1
@@ -0,0 +1,13 @@
1
+ export type Pt = [number, number];
2
+ export declare const r2: (n: number) => number;
3
+ export declare const clamp: (v: number, a: number, b: number) => number;
4
+ export declare function ell(cx: number, cy: number, rx: number, ry?: number, ccw?: boolean): string;
5
+ export declare function rr(x: number, y: number, w: number, h: number, radius: number): string;
6
+ export declare function smooth(p: Pt[]): string;
7
+ export declare function polar(cx: number, cy: number, rf: (a: number) => number, n?: number): string;
8
+ export declare function poly(p: Pt[]): string;
9
+ export declare function rotRect(cx: number, cy: number, w: number, h: number, ang: number): string;
10
+ export declare function qpts(p0: Pt, c: Pt, p1: Pt, n?: number): Pt[];
11
+ export declare function cpts(p0: Pt, c1: Pt, c2: Pt, p1: Pt, n?: number): Pt[];
12
+ /** Thick polyline with round caps, clockwise. */
13
+ export declare function tube(pts: Pt[], w: number): string;
@@ -0,0 +1,118 @@
1
+ const r2 = (n)=>Math.round(100 * n) / 100;
2
+ const clamp = (v, a, b)=>Math.max(a, Math.min(b, v));
3
+ function ell(cx, cy, rx, ry = rx, ccw = false) {
4
+ const s = ccw ? 0 : 1;
5
+ return `M${r2(cx - rx)} ${r2(cy)}A${r2(rx)} ${r2(ry)} 0 1 ${s} ${r2(cx + rx)} ${r2(cy)}A${r2(rx)} ${r2(ry)} 0 1 ${s} ${r2(cx - rx)} ${r2(cy)}Z`;
6
+ }
7
+ function rr(x, y, w, h, radius) {
8
+ const r = Math.min(radius, w / 2, h / 2);
9
+ return `M${r2(x + r)} ${r2(y)}H${r2(x + w - r)}A${r2(r)} ${r2(r)} 0 0 1 ${r2(x + w)} ${r2(y + r)}V${r2(y + h - r)}A${r2(r)} ${r2(r)} 0 0 1 ${r2(x + w - r)} ${r2(y + h)}H${r2(x + r)}A${r2(r)} ${r2(r)} 0 0 1 ${r2(x)} ${r2(y + h - r)}V${r2(y + r)}A${r2(r)} ${r2(r)} 0 0 1 ${r2(x + r)} ${r2(y)}Z`;
10
+ }
11
+ function smooth(p) {
12
+ const n = p.length;
13
+ let d = `M${r2(p[0][0])} ${r2(p[0][1])}`;
14
+ for(let i = 0; i < n; i++){
15
+ const p0 = p[(i - 1 + n) % n];
16
+ const p1 = p[i];
17
+ const p2 = p[(i + 1) % n];
18
+ const p3 = p[(i + 2) % n];
19
+ d += `C${r2(p1[0] + (p2[0] - p0[0]) / 6)} ${r2(p1[1] + (p2[1] - p0[1]) / 6)} ${r2(p2[0] - (p3[0] - p1[0]) / 6)} ${r2(p2[1] - (p3[1] - p1[1]) / 6)} ${r2(p2[0])} ${r2(p2[1])}`;
20
+ }
21
+ return `${d}Z`;
22
+ }
23
+ function polar(cx, cy, rf, n = 96) {
24
+ const p = [];
25
+ for(let i = 0; i < n; i++){
26
+ const a = i / n * Math.PI * 2;
27
+ const r = rf(a);
28
+ p.push([
29
+ cx + r * Math.cos(a),
30
+ cy + r * Math.sin(a)
31
+ ]);
32
+ }
33
+ return smooth(p);
34
+ }
35
+ function poly(p) {
36
+ return `M${p.map((q)=>`${r2(q[0])} ${r2(q[1])}`).join('L')}Z`;
37
+ }
38
+ function rotRect(cx, cy, w, h, ang) {
39
+ const a = ang * Math.PI / 180;
40
+ const c = Math.cos(a);
41
+ const s = Math.sin(a);
42
+ const corners = [
43
+ [
44
+ -w / 2,
45
+ -h / 2
46
+ ],
47
+ [
48
+ w / 2,
49
+ -h / 2
50
+ ],
51
+ [
52
+ w / 2,
53
+ h / 2
54
+ ],
55
+ [
56
+ -w / 2,
57
+ h / 2
58
+ ]
59
+ ];
60
+ return poly(corners.map(([x, y])=>[
61
+ cx + x * c - y * s,
62
+ cy + x * s + y * c
63
+ ]));
64
+ }
65
+ function qpts(p0, c, p1, n = 14) {
66
+ const o = [];
67
+ for(let i = 0; i <= n; i++){
68
+ const t = i / n;
69
+ o.push([
70
+ (1 - t) * (1 - t) * p0[0] + 2 * (1 - t) * t * c[0] + t * t * p1[0],
71
+ (1 - t) * (1 - t) * p0[1] + 2 * (1 - t) * t * c[1] + t * t * p1[1]
72
+ ]);
73
+ }
74
+ return o;
75
+ }
76
+ function cpts(p0, c1, c2, p1, n = 20) {
77
+ const o = [];
78
+ for(let i = 0; i <= n; i++){
79
+ const t = i / n;
80
+ const u = 1 - t;
81
+ o.push([
82
+ u * u * u * p0[0] + 3 * u * u * t * c1[0] + 3 * u * t * t * c2[0] + t * t * t * p1[0],
83
+ u * u * u * p0[1] + 3 * u * u * t * c1[1] + 3 * u * t * t * c2[1] + t * t * t * p1[1]
84
+ ]);
85
+ }
86
+ return o;
87
+ }
88
+ function tube(pts, w) {
89
+ const h = w / 2;
90
+ const L = [];
91
+ const R = [];
92
+ for(let i = 0; i < pts.length; i++){
93
+ const a = pts[Math.max(0, i - 1)];
94
+ const b = pts[Math.min(pts.length - 1, i + 1)];
95
+ const p = pts[i];
96
+ let dx = b[0] - a[0];
97
+ let dy = b[1] - a[1];
98
+ const l = Math.hypot(dx, dy) || 1;
99
+ dx /= l;
100
+ dy /= l;
101
+ L.push([
102
+ p[0] - dy * h,
103
+ p[1] + dx * h
104
+ ]);
105
+ R.push([
106
+ p[0] + dy * h,
107
+ p[1] - dx * h
108
+ ]);
109
+ }
110
+ const r0 = R[0];
111
+ let d = `M${r2(r0[0])} ${r2(r0[1])}`;
112
+ for (const q of R.slice(1))d += `L${r2(q[0])} ${r2(q[1])}`;
113
+ const le = L[L.length - 1];
114
+ d += `A${r2(h)} ${r2(h)} 0 0 1 ${r2(le[0])} ${r2(le[1])}`;
115
+ for (const q of L.slice(0, -1).reverse())d += `L${r2(q[0])} ${r2(q[1])}`;
116
+ return `${d}A${r2(h)} ${r2(h)} 0 0 1 ${r2(r0[0])} ${r2(r0[1])}Z`;
117
+ }
118
+ export { clamp, cpts, ell, polar, poly, qpts, r2, rotRect, rr, smooth, tube };
@@ -0,0 +1,76 @@
1
+ export type AgentGlyphSize = 16 | 20 | 24 | 32;
2
+ export type AgentAvatarSize = 40 | 48 | 56 | 72 | 120;
3
+ export declare const PLACES: {
4
+ /** in text, chips, history and principal names, beside text-sm or larger (D3) */
5
+ readonly inline: {
6
+ readonly size: 20;
7
+ readonly renderer: 'glyph';
8
+ readonly live: false;
9
+ readonly shadow: false;
10
+ };
11
+ /** in text beside text-xs (D3, D26: 16 px is the floor) */
12
+ readonly inlineXs: {
13
+ readonly size: 16;
14
+ readonly renderer: 'glyph';
15
+ readonly live: false;
16
+ readonly shadow: false;
17
+ };
18
+ /** table rows: «Found by», «Agent», run rows */
19
+ readonly tableRow: {
20
+ readonly size: 20;
21
+ readonly renderer: 'glyph';
22
+ readonly live: false;
23
+ readonly shadow: false;
24
+ };
25
+ /** Overview and Agent team rows of active agents, with the idle repertoire and the look-around (D2) */
26
+ readonly overviewRow: {
27
+ readonly size: 40;
28
+ readonly renderer: '3d';
29
+ readonly live: true;
30
+ readonly shadow: false;
31
+ };
32
+ /** Overview: a Not set up or «Soon» row, static */
33
+ readonly overviewSetup: {
34
+ readonly size: 40;
35
+ readonly renderer: '3d';
36
+ readonly live: false;
37
+ readonly shadow: false;
38
+ };
39
+ /** Approval policy full-screen header, toasts, run headers */
40
+ readonly header: {
41
+ readonly size: 48;
42
+ readonly renderer: '3d';
43
+ readonly live: false;
44
+ readonly shadow: false;
45
+ };
46
+ /** a row beside people's avatars */
47
+ readonly peopleRow: {
48
+ readonly size: 56;
49
+ readonly renderer: '3d';
50
+ readonly live: false;
51
+ readonly shadow: false;
52
+ };
53
+ /** Agent team card */
54
+ readonly teamCard: {
55
+ readonly size: 72;
56
+ readonly renderer: '3d';
57
+ readonly live: true;
58
+ readonly shadow: false;
59
+ };
60
+ /** Agent drawer header */
61
+ readonly drawerHeader: {
62
+ readonly size: 72;
63
+ readonly renderer: '3d';
64
+ readonly live: true;
65
+ readonly shadow: true;
66
+ };
67
+ /** Wally's empty chat (D9) */
68
+ readonly emptyChat: {
69
+ readonly size: 120;
70
+ readonly renderer: '3d';
71
+ readonly live: true;
72
+ readonly shadow: true;
73
+ };
74
+ };
75
+ export type AgentPlace = keyof typeof PLACES;
76
+ export declare const rendererFor: (size: number) => 'glyph' | '3d';
@@ -0,0 +1,64 @@
1
+ const PLACES = {
2
+ inline: {
3
+ size: 20,
4
+ renderer: 'glyph',
5
+ live: false,
6
+ shadow: false
7
+ },
8
+ inlineXs: {
9
+ size: 16,
10
+ renderer: 'glyph',
11
+ live: false,
12
+ shadow: false
13
+ },
14
+ tableRow: {
15
+ size: 20,
16
+ renderer: 'glyph',
17
+ live: false,
18
+ shadow: false
19
+ },
20
+ overviewRow: {
21
+ size: 40,
22
+ renderer: '3d',
23
+ live: true,
24
+ shadow: false
25
+ },
26
+ overviewSetup: {
27
+ size: 40,
28
+ renderer: '3d',
29
+ live: false,
30
+ shadow: false
31
+ },
32
+ header: {
33
+ size: 48,
34
+ renderer: '3d',
35
+ live: false,
36
+ shadow: false
37
+ },
38
+ peopleRow: {
39
+ size: 56,
40
+ renderer: '3d',
41
+ live: false,
42
+ shadow: false
43
+ },
44
+ teamCard: {
45
+ size: 72,
46
+ renderer: '3d',
47
+ live: true,
48
+ shadow: false
49
+ },
50
+ drawerHeader: {
51
+ size: 72,
52
+ renderer: '3d',
53
+ live: true,
54
+ shadow: true
55
+ },
56
+ emptyChat: {
57
+ size: 120,
58
+ renderer: '3d',
59
+ live: true,
60
+ shadow: true
61
+ }
62
+ };
63
+ const rendererFor = (size)=>size <= 32 ? 'glyph' : '3d';
64
+ export { PLACES, rendererFor };
@@ -0,0 +1,7 @@
1
+ import { type AgentShapeDef, type PropDef } from './data.gen.js';
2
+ type PropLibrary = (kind: string, S: AgentShapeDef, col: string) => PropDef;
3
+ /** Registers the full prop library (AgentLookBuilder's enableAgentLookLibrary); null unregisters (tests). */
4
+ export declare function setPropLibrary(lib: PropLibrary | null): void;
5
+ /** propDef() for a look: the library when registered, else the preset table, else no prop. Never throws. */
6
+ export declare function propOf(kind: string, S: AgentShapeDef, col: string): PropDef | null;
7
+ export {};
@@ -0,0 +1,20 @@
1
+ import { PRESET_PROPS } from "./data.gen.js";
2
+ const KEY = Symbol.for('@wallarm-org/design-system/agent-characters/prop-library');
3
+ const registry = globalThis;
4
+ const warned = new Set();
5
+ function setPropLibrary(lib) {
6
+ registry[KEY] = lib;
7
+ }
8
+ function propOf(kind, S, col) {
9
+ const library = registry[KEY];
10
+ if (library) return library(kind, S, col);
11
+ const key = `${S.id}|${col}|${kind}`;
12
+ const hit = PRESET_PROPS[key];
13
+ if (hit) return hit;
14
+ if ('none' !== kind && 'production' !== process.env.NODE_ENV && !warned.has(key)) {
15
+ warned.add(key);
16
+ console.warn(`[AgentAvatar] the prop "${kind}" on ${S.id} needs the full prop library: call enableAgentLookLibrary() from @wallarm-org/design-system/AgentLookBuilder. Drawn without the prop.`);
17
+ }
18
+ return null;
19
+ }
20
+ export { propOf, setPropLibrary };
@@ -0,0 +1,4 @@
1
+ import { type AgentShapeDef, type PropDef } from './data.gen.js';
2
+ /** Any other prop: 'bob' (a greeting lift, no idle fiddle). */
3
+ export declare const fidKind: (p: string) => string;
4
+ export declare function propDef(kind: string, S: AgentShapeDef, col: string): PropDef;
@@ -0,0 +1,337 @@
1
+ import { mix } from "./color.js";
2
+ import { HARD, TONE } from "./data.gen.js";
3
+ import { geom } from "./geom.js";
4
+ import { ell, polar, qpts, r2, rotRect, rr, tube } from "./paths.js";
5
+ const PROP_FID = {
6
+ antennae: 'twitch',
7
+ dish: 'scan',
8
+ periscope: 'turn',
9
+ magnifier: 'sweep',
10
+ pennant: 'flutter',
11
+ sprout: 'sway',
12
+ headlamp: 'flicker',
13
+ windkey: 'spin',
14
+ monocle: 'slip',
15
+ seam: 'none',
16
+ plaster: 'none'
17
+ };
18
+ const fidKind = (p)=>PROP_FID[p] || 'bob';
19
+ function propDef(kind, S, col) {
20
+ const G = geom(S);
21
+ const [tx, ty] = G.top;
22
+ const [vx, vy, vw, vh] = S.v;
23
+ const cy = vy + vh / 2;
24
+ const ex = [
25
+ vx + 0.3 * vw,
26
+ vx + 0.7 * vw
27
+ ];
28
+ const hwT = (y)=>Math.max(8, G.hw(y));
29
+ const L = [];
30
+ const deco = [];
31
+ let anim = null;
32
+ const add = (d, tone, mat)=>L.push({
33
+ d,
34
+ col: TONE[tone] ?? tone,
35
+ mat: mat || (HARD.has(tone) ? 'vinyl' : null)
36
+ });
37
+ const ax = vx + vw / 2;
38
+ switch(kind){
39
+ case 'antennae':
40
+ add(tube(qpts([
41
+ tx - 9,
42
+ ty + 5
43
+ ], [
44
+ tx - 15,
45
+ ty - 6
46
+ ], [
47
+ tx - 22,
48
+ ty - 14
49
+ ]), 3) + ell(tx - 22.5, ty - 15.5, 4.4) + tube(qpts([
50
+ tx + 9,
51
+ ty + 5
52
+ ], [
53
+ tx + 15,
54
+ ty - 6
55
+ ], [
56
+ tx + 22,
57
+ ty - 14
58
+ ]), 3) + ell(tx + 22.5, ty - 15.5, 4.4), 'ink');
59
+ anim = {
60
+ type: 'twitch',
61
+ px: tx,
62
+ py: ty + 4
63
+ };
64
+ break;
65
+ case 'dish':
66
+ add(tube([
67
+ [
68
+ tx + 2,
69
+ ty + 4
70
+ ],
71
+ [
72
+ tx + 5,
73
+ ty - 9
74
+ ]
75
+ ], 2.6), 'ink');
76
+ add(`M${tx - 8} ${ty - 16}Q${tx + 5} ${ty - 1} ${tx + 19} ${ty - 14}Z`, mix(col, '#ffffff', 0.55));
77
+ add(tube([
78
+ [
79
+ tx + 5,
80
+ ty - 12
81
+ ],
82
+ [
83
+ tx + 8,
84
+ ty - 23
85
+ ]
86
+ ], 1.8) + ell(tx + 8, ty - 24, 2.4), 'ink');
87
+ anim = {
88
+ type: 'dish',
89
+ px: tx + 3,
90
+ py: ty + 2
91
+ };
92
+ break;
93
+ case 'glasses':
94
+ add(ell(ex[0], cy, 10.5) + ell(ex[0], cy, 8.4, 8.4, true) + ell(ex[1], cy, 10.5) + ell(ex[1], cy, 8.4, 8.4, true) + tube(qpts([
95
+ ex[0] + 9.5,
96
+ cy - 1.5
97
+ ], [
98
+ (ex[0] + ex[1]) / 2,
99
+ cy - 5
100
+ ], [
101
+ ex[1] - 9.5,
102
+ cy - 1.5
103
+ ]), 1.8), 'oat', 'vinyl');
104
+ deco.push({
105
+ s: `<path class="glint" d="M${ex[1] + 2.5} ${cy - 6.5}l3.2 3.2M${ex[0] + 2.5} ${cy - 6.5}l3.2 3.2" stroke="#fff" stroke-width="1.5" stroke-linecap="round" opacity=".55"/>`
106
+ });
107
+ break;
108
+ case 'seam':
109
+ {
110
+ const s = Math.min(G.hw(ty + 16) - 4, 34);
111
+ deco.push({
112
+ clip: true,
113
+ s: `<path d="M${tx - s} ${ty + 17}Q${tx} ${ty + 7} ${tx + s} ${ty + 17}" stroke="${mix(col, '#0d0b0c', 0.4)}" stroke-width="1.3" fill="none"/><path class="stitch" d="M${tx - s} ${ty + 17}Q${tx} ${ty + 7} ${tx + s} ${ty + 17}" stroke="#F4EEE4" stroke-width="3.4" stroke-dasharray="1.6 4.4" stroke-linecap="round" fill="none"/>`
114
+ });
115
+ break;
116
+ }
117
+ case 'beanie':
118
+ {
119
+ const b = Math.max(hwT(ty + 12) + 2, 16);
120
+ add(`M${tx - b} ${ty + 13}Q${tx - b} ${ty - 9} ${tx} ${ty - 9}Q${tx + b} ${ty - 9} ${tx + b} ${ty + 13}Z`, mix(col, '#0d0b0c', 0.5));
121
+ add(rr(tx - b - 2, ty + 8, 2 * b + 4, 8, 4) + ell(tx, ty - 12, 4.8), mix(mix(col, '#0d0b0c', 0.5), '#ffffff', 0.22));
122
+ break;
123
+ }
124
+ case 'headlamp':
125
+ {
126
+ const b = hwT(ty + 13) + 1.5;
127
+ add(tube(qpts([
128
+ tx - b,
129
+ ty + 15
130
+ ], [
131
+ tx,
132
+ ty + 8
133
+ ], [
134
+ tx + b,
135
+ ty + 15
136
+ ]), 3), 'ink');
137
+ add(rr(tx - 7, ty + 5, 14, 11, 4), 'metal');
138
+ add(ell(tx, ty + 10.5, 4.6, 3.8), 'oat', 'vinyl');
139
+ deco.push({
140
+ s: `<path class="beam" d="M${tx - 4} ${ty + 8}L${tx - 16} ${ty - 26}L${tx + 16} ${ty - 26}L${tx + 4} ${ty + 8}Z" fill="#FFF6D6" opacity="0"/>`
141
+ });
142
+ break;
143
+ }
144
+ case 'periscope':
145
+ add(tube([
146
+ [
147
+ tx + 2,
148
+ ty + 4
149
+ ],
150
+ [
151
+ tx + 2,
152
+ ty - 17
153
+ ]
154
+ ], 6), 'metal');
155
+ add(rr(tx - 1, ty - 27, 14, 10, 3.5), 'metal');
156
+ add(ell(tx + 10, ty - 22, 2.2, 3.2), 'ink');
157
+ anim = {
158
+ type: 'sway',
159
+ px: tx + 2,
160
+ py: ty + 4
161
+ };
162
+ break;
163
+ case 'magnifier':
164
+ {
165
+ const x = vx + vw - 3;
166
+ const y = cy + 3;
167
+ add(ell(x, y, 11.5) + ell(x, y, 8.6, 8.6, true), 'metal');
168
+ add(ell(x, y, 8.7), 'glass', 'vinyl');
169
+ add(tube([
170
+ [
171
+ x + 8,
172
+ y + 8
173
+ ],
174
+ [
175
+ x + 16,
176
+ y + 17
177
+ ]
178
+ ], 4.6), 'wood');
179
+ break;
180
+ }
181
+ case 'pennant':
182
+ add(tube([
183
+ [
184
+ tx + 3,
185
+ ty + 5
186
+ ],
187
+ [
188
+ tx + 6,
189
+ ty - 21
190
+ ]
191
+ ], 2), 'ink');
192
+ add(`M${tx + 6} ${ty - 21}L${tx + 23} ${ty - 16}L${tx + 6} ${ty - 10}Z`, 'oat');
193
+ anim = {
194
+ type: 'wave',
195
+ px: tx + 6,
196
+ py: ty - 15
197
+ };
198
+ break;
199
+ case 'flowerclip':
200
+ {
201
+ const seat = 'kettle' === S.id ? [
202
+ 77,
203
+ 38
204
+ ] : null;
205
+ const x = seat ? seat[0] : ax + Math.min(0.55 * hwT(ty + 11), 17);
206
+ const y = seat ? seat[1] : Math.min(ty + 8, vy - 11);
207
+ const k = 1.5;
208
+ add(polar(x, y, (a)=>k * (4 + 2.6 * Math.abs(Math.cos(2.5 * a))), 40), 'oat');
209
+ add(ell(x, y, 2.4 * k), 'honey');
210
+ break;
211
+ }
212
+ case 'plaster':
213
+ {
214
+ const x = tx - Math.min(0.45 * hwT(ty + 14), 16);
215
+ const y = ty + 15;
216
+ add(rotRect(x, y, 20, 6, -35) + rotRect(x, y, 20, 6, 35), 'beige');
217
+ deco.push({
218
+ s: `<g fill="#B79C7D" opacity=".7"><circle cx="${x - 1.5}" cy="${y}" r=".7"/><circle cx="${x + 1.5}" cy="${y}" r=".7"/><circle cx="${x}" cy="${y - 1.5}" r=".7"/><circle cx="${x}" cy="${y + 1.5}" r=".7"/></g>`
219
+ });
220
+ break;
221
+ }
222
+ case 'sprout':
223
+ add(tube([
224
+ [
225
+ tx,
226
+ ty + 3
227
+ ],
228
+ [
229
+ tx,
230
+ ty - 8
231
+ ]
232
+ ], 2.2), 'leaf');
233
+ add(`M${tx} ${ty - 7}C${tx - 4} ${ty - 16} ${tx - 14} ${ty - 18} ${tx - 18} ${ty - 14}C${tx - 14} ${ty - 8} ${tx - 6} ${ty - 5} ${tx} ${ty - 7}Z M${tx} ${ty - 8}C${tx + 3} ${ty - 19} ${tx + 14} ${ty - 23} ${tx + 21} ${ty - 19}C${tx + 17} ${ty - 10} ${tx + 7} ${ty - 6} ${tx} ${ty - 8}Z`, 'leaf');
234
+ anim = {
235
+ type: 'sway',
236
+ px: tx,
237
+ py: ty + 3
238
+ };
239
+ break;
240
+ case 'badge':
241
+ {
242
+ const x = vx + vw + 2;
243
+ const y = cy + 6;
244
+ add(rr(x + 3, y - 5, 6, 7, 2), 'metal');
245
+ add(rr(x, y + 1, 13, 17, 2.5), 'oat');
246
+ deco.push({
247
+ s: `<rect x="${x + 2.5}" y="${y + 4}" width="5" height="6" rx="1" fill="#A9B1BC"/><rect x="${x + 2.5}" y="${y + 12}" width="8" height="1.6" rx=".8" fill="#2D6E8E"/>`
248
+ });
249
+ break;
250
+ }
251
+ case 'windkey':
252
+ add(rr(tx - 2, ty - 9, 4, 12, 1.5), 'brass');
253
+ add(ell(tx - 6.5, ty - 14, 6.5, 5.5) + ell(tx - 6.5, ty - 14, 2.6, 2.2, true) + ell(tx + 6.5, ty - 14, 6.5, 5.5) + ell(tx + 6.5, ty - 14, 2.6, 2.2, true), 'brass');
254
+ anim = {
255
+ type: 'wind',
256
+ px: tx,
257
+ py: ty - 10
258
+ };
259
+ break;
260
+ case 'monocle':
261
+ {
262
+ const x = ex[1];
263
+ const r = Math.min(10.6, 0.4 * vh);
264
+ const sx = x + 0.72 * r;
265
+ const sy = cy + 0.7 * r;
266
+ const qx = vx + vw - ('safe' === S.id ? 16 : 2);
267
+ let qy = Math.min(vy + vh + 9, 103);
268
+ while(qy > vy + vh + 4 && (G.hw(qy + 4) < qx - tx + 4 || G.hw(qy + 5) < qx - tx))qy -= 0.5;
269
+ add(ell(x, cy, r) + ell(x, cy, r - 3, r - 3, true), 'brass');
270
+ add(ell(qx, qy, 2.6), 'brass');
271
+ deco.push({
272
+ s: `<path d="M${r2(sx)} ${r2(sy)}C${r2(sx + 3)} ${r2(sy + 7)} ${r2(qx + 4)} ${r2(qy - 7)} ${r2(qx)} ${r2(qy - 2)}" fill="none" stroke="#B08D4C" stroke-width="2.1" stroke-dasharray="0 2.9" stroke-linecap="round"/><path class="glint" d="M${r2(x + 1.5)} ${r2(cy - r + 4.4)}l3 3" stroke="#fff" stroke-width="1.5" stroke-linecap="round" opacity=".55"/>`
273
+ });
274
+ anim = {
275
+ type: 'focus',
276
+ px: r2(x),
277
+ py: r2(cy)
278
+ };
279
+ break;
280
+ }
281
+ default:
282
+ break;
283
+ }
284
+ const fk = fidKind(kind);
285
+ const FP = {
286
+ twitch: [
287
+ tx,
288
+ ty + 4
289
+ ],
290
+ scan: [
291
+ tx + 3,
292
+ ty + 2
293
+ ],
294
+ turn: [
295
+ tx + 2,
296
+ ty + 4
297
+ ],
298
+ sweep: [
299
+ vx + vw + 13,
300
+ cy + 20
301
+ ],
302
+ flutter: [
303
+ tx + 3,
304
+ ty + 5
305
+ ],
306
+ sway: [
307
+ tx,
308
+ ty + 3
309
+ ],
310
+ flicker: [
311
+ tx,
312
+ ty + 10
313
+ ],
314
+ spin: [
315
+ tx,
316
+ ty - 10
317
+ ]
318
+ };
319
+ const fp = FP[fk] || (anim && 'slip' === fk ? [
320
+ anim.px,
321
+ anim.py
322
+ ] : [
323
+ tx,
324
+ ty
325
+ ]);
326
+ return {
327
+ layers: L,
328
+ deco,
329
+ anim,
330
+ fid: {
331
+ k: fk,
332
+ px: r2(fp[0]),
333
+ py: r2(fp[1])
334
+ }
335
+ };
336
+ }
337
+ export { fidKind, propDef };
@@ -0,0 +1,23 @@
1
+ export interface Job {
2
+ alive: () => boolean;
3
+ run: () => void;
4
+ }
5
+ export declare function createQueue(): {
6
+ enqueue(job: Job, front?: boolean): void;
7
+ };
8
+ /** A Map in insertion order, refreshed on read: the first key is the least recently used. */
9
+ export declare class Lru<V> {
10
+ private readonly cap;
11
+ private readonly onEvict;
12
+ /** a pinned entry is never evicted (a mounted character still shows it) */
13
+ private readonly isPinned;
14
+ private readonly map;
15
+ constructor(cap: number, onEvict?: (v: V) => void,
16
+ /** a pinned entry is never evicted (a mounted character still shows it) */
17
+ isPinned?: (k: string) => boolean);
18
+ has(k: string): boolean;
19
+ get(k: string): V | undefined;
20
+ set(k: string, v: V): void;
21
+ }
22
+ /** Runs a runner's jobs through the queue, so main-thread bakes come in 14 ms slices instead of one long task. */
23
+ export declare const queuedRunner: <J, R>(run: (job: J) => Promise<R>, q: ReturnType<typeof createQueue>) => (job: J) => Promise<R>;