@paramrig/web 0.1.0 → 0.1.2
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/es-DC0_iRTj.js +455 -0
- package/dist/paramrig-web.js +808 -511
- package/dist/rigs/extended-types.d.ts +1 -1
- package/dist/rigs/types.d.ts +10 -7
- package/dist/web/contracts.d.ts +1 -1
- package/dist/web/geometry.d.ts +1 -1
- package/dist/web/sdk.d.ts +5 -5
- package/package.json +1 -1
- package/dist/index-L3Zm-CoX.js +0 -512
package/dist/paramrig-web.js
CHANGED
|
@@ -1,533 +1,830 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
|
|
1
|
+
var e = "paramrig.web";
|
|
2
|
+
function t(e) {
|
|
3
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
|
|
5
|
+
function n(e) {
|
|
6
|
+
return typeof e == "string" && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(e);
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
8
|
+
function r(e) {
|
|
9
|
+
return typeof e == "string" && e.length > 0 && e.length <= 2e3;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
function i(e) {
|
|
12
|
+
if (!t(e)) return !1;
|
|
13
|
+
let n = (e, r) => r < 12 && (e === null || typeof e == "boolean" || typeof e == "string" && e.length <= 1e5 || typeof e == "number" && Number.isFinite(e) || Array.isArray(e) && e.length <= 1e3 && e.every((e) => n(e, r + 1)) || t(e) && Object.keys(e).length <= 1e3 && Object.entries(e).every(([e, t]) => ![
|
|
14
|
+
"__proto__",
|
|
15
|
+
"prototype",
|
|
16
|
+
"constructor"
|
|
17
|
+
].includes(e) && n(t, r + 1)));
|
|
18
|
+
return n(e, 0);
|
|
15
19
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
function a(e) {
|
|
21
|
+
if (!t(e) || e.version !== 1 || !n(e.id) || !r(e.name) || !r(e.revision) || typeof e.origin != "string") throw Error("Invalid web project manifest.");
|
|
22
|
+
let a = new URL(e.origin);
|
|
23
|
+
if (!["http:", "https:"].includes(a.protocol) || a.origin !== e.origin || a.username || a.password) throw Error("The project origin must be an HTTP or HTTPS origin.");
|
|
24
|
+
if (!Array.isArray(e.pages) || !e.pages.length || e.pages.length > 100 || !e.pages.every((e) => t(e) && n(e.id) && r(e.name) && typeof e.path == "string" && e.path.startsWith("/") && new URL(e.path, a).origin === a.origin)) throw Error("Declare valid project pages.");
|
|
25
|
+
if (!Array.isArray(e.groups) || !e.groups.every((e) => t(e) && n(e.id) && r(e.label))) throw Error("Invalid control groups.");
|
|
26
|
+
if (!Array.isArray(e.parameters) || e.parameters.length > 500) throw Error("Invalid controls.");
|
|
27
|
+
let o = /* @__PURE__ */ new Set([
|
|
28
|
+
"number",
|
|
29
|
+
"color",
|
|
30
|
+
"select",
|
|
31
|
+
"curve",
|
|
32
|
+
"switch",
|
|
33
|
+
"gradient",
|
|
34
|
+
"text",
|
|
35
|
+
"vector",
|
|
36
|
+
"range",
|
|
37
|
+
"palette",
|
|
38
|
+
"points",
|
|
39
|
+
"radial",
|
|
40
|
+
"group",
|
|
41
|
+
"list",
|
|
42
|
+
"resource",
|
|
43
|
+
"gizmo2d",
|
|
44
|
+
"gizmo3d",
|
|
45
|
+
"camera",
|
|
46
|
+
"textureFrame",
|
|
47
|
+
"multiselect",
|
|
48
|
+
"action",
|
|
49
|
+
"preset"
|
|
50
|
+
]), s = (e, a = 0) => !(a > 8 || !t(e) || !n(e.id) || !r(e.label) || typeof e.group != "string" || !o.has(String(e.kind)) || !i({ value: e.defaultValue }) || e.kind === "number" && !(typeof e.min == "number" && typeof e.max == "number" && e.min <= e.max && typeof e.step == "number" && e.step > 0) || [
|
|
51
|
+
"select",
|
|
52
|
+
"preset",
|
|
53
|
+
"multiselect"
|
|
54
|
+
].includes(String(e.kind)) && !(Array.isArray(e.options) && e.options.every((e) => t(e) && typeof e.value == "string" && r(e.label))) || e.kind === "group" && !(Array.isArray(e.fields) && e.fields.every((e) => s(e, a + 1))) || e.kind === "list" && !s(e.item, a + 1));
|
|
55
|
+
if (!e.parameters.every((e) => s(e))) throw Error("Invalid control definition.");
|
|
56
|
+
let c = e.parameters.map((e) => e.id);
|
|
57
|
+
if (new Set(c).size !== c.length || new Set(e.pages.map((e) => e.id)).size !== e.pages.length) throw Error("Control and page IDs must be unique.");
|
|
58
|
+
let l = e.pages;
|
|
59
|
+
if (!Array.isArray(e.bindings) || !e.bindings.every((e) => t(e) && c.includes(String(e.paramId)) && [
|
|
60
|
+
"global",
|
|
61
|
+
"page",
|
|
62
|
+
"element"
|
|
63
|
+
].includes(String(e.scope)) && [
|
|
64
|
+
"css-variable",
|
|
65
|
+
"style",
|
|
66
|
+
"adapter"
|
|
67
|
+
].includes(String(e.kind)) && r(e.property) && (e.scope !== "element" || t(e.target) && r(e.target.id)) && (e.scope !== "page" || l.some((t) => t.id === e.pageId)))) throw Error("Invalid web bindings.");
|
|
68
|
+
return structuredClone(e);
|
|
30
69
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
70
|
+
function o(e) {
|
|
71
|
+
return t(e) && [
|
|
72
|
+
"x",
|
|
73
|
+
"y",
|
|
74
|
+
"width",
|
|
75
|
+
"height"
|
|
76
|
+
].every((t) => Number.isFinite(e[t])) && Number(e.width) >= 0 && Number(e.height) >= 0;
|
|
33
77
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
78
|
+
function s(e) {
|
|
79
|
+
let n = (e) => e === void 0 || t(e) && r(e.id) && (e.instance === void 0 || r(e.instance));
|
|
80
|
+
return t(e) && r(e.key) && typeof e.tag == "string" && n(e.stable) && typeof e.selector == "string" && typeof e.fingerprint == "string" && typeof e.label == "string" && typeof e.pageId == "string" && Array.isArray(e.ancestors) && e.ancestors.every((e) => t(e) && r(e.key) && typeof e.label == "string" && n(e.stable)) && o(e.rect) && (e.clip === void 0 || o(e.clip)) && [
|
|
81
|
+
"resolved",
|
|
82
|
+
"provisional",
|
|
83
|
+
"missing",
|
|
84
|
+
"ambiguous"
|
|
85
|
+
].includes(String(e.status)) && (e.controls === void 0 || Number.isInteger(e.controls) && Number(e.controls) >= 0 && Number(e.controls) <= 1e3);
|
|
37
86
|
}
|
|
38
|
-
|
|
39
|
-
function
|
|
40
|
-
|
|
87
|
+
var c = (e) => typeof e == "string" && /^#[\da-f]{3,8}$/i.test(e);
|
|
88
|
+
function l(e) {
|
|
89
|
+
return t(e) && c(e.outline) && c(e.chip) && c(e.chipText);
|
|
41
90
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
91
|
+
function u(e) {
|
|
92
|
+
return t(e) && typeof e.pageId == "string" && typeof e.url == "string" && t(e.viewport) && [
|
|
93
|
+
"width",
|
|
94
|
+
"height",
|
|
95
|
+
"dpr"
|
|
96
|
+
].every((t) => Number.isFinite(e.viewport[t]) && Number(e.viewport[t]) > 0) && t(e.scroll) && Number.isFinite(e.scroll.x) && Number.isFinite(e.scroll.y) && Array.isArray(e.scrollers) && e.scrollers.length <= 1e3 && e.scrollers.every((e) => t(e) && s(e.target) && Number.isFinite(e.x) && Number.isFinite(e.y));
|
|
44
97
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
98
|
+
function d(e) {
|
|
99
|
+
return t(e) && n(e.id) && [
|
|
100
|
+
"note",
|
|
101
|
+
"arrow",
|
|
102
|
+
"rectangle",
|
|
103
|
+
"ellipse",
|
|
104
|
+
"highlight",
|
|
105
|
+
"pen"
|
|
106
|
+
].includes(String(e.tool)) && typeof e.color == "string" && /^#[\da-f]{6}$/i.test(e.color) && typeof e.width == "number" && e.width > 0 && e.width <= 32 && typeof e.pageId == "string" && t(e.viewport) && Number.isFinite(e.viewport.width) && Number.isFinite(e.viewport.height) && Array.isArray(e.points) && e.points.length <= 1e4 && e.points.every((e) => t(e) && Number.isFinite(e.x) && Number.isFinite(e.y));
|
|
47
107
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
108
|
+
function f(t, n) {
|
|
109
|
+
return {
|
|
110
|
+
channel: e,
|
|
111
|
+
version: 1,
|
|
112
|
+
sessionId: t,
|
|
113
|
+
payload: n
|
|
114
|
+
};
|
|
50
115
|
}
|
|
51
|
-
function
|
|
52
|
-
|
|
116
|
+
function ee(t, n) {
|
|
117
|
+
return {
|
|
118
|
+
channel: e,
|
|
119
|
+
version: 1,
|
|
120
|
+
type: "sdk-present",
|
|
121
|
+
projectId: t,
|
|
122
|
+
instanceId: n
|
|
123
|
+
};
|
|
53
124
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
125
|
+
function te(e) {
|
|
126
|
+
return t(e) && e.channel === "paramrig.web" && typeof e.version == "number" && n(e.sessionId) && t(e.payload) && typeof e.payload.type == "string";
|
|
56
127
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
128
|
+
function ne(e) {
|
|
129
|
+
switch (e.type) {
|
|
130
|
+
case "hello": return n(e.projectId);
|
|
131
|
+
case "values": return i(e.values) && typeof e.source == "boolean";
|
|
132
|
+
case "select": return s(e.target);
|
|
133
|
+
case "reveal-target": return s(e.target);
|
|
134
|
+
case "restore-context": return u(e.context);
|
|
135
|
+
case "navigate": return typeof e.path == "string";
|
|
136
|
+
case "capture": return n(e.requestId);
|
|
137
|
+
case "configure": return (e.chrome === void 0 || l(e.chrome)) && (e.activeMarks === void 0 || Array.isArray(e.activeMarks) && e.activeMarks.every(n)) && (e.activeTargets === void 0 || Array.isArray(e.activeTargets) && e.activeTargets.every((e) => typeof e == "string" && e.length < 2e3)) && (e.displayScale === void 0 || typeof e.displayScale == "number" && e.displayScale >= .05 && e.displayScale <= 4) && [
|
|
138
|
+
"browse",
|
|
139
|
+
"select",
|
|
140
|
+
"annotate"
|
|
141
|
+
].includes(String(e.mode)) && [
|
|
142
|
+
"note",
|
|
143
|
+
"arrow",
|
|
144
|
+
"rectangle",
|
|
145
|
+
"ellipse",
|
|
146
|
+
"highlight",
|
|
147
|
+
"pen"
|
|
148
|
+
].includes(String(e.tool)) && typeof e.color == "string" && /^#[\da-f]{6}$/i.test(e.color) && Array.isArray(e.targets) && e.targets.every(s) && Array.isArray(e.marks) && e.marks.every(d);
|
|
149
|
+
default: return !1;
|
|
150
|
+
}
|
|
78
151
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/web/geometry.ts
|
|
154
|
+
function re(e, t, n) {
|
|
155
|
+
if (!e.targetKey) return e.points.map((e) => ({
|
|
156
|
+
x: e.x - n.x,
|
|
157
|
+
y: e.y - n.y
|
|
158
|
+
}));
|
|
159
|
+
let r = t.find((t) => t.key === e.targetKey);
|
|
160
|
+
return !r || r.status === "missing" || r.status === "ambiguous" ? null : e.points.map((e) => ({
|
|
161
|
+
x: r.rect.x + e.x * r.rect.width,
|
|
162
|
+
y: r.rect.y + e.y * r.rect.height
|
|
163
|
+
}));
|
|
83
164
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
165
|
+
function ie(e, t, n) {
|
|
166
|
+
return t ? {
|
|
167
|
+
x: (e.x - t.rect.x) / Math.max(1, t.rect.width),
|
|
168
|
+
y: (e.y - t.rect.y) / Math.max(1, t.rect.height)
|
|
169
|
+
} : {
|
|
170
|
+
x: e.x + n.x,
|
|
171
|
+
y: e.y + n.y
|
|
172
|
+
};
|
|
86
173
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
174
|
+
function p(e) {
|
|
175
|
+
let t = e.map((e) => e.x), n = e.map((e) => e.y), r = Math.min(...t), i = Math.min(...n);
|
|
176
|
+
return {
|
|
177
|
+
x: r,
|
|
178
|
+
y: i,
|
|
179
|
+
width: Math.max(...t) - r,
|
|
180
|
+
height: Math.max(...n) - i
|
|
181
|
+
};
|
|
90
182
|
}
|
|
91
|
-
function
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
183
|
+
function ae(e, t) {
|
|
184
|
+
let n = t[0], r = t.at(-1);
|
|
185
|
+
if (!n || !r) return "";
|
|
186
|
+
let i = p([n, r]);
|
|
187
|
+
if (e.tool === "rectangle" || e.tool === "highlight") return `M${i.x},${i.y}h${i.width}v${i.height}h${-i.width}Z`;
|
|
188
|
+
if (e.tool === "ellipse") return `M${i.x},${i.y + i.height / 2}a${i.width / 2},${i.height / 2} 0 1 0 ${i.width},0a${i.width / 2},${i.height / 2} 0 1 0 ${-i.width},0`;
|
|
189
|
+
if (e.tool === "note") return `M${n.x - 6},${n.y}a6,6 0 1 0 12,0a6,6 0 1 0 -12,0`;
|
|
190
|
+
if (e.tool === "arrow") {
|
|
191
|
+
let e = Math.atan2(r.y - n.y, r.x - n.x);
|
|
192
|
+
return `M${n.x},${n.y}L${r.x},${r.y}M${r.x - Math.cos(e - .5) * 12},${r.y - Math.sin(e - .5) * 12}L${r.x},${r.y}L${r.x - Math.cos(e + .5) * 12},${r.y - Math.sin(e + .5) * 12}`;
|
|
193
|
+
}
|
|
194
|
+
return t.map((e, t) => `${t ? "L" : "M"}${e.x},${e.y}`).join(" ");
|
|
103
195
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/web/sdk.ts
|
|
198
|
+
var oe = ["http://localhost:5174", "http://127.0.0.1:5174"], se = (e) => {
|
|
199
|
+
try {
|
|
200
|
+
return typeof e == "string" && new URL(e).origin === e;
|
|
201
|
+
} catch {
|
|
202
|
+
return !1;
|
|
203
|
+
}
|
|
204
|
+
}, ce = () => ({ dispose() {} }), m = null, h = {
|
|
205
|
+
px: 1,
|
|
206
|
+
pt: 96 / 72,
|
|
207
|
+
pc: 16,
|
|
208
|
+
in: 96,
|
|
209
|
+
cm: 96 / 2.54,
|
|
210
|
+
mm: 96 / 25.4,
|
|
211
|
+
q: 96 / 101.6
|
|
212
|
+
}, g = {
|
|
213
|
+
s: 1,
|
|
214
|
+
ms: 1 / 1e3
|
|
215
|
+
}, _ = {
|
|
216
|
+
deg: 1,
|
|
217
|
+
grad: .9,
|
|
218
|
+
rad: 180 / Math.PI,
|
|
219
|
+
turn: 360
|
|
220
|
+
};
|
|
221
|
+
function v(e, t, n) {
|
|
222
|
+
if (e in h) return h[e];
|
|
223
|
+
let r = (e) => parseFloat(getComputedStyle(e).fontSize) || 16;
|
|
224
|
+
if (e === "rem") return r(document.documentElement);
|
|
225
|
+
if (e === "em") return r(n === "font-size" && t.parentElement ? t.parentElement : t);
|
|
226
|
+
if (e === "vw") return window.innerWidth / 100;
|
|
227
|
+
if (e === "vh") return window.innerHeight / 100;
|
|
228
|
+
if (e === "vmin") return Math.min(window.innerWidth, window.innerHeight) / 100;
|
|
229
|
+
if (e === "vmax") return Math.max(window.innerWidth, window.innerHeight) / 100;
|
|
123
230
|
}
|
|
124
|
-
function
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
231
|
+
function y(e, t, n, r, i) {
|
|
232
|
+
for (let r of [g, _]) if (t in r && n in r) return e * r[t] / r[n];
|
|
233
|
+
let a = v(t, r, i), o = v(n, r, i);
|
|
234
|
+
return a !== void 0 && o !== void 0 && o > 0 ? e * a / o : void 0;
|
|
128
235
|
}
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
236
|
+
function le(e, t, n) {
|
|
237
|
+
let r = /^(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)([a-z%]*)$/i.exec(e);
|
|
238
|
+
if (!r) {
|
|
239
|
+
let t = parseFloat(e);
|
|
240
|
+
return Number.isFinite(t) ? t : void 0;
|
|
241
|
+
}
|
|
242
|
+
let i = Number(r[1]), a = r[2].toLowerCase(), o = (t.unit ?? "").toLowerCase();
|
|
243
|
+
if (!a || a === o) return i;
|
|
244
|
+
let s = y(i, a, o, n, t.property);
|
|
245
|
+
return s === void 0 ? void 0 : Math.round(s * 1e6) / 1e6;
|
|
139
246
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
247
|
+
function b({ manifest: e, hostOrigin: t = oe, adapters: n = {} }) {
|
|
248
|
+
let r = a(e), i = typeof t == "string" ? [t] : [...t];
|
|
249
|
+
if (!i.length || i.some((e) => !se(e))) return console.warn(`ParamRig: hostOrigin must be one or more workbench origins such as "http://localhost:5174", but is ${JSON.stringify(t)}. The page is left untouched.`), ce();
|
|
250
|
+
if (r.origin !== location.origin) return console.warn(`ParamRig: this page is at ${location.origin} and .paramrig/manifest.json declares ${r.origin}. Open the page at the manifest origin, or set the manifest's "origin" to ${location.origin}. The page is left untouched.`), ce();
|
|
251
|
+
if (window.parent === window) return ce();
|
|
252
|
+
m && (console.warn("ParamRig: connectWeb was called again before the previous connection was disposed. The previous one is replaced; call dispose() in the effect cleanup and in the hot-reload handler."), m.dispose());
|
|
253
|
+
let o = "", s = "", c = crypto.randomUUID(), l = "browse", u = "note", d = "#df7757", p = 1, h, g = [], _ = [], v = [], y = [], b = null, x = null, S = null, C, w, T, E = null, D = null, O = !1, k = !1, A = 0, ue = "", de = "", j = "", fe = [], M = {
|
|
254
|
+
outline: "#488a99",
|
|
255
|
+
chip: "#1e2423",
|
|
256
|
+
chipText: "#eef2f1"
|
|
257
|
+
}, N = document.documentElement.style.touchAction, P = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map(), I = Object.fromEntries(r.parameters.map((e) => [e.id, structuredClone(e.defaultValue)])), L = "http://www.w3.org/2000/svg", R = document.createElement("paramrig-overlay");
|
|
258
|
+
R.tabIndex = -1, R.setAttribute("aria-label", "Page selection. Use arrow keys to select ancestors, children and siblings."), Object.assign(R.style, {
|
|
259
|
+
position: "fixed",
|
|
260
|
+
inset: "0",
|
|
261
|
+
pointerEvents: "none",
|
|
262
|
+
zIndex: "2147483647",
|
|
263
|
+
contain: "strict",
|
|
264
|
+
outline: "none"
|
|
265
|
+
});
|
|
266
|
+
let pe = R.attachShadow({ mode: "closed" }), z = document.createElementNS(L, "svg");
|
|
267
|
+
z.setAttribute("width", "100%"), z.setAttribute("height", "100%"), z.style.overflow = "visible", pe.append(z);
|
|
268
|
+
let B = () => r.pages.find((e) => new URL(e.path, r.origin).pathname === location.pathname)?.id ?? location.pathname, me = (e) => `id:${encodeURIComponent(B())}:${encodeURIComponent(e.id)}:${encodeURIComponent(e.instance ?? "")}`, V = (e) => {
|
|
269
|
+
let t = e.getAttribute("data-paramrig-id");
|
|
270
|
+
if (!t) return;
|
|
271
|
+
let n = e.getAttribute("data-paramrig-instance") ?? e.closest("[data-paramrig-instance]")?.getAttribute("data-paramrig-instance") ?? void 0;
|
|
272
|
+
return {
|
|
273
|
+
id: t,
|
|
274
|
+
...n ? { instance: n } : {}
|
|
275
|
+
};
|
|
276
|
+
}, H = (e, t = !1) => [...document.querySelectorAll(`[data-paramrig-id="${CSS.escape(e.id)}"]`)].filter((n) => !t && e.instance === void 0 || V(n)?.instance === e.instance);
|
|
277
|
+
function he(e) {
|
|
278
|
+
let t = [], n = e;
|
|
279
|
+
for (; n && n !== document.documentElement;) {
|
|
280
|
+
if (n.id && document.querySelectorAll(`#${CSS.escape(n.id)}`).length === 1) {
|
|
281
|
+
t.unshift(`#${CSS.escape(n.id)}`);
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
let e = n.parentElement ? [...n.parentElement.children].filter((e) => e.tagName === n.tagName) : [];
|
|
285
|
+
t.unshift(`${n.localName}:nth-of-type(${e.indexOf(n) + 1})`), n = n.parentElement;
|
|
286
|
+
}
|
|
287
|
+
return t.join(" > ") || "html";
|
|
288
|
+
}
|
|
289
|
+
let ge = (e) => `${e.localName}|${e.getAttribute("role") ?? ""}|${e.getAttribute("aria-label") ?? ""}|${(e.textContent ?? "").trim().replace(/\s+/g, " ").slice(0, 160)}`, _e = (e) => {
|
|
290
|
+
let t = e.replace(/[-_]+/g, " ").trim();
|
|
291
|
+
return t ? t[0].toUpperCase() + t.slice(1) : "";
|
|
292
|
+
}, ve = (e) => {
|
|
293
|
+
let t = e.getAttribute("data-paramrig-label");
|
|
294
|
+
if (t) return t.slice(0, 90);
|
|
295
|
+
let n = e.getAttribute("data-paramrig-id");
|
|
296
|
+
if (n && _e(n)) return _e(n).slice(0, 60);
|
|
297
|
+
let r = e.getAttribute("aria-label");
|
|
298
|
+
return r ? r.slice(0, 90) : ((e.matches("a,button,p,h1,h2,h3,h4,h5,h6,label,span,li,em,strong,small,figcaption,summary,td,th,dt,dd,legend") ? (e.textContent ?? "").trim().replace(/\s+/g, " ") : "") || `Unnamed ${e.localName}`).slice(0, 60);
|
|
299
|
+
}, ye = (e) => {
|
|
300
|
+
let t = V(e);
|
|
301
|
+
return t ? new Set(r.bindings.filter((e) => J(e) && e.scope === "element" && e.target?.id === t.id && (e.target.instance === void 0 || e.target.instance === t.instance)).map((e) => e.paramId)).size : 0;
|
|
302
|
+
};
|
|
303
|
+
function U(e, t = !0) {
|
|
304
|
+
let n = V(e), r = he(e), i = n ? me(n) : `dom:${B()}:${r}`, a = e.getBoundingClientRect(), o = 0, s = 0, c = innerWidth, l = innerHeight;
|
|
305
|
+
for (let t = e.parentElement; t; t = t.parentElement) {
|
|
306
|
+
let e = getComputedStyle(t), n = t.getBoundingClientRect();
|
|
307
|
+
/(auto|scroll|hidden|clip)/.test(e.overflowX) && (o = Math.max(o, n.left), c = Math.min(c, n.right)), /(auto|scroll|hidden|clip)/.test(e.overflowY) && (s = Math.max(s, n.top), l = Math.min(l, n.bottom));
|
|
308
|
+
}
|
|
309
|
+
let u = {
|
|
310
|
+
x: o,
|
|
311
|
+
y: s,
|
|
312
|
+
width: Math.max(0, c - o),
|
|
313
|
+
height: Math.max(0, l - s)
|
|
314
|
+
}, d = e.closest("[data-paramrig-source]")?.getAttribute("data-paramrig-source");
|
|
315
|
+
P.set(i, e);
|
|
316
|
+
let f = [];
|
|
317
|
+
if (t) {
|
|
318
|
+
let t = e.parentElement;
|
|
319
|
+
for (; t && f.length < 12;) {
|
|
320
|
+
let e = V(t), n = e ? me(e) : `dom:${B()}:${he(t)}`;
|
|
321
|
+
P.set(n, t), f.push({
|
|
322
|
+
key: n,
|
|
323
|
+
label: ve(t),
|
|
324
|
+
stable: e
|
|
325
|
+
}), t = t.parentElement;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
key: i,
|
|
330
|
+
stable: n,
|
|
331
|
+
selector: r,
|
|
332
|
+
fingerprint: ge(e),
|
|
333
|
+
label: ve(e),
|
|
334
|
+
tag: e.localName,
|
|
335
|
+
...d ? { source: d } : {},
|
|
336
|
+
pageId: B(),
|
|
337
|
+
rect: {
|
|
338
|
+
x: a.x,
|
|
339
|
+
y: a.y,
|
|
340
|
+
width: a.width,
|
|
341
|
+
height: a.height
|
|
342
|
+
},
|
|
343
|
+
clip: u,
|
|
344
|
+
ancestors: f,
|
|
345
|
+
controls: ye(e),
|
|
346
|
+
status: n ? H(n, !0).length === 1 ? "resolved" : "ambiguous" : "provisional"
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function W(e) {
|
|
350
|
+
if (e.pageId !== B()) return { target: {
|
|
351
|
+
...e,
|
|
352
|
+
status: "missing"
|
|
353
|
+
} };
|
|
354
|
+
if (e.stable) {
|
|
355
|
+
let t = H(e.stable, !0);
|
|
356
|
+
return t.length === 1 ? {
|
|
357
|
+
element: t[0],
|
|
358
|
+
target: {
|
|
359
|
+
...U(t[0]),
|
|
360
|
+
key: e.key
|
|
361
|
+
}
|
|
362
|
+
} : { target: {
|
|
363
|
+
...e,
|
|
364
|
+
status: t.length ? "ambiguous" : "missing"
|
|
365
|
+
} };
|
|
366
|
+
}
|
|
367
|
+
let t = P.get(e.key);
|
|
368
|
+
return t?.isConnected ? {
|
|
369
|
+
element: t,
|
|
370
|
+
target: {
|
|
371
|
+
...U(t),
|
|
372
|
+
key: e.key
|
|
373
|
+
}
|
|
374
|
+
} : { target: {
|
|
375
|
+
...e,
|
|
376
|
+
status: "missing"
|
|
377
|
+
} };
|
|
378
|
+
}
|
|
379
|
+
function be() {
|
|
380
|
+
let e = [...document.querySelectorAll("[data-paramrig-id]")].slice(0, 200), t = `${B()}|${e.map((e) => `${e.getAttribute("data-paramrig-id")}/${V(e)?.instance ?? ""}`).join(",")}`;
|
|
381
|
+
return t !== j && (j = t, fe = e.map((e) => U(e, !1))), fe;
|
|
382
|
+
}
|
|
383
|
+
function G() {
|
|
384
|
+
let e = [];
|
|
385
|
+
for (let t of document.querySelectorAll("[data-paramrig-id]")) (t.scrollTop || t.scrollLeft) && e.push({
|
|
386
|
+
target: U(t, !1),
|
|
387
|
+
x: t.scrollLeft,
|
|
388
|
+
y: t.scrollTop
|
|
389
|
+
});
|
|
390
|
+
return {
|
|
391
|
+
pageId: B(),
|
|
392
|
+
url: location.href,
|
|
393
|
+
viewport: {
|
|
394
|
+
width: innerWidth,
|
|
395
|
+
height: innerHeight,
|
|
396
|
+
dpr: devicePixelRatio
|
|
397
|
+
},
|
|
398
|
+
scroll: {
|
|
399
|
+
x: scrollX,
|
|
400
|
+
y: scrollY
|
|
401
|
+
},
|
|
402
|
+
scrollers: e
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function K(e) {
|
|
406
|
+
o && s && !k && window.parent.postMessage(f(o, e), s);
|
|
407
|
+
}
|
|
408
|
+
function xe() {
|
|
409
|
+
z.replaceChildren(), delete R.dataset.hover;
|
|
410
|
+
let e = (e) => {
|
|
411
|
+
if (!e?.clip) return z;
|
|
412
|
+
let t = document.createElementNS(L, "clipPath"), n = document.createElementNS(L, "rect"), r = `paramrig-clip-${z.childElementCount}`;
|
|
413
|
+
t.id = r;
|
|
414
|
+
for (let t of [
|
|
415
|
+
"x",
|
|
416
|
+
"y",
|
|
417
|
+
"width",
|
|
418
|
+
"height"
|
|
419
|
+
]) n.setAttribute(t, String(e.clip[t]));
|
|
420
|
+
t.append(n), z.append(t);
|
|
421
|
+
let i = document.createElementNS(L, "g");
|
|
422
|
+
return i.setAttribute("clip-path", `url(#${r})`), z.append(i), i;
|
|
423
|
+
}, t = l === "browse" ? [] : [b, ...v.filter((e) => g.includes(e.key))];
|
|
424
|
+
for (let n of t.filter((e) => !!e && !["missing", "ambiguous"].includes(e.status))) {
|
|
425
|
+
let t = e(n), r = document.createElementNS(L, "rect");
|
|
426
|
+
for (let e of [
|
|
427
|
+
"x",
|
|
428
|
+
"y",
|
|
429
|
+
"width",
|
|
430
|
+
"height"
|
|
431
|
+
]) r.setAttribute(e, String(n.rect[e]));
|
|
432
|
+
r.setAttribute("fill", `${M.outline.slice(0, 7)}14`), r.setAttribute("stroke", M.outline), r.setAttribute("stroke-width", "1.5"), t.append(r), n === b && Se(t, n);
|
|
433
|
+
}
|
|
434
|
+
for (let t of [...y.filter((e) => e.id !== S?.id), ...S ? [S] : []]) {
|
|
435
|
+
if (t.pageId !== B()) continue;
|
|
436
|
+
let n = re(t, [...v, ...C ? [C] : []], {
|
|
437
|
+
x: scrollX,
|
|
438
|
+
y: scrollY
|
|
439
|
+
});
|
|
440
|
+
if (!n) continue;
|
|
441
|
+
let r = e(t.targetKey ? [...v, ...C ? [C] : []].find((e) => e.key === t.targetKey) : void 0), i = document.createElementNS(L, "path"), a = l !== "annotate" || _.includes(t.id);
|
|
442
|
+
if (i.setAttribute("d", ae(t, n)), i.setAttribute("stroke", t.color), i.setAttribute("stroke-width", String(t.width)), i.setAttribute("stroke-linecap", "round"), i.setAttribute("stroke-linejoin", "round"), i.setAttribute("fill", t.tool === "highlight" ? `${t.color}33` : t.tool === "note" ? t.color : "none"), r.append(i), a || i.setAttribute("opacity", ".35"), l === "annotate" && a) for (let e of [n[0], n.at(-1)].filter((e) => !!e)) {
|
|
443
|
+
let n = document.createElementNS(L, "circle");
|
|
444
|
+
n.setAttribute("cx", String(e.x)), n.setAttribute("cy", String(e.y)), n.setAttribute("r", "3"), n.setAttribute("fill", t.color), r.append(n);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
function Se(e, t) {
|
|
449
|
+
let n = 1 / Math.max(.05, p), r = 11 * n, i = 18 * n, a = 6 * n, o = t.controls ? `${t.label} · ${t.controls} control${t.controls === 1 ? "" : "s"}` : t.label;
|
|
450
|
+
R.dataset.hover = o;
|
|
451
|
+
let s = document.createElementNS(L, "rect"), c = document.createElementNS(L, "text");
|
|
452
|
+
c.textContent = o, c.setAttribute("font-family", "system-ui, -apple-system, Segoe UI, sans-serif"), c.setAttribute("font-size", String(r)), c.setAttribute("fill", M.chipText), c.setAttribute("dominant-baseline", "central"), e.append(s, c);
|
|
453
|
+
let l = Math.min((c.getComputedTextLength?.() ?? o.length * r * .55) + a * 2, innerWidth), u = Math.max(0, Math.min(innerWidth - l, t.rect.x)), d = t.rect.y - i - 2 * n >= 0 ? t.rect.y - i - 2 * n : Math.min(innerHeight - i, t.rect.y + 2 * n);
|
|
454
|
+
for (let [e, t] of [
|
|
455
|
+
["x", u],
|
|
456
|
+
["y", d],
|
|
457
|
+
["width", l],
|
|
458
|
+
["height", i],
|
|
459
|
+
["rx", 3 * n]
|
|
460
|
+
]) s.setAttribute(e, String(t));
|
|
461
|
+
s.setAttribute("fill", M.chip), s.setAttribute("stroke", M.outline), s.setAttribute("stroke-width", String(n)), c.setAttribute("x", String(u + a)), c.setAttribute("y", String(d + i / 2));
|
|
462
|
+
}
|
|
463
|
+
function Ce() {
|
|
464
|
+
if (A = 0, !o || k) return;
|
|
465
|
+
if (v = v.map((e) => W(e).target), b) {
|
|
466
|
+
let e = P.get(b.key);
|
|
467
|
+
b = e?.isConnected ? U(e) : null;
|
|
468
|
+
}
|
|
469
|
+
let e = JSON.stringify([
|
|
470
|
+
b,
|
|
471
|
+
v,
|
|
472
|
+
g,
|
|
473
|
+
y,
|
|
474
|
+
S,
|
|
475
|
+
l,
|
|
476
|
+
scrollX,
|
|
477
|
+
scrollY
|
|
478
|
+
]);
|
|
479
|
+
e !== de && (xe(), de = e);
|
|
480
|
+
let t = G(), n = be(), r = JSON.stringify([
|
|
481
|
+
t,
|
|
482
|
+
v,
|
|
483
|
+
j
|
|
484
|
+
]);
|
|
485
|
+
r !== ue && (ue = r, K({
|
|
486
|
+
type: "scene",
|
|
487
|
+
context: t,
|
|
488
|
+
targets: v,
|
|
489
|
+
page: n
|
|
490
|
+
})), !document.hidden && (l !== "browse" || y.length > 0 || v.length > 0) && q();
|
|
491
|
+
}
|
|
492
|
+
function q() {
|
|
493
|
+
!A && o && (A = requestAnimationFrame(Ce));
|
|
494
|
+
}
|
|
495
|
+
function we(e) {
|
|
496
|
+
return e.target ? H(e.target) : [document.documentElement];
|
|
497
|
+
}
|
|
498
|
+
function J(e) {
|
|
499
|
+
return !e.pageId || e.pageId === B();
|
|
500
|
+
}
|
|
501
|
+
function Y() {
|
|
502
|
+
for (let [e, t] of F) if (e instanceof HTMLElement || e instanceof SVGElement) for (let [n, r] of t) r.value ? e.style.setProperty(n, r.value, r.priority) : e.style.removeProperty(n);
|
|
503
|
+
F.clear();
|
|
504
|
+
for (let e of Object.values(n)) e.restore();
|
|
505
|
+
}
|
|
506
|
+
function Te() {
|
|
507
|
+
for (let e of r.bindings.filter(J)) {
|
|
508
|
+
let t = r.parameters.find((t) => t.id === e.paramId);
|
|
509
|
+
if (e.kind === "adapter") {
|
|
510
|
+
n[e.property] && (I[e.paramId] = n[e.property].read());
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
let i = we(e)[0];
|
|
514
|
+
if (!i) continue;
|
|
515
|
+
let a = getComputedStyle(i).getPropertyValue(e.property).trim();
|
|
516
|
+
if (a) {
|
|
517
|
+
if (t.kind === "number") {
|
|
518
|
+
let n = le(a, e, i);
|
|
519
|
+
n !== void 0 && (I[t.id] = n);
|
|
520
|
+
} else if (t.kind === "color") {
|
|
521
|
+
if (/^#[\da-f]{6}([\da-f]{2})?$/i.test(a)) {
|
|
522
|
+
I[t.id] = a.toLowerCase();
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
let e = document.createElement("canvas").getContext("2d");
|
|
526
|
+
if (e) {
|
|
527
|
+
e.fillStyle = a, e.fillRect(0, 0, 1, 1);
|
|
528
|
+
let n = e.getImageData(0, 0, 1, 1).data;
|
|
529
|
+
I[t.id] = `#${[...n].slice(0, t.alpha ? 4 : 3).map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
530
|
+
}
|
|
531
|
+
} else I[t.id] = a;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function Ee() {
|
|
536
|
+
if (Y(), !D || O) {
|
|
537
|
+
q();
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
for (let e of r.bindings.filter(J)) {
|
|
541
|
+
let t = D[e.paramId];
|
|
542
|
+
if (t !== void 0 && JSON.stringify(t) !== JSON.stringify(I[e.paramId]) && e.kind === "adapter") {
|
|
543
|
+
if (!n[e.property]) {
|
|
544
|
+
K({
|
|
545
|
+
type: "error",
|
|
546
|
+
message: `Missing adapter: ${e.property}`
|
|
547
|
+
});
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
n[e.property].apply(t);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
De(), q();
|
|
554
|
+
}
|
|
555
|
+
function De() {
|
|
556
|
+
if (D && !O) {
|
|
557
|
+
for (let [e] of F) e.isConnected || F.delete(e);
|
|
558
|
+
for (let e of r.bindings.filter((e) => J(e) && e.kind !== "adapter")) {
|
|
559
|
+
let t = D[e.paramId];
|
|
560
|
+
if (t !== void 0 && JSON.stringify(t) !== JSON.stringify(I[e.paramId]) && (typeof t == "string" || typeof t == "number")) {
|
|
561
|
+
for (let n of we(e)) if (n instanceof HTMLElement || n instanceof SVGElement) {
|
|
562
|
+
let r = F.get(n) ?? /* @__PURE__ */ new Map();
|
|
563
|
+
r.has(e.property) || r.set(e.property, {
|
|
564
|
+
value: n.style.getPropertyValue(e.property),
|
|
565
|
+
priority: n.style.getPropertyPriority(e.property)
|
|
566
|
+
}), F.set(n, r);
|
|
567
|
+
let i = `${t}${e.unit ?? ""}`, a = document.createElement("span").style;
|
|
568
|
+
a.setProperty(e.property, i, "important");
|
|
569
|
+
let o = a.getPropertyValue(e.property);
|
|
570
|
+
o && (n.style.getPropertyValue(e.property) !== o || n.style.getPropertyPriority(e.property) !== a.getPropertyPriority(e.property)) && n.style.setProperty(e.property, o, "important");
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
function Oe() {
|
|
577
|
+
K({
|
|
578
|
+
type: "ready",
|
|
579
|
+
instanceId: c,
|
|
580
|
+
manifest: r,
|
|
581
|
+
sourceValues: I,
|
|
582
|
+
context: G()
|
|
583
|
+
}), q();
|
|
584
|
+
}
|
|
585
|
+
function X(e, t = !1) {
|
|
586
|
+
x = e, b = U(e), K({
|
|
587
|
+
type: "selection",
|
|
588
|
+
target: b,
|
|
589
|
+
additive: t
|
|
590
|
+
}), q();
|
|
591
|
+
}
|
|
592
|
+
async function ke(e) {
|
|
593
|
+
try {
|
|
594
|
+
let { toPng: t } = await import("./es-DC0_iRTj.js");
|
|
595
|
+
K({
|
|
596
|
+
type: "capture",
|
|
597
|
+
requestId: e,
|
|
598
|
+
dataUrl: await t(document.documentElement, {
|
|
599
|
+
filter: (e) => e !== R,
|
|
600
|
+
pixelRatio: 1,
|
|
601
|
+
width: innerWidth,
|
|
602
|
+
height: innerHeight,
|
|
603
|
+
style: {
|
|
604
|
+
transform: `translate(${-scrollX}px, ${-scrollY}px)`,
|
|
605
|
+
transformOrigin: "0 0"
|
|
606
|
+
}
|
|
607
|
+
})
|
|
608
|
+
});
|
|
609
|
+
} catch (t) {
|
|
610
|
+
K({
|
|
611
|
+
type: "capture",
|
|
612
|
+
requestId: e,
|
|
613
|
+
error: t instanceof Error ? t.message : "DOM capture is unavailable."
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
function Ae(e) {
|
|
618
|
+
if (e.source !== window.parent || !te(e.data) || (s ? e.origin !== s : !i.includes(e.origin))) return;
|
|
619
|
+
let t = e.data;
|
|
620
|
+
if (t.payload.type === "hello") {
|
|
621
|
+
if (t.payload.projectId !== r.id) return;
|
|
622
|
+
if (t.version !== 1) {
|
|
623
|
+
window.parent.postMessage(f(t.sessionId, {
|
|
624
|
+
type: "error",
|
|
625
|
+
message: "Incompatible web protocol. Update the project integration."
|
|
626
|
+
}), e.origin);
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
if (s = e.origin, o !== t.sessionId) {
|
|
630
|
+
o = t.sessionId;
|
|
631
|
+
try {
|
|
632
|
+
Y(), Te();
|
|
633
|
+
} catch (e) {
|
|
634
|
+
K({
|
|
635
|
+
type: "error",
|
|
636
|
+
message: `Cannot read the source controls: ${String(e)}`
|
|
637
|
+
});
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
R.isConnected || document.documentElement.append(R);
|
|
641
|
+
}
|
|
642
|
+
Oe();
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
if (t.sessionId !== o || t.version !== 1 || !ne(t.payload)) return;
|
|
646
|
+
let n = t.payload;
|
|
647
|
+
if (n.type === "configure" && ((n.mode !== l || n.tool !== u) && Q(), l = n.mode, p = n.displayScale ?? 1, n.chrome && (M = n.chrome), l === "browse" && (b = null), u = n.tool, d = n.color, v = n.targets, y = n.marks, h = n.activeTarget, g = n.activeTargets ?? (n.activeTarget ? [n.activeTarget] : []), _ = n.activeMarks ?? y.map((e) => e.id), document.documentElement.style.touchAction = l === "annotate" ? "none" : N, q()), n.type === "values") {
|
|
648
|
+
D = n.values, O = n.source;
|
|
649
|
+
try {
|
|
650
|
+
Ee();
|
|
651
|
+
} catch (e) {
|
|
652
|
+
K({
|
|
653
|
+
type: "error",
|
|
654
|
+
message: String(e)
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
if (n.type === "select") {
|
|
659
|
+
let e = W(n.target);
|
|
660
|
+
e.element && (e.element.scrollIntoView({
|
|
661
|
+
block: "nearest",
|
|
662
|
+
inline: "nearest"
|
|
663
|
+
}), X(e.element));
|
|
664
|
+
}
|
|
665
|
+
if (n.type === "reveal-target" && W(n.target).element?.scrollIntoView({
|
|
666
|
+
block: "nearest",
|
|
667
|
+
inline: "nearest"
|
|
668
|
+
}), n.type === "restore-context" && n.context.pageId === B()) {
|
|
669
|
+
for (let e of n.context.scrollers) W(e.target).element?.scrollTo(e.x, e.y);
|
|
670
|
+
window.scrollTo(n.context.scroll.x, n.context.scroll.y), q();
|
|
671
|
+
}
|
|
672
|
+
if (n.type === "navigate") {
|
|
673
|
+
let e = new URL(n.path, r.origin);
|
|
674
|
+
e.origin === r.origin && r.pages.some((e) => e.path === n.path) && location.assign(e);
|
|
675
|
+
}
|
|
676
|
+
n.type === "capture" && ke(n.requestId);
|
|
677
|
+
}
|
|
678
|
+
function Z() {
|
|
679
|
+
return o && l !== "browse";
|
|
680
|
+
}
|
|
681
|
+
function je(e) {
|
|
682
|
+
return e.composedPath().find((e) => e instanceof Element && e !== R && !R.contains(e));
|
|
683
|
+
}
|
|
684
|
+
function Me(e) {
|
|
685
|
+
if (!Z() || e.button !== 0) return;
|
|
686
|
+
e.preventDefault(), e.stopImmediatePropagation();
|
|
687
|
+
let t = je(e);
|
|
688
|
+
if (!t) return;
|
|
689
|
+
if (R.focus({ preventScroll: !0 }), l === "select") {
|
|
690
|
+
X(t, e.shiftKey);
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
let n = {
|
|
694
|
+
x: e.clientX,
|
|
695
|
+
y: e.clientY
|
|
696
|
+
};
|
|
697
|
+
w = void 0;
|
|
698
|
+
for (let t of [...y].reverse().filter((e) => e.pageId === B() && _.includes(e.id))) {
|
|
699
|
+
let r = re(t, v, {
|
|
700
|
+
x: scrollX,
|
|
701
|
+
y: scrollY
|
|
702
|
+
});
|
|
703
|
+
if (!r) continue;
|
|
704
|
+
let i = v.find((e) => e.key === t.targetKey)?.clip;
|
|
705
|
+
if (i && (n.x < i.x || n.y < i.y || n.x > i.x + i.width || n.y > i.y + i.height)) continue;
|
|
706
|
+
let a = (e.pointerType === "touch" ? 22 : 16) / p, o = [0, r.length - 1].find((e) => Math.hypot(r[e].x - n.x, r[e].y - n.y) <= a);
|
|
707
|
+
if (o !== void 0) {
|
|
708
|
+
S = structuredClone(t), w = o, C = v.find((e) => e.key === t.targetKey);
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
if (!S) {
|
|
713
|
+
C = u === "note" ? U(t) : v.find((e) => e.key === h && !["missing", "ambiguous"].includes(e.status));
|
|
714
|
+
let e = ie(n, C, {
|
|
715
|
+
x: scrollX,
|
|
716
|
+
y: scrollY
|
|
717
|
+
});
|
|
718
|
+
S = {
|
|
719
|
+
id: crypto.randomUUID(),
|
|
720
|
+
tool: u,
|
|
721
|
+
color: d,
|
|
722
|
+
width: 2,
|
|
723
|
+
points: [e, e],
|
|
724
|
+
targetKey: C?.key,
|
|
725
|
+
pageId: B(),
|
|
726
|
+
viewport: {
|
|
727
|
+
width: innerWidth,
|
|
728
|
+
height: innerHeight
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
T = e.pointerId, E = t;
|
|
733
|
+
try {
|
|
734
|
+
t.setPointerCapture(e.pointerId);
|
|
735
|
+
} catch {}
|
|
736
|
+
q();
|
|
737
|
+
}
|
|
738
|
+
function Ne(e) {
|
|
739
|
+
if (Z()) {
|
|
740
|
+
if (S && e.pointerId === T) {
|
|
741
|
+
e.preventDefault(), e.stopImmediatePropagation();
|
|
742
|
+
let t = ie({
|
|
743
|
+
x: e.clientX,
|
|
744
|
+
y: e.clientY
|
|
745
|
+
}, C, {
|
|
746
|
+
x: scrollX,
|
|
747
|
+
y: scrollY
|
|
748
|
+
});
|
|
749
|
+
w === void 0 ? S.tool === "pen" ? S.points.length < 1e4 && S.points.push(t) : S.points[S.points.length - 1] = t : S.points[w] = t;
|
|
750
|
+
} else {
|
|
751
|
+
let t = je(e);
|
|
752
|
+
b = t ? U(t) : null;
|
|
753
|
+
}
|
|
754
|
+
q();
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
function Pe(e) {
|
|
758
|
+
Z() && (e.preventDefault(), e.stopImmediatePropagation(), S && e.pointerId === T && (K({
|
|
759
|
+
type: "mark",
|
|
760
|
+
mark: S,
|
|
761
|
+
target: C,
|
|
762
|
+
context: G()
|
|
763
|
+
}), y = [...y.filter((e) => e.id !== S.id), S], Q()));
|
|
764
|
+
}
|
|
765
|
+
function Q() {
|
|
766
|
+
if (E && T !== void 0) try {
|
|
767
|
+
E.releasePointerCapture(T);
|
|
768
|
+
} catch {}
|
|
769
|
+
S = null, T = void 0, E = null, C = void 0, w = void 0, q();
|
|
770
|
+
}
|
|
771
|
+
function $(e) {
|
|
772
|
+
Z() && !e.relatedTarget && b && (b = null, q());
|
|
773
|
+
}
|
|
774
|
+
function Fe() {
|
|
775
|
+
Q(), b && (b = null, q());
|
|
776
|
+
}
|
|
777
|
+
function Ie(e) {
|
|
778
|
+
Z() && (e.preventDefault(), e.stopImmediatePropagation());
|
|
779
|
+
}
|
|
780
|
+
function Le(e) {
|
|
781
|
+
if (!Z()) return;
|
|
782
|
+
if (e.key === "Escape") {
|
|
783
|
+
Q(), b = null, l = "browse", document.documentElement.style.touchAction = N, K({ type: "exit-tool" }), q(), e.preventDefault();
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
if (e.key.toLowerCase() === "c" && !e.metaKey && !e.ctrlKey && !e.altKey && x?.isConnected) {
|
|
787
|
+
e.preventDefault(), e.stopImmediatePropagation(), K({
|
|
788
|
+
type: "comment",
|
|
789
|
+
target: U(x)
|
|
790
|
+
});
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
if ((e.metaKey || e.ctrlKey) && ["z", "y"].includes(e.key.toLowerCase())) {
|
|
794
|
+
e.preventDefault(), e.stopImmediatePropagation(), K({
|
|
795
|
+
type: "history",
|
|
796
|
+
direction: e.shiftKey || e.key === "y" ? "redo" : "undo"
|
|
797
|
+
});
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
let t = x?.isConnected ? x : document.body, n = e.key === "ArrowUp" ? t.parentElement : e.key === "ArrowDown" ? t.firstElementChild : e.key === "ArrowRight" ? t.nextElementSibling : e.key === "ArrowLeft" ? t.previousElementSibling : null;
|
|
801
|
+
n && n !== R && (e.preventDefault(), e.stopImmediatePropagation(), X(n)), e.key === "Enter" && (e.preventDefault(), X(t));
|
|
802
|
+
}
|
|
803
|
+
let Re = new MutationObserver((e) => {
|
|
804
|
+
o && !e.every((e) => e.target === R || R.contains(e.target)) && (De(), q());
|
|
805
|
+
});
|
|
806
|
+
Re.observe(document.documentElement, {
|
|
807
|
+
subtree: !0,
|
|
808
|
+
childList: !0,
|
|
809
|
+
attributes: !0,
|
|
810
|
+
characterData: !0
|
|
811
|
+
});
|
|
812
|
+
let ze = new ResizeObserver(q);
|
|
813
|
+
ze.observe(document.documentElement), window.addEventListener("message", Ae), window.addEventListener("scroll", q, !0), window.addEventListener("resize", q), window.addEventListener("pointerdown", Me, !0), window.addEventListener("pointermove", Ne, !0), window.addEventListener("pointerup", Pe, !0), window.addEventListener("pointercancel", Q, !0), window.addEventListener("click", Ie, !0), window.addEventListener("keydown", Le, !0), window.addEventListener("blur", Fe), window.addEventListener("pointerout", $, !0), window.addEventListener("pointerleave", $, !0), window.parent.postMessage(ee(r.id, c), (() => {
|
|
814
|
+
let e = location.ancestorOrigins?.[0];
|
|
815
|
+
if (se(e)) return e;
|
|
816
|
+
try {
|
|
817
|
+
return document.referrer ? new URL(document.referrer).origin : void 0;
|
|
818
|
+
} catch {
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
})() ?? "*");
|
|
822
|
+
let Be = B(), Ve = setInterval(() => {
|
|
823
|
+
o && (Be !== B() && (Be = B(), Y(), Te(), Ee(), Oe()), q());
|
|
824
|
+
}, 750), He = { dispose() {
|
|
825
|
+
m === He && (m = null), k = !0, Q(), Y(), document.documentElement.style.touchAction = N, R.remove(), Re.disconnect(), ze.disconnect(), clearInterval(Ve), cancelAnimationFrame(A), window.removeEventListener("message", Ae), window.removeEventListener("scroll", q, !0), window.removeEventListener("resize", q), window.removeEventListener("pointerdown", Me, !0), window.removeEventListener("pointermove", Ne, !0), window.removeEventListener("pointerup", Pe, !0), window.removeEventListener("pointercancel", Q, !0), window.removeEventListener("click", Ie, !0), window.removeEventListener("keydown", Le, !0), window.removeEventListener("blur", Fe), window.removeEventListener("pointerout", $, !0), window.removeEventListener("pointerleave", $, !0);
|
|
826
|
+
} };
|
|
827
|
+
return m = He, He;
|
|
528
828
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
St as connectWeb,
|
|
532
|
-
lt as parseManifest
|
|
533
|
-
};
|
|
829
|
+
//#endregion
|
|
830
|
+
export { oe as DEFAULT_HOST_ORIGINS, b as connectWeb, a as parseManifest };
|