@doan-labs/peek 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/README.md +38 -0
- package/dist/animate.d.ts +58 -0
- package/dist/draw.d.ts +69 -0
- package/dist/identity.d.ts +55 -0
- package/dist/identity.js +398 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1700 -0
- package/dist/peek.d.ts +13 -0
- package/dist/svg.d.ts +33 -0
- package/dist/svg.js +1053 -0
- package/dist/tables.d.ts +258 -0
- package/package.json +70 -0
- package/src/animate.ts +670 -0
- package/src/draw.ts +849 -0
- package/src/identity.ts +147 -0
- package/src/index.ts +28 -0
- package/src/peek.tsx +98 -0
- package/src/svg.ts +94 -0
- package/src/tables.ts +414 -0
package/dist/tables.d.ts
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
type Pt = readonly [number, number];
|
|
2
|
+
/** Structure inks: never a body color. Signal stays in the interface. */
|
|
3
|
+
export declare const INK: {
|
|
4
|
+
readonly ink: "#1A1918";
|
|
5
|
+
readonly bone: "#F3F0E8";
|
|
6
|
+
readonly paper: "#FFFDF8";
|
|
7
|
+
};
|
|
8
|
+
export type FaceGeom = {
|
|
9
|
+
/** `stroke` rounds the corners: a round-join outline in the body ink. */
|
|
10
|
+
body: {
|
|
11
|
+
readonly d: string;
|
|
12
|
+
readonly stroke?: number;
|
|
13
|
+
} | {
|
|
14
|
+
readonly circle: readonly [number, number, number];
|
|
15
|
+
};
|
|
16
|
+
bottom: number;
|
|
17
|
+
/** How far the body sinks below the floor at rest. */
|
|
18
|
+
sink: number;
|
|
19
|
+
eyes: readonly [Pt, Pt];
|
|
20
|
+
rx: number;
|
|
21
|
+
ry: number;
|
|
22
|
+
pr: number;
|
|
23
|
+
brow: {
|
|
24
|
+
readonly y: number;
|
|
25
|
+
readonly hw: number;
|
|
26
|
+
readonly arch: number;
|
|
27
|
+
readonly w: number;
|
|
28
|
+
};
|
|
29
|
+
cheeks: readonly [Pt, Pt];
|
|
30
|
+
crx: number;
|
|
31
|
+
cry: number;
|
|
32
|
+
mouth: {
|
|
33
|
+
readonly x: number;
|
|
34
|
+
readonly y: number;
|
|
35
|
+
readonly w: number;
|
|
36
|
+
readonly d: number;
|
|
37
|
+
readonly sw: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The crown: the visible outline above the eyes, as a convex polygon grown
|
|
41
|
+
* by `r` (a point grown by r is a circle). `poly[0]` is the top and the
|
|
42
|
+
* polygon runs clockwise. Every trait sits on this outline, so any trait
|
|
43
|
+
* fits any face.
|
|
44
|
+
*/
|
|
45
|
+
crown: {
|
|
46
|
+
readonly poly: readonly Pt[];
|
|
47
|
+
readonly r: number;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export declare const FACES: {
|
|
51
|
+
readonly diamond: {
|
|
52
|
+
readonly body: {
|
|
53
|
+
readonly d: "M170 20L320 170L170 320L20 170Z";
|
|
54
|
+
};
|
|
55
|
+
readonly bottom: 320;
|
|
56
|
+
readonly sink: 30;
|
|
57
|
+
readonly eyes: readonly [readonly [132.5, 155], readonly [207.5, 155]];
|
|
58
|
+
readonly rx: 20;
|
|
59
|
+
readonly ry: 27.5;
|
|
60
|
+
readonly pr: 10;
|
|
61
|
+
readonly brow: {
|
|
62
|
+
readonly y: 102.5;
|
|
63
|
+
readonly hw: 18.75;
|
|
64
|
+
readonly arch: 15;
|
|
65
|
+
readonly w: 5.62;
|
|
66
|
+
};
|
|
67
|
+
readonly cheeks: readonly [readonly [117.5, 200], readonly [222.5, 200]];
|
|
68
|
+
readonly crx: 11.25;
|
|
69
|
+
readonly cry: 5.62;
|
|
70
|
+
readonly mouth: {
|
|
71
|
+
readonly x: 170;
|
|
72
|
+
readonly y: 218.75;
|
|
73
|
+
readonly w: 15;
|
|
74
|
+
readonly d: 16.25;
|
|
75
|
+
readonly sw: 4.38;
|
|
76
|
+
};
|
|
77
|
+
readonly crown: {
|
|
78
|
+
readonly poly: readonly [readonly [170, 20], readonly [320, 170], readonly [170, 320], readonly [20, 170]];
|
|
79
|
+
readonly r: 0;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
readonly semicircle: {
|
|
83
|
+
readonly body: {
|
|
84
|
+
readonly d: "M0 255A170 170 0 0 1 340 255Z";
|
|
85
|
+
};
|
|
86
|
+
readonly bottom: 255;
|
|
87
|
+
readonly sink: 0;
|
|
88
|
+
readonly eyes: readonly [readonly [102.5, 175], readonly [237.5, 175]];
|
|
89
|
+
readonly rx: 30;
|
|
90
|
+
readonly ry: 25;
|
|
91
|
+
readonly pr: 11.25;
|
|
92
|
+
readonly brow: {
|
|
93
|
+
readonly y: 127.5;
|
|
94
|
+
readonly hw: 25;
|
|
95
|
+
readonly arch: 15;
|
|
96
|
+
readonly w: 5.62;
|
|
97
|
+
};
|
|
98
|
+
readonly cheeks: readonly [readonly [55, 212.5], readonly [285, 212.5]];
|
|
99
|
+
readonly crx: 11.25;
|
|
100
|
+
readonly cry: 5.62;
|
|
101
|
+
readonly mouth: {
|
|
102
|
+
readonly x: 170;
|
|
103
|
+
readonly y: 221.25;
|
|
104
|
+
readonly w: 16.25;
|
|
105
|
+
readonly d: 16.25;
|
|
106
|
+
readonly sw: 4.38;
|
|
107
|
+
};
|
|
108
|
+
readonly crown: {
|
|
109
|
+
readonly poly: readonly [readonly [170, 255]];
|
|
110
|
+
readonly r: 170;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
readonly circle: {
|
|
114
|
+
readonly body: {
|
|
115
|
+
readonly circle: readonly [170, 170, 150];
|
|
116
|
+
};
|
|
117
|
+
readonly bottom: 320;
|
|
118
|
+
readonly sink: 20;
|
|
119
|
+
readonly eyes: readonly [readonly [112.8, 162.2], readonly [227.2, 162.2]];
|
|
120
|
+
readonly rx: 29.9;
|
|
121
|
+
readonly ry: 29.9;
|
|
122
|
+
readonly pr: 13;
|
|
123
|
+
readonly brow: {
|
|
124
|
+
readonly y: 110.2;
|
|
125
|
+
readonly hw: 23.4;
|
|
126
|
+
readonly arch: 15.6;
|
|
127
|
+
readonly w: 5.85;
|
|
128
|
+
};
|
|
129
|
+
readonly cheeks: readonly [readonly [84.2, 203.8], readonly [255.8, 203.8]];
|
|
130
|
+
readonly crx: 11.7;
|
|
131
|
+
readonly cry: 5.85;
|
|
132
|
+
readonly mouth: {
|
|
133
|
+
readonly x: 170;
|
|
134
|
+
readonly y: 223.3;
|
|
135
|
+
readonly w: 16.9;
|
|
136
|
+
readonly d: 16.9;
|
|
137
|
+
readonly sw: 4.55;
|
|
138
|
+
};
|
|
139
|
+
readonly crown: {
|
|
140
|
+
readonly poly: readonly [readonly [170, 170]];
|
|
141
|
+
readonly r: 150;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
readonly triangle: {
|
|
145
|
+
readonly body: {
|
|
146
|
+
readonly d: "M170 40.8L312.8 299.2L27.2 299.2Z";
|
|
147
|
+
readonly stroke: 27.2;
|
|
148
|
+
};
|
|
149
|
+
readonly bottom: 312.8;
|
|
150
|
+
readonly sink: 0;
|
|
151
|
+
readonly eyes: readonly [readonly [132.6, 210.8], readonly [207.4, 210.8]];
|
|
152
|
+
readonly rx: 20.4;
|
|
153
|
+
readonly ry: 27.2;
|
|
154
|
+
readonly pr: 10;
|
|
155
|
+
readonly brow: {
|
|
156
|
+
readonly y: 166.6;
|
|
157
|
+
readonly hw: 18.7;
|
|
158
|
+
readonly arch: 15.3;
|
|
159
|
+
readonly w: 5.62;
|
|
160
|
+
};
|
|
161
|
+
readonly cheeks: readonly [readonly [98.6, 238], readonly [241.4, 238]];
|
|
162
|
+
readonly crx: 11.5;
|
|
163
|
+
readonly cry: 5.75;
|
|
164
|
+
readonly mouth: {
|
|
165
|
+
readonly x: 170;
|
|
166
|
+
readonly y: 254;
|
|
167
|
+
readonly w: 17;
|
|
168
|
+
readonly d: 16.25;
|
|
169
|
+
readonly sw: 4.38;
|
|
170
|
+
};
|
|
171
|
+
readonly crown: {
|
|
172
|
+
readonly poly: readonly [readonly [170, 40.8], readonly [312.8, 299.2], readonly [27.2, 299.2]];
|
|
173
|
+
readonly r: 13.6;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Body inks, each with a deep partner at the same hue. The body fills the
|
|
179
|
+
* face and the lids, the deep ink carries cheeks and trait. The first four
|
|
180
|
+
* are from v1.2; butter, rose and aqua are provisional, matched to the same
|
|
181
|
+
* OKLCH lightness and chroma.
|
|
182
|
+
*/
|
|
183
|
+
export declare const COLORS: {
|
|
184
|
+
readonly lavender: {
|
|
185
|
+
readonly body: "#D8CDF0";
|
|
186
|
+
readonly deep: "#BDAEE6";
|
|
187
|
+
};
|
|
188
|
+
readonly fog: {
|
|
189
|
+
readonly body: "#C8D6E8";
|
|
190
|
+
readonly deep: "#A8BCDC";
|
|
191
|
+
};
|
|
192
|
+
readonly clay: {
|
|
193
|
+
readonly body: "#F1CDBF";
|
|
194
|
+
readonly deep: "#E2A893";
|
|
195
|
+
};
|
|
196
|
+
readonly mint: {
|
|
197
|
+
readonly body: "#CFE7D6";
|
|
198
|
+
readonly deep: "#A5CDB1";
|
|
199
|
+
};
|
|
200
|
+
readonly butter: {
|
|
201
|
+
readonly body: "#ECE2B9";
|
|
202
|
+
readonly deep: "#D9C284";
|
|
203
|
+
};
|
|
204
|
+
readonly rose: {
|
|
205
|
+
readonly body: "#EFCAD7";
|
|
206
|
+
readonly deep: "#DFA4BA";
|
|
207
|
+
};
|
|
208
|
+
readonly aqua: {
|
|
209
|
+
readonly body: "#BDE1E5";
|
|
210
|
+
readonly deep: "#8FC7D1";
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
/** Discrete anatomy. Each part reads every channel its feature owns. */
|
|
214
|
+
export declare const PARTS: {
|
|
215
|
+
readonly eyes: readonly ["oval", "bead", "ring"];
|
|
216
|
+
readonly brows: readonly ["arch", "bar", "wedge", "dash"];
|
|
217
|
+
readonly mouth: readonly ["poly", "round", "line", "box"];
|
|
218
|
+
readonly cheeks: readonly ["oval", "dots", "lines"];
|
|
219
|
+
readonly trait: readonly ["square", "fin", "ring", "dot", "peak"];
|
|
220
|
+
};
|
|
221
|
+
export type Face = keyof typeof FACES;
|
|
222
|
+
export type Color = keyof typeof COLORS;
|
|
223
|
+
export type Part = keyof typeof PARTS;
|
|
224
|
+
export type Eyes = (typeof PARTS.eyes)[number];
|
|
225
|
+
export type Brows = (typeof PARTS.brows)[number];
|
|
226
|
+
export type Mouth = (typeof PARTS.mouth)[number];
|
|
227
|
+
export type Cheeks = (typeof PARTS.cheeks)[number];
|
|
228
|
+
export type Trait = (typeof PARTS.trait)[number];
|
|
229
|
+
export type Axis = 'face' | 'color' | Part;
|
|
230
|
+
/** How much of each list a version may pick from. Append-only too. */
|
|
231
|
+
export declare const VERSIONS: Record<number, Record<Axis, number>>;
|
|
232
|
+
export declare const LATEST = 1;
|
|
233
|
+
export declare const GROUPS: {
|
|
234
|
+
readonly eyes: readonly ["lid", "lower", "lidTilt", "eyeS", "lidAsym"];
|
|
235
|
+
readonly pupil: readonly ["pupil", "gx", "gy", "shine"];
|
|
236
|
+
readonly brows: readonly ["browY", "browTilt", "browArch", "browW", "browAsym"];
|
|
237
|
+
readonly mouth: readonly ["mw", "mt", "mb", "mx", "my", "mk"];
|
|
238
|
+
readonly body: readonly ["alt", "rot", "x", "sx", "sy"];
|
|
239
|
+
readonly extra: readonly ["blush", "hair", "dim", "thing"];
|
|
240
|
+
};
|
|
241
|
+
export type Group = keyof typeof GROUPS;
|
|
242
|
+
export type Channel = (typeof GROUPS)[Group][number];
|
|
243
|
+
export type Channels = Record<Channel, number>;
|
|
244
|
+
export declare const EXPRESSIONS: {
|
|
245
|
+
readonly normal: Readonly<Channels>;
|
|
246
|
+
readonly happy: Readonly<Channels>;
|
|
247
|
+
readonly sad: Readonly<Channels>;
|
|
248
|
+
readonly angry: Readonly<Channels>;
|
|
249
|
+
readonly sleepy: Readonly<Channels>;
|
|
250
|
+
readonly curious: Readonly<Channels>;
|
|
251
|
+
readonly surprised: Readonly<Channels>;
|
|
252
|
+
readonly excited: Readonly<Channels>;
|
|
253
|
+
readonly confused: Readonly<Channels>;
|
|
254
|
+
readonly bored: Readonly<Channels>;
|
|
255
|
+
readonly attentive: Readonly<Channels>;
|
|
256
|
+
};
|
|
257
|
+
export type Expression = keyof typeof EXPRESSIONS;
|
|
258
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@doan-labs/peek",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"development": "./src/index.ts",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./svg": {
|
|
13
|
+
"types": "./dist/svg.d.ts",
|
|
14
|
+
"import": "./dist/svg.js",
|
|
15
|
+
"default": "./dist/svg.js"
|
|
16
|
+
},
|
|
17
|
+
"./identity": {
|
|
18
|
+
"types": "./dist/identity.d.ts",
|
|
19
|
+
"import": "./dist/identity.js",
|
|
20
|
+
"default": "./dist/identity.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"check-types": "tsc --noEmit",
|
|
25
|
+
"test": "bun test",
|
|
26
|
+
"build": "bun scripts/build.ts",
|
|
27
|
+
"prepack": "bun run build"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": ">=19"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@peek/typescript-config": "workspace:*",
|
|
34
|
+
"@types/bun": "latest",
|
|
35
|
+
"@types/react": "^19.2.0",
|
|
36
|
+
"@types/react-dom": "^19.2.0",
|
|
37
|
+
"react": "^19.2.0",
|
|
38
|
+
"react-dom": "^19.2.0",
|
|
39
|
+
"typescript": "^6.0.2"
|
|
40
|
+
},
|
|
41
|
+
"description": "Deterministic SVG avatars from a name, with expressions and a React component.",
|
|
42
|
+
"homepage": "https://peek.doan-labs.com",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/doan-labs/peek.git",
|
|
46
|
+
"directory": "packages/peek"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"avatar",
|
|
50
|
+
"svg",
|
|
51
|
+
"react",
|
|
52
|
+
"deterministic",
|
|
53
|
+
"peek"
|
|
54
|
+
],
|
|
55
|
+
"files": [
|
|
56
|
+
"dist",
|
|
57
|
+
"src/*.ts",
|
|
58
|
+
"src/*.tsx",
|
|
59
|
+
"!src/*.test.ts",
|
|
60
|
+
"README.md"
|
|
61
|
+
],
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"peerDependenciesMeta": {
|
|
66
|
+
"react": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|