@nebula-spatial/cad-loader 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this package are documented in this file.
4
4
 
5
+ ## 0.2.1
6
+
7
+ - Added geometry Worker overrides to document sessions and external variant delta loading.
8
+
5
9
  ## 0.2.0
6
10
 
7
11
  - Added document-level CAD sessions with progressive content loading and viewport demand control.
package/README.md CHANGED
@@ -40,6 +40,17 @@ session.dispose();
40
40
  `headerReady` 提供文档边界和图层元数据,`initialContentReady` 表示基础内容已可用。
41
41
  通过 `content-appended`、`demand-progress`、`phase-change` 和错误事件可监听后续变化。
42
42
 
43
+ 默认几何准备 Worker 从包内的相对资源路径加载。使用非 Vite bundler、CSP 限制环境或自行托管
44
+ Worker 资源时,可在会话选项中传入 `workerUrl`;需要完全控制 Worker 创建时,可传入优先级更高的
45
+ `workerFactory`:
46
+
47
+ ```ts
48
+ const session = createCadDocumentSession(source, {
49
+ workerUrl: new URL('/assets/geo-prepare.worker.js', window.location.href),
50
+ // workerFactory: () => new Worker('/assets/geo-prepare.worker.js', { type: 'module' }),
51
+ });
52
+ ```
53
+
43
54
  `CadRenderNode` 是只读渲染资源。选择状态、属性面板、编辑命令和历史记录由产品层维护。
44
55
 
45
56
  ## 其他入口
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- var kr = Object.defineProperty;
1
+ var Tr = Object.defineProperty;
2
2
  var nn = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
- var Lr = (t, n, e) => n in t ? kr(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
5
+ var Lr = (t, n, e) => n in t ? Tr(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
6
6
  var f = (t, n, e) => Lr(t, typeof n != "symbol" ? n + "" : n, e), tt = (t, n, e) => n.has(t) || nn("Cannot " + e);
7
7
  var b = (t, n, e) => (tt(t, n, "read from private field"), e ? e.call(t) : n.get(t)), E = (t, n, e) => n.has(t) ? nn("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(t) : n.set(t, e), F = (t, n, e, r) => (tt(t, n, "write to private field"), r ? r.call(t, e) : n.set(t, e), e), R = (t, n, e) => (tt(t, n, "access private method"), e);
8
- import { CadPackError as O, normalizeGeometrySegments as Mr, normalizeViewportRect as Mt, cloneViewportRect as ze, mergeViewportRects as ve, readGroup as Dr, transformBBoxByInstance as Fr, parseBinStreaming as Dt, isStrictTextRoundtripEnabled as Or, assertStrictTextRoundtrip as _r, computeViewportRectFromPositions as Fe, expandViewportRect as je, viewportRectEquals as Gr, viewportRectIntersects as zn, viewportRectContains as Ft, transformViewportRect as Ur, readExternalVariantDependencyPlan as He, readExternalAnnotationManifest as Ot, readExternalBlockAnnotations as _t, readSceneAnnotationSidecar as Nr, parseBinPayload as zr, parseBinBounds as Hr, readExternalVariantManifest as qr } from "./core/index.js";
8
+ import { CadPackError as O, normalizeGeometrySegments as Mr, normalizeViewportRect as Mt, cloneViewportRect as ze, mergeViewportRects as ve, readGroup as Dr, transformBBoxByInstance as Fr, parseBinStreaming as Dt, isStrictTextRoundtripEnabled as Or, assertStrictTextRoundtrip as _r, computeViewportRectFromPositions as Fe, expandViewportRect as je, viewportRectEquals as Ur, viewportRectIntersects as zn, viewportRectContains as Ft, transformViewportRect as Gr, readExternalVariantDependencyPlan as He, readExternalAnnotationManifest as Ot, readExternalBlockAnnotations as _t, readSceneAnnotationSidecar as Nr, parseBinPayload as zr, parseBinBounds as Hr, readExternalVariantManifest as qr } from "./core/index.js";
9
9
  import { readBlockAnnotationSidecar as zo } from "./core/index.js";
10
- import { BufferAttribute as Q, RawShaderMaterial as Kr, Color as Hn, Vector2 as qn, DoubleSide as Ct, BufferGeometry as Gt, LineSegments as Ut, InstancedInterleavedBuffer as rn, InstancedBufferGeometry as Kn, Float32BufferAttribute as Xn, InterleavedBufferAttribute as Le, Mesh as Nt, Vector3 as nt, Box3 as Xr, Sphere as Wr, Object3D as wt, InstancedBufferAttribute as ce, Points as Wn, Group as J, PointsMaterial as sn, LineBasicMaterial as an, MeshBasicMaterial as on } from "three";
10
+ import { BufferAttribute as Q, RawShaderMaterial as Kr, Color as Hn, Vector2 as qn, DoubleSide as Ct, BufferGeometry as Ut, LineSegments as Gt, InstancedInterleavedBuffer as rn, InstancedBufferGeometry as Kn, Float32BufferAttribute as Xn, InterleavedBufferAttribute as Le, Mesh as Nt, Vector3 as nt, Box3 as Xr, Sphere as Wr, Object3D as wt, InstancedBufferAttribute as ce, Points as Wn, Group as J, PointsMaterial as sn, LineBasicMaterial as an, MeshBasicMaterial as on } from "three";
11
11
  import { BatchedText as ln, Text as Yr, preloadFont as qe } from "troika-three-text";
12
12
  import Qr from "rbush";
13
13
  const zt = 16.7, Ht = 6, qt = 128 * 1024 * 1024, Kt = 64 * 1024 * 1024, Xt = 2, Wt = 1, $r = 3e5, jr = 22e4, cn = 2;
@@ -556,7 +556,7 @@ async function at(t, n, e, r) {
556
556
  bytes: $n(i)
557
557
  }), s;
558
558
  }
559
- async function Ti(t, n, e) {
559
+ async function ki(t, n, e) {
560
560
  return await at("line", t.line, n, e) + await at("fill", t.fill, n, e) + await at("dot", t.dot, n, e);
561
561
  }
562
562
  async function mn(t, n, e) {
@@ -589,7 +589,7 @@ function Yt() {
589
589
  if (r()) return;
590
590
  await n({ type: "header", header: d.header });
591
591
  const h = async () => {
592
- const m = await Ti(s, n, r);
592
+ const m = await ki(s, n, r);
593
593
  return o = 0, m > 0 && (c = !0), m;
594
594
  };
595
595
  try {
@@ -629,7 +629,7 @@ function Yt() {
629
629
  }
630
630
  };
631
631
  }
632
- function ki(t) {
632
+ function Ti(t) {
633
633
  return t.reduce((n, e) => n + e.t.length * 2 + 128, 0);
634
634
  }
635
635
  function Li(t) {
@@ -720,7 +720,7 @@ function $t(t = {}) {
720
720
  type: "text",
721
721
  texts: x.texts,
722
722
  cost: x.cost,
723
- bytes: ki(x.texts)
723
+ bytes: Ti(x.texts)
724
724
  });
725
725
  return;
726
726
  }
@@ -818,13 +818,13 @@ function xn() {
818
818
  t = r, n = i;
819
819
  }), resolve: t, reject: n };
820
820
  }
821
- function Gi(t) {
821
+ function Ui(t) {
822
822
  return t instanceof Error ? t : new Error(String(t));
823
823
  }
824
824
  function ot(t) {
825
825
  return t === void 0 ? void 0 : new Set(t);
826
826
  }
827
- function Ui(t) {
827
+ function Gi(t) {
828
828
  return {
829
829
  highWatermarkBytes: (t == null ? void 0 : t.highWatermarkBytes) ?? qt,
830
830
  lowWatermarkBytes: (t == null ? void 0 : t.lowWatermarkBytes) ?? Kt,
@@ -901,19 +901,19 @@ function Xi(t) {
901
901
  dot: t.dot.map(lt)
902
902
  };
903
903
  }
904
- var k, Re, Be, Ae, xe, te, U, pe, ne, ge, Ee, Y, be, Se, Ve, _, Pe, Te, v, Jn, er, tr, ue, Bt, nr, we, At, Oe, _e, Ge;
904
+ var T, Re, Be, Ae, xe, te, G, pe, ne, ge, Ee, Y, be, Se, Ve, _, Pe, ke, v, Jn, er, tr, ue, Bt, nr, we, At, Oe, _e, Ue;
905
905
  class Wi {
906
906
  constructor(n, e) {
907
907
  E(this, v);
908
908
  f(this, "events");
909
909
  f(this, "ready");
910
- E(this, k);
910
+ E(this, T);
911
911
  E(this, Re);
912
912
  E(this, Be);
913
913
  E(this, Ae, new AbortController());
914
914
  E(this, xe, xn());
915
915
  E(this, te, xn());
916
- E(this, U);
916
+ E(this, G);
917
917
  E(this, pe, []);
918
918
  E(this, ne);
919
919
  E(this, ge, /* @__PURE__ */ new Set());
@@ -924,10 +924,10 @@ class Wi {
924
924
  E(this, Ve, !1);
925
925
  E(this, _, !1);
926
926
  E(this, Pe, !1);
927
- E(this, Te, vt());
928
- F(this, k, e);
927
+ E(this, ke, vt());
928
+ F(this, T, e);
929
929
  const r = Je(n, b(this, Ae).signal);
930
- F(this, Re, r.source), F(this, Be, r.sourceSignal), F(this, ne, new Qn(Ui(e.flowControl))), F(this, U, new _i((i) => R(this, v, nr).call(this, i))), this.events = b(this, U), this.ready = b(this, xe).promise, this.ready.catch(() => {
930
+ F(this, Re, r.source), F(this, Be, r.sourceSignal), F(this, ne, new Qn(Gi(e.flowControl))), F(this, G, new _i((i) => R(this, v, nr).call(this, i))), this.events = b(this, G), this.ready = b(this, xe).promise, this.ready.catch(() => {
931
931
  }), b(this, te).promise.catch(() => {
932
932
  }), R(this, v, At).call(this, e.signal), R(this, v, At).call(this, b(this, Be)), b(this, _) || R(this, v, Jn).call(this);
933
933
  }
@@ -941,11 +941,11 @@ class Wi {
941
941
  R(this, v, Oe).call(this, N("CAD load session disposed"));
942
942
  return;
943
943
  }
944
- (n = b(this, Y)) == null || n.dispose(), b(this, U).clear(), R(this, v, Ge).call(this);
944
+ (n = b(this, Y)) == null || n.dispose(), b(this, G).clear(), R(this, v, Ue).call(this);
945
945
  }
946
946
  }
947
947
  }
948
- k = new WeakMap(), Re = new WeakMap(), Be = new WeakMap(), Ae = new WeakMap(), xe = new WeakMap(), te = new WeakMap(), U = new WeakMap(), pe = new WeakMap(), ne = new WeakMap(), ge = new WeakMap(), Ee = new WeakMap(), Y = new WeakMap(), be = new WeakMap(), Se = new WeakMap(), Ve = new WeakMap(), _ = new WeakMap(), Pe = new WeakMap(), Te = new WeakMap(), v = new WeakSet(), Jn = async function() {
948
+ T = new WeakMap(), Re = new WeakMap(), Be = new WeakMap(), Ae = new WeakMap(), xe = new WeakMap(), te = new WeakMap(), G = new WeakMap(), pe = new WeakMap(), ne = new WeakMap(), ge = new WeakMap(), Ee = new WeakMap(), Y = new WeakMap(), be = new WeakMap(), Se = new WeakMap(), Ve = new WeakMap(), _ = new WeakMap(), Pe = new WeakMap(), ke = new WeakMap(), v = new WeakSet(), Jn = async function() {
949
949
  var n, e;
950
950
  try {
951
951
  const r = await Promise.race([
@@ -956,15 +956,15 @@ k = new WeakMap(), Re = new WeakMap(), Be = new WeakMap(), Ae = new WeakMap(), x
956
956
  F(this, Se, r.byteLength);
957
957
  const s = R(this, v, er).call(this).start({
958
958
  buffer: r,
959
- hiddenInstanceIds: ot(b(this, k).hiddenInstanceIds),
960
- keepTextsForHiddenInstances: b(this, k).keepTextsForHiddenInstances || void 0,
961
- loadBlocks: b(this, k).loadBlocks,
962
- suppressExpandedInsertGeometry: b(this, k).loadBlocks !== !1,
963
- maxExpandedInstanceVertices: b(this, k).maxExpandedInstanceVertices,
964
- externalVariantFetchSource: b(this, k).externalVariantFetchSource,
965
- externalVariantBuffers: b(this, k).externalVariantBuffers,
966
- requiredExternalVariantIds: ot(b(this, k).requiredExternalVariantIds),
967
- externalVariantGeometryFetchIds: ot(b(this, k).externalVariantGeometryFetchIds)
959
+ hiddenInstanceIds: ot(b(this, T).hiddenInstanceIds),
960
+ keepTextsForHiddenInstances: b(this, T).keepTextsForHiddenInstances || void 0,
961
+ loadBlocks: b(this, T).loadBlocks,
962
+ suppressExpandedInsertGeometry: b(this, T).loadBlocks !== !1,
963
+ maxExpandedInstanceVertices: b(this, T).maxExpandedInstanceVertices,
964
+ externalVariantFetchSource: b(this, T).externalVariantFetchSource,
965
+ externalVariantBuffers: b(this, T).externalVariantBuffers,
966
+ requiredExternalVariantIds: ot(b(this, T).requiredExternalVariantIds),
967
+ externalVariantGeometryFetchIds: ot(b(this, T).externalVariantGeometryFetchIds)
968
968
  }, (o) => R(this, v, tr).call(this, o));
969
969
  if (F(this, Y, s), s.completion.catch(() => {
970
970
  }), (n = s.backgroundCompletion) == null || n.catch(() => {
@@ -978,21 +978,21 @@ k = new WeakMap(), Re = new WeakMap(), Be = new WeakMap(), Ae = new WeakMap(), x
978
978
  chunks: b(this, pe),
979
979
  rawBytes: b(this, Se)
980
980
  };
981
- F(this, _, !0), b(this, U).push({ event: { type: "ready", document: a } }), b(this, U).close(), b(this, xe).resolve(a), R(this, v, Ge).call(this);
981
+ F(this, _, !0), b(this, G).push({ event: { type: "ready", document: a } }), b(this, G).close(), b(this, xe).resolve(a), R(this, v, Ue).call(this);
982
982
  } catch (r) {
983
- b(this, _) || R(this, v, Oe).call(this, Gi(r));
983
+ b(this, _) || R(this, v, Oe).call(this, Ui(r));
984
984
  } finally {
985
985
  (e = b(this, Y)) == null || e.dispose(), R(this, v, _e).call(this);
986
986
  }
987
987
  }, er = function() {
988
- return b(this, k).preferWorker !== !1 && Qt(b(this, k).workerFactory) ? $t({
989
- workerUrl: b(this, k).workerUrl,
990
- workerFactory: b(this, k).workerFactory
988
+ return b(this, T).preferWorker !== !1 && Qt(b(this, T).workerFactory) ? $t({
989
+ workerUrl: b(this, T).workerUrl,
990
+ workerFactory: b(this, T).workerFactory
991
991
  }) : Yt();
992
992
  }, tr = async function(n) {
993
993
  if (!b(this, _)) {
994
994
  if (n.type === "header") {
995
- F(this, be, n.header), b(this, U).push({
995
+ F(this, be, n.header), b(this, G).push({
996
996
  event: { type: "meta", meta: n.header, header: n.header }
997
997
  }), await R(this, v, ue).call(this);
998
998
  return;
@@ -1020,7 +1020,7 @@ k = new WeakMap(), Re = new WeakMap(), Be = new WeakMap(), Ae = new WeakMap(), x
1020
1020
  return;
1021
1021
  }
1022
1022
  if (n.type === "insertModel") {
1023
- b(this, U).push({
1023
+ b(this, G).push({
1024
1024
  event: {
1025
1025
  type: "insert",
1026
1026
  instances: Ki(n.instances),
@@ -1032,10 +1032,10 @@ k = new WeakMap(), Re = new WeakMap(), Be = new WeakMap(), Ae = new WeakMap(), x
1032
1032
  F(this, Ve, !0), await R(this, v, ue).call(this);
1033
1033
  }
1034
1034
  }, ue = async function() {
1035
- const n = Math.max(0, (b(this, k).frameBudgetMs ?? zt) - (b(this, k).frameReserveMs ?? Ht));
1036
- typeof performance > "u" || typeof performance.now != "function" || performance.now() - b(this, Te) < n || (await new Promise((e) => {
1035
+ const n = Math.max(0, (b(this, T).frameBudgetMs ?? zt) - (b(this, T).frameReserveMs ?? Ht));
1036
+ typeof performance > "u" || typeof performance.now != "function" || performance.now() - b(this, ke) < n || (await new Promise((e) => {
1037
1037
  typeof globalThis.requestAnimationFrame == "function" ? globalThis.requestAnimationFrame(() => e()) : setTimeout(e, 0);
1038
- }), F(this, Te, performance.now()));
1038
+ }), F(this, ke, performance.now()));
1039
1039
  }, Bt = function(n, e, r) {
1040
1040
  if (n.length === 0) {
1041
1041
  R(this, v, we).call(this, e === "geometry" ? { geometryCredits: 1, textCredits: 0 } : { geometryCredits: 0, textCredits: 1 });
@@ -1045,7 +1045,7 @@ k = new WeakMap(), Re = new WeakMap(), Be = new WeakMap(), Ae = new WeakMap(), x
1045
1045
  b(this, ne).onQueued(e, i.bytes);
1046
1046
  const s = b(this, ne).onConsumed(e, 0);
1047
1047
  if (i.creditReplaced = R(this, v, we).call(this, s), n.forEach((a, o) => {
1048
- b(this, U).push({
1048
+ b(this, G).push({
1049
1049
  ...a,
1050
1050
  batch: i,
1051
1051
  accountsBatch: o === n.length - 1
@@ -1074,11 +1074,11 @@ k = new WeakMap(), Re = new WeakMap(), Be = new WeakMap(), Ae = new WeakMap(), x
1074
1074
  n.addEventListener("abort", e, { once: !0 }), b(this, Ee).push(() => n.removeEventListener("abort", e));
1075
1075
  }, Oe = function(n) {
1076
1076
  var e, r, i;
1077
- b(this, _) || (F(this, _, !0), b(this, Ae).abort(n), (r = (e = b(this, Y)) == null ? void 0 : e.cancel) == null || r.call(e), (i = b(this, Y)) == null || i.dispose(), b(this, te).reject(n), b(this, xe).reject(n), b(this, U).push({ event: { type: "error", error: n } }), b(this, U).close(), R(this, v, _e).call(this), R(this, v, Ge).call(this));
1077
+ b(this, _) || (F(this, _, !0), b(this, Ae).abort(n), (r = (e = b(this, Y)) == null ? void 0 : e.cancel) == null || r.call(e), (i = b(this, Y)) == null || i.dispose(), b(this, te).reject(n), b(this, xe).reject(n), b(this, G).push({ event: { type: "error", error: n } }), b(this, G).close(), R(this, v, _e).call(this), R(this, v, Ue).call(this));
1078
1078
  }, _e = function() {
1079
1079
  for (const n of b(this, ge)) n();
1080
1080
  b(this, ge).clear();
1081
- }, Ge = function() {
1081
+ }, Ue = function() {
1082
1082
  for (const n of b(this, Ee).splice(0)) n();
1083
1083
  };
1084
1084
  function vo(t, n = {}) {
@@ -1202,22 +1202,22 @@ async function rr(t) {
1202
1202
  var z, en;
1203
1203
  const { node: n } = t, e = new ji(n), r = t.appendExternalVariantDelta === !0, i = new Yi(Ji(t.scheduler));
1204
1204
  let s = null, a = !0, o = null, c = !1, l = !1, d = !1, u = null, h = !1, y = null, p = null, m = null;
1205
- const I = [], w = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Set(), C = new Promise((g, T) => {
1206
- y = T;
1205
+ const I = [], w = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Set(), C = new Promise((g, k) => {
1206
+ y = k;
1207
1207
  });
1208
1208
  C.catch(() => {
1209
1209
  });
1210
1210
  const S = (g) => {
1211
1211
  var oe;
1212
- const T = pn(g);
1212
+ const k = pn(g);
1213
1213
  if (!d) {
1214
1214
  d = !0, (oe = s == null ? void 0 : s.cancel) == null || oe.call(s);
1215
1215
  for (const $ of w)
1216
- D($, T);
1217
- r || e.fail(T), n.ready.catch(() => {
1218
- }), y == null || y(T);
1216
+ D($, k);
1217
+ r || e.fail(k), n.ready.catch(() => {
1218
+ }), y == null || y(k);
1219
1219
  }
1220
- return T;
1220
+ return k;
1221
1221
  }, B = (g) => (x.add(g), g.then(
1222
1222
  () => {
1223
1223
  x.delete(g);
@@ -1229,17 +1229,17 @@ async function rr(t) {
1229
1229
  }), g), V = (g) => ({
1230
1230
  geometryCredits: g.geometryCredits,
1231
1231
  textCredits: g.textCredits
1232
- }), A = (g, T) => {
1233
- d || !(s != null && s.grant) || T && g.geometryCredits <= 0 && g.textCredits <= 0 || s.grant(V(g));
1232
+ }), A = (g, k) => {
1233
+ d || !(s != null && s.grant) || k && g.geometryCredits <= 0 && g.textCredits <= 0 || s.grant(V(g));
1234
1234
  }, P = (g) => {
1235
1235
  !o || g.flowQueued || (o.onQueued(g.kind, g.bytes), g.flowQueued = !0);
1236
1236
  }, M = () => {
1237
1237
  for (const g of w)
1238
1238
  P(g);
1239
- }, D = (g, T) => {
1239
+ }, D = (g, k) => {
1240
1240
  if (!g.settled) {
1241
- if (g.settled = !0, w.delete(g), T) {
1242
- g.reject(T);
1241
+ if (g.settled = !0, w.delete(g), k) {
1242
+ g.reject(k);
1243
1243
  return;
1244
1244
  }
1245
1245
  g.resolve();
@@ -1258,13 +1258,13 @@ async function rr(t) {
1258
1258
  }).finally(() => {
1259
1259
  u = null, !d && h && i.hasPending() && K();
1260
1260
  }), u.catch(() => {
1261
- }), u)), L = (g, T, oe) => {
1261
+ }), u)), L = (g, k, oe) => {
1262
1262
  let $ = null, tn = null;
1263
- const le = new Promise((ke, et) => {
1264
- $ = ke, tn = et;
1263
+ const le = new Promise((Te, et) => {
1264
+ $ = Te, tn = et;
1265
1265
  }), j = {
1266
1266
  kind: g,
1267
- bytes: T,
1267
+ bytes: k,
1268
1268
  append: oe,
1269
1269
  flowQueued: !1,
1270
1270
  settled: !1,
@@ -1286,9 +1286,9 @@ async function rr(t) {
1286
1286
  }
1287
1287
  try {
1288
1288
  j.append(), o && j.flowQueued && A(o.onConsumed(j.kind, j.bytes), !0), D(j);
1289
- } catch (ke) {
1290
- const et = pn(ke);
1291
- throw D(j, et), S(ke);
1289
+ } catch (Te) {
1290
+ const et = pn(Te);
1291
+ throw D(j, et), S(Te);
1292
1292
  }
1293
1293
  }), K(), le;
1294
1294
  }, X = (g) => {
@@ -1314,10 +1314,10 @@ async function rr(t) {
1314
1314
  return;
1315
1315
  }
1316
1316
  I.push(g);
1317
- }), H = (g, T) => {
1317
+ }), H = (g, k) => {
1318
1318
  const oe = Promise.resolve().then(async () => {
1319
1319
  var $;
1320
- await (($ = t.beforeTextAppend) == null ? void 0 : $.call(t, g)), await T();
1320
+ await (($ = t.beforeTextAppend) == null ? void 0 : $.call(t, g)), await k();
1321
1321
  }).catch(($) => {
1322
1322
  throw S($);
1323
1323
  });
@@ -1386,10 +1386,10 @@ async function rr(t) {
1386
1386
  W
1387
1387
  ), s.completion.catch(() => {
1388
1388
  }), t.signal) {
1389
- const g = t.signal, T = () => {
1389
+ const g = t.signal, k = () => {
1390
1390
  S(N(g.reason));
1391
1391
  };
1392
- g.addEventListener("abort", T, { once: !0 }), p = () => g.removeEventListener("abort", T), g.aborted && T();
1392
+ g.addEventListener("abort", k, { once: !0 }), p = () => g.removeEventListener("abort", k), g.aborted && k();
1393
1393
  }
1394
1394
  if (s.grant && (o = new Qn(es(t.flowControl)), M(), A(o.takeInitialGrant(), !1)), await Promise.race([s.completion, C]), s.backgroundCompletion && await Promise.race([s.backgroundCompletion, C]), await K(), await Promise.all(Array.from(x)), !c)
1395
1395
  throw new Error("Geo loader pipeline completed without done event");
@@ -1742,7 +1742,7 @@ function hr(t) {
1742
1742
  return xs[t];
1743
1743
  }
1744
1744
  function Cn(t, n) {
1745
- const e = hr(n.theme), r = n.elementKind ?? "line", i = n.state ?? "normal", s = Ue(t, n, 0);
1745
+ const e = hr(n.theme), r = n.elementKind ?? "line", i = n.state ?? "normal", s = Ge(t, n, 0);
1746
1746
  let a = ws(s, e, r), o = s.kind === "aci" && fr(s.index) === 7;
1747
1747
  if (n.enhanceContrast) {
1748
1748
  const l = bs(a, {
@@ -1764,15 +1764,15 @@ function bs(t, n) {
1764
1764
  const e = hr(n.theme), r = n.elementKind === "text" ? 4.5 : n.elementKind === "hatch" ? 1.6 : 2.2;
1765
1765
  return yr(t, e.background) >= r ? Ie(t) : Bs(t, e.background, r, n.theme);
1766
1766
  }
1767
- function Ue(t, n, e = 0) {
1768
- return e > gs ? n.fallbackColor ?? { kind: "aci", index: 7 } : t.kind === "bylayer" ? Ue(n.layerColor ?? n.fallbackColor ?? { kind: "aci", index: 7 }, n, e + 1) : t.kind === "byblock" ? Ue(
1767
+ function Ge(t, n, e = 0) {
1768
+ return e > gs ? n.fallbackColor ?? { kind: "aci", index: 7 } : t.kind === "bylayer" ? Ge(n.layerColor ?? n.fallbackColor ?? { kind: "aci", index: 7 }, n, e + 1) : t.kind === "byblock" ? Ge(
1769
1769
  n.byBlockColor ?? n.parentByBlockColor ?? n.fallbackColor ?? { kind: "aci", index: 7 },
1770
1770
  {
1771
1771
  ...n,
1772
1772
  byBlockColor: n.parentByBlockColor ?? null
1773
1773
  },
1774
1774
  e + 1
1775
- ) : t.kind === "none" ? Ue(n.fallbackColor ?? { kind: "aci", index: 7 }, n, e + 1) : t;
1775
+ ) : t.kind === "none" ? Ge(n.fallbackColor ?? { kind: "aci", index: 7 }, n, e + 1) : t;
1776
1776
  }
1777
1777
  function Is(t) {
1778
1778
  return Zt(t);
@@ -1960,7 +1960,7 @@ class mr extends Kr {
1960
1960
  this.uniforms.uResolution.value.set(Math.max(1, e), Math.max(1, r));
1961
1961
  }
1962
1962
  }
1963
- const Ts = new Float32Array([
1963
+ const ks = new Float32Array([
1964
1964
  -1,
1965
1965
  1,
1966
1966
  1,
@@ -1985,7 +1985,7 @@ const Ts = new Float32Array([
1985
1985
  1,
1986
1986
  0,
1987
1987
  -1
1988
- ]), ks = [
1988
+ ]), Ts = [
1989
1989
  0,
1990
1990
  2,
1991
1991
  1,
@@ -2014,14 +2014,14 @@ function xr(t, n) {
2014
2014
  t.boundingBox = e.box, t.boundingSphere = e.sphere;
2015
2015
  }
2016
2016
  function Ms(t) {
2017
- const n = new Gt();
2017
+ const n = new Ut();
2018
2018
  n.setAttribute("position", new Q(t.position, t.positionItemSize)), n.setAttribute("color", new Q(t.color, 3, !0)), xr(n, t.bbox);
2019
- const e = new mr({ variant: "thin" }), r = new Ut(n, e);
2019
+ const e = new mr({ variant: "thin" }), r = new Gt(n, e);
2020
2020
  return r.name = "cad-thin-line", r.renderOrder = 1, r.userData.kind = "line", r.userData.mode = "thin", r.userData.vertexCount = t.vertexCount, r.userData.bbox = t.bbox, r;
2021
2021
  }
2022
2022
  function Ds(t) {
2023
2023
  const n = Math.floor(t.vertexCount / 2), e = t.positionItemSize * 2, r = new rn(t.position, e, 1), i = new rn(t.color, 6, 1), s = new Kn();
2024
- s.setIndex(ks), s.setAttribute("position", new Xn(Ts.slice(), 3)), s.setAttribute("instanceStart", new Le(r, t.positionItemSize, 0)), s.setAttribute("instanceEnd", new Le(r, t.positionItemSize, t.positionItemSize)), s.setAttribute("instanceColorStart", new Le(i, 3, 0, !0)), s.setAttribute("instanceColorEnd", new Le(i, 3, 3, !0)), s.instanceCount = n, xr(s, t.bbox);
2024
+ s.setIndex(Ts), s.setAttribute("position", new Xn(ks.slice(), 3)), s.setAttribute("instanceStart", new Le(r, t.positionItemSize, 0)), s.setAttribute("instanceEnd", new Le(r, t.positionItemSize, t.positionItemSize)), s.setAttribute("instanceColorStart", new Le(i, 3, 0, !0)), s.setAttribute("instanceColorEnd", new Le(i, 3, 3, !0)), s.instanceCount = n, xr(s, t.bbox);
2025
2025
  const a = new mr({
2026
2026
  variant: "fat",
2027
2027
  linewidthPx: t.linewidthPx,
@@ -2066,9 +2066,9 @@ function dt(t, n) {
2066
2066
  const e = [];
2067
2067
  for (const r of n) {
2068
2068
  if (r.count <= 0) continue;
2069
- const i = r.bbox !== void 0 ? Us(r.bbox) : Fe(r.pos, r.count, 3), s = _s(t);
2069
+ const i = r.bbox !== void 0 ? Gs(r.bbox) : Fe(r.pos, r.count, 3), s = _s(t);
2070
2070
  for (let a = 0; a < r.count; ) {
2071
- const o = Gs(a, r.count, s, pr(t)), c = new Gt(), l = r.pos.subarray(a * 3, o * 3), d = r.col.subarray(a * 3, o * 3), u = o - a;
2071
+ const o = Us(a, r.count, s, pr(t)), c = new Ut(), l = r.pos.subarray(a * 3, o * 3), d = r.col.subarray(a * 3, o * 3), u = o - a;
2072
2072
  c.setAttribute("position", new Q(l, 3)), c.setAttribute("color", new Q(d, 3, !0)), e.push({
2073
2073
  geometry: c,
2074
2074
  vertexCount: u,
@@ -2087,7 +2087,7 @@ function _s(t) {
2087
2087
  const n = pr(t);
2088
2088
  return Math.max(n, Math.floor(Fs / n) * n);
2089
2089
  }
2090
- function Gs(t, n, e, r) {
2090
+ function Us(t, n, e, r) {
2091
2091
  let i = Math.min(n, t + e);
2092
2092
  if (i < n) {
2093
2093
  const s = t + Math.floor((i - t) / r) * r;
@@ -2095,7 +2095,7 @@ function Gs(t, n, e, r) {
2095
2095
  }
2096
2096
  return i > t ? i : n;
2097
2097
  }
2098
- function Us(t) {
2098
+ function Gs(t) {
2099
2099
  return t ? { minX: t.minX, minY: t.minY, maxX: t.maxX, maxY: t.maxY } : null;
2100
2100
  }
2101
2101
  function Ns(t) {
@@ -2253,7 +2253,7 @@ class Bn {
2253
2253
  }
2254
2254
  refresh(n, e, r, i) {
2255
2255
  const s = n ? je(n, this.marginRatio) : null, a = !s, o = i === void 0 ? `signature:${Hs(r)}` : `revision:${i}`;
2256
- if (this.cacheValid && this.lastLayerVersion === e.version && this.lastUserHiddenCacheKey === o && this.lastFilteredQueryAll === a && Gr(this.lastFilteredQueryRect, s))
2256
+ if (this.cacheValid && this.lastLayerVersion === e.version && this.lastUserHiddenCacheKey === o && this.lastFilteredQueryAll === a && Ur(this.lastFilteredQueryRect, s))
2257
2257
  return;
2258
2258
  const c = this.resolveQueryHits(s), l = /* @__PURE__ */ new Map();
2259
2259
  for (const u of c) {
@@ -2331,7 +2331,7 @@ function Hs(t) {
2331
2331
  return t.size === 0 ? "0:" : `${t.size}:${Array.from(t).sort((n, e) => n - e).join(",")}`;
2332
2332
  }
2333
2333
  function qs(t, n, e) {
2334
- const r = t === "line" ? new Ut(n, e) : t === "fill" ? new Nt(n, e) : new Wn(n, e);
2334
+ const r = t === "line" ? new Gt(n, e) : t === "fill" ? new Nt(n, e) : new Wn(n, e);
2335
2335
  return r.count = 0, r;
2336
2336
  }
2337
2337
  function An(t, n) {
@@ -2504,7 +2504,7 @@ function Cr(t, n, e) {
2504
2504
  function aa(t) {
2505
2505
  return t.recordKey ?? Cr(t.instanceId, t.variantId, 0);
2506
2506
  }
2507
- const ft = "geo-node:promoted-instanced-v1", Pn = "geo-node:text-batch-static-bounds-v1", Me = "geo-node:text-batch-bounds-dirty-v1", Tn = 1.5, oa = 1, kn = "geo-node:world-sized-points-v1", wr = "geo-node:world-sized-points-uniforms", la = 16777216, ca = 25, ua = 28, da = 29;
2507
+ const ft = "geo-node:promoted-instanced-v1", Pn = "geo-node:text-batch-static-bounds-v1", Me = "geo-node:text-batch-bounds-dirty-v1", kn = 1.5, oa = 1, Tn = "geo-node:world-sized-points-v1", wr = "geo-node:world-sized-points-uniforms", la = 16777216, ca = 25, ua = 28, da = 29;
2508
2508
  function ha() {
2509
2509
  return {
2510
2510
  activeThinCount: 0,
@@ -2519,7 +2519,7 @@ function Ce(t) {
2519
2519
  function fa(t, n) {
2520
2520
  return [Math.min(t[0], n[0]), Math.min(t[1], n[1]), Math.max(t[2], n[2]), Math.max(t[3], n[3])];
2521
2521
  }
2522
- function G(t) {
2522
+ function U(t) {
2523
2523
  return [t[0], t[1], t[2]];
2524
2524
  }
2525
2525
  function ya(t, n) {
@@ -2530,7 +2530,7 @@ function Ln(t, n, e) {
2530
2530
  r.vertexCount <= 0 || t.push({
2531
2531
  startVertex: r.startVertex + e,
2532
2532
  vertexCount: r.vertexCount,
2533
- color: G(r.color)
2533
+ color: U(r.color)
2534
2534
  });
2535
2535
  }
2536
2536
  function Pt(t) {
@@ -2540,7 +2540,7 @@ function Pt(t) {
2540
2540
  const r = {
2541
2541
  startVertex: e.startVertex,
2542
2542
  vertexCount: e.vertexCount,
2543
- color: G(e.color)
2543
+ color: U(e.color)
2544
2544
  }, i = n[n.length - 1];
2545
2545
  if (i && i.startVertex + i.vertexCount === r.startVertex && ya(i.color, r.color)) {
2546
2546
  n[n.length - 1] = {
@@ -2644,7 +2644,7 @@ function ba(t) {
2644
2644
  return {
2645
2645
  index: t.index,
2646
2646
  name: t.name,
2647
- color: G(t.color),
2647
+ color: U(t.color),
2648
2648
  lw_px: t.lw_px,
2649
2649
  visible: t.visible
2650
2650
  };
@@ -2748,11 +2748,11 @@ function Aa(t, n) {
2748
2748
  var o;
2749
2749
  const e = t.userData, r = Ba(t);
2750
2750
  if (r)
2751
- return r.uGeoPointWorldSize.value = n.pointWorldSize, r.uGeoPointViewportHeight.value = Math.max(1, Math.floor(n.viewportHeight) || 1), r.uGeoPointMinVisiblePixelSize.value = Tn, r;
2751
+ return r.uGeoPointWorldSize.value = n.pointWorldSize, r.uGeoPointViewportHeight.value = Math.max(1, Math.floor(n.viewportHeight) || 1), r.uGeoPointMinVisiblePixelSize.value = kn, r;
2752
2752
  const i = {
2753
2753
  uGeoPointWorldSize: { value: n.pointWorldSize },
2754
2754
  uGeoPointViewportHeight: { value: Math.max(1, Math.floor(n.viewportHeight) || 1) },
2755
- uGeoPointMinVisiblePixelSize: { value: Tn }
2755
+ uGeoPointMinVisiblePixelSize: { value: kn }
2756
2756
  };
2757
2757
  e[wr] = i;
2758
2758
  const s = t.onBeforeCompile;
@@ -2783,7 +2783,7 @@ function Aa(t, n) {
2783
2783
  ));
2784
2784
  };
2785
2785
  const a = (o = t.customProgramCacheKey) == null ? void 0 : o.bind(t);
2786
- return t.customProgramCacheKey = () => `${a ? a() : ""}|${kn}`, e[kn] = !0, t.needsUpdate = !0, i;
2786
+ return t.customProgramCacheKey = () => `${a ? a() : ""}|${Tn}`, e[Tn] = !0, t.needsUpdate = !0, i;
2787
2787
  }
2788
2788
  const We = /* @__PURE__ */ new WeakMap();
2789
2789
  function Ye(t, n) {
@@ -2903,7 +2903,7 @@ class fe extends J {
2903
2903
  const i = this.layerStatesByIndex.get(e), s = this.layerGroupsByIndex.get(e), a = this.originalLayerColorsByIndex.get(e);
2904
2904
  if (!i || !s || !a) return;
2905
2905
  const o = r === null ? null : Ia(r);
2906
- o ? this.colorOverridesByIndex.set(e, G(o)) : this.colorOverridesByIndex.delete(e), this.displayHexMemo.clear(), i.color = G(o ?? a), this.layerStateRevision += 1, s.traverse((c) => {
2906
+ o ? this.colorOverridesByIndex.set(e, U(o)) : this.colorOverridesByIndex.delete(e), this.displayHexMemo.clear(), i.color = U(o ?? a), this.layerStateRevision += 1, s.traverse((c) => {
2907
2907
  var h;
2908
2908
  const l = (h = c.userData) == null ? void 0 : h.kind;
2909
2909
  if (l === "text" || l === "text-batch") return;
@@ -2997,7 +2997,7 @@ class fe extends J {
2997
2997
  return [...e, ...r];
2998
2998
  }
2999
2999
  _collectTextUserDataForDebug() {
3000
- return this.textUserDataByAppendOrder.map((e) => ({ ...e, c: G(e.c) }));
3000
+ return this.textUserDataByAppendOrder.map((e) => ({ ...e, c: U(e.c) }));
3001
3001
  }
3002
3002
  getTextEntries() {
3003
3003
  return this.textUserDataByAppendOrder;
@@ -3194,9 +3194,9 @@ class fe extends J {
3194
3194
  const i = r.index, s = {
3195
3195
  ...r,
3196
3196
  visible: r.visible ?? !0,
3197
- color: G(r.color)
3197
+ color: U(r.color)
3198
3198
  };
3199
- this.layerOrder.push(i), this.layerStatesByIndex.set(i, s), this.originalLayerColorsByIndex.set(i, G(s.color));
3199
+ this.layerOrder.push(i), this.layerStatesByIndex.set(i, s), this.originalLayerColorsByIndex.set(i, U(s.color));
3200
3200
  const a = this.ensureLayerGroup(i, s.name, s.visible);
3201
3201
  a.name = s.name, a.visible = s.visible;
3202
3202
  }
@@ -3334,7 +3334,7 @@ class fe extends J {
3334
3334
  for (const l of c)
3335
3335
  s = ve(s, l.bbox);
3336
3336
  if (!s) return null;
3337
- const a = Ur(s, r);
3337
+ const a = Gr(s, r);
3338
3338
  return Vt(a) ? a : null;
3339
3339
  }
3340
3340
  _debugHasInsertPresenter() {
@@ -3444,7 +3444,7 @@ class fe extends J {
3444
3444
  const s = this.textRenderablesByLayerIndex.get(e.li) ?? [];
3445
3445
  s.push(i), this.textRenderablesByLayerIndex.set(e.li, s), this.textRenderablesByAppendOrder.push(i);
3446
3446
  const a = Number(r.userData.textCount || 0);
3447
- r.userData.textCount = a + 1, this.textUserDataByAppendOrder.push({ ...i.userData.text, c: G(i.userData.text.c) }), typeof globalThis.self < "u" && this.scheduleTextBatchSync(r);
3447
+ r.userData.textCount = a + 1, this.textUserDataByAppendOrder.push({ ...i.userData.text, c: U(i.userData.text.c) }), typeof globalThis.self < "u" && this.scheduleTextBatchSync(r);
3448
3448
  }
3449
3449
  appendAnnotationTextChunks(e) {
3450
3450
  if (!(this.disposed || e.length === 0))
@@ -3468,7 +3468,7 @@ class fe extends J {
3468
3468
  }
3469
3469
  this.applyAnnotationTextRenderableVisibility(o);
3470
3470
  const l = Number(r.userData.textCount || 0);
3471
- r.userData.textCount = l + 1, this.textUserDataByAppendOrder.push({ ...i.userData.text, c: G(i.userData.text.c) }), typeof globalThis.self < "u" && this.scheduleTextBatchSync(r);
3471
+ r.userData.textCount = l + 1, this.textUserDataByAppendOrder.push({ ...i.userData.text, c: U(i.userData.text.c) }), typeof globalThis.self < "u" && this.scheduleTextBatchSync(r);
3472
3472
  }
3473
3473
  getOrCreateTextBatch(e) {
3474
3474
  const r = this.textBatchByLayerIndex.get(e);
@@ -3512,7 +3512,7 @@ class fe extends J {
3512
3512
  }));
3513
3513
  }
3514
3514
  createRenderableChunk(e, r, i, s, a, o, c) {
3515
- const l = new Gt();
3515
+ const l = new Ut();
3516
3516
  l.setAttribute("position", new Xn(i, 3)), this.registerGeometryDisplayColors(
3517
3517
  l,
3518
3518
  s,
@@ -3525,7 +3525,7 @@ class fe extends J {
3525
3525
  if (e === "line") {
3526
3526
  const y = new an({ vertexColors: !0 });
3527
3527
  this.applyLayerColorState(y, d, e);
3528
- const p = new Ut(l, y);
3528
+ const p = new Gt(l, y);
3529
3529
  p.renderOrder = 1, u = p;
3530
3530
  } else if (e === "fill") {
3531
3531
  const y = new on({
@@ -3686,7 +3686,7 @@ class fe extends J {
3686
3686
  const r = Yr, i = this.resolveTextFont(e.t), s = new r();
3687
3687
  s.text = i.text, s.fontSize = e.h, s.position.set(e.x, e.y, 0), s.rotation.z = (e.r || 0) * Math.PI / 180, s.color = this.resolveDisplayHexForRgb(e.c, e.li, "text"), s.anchorX = fe.resolveTextAnchorX(e.ha), s.anchorY = fe.resolveTextAnchorY(e.va), i.fontUrl && (s.font = i.fontUrl), e.w && (s.maxWidth = e.w), e.lh && (s.lineHeight = e.lh);
3688
3688
  const a = e.wf || 1;
3689
- return s.scale.x = (e.mx ? -1 : 1) * a, e.my && (s.scale.y = -1), this.commitTroikaTextTransform(s), s.name = "text-chunk", s.userData.kind = "text", s.userData.layerIndex = e.li, s.userData.text = { ...e, c: G(e.c) }, s.userData.renderedText = i.text, s.userData.fontKind = i.kind ?? "default", s.userData.replacedUnsupportedText = i.replacedUnsupported === !0, s;
3689
+ return s.scale.x = (e.mx ? -1 : 1) * a, e.my && (s.scale.y = -1), this.commitTroikaTextTransform(s), s.name = "text-chunk", s.userData.kind = "text", s.userData.layerIndex = e.li, s.userData.text = { ...e, c: U(e.c) }, s.userData.renderedText = i.text, s.userData.fontKind = i.kind ?? "default", s.userData.replacedUnsupportedText = i.replacedUnsupported === !0, s;
3690
3690
  }
3691
3691
  commitTroikaTextTransform(e) {
3692
3692
  e.matrixAutoUpdate = !1, e.updateMatrix();
@@ -3782,10 +3782,10 @@ class fe extends J {
3782
3782
  this.layerStatesByIndex.set(e, {
3783
3783
  index: e,
3784
3784
  name: a.name,
3785
- color: G(c),
3785
+ color: U(c),
3786
3786
  lw_px: 1,
3787
3787
  visible: i
3788
- }), this.originalLayerColorsByIndex.set(e, G(c)), this.layerStateRevision += 1;
3788
+ }), this.originalLayerColorsByIndex.set(e, U(c)), this.layerStateRevision += 1;
3789
3789
  }
3790
3790
  return a;
3791
3791
  }
@@ -4311,6 +4311,8 @@ async function Sa(t, n, e) {
4311
4311
  await is(t, n, void 0, {
4312
4312
  signal: e.signal,
4313
4313
  hiddenInstanceIds: Jt(e.hiddenInstanceIds),
4314
+ workerUrl: e.workerUrl,
4315
+ workerFactory: e.workerFactory,
4314
4316
  externalVariantFetchSource: e.externalVariantFetchSource,
4315
4317
  externalVariantBuffers: e.externalVariantBuffers,
4316
4318
  requiredExternalVariantIds: re(e.requiredExternalVariantIds),
@@ -4343,7 +4345,7 @@ function Vo(t) {
4343
4345
  function Po(t, n) {
4344
4346
  return _t(t, n);
4345
4347
  }
4346
- function To(t, n) {
4348
+ function ko(t, n) {
4347
4349
  if (!n.externalVariantBuffers && !n.externalVariantFetchSource)
4348
4350
  throw new Error("External variant delta requires buffers or fetch source");
4349
4351
  const e = Dt(t, {
@@ -4357,10 +4359,10 @@ function To(t, n) {
4357
4359
  chunks: Array.from(e.chunks)
4358
4360
  };
4359
4361
  }
4360
- function ko(t) {
4362
+ function To(t) {
4361
4363
  ei(t);
4362
4364
  }
4363
- function Ta(t) {
4365
+ function ka(t) {
4364
4366
  return t instanceof Error ? t : typeof t == "string" ? new Error(t) : new Error(`Unknown geo load error: ${String(t)}`);
4365
4367
  }
4366
4368
  function Jt(t) {
@@ -4409,14 +4411,14 @@ function Lo(t, n = {}) {
4409
4411
  ...h
4410
4412
  });
4411
4413
  } catch (d) {
4412
- i._fail(Ta(d));
4414
+ i._fail(ka(d));
4413
4415
  } finally {
4414
4416
  for (const d of s) d();
4415
4417
  Ye(i, null);
4416
4418
  }
4417
4419
  })(), i;
4418
4420
  }
4419
- const ka = 40;
4421
+ const Ta = 40;
4420
4422
  function Br(t) {
4421
4423
  return !!(t && Number.isFinite(t.minX) && Number.isFinite(t.minY) && Number.isFinite(t.maxX) && Number.isFinite(t.maxY) && t.maxX >= t.minX && t.maxY >= t.minY);
4422
4424
  }
@@ -4432,7 +4434,7 @@ function Mo(t, n) {
4432
4434
  function Da(t, n, e = {}) {
4433
4435
  var a;
4434
4436
  if (!Number.isFinite(n.x) || !Number.isFinite(n.y)) return null;
4435
- const r = Math.max(0, e.padding ?? ka), i = t.getLayers();
4437
+ const r = Math.max(0, e.padding ?? Ta), i = t.getLayers();
4436
4438
  let s = null;
4437
4439
  for (let o = i.length - 1; o >= 0; o -= 1) {
4438
4440
  const c = i[o];
@@ -4485,7 +4487,7 @@ function _a(t, n, e) {
4485
4487
  const r = t.x - n.x, i = t.y - n.y, s = (n.r || 0) * Math.PI / 180, a = Math.cos(-s), o = Math.sin(-s), c = r * a - i * o, l = r * o + i * a;
4486
4488
  return c >= e.x0 && c <= e.x1 && l >= e.y0 && l <= e.y1;
4487
4489
  }
4488
- function Ga(t, n, e = {}) {
4490
+ function Ua(t, n, e = {}) {
4489
4491
  if (!Number.isFinite(n.x) || !Number.isFinite(n.y)) return null;
4490
4492
  const r = t.getTextEntries(), i = e.maxTextCount;
4491
4493
  if (r.length === 0) return null;
@@ -4497,7 +4499,7 @@ function Ga(t, n, e = {}) {
4497
4499
  }
4498
4500
  return null;
4499
4501
  }
4500
- function Ua(t, n) {
4502
+ function Ga(t, n) {
4501
4503
  if (n.kind !== "text" || !Number.isInteger(n.textId) || n.textId < 0) return null;
4502
4504
  const e = t.getTextEntries()[n.textId];
4503
4505
  if (!e) return null;
@@ -4523,13 +4525,13 @@ const Fo = [
4523
4525
  "interactive",
4524
4526
  "failed",
4525
4527
  "disposed"
4526
- ], Tt = "insert:";
4528
+ ], kt = "insert:";
4527
4529
  function Na(t) {
4528
- return `${Tt}${t.layerIndex}:${t.variantId}:${t.instanceId}`;
4530
+ return `${kt}${t.layerIndex}:${t.variantId}:${t.instanceId}`;
4529
4531
  }
4530
4532
  function Ar(t) {
4531
- if (t.startsWith(Tt)) {
4532
- const e = t.slice(Tt.length).split(":");
4533
+ if (t.startsWith(kt)) {
4534
+ const e = t.slice(kt.length).split(":");
4533
4535
  if (e.length !== 3) return null;
4534
4536
  const r = Number(e[0]), i = Number(e[1]), s = Number(e[2]);
4535
4537
  return [r, i, s].every(Number.isInteger) ? { kind: "insert", layerIndex: r, variantId: i, instanceId: s } : null;
@@ -4777,14 +4779,14 @@ function _n(t) {
4777
4779
  t.manifestBBox
4778
4780
  );
4779
4781
  }
4780
- function Gn(t) {
4782
+ function Un(t) {
4781
4783
  const n = t == null ? void 0 : t.bbox;
4782
4784
  return n ? { minX: n[0], minY: n[1], maxX: n[2], maxY: n[3] } : null;
4783
4785
  }
4784
4786
  function gt(t) {
4785
4787
  return "annotation" in t && (t.annotation.line_count > 0 || t.annotation.fill_count > 0 || t.annotation.dot_count > 0 || t.annotation.text_count > 0);
4786
4788
  }
4787
- function Un(t) {
4789
+ function Gn(t) {
4788
4790
  return Number.isFinite(t) && t > 0 && t <= Vr;
4789
4791
  }
4790
4792
  function Ja(t) {
@@ -4954,19 +4956,19 @@ function ho(t) {
4954
4956
  function bt(t) {
4955
4957
  return Array.from(t).sort((n, e) => n - e).join(",");
4956
4958
  }
4957
- function Tr(t, n) {
4959
+ function kr(t, n) {
4958
4960
  if (t === null || !Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) return !1;
4959
4961
  const e = n / t;
4960
4962
  return e >= 1 - Nn && e <= 1 + Nn;
4961
4963
  }
4962
4964
  function fo(t) {
4963
- return !t.viewport || !t.coverage || !Ft(t.coverage, t.viewport) || !Tr(t.coverageWorldUnitsPerPixel, t.worldUnitsPerPixel) ? !1 : t.coverageHiddenSignature === t.hiddenSignature;
4965
+ return !t.viewport || !t.coverage || !Ft(t.coverage, t.viewport) || !kr(t.coverageWorldUnitsPerPixel, t.worldUnitsPerPixel) ? !1 : t.coverageHiddenSignature === t.hiddenSignature;
4964
4966
  }
4965
4967
  function yo(t) {
4966
4968
  return !t.latestViewport || !Ft(
4967
4969
  je(t.requestedViewport, Pr),
4968
4970
  t.latestViewport
4969
- ) || !Tr(t.requestedWorldUnitsPerPixel, t.latestWorldUnitsPerPixel) ? !1 : t.requestedHiddenSignature === t.latestHiddenSignature;
4971
+ ) || !kr(t.requestedWorldUnitsPerPixel, t.latestWorldUnitsPerPixel) ? !1 : t.requestedHiddenSignature === t.latestHiddenSignature;
4970
4972
  }
4971
4973
  function De(t, n, e) {
4972
4974
  return {
@@ -4975,9 +4977,9 @@ function De(t, n, e) {
4975
4977
  hiddenSignature: e
4976
4978
  };
4977
4979
  }
4978
- const kt = /* @__PURE__ */ new WeakMap();
4980
+ const Tt = /* @__PURE__ */ new WeakMap();
4979
4981
  function Oo(t) {
4980
- const n = kt.get(t);
4982
+ const n = Tt.get(t);
4981
4983
  if (!n)
4982
4984
  throw new Error("CAD document session has no render resource");
4983
4985
  return n;
@@ -5030,6 +5032,8 @@ const $e = class $e {
5030
5032
  f(this, "textWarmup");
5031
5033
  f(this, "resolveTextFont");
5032
5034
  f(this, "loadAnnotations");
5035
+ f(this, "workerUrl");
5036
+ f(this, "workerFactory");
5033
5037
  f(this, "listeners", /* @__PURE__ */ new Map());
5034
5038
  f(this, "resolveHeader");
5035
5039
  f(this, "rejectHeader");
@@ -5039,7 +5043,7 @@ const $e = class $e {
5039
5043
  f(this, "handleBeforeTextAppend", (n) => {
5040
5044
  this.scheduleTextWarmup(n);
5041
5045
  });
5042
- this.sessionEpoch = $e.nextEpoch++, this.documentKey = e.documentKey ?? null, this.filename = e.filename ?? null, this.loadAnnotations = e.loadAnnotations !== !1, this.fontRuntime = Ja({
5046
+ this.sessionEpoch = $e.nextEpoch++, this.documentKey = e.documentKey ?? null, this.filename = e.filename ?? null, this.loadAnnotations = e.loadAnnotations !== !1, this.workerUrl = e.workerUrl, this.workerFactory = e.workerFactory, this.fontRuntime = Ja({
5043
5047
  fontResolver: e.fontResolver,
5044
5048
  signal: this.sessionAbort.signal,
5045
5049
  onNonFatalError: (i) => this.emit("non-fatal-error", { error: i })
@@ -5058,7 +5062,7 @@ const $e = class $e {
5058
5062
  onInsertVisibilityChange: () => {
5059
5063
  this.latestDemand && this.maybeRefreshExternalSidecars({ force: !0 });
5060
5064
  }
5061
- }), kt.set(this, this.renderNode), this.headerReady = new Promise((i, s) => {
5065
+ }), Tt.set(this, this.renderNode), this.headerReady = new Promise((i, s) => {
5062
5066
  this.resolveHeader = i, this.rejectHeader = s;
5063
5067
  }), this.initialContentReady = new Promise((i, s) => {
5064
5068
  this.resolveInitial = i, this.rejectInitial = s;
@@ -5152,11 +5156,11 @@ const $e = class $e {
5152
5156
  } : null;
5153
5157
  }
5154
5158
  pickTextAtPoint(n) {
5155
- const e = Ga(this.node, { x: n.x, y: n.y });
5159
+ const e = Ua(this.node, { x: n.x, y: n.y });
5156
5160
  return e ? {
5157
5161
  documentKey: this.documentKey,
5158
5162
  id: e,
5159
- details: Ua(this.node, e)
5163
+ details: Ga(this.node, e)
5160
5164
  } : null;
5161
5165
  }
5162
5166
  abort(n) {
@@ -5171,7 +5175,7 @@ const $e = class $e {
5171
5175
  this.disposed = !0, this.sessionAbort.abort(n), this.demandAbort.abort(n), this.annotationAbort.abort(n), this.clearAnnotationTimer(), this.rejectHeader(n), this.rejectInitial(n), this.setPhase("disposed"), (e = this.textWarmup) == null || e.dispose(), this.fontRuntime.dispose(), this.listeners.clear();
5172
5176
  for (const r of this.signalCleanups) r();
5173
5177
  this.signalCleanups.length = 0, Ye(this.node, null), this.node.ready.catch(() => {
5174
- }), this.renderNode.dispose(), kt.delete(this);
5178
+ }), this.renderNode.dispose(), Tt.delete(this);
5175
5179
  }
5176
5180
  async runLoad() {
5177
5181
  const n = this.sessionEpoch;
@@ -5188,6 +5192,8 @@ const $e = class $e {
5188
5192
  const s = this.latestDemand ?? this.pendingDemand, a = await this.prepareInitialExternalVariants(s);
5189
5193
  if (!this.isCurrent(n) || (await ar(this.node, e.slice(0), void 0, {
5190
5194
  signal: this.sessionAbort.signal,
5195
+ workerUrl: this.workerUrl,
5196
+ workerFactory: this.workerFactory,
5191
5197
  hiddenInstanceIds: this.hiddenInstanceIds.size > 0 ? this.hiddenInstanceIds : void 0,
5192
5198
  externalVariantBuffers: xo(a.buffers),
5193
5199
  requiredExternalVariantIds: a.requiredVariantIds,
@@ -5310,6 +5316,8 @@ const $e = class $e {
5310
5316
  }
5311
5317
  if (await Sa(this.node, i, {
5312
5318
  signal: this.demandAbort.signal,
5319
+ workerUrl: this.workerUrl,
5320
+ workerFactory: this.workerFactory,
5313
5321
  hiddenInstanceIds: Array.from(this.hiddenInstanceIds).sort((h, y) => h - y),
5314
5322
  externalVariantBuffers: d,
5315
5323
  requiredExternalVariantIds: l,
@@ -5347,10 +5355,10 @@ const $e = class $e {
5347
5355
  }
5348
5356
  shouldScheduleAnnotationLoad(n) {
5349
5357
  var i;
5350
- if (!Un(n.worldUnitsPerPixel)) return !1;
5358
+ if (!Gn(n.worldUnitsPerPixel)) return !1;
5351
5359
  const e = (i = this.annotationManifest) == null ? void 0 : i.scene;
5352
5360
  return e && !this.sceneAnnotationsLoaded && !this.sceneAnnotationsLoading && _n({
5353
- manifestBBox: Gn(e),
5361
+ manifestBBox: Un(e),
5354
5362
  viewport: n.documentRect,
5355
5363
  worldUnitsPerPixel: n.worldUnitsPerPixel
5356
5364
  }) ? !0 : !!(!this.blockAnnotationsLoaded && !this.blockAnnotationsLoading && this.variantManifest.some(gt));
@@ -5385,7 +5393,7 @@ const $e = class $e {
5385
5393
  var r;
5386
5394
  const e = (r = this.annotationManifest) == null ? void 0 : r.scene;
5387
5395
  if (!(!e || this.sceneAnnotationsLoaded || this.sceneAnnotationsLoading) && this.baseUrl && _n({
5388
- manifestBBox: Gn(e),
5396
+ manifestBBox: Un(e),
5389
5397
  viewport: n.documentRect,
5390
5398
  worldUnitsPerPixel: n.worldUnitsPerPixel
5391
5399
  })) {
@@ -5403,7 +5411,7 @@ const $e = class $e {
5403
5411
  }
5404
5412
  }
5405
5413
  async loadBlockAnnotations(n) {
5406
- if (!(this.blockAnnotationsLoaded || this.blockAnnotationsLoading) && this.mainBuffer && this.variantManifest.some(gt) && Un(n.worldUnitsPerPixel)) {
5414
+ if (!(this.blockAnnotationsLoaded || this.blockAnnotationsLoading) && this.mainBuffer && this.variantManifest.some(gt) && Gn(n.worldUnitsPerPixel)) {
5407
5415
  this.blockAnnotationsLoading = !0;
5408
5416
  try {
5409
5417
  const e = _t(this.mainBuffer, {
@@ -5556,7 +5564,7 @@ const po = [
5556
5564
  "applyInsertTransform",
5557
5565
  "editBlock"
5558
5566
  ];
5559
- function Go(t) {
5567
+ function Uo(t) {
5560
5568
  return po.includes(t);
5561
5569
  }
5562
5570
  export {
@@ -5567,7 +5575,7 @@ export {
5567
5575
  O as GeoLoaderError,
5568
5576
  fe as GeoNode,
5569
5577
  Sa as appendExternalVariantDeltaToGeoNode,
5570
- ko as assertValidSourceOrThrow,
5578
+ To as assertValidSourceOrThrow,
5571
5579
  Mo as cadInsertSelectionEquals,
5572
5580
  Do as cadTextSelectionEquals,
5573
5581
  _o as createCadDocumentSession,
@@ -5575,17 +5583,17 @@ export {
5575
5583
  je as expandViewportRect,
5576
5584
  Na as formatCadInsertId,
5577
5585
  Oo as getCadDocumentRenderResource,
5578
- Go as isCadRenderNodeEditMethod,
5579
- To as loadExternalVariantDeltaFromBuffer,
5586
+ Uo as isCadRenderNodeEditMethod,
5587
+ ko as loadExternalVariantDeltaFromBuffer,
5580
5588
  Lo as loadGeo,
5581
5589
  ve as mergeViewportRects,
5582
- Ta as normalizeGeoError,
5590
+ ka as normalizeGeoError,
5583
5591
  Bo as parseBuffer,
5584
5592
  Ao as parseBufferBounds,
5585
5593
  Pa as parseBufferHeader,
5586
5594
  Ar as parseCadInsertId,
5587
5595
  Da as pickCadInsertAtPoint,
5588
- Ga as pickCadTextAtPoint,
5596
+ Ua as pickCadTextAtPoint,
5589
5597
  zo as readBlockAnnotationSidecar,
5590
5598
  Vo as readBufferExternalAnnotationManifest,
5591
5599
  Po as readBufferExternalBlockAnnotations,
@@ -5593,7 +5601,7 @@ export {
5593
5601
  Eo as readBufferExternalVariantManifest,
5594
5602
  Nr as readSceneAnnotationSidecar,
5595
5603
  pt as resolveCadInsertDetails,
5596
- Ua as resolveCadTextDetails,
5604
+ Ga as resolveCadTextDetails,
5597
5605
  Fr as transformBBoxByInstance,
5598
5606
  Ft as viewportRectContains,
5599
5607
  zn as viewportRectIntersects
@@ -28,6 +28,8 @@ export interface LoadExternalVariantDeltaOptions {
28
28
  signal?: AbortSignal;
29
29
  beforeTextAppend?: (texts: readonly TextEntity[]) => void | Promise<void>;
30
30
  hiddenInstanceIds?: readonly number[];
31
+ workerUrl?: string | URL;
32
+ workerFactory?: () => Worker;
31
33
  externalVariantFetchSource?: ExternalVariantFetchSource;
32
34
  externalVariantBuffers: ReadonlyMap<number, ArrayBuffer>;
33
35
  requiredExternalVariantIds: readonly number[];
@@ -143,6 +143,10 @@ export interface CadDocumentSessionOptions {
143
143
  readonly documentKey?: string;
144
144
  readonly filename?: string;
145
145
  readonly loadAnnotations?: boolean;
146
+ /** Override the package-relative geometry preparation Worker URL. */
147
+ readonly workerUrl?: string | URL;
148
+ /** Create the geometry preparation Worker. Takes precedence over `workerUrl`. */
149
+ readonly workerFactory?: () => Worker;
146
150
  readonly fontResolver?: CadFontResolver;
147
151
  readonly resolveTextFont?: ResolveTextFont;
148
152
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebula-spatial/cad-loader",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Browser-side DXB3/DXBS CAD pack loader runtime",
5
5
  "license": "ISC",
6
6
  "engines": {