modern-text 2.0.3 → 2.0.5

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
@@ -1,5 +1,5 @@
1
- import { T as Text } from './shared/modern-text.BZDfPcWk.mjs';
2
- export { C as Canvas2DRenderer, a as Character, D as DomMeasurer, F as FontMeasurer, b as Fragment, P as Paragraph, c as backgroundPlugin, d as createSvgLoader, e as createSvgParser, g as getEffectTransform2D, f as getHighlightStyle, h as highlightPlugin, i as isEqualObject, j as isEqualValue, l as listStylePlugin, o as outlinePlugin, p as parseColormap, k as parseTransformOrigin, m as parseValueNumber, r as renderPlugin, t as textDecorationPlugin, n as textDefaultStyle } from './shared/modern-text.BZDfPcWk.mjs';
1
+ import { T as Text } from './shared/modern-text.Cvo-gyIv.mjs';
2
+ export { C as Canvas2DRenderer, a as Character, D as DomMeasurer, F as FontMeasurer, b as Fragment, P as Paragraph, c as backgroundPlugin, d as createSvgLoader, e as createSvgParser, g as getEffectTransform2D, f as getHighlightStyle, h as highlightPlugin, i as isEqualObject, j as isEqualValue, l as listStylePlugin, o as outlinePlugin, p as parseColormap, k as parseTransformOrigin, m as parseValueNumber, r as renderPlugin, t as textDecorationPlugin, n as textDefaultStyle } from './shared/modern-text.Cvo-gyIv.mjs';
3
3
  export { d as defineDeformation, a as definePlugin, b as deformationPlugin, g as getDeformationNames, r as removeDeformation } from './shared/modern-text.JF1ny7A-.mjs';
4
4
  export { C as CircleCurve, E as EllipseCurve, H as HeartCurve, P as PolygonCurve, R as RectangularCurve } from './shared/modern-text.fT17R5HY.mjs';
5
5
  import 'modern-font';
@@ -199,6 +199,9 @@ class Canvas2DRenderer {
199
199
  case "linear-gradient": {
200
200
  const { left, top, width: w, height: h } = box;
201
201
  const { angle = 0, stops } = source;
202
+ if (![left, top, w, h, angle].every(Number.isFinite)) {
203
+ return stops?.find((s) => s?.color)?.color ?? "transparent";
204
+ }
202
205
  const cx = left + w / 2;
203
206
  const cy = top + h / 2;
204
207
  const rad = (angle + 90) * Math.PI / 180;
@@ -210,7 +213,13 @@ class Canvas2DRenderer {
210
213
  const x1 = cx + dx * (l / 2);
211
214
  const y1 = cy + dy * (l / 2);
212
215
  const g = this.context.createLinearGradient(x0, y0, x1, y1);
213
- for (const s of stops) g.addColorStop(s.offset, s.color);
216
+ for (const s of stops) {
217
+ const offset = Number.isFinite(s.offset) ? Math.min(1, Math.max(0, s.offset)) : 0;
218
+ try {
219
+ g.addColorStop(offset, s.color);
220
+ } catch {
221
+ }
222
+ }
214
223
  return g;
215
224
  }
216
225
  }
@@ -197,6 +197,9 @@ class Canvas2DRenderer {
197
197
  case "linear-gradient": {
198
198
  const { left, top, width: w, height: h } = box;
199
199
  const { angle = 0, stops } = source;
200
+ if (![left, top, w, h, angle].every(Number.isFinite)) {
201
+ return stops?.find((s) => s?.color)?.color ?? "transparent";
202
+ }
200
203
  const cx = left + w / 2;
201
204
  const cy = top + h / 2;
202
205
  const rad = (angle + 90) * Math.PI / 180;
@@ -208,7 +211,13 @@ class Canvas2DRenderer {
208
211
  const x1 = cx + dx * (l / 2);
209
212
  const y1 = cy + dy * (l / 2);
210
213
  const g = this.context.createLinearGradient(x0, y0, x1, y1);
211
- for (const s of stops) g.addColorStop(s.offset, s.color);
214
+ for (const s of stops) {
215
+ const offset = Number.isFinite(s.offset) ? Math.min(1, Math.max(0, s.offset)) : 0;
216
+ try {
217
+ g.addColorStop(offset, s.color);
218
+ } catch {
219
+ }
220
+ }
212
221
  return g;
213
222
  }
214
223
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  const diff = require('diff');
4
4
  const modernIdoc = require('modern-idoc');
5
- const Text = require('../shared/modern-text.BZmgmU_p.cjs');
5
+ const Text = require('../shared/modern-text.BgJlrIQB.cjs');
6
6
  require('modern-font');
7
7
  require('modern-path2d');
8
8
  require('../shared/modern-text.B2xfrqDc.cjs');
@@ -1,6 +1,6 @@
1
1
  import { diffChars } from 'diff';
2
2
  import { isCRLF, textContentToString, normalizeCRLF, normalizeTextContent, property } from 'modern-idoc';
3
- import { T as Text } from '../shared/modern-text.BZDfPcWk.mjs';
3
+ import { T as Text } from '../shared/modern-text.Cvo-gyIv.mjs';
4
4
  import 'modern-font';
5
5
  import 'modern-path2d';
6
6
  import '../shared/modern-text.JF1ny7A-.mjs';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-text",
3
3
  "type": "module",
4
- "version": "2.0.3",
4
+ "version": "2.0.5",
5
5
  "packageManager": "pnpm@10.18.1",
6
6
  "description": "Measure and render text in a way that describes the DOM.",
7
7
  "author": "wxm",
@@ -61,7 +61,7 @@
61
61
  "dependencies": {
62
62
  "diff": "^9.0.0",
63
63
  "modern-font": "^0.6.0",
64
- "modern-idoc": "^0.11.5",
64
+ "modern-idoc": "^0.11.9",
65
65
  "modern-path2d": "^1.7.0"
66
66
  },
67
67
  "devDependencies": {