dotmote 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/LICENSE +21 -0
- package/README.md +178 -0
- package/README.zh-CN.md +155 -0
- package/dist/Dotmote.d.ts +16 -0
- package/dist/Dotmote.d.ts.map +1 -0
- package/dist/Dotmote.js +142 -0
- package/dist/Dotmote.js.map +1 -0
- package/dist/core/createDotMatrixCore.d.ts +37 -0
- package/dist/core/createDotMatrixCore.d.ts.map +1 -0
- package/dist/core/createDotMatrixCore.js +541 -0
- package/dist/core/createDotMatrixCore.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/physics.d.ts +58 -0
- package/dist/core/physics.d.ts.map +1 -0
- package/dist/core/physics.js +177 -0
- package/dist/core/physics.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/themes.d.ts +21 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +79 -0
- package/dist/themes.js.map +1 -0
- package/dist/types.d.ts +162 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize loose `items` input into concrete {@link ContentItem}s.
|
|
3
|
+
* Strings become `{ kind: 'text', value }`. Anything already shaped like a
|
|
4
|
+
* `ContentItem` is passed through. Non-string / non-object values are dropped.
|
|
5
|
+
*/
|
|
6
|
+
export function normalizeItems(input) {
|
|
7
|
+
if (!input || !Array.isArray(input))
|
|
8
|
+
return [];
|
|
9
|
+
const out = [];
|
|
10
|
+
for (const raw of input) {
|
|
11
|
+
if (typeof raw === 'string') {
|
|
12
|
+
if (raw.length === 0)
|
|
13
|
+
continue;
|
|
14
|
+
out.push({ kind: 'text', value: raw });
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (raw && typeof raw === 'object' && 'kind' in raw) {
|
|
18
|
+
const item = raw;
|
|
19
|
+
if (item.kind === 'text' || item.kind === 'emoji') {
|
|
20
|
+
if (item.value.length === 0)
|
|
21
|
+
continue;
|
|
22
|
+
out.push({ kind: item.kind, value: item.value });
|
|
23
|
+
}
|
|
24
|
+
else if (item.kind === 'shape') {
|
|
25
|
+
out.push({
|
|
26
|
+
kind: 'shape',
|
|
27
|
+
value: item.value,
|
|
28
|
+
...(typeof item.radius === 'number' ? { radius: item.radius } : {}),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
else if (item.kind === 'path') {
|
|
32
|
+
if (item.value.length === 0)
|
|
33
|
+
continue;
|
|
34
|
+
out.push({ kind: 'path', value: item.value });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Reflect a body's velocity component when its center crosses a wall, and
|
|
42
|
+
* clamp its center back onto the boundary line so it can't tunnel.
|
|
43
|
+
*
|
|
44
|
+
* `edgePadding` is the distance from each edge the body stays inside.
|
|
45
|
+
*/
|
|
46
|
+
export function bounce(body, width, height, edgePadding) {
|
|
47
|
+
if (body.centerX < edgePadding) {
|
|
48
|
+
body.centerX = edgePadding + (edgePadding - body.centerX);
|
|
49
|
+
body.velocityX = Math.abs(body.velocityX);
|
|
50
|
+
}
|
|
51
|
+
else if (body.centerX > width - edgePadding) {
|
|
52
|
+
body.centerX = width - edgePadding - (body.centerX - (width - edgePadding));
|
|
53
|
+
body.velocityX = -Math.abs(body.velocityX);
|
|
54
|
+
}
|
|
55
|
+
if (body.centerY < edgePadding) {
|
|
56
|
+
body.centerY = edgePadding + (edgePadding - body.centerY);
|
|
57
|
+
body.velocityY = Math.abs(body.velocityY);
|
|
58
|
+
}
|
|
59
|
+
else if (body.centerY > height - edgePadding) {
|
|
60
|
+
body.centerY = height - edgePadding - (body.centerY - (height - edgePadding));
|
|
61
|
+
body.velocityY = -Math.abs(body.velocityY);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* AABB collision test using half-sizes: two bodies overlap only when both
|
|
66
|
+
* `x` and `y` spans intersect. Returns `true` when a collision was resolved.
|
|
67
|
+
*
|
|
68
|
+
* On overlap, the pair is separated along the axis of *smaller* overlap (each
|
|
69
|
+
* moved by half the penetration, in opposite directions) and their velocity
|
|
70
|
+
* components on that axis are **swapped** (a simplified exchange, per spec —
|
|
71
|
+
* not a full elastic impulse).
|
|
72
|
+
*/
|
|
73
|
+
export function resolveCollision(a, b) {
|
|
74
|
+
const overlapX = a.width / 2 + b.width / 2 - Math.abs(b.centerX - a.centerX);
|
|
75
|
+
const overlapY = a.height / 2 + b.height / 2 - Math.abs(b.centerY - a.centerY);
|
|
76
|
+
if (overlapX <= 0 || overlapY <= 0)
|
|
77
|
+
return false;
|
|
78
|
+
if (overlapX < overlapY) {
|
|
79
|
+
const sign = a.centerX === b.centerX ? 1 : Math.sign(b.centerX - a.centerX);
|
|
80
|
+
const push = overlapX / 2;
|
|
81
|
+
a.centerX -= sign * push;
|
|
82
|
+
b.centerX += sign * push;
|
|
83
|
+
const tmp = a.velocityX;
|
|
84
|
+
a.velocityX = b.velocityX;
|
|
85
|
+
b.velocityX = tmp;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const sign = a.centerY === b.centerY ? 1 : Math.sign(b.centerY - a.centerY);
|
|
89
|
+
const push = overlapY / 2;
|
|
90
|
+
a.centerY -= sign * push;
|
|
91
|
+
b.centerY += sign * push;
|
|
92
|
+
const tmp = a.velocityY;
|
|
93
|
+
a.velocityY = b.velocityY;
|
|
94
|
+
b.velocityY = tmp;
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Advance the *active* bodies by `dt` seconds: integrate position, bounce off
|
|
100
|
+
* the walls, then pairwise-resolve collisions.
|
|
101
|
+
*
|
|
102
|
+
* Returns a NEW array of the same bodies so callers can pass a slice of their
|
|
103
|
+
* `bodies` list (e.g. only the bodies whose intro has finished) without
|
|
104
|
+
* mutating the source ordering.
|
|
105
|
+
*/
|
|
106
|
+
export function stepBodies(bodies, dt, width, height, edgePadding) {
|
|
107
|
+
if (dt <= 0)
|
|
108
|
+
return;
|
|
109
|
+
for (const body of bodies) {
|
|
110
|
+
body.centerX += body.velocityX * dt;
|
|
111
|
+
body.centerY += body.velocityY * dt;
|
|
112
|
+
bounce(body, width, height, edgePadding);
|
|
113
|
+
}
|
|
114
|
+
// O(n^2) pairwise collision resolution. Fine for the small counts we use.
|
|
115
|
+
for (let i = 0; i < bodies.length; i++) {
|
|
116
|
+
for (let j = i + 1; j < bodies.length; j++) {
|
|
117
|
+
resolveCollision(bodies[i], bodies[j]);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Advance bodies by `dt` seconds with WALL bounce only — no pairwise collision,
|
|
123
|
+
* so bodies can pass through each other (the `roam` motion).
|
|
124
|
+
*/
|
|
125
|
+
export function stepRoam(bodies, dt, width, height, edgePadding) {
|
|
126
|
+
if (dt <= 0)
|
|
127
|
+
return;
|
|
128
|
+
for (const body of bodies) {
|
|
129
|
+
body.centerX += body.velocityX * dt;
|
|
130
|
+
body.centerY += body.velocityY * dt;
|
|
131
|
+
bounce(body, width, height, edgePadding);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Advance bodies for the horizontal ticker (marquee) modes: move along X (the
|
|
136
|
+
* velocity already encodes direction) and wrap around a horizontal track.
|
|
137
|
+
*
|
|
138
|
+
* `dir` is `+1` for left→right and `-1` for right→left; `gap` is the padding
|
|
139
|
+
* between a body and the screen edge that triggers a wrap. `track` is the loop
|
|
140
|
+
* length (sum of body widths + `n * gap`), which keeps the first/last gap even.
|
|
141
|
+
*/
|
|
142
|
+
export function stepTicker(bodies, dt, width, dir, gap, track) {
|
|
143
|
+
if (dt <= 0)
|
|
144
|
+
return;
|
|
145
|
+
const loop = track && track > 0 ? track : width + 2 * gap;
|
|
146
|
+
for (const body of bodies) {
|
|
147
|
+
body.centerX += body.velocityX * dt;
|
|
148
|
+
if (dir > 0) {
|
|
149
|
+
if (body.centerX - body.width / 2 > width + gap) {
|
|
150
|
+
body.centerX -= loop;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
if (body.centerX + body.width / 2 < -gap) {
|
|
155
|
+
body.centerX += loop;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** Whether a motion mode is one of the horizontal ticker (marquee) modes. */
|
|
161
|
+
export function isTickerMotion(mode) {
|
|
162
|
+
return mode === 'ticker-left' || mode === 'ticker-right';
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Clamp a value into `[min, max]`.
|
|
166
|
+
*/
|
|
167
|
+
export function clamp(value, min, max) {
|
|
168
|
+
return value < min ? min : value > max ? max : value;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A short ease-out curve for the intro fade-in (0..1 input → 0..1 output).
|
|
172
|
+
*/
|
|
173
|
+
export function easeOutCubic(t) {
|
|
174
|
+
const x = clamp(t, 0, 1);
|
|
175
|
+
return 1 - Math.pow(1 - x, 3);
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=physics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"physics.js","sourceRoot":"","sources":["../../src/core/physics.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAsB;IACnD,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC/C,MAAM,GAAG,G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AI,KAAK,aAAa,IAAI,IAAI,KAAK,cAAc,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW;IAC3D,OAAO,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,CAAS;IACpC,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;AAChC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { Dotmote } from './Dotmote.js';
|
|
2
|
+
/** @deprecated Use {@link Dotmote}. Kept as a backwards-compatible alias. */
|
|
3
|
+
export { Dotmote as DotMatrixBackground } from './Dotmote.js';
|
|
4
|
+
export type { DotmoteProps, DotMatrixBackgroundProps, ContentItem, ContentInput, ThemeConfig, ThemePreset, ThemeLike, Breakpoints, MotionMode, Body, CoreOptions, } from './types.js';
|
|
5
|
+
export { themes, resolveTheme } from './themes.js';
|
|
6
|
+
export { createDotMatrixCore, DEFAULT_BREAKPOINTS, DEFAULT_ITEMS, normalizeItems, bounce, resolveCollision, stepBodies, stepRoam, stepTicker, isTickerMotion, clamp, easeOutCubic, } from './core/index.js';
|
|
7
|
+
export type { DotMatrixCoreHandle, DotMatrixCoreConfig } from './core/index.js';
|
|
8
|
+
/** Default export is the component itself. */
|
|
9
|
+
export { Dotmote as default } from './Dotmote.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,6EAA6E;AAC7E,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE9D,YAAY,EACV,YAAY,EACZ,wBAAwB,EACxB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,IAAI,EACJ,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,UAAU,EACV,cAAc,EACd,KAAK,EACL,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,8CAA8C;AAC9C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Dotmote } from './Dotmote.js';
|
|
2
|
+
/** @deprecated Use {@link Dotmote}. Kept as a backwards-compatible alias. */
|
|
3
|
+
export { Dotmote as DotMatrixBackground } from './Dotmote.js';
|
|
4
|
+
export { themes, resolveTheme } from './themes.js';
|
|
5
|
+
export { createDotMatrixCore, DEFAULT_BREAKPOINTS, DEFAULT_ITEMS, normalizeItems, bounce, resolveCollision, stepBodies, stepRoam, stepTicker, isTickerMotion, clamp, easeOutCubic, } from './core/index.js';
|
|
6
|
+
/** Default export is the component itself. */
|
|
7
|
+
export { Dotmote as default } from './Dotmote.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,6EAA6E;AAC7E,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAgB9D,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,UAAU,EACV,cAAc,EACd,KAAK,EACL,YAAY,GACb,MAAM,iBAAiB,CAAC;AAGzB,8CAA8C;AAC9C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/themes.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ThemeConfig, ThemeLike } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Built-in brand-agnostic theme presets.
|
|
4
|
+
*
|
|
5
|
+
* All rgb stops and dot colors are intentionally generic so the backdrop reads
|
|
6
|
+
* as "subtle dotted texture", not a particular brand. Swap them out via the
|
|
7
|
+
* `theme` prop with an inline {@link ThemeConfig} if you need custom colors.
|
|
8
|
+
*/
|
|
9
|
+
export declare const themes: Record<'light' | 'dark' | 'mono' | 'gradient', ThemeConfig>;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve a {@link ThemeLike} into a concrete {@link ThemeConfig}.
|
|
12
|
+
*
|
|
13
|
+
* `auto` (or `undefined`) resolves to `light`/`dark` based on `dark`. Pass the
|
|
14
|
+
* current OS `prefers-color-scheme` value here; it defaults to light so the
|
|
15
|
+
* function stays SSR-safe (it never touches `window`/`matchMedia` itself).
|
|
16
|
+
*
|
|
17
|
+
* @param theme A preset name or an inline config. Defaults to `auto`.
|
|
18
|
+
* @param dark Whether the OS prefers a dark scheme (used only for `auto`).
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveTheme(theme?: ThemeLike, dark?: boolean): ThemeConfig;
|
|
21
|
+
//# sourceMappingURL=themes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../src/themes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,EAAE,WAAW,CAsC9E,CAAC;AAMF;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,UAAQ,GAAG,WAAW,CAoBzE"}
|
package/dist/themes.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in brand-agnostic theme presets.
|
|
3
|
+
*
|
|
4
|
+
* All rgb stops and dot colors are intentionally generic so the backdrop reads
|
|
5
|
+
* as "subtle dotted texture", not a particular brand. Swap them out via the
|
|
6
|
+
* `theme` prop with an inline {@link ThemeConfig} if you need custom colors.
|
|
7
|
+
*/
|
|
8
|
+
export const themes = {
|
|
9
|
+
/** Classic light theme: white background, soft gray dots, mid-gray glow. */
|
|
10
|
+
light: {
|
|
11
|
+
background: '#ffffff',
|
|
12
|
+
dotColor: 'rgb(230, 228, 228)',
|
|
13
|
+
glow: [
|
|
14
|
+
'rgb(160, 159, 159)',
|
|
15
|
+
'rgb(160, 159, 159)',
|
|
16
|
+
'rgb(160, 159, 159)',
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
/** Soft light dots that sit on dark backdrops. */
|
|
20
|
+
dark: {
|
|
21
|
+
dotColor: 'rgba(255, 255, 255, 0.16)',
|
|
22
|
+
glow: [
|
|
23
|
+
'rgba(255, 255, 255, 0.14)',
|
|
24
|
+
'rgba(255, 255, 255, 0.30)',
|
|
25
|
+
'rgba(255, 255, 255, 0.56)',
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
/** The default — a neutral gray-readable lattice on any backdrop. */
|
|
29
|
+
mono: {
|
|
30
|
+
dotColor: 'rgba(128, 128, 128, 0.5)',
|
|
31
|
+
glow: [
|
|
32
|
+
'rgba(120, 120, 120, 0.9)',
|
|
33
|
+
'rgba(170, 170, 170, 0.9)',
|
|
34
|
+
'rgba(220, 220, 220, 0.9)',
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
/** A colorful (but still generic) gradient for demos. */
|
|
38
|
+
gradient: {
|
|
39
|
+
dotColor: 'rgba(128, 128, 128, 0.5)',
|
|
40
|
+
glow: [
|
|
41
|
+
'rgba(56, 189, 248, 0.9)',
|
|
42
|
+
'rgba(99, 102, 241, 0.9)',
|
|
43
|
+
'rgba(236, 72, 153, 0.9)',
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const THEME_KEYS = new Set(['light', 'dark', 'mono', 'gradient']);
|
|
48
|
+
/**
|
|
49
|
+
* Resolve a {@link ThemeLike} into a concrete {@link ThemeConfig}.
|
|
50
|
+
*
|
|
51
|
+
* `auto` (or `undefined`) resolves to `light`/`dark` based on `dark`. Pass the
|
|
52
|
+
* current OS `prefers-color-scheme` value here; it defaults to light so the
|
|
53
|
+
* function stays SSR-safe (it never touches `window`/`matchMedia` itself).
|
|
54
|
+
*
|
|
55
|
+
* @param theme A preset name or an inline config. Defaults to `auto`.
|
|
56
|
+
* @param dark Whether the OS prefers a dark scheme (used only for `auto`).
|
|
57
|
+
*/
|
|
58
|
+
export function resolveTheme(theme, dark = false) {
|
|
59
|
+
if (theme === undefined || theme === null || theme === 'auto') {
|
|
60
|
+
return themes[dark ? 'dark' : 'light'];
|
|
61
|
+
}
|
|
62
|
+
if (typeof theme === 'string') {
|
|
63
|
+
if (THEME_KEYS.has(theme))
|
|
64
|
+
return themes[theme];
|
|
65
|
+
// Unknown preset name: fall back to the scheme-appropriate default.
|
|
66
|
+
return themes[dark ? 'dark' : 'light'];
|
|
67
|
+
}
|
|
68
|
+
// Inline config — clone so callers can't accidentally mutate our preset.
|
|
69
|
+
const glow = Array.isArray(theme.glow) && theme.glow.length === 3
|
|
70
|
+
? theme.glow
|
|
71
|
+
: themes[dark ? 'dark' : 'light'].glow;
|
|
72
|
+
return {
|
|
73
|
+
dotColor: theme.dotColor ?? themes.mono.dotColor,
|
|
74
|
+
glow: [glow[0], glow[1], glow[2]],
|
|
75
|
+
...(theme.activeDotColor ? { activeDotColor: theme.activeDotColor } : {}),
|
|
76
|
+
...(theme.background ? { background: theme.background } : {}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=themes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.js","sourceRoot":"","sources":["../src/themes.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,MAAM,GAAgE;IACjF,4EAA4E;IAC5E,KAAK,EAAE;QACL,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,oBAAoB;QAC9B,IAAI,EAAE;YACJ,oBAAoB;YACpB,oBAAoB;YACpB,oBAAoB;SACrB;KACF;IACD,kDAAkD;IAClD,IAAI,EAAE;QACJ,QAAQ,EAAE,2BAA2B;QACrC,IAAI,EAAE;YACJ,2BAA2B;YAC3B,2BAA2B;YAC3B,2BAA2B;SAC5B;KACF;IACD,qEAAqE;IACrE,IAAI,EAAE;QACJ,QAAQ,EAAE,0BAA0B;QACpC,IAAI,EAAE;YACJ,0BAA0B;YAC1B,0BAA0B;YAC1B,0BAA0B;SAC3B;KACF;IACD,yDAAyD;IACzD,QAAQ,EAAE;QACR,QAAQ,EAAE,0BAA0B;QACpC,IAAI,EAAE;YACJ,yBAAyB;YACzB,yBAAyB;YACzB,yBAAyB;SAC1B;KACF;CACF,CAAC;AAEF,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,M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E,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9D,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A single drifting "body" that will be revealed through the dot-matrix mask.
|
|
4
|
+
*/
|
|
5
|
+
export type ContentItem = {
|
|
6
|
+
kind: 'text';
|
|
7
|
+
value: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'emoji';
|
|
10
|
+
value: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'shape';
|
|
13
|
+
value: 'circle' | 'square' | 'triangle' | 'star' | 'diamond';
|
|
14
|
+
radius?: number;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'path';
|
|
17
|
+
value: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Loose input accepted for `items`. Strings are normalized to `{ kind: 'text' }`.
|
|
21
|
+
*/
|
|
22
|
+
export type ContentInput = ContentItem | string;
|
|
23
|
+
/**
|
|
24
|
+
* Animation behavior for the drifting bodies.
|
|
25
|
+
* - `drift` — random drift + wall bounce + pairwise collision (default).
|
|
26
|
+
* - `roam` — random drift + wall bounce, but bodies pass through each other.
|
|
27
|
+
* - `static` — frozen (after the intro fade-in).
|
|
28
|
+
* - `ticker-left` / `ticker-right` — a marquee / billboard: the bodies scroll
|
|
29
|
+
* in a single row at the vertical center, looping left→right or right→left.
|
|
30
|
+
*/
|
|
31
|
+
export type MotionMode = 'static' | 'drift' | 'roam' | 'ticker-left' | 'ticker-right';
|
|
32
|
+
/**
|
|
33
|
+
* A resolved theme: the colors that drive the dot grid and the glow gradient.
|
|
34
|
+
* `dot` and `background` are optional so a preset can keep them neutral.
|
|
35
|
+
*/
|
|
36
|
+
export interface ThemeConfig {
|
|
37
|
+
/** Dot color of the background lattice (CSS color string). Defaults to `rgba(128,128,128,0.5)`. */
|
|
38
|
+
dotColor?: string;
|
|
39
|
+
/** Color of the *illuminated* (lit) dots. When set the glow is a flat color (all three gradient stops). Omit to use `glow`. */
|
|
40
|
+
activeDotColor?: string;
|
|
41
|
+
/** Three-stop linear gradient for the illuminated glow: [start, mid, end]. */
|
|
42
|
+
glow: [string, string, string];
|
|
43
|
+
/** Optional background color applied to the element (behind the dots). */
|
|
44
|
+
background?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Built-in theme names. `auto` resolves to `light`/`dark` from the OS setting. */
|
|
47
|
+
export type ThemePreset = 'auto' | 'light' | 'dark' | 'mono' | 'gradient';
|
|
48
|
+
/** A theme may be a preset name or an inline config. */
|
|
49
|
+
export type ThemeLike = ThemePreset | ThemeConfig;
|
|
50
|
+
/** Responsive breakpoint geometry. */
|
|
51
|
+
export interface Breakpoints {
|
|
52
|
+
small: number;
|
|
53
|
+
medium: number;
|
|
54
|
+
smallSpacing: number;
|
|
55
|
+
mediumSpacing: number;
|
|
56
|
+
largeSpacing: number;
|
|
57
|
+
}
|
|
58
|
+
export interface DotmoteProps {
|
|
59
|
+
/**
|
|
60
|
+
* String content — each character becomes a drifting body (whitespace is
|
|
61
|
+
* skipped) and is rendered as one letter/emoji. Shorthand for passing an
|
|
62
|
+
* array of one-character text items. Takes precedence over {@link items}.
|
|
63
|
+
*/
|
|
64
|
+
values?: string;
|
|
65
|
+
/** Bodies to drift. Defaults to the neutral letters `['A','B','C','D','E']`. */
|
|
66
|
+
items?: ContentInput[];
|
|
67
|
+
/** Theme preset or custom config. Defaults to `'mono'`. */
|
|
68
|
+
theme?: ThemeLike;
|
|
69
|
+
/** Dot radius in px. Defaults to `spacing <= 9 ? 0.82 : 1`. */
|
|
70
|
+
dotRadius?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Glow *strength* (not opacity). Defaults to `1`. `<1` fades the glow;
|
|
73
|
+
* `>1` (up to ~3) layers it brighter via additive compositing.
|
|
74
|
+
*/
|
|
75
|
+
glowStrength?: number;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Renamed to {@link glowStrength}. Kept as a backwards-compatible
|
|
78
|
+
* alias; when both are set, `glowStrength` wins.
|
|
79
|
+
*/
|
|
80
|
+
glowAlpha?: number;
|
|
81
|
+
/** Global speed multiplier. Defaults to `1`. */
|
|
82
|
+
speed?: number;
|
|
83
|
+
/** Animation behavior for the bodies. Defaults to `'drift'`. */
|
|
84
|
+
motion?: MotionMode;
|
|
85
|
+
/**
|
|
86
|
+
* Font stack for text/emoji bodies. Defaults to a neutral stack.
|
|
87
|
+
* Note: the weight and size are prefixed automatically (`900 ${fontSize}px ...`).
|
|
88
|
+
*/
|
|
89
|
+
fontFamily?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Fixed character size in px. Overrides the automatic font size (and
|
|
92
|
+
* `fontSizeOverride`). Defaults to the responsive clamp / breakpoint logic.
|
|
93
|
+
*/
|
|
94
|
+
fontSize?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Override the automatic font size for the largest breakpoint.
|
|
97
|
+
* A number sets it directly; a function receives the container width in px.
|
|
98
|
+
*/
|
|
99
|
+
fontSizeOverride?: number | ((width: number) => number);
|
|
100
|
+
/** Minimum of the automatic large-screen font-size clamp. Defaults to `207`. */
|
|
101
|
+
fontSizeMin?: number;
|
|
102
|
+
/** Maximum of the automatic large-screen font-size clamp. Defaults to `270`. */
|
|
103
|
+
fontSizeMax?: number;
|
|
104
|
+
/** Responsive breakpoints. See {@link Breakpoints} for defaults. */
|
|
105
|
+
breakpoints?: Partial<Breakpoints>;
|
|
106
|
+
/**
|
|
107
|
+
* Scale the lattice density on top of the responsive breakpoints.
|
|
108
|
+
* `1` (default) keeps the breakpoint spacing; `<1` makes the dots denser,
|
|
109
|
+
* `>1` sparser. This also scales the edge padding and the default dot size.
|
|
110
|
+
*/
|
|
111
|
+
spacingScale?: number;
|
|
112
|
+
/** Intro hold duration in ms during which bodies are frozen and fade in. Defaults to `520`. */
|
|
113
|
+
introDurationMs?: number;
|
|
114
|
+
/** Passed through to the container `<div>`. */
|
|
115
|
+
className?: string;
|
|
116
|
+
/** Alias for `className` (HTML-style). Used when `className` is omitted. */
|
|
117
|
+
class?: string;
|
|
118
|
+
/** Passed through to the container `<div>`. */
|
|
119
|
+
style?: React.CSSProperties;
|
|
120
|
+
/** Hide the element from assistive tech. Defaults to `true`. */
|
|
121
|
+
ariaHidden?: boolean;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated Renamed to {@link DotmoteProps}. Kept as a backwards-compatible
|
|
125
|
+
* alias.
|
|
126
|
+
*/
|
|
127
|
+
export type DotMatrixBackgroundProps = DotmoteProps;
|
|
128
|
+
/** Internal resolved options passed to the canvas core. */
|
|
129
|
+
export interface CoreOptions {
|
|
130
|
+
items: ContentItem[];
|
|
131
|
+
dot: string;
|
|
132
|
+
glow: [string, string, string];
|
|
133
|
+
background?: string;
|
|
134
|
+
dotRadius?: number;
|
|
135
|
+
glowStrength: number;
|
|
136
|
+
speed: number;
|
|
137
|
+
motion: MotionMode;
|
|
138
|
+
fontFamily: string;
|
|
139
|
+
fontSize?: number;
|
|
140
|
+
fontSizeOverride?: number | ((width: number) => number);
|
|
141
|
+
fontSizeMin: number;
|
|
142
|
+
fontSizeMax: number;
|
|
143
|
+
breakpoints: Breakpoints;
|
|
144
|
+
spacingScale: number;
|
|
145
|
+
introDurationMs: number;
|
|
146
|
+
}
|
|
147
|
+
/** A static container to keep physics pure and testable. */
|
|
148
|
+
export interface Body {
|
|
149
|
+
id: number;
|
|
150
|
+
item: ContentItem;
|
|
151
|
+
centerX: number;
|
|
152
|
+
centerY: number;
|
|
153
|
+
width: number;
|
|
154
|
+
height: number;
|
|
155
|
+
fontSize: number;
|
|
156
|
+
velocityX: number;
|
|
157
|
+
velocityY: number;
|
|
158
|
+
colors: [string, string, string];
|
|
159
|
+
/** Performance-ish timestamp (ms) at which this body's intro started. */
|
|
160
|
+
introStart: number;
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=types.d.ts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@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dotmote",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Brand-agnostic dotted-matrix glowing background component (React + TypeScript + Canvas). Zero runtime deps besides react.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"canvas",
|
|
8
|
+
"background",
|
|
9
|
+
"dot-matrix",
|
|
10
|
+
"dotted-grid",
|
|
11
|
+
"particles",
|
|
12
|
+
"glow",
|
|
13
|
+
"typescript"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./themes": {
|
|
27
|
+
"types": "./dist/themes.d.ts",
|
|
28
|
+
"import": "./dist/themes.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"README.zh-CN.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"build": "tsc -p tsconfig.build.json",
|
|
40
|
+
"build:site": "vite build",
|
|
41
|
+
"prepublishOnly": "npm run build",
|
|
42
|
+
"lint": "eslint . --ext .ts,.tsx",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"dev": "vite",
|
|
45
|
+
"clean": "rm -rf dist"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"react": ">=18"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/react": "^18.3.3",
|
|
52
|
+
"@types/react-dom": "^18.3.0",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^7.16.1",
|
|
54
|
+
"@typescript-eslint/parser": "^7.16.1",
|
|
55
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
56
|
+
"eslint": "^8.57.0",
|
|
57
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
58
|
+
"react": "^18.3.1",
|
|
59
|
+
"react-dom": "^18.3.1",
|
|
60
|
+
"typescript": "^5.5.3",
|
|
61
|
+
"vite": "^5.4.0",
|
|
62
|
+
"vitest": "^2.0.3"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=18"
|
|
66
|
+
}
|
|
67
|
+
}
|