@vitreajs/vitrea 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 +202 -0
- package/NOTICE +36 -0
- package/README.md +359 -0
- package/dist/chunk-ST6GFEQT.js +502 -0
- package/dist/chunk-ST6GFEQT.js.map +1 -0
- package/dist/dist-FGJI5LQM.js +3573 -0
- package/dist/dist-FGJI5LQM.js.map +1 -0
- package/dist/index.d.ts +2450 -0
- package/dist/index.js +1001 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
// ../geometry/dist/channels.js
|
|
2
|
+
var SHAPE_FAMILIES = ["fixed-rounded-rect", "capsule", "concentric-rounded-rect"];
|
|
3
|
+
function halfExtents(size) {
|
|
4
|
+
return { halfW: Math.max(size[0], 0) / 2, halfH: Math.max(size[1], 0) / 2 };
|
|
5
|
+
}
|
|
6
|
+
var uniformRadii = (r) => [r, r, r, r];
|
|
7
|
+
|
|
8
|
+
// ../geometry/dist/errors.js
|
|
9
|
+
var GeometryError = class extends Error {
|
|
10
|
+
code;
|
|
11
|
+
constructor(code, message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "GeometryError";
|
|
14
|
+
this.code = code;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// ../geometry/dist/corner.js
|
|
19
|
+
var toRad = (deg) => deg * Math.PI / 180;
|
|
20
|
+
function cornerBudget(halfW, halfH) {
|
|
21
|
+
return Math.min(halfW, halfH);
|
|
22
|
+
}
|
|
23
|
+
function smoothingCeiling(radius, budget) {
|
|
24
|
+
if (radius <= 0)
|
|
25
|
+
return Number.POSITIVE_INFINITY;
|
|
26
|
+
return Math.max(0, budget / radius - 1);
|
|
27
|
+
}
|
|
28
|
+
function resolveCornerConstruction(halfW, halfH, radius, smoothing) {
|
|
29
|
+
const budget = cornerBudget(halfW, halfH);
|
|
30
|
+
const r = Math.min(Math.max(radius, 0), budget);
|
|
31
|
+
const requested = Math.min(Math.max(smoothing, 0), 1);
|
|
32
|
+
const s = Math.min(requested, smoothingCeiling(r, budget));
|
|
33
|
+
const reach = Math.min((1 + s) * r, budget);
|
|
34
|
+
const arcMeasureDeg = 90 * (1 - s);
|
|
35
|
+
const arcSectionLength = Math.sin(toRad(arcMeasureDeg / 2)) * r * Math.SQRT2;
|
|
36
|
+
const angleAlpha = (90 - arcMeasureDeg) / 2;
|
|
37
|
+
const p3ToP4Distance = r * Math.tan(toRad(angleAlpha / 2));
|
|
38
|
+
const angleBeta = 45 * s;
|
|
39
|
+
const c = p3ToP4Distance * Math.cos(toRad(angleBeta));
|
|
40
|
+
const d = c * Math.tan(toRad(angleBeta));
|
|
41
|
+
const b = (reach - arcSectionLength - c - d) / 3;
|
|
42
|
+
const a = 2 * b;
|
|
43
|
+
return {
|
|
44
|
+
radius: r,
|
|
45
|
+
smoothingEff: s,
|
|
46
|
+
reach,
|
|
47
|
+
a,
|
|
48
|
+
b,
|
|
49
|
+
c,
|
|
50
|
+
d,
|
|
51
|
+
arcSectionLength,
|
|
52
|
+
arcMeasure: toRad(arcMeasureDeg),
|
|
53
|
+
budget
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ../geometry/dist/coefficients.js
|
|
58
|
+
var ZERO_COEFFICIENTS = [0, 0, 0, 0, 0];
|
|
59
|
+
var FIGMA_RSUPN_TABLE = [
|
|
60
|
+
{ sEff: 0, k: [0, 0, 0, 0, 0], contourDevPerR: 444089e-20 },
|
|
61
|
+
{ sEff: 0.05, k: [0.17192786, -0.57453584, 0.93678851, -0.74224658, 0.22784924], contourDevPerR: 787263e-10 },
|
|
62
|
+
{ sEff: 0.1, k: [0.15267992, -0.12909167, -0.22499519, 0.42555348, -0.18655278], contourDevPerR: 220143e-9 },
|
|
63
|
+
{ sEff: 0.15, k: [0.08481224, 0.39460055, -1.27818536, 1.3146661, -0.46204673], contourDevPerR: 208252e-9 },
|
|
64
|
+
{ sEff: 0.2, k: [0.06710202, 0.4426899, -1.08444805, 0.90833394, -0.26486554], contourDevPerR: 317781e-9 },
|
|
65
|
+
{ sEff: 0.25, k: [0.08593485, 0.21389316, -0.284278, -0.03442399, 0.10203143], contourDevPerR: 393427e-9 },
|
|
66
|
+
{ sEff: 0.3, k: [0.12086127, -0.09837148, 0.58740362, -0.92505881, 0.41092682], contourDevPerR: 384627e-9 },
|
|
67
|
+
{ sEff: 0.35, k: [0.19195982, -0.58065521, 1.68747114, -1.90488976, 0.71339719], contourDevPerR: 37628e-8 },
|
|
68
|
+
{ sEff: 0.4, k: [0.20580383, -0.64359429, 1.72183146, -1.7735827, 0.60749205], contourDevPerR: 554941e-9 },
|
|
69
|
+
{ sEff: 0.45, k: [0.20963391, -0.6235343, 1.53893663, -1.42961335, 0.43272753], contourDevPerR: 696599e-9 },
|
|
70
|
+
{ sEff: 0.5, k: [0.18345838, -0.39738895, 0.86930065, -0.6162596, 0.09847429], contourDevPerR: 729633e-9 },
|
|
71
|
+
{ sEff: 0.55, k: [0.15021017, -0.10642312, 0.03456218, 0.35031318, -0.28210743], contourDevPerR: 65723e-8 },
|
|
72
|
+
{ sEff: 0.6, k: [0.0574571, 0.54959359, -1.57948482, 2.01134453, -0.88391405], contourDevPerR: 533969e-9 },
|
|
73
|
+
{ sEff: 0.65, k: [0.0290426, 0.79150557, -2.2341988, 2.71564668, -1.13881723], contourDevPerR: 705984e-9 },
|
|
74
|
+
{ sEff: 0.7, k: [610502e-8, 0.95536509, -2.62411085, 3.08626749, -1.25256664], contourDevPerR: 951783e-9 },
|
|
75
|
+
{ sEff: 0.75, k: [-912482e-8, 1.0608592, -2.86162189, 3.29090302, -1.30280908], contourDevPerR: 120108e-8 },
|
|
76
|
+
{ sEff: 0.8, k: [-0.02095565, 1.12907188, -2.97794712, 3.34408477, -1.28941254], contourDevPerR: 134355e-8 },
|
|
77
|
+
{ sEff: 0.85, k: [0.01389408, 0.89302668, -2.39016784, 2.70448292, -1.03018516], contourDevPerR: 138316e-8 },
|
|
78
|
+
{ sEff: 0.9, k: [0.01628625, 0.79606496, -2.00469962, 2.1767657, -0.78757687], contourDevPerR: 120458e-8 },
|
|
79
|
+
{ sEff: 0.95, k: [0.06037106, 0.48294462, -1.1916487, 1.27094865, -0.42038678], contourDevPerR: 843346e-9 },
|
|
80
|
+
{ sEff: 1, k: [0.10910234, 0.09555105, -0.1426663, 0.0921919, 0.05309191], contourDevPerR: 328245e-9 }
|
|
81
|
+
];
|
|
82
|
+
var FIGMA_RSUP_TABLE = [
|
|
83
|
+
{ sEff: 0, k: [0, 0, 0, 0, 0], contourDevPerR: 455191e-20 },
|
|
84
|
+
{ sEff: 0.05, k: [0.17229922, -0.57843267, 0.94745447, -0.75342668, 0.23188652], contourDevPerR: 795723e-10 },
|
|
85
|
+
{ sEff: 0.1, k: [0.1528229, -0.13030581, -0.2214859, 0.42143243, -0.18487674], contourDevPerR: 221321e-9 },
|
|
86
|
+
{ sEff: 0.15, k: [0.08799722, 0.37596759, -1.23860352, 1.27833243, -0.44984249], contourDevPerR: 20311e-8 },
|
|
87
|
+
{ sEff: 0.2, k: [0.06791092, 0.43598426, -1.06654674, 0.88960434, -0.25815276], contourDevPerR: 314471e-9 },
|
|
88
|
+
{ sEff: 0.25, k: [0.08568973, 0.21482387, -0.2852117, -0.03448269, 0.10234124], contourDevPerR: 397169e-9 },
|
|
89
|
+
{ sEff: 0.3, k: [0.12107115, -0.10034704, 0.59290929, -0.93110813, 0.41323529], contourDevPerR: 389318e-9 },
|
|
90
|
+
{ sEff: 0.35, k: [0.19473757, -0.60204839, 1.74425741, -1.96756079, 0.73790198], contourDevPerR: 396366e-9 },
|
|
91
|
+
{ sEff: 0.4, k: [0.20633019, -0.64612615, 1.7257626, -1.77580066, 0.60777871], contourDevPerR: 562865e-9 },
|
|
92
|
+
{ sEff: 0.45, k: [0.20740344, -0.60694729, 1.49567287, -1.38229267, 0.41422845], contourDevPerR: 702136e-9 },
|
|
93
|
+
{ sEff: 0.5, k: [0.18442027, -0.40109927, 0.87301409, -0.61604528, 0.09728682], contourDevPerR: 741861e-9 },
|
|
94
|
+
{ sEff: 0.55, k: [0.14433866, -0.07398101, -0.03198855, 0.41009473, -0.30191682], contourDevPerR: 669581e-9 },
|
|
95
|
+
{ sEff: 0.6, k: [0.05594672, 0.55731115, -1.59567242, 2.0268849, -0.88947808], contourDevPerR: 540505e-9 },
|
|
96
|
+
{ sEff: 0.65, k: [0.02895533, 0.78966635, -2.22398983, 2.69966652, -1.13103881], contourDevPerR: 713798e-9 },
|
|
97
|
+
{ sEff: 0.7, k: [364655e-8, 0.97120044, -2.65963414, 3.1198731, -1.26404382], contourDevPerR: 983567e-9 },
|
|
98
|
+
{ sEff: 0.75, k: [-900127e-8, 1.06159349, -2.86306846, 3.29036733, -1.30166793], contourDevPerR: 123106e-8 },
|
|
99
|
+
{ sEff: 0.8, k: [-0.02181546, 1.13237968, -2.9794545, 3.33958794, -1.28583799], contourDevPerR: 137656e-8 },
|
|
100
|
+
{ sEff: 0.85, k: [0.01079982, 0.90842707, -2.41502297, 2.7192196, -1.03234863], contourDevPerR: 140703e-8 },
|
|
101
|
+
{ sEff: 0.9, k: [0.02082712, 0.78785003, -2.01122302, 2.1960281, -0.79663302], contourDevPerR: 122131e-8 },
|
|
102
|
+
{ sEff: 0.95, k: [0.06028054, 0.48151129, -1.18355152, 1.25863912, -0.41464021], contourDevPerR: 863628e-9 },
|
|
103
|
+
{ sEff: 1, k: [0.10998181, 0.08963148, -0.12832942, 0.07742006, 0.05857178], contourDevPerR: 337869e-9 }
|
|
104
|
+
];
|
|
105
|
+
var APPLE_RSUPN = {
|
|
106
|
+
k: [0.058939, 0.53608908, -1.48273371, 1.77253595, -0.74059491],
|
|
107
|
+
contourDevPerR: 606381e-9
|
|
108
|
+
};
|
|
109
|
+
var APPLE_RSUP = {
|
|
110
|
+
k: [0.05944375, 0.53352847, -1.47723609, 1.76689797, -0.73837656],
|
|
111
|
+
contourDevPerR: 62355e-8
|
|
112
|
+
};
|
|
113
|
+
function coefficientsAt(table, sEff) {
|
|
114
|
+
const first = table[0];
|
|
115
|
+
const last = table[table.length - 1];
|
|
116
|
+
if (first === void 0 || last === void 0) {
|
|
117
|
+
throw new Error("empty coefficient table");
|
|
118
|
+
}
|
|
119
|
+
if (sEff <= first.sEff)
|
|
120
|
+
return { k: first.k, contourDevPerR: first.contourDevPerR };
|
|
121
|
+
if (sEff >= last.sEff)
|
|
122
|
+
return { k: last.k, contourDevPerR: last.contourDevPerR };
|
|
123
|
+
for (let i = 1; i < table.length; i++) {
|
|
124
|
+
const lo = table[i - 1];
|
|
125
|
+
const hi = table[i];
|
|
126
|
+
if (lo === void 0 || hi === void 0)
|
|
127
|
+
break;
|
|
128
|
+
if (sEff <= hi.sEff) {
|
|
129
|
+
const u = (sEff - lo.sEff) / (hi.sEff - lo.sEff);
|
|
130
|
+
const mix = (j) => lo.k[j] + u * (hi.k[j] - lo.k[j]);
|
|
131
|
+
return {
|
|
132
|
+
k: [mix(0), mix(1), mix(2), mix(3), mix(4)],
|
|
133
|
+
contourDevPerR: lo.contourDevPerR + u * (hi.contourDevPerR - lo.contourDevPerR)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { k: last.k, contourDevPerR: last.contourDevPerR };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ../geometry/dist/apple.js
|
|
141
|
+
var APPLE_REACH = 1.52866495;
|
|
142
|
+
var APPLE_CONTINUOUS_SMOOTHING_SEED = APPLE_REACH - 1;
|
|
143
|
+
|
|
144
|
+
// ../geometry/dist/shape.js
|
|
145
|
+
function assertUniformRadii(radii) {
|
|
146
|
+
const [tl, tr, br, bl] = radii;
|
|
147
|
+
const spread = Math.max(tl, tr, br, bl) - Math.min(tl, tr, br, bl);
|
|
148
|
+
if (spread > 1e-9) {
|
|
149
|
+
throw new GeometryError("non-uniform-radii", `Per-corner radii are post-v1: got [${tl}, ${tr}, ${br}, ${bl}]. v1's corner algebra is mirror-symmetric (it reads |x| and |y|), so it cannot express four different corners, and the declared error bound was swept for uniform radii only. Use one radius for all four corners.`);
|
|
150
|
+
}
|
|
151
|
+
return tl;
|
|
152
|
+
}
|
|
153
|
+
function coefficientsFor(reference, family, sEff, radius) {
|
|
154
|
+
if (radius <= 0)
|
|
155
|
+
return { k: ZERO_COEFFICIENTS, contourDevPerR: 0 };
|
|
156
|
+
if (reference === "apple-continuous") {
|
|
157
|
+
const fit = family === "rsupn" ? APPLE_RSUPN : APPLE_RSUP;
|
|
158
|
+
return { k: fit.k, contourDevPerR: fit.contourDevPerR };
|
|
159
|
+
}
|
|
160
|
+
return coefficientsAt(family === "rsupn" ? FIGMA_RSUPN_TABLE : FIGMA_RSUP_TABLE, sEff);
|
|
161
|
+
}
|
|
162
|
+
function resolveCorner(size, radius, smoothing, reference, family = "rsupn") {
|
|
163
|
+
const { halfW, halfH } = halfExtents(size);
|
|
164
|
+
if (reference === "apple-continuous") {
|
|
165
|
+
const budget = cornerBudget(halfW, halfH);
|
|
166
|
+
const r = Math.max(0, Math.min(radius, budget / APPLE_REACH));
|
|
167
|
+
const fit2 = coefficientsFor(reference, family, APPLE_CONTINUOUS_SMOOTHING_SEED, r);
|
|
168
|
+
return {
|
|
169
|
+
reference,
|
|
170
|
+
radius: r,
|
|
171
|
+
smoothingEff: r > 0 ? APPLE_CONTINUOUS_SMOOTHING_SEED : 0,
|
|
172
|
+
reach: APPLE_REACH * r,
|
|
173
|
+
a: 0,
|
|
174
|
+
b: 0,
|
|
175
|
+
c: 0,
|
|
176
|
+
d: 0,
|
|
177
|
+
arcSectionLength: 0,
|
|
178
|
+
arcMeasure: 50 * Math.PI / 180,
|
|
179
|
+
budget,
|
|
180
|
+
k: fit2.k,
|
|
181
|
+
contourDevPerR: fit2.contourDevPerR
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const construction = resolveCornerConstruction(halfW, halfH, radius, smoothing);
|
|
185
|
+
const fit = coefficientsFor(reference, family, construction.smoothingEff, construction.radius);
|
|
186
|
+
return { ...construction, reference, k: fit.k, contourDevPerR: fit.contourDevPerR };
|
|
187
|
+
}
|
|
188
|
+
function resolveFromChannels(channels, reference, family = "fixed-rounded-rect", options = {}) {
|
|
189
|
+
const devMode = options.devMode ?? true;
|
|
190
|
+
const radius = devMode ? assertUniformRadii(channels.radii) : channels.radii[0] ?? 0;
|
|
191
|
+
return {
|
|
192
|
+
family,
|
|
193
|
+
channels,
|
|
194
|
+
corner: resolveCorner(channels.size, radius, channels.smoothing, reference)
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function fieldParams(shape) {
|
|
198
|
+
const { halfW, halfH } = halfExtents(shape.channels.size);
|
|
199
|
+
return { halfW, halfH, reach: shape.corner.reach, k: shape.corner.k };
|
|
200
|
+
}
|
|
201
|
+
function governorFieldParams(shape) {
|
|
202
|
+
const { halfW, halfH } = halfExtents(shape.channels.size);
|
|
203
|
+
const corner = resolveCorner(shape.channels.size, shape.corner.radius, shape.channels.smoothing, shape.corner.reference, "rsup");
|
|
204
|
+
return { halfW, halfH, reach: corner.reach, k: corner.k };
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ../geometry/dist/concentric.js
|
|
208
|
+
var MEASURED_BAND_PX = 8;
|
|
209
|
+
var DEFAULT_CONCENTRIC_MIN_RADIUS = 2;
|
|
210
|
+
function resolveConcentric(parent, spec) {
|
|
211
|
+
const inset = Math.max(spec.inset, 0);
|
|
212
|
+
const minRadius = spec.minRadius ?? DEFAULT_CONCENTRIC_MIN_RADIUS;
|
|
213
|
+
const size = [
|
|
214
|
+
Math.max(parent.channels.size[0] - 2 * inset, 0),
|
|
215
|
+
Math.max(parent.channels.size[1] - 2 * inset, 0)
|
|
216
|
+
];
|
|
217
|
+
const { halfW, halfH } = halfExtents(size);
|
|
218
|
+
const childBudget = cornerBudget(halfW, halfH);
|
|
219
|
+
const offsetRadius = parent.corner.radius - inset;
|
|
220
|
+
const floored = Math.max(offsetRadius, minRadius);
|
|
221
|
+
const radius = Math.min(floored, childBudget);
|
|
222
|
+
const radiusFloored = floored > offsetRadius + 1e-12;
|
|
223
|
+
const smoothing = parent.channels.smoothing;
|
|
224
|
+
const channels = {
|
|
225
|
+
center: parent.channels.center,
|
|
226
|
+
size,
|
|
227
|
+
radii: uniformRadii(radius),
|
|
228
|
+
smoothing,
|
|
229
|
+
thickness: spec.thickness ?? parent.channels.thickness
|
|
230
|
+
};
|
|
231
|
+
return {
|
|
232
|
+
shape: {
|
|
233
|
+
family: "concentric-rounded-rect",
|
|
234
|
+
channels,
|
|
235
|
+
corner: resolveCorner(size, radius, smoothing, parent.corner.reference)
|
|
236
|
+
},
|
|
237
|
+
radiusFloored,
|
|
238
|
+
beyondMeasuredBand: inset > MEASURED_BAND_PX
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ../geometry/dist/union.js
|
|
243
|
+
var DEFAULT_GROUP_UNION = {
|
|
244
|
+
neckWidth: 8,
|
|
245
|
+
maxBulge: 2,
|
|
246
|
+
separationThreshold: 16
|
|
247
|
+
};
|
|
248
|
+
var WGSL_RSUPN = `fn sd_rsupn(p : vec2f, half : vec2f, re : f32, k : vec4f, k4 : f32) -> f32 {
|
|
249
|
+
let q = abs(p) - half + vec2f(re, re);
|
|
250
|
+
let c = max(q, vec2f(0.0, 0.0));
|
|
251
|
+
let r2 = max(dot(c, c), 1e-20);
|
|
252
|
+
let inv = 1.0 / r2;
|
|
253
|
+
let s2 = 2.0 * c.x * c.y * inv; // sin(2*theta)
|
|
254
|
+
let c2 = (c.x * c.x - c.y * c.y) * inv; // cos(2*theta)
|
|
255
|
+
|
|
256
|
+
// R(theta) = re * (1 + s2^2 * poly(s2)), Horner
|
|
257
|
+
var acc = k4;
|
|
258
|
+
acc = acc * s2 + k.w;
|
|
259
|
+
acc = acc * s2 + k.z;
|
|
260
|
+
acc = acc * s2 + k.y;
|
|
261
|
+
acc = acc * s2 + k.x;
|
|
262
|
+
let R = re * (1.0 + s2 * s2 * acc);
|
|
263
|
+
|
|
264
|
+
// dR/d(s2) * d(s2)/dtheta, same Horner shape with the differentiated weights
|
|
265
|
+
var dac = 6.0 * k4;
|
|
266
|
+
dac = dac * s2 + 5.0 * k.w;
|
|
267
|
+
dac = dac * s2 + 4.0 * k.z;
|
|
268
|
+
dac = dac * s2 + 3.0 * k.y;
|
|
269
|
+
dac = dac * s2 + 2.0 * k.x;
|
|
270
|
+
let dRdt = re * s2 * dac * (2.0 * c2);
|
|
271
|
+
|
|
272
|
+
let base = sqrt(r2) + min(max(q.x, q.y), 0.0) - R;
|
|
273
|
+
// The normalization is a Newton step to the zero set, so its slope is read at
|
|
274
|
+
// the FOOT of the step: at the contour radius R, never at a sample radius
|
|
275
|
+
// inside it. On and outside the level set the selected arm is bit-for-bit the
|
|
276
|
+
// product S2 benchmarked; inside the corner sector the anchor is what stops
|
|
277
|
+
// R'/rho diverging toward the sector vertex and collapsing the field into a
|
|
278
|
+
// false near-surface region. See field.ts, "The normalization".
|
|
279
|
+
let g = select(dRdt / R, dRdt * inv * sqrt(r2), sqrt(r2) >= R);
|
|
280
|
+
return base * inverseSqrt(1.0 + g * g);
|
|
281
|
+
}`;
|
|
282
|
+
var WGSL_RSUP = `fn sd_rsup(p : vec2f, half : vec2f, re : f32, k : vec4f, k4 : f32) -> f32 {
|
|
283
|
+
let q = abs(p) - half + vec2f(re, re);
|
|
284
|
+
let c = max(q, vec2f(0.0, 0.0));
|
|
285
|
+
let r2 = max(dot(c, c), 1e-20);
|
|
286
|
+
let s2 = 2.0 * c.x * c.y / r2;
|
|
287
|
+
var acc = k4;
|
|
288
|
+
acc = acc * s2 + k.w;
|
|
289
|
+
acc = acc * s2 + k.z;
|
|
290
|
+
acc = acc * s2 + k.y;
|
|
291
|
+
acc = acc * s2 + k.x;
|
|
292
|
+
let R = re * (1.0 + s2 * s2 * acc);
|
|
293
|
+
return sqrt(r2) + min(max(q.x, q.y), 0.0) - R;
|
|
294
|
+
}`;
|
|
295
|
+
|
|
296
|
+
// ../motion/dist/channels.js
|
|
297
|
+
var MOTION_CHANNELS = [
|
|
298
|
+
"position",
|
|
299
|
+
"size",
|
|
300
|
+
"radius",
|
|
301
|
+
"pressCompression",
|
|
302
|
+
"lensStrength",
|
|
303
|
+
"glow",
|
|
304
|
+
"backdropAdaptation",
|
|
305
|
+
"foregroundTone",
|
|
306
|
+
"materialization",
|
|
307
|
+
"disabled",
|
|
308
|
+
"qualityTier"
|
|
309
|
+
];
|
|
310
|
+
var MOTION_DRIVER_BY_CHANNEL = {
|
|
311
|
+
position: "interruptible-spring",
|
|
312
|
+
size: "interruptible-spring",
|
|
313
|
+
radius: "interruptible-spring",
|
|
314
|
+
pressCompression: "interruptible-spring",
|
|
315
|
+
lensStrength: "critically-damped",
|
|
316
|
+
glow: "attack-decay",
|
|
317
|
+
backdropAdaptation: "low-pass-hysteresis",
|
|
318
|
+
foregroundTone: "threshold-crossfade",
|
|
319
|
+
materialization: "monotonic-ease",
|
|
320
|
+
disabled: "step",
|
|
321
|
+
qualityTier: "hysteresis-cooldown"
|
|
322
|
+
};
|
|
323
|
+
MOTION_CHANNELS.filter((channel) => MOTION_DRIVER_BY_CHANNEL[channel] === "monotonic-ease" || MOTION_DRIVER_BY_CHANNEL[channel] === "step");
|
|
324
|
+
|
|
325
|
+
// ../motion/dist/states.js
|
|
326
|
+
var INTERACTION_STATES = [
|
|
327
|
+
"idle",
|
|
328
|
+
"hover",
|
|
329
|
+
"pressed",
|
|
330
|
+
"focused",
|
|
331
|
+
"disabled",
|
|
332
|
+
"morphing"
|
|
333
|
+
];
|
|
334
|
+
|
|
335
|
+
// ../motion/dist/drivers/low-pass.js
|
|
336
|
+
var LowPassHysteresisDriver = class {
|
|
337
|
+
config;
|
|
338
|
+
#value;
|
|
339
|
+
#committed;
|
|
340
|
+
constructor(config, initialValue) {
|
|
341
|
+
this.config = config;
|
|
342
|
+
this.#value = initialValue;
|
|
343
|
+
this.#committed = initialValue;
|
|
344
|
+
}
|
|
345
|
+
get value() {
|
|
346
|
+
return this.#value;
|
|
347
|
+
}
|
|
348
|
+
get velocity() {
|
|
349
|
+
const tau = this.config.timeConstantMs;
|
|
350
|
+
if (tau <= 0)
|
|
351
|
+
return 0;
|
|
352
|
+
return (this.#committed - this.#value) * 1e3 / tau;
|
|
353
|
+
}
|
|
354
|
+
get target() {
|
|
355
|
+
return this.#committed;
|
|
356
|
+
}
|
|
357
|
+
get settled() {
|
|
358
|
+
return Math.abs(this.#value - this.#committed) <= this.config.restDistance;
|
|
359
|
+
}
|
|
360
|
+
retarget(input) {
|
|
361
|
+
if (Math.abs(input - this.#committed) <= this.config.hysteresis)
|
|
362
|
+
return;
|
|
363
|
+
this.#committed = input;
|
|
364
|
+
}
|
|
365
|
+
jumpTo(value) {
|
|
366
|
+
this.#value = value;
|
|
367
|
+
this.#committed = value;
|
|
368
|
+
}
|
|
369
|
+
advance(dtMs) {
|
|
370
|
+
if (!(dtMs > 0))
|
|
371
|
+
return;
|
|
372
|
+
const tau = this.config.timeConstantMs;
|
|
373
|
+
if (tau <= 0) {
|
|
374
|
+
this.#value = this.#committed;
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
this.#value = this.#committed + (this.#value - this.#committed) * Math.exp(-dtMs / tau);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
// ../motion/dist/tunables.js
|
|
382
|
+
var DEFAULT_MOTION_PROFILE = {
|
|
383
|
+
frame: { maxDeltaMs: 50 },
|
|
384
|
+
channels: {
|
|
385
|
+
// Layout and morph geometry. Slightly underdamped: a trace of overshoot is
|
|
386
|
+
// what reads as material rather than as a tween.
|
|
387
|
+
position: {
|
|
388
|
+
kind: "interruptible-spring",
|
|
389
|
+
responseMs: 420,
|
|
390
|
+
dampingRatio: 0.82,
|
|
391
|
+
restDistance: 0.02,
|
|
392
|
+
restVelocity: 0.05
|
|
393
|
+
},
|
|
394
|
+
size: {
|
|
395
|
+
kind: "interruptible-spring",
|
|
396
|
+
responseMs: 460,
|
|
397
|
+
dampingRatio: 0.85,
|
|
398
|
+
restDistance: 0.02,
|
|
399
|
+
restVelocity: 0.05
|
|
400
|
+
},
|
|
401
|
+
radius: {
|
|
402
|
+
kind: "interruptible-spring",
|
|
403
|
+
responseMs: 460,
|
|
404
|
+
dampingRatio: 0.9,
|
|
405
|
+
restDistance: 0.02,
|
|
406
|
+
restVelocity: 0.05
|
|
407
|
+
},
|
|
408
|
+
// Press compression. Faster and looser than layout — the release bounce is
|
|
409
|
+
// most of what makes a press feel physical.
|
|
410
|
+
pressCompression: {
|
|
411
|
+
kind: "interruptible-spring",
|
|
412
|
+
responseMs: 260,
|
|
413
|
+
dampingRatio: 0.72,
|
|
414
|
+
restDistance: 1e-3,
|
|
415
|
+
restVelocity: 5e-3
|
|
416
|
+
},
|
|
417
|
+
// Optical strength must not overshoot: past 1 the lens visibly over-bends.
|
|
418
|
+
lensStrength: {
|
|
419
|
+
kind: "critically-damped",
|
|
420
|
+
responseMs: 300,
|
|
421
|
+
dampingRatio: 1,
|
|
422
|
+
restDistance: 1e-3,
|
|
423
|
+
restVelocity: 5e-3
|
|
424
|
+
},
|
|
425
|
+
// Fast attack, slow decay: light arrives with the finger and lingers after.
|
|
426
|
+
glow: { kind: "attack-decay", attackMs: 70, decayMs: 320, restDistance: 1e-3 },
|
|
427
|
+
// Backdrop adaptation. Long constant and a wide band so scrolling past a
|
|
428
|
+
// contrast edge cannot pump the material.
|
|
429
|
+
backdropAdaptation: {
|
|
430
|
+
kind: "low-pass-hysteresis",
|
|
431
|
+
timeConstantMs: 500,
|
|
432
|
+
hysteresis: 0.04,
|
|
433
|
+
restDistance: 1e-3
|
|
434
|
+
},
|
|
435
|
+
// Foreground light/dark. Band wide enough that mid-luminance backdrops do
|
|
436
|
+
// not oscillate the text colour.
|
|
437
|
+
foregroundTone: {
|
|
438
|
+
kind: "threshold-crossfade",
|
|
439
|
+
threshold: 0.5,
|
|
440
|
+
hysteresis: 0.08,
|
|
441
|
+
crossfadeMs: 180
|
|
442
|
+
},
|
|
443
|
+
materialization: { kind: "monotonic-ease", durationMs: 220, easing: "easeOutCubic" },
|
|
444
|
+
disabled: { kind: "step", hysteresis: 0, cooldownMs: 0 },
|
|
445
|
+
// Quality tier. Long dwell, half-a-tier band: §Performance's governor
|
|
446
|
+
// switches tiers only with long hysteresis and cooldown.
|
|
447
|
+
qualityTier: { kind: "hysteresis-cooldown", hysteresis: 0.5, cooldownMs: 2500 }
|
|
448
|
+
},
|
|
449
|
+
// Interaction-driven targets. Geometry, backdrop and governor channels are
|
|
450
|
+
// absent because interaction state does not decide them (§channels).
|
|
451
|
+
stateTargets: {
|
|
452
|
+
idle: {
|
|
453
|
+
pressCompression: 0,
|
|
454
|
+
lensStrength: 1,
|
|
455
|
+
glow: 0,
|
|
456
|
+
materialization: 1,
|
|
457
|
+
disabled: 0
|
|
458
|
+
},
|
|
459
|
+
hover: {
|
|
460
|
+
pressCompression: 0,
|
|
461
|
+
lensStrength: 1.06,
|
|
462
|
+
glow: 0.28,
|
|
463
|
+
materialization: 1,
|
|
464
|
+
disabled: 0
|
|
465
|
+
},
|
|
466
|
+
pressed: {
|
|
467
|
+
pressCompression: 1,
|
|
468
|
+
lensStrength: 1.14,
|
|
469
|
+
glow: 1,
|
|
470
|
+
materialization: 1,
|
|
471
|
+
disabled: 0
|
|
472
|
+
},
|
|
473
|
+
focused: {
|
|
474
|
+
pressCompression: 0,
|
|
475
|
+
lensStrength: 1.03,
|
|
476
|
+
glow: 0.16,
|
|
477
|
+
materialization: 1,
|
|
478
|
+
disabled: 0
|
|
479
|
+
},
|
|
480
|
+
disabled: {
|
|
481
|
+
pressCompression: 0,
|
|
482
|
+
lensStrength: 0.5,
|
|
483
|
+
glow: 0,
|
|
484
|
+
materialization: 1,
|
|
485
|
+
disabled: 1
|
|
486
|
+
},
|
|
487
|
+
morphing: {
|
|
488
|
+
pressCompression: 0,
|
|
489
|
+
lensStrength: 1.1,
|
|
490
|
+
glow: 0.35,
|
|
491
|
+
materialization: 1,
|
|
492
|
+
disabled: 0
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
reducedMotion: { minDampingRatio: 1, morphResponseFactor: 0.7 },
|
|
496
|
+
pressCompressionScale: 0.015,
|
|
497
|
+
reducedMotionApplied: false
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
export { DEFAULT_GROUP_UNION, DEFAULT_MOTION_PROFILE, INTERACTION_STATES, LowPassHysteresisDriver, MOTION_DRIVER_BY_CHANNEL, SHAPE_FAMILIES, WGSL_RSUP, WGSL_RSUPN, fieldParams, governorFieldParams, resolveConcentric, resolveFromChannels };
|
|
501
|
+
//# sourceMappingURL=chunk-ST6GFEQT.js.map
|
|
502
|
+
//# sourceMappingURL=chunk-ST6GFEQT.js.map
|