@doan-labs/peek 1.1.0 → 2.0.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 CHANGED
@@ -19,6 +19,37 @@ import { Peek } from '@doan-labs/peek'
19
19
  Use `animate` for blinking and expression transitions, and
20
20
  `gaze='pointer'` to follow the pointer. Animation respects reduced motion.
21
21
 
22
+ ## Vue 3.5
23
+
24
+ The same component, with the same props and the same markup:
25
+
26
+ ```vue
27
+ <script setup>
28
+ import { Peek } from '@doan-labs/peek/vue'
29
+ </script>
30
+
31
+ <template>
32
+ <Peek name="Linh" :size="96" expression="happy" animate />
33
+ </template>
34
+ ```
35
+
36
+ ## Svelte 5
37
+
38
+ Needs Svelte 5.20 or newer. The component ships as source, so your bundler
39
+ compiles it:
40
+
41
+ ```svelte
42
+ <script>
43
+ import { Peek } from '@doan-labs/peek/svelte'
44
+ </script>
45
+
46
+ <Peek name="Linh" size={96} expression="happy" animate />
47
+ ```
48
+
49
+ In Vue and Svelte, use `class` and `style` in place of `className` and
50
+ `style`. Both entry points also export `toSvg`, `identify` and the option
51
+ lists, so neither needs React installed.
52
+
22
53
  ## Accessories
23
54
 
24
55
  Dress a face with three independent slots:
@@ -34,7 +65,20 @@ Eyewear: `none`, `glasses`, `sunglasses`. Headwear: `none`, `bow`, `cap`,
34
65
  existing avatars stay unchanged. Slots combine and work with every
35
66
  expression, gaze and frame. The same options work with `toSvg`.
36
67
 
37
- ## Plain SVG, without React
68
+ ## Variants
69
+
70
+ Draw the same face another way. A variant never changes who it is:
71
+
72
+ ```tsx
73
+ <Peek name='Linh' variant='haze' />
74
+ <Peek name='Linh' variant='bloc' expression='angry' animate />
75
+ ```
76
+
77
+ `peek` (default), `haze` (the body in soft color) or `bloc` (flat
78
+ geometry: two tones, one bar, hard edges). Every variant draws every
79
+ expression, gaze and frame.
80
+
81
+ ## Plain SVG, without a framework
38
82
 
39
83
  The SVG and identity entry points have no runtime dependencies:
40
84
 
package/dist/bloc.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { type Node, type Parts } from './draw.js';
2
+ export declare function blocParts({ who, pose, o, defs, g }: Parts): [Node[], Node[]];
package/dist/core.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export type { Frame, Gaze, Node } from './draw.js';
2
+ /** Low level: the drawing tree that toSvg and <Peek> both render. */
3
+ export { draw } from './draw.js';
4
+ export type { Axes, Identity, Persona } from './identity.js';
5
+ export { AXES, identify, LISTS, tidy } from './identity.js';
6
+ export type { PeekOptions } from './svg.js';
7
+ export { settle, toSvg } from './svg.js';
8
+ export type { AccessorySlot, Axis, Brows, Channel, Cheeks, Color, Expression, Eyes, Eyewear, Face, Headwear, Mouth, Neckwear, Trait, Variant, } from './tables.js';
9
+ export { ACCESSORIES, BLOC, COLORS, EXPRESSIONS, FACES, GROUPS, HAZE, LATEST, PARTS, VARIANTS, VERSIONS, WHEEL, } from './tables.js';
package/dist/draw.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Axes, Persona } from './identity.js';
2
- import { type Channels, type Expression, type FaceGeom } from './tables.js';
1
+ import { type Axes, type Persona } from './identity.js';
2
+ import { type Channel, type Channels, type Expression, type FaceGeom, type Variant } from './tables.js';
3
3
  export type Node = {
4
4
  tag: string;
5
5
  key: string;
@@ -30,13 +30,18 @@ export type DrawOptions = {
30
30
  title: string | false;
31
31
  /** Keep invisible nodes so an animator can write into them. */
32
32
  live?: boolean;
33
+ /** How the face is drawn. Default 'peek'. */
34
+ variant?: Variant;
33
35
  };
36
+ /** `key`, the tidied name, seeds Haze's blobs; without it, it hazes as ''. */
34
37
  export type Drawable = Axes & {
35
38
  persona: Persona;
39
+ key?: string;
36
40
  };
37
41
  export declare const VB: readonly [-30, -30, 400, 400];
38
42
  export declare const clamp: (v: number, a: number, b: number) => number;
39
43
  export declare const smooth: (a: number, b: number, v: number) => number;
44
+ export declare const f2: (v: number) => string;
40
45
  /** Where a face rests: the body offset, the eye line, one altitude unit. */
41
46
  export declare function frameOf(face: FaceGeom): {
42
47
  baseY: number;
@@ -66,4 +71,21 @@ export declare function ringWalk(sh: FaceGeom): {
66
71
  rest: number;
67
72
  min: number;
68
73
  };
74
+ type Attrs = Record<string, string | number | false | undefined>;
75
+ export declare function n(tag: string, key: string, attrs: Attrs, children?: Node[]): {
76
+ tag: string;
77
+ key: string;
78
+ attrs: Record<string, string>;
79
+ children: Node[];
80
+ };
69
81
  export declare function draw(who: Drawable, pose: Pose, o: DrawOptions): Node;
82
+ /** What a variant draws from: the defs it may add to, and the pose reader. */
83
+ export type Parts = {
84
+ who: Drawable;
85
+ pose: Pose;
86
+ o: DrawOptions;
87
+ defs: Node[];
88
+ /** A channel with the persona applied. */
89
+ g: (c: Channel) => number;
90
+ };
91
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,11 +1,3 @@
1
- export type { Frame, Gaze, Node } from './draw.js';
2
- /** Low level: the drawing tree that toSvg and <Peek> both render. */
3
- export { draw } from './draw.js';
4
- export type { Axes, Identity, Persona } from './identity.js';
5
- export { AXES, identify, LISTS, tidy } from './identity.js';
1
+ export * from './core.js';
6
2
  export type { PeekProps } from './peek.js';
7
3
  export { Peek } from './peek.js';
8
- export type { PeekOptions } from './svg.js';
9
- export { settle, toSvg } from './svg.js';
10
- export type { AccessorySlot, Axis, Brows, Channel, Cheeks, Color, Expression, Eyes, Eyewear, Face, Headwear, Mouth, Neckwear, Trait, } from './tables.js';
11
- export { ACCESSORIES, COLORS, EXPRESSIONS, FACES, GROUPS, LATEST, PARTS, VERSIONS, } from './tables.js';