modern-text 1.2.0 → 1.2.2

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.mjs CHANGED
@@ -179,13 +179,13 @@ class Character {
179
179
  get fontHeight() {
180
180
  return this.fontSize * this.computedStyle.lineHeight;
181
181
  }
182
- _getFontSfnt(fonts$1) {
182
+ _getFontSFNT(fonts$1) {
183
183
  const fontFamily = this.computedStyle.fontFamily;
184
184
  const _fonts = fonts$1 ?? fonts;
185
185
  const font = fontFamily ? _fonts.get(fontFamily) : _fonts.fallbackFont;
186
- return font?.getSfnt();
186
+ return font?.getSFNT();
187
187
  }
188
- updateGlyph(sfnt = this._getFontSfnt()) {
188
+ updateGlyph(sfnt = this._getFontSFNT()) {
189
189
  if (!sfnt) {
190
190
  return this;
191
191
  }
@@ -222,7 +222,7 @@ class Character {
222
222
  return this;
223
223
  }
224
224
  update(fonts) {
225
- const sfnt = this._getFontSfnt(fonts);
225
+ const sfnt = this._getFontSFNT(fonts);
226
226
  if (!sfnt) {
227
227
  return this;
228
228
  }
@@ -251,7 +251,7 @@ class Character {
251
251
  if (Math.abs(advanceWidth - advanceHeight) > 0.1) {
252
252
  y -= (ascender - typoAscender) / (ascender + Math.abs(descender)) * advanceHeight;
253
253
  }
254
- glyphIndex = void 0;
254
+ glyphIndex = undefined;
255
255
  }
256
256
  if (isVertical && !set1.has(content) && (content.codePointAt(0) <= 256 || set2.has(content))) {
257
257
  path.addCommands(
@@ -272,12 +272,12 @@ class Character {
272
272
  isVertical ? {
273
273
  x: point.x,
274
274
  y: top - (advanceHeight - advanceWidth) / 2 + baseline
275
- } : void 0
275
+ } : undefined
276
276
  );
277
277
  }
278
278
  path.rotate(90, point);
279
279
  } else {
280
- if (glyphIndex !== void 0) {
280
+ if (glyphIndex !== undefined) {
281
281
  path.addCommands(
282
282
  sfnt.glyphs.get(glyphIndex).getPathCommands(x, y, style.fontSize)
283
283
  );
@@ -287,7 +287,7 @@ class Character {
287
287
  isVertical ? {
288
288
  x: x + advanceWidth / 2,
289
289
  y: top + typoAscender / (ascender + Math.abs(descender)) * advanceHeight
290
- } : void 0
290
+ } : undefined
291
291
  );
292
292
  }
293
293
  } else {
@@ -295,7 +295,7 @@ class Character {
295
295
  if (needsItalic) {
296
296
  this._italic(
297
297
  path,
298
- isVertical ? { x: x + advanceHeight / 2, y } : void 0
298
+ isVertical ? { x: x + advanceHeight / 2, y } : undefined
299
299
  );
300
300
  }
301
301
  }
@@ -323,13 +323,13 @@ class Character {
323
323
  if (this.path.curves[0]?.curves.length) {
324
324
  return this.path.getMinMax(min, max, withStyle);
325
325
  } else {
326
- return void 0;
326
+ return undefined;
327
327
  }
328
328
  }
329
329
  getGlyphBoundingBox(withStyle) {
330
- const minMax = this.getGlyphMinMax(void 0, void 0, withStyle);
330
+ const minMax = this.getGlyphMinMax(undefined, undefined, withStyle);
331
331
  if (!minMax) {
332
- return void 0;
332
+ return undefined;
333
333
  }
334
334
  const { min, max } = minMax;
335
335
  return new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
@@ -443,7 +443,7 @@ function filterEmpty(val) {
443
443
  return val;
444
444
  const res = {};
445
445
  for (const key in val) {
446
- if (val[key] !== "" && val[key] !== void 0) {
446
+ if (val[key] !== "" && val[key] !== undefined) {
447
447
  res[key] = val[key];
448
448
  }
449
449
  }
@@ -587,7 +587,7 @@ class Measurer {
587
587
  const isFlex = Boolean(style.justifyContent || style.alignItems);
588
588
  Object.assign(dom.style, {
589
589
  boxSizing: "border-box",
590
- display: isFlex ? "inline-flex" : void 0,
590
+ display: isFlex ? "inline-flex" : undefined,
591
591
  width: "max-content",
592
592
  height: "max-content",
593
593
  whiteSpace: "pre-wrap",
@@ -602,8 +602,8 @@ class Measurer {
602
602
  listStyleType: "inherit",
603
603
  padding: "0",
604
604
  margin: "0",
605
- width: isFlex && isHorizontal ? "100%" : void 0,
606
- height: isFlex && !isHorizontal ? "100%" : void 0
605
+ width: isFlex && isHorizontal ? "100%" : undefined,
606
+ height: isFlex && !isHorizontal ? "100%" : undefined
607
607
  });
608
608
  paragraphs.forEach((paragraph) => {
609
609
  const li = document.createElement("li");
@@ -656,7 +656,7 @@ class Measurer {
656
656
  width: rect.width
657
657
  };
658
658
  }
659
- return void 0;
659
+ return undefined;
660
660
  }).filter(Boolean);
661
661
  }
662
662
  measureDom(dom) {
@@ -1274,7 +1274,7 @@ function render() {
1274
1274
  boxes.push(aabb);
1275
1275
  });
1276
1276
  });
1277
- return boxes.length ? BoundingBox.from(...boxes) : void 0;
1277
+ return boxes.length ? BoundingBox.from(...boxes) : undefined;
1278
1278
  },
1279
1279
  render: (ctx, text) => {
1280
1280
  const { paragraphs, glyphBox, effects, style } = text;
@@ -1396,7 +1396,7 @@ function textDecoration() {
1396
1396
  }
1397
1397
  prevStyle = style;
1398
1398
  } else {
1399
- prevStyle = void 0;
1399
+ prevStyle = undefined;
1400
1400
  }
1401
1401
  });
1402
1402
  groups.forEach((group2) => {
@@ -1562,7 +1562,7 @@ class Text extends EventEmitter {
1562
1562
  paragraph.addFragment(f);
1563
1563
  } else {
1564
1564
  const { content: content2, ...fStyle } = f;
1565
- if (content2 !== void 0) {
1565
+ if (content2 !== undefined) {
1566
1566
  paragraph.addFragment(content2, fStyle);
1567
1567
  }
1568
1568
  }
@@ -1573,14 +1573,14 @@ class Text extends EventEmitter {
1573
1573
  const paragraph = new Paragraph(pStyle, style);
1574
1574
  fragments.forEach((f) => {
1575
1575
  const { content: content2, ...fStyle } = f;
1576
- if (content2 !== void 0) {
1576
+ if (content2 !== undefined) {
1577
1577
  paragraph.addFragment(content2, fStyle);
1578
1578
  }
1579
1579
  });
1580
1580
  paragraphs.push(paragraph);
1581
1581
  } else if ("content" in p) {
1582
1582
  const { content: pData, ...pStyle } = p;
1583
- if (pData !== void 0) {
1583
+ if (pData !== undefined) {
1584
1584
  const paragraph = new Paragraph(pStyle, style);
1585
1585
  paragraph.addFragment(pData);
1586
1586
  paragraphs.push(paragraph);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-text",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.2.2",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Measure and render text in a way that describes the DOM.",
7
7
  "author": "wxm",
@@ -57,21 +57,21 @@
57
57
  "prepare": "simple-git-hooks"
58
58
  },
59
59
  "dependencies": {
60
- "modern-font": "^0.3.5",
61
- "modern-idoc": "^0.1.4",
62
- "modern-path2d": "^1.2.2"
60
+ "modern-font": "^0.4.0",
61
+ "modern-idoc": "^0.1.5",
62
+ "modern-path2d": "^1.2.6"
63
63
  },
64
64
  "devDependencies": {
65
- "@antfu/eslint-config": "^3.12.1",
66
- "@types/node": "^22.10.3",
67
- "bumpp": "^9.9.2",
65
+ "@antfu/eslint-config": "^3.12.2",
66
+ "@types/node": "^22.10.5",
67
+ "bumpp": "^9.9.3",
68
68
  "conventional-changelog-cli": "^5.0.0",
69
69
  "eslint": "^9.17.0",
70
70
  "lint-staged": "^15.3.0",
71
71
  "simple-git-hooks": "^2.11.1",
72
- "typescript": "^5.7.2",
72
+ "typescript": "^5.7.3",
73
73
  "unbuild": "^3.2.0",
74
- "vite": "^6.0.6",
74
+ "vite": "^6.0.7",
75
75
  "vitest": "^2.1.8"
76
76
  },
77
77
  "simple-git-hooks": {