modern-text 1.4.3 → 1.5.0

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.cjs CHANGED
@@ -420,7 +420,7 @@ function createSVGParser(loader) {
420
420
  function parse(svg) {
421
421
  let result = parsed.get(svg);
422
422
  if (!result) {
423
- const dom = modernPath2d.svgToDOM(
423
+ const dom = modernPath2d.svgToDom(
424
424
  loader.needsLoad(svg) ? loader.loaded.get(svg) ?? svg : svg
425
425
  );
426
426
  const pathSet = modernPath2d.svgToPath2DSet(dom);
@@ -1816,6 +1816,9 @@ class Text extends EventEmitter {
1816
1816
  this.emit("render", { text: this, view, pixelRatio });
1817
1817
  options.onContext?.(ctx);
1818
1818
  }
1819
+ toString() {
1820
+ return this.content.flatMap((p) => p.fragments.map((f) => f.content)).join("");
1821
+ }
1819
1822
  }
1820
1823
 
1821
1824
  function measureText(options, load) {
package/dist/index.d.cts CHANGED
@@ -105,10 +105,10 @@ interface TextPlugin {
105
105
  load?: (text: Text$1) => Promise<void>;
106
106
  }
107
107
  interface TextOptions {
108
+ debug?: boolean;
108
109
  style?: Partial<NormalizedStyle>;
109
110
  content?: TextContent;
110
111
  effects?: Partial<NormalizedStyle>[];
111
- debug?: boolean;
112
112
  measureDOM?: HTMLElement;
113
113
  fonts?: Fonts;
114
114
  plugins?: TextPlugin[];
@@ -262,6 +262,7 @@ declare class Text$1 extends EventEmitter<TextEventMap> {
262
262
  requestUpdate(): this;
263
263
  update(dom?: HTMLElement | undefined): this;
264
264
  render(options: TextRenderOptions): void;
265
+ toString(): string;
265
266
  }
266
267
 
267
268
  declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text$1): void;
package/dist/index.d.mts CHANGED
@@ -105,10 +105,10 @@ interface TextPlugin {
105
105
  load?: (text: Text$1) => Promise<void>;
106
106
  }
107
107
  interface TextOptions {
108
+ debug?: boolean;
108
109
  style?: Partial<NormalizedStyle>;
109
110
  content?: TextContent;
110
111
  effects?: Partial<NormalizedStyle>[];
111
- debug?: boolean;
112
112
  measureDOM?: HTMLElement;
113
113
  fonts?: Fonts;
114
114
  plugins?: TextPlugin[];
@@ -262,6 +262,7 @@ declare class Text$1 extends EventEmitter<TextEventMap> {
262
262
  requestUpdate(): this;
263
263
  update(dom?: HTMLElement | undefined): this;
264
264
  render(options: TextRenderOptions): void;
265
+ toString(): string;
265
266
  }
266
267
 
267
268
  declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text$1): void;
package/dist/index.d.ts CHANGED
@@ -105,10 +105,10 @@ interface TextPlugin {
105
105
  load?: (text: Text$1) => Promise<void>;
106
106
  }
107
107
  interface TextOptions {
108
+ debug?: boolean;
108
109
  style?: Partial<NormalizedStyle>;
109
110
  content?: TextContent;
110
111
  effects?: Partial<NormalizedStyle>[];
111
- debug?: boolean;
112
112
  measureDOM?: HTMLElement;
113
113
  fonts?: Fonts;
114
114
  plugins?: TextPlugin[];
@@ -262,6 +262,7 @@ declare class Text$1 extends EventEmitter<TextEventMap> {
262
262
  requestUpdate(): this;
263
263
  update(dom?: HTMLElement | undefined): this;
264
264
  render(options: TextRenderOptions): void;
265
+ toString(): string;
265
266
  }
266
267
 
267
268
  declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text$1): void;