@mlightcad/mtext-renderer 0.4.8 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -367,7 +367,9 @@ const Pe = {
367
367
  {
368
368
  upgrade: (e, r, n) => this.handleUpgrade(e, r, n),
369
369
  blocked() {
370
- console.warn("Database upgrade blocked - please close other tabs using the application");
370
+ console.warn(
371
+ "Database upgrade blocked - please close other tabs using the application"
372
+ );
371
373
  },
372
374
  blocking() {
373
375
  console.warn("Database blocking newer version - closing connection"), ee.instance.close();
@@ -10757,7 +10759,12 @@ class pr extends kn {
10757
10759
  return e.maxX - e.minX;
10758
10760
  }
10759
10761
  offset(e) {
10760
- return new pr(this.char, this.fontSize, this.shape.offset(e), this.font);
10762
+ return new pr(
10763
+ this.char,
10764
+ this.fontSize,
10765
+ this.shape.offset(e),
10766
+ this.font
10767
+ );
10761
10768
  }
10762
10769
  /**
10763
10770
  * Converts the text shape to a THREE.js geometry
@@ -10776,7 +10783,10 @@ class pr extends kn {
10776
10783
  n.push(l.x, l.y, 0), u === o.length - 1 || a.push(s, s + 1), s++;
10777
10784
  }
10778
10785
  }
10779
- e.setAttribute("position", new L.Float32BufferAttribute(n, 3)), e.setIndex(a);
10786
+ e.setAttribute(
10787
+ "position",
10788
+ new L.Float32BufferAttribute(n, 3)
10789
+ ), e.setIndex(a);
10780
10790
  }
10781
10791
  return e;
10782
10792
  }
@@ -10838,7 +10848,9 @@ class mn extends Sn {
10838
10848
  }
10839
10849
  getCode(e) {
10840
10850
  if (this.font.fontData.header.fontType === te.BIGFONT)
10841
- throw new Error(`Can't get font glyph for '${e}' because big font is not supported yet!`);
10851
+ throw new Error(
10852
+ `Can't get font glyph for '${e}' because big font is not supported yet!`
10853
+ );
10842
10854
  return e.charCodeAt(0);
10843
10855
  }
10844
10856
  }
@@ -10892,7 +10904,7 @@ class ke {
10892
10904
  fontNotFound: new yr(),
10893
10905
  /** Event triggered when a font is successfully loaded */
10894
10906
  fontLoaded: new yr()
10895
- }, this.loader = new L.FileLoader(), this.loader.setResponseType("arraybuffer"), this.fileNames = [];
10907
+ }, this.loader = new L.FileLoader(), this.loader.setResponseType("arraybuffer"), this.fileNames = [], this.fontLoader = new ml();
10896
10908
  }
10897
10909
  /**
10898
10910
  * Gets the singleton instance of the FontManager
@@ -10908,12 +10920,36 @@ class ke {
10908
10920
  setFontMapping(e) {
10909
10921
  this.fontMapping = e;
10910
10922
  }
10923
+ /**
10924
+ * Sets the font loader
10925
+ * @param fontLoader - The font loader to set
10926
+ */
10927
+ setFontLoader(e) {
10928
+ this.fontLoader = e;
10929
+ }
10930
+ /**
10931
+ * Retrieves information about all available fonts in the system.
10932
+ * Loads font metadata from a CDN if not already loaded.
10933
+ * @returns Promise that resolves to an array of FontInfo objects
10934
+ * @throws {Error} If font metadata cannot be loaded from the CDN
10935
+ */
10936
+ async getAvaiableFonts() {
10937
+ return await this.fontLoader.getAvaiableFonts();
10938
+ }
10939
+ /**
10940
+ * Loads the specified fonts from font names
10941
+ * @param names - Font names to load.
10942
+ * @returns Promise that resolves to an array of font load statuses
10943
+ */
10944
+ async loadFontsByNames(e) {
10945
+ return e = Array.isArray(e) ? e : [e], await this.fontLoader.load(e);
10946
+ }
10911
10947
  /**
10912
10948
  * Loads the specified fonts from URLs
10913
- * @param urls - URLs of font files to load. The order represents the priority
10949
+ * @param urls - URLs of font files to load.
10914
10950
  * @returns Promise that resolves to an array of font load statuses
10915
10951
  */
10916
- async loadFonts(e) {
10952
+ async loadFontsByUrls(e) {
10917
10953
  e = Array.isArray(e) ? e : [e];
10918
10954
  const r = [];
10919
10955
  for (let a = 0; a < e.length; a++) {
@@ -11141,8 +11177,7 @@ class ml {
11141
11177
  * @returns Promise that resolves to an array of FontLoadStatus objects
11142
11178
  */
11143
11179
  async load(e) {
11144
- if (e.length == 0)
11145
- return await this.getAvaiableFonts(), [];
11180
+ e.length == 0 && await this.getAvaiableFonts();
11146
11181
  const r = [], n = [], a = {};
11147
11182
  this._avaiableFonts.forEach((o) => {
11148
11183
  o.name.forEach((u) => {
@@ -11157,7 +11192,7 @@ class ml {
11157
11192
  }) : r.push(l));
11158
11193
  });
11159
11194
  let s = [];
11160
- r.length > 0 && (s = await ke.instance.loadFonts(r));
11195
+ r.length > 0 && (s = await ke.instance.loadFontsByUrls(r));
11161
11196
  const i = {};
11162
11197
  return [...n, ...s].forEach((o) => {
11163
11198
  i[o.fontName] = o;
@@ -12246,7 +12281,9 @@ class Cl {
12246
12281
  */
12247
12282
  constructor(e, r, n, a) {
12248
12283
  this._contextStack = [], this._maxFontSize = 0, this._currentIndent = 0, this._currentLeftMargin = 0, this._currentRightMargin = 0, this._style = e, this._styleManager = r, this._fontManager = n, this._options = a, this._totalHeight = 0, this._hOffset = 0, this._vOffset = 0, this._lineCount = 1, this._currentLineObjects = [], this._currentContext = new gr({
12249
- fontScaleFactor: this.fontManager.getFontScaleFactor(this.textStyle.font.toLowerCase()),
12284
+ fontScaleFactor: this.fontManager.getFontScaleFactor(
12285
+ this.textStyle.font.toLowerCase()
12286
+ ),
12250
12287
  fontSize: a.fontSize,
12251
12288
  fontSizeScaleFactor: 1,
12252
12289
  italic: !1,
@@ -12255,7 +12292,10 @@ class Cl {
12255
12292
  this.textStyle.font.toLowerCase(),
12256
12293
  a.fontSize
12257
12294
  )
12258
- }), this._currentContext.setColorFromHex(e.color), this._currentContext.fontFace.family = this.textStyle.font.toLowerCase(), this._currentContext.widthFactor = { value: a.widthFactor, isRelative: !0 }, this._currentContext.oblique = e.obliqueAngle || 0, this._maxFontSize = 0, this._currentHorizontalAlignment = a.horizontalAlignment, this._currentIndent = 0, this._currentLeftMargin = 0, this._currentRightMargin = 0, this.initLineParams();
12295
+ }), this._currentContext.setColorFromHex(e.color), this._currentContext.fontFace.family = this.textStyle.font.toLowerCase(), this._currentContext.widthFactor = {
12296
+ value: a.widthFactor,
12297
+ isRelative: !0
12298
+ }, this._currentContext.oblique = e.obliqueAngle || 0, this._maxFontSize = 0, this._currentHorizontalAlignment = a.horizontalAlignment, this._currentIndent = 0, this._currentLeftMargin = 0, this._currentRightMargin = 0, this.initLineParams();
12259
12299
  }
12260
12300
  get fontManager() {
12261
12301
  return this._fontManager;
@@ -12399,7 +12439,9 @@ class Cl {
12399
12439
  switch (e.command) {
12400
12440
  case "f":
12401
12441
  case "F":
12402
- e.changes.fontFace && (this.changeFont(e.changes.fontFace.family), this.fontManager.getFontType(this._currentContext.fontFace.family) === "mesh" ? (this._currentContext.italic = e.changes.fontFace.style === "Italic", this._currentContext.bold = (e.changes.fontFace.weight || 400) >= 700, this._currentContext.oblique = this.textStyle.obliqueAngle || 0) : (this._currentContext.italic = !1, this._currentContext.bold = !1, e.changes.fontFace.style === "Italic" ? this._currentContext.oblique = 15 : this._currentContext.oblique = this.textStyle.obliqueAngle || 0));
12442
+ e.changes.fontFace && (this.changeFont(e.changes.fontFace.family), this.fontManager.getFontType(
12443
+ this._currentContext.fontFace.family
12444
+ ) === "mesh" ? (this._currentContext.italic = e.changes.fontFace.style === "Italic", this._currentContext.bold = (e.changes.fontFace.weight || 400) >= 700, this._currentContext.oblique = this.textStyle.obliqueAngle || 0) : (this._currentContext.italic = !1, this._currentContext.bold = !1, e.changes.fontFace.style === "Italic" ? this._currentContext.oblique = 15 : this._currentContext.oblique = this.textStyle.obliqueAngle || 0));
12403
12445
  break;
12404
12446
  case "c":
12405
12447
  case "C":
@@ -12479,7 +12521,9 @@ class Cl {
12479
12521
  this.startNewParagraph(r, n, a);
12480
12522
  else if (s.type === Be.WORD) {
12481
12523
  const i = s.data;
12482
- Array.isArray(i) ? i.forEach((o) => this.processWord(o, r, n)) : typeof i == "string" && i.length > 0 && this.processWord(i, r, n);
12524
+ Array.isArray(i) ? i.forEach(
12525
+ (o) => this.processWord(o, r, n)
12526
+ ) : typeof i == "string" && i.length > 0 && this.processWord(i, r, n);
12483
12527
  } else if (s.type === Be.SPACE)
12484
12528
  this.processBlank();
12485
12529
  else if (s.type === Be.PROPERTIES_CHANGED) {
@@ -12525,13 +12569,21 @@ class Cl {
12525
12569
  const m = [], b = [];
12526
12570
  this._hOffset = o, this._vOffset = u + h * 0.1;
12527
12571
  for (let x = 0; x < a.length; x++)
12528
- this.processChar(a[x], m, b);
12572
+ this.processChar(
12573
+ a[x],
12574
+ m,
12575
+ b
12576
+ );
12529
12577
  r.push(...m), n.push(...b), this._hOffset = o + c;
12530
12578
  } else if (!a && s) {
12531
12579
  const m = [], b = [];
12532
12580
  this._hOffset = o, this._vOffset = u - h * 0.6;
12533
12581
  for (let x = 0; x < s.length; x++)
12534
- this.processChar(s[x], m, b);
12582
+ this.processChar(
12583
+ s[x],
12584
+ m,
12585
+ b
12586
+ );
12535
12587
  r.push(...m), n.push(...b), this._hOffset = o + p;
12536
12588
  }
12537
12589
  this._currentContext.fontSizeScaleFactor = f, this.calcuateLineParams();
@@ -12539,12 +12591,20 @@ class Cl {
12539
12591
  const m = [], b = [];
12540
12592
  this._hOffset = o + v, this._vOffset = u + this.currentFontSize * 0.3;
12541
12593
  for (let S = 0; S < a.length; S++)
12542
- this.processChar(a[S], m, b);
12594
+ this.processChar(
12595
+ a[S],
12596
+ m,
12597
+ b
12598
+ );
12543
12599
  r.push(...m), n.push(...b);
12544
12600
  const x = [], T = [];
12545
12601
  this._hOffset = o + y, this._vOffset = u - this.currentFontSize * 0.6;
12546
12602
  for (let S = 0; S < s.length; S++)
12547
- this.processChar(s[S], x, T);
12603
+ this.processChar(
12604
+ s[S],
12605
+ x,
12606
+ T
12607
+ );
12548
12608
  if (r.push(...x), n.push(...T), i === "/" || i === "#") {
12549
12609
  const S = new L.BufferGeometry(), A = new Float32Array([
12550
12610
  o,
@@ -12554,11 +12614,17 @@ class Cl {
12554
12614
  u - this.currentFontSize * 0.8,
12555
12615
  0
12556
12616
  ]);
12557
- S.setAttribute("position", new L.BufferAttribute(A, 3)), S.setIndex(null), n.push(S);
12617
+ S.setAttribute(
12618
+ "position",
12619
+ new L.BufferAttribute(A, 3)
12620
+ ), S.setIndex(null), n.push(S);
12558
12621
  }
12559
12622
  this._hOffset = o + d;
12560
12623
  }
12561
- this._vOffset = u, this._currentContext.charTrackingFactor = { value: l, isRelative: !1 };
12624
+ this._vOffset = u, this._currentContext.charTrackingFactor = {
12625
+ value: l,
12626
+ isRelative: !1
12627
+ };
12562
12628
  }
12563
12629
  processBlank() {
12564
12630
  this._hOffset += this._currentContext.blankWidth;
@@ -12574,7 +12640,24 @@ class Cl {
12574
12640
  let i = this._currentContext.oblique;
12575
12641
  if (this._currentContext.italic && (i += 15), i) {
12576
12642
  const d = i * Math.PI / 180, v = new L.Matrix4();
12577
- v.set(1, Math.tan(d), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), s.applyMatrix4(v);
12643
+ v.set(
12644
+ 1,
12645
+ Math.tan(d),
12646
+ 0,
12647
+ 0,
12648
+ 0,
12649
+ 1,
12650
+ 0,
12651
+ 0,
12652
+ 0,
12653
+ 0,
12654
+ 1,
12655
+ 0,
12656
+ 0,
12657
+ 0,
12658
+ 0,
12659
+ 1
12660
+ ), s.applyMatrix4(v);
12578
12661
  }
12579
12662
  const o = this.fontManager.getFontType(this.currentFont);
12580
12663
  this._currentContext.bold && o === "mesh" && s.scale(1.06, 1.06, 1), this.hOffset > (this.maxLineWidth || 1 / 0) && this.startNewLine();
@@ -12586,7 +12669,14 @@ class Cl {
12586
12669
  d.setAttribute(
12587
12670
  "position",
12588
12671
  new L.BufferAttribute(
12589
- new Float32Array([u, v, p, u + h, v, p]),
12672
+ new Float32Array([
12673
+ u,
12674
+ v,
12675
+ p,
12676
+ u + h,
12677
+ v,
12678
+ p
12679
+ ]),
12590
12680
  3
12591
12681
  )
12592
12682
  ), d.setIndex(null), n.push(d);
@@ -12596,7 +12686,14 @@ class Cl {
12596
12686
  d.setAttribute(
12597
12687
  "position",
12598
12688
  new L.BufferAttribute(
12599
- new Float32Array([u, v, p, u + h, v, p]),
12689
+ new Float32Array([
12690
+ u,
12691
+ v,
12692
+ p,
12693
+ u + h,
12694
+ v,
12695
+ p
12696
+ ]),
12600
12697
  3
12601
12698
  )
12602
12699
  ), d.setIndex(null), n.push(d);
@@ -12606,7 +12703,14 @@ class Cl {
12606
12703
  d.setAttribute(
12607
12704
  "position",
12608
12705
  new L.BufferAttribute(
12609
- new Float32Array([u, v, p, u + h, v, p]),
12706
+ new Float32Array([
12707
+ u,
12708
+ v,
12709
+ p,
12710
+ u + h,
12711
+ v,
12712
+ p
12713
+ ]),
12610
12714
  3
12611
12715
  )
12612
12716
  ), d.setIndex(null), n.push(d);
@@ -12629,7 +12733,9 @@ class Cl {
12629
12733
  * Calcuate font size, line space, line height and other parameters.
12630
12734
  */
12631
12735
  calcuateLineParams(e) {
12632
- this._currentContext.fontScaleFactor = this.fontManager.getFontScaleFactor(this.currentFont);
12736
+ this._currentContext.fontScaleFactor = this.fontManager.getFontScaleFactor(
12737
+ this.currentFont
12738
+ );
12633
12739
  const r = e || this.defaultFontSize || this.textStyle.fixedTextHeight;
12634
12740
  this._currentContext.fontSize = r * this._currentContext.fontScaleFactor * this._currentContext.fontSizeScaleFactor;
12635
12741
  }
@@ -12639,8 +12745,16 @@ class Cl {
12639
12745
  * @returns Return the text shape of the specified character
12640
12746
  */
12641
12747
  getCharShape(e) {
12642
- let r = this.fontManager.getCharShape(e, this.currentFont, this.currentFontSize);
12643
- return this.textStyle.bigFont && !r && (r = this.fontManager.getCharShape(e, this.textStyle.bigFont, this.currentFontSize)), r || (r = this.fontManager.getCharShape(e, "", this.currentFontSize)), r || (r = this.fontManager.getNotFoundTextShape(this.currentFontSize)), this.currentFontSize > this._maxFontSize && (this._maxFontSize = this.currentFontSize), r;
12748
+ let r = this.fontManager.getCharShape(
12749
+ e,
12750
+ this.currentFont,
12751
+ this.currentFontSize
12752
+ );
12753
+ return this.textStyle.bigFont && !r && (r = this.fontManager.getCharShape(
12754
+ e,
12755
+ this.textStyle.bigFont,
12756
+ this.currentFontSize
12757
+ )), r || (r = this.fontManager.getCharShape(e, "", this.currentFontSize)), r || (r = this.fontManager.getNotFoundTextShape(this.currentFontSize)), this.currentFontSize > this._maxFontSize && (this._maxFontSize = this.currentFontSize), r;
12644
12758
  }
12645
12759
  startNewLine() {
12646
12760
  this._hOffset = 0, this.flowDirection == je.BOTTOM_TO_TOP ? this._vOffset += this.currentLineHeight : this._vOffset -= this.currentLineHeight, this._lineCount++, this.processAlignment(), this._currentLineObjects = [], this._lineCount == 2 ? this._totalHeight = this.currentMaxFontSize : this._totalHeight = this._totalHeight + this.currentLineHeight, this._maxFontSize = 0;
@@ -12662,7 +12776,9 @@ class Cl {
12662
12776
  const n = r.getSize(Tl);
12663
12777
  switch (this.currentHorizontalAlignment) {
12664
12778
  case se.LEFT:
12665
- e.forEach((a) => a.translate(this._currentLeftMargin - r.min.x, 0, 0));
12779
+ e.forEach(
12780
+ (a) => a.translate(this._currentLeftMargin - r.min.x, 0, 0)
12781
+ );
12666
12782
  break;
12667
12783
  case se.CENTER:
12668
12784
  e.forEach(
@@ -12675,7 +12791,11 @@ class Cl {
12675
12791
  break;
12676
12792
  case se.RIGHT:
12677
12793
  e.forEach(
12678
- (a) => a.translate(this._currentLeftMargin + this.maxLineWidth - n.x - r.min.x, 0, 0)
12794
+ (a) => a.translate(
12795
+ this._currentLeftMargin + this.maxLineWidth - n.x - r.min.x,
12796
+ 0,
12797
+ 0
12798
+ )
12679
12799
  );
12680
12800
  break;
12681
12801
  case se.DISTRIBUTED:
@@ -12684,7 +12804,9 @@ class Cl {
12684
12804
  for (let s = 1; s < e.length; s++)
12685
12805
  e[s].translate(a * s, 0, 0);
12686
12806
  }
12687
- e.forEach((a) => a.translate(this._currentLeftMargin - r.min.x, 0, 0));
12807
+ e.forEach(
12808
+ (a) => a.translate(this._currentLeftMargin - r.min.x, 0, 0)
12809
+ );
12688
12810
  break;
12689
12811
  }
12690
12812
  }
@@ -12758,7 +12880,10 @@ class El extends L.Object3D {
12758
12880
  * @param fontManager - The font manager instance
12759
12881
  * @param colorSettings - Color settings used to decided font color
12760
12882
  */
12761
- constructor(e, r, n, a, s = { byLayerColor: 16777215, byBlockColor: 16777215 }) {
12883
+ constructor(e, r, n, a, s = {
12884
+ byLayerColor: 16777215,
12885
+ byBlockColor: 16777215
12886
+ }) {
12762
12887
  super(), this._style = r, this._styleManager = n, this._fontManager = a, this._colorSettings = {
12763
12888
  byLayerColor: s.byLayerColor,
12764
12889
  byBlockColor: s.byBlockColor
@@ -12875,7 +13000,10 @@ class El extends L.Object3D {
12875
13000
  byLayerColor: this._colorSettings.byLayerColor,
12876
13001
  removeFontExtension: !0
12877
13002
  }, h = new tt();
12878
- h.fontFace.family = r.font, h.capHeight = { value: e.height || 1, isRelative: !0 }, h.widthFactor = { value: e.widthFactor ?? 1, isRelative: !0 }, h.align = s, h.paragraph.align = a;
13003
+ h.fontFace.family = r.font, h.capHeight = { value: e.height || 1, isRelative: !0 }, h.widthFactor = {
13004
+ value: e.widthFactor ?? 1,
13005
+ isRelative: !0
13006
+ }, h.align = s, h.paragraph.align = a;
12879
13007
  const f = new Cl(
12880
13008
  r,
12881
13009
  this.styleManager,
@@ -12972,7 +13100,9 @@ class bn {
12972
13100
  );
12973
13101
  const r = e.workerUrl ?? "./mtext-renderer-worker.js";
12974
13102
  for (let n = 0; n < this.poolSize; n++) {
12975
- const a = new Worker(new URL(r, import.meta.url), { type: "module" });
13103
+ const a = new Worker(new URL(r, import.meta.url), {
13104
+ type: "module"
13105
+ });
12976
13106
  this.attachWorkerHandlers(a, n), this.workers.push(a), this.inFlightPerWorker.push(0);
12977
13107
  }
12978
13108
  this.ensureInitialized();
@@ -12982,7 +13112,10 @@ class bn {
12982
13112
  if (i) {
12983
13113
  this.pendingRequests.delete(r);
12984
13114
  const { workerIndex: o } = i;
12985
- this.inFlightPerWorker[o] = Math.max(0, this.inFlightPerWorker[o] - 1), n ? i.resolve(a) : i.reject(new Error(s || "Unknown worker error"));
13115
+ this.inFlightPerWorker[o] = Math.max(
13116
+ 0,
13117
+ this.inFlightPerWorker[o] - 1
13118
+ ), n ? i.resolve(a) : i.reject(new Error(s || "Unknown worker error"));
12986
13119
  }
12987
13120
  }
12988
13121
  attachWorkerHandlers(e, r) {
@@ -13033,7 +13166,10 @@ class bn {
13033
13166
  reject: a,
13034
13167
  workerIndex: r
13035
13168
  }), this.inFlightPerWorker[r] = (this.inFlightPerWorker[r] ?? 0) + 1, e.postMessage({ type: "getAvailableFonts", id: s }), setTimeout(() => {
13036
- this.pendingRequests.get(s) && (this.pendingRequests.delete(s), this.inFlightPerWorker[r] = Math.max(0, this.inFlightPerWorker[r] - 1), a(new Error("Worker init timeout")));
13169
+ this.pendingRequests.get(s) && (this.pendingRequests.delete(s), this.inFlightPerWorker[r] = Math.max(
13170
+ 0,
13171
+ this.inFlightPerWorker[r] - 1
13172
+ ), a(new Error("Worker init timeout")));
13037
13173
  }, 3e4);
13038
13174
  })
13039
13175
  )
@@ -13043,7 +13179,10 @@ class bn {
13043
13179
  /**
13044
13180
  * Render MText in the worker and return serialized data
13045
13181
  */
13046
- async renderMText(e, r, n = { byLayerColor: 16777215, byBlockColor: 16777215 }) {
13182
+ async renderMText(e, r, n = {
13183
+ byLayerColor: 16777215,
13184
+ byBlockColor: 16777215
13185
+ }) {
13047
13186
  await this.ensureInitialized();
13048
13187
  const a = await this.sendMessage("render", {
13049
13188
  mtextContent: e,
@@ -13066,7 +13205,10 @@ class bn {
13066
13205
  reject: o,
13067
13206
  workerIndex: s
13068
13207
  }), this.inFlightPerWorker[s] = (this.inFlightPerWorker[s] ?? 0) + 1, a.postMessage({ type: "loadFonts", id: u, data: { fonts: e } }), setTimeout(() => {
13069
- this.pendingRequests.get(u) && (this.pendingRequests.delete(u), this.inFlightPerWorker[s] = Math.max(0, this.inFlightPerWorker[s] - 1), o(new Error("Worker request timeout")));
13208
+ this.pendingRequests.get(u) && (this.pendingRequests.delete(u), this.inFlightPerWorker[s] = Math.max(
13209
+ 0,
13210
+ this.inFlightPerWorker[s] - 1
13211
+ ), o(new Error("Worker request timeout")));
13070
13212
  }, 3e4);
13071
13213
  })
13072
13214
  )
@@ -13083,19 +13225,21 @@ class bn {
13083
13225
  if (this.workers.length === 0) return { fonts: [] };
13084
13226
  await this.ensureInitialized();
13085
13227
  const e = 0, r = this.workers[e];
13086
- return new Promise((n, a) => {
13087
- const s = `req_${++this.requestId}`;
13088
- this.pendingRequests.set(s, {
13089
- resolve: (i) => n(i),
13090
- reject: a,
13091
- workerIndex: e
13092
- }), this.inFlightPerWorker[e] = (this.inFlightPerWorker[e] ?? 0) + 1, r.postMessage({ type: "getAvailableFonts", id: s }), setTimeout(() => {
13093
- this.pendingRequests.get(s) && (this.pendingRequests.delete(s), this.inFlightPerWorker[e] = Math.max(
13094
- 0,
13095
- this.inFlightPerWorker[e] - 1
13096
- ), a(new Error("Worker request timeout")));
13097
- }, 3e4);
13098
- });
13228
+ return new Promise(
13229
+ (n, a) => {
13230
+ const s = `req_${++this.requestId}`;
13231
+ this.pendingRequests.set(s, {
13232
+ resolve: (i) => n(i),
13233
+ reject: a,
13234
+ workerIndex: e
13235
+ }), this.inFlightPerWorker[e] = (this.inFlightPerWorker[e] ?? 0) + 1, r.postMessage({ type: "getAvailableFonts", id: s }), setTimeout(() => {
13236
+ this.pendingRequests.get(s) && (this.pendingRequests.delete(s), this.inFlightPerWorker[e] = Math.max(
13237
+ 0,
13238
+ this.inFlightPerWorker[e] - 1
13239
+ ), a(new Error("Worker request timeout")));
13240
+ }, 3e4);
13241
+ }
13242
+ );
13099
13243
  }
13100
13244
  /**
13101
13245
  * Reconstruct MText object from JSON serialized data
@@ -13105,7 +13249,11 @@ class bn {
13105
13249
  return e.children.forEach((n) => {
13106
13250
  const a = new L.BufferGeometry();
13107
13251
  if (Object.keys(n.geometry.attributes).forEach((o) => {
13108
- const u = n.geometry.attributes[o], l = new Float32Array(u.arrayBuffer, u.byteOffset, u.length), h = new L.BufferAttribute(
13252
+ const u = n.geometry.attributes[o], l = new Float32Array(
13253
+ u.arrayBuffer,
13254
+ u.byteOffset,
13255
+ u.length
13256
+ ), h = new L.BufferAttribute(
13109
13257
  l,
13110
13258
  u.itemSize,
13111
13259
  u.normalized
@@ -13140,7 +13288,11 @@ class bn {
13140
13288
  linewidth: n.material.linewidth
13141
13289
  });
13142
13290
  let i;
13143
- n.type === "mesh" ? i = new L.Mesh(a, s) : i = new L.Line(a, s), a.boundingBox || a.computeBoundingBox(), a.boundingSphere || a.computeBoundingSphere(), i.position.set(n.position.x, n.position.y, n.position.z), i.quaternion.set(
13291
+ n.type === "mesh" ? i = new L.Mesh(a, s) : i = new L.Line(a, s), a.boundingBox || a.computeBoundingBox(), a.boundingSphere || a.computeBoundingSphere(), i.position.set(
13292
+ n.position.x,
13293
+ n.position.y,
13294
+ n.position.z
13295
+ ), i.quaternion.set(
13144
13296
  n.rotation.x,
13145
13297
  n.rotation.y,
13146
13298
  n.rotation.z,
@@ -13173,12 +13325,15 @@ class bn {
13173
13325
  }
13174
13326
  class Ul {
13175
13327
  constructor() {
13176
- this.fontManager = ke.instance, this.styleManager = new Ol(), this.fontLoader = new ml(), this.fontManager.defaultFont = "simkai";
13328
+ this.fontManager = ke.instance, this.styleManager = new Ol(), this.fontManager.defaultFont = "simkai";
13177
13329
  }
13178
13330
  /**
13179
13331
  * Render MText directly in the main thread
13180
13332
  */
13181
- async renderMText(e, r, n = { byLayerColor: 16777215, byBlockColor: 16777215 }) {
13333
+ async renderMText(e, r, n = {
13334
+ byLayerColor: 16777215,
13335
+ byBlockColor: 16777215
13336
+ }) {
13182
13337
  const a = new El(
13183
13338
  e,
13184
13339
  r,
@@ -13192,13 +13347,13 @@ class Ul {
13192
13347
  * Load fonts in the main thread
13193
13348
  */
13194
13349
  async loadFonts(e) {
13195
- return await this.fontLoader.load(e), { loaded: e };
13350
+ return await this.fontManager.loadFontsByNames(e), { loaded: e };
13196
13351
  }
13197
13352
  /**
13198
13353
  * Get available fonts from the main thread
13199
13354
  */
13200
13355
  async getAvailableFonts() {
13201
- return { fonts: await this.fontLoader.getAvaiableFonts() };
13356
+ return { fonts: await this.fontManager.getAvaiableFonts() };
13202
13357
  }
13203
13358
  destroy() {
13204
13359
  }
@@ -13224,7 +13379,10 @@ class Pl {
13224
13379
  /**
13225
13380
  * Render MText using the current mode
13226
13381
  */
13227
- async renderMText(e, r, n = { byLayerColor: 16777215, byBlockColor: 16777215 }) {
13382
+ async renderMText(e, r, n = {
13383
+ byLayerColor: 16777215,
13384
+ byBlockColor: 16777215
13385
+ }) {
13228
13386
  return this.adapter.renderMText(e, r, n);
13229
13387
  }
13230
13388
  /**