@markmiro/hairy 0.0.0-stage → 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 +127 -2
- package/dist/chunk-JIET4PY7.js +2641 -0
- package/dist/chunk-JIET4PY7.js.map +1 -0
- package/dist/index.d.ts +1298 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/react.d.ts +17 -0
- package/dist/react.js +29 -0
- package/dist/react.js.map +1 -0
- package/package.json +60 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
apca,
|
|
3
|
+
autoLabel,
|
|
4
|
+
defaultSettings,
|
|
5
|
+
diffOptions,
|
|
6
|
+
eases,
|
|
7
|
+
gpuSupported,
|
|
8
|
+
hairy,
|
|
9
|
+
isSettingValue,
|
|
10
|
+
labelContrast,
|
|
11
|
+
optionGroups,
|
|
12
|
+
presetNames,
|
|
13
|
+
presets,
|
|
14
|
+
regrowSettings,
|
|
15
|
+
resolveSettings,
|
|
16
|
+
settingChoices,
|
|
17
|
+
supportsWideGamut
|
|
18
|
+
} from "./chunk-JIET4PY7.js";
|
|
19
|
+
export {
|
|
20
|
+
apca,
|
|
21
|
+
autoLabel,
|
|
22
|
+
defaultSettings,
|
|
23
|
+
diffOptions,
|
|
24
|
+
eases,
|
|
25
|
+
hairy,
|
|
26
|
+
isSettingValue,
|
|
27
|
+
labelContrast,
|
|
28
|
+
optionGroups,
|
|
29
|
+
presetNames,
|
|
30
|
+
presets,
|
|
31
|
+
regrowSettings,
|
|
32
|
+
resolveSettings,
|
|
33
|
+
settingChoices,
|
|
34
|
+
gpuSupported as supportsFur,
|
|
35
|
+
supportsWideGamut
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HairyOptions, Hairy } from './index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds fur to the element you pass the returned ref to:
|
|
5
|
+
*
|
|
6
|
+
* ```tsx
|
|
7
|
+
* const ref = useHairy({ preset: "plush", color: "#ff4d70", label: "auto" });
|
|
8
|
+
* return <button ref={ref}>Adopt a cat</button>;
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* The fur follows `options` as they change (compared by value, so a new
|
|
12
|
+
* object each render is fine), and is removed when the element unmounts.
|
|
13
|
+
* `onReady` gets the fur, for `play()` and `label`.
|
|
14
|
+
*/
|
|
15
|
+
declare function useHairy<T extends HTMLElement = HTMLElement>(options?: HairyOptions, onReady?: (fur: Hairy) => void): (element: T | null) => void;
|
|
16
|
+
|
|
17
|
+
export { Hairy, HairyOptions, useHairy };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hairy
|
|
3
|
+
} from "./chunk-JIET4PY7.js";
|
|
4
|
+
|
|
5
|
+
// src/react.ts
|
|
6
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
7
|
+
function useHairy(options = {}, onReady) {
|
|
8
|
+
const fur = useRef(null);
|
|
9
|
+
const latest = useRef(options);
|
|
10
|
+
latest.current = options;
|
|
11
|
+
const ready = useRef(onReady);
|
|
12
|
+
ready.current = onReady;
|
|
13
|
+
const ref = useCallback((element) => {
|
|
14
|
+
fur.current?.destroy();
|
|
15
|
+
fur.current = null;
|
|
16
|
+
if (!element) return;
|
|
17
|
+
fur.current = hairy(element, latest.current);
|
|
18
|
+
ready.current?.(fur.current);
|
|
19
|
+
}, []);
|
|
20
|
+
const key = JSON.stringify(options);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
fur.current?.set(latest.current);
|
|
23
|
+
}, [key]);
|
|
24
|
+
return ref;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
useHairy
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from \"react\";\nimport { hairy, type Hairy, type HairyOptions } from \"./index\";\n\n/**\n * Adds fur to the element you pass the returned ref to:\n *\n * ```tsx\n * const ref = useHairy({ preset: \"plush\", color: \"#ff4d70\", label: \"auto\" });\n * return <button ref={ref}>Adopt a cat</button>;\n * ```\n *\n * The fur follows `options` as they change (compared by value, so a new\n * object each render is fine), and is removed when the element unmounts.\n * `onReady` gets the fur, for `play()` and `label`.\n */\nexport function useHairy<T extends HTMLElement = HTMLElement>(options: HairyOptions = {}, onReady?: (fur: Hairy) => void) {\n const fur = useRef<Hairy | null>(null);\n const latest = useRef(options);\n latest.current = options;\n const ready = useRef(onReady);\n ready.current = onReady;\n\n const ref = useCallback((element: T | null) => {\n fur.current?.destroy();\n fur.current = null;\n if (!element) return;\n fur.current = hairy(element, latest.current);\n ready.current?.(fur.current);\n }, []);\n\n const key = JSON.stringify(options);\n useEffect(() => {\n fur.current?.set(latest.current);\n }, [key]);\n\n return ref;\n}\n\nexport type { Hairy, HairyOptions } from \"./index\";\n"],"mappings":";;;;;AAAA,SAAS,aAAa,WAAW,cAAc;AAexC,SAAS,SAA8C,UAAwB,CAAC,GAAG,SAAgC;AACxH,QAAM,MAAM,OAAqB,IAAI;AACrC,QAAM,SAAS,OAAO,OAAO;AAC7B,SAAO,UAAU;AACjB,QAAM,QAAQ,OAAO,OAAO;AAC5B,QAAM,UAAU;AAEhB,QAAM,MAAM,YAAY,CAAC,YAAsB;AAC7C,QAAI,SAAS,QAAQ;AACrB,QAAI,UAAU;AACd,QAAI,CAAC,QAAS;AACd,QAAI,UAAU,MAAM,SAAS,OAAO,OAAO;AAC3C,UAAM,UAAU,IAAI,OAAO;AAAA,EAC7B,GAAG,CAAC,CAAC;AAEL,QAAM,MAAM,KAAK,UAAU,OAAO;AAClC,YAAU,MAAM;AACd,QAAI,SAAS,IAAI,OAAO,OAAO;AAAA,EACjC,GAAG,CAAC,GAAG,CAAC;AAER,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markmiro/hairy",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fur for your buttons: a GPU-drawn, animated, customizable hairy texture that reacts to hover, click and brushing.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Mark Mironyuk",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/markmiro/hairy.git",
|
|
10
|
+
"directory": "packages/hairy"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/markmiro/hairy#readme",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
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
|
+
"./react": {
|
|
27
|
+
"types": "./dist/react.d.ts",
|
|
28
|
+
"import": "./dist/react.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"fur",
|
|
34
|
+
"hair",
|
|
35
|
+
"button",
|
|
36
|
+
"canvas",
|
|
37
|
+
"webgl",
|
|
38
|
+
"animation",
|
|
39
|
+
"texture"
|
|
40
|
+
],
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react": ">=18"
|
|
43
|
+
},
|
|
44
|
+
"peerDependenciesMeta": {
|
|
45
|
+
"react": {
|
|
46
|
+
"optional": true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/react": "^19.3.0",
|
|
51
|
+
"react": "^19.2.0",
|
|
52
|
+
"tsup": "^9.0.0",
|
|
53
|
+
"typescript": "^6.0.3"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsup",
|
|
60
|
+
"dev": "tsup --watch",
|
|
61
|
+
"typecheck": "tsc --noEmit"
|
|
62
|
+
}
|
|
6
63
|
}
|