@mlightcad/mtext-renderer 0.10.12 → 0.10.13

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
@@ -22631,6 +22631,7 @@ function er(t) {
22631
22631
  const e = t.color, r = e.aci;
22632
22632
  return r === 0 ? $t(t.byBlockColor) : r === 256 ? $t(t.byLayerColor) : r != null ? Za(r) : e.rgbValue !== null ? $t(e.rgbValue) : $t(t.byLayerColor);
22633
22633
  }
22634
+ const ql = 1.666666, Zt = 0.3;
22634
22635
  var Z;
22635
22636
  (function(t) {
22636
22637
  t[t.NONE = 0] = "NONE", t[t.WORD = 1] = "WORD", t[t.STACK = 2] = "STACK", t[t.SPACE = 3] = "SPACE", t[t.NBSP = 4] = "NBSP", t[t.TABULATOR = 5] = "TABULATOR", t[t.NEW_PARAGRAPH = 6] = "NEW_PARAGRAPH", t[t.NEW_COLUMN = 7] = "NEW_COLUMN", t[t.WRAP_AT_DIMLINE = 8] = "WRAP_AT_DIMLINE", t[t.PROPERTIES_CHANGED = 9] = "PROPERTIES_CHANGED";
@@ -22647,19 +22648,19 @@ var Xe;
22647
22648
  (function(t) {
22648
22649
  t[t.NONE = 0] = "NONE", t[t.UNDERLINE = 1] = "UNDERLINE", t[t.OVERLINE = 2] = "OVERLINE", t[t.STRIKE_THROUGH = 4] = "STRIKE_THROUGH";
22649
22650
  })(Xe || (Xe = {}));
22650
- const ql = {
22651
+ const Xl = {
22651
22652
  c: "Ø",
22652
22653
  d: "°",
22653
22654
  p: "±",
22654
22655
  "%": "%"
22655
- }, Xl = {
22656
+ }, Yl = {
22656
22657
  l: ee.LEFT,
22657
22658
  r: ee.RIGHT,
22658
22659
  c: ee.CENTER,
22659
22660
  j: ee.JUSTIFIED,
22660
22661
  d: ee.DISTRIBUTED
22661
22662
  };
22662
- function Yl(t) {
22663
+ function jl(t) {
22663
22664
  const [e, r, n] = t;
22664
22665
  return e << 16 | r << 8 | n;
22665
22666
  }
@@ -22673,10 +22674,10 @@ function Ha(t) {
22673
22674
  function Ki(t) {
22674
22675
  return Math.max(0, Math.min(16777215, Math.round(t)));
22675
22676
  }
22676
- function jl(t) {
22677
+ function $l(t) {
22677
22678
  return t === null ? null : `#${Ki(t).toString(16).padStart(6, "0")}`;
22678
22679
  }
22679
- function $l(t) {
22680
+ function Zl(t) {
22680
22681
  if (!t)
22681
22682
  return null;
22682
22683
  const e = t.trim().toLowerCase();
@@ -22694,13 +22695,13 @@ function $l(t) {
22694
22695
  }
22695
22696
  return null;
22696
22697
  }
22697
- function Zl(t) {
22698
+ function Kl(t) {
22698
22699
  if (!t)
22699
22700
  return null;
22700
22701
  const e = t.trim().toLowerCase();
22701
22702
  if (e === "transparent")
22702
22703
  return null;
22703
- const r = $l(e);
22704
+ const r = Zl(e);
22704
22705
  if (r)
22705
22706
  return Ki(Number.parseInt(r.slice(1), 16));
22706
22707
  const n = e.match(/^rgba?\((.*)\)$/);
@@ -22717,7 +22718,7 @@ function Zl(t) {
22717
22718
  const h = Number.parseFloat(u);
22718
22719
  return Ha(h);
22719
22720
  }, s = i(a[0]), o = i(a[1]), c = i(a[2]);
22720
- return Yl([s, o, c]);
22721
+ return jl([s, o, c]);
22721
22722
  }
22722
22723
  function uf(t) {
22723
22724
  return t.replace(/\r\n|\r|\n/g, "\\P");
@@ -22725,14 +22726,14 @@ function uf(t) {
22725
22726
  function hf(t) {
22726
22727
  return t.replace(/\\P/g, "").replace(/\\~/g, "").includes("\\");
22727
22728
  }
22728
- function Kl(t, e = !1) {
22729
+ function Ql(t, e = !1) {
22729
22730
  const r = /* @__PURE__ */ new Set(), n = /\\[fF](.*?)[;|]/g;
22730
22731
  return [...t.matchAll(n)].forEach((a) => {
22731
22732
  let i = a[1].toLowerCase();
22732
22733
  e && (i = i.replace(/\.(ttf|otf|woff|shx)$/, "")), r.add(i);
22733
22734
  }), r;
22734
22735
  }
22735
- class Ql {
22736
+ class Jl {
22736
22737
  /**
22737
22738
  * Creates a new ContextStack with an initial context.
22738
22739
  * @param initial The initial MTextContext to use as the base of the stack.
@@ -22785,7 +22786,7 @@ class Ql {
22785
22786
  this.stack[this.stack.length - 1] = e;
22786
22787
  }
22787
22788
  }
22788
- class Jl {
22789
+ class ef {
22789
22790
  /**
22790
22791
  * Creates a new MTextParser instance
22791
22792
  * @param content - The MText content to parse
@@ -22795,7 +22796,7 @@ class Jl {
22795
22796
  constructor(e, r, n = {}) {
22796
22797
  this.continueStroke = !1, this.inStackContext = !1, this.scanner = new Pr(e);
22797
22798
  const a = r ?? new Dt();
22798
- this.ctxStack = new Ql(a), this.yieldPropertyCommands = n.yieldPropertyCommands ?? !1, this.resetParagraphParameters = n.resetParagraphParameters ?? !1, this.mifDecoder = n.mifDecoder ?? this.decodeMultiByteChar.bind(this), this.mifCodeLength = n.mifCodeLength ?? "auto";
22799
+ this.ctxStack = new Jl(a), this.yieldPropertyCommands = n.yieldPropertyCommands ?? !1, this.resetParagraphParameters = n.resetParagraphParameters ?? !1, this.mifDecoder = n.mifDecoder ?? this.decodeMultiByteChar.bind(this), this.mifCodeLength = n.mifCodeLength ?? "auto";
22799
22800
  }
22800
22801
  /**
22801
22802
  * Decode multi-byte character from hex code
@@ -23179,7 +23180,7 @@ class Jl {
23179
23180
  break;
23180
23181
  case "q": {
23181
23182
  const h = r.get();
23182
- for (s = Xl[h] || ee.DEFAULT; r.peek() === ","; )
23183
+ for (s = Yl[h] || ee.DEFAULT; r.peek() === ","; )
23183
23184
  r.consume(1);
23184
23185
  break;
23185
23186
  }
@@ -23314,7 +23315,7 @@ class Jl {
23314
23315
  continue;
23315
23316
  }
23316
23317
  if (c === "%" && this.scanner.peek(1) === "%") {
23317
- const h = this.scanner.peek(2).toLowerCase(), p = ql[h];
23318
+ const h = this.scanner.peek(2).toLowerCase(), p = Xl[h];
23318
23319
  if (p) {
23319
23320
  this.scanner.consume(3), s += p;
23320
23321
  continue;
@@ -23583,14 +23584,14 @@ class vt {
23583
23584
  * Returns null if the color is ACI-based and has no RGB value.
23584
23585
  */
23585
23586
  toCssColor() {
23586
- return this._rgbValue !== null ? jl(this._rgbValue) : null;
23587
+ return this._rgbValue !== null ? $l(this._rgbValue) : null;
23587
23588
  }
23588
23589
  /**
23589
23590
  * Create an MTextColor from a CSS color string.
23590
23591
  * Supports #rgb, #rrggbb, rgb(...), rgba(...). Returns null if invalid or transparent.
23591
23592
  */
23592
23593
  static fromCssColor(e) {
23593
- const r = Zl(e);
23594
+ const r = Kl(e);
23594
23595
  if (r === null)
23595
23596
  return null;
23596
23597
  const n = new vt();
@@ -23799,7 +23800,7 @@ const tr = "", ct = () => ({
23799
23800
  layer: "0",
23800
23801
  color: new vt()
23801
23802
  });
23802
- function ef(t) {
23803
+ function tf(t) {
23803
23804
  if (!(!t || [
23804
23805
  t.min.x,
23805
23806
  t.min.y,
@@ -23813,7 +23814,7 @@ function ef(t) {
23813
23814
  function nn(t, e, r) {
23814
23815
  const n = [];
23815
23816
  if (t.filter((l) => l.char !== tr).forEach((l) => {
23816
- const g = ef(
23817
+ const g = tf(
23817
23818
  new M.Box3().copy(l.box).applyMatrix4(e)
23818
23819
  );
23819
23820
  g && n.push({
@@ -23846,7 +23847,7 @@ function nn(t, e, r) {
23846
23847
  ...u
23847
23848
  ];
23848
23849
  }
23849
- const tf = /* @__PURE__ */ new M.Vector3(), rf = 1.666666, Zt = 0.3;
23850
+ const rf = /* @__PURE__ */ new M.Vector3();
23850
23851
  class wn extends Dt {
23851
23852
  /**
23852
23853
  * Creates a new RenderContext instance with optional initial values.
@@ -23992,7 +23993,7 @@ class nf {
23992
23993
  * The height of current line of texts
23993
23994
  */
23994
23995
  get currentLineHeight() {
23995
- const e = this.defaultLineSpaceFactor * this.currentFontSize * rf, r = this.currentMaxFontSize > 0 ? this.currentMaxFontSize : this.currentFontSize;
23996
+ const e = this.defaultLineSpaceFactor * this.currentFontSize * ql, r = this.currentMaxFontSize > 0 ? this.currentMaxFontSize : this.currentFontSize;
23996
23997
  return e + r;
23997
23998
  }
23998
23999
  /**
@@ -24716,7 +24717,7 @@ class nf {
24716
24717
  if (e.forEach((s, o) => {
24717
24718
  s.geometry.boundingBox || s.geometry.computeBoundingBox(), o === 0 ? r = s.geometry.boundingBox : r.union(s.geometry.boundingBox);
24718
24719
  }), !r) return;
24719
- const n = r, a = n.getSize(tf), i = (s, o) => {
24720
+ const n = r, a = n.getSize(rf), i = (s, o) => {
24720
24721
  var u, h;
24721
24722
  const c = (h = (u = s.userData) == null ? void 0 : u.layout) == null ? void 0 : h.chars;
24722
24723
  if (c && c.length > 0) {
@@ -24834,7 +24835,7 @@ class cr extends M.Object3D {
24834
24835
  * ```
24835
24836
  */
24836
24837
  static getFonts(e, r = !1) {
24837
- return Kl(e, r);
24838
+ return Ql(e, r);
24838
24839
  }
24839
24840
  /**
24840
24841
  * Creates a new instance of MText.
@@ -25083,7 +25084,7 @@ class cr extends M.Object3D {
25083
25084
  this.styleManager,
25084
25085
  this.fontManager,
25085
25086
  p
25086
- ), v = new Jl(e.text, l, {
25087
+ ), v = new ef(e.text, l, {
25087
25088
  resetParagraphParameters: !0,
25088
25089
  yieldPropertyCommands: !0
25089
25090
  }).parse();
@@ -25752,6 +25753,7 @@ export {
25752
25753
  An as EventManager,
25753
25754
  $e as FontFactory,
25754
25755
  Ie as FontManager,
25756
+ ql as LINE_SPACING_SCALE_FACTOR,
25755
25757
  cr as MText,
25756
25758
  X as MTextAttachmentPoint,
25757
25759
  vt as MTextColor,
@@ -25759,11 +25761,12 @@ export {
25759
25761
  Ye as MTextFlowDirection,
25760
25762
  Ze as MTextLineAlignment,
25761
25763
  ee as MTextParagraphAlignment,
25762
- Jl as MTextParser,
25764
+ ef as MTextParser,
25763
25765
  Xe as MTextStroke,
25764
25766
  Nr as MTextToken,
25765
25767
  sf as MainThreadRenderer,
25766
25768
  tr as STACK_DIVIDER_CHAR,
25769
+ Zt as STACK_VERTICAL_SHIFT_FACTOR,
25767
25770
  il as ShxParserFont,
25768
25771
  Pr as TextScanner,
25769
25772
  Z as TokenType,
@@ -25772,9 +25775,9 @@ export {
25772
25775
  ct as createDefaultColorSettings,
25773
25776
  uf as escapeDxfLineEndings,
25774
25777
  Za as getColorByIndex,
25775
- Kl as getFonts,
25778
+ Ql as getFonts,
25776
25779
  hf as hasInlineFormattingCodes,
25777
25780
  cf as int2rgb,
25778
25781
  er as resolveMTextColor,
25779
- Yl as rgb2int
25782
+ jl as rgb2int
25780
25783
  };