@mirage-engine/core 0.3.8 → 0.3.10
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/CHANGELOG.md +15 -0
- package/dist/mirage-engine.js +552 -523
- package/dist/mirage-engine.umd.js +13 -13
- package/package.json +3 -3
- package/src/dom/Extractor.ts +1 -0
- package/src/renderer/Renderer.ts +57 -3
package/dist/mirage-engine.js
CHANGED
|
@@ -10,21 +10,21 @@ var ae = (s, e, t) => e in s ? Be(s, e, { enumerable: !0, configurable: !0, writ
|
|
|
10
10
|
Ne.call(e, t) && ae(s, t, e[t]);
|
|
11
11
|
return s;
|
|
12
12
|
}, be = (s, e) => Oe(s, Fe(e));
|
|
13
|
-
var
|
|
13
|
+
var g = (s, e, t) => (ae(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
14
|
var we = (s, e, t) => new Promise((r, i) => {
|
|
15
|
-
var
|
|
15
|
+
var l = (a) => {
|
|
16
16
|
try {
|
|
17
|
-
o(t.next(
|
|
18
|
-
} catch (
|
|
19
|
-
i(
|
|
17
|
+
o(t.next(a));
|
|
18
|
+
} catch (c) {
|
|
19
|
+
i(c);
|
|
20
20
|
}
|
|
21
|
-
}, n = (
|
|
21
|
+
}, n = (a) => {
|
|
22
22
|
try {
|
|
23
|
-
o(t.throw(
|
|
24
|
-
} catch (
|
|
25
|
-
i(
|
|
23
|
+
o(t.throw(a));
|
|
24
|
+
} catch (c) {
|
|
25
|
+
i(c);
|
|
26
26
|
}
|
|
27
|
-
}, o = (
|
|
27
|
+
}, o = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(l, n);
|
|
28
28
|
o((t = t.apply(s, e)).next());
|
|
29
29
|
});
|
|
30
30
|
import * as y from "three";
|
|
@@ -34,7 +34,7 @@ const Re = {
|
|
|
34
34
|
INCLUDE_SELF: "include-self",
|
|
35
35
|
EXCLUDE_SELF: "exclude-self",
|
|
36
36
|
END: "end"
|
|
37
|
-
},
|
|
37
|
+
}, G = {
|
|
38
38
|
NAME: "data-mirage-dom",
|
|
39
39
|
KEY: "mirageDom",
|
|
40
40
|
VALUES: {
|
|
@@ -54,20 +54,20 @@ const Re = {
|
|
|
54
54
|
CAPTURE_8: "8",
|
|
55
55
|
CAPTURE_9: "9",
|
|
56
56
|
CAPTURE_10: "10"
|
|
57
|
-
},
|
|
57
|
+
}, O = {
|
|
58
58
|
NAME: "data-mirage-travel",
|
|
59
59
|
KEY: "mirageTravel",
|
|
60
60
|
VALUES: xe,
|
|
61
61
|
MAX_LAYERS: Object.keys(xe).length - 1
|
|
62
|
-
},
|
|
62
|
+
}, z = {
|
|
63
63
|
NAME: "data-mirage-filter",
|
|
64
64
|
KEY: "mirageFilter",
|
|
65
65
|
VALUES: Re
|
|
66
|
-
},
|
|
66
|
+
}, W = {
|
|
67
67
|
NAME: "data-mirage-select",
|
|
68
68
|
KEY: "mirageSelect",
|
|
69
69
|
VALUES: Re
|
|
70
|
-
},
|
|
70
|
+
}, Xe = {
|
|
71
71
|
NAME: "data-mirage-shader",
|
|
72
72
|
KEY: "mirageShader"
|
|
73
73
|
}, at = {
|
|
@@ -76,7 +76,7 @@ const Re = {
|
|
|
76
76
|
VALUES: {
|
|
77
77
|
FRONT: "front"
|
|
78
78
|
}
|
|
79
|
-
}, re = 0, $ = 1, Z = 2,
|
|
79
|
+
}, re = 0, $ = 1, Z = 2, ze = 4, ie = 8, ce = 16;
|
|
80
80
|
function Ve(s) {
|
|
81
81
|
const e = s.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
82
82
|
return e ? {
|
|
@@ -99,32 +99,32 @@ function Ye(s) {
|
|
|
99
99
|
}
|
|
100
100
|
class We {
|
|
101
101
|
constructor(e, t) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
102
|
+
g(this, "target");
|
|
103
|
+
g(this, "observer");
|
|
104
|
+
g(this, "pendingDeletions", /* @__PURE__ */ new Set());
|
|
105
|
+
g(this, "pendingStyles", /* @__PURE__ */ new Map());
|
|
106
|
+
g(this, "isDomDirty", !1);
|
|
107
|
+
g(this, "isRunning", !1);
|
|
108
|
+
g(this, "pendingMask", re);
|
|
109
|
+
g(this, "mutationTimer", null);
|
|
110
|
+
g(this, "cssTimer", null);
|
|
111
|
+
g(this, "resizeConfig");
|
|
112
|
+
g(this, "resizeTimer", null);
|
|
113
|
+
g(this, "isResizing", !1);
|
|
114
|
+
g(this, "lastScrollX", 0);
|
|
115
|
+
g(this, "lastScrollY", 0);
|
|
116
|
+
g(this, "scrollTimer", null);
|
|
117
|
+
g(this, "onBeforeRender", /* @__PURE__ */ new Set());
|
|
118
|
+
g(this, "onLayoutChange", /* @__PURE__ */ new Set());
|
|
119
|
+
g(this, "onStyleChange", /* @__PURE__ */ new Set());
|
|
120
|
+
g(this, "onScrollChange", /* @__PURE__ */ new Set());
|
|
121
|
+
g(this, "onRender", /* @__PURE__ */ new Set());
|
|
122
|
+
g(this, "onTransitionFinished", (e) => {
|
|
123
123
|
this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= $ | Z, this.cssTimer = window.setTimeout(() => {
|
|
124
124
|
this.isDomDirty = !0, this.cssTimer = null;
|
|
125
125
|
}, 50)));
|
|
126
126
|
});
|
|
127
|
-
|
|
127
|
+
g(this, "onWindowResize", () => {
|
|
128
128
|
if (!this.resizeConfig.enabled) {
|
|
129
129
|
this.isDomDirty = !0;
|
|
130
130
|
return;
|
|
@@ -133,7 +133,7 @@ class We {
|
|
|
133
133
|
this.isDomDirty = !0, this.resizeConfig.onEnd && this.resizeConfig.onEnd(), this.isResizing = !1, this.resizeTimer = null;
|
|
134
134
|
}, this.resizeConfig.delay);
|
|
135
135
|
});
|
|
136
|
-
|
|
136
|
+
g(this, "renderLoop", () => {
|
|
137
137
|
if (!this.isRunning)
|
|
138
138
|
return;
|
|
139
139
|
this.onBeforeRender.forEach((r) => r()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((r) => r(this.pendingMask, this.pendingDeletions)), this.pendingDeletions.clear(), this.pendingMask = re);
|
|
@@ -142,30 +142,30 @@ class We {
|
|
|
142
142
|
this.pendingMask |= $, this.isDomDirty = !0, this.scrollTimer = null;
|
|
143
143
|
}, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((r) => r(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((r) => r()), requestAnimationFrame(this.renderLoop);
|
|
144
144
|
});
|
|
145
|
-
var i,
|
|
145
|
+
var i, l;
|
|
146
146
|
this.target = e;
|
|
147
147
|
const r = (i = t.resizeDebounce) != null ? i : !0;
|
|
148
148
|
r === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : r === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
|
|
149
149
|
enabled: !0,
|
|
150
|
-
delay: (
|
|
150
|
+
delay: (l = r.delay) != null ? l : 150,
|
|
151
151
|
onStart: r.onStart,
|
|
152
152
|
onEnd: r.onEnd
|
|
153
153
|
}, this.observer = new MutationObserver((n) => {
|
|
154
154
|
let o = re;
|
|
155
|
-
for (const
|
|
156
|
-
if (
|
|
157
|
-
o |= ie,
|
|
158
|
-
|
|
155
|
+
for (const a of n)
|
|
156
|
+
if (a.type === "childList")
|
|
157
|
+
o |= ie, a.removedNodes.length > 0 && a.removedNodes.forEach((c) => {
|
|
158
|
+
c instanceof HTMLElement && this.pendingDeletions.add(c);
|
|
159
159
|
});
|
|
160
|
-
else if (
|
|
161
|
-
if (
|
|
160
|
+
else if (a.type === "attributes")
|
|
161
|
+
if (a.attributeName === "style") {
|
|
162
162
|
o |= $ | Z;
|
|
163
|
-
const
|
|
164
|
-
this.pendingStyles.set(
|
|
163
|
+
const c = a.target, d = Ye(c.style);
|
|
164
|
+
this.pendingStyles.set(c, d);
|
|
165
165
|
} else
|
|
166
|
-
|
|
166
|
+
a.attributeName === "class" ? o |= $ | Z : a.attributeName && a.attributeName.startsWith("data-") && (o |= $ | Z, a.attributeName.startsWith("data-mirage") && (o |= ie));
|
|
167
167
|
else
|
|
168
|
-
|
|
168
|
+
a.type === "characterData" && (o |= ce | $);
|
|
169
169
|
if (o !== re) {
|
|
170
170
|
if (this.pendingMask |= o, o & ie) {
|
|
171
171
|
this.clearTimers(), this.isDomDirty = !0;
|
|
@@ -192,12 +192,12 @@ class We {
|
|
|
192
192
|
this.mutationTimer && (clearTimeout(this.mutationTimer), this.mutationTimer = null), this.cssTimer && (clearTimeout(this.cssTimer), this.cssTimer = null), this.scrollTimer && (clearTimeout(this.scrollTimer), this.scrollTimer = null);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
const
|
|
195
|
+
const H = 1, K = 2, ct = 0, U = {
|
|
196
196
|
BASE: 0,
|
|
197
197
|
SELECTED: 1,
|
|
198
198
|
getCaptureLayer: (s) => 31 - s,
|
|
199
199
|
HIDDEN: 31
|
|
200
|
-
}, Ee = Object.values(
|
|
200
|
+
}, Ee = Object.values(z.VALUES);
|
|
201
201
|
class Le {
|
|
202
202
|
/**
|
|
203
203
|
* Calculates or retrieves the exact alphabetic baseline (in pixels) for the given font.
|
|
@@ -215,51 +215,51 @@ class Le {
|
|
|
215
215
|
return 0;
|
|
216
216
|
const t = document.createElement("div"), r = document.createElement("span"), i = document.createElement("img");
|
|
217
217
|
t.style.visibility = "hidden", t.style.position = "absolute", t.style.top = "0px", t.style.left = "0px", t.style.font = e, t.style.margin = "0", t.style.padding = "0", t.style.border = "none", r.style.margin = "0", r.style.padding = "0", r.style.border = "none", r.style.lineHeight = "normal", i.width = 1, i.height = 1, i.style.verticalAlign = "baseline", r.appendChild(document.createTextNode("Hidden Text")), t.appendChild(r), t.appendChild(i), document.body.appendChild(t);
|
|
218
|
-
const
|
|
219
|
-
return document.body.removeChild(t),
|
|
218
|
+
const l = i.offsetTop - r.offsetTop;
|
|
219
|
+
return document.body.removeChild(t), l;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
|
|
222
|
+
g(Le, "cache", /* @__PURE__ */ new Map());
|
|
223
223
|
class He extends y.MeshBasicMaterial {
|
|
224
|
-
constructor(t, r, i,
|
|
224
|
+
constructor(t, r, i, l, n = 2) {
|
|
225
225
|
super({
|
|
226
226
|
transparent: !0,
|
|
227
227
|
side: y.FrontSide,
|
|
228
228
|
color: 16777215
|
|
229
229
|
});
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
g(this, "canvas");
|
|
231
|
+
g(this, "ctx");
|
|
232
|
+
g(this, "qualityFactor");
|
|
233
233
|
if (this.canvas = document.createElement("canvas"), this.ctx = this.canvas.getContext("2d"), !this.ctx)
|
|
234
234
|
throw new Error("[Mirage] Failed to create canvas context");
|
|
235
|
-
this.qualityFactor = n, this.map = new y.CanvasTexture(this.canvas), this.map.colorSpace = y.LinearSRGBColorSpace, this.map.minFilter = y.LinearFilter, this.map.magFilter = y.LinearFilter, this.updateText(t, r, i,
|
|
235
|
+
this.qualityFactor = n, this.map = new y.CanvasTexture(this.canvas), this.map.colorSpace = y.LinearSRGBColorSpace, this.map.minFilter = y.LinearFilter, this.map.magFilter = y.LinearFilter, this.updateText(t, r, i, l);
|
|
236
236
|
}
|
|
237
237
|
wrapText(t, r) {
|
|
238
238
|
const i = t.split(`
|
|
239
|
-
`),
|
|
239
|
+
`), l = [];
|
|
240
240
|
return i.forEach((n) => {
|
|
241
241
|
const o = n.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
242
242
|
if (o.length === 0) {
|
|
243
|
-
|
|
243
|
+
l.push("");
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
|
-
let
|
|
247
|
-
for (let
|
|
248
|
-
const d = o[
|
|
249
|
-
this.ctx.measureText(
|
|
246
|
+
let a = o[0];
|
|
247
|
+
for (let c = 1; c < o.length; c++) {
|
|
248
|
+
const d = o[c];
|
|
249
|
+
this.ctx.measureText(a + d).width <= r + 2 ? a += d : (a && l.push(a), a = d.trimStart());
|
|
250
250
|
}
|
|
251
|
-
|
|
252
|
-
}),
|
|
251
|
+
a && l.push(a);
|
|
252
|
+
}), l;
|
|
253
253
|
}
|
|
254
|
-
updateText(t, r, i,
|
|
254
|
+
updateText(t, r, i, l, n) {
|
|
255
255
|
n !== void 0 && (this.qualityFactor = n);
|
|
256
|
-
const
|
|
257
|
-
this.canvas.width !==
|
|
256
|
+
const a = (window.devicePixelRatio || 1) * this.qualityFactor, c = i * a, d = l * a;
|
|
257
|
+
this.canvas.width !== c || this.canvas.height !== d ? (this.canvas.width = c, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(a, 0, 0, a, 0, 0), this.ctx.font = r.font, this.ctx.fillStyle = r.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
|
|
258
258
|
const h = this.wrapText(t, i), u = r.lineHeight, p = Le.getBaseline(r.font);
|
|
259
|
-
h.forEach((
|
|
260
|
-
const
|
|
261
|
-
let
|
|
262
|
-
r.textAlign === "center" ?
|
|
259
|
+
h.forEach((f, m) => {
|
|
260
|
+
const b = m * u + p;
|
|
261
|
+
let R = 0;
|
|
262
|
+
r.textAlign === "center" ? R = i / 2 : r.textAlign === "right" && (R = i), this.ctx.textAlign = r.textAlign, this.ctx.fillText(f, R, b);
|
|
263
263
|
}), this.map && (this.map.needsUpdate = !0);
|
|
264
264
|
}
|
|
265
265
|
dispose() {
|
|
@@ -279,8 +279,8 @@ function ee(s) {
|
|
|
279
279
|
/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
|
|
280
280
|
);
|
|
281
281
|
if (e) {
|
|
282
|
-
const t = parseInt(e[1], 10), r = parseInt(e[2], 10), i = parseInt(e[3], 10),
|
|
283
|
-
return { color: new y.Color(`rgb(${t}, ${r}, ${i})`), alpha:
|
|
282
|
+
const t = parseInt(e[1], 10), r = parseInt(e[2], 10), i = parseInt(e[3], 10), l = e[4] !== void 0 ? parseFloat(e[4]) : 1;
|
|
283
|
+
return { color: new y.Color(`rgb(${t}, ${r}, ${i})`), alpha: l };
|
|
284
284
|
}
|
|
285
285
|
return { color: new y.Color(s), alpha: 1 };
|
|
286
286
|
}
|
|
@@ -288,16 +288,16 @@ function Pe(s) {
|
|
|
288
288
|
const e = [];
|
|
289
289
|
let t = "", r = 0;
|
|
290
290
|
for (let i = 0; i < s.length; i++) {
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
291
|
+
const l = s[i];
|
|
292
|
+
if (l === "(")
|
|
293
293
|
r++;
|
|
294
|
-
else if (
|
|
294
|
+
else if (l === ")")
|
|
295
295
|
r--;
|
|
296
|
-
else if (
|
|
296
|
+
else if (l === "," && r === 0) {
|
|
297
297
|
e.push(t.trim()), t = "";
|
|
298
298
|
continue;
|
|
299
299
|
}
|
|
300
|
-
t +=
|
|
300
|
+
t += l;
|
|
301
301
|
}
|
|
302
302
|
return t && e.push(t.trim()), e;
|
|
303
303
|
}
|
|
@@ -308,21 +308,21 @@ function Ge(s) {
|
|
|
308
308
|
if (!e)
|
|
309
309
|
return null;
|
|
310
310
|
const t = e[1], r = Pe(t);
|
|
311
|
-
let i = Math.PI,
|
|
311
|
+
let i = Math.PI, l = 0;
|
|
312
312
|
const n = r[0].trim();
|
|
313
313
|
if (n.startsWith("to "))
|
|
314
|
-
n === "to top" ? i = 0 : n === "to right" ? i = Math.PI / 2 : n === "to bottom" ? i = Math.PI : n === "to left" ? i = Math.PI * 1.5 : n === "to top right" || n === "to right top" ? i = Math.PI / 4 : n === "to bottom right" || n === "to right bottom" ? i = Math.PI * 0.75 : n === "to bottom left" || n === "to left bottom" ? i = Math.PI * 1.25 : (n === "to top left" || n === "to left top") && (i = Math.PI * 1.75),
|
|
314
|
+
n === "to top" ? i = 0 : n === "to right" ? i = Math.PI / 2 : n === "to bottom" ? i = Math.PI : n === "to left" ? i = Math.PI * 1.5 : n === "to top right" || n === "to right top" ? i = Math.PI / 4 : n === "to bottom right" || n === "to right bottom" ? i = Math.PI * 0.75 : n === "to bottom left" || n === "to left bottom" ? i = Math.PI * 1.25 : (n === "to top left" || n === "to left top") && (i = Math.PI * 1.75), l = 1;
|
|
315
315
|
else if (n.endsWith("deg") || n.endsWith("rad") || n.endsWith("turn")) {
|
|
316
|
-
const
|
|
317
|
-
n.endsWith("deg") ? i =
|
|
316
|
+
const a = parseFloat(n);
|
|
317
|
+
n.endsWith("deg") ? i = a * (Math.PI / 180) : n.endsWith("rad") ? i = a : n.endsWith("turn") && (i = a * Math.PI * 2), l = 1;
|
|
318
318
|
}
|
|
319
319
|
const o = [];
|
|
320
|
-
for (let
|
|
321
|
-
const
|
|
322
|
-
let h =
|
|
323
|
-
if (d !== -1 && !
|
|
324
|
-
const
|
|
325
|
-
(
|
|
320
|
+
for (let a = l; a < r.length && !(o.length >= 8); a++) {
|
|
321
|
+
const c = r[a].trim(), d = c.lastIndexOf(" ");
|
|
322
|
+
let h = c, u = null;
|
|
323
|
+
if (d !== -1 && !c.endsWith(")")) {
|
|
324
|
+
const f = c.substring(d + 1);
|
|
325
|
+
(f.endsWith("%") || f.endsWith("px") || !isNaN(parseFloat(f))) && (h = c.substring(0, d).trim(), u = f);
|
|
326
326
|
}
|
|
327
327
|
const p = ee(h);
|
|
328
328
|
o.push({
|
|
@@ -333,19 +333,19 @@ function Ge(s) {
|
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
335
|
if (o.length > 0) {
|
|
336
|
-
for (let
|
|
337
|
-
o[
|
|
336
|
+
for (let c = 0; c < o.length; c++)
|
|
337
|
+
o[c].rawStop !== null && (o[c].stop = parseFloat(o[c].rawStop) / 100);
|
|
338
338
|
o[0].rawStop === null && (o[0].stop = 0), o.length > 1 && o[o.length - 1].rawStop === null && (o[o.length - 1].stop = 1);
|
|
339
|
-
let
|
|
340
|
-
for (let
|
|
341
|
-
if (o[
|
|
342
|
-
const d =
|
|
339
|
+
let a = 0;
|
|
340
|
+
for (let c = 1; c < o.length; c++)
|
|
341
|
+
if (o[c].rawStop !== null || c === o.length - 1) {
|
|
342
|
+
const d = c - a;
|
|
343
343
|
if (d > 1) {
|
|
344
|
-
const h = o[
|
|
345
|
-
for (let
|
|
346
|
-
o[
|
|
344
|
+
const h = o[a].stop, p = (o[c].stop - h) / d;
|
|
345
|
+
for (let f = 1; f < d; f++)
|
|
346
|
+
o[a + f].stop = h + p * f;
|
|
347
347
|
}
|
|
348
|
-
|
|
348
|
+
a = c;
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
return { angle: i, stops: o };
|
|
@@ -512,43 +512,43 @@ baseColor = blendSrcOver(baseColor, texColor);`, Ce = {
|
|
|
512
512
|
baseColorChunk: Je
|
|
513
513
|
};
|
|
514
514
|
function Qe(s, e, t, r = null, i) {
|
|
515
|
-
var
|
|
516
|
-
const
|
|
515
|
+
var x;
|
|
516
|
+
const l = r !== null || !!s.imageSrc;
|
|
517
517
|
let n = "";
|
|
518
518
|
const o = {};
|
|
519
519
|
if (i != null && i.uniforms)
|
|
520
|
-
for (const [C,
|
|
521
|
-
typeof
|
|
522
|
-
`, o[C] = { value:
|
|
523
|
-
`, o[C] = { value: new y.Vector2(...
|
|
524
|
-
`, o[C] = { value: new y.Vector3(...
|
|
525
|
-
`, o[C] = { value: new y.Vector4(...
|
|
526
|
-
`, o[C] = { value:
|
|
527
|
-
const
|
|
520
|
+
for (const [C, w] of Object.entries(i.uniforms))
|
|
521
|
+
typeof w == "number" ? (n += `uniform float ${C};
|
|
522
|
+
`, o[C] = { value: w }) : Array.isArray(w) ? w.length === 2 ? (n += `uniform vec2 ${C};
|
|
523
|
+
`, o[C] = { value: new y.Vector2(...w) }) : w.length === 3 ? (n += `uniform vec3 ${C};
|
|
524
|
+
`, o[C] = { value: new y.Vector3(...w) }) : w.length === 4 && (n += `uniform vec4 ${C};
|
|
525
|
+
`, o[C] = { value: new y.Vector4(...w) }) : (n += `uniform float ${C};
|
|
526
|
+
`, o[C] = { value: w });
|
|
527
|
+
const a = i !== void 0, c = (l || a ? Te.declChunk : "") + `
|
|
528
528
|
` + n, d = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
|
|
529
529
|
`, h = s.isTraveler ? `vec2 resultUv = screenUv;
|
|
530
530
|
` : `vec2 resultUv = vUv * uTextureRepeat + uTextureOffset;
|
|
531
|
-
`, u =
|
|
531
|
+
`, u = l || a ? d + h + ((i == null ? void 0 : i.uvModifier) || "") : "", p = l || a ? Te.baseColorChunk : "", f = (i == null ? void 0 : i.colorModifier) || "", m = Ce.fragmentShader.replace("#INJECT_DECLARATIONS", c).replace("#INJECT_UV_MODIFIER", u).replace("#INJECT_BASE_COLOR", p).replace("#INJECT_COLOR_MODIFIER", f), b = ee(s.backgroundColor), R = ee(s.borderColor), L = {
|
|
532
532
|
uSize: { value: new y.Vector2(e, t) },
|
|
533
533
|
uBgColor: {
|
|
534
534
|
value: new y.Vector4(
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
535
|
+
b.color.r,
|
|
536
|
+
b.color.g,
|
|
537
|
+
b.color.b,
|
|
538
|
+
b.alpha
|
|
539
539
|
)
|
|
540
540
|
},
|
|
541
541
|
uBorderColor: {
|
|
542
542
|
value: new y.Vector4(
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
543
|
+
R.color.r,
|
|
544
|
+
R.color.g,
|
|
545
|
+
R.color.b,
|
|
546
|
+
R.alpha
|
|
547
547
|
)
|
|
548
548
|
},
|
|
549
549
|
uBorderRadius: { value: new y.Vector4(0, 0, 0, 0) },
|
|
550
550
|
uBorderWidth: { value: J(s.borderWidth) },
|
|
551
|
-
uOpacity: { value: (
|
|
551
|
+
uOpacity: { value: (x = s.opacity) != null ? x : 1 },
|
|
552
552
|
uTexture: { value: null },
|
|
553
553
|
uTextureRepeat: { value: new y.Vector2(1, 1) },
|
|
554
554
|
uTextureOffset: { value: new y.Vector2(0, 0) },
|
|
@@ -559,24 +559,24 @@ function Qe(s, e, t, r = null, i) {
|
|
|
559
559
|
},
|
|
560
560
|
uGradientStops: { value: new Float32Array(8) }
|
|
561
561
|
};
|
|
562
|
-
Me(
|
|
563
|
-
const
|
|
564
|
-
uniforms: q(q({},
|
|
562
|
+
Me(L.uBorderRadius.value, s.borderRadius, Math.min(e, t)), l && (L.uTexture.value = r);
|
|
563
|
+
const T = new y.ShaderMaterial({
|
|
564
|
+
uniforms: q(q({}, L), o),
|
|
565
565
|
vertexShader: Ce.vertexShader,
|
|
566
|
-
fragmentShader:
|
|
566
|
+
fragmentShader: m,
|
|
567
567
|
transparent: !0,
|
|
568
568
|
side: y.FrontSide
|
|
569
569
|
// for better performance
|
|
570
570
|
});
|
|
571
|
-
return s.backgroundImage && le(
|
|
571
|
+
return s.backgroundImage && le(T, { backgroundImage: s.backgroundImage }), T;
|
|
572
572
|
}
|
|
573
573
|
function Ze(s, e, t, r, i) {
|
|
574
|
-
const
|
|
574
|
+
const l = J(e.borderWidth);
|
|
575
575
|
le(s, {
|
|
576
576
|
width: t,
|
|
577
577
|
height: r,
|
|
578
578
|
borderRadius: e.borderRadius,
|
|
579
|
-
borderWidth:
|
|
579
|
+
borderWidth: l,
|
|
580
580
|
backgroundColor: e.backgroundColor,
|
|
581
581
|
borderColor: e.borderColor,
|
|
582
582
|
opacity: e.opacity,
|
|
@@ -585,7 +585,7 @@ function Ze(s, e, t, r, i) {
|
|
|
585
585
|
});
|
|
586
586
|
}
|
|
587
587
|
function le(s, e) {
|
|
588
|
-
var r, i,
|
|
588
|
+
var r, i, l;
|
|
589
589
|
if (e.width !== void 0 && e.height !== void 0 && s.uniforms.uSize.value.set(e.width, e.height), e.borderRadius !== void 0) {
|
|
590
590
|
const n = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(s.uniforms.uSize.value.x, s.uniforms.uSize.value.y);
|
|
591
591
|
Me(s.uniforms.uBorderRadius.value, e.borderRadius, n);
|
|
@@ -645,9 +645,9 @@ function le(s, e) {
|
|
|
645
645
|
e.opacity !== void 0 && (s.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (s.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (s.uniforms.uBorderColor.value.w = e.borderOpacity), s.uniforms.uTexture && e.texture !== void 0 && (s.uniforms.uTexture.value = e.texture);
|
|
646
646
|
const t = e.texture !== void 0 ? e.texture : (r = s.uniforms.uTexture) == null ? void 0 : r.value;
|
|
647
647
|
if (t && (t.image instanceof ImageBitmap || t.image instanceof HTMLImageElement || t.image instanceof HTMLCanvasElement)) {
|
|
648
|
-
const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, o = t.image.naturalHeight || t.image.videoHeight || t.image.height,
|
|
649
|
-
if (n && o &&
|
|
650
|
-
const d = n / o, h =
|
|
648
|
+
const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, o = t.image.naturalHeight || t.image.videoHeight || t.image.height, a = (i = e.width) != null ? i : s.uniforms.uSize.value.x, c = (l = e.height) != null ? l : s.uniforms.uSize.value.y;
|
|
649
|
+
if (n && o && a && c) {
|
|
650
|
+
const d = n / o, h = a / c;
|
|
651
651
|
if (d > h) {
|
|
652
652
|
const u = h / d;
|
|
653
653
|
s.uniforms.uTextureRepeat.value.set(u, 1), s.uniforms.uTextureOffset.value.set((1 - u) / 2, 0);
|
|
@@ -664,13 +664,13 @@ function le(s, e) {
|
|
|
664
664
|
s.uniforms.uGradientCount.value = n.stops.length, s.uniforms.uGradientAngle.value = n.angle;
|
|
665
665
|
for (let o = 0; o < 8; o++)
|
|
666
666
|
if (o < n.stops.length) {
|
|
667
|
-
const
|
|
667
|
+
const a = n.stops[o];
|
|
668
668
|
s.uniforms.uGradientColors.value[o].set(
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
), s.uniforms.uGradientStops.value[o] =
|
|
669
|
+
a.color.r,
|
|
670
|
+
a.color.g,
|
|
671
|
+
a.color.b,
|
|
672
|
+
a.alpha
|
|
673
|
+
), s.uniforms.uGradientStops.value[o] = a.stop;
|
|
674
674
|
} else
|
|
675
675
|
s.uniforms.uGradientColors.value[o].set(0, 0, 0, 0), s.uniforms.uGradientStops.value[o] = 1;
|
|
676
676
|
} else
|
|
@@ -680,7 +680,7 @@ function le(s, e) {
|
|
|
680
680
|
n !== "width" && n !== "height" && n !== "borderRadius" && n !== "borderWidth" && n !== "backgroundColor" && n !== "borderColor" && n !== "opacity" && n !== "bgOpacity" && n !== "borderOpacity" && n !== "texture" && n !== "backgroundImage" && s.uniforms[n] !== void 0 && (s.uniforms[n].value !== void 0 && s.uniforms[n].value !== null && typeof s.uniforms[n].value.set == "function" ? Array.isArray(e[n]) ? s.uniforms[n].value.set(...e[n]) : e[n] !== void 0 && (e[n].copy ? s.uniforms[n].value.copy(e[n]) : s.uniforms[n].value = e[n]) : s.uniforms[n].value = e[n]);
|
|
681
681
|
}
|
|
682
682
|
function Me(s, e, t = 0) {
|
|
683
|
-
var
|
|
683
|
+
var a, c, d, h;
|
|
684
684
|
if (e == null) {
|
|
685
685
|
s.set(0, 0, 0, 0);
|
|
686
686
|
return;
|
|
@@ -693,11 +693,11 @@ function Me(s, e, t = 0) {
|
|
|
693
693
|
s.set(e[0], e[1], e[2], e[3]);
|
|
694
694
|
return;
|
|
695
695
|
}
|
|
696
|
-
const r = e.split("/")[0].trim().split(/\s+/), i = J(r[0], t),
|
|
697
|
-
s.set(i,
|
|
696
|
+
const r = e.split("/")[0].trim().split(/\s+/), i = J(r[0], t), l = J((a = r[1]) != null ? a : r[0], t), n = J((c = r[2]) != null ? c : r[0], t), o = J((h = (d = r[3]) != null ? d : r[1]) != null ? h : r[0], t);
|
|
697
|
+
s.set(i, l, n, o);
|
|
698
698
|
}
|
|
699
|
-
const
|
|
700
|
-
create(s, e, t, r, i,
|
|
699
|
+
const V = {
|
|
700
|
+
create(s, e, t, r, i, l = 2, n = null, o) {
|
|
701
701
|
return s === "BOX" ? Qe(
|
|
702
702
|
e,
|
|
703
703
|
r,
|
|
@@ -709,21 +709,21 @@ const z = {
|
|
|
709
709
|
e,
|
|
710
710
|
r,
|
|
711
711
|
i,
|
|
712
|
-
|
|
712
|
+
l
|
|
713
713
|
) : new y.MeshBasicMaterial({ visible: !1 });
|
|
714
714
|
},
|
|
715
|
-
update(s, e, t, r, i,
|
|
715
|
+
update(s, e, t, r, i, l, n = 2, o) {
|
|
716
716
|
e === "BOX" ? Ze(
|
|
717
717
|
s,
|
|
718
718
|
t,
|
|
719
719
|
i,
|
|
720
|
-
|
|
720
|
+
l,
|
|
721
721
|
o
|
|
722
722
|
) : e === "TEXT" && s.updateText(
|
|
723
723
|
r || "",
|
|
724
724
|
t,
|
|
725
725
|
i,
|
|
726
|
-
|
|
726
|
+
l,
|
|
727
727
|
n
|
|
728
728
|
);
|
|
729
729
|
},
|
|
@@ -733,16 +733,16 @@ const z = {
|
|
|
733
733
|
};
|
|
734
734
|
class et {
|
|
735
735
|
constructor(e, t = !0) {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
736
|
+
g(this, "observer");
|
|
737
|
+
g(this, "textures", /* @__PURE__ */ new WeakMap());
|
|
738
|
+
g(this, "loadStatus", /* @__PURE__ */ new WeakMap());
|
|
739
|
+
g(this, "elementUrls", /* @__PURE__ */ new WeakMap());
|
|
740
|
+
g(this, "onUpdate");
|
|
741
741
|
this.onUpdate = e, t && (this.observer = new IntersectionObserver(
|
|
742
742
|
(r) => {
|
|
743
743
|
for (const i of r) {
|
|
744
|
-
const
|
|
745
|
-
i.isIntersecting ? this.loadTexture(
|
|
744
|
+
const l = i.target;
|
|
745
|
+
i.isIntersecting ? this.loadTexture(l) : this.disposeTexture(l);
|
|
746
746
|
}
|
|
747
747
|
},
|
|
748
748
|
{ rootMargin: "300px" }
|
|
@@ -766,9 +766,9 @@ class et {
|
|
|
766
766
|
try {
|
|
767
767
|
let r;
|
|
768
768
|
if (t.startsWith("data:image/svg+xml"))
|
|
769
|
-
r = yield new Promise((
|
|
769
|
+
r = yield new Promise((l, n) => {
|
|
770
770
|
const o = new Image();
|
|
771
|
-
o.onload = () =>
|
|
771
|
+
o.onload = () => l(o), o.onerror = n, o.src = t;
|
|
772
772
|
});
|
|
773
773
|
else {
|
|
774
774
|
const n = yield (yield fetch(t)).blob();
|
|
@@ -801,38 +801,38 @@ class et {
|
|
|
801
801
|
}
|
|
802
802
|
class tt {
|
|
803
803
|
constructor(e, t, r, i) {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
{ length:
|
|
804
|
+
g(this, "canvas");
|
|
805
|
+
g(this, "scene");
|
|
806
|
+
g(this, "camera");
|
|
807
|
+
g(this, "renderer");
|
|
808
|
+
g(this, "renderTargets", []);
|
|
809
|
+
g(this, "renderOrder", 0);
|
|
810
|
+
g(this, "qualityFactor", 2);
|
|
811
|
+
g(this, "mode", "overlay");
|
|
812
|
+
g(this, "canvasSize", "viewport");
|
|
813
|
+
g(this, "clipArea", 1);
|
|
814
|
+
g(this, "targetLayer", "base");
|
|
815
|
+
g(this, "overscan", 200);
|
|
816
|
+
g(this, "target");
|
|
817
|
+
g(this, "mountContainer");
|
|
818
|
+
g(this, "registry");
|
|
819
|
+
g(this, "targetRect");
|
|
820
|
+
g(this, "travelersByLayer", Array.from(
|
|
821
|
+
{ length: O.MAX_LAYERS },
|
|
822
822
|
() => /* @__PURE__ */ new Set()
|
|
823
823
|
));
|
|
824
|
-
|
|
824
|
+
g(this, "textureManager");
|
|
825
825
|
// private meshMap: Map<HTMLElement, THREE.Mesh> = new Map();
|
|
826
|
-
|
|
827
|
-
var o,
|
|
828
|
-
this.target = e, this.mountContainer = r, this.registry = i, this.mode = (o = t.mode) != null ? o : "overlay", this.canvasSize = (
|
|
829
|
-
const
|
|
830
|
-
|
|
826
|
+
g(this, "fixedMeshes", /* @__PURE__ */ new Set());
|
|
827
|
+
var o, a, c, d, h;
|
|
828
|
+
this.target = e, this.mountContainer = r, this.registry = i, this.mode = (o = t.mode) != null ? o : "overlay", this.canvasSize = (a = t.canvasSize) != null ? a : "viewport", this.clipArea = (c = t.travelerClipArea) != null ? c : 1, this.targetLayer = (d = t.layer) != null ? d : "base", this.textureManager = new et((u, p) => {
|
|
829
|
+
const f = this.registry.get(u);
|
|
830
|
+
f && f.material instanceof y.ShaderMaterial && V.forceUpdateUniforms(f.material, { texture: p });
|
|
831
831
|
}, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new y.Scene(), this.targetRect = this.target.getBoundingClientRect();
|
|
832
|
-
const
|
|
832
|
+
const l = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, n = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
833
833
|
this.camera = new y.OrthographicCamera(
|
|
834
|
-
|
|
835
|
-
|
|
834
|
+
l / -2,
|
|
835
|
+
l / 2,
|
|
836
836
|
n / 2,
|
|
837
837
|
n / -2,
|
|
838
838
|
1,
|
|
@@ -843,16 +843,16 @@ class tt {
|
|
|
843
843
|
antialias: !0
|
|
844
844
|
// [new]
|
|
845
845
|
// premultipliedAlpha: true
|
|
846
|
-
}), y.ColorManagement.enabled = !1, this.renderer.outputColorSpace = y.LinearSRGBColorSpace, this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(
|
|
846
|
+
}), y.ColorManagement.enabled = !1, this.renderer.outputColorSpace = y.LinearSRGBColorSpace, this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(l, n), this.applyTextQuality((h = t.quality) != null ? h : "medium");
|
|
847
847
|
}
|
|
848
848
|
get isViewport() {
|
|
849
849
|
return this.mode === "overlay" && this.canvasSize === "viewport";
|
|
850
850
|
}
|
|
851
851
|
getSceneLayer() {
|
|
852
|
-
return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ?
|
|
852
|
+
return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? U.SELECTED : U.BASE;
|
|
853
853
|
}
|
|
854
854
|
createRenderTarget() {
|
|
855
|
-
for (let e = 0; e <
|
|
855
|
+
for (let e = 0; e < O.MAX_LAYERS; e++) {
|
|
856
856
|
const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, r = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
857
857
|
this.renderTargets.push(
|
|
858
858
|
new y.WebGLRenderTarget(
|
|
@@ -899,12 +899,12 @@ class tt {
|
|
|
899
899
|
updateUniforms(e, t) {
|
|
900
900
|
const r = this.registry.get(e);
|
|
901
901
|
r && (r.traverse((i) => {
|
|
902
|
-
i.isMesh && i.material &&
|
|
902
|
+
i.isMesh && i.material && V.forceUpdateUniforms(
|
|
903
903
|
i.material,
|
|
904
904
|
t
|
|
905
905
|
);
|
|
906
906
|
}), r.userData.nativeMesh && r.userData.nativeMesh.traverse((i) => {
|
|
907
|
-
i.isMesh && i.material &&
|
|
907
|
+
i.isMesh && i.material && V.forceUpdateUniforms(
|
|
908
908
|
i.material,
|
|
909
909
|
t
|
|
910
910
|
);
|
|
@@ -920,8 +920,8 @@ class tt {
|
|
|
920
920
|
this.camera.left = e / -2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = t / -2, this.camera.updateProjectionMatrix();
|
|
921
921
|
}
|
|
922
922
|
syncScene(e, t) {
|
|
923
|
-
const r = this.target.getBoundingClientRect(), i = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width,
|
|
924
|
-
|
|
923
|
+
const r = this.target.getBoundingClientRect(), i = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width, l = this.isViewport ? window.innerHeight + this.overscan * 2 : r.height, n = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, o = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, a = Math.abs(i - n) > 0.1 || Math.abs(l - o) > 0.1, c = this.mode === "overlay" && (Math.abs(r.top - this.targetRect.top) > 0.1 || Math.abs(r.left - this.targetRect.left) > 0.1);
|
|
924
|
+
a ? (this.targetRect = r, this.setSize(i, l), this.updateCanvasLayout()) : c ? (this.targetRect = r, this.updateCanvasLayout()) : this.targetRect = r, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((d) => {
|
|
925
925
|
const h = this.registry.get(d);
|
|
926
926
|
if (h) {
|
|
927
927
|
this.scene.remove(h);
|
|
@@ -940,31 +940,31 @@ class tt {
|
|
|
940
940
|
// => 이후 activeElements를 이용하여 mesh를 정리!!!+ map에서도 삭제
|
|
941
941
|
// private reconcileNode(node: SceneNode, activeElements: Set<HTMLElement>) {
|
|
942
942
|
reconcileNode(e) {
|
|
943
|
-
var i;
|
|
943
|
+
var i, l;
|
|
944
944
|
let t = this.registry.get(e.element);
|
|
945
945
|
const r = JSON.stringify(e.shaderHooks || null);
|
|
946
946
|
if (t && t.userData.shaderHash !== r && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof y.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
|
|
947
|
-
const
|
|
947
|
+
const n = new y.PlaneGeometry(1, 1), o = e.isTraveler ? (i = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : i.texture : this.textureManager.get(e.element), a = V.create(
|
|
948
948
|
"BOX",
|
|
949
949
|
e.styles,
|
|
950
950
|
"",
|
|
951
951
|
e.rect.width,
|
|
952
952
|
e.rect.height,
|
|
953
953
|
this.qualityFactor,
|
|
954
|
-
|
|
954
|
+
o,
|
|
955
955
|
e.shaderHooks
|
|
956
956
|
);
|
|
957
|
-
t = new y.Mesh(
|
|
957
|
+
t = new y.Mesh(n, a), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = a, t.userData.domElement = e.element, t.userData.shaderHash = r;
|
|
958
958
|
}
|
|
959
|
-
if (this.updateMeshProperties(t, e), this.updateMeshLayers(t, e), e.isTraveler)
|
|
960
|
-
for (let
|
|
961
|
-
|
|
959
|
+
if ((l = e.nativeStyles) != null && l.transform ? t.userData.nativeTransform = e.nativeStyles.transform : t.userData.nativeTransform = void 0, this.updateMeshProperties(t, e), this.updateMeshLayers(t, e), e.isTraveler)
|
|
960
|
+
for (let n = 0; n < O.MAX_LAYERS; n++)
|
|
961
|
+
n === e.captureLayer - 2 ? this.travelersByLayer[n].add(t) : this.travelersByLayer[n].delete(t);
|
|
962
962
|
else
|
|
963
|
-
for (const
|
|
964
|
-
|
|
963
|
+
for (const n of this.travelersByLayer)
|
|
964
|
+
n.delete(t);
|
|
965
965
|
if (e.isFixed ? this.fixedMeshes.add(t) : this.fixedMeshes.delete(t), e.styles.imageSrc ? this.textureManager.register(e.element, e.styles.imageSrc) : this.textureManager.unregister(e.element), e.type === "BOX")
|
|
966
|
-
for (const
|
|
967
|
-
this.reconcileNode(
|
|
966
|
+
for (const n of e.children)
|
|
967
|
+
this.reconcileNode(n);
|
|
968
968
|
else
|
|
969
969
|
e.type === "TEXT" && (this.reconcileTextChild(t, e, !1), t.userData.nativeMesh && e.nativeStyles && this.reconcileTextChild(
|
|
970
970
|
t.userData.nativeMesh,
|
|
@@ -973,88 +973,88 @@ class tt {
|
|
|
973
973
|
));
|
|
974
974
|
}
|
|
975
975
|
reconcileTextChild(e, t, r) {
|
|
976
|
-
var
|
|
976
|
+
var c;
|
|
977
977
|
const i = t.textLines || [
|
|
978
978
|
{ text: t.textContent || "", rect: t.rect }
|
|
979
|
-
],
|
|
979
|
+
], l = r ? t.nativeStyles : t.textStyles, n = JSON.stringify(l) + t.textContent + i.map((d) => d.text).join("|"), o = (c = e.userData) == null ? void 0 : c.textChildStyleHash;
|
|
980
980
|
if (t.dirtyMask & ce || n !== o) {
|
|
981
981
|
e.children.filter(
|
|
982
|
-
(
|
|
983
|
-
).forEach((
|
|
984
|
-
var
|
|
985
|
-
const
|
|
986
|
-
(
|
|
982
|
+
(f) => f.name.startsWith("TEXT_CHILD")
|
|
983
|
+
).forEach((f) => {
|
|
984
|
+
var b;
|
|
985
|
+
const m = f;
|
|
986
|
+
(b = m.material.map) == null || b.dispose(), m.geometry.dispose(), e.remove(m);
|
|
987
987
|
});
|
|
988
988
|
const h = t.rect, u = h.x + h.width / 2, p = h.y + h.height / 2;
|
|
989
|
-
i.forEach((
|
|
990
|
-
const
|
|
989
|
+
i.forEach((f, m) => {
|
|
990
|
+
const b = V.create(
|
|
991
991
|
"TEXT",
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
992
|
+
l,
|
|
993
|
+
f.text,
|
|
994
|
+
f.rect.width,
|
|
995
|
+
f.rect.height,
|
|
996
996
|
this.qualityFactor
|
|
997
|
-
),
|
|
998
|
-
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
const C =
|
|
1002
|
-
|
|
1003
|
-
t.rect.width === 0 ? 0 :
|
|
1004
|
-
t.rect.height === 0 ? 0 :
|
|
997
|
+
), R = new y.PlaneGeometry(1, 1), L = new y.Mesh(R, b);
|
|
998
|
+
L.name = `TEXT_CHILD_${m}`;
|
|
999
|
+
const T = t.rect.width === 0 ? 1 : f.rect.width / t.rect.width, x = t.rect.height === 0 ? 1 : f.rect.height / t.rect.height;
|
|
1000
|
+
L.scale.set(T, x, 1);
|
|
1001
|
+
const C = f.rect.x + f.rect.width / 2, w = f.rect.y + f.rect.height / 2, S = C - u, M = -(w - p);
|
|
1002
|
+
L.position.set(
|
|
1003
|
+
t.rect.width === 0 ? 0 : S / t.rect.width,
|
|
1004
|
+
t.rect.height === 0 ? 0 : M / t.rect.height,
|
|
1005
1005
|
5e-3
|
|
1006
|
-
), e.add(
|
|
1006
|
+
), e.add(L);
|
|
1007
1007
|
}), e.userData.textChildStyleHash = n;
|
|
1008
1008
|
}
|
|
1009
1009
|
e.children.forEach((d) => {
|
|
1010
1010
|
if (!d.name.startsWith("TEXT_CHILD"))
|
|
1011
1011
|
return;
|
|
1012
|
-
const h = d, u = t.visibility &
|
|
1013
|
-
if (h.layers.set(u), t.visibility & K && h.layers.enable(
|
|
1012
|
+
const h = d, u = t.visibility & H ? U.BASE : U.HIDDEN;
|
|
1013
|
+
if (h.layers.set(u), t.visibility & K && h.layers.enable(U.SELECTED), t.visibility & H)
|
|
1014
1014
|
if (!r && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
|
|
1015
1015
|
for (let p = t.captureLayer; p < t.nativeLayer; p++)
|
|
1016
|
-
h.layers.enable(
|
|
1016
|
+
h.layers.enable(U.getCaptureLayer(p));
|
|
1017
1017
|
else if (r && t.nativeLayer !== void 0)
|
|
1018
|
-
for (let p = Math.max(t.captureLayer, t.nativeLayer); p <=
|
|
1019
|
-
h.layers.enable(
|
|
1018
|
+
for (let p = Math.max(t.captureLayer, t.nativeLayer); p <= O.MAX_LAYERS + 1; p++)
|
|
1019
|
+
h.layers.enable(U.getCaptureLayer(p));
|
|
1020
1020
|
else
|
|
1021
|
-
for (let p = t.captureLayer; p <=
|
|
1022
|
-
h.layers.enable(
|
|
1021
|
+
for (let p = t.captureLayer; p <= O.MAX_LAYERS + 1; p++)
|
|
1022
|
+
h.layers.enable(U.getCaptureLayer(p));
|
|
1023
1023
|
});
|
|
1024
1024
|
}
|
|
1025
1025
|
updateMeshProperties(e, t) {
|
|
1026
|
-
var
|
|
1027
|
-
const { rect: r, styles: i } = t,
|
|
1026
|
+
var T, x, C;
|
|
1027
|
+
const { rect: r, styles: i } = t, l = this.renderer.getPixelRatio(), n = this.renderer.domElement.width / l, o = this.renderer.domElement.height / l;
|
|
1028
1028
|
e.material = e.userData.baseMaterial, e.scale.set(r.width, r.height, 1), e.userData.domRect = {
|
|
1029
1029
|
x: r.x,
|
|
1030
1030
|
y: r.y,
|
|
1031
1031
|
width: r.width,
|
|
1032
1032
|
height: r.height
|
|
1033
1033
|
};
|
|
1034
|
-
const
|
|
1034
|
+
const a = 1e-3;
|
|
1035
1035
|
this.renderOrder++;
|
|
1036
|
-
const
|
|
1036
|
+
const c = this.targetRect.left + window.scrollX, d = this.targetRect.top + window.scrollY;
|
|
1037
1037
|
let h, u;
|
|
1038
1038
|
if (this.isViewport)
|
|
1039
1039
|
h = r.x - window.innerWidth / 2 + r.width / 2, u = -r.y + window.innerHeight / 2 - r.height / 2;
|
|
1040
1040
|
else {
|
|
1041
|
-
const
|
|
1042
|
-
h =
|
|
1041
|
+
const w = r.x - c, S = r.y - d;
|
|
1042
|
+
h = w - n / 2 + r.width / 2, u = -S + o / 2 - r.height / 2;
|
|
1043
1043
|
}
|
|
1044
1044
|
e.position.set(
|
|
1045
1045
|
h,
|
|
1046
1046
|
u,
|
|
1047
|
-
i.zIndex + this.renderOrder *
|
|
1047
|
+
i.zIndex + this.renderOrder * a
|
|
1048
1048
|
);
|
|
1049
|
-
const p = r.x,
|
|
1050
|
-
e.userData.basePosition = { x: h, y: u }, e.userData.originalBasePosition = { x: h, y: u }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: p, y:
|
|
1051
|
-
const
|
|
1052
|
-
let
|
|
1053
|
-
if (
|
|
1054
|
-
const
|
|
1055
|
-
|
|
1049
|
+
const p = r.x, f = r.y;
|
|
1050
|
+
e.userData.basePosition = { x: h, y: u }, e.userData.originalBasePosition = { x: h, y: u }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: p, y: f }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
|
|
1051
|
+
const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, b = window.getComputedStyle(m);
|
|
1052
|
+
let R = 0, L = 0;
|
|
1053
|
+
if (b.transform && b.transform !== "none") {
|
|
1054
|
+
const w = new DOMMatrix(b.transform);
|
|
1055
|
+
R = w.m41, L = w.m42;
|
|
1056
1056
|
}
|
|
1057
|
-
if (e.userData.baseTransform = { x:
|
|
1057
|
+
if (e.userData.baseTransform = { x: R, y: L }, delete e.userData.originRatioX, delete e.userData.originRatioY, V.update(
|
|
1058
1058
|
e.userData.baseMaterial,
|
|
1059
1059
|
"BOX",
|
|
1060
1060
|
i,
|
|
@@ -1062,35 +1062,35 @@ class tt {
|
|
|
1062
1062
|
r.width,
|
|
1063
1063
|
r.height,
|
|
1064
1064
|
this.qualityFactor,
|
|
1065
|
-
t.isTraveler ? (
|
|
1065
|
+
t.isTraveler ? (T = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : T.texture : this.textureManager.get(t.element)
|
|
1066
1066
|
), t.nativeStyles && t.nativeRect) {
|
|
1067
1067
|
if (!e.userData.nativeMesh) {
|
|
1068
|
-
const k =
|
|
1068
|
+
const k = V.create(
|
|
1069
1069
|
"BOX",
|
|
1070
1070
|
t.nativeStyles,
|
|
1071
1071
|
"",
|
|
1072
1072
|
t.nativeRect.width,
|
|
1073
1073
|
t.nativeRect.height,
|
|
1074
1074
|
this.qualityFactor,
|
|
1075
|
-
t.isTraveler ? (
|
|
1075
|
+
t.isTraveler ? (x = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : x.texture : this.textureManager.get(t.element),
|
|
1076
1076
|
t.shaderHooks
|
|
1077
|
-
),
|
|
1078
|
-
t.type === "TEXT" && (
|
|
1077
|
+
), _ = new y.Mesh(e.geometry, k);
|
|
1078
|
+
t.type === "TEXT" && (_.name = "BG_MESH"), this.scene.add(_), e.userData.nativeMesh = _;
|
|
1079
1079
|
}
|
|
1080
|
-
const
|
|
1081
|
-
let
|
|
1080
|
+
const w = e.userData.nativeMesh;
|
|
1081
|
+
let S, M;
|
|
1082
1082
|
if (this.isViewport)
|
|
1083
|
-
|
|
1083
|
+
S = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, M = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
|
|
1084
1084
|
else {
|
|
1085
|
-
const k = t.nativeRect.x -
|
|
1086
|
-
|
|
1085
|
+
const k = t.nativeRect.x - c, _ = t.nativeRect.y - d;
|
|
1086
|
+
S = k - n / 2 + t.nativeRect.width / 2, M = -_ + o / 2 - t.nativeRect.height / 2;
|
|
1087
1087
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
t.nativeStyles.zIndex + this.renderOrder *
|
|
1092
|
-
),
|
|
1093
|
-
|
|
1088
|
+
w.scale.set(t.nativeRect.width, t.nativeRect.height, 1), w.position.set(
|
|
1089
|
+
S,
|
|
1090
|
+
M,
|
|
1091
|
+
t.nativeStyles.zIndex + this.renderOrder * a
|
|
1092
|
+
), V.update(
|
|
1093
|
+
w.material,
|
|
1094
1094
|
"BOX",
|
|
1095
1095
|
t.nativeStyles,
|
|
1096
1096
|
"",
|
|
@@ -1103,82 +1103,110 @@ class tt {
|
|
|
1103
1103
|
e.userData.nativeMesh && (this.scene.remove(e.userData.nativeMesh), e.userData.nativeMesh.material instanceof y.Material && e.userData.nativeMesh.material.dispose(), delete e.userData.nativeMesh);
|
|
1104
1104
|
}
|
|
1105
1105
|
updateMeshLayers(e, t) {
|
|
1106
|
-
const r = t.visibility &
|
|
1107
|
-
if (e.layers.set(r), t.visibility & K && e.layers.enable(
|
|
1106
|
+
const r = t.visibility & H ? U.BASE : U.HIDDEN;
|
|
1107
|
+
if (e.layers.set(r), t.visibility & K && e.layers.enable(U.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
|
|
1108
1108
|
const i = e.userData.nativeMesh;
|
|
1109
|
-
if (i.layers.set(
|
|
1110
|
-
for (let
|
|
1111
|
-
e.layers.enable(
|
|
1112
|
-
for (let
|
|
1113
|
-
i.layers.enable(
|
|
1109
|
+
if (i.layers.set(U.HIDDEN), t.visibility & H) {
|
|
1110
|
+
for (let l = t.captureLayer; l < t.nativeLayer; l++)
|
|
1111
|
+
e.layers.enable(U.getCaptureLayer(l));
|
|
1112
|
+
for (let l = Math.max(t.captureLayer, t.nativeLayer); l <= O.MAX_LAYERS + 1; l++)
|
|
1113
|
+
i.layers.enable(U.getCaptureLayer(l));
|
|
1114
1114
|
}
|
|
1115
|
-
} else if (t.visibility &
|
|
1116
|
-
for (let i = t.captureLayer; i <=
|
|
1117
|
-
e.layers.enable(
|
|
1115
|
+
} else if (t.visibility & H)
|
|
1116
|
+
for (let i = t.captureLayer; i <= O.MAX_LAYERS + 1; i++)
|
|
1117
|
+
e.layers.enable(U.getCaptureLayer(i));
|
|
1118
1118
|
}
|
|
1119
1119
|
captureRenderTarget(e, t, r) {
|
|
1120
1120
|
if (e.size === 0 || !r)
|
|
1121
1121
|
return;
|
|
1122
|
-
const i = new y.Color(),
|
|
1122
|
+
const i = new y.Color(), l = this.renderer.getClearAlpha();
|
|
1123
1123
|
this.renderer.getClearColor(i), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(r), this.renderer.clear(), this.renderer.autoClear = !1, this.renderer.setScissorTest(!0), this.camera.layers.set(t);
|
|
1124
|
-
const n = new y.Vector3(), o = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width,
|
|
1124
|
+
const n = new y.Vector3(), o = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, a = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height, c = this.renderer.getPixelRatio();
|
|
1125
1125
|
for (const d of e) {
|
|
1126
1126
|
n.setFromMatrixPosition(d.matrixWorld), n.project(this.camera);
|
|
1127
|
-
const h = (n.x + 1) / 2 * o, u = (n.y + 1) / 2 *
|
|
1128
|
-
let p = 0,
|
|
1129
|
-
typeof this.clipArea == "number" ?
|
|
1130
|
-
const
|
|
1131
|
-
this.renderer.setScissor(
|
|
1127
|
+
const h = (n.x + 1) / 2 * o, u = (n.y + 1) / 2 * a;
|
|
1128
|
+
let p = 0, f = 1;
|
|
1129
|
+
typeof this.clipArea == "number" ? f = this.clipArea : this.clipArea.endsWith("%") ? f = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (p = parseFloat(this.clipArea));
|
|
1130
|
+
const m = d.scale.x * f + 0.5, b = d.scale.y * f + 0.5, R = h - m / 2, L = u - b / 2, T = (R * this.qualityFactor - p) / c, x = (L * this.qualityFactor - p) / c, C = (m * this.qualityFactor + p * 2) / c, w = (b * this.qualityFactor + p * 2) / c;
|
|
1131
|
+
this.renderer.setScissor(T, x, C, w), this.renderer.render(this.scene, this.camera);
|
|
1132
1132
|
}
|
|
1133
|
-
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(i,
|
|
1133
|
+
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(i, l);
|
|
1134
1134
|
}
|
|
1135
1135
|
render() {
|
|
1136
|
-
for (let e = 0; e <
|
|
1136
|
+
for (let e = 0; e < O.MAX_LAYERS; e++) {
|
|
1137
1137
|
const t = e + 1;
|
|
1138
1138
|
this.captureRenderTarget(
|
|
1139
1139
|
this.travelersByLayer[e],
|
|
1140
|
-
|
|
1140
|
+
U.getCaptureLayer(t),
|
|
1141
1141
|
this.renderTargets[e]
|
|
1142
1142
|
);
|
|
1143
1143
|
}
|
|
1144
1144
|
this.renderer.render(this.scene, this.camera);
|
|
1145
1145
|
}
|
|
1146
1146
|
syncMeshesByDOM() {
|
|
1147
|
-
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), i = this.renderer.domElement.width / r,
|
|
1147
|
+
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), i = this.renderer.domElement.width / r, l = this.renderer.domElement.height / r;
|
|
1148
1148
|
this.scene.children.forEach((n) => {
|
|
1149
1149
|
const o = n;
|
|
1150
1150
|
if (!o.userData || !o.userData.domElement)
|
|
1151
1151
|
return;
|
|
1152
|
-
const
|
|
1153
|
-
if (!
|
|
1152
|
+
const a = o.userData.domElement;
|
|
1153
|
+
if (!a.isConnected)
|
|
1154
1154
|
return;
|
|
1155
|
-
let
|
|
1156
|
-
if (
|
|
1155
|
+
let c;
|
|
1156
|
+
if (a.nodeType === Node.TEXT_NODE) {
|
|
1157
1157
|
const h = document.createRange();
|
|
1158
|
-
h.selectNode(
|
|
1158
|
+
h.selectNode(a), c = h.getBoundingClientRect();
|
|
1159
1159
|
} else
|
|
1160
|
-
|
|
1160
|
+
c = a.getBoundingClientRect();
|
|
1161
1161
|
const d = o.userData.domRect;
|
|
1162
|
-
if (!d || Math.abs(
|
|
1162
|
+
if (!d || Math.abs(c.x - d.x) > 0.5 || Math.abs(c.y - d.y) > 0.5 || Math.abs(c.width - d.width) > 0.5 || Math.abs(c.height - d.height) > 0.5) {
|
|
1163
1163
|
o.userData.domRect = {
|
|
1164
|
-
x:
|
|
1165
|
-
y:
|
|
1166
|
-
width:
|
|
1167
|
-
height:
|
|
1164
|
+
x: c.x,
|
|
1165
|
+
y: c.y,
|
|
1166
|
+
width: c.width,
|
|
1167
|
+
height: c.height
|
|
1168
1168
|
};
|
|
1169
1169
|
let h, u;
|
|
1170
1170
|
if (this.isViewport)
|
|
1171
|
-
h =
|
|
1171
|
+
h = c.x - window.innerWidth / 2 + c.width / 2, u = -c.y + window.innerHeight / 2 - c.height / 2;
|
|
1172
1172
|
else {
|
|
1173
|
-
const p =
|
|
1174
|
-
h = p - i / 2 +
|
|
1173
|
+
const p = c.x - e, f = c.y - t;
|
|
1174
|
+
h = p - i / 2 + c.width / 2, u = -f + l / 2 - c.height / 2;
|
|
1175
1175
|
}
|
|
1176
|
-
if (o.position.setX(h), o.position.setY(u), o.scale.set(
|
|
1177
|
-
width:
|
|
1178
|
-
height:
|
|
1176
|
+
if (o.position.setX(h), o.position.setY(u), o.scale.set(c.width, c.height, 1), o.updateMatrixWorld(), o.material instanceof y.ShaderMaterial && V.forceUpdateUniforms(o.material, {
|
|
1177
|
+
width: c.width,
|
|
1178
|
+
height: c.height
|
|
1179
1179
|
}), o.userData.nativeMesh) {
|
|
1180
1180
|
const p = o.userData.nativeMesh;
|
|
1181
|
-
|
|
1181
|
+
let f = c.width, m = c.height, b = h, R = u;
|
|
1182
|
+
if (o.userData.nativeTransform) {
|
|
1183
|
+
const L = o.userData.nativeTransform, T = L.match(/scale\(([\d.]+%?)\)/);
|
|
1184
|
+
if (T) {
|
|
1185
|
+
let S = parseFloat(T[1]);
|
|
1186
|
+
T[1].includes("%") && (S /= 100), f *= S, m *= S;
|
|
1187
|
+
}
|
|
1188
|
+
const x = L.match(/translate\(([^,]+),\s*([^)]+)\)/);
|
|
1189
|
+
if (x) {
|
|
1190
|
+
const S = x[1].trim(), M = x[2].trim();
|
|
1191
|
+
let k = parseFloat(S);
|
|
1192
|
+
S.includes("%") && (k = k / 100 * c.width);
|
|
1193
|
+
let _ = parseFloat(M);
|
|
1194
|
+
M.includes("%") && (_ = _ / 100 * c.height), b += k, R -= _;
|
|
1195
|
+
}
|
|
1196
|
+
const C = L.match(/translateX\(([^)]+)\)/);
|
|
1197
|
+
if (C) {
|
|
1198
|
+
const S = C[1].trim();
|
|
1199
|
+
let M = parseFloat(S);
|
|
1200
|
+
S.includes("%") && (M = M / 100 * c.width), b += M;
|
|
1201
|
+
}
|
|
1202
|
+
const w = L.match(/translateY\(([^)]+)\)/);
|
|
1203
|
+
if (w) {
|
|
1204
|
+
const S = w[1].trim();
|
|
1205
|
+
let M = parseFloat(S);
|
|
1206
|
+
S.includes("%") && (M = M / 100 * c.height), R -= M;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
p.position.setX(b), p.position.setY(R), p.scale.set(f, m, 1), p.updateMatrixWorld();
|
|
1182
1210
|
}
|
|
1183
1211
|
}
|
|
1184
1212
|
});
|
|
@@ -1186,17 +1214,17 @@ class tt {
|
|
|
1186
1214
|
}
|
|
1187
1215
|
function rt(s) {
|
|
1188
1216
|
const e = s.textContent || "", t = [];
|
|
1189
|
-
let r = "", i = null,
|
|
1190
|
-
const n = (
|
|
1191
|
-
for (let h = 0; h <
|
|
1192
|
-
const u =
|
|
1217
|
+
let r = "", i = null, l = -1;
|
|
1218
|
+
const n = (c, d) => {
|
|
1219
|
+
for (let h = 0; h < c.length; h++) {
|
|
1220
|
+
const u = c[h], p = document.createRange();
|
|
1193
1221
|
p.setStart(s, d + h), p.setEnd(s, d + h + 1);
|
|
1194
|
-
const
|
|
1195
|
-
if (
|
|
1222
|
+
const f = p.getBoundingClientRect();
|
|
1223
|
+
if (f.width === 0 && f.height === 0) {
|
|
1196
1224
|
r += u;
|
|
1197
1225
|
continue;
|
|
1198
1226
|
}
|
|
1199
|
-
|
|
1227
|
+
l === -1 || Math.abs(f.top - l) > f.height / 2 ? (r && i && t.push({
|
|
1200
1228
|
text: r,
|
|
1201
1229
|
rect: {
|
|
1202
1230
|
left: i.left,
|
|
@@ -1205,30 +1233,30 @@ function rt(s) {
|
|
|
1205
1233
|
height: i.bottom - i.top
|
|
1206
1234
|
}
|
|
1207
1235
|
}), r = u, i = {
|
|
1208
|
-
left:
|
|
1209
|
-
top:
|
|
1210
|
-
right:
|
|
1211
|
-
bottom:
|
|
1212
|
-
},
|
|
1236
|
+
left: f.left,
|
|
1237
|
+
top: f.top,
|
|
1238
|
+
right: f.right,
|
|
1239
|
+
bottom: f.bottom
|
|
1240
|
+
}, l = f.top) : (r += u, i && (i.left = Math.min(i.left, f.left), i.top = Math.min(i.top, f.top), i.right = Math.max(i.right, f.right), i.bottom = Math.max(
|
|
1213
1241
|
i.bottom,
|
|
1214
|
-
|
|
1242
|
+
f.bottom
|
|
1215
1243
|
)));
|
|
1216
1244
|
}
|
|
1217
1245
|
}, o = e.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
1218
|
-
let
|
|
1219
|
-
for (const
|
|
1246
|
+
let a = 0;
|
|
1247
|
+
for (const c of o) {
|
|
1220
1248
|
const d = document.createRange();
|
|
1221
|
-
d.setStart(s,
|
|
1249
|
+
d.setStart(s, a), d.setEnd(s, a + c.length);
|
|
1222
1250
|
const h = d.getClientRects();
|
|
1223
1251
|
if (h.length > 1)
|
|
1224
|
-
n(
|
|
1252
|
+
n(c, a);
|
|
1225
1253
|
else {
|
|
1226
1254
|
const u = h.length === 1 ? h[0] : d.getBoundingClientRect();
|
|
1227
1255
|
if (u.width === 0 && u.height === 0) {
|
|
1228
|
-
r +=
|
|
1256
|
+
r += c, a += c.length;
|
|
1229
1257
|
continue;
|
|
1230
1258
|
}
|
|
1231
|
-
|
|
1259
|
+
l === -1 || Math.abs(u.top - l) > u.height / 2 ? (r && i && t.push({
|
|
1232
1260
|
text: r,
|
|
1233
1261
|
rect: {
|
|
1234
1262
|
left: i.left,
|
|
@@ -1236,17 +1264,17 @@ function rt(s) {
|
|
|
1236
1264
|
width: i.right - i.left,
|
|
1237
1265
|
height: i.bottom - i.top
|
|
1238
1266
|
}
|
|
1239
|
-
}), r =
|
|
1267
|
+
}), r = c, i = {
|
|
1240
1268
|
left: u.left,
|
|
1241
1269
|
top: u.top,
|
|
1242
1270
|
right: u.right,
|
|
1243
1271
|
bottom: u.bottom
|
|
1244
|
-
},
|
|
1272
|
+
}, l = u.top) : (r += c, i && (i.left = Math.min(i.left, u.left), i.top = Math.min(i.top, u.top), i.right = Math.max(i.right, u.right), i.bottom = Math.max(
|
|
1245
1273
|
i.bottom,
|
|
1246
1274
|
u.bottom
|
|
1247
1275
|
)));
|
|
1248
1276
|
}
|
|
1249
|
-
|
|
1277
|
+
a += c.length;
|
|
1250
1278
|
}
|
|
1251
1279
|
return r && i && t.push({
|
|
1252
1280
|
text: r,
|
|
@@ -1257,7 +1285,7 @@ function rt(s) {
|
|
|
1257
1285
|
height: i.bottom - i.top
|
|
1258
1286
|
}
|
|
1259
1287
|
}), t.filter(
|
|
1260
|
-
(
|
|
1288
|
+
(c) => c.text.trim().length > 0 && c.rect.width > 0 && c.rect.height > 0
|
|
1261
1289
|
);
|
|
1262
1290
|
}
|
|
1263
1291
|
function Se(s) {
|
|
@@ -1276,311 +1304,312 @@ function Se(s) {
|
|
|
1276
1304
|
letterSpacing: r
|
|
1277
1305
|
};
|
|
1278
1306
|
}
|
|
1279
|
-
function
|
|
1307
|
+
function De(s, e = $ | Z | ze | ce | ie, t, r = 1, i = 0, l = 2, n, o) {
|
|
1280
1308
|
var de, ue, fe, ge, pe, me;
|
|
1281
1309
|
if (s.nodeType === Node.TEXT_NODE) {
|
|
1282
|
-
const
|
|
1283
|
-
if (!
|
|
1310
|
+
const v = s;
|
|
1311
|
+
if (!v.textContent || !v.textContent.trim())
|
|
1284
1312
|
return null;
|
|
1285
|
-
const
|
|
1286
|
-
if (
|
|
1313
|
+
const A = v.textContent.replace(/\s+/g, " ");
|
|
1314
|
+
if (A.length === 0)
|
|
1287
1315
|
return null;
|
|
1288
|
-
const
|
|
1289
|
-
if (
|
|
1316
|
+
const B = rt(v);
|
|
1317
|
+
if (B.length === 0)
|
|
1290
1318
|
return null;
|
|
1291
|
-
const
|
|
1292
|
-
if (!
|
|
1319
|
+
const N = v.parentElement, I = N ? window.getComputedStyle(N) : null;
|
|
1320
|
+
if (!I)
|
|
1293
1321
|
return null;
|
|
1294
|
-
const
|
|
1322
|
+
const Y = Math.min(...B.map((E) => E.rect.left)), F = Math.min(...B.map((E) => E.rect.top)), P = Math.max(...B.map((E) => E.rect.left + E.rect.width)), D = Math.max(...B.map((E) => E.rect.top + E.rect.height));
|
|
1295
1323
|
return {
|
|
1296
1324
|
id: Math.random().toString(36).substring(2, 9),
|
|
1297
1325
|
type: "TEXT",
|
|
1298
|
-
element:
|
|
1326
|
+
element: v,
|
|
1299
1327
|
rect: {
|
|
1300
|
-
x:
|
|
1301
|
-
y:
|
|
1302
|
-
width:
|
|
1303
|
-
height:
|
|
1328
|
+
x: Y + window.scrollX,
|
|
1329
|
+
y: F + window.scrollY,
|
|
1330
|
+
width: P - Y,
|
|
1331
|
+
height: D - F
|
|
1304
1332
|
},
|
|
1305
1333
|
styles: {
|
|
1306
1334
|
backgroundColor: "transparent",
|
|
1307
1335
|
backgroundImage: "",
|
|
1308
|
-
opacity:
|
|
1309
|
-
zIndex: (isNaN(parseInt(
|
|
1336
|
+
opacity: N && N.dataset[G.KEY] === G.VALUES.HIDE ? 1 : parseFloat(I.opacity),
|
|
1337
|
+
zIndex: (isNaN(parseInt(I.zIndex)) ? 0 : parseInt(I.zIndex)) + i,
|
|
1310
1338
|
borderRadius: "0px",
|
|
1311
1339
|
borderColor: "transparent",
|
|
1312
1340
|
borderWidth: "0px",
|
|
1313
1341
|
isTraveler: !1
|
|
1314
1342
|
},
|
|
1315
|
-
textContent:
|
|
1316
|
-
textLines:
|
|
1317
|
-
text:
|
|
1343
|
+
textContent: A,
|
|
1344
|
+
textLines: B.map((E) => ({
|
|
1345
|
+
text: E.text.trim(),
|
|
1318
1346
|
rect: {
|
|
1319
|
-
x:
|
|
1320
|
-
y:
|
|
1321
|
-
width:
|
|
1322
|
-
height:
|
|
1347
|
+
x: E.rect.left + window.scrollX,
|
|
1348
|
+
y: E.rect.top + window.scrollY,
|
|
1349
|
+
width: E.rect.width,
|
|
1350
|
+
height: E.rect.height
|
|
1323
1351
|
}
|
|
1324
1352
|
})),
|
|
1325
|
-
textStyles: Se(
|
|
1353
|
+
textStyles: Se(I),
|
|
1326
1354
|
dirtyMask: e,
|
|
1327
1355
|
visibility: t,
|
|
1328
1356
|
isTraveler: !1,
|
|
1329
1357
|
captureLayer: r,
|
|
1330
|
-
isFixed:
|
|
1358
|
+
isFixed: I.position === "fixed",
|
|
1331
1359
|
nativeLayer: n,
|
|
1332
1360
|
nativeStyles: o ? q(q({
|
|
1333
1361
|
backgroundColor: "transparent",
|
|
1334
1362
|
backgroundImage: "",
|
|
1335
|
-
opacity:
|
|
1336
|
-
zIndex: (isNaN(parseInt(
|
|
1363
|
+
opacity: N && N.dataset[G.KEY] === G.VALUES.HIDE ? 1 : parseFloat(I.opacity),
|
|
1364
|
+
zIndex: (isNaN(parseInt(I.zIndex)) ? 0 : parseInt(I.zIndex)) + i,
|
|
1337
1365
|
borderRadius: "0px",
|
|
1338
1366
|
borderColor: "transparent",
|
|
1339
1367
|
borderWidth: "0px",
|
|
1340
1368
|
isTraveler: !1
|
|
1341
|
-
}, Se(
|
|
1369
|
+
}, Se(I)), o) : void 0,
|
|
1342
1370
|
nativeRect: o ? {
|
|
1343
|
-
x:
|
|
1344
|
-
y:
|
|
1345
|
-
width:
|
|
1346
|
-
height:
|
|
1371
|
+
x: Y + window.scrollX,
|
|
1372
|
+
y: F + window.scrollY,
|
|
1373
|
+
width: P - Y,
|
|
1374
|
+
height: D - F
|
|
1347
1375
|
} : void 0,
|
|
1348
1376
|
children: []
|
|
1349
1377
|
};
|
|
1350
1378
|
}
|
|
1351
1379
|
if (s.nodeType !== Node.ELEMENT_NODE)
|
|
1352
1380
|
return null;
|
|
1353
|
-
const
|
|
1381
|
+
const a = s, c = a.dataset[z.KEY];
|
|
1354
1382
|
let d = t, h = t;
|
|
1355
|
-
if (
|
|
1356
|
-
const
|
|
1357
|
-
for (const
|
|
1358
|
-
if (!Ee.includes(
|
|
1383
|
+
if (c) {
|
|
1384
|
+
const v = new Set(c.split(/\s+/));
|
|
1385
|
+
for (const A of v)
|
|
1386
|
+
if (!Ee.includes(A))
|
|
1359
1387
|
throw new Error(
|
|
1360
|
-
`[MirageEngine] Invalid filter token: '${
|
|
1388
|
+
`[MirageEngine] Invalid filter token: '${A}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1361
1389
|
);
|
|
1362
|
-
if (
|
|
1390
|
+
if (v.has(z.VALUES.END))
|
|
1363
1391
|
return null;
|
|
1364
|
-
if (
|
|
1392
|
+
if (v.has(z.VALUES.INCLUDE_TREE) && v.has(z.VALUES.EXCLUDE_TREE))
|
|
1365
1393
|
throw new Error(
|
|
1366
1394
|
"[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1367
1395
|
);
|
|
1368
|
-
if (
|
|
1396
|
+
if (v.has(z.VALUES.INCLUDE_SELF) && v.has(z.VALUES.EXCLUDE_SELF))
|
|
1369
1397
|
throw new Error(
|
|
1370
1398
|
"[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1371
1399
|
);
|
|
1372
|
-
|
|
1400
|
+
v.has(z.VALUES.INCLUDE_TREE) ? d = d | H : v.has(z.VALUES.EXCLUDE_TREE) && (d = d & ~H), h = d, v.has(z.VALUES.INCLUDE_SELF) ? h = h | H : v.has(z.VALUES.EXCLUDE_SELF) && (h = h & ~H);
|
|
1373
1401
|
}
|
|
1374
|
-
const u =
|
|
1402
|
+
const u = a.dataset[W.KEY];
|
|
1375
1403
|
if (u) {
|
|
1376
|
-
const
|
|
1377
|
-
for (const
|
|
1378
|
-
if (!Ee.includes(
|
|
1404
|
+
const v = new Set(u.split(/\s+/));
|
|
1405
|
+
for (const A of v)
|
|
1406
|
+
if (!Ee.includes(A))
|
|
1379
1407
|
throw new Error(
|
|
1380
|
-
`[MirageEngine] Invalid select token: '${
|
|
1408
|
+
`[MirageEngine] Invalid select token: '${A}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1381
1409
|
);
|
|
1382
|
-
if (
|
|
1410
|
+
if (v.has(W.VALUES.END))
|
|
1383
1411
|
return null;
|
|
1384
|
-
if (
|
|
1412
|
+
if (v.has(W.VALUES.INCLUDE_TREE) && v.has(W.VALUES.EXCLUDE_TREE))
|
|
1385
1413
|
throw new Error(
|
|
1386
1414
|
"[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1387
1415
|
);
|
|
1388
|
-
if (
|
|
1416
|
+
if (v.has(W.VALUES.INCLUDE_SELF) && v.has(W.VALUES.EXCLUDE_SELF))
|
|
1389
1417
|
throw new Error(
|
|
1390
1418
|
"[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1391
1419
|
);
|
|
1392
|
-
|
|
1420
|
+
v.has(W.VALUES.INCLUDE_TREE) ? d = d | K : v.has(W.VALUES.EXCLUDE_TREE) && (d = d & ~K), h = d, v.has(W.VALUES.INCLUDE_SELF) ? h = h | K : v.has(W.VALUES.EXCLUDE_SELF) && (h = h & ~K);
|
|
1393
1421
|
}
|
|
1394
|
-
const p =
|
|
1395
|
-
let
|
|
1422
|
+
const p = a.dataset[O.KEY];
|
|
1423
|
+
let f = !1, m = o ? q({}, o) : {}, b = n;
|
|
1396
1424
|
if (p) {
|
|
1397
|
-
let
|
|
1398
|
-
const
|
|
1399
|
-
let
|
|
1400
|
-
if (
|
|
1401
|
-
|
|
1402
|
-
const
|
|
1425
|
+
let v = 1;
|
|
1426
|
+
const A = p.indexOf("{"), B = p.lastIndexOf("}");
|
|
1427
|
+
let N = p;
|
|
1428
|
+
if (A !== -1 && B !== -1 && B > A) {
|
|
1429
|
+
N = p.substring(0, A).trim();
|
|
1430
|
+
const D = p.substring(A, B + 1);
|
|
1403
1431
|
try {
|
|
1404
|
-
|
|
1405
|
-
} catch (
|
|
1432
|
+
m = new Function("return " + D)();
|
|
1433
|
+
} catch (E) {
|
|
1406
1434
|
console.warn(
|
|
1407
|
-
`[MirageEngine] Failed to parse travel styles JSON: ${
|
|
1435
|
+
`[MirageEngine] Failed to parse travel styles JSON: ${D}`
|
|
1408
1436
|
);
|
|
1409
1437
|
}
|
|
1410
1438
|
}
|
|
1411
|
-
const
|
|
1412
|
-
let
|
|
1413
|
-
const
|
|
1414
|
-
if (
|
|
1415
|
-
|
|
1416
|
-
const
|
|
1417
|
-
if (
|
|
1418
|
-
|
|
1439
|
+
const I = N.split(/\s+/);
|
|
1440
|
+
let Y = !1;
|
|
1441
|
+
const F = I.indexOf(O.VALUES.TRAVELER);
|
|
1442
|
+
if (F !== -1) {
|
|
1443
|
+
f = !0, Y = !0;
|
|
1444
|
+
const D = I[F + 1];
|
|
1445
|
+
if (D && !isNaN(parseInt(D, 10)))
|
|
1446
|
+
v = parseInt(D, 10);
|
|
1419
1447
|
else {
|
|
1420
|
-
const
|
|
1421
|
-
|
|
1448
|
+
const E = I.find((j) => !isNaN(parseInt(j, 10)));
|
|
1449
|
+
E && (v = parseInt(E, 10));
|
|
1422
1450
|
}
|
|
1423
1451
|
}
|
|
1424
|
-
const
|
|
1425
|
-
if (
|
|
1426
|
-
const
|
|
1427
|
-
if (
|
|
1428
|
-
|
|
1429
|
-
else if (!
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1452
|
+
const P = I.indexOf(O.VALUES.NATIVE);
|
|
1453
|
+
if (P !== -1) {
|
|
1454
|
+
const D = I[P + 1];
|
|
1455
|
+
if (D && !isNaN(parseInt(D, 10)))
|
|
1456
|
+
b = parseInt(D, 10);
|
|
1457
|
+
else if (!f) {
|
|
1458
|
+
const E = I.find((j) => !isNaN(parseInt(j, 10)));
|
|
1459
|
+
E && (b = parseInt(E, 10));
|
|
1432
1460
|
}
|
|
1433
1461
|
}
|
|
1434
|
-
if (
|
|
1435
|
-
const
|
|
1436
|
-
if (
|
|
1462
|
+
if (Y) {
|
|
1463
|
+
const D = v + 1;
|
|
1464
|
+
if (D < r)
|
|
1437
1465
|
throw new Error(
|
|
1438
|
-
`[MirageEngine] Traveler layer (${
|
|
1466
|
+
`[MirageEngine] Traveler layer (${v}) cannot be smaller than inherited capture layer (${r - 1}).`
|
|
1439
1467
|
);
|
|
1440
|
-
r = Math.min(
|
|
1468
|
+
r = Math.min(D, O.MAX_LAYERS + 1);
|
|
1441
1469
|
}
|
|
1442
1470
|
}
|
|
1443
|
-
const
|
|
1444
|
-
let
|
|
1445
|
-
|
|
1446
|
-
const
|
|
1447
|
-
if (
|
|
1471
|
+
const R = a.dataset[Xe.KEY];
|
|
1472
|
+
let L;
|
|
1473
|
+
R && (L = JSON.parse(R));
|
|
1474
|
+
const T = a.getBoundingClientRect(), x = window.getComputedStyle(a);
|
|
1475
|
+
if (T.width === 0 || T.height === 0 || x.display === "none")
|
|
1448
1476
|
return null;
|
|
1449
|
-
let C =
|
|
1450
|
-
C || (C = Math.random().toString(36).substring(2, 11),
|
|
1451
|
-
const
|
|
1452
|
-
let
|
|
1453
|
-
if (
|
|
1454
|
-
|
|
1455
|
-
else if (
|
|
1456
|
-
const
|
|
1457
|
-
const
|
|
1477
|
+
let C = a.getAttribute("data-mid");
|
|
1478
|
+
C || (C = Math.random().toString(36).substring(2, 11), a.setAttribute("data-mid", C));
|
|
1479
|
+
const w = parseInt(x.zIndex), S = (isNaN(w) ? 0 : w) + i;
|
|
1480
|
+
let M;
|
|
1481
|
+
if (a.tagName === "IMG")
|
|
1482
|
+
M = a.src;
|
|
1483
|
+
else if (a.tagName.toLowerCase() === "svg") {
|
|
1484
|
+
const v = a.cloneNode(!0), A = m == null ? void 0 : m.color, B = m == null ? void 0 : m.fill, N = m == null ? void 0 : m.stroke, I = m == null ? void 0 : m.opacity, Y = (E, j) => {
|
|
1485
|
+
const X = window.getComputedStyle(E), Q = j, ke = X.fill === X.color, Ue = X.stroke === X.color, se = B || (ke ? A : void 0) || X.fill;
|
|
1458
1486
|
se && se !== "none" && (Q.style.fill = se);
|
|
1459
|
-
const ne =
|
|
1460
|
-
ne && ne !== "none" && (Q.style.stroke = ne),
|
|
1461
|
-
const ve =
|
|
1487
|
+
const ne = N || (Ue ? A : void 0) || X.stroke;
|
|
1488
|
+
ne && ne !== "none" && (Q.style.stroke = ne), X.strokeWidth && X.strokeWidth !== "0px" && (Q.style.strokeWidth = X.strokeWidth);
|
|
1489
|
+
const ve = A || X.color;
|
|
1462
1490
|
ve && (Q.style.color = ve);
|
|
1463
|
-
const oe =
|
|
1491
|
+
const oe = I || X.opacity;
|
|
1464
1492
|
oe && oe !== "1" && (Q.style.opacity = oe);
|
|
1465
|
-
for (let te = 0; te <
|
|
1466
|
-
|
|
1493
|
+
for (let te = 0; te < E.children.length; te++)
|
|
1494
|
+
Y(E.children[te], j.children[te]);
|
|
1467
1495
|
};
|
|
1468
|
-
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1471
|
-
let
|
|
1472
|
-
|
|
1496
|
+
Y(a, v);
|
|
1497
|
+
const F = a.getBoundingClientRect(), P = window.devicePixelRatio * l;
|
|
1498
|
+
v.hasAttribute("viewBox") || v.setAttribute("viewBox", `0 0 ${F.width} ${F.height}`), v.setAttribute("width", (F.width * P).toString()), v.setAttribute("height", (F.height * P).toString());
|
|
1499
|
+
let D = new XMLSerializer().serializeToString(v);
|
|
1500
|
+
D.includes("xmlns=") || (D = D.replace(
|
|
1473
1501
|
"<svg",
|
|
1474
1502
|
'<svg xmlns="http://www.w3.org/2000/svg"'
|
|
1475
|
-
)),
|
|
1476
|
-
} else if (
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1503
|
+
)), M = `data:image/svg+xml;utf8,${encodeURIComponent(D)}`;
|
|
1504
|
+
} else if (x.backgroundImage && x.backgroundImage !== "none") {
|
|
1505
|
+
const v = x.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
|
|
1506
|
+
v && (M = v[1]);
|
|
1479
1507
|
}
|
|
1480
1508
|
const k = {
|
|
1481
|
-
backgroundColor:
|
|
1482
|
-
backgroundImage:
|
|
1483
|
-
opacity:
|
|
1484
|
-
zIndex:
|
|
1485
|
-
borderRadius:
|
|
1486
|
-
borderColor:
|
|
1487
|
-
borderWidth:
|
|
1488
|
-
imageSrc:
|
|
1489
|
-
isTraveler:
|
|
1490
|
-
},
|
|
1491
|
-
let
|
|
1509
|
+
backgroundColor: x.backgroundColor,
|
|
1510
|
+
backgroundImage: x.backgroundImage,
|
|
1511
|
+
opacity: a.dataset[G.KEY] === G.VALUES.HIDE ? 1 : parseFloat(x.opacity),
|
|
1512
|
+
zIndex: S,
|
|
1513
|
+
borderRadius: x.borderRadius,
|
|
1514
|
+
borderColor: x.borderColor,
|
|
1515
|
+
borderWidth: x.borderWidth,
|
|
1516
|
+
imageSrc: M,
|
|
1517
|
+
isTraveler: f
|
|
1518
|
+
}, _ = k;
|
|
1519
|
+
let Ae, Ie;
|
|
1492
1520
|
const he = [];
|
|
1493
|
-
return
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1521
|
+
return a.tagName.toLowerCase() !== "svg" && Array.from(a.childNodes).forEach((v) => {
|
|
1522
|
+
const A = v.nodeType === Node.TEXT_NODE ? h : d, B = De(
|
|
1523
|
+
v,
|
|
1496
1524
|
e,
|
|
1497
|
-
|
|
1525
|
+
A,
|
|
1498
1526
|
r,
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1527
|
+
S,
|
|
1528
|
+
l,
|
|
1529
|
+
v.nodeType === Node.TEXT_NODE ? b : void 0,
|
|
1530
|
+
v.nodeType === Node.TEXT_NODE && Object.keys(m).length > 0 ? m : void 0
|
|
1503
1531
|
);
|
|
1504
|
-
|
|
1532
|
+
B && he.push(B);
|
|
1505
1533
|
}), {
|
|
1506
1534
|
id: C,
|
|
1507
1535
|
type: "BOX",
|
|
1508
|
-
element:
|
|
1536
|
+
element: a,
|
|
1509
1537
|
rect: {
|
|
1510
|
-
x:
|
|
1511
|
-
y:
|
|
1512
|
-
width:
|
|
1513
|
-
height:
|
|
1538
|
+
x: T.left + window.scrollX,
|
|
1539
|
+
y: T.top + window.scrollY,
|
|
1540
|
+
width: T.width,
|
|
1541
|
+
height: T.height
|
|
1514
1542
|
},
|
|
1515
|
-
styles:
|
|
1516
|
-
textContent:
|
|
1543
|
+
styles: _,
|
|
1544
|
+
textContent: Ae,
|
|
1517
1545
|
textStyles: Ie,
|
|
1518
1546
|
dirtyMask: e,
|
|
1519
1547
|
visibility: h,
|
|
1520
|
-
isTraveler:
|
|
1548
|
+
isTraveler: f,
|
|
1521
1549
|
captureLayer: r,
|
|
1522
|
-
nativeLayer:
|
|
1523
|
-
nativeStyles:
|
|
1524
|
-
backgroundColor: (de =
|
|
1525
|
-
backgroundImage: (ue =
|
|
1526
|
-
opacity: (fe =
|
|
1527
|
-
zIndex:
|
|
1528
|
-
borderRadius: (ge =
|
|
1529
|
-
borderColor: (pe =
|
|
1530
|
-
borderWidth: (me =
|
|
1531
|
-
isTraveler: k.isTraveler
|
|
1550
|
+
nativeLayer: b,
|
|
1551
|
+
nativeStyles: b !== void 0 ? be(q({}, k), {
|
|
1552
|
+
backgroundColor: (de = m.backgroundColor) != null ? de : k.backgroundColor,
|
|
1553
|
+
backgroundImage: (ue = m.backgroundImage) != null ? ue : k.backgroundImage,
|
|
1554
|
+
opacity: (fe = m.opacity) != null ? fe : k.opacity,
|
|
1555
|
+
zIndex: m.zIndex !== void 0 ? m.zIndex + S : k.zIndex,
|
|
1556
|
+
borderRadius: (ge = m.borderRadius) != null ? ge : k.borderRadius,
|
|
1557
|
+
borderColor: (pe = m.borderColor) != null ? pe : k.borderColor,
|
|
1558
|
+
borderWidth: (me = m.borderWidth) != null ? me : k.borderWidth,
|
|
1559
|
+
isTraveler: k.isTraveler,
|
|
1560
|
+
transform: m.transform
|
|
1532
1561
|
}) : void 0,
|
|
1533
|
-
nativeRect:
|
|
1534
|
-
x:
|
|
1535
|
-
y:
|
|
1536
|
-
width:
|
|
1537
|
-
height:
|
|
1562
|
+
nativeRect: b !== void 0 ? {
|
|
1563
|
+
x: m.x !== void 0 ? parseFloat(m.x) : T.left + window.scrollX,
|
|
1564
|
+
y: m.y !== void 0 ? parseFloat(m.y) : T.top + window.scrollY,
|
|
1565
|
+
width: m.width !== void 0 ? parseFloat(m.width) : T.width,
|
|
1566
|
+
height: m.height !== void 0 ? parseFloat(m.height) : T.height
|
|
1538
1567
|
} : void 0,
|
|
1539
|
-
isFixed:
|
|
1568
|
+
isFixed: x.position === "fixed",
|
|
1540
1569
|
children: he,
|
|
1541
|
-
shaderHooks:
|
|
1570
|
+
shaderHooks: L
|
|
1542
1571
|
};
|
|
1543
1572
|
}
|
|
1544
1573
|
function it(s, e) {
|
|
1545
1574
|
e.size !== 0 && e.forEach((t, r) => {
|
|
1546
|
-
var
|
|
1575
|
+
var l, n, o, a;
|
|
1547
1576
|
const i = s.get(r);
|
|
1548
|
-
!i || !i.userData.basePosition || (
|
|
1577
|
+
!i || !i.userData.basePosition || (V.forceUpdateUniforms(i.material, {
|
|
1549
1578
|
backgroundColor: t.backgroundColor,
|
|
1550
1579
|
backgroundImage: t.backgroundImage,
|
|
1551
1580
|
opacity: t.opacity,
|
|
1552
|
-
borderRadius: (n = t.borderRadius) != null ? n : (
|
|
1581
|
+
borderRadius: (n = t.borderRadius) != null ? n : (l = i.userData.baseStyles) == null ? void 0 : l.borderRadius
|
|
1553
1582
|
// width and height are no longer updated here, they are updated in syncMeshesByDOM
|
|
1554
|
-
}), i.userData.nativeMesh &&
|
|
1583
|
+
}), i.userData.nativeMesh && V.forceUpdateUniforms(i.userData.nativeMesh.material, {
|
|
1555
1584
|
backgroundColor: t.backgroundColor,
|
|
1556
1585
|
backgroundImage: t.backgroundImage,
|
|
1557
1586
|
opacity: t.opacity,
|
|
1558
|
-
borderRadius: (
|
|
1587
|
+
borderRadius: (a = t.borderRadius) != null ? a : (o = i.userData.baseStyles) == null ? void 0 : o.borderRadius
|
|
1559
1588
|
}));
|
|
1560
1589
|
});
|
|
1561
1590
|
}
|
|
1562
1591
|
class st {
|
|
1563
1592
|
constructor(e, t, r, i) {
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1593
|
+
g(this, "target");
|
|
1594
|
+
g(this, "renderer");
|
|
1595
|
+
g(this, "registry");
|
|
1596
|
+
g(this, "isTravelEnabled", !1);
|
|
1597
|
+
g(this, "tracker");
|
|
1569
1598
|
this.target = e, this.renderer = t, this.registry = r, this.tracker = new We(e, {
|
|
1570
1599
|
resizeDebounce: i.resizeDebounce
|
|
1571
|
-
}), this.tracker.onLayoutChange.add((
|
|
1572
|
-
document.querySelector(`[${
|
|
1573
|
-
const
|
|
1600
|
+
}), this.tracker.onLayoutChange.add((l, n) => {
|
|
1601
|
+
document.querySelector(`[${O.NAME}~='${O.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
|
|
1602
|
+
const a = De(
|
|
1574
1603
|
this.target,
|
|
1575
|
-
|
|
1576
|
-
|
|
1604
|
+
l,
|
|
1605
|
+
H,
|
|
1577
1606
|
1,
|
|
1578
1607
|
0,
|
|
1579
1608
|
this.renderer.qualityFactor
|
|
1580
1609
|
);
|
|
1581
|
-
|
|
1582
|
-
}), this.tracker.onStyleChange.add((
|
|
1583
|
-
it(this.registry,
|
|
1610
|
+
a && this.renderer.syncScene(a, n);
|
|
1611
|
+
}), this.tracker.onStyleChange.add((l) => {
|
|
1612
|
+
it(this.registry, l);
|
|
1584
1613
|
}), this.tracker.onRender.add(() => {
|
|
1585
1614
|
this.renderer.syncMeshesByDOM(), this.renderer.render();
|
|
1586
1615
|
});
|
|
@@ -1594,7 +1623,7 @@ class st {
|
|
|
1594
1623
|
}
|
|
1595
1624
|
class nt {
|
|
1596
1625
|
constructor() {
|
|
1597
|
-
|
|
1626
|
+
g(this, "store");
|
|
1598
1627
|
this.store = /* @__PURE__ */ new WeakMap();
|
|
1599
1628
|
}
|
|
1600
1629
|
register(e, t) {
|
|
@@ -1619,21 +1648,21 @@ class nt {
|
|
|
1619
1648
|
}
|
|
1620
1649
|
class lt {
|
|
1621
1650
|
constructor(e, t) {
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
var i,
|
|
1651
|
+
g(this, "renderer");
|
|
1652
|
+
g(this, "syncer");
|
|
1653
|
+
g(this, "target");
|
|
1654
|
+
g(this, "registry");
|
|
1655
|
+
var i, l, n;
|
|
1627
1656
|
if (this.target = e, this.registry = new nt(), !document.getElementById("mirage-engine-styles")) {
|
|
1628
1657
|
const o = document.createElement("style");
|
|
1629
1658
|
o.id = "mirage-engine-styles", o.textContent = `
|
|
1630
|
-
[${
|
|
1659
|
+
[${G.NAME}="${G.VALUES.HIDE}"] {
|
|
1631
1660
|
opacity: 0 !important;
|
|
1632
1661
|
}
|
|
1633
1662
|
`, document.head.appendChild(o);
|
|
1634
1663
|
}
|
|
1635
1664
|
let r;
|
|
1636
|
-
if (t.mode === "duplicate" ? r = (
|
|
1665
|
+
if (t.mode === "duplicate" ? r = (l = (i = t.container) != null ? i : this.target.parentElement) != null ? l : void 0 : r = (n = this.target.parentElement) != null ? n : void 0, !r)
|
|
1637
1666
|
throw new Error("[Mirage] Cannot find a container (parent or option).");
|
|
1638
1667
|
this.renderer = new tt(
|
|
1639
1668
|
this.target,
|
|
@@ -1672,10 +1701,10 @@ class lt {
|
|
|
1672
1701
|
ArrowUp: !1,
|
|
1673
1702
|
ArrowDown: !1
|
|
1674
1703
|
};
|
|
1675
|
-
window.addEventListener("keydown", (
|
|
1676
|
-
t[
|
|
1677
|
-
}), window.addEventListener("keyup", (
|
|
1678
|
-
t[
|
|
1704
|
+
window.addEventListener("keydown", (l) => {
|
|
1705
|
+
t[l.key] !== void 0 && (t[l.key] = !0);
|
|
1706
|
+
}), window.addEventListener("keyup", (l) => {
|
|
1707
|
+
t[l.key] !== void 0 && (t[l.key] = !1);
|
|
1679
1708
|
});
|
|
1680
1709
|
const r = 2, i = () => {
|
|
1681
1710
|
requestAnimationFrame(i), t.ArrowRight && e.position.setX(e.position.x + r), t.ArrowLeft && e.position.setX(e.position.x - r), t.ArrowUp && e.position.setY(e.position.y + r), t.ArrowDown && e.position.setY(e.position.y - r);
|
|
@@ -1685,24 +1714,24 @@ class lt {
|
|
|
1685
1714
|
}
|
|
1686
1715
|
export {
|
|
1687
1716
|
Ee as ALLOWED_FILTERS,
|
|
1688
|
-
|
|
1689
|
-
|
|
1717
|
+
G as ATTR_DOM,
|
|
1718
|
+
z as ATTR_FILTER,
|
|
1690
1719
|
at as ATTR_SANDWICH,
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1720
|
+
W as ATTR_SELECT,
|
|
1721
|
+
Xe as ATTR_SHADER,
|
|
1722
|
+
O as ATTR_TRAVEL,
|
|
1694
1723
|
ce as DIRTY_CONTENT,
|
|
1695
1724
|
re as DIRTY_NONE,
|
|
1696
1725
|
$ as DIRTY_RECT,
|
|
1697
1726
|
ie as DIRTY_STRUCTURE,
|
|
1698
1727
|
Z as DIRTY_STYLE,
|
|
1699
|
-
|
|
1728
|
+
ze as DIRTY_ZINDEX,
|
|
1700
1729
|
ct as EXCLUDED,
|
|
1701
1730
|
lt as Engine,
|
|
1702
1731
|
K as SELECT_LAYER,
|
|
1703
|
-
|
|
1732
|
+
U as THREE_LAYERS,
|
|
1704
1733
|
xe as TRAVEL_VALUES,
|
|
1705
1734
|
We as Tracker,
|
|
1706
|
-
|
|
1735
|
+
H as USER_LAYER,
|
|
1707
1736
|
Ye as extractFromStyle
|
|
1708
1737
|
};
|