@glass-sdk/liquid-glass 0.0.0-stage → 0.0.1

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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +596 -2
  3. package/dist/concentric-COCiG9DQ.js +179 -0
  4. package/dist/core.js +9 -0
  5. package/dist/dom-CKc8vDTR.js +2532 -0
  6. package/dist/dom.js +2 -0
  7. package/dist/gpu-Co5Y89mh.js +244 -0
  8. package/dist/gpu.js +2 -0
  9. package/dist/index.js +933 -0
  10. package/dist/map-encoder.worker-DO1drw0Y.js +16 -0
  11. package/dist/materials-DVPgteZ9.js +234 -0
  12. package/dist/styles.css +341 -0
  13. package/dist/styles.d.css.ts +2 -0
  14. package/dist/types/core/concentric.d.ts +32 -0
  15. package/dist/types/core/index.d.ts +10 -0
  16. package/dist/types/core/materials.d.ts +43 -0
  17. package/dist/types/core/morph-path.d.ts +110 -0
  18. package/dist/types/core/optics.d.ts +2 -0
  19. package/dist/types/core/progressive.d.ts +17 -0
  20. package/dist/types/core/shape.d.ts +16 -0
  21. package/dist/types/core/spring.d.ts +60 -0
  22. package/dist/types/core/union.d.ts +20 -0
  23. package/dist/types/dom/control-motion.d.ts +13 -0
  24. package/dist/types/dom/filter-bounds.d.ts +30 -0
  25. package/dist/types/dom/filter-patch.d.ts +9 -0
  26. package/dist/types/dom/fixed-shape.d.ts +3 -0
  27. package/dist/types/dom/foreground.d.ts +20 -0
  28. package/dist/types/dom/index.d.ts +61 -0
  29. package/dist/types/dom/interaction.d.ts +16 -0
  30. package/dist/types/dom/map-encoder.d.ts +5 -0
  31. package/dist/types/dom/map-encoder.worker.d.ts +1 -0
  32. package/dist/types/dom/map-encoding.d.ts +5 -0
  33. package/dist/types/dom/map-image.d.ts +14 -0
  34. package/dist/types/dom/map-store.d.ts +22 -0
  35. package/dist/types/dom/maps.d.ts +31 -0
  36. package/dist/types/dom/morph.d.ts +70 -0
  37. package/dist/types/dom/png.d.ts +7 -0
  38. package/dist/types/dom/progressive-maps.d.ts +6 -0
  39. package/dist/types/dom/progressive.d.ts +14 -0
  40. package/dist/types/dom/selection.d.ts +5 -0
  41. package/dist/types/dom/shape-layout.d.ts +29 -0
  42. package/dist/types/dom/ticker.d.ts +36 -0
  43. package/dist/types/dom/warm.d.ts +14 -0
  44. package/dist/types/gpu/index.d.ts +48 -0
  45. package/dist/types/index.d.ts +4 -0
  46. package/dist/types/react/control-thumb.d.ts +11 -0
  47. package/dist/types/react/index.d.ts +155 -0
  48. package/dist/types/react/merged-ref.d.ts +3 -0
  49. package/dist/types/react/shape.d.ts +23 -0
  50. package/dist/types/react/value-control-motion.d.ts +9 -0
  51. package/dist/types/react/value-controls.d.ts +20 -0
  52. package/package.json +80 -4
@@ -0,0 +1,179 @@
1
+ import { generateClipPath as e, generatePath as t } from "@lisse/core";
2
+ //#region src/core/shape.ts
3
+ function n(e) {
4
+ if (typeof e != "number" && e !== "capsule" && e !== "circle") throw RangeError("Unknown glass radius.");
5
+ if (typeof e == "number" && (!Number.isFinite(e) || e < 0)) throw RangeError("Corner radius must be finite and nonnegative.");
6
+ return {
7
+ radius: typeof e == "number" ? e : 2 ** 53 - 1,
8
+ smoothing: .8125,
9
+ preserveSmoothing: !0,
10
+ curve: e === "circle" ? "arc" : "squircle"
11
+ };
12
+ }
13
+ var r = /* @__PURE__ */ new Map();
14
+ function i(e, t) {
15
+ let n = r.get(e);
16
+ return n === void 0 && (n = t(), r.size >= 1024 && r.delete(r.keys().next().value), r.set(e, n)), n;
17
+ }
18
+ function a(e, r, a) {
19
+ return i(`p|${e}|${r}|${a}`, () => t(e, r, n(a)));
20
+ }
21
+ function o(t, r, a) {
22
+ return i(`c|${t}|${r}|${a}`, () => e(t, r, n(a)));
23
+ }
24
+ function s(e, t, n) {
25
+ let r = a(e, t, n).match(/[a-zA-Z]|[-+]?(?:\d*\.)?\d+(?:e[-+]?\d+)?/g), i = [], o = 0, s = [0, 0], c = [0, 0], l = () => Number(r[o++]), u = () => [l(), l()], d = (e) => {
26
+ i.push(e), s = e;
27
+ };
28
+ for (; o < r.length;) {
29
+ let e = r[o++];
30
+ if (e === "M") d(u()), c = s;
31
+ else if (e === "L") d(u());
32
+ else if (e === "H") d([l(), s[1]]);
33
+ else if (e === "V") d([s[0], l()]);
34
+ else if (e === "c") {
35
+ let e = s, t = u(), n = u(), r = u();
36
+ for (let i = 1; i <= 32; i++) {
37
+ let a = i / 32, o = 1 - a;
38
+ d([e[0] + 3 * o * o * a * t[0] + 3 * o * a * a * n[0] + a * a * a * r[0], e[1] + 3 * o * o * a * t[1] + 3 * o * a * a * n[1] + a * a * a * r[1]]);
39
+ }
40
+ } else if (e === "a") {
41
+ let e = l(), t = l(), n = l(), r = l(), i = l(), a = u();
42
+ if (e !== t || n !== 0 || r !== 0 || i !== 1) throw Error("Unsupported Lisse arc geometry.");
43
+ let o = s, c = Math.hypot(...a);
44
+ if (c < 1e-8) continue;
45
+ let f = Math.sqrt(Math.max(0, e * e - c * c / 4)), p = [o[0] + a[0] / 2 - a[1] / c * f, o[1] + a[1] / 2 + a[0] / c * f], m = Math.atan2(o[1] - p[1], o[0] - p[0]), h = 2 * Math.asin(Math.min(1, c / (2 * e)));
46
+ for (let t = 1; t <= 32; t++) {
47
+ let n = m + h * t / 32;
48
+ d([p[0] + e * Math.cos(n), p[1] + e * Math.sin(n)]);
49
+ }
50
+ } else if (e === "Z") d(c);
51
+ else throw Error(`Unsupported Lisse path command: ${e}`);
52
+ }
53
+ return i;
54
+ }
55
+ function c(e, t, n) {
56
+ let r = s(e, t, n);
57
+ for (let n of r) {
58
+ for (let t of [0, e]) Math.abs(n[0] - t) < 2e-4 && (n[0] = t);
59
+ for (let e of [0, t]) Math.abs(n[1] - e) < 2e-4 && (n[1] = e);
60
+ Math.abs(n[0] - e / 2) < 2e-4 && (n[0] = e / 2), Math.abs(n[1] - t / 2) < 2e-4 && (n[1] = t / 2);
61
+ }
62
+ let i = [];
63
+ for (let n = 1; n < r.length; n++) {
64
+ let a = r[n - 1], o = r[n], s = o[0] - a[0], c = o[1] - a[1], l = 0, u = 1;
65
+ for (let [n, r, i, o] of [[
66
+ a[0],
67
+ s,
68
+ e / 2,
69
+ 1
70
+ ], [
71
+ a[1],
72
+ c,
73
+ t / 2,
74
+ -1
75
+ ]]) if (Math.abs(r) < 1e-8) (n - i) * o < -1e-6 && (u = -1);
76
+ else {
77
+ let e = (i - n) / r;
78
+ r * o > 0 ? l = Math.max(l, e) : u = Math.min(u, e);
79
+ }
80
+ u <= l || Math.hypot(s, c) * (u - l) < 1e-6 || i.push([
81
+ a[0] + s * l,
82
+ a[1] + c * l,
83
+ a[0] + s * u,
84
+ a[1] + c * u
85
+ ]);
86
+ }
87
+ let a = i.length;
88
+ if (a > 128 || !a) throw RangeError("Lisse outline exceeds the GPU segment budget.");
89
+ return {
90
+ segments: i,
91
+ count: a
92
+ };
93
+ }
94
+ //#endregion
95
+ //#region src/core/concentric.ts
96
+ function l(e, t) {
97
+ if (!Number.isFinite(t) || t < 0) throw RangeError("Shape inset must be finite and nonnegative.");
98
+ if (e.outline && !e.outline.length) return [];
99
+ let n = e.outline ? [...e.outline, e.outline[0]] : s(e.width, e.height, e.radius), r = [
100
+ [0, 0],
101
+ [e.width, 0],
102
+ [e.width, e.height],
103
+ [0, e.height]
104
+ ];
105
+ for (let e = 1; e < n.length; e++) {
106
+ let i = n[e - 1], a = n[e], o = a[0] - i[0], s = a[1] - i[1], c = Math.hypot(o, s);
107
+ if (!(c < 2e-4) && (r = u(r, -s / c, o / c, (-s * i[0] + o * i[1]) / c + t), !r.length)) break;
108
+ }
109
+ return r;
110
+ }
111
+ function u(e, t, n, r) {
112
+ let i = [];
113
+ for (let a = 0; a < e.length; a++) {
114
+ let o = e[a], s = e[(a + 1) % e.length], c = o[0] * t + o[1] * n - r, l = s[0] * t + s[1] * n - r;
115
+ if (c >= -1e-7 && i.push(o), c < 0 != l < 0) {
116
+ let e = c / (c - l);
117
+ i.push([o[0] + (s[0] - o[0]) * e, o[1] + (s[1] - o[1]) * e]);
118
+ }
119
+ }
120
+ return i;
121
+ }
122
+ function d(e, t, n = 8) {
123
+ let r = s(t.width, t.height, n).map(([e, n]) => [e + t.x, n + t.y]);
124
+ for (let t = 0; t < e.length; t++) {
125
+ let n = e[t], i = e[(t + 1) % e.length], a = i[0] - n[0], o = i[1] - n[1], s = Math.hypot(a, o);
126
+ s < 1e-7 || (r = u(r, -o / s, a / s, (-o * n[0] + a * n[1]) / s));
127
+ }
128
+ return r.map(([e, n]) => [Math.round((e - t.x) * 1e4) / 1e4, Math.round((n - t.y) * 1e4) / 1e4]);
129
+ }
130
+ function f(e) {
131
+ return e.length ? `polygon(${e.map(([e, t]) => `${e.toFixed(3)}px ${t.toFixed(3)}px`).join(",")})` : "polygon(0px 0px,0px 0px,0px 0px)";
132
+ }
133
+ function p(e, t, n) {
134
+ return e.every((r, i) => {
135
+ let a = e[(i + 1) % e.length];
136
+ return (a[0] - r[0]) * (n - r[1]) - (a[1] - r[1]) * (t - r[0]) >= -.001;
137
+ });
138
+ }
139
+ function m(e, t, n, r, i = "circle") {
140
+ let a = l(e, r), o = s(t, n, i), c = (e) => a.length > 0 && o.every(([t, n]) => p(a, t + e, n + e)), u = Math.min((e.width - t) / 2, (e.height - n) / 2);
141
+ if (u < 0 || !c(u)) throw RangeError("The control does not fit inside its shape container.");
142
+ let d = 0, f = u;
143
+ for (let e = 0; e < 24; e++) {
144
+ let e = (d + f) / 2;
145
+ c(e) ? f = e : d = e;
146
+ }
147
+ return f;
148
+ }
149
+ function h(e, t, n, r) {
150
+ let i = [(n - Math.min(n, r)) / 2, (n + Math.min(n, r)) / 2], a = 0, o = t;
151
+ for (let t of i) {
152
+ let n = [];
153
+ for (let r = 0; r < e.length; r++) {
154
+ let i = e[r], a = e[(r + 1) % e.length];
155
+ Math.abs(i[1] - a[1]) < 1e-7 ? Math.abs(t - i[1]) < 1e-5 && n.push(i[0], a[0]) : t >= Math.min(i[1], a[1]) && t <= Math.max(i[1], a[1]) && n.push(i[0] + (a[0] - i[0]) * (t - i[1]) / (a[1] - i[1]));
156
+ }
157
+ n.length && (a = Math.max(a, Math.min(...n)), o = Math.min(o, Math.max(...n)));
158
+ }
159
+ return {
160
+ left: a,
161
+ right: t - o
162
+ };
163
+ }
164
+ function g(e) {
165
+ let t = [];
166
+ for (let n = 0; n < e.length; n++) {
167
+ let r = e[n], i = e[(n + 1) % e.length];
168
+ if (![...r, ...i].every(Number.isFinite)) throw RangeError("Outline coordinates must be finite.");
169
+ Math.hypot(i[0] - r[0], i[1] - r[1]) > 1e-5 && t.push([...r, ...i]);
170
+ }
171
+ let n = t.length;
172
+ if (n < 3 || n > 1024) throw RangeError("A glass outline needs between 3 and 1024 edges.");
173
+ return {
174
+ segments: t,
175
+ count: n
176
+ };
177
+ }
178
+ //#endregion
179
+ export { g as a, o as c, l as i, s as l, h as n, f as o, m as r, n as s, d as t, c as u };
package/dist/core.js ADDED
@@ -0,0 +1,9 @@
1
+ import { i as e, n as t, o as n, r, t as i } from "./concentric-COCiG9DQ.js";
2
+ import { a, c as o, i as s, n as c, o as l, r as u, s as d, t as f } from "./materials-DVPgteZ9.js";
3
+ //#region src/core/optics.ts
4
+ function p(e, t, n) {
5
+ let r = Math.max(0, Math.min(1, -e * n));
6
+ return t * (1 - Math.max(0, Math.min(1, Math.sqrt((2 - r) * r))));
7
+ }
8
+ //#endregion
9
+ export { a as Spring, i as concentricOutline, t as contentInsets, r as cornerPlacement, p as edgeDisplacement, e as insetShape, f as materials, n as polygonClip, c as roundRectDistance, l as rubberBand, d as settleTime, u as smoothMin, s as smoothUnion, o as springs };