@nebula-spatial/cad-loader 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +22 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1398 -1322
- package/dist/core/parser/bin-parser.d.ts +17 -4
- package/dist/core/parser/types.d.ts +2 -1
- package/dist/core/types.d.ts +6 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1096 -1053
- package/dist/loader/internal/external-variant-sidecar-fetch.d.ts +0 -1
- package/dist/loader/internal/geo-loader-pipeline.d.ts +2 -0
- package/dist/loader/internal/geo-node-builder.d.ts +1 -0
- package/dist/loader/internal/geo-node.d.ts +4 -0
- package/dist/loader/internal/geo-prepare-worker-types.d.ts +1 -0
- package/dist/render-resource/cad-render-node.d.ts +9 -0
- package/dist/session/cad-document-session.d.ts +8 -1
- package/dist/shared/text-builder.d.ts +25 -0
- package/dist/workers/geo-prepare.worker.js +1048 -974
- package/package.json +1 -1
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var rn = Object.defineProperty;
|
|
2
|
+
var te = (t) => {
|
|
3
3
|
throw TypeError(t);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
class
|
|
5
|
+
var on = (t, e, n) => e in t ? rn(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
6
|
+
var Q = (t, e, n) => on(t, typeof e != "symbol" ? e + "" : e, n), sn = (t, e, n) => e.has(t) || te("Cannot " + n);
|
|
7
|
+
var rt = (t, e, n) => (sn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), ee = (t, e, n) => e.has(t) ? te("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n);
|
|
8
|
+
class f extends Error {
|
|
9
9
|
constructor(n, r) {
|
|
10
10
|
super(r);
|
|
11
|
-
|
|
11
|
+
Q(this, "code");
|
|
12
12
|
this.name = "GeoLoaderError", this.code = n;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
function
|
|
15
|
+
const Bt = 4096;
|
|
16
|
+
function Ie(t) {
|
|
17
17
|
return t >= 6 ? "u16_lw" : t >= 5 ? "u8_lw" : t >= 4 ? "u16" : "u8";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function Re(t) {
|
|
20
20
|
return t === "u16_lw" ? 13 : t === "u8_lw" ? 12 : t === "u16" ? 9 : 8;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function Ve(t, e, n) {
|
|
23
23
|
return n === "u16" || n === "u16_lw" ? t.getUint16(e + 7, !0) : t.getUint8(e + 7);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function an(t) {
|
|
26
26
|
return t === "u16" || t === "u16_lw" ? 2 : 1;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function Ge(t, e, n) {
|
|
29
29
|
if (!(n !== "u8_lw" && n !== "u16_lw"))
|
|
30
|
-
return t.getFloat32(e + 7 +
|
|
30
|
+
return t.getFloat32(e + 7 + an(n), !0);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Ne(t, e, n, r, s = t.byteLength, o = "u8") {
|
|
33
33
|
if (n > s || s > t.byteLength)
|
|
34
|
-
throw new
|
|
34
|
+
throw new f("E_GROUP_RANGE", "Group byte range exceeds payload length");
|
|
35
35
|
let i = n;
|
|
36
|
-
const a = r * 2,
|
|
37
|
-
if (i +
|
|
38
|
-
throw new
|
|
39
|
-
let
|
|
36
|
+
const a = r * 2, u = a * 4;
|
|
37
|
+
if (i + u > s)
|
|
38
|
+
throw new f("E_GROUP_RANGE", "Group position bytes exceed payload length");
|
|
39
|
+
let c;
|
|
40
40
|
if (a > 0) {
|
|
41
|
-
const
|
|
42
|
-
for (let
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const p = new Uint8Array(t, i, u), h = new Uint8Array(u), y = a;
|
|
42
|
+
for (let w = 0; w < a; w++)
|
|
43
|
+
h[w * 4] = p[w], h[w * 4 + 1] = p[y + w], h[w * 4 + 2] = p[y * 2 + w], h[w * 4 + 3] = p[y * 3 + w];
|
|
44
|
+
c = new Float32Array(h.buffer);
|
|
45
45
|
} else
|
|
46
|
-
|
|
47
|
-
if (i +=
|
|
48
|
-
throw new
|
|
46
|
+
c = new Float32Array(0);
|
|
47
|
+
if (i += u, i + 4 > s)
|
|
48
|
+
throw new f("E_GROUP_RANGE", "Missing seg_count field for group");
|
|
49
49
|
const m = e.getUint32(i, !0);
|
|
50
50
|
i += 4;
|
|
51
51
|
const g = [];
|
|
52
|
-
let
|
|
53
|
-
const
|
|
54
|
-
for (let
|
|
55
|
-
if (i +
|
|
56
|
-
throw new
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
throw new
|
|
52
|
+
let l = 0;
|
|
53
|
+
const d = Re(o);
|
|
54
|
+
for (let p = 0; p < m; p++) {
|
|
55
|
+
if (i + d > s)
|
|
56
|
+
throw new f("E_GROUP_RANGE", "Segment record exceeds payload length");
|
|
57
|
+
const h = e.getUint32(i, !0), y = e.getUint8(i + 4), w = e.getUint8(i + 5), _ = e.getUint8(i + 6), E = Ve(e, i, o), A = Ge(e, i, o);
|
|
58
|
+
if (l + h > r)
|
|
59
|
+
throw new f("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
|
|
60
60
|
g.push({
|
|
61
|
-
startVertex:
|
|
62
|
-
vertexCount:
|
|
63
|
-
color: [
|
|
61
|
+
startVertex: l,
|
|
62
|
+
vertexCount: h,
|
|
63
|
+
color: [y, w, _],
|
|
64
64
|
layerIndex: E,
|
|
65
|
-
...
|
|
66
|
-
}), i +=
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
let N =
|
|
70
|
-
for (let
|
|
71
|
-
const
|
|
72
|
-
N +=
|
|
65
|
+
...A === void 0 ? {} : { lineweightPx: A }
|
|
66
|
+
}), i += d;
|
|
67
|
+
const U = l * 2;
|
|
68
|
+
if (h > 1) {
|
|
69
|
+
let N = c[U], C = c[U + 1];
|
|
70
|
+
for (let V = 1; V < h; V++) {
|
|
71
|
+
const G = U + V * 2;
|
|
72
|
+
N += c[G], C += c[G + 1], c[G] = N, c[G + 1] = C;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
l += h;
|
|
76
76
|
}
|
|
77
|
-
if (
|
|
78
|
-
throw new
|
|
77
|
+
if (l !== r)
|
|
78
|
+
throw new f("E_SEGMENT_SUM", `Segment vertex_count sum ${l} does not match group count ${r}`);
|
|
79
79
|
return {
|
|
80
|
-
chunk: { pos:
|
|
80
|
+
chunk: { pos: c, count: r, segments: g },
|
|
81
81
|
offset: i
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function un(t, e, n, r, s = "u8") {
|
|
85
85
|
const o = r * 2, i = o * 4;
|
|
86
86
|
if (n + i > t.byteLength)
|
|
87
|
-
throw new
|
|
87
|
+
throw new f("E_GROUP_RANGE", "Group position bytes exceed payload length");
|
|
88
88
|
const a = new Uint8Array(t, n, i);
|
|
89
|
-
let
|
|
90
|
-
if (
|
|
91
|
-
throw new
|
|
92
|
-
const
|
|
93
|
-
|
|
89
|
+
let u = n + i;
|
|
90
|
+
if (u + 4 > t.byteLength)
|
|
91
|
+
throw new f("E_GROUP_RANGE", "Missing seg_count field for group");
|
|
92
|
+
const c = e.getUint32(u, !0);
|
|
93
|
+
u += 4;
|
|
94
94
|
const m = [];
|
|
95
95
|
let g = 0;
|
|
96
|
-
const
|
|
97
|
-
for (let
|
|
98
|
-
if (
|
|
99
|
-
throw new
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
throw new
|
|
96
|
+
const l = Re(s);
|
|
97
|
+
for (let d = 0; d < c; d++) {
|
|
98
|
+
if (u + l > t.byteLength)
|
|
99
|
+
throw new f("E_GROUP_RANGE", "Segment record exceeds payload length");
|
|
100
|
+
const p = e.getUint32(u, !0), h = e.getUint8(u + 4), y = e.getUint8(u + 5), w = e.getUint8(u + 6), _ = Ve(e, u, s), E = Ge(e, u, s);
|
|
101
|
+
if (u += l, g + p > r)
|
|
102
|
+
throw new f("E_SEGMENT_SUM", "Segment vertex_count sum exceeds group count");
|
|
103
103
|
m.push({
|
|
104
104
|
startVertex: g,
|
|
105
|
-
vertexCount:
|
|
106
|
-
color: [
|
|
107
|
-
layerIndex:
|
|
105
|
+
vertexCount: p,
|
|
106
|
+
color: [h, y, w],
|
|
107
|
+
layerIndex: _,
|
|
108
108
|
...E === void 0 ? {} : { lineweightPx: E }
|
|
109
|
-
}), g +=
|
|
109
|
+
}), g += p;
|
|
110
110
|
}
|
|
111
111
|
if (g !== r)
|
|
112
|
-
throw new
|
|
112
|
+
throw new f("E_SEGMENT_SUM", `Segment vertex_count sum ${g} does not match group count ${r}`);
|
|
113
113
|
return {
|
|
114
114
|
shuffled: a,
|
|
115
115
|
plane: o,
|
|
116
116
|
segments: m,
|
|
117
|
-
offset:
|
|
117
|
+
offset: u
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function ln(t, e, n, r) {
|
|
121
121
|
if (r === 0)
|
|
122
122
|
return new Float32Array(0);
|
|
123
123
|
const s = new Uint8Array(r * 4);
|
|
@@ -125,8 +125,8 @@ function je(t, e, n, r) {
|
|
|
125
125
|
s[o * 4] = t[n + o], s[o * 4 + 1] = t[e + n + o], s[o * 4 + 2] = t[e * 2 + n + o], s[o * 4 + 3] = t[e * 3 + n + o];
|
|
126
126
|
return new Float32Array(s.buffer);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
const o =
|
|
128
|
+
function cn(t, e, n, r, s) {
|
|
129
|
+
const o = ln(
|
|
130
130
|
t.shuffled,
|
|
131
131
|
t.plane,
|
|
132
132
|
(e.startVertex + n) * 2,
|
|
@@ -135,12 +135,12 @@ function We(t, e, n, r, s) {
|
|
|
135
135
|
let i = (s == null ? void 0 : s[0]) ?? 0, a = (s == null ? void 0 : s[1]) ?? 0;
|
|
136
136
|
if (r > 0) {
|
|
137
137
|
n === 0 ? (i = o[0], a = o[1]) : (i += o[0], a += o[1], o[0] = i, o[1] = a);
|
|
138
|
-
for (let
|
|
139
|
-
const m =
|
|
138
|
+
for (let c = 1; c < r; c++) {
|
|
139
|
+
const m = c * 2;
|
|
140
140
|
i += o[m], a += o[m + 1], o[m] = i, o[m + 1] = a;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
const
|
|
143
|
+
const u = r > 0 ? [{
|
|
144
144
|
startVertex: 0,
|
|
145
145
|
vertexCount: r,
|
|
146
146
|
color: [e.color[0], e.color[1], e.color[2]],
|
|
@@ -148,30 +148,30 @@ function We(t, e, n, r, s) {
|
|
|
148
148
|
...e.lineweightPx === void 0 ? {} : { lineweightPx: e.lineweightPx }
|
|
149
149
|
}] : [];
|
|
150
150
|
return {
|
|
151
|
-
chunk: { pos: o, count: r, segments:
|
|
151
|
+
chunk: { pos: o, count: r, segments: u },
|
|
152
152
|
lastPoint: r > 0 ? [i, a] : s
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
function*
|
|
156
|
-
const o =
|
|
155
|
+
function* fn(t, e, n, r, s = "u8") {
|
|
156
|
+
const o = un(t, e, n, r, s);
|
|
157
157
|
if (r === 0)
|
|
158
158
|
return yield { pos: new Float32Array(0), count: 0, segments: [] }, o.offset;
|
|
159
159
|
for (const i of o.segments) {
|
|
160
160
|
let a = null;
|
|
161
|
-
for (let
|
|
162
|
-
const
|
|
161
|
+
for (let u = 0; u < i.vertexCount; u += Bt) {
|
|
162
|
+
const c = Math.min(Bt, i.vertexCount - u), m = cn(o, i, u, c, a);
|
|
163
163
|
a = m.lastPoint, yield m.chunk;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
return o.offset;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function Ue() {
|
|
169
169
|
const t = globalThis.TextDecoder;
|
|
170
170
|
if (!t)
|
|
171
|
-
throw new
|
|
171
|
+
throw new f("E_HEADER_JSON", "TextDecoder is required to parse CAD pack metadata");
|
|
172
172
|
return new t();
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function it(t) {
|
|
175
175
|
return t ? {
|
|
176
176
|
minX: t.minX,
|
|
177
177
|
minY: t.minY,
|
|
@@ -179,47 +179,47 @@ function ot(t) {
|
|
|
179
179
|
maxY: t.maxY
|
|
180
180
|
} : null;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function $t(t) {
|
|
183
183
|
return !!t && Number.isFinite(t.minX) && Number.isFinite(t.minY) && Number.isFinite(t.maxX) && Number.isFinite(t.maxY);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
return
|
|
185
|
+
function ht(t) {
|
|
186
|
+
return $t(t) ? it(t) : null;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
189
|
-
const n =
|
|
188
|
+
function Ce(t, e) {
|
|
189
|
+
const n = $t(t) ? t : null, r = $t(e) ? e : null;
|
|
190
190
|
return n ? r ? {
|
|
191
191
|
minX: Math.min(n.minX, r.minX),
|
|
192
192
|
minY: Math.min(n.minY, r.minY),
|
|
193
193
|
maxX: Math.max(n.maxX, r.maxX),
|
|
194
194
|
maxY: Math.max(n.maxY, r.maxY)
|
|
195
|
-
} :
|
|
195
|
+
} : it(n) : it(r);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function dn(t, e, n, r = 0, s = 1) {
|
|
198
198
|
if (e <= 0 || n <= 0) return null;
|
|
199
|
-
let o = Number.POSITIVE_INFINITY, i = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY,
|
|
199
|
+
let o = Number.POSITIVE_INFINITY, i = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY, u = Number.NEGATIVE_INFINITY, c = !1;
|
|
200
200
|
for (let m = 0; m < e; m += 1) {
|
|
201
|
-
const g = m * n,
|
|
202
|
-
!Number.isFinite(
|
|
201
|
+
const g = m * n, l = t[g + r], d = t[g + s];
|
|
202
|
+
!Number.isFinite(l) || !Number.isFinite(d) || (l < o && (o = l), d < i && (i = d), l > a && (a = l), d > u && (u = d), c = !0);
|
|
203
203
|
}
|
|
204
|
-
return
|
|
204
|
+
return c ? { minX: o, minY: i, maxX: a, maxY: u } : null;
|
|
205
205
|
}
|
|
206
|
-
function
|
|
207
|
-
const n = t.minX, r = t.minY, s = t.maxX, o = t.maxY, { matA: i, matB: a, matC:
|
|
208
|
-
let
|
|
209
|
-
return
|
|
206
|
+
function Se(t, e) {
|
|
207
|
+
const n = t.minX, r = t.minY, s = t.maxX, o = t.maxY, { matA: i, matB: a, matC: u, matD: c, tx: m, ty: g } = e;
|
|
208
|
+
let l = i * n + u * r + m, d = a * n + c * r + g, p = l, h = d, y = l, w = d;
|
|
209
|
+
return l = i * n + u * o + m, d = a * n + c * o + g, l < p && (p = l), d < h && (h = d), l > y && (y = l), d > w && (w = d), l = i * s + u * r + m, d = a * s + c * r + g, l < p && (p = l), d < h && (h = d), l > y && (y = l), d > w && (w = d), l = i * s + u * o + m, d = a * s + c * o + g, l < p && (p = l), d < h && (h = d), l > y && (y = l), d > w && (w = d), { minX: p, minY: h, maxX: y, maxY: w };
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function mn(t) {
|
|
212
212
|
return Math.hypot(t.maxX - t.minX, t.maxY - t.minY);
|
|
213
213
|
}
|
|
214
|
-
function
|
|
214
|
+
function gn(t, e) {
|
|
215
215
|
const n = (t.minX + t.maxX) / 2, r = (t.minY + t.maxY) / 2, s = (e.minX + e.maxX) / 2, o = (e.minY + e.maxY) / 2;
|
|
216
216
|
return Math.hypot(n - s, r - o);
|
|
217
217
|
}
|
|
218
|
-
const
|
|
219
|
-
function
|
|
218
|
+
const yn = {};
|
|
219
|
+
function ne(t) {
|
|
220
220
|
return typeof t == "object" && t !== null;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function dt(t, e) {
|
|
223
223
|
return Object.prototype.hasOwnProperty.call(t, e);
|
|
224
224
|
}
|
|
225
225
|
function K(t) {
|
|
@@ -234,10 +234,10 @@ function K(t) {
|
|
|
234
234
|
}
|
|
235
235
|
return e;
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
return new
|
|
237
|
+
function re(t, e, n, r) {
|
|
238
|
+
return new f("E_TEXT_ROUNDTRIP", `Text roundtrip mismatch at stage=${t} index=${e} path=${n}: ${r}`);
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function vt(t, e, n) {
|
|
241
241
|
if (Object.is(t, e)) return null;
|
|
242
242
|
if (Array.isArray(t)) {
|
|
243
243
|
if (!Array.isArray(e))
|
|
@@ -245,23 +245,23 @@ function St(t, e, n) {
|
|
|
245
245
|
if (t.length !== e.length)
|
|
246
246
|
return { path: K([...n, "length"]), reason: `array length ${t.length} !== ${e.length}` };
|
|
247
247
|
for (let r = 0; r < t.length; r += 1) {
|
|
248
|
-
const s =
|
|
248
|
+
const s = vt(t[r], e[r], [...n, r]);
|
|
249
249
|
if (s) return s;
|
|
250
250
|
}
|
|
251
251
|
return null;
|
|
252
252
|
}
|
|
253
|
-
if (
|
|
254
|
-
if (!
|
|
253
|
+
if (ne(t)) {
|
|
254
|
+
if (!ne(e) || Array.isArray(e))
|
|
255
255
|
return { path: K(n), reason: `expected object but found ${Array.isArray(e) ? "array" : typeof e}` };
|
|
256
256
|
const r = Object.keys(t), s = Object.keys(e);
|
|
257
257
|
if (r.length !== s.length) {
|
|
258
|
-
const o = r.find((a) => !
|
|
258
|
+
const o = r.find((a) => !dt(e, a));
|
|
259
259
|
if (o !== void 0)
|
|
260
260
|
return {
|
|
261
261
|
path: K([...n, o]),
|
|
262
262
|
reason: "missing key on actual"
|
|
263
263
|
};
|
|
264
|
-
const i = s.find((a) => !
|
|
264
|
+
const i = s.find((a) => !dt(t, a));
|
|
265
265
|
if (i !== void 0)
|
|
266
266
|
return {
|
|
267
267
|
path: K([...n, i]),
|
|
@@ -269,109 +269,109 @@ function St(t, e, n) {
|
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
271
|
for (const o of r) {
|
|
272
|
-
if (!
|
|
272
|
+
if (!dt(e, o))
|
|
273
273
|
return { path: K([...n, o]), reason: "missing key on actual" };
|
|
274
|
-
const i =
|
|
274
|
+
const i = vt(t[o], e[o], [...n, o]);
|
|
275
275
|
if (i) return i;
|
|
276
276
|
}
|
|
277
277
|
for (const o of s)
|
|
278
|
-
if (!
|
|
278
|
+
if (!dt(t, o))
|
|
279
279
|
return { path: K([...n, o]), reason: "extra key on actual" };
|
|
280
280
|
return null;
|
|
281
281
|
}
|
|
282
282
|
return { path: K(n), reason: `expected ${String(t)} but found ${String(e)}` };
|
|
283
283
|
}
|
|
284
|
-
function
|
|
285
|
-
return
|
|
284
|
+
function hn(t, e) {
|
|
285
|
+
return vt(t, e, []);
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function oe(t) {
|
|
288
288
|
if (t === !0 || t === "1" || t === "true") return !0;
|
|
289
289
|
if (t === !1 || t === "0" || t === "false") return !1;
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function _n() {
|
|
292
292
|
var s, o;
|
|
293
|
-
const t = globalThis.process, e =
|
|
293
|
+
const t = globalThis.process, e = oe(
|
|
294
294
|
((s = t == null ? void 0 : t.env) == null ? void 0 : s.DXF_STRICT_TEXT_ROUNDTRIP) ?? ((o = t == null ? void 0 : t.env) == null ? void 0 : o.VITE_DXF_STRICT_TEXT_ROUNDTRIP)
|
|
295
295
|
);
|
|
296
296
|
if (e !== void 0) return e;
|
|
297
|
-
const n =
|
|
297
|
+
const n = yn, r = oe(n == null ? void 0 : n.VITE_DXF_STRICT_TEXT_ROUNDTRIP);
|
|
298
298
|
return r !== void 0 ? r : !1;
|
|
299
299
|
}
|
|
300
|
-
function
|
|
300
|
+
function xn(t, e, n) {
|
|
301
301
|
if (e.length !== n.length)
|
|
302
|
-
throw
|
|
302
|
+
throw re(t, Math.min(e.length, n.length), "$length", `text count ${e.length} !== ${n.length}`);
|
|
303
303
|
for (let r = 0; r < e.length; r += 1) {
|
|
304
|
-
const s =
|
|
304
|
+
const s = hn(e[r], n[r]);
|
|
305
305
|
if (s)
|
|
306
|
-
throw
|
|
306
|
+
throw re(t, r, s.path, s.reason);
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
|
-
|
|
310
|
-
function
|
|
309
|
+
Ue();
|
|
310
|
+
function se(t, e) {
|
|
311
311
|
if (t > BigInt(Number.MAX_SAFE_INTEGER))
|
|
312
|
-
throw new
|
|
312
|
+
throw new f("E_GROUP_RANGE", `${e} exceeds safe integer range`);
|
|
313
313
|
return Number(t);
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function ie(t, e, n, r) {
|
|
316
316
|
if (!Number.isInteger(t) || !Number.isInteger(e) || t < 0 || e < 0 || t + e > n)
|
|
317
|
-
throw new
|
|
317
|
+
throw new f("E_GROUP_RANGE", `${r} exceeds payload length`);
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function En(t) {
|
|
320
320
|
if (t.byteLength < 4) return !1;
|
|
321
321
|
const e = new Uint8Array(t, 0, 4);
|
|
322
322
|
return e[0] === 68 && e[1] === 88 && e[2] === 66 && e[3] === 83;
|
|
323
323
|
}
|
|
324
|
-
function
|
|
324
|
+
function wn(t) {
|
|
325
325
|
if (t.byteLength < 20)
|
|
326
|
-
throw new
|
|
327
|
-
if (!
|
|
328
|
-
throw new
|
|
329
|
-
const e = new DataView(t), n = e.getUint16(4, !0), r = e.getUint16(6, !0), s = e.getUint16(8, !0), o = e.getUint16(10, !0), i = e.getUint16(12, !0), a = e.getUint16(14, !0),
|
|
326
|
+
throw new f("E_HEADER", "DXBS payload too small: missing container header");
|
|
327
|
+
if (!En(t))
|
|
328
|
+
throw new f("E_HEADER", "DXBS payload missing magic");
|
|
329
|
+
const e = new DataView(t), n = e.getUint16(4, !0), r = e.getUint16(6, !0), s = e.getUint16(8, !0), o = e.getUint16(10, !0), i = e.getUint16(12, !0), a = e.getUint16(14, !0), u = e.getUint32(16, !0);
|
|
330
330
|
if (n !== 3 || r < 3 || r > 6)
|
|
331
|
-
throw new
|
|
331
|
+
throw new f("E_GROUP_RANGE", `Unsupported DXBS version: ${n}.${r}`);
|
|
332
332
|
if (s !== 0)
|
|
333
|
-
throw new
|
|
333
|
+
throw new f("E_GROUP_RANGE", `Unsupported DXBS sidecar kind: ${s}`);
|
|
334
334
|
if (a !== 0)
|
|
335
|
-
throw new
|
|
335
|
+
throw new f("E_GROUP_RANGE", `Invalid DXBS reserved field: ${a}`);
|
|
336
336
|
if (o < 24)
|
|
337
|
-
throw new
|
|
338
|
-
if (
|
|
339
|
-
throw new
|
|
340
|
-
const
|
|
341
|
-
|
|
337
|
+
throw new f("E_GROUP_RANGE", `Invalid DXBS directory entry size: ${o}`);
|
|
338
|
+
if (u !== o * i)
|
|
339
|
+
throw new f("E_GROUP_RANGE", "DXBS directory byte size mismatch");
|
|
340
|
+
const c = 20;
|
|
341
|
+
ie(c, u, t.byteLength, "DXBS section directory");
|
|
342
342
|
const m = /* @__PURE__ */ new Map();
|
|
343
343
|
for (let g = 0; g < i; g += 1) {
|
|
344
|
-
const
|
|
345
|
-
if (
|
|
346
|
-
throw new
|
|
347
|
-
if (
|
|
348
|
-
throw new
|
|
349
|
-
|
|
344
|
+
const l = c + g * o, d = e.getUint16(l, !0), p = e.getUint16(l + 2, !0), h = e.getUint32(l + 4, !0), y = se(e.getBigUint64(l + 8, !0), "DXBS section offset"), w = se(e.getBigUint64(l + 16, !0), "DXBS section length");
|
|
345
|
+
if (p !== 0)
|
|
346
|
+
throw new f("E_GROUP_RANGE", `Unsupported DXBS section flags for type ${d}: ${p}`);
|
|
347
|
+
if (h !== 0)
|
|
348
|
+
throw new f("E_GROUP_RANGE", `Invalid DXBS section reserved field for type ${d}: ${h}`);
|
|
349
|
+
ie(y, w, t.byteLength, `DXBS section ${d}`), m.set(d, { type: d, flags: p, offset: y, length: w });
|
|
350
350
|
}
|
|
351
351
|
return { versionMajor: n, versionMinor: r, sections: m };
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function pn(t, e, n) {
|
|
354
354
|
const r = t.sections.get(e);
|
|
355
355
|
if (!r)
|
|
356
|
-
throw new
|
|
356
|
+
throw new f("E_GROUP_RANGE", `Missing DXBS section ${n}`);
|
|
357
357
|
return r;
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function bn() {
|
|
360
360
|
return {
|
|
361
361
|
pos: new Float32Array(0),
|
|
362
362
|
count: 0,
|
|
363
363
|
segments: []
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
function
|
|
366
|
+
function Ot(t) {
|
|
367
367
|
if (t.segments && t.segments.length > 0)
|
|
368
|
-
return
|
|
368
|
+
return In(t.segments, t.count), t.segments;
|
|
369
369
|
if (t.count <= 0) return [];
|
|
370
370
|
if (!t.col || !t.lay)
|
|
371
|
-
throw new
|
|
372
|
-
return
|
|
371
|
+
throw new f("E_GROUP_RANGE", "Geometry chunk is missing segment or expanded color/layer metadata");
|
|
372
|
+
return An(t.col, t.lay, t.count);
|
|
373
373
|
}
|
|
374
|
-
function
|
|
374
|
+
function ae(t) {
|
|
375
375
|
const e = [];
|
|
376
376
|
for (const n of t) {
|
|
377
377
|
const r = e[e.length - 1];
|
|
@@ -385,66 +385,67 @@ function ee(t) {
|
|
|
385
385
|
e.push({
|
|
386
386
|
startVertex: n.startVertex,
|
|
387
387
|
vertexCount: n.vertexCount,
|
|
388
|
-
color:
|
|
388
|
+
color: Rn(n),
|
|
389
389
|
layerIndex: n.layerIndex,
|
|
390
390
|
...n.lineweightPx === void 0 ? {} : { lineweightPx: n.lineweightPx }
|
|
391
391
|
});
|
|
392
392
|
}
|
|
393
393
|
return e;
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function An(t, e, n) {
|
|
396
396
|
if (t.length < n * 3 || e.length < n)
|
|
397
|
-
throw new
|
|
397
|
+
throw new f("E_GROUP_RANGE", "Expanded color/layer metadata is shorter than geometry count");
|
|
398
398
|
const r = [];
|
|
399
399
|
let s = 0;
|
|
400
400
|
for (; s < n; ) {
|
|
401
|
-
const o = s * 3, i = t[o] ?? 0, a = t[o + 1] ?? 0,
|
|
401
|
+
const o = s * 3, i = t[o] ?? 0, a = t[o + 1] ?? 0, u = t[o + 2] ?? 0, c = e[s] ?? 0;
|
|
402
402
|
let m = s + 1;
|
|
403
403
|
for (; m < n; ) {
|
|
404
404
|
const g = m * 3;
|
|
405
|
-
if (e[m] !==
|
|
405
|
+
if (e[m] !== c || t[g] !== i || t[g + 1] !== a || t[g + 2] !== u)
|
|
406
406
|
break;
|
|
407
407
|
m += 1;
|
|
408
408
|
}
|
|
409
409
|
r.push({
|
|
410
410
|
startVertex: s,
|
|
411
411
|
vertexCount: m - s,
|
|
412
|
-
color: [i, a,
|
|
413
|
-
layerIndex:
|
|
412
|
+
color: [i, a, u],
|
|
413
|
+
layerIndex: c
|
|
414
414
|
}), s = m;
|
|
415
415
|
}
|
|
416
416
|
return r;
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function In(t, e) {
|
|
419
419
|
let n = 0;
|
|
420
420
|
for (const r of t) {
|
|
421
421
|
if (r.vertexCount < 0 || r.startVertex !== n)
|
|
422
|
-
throw new
|
|
422
|
+
throw new f("E_SEGMENT_SUM", "Geometry segments must be contiguous and non-negative");
|
|
423
423
|
n += r.vertexCount;
|
|
424
424
|
}
|
|
425
425
|
if (n !== e)
|
|
426
|
-
throw new
|
|
426
|
+
throw new f("E_SEGMENT_SUM", `Geometry segment vertex sum ${n} does not match count ${e}`);
|
|
427
427
|
}
|
|
428
|
-
function
|
|
428
|
+
function Rn(t) {
|
|
429
429
|
return [t.color[0], t.color[1], t.color[2]];
|
|
430
430
|
}
|
|
431
|
-
const
|
|
432
|
-
function
|
|
431
|
+
const Vn = 8e6, Lt = Ue(), Gn = ["left", "center", "right"], Nn = ["top", "middle", "bottom", "alphabetic"];
|
|
432
|
+
function ue(t, e, n) {
|
|
433
433
|
for (const r of t)
|
|
434
434
|
n(r);
|
|
435
435
|
for (const r of e)
|
|
436
436
|
n(r);
|
|
437
437
|
}
|
|
438
|
-
|
|
438
|
+
const Te = /* @__PURE__ */ new WeakSet();
|
|
439
|
+
function st(t) {
|
|
439
440
|
return typeof t == "object" && t !== null;
|
|
440
441
|
}
|
|
441
|
-
function
|
|
442
|
+
function Un(t) {
|
|
442
443
|
return Array.isArray(t) ? "array" : t === null ? "null" : typeof t;
|
|
443
444
|
}
|
|
444
|
-
function
|
|
445
|
-
return !(!
|
|
445
|
+
function Cn(t) {
|
|
446
|
+
return !(!st(t) || Array.isArray(t) || typeof t.t != "string" || typeof t.x != "number" || typeof t.y != "number" || typeof t.h != "number" || typeof t.r != "number" || !Array.isArray(t.c) || t.c.length !== 3 || !t.c.every((e) => typeof e == "number") || typeof t.li != "number" || t.ha !== "left" && t.ha !== "center" && t.ha !== "right" || t.va !== "top" && t.va !== "middle" && t.va !== "bottom" && t.va !== "alphabetic" || typeof t.lh != "number" || t.w !== void 0 && typeof t.w != "number" || t.wf !== void 0 && typeof t.wf != "number" || t.iv !== void 0 && typeof t.iv != "number" || t.io !== void 0 && typeof t.io != "number" || t.mx !== void 0 && t.mx !== !0 || t.my !== void 0 && t.my !== !0);
|
|
446
447
|
}
|
|
447
|
-
function
|
|
448
|
+
function Sn(t) {
|
|
448
449
|
return t.map((e, n) => ({
|
|
449
450
|
index: n,
|
|
450
451
|
name: e.name,
|
|
@@ -453,26 +454,27 @@ function _n(t) {
|
|
|
453
454
|
visible: e.visible ?? !0
|
|
454
455
|
}));
|
|
455
456
|
}
|
|
456
|
-
function
|
|
457
|
-
const e = t.texts, n = Array.isArray(e) ? e : [], r = n.filter(
|
|
457
|
+
function Pe(t) {
|
|
458
|
+
const e = t.texts, n = Array.isArray(e) ? e : [], r = n.filter(Cn), s = _n();
|
|
458
459
|
if (s && e !== void 0 && !Array.isArray(e))
|
|
459
|
-
throw new
|
|
460
|
+
throw new f(
|
|
460
461
|
"E_TEXT_ROUNDTRIP",
|
|
461
|
-
`Text roundtrip mismatch at stage=Boundary-2:header->stream index=0 path=$: expected array but found ${
|
|
462
|
+
`Text roundtrip mismatch at stage=Boundary-2:header->stream index=0 path=$: expected array but found ${Un(e)}`
|
|
462
463
|
);
|
|
463
|
-
return s &&
|
|
464
|
+
return s && xn("Boundary-2:header->stream", n, r), {
|
|
464
465
|
bounds: [...t.bounds],
|
|
465
466
|
entityCount: Number(t.entity_count || 0),
|
|
466
467
|
lineCount: Number(t.line_count || 0),
|
|
467
468
|
fillCount: Number(t.fill_count || 0),
|
|
468
469
|
dotCount: Number(t.dot_count || 0),
|
|
469
470
|
textCount: r.length,
|
|
470
|
-
layers:
|
|
471
|
-
texts: r
|
|
471
|
+
layers: Sn(t.layers ?? []),
|
|
472
|
+
texts: r,
|
|
473
|
+
units: t.units
|
|
472
474
|
};
|
|
473
475
|
}
|
|
474
|
-
function
|
|
475
|
-
const e = t == null ? void 0 : t.maxExpandedInstanceVertices, n = typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.floor(e) :
|
|
476
|
+
function Tn(t) {
|
|
477
|
+
const e = t == null ? void 0 : t.maxExpandedInstanceVertices, n = typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.floor(e) : Vn;
|
|
476
478
|
return {
|
|
477
479
|
hiddenInstanceIds: t != null && t.hiddenInstanceIds ? new Set(t.hiddenInstanceIds) : /* @__PURE__ */ new Set(),
|
|
478
480
|
keepTextsForHiddenInstances: (t == null ? void 0 : t.keepTextsForHiddenInstances) === !0,
|
|
@@ -483,27 +485,28 @@ function xn(t) {
|
|
|
483
485
|
externalVariantBuffers: t == null ? void 0 : t.externalVariantBuffers,
|
|
484
486
|
requiredExternalVariantIds: t == null ? void 0 : t.requiredExternalVariantIds,
|
|
485
487
|
externalVariantDeltaOnly: (t == null ? void 0 : t.externalVariantDeltaOnly) === !0,
|
|
486
|
-
deferExternalVariantGeometry: (t == null ? void 0 : t.deferExternalVariantGeometry) === !0
|
|
488
|
+
deferExternalVariantGeometry: (t == null ? void 0 : t.deferExternalVariantGeometry) === !0,
|
|
489
|
+
cacheDocument: (t == null ? void 0 : t.cacheDocument) === !0
|
|
487
490
|
};
|
|
488
491
|
}
|
|
489
|
-
function
|
|
492
|
+
function Pn(t) {
|
|
490
493
|
return t.loadBlocks && !t.suppressExpandedInsertGeometry;
|
|
491
494
|
}
|
|
492
|
-
function
|
|
493
|
-
return
|
|
495
|
+
function Be(t, e) {
|
|
496
|
+
return Pn(e) && !e.hiddenInstanceIds.has(t);
|
|
494
497
|
}
|
|
495
|
-
function
|
|
498
|
+
function Bn(t, e, n) {
|
|
496
499
|
if (n <= 0)
|
|
497
500
|
return;
|
|
498
501
|
const r = t.expandedInstanceVertices + n;
|
|
499
502
|
if (r > t.maxExpandedInstanceVertices)
|
|
500
|
-
throw new
|
|
503
|
+
throw new f(
|
|
501
504
|
"E_EXPANSION_BUDGET",
|
|
502
505
|
`CPU-expanded ${e} instance vertices exceed budget: ${r}/${t.maxExpandedInstanceVertices}. Disable block loading or raise maxExpandedInstanceVertices.`
|
|
503
506
|
);
|
|
504
507
|
t.expandedInstanceVertices = r;
|
|
505
508
|
}
|
|
506
|
-
function
|
|
509
|
+
function $n(t, e, n) {
|
|
507
510
|
return n.loadBlocks ? n.hiddenInstanceIds.size === 0 || n.keepTextsForHiddenInstances ? t : t.filter((r) => {
|
|
508
511
|
if (!Number.isInteger(r.iv) || !Number.isInteger(r.io))
|
|
509
512
|
return !0;
|
|
@@ -511,7 +514,7 @@ function pn(t, e, n) {
|
|
|
511
514
|
return s === void 0 || !n.hiddenInstanceIds.has(s);
|
|
512
515
|
}) : t.filter((r) => !Number.isInteger(r.iv) || !Number.isInteger(r.io));
|
|
513
516
|
}
|
|
514
|
-
function
|
|
517
|
+
function vn(t, e) {
|
|
515
518
|
const n = /* @__PURE__ */ new Map();
|
|
516
519
|
return t.forEach((r, s) => {
|
|
517
520
|
if (!Number.isInteger(r.iv) || !Number.isInteger(r.io))
|
|
@@ -523,43 +526,43 @@ function bn(t, e) {
|
|
|
523
526
|
i ? i.push(s) : n.set(o, [s]);
|
|
524
527
|
}), n;
|
|
525
528
|
}
|
|
526
|
-
function
|
|
527
|
-
const a = e.map((
|
|
528
|
-
id:
|
|
529
|
-
blockName:
|
|
530
|
-
line: n[
|
|
531
|
-
fill: n[
|
|
532
|
-
dot: n[
|
|
533
|
-
texts: r.get(
|
|
529
|
+
function On(t, e, n, r, s, o, i) {
|
|
530
|
+
const a = e.map((u, c) => ({
|
|
531
|
+
id: u.id,
|
|
532
|
+
blockName: $e(u, c),
|
|
533
|
+
line: n[c].line,
|
|
534
|
+
fill: n[c].fill,
|
|
535
|
+
dot: n[c].dot,
|
|
536
|
+
texts: r.get(u.id) ?? []
|
|
534
537
|
}));
|
|
535
538
|
return {
|
|
536
539
|
layer0Index: t,
|
|
537
540
|
variants: a,
|
|
538
541
|
instances: s,
|
|
539
|
-
textIndexesByInstanceId:
|
|
542
|
+
textIndexesByInstanceId: vn(o, i),
|
|
540
543
|
ownerInstanceIdByVariantOrdinal: i
|
|
541
544
|
};
|
|
542
545
|
}
|
|
543
|
-
function
|
|
546
|
+
function Mn(t) {
|
|
544
547
|
if (t.byteLength < 4)
|
|
545
|
-
throw new
|
|
548
|
+
throw new f("E_HEADER", "Payload too small: missing header length");
|
|
546
549
|
const e = new DataView(t), n = e.getUint32(0, !0), r = 4, s = r + n;
|
|
547
550
|
if (s > t.byteLength)
|
|
548
|
-
throw new
|
|
551
|
+
throw new f("E_HEADER", "Header length exceeds payload length");
|
|
549
552
|
let o;
|
|
550
553
|
try {
|
|
551
|
-
o = JSON.parse(
|
|
554
|
+
o = JSON.parse(Lt.decode(new Uint8Array(t, r, n)));
|
|
552
555
|
} catch (i) {
|
|
553
|
-
throw new
|
|
556
|
+
throw new f("E_HEADER_JSON", `Invalid JSON header: ${i.message}`);
|
|
554
557
|
}
|
|
555
558
|
return {
|
|
556
559
|
meta: o,
|
|
557
|
-
header:
|
|
560
|
+
header: Pe(o),
|
|
558
561
|
dataOffset: s,
|
|
559
562
|
view: e
|
|
560
563
|
};
|
|
561
564
|
}
|
|
562
|
-
function
|
|
565
|
+
function $e(t, e) {
|
|
563
566
|
var o, i, a;
|
|
564
567
|
const n = (o = t.name) == null ? void 0 : o.trim();
|
|
565
568
|
if (n)
|
|
@@ -570,145 +573,145 @@ function Ne(t, e) {
|
|
|
570
573
|
const s = (a = t.blockName) == null ? void 0 : a.trim();
|
|
571
574
|
return s || `block_${e}`;
|
|
572
575
|
}
|
|
573
|
-
function
|
|
576
|
+
function kn(t) {
|
|
574
577
|
const e = Number(t.version ?? 1), n = String(t.encoding ?? "").toLowerCase();
|
|
575
578
|
if (e === 2) {
|
|
576
579
|
const r = n ? ` ${n}` : "";
|
|
577
|
-
throw new
|
|
580
|
+
throw new f(
|
|
578
581
|
"E_UNSUPPORTED_PACK_VERSION",
|
|
579
582
|
`当前文件是 V2${r} pack,前端不再兼容解析;请升级到最新版本后再打开。`
|
|
580
583
|
);
|
|
581
584
|
}
|
|
582
585
|
}
|
|
583
|
-
function
|
|
584
|
-
const e =
|
|
585
|
-
return
|
|
586
|
+
function Dn(t) {
|
|
587
|
+
const e = Mn(t);
|
|
588
|
+
return kn(e.meta), e;
|
|
586
589
|
}
|
|
587
|
-
function
|
|
590
|
+
function ve(t) {
|
|
588
591
|
if (t.byteLength < 4)
|
|
589
592
|
return !1;
|
|
590
593
|
const e = new Uint8Array(t, 0, 4);
|
|
591
594
|
return e[0] === 68 && e[1] === 88 && e[2] === 66 && e[3] === 51;
|
|
592
595
|
}
|
|
593
|
-
function
|
|
596
|
+
function le(t, e) {
|
|
594
597
|
if (t > BigInt(Number.MAX_SAFE_INTEGER))
|
|
595
|
-
throw new
|
|
598
|
+
throw new f("E_GROUP_RANGE", `${e} exceeds safe integer range`);
|
|
596
599
|
return Number(t);
|
|
597
600
|
}
|
|
598
|
-
function
|
|
601
|
+
function at(t, e, n, r) {
|
|
599
602
|
if (!Number.isInteger(t) || !Number.isInteger(e) || t < 0 || e < 0 || t + e > n)
|
|
600
|
-
throw new
|
|
603
|
+
throw new f("E_GROUP_RANGE", `${r} exceeds payload length`);
|
|
601
604
|
}
|
|
602
|
-
function
|
|
605
|
+
function Ln(t) {
|
|
603
606
|
if (t.byteLength < 20)
|
|
604
|
-
throw new
|
|
607
|
+
throw new f("E_HEADER", "V3 payload too small: missing container header");
|
|
605
608
|
const e = new DataView(t), n = e.getUint16(4, !0), r = e.getUint16(6, !0), s = e.getUint32(8, !0), o = e.getUint16(12, !0), i = e.getUint16(14, !0), a = e.getUint32(16, !0);
|
|
606
609
|
if (n !== 3 || r > 6)
|
|
607
|
-
throw new
|
|
610
|
+
throw new f("E_GROUP_RANGE", `Unsupported V3 version: ${n}.${r}`);
|
|
608
611
|
if (s !== 0)
|
|
609
|
-
throw new
|
|
612
|
+
throw new f("E_GROUP_RANGE", `Unsupported V3 file flags: ${s}`);
|
|
610
613
|
if (o < 24)
|
|
611
|
-
throw new
|
|
614
|
+
throw new f("E_GROUP_RANGE", `Invalid V3 directory entry size: ${o}`);
|
|
612
615
|
if (a !== o * i)
|
|
613
|
-
throw new
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
const
|
|
616
|
+
throw new f("E_GROUP_RANGE", "V3 directory byte size mismatch");
|
|
617
|
+
const u = 20;
|
|
618
|
+
at(u, a, t.byteLength, "V3 section directory");
|
|
619
|
+
const c = /* @__PURE__ */ new Map();
|
|
617
620
|
for (let m = 0; m < i; m += 1) {
|
|
618
|
-
const g =
|
|
619
|
-
if (
|
|
620
|
-
throw new
|
|
621
|
-
if (
|
|
622
|
-
throw new
|
|
623
|
-
|
|
621
|
+
const g = u + m * o, l = e.getUint16(g, !0), d = e.getUint16(g + 2, !0), p = e.getUint32(g + 4, !0), h = le(e.getBigUint64(g + 8, !0), "V3 section offset"), y = le(e.getBigUint64(g + 16, !0), "V3 section length");
|
|
622
|
+
if (d !== 0)
|
|
623
|
+
throw new f("E_GROUP_RANGE", `Unsupported V3 section flags for type ${l}: ${d}`);
|
|
624
|
+
if (p !== 0)
|
|
625
|
+
throw new f("E_GROUP_RANGE", `Invalid V3 section reserved field for type ${l}: ${p}`);
|
|
626
|
+
at(h, y, t.byteLength, `V3 section ${l}`), c.set(l, { type: l, flags: d, offset: h, length: y });
|
|
624
627
|
}
|
|
625
|
-
return { versionMinor: r, sections:
|
|
628
|
+
return { versionMinor: r, sections: c };
|
|
626
629
|
}
|
|
627
|
-
function
|
|
630
|
+
function tt(t, e, n) {
|
|
628
631
|
const r = t.get(e);
|
|
629
632
|
if (!r)
|
|
630
|
-
throw new
|
|
633
|
+
throw new f("E_GROUP_RANGE", `Missing V3 section ${n}`);
|
|
631
634
|
return r;
|
|
632
635
|
}
|
|
633
|
-
function
|
|
636
|
+
function pt(t, e) {
|
|
634
637
|
return t.get(e) ?? { type: e, flags: 0, offset: 0, length: 0 };
|
|
635
638
|
}
|
|
636
|
-
function
|
|
639
|
+
function Fn(t, e, n) {
|
|
637
640
|
try {
|
|
638
|
-
return JSON.parse(
|
|
641
|
+
return JSON.parse(Lt.decode(new Uint8Array(t, e.offset, e.length)));
|
|
639
642
|
} catch (r) {
|
|
640
|
-
throw new
|
|
643
|
+
throw new f("E_HEADER_JSON", `Invalid V3 ${n} JSON: ${r.message}`);
|
|
641
644
|
}
|
|
642
645
|
}
|
|
643
|
-
function
|
|
646
|
+
function Xn(t) {
|
|
644
647
|
const e = String(t.encoding ?? "").toLowerCase();
|
|
645
648
|
return e === "nested_instanced_external" || e === "nested_instanced_external_annotations";
|
|
646
649
|
}
|
|
647
|
-
function
|
|
650
|
+
function Yn(t) {
|
|
648
651
|
return String(t.encoding ?? "").toLowerCase() === "nested_instanced_external_annotations";
|
|
649
652
|
}
|
|
650
|
-
function
|
|
653
|
+
function zn(t, e, n) {
|
|
651
654
|
const r = t.features, s = r && typeof r == "object" && !Array.isArray(r) ? { ...r } : {};
|
|
652
655
|
return e && (s.has_external_variant_geometry = !0), n && (s.has_external_annotations = !0), Object.keys(s).length ? s : void 0;
|
|
653
656
|
}
|
|
654
|
-
function
|
|
657
|
+
function Y(t, e) {
|
|
655
658
|
if (!Number.isInteger(t) || Number(t) < 0)
|
|
656
|
-
throw new
|
|
659
|
+
throw new f("E_HEADER", `${e} must be a non-negative integer`);
|
|
657
660
|
return Number(t);
|
|
658
661
|
}
|
|
659
|
-
function
|
|
662
|
+
function Oe(t, e) {
|
|
660
663
|
if (typeof t != "string" || !t.trim())
|
|
661
|
-
throw new
|
|
664
|
+
throw new f("E_HEADER", `${e} must be a non-empty string`);
|
|
662
665
|
return t;
|
|
663
666
|
}
|
|
664
|
-
function
|
|
667
|
+
function ce(t, e) {
|
|
665
668
|
if (t == null)
|
|
666
669
|
return null;
|
|
667
670
|
if (!Array.isArray(t) || t.length !== 4 || t.some((n) => typeof n != "number" || !Number.isFinite(n)))
|
|
668
|
-
throw new
|
|
671
|
+
throw new f("E_HEADER", `${e} must be null or [minX, minY, maxX, maxY]`);
|
|
669
672
|
return [t[0], t[1], t[2], t[3]];
|
|
670
673
|
}
|
|
671
|
-
function
|
|
672
|
-
if (!
|
|
673
|
-
throw new
|
|
674
|
+
function Mt(t, e) {
|
|
675
|
+
if (!st(t) || Array.isArray(t))
|
|
676
|
+
throw new f("E_HEADER", `${e} must be an object`);
|
|
674
677
|
return {
|
|
675
|
-
line_count:
|
|
676
|
-
fill_count:
|
|
677
|
-
dot_count:
|
|
678
|
-
bbox:
|
|
679
|
-
own_bbox:
|
|
678
|
+
line_count: Y(t.line_count, `${e}.line_count`),
|
|
679
|
+
fill_count: Y(t.fill_count, `${e}.fill_count`),
|
|
680
|
+
dot_count: Y(t.dot_count, `${e}.dot_count`),
|
|
681
|
+
bbox: ce(t.bbox, `${e}.bbox`),
|
|
682
|
+
own_bbox: ce(t.own_bbox, `${e}.own_bbox`)
|
|
680
683
|
};
|
|
681
684
|
}
|
|
682
|
-
function
|
|
685
|
+
function Hn(t) {
|
|
683
686
|
return t ? { minX: t[0], minY: t[1], maxX: t[2], maxY: t[3] } : null;
|
|
684
687
|
}
|
|
685
|
-
function
|
|
688
|
+
function Kn(t, e) {
|
|
686
689
|
const n = t.external_variants;
|
|
687
690
|
if (!Array.isArray(n))
|
|
688
|
-
throw new
|
|
691
|
+
throw new f("E_HEADER", "V3 external SCENE_META.external_variants must be an array");
|
|
689
692
|
if (n.length !== e)
|
|
690
|
-
throw new
|
|
693
|
+
throw new f(
|
|
691
694
|
"E_GROUP_RANGE",
|
|
692
695
|
`V3 external variant manifest count mismatch: manifest=${n.length}, table=${e}`
|
|
693
696
|
);
|
|
694
697
|
return n.map((r, s) => {
|
|
695
|
-
if (!
|
|
696
|
-
throw new
|
|
697
|
-
const o =
|
|
698
|
+
if (!st(r) || Array.isArray(r))
|
|
699
|
+
throw new f("E_HEADER", `V3 external_variants[${s}] must be an object`);
|
|
700
|
+
const o = Y(r.id, `V3 external_variants[${s}].id`);
|
|
698
701
|
if (o !== s)
|
|
699
|
-
throw new
|
|
700
|
-
const i =
|
|
702
|
+
throw new f("E_GROUP_RANGE", `V3 external_variants[${s}].id must equal ${s}, found ${o}`);
|
|
703
|
+
const i = Oe(r.href, `V3 external_variants[${s}].href`), a = Y(r.raw_size, `V3 external_variants[${s}].raw_size`);
|
|
701
704
|
if ("normal" in r || "annotation" in r) {
|
|
702
|
-
const
|
|
705
|
+
const u = Mt(r.annotation, `V3 external_variants[${s}].annotation`);
|
|
703
706
|
return {
|
|
704
707
|
id: o,
|
|
705
708
|
href: i,
|
|
706
709
|
raw_size: a,
|
|
707
|
-
normal:
|
|
710
|
+
normal: Mt(r.normal, `V3 external_variants[${s}].normal`),
|
|
708
711
|
annotation: {
|
|
709
|
-
...
|
|
710
|
-
text_count:
|
|
711
|
-
|
|
712
|
+
...u,
|
|
713
|
+
text_count: Y(
|
|
714
|
+
st(r.annotation) && !Array.isArray(r.annotation) ? r.annotation.text_count : void 0,
|
|
712
715
|
`V3 external_variants[${s}].annotation.text_count`
|
|
713
716
|
)
|
|
714
717
|
}
|
|
@@ -718,42 +721,42 @@ function Bn(t, e) {
|
|
|
718
721
|
id: o,
|
|
719
722
|
href: i,
|
|
720
723
|
raw_size: a,
|
|
721
|
-
line_count:
|
|
722
|
-
fill_count:
|
|
723
|
-
dot_count:
|
|
724
|
+
line_count: Y(r.line_count, `V3 external_variants[${s}].line_count`),
|
|
725
|
+
fill_count: Y(r.fill_count, `V3 external_variants[${s}].fill_count`),
|
|
726
|
+
dot_count: Y(r.dot_count, `V3 external_variants[${s}].dot_count`)
|
|
724
727
|
};
|
|
725
728
|
});
|
|
726
729
|
}
|
|
727
|
-
function
|
|
730
|
+
function jn(t) {
|
|
728
731
|
const e = t.external_annotations;
|
|
729
732
|
if (e == null) return null;
|
|
730
|
-
if (!
|
|
731
|
-
throw new
|
|
733
|
+
if (!st(e) || Array.isArray(e))
|
|
734
|
+
throw new f("E_HEADER", "V3 external_annotations must be an object");
|
|
732
735
|
const n = e.scene;
|
|
733
736
|
if (n == null) return {};
|
|
734
|
-
if (!
|
|
735
|
-
throw new
|
|
736
|
-
const r =
|
|
737
|
+
if (!st(n) || Array.isArray(n))
|
|
738
|
+
throw new f("E_HEADER", "V3 external_annotations.scene must be an object");
|
|
739
|
+
const r = Mt(n, "V3 external_annotations.scene");
|
|
737
740
|
return {
|
|
738
741
|
scene: {
|
|
739
|
-
href:
|
|
740
|
-
raw_size:
|
|
742
|
+
href: Oe(n.href, "V3 external_annotations.scene.href"),
|
|
743
|
+
raw_size: Y(n.raw_size, "V3 external_annotations.scene.raw_size"),
|
|
741
744
|
...r,
|
|
742
|
-
text_count:
|
|
745
|
+
text_count: Y(n.text_count, "V3 external_annotations.scene.text_count")
|
|
743
746
|
}
|
|
744
747
|
};
|
|
745
748
|
}
|
|
746
|
-
function
|
|
747
|
-
return
|
|
749
|
+
function _t(t, e, n, r) {
|
|
750
|
+
return at(e, n, t.byteLength, r), Lt.decode(t.subarray(e, e + n));
|
|
748
751
|
}
|
|
749
|
-
function
|
|
752
|
+
function Wn(t, e, n) {
|
|
750
753
|
if (e.length % 20 !== 0)
|
|
751
|
-
throw new
|
|
754
|
+
throw new f("E_GROUP_RANGE", "V3 LAYER_TABLE length must be a multiple of 20");
|
|
752
755
|
const r = new DataView(t), s = [];
|
|
753
756
|
for (let o = e.offset; o < e.offset + e.length; o += 20) {
|
|
754
757
|
const i = r.getUint32(o, !0), a = r.getUint32(o + 4, !0);
|
|
755
758
|
s.push({
|
|
756
|
-
name:
|
|
759
|
+
name: _t(n, i, a, "V3 layer name"),
|
|
757
760
|
color: [r.getUint8(o + 8), r.getUint8(o + 9), r.getUint8(o + 10)],
|
|
758
761
|
visible: r.getUint8(o + 11) !== 0,
|
|
759
762
|
lw_px: r.getFloat32(o + 12, !0)
|
|
@@ -761,19 +764,19 @@ function On(t, e, n) {
|
|
|
761
764
|
}
|
|
762
765
|
return s;
|
|
763
766
|
}
|
|
764
|
-
function
|
|
767
|
+
function gt(t, e, n, r, s, o) {
|
|
765
768
|
if (n + 4 > r)
|
|
766
|
-
throw new
|
|
767
|
-
const i = e.getUint32(n, !0), a = n + 4,
|
|
768
|
-
if (
|
|
769
|
-
throw new
|
|
769
|
+
throw new f("E_GROUP_RANGE", `Missing ${s} vertex_count`);
|
|
770
|
+
const i = e.getUint32(n, !0), a = n + 4, u = Ne(t, e, a, i, r, o);
|
|
771
|
+
if (u.offset > r)
|
|
772
|
+
throw new f("E_GROUP_RANGE", `${s} exceeds section bounds`);
|
|
770
773
|
return {
|
|
771
|
-
chunk:
|
|
772
|
-
offset:
|
|
774
|
+
chunk: u.chunk,
|
|
775
|
+
offset: u.offset
|
|
773
776
|
};
|
|
774
777
|
}
|
|
775
|
-
function
|
|
776
|
-
const i =
|
|
778
|
+
function Me(t, e, n, r, s, o) {
|
|
779
|
+
const i = gt(t, e, n, r, s, o), a = n + 4;
|
|
777
780
|
return {
|
|
778
781
|
chunk: i.chunk,
|
|
779
782
|
snapshot: {
|
|
@@ -784,33 +787,33 @@ function Ue(t, e, n, r, s, o) {
|
|
|
784
787
|
offset: i.offset
|
|
785
788
|
};
|
|
786
789
|
}
|
|
787
|
-
function
|
|
790
|
+
function yt(t = "u8") {
|
|
788
791
|
return {
|
|
789
792
|
chunk: { pos: new Float32Array(0), col: new Uint8Array(0), lay: new Uint8Array(0), count: 0 },
|
|
790
793
|
snapshot: { count: 0, raw: new Uint8Array(0), groupLayerEncoding: t }
|
|
791
794
|
};
|
|
792
795
|
}
|
|
793
|
-
function
|
|
796
|
+
function ke(t = "u8") {
|
|
794
797
|
return {
|
|
795
|
-
line:
|
|
796
|
-
fill:
|
|
797
|
-
dot:
|
|
798
|
+
line: yt(t),
|
|
799
|
+
fill: yt(t),
|
|
800
|
+
dot: yt(t)
|
|
798
801
|
};
|
|
799
802
|
}
|
|
800
|
-
function
|
|
803
|
+
function De(t, e, n) {
|
|
801
804
|
var r;
|
|
802
805
|
return !!(e && n && t.deferExternalVariantGeometry && !((r = t.externalVariantBuffers) != null && r.has(e.id)));
|
|
803
806
|
}
|
|
804
|
-
function
|
|
807
|
+
function bt(t, e, n, r, s, o, i) {
|
|
805
808
|
if (s === 0)
|
|
806
|
-
return
|
|
807
|
-
|
|
808
|
-
const a = n.offset + r,
|
|
809
|
-
if (
|
|
810
|
-
throw new
|
|
811
|
-
return { chunk:
|
|
812
|
-
}
|
|
813
|
-
function
|
|
809
|
+
return yt(i);
|
|
810
|
+
at(r, s, n.length, o);
|
|
811
|
+
const a = n.offset + r, u = a + s, c = Me(t, e, a, u, o, i);
|
|
812
|
+
if (c.offset !== u)
|
|
813
|
+
throw new f("E_GROUP_RANGE", `${o} has trailing bytes`);
|
|
814
|
+
return { chunk: c.chunk, snapshot: c.snapshot };
|
|
815
|
+
}
|
|
816
|
+
function Ft(t, e, n) {
|
|
814
817
|
if ([
|
|
815
818
|
t.getUint32(e + 8, !0),
|
|
816
819
|
t.getUint32(e + 12, !0),
|
|
@@ -819,205 +822,232 @@ function Ce(t, e, n) {
|
|
|
819
822
|
t.getUint32(e + 24, !0),
|
|
820
823
|
t.getUint32(e + 28, !0)
|
|
821
824
|
].some((s) => s !== 0))
|
|
822
|
-
throw new
|
|
825
|
+
throw new f("E_GROUP_RANGE", `V3 external variant ${n} must use zero inline geometry offsets`);
|
|
823
826
|
}
|
|
824
|
-
function
|
|
825
|
-
const i =
|
|
827
|
+
function ot(t, e, n, r, s, o) {
|
|
828
|
+
const i = Me(t, e, n, t.byteLength, s, o);
|
|
826
829
|
if (i.chunk.count !== r)
|
|
827
|
-
throw new
|
|
830
|
+
throw new f(
|
|
828
831
|
"E_GROUP_RANGE",
|
|
829
832
|
`${s} vertex_count mismatch: manifest=${r}, sidecar=${i.chunk.count}`
|
|
830
833
|
);
|
|
831
834
|
return i;
|
|
832
835
|
}
|
|
833
|
-
function
|
|
836
|
+
function xt(t) {
|
|
834
837
|
return "normal" in t ? t.normal : t;
|
|
835
838
|
}
|
|
836
|
-
function
|
|
837
|
-
const r =
|
|
839
|
+
function qn(t, e, n) {
|
|
840
|
+
const r = xt(t), s = new DataView(e);
|
|
838
841
|
let o = 0;
|
|
839
|
-
const i =
|
|
842
|
+
const i = ot(e, s, o, r.line_count, `V3 external variant ${t.id} line blob`, n);
|
|
840
843
|
o = i.offset;
|
|
841
|
-
const a =
|
|
844
|
+
const a = ot(e, s, o, r.fill_count, `V3 external variant ${t.id} fill blob`, n);
|
|
842
845
|
o = a.offset;
|
|
843
|
-
const
|
|
844
|
-
if (o =
|
|
845
|
-
throw new
|
|
846
|
+
const u = ot(e, s, o, r.dot_count, `V3 external variant ${t.id} dot blob`, n);
|
|
847
|
+
if (o = u.offset, o !== e.byteLength)
|
|
848
|
+
throw new f("E_GROUP_RANGE", `V3 external variant ${t.id} sidecar has trailing bytes`);
|
|
846
849
|
return {
|
|
847
850
|
line: { chunk: i.chunk, snapshot: i.snapshot },
|
|
848
851
|
fill: { chunk: a.chunk, snapshot: a.snapshot },
|
|
849
|
-
dot: { chunk:
|
|
852
|
+
dot: { chunk: u.chunk, snapshot: u.snapshot }
|
|
850
853
|
};
|
|
851
854
|
}
|
|
852
|
-
function
|
|
853
|
-
const n =
|
|
855
|
+
function Jn(t, e) {
|
|
856
|
+
const n = wn(e), r = pn(n, 257, "BLOCK_NORMAL_GEOMETRY"), s = new DataView(e);
|
|
854
857
|
let o = r.offset;
|
|
855
|
-
const i = r.offset + r.length, a =
|
|
856
|
-
o = c.offset;
|
|
857
|
-
const u = nt(e, s, o, t.normal.fill_count, `V3.3 external variant ${t.id} normal fill blob`, a);
|
|
858
|
+
const i = r.offset + r.length, a = Ie(n.versionMinor), u = ot(e, s, o, t.normal.line_count, `V3.3 external variant ${t.id} normal line blob`, a);
|
|
858
859
|
o = u.offset;
|
|
859
|
-
const
|
|
860
|
+
const c = ot(e, s, o, t.normal.fill_count, `V3.3 external variant ${t.id} normal fill blob`, a);
|
|
861
|
+
o = c.offset;
|
|
862
|
+
const m = ot(e, s, o, t.normal.dot_count, `V3.3 external variant ${t.id} normal dot blob`, a);
|
|
860
863
|
if (o = m.offset, o !== i)
|
|
861
|
-
throw new
|
|
864
|
+
throw new f("E_GROUP_RANGE", `V3.3 external variant ${t.id} normal geometry section has trailing bytes`);
|
|
862
865
|
return {
|
|
863
|
-
line: { chunk:
|
|
864
|
-
fill: { chunk:
|
|
866
|
+
line: { chunk: u.chunk, snapshot: u.snapshot },
|
|
867
|
+
fill: { chunk: c.chunk, snapshot: c.snapshot },
|
|
865
868
|
dot: { chunk: m.chunk, snapshot: m.snapshot }
|
|
866
869
|
};
|
|
867
870
|
}
|
|
868
|
-
function
|
|
871
|
+
function Zn(t, e, n = "u8") {
|
|
869
872
|
if (e.byteLength !== t.raw_size)
|
|
870
|
-
throw new
|
|
873
|
+
throw new f(
|
|
871
874
|
"E_GROUP_RANGE",
|
|
872
875
|
`V3 external variant ${t.id} raw_size mismatch: manifest=${t.raw_size}, sidecar=${e.byteLength}`
|
|
873
876
|
);
|
|
874
|
-
return "normal" in t ?
|
|
877
|
+
return "normal" in t ? Jn(t, e) : qn(t, e, n);
|
|
875
878
|
}
|
|
876
|
-
function
|
|
879
|
+
function Le(t, e, n) {
|
|
877
880
|
const r = e == null ? void 0 : e.get(t.id);
|
|
878
881
|
if (!r)
|
|
879
|
-
throw new
|
|
880
|
-
return
|
|
882
|
+
throw new f("E_GROUP_RANGE", `Missing V3 external sidecar buffer for variant ${t.id}`);
|
|
883
|
+
return Zn(t, r, n);
|
|
881
884
|
}
|
|
882
|
-
function
|
|
885
|
+
function At(t, e, n, r, s) {
|
|
883
886
|
if (r === 0)
|
|
884
887
|
return 0;
|
|
885
|
-
if (
|
|
886
|
-
throw new
|
|
888
|
+
if (at(n, r, e.length, s), r < 4)
|
|
889
|
+
throw new f("E_GROUP_RANGE", `Missing ${s} vertex_count`);
|
|
887
890
|
return t.getUint32(e.offset + n, !0);
|
|
888
891
|
}
|
|
889
|
-
function
|
|
892
|
+
function Qn(t, e, n, r) {
|
|
890
893
|
const s = n.offset + n.length;
|
|
891
894
|
let o = n.offset;
|
|
892
|
-
const i =
|
|
895
|
+
const i = gt(t, e, o, s, "V3 BASE_GEOMETRY line", r);
|
|
893
896
|
o = i.offset;
|
|
894
|
-
const a =
|
|
897
|
+
const a = gt(t, e, o, s, "V3 BASE_GEOMETRY fill", r);
|
|
895
898
|
o = a.offset;
|
|
896
|
-
const
|
|
897
|
-
if (o =
|
|
898
|
-
throw new
|
|
899
|
+
const u = gt(t, e, o, s, "V3 BASE_GEOMETRY dot", r);
|
|
900
|
+
if (o = u.offset, o !== s)
|
|
901
|
+
throw new f("E_GROUP_RANGE", "V3 BASE_GEOMETRY has trailing bytes");
|
|
899
902
|
return {
|
|
900
903
|
line: i.chunk,
|
|
901
904
|
fill: a.chunk,
|
|
902
|
-
dot:
|
|
905
|
+
dot: u.chunk
|
|
903
906
|
};
|
|
904
907
|
}
|
|
905
|
-
function
|
|
906
|
-
return
|
|
908
|
+
function It(t) {
|
|
909
|
+
return dn(t.pos, t.count, 2);
|
|
907
910
|
}
|
|
908
|
-
function
|
|
909
|
-
return
|
|
911
|
+
function Fe(t, e, n) {
|
|
912
|
+
return kt(kt(It(t), It(e)), It(n));
|
|
910
913
|
}
|
|
911
|
-
function
|
|
912
|
-
return "normal" in t ?
|
|
914
|
+
function Xt(t) {
|
|
915
|
+
return "normal" in t ? Hn(t.normal.bbox ?? t.normal.own_bbox ?? null) : null;
|
|
913
916
|
}
|
|
914
|
-
function
|
|
917
|
+
function tr(t, e, n, r, s, o, i, a) {
|
|
915
918
|
if (n.length % 60 !== 0)
|
|
916
|
-
throw new
|
|
917
|
-
const
|
|
918
|
-
for (let
|
|
919
|
-
const
|
|
920
|
-
line:
|
|
919
|
+
throw new f("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
|
|
920
|
+
const u = [], c = /* @__PURE__ */ new Map(), m = [], g = n.length / 60;
|
|
921
|
+
for (let l = 0; l < g; l += 1) {
|
|
922
|
+
const d = n.offset + l * 60, p = e.getUint32(d, !0), h = e.getUint32(d + 4, !0), y = (o == null ? void 0 : o[l]) ?? null, w = !y || !a.requiredExternalVariantIds || a.requiredExternalVariantIds.has(l), _ = De(a, y, w), E = y ? (Ft(e, d, l), !w || _ ? ke(i) : Le(y, a.externalVariantBuffers, i)) : {
|
|
923
|
+
line: bt(
|
|
921
924
|
t,
|
|
922
925
|
e,
|
|
923
926
|
r,
|
|
924
|
-
e.getUint32(
|
|
925
|
-
e.getUint32(
|
|
926
|
-
`V3 variant ${
|
|
927
|
+
e.getUint32(d + 8, !0),
|
|
928
|
+
e.getUint32(d + 12, !0),
|
|
929
|
+
`V3 variant ${l} line blob`,
|
|
927
930
|
i
|
|
928
931
|
),
|
|
929
|
-
fill:
|
|
932
|
+
fill: bt(
|
|
930
933
|
t,
|
|
931
934
|
e,
|
|
932
935
|
r,
|
|
933
|
-
e.getUint32(
|
|
934
|
-
e.getUint32(
|
|
935
|
-
`V3 variant ${
|
|
936
|
+
e.getUint32(d + 16, !0),
|
|
937
|
+
e.getUint32(d + 20, !0),
|
|
938
|
+
`V3 variant ${l} fill blob`,
|
|
936
939
|
i
|
|
937
940
|
),
|
|
938
|
-
dot:
|
|
941
|
+
dot: bt(
|
|
939
942
|
t,
|
|
940
943
|
e,
|
|
941
944
|
r,
|
|
942
|
-
e.getUint32(
|
|
943
|
-
e.getUint32(
|
|
944
|
-
`V3 variant ${
|
|
945
|
+
e.getUint32(d + 24, !0),
|
|
946
|
+
e.getUint32(d + 28, !0),
|
|
947
|
+
`V3 variant ${l} dot blob`,
|
|
945
948
|
i
|
|
946
949
|
)
|
|
947
|
-
},
|
|
948
|
-
id:
|
|
949
|
-
name:
|
|
950
|
-
line_count:
|
|
951
|
-
fill_count:
|
|
952
|
-
dot_count:
|
|
953
|
-
sourceLineCount:
|
|
950
|
+
}, A = y ? xt(y) : null, U = (A == null ? void 0 : A.line_count) ?? E.line.chunk.count, N = (A == null ? void 0 : A.fill_count) ?? E.fill.chunk.count, C = (A == null ? void 0 : A.dot_count) ?? E.dot.chunk.count, V = y && (!w || _) ? Xt(y) : Fe(E.line.chunk, E.fill.chunk, E.dot.chunk), G = {
|
|
951
|
+
id: l,
|
|
952
|
+
name: _t(s, p, h, `V3 variant ${l} name`),
|
|
953
|
+
line_count: _ ? U : E.line.chunk.count,
|
|
954
|
+
fill_count: _ ? N : E.fill.chunk.count,
|
|
955
|
+
dot_count: _ ? C : E.dot.chunk.count,
|
|
956
|
+
sourceLineCount: U,
|
|
954
957
|
sourceFillCount: N,
|
|
955
958
|
sourceDotCount: C,
|
|
956
|
-
nestedStart: e.getUint32(
|
|
957
|
-
nestedCount: e.getUint32(
|
|
958
|
-
textStart: e.getUint32(
|
|
959
|
-
textCount: e.getUint32(
|
|
960
|
-
precisionOriginX: e.getFloat32(
|
|
961
|
-
precisionOriginY: e.getFloat32(
|
|
959
|
+
nestedStart: e.getUint32(d + 32, !0),
|
|
960
|
+
nestedCount: e.getUint32(d + 36, !0),
|
|
961
|
+
textStart: e.getUint32(d + 40, !0),
|
|
962
|
+
textCount: e.getUint32(d + 44, !0),
|
|
963
|
+
precisionOriginX: e.getFloat32(d + 48, !0),
|
|
964
|
+
precisionOriginY: e.getFloat32(d + 52, !0),
|
|
962
965
|
lineSnapshot: E.line.snapshot,
|
|
963
966
|
fillSnapshot: E.fill.snapshot,
|
|
964
967
|
dotSnapshot: E.dot.snapshot,
|
|
965
|
-
bbox:
|
|
968
|
+
bbox: V
|
|
966
969
|
};
|
|
967
|
-
|
|
970
|
+
u.push(G), c.set(l, { line: E.line.chunk, fill: E.fill.chunk, dot: E.dot.chunk }), m.push({ line: E.line.snapshot, fill: E.fill.snapshot, dot: E.dot.snapshot });
|
|
968
971
|
}
|
|
969
|
-
return { variantsById:
|
|
972
|
+
return { variantsById: u, variants: c, snapshots: m };
|
|
970
973
|
}
|
|
971
|
-
function
|
|
974
|
+
function fe(t, e, n, r, s) {
|
|
972
975
|
if (e.length % 60 !== 0)
|
|
973
|
-
throw new
|
|
976
|
+
throw new f("E_GROUP_RANGE", "V3 VARIANT_TABLE length must be a multiple of 60");
|
|
974
977
|
const o = [], i = e.length / 60;
|
|
975
978
|
for (let a = 0; a < i; a += 1) {
|
|
976
|
-
const
|
|
977
|
-
g &&
|
|
978
|
-
const
|
|
979
|
+
const u = e.offset + a * 60, c = t.getUint32(u, !0), m = t.getUint32(u + 4, !0), g = (s == null ? void 0 : s[a]) ?? null;
|
|
980
|
+
g && Ft(t, u, a);
|
|
981
|
+
const l = g ? xt(g) : null, d = t.getFloat32(u + 48, !0), p = t.getFloat32(u + 52, !0);
|
|
979
982
|
o.push({
|
|
980
983
|
id: a,
|
|
981
|
-
name:
|
|
982
|
-
line_count: g ?
|
|
984
|
+
name: _t(r, c, m, `V3 variant ${a} name`),
|
|
985
|
+
line_count: g ? l.line_count : At(
|
|
983
986
|
t,
|
|
984
987
|
n,
|
|
985
|
-
t.getUint32(
|
|
986
|
-
t.getUint32(
|
|
988
|
+
t.getUint32(u + 8, !0),
|
|
989
|
+
t.getUint32(u + 12, !0),
|
|
987
990
|
`V3 variant ${a} line blob`
|
|
988
991
|
),
|
|
989
|
-
fill_count: g ?
|
|
992
|
+
fill_count: g ? l.fill_count : At(
|
|
990
993
|
t,
|
|
991
994
|
n,
|
|
992
|
-
t.getUint32(
|
|
993
|
-
t.getUint32(
|
|
995
|
+
t.getUint32(u + 16, !0),
|
|
996
|
+
t.getUint32(u + 20, !0),
|
|
994
997
|
`V3 variant ${a} fill blob`
|
|
995
998
|
),
|
|
996
|
-
dot_count: g ?
|
|
999
|
+
dot_count: g ? l.dot_count : At(
|
|
997
1000
|
t,
|
|
998
1001
|
n,
|
|
999
|
-
t.getUint32(
|
|
1000
|
-
t.getUint32(
|
|
1002
|
+
t.getUint32(u + 24, !0),
|
|
1003
|
+
t.getUint32(u + 28, !0),
|
|
1001
1004
|
`V3 variant ${a} dot blob`
|
|
1002
1005
|
),
|
|
1003
|
-
nestedStart: t.getUint32(
|
|
1004
|
-
nestedCount: t.getUint32(
|
|
1005
|
-
textStart: t.getUint32(
|
|
1006
|
-
textCount: t.getUint32(
|
|
1007
|
-
precisionOriginX:
|
|
1008
|
-
precisionOriginY:
|
|
1009
|
-
bbox: g ?
|
|
1006
|
+
nestedStart: t.getUint32(u + 32, !0),
|
|
1007
|
+
nestedCount: t.getUint32(u + 36, !0),
|
|
1008
|
+
textStart: t.getUint32(u + 40, !0),
|
|
1009
|
+
textCount: t.getUint32(u + 44, !0),
|
|
1010
|
+
precisionOriginX: d,
|
|
1011
|
+
precisionOriginY: p,
|
|
1012
|
+
bbox: g ? Xt(g) : null
|
|
1010
1013
|
});
|
|
1011
1014
|
}
|
|
1012
1015
|
return o;
|
|
1013
1016
|
}
|
|
1014
|
-
function
|
|
1017
|
+
function er(t, e, n) {
|
|
1018
|
+
var a;
|
|
1019
|
+
const r = new DataView(t), s = [], o = /* @__PURE__ */ new Map(), i = [];
|
|
1020
|
+
for (const u of e.variantHeaders) {
|
|
1021
|
+
const c = ((a = e.externalVariants) == null ? void 0 : a[u.id]) ?? null, m = !c || !n.requiredExternalVariantIds || n.requiredExternalVariantIds.has(u.id), g = De(n, c, m), l = c ? (() => {
|
|
1022
|
+
const E = e.sections.get(5).offset + u.id * 60;
|
|
1023
|
+
return Ft(r, E, u.id), !m || g ? ke(e.groupLayerEncoding) : Le(c, n.externalVariantBuffers, e.groupLayerEncoding);
|
|
1024
|
+
})() : e.internalVariants.get(u.id);
|
|
1025
|
+
if (!l)
|
|
1026
|
+
throw new f("E_GROUP_RANGE", `Missing cached V3 variant geometry for variant ${u.id}`);
|
|
1027
|
+
const d = c ? xt(c) : null, p = (d == null ? void 0 : d.line_count) ?? l.line.chunk.count, h = (d == null ? void 0 : d.fill_count) ?? l.fill.chunk.count, y = (d == null ? void 0 : d.dot_count) ?? l.dot.chunk.count, w = c && (!m || g) ? Xt(c) : Fe(l.line.chunk, l.fill.chunk, l.dot.chunk), _ = {
|
|
1028
|
+
...u,
|
|
1029
|
+
line_count: g ? p : l.line.chunk.count,
|
|
1030
|
+
fill_count: g ? h : l.fill.chunk.count,
|
|
1031
|
+
dot_count: g ? y : l.dot.chunk.count,
|
|
1032
|
+
sourceLineCount: p,
|
|
1033
|
+
sourceFillCount: h,
|
|
1034
|
+
sourceDotCount: y,
|
|
1035
|
+
lineSnapshot: l.line.snapshot,
|
|
1036
|
+
fillSnapshot: l.fill.snapshot,
|
|
1037
|
+
dotSnapshot: l.dot.snapshot,
|
|
1038
|
+
bbox: w
|
|
1039
|
+
};
|
|
1040
|
+
s.push(_), o.set(u.id, { line: l.line.chunk, fill: l.fill.chunk, dot: l.dot.chunk }), i.push({ line: l.line.snapshot, fill: l.fill.snapshot, dot: l.dot.snapshot });
|
|
1041
|
+
}
|
|
1042
|
+
return { variantsById: s, variants: o, snapshots: i };
|
|
1043
|
+
}
|
|
1044
|
+
function mt(t, e, n) {
|
|
1015
1045
|
if (e.length % 32 !== 0)
|
|
1016
|
-
throw new
|
|
1046
|
+
throw new f("E_GROUP_RANGE", `${n} length must be a multiple of 32`);
|
|
1017
1047
|
const r = new DataView(t), s = [];
|
|
1018
1048
|
for (let o = e.offset; o < e.offset + e.length; o += 32) {
|
|
1019
1049
|
const i = r.getUint16(o + 30, !0);
|
|
1020
|
-
|
|
1050
|
+
dr(i), s.push({
|
|
1021
1051
|
variantId: r.getUint32(o, !0),
|
|
1022
1052
|
matA: r.getFloat32(o + 4, !0),
|
|
1023
1053
|
matB: r.getFloat32(o + 8, !0),
|
|
@@ -1031,39 +1061,39 @@ function lt(t, e, n) {
|
|
|
1031
1061
|
}
|
|
1032
1062
|
return s;
|
|
1033
1063
|
}
|
|
1034
|
-
function
|
|
1035
|
-
const r = t.getUint32(e, !0), s = t.getUint32(e + 4, !0), o = t.getUint8(e + 42), i = t.getUint8(e + 43), a = t.getFloat32(e + 24, !0),
|
|
1064
|
+
function nr(t, e, n) {
|
|
1065
|
+
const r = t.getUint32(e, !0), s = t.getUint32(e + 4, !0), o = t.getUint8(e + 42), i = t.getUint8(e + 43), a = t.getFloat32(e + 24, !0), u = t.getFloat32(e + 28, !0);
|
|
1036
1066
|
return {
|
|
1037
|
-
t:
|
|
1067
|
+
t: _t(n, r, s, "V3 text value"),
|
|
1038
1068
|
x: t.getFloat32(e + 8, !0),
|
|
1039
1069
|
y: t.getFloat32(e + 12, !0),
|
|
1040
1070
|
h: t.getFloat32(e + 16, !0),
|
|
1041
1071
|
r: t.getFloat32(e + 20, !0),
|
|
1042
1072
|
c: [t.getUint8(e + 36), t.getUint8(e + 37), t.getUint8(e + 38)],
|
|
1043
1073
|
li: t.getUint16(e + 40, !0),
|
|
1044
|
-
ha:
|
|
1045
|
-
va:
|
|
1074
|
+
ha: Gn[o & 3] ?? "left",
|
|
1075
|
+
va: Nn[o >> 2 & 3] ?? "alphabetic",
|
|
1046
1076
|
lh: t.getFloat32(e + 32, !0),
|
|
1047
1077
|
...a ? { w: a } : {},
|
|
1048
|
-
...
|
|
1078
|
+
...u !== 1 ? { wf: u } : {},
|
|
1049
1079
|
...i & 1 ? { mx: !0 } : {},
|
|
1050
1080
|
...i & 2 ? { my: !0 } : {}
|
|
1051
1081
|
};
|
|
1052
1082
|
}
|
|
1053
|
-
function
|
|
1083
|
+
function Rt(t, e, n, r) {
|
|
1054
1084
|
if (e.length % 44 !== 0)
|
|
1055
|
-
throw new
|
|
1085
|
+
throw new f("E_GROUP_RANGE", `${r} length must be a multiple of 44`);
|
|
1056
1086
|
const s = [], o = new DataView(t);
|
|
1057
1087
|
for (let i = e.offset; i < e.offset + e.length; i += 44)
|
|
1058
|
-
s.push(
|
|
1088
|
+
s.push(nr(o, i, n));
|
|
1059
1089
|
return s;
|
|
1060
1090
|
}
|
|
1061
|
-
function
|
|
1091
|
+
function rr(t, e) {
|
|
1062
1092
|
if (t.length % 44 !== 0)
|
|
1063
|
-
throw new
|
|
1093
|
+
throw new f("E_GROUP_RANGE", `${e} length must be a multiple of 44`);
|
|
1064
1094
|
return t.length / 44;
|
|
1065
1095
|
}
|
|
1066
|
-
function
|
|
1096
|
+
function or(t, e, n, r) {
|
|
1067
1097
|
return {
|
|
1068
1098
|
instanceId: n,
|
|
1069
1099
|
variantId: e.variantId,
|
|
@@ -1076,15 +1106,15 @@ function Wn(t, e, n, r) {
|
|
|
1076
1106
|
insLayerIdx: r
|
|
1077
1107
|
};
|
|
1078
1108
|
}
|
|
1079
|
-
function
|
|
1080
|
-
var
|
|
1081
|
-
const s = ((
|
|
1109
|
+
function sr(t, e, n, r) {
|
|
1110
|
+
var h;
|
|
1111
|
+
const s = ((h = r[e.insLayerIdx]) == null ? void 0 : h.visible) === !1, o = e.matA * t.x + e.matC * t.y + e.tx, i = e.matB * t.x + e.matD * t.y + e.ty, a = Math.hypot(e.matA, e.matB), u = Math.hypot(e.matC, e.matD), c = u > 1e-12 ? u : a > 1e-12 ? a : 1, m = a > 1e-12 && c > 1e-12 ? a / c : 1, g = ir(t, e), { mx: l, my: d, ...p } = t;
|
|
1082
1112
|
return {
|
|
1083
|
-
...
|
|
1113
|
+
...p,
|
|
1084
1114
|
x: o,
|
|
1085
1115
|
y: i,
|
|
1086
|
-
h: t.h *
|
|
1087
|
-
w: t.w === void 0 ? void 0 : t.w *
|
|
1116
|
+
h: t.h * c,
|
|
1117
|
+
w: t.w === void 0 ? void 0 : t.w * c,
|
|
1088
1118
|
wf: (t.wf ?? 1) * m,
|
|
1089
1119
|
r: g.r,
|
|
1090
1120
|
...g.mx ? { mx: !0 } : {},
|
|
@@ -1092,294 +1122,336 @@ function qn(t, e, n, r) {
|
|
|
1092
1122
|
li: s || t.li === n ? e.insLayerIdx : t.li
|
|
1093
1123
|
};
|
|
1094
1124
|
}
|
|
1095
|
-
function
|
|
1096
|
-
const n = t.r * Math.PI / 180, r = Math.cos(n), s = Math.sin(n), o = t.mx ? -1 : 1, i = t.my ? -1 : 1, a = o * (e.matA * r + e.matC * s),
|
|
1097
|
-
return g < 0 ? { r: Math.atan2(-
|
|
1125
|
+
function ir(t, e) {
|
|
1126
|
+
const n = t.r * Math.PI / 180, r = Math.cos(n), s = Math.sin(n), o = t.mx ? -1 : 1, i = t.my ? -1 : 1, a = o * (e.matA * r + e.matC * s), u = o * (e.matB * r + e.matD * s), c = i * (e.matC * r - e.matA * s), m = i * (e.matD * r - e.matB * s), g = a * m - u * c, l = Math.atan2(u, a) * 180 / Math.PI;
|
|
1127
|
+
return g < 0 ? { r: Math.atan2(-u, -a) * 180 / Math.PI, mx: !0 } : { r: l };
|
|
1098
1128
|
}
|
|
1099
|
-
function
|
|
1129
|
+
function ar(t, e) {
|
|
1100
1130
|
return t === e ? e : t;
|
|
1101
1131
|
}
|
|
1102
|
-
function
|
|
1132
|
+
function ur(t, e, n) {
|
|
1103
1133
|
return t === n ? e : t;
|
|
1104
1134
|
}
|
|
1105
|
-
function
|
|
1106
|
-
const
|
|
1107
|
-
bounds:
|
|
1108
|
-
entity_count: Number(
|
|
1109
|
-
line_count: Number(
|
|
1110
|
-
fill_count: Number(
|
|
1111
|
-
dot_count: Number(
|
|
1112
|
-
layers:
|
|
1135
|
+
function lr(t, e, n) {
|
|
1136
|
+
const r = new DataView(t), s = n ? void 0 : Ln(t), o = (n == null ? void 0 : n.versionMinor) ?? s.versionMinor, i = (n == null ? void 0 : n.sections) ?? s.sections, a = (n == null ? void 0 : n.groupLayerEncoding) ?? Ie(o), u = n ? n.sections.get(1) : tt(i, 1, "SCENE_META"), c = n ? n.sections.get(2) : tt(i, 2, "LAYER_TABLE"), m = n ? n.sections.get(3) : tt(i, 3, "STRING_TABLE"), g = n ? n.sections.get(4) : tt(i, 4, "BASE_GEOMETRY"), l = n ? n.sections.get(5) : tt(i, 5, "VARIANT_TABLE"), d = n ? n.sections.get(6) : tt(i, 6, "VARIANT_GEOMETRY"), p = n ? n.sections.get(7) : tt(i, 7, "SCENE_INSTANCE_TABLE"), h = (n == null ? void 0 : n.sections.get(8)) ?? pt(i, 8), y = (n == null ? void 0 : n.sections.get(9)) ?? pt(i, 9), w = (n == null ? void 0 : n.sections.get(10)) ?? pt(i, 10), _ = (n == null ? void 0 : n.sceneMeta) ?? Fn(t, u, "SCENE_META"), E = (n == null ? void 0 : n.externalVariants) ?? (Xn(_) ? Kn(_, l.length / 60) : null), A = Yn(_), U = (n == null ? void 0 : n.externalAnnotations) ?? (A ? jn(_) : null), N = (n == null ? void 0 : n.geoMetaFeatures) ?? zn(_, E, A), C = (n == null ? void 0 : n.geoMetaEncoding) ?? (A ? "nested_instanced_external_annotations" : E ? "nested_instanced_external" : "nested_instanced"), V = (n == null ? void 0 : n.stringTable) ?? new Uint8Array(t, m.offset, m.length), G = n != null && n.layers ? [...n.layers] : Wn(t, c, V), $ = (n == null ? void 0 : n.layer0Index) ?? Number(_.layer0_index ?? 0), M = (n == null ? void 0 : n.headerForValidation) ?? Pe({
|
|
1137
|
+
bounds: _.bounds ?? [0, 0, 0, 0],
|
|
1138
|
+
entity_count: Number(_.entity_count ?? 0),
|
|
1139
|
+
line_count: Number(_.base_line_count ?? 0),
|
|
1140
|
+
fill_count: Number(_.base_fill_count ?? 0),
|
|
1141
|
+
dot_count: Number(_.base_dot_count ?? 0),
|
|
1142
|
+
layers: G,
|
|
1113
1143
|
texts: []
|
|
1114
1144
|
});
|
|
1115
|
-
|
|
1116
|
-
const
|
|
1145
|
+
fr($, M.layers);
|
|
1146
|
+
const I = (n == null ? void 0 : n.baseGeometry) ?? Qn(t, r, g, a);
|
|
1117
1147
|
if (!e.loadBlocks) {
|
|
1118
|
-
const
|
|
1119
|
-
if (Number(
|
|
1120
|
-
throw new
|
|
1121
|
-
if (Number(
|
|
1122
|
-
throw new
|
|
1123
|
-
if (Number(
|
|
1124
|
-
throw new
|
|
1125
|
-
if (Number(
|
|
1126
|
-
throw new
|
|
1127
|
-
if (Number(
|
|
1128
|
-
throw new
|
|
1129
|
-
for (const
|
|
1130
|
-
if (
|
|
1131
|
-
throw new
|
|
1132
|
-
if (
|
|
1133
|
-
throw new
|
|
1148
|
+
const x = (n == null ? void 0 : n.variantHeaders) ?? fe(r, l, d, V, E), b = (n == null ? void 0 : n.sceneInstances) ?? mt(t, p, "V3 SCENE_INSTANCE_TABLE"), B = (n == null ? void 0 : n.nestedInstances) ?? mt(t, h, "V3 NESTED_INSTANCE_TABLE"), S = (n == null ? void 0 : n.sceneTexts) ?? Rt(t, y, V, "V3 SCENE_TEXT_TABLE"), O = (n == null ? void 0 : n.variantTextCount) ?? rr(w, "V3 VARIANT_TEXT_TABLE");
|
|
1149
|
+
if (Number(_.variant_count ?? x.length) !== x.length)
|
|
1150
|
+
throw new f("E_GROUP_RANGE", "V3 variant count mismatch");
|
|
1151
|
+
if (Number(_.scene_instance_count ?? b.length) !== b.length)
|
|
1152
|
+
throw new f("E_GROUP_RANGE", "V3 scene instance count mismatch");
|
|
1153
|
+
if (Number(_.nested_instance_count ?? B.length) !== B.length)
|
|
1154
|
+
throw new f("E_GROUP_RANGE", "V3 nested instance count mismatch");
|
|
1155
|
+
if (Number(_.scene_text_count ?? S.length) !== S.length)
|
|
1156
|
+
throw new f("E_GROUP_RANGE", "V3 scene text count mismatch");
|
|
1157
|
+
if (Number(_.variant_text_count ?? O) !== O)
|
|
1158
|
+
throw new f("E_GROUP_RANGE", "V3 variant text count mismatch");
|
|
1159
|
+
for (const R of x) {
|
|
1160
|
+
if (R.nestedStart + R.nestedCount > B.length)
|
|
1161
|
+
throw new f("E_GROUP_RANGE", `V3 variant ${R.id} nested range exceeds table`);
|
|
1162
|
+
if (R.textStart + R.textCount > O)
|
|
1163
|
+
throw new f("E_GROUP_RANGE", `V3 variant ${R.id} text range exceeds table`);
|
|
1134
1164
|
}
|
|
1135
|
-
return
|
|
1136
|
-
if (!
|
|
1137
|
-
throw new
|
|
1138
|
-
|
|
1165
|
+
return ue(b, B, (R) => {
|
|
1166
|
+
if (!x[R.variantId])
|
|
1167
|
+
throw new f("E_GROUP_RANGE", `Unknown V3 variantId ${R.variantId}`);
|
|
1168
|
+
ye(R.insLayerIdx, G.length);
|
|
1139
1169
|
}), {
|
|
1140
1170
|
meta: {
|
|
1141
|
-
bounds:
|
|
1142
|
-
entity_count: Number(
|
|
1143
|
-
line_count:
|
|
1144
|
-
fill_count:
|
|
1145
|
-
dot_count:
|
|
1171
|
+
bounds: _.bounds ?? [0, 0, 0, 0],
|
|
1172
|
+
entity_count: Number(_.entity_count ?? 0),
|
|
1173
|
+
line_count: I.line.count,
|
|
1174
|
+
fill_count: I.fill.count,
|
|
1175
|
+
dot_count: I.dot.count,
|
|
1146
1176
|
version: 3,
|
|
1147
|
-
version_minor:
|
|
1148
|
-
encoding:
|
|
1149
|
-
...
|
|
1150
|
-
...
|
|
1151
|
-
...
|
|
1152
|
-
layer0_index:
|
|
1153
|
-
block_variants:
|
|
1154
|
-
id:
|
|
1155
|
-
name:
|
|
1156
|
-
line_count:
|
|
1157
|
-
fill_count:
|
|
1158
|
-
dot_count:
|
|
1177
|
+
version_minor: o,
|
|
1178
|
+
encoding: C,
|
|
1179
|
+
...N ? { features: N } : {},
|
|
1180
|
+
...E ? { external_variants: [...E] } : {},
|
|
1181
|
+
...U ? { external_annotations: U } : {},
|
|
1182
|
+
layer0_index: $,
|
|
1183
|
+
block_variants: x.map((R) => ({
|
|
1184
|
+
id: R.id,
|
|
1185
|
+
name: R.name,
|
|
1186
|
+
line_count: R.line_count,
|
|
1187
|
+
fill_count: R.fill_count,
|
|
1188
|
+
dot_count: R.dot_count
|
|
1159
1189
|
})),
|
|
1160
|
-
instance_count:
|
|
1161
|
-
layers:
|
|
1190
|
+
instance_count: b.length,
|
|
1191
|
+
layers: G,
|
|
1162
1192
|
texts: S
|
|
1163
1193
|
},
|
|
1164
1194
|
header: {
|
|
1165
|
-
...
|
|
1166
|
-
lineCount:
|
|
1167
|
-
fillCount:
|
|
1168
|
-
dotCount:
|
|
1195
|
+
...M,
|
|
1196
|
+
lineCount: I.line.count,
|
|
1197
|
+
fillCount: I.fill.count,
|
|
1198
|
+
dotCount: I.dot.count,
|
|
1169
1199
|
textCount: S.length,
|
|
1170
1200
|
texts: S
|
|
1171
1201
|
},
|
|
1172
1202
|
decoded: {
|
|
1173
|
-
baseLine:
|
|
1174
|
-
baseFill:
|
|
1175
|
-
baseDot:
|
|
1203
|
+
baseLine: I.line,
|
|
1204
|
+
baseFill: I.fill,
|
|
1205
|
+
baseDot: I.dot,
|
|
1176
1206
|
variants: /* @__PURE__ */ new Map(),
|
|
1177
1207
|
instances: [],
|
|
1178
1208
|
instanceIdByVariantOrdinal: /* @__PURE__ */ new Map()
|
|
1179
1209
|
}
|
|
1180
1210
|
};
|
|
1181
1211
|
}
|
|
1182
|
-
const
|
|
1212
|
+
const T = n ? er(t, n, e) : tr(
|
|
1183
1213
|
t,
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1214
|
+
r,
|
|
1215
|
+
l,
|
|
1216
|
+
d,
|
|
1217
|
+
V,
|
|
1218
|
+
E,
|
|
1219
|
+
a,
|
|
1190
1220
|
e
|
|
1191
|
-
),
|
|
1192
|
-
if (Number(
|
|
1193
|
-
throw new
|
|
1194
|
-
if (Number(
|
|
1195
|
-
throw new
|
|
1196
|
-
if (Number(
|
|
1197
|
-
throw new
|
|
1198
|
-
if (Number(
|
|
1199
|
-
throw new
|
|
1200
|
-
if (Number(
|
|
1201
|
-
throw new
|
|
1202
|
-
for (const
|
|
1203
|
-
if (
|
|
1204
|
-
throw new
|
|
1205
|
-
if (
|
|
1206
|
-
throw new
|
|
1221
|
+
), { variantsById: P, variants: k, snapshots: D } = T, v = (n == null ? void 0 : n.sceneInstances) ?? mt(t, p, "V3 SCENE_INSTANCE_TABLE"), et = (n == null ? void 0 : n.nestedInstances) ?? mt(t, h, "V3 NESTED_INSTANCE_TABLE"), ut = (n == null ? void 0 : n.sceneTexts) ?? Rt(t, y, V, "V3 SCENE_TEXT_TABLE"), W = (n == null ? void 0 : n.variantTexts) ?? Rt(t, w, V, "V3 VARIANT_TEXT_TABLE");
|
|
1222
|
+
if (Number(_.variant_count ?? P.length) !== P.length)
|
|
1223
|
+
throw new f("E_GROUP_RANGE", "V3 variant count mismatch");
|
|
1224
|
+
if (Number(_.scene_instance_count ?? v.length) !== v.length)
|
|
1225
|
+
throw new f("E_GROUP_RANGE", "V3 scene instance count mismatch");
|
|
1226
|
+
if (Number(_.nested_instance_count ?? et.length) !== et.length)
|
|
1227
|
+
throw new f("E_GROUP_RANGE", "V3 nested instance count mismatch");
|
|
1228
|
+
if (Number(_.scene_text_count ?? ut.length) !== ut.length)
|
|
1229
|
+
throw new f("E_GROUP_RANGE", "V3 scene text count mismatch");
|
|
1230
|
+
if (Number(_.variant_text_count ?? W.length) !== W.length)
|
|
1231
|
+
throw new f("E_GROUP_RANGE", "V3 variant text count mismatch");
|
|
1232
|
+
for (const x of P) {
|
|
1233
|
+
if (x.nestedStart + x.nestedCount > et.length)
|
|
1234
|
+
throw new f("E_GROUP_RANGE", `V3 variant ${x.id} nested range exceeds table`);
|
|
1235
|
+
if (x.textStart + x.textCount > W.length)
|
|
1236
|
+
throw new f("E_GROUP_RANGE", `V3 variant ${x.id} text range exceeds table`);
|
|
1207
1237
|
}
|
|
1208
|
-
|
|
1209
|
-
if (!
|
|
1210
|
-
throw new
|
|
1211
|
-
|
|
1238
|
+
ue(v, et, (x) => {
|
|
1239
|
+
if (!P[x.variantId])
|
|
1240
|
+
throw new f("E_GROUP_RANGE", `Unknown V3 variantId ${x.variantId}`);
|
|
1241
|
+
ye(x.insLayerIdx, G.length);
|
|
1212
1242
|
});
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
},
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
if (
|
|
1226
|
-
throw new
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1243
|
+
const Yt = (n == null ? void 0 : n.variantTextsByVariantId) ?? (() => {
|
|
1244
|
+
const x = /* @__PURE__ */ new Map();
|
|
1245
|
+
for (const b of P)
|
|
1246
|
+
x.set(
|
|
1247
|
+
b.id,
|
|
1248
|
+
W.slice(b.textStart, b.textStart + b.textCount)
|
|
1249
|
+
);
|
|
1250
|
+
return x;
|
|
1251
|
+
})(), lt = [], L = e.externalVariantDeltaOnly, zt = L ? [] : [...ut], Et = /* @__PURE__ */ new Map(), ct = /* @__PURE__ */ new Map(), Ht = /* @__PURE__ */ new Map(), We = (x, b) => {
|
|
1252
|
+
Et.set(x, kt(Et.get(x) ?? null, b));
|
|
1253
|
+
}, Kt = (x, b, B, S, O, q) => {
|
|
1254
|
+
var Qt;
|
|
1255
|
+
if (O > 64)
|
|
1256
|
+
throw new f("E_GROUP_RANGE", "V3 nested instance depth exceeds limit");
|
|
1257
|
+
if (q.has(x))
|
|
1258
|
+
throw new f("E_GROUP_RANGE", `V3 nested variant cycle detected at ${x}`);
|
|
1259
|
+
const R = P[x];
|
|
1260
|
+
if (!R)
|
|
1261
|
+
throw new f("E_GROUP_RANGE", `Unknown V3 variantId ${x}`);
|
|
1262
|
+
q.add(x);
|
|
1263
|
+
const J = !e.requiredExternalVariantIds || e.requiredExternalVariantIds.has(x), z = L ? ((Qt = e.requiredExternalVariantIds) == null ? void 0 : Qt.has(x)) === !0 : J;
|
|
1264
|
+
let F = !1;
|
|
1265
|
+
const Zt = !!(R.line_count || R.fill_count || R.dot_count), Qe = R.textCount > 0;
|
|
1266
|
+
if (z && (Zt || Qe) && (lt.push({
|
|
1267
|
+
instanceId: b.instanceId,
|
|
1268
|
+
variantId: x,
|
|
1269
|
+
matA: b.matA,
|
|
1270
|
+
matB: b.matB,
|
|
1271
|
+
matC: b.matC,
|
|
1272
|
+
matD: b.matD,
|
|
1273
|
+
tx: b.tx,
|
|
1274
|
+
ty: b.ty,
|
|
1275
|
+
insLayerIdx: b.insLayerIdx
|
|
1276
|
+
}), Zt && We(b.instanceId, R.bbox ? Xe(R.bbox, b) : null), F = !0), z) {
|
|
1277
|
+
R.textCount > 0 && (F = !0);
|
|
1278
|
+
for (let Z = 0; Z < R.textCount; Z += 1) {
|
|
1279
|
+
const nt = sr(W[R.textStart + Z], b, $, M.layers);
|
|
1280
|
+
zt.push({
|
|
1281
|
+
...nt,
|
|
1282
|
+
iv: B,
|
|
1251
1283
|
io: S
|
|
1252
1284
|
});
|
|
1253
1285
|
}
|
|
1254
1286
|
}
|
|
1255
|
-
for (let
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1287
|
+
for (let Z = 0; Z < R.nestedCount; Z += 1) {
|
|
1288
|
+
const nt = et[R.nestedStart + Z], tn = ur(nt.insLayerIdx, b.insLayerIdx, $), en = cr(nt, R, P[nt.variantId]), nn = or(b, en, b.instanceId, tn);
|
|
1289
|
+
F = Kt(nt.variantId, nn, B, S, O + 1, q) || F;
|
|
1258
1290
|
}
|
|
1259
|
-
return
|
|
1260
|
-
},
|
|
1261
|
-
|
|
1262
|
-
if (!
|
|
1263
|
-
throw new
|
|
1264
|
-
const S =
|
|
1265
|
-
|
|
1266
|
-
const
|
|
1267
|
-
instanceId:
|
|
1268
|
-
variantId:
|
|
1269
|
-
matA:
|
|
1270
|
-
matB:
|
|
1271
|
-
matC:
|
|
1272
|
-
matD:
|
|
1273
|
-
tx:
|
|
1274
|
-
ty:
|
|
1275
|
-
insLayerIdx:
|
|
1276
|
-
},
|
|
1277
|
-
if (
|
|
1291
|
+
return q.delete(x), F;
|
|
1292
|
+
}, wt = /* @__PURE__ */ new Map();
|
|
1293
|
+
v.forEach((x, b) => {
|
|
1294
|
+
if (!P[x.variantId])
|
|
1295
|
+
throw new f("E_GROUP_RANGE", `Unknown V3 scene variantId ${x.variantId}`);
|
|
1296
|
+
const S = Ht.get(x.variantId) ?? 0;
|
|
1297
|
+
Ht.set(x.variantId, S + 1), ct.set(`${x.variantId}:${S}`, b);
|
|
1298
|
+
const O = ar(x.insLayerIdx, $), q = {
|
|
1299
|
+
instanceId: b,
|
|
1300
|
+
variantId: x.variantId,
|
|
1301
|
+
matA: x.matA,
|
|
1302
|
+
matB: x.matB,
|
|
1303
|
+
matC: x.matC,
|
|
1304
|
+
matD: x.matD,
|
|
1305
|
+
tx: x.tx,
|
|
1306
|
+
ty: x.ty,
|
|
1307
|
+
insLayerIdx: O
|
|
1308
|
+
}, R = Kt(x.variantId, q, x.variantId, S, 0, /* @__PURE__ */ new Set());
|
|
1309
|
+
if (L && !R)
|
|
1278
1310
|
return;
|
|
1279
|
-
let
|
|
1280
|
-
|
|
1281
|
-
let
|
|
1282
|
-
|
|
1283
|
-
const
|
|
1284
|
-
|
|
1285
|
-
instanceId:
|
|
1286
|
-
variantId:
|
|
1287
|
-
label: `#${
|
|
1288
|
-
tx:
|
|
1289
|
-
ty:
|
|
1290
|
-
canHighlight:
|
|
1291
|
-
...
|
|
1311
|
+
let J = wt.get(O);
|
|
1312
|
+
J || (J = /* @__PURE__ */ new Map(), wt.set(O, J));
|
|
1313
|
+
let z = J.get(x.variantId);
|
|
1314
|
+
z || (z = { count: 0, bboxes: [], inserts: [] }, J.set(x.variantId, z)), z.count += 1;
|
|
1315
|
+
const F = Et.get(b) ?? null;
|
|
1316
|
+
F && z.bboxes.push(F), z.inserts.push({
|
|
1317
|
+
instanceId: b,
|
|
1318
|
+
variantId: x.variantId,
|
|
1319
|
+
label: `#${b + 1} (${x.tx.toFixed(1)}, ${x.ty.toFixed(1)})`,
|
|
1320
|
+
tx: x.tx,
|
|
1321
|
+
ty: x.ty,
|
|
1322
|
+
canHighlight: F !== null,
|
|
1323
|
+
...F ? { bbox: F } : {}
|
|
1292
1324
|
});
|
|
1293
1325
|
});
|
|
1294
|
-
const
|
|
1295
|
-
for (const [
|
|
1296
|
-
const
|
|
1297
|
-
for (const [S,
|
|
1298
|
-
|
|
1326
|
+
const jt = /* @__PURE__ */ new Map();
|
|
1327
|
+
for (const [x, b] of wt) {
|
|
1328
|
+
const B = [];
|
|
1329
|
+
for (const [S, O] of b)
|
|
1330
|
+
B.push({
|
|
1299
1331
|
variantId: S,
|
|
1300
|
-
blockName:
|
|
1301
|
-
instanceCount:
|
|
1302
|
-
bboxes:
|
|
1303
|
-
inserts:
|
|
1332
|
+
blockName: $e(P[S], S),
|
|
1333
|
+
instanceCount: O.count,
|
|
1334
|
+
bboxes: O.bboxes,
|
|
1335
|
+
inserts: O.inserts
|
|
1304
1336
|
});
|
|
1305
|
-
|
|
1337
|
+
B.sort((S, O) => O.instanceCount - S.instanceCount), jt.set(x, B);
|
|
1306
1338
|
}
|
|
1307
|
-
let
|
|
1308
|
-
for (const
|
|
1309
|
-
const
|
|
1310
|
-
e.deferExternalVariantGeometry &&
|
|
1339
|
+
let Wt = L ? 0 : I.line.count, qt = L ? 0 : I.fill.count, Jt = L ? 0 : I.dot.count;
|
|
1340
|
+
for (const x of lt) {
|
|
1341
|
+
const b = P[x.variantId];
|
|
1342
|
+
e.deferExternalVariantGeometry && b.lineSnapshot.count === 0 && b.fillSnapshot.count === 0 && b.dotSnapshot.count === 0 || !Be(x.instanceId, e) || (Wt += b.line_count, qt += b.fill_count, Jt += b.dot_count);
|
|
1311
1343
|
}
|
|
1312
|
-
const
|
|
1313
|
-
bounds:
|
|
1314
|
-
entity_count:
|
|
1315
|
-
line_count:
|
|
1316
|
-
fill_count:
|
|
1317
|
-
dot_count:
|
|
1344
|
+
const ft = $n(zt, ct, e), qe = {
|
|
1345
|
+
bounds: _.bounds ?? [0, 0, 0, 0],
|
|
1346
|
+
entity_count: L ? 0 : Number(_.entity_count ?? 0),
|
|
1347
|
+
line_count: I.line.count,
|
|
1348
|
+
fill_count: I.fill.count,
|
|
1349
|
+
dot_count: I.dot.count,
|
|
1318
1350
|
version: 3,
|
|
1319
|
-
version_minor:
|
|
1320
|
-
encoding:
|
|
1321
|
-
...
|
|
1322
|
-
...
|
|
1323
|
-
...
|
|
1324
|
-
layer0_index:
|
|
1325
|
-
block_variants:
|
|
1326
|
-
id:
|
|
1327
|
-
name:
|
|
1328
|
-
line_count:
|
|
1329
|
-
fill_count:
|
|
1330
|
-
dot_count:
|
|
1351
|
+
version_minor: o,
|
|
1352
|
+
encoding: C,
|
|
1353
|
+
...N ? { features: N } : {},
|
|
1354
|
+
...E ? { external_variants: [...E] } : {},
|
|
1355
|
+
...U ? { external_annotations: U } : {},
|
|
1356
|
+
layer0_index: $,
|
|
1357
|
+
block_variants: P.map((x) => ({
|
|
1358
|
+
id: x.id,
|
|
1359
|
+
name: x.name,
|
|
1360
|
+
line_count: x.sourceLineCount,
|
|
1361
|
+
fill_count: x.sourceFillCount,
|
|
1362
|
+
dot_count: x.sourceDotCount
|
|
1331
1363
|
})),
|
|
1332
|
-
instance_count:
|
|
1333
|
-
layers:
|
|
1334
|
-
texts:
|
|
1335
|
-
},
|
|
1336
|
-
...
|
|
1337
|
-
entityCount:
|
|
1338
|
-
lineCount:
|
|
1339
|
-
fillCount:
|
|
1340
|
-
dotCount:
|
|
1341
|
-
textCount:
|
|
1342
|
-
texts:
|
|
1364
|
+
instance_count: v.length,
|
|
1365
|
+
layers: G,
|
|
1366
|
+
texts: ft
|
|
1367
|
+
}, Je = {
|
|
1368
|
+
...M,
|
|
1369
|
+
entityCount: L ? 0 : M.entityCount,
|
|
1370
|
+
lineCount: Wt,
|
|
1371
|
+
fillCount: qt,
|
|
1372
|
+
dotCount: Jt,
|
|
1373
|
+
textCount: ft.length,
|
|
1374
|
+
texts: ft,
|
|
1343
1375
|
...e.loadBlocks ? {
|
|
1344
|
-
layerBlockUsages:
|
|
1345
|
-
insertRuntime:
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1376
|
+
layerBlockUsages: jt,
|
|
1377
|
+
insertRuntime: On(
|
|
1378
|
+
$,
|
|
1379
|
+
P,
|
|
1380
|
+
D,
|
|
1381
|
+
Yt,
|
|
1382
|
+
lt,
|
|
1383
|
+
ft,
|
|
1384
|
+
ct
|
|
1353
1385
|
)
|
|
1354
1386
|
} : {}
|
|
1355
|
-
}
|
|
1387
|
+
}, Ze = n ?? (e.cacheDocument ? (() => {
|
|
1388
|
+
const x = /* @__PURE__ */ new Map();
|
|
1389
|
+
for (const [b, B] of k)
|
|
1390
|
+
E != null && E[b] || x.set(b, {
|
|
1391
|
+
line: { chunk: B.line, snapshot: D[b].line },
|
|
1392
|
+
fill: { chunk: B.fill, snapshot: D[b].fill },
|
|
1393
|
+
dot: { chunk: B.dot, snapshot: D[b].dot }
|
|
1394
|
+
});
|
|
1395
|
+
return {
|
|
1396
|
+
kind: "dxb3-v3",
|
|
1397
|
+
buffer: t,
|
|
1398
|
+
versionMinor: o,
|
|
1399
|
+
sections: i,
|
|
1400
|
+
groupLayerEncoding: a,
|
|
1401
|
+
sceneMeta: _,
|
|
1402
|
+
externalVariants: E,
|
|
1403
|
+
externalAnnotations: U,
|
|
1404
|
+
geoMetaFeatures: N,
|
|
1405
|
+
geoMetaEncoding: C,
|
|
1406
|
+
stringTable: V,
|
|
1407
|
+
layers: G,
|
|
1408
|
+
layer0Index: $,
|
|
1409
|
+
headerForValidation: M,
|
|
1410
|
+
baseGeometry: I,
|
|
1411
|
+
variantHeaders: fe(
|
|
1412
|
+
r,
|
|
1413
|
+
l,
|
|
1414
|
+
d,
|
|
1415
|
+
V,
|
|
1416
|
+
E
|
|
1417
|
+
),
|
|
1418
|
+
internalVariants: x,
|
|
1419
|
+
sceneInstances: v,
|
|
1420
|
+
nestedInstances: et,
|
|
1421
|
+
sceneTexts: ut,
|
|
1422
|
+
variantTexts: W,
|
|
1423
|
+
variantTextCount: W.length,
|
|
1424
|
+
variantTextsByVariantId: Yt
|
|
1425
|
+
};
|
|
1426
|
+
})() : void 0);
|
|
1356
1427
|
return {
|
|
1357
|
-
meta:
|
|
1358
|
-
header:
|
|
1428
|
+
meta: qe,
|
|
1429
|
+
header: Je,
|
|
1430
|
+
documentCache: Ze,
|
|
1359
1431
|
decoded: {
|
|
1360
|
-
baseLine:
|
|
1361
|
-
baseFill:
|
|
1362
|
-
baseDot:
|
|
1363
|
-
variants:
|
|
1364
|
-
instances:
|
|
1365
|
-
instanceIdByVariantOrdinal:
|
|
1432
|
+
baseLine: L ? Gt() : I.line,
|
|
1433
|
+
baseFill: L ? Gt() : I.fill,
|
|
1434
|
+
baseDot: L ? Gt() : I.dot,
|
|
1435
|
+
variants: k,
|
|
1436
|
+
instances: lt,
|
|
1437
|
+
instanceIdByVariantOrdinal: ct
|
|
1366
1438
|
}
|
|
1367
1439
|
};
|
|
1368
1440
|
}
|
|
1369
|
-
function
|
|
1370
|
-
return
|
|
1441
|
+
function kt(t, e) {
|
|
1442
|
+
return Ce(t, e);
|
|
1371
1443
|
}
|
|
1372
|
-
function
|
|
1373
|
-
return
|
|
1444
|
+
function Xe(t, e) {
|
|
1445
|
+
return Se(t, e);
|
|
1374
1446
|
}
|
|
1375
|
-
function
|
|
1376
|
-
return
|
|
1447
|
+
function de(t) {
|
|
1448
|
+
return mn(t);
|
|
1377
1449
|
}
|
|
1378
|
-
function
|
|
1379
|
-
return
|
|
1450
|
+
function me(t, e) {
|
|
1451
|
+
return gn(t, e);
|
|
1380
1452
|
}
|
|
1381
|
-
function
|
|
1382
|
-
return
|
|
1453
|
+
function ge(t, e) {
|
|
1454
|
+
return Xe(t, {
|
|
1383
1455
|
variantId: e.variantId,
|
|
1384
1456
|
matA: e.matA,
|
|
1385
1457
|
matB: e.matB,
|
|
@@ -1390,7 +1462,7 @@ function ae(t, e) {
|
|
|
1390
1462
|
insLayerIdx: e.insLayerIdx
|
|
1391
1463
|
});
|
|
1392
1464
|
}
|
|
1393
|
-
function
|
|
1465
|
+
function cr(t, e, n) {
|
|
1394
1466
|
if (!(n != null && n.bbox) || !e.bbox)
|
|
1395
1467
|
return t;
|
|
1396
1468
|
const r = e.precisionOriginX, s = e.precisionOriginY;
|
|
@@ -1400,27 +1472,27 @@ function er(t, e, n) {
|
|
|
1400
1472
|
...t,
|
|
1401
1473
|
tx: t.tx - r,
|
|
1402
1474
|
ty: t.ty - s
|
|
1403
|
-
}, i =
|
|
1404
|
-
if (
|
|
1475
|
+
}, i = ge(n.bbox, t), a = ge(n.bbox, o), u = Math.max(de(e.bbox), de(n.bbox), 1), c = Math.hypot(r, s), m = Math.hypot(t.tx, t.ty), g = Math.hypot(o.tx, o.ty);
|
|
1476
|
+
if (c <= u * 16 || m <= u * 16)
|
|
1405
1477
|
return t;
|
|
1406
|
-
const
|
|
1407
|
-
return
|
|
1478
|
+
const l = me(e.bbox, i), d = me(e.bbox, a);
|
|
1479
|
+
return l > u * 16 && d * 4 < l && g * 4 < m ? o : t;
|
|
1408
1480
|
}
|
|
1409
|
-
function
|
|
1481
|
+
function ye(t, e) {
|
|
1410
1482
|
if (t >= e)
|
|
1411
|
-
throw new
|
|
1483
|
+
throw new f("E_GROUP_RANGE", `Instance layer index ${t} exceeds layer count ${e}`);
|
|
1412
1484
|
}
|
|
1413
|
-
function
|
|
1485
|
+
function fr(t, e) {
|
|
1414
1486
|
if (!Number.isInteger(t) || t < 0 || t >= e.length)
|
|
1415
|
-
throw new
|
|
1487
|
+
throw new f("E_GROUP_RANGE", `layer0_index out of range: ${t}`);
|
|
1416
1488
|
if (e[t].name !== "0")
|
|
1417
|
-
throw new
|
|
1489
|
+
throw new f("E_GROUP_RANGE", `layer0_index must reference layer "0": ${t}`);
|
|
1418
1490
|
}
|
|
1419
|
-
function
|
|
1491
|
+
function dr(t) {
|
|
1420
1492
|
if (t !== 0)
|
|
1421
|
-
throw new
|
|
1493
|
+
throw new f("E_GROUP_RANGE", `Instance flags must be zero for Stage 1, found ${t}`);
|
|
1422
1494
|
}
|
|
1423
|
-
function*
|
|
1495
|
+
function* mr(t, e, n, r, s) {
|
|
1424
1496
|
let o = n;
|
|
1425
1497
|
const i = [
|
|
1426
1498
|
{ kind: "line", count: r.lineCount },
|
|
@@ -1428,91 +1500,91 @@ function* or(t, e, n, r, s) {
|
|
|
1428
1500
|
{ kind: "dot", count: r.dotCount }
|
|
1429
1501
|
];
|
|
1430
1502
|
for (const a of i) {
|
|
1431
|
-
const
|
|
1503
|
+
const u = fn(t, e, o, a.count);
|
|
1432
1504
|
for (; ; ) {
|
|
1433
|
-
const
|
|
1434
|
-
if (
|
|
1435
|
-
o =
|
|
1505
|
+
const c = u.next();
|
|
1506
|
+
if (c.done) {
|
|
1507
|
+
o = c.value;
|
|
1436
1508
|
break;
|
|
1437
1509
|
}
|
|
1438
|
-
yield { kind: a.kind, payload:
|
|
1510
|
+
yield { kind: a.kind, payload: c.value };
|
|
1439
1511
|
}
|
|
1440
1512
|
}
|
|
1441
1513
|
if (o !== t.byteLength)
|
|
1442
|
-
throw new
|
|
1514
|
+
throw new f("E_GROUP_RANGE", `Trailing bytes detected: offset=${o}, size=${t.byteLength}`);
|
|
1443
1515
|
for (const a of r.texts)
|
|
1444
1516
|
yield { kind: "text", payload: a };
|
|
1445
1517
|
}
|
|
1446
|
-
function*
|
|
1447
|
-
yield*
|
|
1518
|
+
function* gr(t, e, n, r) {
|
|
1519
|
+
yield* mr(t, e, n, r);
|
|
1448
1520
|
}
|
|
1449
|
-
function*
|
|
1450
|
-
if (
|
|
1451
|
-
yield { kind: t, payload:
|
|
1521
|
+
function* Vt(t, e, n, r, s, o, i, a) {
|
|
1522
|
+
if (Bn(a, t, Math.max(0, e - n.count)), e === 0) {
|
|
1523
|
+
yield { kind: t, payload: bn() };
|
|
1452
1524
|
return;
|
|
1453
1525
|
}
|
|
1454
|
-
const
|
|
1455
|
-
let
|
|
1456
|
-
const
|
|
1526
|
+
const u = Bt;
|
|
1527
|
+
let c = new Float32Array(u * 2), m = [], g = 0, l = 0;
|
|
1528
|
+
const d = function* () {
|
|
1457
1529
|
if (g <= 0)
|
|
1458
1530
|
return;
|
|
1459
|
-
const
|
|
1460
|
-
yield { kind: t, payload:
|
|
1461
|
-
},
|
|
1462
|
-
if (
|
|
1531
|
+
const y = g === u ? { pos: c, count: g, segments: ae(m) } : { pos: c.slice(0, g * 2), count: g, segments: ae(m) };
|
|
1532
|
+
yield { kind: t, payload: y }, l += g, g = 0, c = new Float32Array(u * 2), m = [];
|
|
1533
|
+
}, p = (y, w, _, E) => {
|
|
1534
|
+
if (y <= 0)
|
|
1463
1535
|
return;
|
|
1464
|
-
const
|
|
1465
|
-
if (
|
|
1536
|
+
const A = m[m.length - 1];
|
|
1537
|
+
if (A && A.startVertex + A.vertexCount === g && A.layerIndex === _ && A.color[0] === w[0] && A.color[1] === w[1] && A.color[2] === w[2] && A.lineweightPx === E) {
|
|
1466
1538
|
m[m.length - 1] = {
|
|
1467
|
-
...
|
|
1468
|
-
vertexCount:
|
|
1539
|
+
...A,
|
|
1540
|
+
vertexCount: A.vertexCount + y
|
|
1469
1541
|
};
|
|
1470
1542
|
return;
|
|
1471
1543
|
}
|
|
1472
1544
|
m.push({
|
|
1473
1545
|
startVertex: g,
|
|
1474
|
-
vertexCount:
|
|
1475
|
-
color: [
|
|
1476
|
-
layerIndex:
|
|
1546
|
+
vertexCount: y,
|
|
1547
|
+
color: [w[0], w[1], w[2]],
|
|
1548
|
+
layerIndex: _,
|
|
1477
1549
|
...E === void 0 ? {} : { lineweightPx: E }
|
|
1478
1550
|
});
|
|
1479
1551
|
};
|
|
1480
1552
|
yield* function* () {
|
|
1481
|
-
for (const
|
|
1482
|
-
let
|
|
1483
|
-
const
|
|
1484
|
-
for (;
|
|
1485
|
-
const E = Math.min(
|
|
1486
|
-
|
|
1553
|
+
for (const y of Ot(n)) {
|
|
1554
|
+
let w = y.startVertex;
|
|
1555
|
+
const _ = y.startVertex + y.vertexCount;
|
|
1556
|
+
for (; w < _; ) {
|
|
1557
|
+
const E = Math.min(u - g, _ - w), A = w * 2, U = g * 2;
|
|
1558
|
+
c.set(n.pos.subarray(A, A + E * 2), U), p(E, y.color, y.layerIndex, y.lineweightPx), w += E, g += E, g === u && (yield* d());
|
|
1487
1559
|
}
|
|
1488
1560
|
}
|
|
1489
1561
|
}();
|
|
1490
|
-
for (const
|
|
1491
|
-
if (!
|
|
1562
|
+
for (const y of s) {
|
|
1563
|
+
if (!Be(y.instanceId, a))
|
|
1492
1564
|
continue;
|
|
1493
|
-
const
|
|
1494
|
-
if (!
|
|
1495
|
-
throw new
|
|
1496
|
-
const
|
|
1497
|
-
for (const
|
|
1498
|
-
const
|
|
1499
|
-
let N =
|
|
1500
|
-
const C =
|
|
1565
|
+
const w = r.get(y.variantId);
|
|
1566
|
+
if (!w)
|
|
1567
|
+
throw new f("E_GROUP_RANGE", `Unknown variantId ${y.variantId}`);
|
|
1568
|
+
const _ = w[t], E = i[y.insLayerIdx].visible === !1;
|
|
1569
|
+
for (const A of Ot(_)) {
|
|
1570
|
+
const U = E || A.layerIndex === o ? y.insLayerIdx : A.layerIndex;
|
|
1571
|
+
let N = A.startVertex;
|
|
1572
|
+
const C = A.startVertex + A.vertexCount;
|
|
1501
1573
|
for (; N < C; ) {
|
|
1502
|
-
const
|
|
1503
|
-
for (let
|
|
1504
|
-
const
|
|
1505
|
-
|
|
1574
|
+
const V = Math.min(u - g, C - N);
|
|
1575
|
+
for (let G = 0; G < V; G += 1) {
|
|
1576
|
+
const $ = (N + G) * 2, M = (g + G) * 2, I = _.pos[$], T = _.pos[$ + 1];
|
|
1577
|
+
c[M] = y.matA * I + y.matC * T + y.tx, c[M + 1] = y.matB * I + y.matD * T + y.ty;
|
|
1506
1578
|
}
|
|
1507
|
-
|
|
1579
|
+
p(V, A.color, U, A.lineweightPx), N += V, g += V, g === u && (yield* d());
|
|
1508
1580
|
}
|
|
1509
1581
|
}
|
|
1510
1582
|
}
|
|
1511
|
-
if (yield*
|
|
1512
|
-
throw new
|
|
1583
|
+
if (yield* d(), l !== e)
|
|
1584
|
+
throw new f("E_GROUP_RANGE", `Expanded ${t} count mismatch: header=${e}, emitted=${l}`);
|
|
1513
1585
|
}
|
|
1514
|
-
function*
|
|
1515
|
-
yield*
|
|
1586
|
+
function* yr(t, e, n, r) {
|
|
1587
|
+
yield* Vt(
|
|
1516
1588
|
"line",
|
|
1517
1589
|
e.lineCount,
|
|
1518
1590
|
t.baseLine,
|
|
@@ -1521,7 +1593,7 @@ function* ir(t, e, n, r) {
|
|
|
1521
1593
|
n.layer0_index,
|
|
1522
1594
|
e.layers,
|
|
1523
1595
|
r
|
|
1524
|
-
), yield*
|
|
1596
|
+
), yield* Vt(
|
|
1525
1597
|
"fill",
|
|
1526
1598
|
e.fillCount,
|
|
1527
1599
|
t.baseFill,
|
|
@@ -1530,7 +1602,7 @@ function* ir(t, e, n, r) {
|
|
|
1530
1602
|
n.layer0_index,
|
|
1531
1603
|
e.layers,
|
|
1532
1604
|
r
|
|
1533
|
-
), yield*
|
|
1605
|
+
), yield* Vt(
|
|
1534
1606
|
"dot",
|
|
1535
1607
|
e.dotCount,
|
|
1536
1608
|
t.baseDot,
|
|
@@ -1543,28 +1615,32 @@ function* ir(t, e, n, r) {
|
|
|
1543
1615
|
for (const s of e.texts)
|
|
1544
1616
|
yield { kind: "text", payload: s };
|
|
1545
1617
|
}
|
|
1546
|
-
function
|
|
1547
|
-
const
|
|
1548
|
-
return {
|
|
1549
|
-
header:
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1618
|
+
function Ye(t, e, n) {
|
|
1619
|
+
const r = Tn(e), s = lr(t, r, n);
|
|
1620
|
+
return s.documentCache && Te.add(s.documentCache), {
|
|
1621
|
+
header: s.header,
|
|
1622
|
+
...s.documentCache ? { documentCache: s.documentCache } : {},
|
|
1623
|
+
chunks: yr(
|
|
1624
|
+
s.decoded,
|
|
1625
|
+
s.header,
|
|
1626
|
+
{ layer0_index: s.meta.layer0_index ?? 0 },
|
|
1627
|
+
r
|
|
1555
1628
|
)
|
|
1556
1629
|
};
|
|
1557
1630
|
}
|
|
1558
|
-
function
|
|
1559
|
-
if (
|
|
1560
|
-
return
|
|
1561
|
-
const n =
|
|
1631
|
+
function ze(t, e) {
|
|
1632
|
+
if (ve(t))
|
|
1633
|
+
return Ye(t, e);
|
|
1634
|
+
const n = Dn(t);
|
|
1562
1635
|
return {
|
|
1563
1636
|
header: n.header,
|
|
1564
|
-
chunks:
|
|
1637
|
+
chunks: gr(t, n.view, n.dataOffset, n.header)
|
|
1565
1638
|
};
|
|
1566
1639
|
}
|
|
1567
|
-
function
|
|
1640
|
+
function hr(t, e, n) {
|
|
1641
|
+
return e.kind !== "dxb3-v3" || e.buffer !== t || !Te.has(e) || !ve(t) ? ze(t, n) : Ye(t, n, e);
|
|
1642
|
+
}
|
|
1643
|
+
function Gt() {
|
|
1568
1644
|
return {
|
|
1569
1645
|
pos: new Float32Array(0),
|
|
1570
1646
|
col: new Uint8Array(0),
|
|
@@ -1572,110 +1648,103 @@ function At() {
|
|
|
1572
1648
|
count: 0
|
|
1573
1649
|
};
|
|
1574
1650
|
}
|
|
1575
|
-
function
|
|
1576
|
-
return t ?
|
|
1577
|
-
}
|
|
1578
|
-
async function
|
|
1579
|
-
const e =
|
|
1580
|
-
t.entries.map((
|
|
1581
|
-
), s = Array.from(new Set(t.requiredVariantIds)).sort((
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
const d =
|
|
1590
|
-
|
|
1591
|
-
const y = "status" in h ? h.status : void 0, f = "statusText" in h ? h.statusText : void 0, x = [y, f].filter((p) => p !== void 0 && p !== "").join(" ");
|
|
1592
|
-
throw new Error(`External block ${m} fetch failed${x ? `: ${x}` : ""}`);
|
|
1593
|
-
}
|
|
1594
|
-
const w = await h.arrayBuffer();
|
|
1595
|
-
if (w.byteLength !== g.raw_size)
|
|
1596
|
-
throw new Error(
|
|
1597
|
-
`External block ${m} raw_size mismatch: manifest=${g.raw_size}, response=${w.byteLength}`
|
|
1598
|
-
);
|
|
1599
|
-
o.set(m, w), await ((u = t.onBuffer) == null ? void 0 : u.call(t, m, w));
|
|
1651
|
+
function _r(t, e) {
|
|
1652
|
+
return t ? ht(Se(t, e)) : null;
|
|
1653
|
+
}
|
|
1654
|
+
async function xr(t) {
|
|
1655
|
+
const e = he(), n = t.fetchImpl ?? fetch, r = new Map(
|
|
1656
|
+
t.entries.map((a) => [a.id, a])
|
|
1657
|
+
), s = Array.from(new Set(t.requiredVariantIds)).sort((a, u) => a - u), o = /* @__PURE__ */ new Map();
|
|
1658
|
+
async function i(a) {
|
|
1659
|
+
var l;
|
|
1660
|
+
const u = r.get(a);
|
|
1661
|
+
if (!u)
|
|
1662
|
+
throw new Error(`External block ${a} is missing from manifest`);
|
|
1663
|
+
const c = new URL(u.href, t.baseUrl).href, m = await n(c, { signal: t.signal });
|
|
1664
|
+
if (!m.ok) {
|
|
1665
|
+
const d = "status" in m ? m.status : void 0, p = "statusText" in m ? m.statusText : void 0, h = [d, p].filter((y) => y !== void 0 && y !== "").join(" ");
|
|
1666
|
+
throw new Error(`External block ${a} fetch failed${h ? `: ${h}` : ""}`);
|
|
1600
1667
|
}
|
|
1668
|
+
const g = await m.arrayBuffer();
|
|
1669
|
+
if (g.byteLength !== u.raw_size)
|
|
1670
|
+
throw new Error(
|
|
1671
|
+
`External block ${a} raw_size mismatch: manifest=${u.raw_size}, response=${g.byteLength}`
|
|
1672
|
+
);
|
|
1673
|
+
o.set(a, g), await ((l = t.onBuffer) == null ? void 0 : l.call(t, a, g));
|
|
1601
1674
|
}
|
|
1602
|
-
return await Promise.all(
|
|
1675
|
+
return await Promise.all(s.map(i)), { buffers: o, fetchMs: he() - e };
|
|
1603
1676
|
}
|
|
1604
|
-
function
|
|
1605
|
-
const e = Math.floor(t ?? 3);
|
|
1606
|
-
return Number.isFinite(e) ? Math.max(1, Math.min(e, 8)) : 3;
|
|
1607
|
-
}
|
|
1608
|
-
function ue() {
|
|
1677
|
+
function he() {
|
|
1609
1678
|
var t, e;
|
|
1610
1679
|
return ((e = (t = globalThis.performance) == null ? void 0 : t.now) == null ? void 0 : e.call(t)) ?? Date.now();
|
|
1611
1680
|
}
|
|
1612
1681
|
var j;
|
|
1613
|
-
class
|
|
1682
|
+
class Er {
|
|
1614
1683
|
constructor() {
|
|
1615
|
-
|
|
1684
|
+
ee(this, j, /* @__PURE__ */ new Map());
|
|
1616
1685
|
}
|
|
1617
1686
|
get size() {
|
|
1618
|
-
return
|
|
1687
|
+
return rt(this, j).size;
|
|
1619
1688
|
}
|
|
1620
1689
|
append(e) {
|
|
1621
1690
|
let n = 0;
|
|
1622
1691
|
for (const r of e) {
|
|
1623
1692
|
if (r.count <= 0) continue;
|
|
1624
|
-
const s =
|
|
1625
|
-
let o =
|
|
1626
|
-
const
|
|
1627
|
-
o ? o.positionItemSize !== a && (
|
|
1693
|
+
const s = Dt(r.layerIndex, r.lineweightPx);
|
|
1694
|
+
let o = rt(this, j).get(s), i = r.pos, a = r.positionItemSize;
|
|
1695
|
+
const u = r.linePositionKind ?? null;
|
|
1696
|
+
o ? o.positionItemSize !== a && (_e(o), a !== 3 && (i = Ke(i, r.count, a)), o.positionItemSize = 3, a = 3, o.linePositionKind = null) : (o = {
|
|
1628
1697
|
layerIndex: r.layerIndex,
|
|
1629
1698
|
...r.lineweightPx === void 0 ? {} : { lineweightPx: r.lineweightPx },
|
|
1630
1699
|
posParts: [],
|
|
1631
1700
|
positionItemSize: a,
|
|
1632
1701
|
colParts: [],
|
|
1633
1702
|
colorRunParts: [],
|
|
1634
|
-
linePositionKind:
|
|
1703
|
+
linePositionKind: u,
|
|
1635
1704
|
count: 0,
|
|
1636
1705
|
bbox: null
|
|
1637
|
-
},
|
|
1638
|
-
const
|
|
1706
|
+
}, rt(this, j).set(s, o));
|
|
1707
|
+
const c = o.count > 0;
|
|
1639
1708
|
o.posParts.push(i), o.colParts.push(r.col);
|
|
1640
|
-
const m =
|
|
1641
|
-
r.colorRuns ??
|
|
1709
|
+
const m = Gr(
|
|
1710
|
+
r.colorRuns ?? Nr(r.col),
|
|
1642
1711
|
o.count
|
|
1643
1712
|
);
|
|
1644
|
-
o.colorRunParts.push(m), o.linePositionKind !==
|
|
1713
|
+
o.colorRunParts.push(m), o.linePositionKind !== u && (o.linePositionKind = null), o.positionItemSize === 2 && o.linePositionKind === null && _e(o), o.count += r.count, o.bbox = c && o.bbox === null ? null : pr(o.bbox, r.bbox), n += r.count;
|
|
1645
1714
|
}
|
|
1646
1715
|
return n;
|
|
1647
1716
|
}
|
|
1648
1717
|
drain() {
|
|
1649
1718
|
const e = [];
|
|
1650
|
-
for (const n of
|
|
1719
|
+
for (const n of rt(this, j).values()) {
|
|
1651
1720
|
if (n.count <= 0) continue;
|
|
1652
|
-
const r = n.posParts.length === 1 ? n.posParts[0] :
|
|
1721
|
+
const r = n.posParts.length === 1 ? n.posParts[0] : Rr(n.posParts, n.count * n.positionItemSize), s = n.colParts.length === 1 ? n.colParts[0] : Vr(n.colParts, n.count * 3), o = je(n.colorRunParts.flat()), i = {
|
|
1653
1722
|
layerIndex: n.layerIndex,
|
|
1654
1723
|
pos: r,
|
|
1655
1724
|
positionItemSize: n.positionItemSize,
|
|
1656
1725
|
col: s,
|
|
1657
1726
|
count: n.count,
|
|
1658
|
-
bbox:
|
|
1727
|
+
bbox: ht(n.bbox),
|
|
1659
1728
|
colorRuns: o
|
|
1660
1729
|
};
|
|
1661
1730
|
n.lineweightPx !== void 0 && (i.lineweightPx = n.lineweightPx), n.linePositionKind && (i.linePositionKind = n.linePositionKind), e.push(i);
|
|
1662
1731
|
}
|
|
1663
|
-
return
|
|
1732
|
+
return rt(this, j).clear(), e;
|
|
1664
1733
|
}
|
|
1665
1734
|
}
|
|
1666
1735
|
j = new WeakMap();
|
|
1667
|
-
function
|
|
1668
|
-
return new
|
|
1736
|
+
function Nt() {
|
|
1737
|
+
return new Er();
|
|
1669
1738
|
}
|
|
1670
|
-
function
|
|
1739
|
+
function wr() {
|
|
1671
1740
|
return {
|
|
1672
|
-
line:
|
|
1673
|
-
fill:
|
|
1674
|
-
dot:
|
|
1741
|
+
line: Nt(),
|
|
1742
|
+
fill: Nt(),
|
|
1743
|
+
dot: Nt()
|
|
1675
1744
|
};
|
|
1676
1745
|
}
|
|
1677
|
-
function
|
|
1678
|
-
const n =
|
|
1746
|
+
function pr(t, e) {
|
|
1747
|
+
const n = ht(e);
|
|
1679
1748
|
return t ? n ? {
|
|
1680
1749
|
minX: Math.min(t.minX, n.minX),
|
|
1681
1750
|
minY: Math.min(t.minY, n.minY),
|
|
@@ -1683,73 +1752,73 @@ function hr(t, e) {
|
|
|
1683
1752
|
maxY: Math.max(t.maxY, n.maxY)
|
|
1684
1753
|
} : null : n;
|
|
1685
1754
|
}
|
|
1686
|
-
function
|
|
1755
|
+
function He(t, e = {}) {
|
|
1687
1756
|
if (t.count <= 0) return [];
|
|
1688
|
-
const n =
|
|
1689
|
-
for (const
|
|
1690
|
-
if (
|
|
1691
|
-
const
|
|
1692
|
-
E === void 0 ? (s.set(
|
|
1757
|
+
const n = Ot(t), r = [], s = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = e.markLinePositionXy === !0 || e.splitLineweight === !0;
|
|
1758
|
+
for (const h of n) {
|
|
1759
|
+
if (h.vertexCount <= 0) continue;
|
|
1760
|
+
const y = h.layerIndex, w = a ? h.lineweightPx : void 0, _ = Dt(y, w), E = s.get(_);
|
|
1761
|
+
E === void 0 ? (s.set(_, h.vertexCount), o.set(_, y), i.set(_, w), r.push(_)) : s.set(_, E + h.vertexCount);
|
|
1693
1762
|
}
|
|
1694
|
-
const
|
|
1695
|
-
for (const
|
|
1696
|
-
const
|
|
1697
|
-
layerIndex:
|
|
1698
|
-
...
|
|
1699
|
-
pos: new Float32Array(
|
|
1700
|
-
positionItemSize:
|
|
1701
|
-
col: new Uint8Array(
|
|
1702
|
-
count:
|
|
1763
|
+
const u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), l = e.markLinePositionXy === !0 ? "xy-zero-z" : void 0, d = l ? 2 : 3;
|
|
1764
|
+
for (const h of r) {
|
|
1765
|
+
const y = o.get(h), w = i.get(h), _ = s.get(h) ?? 0, E = {
|
|
1766
|
+
layerIndex: y,
|
|
1767
|
+
...w === void 0 ? {} : { lineweightPx: w },
|
|
1768
|
+
pos: new Float32Array(_ * d),
|
|
1769
|
+
positionItemSize: d,
|
|
1770
|
+
col: new Uint8Array(_ * 3),
|
|
1771
|
+
count: _,
|
|
1703
1772
|
bbox: null,
|
|
1704
1773
|
colorRuns: []
|
|
1705
1774
|
};
|
|
1706
|
-
|
|
1775
|
+
l && (E.linePositionKind = l), u.set(h, E), c.set(h, 0), m.set(h, null);
|
|
1707
1776
|
}
|
|
1708
|
-
for (const
|
|
1709
|
-
if (
|
|
1710
|
-
const
|
|
1711
|
-
for (let
|
|
1712
|
-
const
|
|
1713
|
-
E.pos[
|
|
1714
|
-
const
|
|
1715
|
-
!Number.isFinite(
|
|
1777
|
+
for (const h of n) {
|
|
1778
|
+
if (h.vertexCount <= 0) continue;
|
|
1779
|
+
const y = h.layerIndex, w = a ? h.lineweightPx : void 0, _ = Dt(y, w), E = u.get(_), A = c.get(_), U = A, N = h.color[0], C = h.color[1], V = h.color[2];
|
|
1780
|
+
for (let G = 0; G < h.vertexCount; G += 1) {
|
|
1781
|
+
const $ = h.startVertex + G, M = A + G, I = M * d, T = M * 3, P = $ * 2, k = t.pos[P], D = t.pos[P + 1];
|
|
1782
|
+
E.pos[I] = k, E.pos[I + 1] = D, d === 3 && (E.pos[I + 2] = 0), E.col[T] = N, E.col[T + 1] = C, E.col[T + 2] = V;
|
|
1783
|
+
const v = m.get(_);
|
|
1784
|
+
!Number.isFinite(k) || !Number.isFinite(D) ? g.add(_) : v ? (k < v.minX && (v.minX = k), D < v.minY && (v.minY = D), k > v.maxX && (v.maxX = k), D > v.maxY && (v.maxY = D)) : m.set(_, { minX: k, minY: D, maxX: k, maxY: D });
|
|
1716
1785
|
}
|
|
1717
1786
|
E.colorRuns.push({
|
|
1718
|
-
startVertex:
|
|
1719
|
-
vertexCount:
|
|
1720
|
-
color: [N, C,
|
|
1721
|
-
}),
|
|
1787
|
+
startVertex: U,
|
|
1788
|
+
vertexCount: h.vertexCount,
|
|
1789
|
+
color: [N, C, V]
|
|
1790
|
+
}), c.set(_, A + h.vertexCount);
|
|
1722
1791
|
}
|
|
1723
|
-
const
|
|
1724
|
-
for (const
|
|
1725
|
-
const
|
|
1726
|
-
|
|
1792
|
+
const p = [];
|
|
1793
|
+
for (const h of r) {
|
|
1794
|
+
const y = u.get(h);
|
|
1795
|
+
y && (y.bbox = g.has(h) ? null : ht(m.get(h) ?? null), y.colorRuns = je(y.colorRuns ?? []), p.push(y));
|
|
1727
1796
|
}
|
|
1728
|
-
return
|
|
1797
|
+
return p;
|
|
1729
1798
|
}
|
|
1730
|
-
function
|
|
1799
|
+
function Dt(t, e) {
|
|
1731
1800
|
return e === void 0 ? `${t}:` : `${t}:${e}`;
|
|
1732
1801
|
}
|
|
1733
|
-
function
|
|
1802
|
+
function br(t, e) {
|
|
1734
1803
|
return t.append(e);
|
|
1735
1804
|
}
|
|
1736
|
-
function
|
|
1805
|
+
function Ar(t) {
|
|
1737
1806
|
return t.drain();
|
|
1738
1807
|
}
|
|
1739
|
-
function
|
|
1808
|
+
function Ir(t) {
|
|
1740
1809
|
const e = [], n = /* @__PURE__ */ new Set();
|
|
1741
1810
|
for (const r of t)
|
|
1742
|
-
|
|
1811
|
+
xe(e, n, r.pos.buffer), xe(e, n, r.col.buffer);
|
|
1743
1812
|
return e;
|
|
1744
1813
|
}
|
|
1745
|
-
function
|
|
1814
|
+
function Rr(t, e) {
|
|
1746
1815
|
const n = new Float32Array(e);
|
|
1747
1816
|
let r = 0;
|
|
1748
1817
|
for (const s of t)
|
|
1749
1818
|
n.set(s, r), r += s.length;
|
|
1750
1819
|
return n;
|
|
1751
1820
|
}
|
|
1752
|
-
function
|
|
1821
|
+
function Ke(t, e, n) {
|
|
1753
1822
|
if (n === 3) return t;
|
|
1754
1823
|
const r = new Float32Array(e * 3);
|
|
1755
1824
|
for (let s = 0; s < e; s += 1) {
|
|
@@ -1758,26 +1827,26 @@ function Be(t, e, n) {
|
|
|
1758
1827
|
}
|
|
1759
1828
|
return r;
|
|
1760
1829
|
}
|
|
1761
|
-
function
|
|
1830
|
+
function _e(t) {
|
|
1762
1831
|
if (t.positionItemSize === 3) return;
|
|
1763
1832
|
const e = t.positionItemSize;
|
|
1764
|
-
t.posParts = t.posParts.map((n) =>
|
|
1833
|
+
t.posParts = t.posParts.map((n) => Ke(n, n.length / e, e)), t.positionItemSize = 3, t.linePositionKind = null;
|
|
1765
1834
|
}
|
|
1766
|
-
function
|
|
1835
|
+
function Vr(t, e) {
|
|
1767
1836
|
const n = new Uint8Array(e);
|
|
1768
1837
|
let r = 0;
|
|
1769
1838
|
for (const s of t)
|
|
1770
1839
|
n.set(s, r), r += s.length;
|
|
1771
1840
|
return n;
|
|
1772
1841
|
}
|
|
1773
|
-
function
|
|
1842
|
+
function Gr(t, e) {
|
|
1774
1843
|
return t.map((n) => ({
|
|
1775
1844
|
startVertex: n.startVertex + e,
|
|
1776
1845
|
vertexCount: n.vertexCount,
|
|
1777
1846
|
color: [n.color[0], n.color[1], n.color[2]]
|
|
1778
1847
|
}));
|
|
1779
1848
|
}
|
|
1780
|
-
function
|
|
1849
|
+
function je(t) {
|
|
1781
1850
|
const e = [];
|
|
1782
1851
|
for (const n of t) {
|
|
1783
1852
|
const r = e[e.length - 1];
|
|
@@ -1796,50 +1865,50 @@ function $e(t) {
|
|
|
1796
1865
|
}
|
|
1797
1866
|
return e;
|
|
1798
1867
|
}
|
|
1799
|
-
function
|
|
1868
|
+
function Nr(t) {
|
|
1800
1869
|
const e = Math.floor(t.length / 3), n = [];
|
|
1801
1870
|
let r = 0;
|
|
1802
1871
|
for (; r < e; ) {
|
|
1803
1872
|
const s = r * 3, o = t[s] ?? 0, i = t[s + 1] ?? 0, a = t[s + 2] ?? 0;
|
|
1804
|
-
let
|
|
1805
|
-
for (;
|
|
1806
|
-
const
|
|
1807
|
-
if (t[
|
|
1808
|
-
|
|
1873
|
+
let u = r + 1;
|
|
1874
|
+
for (; u < e; ) {
|
|
1875
|
+
const c = u * 3;
|
|
1876
|
+
if (t[c] !== o || t[c + 1] !== i || t[c + 2] !== a) break;
|
|
1877
|
+
u += 1;
|
|
1809
1878
|
}
|
|
1810
|
-
n.push({ startVertex: r, vertexCount:
|
|
1879
|
+
n.push({ startVertex: r, vertexCount: u - r, color: [o, i, a] }), r = u;
|
|
1811
1880
|
}
|
|
1812
1881
|
return n;
|
|
1813
1882
|
}
|
|
1814
|
-
function
|
|
1883
|
+
function xe(t, e, n) {
|
|
1815
1884
|
n instanceof ArrayBuffer && (e.has(n) || (e.add(n), t.push(n)));
|
|
1816
1885
|
}
|
|
1817
|
-
function
|
|
1886
|
+
function Ur(t, e, n = "u8") {
|
|
1818
1887
|
if (e <= 0 && t.byteLength === 0)
|
|
1819
1888
|
return { pos: new Float32Array(0), count: 0, segments: [] };
|
|
1820
|
-
const { buffer: r, startOffset: s, endOffset: o } =
|
|
1889
|
+
const { buffer: r, startOffset: s, endOffset: o } = Pr(t), i = new DataView(r), a = Ne(r, i, s, e, o, n);
|
|
1821
1890
|
if (a.offset !== o)
|
|
1822
|
-
throw new
|
|
1891
|
+
throw new f(
|
|
1823
1892
|
"E_GROUP_RANGE",
|
|
1824
1893
|
`Insert runtime geometry chunk has trailing bytes: offset=${a.offset - s}, length=${t.byteLength}`
|
|
1825
1894
|
);
|
|
1826
1895
|
return a.chunk;
|
|
1827
1896
|
}
|
|
1828
|
-
function
|
|
1897
|
+
function Cr(t) {
|
|
1829
1898
|
const e = (n) => {
|
|
1830
|
-
const r = t[n], s =
|
|
1899
|
+
const r = t[n], s = Ur(
|
|
1831
1900
|
r.raw,
|
|
1832
1901
|
r.count,
|
|
1833
1902
|
r.groupLayerEncoding
|
|
1834
|
-
), o =
|
|
1903
|
+
), o = He(s, { splitLineweight: n === "line" }), i = /* @__PURE__ */ new Map();
|
|
1835
1904
|
for (const a of o)
|
|
1836
|
-
i.set(
|
|
1905
|
+
i.set(Sr(a.layerIndex, a.lineweightPx), {
|
|
1837
1906
|
layerIndex: a.layerIndex,
|
|
1838
1907
|
...a.lineweightPx === void 0 ? {} : { lineweightPx: a.lineweightPx },
|
|
1839
1908
|
pos: a.pos,
|
|
1840
1909
|
col: a.col,
|
|
1841
1910
|
count: a.count,
|
|
1842
|
-
bbox:
|
|
1911
|
+
bbox: it(a.bbox)
|
|
1843
1912
|
});
|
|
1844
1913
|
return i;
|
|
1845
1914
|
};
|
|
@@ -1849,17 +1918,17 @@ function Ar(t) {
|
|
|
1849
1918
|
dot: e("dot")
|
|
1850
1919
|
};
|
|
1851
1920
|
}
|
|
1852
|
-
function
|
|
1921
|
+
function Sr(t, e) {
|
|
1853
1922
|
return e === void 0 ? `${t}:` : `${t}:${e}`;
|
|
1854
1923
|
}
|
|
1855
|
-
function
|
|
1856
|
-
let n = e ?
|
|
1924
|
+
function Tr(t, e) {
|
|
1925
|
+
let n = e ? it(e) : null;
|
|
1857
1926
|
for (const r of ["line", "fill", "dot"])
|
|
1858
1927
|
for (const s of t[r].values())
|
|
1859
|
-
n =
|
|
1928
|
+
n = Ce(n, s.bbox);
|
|
1860
1929
|
return n;
|
|
1861
1930
|
}
|
|
1862
|
-
function
|
|
1931
|
+
function Pr(t) {
|
|
1863
1932
|
if (t.buffer instanceof ArrayBuffer)
|
|
1864
1933
|
return {
|
|
1865
1934
|
buffer: t.buffer,
|
|
@@ -1873,22 +1942,22 @@ function Vr(t) {
|
|
|
1873
1942
|
endOffset: e.byteOffset + e.byteLength
|
|
1874
1943
|
};
|
|
1875
1944
|
}
|
|
1876
|
-
function
|
|
1945
|
+
function Br(t) {
|
|
1877
1946
|
const e = t.insertRuntime;
|
|
1878
1947
|
if (!e || e.instances.length === 0) return null;
|
|
1879
1948
|
const n = [], r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set();
|
|
1880
|
-
for (const
|
|
1881
|
-
const
|
|
1882
|
-
r.set(
|
|
1883
|
-
variantId:
|
|
1949
|
+
for (const u of e.variants) {
|
|
1950
|
+
const c = Cr(u), m = Ut(c.line), g = Ut(c.fill), l = Ut(c.dot), d = m.length > 0 || g.length > 0 || l.length > 0;
|
|
1951
|
+
r.set(u.id, d ? Tr(c, null) : null), d && (s.add(u.id), n.push({
|
|
1952
|
+
variantId: u.id,
|
|
1884
1953
|
line: m,
|
|
1885
1954
|
fill: g,
|
|
1886
|
-
dot:
|
|
1955
|
+
dot: l
|
|
1887
1956
|
}));
|
|
1888
1957
|
}
|
|
1889
|
-
const o = e.instances.filter((
|
|
1958
|
+
const o = e.instances.filter((u) => s.has(u.variantId));
|
|
1890
1959
|
if (o.length === 0) return null;
|
|
1891
|
-
const i =
|
|
1960
|
+
const i = Or(o, r), a = kr(n, i);
|
|
1892
1961
|
return {
|
|
1893
1962
|
variants: n,
|
|
1894
1963
|
instances: i,
|
|
@@ -1896,22 +1965,22 @@ function Nr(t) {
|
|
|
1896
1965
|
cost: i.count
|
|
1897
1966
|
};
|
|
1898
1967
|
}
|
|
1899
|
-
function
|
|
1968
|
+
function $r(t) {
|
|
1900
1969
|
const e = [], n = /* @__PURE__ */ new Set(), r = (s) => {
|
|
1901
1970
|
n.has(s) || (n.add(s), e.push(s));
|
|
1902
1971
|
};
|
|
1903
1972
|
r(t.instances.meta.buffer), r(t.instances.mats.buffer), r(t.instances.bboxes.buffer);
|
|
1904
1973
|
for (const s of t.variants)
|
|
1905
|
-
|
|
1974
|
+
St(s.line, r), St(s.fill, r), St(s.dot, r);
|
|
1906
1975
|
return e;
|
|
1907
1976
|
}
|
|
1908
|
-
function
|
|
1977
|
+
function Ut(t) {
|
|
1909
1978
|
const e = [];
|
|
1910
1979
|
for (const n of t.values())
|
|
1911
|
-
n.count <= 0 || e.push(
|
|
1980
|
+
n.count <= 0 || e.push(vr(n));
|
|
1912
1981
|
return e;
|
|
1913
1982
|
}
|
|
1914
|
-
function
|
|
1983
|
+
function vr(t) {
|
|
1915
1984
|
return {
|
|
1916
1985
|
pos: t.pos,
|
|
1917
1986
|
col: t.col,
|
|
@@ -1921,48 +1990,48 @@ function Ur(t) {
|
|
|
1921
1990
|
bbox: t.bbox
|
|
1922
1991
|
};
|
|
1923
1992
|
}
|
|
1924
|
-
function
|
|
1993
|
+
function Or(t, e) {
|
|
1925
1994
|
const n = t.length, r = new Uint32Array(n * 3), s = new Float32Array(n * 6), o = new Float32Array(n * 4);
|
|
1926
1995
|
for (let i = 0; i < n; i += 1) {
|
|
1927
|
-
const a = t[i],
|
|
1928
|
-
r[
|
|
1929
|
-
const
|
|
1930
|
-
s[
|
|
1931
|
-
const m =
|
|
1932
|
-
|
|
1996
|
+
const a = t[i], u = i * 3;
|
|
1997
|
+
r[u] = a.instanceId, r[u + 1] = a.variantId, r[u + 2] = a.insLayerIdx;
|
|
1998
|
+
const c = i * 6;
|
|
1999
|
+
s[c] = a.matA, s[c + 1] = a.matB, s[c + 2] = a.matC, s[c + 3] = a.matD, s[c + 4] = a.tx, s[c + 5] = a.ty;
|
|
2000
|
+
const m = _r(e.get(a.variantId) ?? null, a);
|
|
2001
|
+
Mr(o, i * 4, m);
|
|
1933
2002
|
}
|
|
1934
2003
|
return { meta: r, mats: s, bboxes: o, count: n };
|
|
1935
2004
|
}
|
|
1936
|
-
function
|
|
2005
|
+
function Mr(t, e, n) {
|
|
1937
2006
|
if (!n) {
|
|
1938
2007
|
t[e] = Number.POSITIVE_INFINITY, t[e + 1] = Number.POSITIVE_INFINITY, t[e + 2] = Number.NEGATIVE_INFINITY, t[e + 3] = Number.NEGATIVE_INFINITY;
|
|
1939
2008
|
return;
|
|
1940
2009
|
}
|
|
1941
2010
|
t[e] = n.minX, t[e + 1] = n.minY, t[e + 2] = n.maxX, t[e + 3] = n.maxY;
|
|
1942
2011
|
}
|
|
1943
|
-
function
|
|
2012
|
+
function kr(t, e) {
|
|
1944
2013
|
let n = e.meta.byteLength + e.mats.byteLength + e.bboxes.byteLength;
|
|
1945
2014
|
for (const r of t)
|
|
1946
|
-
n +=
|
|
2015
|
+
n += Ct(r.line), n += Ct(r.fill), n += Ct(r.dot);
|
|
1947
2016
|
return n;
|
|
1948
2017
|
}
|
|
1949
|
-
function
|
|
2018
|
+
function Ct(t) {
|
|
1950
2019
|
return t.reduce((e, n) => e + n.pos.byteLength + n.col.byteLength, 0);
|
|
1951
2020
|
}
|
|
1952
|
-
function
|
|
2021
|
+
function St(t, e) {
|
|
1953
2022
|
for (const n of t)
|
|
1954
2023
|
e(n.pos.buffer), e(n.col.buffer);
|
|
1955
2024
|
}
|
|
1956
|
-
function
|
|
2025
|
+
function Ee() {
|
|
1957
2026
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
1958
2027
|
}
|
|
1959
|
-
class
|
|
2028
|
+
class Dr {
|
|
1960
2029
|
constructor() {
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
2030
|
+
Q(this, "geometryCredits", 0);
|
|
2031
|
+
Q(this, "textCredits", 0);
|
|
2032
|
+
Q(this, "cancelled", !1);
|
|
2033
|
+
Q(this, "geometryWaiters", []);
|
|
2034
|
+
Q(this, "textWaiters", []);
|
|
1966
2035
|
}
|
|
1967
2036
|
grant(e) {
|
|
1968
2037
|
this.cancelled || (this.geometryCredits += Math.max(0, e.geometryCredits), this.textCredits += Math.max(0, e.textCredits), this.flushWaiters());
|
|
@@ -2006,23 +2075,23 @@ class Tr {
|
|
|
2006
2075
|
return e === "geometry" ? this.geometryWaiters : this.textWaiters;
|
|
2007
2076
|
}
|
|
2008
2077
|
}
|
|
2009
|
-
const
|
|
2010
|
-
let
|
|
2011
|
-
async function
|
|
2012
|
-
const r =
|
|
2078
|
+
const we = 262144, Lr = Number.MAX_SAFE_INTEGER, pe = 524288, Fr = Number.MAX_SAFE_INTEGER, Xr = 5e6, Yr = 64, H = self;
|
|
2079
|
+
let X = null, be = null, Tt = null;
|
|
2080
|
+
async function Pt(t, e, n) {
|
|
2081
|
+
const r = Ar(e);
|
|
2013
2082
|
if (!r.length || !await n.take("geometry")) return 0;
|
|
2014
|
-
const o = r.reduce((a,
|
|
2083
|
+
const o = r.reduce((a, u) => a + u.count, 0), i = {
|
|
2015
2084
|
type: "geometry",
|
|
2016
2085
|
kind: t,
|
|
2017
2086
|
layers: r,
|
|
2018
2087
|
cost: o
|
|
2019
2088
|
};
|
|
2020
|
-
return
|
|
2089
|
+
return H.postMessage(i, Ir(r)), o;
|
|
2021
2090
|
}
|
|
2022
|
-
async function
|
|
2023
|
-
return await
|
|
2091
|
+
async function zr(t, e) {
|
|
2092
|
+
return await Pt("line", t.line, e) + await Pt("fill", t.fill, e) + await Pt("dot", t.dot, e);
|
|
2024
2093
|
}
|
|
2025
|
-
async function
|
|
2094
|
+
async function Ae(t, e) {
|
|
2026
2095
|
if (!t.length || !await e.take("text")) return 0;
|
|
2027
2096
|
const r = t.slice();
|
|
2028
2097
|
t.length = 0;
|
|
@@ -2031,139 +2100,142 @@ async function ye(t, e) {
|
|
|
2031
2100
|
texts: r,
|
|
2032
2101
|
cost: r.length
|
|
2033
2102
|
};
|
|
2034
|
-
return
|
|
2103
|
+
return H.postMessage(s), r.length;
|
|
2035
2104
|
}
|
|
2036
|
-
function
|
|
2105
|
+
function Hr(t) {
|
|
2037
2106
|
return t.lineCount + t.fillCount + t.dotCount;
|
|
2038
2107
|
}
|
|
2039
|
-
function
|
|
2040
|
-
return
|
|
2041
|
-
initial:
|
|
2042
|
-
steady: e ?
|
|
2108
|
+
function Kr(t, e) {
|
|
2109
|
+
return Hr(t) >= Xr ? {
|
|
2110
|
+
initial: pe,
|
|
2111
|
+
steady: e ? pe : Fr
|
|
2043
2112
|
} : {
|
|
2044
|
-
initial:
|
|
2045
|
-
steady: e ?
|
|
2113
|
+
initial: we,
|
|
2114
|
+
steady: e ? we : Lr
|
|
2046
2115
|
};
|
|
2047
2116
|
}
|
|
2048
|
-
function
|
|
2117
|
+
function jr(t) {
|
|
2049
2118
|
return t instanceof Error ? t : new Error(String(t));
|
|
2050
2119
|
}
|
|
2051
|
-
function
|
|
2120
|
+
function Wr(t) {
|
|
2052
2121
|
if (!(!t || t.length === 0))
|
|
2053
2122
|
return new Map(t.map((e) => [e.variantId, e.buffer]));
|
|
2054
2123
|
}
|
|
2055
|
-
function
|
|
2124
|
+
function qr(t) {
|
|
2056
2125
|
if (t !== void 0)
|
|
2057
2126
|
return new Set(t);
|
|
2058
2127
|
}
|
|
2059
|
-
async function
|
|
2060
|
-
const r =
|
|
2128
|
+
async function Jr(t, e, n) {
|
|
2129
|
+
const r = Wr(e);
|
|
2061
2130
|
if (!t || !n || n.length === 0)
|
|
2062
2131
|
return r;
|
|
2063
|
-
const s = Array.from(new Set(n)).filter((a) => !(r != null && r.has(a))).sort((a,
|
|
2132
|
+
const s = Array.from(new Set(n)).filter((a) => !(r != null && r.has(a))).sort((a, u) => a - u);
|
|
2064
2133
|
if (s.length === 0)
|
|
2065
2134
|
return r;
|
|
2066
|
-
const o = await
|
|
2135
|
+
const o = await xr({
|
|
2067
2136
|
baseUrl: t.baseUrl,
|
|
2068
2137
|
entries: t.entries,
|
|
2069
2138
|
requiredVariantIds: s
|
|
2070
2139
|
}), i = new Map(r ?? []);
|
|
2071
|
-
for (const [a,
|
|
2072
|
-
i.set(a,
|
|
2140
|
+
for (const [a, u] of o.buffers)
|
|
2141
|
+
i.set(a, u);
|
|
2073
2142
|
return i;
|
|
2074
2143
|
}
|
|
2075
|
-
async function
|
|
2076
|
-
const h =
|
|
2077
|
-
let
|
|
2078
|
-
const
|
|
2144
|
+
async function Zr(t, e, n, r, s = !0, o, i, a, u, c, m, g, l, d, p = !1) {
|
|
2145
|
+
const h = wr(), y = [];
|
|
2146
|
+
let w = 0, _ = !1;
|
|
2147
|
+
const E = u === !0, A = typeof i == "number" && Number.isFinite(i) && i >= 0, U = await Jr(
|
|
2079
2148
|
a,
|
|
2080
|
-
|
|
2149
|
+
c,
|
|
2081
2150
|
g
|
|
2082
|
-
),
|
|
2151
|
+
), N = qr(m), C = n && n.length > 0 || r === !0 || s === !1 || o === !0 || A || E || U || N !== void 0 || l === !0 || d === !0 ? {
|
|
2083
2152
|
...n && n.length > 0 ? { hiddenInstanceIds: new Set(n) } : {},
|
|
2084
2153
|
...r === !0 ? { keepTextsForHiddenInstances: !0 } : {},
|
|
2085
2154
|
...s === !1 ? { loadBlocks: !1 } : {},
|
|
2086
2155
|
...o === !0 ? { suppressExpandedInsertGeometry: !0 } : {},
|
|
2087
|
-
...
|
|
2088
|
-
...
|
|
2089
|
-
...
|
|
2090
|
-
...
|
|
2091
|
-
...
|
|
2092
|
-
|
|
2093
|
-
|
|
2156
|
+
...A ? { maxExpandedInstanceVertices: i } : {},
|
|
2157
|
+
...E ? { deferExternalVariantGeometry: !0 } : {},
|
|
2158
|
+
...U ? { externalVariantBuffers: U } : {},
|
|
2159
|
+
...N !== void 0 ? { requiredExternalVariantIds: N } : {},
|
|
2160
|
+
...l === !0 ? { externalVariantDeltaOnly: !0 } : {},
|
|
2161
|
+
...d === !0 ? { cacheDocument: !0 } : {}
|
|
2162
|
+
} : void 0, V = p && Tt ? hr(t, Tt, C) : ze(t, C);
|
|
2163
|
+
p || (Tt = V.documentCache ?? null);
|
|
2164
|
+
const G = Kr(V.header, l === !0);
|
|
2165
|
+
H.postMessage({
|
|
2094
2166
|
type: "header",
|
|
2095
|
-
header:
|
|
2167
|
+
header: V.header
|
|
2096
2168
|
});
|
|
2097
|
-
const
|
|
2098
|
-
const
|
|
2099
|
-
return
|
|
2169
|
+
const $ = async () => {
|
|
2170
|
+
const T = await zr(h, e);
|
|
2171
|
+
return w = 0, T > 0 && (_ = !0), T;
|
|
2100
2172
|
};
|
|
2101
|
-
for (const
|
|
2102
|
-
if (
|
|
2103
|
-
|
|
2173
|
+
for (const T of V.chunks) {
|
|
2174
|
+
if (T.kind === "text") {
|
|
2175
|
+
y.push(T.payload), y.length >= Yr && await Ae(y, e);
|
|
2104
2176
|
continue;
|
|
2105
2177
|
}
|
|
2106
|
-
const
|
|
2107
|
-
markLinePositionXy:
|
|
2178
|
+
const P = He(T.payload, {
|
|
2179
|
+
markLinePositionXy: T.kind === "line"
|
|
2108
2180
|
});
|
|
2109
|
-
|
|
2110
|
-
const
|
|
2111
|
-
|
|
2181
|
+
w += br(h[T.kind], P);
|
|
2182
|
+
const k = _ ? G.steady : G.initial;
|
|
2183
|
+
w >= k && await $();
|
|
2112
2184
|
}
|
|
2113
|
-
await
|
|
2114
|
-
const
|
|
2115
|
-
|
|
2185
|
+
await $(), await Ae(y, e), H.postMessage({ type: "done" });
|
|
2186
|
+
const M = Ee(), I = Br(V.header);
|
|
2187
|
+
I && H.postMessage(
|
|
2116
2188
|
{
|
|
2117
2189
|
type: "insertModel",
|
|
2118
|
-
variants:
|
|
2119
|
-
instances:
|
|
2120
|
-
cost:
|
|
2121
|
-
bytes:
|
|
2122
|
-
planMs:
|
|
2190
|
+
variants: I.variants,
|
|
2191
|
+
instances: I.instances,
|
|
2192
|
+
cost: I.cost,
|
|
2193
|
+
bytes: I.bytes,
|
|
2194
|
+
planMs: Ee() - M
|
|
2123
2195
|
},
|
|
2124
|
-
|
|
2125
|
-
),
|
|
2196
|
+
$r(I)
|
|
2197
|
+
), H.postMessage({ type: "complete" });
|
|
2126
2198
|
}
|
|
2127
2199
|
self.addEventListener("message", (t) => {
|
|
2128
2200
|
const e = t.data;
|
|
2129
2201
|
if (!e) return;
|
|
2130
2202
|
if (e.type === "grant") {
|
|
2131
|
-
|
|
2203
|
+
X == null || X.grant({
|
|
2132
2204
|
geometryCredits: e.geometryCredits,
|
|
2133
2205
|
textCredits: e.textCredits
|
|
2134
2206
|
});
|
|
2135
2207
|
return;
|
|
2136
2208
|
}
|
|
2137
2209
|
if (e.type === "cancel") {
|
|
2138
|
-
|
|
2210
|
+
X == null || X.cancel();
|
|
2139
2211
|
return;
|
|
2140
2212
|
}
|
|
2141
2213
|
if (e.type !== "parse") return;
|
|
2142
|
-
const n = new
|
|
2143
|
-
|
|
2214
|
+
const n = new Dr();
|
|
2215
|
+
X = n;
|
|
2144
2216
|
const r = e.useRetainedMainBuffer === !0;
|
|
2145
2217
|
if (r && e.buffer !== void 0) {
|
|
2146
2218
|
const o = new Error("Geo prepare worker parse request cannot include both a retained and transferred main buffer");
|
|
2147
|
-
o.code = "E_MAIN_BUFFER_PROTOCOL",
|
|
2219
|
+
o.code = "E_MAIN_BUFFER_PROTOCOL", H.postMessage({
|
|
2148
2220
|
type: "error",
|
|
2149
2221
|
message: o.message,
|
|
2150
2222
|
code: "E_MAIN_BUFFER_PROTOCOL"
|
|
2151
|
-
}),
|
|
2223
|
+
}), X = null;
|
|
2152
2224
|
return;
|
|
2153
2225
|
}
|
|
2154
|
-
const s = r ?
|
|
2226
|
+
const s = r ? be : e.buffer;
|
|
2155
2227
|
if (!s) {
|
|
2156
2228
|
const o = new Error(
|
|
2157
2229
|
r ? "Geo prepare worker has no retained main buffer for this delta parse" : "Geo prepare worker parse request is missing its main buffer"
|
|
2158
2230
|
);
|
|
2159
|
-
o.code = "E_MAIN_BUFFER_MISSING",
|
|
2231
|
+
o.code = "E_MAIN_BUFFER_MISSING", H.postMessage({
|
|
2160
2232
|
type: "error",
|
|
2161
2233
|
message: o.message,
|
|
2162
2234
|
code: "E_MAIN_BUFFER_MISSING"
|
|
2163
|
-
}),
|
|
2235
|
+
}), X = null;
|
|
2164
2236
|
return;
|
|
2165
2237
|
}
|
|
2166
|
-
r || (
|
|
2238
|
+
r || (be = s), Zr(
|
|
2167
2239
|
s,
|
|
2168
2240
|
n,
|
|
2169
2241
|
e.hiddenInstanceIds,
|
|
@@ -2176,15 +2248,17 @@ self.addEventListener("message", (t) => {
|
|
|
2176
2248
|
e.externalVariantBuffers,
|
|
2177
2249
|
e.requiredExternalVariantIds,
|
|
2178
2250
|
e.externalVariantGeometryFetchIds,
|
|
2179
|
-
e.externalVariantDeltaOnly
|
|
2251
|
+
e.externalVariantDeltaOnly,
|
|
2252
|
+
e.cacheDocument,
|
|
2253
|
+
r
|
|
2180
2254
|
).catch((o) => {
|
|
2181
|
-
const i =
|
|
2182
|
-
|
|
2255
|
+
const i = jr(o), a = i.code;
|
|
2256
|
+
H.postMessage({
|
|
2183
2257
|
type: "error",
|
|
2184
2258
|
message: i.message,
|
|
2185
2259
|
code: typeof a == "string" ? a : void 0
|
|
2186
2260
|
});
|
|
2187
2261
|
}).finally(() => {
|
|
2188
|
-
|
|
2262
|
+
X === n && (X = null);
|
|
2189
2263
|
});
|
|
2190
2264
|
});
|