robot-heads-solid 0.1.0 → 0.2.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/README.md +101 -78
- package/dist/solid2.d.ts +40 -0
- package/dist/solid2.js +1423 -0
- package/dist/solid2.server.js +532 -0
- package/dist/types/RobotHead.d.ts +4 -0
- package/dist/types/color.d.ts +2 -0
- package/dist/types/domain-types.d.ts +8 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/ticker.d.ts +8 -0
- package/dist/types/tv/faces.d.ts +28 -0
- package/dist/types/tv/geometry.d.ts +62 -0
- package/dist/types/tv/light.d.ts +16 -0
- package/dist/types/tv/render.d.ts +44 -0
- package/dist/types/tv/sim.d.ts +59 -0
- package/dist/types/types.d.ts +22 -0
- package/package.json +46 -19
- package/dist/index.d.ts +0 -39
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type Shape } from './geometry';
|
|
2
|
+
import { type Material } from './light';
|
|
3
|
+
import type { RobotPose, RobotSim } from './sim';
|
|
4
|
+
import type { RobotHeadState } from '../domain-types';
|
|
5
|
+
export interface Palette {
|
|
6
|
+
shell: Material;
|
|
7
|
+
trim: Material;
|
|
8
|
+
led: [number, number, number];
|
|
9
|
+
}
|
|
10
|
+
export interface RenderOptions {
|
|
11
|
+
floorShadow: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Diagnostics for the bounded, shared texture cache. */
|
|
14
|
+
export declare function bakeCacheStats(): {
|
|
15
|
+
entries: number;
|
|
16
|
+
bytes: number;
|
|
17
|
+
};
|
|
18
|
+
export declare class RobotRenderer {
|
|
19
|
+
private shape;
|
|
20
|
+
private meshes;
|
|
21
|
+
private unit;
|
|
22
|
+
private ledKey;
|
|
23
|
+
private front;
|
|
24
|
+
private back;
|
|
25
|
+
private screen;
|
|
26
|
+
private screenBase;
|
|
27
|
+
private glass;
|
|
28
|
+
private layer;
|
|
29
|
+
private tiny;
|
|
30
|
+
private tinyHalf;
|
|
31
|
+
private tinyImg;
|
|
32
|
+
private grain;
|
|
33
|
+
private grid;
|
|
34
|
+
private gridPrev;
|
|
35
|
+
private proj;
|
|
36
|
+
private screenGeo;
|
|
37
|
+
private prepare;
|
|
38
|
+
private compose;
|
|
39
|
+
private drawScreen;
|
|
40
|
+
private drawFloorShadow;
|
|
41
|
+
private drawGrain;
|
|
42
|
+
draw(ctx: CanvasRenderingContext2D, size: number, pose: RobotPose, sim: RobotSim | null, state: RobotHeadState, shape: Shape, palette: Palette, opts: RenderOptions): void;
|
|
43
|
+
private drawAntenna;
|
|
44
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { RobotHeadState } from '../domain-types';
|
|
2
|
+
import type { FaceParams } from './faces';
|
|
3
|
+
export interface RobotPose {
|
|
4
|
+
yaw: number;
|
|
5
|
+
pitch: number;
|
|
6
|
+
roll: number;
|
|
7
|
+
x: number;
|
|
8
|
+
lift: number;
|
|
9
|
+
sx: number;
|
|
10
|
+
sy: number;
|
|
11
|
+
antennaX: number;
|
|
12
|
+
antennaZ: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class RobotSim {
|
|
15
|
+
state: RobotHeadState;
|
|
16
|
+
shown: RobotHeadState;
|
|
17
|
+
previous: RobotHeadState;
|
|
18
|
+
switched: number;
|
|
19
|
+
age: number;
|
|
20
|
+
time: number;
|
|
21
|
+
since: number;
|
|
22
|
+
pose: RobotPose;
|
|
23
|
+
face: FaceParams;
|
|
24
|
+
pointer: {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
} | null;
|
|
28
|
+
private yaw;
|
|
29
|
+
private pitch;
|
|
30
|
+
private roll;
|
|
31
|
+
private sway;
|
|
32
|
+
private squash;
|
|
33
|
+
private antX;
|
|
34
|
+
private antZ;
|
|
35
|
+
private lastV;
|
|
36
|
+
private jump;
|
|
37
|
+
private random;
|
|
38
|
+
private lookAt;
|
|
39
|
+
private nextLook;
|
|
40
|
+
private nextBlink;
|
|
41
|
+
private blinkAge;
|
|
42
|
+
private nextHop;
|
|
43
|
+
private nextSide;
|
|
44
|
+
private reactUntil;
|
|
45
|
+
private nextNod;
|
|
46
|
+
constructor(seed: number, state: RobotHeadState);
|
|
47
|
+
setState(s: RobotHeadState): void;
|
|
48
|
+
/** A click: a hop with a full turn and a happy face. */
|
|
49
|
+
poke(): void;
|
|
50
|
+
hop(height: number, spin: number): void;
|
|
51
|
+
update(dt: number): void;
|
|
52
|
+
private stepJump;
|
|
53
|
+
private hopWithChance;
|
|
54
|
+
private updateLookAt;
|
|
55
|
+
private stateTargets;
|
|
56
|
+
private step;
|
|
57
|
+
}
|
|
58
|
+
/** The still pose of a state, for reduced motion and paused heads. */
|
|
59
|
+
export declare function restPose(state: RobotHeadState): RobotPose;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { JSX } from 'solid-js';
|
|
2
|
+
import type { RobotHeadModel, RobotHeadShape, RobotHeadState } from './domain-types';
|
|
3
|
+
export { robotHeadShapes, robotHeadStates } from './domain-types';
|
|
4
|
+
export type { RobotHeadModel, RobotHeadShape, RobotHeadState } from './domain-types';
|
|
5
|
+
/** Canvas attributes are forwarded to the underlying canvas. */
|
|
6
|
+
export interface RobotHeadProps extends Omit<JSX.CanvasHTMLAttributes<HTMLCanvasElement>, 'color'> {
|
|
7
|
+
model?: RobotHeadModel;
|
|
8
|
+
shape?: RobotHeadShape;
|
|
9
|
+
state?: RobotHeadState;
|
|
10
|
+
size?: number;
|
|
11
|
+
color?: string;
|
|
12
|
+
trimColor?: string;
|
|
13
|
+
screenColor?: string;
|
|
14
|
+
speed?: number;
|
|
15
|
+
paused?: boolean;
|
|
16
|
+
interactive?: boolean;
|
|
17
|
+
floorShadow?: boolean;
|
|
18
|
+
/** 0–1. Offsets blinks and glances across a row of heads. */
|
|
19
|
+
seed?: number;
|
|
20
|
+
/** React-compatible className alias; Solid's class prop also works. */
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "robot-heads-solid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Animated TV-headed robot avatars for Solid, drawn with Canvas 2D.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"solid",
|
|
@@ -26,39 +26,57 @@
|
|
|
26
26
|
"homepage": "https://github.com/jhomra21/robot-heads-solid#readme",
|
|
27
27
|
"main": "./dist/index.cjs",
|
|
28
28
|
"module": "./dist/index.js",
|
|
29
|
-
"types": "./dist/index.d.ts",
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
30
30
|
"exports": {
|
|
31
31
|
".": {
|
|
32
32
|
"browser": {
|
|
33
33
|
"import": {
|
|
34
|
-
"types": "./dist/index.d.ts",
|
|
34
|
+
"types": "./dist/types/index.d.ts",
|
|
35
35
|
"default": "./dist/index.js"
|
|
36
36
|
},
|
|
37
37
|
"require": {
|
|
38
|
-
"types": "./dist/index.d.ts",
|
|
38
|
+
"types": "./dist/types/index.d.ts",
|
|
39
39
|
"default": "./dist/index.cjs"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"node": {
|
|
43
43
|
"import": {
|
|
44
|
-
"types": "./dist/index.d.ts",
|
|
44
|
+
"types": "./dist/types/index.d.ts",
|
|
45
45
|
"default": "./dist/index.server.js"
|
|
46
46
|
},
|
|
47
47
|
"require": {
|
|
48
|
-
"types": "./dist/index.d.ts",
|
|
48
|
+
"types": "./dist/types/index.d.ts",
|
|
49
49
|
"default": "./dist/index.server.cjs"
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"import": {
|
|
53
|
-
"types": "./dist/index.d.ts",
|
|
53
|
+
"types": "./dist/types/index.d.ts",
|
|
54
54
|
"default": "./dist/index.js"
|
|
55
55
|
},
|
|
56
56
|
"require": {
|
|
57
|
-
"types": "./dist/index.d.ts",
|
|
57
|
+
"types": "./dist/types/index.d.ts",
|
|
58
58
|
"default": "./dist/index.cjs"
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
|
-
"./package.json": "./package.json"
|
|
61
|
+
"./package.json": "./package.json",
|
|
62
|
+
"./solid2": {
|
|
63
|
+
"browser": {
|
|
64
|
+
"import": {
|
|
65
|
+
"types": "./dist/solid2.d.ts",
|
|
66
|
+
"default": "./dist/solid2.js"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"node": {
|
|
70
|
+
"import": {
|
|
71
|
+
"types": "./dist/solid2.d.ts",
|
|
72
|
+
"default": "./dist/solid2.server.js"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"import": {
|
|
76
|
+
"types": "./dist/solid2.d.ts",
|
|
77
|
+
"default": "./dist/solid2.js"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
62
80
|
},
|
|
63
81
|
"files": [
|
|
64
82
|
"dist"
|
|
@@ -69,27 +87,36 @@
|
|
|
69
87
|
],
|
|
70
88
|
"scripts": {
|
|
71
89
|
"dev": "cd site && bun run dev",
|
|
72
|
-
"build": "vite build && vite build --config vite.ssr.config.ts",
|
|
73
|
-
"
|
|
90
|
+
"build": "vite build && vite build --config vite.ssr.config.ts && bun run build:solid2 && bun run build:types",
|
|
91
|
+
"setup:solid2": "cd solid2-toolchain && bun install --frozen-lockfile",
|
|
92
|
+
"build:solid2": "bun run setup:solid2 && cd solid2-toolchain && bun run build",
|
|
93
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
94
|
+
"typecheck": "bun run setup:solid2 && tsc --noEmit && cd solid2-toolchain && bun run typecheck",
|
|
74
95
|
"lint": "oxlint .",
|
|
75
96
|
"build:site": "bun run build && cd site && bun run build",
|
|
76
97
|
"check": "bun run lint && bun run typecheck && bun run build && cd site && bun run typecheck && bun run build",
|
|
77
98
|
"deploy": "bun run build:site && cd site && bun run deploy",
|
|
78
99
|
"prepublishOnly": "bun run check",
|
|
79
100
|
"e2e": "playwright test",
|
|
80
|
-
"e2e:consumer": "bun run build && bun
|
|
101
|
+
"e2e:consumer": "bun run build && bun run e2e:consumer:built",
|
|
102
|
+
"e2e:consumer:built": "bun pm pack --filename test-results/consumer-solid1.tgz && bun pm pack --filename test-results/consumer-solid2.tgz && cd e2e/consumer && rm -f bun.lock && bun install --force && bun run typecheck && bun run build && node ssr.mjs && cd ../consumer-solid2 && rm -f bun.lock && bun install --force && bun run typecheck && bun run build && node ssr.mjs && cd ../.. && bunx playwright test --config playwright.consumer.config.ts && bunx playwright test --config playwright.consumer-solid2.config.ts"
|
|
81
103
|
},
|
|
82
104
|
"peerDependencies": {
|
|
83
|
-
"solid-js": "^1.9.0"
|
|
105
|
+
"solid-js": "^1.9.0 || ^2.0.0-rc.14",
|
|
106
|
+
"@solidjs/web": "^2.0.0-rc.14"
|
|
107
|
+
},
|
|
108
|
+
"peerDependenciesMeta": {
|
|
109
|
+
"@solidjs/web": {
|
|
110
|
+
"optional": true
|
|
111
|
+
}
|
|
84
112
|
},
|
|
85
113
|
"devDependencies": {
|
|
86
|
-
"
|
|
87
|
-
"vite": "^8.3.0",
|
|
88
|
-
"vite-plugin-solid": "^2.11.14",
|
|
89
|
-
"vite-plugin-dts": "^4.5.0",
|
|
90
|
-
"typescript": "^5.9.3",
|
|
114
|
+
"@oxlint/plugins": "1.87.0",
|
|
91
115
|
"@playwright/test": "^1.56.0",
|
|
92
116
|
"oxlint": "1.87.0",
|
|
93
|
-
"
|
|
117
|
+
"solid-js": "^1.9.15",
|
|
118
|
+
"typescript": "^5.9.3",
|
|
119
|
+
"vite": "^8.3.0",
|
|
120
|
+
"vite-plugin-solid": "^2.11.14"
|
|
94
121
|
}
|
|
95
122
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { JSX } from 'solid-js';
|
|
2
|
-
|
|
3
|
-
declare const geometries: readonly ["rectangle", "square", "circle", "hexagon"];
|
|
4
|
-
|
|
5
|
-
/** An animated TV-headed robot, rendered on a 2D canvas. */
|
|
6
|
-
export declare function RobotHead(props: RobotHeadProps): JSX.Element;
|
|
7
|
-
|
|
8
|
-
export declare type RobotHeadModel = 'tv';
|
|
9
|
-
|
|
10
|
-
/** Canvas attributes are forwarded to the underlying canvas. */
|
|
11
|
-
export declare interface RobotHeadProps extends Omit<JSX.CanvasHTMLAttributes<HTMLCanvasElement>, 'color'> {
|
|
12
|
-
model?: RobotHeadModel;
|
|
13
|
-
shape?: RobotHeadShape;
|
|
14
|
-
state?: RobotHeadState;
|
|
15
|
-
size?: number;
|
|
16
|
-
color?: string;
|
|
17
|
-
trimColor?: string;
|
|
18
|
-
screenColor?: string;
|
|
19
|
-
speed?: number;
|
|
20
|
-
paused?: boolean;
|
|
21
|
-
interactive?: boolean;
|
|
22
|
-
floorShadow?: boolean;
|
|
23
|
-
/** 0–1. Offsets blinks and glances across a row of heads. */
|
|
24
|
-
seed?: number;
|
|
25
|
-
/** React-compatible className alias; Solid's class prop also works. */
|
|
26
|
-
className?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export declare type RobotHeadShape = typeof geometries[number];
|
|
30
|
-
|
|
31
|
-
export declare const robotHeadShapes: RobotHeadShape[];
|
|
32
|
-
|
|
33
|
-
export declare type RobotHeadState = typeof states[number];
|
|
34
|
-
|
|
35
|
-
export declare const robotHeadStates: RobotHeadState[];
|
|
36
|
-
|
|
37
|
-
declare const states: readonly ["idle", "thinking", "searching", "listening", "speaking", "working", "happy", "error", "sleeping"];
|
|
38
|
-
|
|
39
|
-
export { }
|