bard-legends-framework 0.8.5 → 0.8.6

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.
Files changed (53) hide show
  1. package/.cursorignore +4 -0
  2. package/.eslintrc.js +7 -0
  3. package/dist/pixi/display-object/index.d.ts +8 -0
  4. package/dist/pixi/display-object/index.js +19 -0
  5. package/dist/pixi/display-object/index.js.map +1 -0
  6. package/dist/pixi/display-object/objects/text/helpers/index.d.ts +8 -0
  7. package/dist/pixi/display-object/objects/text/helpers/index.js +6 -0
  8. package/dist/pixi/display-object/objects/text/helpers/index.js.map +1 -0
  9. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.d.ts +25 -0
  10. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.js +50 -0
  11. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.js.map +1 -0
  12. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.d.ts +20 -0
  13. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +167 -0
  14. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js.map +1 -0
  15. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.d.ts +1 -0
  16. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +398 -0
  17. package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js.map +1 -0
  18. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.d.ts +6 -0
  19. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.js +70 -0
  20. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.js.map +1 -0
  21. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.test.d.ts +1 -0
  22. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.test.js +136 -0
  23. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.test.js.map +1 -0
  24. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.d.ts +37 -0
  25. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.js +169 -0
  26. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.js.map +1 -0
  27. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.test.d.ts +1 -0
  28. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.test.js +283 -0
  29. package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.test.js.map +1 -0
  30. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.d.ts +8 -0
  31. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.js +88 -0
  32. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.js.map +1 -0
  33. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.test.d.ts +1 -0
  34. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.test.js +147 -0
  35. package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.test.js.map +1 -0
  36. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +28 -0
  37. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.js +28 -0
  38. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.js.map +1 -0
  39. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.test.d.ts +5 -0
  40. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.test.js +558 -0
  41. package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.test.js.map +1 -0
  42. package/dist/pixi/display-object/objects/text/rich-text.d.ts +19 -0
  43. package/dist/pixi/display-object/objects/text/rich-text.js +16 -0
  44. package/dist/pixi/display-object/objects/text/rich-text.js.map +1 -0
  45. package/dist/pixi/display-object/objects/text/text.d.ts +19 -0
  46. package/dist/pixi/display-object/objects/text/text.js +88 -0
  47. package/dist/pixi/display-object/objects/text/text.js.map +1 -0
  48. package/dist/pixi/index.d.ts +2 -7
  49. package/dist/pixi/index.js +3 -15
  50. package/dist/pixi/index.js.map +1 -1
  51. package/package.json +4 -3
  52. package/package.json.bak +4 -3
  53. package/vitest.config.ts +2 -1
package/.cursorignore ADDED
@@ -0,0 +1,4 @@
1
+ # Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
2
+ /dist
3
+ /build
4
+ /node_modules
package/.eslintrc.js CHANGED
@@ -65,6 +65,13 @@ module.exports = {
65
65
  selector: 'variable',
66
66
  modifiers: ['const'],
67
67
  format: ['PascalCase', 'UPPER_CASE']
68
+ },
69
+ {
70
+ selector: 'variable',
71
+ modifiers: [],
72
+ format: ['camelCase'],
73
+ leadingUnderscore: 'forbid',
74
+ trailingUnderscore: 'forbid'
68
75
  }
69
76
  ],
70
77
  '@typescript-eslint/no-array-constructor': 'error',
@@ -0,0 +1,8 @@
1
+ export { Container, SetParentOptions } from './container';
2
+ export { ContainerEventType, Cursor } from './container-attributes';
3
+ export { Graphics } from './objects/graphics';
4
+ export { Placeholder } from './objects/placeholder';
5
+ export { Sprite } from './objects/sprite';
6
+ export { DropShadowOptions, PartialTextOptions, TextOptions } from './objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter';
7
+ export { RichText as AdvancedText, RichTextRectangleCut as AdvancedTextRectangleCut, RichTextStyles as AdvancedTextStyles } from './objects/text/rich-text';
8
+ export { Text } from './objects/text/text';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Text = exports.AdvancedText = exports.Sprite = exports.Placeholder = exports.Graphics = exports.Cursor = exports.ContainerEventType = exports.Container = void 0;
4
+ var container_1 = require("./container");
5
+ Object.defineProperty(exports, "Container", { enumerable: true, get: function () { return container_1.Container; } });
6
+ var container_attributes_1 = require("./container-attributes");
7
+ Object.defineProperty(exports, "ContainerEventType", { enumerable: true, get: function () { return container_attributes_1.ContainerEventType; } });
8
+ Object.defineProperty(exports, "Cursor", { enumerable: true, get: function () { return container_attributes_1.Cursor; } });
9
+ var graphics_1 = require("./objects/graphics");
10
+ Object.defineProperty(exports, "Graphics", { enumerable: true, get: function () { return graphics_1.Graphics; } });
11
+ var placeholder_1 = require("./objects/placeholder");
12
+ Object.defineProperty(exports, "Placeholder", { enumerable: true, get: function () { return placeholder_1.Placeholder; } });
13
+ var sprite_1 = require("./objects/sprite");
14
+ Object.defineProperty(exports, "Sprite", { enumerable: true, get: function () { return sprite_1.Sprite; } });
15
+ var rich_text_1 = require("./objects/text/rich-text");
16
+ Object.defineProperty(exports, "AdvancedText", { enumerable: true, get: function () { return rich_text_1.RichText; } });
17
+ var text_1 = require("./objects/text/text");
18
+ Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return text_1.Text; } });
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pixi/display-object/index.ts"],"names":[],"mappings":";;;AAAA,yCAA0D;AAAjD,sGAAA,SAAS,OAAA;AAClB,+DAAoE;AAA3D,0HAAA,kBAAkB,OAAA;AAAE,8GAAA,MAAM,OAAA;AACnC,+CAA8C;AAArC,oGAAA,QAAQ,OAAA;AACjB,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,2CAA0C;AAAjC,gGAAA,MAAM,OAAA;AAMf,sDAIkC;AAHhC,yGAAA,QAAQ,OAAgB;AAI1B,4CAA2C;AAAlC,4FAAA,IAAI,OAAA"}
@@ -0,0 +1,8 @@
1
+ import { Vector } from 'helpers-lib';
2
+ import { PartialTextOptions } from './process-steps/1-data-in-converter/pixi-text-style-converter';
3
+ export interface TextData {
4
+ readonly text: string;
5
+ readonly style: PartialTextOptions;
6
+ readonly position: Vector;
7
+ }
8
+ export { RichTextToPlaneText } from './rich-text-to-plane-text';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RichTextToPlaneText = void 0;
4
+ var rich_text_to_plane_text_1 = require("./rich-text-to-plane-text");
5
+ Object.defineProperty(exports, "RichTextToPlaneText", { enumerable: true, get: function () { return rich_text_to_plane_text_1.RichTextToPlaneText; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/pixi/display-object/objects/text/helpers/index.ts"],"names":[],"mappings":";;;AAUA,qEAAgE;AAAvD,8HAAA,mBAAmB,OAAA"}
@@ -0,0 +1,25 @@
1
+ import { Radian, RGBColor } from 'helpers-lib';
2
+ import * as PIXI from 'pixi.js';
3
+ export interface DropShadowOptions {
4
+ readonly blur: number;
5
+ readonly angle: Radian;
6
+ readonly distance: number;
7
+ readonly color: RGBColor;
8
+ readonly alpha: number;
9
+ }
10
+ export interface TextOptions {
11
+ readonly color: RGBColor;
12
+ readonly align: 'left' | 'center' | 'right';
13
+ readonly fontFamily: string;
14
+ readonly fontSize: number;
15
+ readonly fontStyle: 'normal' | 'italic' | 'oblique';
16
+ readonly lineHeight: number | undefined;
17
+ readonly dropShadow: DropShadowOptions | undefined;
18
+ readonly wordWrapWidth?: number;
19
+ }
20
+ export type PartialTextOptions = Partial<Omit<TextOptions, 'dropShadow'>> & {
21
+ dropShadow?: Partial<DropShadowOptions> | true;
22
+ };
23
+ export declare class PixiTextStyleConverter {
24
+ static getPixiTextStyle(partialOptions?: PartialTextOptions): Partial<PIXI.ITextStyle>;
25
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PixiTextStyleConverter = void 0;
4
+ const helpers_lib_1 = require("helpers-lib");
5
+ class PixiTextStyleConverter {
6
+ static getPixiTextStyle(partialOptions) {
7
+ let options = {
8
+ color: helpers_lib_1.ColorHelper.white,
9
+ align: 'center',
10
+ fontFamily: 'Arial',
11
+ fontStyle: 'normal',
12
+ fontSize: 18,
13
+ lineHeight: undefined,
14
+ ...partialOptions
15
+ };
16
+ let partialDropShadowOptions = partialOptions?.dropShadow === true ? {} : partialOptions?.dropShadow;
17
+ let shadowOptions = {};
18
+ if (partialDropShadowOptions) {
19
+ let dropShadowOptions = {
20
+ blur: 4,
21
+ angle: helpers_lib_1.Radian.get60,
22
+ distance: 10,
23
+ color: helpers_lib_1.ColorHelper.black,
24
+ alpha: 0.5,
25
+ ...partialDropShadowOptions
26
+ };
27
+ shadowOptions = {
28
+ dropShadow: true,
29
+ dropShadowBlur: dropShadowOptions.blur,
30
+ dropShadowAngle: dropShadowOptions.angle.value,
31
+ dropShadowDistance: dropShadowOptions.distance,
32
+ dropShadowColor: helpers_lib_1.ColorHelper.rgbToHex(dropShadowOptions.color),
33
+ dropShadowAlpha: dropShadowOptions.alpha
34
+ };
35
+ }
36
+ return {
37
+ fontFamily: options.fontFamily,
38
+ fill: helpers_lib_1.ColorHelper.rgbToHex(options.color),
39
+ align: options.align,
40
+ fontSize: options.fontSize,
41
+ fontStyle: options.fontStyle,
42
+ lineHeight: options.lineHeight,
43
+ wordWrapWidth: options.wordWrapWidth,
44
+ wordWrap: options.wordWrapWidth !== undefined,
45
+ ...shadowOptions
46
+ };
47
+ }
48
+ }
49
+ exports.PixiTextStyleConverter = PixiTextStyleConverter;
50
+ //# sourceMappingURL=pixi-text-style-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixi-text-style-converter.js","sourceRoot":"","sources":["../../../../../../../../src/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.ts"],"names":[],"mappings":";;;AAAA,6CAA4D;AA0B5D,MAAa,sBAAsB;IACjC,MAAM,CAAC,gBAAgB,CAAC,cAAmC;QACzD,IAAI,OAAO,GAAoC;YAC7C,KAAK,EAAE,yBAAW,CAAC,KAAK;YACxB,KAAK,EAAE,QAAQ;YACf,UAAU,EAAE,OAAO;YACnB,SAAS,EAAE,QAAQ;YACnB,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,SAAS;YACrB,GAAG,cAAc;SAClB,CAAC;QAEF,IAAI,wBAAwB,GAAG,cAAc,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,UAAU,CAAC;QAErG,IAAI,aAAa,GAAG,EAAE,CAAC;QACvB,IAAI,wBAAwB,EAAE,CAAC;YAC7B,IAAI,iBAAiB,GAAsB;gBACzC,IAAI,EAAE,CAAC;gBACP,KAAK,EAAE,oBAAM,CAAC,KAAK;gBACnB,QAAQ,EAAE,EAAE;gBACZ,KAAK,EAAE,yBAAW,CAAC,KAAK;gBACxB,KAAK,EAAE,GAAG;gBACV,GAAG,wBAAwB;aAC5B,CAAC;YAEF,aAAa,GAAG;gBACd,UAAU,EAAE,IAAI;gBAChB,cAAc,EAAE,iBAAiB,CAAC,IAAI;gBACtC,eAAe,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK;gBAC9C,kBAAkB,EAAE,iBAAiB,CAAC,QAAQ;gBAC9C,eAAe,EAAE,yBAAW,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,CAAC;gBAC9D,eAAe,EAAE,iBAAiB,CAAC,KAAK;aACzC,CAAC;QACJ,CAAC;QAED,OAAO;YACL,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,IAAI,EAAE,yBAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;YACzC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,QAAQ,EAAE,OAAO,CAAC,aAAa,KAAK,SAAS;YAC7C,GAAG,aAAa;SACjB,CAAC;IACJ,CAAC;CACF;AA/CD,wDA+CC"}
@@ -0,0 +1,20 @@
1
+ import * as PIXI from 'pixi.js';
2
+ import { RichTextStyles } from '../../../rich-text';
3
+ import { ChunkData } from '../../rich-text-to-plane-text';
4
+ import { PartialTextOptions } from './pixi-text-style-converter';
5
+ export interface TagsWithStyles {
6
+ readonly text: string;
7
+ readonly cacheKey: string;
8
+ readonly style: PartialTextOptions;
9
+ readonly pixiStyle: PIXI.TextStyle;
10
+ readonly spaceWidth: number;
11
+ }
12
+ export declare class RichTextDataInConverter {
13
+ static process(text: string, styles: RichTextStyles): ChunkData[][];
14
+ private static includeStylesToTags;
15
+ private static getCombinedStyle;
16
+ private static combineStyles;
17
+ private static applyNewLines;
18
+ private static splitIntoChunks;
19
+ private static splitToChunks;
20
+ }
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.RichTextDataInConverter = void 0;
27
+ const PIXI = __importStar(require("pixi.js"));
28
+ const story_engine_lib_1 = require("story-engine-lib");
29
+ const pixi_text_style_converter_1 = require("./pixi-text-style-converter");
30
+ class RichTextDataInConverter {
31
+ static process(text, styles) {
32
+ let styleNameSet = new Set(styles.styles ? Object.keys(styles.styles) : []);
33
+ let textSegments = story_engine_lib_1.RichTextSeparator.process(text, styleNameSet);
34
+ let tagsWithStyles = this.includeStylesToTags(textSegments, styles);
35
+ let lines = this.applyNewLines(tagsWithStyles);
36
+ let chunks = this.splitIntoChunks(lines);
37
+ return chunks;
38
+ }
39
+ static includeStylesToTags(textSegments, styles) {
40
+ let styleCache = new Map();
41
+ let pixiStyleCache = new Map();
42
+ const GetPixiStyle = (style, cacheKey) => {
43
+ if (pixiStyleCache.has(cacheKey)) {
44
+ return pixiStyleCache.get(cacheKey);
45
+ }
46
+ let pixiStyle = new PIXI.TextStyle(pixi_text_style_converter_1.PixiTextStyleConverter.getPixiTextStyle(style));
47
+ pixiStyleCache.set(cacheKey, pixiStyle);
48
+ return pixiStyle;
49
+ };
50
+ let tagsWithStyles = textSegments.map(segment => {
51
+ let { style, cacheKey } = this.getCombinedStyle(segment.tags, styles, styleCache);
52
+ let pixiStyle = GetPixiStyle(style, cacheKey);
53
+ let spaceMeasurement = PIXI.TextMetrics.measureText(' ', pixiStyle, false);
54
+ let data = {
55
+ text: segment.text,
56
+ cacheKey,
57
+ style,
58
+ pixiStyle,
59
+ spaceWidth: spaceMeasurement.width
60
+ };
61
+ return data;
62
+ });
63
+ return tagsWithStyles;
64
+ }
65
+ static getCombinedStyle(tags, styles, styleCache) {
66
+ let cacheKey = tags.join('+');
67
+ if (styleCache.has(cacheKey)) {
68
+ return { style: styleCache.get(cacheKey), cacheKey };
69
+ }
70
+ let result = this.combineStyles(tags, styles);
71
+ styleCache.set(cacheKey, result);
72
+ return { style: result, cacheKey };
73
+ }
74
+ static combineStyles(tags, styles) {
75
+ let result = { ...styles.default };
76
+ for (let tag of tags) {
77
+ if (styles.styles && styles.styles[tag]) {
78
+ result = { ...result, ...styles.styles[tag] };
79
+ }
80
+ }
81
+ let { wordWrapWidth, align, dropShadow, ...supportedStyles } = result;
82
+ return supportedStyles;
83
+ }
84
+ static applyNewLines(tokens) {
85
+ let result = [];
86
+ let currentLine = [];
87
+ tokens.forEach((token, index) => {
88
+ let lines = token.text.split(/\r?\n/);
89
+ lines.forEach((lineText, i) => {
90
+ if (i > 0) {
91
+ result.push(currentLine);
92
+ currentLine = [];
93
+ }
94
+ let lineStartsWithNewline = (index === 0 && token.text.startsWith('\n')) || token.text.startsWith('\r');
95
+ let lineEndsWithNewline = (index === tokens.length - 1 && token.text.endsWith('\n')) || token.text.endsWith('\r');
96
+ let preceedingTag = i === 0 && lineText === '' && !lineStartsWithNewline;
97
+ let followingTag = i === lines.length - 1 && lineText === '' && !lineEndsWithNewline;
98
+ if (!preceedingTag && !followingTag) {
99
+ currentLine.push({
100
+ text: lineText,
101
+ cacheKey: token.cacheKey,
102
+ style: token.style,
103
+ pixiStyle: token.pixiStyle,
104
+ spaceWidth: token.spaceWidth
105
+ });
106
+ }
107
+ });
108
+ });
109
+ result.push(currentLine);
110
+ return result;
111
+ }
112
+ static splitIntoChunks(tagsWithStyles) {
113
+ let chunks = [];
114
+ tagsWithStyles.forEach(line => {
115
+ if (line.length === 0) {
116
+ throw new Error('Internal Error: Line is unexpectedly empty');
117
+ }
118
+ let chunkData = line.flatMap(data => {
119
+ let chunkStrings = this.splitToChunks(data.text);
120
+ return chunkStrings.map(chunkString => {
121
+ let metrics = PIXI.TextMetrics.measureText(chunkString, data.pixiStyle, false);
122
+ let chunkDatum = {
123
+ text: chunkString,
124
+ whitespace: chunkString.trim() === '',
125
+ style: {
126
+ cacheKey: data.cacheKey,
127
+ style: data.style,
128
+ pixiStyle: data.pixiStyle,
129
+ height: metrics.height,
130
+ ascent: metrics.fontProperties.ascent,
131
+ descent: metrics.fontProperties.descent,
132
+ width: metrics.width,
133
+ spaceWidth: data.spaceWidth
134
+ }
135
+ };
136
+ return chunkDatum;
137
+ });
138
+ });
139
+ chunks.push(chunkData);
140
+ });
141
+ return chunks;
142
+ }
143
+ static splitToChunks(str) {
144
+ if (str === '') {
145
+ return [''];
146
+ }
147
+ let result = [];
148
+ let currentWord = '';
149
+ let iteratingSpaces = str[0] === ' ';
150
+ for (let i = 0; i < str.length; i++) {
151
+ let char = str[i];
152
+ let charIsSpace = char === ' ';
153
+ if (charIsSpace === iteratingSpaces) {
154
+ currentWord += char;
155
+ }
156
+ else {
157
+ result.push(currentWord);
158
+ currentWord = char;
159
+ iteratingSpaces = charIsSpace;
160
+ }
161
+ }
162
+ currentWord && result.push(currentWord);
163
+ return result;
164
+ }
165
+ }
166
+ exports.RichTextDataInConverter = RichTextDataInConverter;
167
+ //# sourceMappingURL=rich-text-data-in-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rich-text-data-in-converter.js","sourceRoot":"","sources":["../../../../../../../../src/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAgC;AAChC,uDAAkE;AAIlE,2EAAyF;AAUzF,MAAa,uBAAuB;IAClC,MAAM,CAAC,OAAO,CAAC,IAAY,EAAE,MAAsB;QACjD,IAAI,YAAY,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAA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