@q9labsai/facehash 5.4.0 → 5.5.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/dist/chunk-H6Z3WHYR.js +0 -0
- package/dist/chunk-JF6OENWX.js +16 -0
- package/dist/core/blink-scale.d.ts +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -0
- package/dist/index.native.d.ts +1 -2
- package/dist/index.native.js +7 -6
- package/dist/react.d.ts +1 -2
- package/dist/react.js +10 -10
- package/dist/scene-svg.d.ts +3 -0
- package/package.json +3 -5
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/scene-svg.ts
|
|
2
|
+
function sanitizeId(value) {
|
|
3
|
+
return value.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
4
|
+
}
|
|
5
|
+
function faceBoxTransform({ faceBox, faceGeometry }) {
|
|
6
|
+
return `translate(${faceBox.x} ${faceBox.y}) scale(${faceBox.width / faceGeometry.viewBox.width} ${faceBox.height / faceGeometry.viewBox.height})`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// src/core/blink-scale.ts
|
|
10
|
+
var BLINK_CLOSED_SCALE_Y = 0.05;
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
BLINK_CLOSED_SCALE_Y,
|
|
14
|
+
sanitizeId,
|
|
15
|
+
faceBoxTransform
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BLINK_CLOSED_SCALE_Y = 0.05;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { DEFAULT_COLORS, FACE_GEOMETRIES, computeFacehash, createFacehashScene, getColor, getForegroundColor } from "./core/index.js";
|
|
1
|
+
export * from "./core/index.js";
|
package/dist/index.js
CHANGED
package/dist/index.native.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export type { FacehashNativeProps } from "./FacehashNative.js";
|
|
2
2
|
export { FacehashNative } from "./FacehashNative.js";
|
|
3
|
-
export
|
|
4
|
-
export { DEFAULT_COLORS, FACE_GEOMETRIES, computeFacehash, createFacehashScene, getColor, getForegroundColor } from "./core/index.js";
|
|
3
|
+
export * from "./core/index.js";
|
package/dist/index.native.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BLINK_CLOSED_SCALE_Y,
|
|
3
|
+
faceBoxTransform,
|
|
4
|
+
sanitizeId
|
|
5
|
+
} from "./chunk-JF6OENWX.js";
|
|
1
6
|
import {
|
|
2
7
|
DEFAULT_COLORS,
|
|
3
8
|
FACE_GEOMETRIES,
|
|
@@ -16,7 +21,6 @@ import Svg, { Defs, G, Path, RadialGradient, Rect, Stop, Text as SvgText } from
|
|
|
16
21
|
|
|
17
22
|
// src/native-blink.ts
|
|
18
23
|
import { useEffect, useState } from "react";
|
|
19
|
-
var CLOSED_SCALE_Y = 0.05;
|
|
20
24
|
var BLINK_CLOSED_MS = 85;
|
|
21
25
|
function buildEyeTransform(anchor, scaleY) {
|
|
22
26
|
return `translate(${anchor.x} ${anchor.y}) scale(1 ${scaleY}) translate(${-anchor.x} ${-anchor.y})`;
|
|
@@ -36,7 +40,7 @@ function useBlinkTransform(enableBlink, timing, anchor) {
|
|
|
36
40
|
if (cancelled) {
|
|
37
41
|
return;
|
|
38
42
|
}
|
|
39
|
-
setScaleY(
|
|
43
|
+
setScaleY(BLINK_CLOSED_SCALE_Y);
|
|
40
44
|
openTimeout = setTimeout(() => {
|
|
41
45
|
if (!cancelled) {
|
|
42
46
|
setScaleY(1);
|
|
@@ -80,7 +84,7 @@ function FacehashSceneSvgNative({ backgroundColor, enableBlink = false, foregrou
|
|
|
80
84
|
/* @__PURE__ */ jsx(Rect, { fill: backgroundColor, height: "100", width: "100", x: "0", y: "0" }),
|
|
81
85
|
variant === "gradient" ? /* @__PURE__ */ jsx(Rect, { fill: `url(#${gradientId})`, height: "100", width: "100", x: "0", y: "0" }) : null,
|
|
82
86
|
/* @__PURE__ */ jsxs(G, { transform: scene.projection.svgTransform, children: [
|
|
83
|
-
/* @__PURE__ */ jsxs(G, { transform:
|
|
87
|
+
/* @__PURE__ */ jsxs(G, { transform: faceBoxTransform(scene), children: [
|
|
84
88
|
renderEye(scene.faceGeometry.leftEyePaths, leftBlinkTransform, foregroundColor),
|
|
85
89
|
renderEye(scene.faceGeometry.rightEyePaths, rightBlinkTransform, foregroundColor)
|
|
86
90
|
] }),
|
|
@@ -91,9 +95,6 @@ function FacehashSceneSvgNative({ backgroundColor, enableBlink = false, foregrou
|
|
|
91
95
|
|
|
92
96
|
// src/FacehashNative.tsx
|
|
93
97
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
94
|
-
function sanitizeId(value) {
|
|
95
|
-
return value.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
96
|
-
}
|
|
97
98
|
function FacehashNative({ name, size = 40, variant = "gradient", intensity3d = "dramatic", interactive = true, showInitial = true, colors, enableBlink = false, renderMouth, testID }) {
|
|
98
99
|
const [isPressed, setIsPressed] = React.useState(false);
|
|
99
100
|
const colorsLength = colors?.length ?? 1;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export type { FacehashProps } from "./Facehash.js";
|
|
2
2
|
export { Facehash } from "./Facehash.js";
|
|
3
|
-
export
|
|
4
|
-
export { DEFAULT_COLORS, FACE_GEOMETRIES, computeFacehash, createFacehashScene, getColor, getForegroundColor } from "./core/index.js";
|
|
3
|
+
export * from "./index.js";
|
package/dist/react.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BLINK_CLOSED_SCALE_Y,
|
|
3
|
+
faceBoxTransform,
|
|
4
|
+
sanitizeId
|
|
5
|
+
} from "./chunk-JF6OENWX.js";
|
|
6
|
+
import "./chunk-H6Z3WHYR.js";
|
|
1
7
|
import {
|
|
2
8
|
DEFAULT_COLORS,
|
|
3
9
|
FACE_GEOMETRIES,
|
|
@@ -14,7 +20,7 @@ import * as React from "react";
|
|
|
14
20
|
var BLINK_KEYFRAMES = `
|
|
15
21
|
@keyframes facehash-blink {
|
|
16
22
|
0%, 92%, 100% { transform: scaleY(1); }
|
|
17
|
-
96% { transform: scaleY(
|
|
23
|
+
96% { transform: scaleY(${BLINK_CLOSED_SCALE_Y}); }
|
|
18
24
|
}
|
|
19
25
|
`;
|
|
20
26
|
var keyframesInjected = false;
|
|
@@ -40,14 +46,11 @@ function getBlinkStyle(enableBlink, timing) {
|
|
|
40
46
|
|
|
41
47
|
// src/FacehashSceneSvg.tsx
|
|
42
48
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
43
|
-
function sanitizeId(value) {
|
|
44
|
-
return value.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
45
|
-
}
|
|
46
49
|
function FacehashSceneSvg({ backgroundColor, enableBlink = false, height = "100%", idPrefix, scene, showInitial, style, variant, width = "100%", withAnimatedProjection = false }) {
|
|
47
50
|
if (enableBlink) {
|
|
48
51
|
ensureBlinkKeyframes();
|
|
49
52
|
}
|
|
50
|
-
const gradientId = `${
|
|
53
|
+
const gradientId = `${idPrefix}-gradient`;
|
|
51
54
|
const projectionStyle = withAnimatedProjection ? {
|
|
52
55
|
transformBox: "view-box",
|
|
53
56
|
transformOrigin: "50% 50%",
|
|
@@ -77,7 +80,7 @@ function FacehashSceneSvg({ backgroundColor, enableBlink = false, height = "100%
|
|
|
77
80
|
/* @__PURE__ */ jsx("rect", { fill: backgroundColor, height: "100", width: "100", x: "0", y: "0" }),
|
|
78
81
|
variant === "gradient" ? /* @__PURE__ */ jsx("rect", { fill: `url(#${gradientId})`, height: "100", width: "100", x: "0", y: "0" }) : null,
|
|
79
82
|
/* @__PURE__ */ jsxs("g", { style: projectionStyle, transform: scene.projection.svgTransform, children: [
|
|
80
|
-
/* @__PURE__ */ jsxs("g", { transform:
|
|
83
|
+
/* @__PURE__ */ jsxs("g", { transform: faceBoxTransform(scene), children: [
|
|
81
84
|
/* @__PURE__ */ jsx("g", { style: getBlinkStyle(enableBlink, scene.data.blinkTimings.left), children: scene.faceGeometry.leftEyePaths.map((path) => /* @__PURE__ */ jsx("path", { d: path, fill: "currentColor" }, path)) }),
|
|
82
85
|
/* @__PURE__ */ jsx("g", { style: getBlinkStyle(enableBlink, scene.data.blinkTimings.right), children: scene.faceGeometry.rightEyePaths.map((path) => /* @__PURE__ */ jsx("path", { d: path, fill: "currentColor" }, path)) })
|
|
83
86
|
] }),
|
|
@@ -90,9 +93,6 @@ function FacehashSceneSvg({ backgroundColor, enableBlink = false, height = "100%
|
|
|
90
93
|
|
|
91
94
|
// src/Facehash.tsx
|
|
92
95
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
93
|
-
function sanitizeId2(value) {
|
|
94
|
-
return value.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
95
|
-
}
|
|
96
96
|
var Facehash = React.forwardRef(function Facehash2({ name, size = 40, variant = "gradient", intensity3d = "dramatic", interactive = true, showInitial = true, colors, enableBlink = false, renderMouth, className, style, onMouseEnter, onMouseLeave, ...props }, ref) {
|
|
97
97
|
const [isHovered, setIsHovered] = React.useState(false);
|
|
98
98
|
const reactId = React.useId();
|
|
@@ -109,7 +109,7 @@ var Facehash = React.forwardRef(function Facehash2({ name, size = 40, variant =
|
|
|
109
109
|
const backgroundColor = getColor(colors, scene.data.colorIndex);
|
|
110
110
|
const foregroundColor = getForegroundColor(backgroundColor);
|
|
111
111
|
const sizeValue = typeof size === "number" ? `${size}px` : size;
|
|
112
|
-
const svgIdPrefix = React.useMemo(() =>
|
|
112
|
+
const svgIdPrefix = React.useMemo(() => sanitizeId(`facehash-${reactId}-${name}`), [name, reactId]);
|
|
113
113
|
return /* @__PURE__ */ jsxs2(
|
|
114
114
|
"div",
|
|
115
115
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@q9labsai/facehash",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -75,11 +75,9 @@
|
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
|
-
"build": "rm
|
|
79
|
-
"build:types": "rm
|
|
78
|
+
"build": "node ../../scripts/fs.mjs rm ./dist && tsup ./src/index.ts ./src/react.ts ./src/index.native.ts --format esm --out-dir ./dist --platform browser --external react --external react-dom --external react-native --external react-native-svg && pnpm run build:types",
|
|
79
|
+
"build:types": "node ../../scripts/fs.mjs rm tsconfig.tsbuildinfo && tsc --project tsconfig.json && node ../../scripts/rewrite-declaration-specifiers.mjs ./dist",
|
|
80
80
|
"dev": "tsup ./src/index.ts ./src/react.ts ./src/index.native.ts --format esm --out-dir ./dist --platform browser --external react --external react-dom --external react-native --external react-native-svg --watch",
|
|
81
|
-
"test": "pnpm run test:declarations",
|
|
82
|
-
"test:declarations": "node ../../scripts/test/run.mjs node --test scripts/rewrite-declaration-specifiers.node.mjs",
|
|
83
81
|
"check-types": "tsc-rs --noEmit",
|
|
84
82
|
"lint": "pnpm exec oxfmt --check . && tsc --noEmit"
|
|
85
83
|
}
|