morphicons 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.
@@ -0,0 +1,60 @@
1
+ //#region src/core/spring.d.ts
2
+ declare class Spring {
3
+ x: number;
4
+ v: number;
5
+ k: number;
6
+ c: number;
7
+ config(k: number, c: number): void;
8
+ /** Starts (or restarts mid-flight) preserving velocity. */
9
+ start(): void;
10
+ /** Advances dt seconds. Returns true on settle (|1−x| < 0.001 ∧ |v| < 0.02). */
11
+ step(dt: number): boolean;
12
+ }
13
+ /** Spring presets (ζ = c/(2√k)) with the API's public names. */
14
+ declare const SPRING_PRESETS: {
15
+ /** ζ = 1.00 — critically damped, no overshoot. */
16
+ readonly smooth: {
17
+ readonly k: 170;
18
+ readonly c: 26;
19
+ };
20
+ /** ζ = 0.73 — fast, subtle overshoot. */
21
+ readonly snappy: {
22
+ readonly k: 420;
23
+ readonly c: 30;
24
+ };
25
+ /** ζ = 0.40 — playful. */
26
+ readonly bouncy: {
27
+ readonly k: 300;
28
+ readonly c: 14;
29
+ };
30
+ };
31
+ type SpringPreset = keyof typeof SPRING_PRESETS;
32
+ //#endregion
33
+ //#region src/core/types.d.ts
34
+ /** Attributes of an icon node (values as Lucide exports them: string or
35
+ * number). `undefined` is allowed on purpose — lucide's SVGProps includes it
36
+ * and the runtime treats an undefined attr as absent (fallback). */
37
+ type IconNodeAttrs = Record<string, string | number | undefined>;
38
+ /** Lucide-style icon data: a `[tag, attrs]` list. Structurally typed —
39
+ * Lucide is neither a dependency nor a peer; Feather/Tabler/custom paths
40
+ * work just the same. */
41
+ type IconNode = ReadonlyArray<readonly [string, IconNodeAttrs]>;
42
+ /** Input accepted by the core: an IconNode or a raw `d` attribute.
43
+ * (SVGElement is resolved in the dom layer — the core never touches DOM.) */
44
+ type IconInput = IconNode | string;
45
+ /** Normalized subpath: a chain of cubics packed as points
46
+ * [p0, c1, c2, p1, c1', c2', p2, …] → Float64Array of length 2·(3m+1),
47
+ * with m = number of segments. Consecutive segments share an endpoint. */
48
+ interface CubicPath {
49
+ pts: Float64Array;
50
+ closed: boolean;
51
+ }
52
+ /** Subpath sampled at N points by arc length + its topology. It is the
53
+ * currency between resample and plan; an intermediate shape (interruption)
54
+ * is also a list of Sampled. */
55
+ interface Sampled {
56
+ pts: Float64Array;
57
+ closed: boolean;
58
+ }
59
+ //#endregion
60
+ export { Sampled as a, SpringPreset as c, IconNodeAttrs as i, IconInput as n, SPRING_PRESETS as o, IconNode as r, Spring as s, CubicPath as t };
package/package.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "name": "morphicons",
3
+ "version": "0.1.0",
4
+ "description": "Universal morphing for stroke-based icons with spring physics — zero runtime dependencies",
5
+ "license": "MIT",
6
+ "author": "Guillermo (https://guillermolg.com)",
7
+ "homepage": "https://www.morphicons.com",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/guillermolg00/morphicons.git"
11
+ },
12
+ "bugs": "https://github.com/guillermolg00/morphicons/issues",
13
+ "keywords": [
14
+ "icons",
15
+ "svg",
16
+ "morphing",
17
+ "animation",
18
+ "spring",
19
+ "lucide",
20
+ "feather",
21
+ "tabler",
22
+ "react",
23
+ "icon-animation"
24
+ ],
25
+ "type": "module",
26
+ "sideEffects": false,
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./dom": {
36
+ "types": "./dist/dom.d.ts",
37
+ "default": "./dist/dom.js"
38
+ },
39
+ "./react": {
40
+ "types": "./dist/react.d.ts",
41
+ "default": "./dist/react.js"
42
+ }
43
+ },
44
+ "peerDependencies": {
45
+ "react": ">=18"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "react": {
49
+ "optional": true
50
+ }
51
+ },
52
+ "files": [
53
+ "dist"
54
+ ],
55
+ "scripts": {
56
+ "test": "bun test",
57
+ "typecheck": "tsc --noEmit && tsc -p playground --noEmit && tsc -p tsconfig.react.json --noEmit",
58
+ "play": "bun ./playground/index.html",
59
+ "lint": "biome check .",
60
+ "format": "biome check --write .",
61
+ "build": "tsdown",
62
+ "size": "size-limit",
63
+ "prepublishOnly": "bun run build"
64
+ },
65
+ "size-limit": [
66
+ {
67
+ "name": "core (gzip — anti-regression tripwire, see README)",
68
+ "path": "dist/index.js",
69
+ "import": "*",
70
+ "limit": "7 KB",
71
+ "gzip": true
72
+ },
73
+ {
74
+ "name": "core + dom (createMorph + scheduler)",
75
+ "path": "dist/dom.js",
76
+ "import": "*",
77
+ "limit": "7.5 KB",
78
+ "gzip": true
79
+ },
80
+ {
81
+ "name": "core + dom + react (MorphIcon, react external)",
82
+ "path": "dist/react.js",
83
+ "import": "*",
84
+ "ignore": [
85
+ "react"
86
+ ],
87
+ "limit": "8.5 KB",
88
+ "gzip": true
89
+ }
90
+ ],
91
+ "devDependencies": {
92
+ "@biomejs/biome": "^2.5.6",
93
+ "@size-limit/preset-small-lib": "^13.0.3",
94
+ "@tabler/icons": "^3.46.0",
95
+ "@types/bun": "^1.3.14",
96
+ "@types/react": "^19.2.18",
97
+ "@types/react-dom": "^19.2.4",
98
+ "feather-icons": "^4.29.2",
99
+ "lucide": "^1.28.0",
100
+ "react": "^19.2.8",
101
+ "react-dom": "^19.2.8",
102
+ "size-limit": "^13.0.3",
103
+ "tsdown": "^0.22.14",
104
+ "typescript": "^7.0.2"
105
+ }
106
+ }