@kubohiroya/turbowarp-bubble 0.1.0 → 0.2.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/README.md +225 -31
- package/dist/composition.js +696 -625
- package/dist/extension-manifest.json +22 -22
- package/dist/turbowarp-adapter.js +1209 -533
- package/dist/turbowarp-bubble.js +1800 -346
- package/dist/types/composition.d.ts +49 -17
- package/dist/types/turbowarp-adapter.d.ts +10 -2
- package/docs/assets/animation-mode-guide.svg +2 -2
- package/docs/assets/block-quick-start.svg +8 -8
- package/docs/assets/bubble-lifecycle.gif +0 -0
- package/docs/block-manual.ja.md +37 -37
- package/docs/block-manual.md +44 -44
- package/docs/index.html +31 -31
- package/docs/ja/index.html +23 -23
- package/package.json +40 -31
package/dist/turbowarp-bubble.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Name: Bubble
|
|
2
2
|
// ID: kubohiroyabubble
|
|
3
|
-
// Description: Layered say and think bubbles with portrait animation and
|
|
3
|
+
// Description: Layered say and think bubbles with portrait animation and continue indicators.
|
|
4
4
|
// By: Hiroya Kubo
|
|
5
5
|
// License: MPL-2.0
|
|
6
6
|
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
id: "kubohiroyabubble",
|
|
36
36
|
slug: "turbowarp-bubble",
|
|
37
37
|
name: "Bubble",
|
|
38
|
-
description: "Layered say and think bubbles with portrait animation and
|
|
38
|
+
description: "Layered say and think bubbles with portrait animation and continue indicators.",
|
|
39
39
|
author: "Hiroya Kubo",
|
|
40
40
|
license: "MPL-2.0",
|
|
41
41
|
unsandboxed: true
|
|
@@ -186,10 +186,10 @@
|
|
|
186
186
|
}
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
|
-
"opcode": "
|
|
189
|
+
"opcode": "setLipSyncFrames",
|
|
190
190
|
"blockType": "COMMAND",
|
|
191
|
-
"text": "set
|
|
192
|
-
"description": "Sets comma-separated registered image assets for the portrait
|
|
191
|
+
"text": "set lip-sync frames [ASSETS] every [SECONDS] seconds for bubble style [STYLE]",
|
|
192
|
+
"description": "Sets comma-separated registered image assets for the portrait lip-sync layer. An empty list removes lip-sync animation.",
|
|
193
193
|
"arguments": {
|
|
194
194
|
"ASSETS": {
|
|
195
195
|
"type": "STRING",
|
|
@@ -206,10 +206,10 @@
|
|
|
206
206
|
}
|
|
207
207
|
},
|
|
208
208
|
{
|
|
209
|
-
"opcode": "
|
|
209
|
+
"opcode": "setContinueFrames",
|
|
210
210
|
"blockType": "COMMAND",
|
|
211
|
-
"text": "set
|
|
212
|
-
"description": "Sets at least two comma-separated registered image assets for the awaiting-
|
|
211
|
+
"text": "set continue frames [ASSETS] every [SECONDS] seconds for bubble style [STYLE]",
|
|
212
|
+
"description": "Sets at least two comma-separated registered image assets for the awaiting-continue indicator. An empty list removes the indicator.",
|
|
213
213
|
"arguments": {
|
|
214
214
|
"ASSETS": {
|
|
215
215
|
"type": "STRING",
|
|
@@ -261,18 +261,18 @@
|
|
|
261
261
|
"opcode": "setBubbleAnimationMode",
|
|
262
262
|
"blockType": "COMMAND",
|
|
263
263
|
"text": "set this bubble animation mode [MODE]",
|
|
264
|
-
"description": "Changes this sprite's bubble animation mode. Awaiting
|
|
264
|
+
"description": "Changes this sprite's bubble animation mode. Awaiting continue stops lip-sync animation and starts the configured continue frames.",
|
|
265
265
|
"arguments": { "MODE": {
|
|
266
266
|
"type": "STRING",
|
|
267
|
-
"defaultValue": "awaiting-
|
|
267
|
+
"defaultValue": "awaiting-continue",
|
|
268
268
|
"menu": "animationMode"
|
|
269
269
|
} }
|
|
270
270
|
},
|
|
271
271
|
{
|
|
272
|
-
"opcode": "
|
|
272
|
+
"opcode": "waitForBubbleContinue",
|
|
273
273
|
"blockType": "COMMAND",
|
|
274
274
|
"text": "wait with this bubble until condition [CONDITION] or timeout after [TIMEOUT] seconds",
|
|
275
|
-
"description": "Switches to awaiting-
|
|
275
|
+
"description": "Switches to awaiting-continue mode, evaluates a Runtime Expression condition using variables updated by Async Input, and waits until the condition is true or the timeout expires. Zero disables the timeout.",
|
|
276
276
|
"arguments": {
|
|
277
277
|
"CONDITION": {
|
|
278
278
|
"type": "STRING",
|
|
@@ -343,7 +343,7 @@
|
|
|
343
343
|
"acceptReporters": true,
|
|
344
344
|
"items": [
|
|
345
345
|
"talking",
|
|
346
|
-
"awaiting-
|
|
346
|
+
"awaiting-continue",
|
|
347
347
|
"idle"
|
|
348
348
|
]
|
|
349
349
|
}
|
|
@@ -6065,44 +6065,6 @@
|
|
|
6065
6065
|
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" role="img" data-bubble-renderer="canonical" data-bubble-style="${input.style}"><title>${title}</title>${renderBody(input.style, width, height, direction, fill, border, tailLength, offset)}${text}</svg>`;
|
|
6066
6066
|
}
|
|
6067
6067
|
//#endregion
|
|
6068
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/typeof.js
|
|
6069
|
-
function _typeof(o) {
|
|
6070
|
-
"@babel/helpers - typeof";
|
|
6071
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
6072
|
-
return typeof o;
|
|
6073
|
-
} : function(o) {
|
|
6074
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
6075
|
-
}, _typeof(o);
|
|
6076
|
-
}
|
|
6077
|
-
//#endregion
|
|
6078
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPrimitive.js
|
|
6079
|
-
function toPrimitive(t, r) {
|
|
6080
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
6081
|
-
var e = t[Symbol.toPrimitive];
|
|
6082
|
-
if (void 0 !== e) {
|
|
6083
|
-
var i = e.call(t, r || "default");
|
|
6084
|
-
if ("object" != _typeof(i)) return i;
|
|
6085
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
6086
|
-
}
|
|
6087
|
-
return ("string" === r ? String : Number)(t);
|
|
6088
|
-
}
|
|
6089
|
-
//#endregion
|
|
6090
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPropertyKey.js
|
|
6091
|
-
function toPropertyKey(t) {
|
|
6092
|
-
var i = toPrimitive(t, "string");
|
|
6093
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
6094
|
-
}
|
|
6095
|
-
//#endregion
|
|
6096
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/defineProperty.js
|
|
6097
|
-
function _defineProperty(e, r, t) {
|
|
6098
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
6099
|
-
value: t,
|
|
6100
|
-
enumerable: !0,
|
|
6101
|
-
configurable: !0,
|
|
6102
|
-
writable: !0
|
|
6103
|
-
}) : e[r] = t, e;
|
|
6104
|
-
}
|
|
6105
|
-
//#endregion
|
|
6106
6068
|
//#region node_modules/.pnpm/@cto.af+unicode-trie-runtime@3.2.9/node_modules/@cto.af/unicode-trie-runtime/constants.js
|
|
6107
6069
|
var LSCP_INDEX_2_OFFSET = 2048;
|
|
6108
6070
|
var INDEX_1_OFFSET = 2112;
|
|
@@ -6503,178 +6465,1559 @@
|
|
|
6503
6465
|
} else ({data: this.data, highStart: this.highStart, errorValue: this.errorValue, values: this.values = []} = data);
|
|
6504
6466
|
}
|
|
6505
6467
|
/**
|
|
6506
|
-
* Creates a trie from a base64-encoded string.
|
|
6507
|
-
* @param {string} base64 The base64-encoded trie to initialize.
|
|
6508
|
-
* @returns {UnicodeTrie} The decoded Unicode trie.
|
|
6468
|
+
* Creates a trie from a base64-encoded string.
|
|
6469
|
+
* @param {string} base64 The base64-encoded trie to initialize.
|
|
6470
|
+
* @returns {UnicodeTrie} The decoded Unicode trie.
|
|
6471
|
+
*/
|
|
6472
|
+
static fromBase64(base64) {
|
|
6473
|
+
return new UnicodeTrie(new Uint8Array(atob(base64).split("").map((c) => c.charCodeAt(0))));
|
|
6474
|
+
}
|
|
6475
|
+
/**
|
|
6476
|
+
* Get the value associated with a codepoint, or the default value, or the
|
|
6477
|
+
* error value if codePoint is out of range.
|
|
6478
|
+
*
|
|
6479
|
+
* @param {number} codePoint
|
|
6480
|
+
* @returns {number}
|
|
6481
|
+
*/
|
|
6482
|
+
get(codePoint) {
|
|
6483
|
+
let val = this.errorValue;
|
|
6484
|
+
if (codePoint < 0 || codePoint > 1114111) val = this.errorValue;
|
|
6485
|
+
else if (codePoint < 55296 || codePoint > 56319 && codePoint <= 65535) {
|
|
6486
|
+
const index = (this.data[codePoint >> 5] << 2) + (codePoint & 31);
|
|
6487
|
+
val = this.data[index];
|
|
6488
|
+
} else if (codePoint <= 65535) {
|
|
6489
|
+
const index = (this.data[LSCP_INDEX_2_OFFSET + (codePoint - 55296 >> 5)] << 2) + (codePoint & 31);
|
|
6490
|
+
val = this.data[index];
|
|
6491
|
+
} else if (codePoint < this.highStart) {
|
|
6492
|
+
let index = this.data[INDEX_1_OFFSET - 32 + (codePoint >> 11)];
|
|
6493
|
+
index = this.data[index + (codePoint >> 5 & 63)];
|
|
6494
|
+
index = (index << 2) + (codePoint & 31);
|
|
6495
|
+
val = this.data[index];
|
|
6496
|
+
} else val = this.data[this.data.length - 4];
|
|
6497
|
+
return val;
|
|
6498
|
+
}
|
|
6499
|
+
/**
|
|
6500
|
+
* Get the value associated with the codePoint, stringified if possible.
|
|
6501
|
+
*
|
|
6502
|
+
* @param {number} codePoint
|
|
6503
|
+
* @returns {number|string}
|
|
6504
|
+
*/
|
|
6505
|
+
getString(codePoint) {
|
|
6506
|
+
const val = this.get(codePoint);
|
|
6507
|
+
return this.values[val] ?? val;
|
|
6508
|
+
}
|
|
6509
|
+
};
|
|
6510
|
+
//#endregion
|
|
6511
|
+
//#region node_modules/.pnpm/@cto.af+linebreak@4.0.3/node_modules/@cto.af/linebreak/lib/LineBreak.js
|
|
6512
|
+
var LineBreak = UnicodeTrie.fromBase64(`AAgOAAEAAAD/////nRQAAB+LCAC4xcFoAgP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uxu7xb3cuj7heahiXq4ljrC1R5vm5M39HGFz7yzRLr
|
|
6602
|
+
k1PoMMfcPzeGvDPWPssxw6Rzo8QcXmp3XGSSHX2/Et08k67f5dtmuupKN2FvMpOsKObeDnVx
|
|
6603
|
+
k3ofp1h6VrFIVVdV7T2fYm9013l7k/5rbNlKaBuXso7LLV+K1d67uuWiJ19ShhcjvUP97FsO
|
|
6604
|
+
Q+V7pdfDpy5rtv2qEPkU7XFY0v3Q+Oc8FpqHdHV9Xf415XFbPTPfPk7qNWsufow9vkqlz6v+
|
|
6605
|
+
eA4udH9l3XxtiA5ZyN5XpvxSNzdetRdQlWnKjzbP695Xt9+WTz/bJk5y6tDVlYHUe0Crv9Bv
|
|
6606
|
+
vMf+bnzq79DHenfs/ZD3y4TO7b0S7vPM8Z5yL2mTG1XXKcyMLh5093OzvwbVfzr/1hHDby7u
|
|
6607
|
+
ufhH5z/Vrm1YZPsheUtn2pQh+RnfMmCqy3PN7aSeN0oRtrp8m6oONOXflHVfrnj0ccdU1lVS
|
|
6608
|
+
yYu7Ssjz96ZwxEgz13rX1c3Y+Sp2vJve7eN+zP3nYsojYunAhMq1cs2vM1X9J99+Q2g+d+1z
|
|
6609
|
+
5OznpXJD1zcKcc/U33KN39TzgCnr4lz95Fz1cW79kxT6SDF00UruT5ZDZ8Xl9x83MV0I0CwB
|
|
6610
|
+
AB+LCAC4xcFoAgMdjksWhCAMBO/CelYzJ4gMCqiI4t/n/a9hyk29JN3p5DL7bj7GTQrbKypR
|
|
6611
|
+
dDVVywyhZCz4xkUhnSIj5EExoFoQisIfbICE2WJOoAESSK7wecCscDJSxRXMbBAlfLCyIbTh
|
|
6612
|
+
T8tr5/YikvVFSYq3dURbKo/gf+Q3zBCELycCXW/uB2mPjCb8AAAA`);
|
|
6613
|
+
/**
|
|
6614
|
+
* @type {Record<string, number>}
|
|
6615
|
+
*/
|
|
6616
|
+
var names$1 = Object.fromEntries(LineBreak.values.map((v, i) => [v, i]));
|
|
6617
|
+
var { values: values$1 } = LineBreak;
|
|
6618
|
+
//#endregion
|
|
6619
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/typeof.js
|
|
6620
|
+
function _typeof(o) {
|
|
6621
|
+
"@babel/helpers - typeof";
|
|
6622
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
6623
|
+
return typeof o;
|
|
6624
|
+
} : function(o) {
|
|
6625
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
6626
|
+
}, _typeof(o);
|
|
6627
|
+
}
|
|
6628
|
+
//#endregion
|
|
6629
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPrimitive.js
|
|
6630
|
+
function toPrimitive(t, r) {
|
|
6631
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
6632
|
+
var e = t[Symbol.toPrimitive];
|
|
6633
|
+
if (void 0 !== e) {
|
|
6634
|
+
var i = e.call(t, r || "default");
|
|
6635
|
+
if ("object" != _typeof(i)) return i;
|
|
6636
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
6637
|
+
}
|
|
6638
|
+
return ("string" === r ? String : Number)(t);
|
|
6639
|
+
}
|
|
6640
|
+
//#endregion
|
|
6641
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPropertyKey.js
|
|
6642
|
+
function toPropertyKey(t) {
|
|
6643
|
+
var i = toPrimitive(t, "string");
|
|
6644
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
6645
|
+
}
|
|
6646
|
+
//#endregion
|
|
6647
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/defineProperty.js
|
|
6648
|
+
function _defineProperty(e, r, t) {
|
|
6649
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
6650
|
+
value: t,
|
|
6651
|
+
enumerable: !0,
|
|
6652
|
+
configurable: !0,
|
|
6653
|
+
writable: !0
|
|
6654
|
+
}) : e[r] = t, e;
|
|
6655
|
+
}
|
|
6656
|
+
//#endregion
|
|
6657
|
+
//#region node_modules/.pnpm/@cto.af+linebreak@4.0.3/node_modules/@cto.af/linebreak/lib/state.js
|
|
6658
|
+
var _Symbol$for;
|
|
6659
|
+
var _Symbol$for2;
|
|
6660
|
+
var { AI, AL: AL$1, CJ, CM: CM$1, NS: NS$1, SA, SG, SP: SP$1, XX } = names$1;
|
|
6661
|
+
/**
|
|
6662
|
+
* Convert a class number to a string, if possible.
|
|
6663
|
+
*
|
|
6664
|
+
* @param {number?} cls
|
|
6665
|
+
*/
|
|
6666
|
+
function classText(cls) {
|
|
6667
|
+
switch (cls) {
|
|
6668
|
+
case null: return null;
|
|
6669
|
+
case -1: return "sot";
|
|
6670
|
+
case -2: return "eot";
|
|
6671
|
+
default: return values$1[cls];
|
|
6672
|
+
}
|
|
6673
|
+
}
|
|
6674
|
+
/**
|
|
6675
|
+
* LB1: Assign a line breaking class to each code point of the input. Resolve
|
|
6676
|
+
* AI, CB, CJ, SA, SG, and XX into other line breaking classes depending on
|
|
6677
|
+
* criteria outside the scope of this algorithm.
|
|
6678
|
+
*
|
|
6679
|
+
* @param {number} cls
|
|
6680
|
+
* @param {string} char
|
|
6681
|
+
* @returns {number}
|
|
6682
|
+
*/
|
|
6683
|
+
function resolve(cls, char) {
|
|
6684
|
+
switch (cls) {
|
|
6685
|
+
case AI:
|
|
6686
|
+
case SG:
|
|
6687
|
+
case XX: return AL$1;
|
|
6688
|
+
case SA: return /^[\p{gc=Mn}\p{gc=Mc}]$/u.test(char) ? CM$1 : AL$1;
|
|
6689
|
+
case CJ: return NS$1;
|
|
6690
|
+
}
|
|
6691
|
+
return cls;
|
|
6692
|
+
}
|
|
6693
|
+
_Symbol$for = Symbol.for("nodejs.util.inspect.custom");
|
|
6694
|
+
/**
|
|
6695
|
+
* Information about a particular input character.
|
|
6696
|
+
*/
|
|
6697
|
+
var BreakerChar = class {
|
|
6698
|
+
/**
|
|
6699
|
+
* @param {number} cls
|
|
6700
|
+
* @param {number} cp
|
|
6701
|
+
* @param {string} char
|
|
6702
|
+
* @param {number} len
|
|
6703
|
+
*/
|
|
6704
|
+
constructor(cls, cp, char, len) {
|
|
6705
|
+
_defineProperty(
|
|
6706
|
+
this,
|
|
6707
|
+
/**
|
|
6708
|
+
* Code point
|
|
6709
|
+
*/
|
|
6710
|
+
"cp",
|
|
6711
|
+
-Infinity
|
|
6712
|
+
);
|
|
6713
|
+
_defineProperty(
|
|
6714
|
+
this,
|
|
6715
|
+
/**
|
|
6716
|
+
* Line breaking class, or `sot` or `eot`.
|
|
6717
|
+
*/
|
|
6718
|
+
"cls",
|
|
6719
|
+
-1
|
|
6720
|
+
);
|
|
6721
|
+
_defineProperty(
|
|
6722
|
+
this,
|
|
6723
|
+
/**
|
|
6724
|
+
* The character. Might be one or two UTF-16 JS characters.
|
|
6725
|
+
*/
|
|
6726
|
+
"char",
|
|
6727
|
+
""
|
|
6728
|
+
);
|
|
6729
|
+
_defineProperty(
|
|
6730
|
+
this,
|
|
6731
|
+
/**
|
|
6732
|
+
* The length of the whole string up to and including char, in JS chars.
|
|
6733
|
+
*/
|
|
6734
|
+
"len",
|
|
6735
|
+
0
|
|
6736
|
+
);
|
|
6737
|
+
_defineProperty(
|
|
6738
|
+
this,
|
|
6739
|
+
/**
|
|
6740
|
+
* If true, this is an LB9 CM or ZWJ that is treated as coalesced into
|
|
6741
|
+
* the previous code point.
|
|
6742
|
+
*/
|
|
6743
|
+
"ignored",
|
|
6744
|
+
false
|
|
6745
|
+
);
|
|
6746
|
+
this.cls = cls;
|
|
6747
|
+
this.cp = cp;
|
|
6748
|
+
this.char = char;
|
|
6749
|
+
this.len = len;
|
|
6750
|
+
}
|
|
6751
|
+
/**
|
|
6752
|
+
* Debug helper.
|
|
6753
|
+
*
|
|
6754
|
+
* @param {number} _depth
|
|
6755
|
+
* @param {import('util').InspectOptionsStylized} _inspectOptions
|
|
6756
|
+
* @param {(x: any) => string} _inspect
|
|
6757
|
+
* @returns
|
|
6758
|
+
*/
|
|
6759
|
+
[_Symbol$for](_depth, _inspectOptions, _inspect) {
|
|
6760
|
+
return `${classText(this.cls)}(${this.cp.toString(16).padStart(4, "0")}:${JSON.stringify(this.char)})${this.ignored ? "Ig" : ""}`;
|
|
6761
|
+
}
|
|
6762
|
+
};
|
|
6763
|
+
_Symbol$for2 = Symbol.for("nodejs.util.inspect.custom");
|
|
6764
|
+
/**
|
|
6765
|
+
* @private
|
|
6766
|
+
*/
|
|
6767
|
+
var BreakerState = class {
|
|
6768
|
+
/**
|
|
6769
|
+
* @param {string} str
|
|
6770
|
+
*/
|
|
6771
|
+
constructor(str) {
|
|
6772
|
+
_defineProperty(this, "str", "");
|
|
6773
|
+
_defineProperty(this, "len", 0);
|
|
6774
|
+
_defineProperty(this, "prevChunk", 0);
|
|
6775
|
+
_defineProperty(this, "prev", new BreakerChar(-1, -Infinity, "", 0));
|
|
6776
|
+
_defineProperty(this, "cur", new BreakerChar(-1, -Infinity, "", 0));
|
|
6777
|
+
_defineProperty(this, "next", new BreakerChar(-1, -Infinity, "", 0));
|
|
6778
|
+
_defineProperty(this, "LB8", false);
|
|
6779
|
+
_defineProperty(this, "spaces", false);
|
|
6780
|
+
_defineProperty(this, "RI", 0);
|
|
6781
|
+
_defineProperty(
|
|
6782
|
+
this,
|
|
6783
|
+
/**
|
|
6784
|
+
* Extra properties, to be copied to Break when created.
|
|
6785
|
+
*
|
|
6786
|
+
* @type {Record<string,any>=}
|
|
6787
|
+
*/
|
|
6788
|
+
"props",
|
|
6789
|
+
void 0
|
|
6790
|
+
);
|
|
6791
|
+
_defineProperty(
|
|
6792
|
+
this,
|
|
6793
|
+
/**
|
|
6794
|
+
* Extra state information, for use by tailoring subclasses.
|
|
6795
|
+
*
|
|
6796
|
+
* @type {Record<string,any>}
|
|
6797
|
+
*/
|
|
6798
|
+
"extra",
|
|
6799
|
+
{}
|
|
6800
|
+
);
|
|
6801
|
+
this.str = str;
|
|
6802
|
+
this.len = str.length;
|
|
6803
|
+
}
|
|
6804
|
+
/**
|
|
6805
|
+
* Move to the next state.
|
|
6806
|
+
*
|
|
6807
|
+
* @param {BreakerChar} step
|
|
6808
|
+
*/
|
|
6809
|
+
push(step) {
|
|
6810
|
+
if (this.next.ignored) this.cur.len = this.next.len;
|
|
6811
|
+
else {
|
|
6812
|
+
this.prev = this.cur;
|
|
6813
|
+
this.cur = this.next;
|
|
6814
|
+
}
|
|
6815
|
+
this.next = step;
|
|
6816
|
+
}
|
|
6817
|
+
pushEnd() {
|
|
6818
|
+
this.push(new BreakerChar(-2, Infinity, "", this.next.len));
|
|
6819
|
+
}
|
|
6820
|
+
/**
|
|
6821
|
+
* Iterate over the codepoints in the string, starting at pos.
|
|
6822
|
+
*
|
|
6823
|
+
* @param {number} pos;
|
|
6824
|
+
* @param {boolean} [fwd=true] If true, go forward. Otherwise reverse.
|
|
6825
|
+
*/
|
|
6826
|
+
*codePoints(pos, fwd = true) {
|
|
6827
|
+
if (fwd) while (pos < this.len) if (pos === this.cur.len && this.next.cls >= 0) {
|
|
6828
|
+
yield this.next;
|
|
6829
|
+
pos += this.next.char.length;
|
|
6830
|
+
} else {
|
|
6831
|
+
const cp = this.str.codePointAt(pos);
|
|
6832
|
+
const char = String.fromCodePoint(cp);
|
|
6833
|
+
const cls = LineBreak.get(cp);
|
|
6834
|
+
pos += char.length;
|
|
6835
|
+
yield new BreakerChar(resolve(cls, char), cp, char, pos);
|
|
6836
|
+
}
|
|
6837
|
+
else while (pos > 0) if (pos === this.cur.len) {
|
|
6838
|
+
yield this.cur;
|
|
6839
|
+
pos -= this.cur.char.length;
|
|
6840
|
+
} else if (pos === this.prev.len) {
|
|
6841
|
+
yield this.prev;
|
|
6842
|
+
pos -= this.prev.char.length;
|
|
6843
|
+
} else {
|
|
6844
|
+
let prev = pos - 1;
|
|
6845
|
+
const prevUSV = this.str.charCodeAt(prev);
|
|
6846
|
+
if (prevUSV >= 56320 && prevUSV <= 57343) prev--;
|
|
6847
|
+
const cp = this.str.codePointAt(prev);
|
|
6848
|
+
const char = String.fromCodePoint(cp);
|
|
6849
|
+
yield new BreakerChar(resolve(LineBreak.get(cp), char), cp, char, pos);
|
|
6850
|
+
pos = prev;
|
|
6851
|
+
}
|
|
6852
|
+
}
|
|
6853
|
+
/**
|
|
6854
|
+
* Look ahead in the string to see what the next linebreak class is after zero
|
|
6855
|
+
* or more spaces, starting at JS char offset pos.
|
|
6856
|
+
*
|
|
6857
|
+
* @param {number} pos
|
|
6858
|
+
* @returns {number}
|
|
6859
|
+
*/
|
|
6860
|
+
classAfterSpaces(pos) {
|
|
6861
|
+
for (const { cls } of this.codePoints(pos)) if (cls !== SP$1) return cls;
|
|
6862
|
+
return -2;
|
|
6863
|
+
}
|
|
6864
|
+
/**
|
|
6865
|
+
* Get the character after next.
|
|
6866
|
+
*
|
|
6867
|
+
* @returns {BreakerChar?}
|
|
6868
|
+
*/
|
|
6869
|
+
afterNext(offset = 1) {
|
|
6870
|
+
for (const chr of this.codePoints(this.next.len)) if (--offset <= 0) return chr;
|
|
6871
|
+
return null;
|
|
6872
|
+
}
|
|
6873
|
+
/**
|
|
6874
|
+
* Set some extra information in the state that will be passed to
|
|
6875
|
+
* the next created Break.
|
|
6876
|
+
*
|
|
6877
|
+
* @param {string} key
|
|
6878
|
+
* @param {any} value
|
|
6879
|
+
*/
|
|
6880
|
+
setProp(key, value) {
|
|
6881
|
+
if (!this.props) this.props = {};
|
|
6882
|
+
this.props[key] = value;
|
|
6883
|
+
}
|
|
6884
|
+
/**
|
|
6885
|
+
* Debug helper.
|
|
6886
|
+
*
|
|
6887
|
+
* @param {number} _depth
|
|
6888
|
+
* @param {import('util').InspectOptionsStylized} _inspectOptions
|
|
6889
|
+
* @param {(x: any) => string} inspect
|
|
6890
|
+
* @returns
|
|
6891
|
+
*/
|
|
6892
|
+
[_Symbol$for2](_depth, _inspectOptions, inspect) {
|
|
6893
|
+
let pn = `${inspect(this.prev)} => ${inspect(this.cur)} => ${inspect(this.next)}`;
|
|
6894
|
+
if (this.LB8) pn += " LB8";
|
|
6895
|
+
if (this.spaces) pn += " spaces";
|
|
6896
|
+
if (this.RI > 0) pn += ` RI: ${this.RI}`;
|
|
6897
|
+
if (this.props) pn += ` ${JSON.stringify(this.props)}`;
|
|
6898
|
+
return pn;
|
|
6899
|
+
}
|
|
6900
|
+
};
|
|
6901
|
+
//#endregion
|
|
6902
|
+
//#region node_modules/.pnpm/@cto.af+linebreak@4.0.3/node_modules/@cto.af/linebreak/lib/break.js
|
|
6903
|
+
var Break = class {
|
|
6904
|
+
/**
|
|
6905
|
+
* @param {number} position
|
|
6906
|
+
* @param {boolean} [required=false]
|
|
6907
|
+
*/
|
|
6908
|
+
constructor(position, required = false) {
|
|
6909
|
+
_defineProperty(
|
|
6910
|
+
this,
|
|
6911
|
+
/**
|
|
6912
|
+
* If the `string` option is enabled, a slice of the original input.
|
|
6913
|
+
*
|
|
6914
|
+
* @type {string=}
|
|
6915
|
+
*/
|
|
6916
|
+
"string",
|
|
6917
|
+
void 0
|
|
6918
|
+
);
|
|
6919
|
+
_defineProperty(
|
|
6920
|
+
this,
|
|
6921
|
+
/**
|
|
6922
|
+
* Extra info from plugin rules.
|
|
6923
|
+
*
|
|
6924
|
+
* @type {Record<string,any>=}
|
|
6925
|
+
*/
|
|
6926
|
+
"props",
|
|
6927
|
+
void 0
|
|
6928
|
+
);
|
|
6929
|
+
/**
|
|
6930
|
+
* Offset into input string in JS characters (16bit code units).
|
|
6931
|
+
*
|
|
6932
|
+
* @type {number}
|
|
6933
|
+
*/
|
|
6934
|
+
this.position = position;
|
|
6935
|
+
/**
|
|
6936
|
+
* Is this a required break?
|
|
6937
|
+
*
|
|
6938
|
+
* @type {boolean}
|
|
6939
|
+
*/
|
|
6940
|
+
this.required = required;
|
|
6941
|
+
}
|
|
6942
|
+
};
|
|
6943
|
+
//#endregion
|
|
6944
|
+
//#region node_modules/.pnpm/@cto.af+linebreak@4.0.3/node_modules/@cto.af/linebreak/lib/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iu/69KaxHzOYn6XenTNw1551DW/3V5X7v6c9Tfh7jPX9TrFtqOhjgPttqeW28u
|
|
6958
|
+
33192kvqs2vW7w7BeyuJcEoAAB+LCAC1xcFoAgOLVvJT0lGKVIoFANHfAiwJAAAA`);
|
|
6959
|
+
Object.fromEntries(EastAsianWidth.values.map((v, i) => [v, i]));
|
|
6960
|
+
var { values } = EastAsianWidth;
|
|
6961
|
+
//#endregion
|
|
6962
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/checkPrivateRedeclaration.js
|
|
6963
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
6964
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
6965
|
+
}
|
|
6966
|
+
//#endregion
|
|
6967
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateMethodInitSpec.js
|
|
6968
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
6969
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
6970
|
+
}
|
|
6971
|
+
//#endregion
|
|
6972
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldInitSpec.js
|
|
6973
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
6974
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
6975
|
+
}
|
|
6976
|
+
//#endregion
|
|
6977
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/assertClassBrand.js
|
|
6978
|
+
function _assertClassBrand(e, t, n) {
|
|
6979
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
6980
|
+
throw new TypeError("Private element is not present on this object");
|
|
6981
|
+
}
|
|
6982
|
+
//#endregion
|
|
6983
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldSet2.js
|
|
6984
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
6985
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
6986
|
+
}
|
|
6987
|
+
//#endregion
|
|
6988
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldGet2.js
|
|
6989
|
+
function _classPrivateFieldGet2(s, a) {
|
|
6990
|
+
return s.get(_assertClassBrand(s, a));
|
|
6991
|
+
}
|
|
6992
|
+
//#endregion
|
|
6993
|
+
//#region node_modules/.pnpm/@cto.af+linebreak@4.0.3/node_modules/@cto.af/linebreak/lib/index.js
|
|
6994
|
+
var { AK, AL, AP, AS, B2, BA, BB, BK, CB, CL, CM, CP, CR, EB, EM, EX, GL, H2, H3, HH, HL, HY, ID, IN, IS, JL, JT, JV, LF, NU, OP, NL, NS, PO, PR, RI, SP, SY, QU, VF, VI, WJ, ZW, ZWJ } = names$1;
|
|
6995
|
+
var ALHLNU = /* @__PURE__ */ new Set([
|
|
6996
|
+
AL,
|
|
6997
|
+
HL,
|
|
6998
|
+
NU
|
|
6999
|
+
]);
|
|
7000
|
+
var BKCRLFNLSPZW = /* @__PURE__ */ new Set([
|
|
7001
|
+
BK,
|
|
7002
|
+
CR,
|
|
7003
|
+
LF,
|
|
7004
|
+
NL,
|
|
7005
|
+
SP,
|
|
7006
|
+
ZW
|
|
7007
|
+
]);
|
|
7008
|
+
var IDEBEM = /* @__PURE__ */ new Set([
|
|
7009
|
+
ID,
|
|
7010
|
+
EB,
|
|
7011
|
+
EM
|
|
7012
|
+
]);
|
|
7013
|
+
var JLJVH2H3 = /* @__PURE__ */ new Set([
|
|
7014
|
+
JL,
|
|
7015
|
+
JV,
|
|
7016
|
+
H2,
|
|
7017
|
+
H3
|
|
7018
|
+
]);
|
|
7019
|
+
var JLJVJTH2H3 = /* @__PURE__ */ new Set([
|
|
7020
|
+
JL,
|
|
7021
|
+
JV,
|
|
7022
|
+
JT,
|
|
7023
|
+
H2,
|
|
7024
|
+
H3
|
|
7025
|
+
]);
|
|
7026
|
+
var JVJT = /* @__PURE__ */ new Set([JV, JT]);
|
|
7027
|
+
var SPGLWJCLQUCPEXISSYBKCRLFNLZW = /* @__PURE__ */ new Set([
|
|
7028
|
+
SP,
|
|
7029
|
+
GL,
|
|
7030
|
+
WJ,
|
|
7031
|
+
CL,
|
|
7032
|
+
QU,
|
|
7033
|
+
CP,
|
|
7034
|
+
EX,
|
|
7035
|
+
IS,
|
|
7036
|
+
SY,
|
|
7037
|
+
BK,
|
|
7038
|
+
CR,
|
|
7039
|
+
LF,
|
|
7040
|
+
NL,
|
|
7041
|
+
ZW
|
|
7042
|
+
]);
|
|
7043
|
+
var sotBKCRLFNLOPQUGLSPZW = /* @__PURE__ */ new Set([
|
|
7044
|
+
-1,
|
|
7045
|
+
BK,
|
|
7046
|
+
CR,
|
|
7047
|
+
LF,
|
|
7048
|
+
NL,
|
|
7049
|
+
OP,
|
|
7050
|
+
QU,
|
|
7051
|
+
GL,
|
|
7052
|
+
SP,
|
|
7053
|
+
ZW
|
|
7054
|
+
]);
|
|
7055
|
+
/**
|
|
7056
|
+
* @template T
|
|
7057
|
+
* @typedef {ValuesWithKeys<T, keyof T>} EnumValues
|
|
7058
|
+
*/
|
|
7059
|
+
/**
|
|
7060
|
+
* @template T
|
|
7061
|
+
* @template {keyof T} K
|
|
7062
|
+
* @typedef {T[K]} ValuesWithKeys
|
|
7063
|
+
*/
|
|
7064
|
+
/**
|
|
7065
|
+
* This rule has no opinion.
|
|
7066
|
+
*/
|
|
7067
|
+
var PASS = Symbol("PASS");
|
|
7068
|
+
/**
|
|
7069
|
+
* This rule asserts that there must not be a break after the current
|
|
7070
|
+
* code point.
|
|
7071
|
+
*/
|
|
7072
|
+
var NO_BREAK = Symbol("NO_BREAK");
|
|
7073
|
+
/**
|
|
7074
|
+
* This rule asserts that there may be a break after the current code point.
|
|
7075
|
+
*/
|
|
7076
|
+
var MAY_BREAK = Symbol("MAY_BREAK");
|
|
7077
|
+
/**
|
|
7078
|
+
* This rule asserts that there must be a line break after the current code point.
|
|
7079
|
+
*/
|
|
7080
|
+
var MUST_BREAK = Symbol("MUST_BREAK");
|
|
7081
|
+
/**
|
|
7082
|
+
* @typedef {EnumValues<typeof RuleResults>} RuleResultsEnum
|
|
7083
|
+
*/
|
|
7084
|
+
/**
|
|
7085
|
+
* A rule that impacts linebreaking. Looking ahead and behind one code point
|
|
7086
|
+
* is fast, using `state.prev` and `state.next` respectively. Looking ahead
|
|
7087
|
+
* more code points is possible with `*BreakerState.codePoints()`, but be
|
|
7088
|
+
* careful of causing ReDos vulnerabilities.
|
|
7089
|
+
*
|
|
7090
|
+
* @callback BreakRule
|
|
7091
|
+
* @param {BreakerState} state
|
|
7092
|
+
* @returns {RuleResultsEnum}
|
|
7093
|
+
*/
|
|
7094
|
+
/**
|
|
7095
|
+
* LB2: Never break at the start of text.
|
|
7096
|
+
*
|
|
7097
|
+
* @type {BreakRule}
|
|
7098
|
+
*/
|
|
7099
|
+
function LB02(state) {
|
|
7100
|
+
if (state.cur.cls === -1 && state.next.cls !== -2) return NO_BREAK;
|
|
7101
|
+
return PASS;
|
|
7102
|
+
}
|
|
7103
|
+
/**
|
|
7104
|
+
* LB3 Always break at the end of text.
|
|
7105
|
+
*
|
|
7106
|
+
* @type {BreakRule}
|
|
7107
|
+
*/
|
|
7108
|
+
function LB03(state) {
|
|
7109
|
+
if (state.next.cls === -2 && (state.cur.len === 0 || state.cur.len !== state.prevChunk)) return MUST_BREAK;
|
|
7110
|
+
return PASS;
|
|
7111
|
+
}
|
|
7112
|
+
/**
|
|
7113
|
+
* LB4: Always break after hard line breaks.
|
|
7114
|
+
*
|
|
7115
|
+
* @type {BreakRule}
|
|
7116
|
+
*/
|
|
7117
|
+
function LB04(state) {
|
|
7118
|
+
if (state.cur.cls === BK) return MUST_BREAK;
|
|
7119
|
+
return PASS;
|
|
7120
|
+
}
|
|
7121
|
+
/**
|
|
7122
|
+
* LB5: Treat CR followed by LF, as well as CR, LF, and NL as hard line
|
|
7123
|
+
* breaks.
|
|
7124
|
+
*
|
|
7125
|
+
* @type {BreakRule}
|
|
7126
|
+
*/
|
|
7127
|
+
function LB05(state) {
|
|
7128
|
+
switch (state.cur.cls) {
|
|
7129
|
+
case CR:
|
|
7130
|
+
if (state.next.cls === LF) return NO_BREAK;
|
|
7131
|
+
return MUST_BREAK;
|
|
7132
|
+
case LF:
|
|
7133
|
+
case NL: return MUST_BREAK;
|
|
7134
|
+
}
|
|
7135
|
+
return PASS;
|
|
7136
|
+
}
|
|
7137
|
+
/**
|
|
7138
|
+
* LB6: Do not break before hard line breaks.
|
|
7139
|
+
*
|
|
7140
|
+
* @type {BreakRule}
|
|
7141
|
+
*/
|
|
7142
|
+
function LB06(state) {
|
|
7143
|
+
switch (state.next.cls) {
|
|
7144
|
+
case BK:
|
|
7145
|
+
case CR:
|
|
7146
|
+
case LF:
|
|
7147
|
+
case NL: return NO_BREAK;
|
|
7148
|
+
}
|
|
7149
|
+
return PASS;
|
|
7150
|
+
}
|
|
7151
|
+
/**
|
|
7152
|
+
* The end of a run of spaces, for rules that have "Do not break within
|
|
7153
|
+
* ...even with intervening spaces", such as LB15.
|
|
7154
|
+
*
|
|
7155
|
+
* @type {BreakRule}
|
|
7156
|
+
*/
|
|
7157
|
+
function LBspacesStop(state) {
|
|
7158
|
+
if (state.cur.cls !== RI) state.RI = 0;
|
|
7159
|
+
if (state.spaces) {
|
|
7160
|
+
if (state.next.cls !== SP) state.spaces = false;
|
|
7161
|
+
return NO_BREAK;
|
|
7162
|
+
}
|
|
7163
|
+
return PASS;
|
|
7164
|
+
}
|
|
7165
|
+
/**
|
|
7166
|
+
* LB7: Do not break before spaces or zero width space.
|
|
7167
|
+
*
|
|
7168
|
+
* @type {BreakRule}
|
|
7169
|
+
*/
|
|
7170
|
+
function LB07(state) {
|
|
7171
|
+
if (state.next.cls === ZW) return NO_BREAK;
|
|
7172
|
+
if (state.next.cls === SP) switch (state.cur.cls) {
|
|
7173
|
+
case ZW:
|
|
7174
|
+
case OP:
|
|
7175
|
+
case QU:
|
|
7176
|
+
case CL:
|
|
7177
|
+
case CP:
|
|
7178
|
+
case B2: break;
|
|
7179
|
+
default: return NO_BREAK;
|
|
7180
|
+
}
|
|
7181
|
+
return PASS;
|
|
7182
|
+
}
|
|
7183
|
+
/**
|
|
7184
|
+
* LB8: Break before any character following a zero-width space, even if one or
|
|
7185
|
+
* more spaces intervene.
|
|
7186
|
+
*
|
|
7187
|
+
* @type {BreakRule}
|
|
7188
|
+
*/
|
|
7189
|
+
function LB08(state) {
|
|
7190
|
+
if (state.LB8) {
|
|
7191
|
+
state.LB8 = false;
|
|
7192
|
+
return MAY_BREAK;
|
|
7193
|
+
} else if (state.cur.cls === ZW) {
|
|
7194
|
+
if (state.next.cls === SP) {
|
|
7195
|
+
state.LB8 = true;
|
|
7196
|
+
return NO_BREAK;
|
|
7197
|
+
}
|
|
7198
|
+
return MAY_BREAK;
|
|
7199
|
+
}
|
|
7200
|
+
return PASS;
|
|
7201
|
+
}
|
|
7202
|
+
/**
|
|
7203
|
+
* LB8a: Do not break after a zero width joiner.
|
|
7204
|
+
*
|
|
7205
|
+
* @type {BreakRule}
|
|
7206
|
+
*/
|
|
7207
|
+
function LB08a(state) {
|
|
7208
|
+
if (state.cur.cls === ZWJ) return NO_BREAK;
|
|
7209
|
+
return PASS;
|
|
7210
|
+
}
|
|
7211
|
+
/**
|
|
7212
|
+
* LB9: Do not break a combining character sequence; treat it as if it has the
|
|
7213
|
+
* line breaking class of the base character in all of the following rules.
|
|
7214
|
+
* Treat ZWJ as if it were CM.
|
|
7215
|
+
*
|
|
7216
|
+
* @type {BreakRule}
|
|
7217
|
+
*/
|
|
7218
|
+
function LB09(state) {
|
|
7219
|
+
if (!BKCRLFNLSPZW.has(state.cur.cls) && (state.next.cls === CM || state.next.cls === ZWJ)) {
|
|
7220
|
+
state.next.ignored = true;
|
|
7221
|
+
return NO_BREAK;
|
|
7222
|
+
}
|
|
7223
|
+
return PASS;
|
|
7224
|
+
}
|
|
7225
|
+
/**
|
|
7226
|
+
* LB10: Treat any remaining combining mark or ZWJ as AL.
|
|
7227
|
+
*
|
|
7228
|
+
* @type {BreakRule}
|
|
7229
|
+
*/
|
|
7230
|
+
function LB10(state) {
|
|
7231
|
+
if (state.cur.cls === CM) state.cur.cls = AL;
|
|
7232
|
+
if (state.next.cls === CM) state.next.cls = AL;
|
|
7233
|
+
return PASS;
|
|
7234
|
+
}
|
|
7235
|
+
/**
|
|
7236
|
+
* LB11: Do not break before or after Word joiner and related characters.
|
|
7237
|
+
*
|
|
7238
|
+
* @type {BreakRule}
|
|
7239
|
+
*/
|
|
7240
|
+
function LB11(state) {
|
|
7241
|
+
if (state.next.cls === WJ || state.cur.cls === WJ) return NO_BREAK;
|
|
7242
|
+
return PASS;
|
|
7243
|
+
}
|
|
7244
|
+
/**
|
|
7245
|
+
* LB12: Do not break after NBSP and related characters.
|
|
7246
|
+
*
|
|
7247
|
+
* @type {BreakRule}
|
|
7248
|
+
*/
|
|
7249
|
+
function LB12(state) {
|
|
7250
|
+
if (state.cur.cls === GL) return NO_BREAK;
|
|
7251
|
+
return PASS;
|
|
7252
|
+
}
|
|
7253
|
+
/**
|
|
7254
|
+
* LB12a: Do not break before NBSP and related characters, except after spaces
|
|
7255
|
+
* and hyphens.
|
|
7256
|
+
*
|
|
7257
|
+
* @type {BreakRule}
|
|
7258
|
+
*/
|
|
7259
|
+
function LB12a(state) {
|
|
7260
|
+
if (state.next.cls === GL) switch (state.cur.cls) {
|
|
7261
|
+
case SP:
|
|
7262
|
+
case BA:
|
|
7263
|
+
case HY:
|
|
7264
|
+
case HH: return PASS;
|
|
7265
|
+
default: return NO_BREAK;
|
|
7266
|
+
}
|
|
7267
|
+
return PASS;
|
|
7268
|
+
}
|
|
7269
|
+
/**
|
|
7270
|
+
* LB13: Do not break before ‘]’ or ‘!’ or ‘;’ or ‘/’, even after spaces.
|
|
7271
|
+
*
|
|
7272
|
+
* @type {BreakRule}
|
|
7273
|
+
*/
|
|
7274
|
+
function LB13(state) {
|
|
7275
|
+
switch (state.next.cls) {
|
|
7276
|
+
case CL:
|
|
7277
|
+
case CP:
|
|
7278
|
+
case EX:
|
|
7279
|
+
case SY: return NO_BREAK;
|
|
7280
|
+
}
|
|
7281
|
+
return PASS;
|
|
7282
|
+
}
|
|
7283
|
+
/**
|
|
7284
|
+
* LB14: Do not break after ‘[’, even after spaces.
|
|
7285
|
+
*
|
|
7286
|
+
* @type {BreakRule}
|
|
7287
|
+
*/
|
|
7288
|
+
function LB14(state) {
|
|
7289
|
+
if (state.cur.cls === OP) {
|
|
7290
|
+
if (state.next.cls === SP) state.spaces = true;
|
|
7291
|
+
return NO_BREAK;
|
|
7292
|
+
}
|
|
7293
|
+
return PASS;
|
|
7294
|
+
}
|
|
7295
|
+
/**
|
|
7296
|
+
* LB15a: Do not break after an unresolved initial punctuation that lies at
|
|
7297
|
+
* the start of the line, after a space, after opening punctuation, or after
|
|
7298
|
+
* an unresolved quotation mark, even after spaces.
|
|
7299
|
+
*
|
|
7300
|
+
* @type {BreakRule}
|
|
7301
|
+
*/
|
|
7302
|
+
function LB15a(state) {
|
|
7303
|
+
if (sotBKCRLFNLOPQUGLSPZW.has(state.prev.cls) && /^\p{Pi}$/u.test(state.cur.char) && state.cur.cls === QU) {
|
|
7304
|
+
state.spaces = true;
|
|
7305
|
+
return NO_BREAK;
|
|
7306
|
+
}
|
|
7307
|
+
return PASS;
|
|
7308
|
+
}
|
|
7309
|
+
/**
|
|
7310
|
+
* LB15b: Do not break before an unresolved final punctuation that lies at the
|
|
7311
|
+
* end of the line, before a space, before a prohibited break, or before an
|
|
7312
|
+
* unresolved quotation mark, even after spaces.
|
|
7313
|
+
*
|
|
7314
|
+
* @type {BreakRule}
|
|
7315
|
+
*/
|
|
7316
|
+
function LB15b(state) {
|
|
7317
|
+
if (/^\p{gc=Pf}$/u.test(state.next.char) && state.next.cls === QU) {
|
|
7318
|
+
const after = state.afterNext();
|
|
7319
|
+
if (!after) return NO_BREAK;
|
|
7320
|
+
if (SPGLWJCLQUCPEXISSYBKCRLFNLZW.has(after.cls)) return NO_BREAK;
|
|
7321
|
+
}
|
|
7322
|
+
return PASS;
|
|
7323
|
+
}
|
|
7324
|
+
/**
|
|
7325
|
+
* LB15c: Break before a decimal mark that follows a space, for instance, in
|
|
7326
|
+
* ‘subtract .5’.
|
|
7327
|
+
*
|
|
7328
|
+
* @type {BreakRule}
|
|
7329
|
+
*/
|
|
7330
|
+
function LB15c(state) {
|
|
7331
|
+
if (state.cur.cls === SP && state.next.cls === IS) {
|
|
7332
|
+
if (state.afterNext()?.cls === NU) return MAY_BREAK;
|
|
7333
|
+
}
|
|
7334
|
+
return PASS;
|
|
7335
|
+
}
|
|
7336
|
+
/**
|
|
7337
|
+
* LB15d: Otherwise, do not break before ‘;’, ‘,’, or ‘.’, even after spaces
|
|
7338
|
+
*
|
|
7339
|
+
* @type {BreakRule}
|
|
7340
|
+
*/
|
|
7341
|
+
function LB15d(state) {
|
|
7342
|
+
if (state.next.cls === IS) return NO_BREAK;
|
|
7343
|
+
return PASS;
|
|
7344
|
+
}
|
|
7345
|
+
/**
|
|
7346
|
+
* LB16: Do not break between closing punctuation and a nonstarter (lb=NS),
|
|
7347
|
+
* even with intervening spaces.
|
|
7348
|
+
*
|
|
7349
|
+
* @type {BreakRule}
|
|
7350
|
+
*/
|
|
7351
|
+
function LB16(state) {
|
|
7352
|
+
if (state.cur.cls === CL || state.cur.cls === CP) {
|
|
7353
|
+
if (state.classAfterSpaces(state.cur.len) === NS) {
|
|
7354
|
+
if (state.next.cls === SP) state.spaces = true;
|
|
7355
|
+
return NO_BREAK;
|
|
7356
|
+
}
|
|
7357
|
+
if (state.next.cls === SP) return NO_BREAK;
|
|
7358
|
+
}
|
|
7359
|
+
return PASS;
|
|
7360
|
+
}
|
|
7361
|
+
/**
|
|
7362
|
+
* LB17: Do not break within ‘——’, even with intervening spaces.
|
|
7363
|
+
*
|
|
7364
|
+
* @type {BreakRule}
|
|
7365
|
+
*/
|
|
7366
|
+
function LB17(state) {
|
|
7367
|
+
if (state.cur.cls === B2) {
|
|
7368
|
+
if (state.classAfterSpaces(state.cur.len) === B2) {
|
|
7369
|
+
if (state.next.cls !== SP) return NO_BREAK;
|
|
7370
|
+
state.spaces = true;
|
|
7371
|
+
return NO_BREAK;
|
|
7372
|
+
} else if (state.next.cls === SP) return NO_BREAK;
|
|
7373
|
+
}
|
|
7374
|
+
return PASS;
|
|
7375
|
+
}
|
|
7376
|
+
/**
|
|
7377
|
+
* LB18: Break after spaces.
|
|
7378
|
+
*
|
|
7379
|
+
* @type {BreakRule}
|
|
7380
|
+
*/
|
|
7381
|
+
function LB18(state) {
|
|
7382
|
+
if (state.cur.cls === SP) return MAY_BREAK;
|
|
7383
|
+
return PASS;
|
|
7384
|
+
}
|
|
7385
|
+
/**
|
|
7386
|
+
* LB19: Do not break before non-initial unresolved quotation marks, such as ‘
|
|
7387
|
+
* ” ’ or ‘ " ’, nor after non-final unresolved quotation marks, such as ‘ “ ’
|
|
7388
|
+
* or ‘ " ’.
|
|
7389
|
+
*
|
|
7390
|
+
* @type {BreakRule}
|
|
7391
|
+
*/
|
|
7392
|
+
function LB19(state) {
|
|
7393
|
+
if (state.next.cls === QU && !/^\p{Pi}$/u.test(state.next.char)) return NO_BREAK;
|
|
7394
|
+
if (state.cur.cls === QU && !/^\p{Pf}$/u.test(state.cur.char)) return NO_BREAK;
|
|
7395
|
+
return PASS;
|
|
7396
|
+
}
|
|
7397
|
+
/**
|
|
7398
|
+
* LB19a: Unless surrounded by East Asian characters, do not break either side
|
|
7399
|
+
* of any unresolved quotation marks.
|
|
7400
|
+
*
|
|
7401
|
+
* @type {BreakRule}
|
|
7402
|
+
*/
|
|
7403
|
+
function LB19a(state) {
|
|
7404
|
+
if (!EastAsianWidth.get(state.cur.cp) && state.next.cls === QU) return NO_BREAK;
|
|
7405
|
+
if (state.next.cls === QU) {
|
|
7406
|
+
const after = state.afterNext();
|
|
7407
|
+
if (!after || !EastAsianWidth.get(after.cp)) return NO_BREAK;
|
|
7408
|
+
}
|
|
7409
|
+
if (state.cur.cls === QU && !EastAsianWidth.get(state.next.cp)) return NO_BREAK;
|
|
7410
|
+
if ((state.prev.cls === -1 || !EastAsianWidth.get(state.prev.cp)) && state.cur.cls === QU) return NO_BREAK;
|
|
7411
|
+
return PASS;
|
|
7412
|
+
}
|
|
7413
|
+
/**
|
|
7414
|
+
* LB20: Break before and after unresolved CB.
|
|
7415
|
+
*
|
|
7416
|
+
* @type {BreakRule}
|
|
7417
|
+
*/
|
|
7418
|
+
function LB20(state) {
|
|
7419
|
+
if (state.cur.cls === CB || state.next.cls === CB) return MAY_BREAK;
|
|
7420
|
+
return PASS;
|
|
7421
|
+
}
|
|
7422
|
+
var sotBKCRLFNLSPZWCBGL = /* @__PURE__ */ new Set([
|
|
7423
|
+
-1,
|
|
7424
|
+
BK,
|
|
7425
|
+
CR,
|
|
7426
|
+
LF,
|
|
7427
|
+
NL,
|
|
7428
|
+
SP,
|
|
7429
|
+
ZW,
|
|
7430
|
+
CB,
|
|
7431
|
+
GL
|
|
7432
|
+
]);
|
|
7433
|
+
/**
|
|
7434
|
+
* LB20a: Do not break after a word-initial hyphen.
|
|
7435
|
+
*
|
|
7436
|
+
* @type {BreakRule}
|
|
7437
|
+
*/
|
|
7438
|
+
function LB20a(state) {
|
|
7439
|
+
if (sotBKCRLFNLSPZWCBGL.has(state.prev.cls) && (state.cur.cls === HY || state.cur.cls === HH) && (state.next.cls === AL || state.next.cls === HL)) return NO_BREAK;
|
|
7440
|
+
return PASS;
|
|
7441
|
+
}
|
|
7442
|
+
/**
|
|
7443
|
+
* LB21: Do not break before hyphen-minus, other hyphens, fixed-width spaces,
|
|
7444
|
+
* small kana, and other non-starters, or after acute accents.
|
|
7445
|
+
*
|
|
7446
|
+
* @type {BreakRule}
|
|
7447
|
+
*/
|
|
7448
|
+
function LB21(state) {
|
|
7449
|
+
if (state.cur.cls === BB) return NO_BREAK;
|
|
7450
|
+
switch (state.next.cls) {
|
|
7451
|
+
case BA:
|
|
7452
|
+
case HH:
|
|
7453
|
+
case HY:
|
|
7454
|
+
case NS: return NO_BREAK;
|
|
7455
|
+
}
|
|
7456
|
+
return PASS;
|
|
7457
|
+
}
|
|
7458
|
+
/**
|
|
7459
|
+
* LB21a: Do not break after the hyphen in Hebrew + Hyphen + non-Hebrew.
|
|
7460
|
+
*
|
|
7461
|
+
* @type {BreakRule}
|
|
7462
|
+
*/
|
|
7463
|
+
function LB21a(state) {
|
|
7464
|
+
if (state.prev.cls === HL && (state.cur.cls === HY || state.cur.cls === HH) && state.next.cls !== HL) return NO_BREAK;
|
|
7465
|
+
return PASS;
|
|
7466
|
+
}
|
|
7467
|
+
/**
|
|
7468
|
+
* LB21b: Don’t break between Solidus and Hebrew letters.
|
|
7469
|
+
*
|
|
7470
|
+
* @type {BreakRule}
|
|
7471
|
+
*/
|
|
7472
|
+
function LB21b(state) {
|
|
7473
|
+
if (state.cur.cls === SY && state.next.cls === HL) return NO_BREAK;
|
|
7474
|
+
return PASS;
|
|
7475
|
+
}
|
|
7476
|
+
/**
|
|
7477
|
+
* LB22: Do not break before ellipses.
|
|
7478
|
+
*
|
|
7479
|
+
* @type {BreakRule}
|
|
7480
|
+
*/
|
|
7481
|
+
function LB22(state) {
|
|
7482
|
+
if (state.next.cls === IN) return NO_BREAK;
|
|
7483
|
+
return PASS;
|
|
7484
|
+
}
|
|
7485
|
+
/**
|
|
7486
|
+
* LB23: Do not break between digits and letters.
|
|
7487
|
+
*
|
|
7488
|
+
* @type {BreakRule}
|
|
7489
|
+
*/
|
|
7490
|
+
function LB23(state) {
|
|
7491
|
+
switch (state.cur.cls) {
|
|
7492
|
+
case AL:
|
|
7493
|
+
case HL:
|
|
7494
|
+
if (state.next.cls === NU) return NO_BREAK;
|
|
7495
|
+
break;
|
|
7496
|
+
case NU: if (state.next.cls === AL || state.next.cls === HL) return NO_BREAK;
|
|
7497
|
+
}
|
|
7498
|
+
return PASS;
|
|
7499
|
+
}
|
|
7500
|
+
/**
|
|
7501
|
+
* LB23a: Do not break between numeric prefixes and ideographs, or between
|
|
7502
|
+
* ideographs and numeric postfixes.
|
|
7503
|
+
*
|
|
7504
|
+
* @type {BreakRule}
|
|
7505
|
+
*/
|
|
7506
|
+
function LB23a(state) {
|
|
7507
|
+
if (state.cur.cls === PR && IDEBEM.has(state.next.cls)) return NO_BREAK;
|
|
7508
|
+
if (state.next.cls === PO && IDEBEM.has(state.cur.cls)) return NO_BREAK;
|
|
7509
|
+
return PASS;
|
|
7510
|
+
}
|
|
7511
|
+
/**
|
|
7512
|
+
* LB24: Do not break between numeric prefix/postfix and letters, or between
|
|
7513
|
+
* letters and prefix/postfix.
|
|
7514
|
+
*
|
|
7515
|
+
* @type {BreakRule}
|
|
7516
|
+
*/
|
|
7517
|
+
function LB24(state) {
|
|
7518
|
+
if ((state.cur.cls === PR || state.cur.cls === PO) && (state.next.cls === AL || state.next.cls === HL)) return NO_BREAK;
|
|
7519
|
+
if ((state.cur.cls === AL || state.cur.cls === HL) && (state.next.cls === PR || state.next.cls === PO)) return NO_BREAK;
|
|
7520
|
+
return PASS;
|
|
7521
|
+
}
|
|
7522
|
+
var POPR = /* @__PURE__ */ new Set([PO, PR]);
|
|
7523
|
+
var CLCP = /* @__PURE__ */ new Set([CL, CP]);
|
|
7524
|
+
/**
|
|
7525
|
+
* LB25: Do not break numbers.
|
|
7526
|
+
* Approach: Find the end of a matching run, then no-break everything as we go
|
|
7527
|
+
* past it.
|
|
7528
|
+
*
|
|
7529
|
+
* @type {BreakRule}
|
|
7530
|
+
*/
|
|
7531
|
+
function LB25(state) {
|
|
7532
|
+
let syIs = null;
|
|
7533
|
+
if (POPR.has(state.next.cls)) {
|
|
7534
|
+
if (CLCP.has(state.cur.cls)) syIs = state.prev.len;
|
|
7535
|
+
else syIs = state.cur.len;
|
|
7536
|
+
} else if (state.next.cls === NU) syIs = state.cur.len;
|
|
7537
|
+
if (syIs !== null) SyIsLoop: for (const { cls } of state.codePoints(syIs, false)) switch (cls) {
|
|
7538
|
+
case SY:
|
|
7539
|
+
case IS: continue;
|
|
7540
|
+
case NU: return NO_BREAK;
|
|
7541
|
+
default: break SyIsLoop;
|
|
7542
|
+
}
|
|
7543
|
+
if (state.cur.cls === PO || state.cur.cls === PR) {
|
|
7544
|
+
if (state.next.cls === OP) {
|
|
7545
|
+
const after = state.afterNext();
|
|
7546
|
+
if (after) {
|
|
7547
|
+
if (after.cls === NU) return NO_BREAK;
|
|
7548
|
+
else if (after.cls === IS) {
|
|
7549
|
+
if (state.afterNext(2)?.cls === NU) return NO_BREAK;
|
|
7550
|
+
}
|
|
7551
|
+
}
|
|
7552
|
+
} else if (state.next.cls === NU) return NO_BREAK;
|
|
7553
|
+
}
|
|
7554
|
+
if (state.cur.cls === HY && state.next.cls === NU) return NO_BREAK;
|
|
7555
|
+
if (state.cur.cls === IS && state.next.cls === NU) return NO_BREAK;
|
|
7556
|
+
return PASS;
|
|
7557
|
+
}
|
|
7558
|
+
/**
|
|
7559
|
+
* LB26: Do not break a Korean syllable.
|
|
7560
|
+
*
|
|
7561
|
+
* @type {BreakRule}
|
|
7562
|
+
*/
|
|
7563
|
+
function LB26(state) {
|
|
7564
|
+
switch (state.cur.cls) {
|
|
7565
|
+
case JL:
|
|
7566
|
+
if (JLJVH2H3.has(state.next.cls)) return NO_BREAK;
|
|
7567
|
+
break;
|
|
7568
|
+
case JV:
|
|
7569
|
+
case H2:
|
|
7570
|
+
if (JVJT.has(state.next.cls)) return NO_BREAK;
|
|
7571
|
+
break;
|
|
7572
|
+
case JT:
|
|
7573
|
+
case H3: if (state.next.cls === JT) return NO_BREAK;
|
|
7574
|
+
}
|
|
7575
|
+
return PASS;
|
|
7576
|
+
}
|
|
7577
|
+
/**
|
|
7578
|
+
* LB27: Treat a Korean Syllable Block the same as ID.
|
|
7579
|
+
*
|
|
7580
|
+
* @type {BreakRule}
|
|
7581
|
+
*/
|
|
7582
|
+
function LB27(state) {
|
|
7583
|
+
switch (state.cur.cls) {
|
|
7584
|
+
case JL:
|
|
7585
|
+
case JV:
|
|
7586
|
+
case JT:
|
|
7587
|
+
case H2:
|
|
7588
|
+
case H3:
|
|
7589
|
+
if (state.next.cls === PO) return NO_BREAK;
|
|
7590
|
+
break;
|
|
7591
|
+
case PR: if (JLJVJTH2H3.has(state.next.cls)) return NO_BREAK;
|
|
7592
|
+
}
|
|
7593
|
+
return PASS;
|
|
7594
|
+
}
|
|
7595
|
+
/**
|
|
7596
|
+
* LB28 Do not break between alphabetics (“at”).
|
|
7597
|
+
*
|
|
7598
|
+
* @type {BreakRule}
|
|
7599
|
+
*/
|
|
7600
|
+
function LB28(state) {
|
|
7601
|
+
if ((state.cur.cls === AL || state.cur.cls === HL) && (state.next.cls === AL || state.next.cls === HL)) return NO_BREAK;
|
|
7602
|
+
return PASS;
|
|
7603
|
+
}
|
|
7604
|
+
/**
|
|
7605
|
+
* LB28a: Do not break inside the orthographic syllables of Brahmic scripts.
|
|
7606
|
+
*
|
|
7607
|
+
* @type {BreakRule}
|
|
7608
|
+
*/
|
|
7609
|
+
function LB28a(state) {
|
|
7610
|
+
const { prev, cur, next } = state;
|
|
7611
|
+
const dotCircle = "◌";
|
|
7612
|
+
/**
|
|
7613
|
+
* AK | ◌ | AS
|
|
7614
|
+
*
|
|
7615
|
+
* @param {import('./state.js').BreakerChar} chr Check one char
|
|
7616
|
+
* @returns true if char matches
|
|
7617
|
+
*/
|
|
7618
|
+
function akCas(chr) {
|
|
7619
|
+
return chr.cls === AK || chr.char === dotCircle || chr.cls === AS;
|
|
7620
|
+
}
|
|
7621
|
+
if (cur.cls === AP && akCas(next)) return NO_BREAK;
|
|
7622
|
+
if (akCas(cur) && (next.cls === VF || next.cls === VI)) return NO_BREAK;
|
|
7623
|
+
if (akCas(prev) && cur.cls === VI && (next.cls === AK || next.char === dotCircle)) return NO_BREAK;
|
|
7624
|
+
if (akCas(cur) && akCas(next) && state.afterNext()?.cls === VF) return NO_BREAK;
|
|
7625
|
+
return PASS;
|
|
7626
|
+
}
|
|
7627
|
+
/**
|
|
7628
|
+
* LB29: Do not break between numeric punctuation and alphabetics (“e.g.”).
|
|
7629
|
+
*
|
|
7630
|
+
* @type {BreakRule}
|
|
7631
|
+
*/
|
|
7632
|
+
function LB29(state) {
|
|
7633
|
+
if (state.cur.cls === IS && (state.next.cls === AL || state.next.cls === HL)) return NO_BREAK;
|
|
7634
|
+
return PASS;
|
|
7635
|
+
}
|
|
7636
|
+
/**
|
|
7637
|
+
* LB30: Do not break between letters, numbers, or ordinary symbols and
|
|
7638
|
+
* opening or closing parentheses.
|
|
7639
|
+
*
|
|
7640
|
+
* @type {BreakRule}
|
|
7641
|
+
*/
|
|
7642
|
+
function LB30(state) {
|
|
7643
|
+
switch (state.cur.cls) {
|
|
7644
|
+
case AL:
|
|
7645
|
+
case HL:
|
|
7646
|
+
case NU:
|
|
7647
|
+
if (state.next.cls === OP && !EastAsianWidth.get(state.next.cp)) return NO_BREAK;
|
|
7648
|
+
break;
|
|
7649
|
+
case CP: if (!EastAsianWidth.get(state.cur.cp) && ALHLNU.has(state.next.cls)) return NO_BREAK;
|
|
7650
|
+
}
|
|
7651
|
+
return PASS;
|
|
7652
|
+
}
|
|
7653
|
+
/**
|
|
7654
|
+
* LB30a: Break between two regional indicator symbols if and only if there
|
|
7655
|
+
* are an even number of regional indicators preceding the position of the
|
|
7656
|
+
* break.
|
|
7657
|
+
*
|
|
7658
|
+
* @type {BreakRule}
|
|
7659
|
+
*/
|
|
7660
|
+
function LB30a(state) {
|
|
7661
|
+
if (state.cur.cls === RI) {
|
|
7662
|
+
if (state.next.cls === RI) {
|
|
7663
|
+
if (++state.RI % 2 !== 0) return NO_BREAK;
|
|
7664
|
+
}
|
|
7665
|
+
} else state.RI = 0;
|
|
7666
|
+
return PASS;
|
|
7667
|
+
}
|
|
7668
|
+
/**
|
|
7669
|
+
* LB30b: Do not break between an emoji base (or potential emoji) and an emoji
|
|
7670
|
+
* modifier.
|
|
7671
|
+
*
|
|
7672
|
+
* @type {BreakRule}
|
|
7673
|
+
*/
|
|
7674
|
+
function LB30b(state) {
|
|
7675
|
+
if (state.cur.cls === EB && state.next.cls === EM) return NO_BREAK;
|
|
7676
|
+
if (state.next.cls === EM && /^\p{ExtPict}$/u.test(state.cur.char) && /^\p{gc=Cn}$/u.test(state.cur.char)) return NO_BREAK;
|
|
7677
|
+
return PASS;
|
|
7678
|
+
}
|
|
7679
|
+
/**
|
|
7680
|
+
* LB31: Break everywhere else.
|
|
7681
|
+
*
|
|
7682
|
+
* @type {BreakRule}
|
|
7683
|
+
*/
|
|
7684
|
+
function LB31() {
|
|
7685
|
+
return MAY_BREAK;
|
|
7686
|
+
}
|
|
7687
|
+
/**
|
|
7688
|
+
* @type {BreakRule[]}
|
|
7689
|
+
* @private
|
|
7690
|
+
*/
|
|
7691
|
+
var rules = [
|
|
7692
|
+
LB02,
|
|
7693
|
+
LB03,
|
|
7694
|
+
LB04,
|
|
7695
|
+
LB05,
|
|
7696
|
+
LB06,
|
|
7697
|
+
LBspacesStop,
|
|
7698
|
+
LB07,
|
|
7699
|
+
LB08,
|
|
7700
|
+
LB08a,
|
|
7701
|
+
LB09,
|
|
7702
|
+
LB10,
|
|
7703
|
+
LB11,
|
|
7704
|
+
LB12,
|
|
7705
|
+
LB12a,
|
|
7706
|
+
LB13,
|
|
7707
|
+
LB14,
|
|
7708
|
+
LB15a,
|
|
7709
|
+
LB15b,
|
|
7710
|
+
LB15c,
|
|
7711
|
+
LB15d,
|
|
7712
|
+
LB16,
|
|
7713
|
+
LB17,
|
|
7714
|
+
LB18,
|
|
7715
|
+
LB19,
|
|
7716
|
+
LB19a,
|
|
7717
|
+
LB20,
|
|
7718
|
+
LB20a,
|
|
7719
|
+
LB21a,
|
|
7720
|
+
LB21,
|
|
7721
|
+
LB21b,
|
|
7722
|
+
LB22,
|
|
7723
|
+
LB23,
|
|
7724
|
+
LB23a,
|
|
7725
|
+
LB24,
|
|
7726
|
+
LB25,
|
|
7727
|
+
LB26,
|
|
7728
|
+
LB27,
|
|
7729
|
+
LB28,
|
|
7730
|
+
LB28a,
|
|
7731
|
+
LB29,
|
|
7732
|
+
LB30,
|
|
7733
|
+
LB30a,
|
|
7734
|
+
LB30b,
|
|
7735
|
+
LB31
|
|
7736
|
+
];
|
|
7737
|
+
var _opts = /* @__PURE__ */ new WeakMap();
|
|
7738
|
+
var _Rules_brand = /* @__PURE__ */ new WeakSet();
|
|
7739
|
+
/**
|
|
7740
|
+
* Options for how rules are applied.
|
|
7741
|
+
*
|
|
7742
|
+
* @typedef {object} RulesOptions
|
|
7743
|
+
* @prop {boolean} [string=false] Extract strings from input, rather than just
|
|
7744
|
+
* returning char offsets.
|
|
7745
|
+
* @prop {boolean} [verbose=false] Turn on some verbose logging that is
|
|
7746
|
+
* useful for debug.
|
|
7747
|
+
*/
|
|
7748
|
+
var Rules = class {
|
|
7749
|
+
/**
|
|
7750
|
+
*
|
|
7751
|
+
* @param {RulesOptions} opts
|
|
7752
|
+
*/
|
|
7753
|
+
constructor(opts = {}) {
|
|
7754
|
+
_classPrivateMethodInitSpec(this, _Rules_brand);
|
|
7755
|
+
_classPrivateFieldInitSpec(this, _opts, void 0);
|
|
7756
|
+
/**
|
|
7757
|
+
* @type {Required<RulesOptions>}
|
|
7758
|
+
*/
|
|
7759
|
+
_classPrivateFieldSet2(_opts, this, {
|
|
7760
|
+
string: false,
|
|
7761
|
+
example7: false,
|
|
7762
|
+
verbose: false,
|
|
7763
|
+
...opts
|
|
7764
|
+
});
|
|
7765
|
+
/**
|
|
7766
|
+
* Copy of rules, safe to tweak.
|
|
7767
|
+
*
|
|
7768
|
+
* @type {BreakRule[]}
|
|
7769
|
+
*/
|
|
7770
|
+
this.rules = [...rules];
|
|
7771
|
+
if (_classPrivateFieldGet2(_opts, this).example7) throw new Error("'example7' flag deprecated");
|
|
7772
|
+
if (_classPrivateFieldGet2(_opts, this).verbose) this.rules.unshift((state) => {
|
|
7773
|
+
console.log(state.cur.len, state);
|
|
7774
|
+
return PASS;
|
|
7775
|
+
});
|
|
7776
|
+
}
|
|
7777
|
+
/**
|
|
7778
|
+
* Remove the rules with names as indicated.
|
|
7779
|
+
*
|
|
7780
|
+
* @param {...string} names
|
|
7781
|
+
* @returns {BreakRule[]} The deleted rules
|
|
6509
7782
|
*/
|
|
6510
|
-
|
|
6511
|
-
|
|
7783
|
+
removeRule(...names) {
|
|
7784
|
+
/**
|
|
7785
|
+
* @type {BreakRule[]}
|
|
7786
|
+
*/
|
|
7787
|
+
const ret = [];
|
|
7788
|
+
this.rules = this.rules.filter((r) => {
|
|
7789
|
+
if (names.includes(r.name)) {
|
|
7790
|
+
ret.push(r);
|
|
7791
|
+
return false;
|
|
7792
|
+
}
|
|
7793
|
+
return true;
|
|
7794
|
+
});
|
|
7795
|
+
return ret;
|
|
6512
7796
|
}
|
|
6513
7797
|
/**
|
|
6514
|
-
*
|
|
6515
|
-
* error value if codePoint is out of range.
|
|
7798
|
+
* Add rules after the one named `name`.
|
|
6516
7799
|
*
|
|
6517
|
-
* @param {
|
|
6518
|
-
* @
|
|
7800
|
+
* @param {string} name The name of the rule before.
|
|
7801
|
+
* @param {...BreakRule} newRules
|
|
7802
|
+
* @returns {number} Index of start of the new rules
|
|
6519
7803
|
*/
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
if (
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
val = this.data[index];
|
|
6526
|
-
} else if (codePoint <= 65535) {
|
|
6527
|
-
const index = (this.data[LSCP_INDEX_2_OFFSET + (codePoint - 55296 >> 5)] << 2) + (codePoint & 31);
|
|
6528
|
-
val = this.data[index];
|
|
6529
|
-
} else if (codePoint < this.highStart) {
|
|
6530
|
-
let index = this.data[INDEX_1_OFFSET - 32 + (codePoint >> 11)];
|
|
6531
|
-
index = this.data[index + (codePoint >> 5 & 63)];
|
|
6532
|
-
index = (index << 2) + (codePoint & 31);
|
|
6533
|
-
val = this.data[index];
|
|
6534
|
-
} else val = this.data[this.data.length - 4];
|
|
6535
|
-
return val;
|
|
7804
|
+
addRuleAfter(name, ...newRules) {
|
|
7805
|
+
const i = this.rules.findIndex((r) => r.name === name);
|
|
7806
|
+
if (i === -1) throw new Error(`Rule not found: "${name}"`);
|
|
7807
|
+
this.rules.splice(i + 1, 0, ...newRules);
|
|
7808
|
+
return i + 1;
|
|
6536
7809
|
}
|
|
6537
7810
|
/**
|
|
6538
|
-
*
|
|
7811
|
+
* Add rules before the one named `name`.
|
|
6539
7812
|
*
|
|
6540
|
-
* @param {
|
|
6541
|
-
* @
|
|
7813
|
+
* @param {string} name The name of the rule before.
|
|
7814
|
+
* @param {...BreakRule} newRules
|
|
7815
|
+
* @returns {number} Index of start of the new rules
|
|
6542
7816
|
*/
|
|
6543
|
-
|
|
6544
|
-
const
|
|
6545
|
-
|
|
7817
|
+
addRuleBefore(name, ...newRules) {
|
|
7818
|
+
const i = this.rules.findIndex((r) => r.name === name);
|
|
7819
|
+
if (i === -1) throw new Error(`Rule not found: "${name}"`);
|
|
7820
|
+
this.rules.splice(i, 0, ...newRules);
|
|
7821
|
+
return i;
|
|
7822
|
+
}
|
|
7823
|
+
/**
|
|
7824
|
+
* Replace the rule named `name` with the given rules.
|
|
7825
|
+
*
|
|
7826
|
+
* @param {string} name The name of the rule before.
|
|
7827
|
+
* @param {...BreakRule} newRules
|
|
7828
|
+
* @returns {BreakRule[]} The replaced rules.
|
|
7829
|
+
*/
|
|
7830
|
+
replaceRule(name, ...newRules) {
|
|
7831
|
+
const i = this.rules.findIndex((r) => r.name === name);
|
|
7832
|
+
if (i === -1) throw new Error(`Rule not found: "${name}"`);
|
|
7833
|
+
return this.rules.splice(i, 1, ...newRules);
|
|
7834
|
+
}
|
|
7835
|
+
/**
|
|
7836
|
+
* Enumerate all of the potential line breaks.
|
|
7837
|
+
*
|
|
7838
|
+
* @param {string} str
|
|
7839
|
+
*/
|
|
7840
|
+
*breaks(str) {
|
|
7841
|
+
const state = new BreakerState(str);
|
|
7842
|
+
for (const step of state.codePoints(0)) {
|
|
7843
|
+
state.push(step);
|
|
7844
|
+
yield* _assertClassBrand(_Rules_brand, this, _exec).call(this, state);
|
|
7845
|
+
}
|
|
7846
|
+
state.pushEnd();
|
|
7847
|
+
yield* _assertClassBrand(_Rules_brand, this, _exec).call(this, state);
|
|
6546
7848
|
}
|
|
6547
7849
|
};
|
|
6548
|
-
//#endregion
|
|
6549
|
-
//#region node_modules/.pnpm/@cto.af+linebreak@4.0.3/node_modules/@cto.af/linebreak/lib/LineBreak.js
|
|
6550
|
-
var LineBreak = UnicodeTrie.fromBase64(`AAgOAAEAAAD/////nRQAAB+LCAC4xcFoAgPtnQnwlkUdx1+URLxABcUUghTEEK8Cmwp0LJAa
|
|
6551
|
-
MRrFbBSPSXHSAUYNdFQoBWMKyQrUCo/EyMIjD3TIAxXJM5NBHBm0RDSPzDOVdAz7/nB/07bt
|
|
6552
|
-
s8/e+/zhfef9zD7HPs/e129/u8/yzVutVWANeBl079xq9QJ9wUCwDxjqYQ4DI8BoMBYcBY4D
|
|
6553
|
-
48FEw3NTwDTp/BxwAZgJLgaXgCvAAnADuA3cDe4Hj0rPLQerwLPgJfAaeBe8Az4EnT/Ram0D
|
|
6554
|
-
eoBdwe5gENgX0DsOhHkQGAlGgTHgaHACGA8mgilgGpgBLgJzweVgPlgIbgF3iPOl4BGwAqwG
|
|
6555
|
-
a8Er4C2wDnwEumzRanUDPUFv0B8MBgeAL4BDwNfAN8C3wIngO+A0cCZowd/nwrwA/Eic/wzm
|
|
6556
|
-
L8EMHM+HuRDcDP4g7t8Hk3hYmI8BCv+TwvwLTOZvglfBawKyQ7wrjv8Ns1OXVqsroPNuwuwJ
|
|
6557
|
-
szfoL86JwTgeIp3HYJj0vhE4Hg3GgnHgZMDhnYDjyWCqZP9CHM8Gc8S1y2BeBa4FvweLxPN3
|
|
6558
|
-
wVwq7Dwirp0KVuB4NVgLXgSvg/fA+6C1Jf6gO+gF+oI9wQa3YQ4FwwDlwREwR4Mj+L6GY3Dv
|
|
6559
|
-
eMN9OY7JPAV2Jwn7Z8E8F0wHs8AcMA9cA64Dt4I7wT3gQfA4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p5DL7bj7GTQrbKypR
|
|
6649
|
-
dDVVywyhZCz4xkUhnSIj5EExoFoQisIfbICE2WJOoAESSK7wecCscDJSxRXMbBAlfLCyIbTh
|
|
6650
|
-
T8tr5/YikvVFSYq3dURbKo/gf+Q3zBCELycCXW/uB2mPjCb8AAAA`);
|
|
6651
7850
|
/**
|
|
6652
|
-
*
|
|
7851
|
+
*
|
|
7852
|
+
* @param {BreakerState} state
|
|
7853
|
+
* @returns {Break?}
|
|
6653
7854
|
*/
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
7855
|
+
function _execRules(state) {
|
|
7856
|
+
for (const rule of this.rules) {
|
|
7857
|
+
const res = rule.call(this, state);
|
|
7858
|
+
switch (res) {
|
|
7859
|
+
case PASS: break;
|
|
7860
|
+
case NO_BREAK:
|
|
7861
|
+
if (_classPrivateFieldGet2(_opts, this).verbose) console.log(` ${rule.name}: NO_BREAK`);
|
|
7862
|
+
return null;
|
|
7863
|
+
case MAY_BREAK:
|
|
7864
|
+
if (_classPrivateFieldGet2(_opts, this).verbose) console.log(` ${rule.name}: MAY_BREAK`);
|
|
7865
|
+
return new Break(state.cur.len);
|
|
7866
|
+
case MUST_BREAK:
|
|
7867
|
+
if (_classPrivateFieldGet2(_opts, this).verbose) console.log(` ${rule.name}: MUST_BREAK`);
|
|
7868
|
+
return new Break(state.cur.len, true);
|
|
7869
|
+
default: throw new Error(`Invalid state: "${res}"`);
|
|
7870
|
+
}
|
|
7871
|
+
}
|
|
7872
|
+
return null;
|
|
7873
|
+
}
|
|
7874
|
+
/**
|
|
7875
|
+
* @param {BreakerState} state
|
|
7876
|
+
*/
|
|
7877
|
+
function* _exec(state) {
|
|
7878
|
+
const res = _assertClassBrand(_Rules_brand, this, _execRules).call(this, state);
|
|
7879
|
+
if (res) {
|
|
7880
|
+
if (_classPrivateFieldGet2(_opts, this).string) res.string = state.str.slice(state.prevChunk, state.cur.len);
|
|
7881
|
+
if (state.props) {
|
|
7882
|
+
res.props = state.props;
|
|
7883
|
+
state.props = void 0;
|
|
7884
|
+
}
|
|
7885
|
+
yield res;
|
|
7886
|
+
state.prevChunk = state.cur.len;
|
|
7887
|
+
}
|
|
7888
|
+
}
|
|
6675
7889
|
//#endregion
|
|
6676
|
-
//#region
|
|
6677
|
-
|
|
7890
|
+
//#region src/text-layout.ts
|
|
7891
|
+
function graphemeBoundaries(text, locale) {
|
|
7892
|
+
const segmenter = new Intl.Segmenter(locale, { granularity: "grapheme" });
|
|
7893
|
+
const boundaries = /* @__PURE__ */ new Set([0]);
|
|
7894
|
+
for (const item of segmenter.segment(text)) boundaries.add(item.index + item.segment.length);
|
|
7895
|
+
return boundaries;
|
|
7896
|
+
}
|
|
7897
|
+
var _rules = /* @__PURE__ */ new WeakMap();
|
|
7898
|
+
var _locale = /* @__PURE__ */ new WeakMap();
|
|
7899
|
+
/**
|
|
7900
|
+
* Adapts UAX #14 opportunities and removes positions inside grapheme clusters.
|
|
7901
|
+
*/
|
|
7902
|
+
var UnicodeLineBreakProvider = class {
|
|
7903
|
+
constructor(locale = "ja") {
|
|
7904
|
+
_classPrivateFieldInitSpec(this, _rules, new Rules());
|
|
7905
|
+
_classPrivateFieldInitSpec(this, _locale, void 0);
|
|
7906
|
+
_classPrivateFieldSet2(_locale, this, locale);
|
|
7907
|
+
}
|
|
7908
|
+
getBreakOpportunities(text) {
|
|
7909
|
+
const boundaries = graphemeBoundaries(text, _classPrivateFieldGet2(_locale, this));
|
|
7910
|
+
const opportunities = /* @__PURE__ */ new Map();
|
|
7911
|
+
for (const candidate of _classPrivateFieldGet2(_rules, this).breaks(text)) {
|
|
7912
|
+
if (!boundaries.has(candidate.position)) continue;
|
|
7913
|
+
opportunities.set(candidate.position, (opportunities.get(candidate.position) ?? false) || candidate.required);
|
|
7914
|
+
}
|
|
7915
|
+
return Object.freeze([...opportunities].sort(([left], [right]) => left - right).map(([position, required]) => Object.freeze({
|
|
7916
|
+
position,
|
|
7917
|
+
required
|
|
7918
|
+
})));
|
|
7919
|
+
}
|
|
7920
|
+
};
|
|
7921
|
+
var defaultLineBreakProviders = /* @__PURE__ */ new Map();
|
|
7922
|
+
var newlinePattern = /\r\n|[\n\r\v\f\u0085\u2028\u2029]/gu;
|
|
7923
|
+
function defaultLineBreakProvider(locale) {
|
|
7924
|
+
const existing = defaultLineBreakProviders.get(locale);
|
|
7925
|
+
if (existing) return existing;
|
|
7926
|
+
const provider = new UnicodeLineBreakProvider(locale);
|
|
7927
|
+
defaultLineBreakProviders.set(locale, provider);
|
|
7928
|
+
return provider;
|
|
7929
|
+
}
|
|
7930
|
+
function requireWidth(width, label) {
|
|
7931
|
+
if (!Number.isFinite(width) || width < 0) throw new TypeError(`${label} must return a non-negative finite number.`);
|
|
7932
|
+
return width;
|
|
7933
|
+
}
|
|
7934
|
+
function normalizeOpportunities(text, provider, boundaries) {
|
|
7935
|
+
const normalized = /* @__PURE__ */ new Map();
|
|
7936
|
+
for (const opportunity of provider.getBreakOpportunities(text)) {
|
|
7937
|
+
const { position, required } = opportunity;
|
|
7938
|
+
if (!Number.isInteger(position) || position <= 0 || position > text.length || !boundaries.has(position)) continue;
|
|
7939
|
+
normalized.set(position, (normalized.get(position) ?? false) || required);
|
|
7940
|
+
}
|
|
7941
|
+
normalized.set(text.length, true);
|
|
7942
|
+
return [...normalized].sort(([left], [right]) => left - right).map(([position, required]) => ({
|
|
7943
|
+
position,
|
|
7944
|
+
required
|
|
7945
|
+
}));
|
|
7946
|
+
}
|
|
7947
|
+
function wrapParagraph(text, originalStart, input, provider, locale) {
|
|
7948
|
+
if (text.length === 0) return [{
|
|
7949
|
+
text: "",
|
|
7950
|
+
start: originalStart,
|
|
7951
|
+
end: originalStart,
|
|
7952
|
+
width: 0
|
|
7953
|
+
}];
|
|
7954
|
+
const boundarySet = graphemeBoundaries(text, locale);
|
|
7955
|
+
const boundaries = [...boundarySet].sort((left, right) => left - right);
|
|
7956
|
+
const opportunities = normalizeOpportunities(text, provider, boundarySet);
|
|
7957
|
+
const lines = [];
|
|
7958
|
+
let start = 0;
|
|
7959
|
+
while (start < text.length) {
|
|
7960
|
+
const requiredEnd = opportunities.find((opportunity) => opportunity.position > start && opportunity.required)?.position ?? text.length;
|
|
7961
|
+
let selected;
|
|
7962
|
+
let selectedWidth = 0;
|
|
7963
|
+
for (const opportunity of opportunities) {
|
|
7964
|
+
if (opportunity.position <= start || opportunity.position > requiredEnd) continue;
|
|
7965
|
+
const candidate = text.slice(start, opportunity.position);
|
|
7966
|
+
const width = requireWidth(input.measureText(candidate), "measureText");
|
|
7967
|
+
if (width <= input.maxWidth) {
|
|
7968
|
+
selected = opportunity.position;
|
|
7969
|
+
selectedWidth = width;
|
|
7970
|
+
}
|
|
7971
|
+
}
|
|
7972
|
+
if (selected === void 0) {
|
|
7973
|
+
const fallbackBoundaries = boundaries.filter((position) => position > start && position <= requiredEnd);
|
|
7974
|
+
for (const position of fallbackBoundaries) {
|
|
7975
|
+
const candidate = text.slice(start, position);
|
|
7976
|
+
const width = requireWidth(input.measureText(candidate), "measureText");
|
|
7977
|
+
if (width <= input.maxWidth) {
|
|
7978
|
+
selected = position;
|
|
7979
|
+
selectedWidth = width;
|
|
7980
|
+
}
|
|
7981
|
+
}
|
|
7982
|
+
if (selected === void 0) {
|
|
7983
|
+
selected = fallbackBoundaries[0] ?? requiredEnd;
|
|
7984
|
+
selectedWidth = requireWidth(input.measureText(text.slice(start, selected)), "measureText");
|
|
7985
|
+
}
|
|
7986
|
+
}
|
|
7987
|
+
lines.push({
|
|
7988
|
+
text: text.slice(start, selected),
|
|
7989
|
+
start: originalStart + start,
|
|
7990
|
+
end: originalStart + selected,
|
|
7991
|
+
width: selectedWidth
|
|
7992
|
+
});
|
|
7993
|
+
start = selected;
|
|
7994
|
+
}
|
|
7995
|
+
return lines;
|
|
7996
|
+
}
|
|
7997
|
+
/**
|
|
7998
|
+
* Greedily chooses the last legal break that fits the measured pixel width.
|
|
7999
|
+
* Explicit newlines are preserved. Unbreakable overflow falls back to a
|
|
8000
|
+
* grapheme boundary, even when a single grapheme is wider than maxWidth.
|
|
8001
|
+
*/
|
|
8002
|
+
function wrapText(input) {
|
|
8003
|
+
if (typeof input.text !== "string") throw new TypeError("text must be a string.");
|
|
8004
|
+
if (!Number.isFinite(input.maxWidth) || input.maxWidth <= 0) throw new TypeError("maxWidth must be a positive finite number.");
|
|
8005
|
+
if (typeof input.measureText !== "function") throw new TypeError("measureText must be a function.");
|
|
8006
|
+
const locale = input.locale ?? "ja";
|
|
8007
|
+
const provider = input.lineBreakProvider ?? defaultLineBreakProvider(locale);
|
|
8008
|
+
const lines = [];
|
|
8009
|
+
let paragraphStart = 0;
|
|
8010
|
+
for (const newline of input.text.matchAll(newlinePattern)) {
|
|
8011
|
+
const newlineStart = newline.index;
|
|
8012
|
+
lines.push(...wrapParagraph(input.text.slice(paragraphStart, newlineStart), paragraphStart, input, provider, locale));
|
|
8013
|
+
paragraphStart = newlineStart + newline[0].length;
|
|
8014
|
+
}
|
|
8015
|
+
lines.push(...wrapParagraph(input.text.slice(paragraphStart), paragraphStart, input, provider, locale));
|
|
8016
|
+
return Object.freeze({
|
|
8017
|
+
lines: Object.freeze(lines.map((line) => Object.freeze(line))),
|
|
8018
|
+
maxLineWidth: Math.max(0, ...lines.map((line) => line.width))
|
|
8019
|
+
});
|
|
8020
|
+
}
|
|
6678
8021
|
//#endregion
|
|
6679
8022
|
//#region src/composition.ts
|
|
6680
8023
|
var BubbleCompositionError = class extends Error {
|
|
@@ -6689,7 +8032,7 @@
|
|
|
6689
8032
|
var validAnimationModes$1 = /* @__PURE__ */ new Set([
|
|
6690
8033
|
"idle",
|
|
6691
8034
|
"talking",
|
|
6692
|
-
"awaiting-
|
|
8035
|
+
"awaiting-continue"
|
|
6693
8036
|
]);
|
|
6694
8037
|
function isRecord$1(value) {
|
|
6695
8038
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -6718,28 +8061,30 @@
|
|
|
6718
8061
|
}
|
|
6719
8062
|
function normalizePortrait(value) {
|
|
6720
8063
|
if (!isRecord$1(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Bubble portrait must be an object.");
|
|
6721
|
-
requireExactKeys(value, ["base"], ["blink", "
|
|
8064
|
+
requireExactKeys(value, ["base"], ["blink", "lipSync"], "Bubble portrait");
|
|
6722
8065
|
const blink = value.blink === void 0 ? void 0 : normalizeAnimation(value.blink, "Bubble portrait blink", 1);
|
|
6723
|
-
const
|
|
8066
|
+
const lipSync = value.lipSync === void 0 ? void 0 : normalizeAnimation(value.lipSync, "Bubble portrait lip-sync", 1);
|
|
6724
8067
|
return Object.freeze({
|
|
6725
8068
|
base: requireName(value.base, "Bubble portrait base"),
|
|
6726
8069
|
...blink === void 0 ? {} : { blink },
|
|
6727
|
-
...
|
|
8070
|
+
...lipSync === void 0 ? {} : { lipSync }
|
|
6728
8071
|
});
|
|
6729
8072
|
}
|
|
6730
8073
|
function normalizeStyle(value) {
|
|
6731
8074
|
if (!isRecord$1(value)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Bubble style must be an object.");
|
|
6732
8075
|
requireExactKeys(value, ["name", "textStyle"], [
|
|
6733
8076
|
"placement",
|
|
8077
|
+
"maxWidth",
|
|
8078
|
+
"textLocale",
|
|
6734
8079
|
"distance",
|
|
6735
8080
|
"tailLength",
|
|
6736
8081
|
"offset",
|
|
6737
8082
|
"visualStyle",
|
|
6738
8083
|
"portrait",
|
|
6739
|
-
"
|
|
8084
|
+
"continueIndicator"
|
|
6740
8085
|
], "Bubble style");
|
|
6741
8086
|
const portrait = value.portrait === void 0 ? void 0 : normalizePortrait(value.portrait);
|
|
6742
|
-
const
|
|
8087
|
+
const continueIndicator = value.continueIndicator === void 0 ? void 0 : normalizeAnimation(value.continueIndicator, "Bubble continue indicator", 2);
|
|
6743
8088
|
let placement;
|
|
6744
8089
|
try {
|
|
6745
8090
|
placement = normalizeBubblePlacement(value.placement ?? "up-right");
|
|
@@ -6758,20 +8103,33 @@
|
|
|
6758
8103
|
}
|
|
6759
8104
|
const visualStyle = value.visualStyle ?? "NORMAL";
|
|
6760
8105
|
if (typeof visualStyle !== "string" || !bubbleVisualStyles.includes(visualStyle)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", `Unsupported Bubble visual style: ${String(visualStyle)}`);
|
|
8106
|
+
let maxWidth;
|
|
8107
|
+
if (value.maxWidth !== void 0) {
|
|
8108
|
+
if (typeof value.maxWidth !== "number" || !Number.isFinite(value.maxWidth) || value.maxWidth <= 0) throw new BubbleCompositionError("BUBBLE-COMPOSITION-001", "Bubble style maxWidth must be a positive finite number.");
|
|
8109
|
+
maxWidth = value.maxWidth;
|
|
8110
|
+
}
|
|
8111
|
+
const textLocale = value.textLocale === void 0 ? void 0 : requireName(value.textLocale, "Bubble style text locale");
|
|
6761
8112
|
return Object.freeze({
|
|
6762
8113
|
name: requireName(value.name, "Bubble style name"),
|
|
6763
8114
|
textStyle: requireName(value.textStyle, "Bubble text style name"),
|
|
8115
|
+
...maxWidth === void 0 ? {} : { maxWidth },
|
|
8116
|
+
...textLocale === void 0 ? {} : { textLocale },
|
|
6764
8117
|
placement,
|
|
6765
8118
|
distance,
|
|
6766
8119
|
tailLength,
|
|
6767
8120
|
offset,
|
|
6768
8121
|
visualStyle,
|
|
6769
8122
|
...portrait === void 0 ? {} : { portrait },
|
|
6770
|
-
...
|
|
8123
|
+
...continueIndicator === void 0 ? {} : { continueIndicator }
|
|
6771
8124
|
});
|
|
6772
8125
|
}
|
|
6773
|
-
function
|
|
6774
|
-
if (
|
|
8126
|
+
function validateImageResolver(value) {
|
|
8127
|
+
if (value === void 0) return void 0;
|
|
8128
|
+
if (!isRecord$1(value) || typeof value.applyToTarget !== "function" || typeof value.getMimeType !== "function" || typeof value.isRegistered !== "function") throw new TypeError("Bubble image capability must provide applyToTarget, getMimeType, and isRegistered.");
|
|
8129
|
+
return value;
|
|
8130
|
+
}
|
|
8131
|
+
function requireImageResolver(value) {
|
|
8132
|
+
if (value === void 0) throw new BubbleCompositionError("BUBBLE-COMPOSITION-006", "Bubble image assets require an image capability. Provide options.imageResolver.");
|
|
6775
8133
|
return value;
|
|
6776
8134
|
}
|
|
6777
8135
|
function validateSvgText(value) {
|
|
@@ -6797,7 +8155,7 @@
|
|
|
6797
8155
|
return value;
|
|
6798
8156
|
}
|
|
6799
8157
|
function validateSurface(value, style) {
|
|
6800
|
-
if (!isRecord$1(value) || !isRecord$1(value.targets) || typeof value.setLayerVisible !== "function" || typeof value.show !== "function" || typeof value.hide !== "function" || typeof value.dispose !== "function") throw new BubbleCompositionError("BUBBLE-COMPOSITION-004", "Bubble surface is invalid.");
|
|
8158
|
+
if (!isRecord$1(value) || !isRecord$1(value.targets) || typeof value.setLayerVisible !== "function" || typeof value.updateStyle !== "function" || typeof value.show !== "function" || typeof value.hide !== "function" || typeof value.dispose !== "function") throw new BubbleCompositionError("BUBBLE-COMPOSITION-004", "Bubble surface is invalid.");
|
|
6801
8159
|
const targets = value.targets;
|
|
6802
8160
|
validateTextTarget(targets.text);
|
|
6803
8161
|
const assetTargetIds = /* @__PURE__ */ new Set();
|
|
@@ -6810,20 +8168,34 @@
|
|
|
6810
8168
|
};
|
|
6811
8169
|
requireLayerTarget("portraitBase", style.portrait !== void 0);
|
|
6812
8170
|
requireLayerTarget("portraitBlink", style.portrait?.blink !== void 0);
|
|
6813
|
-
requireLayerTarget("
|
|
6814
|
-
requireLayerTarget("
|
|
8171
|
+
requireLayerTarget("portraitLipSync", style.portrait?.lipSync !== void 0);
|
|
8172
|
+
requireLayerTarget("continueIndicator", style.continueIndicator !== void 0);
|
|
6815
8173
|
return value;
|
|
6816
8174
|
}
|
|
6817
|
-
function requireImageAsset(
|
|
6818
|
-
if (
|
|
6819
|
-
if (!
|
|
8175
|
+
function requireImageAsset(imageResolver, name) {
|
|
8176
|
+
if (imageResolver === void 0) throw new BubbleCompositionError("BUBBLE-COMPOSITION-006", `Bubble image capability is required for: ${name}. Provide options.imageResolver.`);
|
|
8177
|
+
if (!imageResolver.isRegistered(name)) throw new BubbleCompositionError("BUBBLE-COMPOSITION-003", `Bubble image asset is not registered: ${name}`);
|
|
8178
|
+
if (!imageResolver.getMimeType(name).startsWith("image/")) throw new BubbleCompositionError("BUBBLE-COMPOSITION-003", `Bubble asset is not an image: ${name}`);
|
|
6820
8179
|
}
|
|
6821
8180
|
function styleAssetNames(style) {
|
|
6822
8181
|
return [...style.portrait === void 0 ? [] : [
|
|
6823
8182
|
style.portrait.base,
|
|
6824
8183
|
...style.portrait.blink?.frames ?? [],
|
|
6825
|
-
...style.portrait.
|
|
6826
|
-
], ...style.
|
|
8184
|
+
...style.portrait.lipSync?.frames ?? []
|
|
8185
|
+
], ...style.continueIndicator?.frames ?? []];
|
|
8186
|
+
}
|
|
8187
|
+
function formatBubbleText(text, style, textCapability) {
|
|
8188
|
+
if (style.maxWidth === void 0) return text;
|
|
8189
|
+
if (typeof textCapability.measureText !== "function") throw new BubbleCompositionError("BUBBLE-COMPOSITION-007", "Bubble style maxWidth requires the text capability measureText method.");
|
|
8190
|
+
return wrapText({
|
|
8191
|
+
text,
|
|
8192
|
+
maxWidth: style.maxWidth,
|
|
8193
|
+
...style.textLocale === void 0 ? {} : { locale: style.textLocale },
|
|
8194
|
+
measureText: (candidate) => textCapability.measureText?.({
|
|
8195
|
+
styleName: style.textStyle,
|
|
8196
|
+
text: candidate
|
|
8197
|
+
}) ?? 0
|
|
8198
|
+
}).lines.map(({ text: line }) => line).join("\n");
|
|
6827
8199
|
}
|
|
6828
8200
|
function aggregateErrors(errors, message) {
|
|
6829
8201
|
if (errors.length === 1) throw errors[0];
|
|
@@ -6838,7 +8210,7 @@
|
|
|
6838
8210
|
const applyFrame = async (index) => {
|
|
6839
8211
|
const assetName = options.animation.frames[index];
|
|
6840
8212
|
if (assetName === void 0) return;
|
|
6841
|
-
await options.
|
|
8213
|
+
await options.imageResolver.applyToTarget(assetName, options.target);
|
|
6842
8214
|
};
|
|
6843
8215
|
const reportError = (error, assetName) => {
|
|
6844
8216
|
options.onError?.(error, Object.freeze({
|
|
@@ -6911,7 +8283,7 @@
|
|
|
6911
8283
|
}
|
|
6912
8284
|
function createBubbleComposition(options) {
|
|
6913
8285
|
if (!isRecord$1(options)) throw new TypeError("Bubble composition options must be an object.");
|
|
6914
|
-
const
|
|
8286
|
+
const imageResolver = validateImageResolver(options.imageResolver);
|
|
6915
8287
|
const svgText = validateSvgText(options.svgText);
|
|
6916
8288
|
if (typeof options.createSurface !== "function") throw new TypeError("Bubble composition createSurface must be a function.");
|
|
6917
8289
|
if (options.onAnimationError !== void 0 && typeof options.onAnimationError !== "function") throw new TypeError("Bubble composition onAnimationError must be a function.");
|
|
@@ -6936,66 +8308,85 @@
|
|
|
6936
8308
|
ensureActive();
|
|
6937
8309
|
const style = styles.get(input.styleName);
|
|
6938
8310
|
if (!style) throw new BubbleCompositionError("BUBBLE-COMPOSITION-002", `Bubble style is not defined: ${input.styleName}`);
|
|
6939
|
-
|
|
8311
|
+
let activeStyle = style;
|
|
8312
|
+
let currentText = input.text;
|
|
8313
|
+
const resolveStyleImageCapability = (nextStyle) => {
|
|
8314
|
+
const assetNames = new Set(styleAssetNames(nextStyle));
|
|
8315
|
+
const nextImageResolver = assetNames.size === 0 ? void 0 : requireImageResolver(imageResolver);
|
|
8316
|
+
for (const assetName of assetNames) requireImageAsset(nextImageResolver, assetName);
|
|
8317
|
+
return nextImageResolver;
|
|
8318
|
+
};
|
|
8319
|
+
const styleImageResolver = resolveStyleImageCapability(activeStyle);
|
|
8320
|
+
const primeStyleImages = async (nextStyle, nextImageResolver, nextSurface) => {
|
|
8321
|
+
const imageCapability = styleAssetNames(nextStyle).length === 0 ? void 0 : requireImageResolver(nextImageResolver);
|
|
8322
|
+
const operations = [];
|
|
8323
|
+
if (nextStyle.portrait) {
|
|
8324
|
+
const capability = requireImageResolver(imageCapability);
|
|
8325
|
+
operations.push(Promise.resolve(capability.applyToTarget(nextStyle.portrait.base, nextSurface.targets.portraitBase)));
|
|
8326
|
+
const blinkFirst = nextStyle.portrait.blink?.frames[0];
|
|
8327
|
+
if (blinkFirst !== void 0) operations.push(Promise.resolve(capability.applyToTarget(blinkFirst, nextSurface.targets.portraitBlink)));
|
|
8328
|
+
const lipSyncFirst = nextStyle.portrait.lipSync?.frames[0];
|
|
8329
|
+
if (lipSyncFirst !== void 0) operations.push(Promise.resolve(capability.applyToTarget(lipSyncFirst, nextSurface.targets.portraitLipSync)));
|
|
8330
|
+
}
|
|
8331
|
+
const continueFirst = nextStyle.continueIndicator?.frames[0];
|
|
8332
|
+
if (continueFirst !== void 0) {
|
|
8333
|
+
const capability = requireImageResolver(imageCapability);
|
|
8334
|
+
operations.push(Promise.resolve(capability.applyToTarget(continueFirst, nextSurface.targets.continueIndicator)));
|
|
8335
|
+
}
|
|
8336
|
+
await Promise.all(operations);
|
|
8337
|
+
};
|
|
8338
|
+
const createStyleLoops = (nextStyle, nextImageResolver, nextSurface) => {
|
|
8339
|
+
blinkLoop = nextStyle.portrait?.blink === void 0 ? void 0 : createFrameLoop({
|
|
8340
|
+
actorKey: input.actorKey,
|
|
8341
|
+
layer: "portraitBlink",
|
|
8342
|
+
animation: nextStyle.portrait.blink,
|
|
8343
|
+
target: nextSurface.targets.portraitBlink,
|
|
8344
|
+
imageResolver: requireImageResolver(nextImageResolver),
|
|
8345
|
+
scheduler,
|
|
8346
|
+
...options.onAnimationError === void 0 ? {} : { onError: options.onAnimationError }
|
|
8347
|
+
});
|
|
8348
|
+
lipSyncLoop = nextStyle.portrait?.lipSync === void 0 ? void 0 : createFrameLoop({
|
|
8349
|
+
actorKey: input.actorKey,
|
|
8350
|
+
layer: "portraitLipSync",
|
|
8351
|
+
animation: nextStyle.portrait.lipSync,
|
|
8352
|
+
target: nextSurface.targets.portraitLipSync,
|
|
8353
|
+
imageResolver: requireImageResolver(nextImageResolver),
|
|
8354
|
+
scheduler,
|
|
8355
|
+
...options.onAnimationError === void 0 ? {} : { onError: options.onAnimationError }
|
|
8356
|
+
});
|
|
8357
|
+
indicatorLoop = nextStyle.continueIndicator === void 0 ? void 0 : createFrameLoop({
|
|
8358
|
+
actorKey: input.actorKey,
|
|
8359
|
+
layer: "continueIndicator",
|
|
8360
|
+
animation: nextStyle.continueIndicator,
|
|
8361
|
+
target: nextSurface.targets.continueIndicator,
|
|
8362
|
+
imageResolver: requireImageResolver(nextImageResolver),
|
|
8363
|
+
scheduler,
|
|
8364
|
+
...options.onAnimationError === void 0 ? {} : { onError: options.onAnimationError }
|
|
8365
|
+
});
|
|
8366
|
+
};
|
|
6940
8367
|
const previous = active.get(input.actorKey);
|
|
6941
8368
|
if (previous) await previous.close();
|
|
6942
8369
|
let surface;
|
|
6943
8370
|
let textOwned = false;
|
|
6944
8371
|
let surfaceVisible = false;
|
|
6945
8372
|
let blinkLoop;
|
|
6946
|
-
let
|
|
8373
|
+
let lipSyncLoop;
|
|
6947
8374
|
let indicatorLoop;
|
|
6948
8375
|
try {
|
|
6949
8376
|
surface = validateSurface(await options.createSurface(Object.freeze({
|
|
6950
8377
|
actor: input.actor,
|
|
6951
8378
|
actorKey: input.actorKey,
|
|
6952
8379
|
kind: input.kind,
|
|
6953
|
-
style
|
|
6954
|
-
})),
|
|
8380
|
+
style: activeStyle
|
|
8381
|
+
})), activeStyle);
|
|
6955
8382
|
svgText.setText({
|
|
6956
|
-
styleName:
|
|
8383
|
+
styleName: activeStyle.textStyle,
|
|
6957
8384
|
target: surface.targets.text,
|
|
6958
|
-
text: input.text
|
|
8385
|
+
text: formatBubbleText(input.text, activeStyle, svgText)
|
|
6959
8386
|
});
|
|
6960
8387
|
textOwned = true;
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
primeOperations.push(assetManager.applyToTarget(style.portrait.base, surface.targets.portraitBase));
|
|
6964
|
-
const blinkFirst = style.portrait.blink?.frames[0];
|
|
6965
|
-
if (blinkFirst !== void 0) primeOperations.push(assetManager.applyToTarget(blinkFirst, surface.targets.portraitBlink));
|
|
6966
|
-
const talkFirst = style.portrait.talk?.frames[0];
|
|
6967
|
-
if (talkFirst !== void 0) primeOperations.push(assetManager.applyToTarget(talkFirst, surface.targets.portraitTalk));
|
|
6968
|
-
}
|
|
6969
|
-
const indicatorFirst = style.advanceIndicator?.frames[0];
|
|
6970
|
-
if (indicatorFirst !== void 0) primeOperations.push(assetManager.applyToTarget(indicatorFirst, surface.targets.advanceIndicator));
|
|
6971
|
-
await Promise.all(primeOperations);
|
|
6972
|
-
blinkLoop = style.portrait?.blink === void 0 ? void 0 : createFrameLoop({
|
|
6973
|
-
actorKey: input.actorKey,
|
|
6974
|
-
layer: "portraitBlink",
|
|
6975
|
-
animation: style.portrait.blink,
|
|
6976
|
-
target: surface.targets.portraitBlink,
|
|
6977
|
-
assetManager,
|
|
6978
|
-
scheduler,
|
|
6979
|
-
...options.onAnimationError === void 0 ? {} : { onError: options.onAnimationError }
|
|
6980
|
-
});
|
|
6981
|
-
talkLoop = style.portrait?.talk === void 0 ? void 0 : createFrameLoop({
|
|
6982
|
-
actorKey: input.actorKey,
|
|
6983
|
-
layer: "portraitTalk",
|
|
6984
|
-
animation: style.portrait.talk,
|
|
6985
|
-
target: surface.targets.portraitTalk,
|
|
6986
|
-
assetManager,
|
|
6987
|
-
scheduler,
|
|
6988
|
-
...options.onAnimationError === void 0 ? {} : { onError: options.onAnimationError }
|
|
6989
|
-
});
|
|
6990
|
-
indicatorLoop = style.advanceIndicator === void 0 ? void 0 : createFrameLoop({
|
|
6991
|
-
actorKey: input.actorKey,
|
|
6992
|
-
layer: "advanceIndicator",
|
|
6993
|
-
animation: style.advanceIndicator,
|
|
6994
|
-
target: surface.targets.advanceIndicator,
|
|
6995
|
-
assetManager,
|
|
6996
|
-
scheduler,
|
|
6997
|
-
...options.onAnimationError === void 0 ? {} : { onError: options.onAnimationError }
|
|
6998
|
-
});
|
|
8388
|
+
await primeStyleImages(activeStyle, styleImageResolver, surface);
|
|
8389
|
+
createStyleLoops(activeStyle, styleImageResolver, surface);
|
|
6999
8390
|
let currentAnimationMode = "idle";
|
|
7000
8391
|
let closed = false;
|
|
7001
8392
|
let transitionTail = Promise.resolve();
|
|
@@ -7003,25 +8394,25 @@
|
|
|
7003
8394
|
if (mode === currentAnimationMode) return;
|
|
7004
8395
|
if (mode === "talking") {
|
|
7005
8396
|
await indicatorLoop?.stop();
|
|
7006
|
-
await surface?.setLayerVisible("
|
|
7007
|
-
await surface?.setLayerVisible("
|
|
7008
|
-
await
|
|
7009
|
-
} else if (mode === "awaiting-
|
|
7010
|
-
await
|
|
7011
|
-
await surface?.setLayerVisible("
|
|
7012
|
-
await surface?.setLayerVisible("
|
|
8397
|
+
await surface?.setLayerVisible("continueIndicator", false);
|
|
8398
|
+
await surface?.setLayerVisible("portraitLipSync", lipSyncLoop !== void 0);
|
|
8399
|
+
await lipSyncLoop?.start({ primed: true });
|
|
8400
|
+
} else if (mode === "awaiting-continue") {
|
|
8401
|
+
await lipSyncLoop?.stop({ reset: true });
|
|
8402
|
+
await surface?.setLayerVisible("portraitLipSync", false);
|
|
8403
|
+
await surface?.setLayerVisible("continueIndicator", indicatorLoop !== void 0);
|
|
7013
8404
|
await indicatorLoop?.start({ primed: true });
|
|
7014
8405
|
} else {
|
|
7015
|
-
await Promise.all([
|
|
7016
|
-
await Promise.all([surface?.setLayerVisible("
|
|
8406
|
+
await Promise.all([lipSyncLoop?.stop({ reset: true }), indicatorLoop?.stop()]);
|
|
8407
|
+
await Promise.all([surface?.setLayerVisible("portraitLipSync", false), surface?.setLayerVisible("continueIndicator", false)]);
|
|
7017
8408
|
}
|
|
7018
8409
|
currentAnimationMode = mode;
|
|
7019
8410
|
};
|
|
7020
8411
|
await Promise.all([
|
|
7021
|
-
surface.setLayerVisible("portraitBase",
|
|
7022
|
-
surface.setLayerVisible("portraitBlink",
|
|
7023
|
-
surface.setLayerVisible("
|
|
7024
|
-
surface.setLayerVisible("
|
|
8412
|
+
surface.setLayerVisible("portraitBase", activeStyle.portrait !== void 0),
|
|
8413
|
+
surface.setLayerVisible("portraitBlink", activeStyle.portrait?.blink !== void 0),
|
|
8414
|
+
surface.setLayerVisible("portraitLipSync", false),
|
|
8415
|
+
surface.setLayerVisible("continueIndicator", false)
|
|
7025
8416
|
]);
|
|
7026
8417
|
await surface.show();
|
|
7027
8418
|
surfaceVisible = true;
|
|
@@ -7039,10 +8430,51 @@
|
|
|
7039
8430
|
transitionTail = transitionTail.then(async () => {
|
|
7040
8431
|
if (!surface) return;
|
|
7041
8432
|
svgText.setText({
|
|
7042
|
-
styleName:
|
|
8433
|
+
styleName: activeStyle.textStyle,
|
|
8434
|
+
target: surface.targets.text,
|
|
8435
|
+
text: formatBubbleText(text, activeStyle, svgText)
|
|
8436
|
+
});
|
|
8437
|
+
currentText = text;
|
|
8438
|
+
await surface.show();
|
|
8439
|
+
});
|
|
8440
|
+
return transitionTail;
|
|
8441
|
+
},
|
|
8442
|
+
updateStyle(styleInput) {
|
|
8443
|
+
if (closed) return Promise.reject(new BubbleCompositionError("BUBBLE-COMPOSITION-005", `Bubble is already closed: ${input.actorKey}`));
|
|
8444
|
+
let nextStyle;
|
|
8445
|
+
try {
|
|
8446
|
+
nextStyle = normalizeStyle(styleInput);
|
|
8447
|
+
} catch (error) {
|
|
8448
|
+
return Promise.reject(error);
|
|
8449
|
+
}
|
|
8450
|
+
transitionTail = transitionTail.then(async () => {
|
|
8451
|
+
if (!surface) return;
|
|
8452
|
+
validateSurface(surface, nextStyle);
|
|
8453
|
+
const nextImageResolver = resolveStyleImageCapability(nextStyle);
|
|
8454
|
+
await Promise.all([
|
|
8455
|
+
blinkLoop?.stop(),
|
|
8456
|
+
lipSyncLoop?.stop(),
|
|
8457
|
+
indicatorLoop?.stop()
|
|
8458
|
+
]);
|
|
8459
|
+
await primeStyleImages(nextStyle, nextImageResolver, surface);
|
|
8460
|
+
await surface.updateStyle(nextStyle);
|
|
8461
|
+
activeStyle = nextStyle;
|
|
8462
|
+
svgText.setText({
|
|
8463
|
+
styleName: nextStyle.textStyle,
|
|
7043
8464
|
target: surface.targets.text,
|
|
7044
|
-
text
|
|
8465
|
+
text: formatBubbleText(currentText, nextStyle, svgText)
|
|
7045
8466
|
});
|
|
8467
|
+
createStyleLoops(nextStyle, nextImageResolver, surface);
|
|
8468
|
+
await Promise.all([
|
|
8469
|
+
surface.setLayerVisible("portraitBase", nextStyle.portrait !== void 0),
|
|
8470
|
+
surface.setLayerVisible("portraitBlink", nextStyle.portrait?.blink !== void 0),
|
|
8471
|
+
surface.setLayerVisible("portraitLipSync", false),
|
|
8472
|
+
surface.setLayerVisible("continueIndicator", false)
|
|
8473
|
+
]);
|
|
8474
|
+
const previousMode = currentAnimationMode;
|
|
8475
|
+
currentAnimationMode = "idle";
|
|
8476
|
+
await blinkLoop?.start({ primed: true });
|
|
8477
|
+
await applyAnimationMode(previousMode);
|
|
7046
8478
|
await surface.show();
|
|
7047
8479
|
});
|
|
7048
8480
|
return transitionTail;
|
|
@@ -7064,7 +8496,7 @@
|
|
|
7064
8496
|
}
|
|
7065
8497
|
for (const operation of [
|
|
7066
8498
|
() => blinkLoop?.stop(),
|
|
7067
|
-
() =>
|
|
8499
|
+
() => lipSyncLoop?.stop(),
|
|
7068
8500
|
() => indicatorLoop?.stop(),
|
|
7069
8501
|
async () => {
|
|
7070
8502
|
if (surfaceVisible) await surface?.hide();
|
|
@@ -7088,7 +8520,7 @@
|
|
|
7088
8520
|
const cleanupErrors = [];
|
|
7089
8521
|
const loopResults = await Promise.allSettled([
|
|
7090
8522
|
blinkLoop?.stop(),
|
|
7091
|
-
|
|
8523
|
+
lipSyncLoop?.stop(),
|
|
7092
8524
|
indicatorLoop?.stop()
|
|
7093
8525
|
]);
|
|
7094
8526
|
cleanupErrors.push(...loopResults.flatMap((result) => result.status === "rejected" ? [result.reason] : []));
|
|
@@ -7184,7 +8616,7 @@
|
|
|
7184
8616
|
return value;
|
|
7185
8617
|
}
|
|
7186
8618
|
function requireAssetManager(value) {
|
|
7187
|
-
if (!isRecord(value) || typeof value.isLoaded !== "function" || typeof value.getAssetMimeType !== "function" || typeof value.resolveSkin !== "function") throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-002", "Bubble
|
|
8619
|
+
if (!isRecord(value) || typeof value.isLoaded !== "function" || typeof value.getAssetMimeType !== "function" || typeof value.resolveSkin !== "function") throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-002", "Bubble image assets require an imageResolver capability. Load @kubohiroya/turbowarp-asset-manager or provide options.imageResolver before using image features.");
|
|
7188
8620
|
return value;
|
|
7189
8621
|
}
|
|
7190
8622
|
function requireSvgText(value) {
|
|
@@ -7269,35 +8701,36 @@
|
|
|
7269
8701
|
const body = createTarget("body");
|
|
7270
8702
|
const portraitBase = style.portrait ? createTarget("portrait-base") : void 0;
|
|
7271
8703
|
const portraitBlink = style.portrait?.blink ? createTarget("portrait-blink") : void 0;
|
|
7272
|
-
const
|
|
8704
|
+
const portraitLipSync = style.portrait?.lipSync ? createTarget("portrait-lip-sync") : void 0;
|
|
7273
8705
|
const text = createTarget("text");
|
|
7274
|
-
const
|
|
8706
|
+
const continueIndicator = style.continueIndicator ? createTarget("continue-indicator") : void 0;
|
|
7275
8707
|
const targets = Object.freeze({
|
|
7276
8708
|
text,
|
|
7277
8709
|
...portraitBase ? { portraitBase } : {},
|
|
7278
8710
|
...portraitBlink ? { portraitBlink } : {},
|
|
7279
|
-
...
|
|
7280
|
-
...
|
|
8711
|
+
...portraitLipSync ? { portraitLipSync } : {},
|
|
8712
|
+
...continueIndicator ? { continueIndicator } : {}
|
|
7281
8713
|
});
|
|
7282
8714
|
const layerTargets = /* @__PURE__ */ new Map();
|
|
7283
8715
|
if (portraitBase) layerTargets.set("portraitBase", portraitBase);
|
|
7284
8716
|
if (portraitBlink) layerTargets.set("portraitBlink", portraitBlink);
|
|
7285
|
-
if (
|
|
7286
|
-
if (
|
|
8717
|
+
if (portraitLipSync) layerTargets.set("portraitLipSync", portraitLipSync);
|
|
8718
|
+
if (continueIndicator) layerTargets.set("continueIndicator", continueIndicator);
|
|
7287
8719
|
const layerVisibility = /* @__PURE__ */ new Map();
|
|
7288
8720
|
let surfaceVisible = false;
|
|
7289
8721
|
let disposed = false;
|
|
7290
8722
|
let cachedBodySkinSignature = "";
|
|
8723
|
+
let currentStyle = style;
|
|
7291
8724
|
const updateVisibility = () => {
|
|
7292
|
-
const actorVisible =
|
|
7293
|
-
renderer.updateDrawableVisible(body.drawableID, surfaceVisible && actorVisible &&
|
|
8725
|
+
const actorVisible = currentStyle.placement.basis === "background" || actor.visible !== false;
|
|
8726
|
+
renderer.updateDrawableVisible(body.drawableID, surfaceVisible && actorVisible && currentStyle.visualStyle !== "NO_BUBBLE");
|
|
7294
8727
|
renderer.updateDrawableVisible(text.drawableID, surfaceVisible && actorVisible);
|
|
7295
8728
|
for (const [layer, target] of layerTargets) renderer.updateDrawableVisible(target.drawableID, surfaceVisible && actorVisible && (layerVisibility.get(layer) ?? false));
|
|
7296
8729
|
runtime.requestRedraw?.();
|
|
7297
8730
|
};
|
|
7298
8731
|
const position = () => {
|
|
7299
8732
|
if (disposed) return;
|
|
7300
|
-
const scaleMultiplier =
|
|
8733
|
+
const scaleMultiplier = currentStyle.placement.basis === "actor" ? currentStyle.offset.scalePercent / 100 : 1;
|
|
7301
8734
|
const nativeTextSize = readSize(renderer, text, {
|
|
7302
8735
|
width: 180,
|
|
7303
8736
|
height: 48
|
|
@@ -7311,8 +8744,8 @@
|
|
|
7311
8744
|
width: 0,
|
|
7312
8745
|
height: 0
|
|
7313
8746
|
};
|
|
7314
|
-
for (const target of [portraitBlink,
|
|
7315
|
-
const indicatorSize =
|
|
8747
|
+
for (const target of [portraitBlink, portraitLipSync]) if (target) fitDrawable(renderer, target, portraitBoxSize, scaleMultiplier);
|
|
8748
|
+
const indicatorSize = continueIndicator ? fitDrawable(renderer, continueIndicator, indicatorBoxSize, scaleMultiplier) : {
|
|
7316
8749
|
width: 0,
|
|
7317
8750
|
height: 0
|
|
7318
8751
|
};
|
|
@@ -7335,31 +8768,31 @@
|
|
|
7335
8768
|
const maximumCenterY = stageTop - bubbleHeight / 2;
|
|
7336
8769
|
let centerX;
|
|
7337
8770
|
let centerY;
|
|
7338
|
-
if (
|
|
8771
|
+
if (currentStyle.placement.basis === "background") {
|
|
7339
8772
|
centerX = 0;
|
|
7340
|
-
if (
|
|
7341
|
-
else if (
|
|
8773
|
+
if (currentStyle.placement.region === "HEADER_LIKE") centerY = stageTop - stageSafeMargin - bubbleHeight / 2;
|
|
8774
|
+
else if (currentStyle.placement.region === "FOOTER_LIKE") centerY = stageBottom + stageSafeMargin + bubbleHeight / 2;
|
|
7342
8775
|
else centerY = 0;
|
|
7343
8776
|
} else {
|
|
7344
8777
|
const center = actorRelativeBubbleCenter({
|
|
7345
8778
|
bounds: targetBounds(actor),
|
|
7346
8779
|
bubbleWidth,
|
|
7347
8780
|
bubbleHeight,
|
|
7348
|
-
direction:
|
|
7349
|
-
distance:
|
|
7350
|
-
tailLength:
|
|
7351
|
-
offset:
|
|
8781
|
+
direction: currentStyle.placement.direction,
|
|
8782
|
+
distance: currentStyle.distance,
|
|
8783
|
+
tailLength: currentStyle.tailLength,
|
|
8784
|
+
offset: currentStyle.offset
|
|
7352
8785
|
});
|
|
7353
8786
|
centerX = center.x;
|
|
7354
8787
|
centerY = center.y;
|
|
7355
8788
|
}
|
|
7356
8789
|
centerX = clamp(centerX, minimumCenterX, maximumCenterX);
|
|
7357
8790
|
centerY = clamp(centerY, minimumCenterY, maximumCenterY);
|
|
7358
|
-
const tailDirection =
|
|
7359
|
-
const bodyOffset =
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
8791
|
+
const tailDirection = currentStyle.placement.basis === "actor" ? tailDirectionForPlacement(currentStyle.placement.direction) : null;
|
|
8792
|
+
const bodyOffset = currentStyle.placement.basis === "actor" ? [
|
|
8793
|
+
currentStyle.offset.x,
|
|
8794
|
+
currentStyle.offset.y,
|
|
8795
|
+
currentStyle.offset.scalePercent
|
|
7363
8796
|
] : [
|
|
7364
8797
|
0,
|
|
7365
8798
|
0,
|
|
@@ -7369,35 +8802,35 @@
|
|
|
7369
8802
|
x: 0,
|
|
7370
8803
|
y: 0
|
|
7371
8804
|
} : bubbleBodyCenterOffset({
|
|
7372
|
-
style:
|
|
8805
|
+
style: currentStyle.visualStyle,
|
|
7373
8806
|
width: baseBubbleWidth,
|
|
7374
8807
|
height: baseBubbleHeight,
|
|
7375
8808
|
tailDirection,
|
|
7376
|
-
tailLength:
|
|
8809
|
+
tailLength: currentStyle.tailLength,
|
|
7377
8810
|
offset: bodyOffset
|
|
7378
8811
|
});
|
|
7379
|
-
const viewportExtraX = Math.abs(bodyOffset[0]) + baseBubbleWidth * Math.abs(scaleMultiplier - 1) + Math.max(0,
|
|
7380
|
-
const viewportExtraY = Math.abs(bodyOffset[1]) + baseBubbleHeight * Math.abs(scaleMultiplier - 1) + Math.max(0,
|
|
8812
|
+
const viewportExtraX = Math.abs(bodyOffset[0]) + baseBubbleWidth * Math.abs(scaleMultiplier - 1) + Math.max(0, currentStyle.tailLength - 18) + 8;
|
|
8813
|
+
const viewportExtraY = Math.abs(bodyOffset[1]) + baseBubbleHeight * Math.abs(scaleMultiplier - 1) + Math.max(0, currentStyle.tailLength - 18) + 8;
|
|
7381
8814
|
const nextBodySkinSignature = JSON.stringify({
|
|
7382
8815
|
baseBubbleHeight,
|
|
7383
8816
|
baseBubbleWidth,
|
|
7384
8817
|
bodyOffset,
|
|
7385
8818
|
tailDirection,
|
|
7386
|
-
tailLength:
|
|
8819
|
+
tailLength: currentStyle.tailLength,
|
|
7387
8820
|
viewportExtraX,
|
|
7388
8821
|
viewportExtraY,
|
|
7389
|
-
visualStyle:
|
|
8822
|
+
visualStyle: currentStyle.visualStyle
|
|
7390
8823
|
});
|
|
7391
8824
|
if (nextBodySkinSignature !== cachedBodySkinSignature) {
|
|
7392
8825
|
const expanded = expandSvgViewport(renderBubbleSvg({
|
|
7393
|
-
style:
|
|
8826
|
+
style: currentStyle.visualStyle,
|
|
7394
8827
|
lines: [],
|
|
7395
8828
|
width: baseBubbleWidth,
|
|
7396
8829
|
height: baseBubbleHeight,
|
|
7397
8830
|
tailDirection,
|
|
7398
|
-
tailLength:
|
|
8831
|
+
tailLength: currentStyle.tailLength,
|
|
7399
8832
|
offset: bodyOffset,
|
|
7400
|
-
title: `${
|
|
8833
|
+
title: `${currentStyle.name} Bubble body`
|
|
7401
8834
|
}), baseBubbleWidth, baseBubbleHeight, viewportExtraX, viewportExtraY);
|
|
7402
8835
|
const nextSkinId = renderer.createSVGSkin(expanded);
|
|
7403
8836
|
if (!Number.isInteger(nextSkinId) || nextSkinId < 0) throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-001", "TurboWarp did not create the Bubble body SVG skin.");
|
|
@@ -7420,10 +8853,10 @@
|
|
|
7420
8853
|
for (const target of [
|
|
7421
8854
|
portraitBase,
|
|
7422
8855
|
portraitBlink,
|
|
7423
|
-
|
|
8856
|
+
portraitLipSync
|
|
7424
8857
|
]) if (target) renderer.updateDrawablePosition(target.drawableID, [portraitX, centerY]);
|
|
7425
8858
|
renderer.updateDrawablePosition(text.drawableID, [textX, centerY]);
|
|
7426
|
-
if (
|
|
8859
|
+
if (continueIndicator) renderer.updateDrawablePosition(continueIndicator.drawableID, [textX + textSize.width / 2 - indicatorSize.width / 2 - contentGap * scaleMultiplier, centerY - textSize.height / 2 + indicatorSize.height / 2 + contentGap * scaleMultiplier]);
|
|
7427
8860
|
updateVisibility();
|
|
7428
8861
|
};
|
|
7429
8862
|
const originalVisualChange = actor.onTargetVisualChange;
|
|
@@ -7431,7 +8864,7 @@
|
|
|
7431
8864
|
originalVisualChange?.(changedTarget);
|
|
7432
8865
|
position();
|
|
7433
8866
|
};
|
|
7434
|
-
if (
|
|
8867
|
+
if (currentStyle.placement.basis === "actor") actor.onTargetVisualChange = visualChangeHook;
|
|
7435
8868
|
return Object.freeze({
|
|
7436
8869
|
targets,
|
|
7437
8870
|
setLayerVisible(layer, visible) {
|
|
@@ -7439,6 +8872,16 @@
|
|
|
7439
8872
|
layerVisibility.set(layer, visible);
|
|
7440
8873
|
updateVisibility();
|
|
7441
8874
|
},
|
|
8875
|
+
updateStyle(nextStyle) {
|
|
8876
|
+
if (disposed) return;
|
|
8877
|
+
const wasActorRelative = currentStyle.placement.basis === "actor";
|
|
8878
|
+
currentStyle = nextStyle;
|
|
8879
|
+
const isActorRelative = currentStyle.placement.basis === "actor";
|
|
8880
|
+
if (wasActorRelative && !isActorRelative) {
|
|
8881
|
+
if (actor.onTargetVisualChange === visualChangeHook) actor.onTargetVisualChange = originalVisualChange ?? null;
|
|
8882
|
+
} else if (!wasActorRelative && isActorRelative) actor.onTargetVisualChange = visualChangeHook;
|
|
8883
|
+
position();
|
|
8884
|
+
},
|
|
7442
8885
|
show() {
|
|
7443
8886
|
if (disposed) return;
|
|
7444
8887
|
surfaceVisible = true;
|
|
@@ -7452,7 +8895,7 @@
|
|
|
7452
8895
|
dispose() {
|
|
7453
8896
|
if (disposed) return;
|
|
7454
8897
|
disposed = true;
|
|
7455
|
-
if (
|
|
8898
|
+
if (currentStyle.placement.basis === "actor" && actor.onTargetVisualChange === visualChangeHook) actor.onTargetVisualChange = originalVisualChange ?? null;
|
|
7456
8899
|
for (const target of [...drawables].reverse()) renderer.destroyDrawable(target.drawableID, spriteLayer);
|
|
7457
8900
|
if (bodySkinId !== void 0) {
|
|
7458
8901
|
renderer.destroySkin(bodySkinId);
|
|
@@ -7471,25 +8914,31 @@
|
|
|
7471
8914
|
if (!isRecord(runtimeInput)) throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-001", "Bubble requires the TurboWarp runtime.");
|
|
7472
8915
|
const runtime = runtimeInput;
|
|
7473
8916
|
const renderer = requireRenderer(runtime.renderer);
|
|
7474
|
-
const
|
|
8917
|
+
const getAssetExtension = () => requireAssetManager(runtime.ext_kubohiroyaassetmanager);
|
|
7475
8918
|
const svgTextExtension = options.svgText ? null : requireSvgText(runtime.ext_kubohiroyasvgtext);
|
|
7476
8919
|
return createBubbleComposition({
|
|
7477
|
-
|
|
8920
|
+
imageResolver: options.imageResolver ?? {
|
|
7478
8921
|
isRegistered(name) {
|
|
7479
|
-
return
|
|
8922
|
+
return getAssetExtension().isLoaded({ NAME: name });
|
|
7480
8923
|
},
|
|
7481
8924
|
getMimeType(name) {
|
|
7482
|
-
return
|
|
8925
|
+
return getAssetExtension().getAssetMimeType({ NAME: name });
|
|
7483
8926
|
},
|
|
7484
8927
|
async applyToTarget(name, target) {
|
|
7485
8928
|
const drawableID = target.drawableID;
|
|
7486
8929
|
if (!Number.isInteger(drawableID) || drawableID < 0) throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-001", "Bubble image target drawable is invalid.");
|
|
7487
|
-
const skin = await
|
|
8930
|
+
const skin = await getAssetExtension().resolveSkin(name);
|
|
7488
8931
|
if (!isRecord(skin) || !Number.isInteger(skin.skinId) || skin.skinId < 0) throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-002", `Asset Manager did not resolve an image skin: ${String(name)}`);
|
|
7489
8932
|
renderer.updateDrawableSkinId(drawableID, skin.skinId);
|
|
7490
8933
|
runtime.requestRedraw?.();
|
|
7491
8934
|
}
|
|
7492
8935
|
},
|
|
8936
|
+
audio: options.audio ?? { async playSound(name, playOptions = {}) {
|
|
8937
|
+
const extension = getAssetExtension();
|
|
8938
|
+
const method = playOptions.untilDone ? extension?.playSoundUntilDone : extension?.playSound;
|
|
8939
|
+
if (typeof method !== "function") throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-002", "TurboWarp Asset Manager does not provide audio playback.");
|
|
8940
|
+
await method.call(extension, { NAME: name });
|
|
8941
|
+
} },
|
|
7493
8942
|
svgText: options.svgText ?? {
|
|
7494
8943
|
setText({ styleName, target, text }) {
|
|
7495
8944
|
svgTextExtension?.setText({
|
|
@@ -7499,6 +8948,11 @@
|
|
|
7499
8948
|
},
|
|
7500
8949
|
releaseTarget(target) {
|
|
7501
8950
|
svgTextExtension?.releaseTextActor(target);
|
|
8951
|
+
},
|
|
8952
|
+
measureText({ styleName, text }) {
|
|
8953
|
+
const measureText = svgTextExtension?.measureText;
|
|
8954
|
+
if (typeof measureText !== "function") throw new BubbleRuntimeAdapterError("BUBBLE-RUNTIME-003", "SVG Text does not provide text measurement.");
|
|
8955
|
+
return measureText.call(svgTextExtension, styleName, text);
|
|
7502
8956
|
}
|
|
7503
8957
|
},
|
|
7504
8958
|
createSurface({ actor, actorKey, style }) {
|
|
@@ -7516,10 +8970,10 @@
|
|
|
7516
8970
|
var validAnimationModes = /* @__PURE__ */ new Set([
|
|
7517
8971
|
"idle",
|
|
7518
8972
|
"talking",
|
|
7519
|
-
"awaiting-
|
|
8973
|
+
"awaiting-continue"
|
|
7520
8974
|
]);
|
|
7521
8975
|
var EXTENSION_DOCS_URI = "https://kubohiroya.github.io/turbowarp-bubble/";
|
|
7522
|
-
var EXTENSION_VERSION = "0.
|
|
8976
|
+
var EXTENSION_VERSION = "0.2.0";
|
|
7523
8977
|
function extensionError(message) {
|
|
7524
8978
|
const error = /* @__PURE__ */ new Error(`[Bubble] ${message}`);
|
|
7525
8979
|
Object.defineProperty(error, "code", { value: "BUBBLE-EXTENSION-001" });
|
|
@@ -7648,18 +9102,18 @@
|
|
|
7648
9102
|
setBlinkFrames(args) {
|
|
7649
9103
|
this.setPortraitAnimation("blink", args);
|
|
7650
9104
|
}
|
|
7651
|
-
|
|
7652
|
-
this.setPortraitAnimation("
|
|
9105
|
+
setLipSyncFrames(args) {
|
|
9106
|
+
this.setPortraitAnimation("lipSync", args);
|
|
7653
9107
|
}
|
|
7654
|
-
|
|
9108
|
+
setContinueFrames(args) {
|
|
7655
9109
|
const style = this.requireStyle(args.STYLE);
|
|
7656
9110
|
const frames = this.parseFrames(args.ASSETS);
|
|
7657
|
-
if (frames.length === 1) throw extensionError("
|
|
7658
|
-
const
|
|
7659
|
-
const {
|
|
9111
|
+
if (frames.length === 1) throw extensionError("continue frames must contain at least two assets.");
|
|
9112
|
+
const continueIndicator = frames.length === 0 ? void 0 : this.animationInput(frames, args.SECONDS, "continue");
|
|
9113
|
+
const { continueIndicator: previousContinue, ...withoutContinue } = style;
|
|
7660
9114
|
const nextStyle = Object.freeze({
|
|
7661
|
-
...
|
|
7662
|
-
...
|
|
9115
|
+
...withoutContinue,
|
|
9116
|
+
...continueIndicator ? { continueIndicator } : {}
|
|
7663
9117
|
});
|
|
7664
9118
|
this.installStyle(nextStyle);
|
|
7665
9119
|
}
|
|
@@ -7672,12 +9126,12 @@
|
|
|
7672
9126
|
async setBubbleAnimationMode(args, util) {
|
|
7673
9127
|
const target = this.requireTarget(util);
|
|
7674
9128
|
const mode = this.toString(args.MODE).trim().toLowerCase();
|
|
7675
|
-
if (!validAnimationModes.has(mode)) throw extensionError("animation mode must be talking, awaiting-
|
|
9129
|
+
if (!validAnimationModes.has(mode)) throw extensionError("animation mode must be talking, awaiting-continue, or idle.");
|
|
7676
9130
|
const handle = this.handles.get(target.id);
|
|
7677
9131
|
if (!handle) throw extensionError("this target does not have an active bubble.");
|
|
7678
9132
|
await handle.setAnimationMode(mode);
|
|
7679
9133
|
}
|
|
7680
|
-
async
|
|
9134
|
+
async waitForBubbleContinue(args, util) {
|
|
7681
9135
|
const target = this.requireTarget(util);
|
|
7682
9136
|
const handle = this.handles.get(target.id);
|
|
7683
9137
|
if (!handle) throw extensionError("this target does not have an active bubble.");
|
|
@@ -7690,7 +9144,7 @@
|
|
|
7690
9144
|
if (!this.isRecord(runtimeExpression) || typeof runtimeExpression.runtimeCondition !== "function") throw extensionError("Bubble wait requires Runtime Expression. Load @kubohiroya/turbowarp-runtime-expression before using this block.");
|
|
7691
9145
|
if (typeof this.runtime.on !== "function" || typeof this.runtime.off !== "function") throw extensionError("TurboWarp runtime events are unavailable.");
|
|
7692
9146
|
this.cancelWait(target.id, "Bubble wait was replaced.");
|
|
7693
|
-
await handle.setAnimationMode("awaiting-
|
|
9147
|
+
await handle.setAnimationMode("awaiting-continue");
|
|
7694
9148
|
await new Promise((resolve, reject) => {
|
|
7695
9149
|
let settled = false;
|
|
7696
9150
|
let timeoutHandle;
|
|
@@ -7820,10 +9274,10 @@
|
|
|
7820
9274
|
base: portrait.base,
|
|
7821
9275
|
...field === "blink" ? {
|
|
7822
9276
|
...animation ? { blink: animation } : {},
|
|
7823
|
-
...portrait.
|
|
9277
|
+
...portrait.lipSync ? { lipSync: portrait.lipSync } : {}
|
|
7824
9278
|
} : {
|
|
7825
9279
|
...portrait.blink ? { blink: portrait.blink } : {},
|
|
7826
|
-
...animation ? {
|
|
9280
|
+
...animation ? { lipSync: animation } : {}
|
|
7827
9281
|
}
|
|
7828
9282
|
});
|
|
7829
9283
|
this.installStyle(Object.freeze({
|