@domandigital/craft 0.11.0 → 0.13.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.
@@ -1,105 +0,0 @@
1
- import {
2
- deltaEOk,
3
- fontClass,
4
- normaliseFamily,
5
- parseColour
6
- } from "./chunk-3NGWXZZE.js";
7
-
8
- // src/fingerprint/index.ts
9
- var FINGERPRINT_VERSION = 1;
10
- var CHROMATIC = 0.03;
11
- var MIN_ACCENT_AREA = 2e4;
12
- var oklch = (value) => {
13
- const parsed = parseColour(value);
14
- return parsed && parsed.alpha > 0.5 ? parsed.oklch : null;
15
- };
16
- function accentOf(s) {
17
- const buttons = /* @__PURE__ */ new Map();
18
- for (const c of s.controls) {
19
- const o = oklch(c.background);
20
- if (o && o.c >= CHROMATIC) buttons.set(c.background, (buttons.get(c.background) ?? 0) + 1);
21
- }
22
- const topButton = [...buttons].sort((a, b) => b[1] - a[1])[0];
23
- if (topButton) return oklch(topButton[0]);
24
- const bg = s.colours.backgrounds.map((b) => ({ o: oklch(b.value), w: b.area })).filter((x) => x.o && x.o.c >= CHROMATIC && x.w >= MIN_ACCENT_AREA).sort((a, b) => b.w - a.w)[0];
25
- if (bg) return bg.o;
26
- const text = s.colours.text.map((t) => ({ o: oklch(t.value), w: t.chars })).filter((x) => x.o && x.o.c >= CHROMATIC).sort((a, b) => b.w - a.w)[0];
27
- return text ? text.o : null;
28
- }
29
- function faces(s) {
30
- const byChars = [...s.fonts].sort((a, b) => b.chars - a.chars);
31
- const byDisplay = [...s.fonts].sort((a, b) => b.displayChars - a.displayChars);
32
- const bodyName = normaliseFamily(byChars[0]?.family ?? "system-ui");
33
- const displayName = normaliseFamily((byDisplay[0]?.displayChars ? byDisplay[0].family : byChars[0]?.family) ?? "system-ui");
34
- return {
35
- display: { family: displayName, class: fontClass(displayName) },
36
- body: { family: bodyName, class: fontClass(bodyName) }
37
- };
38
- }
39
- function median(values) {
40
- if (values.length === 0) return null;
41
- const sorted = [...values].sort((a, b) => a - b);
42
- const mid = Math.floor(sorted.length / 2);
43
- return sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
44
- }
45
- function fingerprint(s) {
46
- const effects = [];
47
- if (s.effects.glass > 0) effects.push("glass-panel");
48
- if (s.effects.gradientText > 0) effects.push("gradient-text");
49
- if (s.effects.glows > 0 || s.effects.gradients.some((g) => g.radial)) effects.push("radial-spotlight-glow");
50
- if (s.effects.gridBackgrounds > 0) effects.push("grid-background");
51
- if (s.effects.marquees > 0) effects.push("marquee");
52
- if (s.effects.hairlineShadowCards >= 3) effects.push("thin-border-wide-shadow");
53
- if (s.effects.eyebrowChip) effects.push("hero-eyebrow-chip");
54
- if (s.motion.introOverlay) effects.push("intro-cinematic");
55
- const below = s.sections.filter((x) => x.top > s.viewport.height).length;
56
- return {
57
- version: FINGERPRINT_VERSION,
58
- accent: accentOf(s),
59
- ground: oklch(s.ground) ?? { l: 1, c: 0, h: 0 },
60
- ...faces(s),
61
- roundness: median(s.controls.map((c) => Math.min(0.5, c.radiusPx / Math.max(1, c.heightPx)))),
62
- motion: below ? Math.min(1, s.motion.hiddenSections / below) : 0,
63
- effects: effects.sort(),
64
- layout: s.sections.map((x) => x.kind)
65
- };
66
- }
67
- var DISTANCE_WEIGHTS = { accent: 0.25, type: 0.25, ground: 0.1, shape: 0.1, motion: 0.1, effects: 0.1, layout: 0.1 };
68
- function levenshtein(a, b) {
69
- const row = Array.from({ length: b.length + 1 }, (_, i) => i);
70
- for (let i = 1; i <= a.length; i += 1) {
71
- let prev = row[0];
72
- row[0] = i;
73
- for (let j = 1; j <= b.length; j += 1) {
74
- const cur = row[j];
75
- row[j] = Math.min(row[j] + 1, row[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
76
- prev = cur;
77
- }
78
- }
79
- return row[b.length];
80
- }
81
- var clamp = (n) => Math.max(0, Math.min(1, n));
82
- function faceDistance(a, b) {
83
- if (a.family.toLowerCase() === b.family.toLowerCase()) return 0;
84
- return a.class === b.class ? 0.5 : 1;
85
- }
86
- function fingerprintDistance(a, b) {
87
- const accent = a.accent && b.accent ? clamp(deltaEOk(a.accent, b.accent) / 0.3) : a.accent || b.accent ? 1 : 0;
88
- const ground = clamp(deltaEOk(a.ground, b.ground) / 0.15);
89
- const type = 0.6 * faceDistance(a.display, b.display) + 0.4 * faceDistance(a.body, b.body);
90
- const shape = a.roundness === null || b.roundness === null ? a.roundness === b.roundness ? 0 : 0.5 : clamp(Math.abs(a.roundness - b.roundness) / 0.5);
91
- const motion = clamp(Math.abs(a.motion - b.motion));
92
- const union = /* @__PURE__ */ new Set([...a.effects, ...b.effects]);
93
- const shared = a.effects.filter((e) => b.effects.includes(e)).length;
94
- const effects = union.size === 0 ? 0 : 1 - shared / union.size;
95
- const longest = Math.max(a.layout.length, b.layout.length);
96
- const layout = longest === 0 ? 0 : levenshtein(a.layout, b.layout) / longest;
97
- const parts = { accent, ground, type, shape, motion, effects, layout };
98
- const total = Object.keys(DISTANCE_WEIGHTS).reduce((sum, k) => sum + DISTANCE_WEIGHTS[k] * parts[k], 0);
99
- return { total: Math.round(total * 1e3) / 1e3, parts };
100
- }
101
-
102
- export {
103
- fingerprint,
104
- fingerprintDistance
105
- };
@@ -1,17 +0,0 @@
1
- import {
2
- describeFingerprint,
3
- merge,
4
- resolvePages,
5
- runAudit
6
- } from "./chunk-MSQ57PJU.js";
7
- import "./chunk-JP75P2DU.js";
8
- import "./chunk-3OZQ4C5R.js";
9
- import "./chunk-2AJB27BJ.js";
10
- import "./chunk-QMYERCBB.js";
11
- import "./chunk-3NGWXZZE.js";
12
- export {
13
- describeFingerprint,
14
- merge,
15
- resolvePages,
16
- runAudit
17
- };
@@ -1,16 +0,0 @@
1
- import {
2
- formatMatches,
3
- formatPairs,
4
- loadEstate,
5
- runEstate
6
- } from "./chunk-HOHHQB4N.js";
7
- import "./chunk-3OZQ4C5R.js";
8
- import "./chunk-2AJB27BJ.js";
9
- import "./chunk-QMYERCBB.js";
10
- import "./chunk-3NGWXZZE.js";
11
- export {
12
- formatMatches,
13
- formatPairs,
14
- loadEstate,
15
- runEstate
16
- };