modern-text 1.9.2 → 1.10.1

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
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const Text = require('./shared/modern-text.BmTeQ51D.cjs');
3
+ const Text = require('./shared/modern-text.CwzFN2LS.cjs');
4
4
  require('modern-idoc');
5
5
  require('modern-path2d');
6
6
  require('modern-font');
@@ -25,16 +25,16 @@ function renderText(options, load) {
25
25
  return text.render(options);
26
26
  }
27
27
 
28
+ exports.Canvas2DRenderer = Text.Canvas2DRenderer;
28
29
  exports.Character = Text.Character;
29
30
  exports.Fragment = Text.Fragment;
30
31
  exports.Measurer = Text.Measurer;
31
32
  exports.Paragraph = Text.Paragraph;
32
33
  exports.Text = Text.Text;
33
34
  exports.backgroundPlugin = Text.backgroundPlugin;
34
- exports.createSVGLoader = Text.createSVGLoader;
35
- exports.createSVGParser = Text.createSVGParser;
35
+ exports.createSvgLoader = Text.createSvgLoader;
36
+ exports.createSvgParser = Text.createSvgParser;
36
37
  exports.definePlugin = Text.definePlugin;
37
- exports.drawPath = Text.drawPath;
38
38
  exports.filterEmpty = Text.filterEmpty;
39
39
  exports.getHighlightStyle = Text.getHighlightStyle;
40
40
  exports.getTransform2D = Text.getTransform2D;
@@ -44,14 +44,10 @@ exports.isEqualObject = Text.isEqualObject;
44
44
  exports.isEqualValue = Text.isEqualValue;
45
45
  exports.listStylePlugin = Text.listStylePlugin;
46
46
  exports.outlinePlugin = Text.outlinePlugin;
47
- exports.parseColor = Text.parseColor;
48
47
  exports.parseColormap = Text.parseColormap;
49
48
  exports.parseValueNumber = Text.parseValueNumber;
50
49
  exports.renderPlugin = Text.renderPlugin;
51
- exports.setupView = Text.setupView;
52
50
  exports.textDecorationPlugin = Text.textDecorationPlugin;
53
51
  exports.textDefaultStyle = Text.textDefaultStyle;
54
- exports.uploadColor = Text.uploadColor;
55
- exports.uploadColors = Text.uploadColors;
56
52
  exports.measureText = measureText;
57
53
  exports.renderText = renderText;
package/dist/index.d.cts CHANGED
@@ -1,65 +1,40 @@
1
+ import { P as Plugin, O as Options, M as MeasureResult, R as RenderOptions, T as Text } from './shared/modern-text.D_VtaVfs.cjs';
2
+ export { C as Canvas2DRenderer, a as Character, D as DrawShapePathsOptions, F as Fragment, f as MeasureDomResult, e as MeasuredCharacter, d as MeasuredFragment, c as MeasuredParagraph, g as Measurer, b as Paragraph, h as TextEvents, t as textDefaultStyle } from './shared/modern-text.D_VtaVfs.cjs';
1
3
  import { NormalizedStyle, NormalizedHighlight } from 'modern-idoc';
2
- import { BoundingBox, Path2DDrawStyle, Path2D, Matrix3, Path2DSet } from 'modern-path2d';
3
- import { T as Text, a as TextPlugin, b as TextOptions, M as MeasureResult, c as TextRenderOptions } from './shared/modern-text.WbWB6f3d.cjs';
4
- export { C as Character, F as Fragment, g as MeasureDomResult, f as MeasuredCharacter, e as MeasuredFragment, d as MeasuredParagraph, h as Measurer, P as Paragraph, i as TextEvents, t as textDefaultStyle } from './shared/modern-text.WbWB6f3d.cjs';
4
+ import { Matrix3, Path2DSet } from 'modern-path2d';
5
5
  import 'modern-font';
6
6
 
7
- declare function parseColor(ctx: CanvasRenderingContext2D, source: string | CanvasGradient | CanvasPattern, box: BoundingBox): string | CanvasGradient | CanvasPattern;
8
- declare function uploadColor(style: NormalizedStyle, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
9
- interface LinearGradient {
10
- x0: number;
11
- y0: number;
12
- x1: number;
13
- y1: number;
14
- stops: {
15
- offset: number;
16
- color: string;
17
- }[];
18
- }
19
-
20
- interface DrawShapePathsOptions extends NormalizedStyle, Omit<Partial<Path2DDrawStyle>, 'fill' | 'outline'> {
21
- ctx: CanvasRenderingContext2D;
22
- path: Path2D;
23
- fontSize: number;
24
- clipRect?: BoundingBox;
25
- }
26
- declare function drawPath(options: DrawShapePathsOptions): void;
27
-
28
- declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, boundingBox: BoundingBox): void;
29
-
30
- declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
31
-
32
- declare function definePlugin(options: TextPlugin): TextPlugin;
7
+ declare function definePlugin(options: Plugin): Plugin;
33
8
 
34
- declare function measureText(options: TextOptions, load: true): Promise<MeasureResult>;
35
- declare function measureText(options: TextOptions): MeasureResult;
9
+ declare function measureText(options: Options, load: true): Promise<MeasureResult>;
10
+ declare function measureText(options: Options): MeasureResult;
36
11
 
37
- type RenderTextOptions = TextOptions & TextRenderOptions;
12
+ type RenderTextOptions = Options & RenderOptions;
38
13
  declare function renderText(options: RenderTextOptions, load: true): Promise<void>;
39
14
  declare function renderText(options: RenderTextOptions): void;
40
15
 
41
- declare function backgroundPlugin(): TextPlugin;
16
+ declare function backgroundPlugin(): Plugin;
42
17
 
43
18
  declare function getHighlightStyle(style: NormalizedStyle): NormalizedHighlight;
44
- declare function highlightPlugin(): TextPlugin;
19
+ declare function highlightPlugin(): Plugin;
45
20
 
46
- declare function listStylePlugin(): TextPlugin;
21
+ declare function listStylePlugin(): Plugin;
47
22
 
48
- declare function outlinePlugin(): TextPlugin;
23
+ declare function outlinePlugin(): Plugin;
49
24
 
50
- declare function renderPlugin(): TextPlugin;
25
+ declare function renderPlugin(): Plugin;
51
26
  declare function getTransform2D(text: Text, style: NormalizedStyle): Matrix3;
52
27
 
53
- declare function textDecorationPlugin(): TextPlugin;
28
+ declare function textDecorationPlugin(): Plugin;
54
29
 
55
- interface SVGLoader {
30
+ interface SvgLoader {
56
31
  loaded: Map<string, string>;
57
32
  needsLoad: (source: string) => boolean;
58
33
  load: (svg: string) => Promise<void>;
59
34
  }
60
- declare function createSVGLoader(): SVGLoader;
35
+ declare function createSvgLoader(): SvgLoader;
61
36
 
62
- interface SVGParser {
37
+ interface SvgParser {
63
38
  parsed: Map<string, {
64
39
  dom: SVGElement;
65
40
  pathSet: Path2DSet;
@@ -69,7 +44,7 @@ interface SVGParser {
69
44
  pathSet: Path2DSet;
70
45
  };
71
46
  }
72
- declare function createSVGParser(loader: SVGLoader): SVGParser;
47
+ declare function createSvgParser(loader: SvgLoader): SvgParser;
73
48
 
74
49
  interface ValueContext {
75
50
  total: number;
@@ -82,5 +57,5 @@ declare function isEqualValue(val1: any, val2: any): boolean;
82
57
  declare function hexToRgb(hex: string): string | null;
83
58
  declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
84
59
 
85
- export { MeasureResult, Text, TextOptions, TextPlugin, TextRenderOptions, backgroundPlugin, createSVGLoader, createSVGParser, definePlugin, drawPath, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlightPlugin, isEqualObject, isEqualValue, listStylePlugin, measureText, outlinePlugin, parseColor, parseColormap, parseValueNumber, renderPlugin, renderText, setupView, textDecorationPlugin, uploadColor, uploadColors };
86
- export type { DrawShapePathsOptions, LinearGradient, RenderTextOptions, SVGLoader, SVGParser };
60
+ export { MeasureResult, Options, Plugin, RenderOptions, Text, backgroundPlugin, createSvgLoader, createSvgParser, definePlugin, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlightPlugin, isEqualObject, isEqualValue, listStylePlugin, measureText, outlinePlugin, parseColormap, parseValueNumber, renderPlugin, renderText, textDecorationPlugin };
61
+ export type { RenderTextOptions, SvgLoader, SvgParser };
package/dist/index.d.mts CHANGED
@@ -1,65 +1,40 @@
1
+ import { P as Plugin, O as Options, M as MeasureResult, R as RenderOptions, T as Text } from './shared/modern-text.D_VtaVfs.mjs';
2
+ export { C as Canvas2DRenderer, a as Character, D as DrawShapePathsOptions, F as Fragment, f as MeasureDomResult, e as MeasuredCharacter, d as MeasuredFragment, c as MeasuredParagraph, g as Measurer, b as Paragraph, h as TextEvents, t as textDefaultStyle } from './shared/modern-text.D_VtaVfs.mjs';
1
3
  import { NormalizedStyle, NormalizedHighlight } from 'modern-idoc';
2
- import { BoundingBox, Path2DDrawStyle, Path2D, Matrix3, Path2DSet } from 'modern-path2d';
3
- import { T as Text, a as TextPlugin, b as TextOptions, M as MeasureResult, c as TextRenderOptions } from './shared/modern-text.WbWB6f3d.mjs';
4
- export { C as Character, F as Fragment, g as MeasureDomResult, f as MeasuredCharacter, e as MeasuredFragment, d as MeasuredParagraph, h as Measurer, P as Paragraph, i as TextEvents, t as textDefaultStyle } from './shared/modern-text.WbWB6f3d.mjs';
4
+ import { Matrix3, Path2DSet } from 'modern-path2d';
5
5
  import 'modern-font';
6
6
 
7
- declare function parseColor(ctx: CanvasRenderingContext2D, source: string | CanvasGradient | CanvasPattern, box: BoundingBox): string | CanvasGradient | CanvasPattern;
8
- declare function uploadColor(style: NormalizedStyle, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
9
- interface LinearGradient {
10
- x0: number;
11
- y0: number;
12
- x1: number;
13
- y1: number;
14
- stops: {
15
- offset: number;
16
- color: string;
17
- }[];
18
- }
19
-
20
- interface DrawShapePathsOptions extends NormalizedStyle, Omit<Partial<Path2DDrawStyle>, 'fill' | 'outline'> {
21
- ctx: CanvasRenderingContext2D;
22
- path: Path2D;
23
- fontSize: number;
24
- clipRect?: BoundingBox;
25
- }
26
- declare function drawPath(options: DrawShapePathsOptions): void;
27
-
28
- declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, boundingBox: BoundingBox): void;
29
-
30
- declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
31
-
32
- declare function definePlugin(options: TextPlugin): TextPlugin;
7
+ declare function definePlugin(options: Plugin): Plugin;
33
8
 
34
- declare function measureText(options: TextOptions, load: true): Promise<MeasureResult>;
35
- declare function measureText(options: TextOptions): MeasureResult;
9
+ declare function measureText(options: Options, load: true): Promise<MeasureResult>;
10
+ declare function measureText(options: Options): MeasureResult;
36
11
 
37
- type RenderTextOptions = TextOptions & TextRenderOptions;
12
+ type RenderTextOptions = Options & RenderOptions;
38
13
  declare function renderText(options: RenderTextOptions, load: true): Promise<void>;
39
14
  declare function renderText(options: RenderTextOptions): void;
40
15
 
41
- declare function backgroundPlugin(): TextPlugin;
16
+ declare function backgroundPlugin(): Plugin;
42
17
 
43
18
  declare function getHighlightStyle(style: NormalizedStyle): NormalizedHighlight;
44
- declare function highlightPlugin(): TextPlugin;
19
+ declare function highlightPlugin(): Plugin;
45
20
 
46
- declare function listStylePlugin(): TextPlugin;
21
+ declare function listStylePlugin(): Plugin;
47
22
 
48
- declare function outlinePlugin(): TextPlugin;
23
+ declare function outlinePlugin(): Plugin;
49
24
 
50
- declare function renderPlugin(): TextPlugin;
25
+ declare function renderPlugin(): Plugin;
51
26
  declare function getTransform2D(text: Text, style: NormalizedStyle): Matrix3;
52
27
 
53
- declare function textDecorationPlugin(): TextPlugin;
28
+ declare function textDecorationPlugin(): Plugin;
54
29
 
55
- interface SVGLoader {
30
+ interface SvgLoader {
56
31
  loaded: Map<string, string>;
57
32
  needsLoad: (source: string) => boolean;
58
33
  load: (svg: string) => Promise<void>;
59
34
  }
60
- declare function createSVGLoader(): SVGLoader;
35
+ declare function createSvgLoader(): SvgLoader;
61
36
 
62
- interface SVGParser {
37
+ interface SvgParser {
63
38
  parsed: Map<string, {
64
39
  dom: SVGElement;
65
40
  pathSet: Path2DSet;
@@ -69,7 +44,7 @@ interface SVGParser {
69
44
  pathSet: Path2DSet;
70
45
  };
71
46
  }
72
- declare function createSVGParser(loader: SVGLoader): SVGParser;
47
+ declare function createSvgParser(loader: SvgLoader): SvgParser;
73
48
 
74
49
  interface ValueContext {
75
50
  total: number;
@@ -82,5 +57,5 @@ declare function isEqualValue(val1: any, val2: any): boolean;
82
57
  declare function hexToRgb(hex: string): string | null;
83
58
  declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
84
59
 
85
- export { MeasureResult, Text, TextOptions, TextPlugin, TextRenderOptions, backgroundPlugin, createSVGLoader, createSVGParser, definePlugin, drawPath, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlightPlugin, isEqualObject, isEqualValue, listStylePlugin, measureText, outlinePlugin, parseColor, parseColormap, parseValueNumber, renderPlugin, renderText, setupView, textDecorationPlugin, uploadColor, uploadColors };
86
- export type { DrawShapePathsOptions, LinearGradient, RenderTextOptions, SVGLoader, SVGParser };
60
+ export { MeasureResult, Options, Plugin, RenderOptions, Text, backgroundPlugin, createSvgLoader, createSvgParser, definePlugin, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlightPlugin, isEqualObject, isEqualValue, listStylePlugin, measureText, outlinePlugin, parseColormap, parseValueNumber, renderPlugin, renderText, textDecorationPlugin };
61
+ export type { RenderTextOptions, SvgLoader, SvgParser };
package/dist/index.d.ts CHANGED
@@ -1,65 +1,40 @@
1
+ import { P as Plugin, O as Options, M as MeasureResult, R as RenderOptions, T as Text } from './shared/modern-text.D_VtaVfs.js';
2
+ export { C as Canvas2DRenderer, a as Character, D as DrawShapePathsOptions, F as Fragment, f as MeasureDomResult, e as MeasuredCharacter, d as MeasuredFragment, c as MeasuredParagraph, g as Measurer, b as Paragraph, h as TextEvents, t as textDefaultStyle } from './shared/modern-text.D_VtaVfs.js';
1
3
  import { NormalizedStyle, NormalizedHighlight } from 'modern-idoc';
2
- import { BoundingBox, Path2DDrawStyle, Path2D, Matrix3, Path2DSet } from 'modern-path2d';
3
- import { T as Text, a as TextPlugin, b as TextOptions, M as MeasureResult, c as TextRenderOptions } from './shared/modern-text.WbWB6f3d.js';
4
- export { C as Character, F as Fragment, g as MeasureDomResult, f as MeasuredCharacter, e as MeasuredFragment, d as MeasuredParagraph, h as Measurer, P as Paragraph, i as TextEvents, t as textDefaultStyle } from './shared/modern-text.WbWB6f3d.js';
4
+ import { Matrix3, Path2DSet } from 'modern-path2d';
5
5
  import 'modern-font';
6
6
 
7
- declare function parseColor(ctx: CanvasRenderingContext2D, source: string | CanvasGradient | CanvasPattern, box: BoundingBox): string | CanvasGradient | CanvasPattern;
8
- declare function uploadColor(style: NormalizedStyle, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
9
- interface LinearGradient {
10
- x0: number;
11
- y0: number;
12
- x1: number;
13
- y1: number;
14
- stops: {
15
- offset: number;
16
- color: string;
17
- }[];
18
- }
19
-
20
- interface DrawShapePathsOptions extends NormalizedStyle, Omit<Partial<Path2DDrawStyle>, 'fill' | 'outline'> {
21
- ctx: CanvasRenderingContext2D;
22
- path: Path2D;
23
- fontSize: number;
24
- clipRect?: BoundingBox;
25
- }
26
- declare function drawPath(options: DrawShapePathsOptions): void;
27
-
28
- declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, boundingBox: BoundingBox): void;
29
-
30
- declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
31
-
32
- declare function definePlugin(options: TextPlugin): TextPlugin;
7
+ declare function definePlugin(options: Plugin): Plugin;
33
8
 
34
- declare function measureText(options: TextOptions, load: true): Promise<MeasureResult>;
35
- declare function measureText(options: TextOptions): MeasureResult;
9
+ declare function measureText(options: Options, load: true): Promise<MeasureResult>;
10
+ declare function measureText(options: Options): MeasureResult;
36
11
 
37
- type RenderTextOptions = TextOptions & TextRenderOptions;
12
+ type RenderTextOptions = Options & RenderOptions;
38
13
  declare function renderText(options: RenderTextOptions, load: true): Promise<void>;
39
14
  declare function renderText(options: RenderTextOptions): void;
40
15
 
41
- declare function backgroundPlugin(): TextPlugin;
16
+ declare function backgroundPlugin(): Plugin;
42
17
 
43
18
  declare function getHighlightStyle(style: NormalizedStyle): NormalizedHighlight;
44
- declare function highlightPlugin(): TextPlugin;
19
+ declare function highlightPlugin(): Plugin;
45
20
 
46
- declare function listStylePlugin(): TextPlugin;
21
+ declare function listStylePlugin(): Plugin;
47
22
 
48
- declare function outlinePlugin(): TextPlugin;
23
+ declare function outlinePlugin(): Plugin;
49
24
 
50
- declare function renderPlugin(): TextPlugin;
25
+ declare function renderPlugin(): Plugin;
51
26
  declare function getTransform2D(text: Text, style: NormalizedStyle): Matrix3;
52
27
 
53
- declare function textDecorationPlugin(): TextPlugin;
28
+ declare function textDecorationPlugin(): Plugin;
54
29
 
55
- interface SVGLoader {
30
+ interface SvgLoader {
56
31
  loaded: Map<string, string>;
57
32
  needsLoad: (source: string) => boolean;
58
33
  load: (svg: string) => Promise<void>;
59
34
  }
60
- declare function createSVGLoader(): SVGLoader;
35
+ declare function createSvgLoader(): SvgLoader;
61
36
 
62
- interface SVGParser {
37
+ interface SvgParser {
63
38
  parsed: Map<string, {
64
39
  dom: SVGElement;
65
40
  pathSet: Path2DSet;
@@ -69,7 +44,7 @@ interface SVGParser {
69
44
  pathSet: Path2DSet;
70
45
  };
71
46
  }
72
- declare function createSVGParser(loader: SVGLoader): SVGParser;
47
+ declare function createSvgParser(loader: SvgLoader): SvgParser;
73
48
 
74
49
  interface ValueContext {
75
50
  total: number;
@@ -82,5 +57,5 @@ declare function isEqualValue(val1: any, val2: any): boolean;
82
57
  declare function hexToRgb(hex: string): string | null;
83
58
  declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
84
59
 
85
- export { MeasureResult, Text, TextOptions, TextPlugin, TextRenderOptions, backgroundPlugin, createSVGLoader, createSVGParser, definePlugin, drawPath, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlightPlugin, isEqualObject, isEqualValue, listStylePlugin, measureText, outlinePlugin, parseColor, parseColormap, parseValueNumber, renderPlugin, renderText, setupView, textDecorationPlugin, uploadColor, uploadColors };
86
- export type { DrawShapePathsOptions, LinearGradient, RenderTextOptions, SVGLoader, SVGParser };
60
+ export { MeasureResult, Options, Plugin, RenderOptions, Text, backgroundPlugin, createSvgLoader, createSvgParser, definePlugin, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlightPlugin, isEqualObject, isEqualValue, listStylePlugin, measureText, outlinePlugin, parseColormap, parseValueNumber, renderPlugin, renderText, textDecorationPlugin };
61
+ export type { RenderTextOptions, SvgLoader, SvgParser };