@paulirish/trace_engine 0.0.67 → 0.0.69
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/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
- package/README.md +17 -1
- package/core/common/ParsedURL.d.ts +0 -2
- package/core/common/ParsedURL.js +3 -3
- package/core/common/ParsedURL.js.map +1 -1
- package/core/platform/StringUtilities.d.ts +15 -4
- package/core/platform/StringUtilities.js +48 -12
- package/core/platform/StringUtilities.js.map +1 -1
- package/generated/protocol.d.ts +89 -19
- package/generated/protocol.js +9 -4
- package/locales/af.json +12 -12
- package/locales/am.json +19 -19
- package/locales/ar.json +56 -56
- package/locales/as.json +69 -69
- package/locales/az.json +22 -22
- package/locales/be.json +46 -46
- package/locales/bg.json +17 -17
- package/locales/bn.json +76 -76
- package/locales/bs.json +23 -23
- package/locales/ca.json +14 -14
- package/locales/cs.json +13 -13
- package/locales/cy.json +21 -21
- package/locales/da.json +12 -12
- package/locales/de.json +10 -10
- package/locales/el.json +14 -14
- package/locales/en-GB.json +73 -73
- package/locales/en-US.json +3 -6
- package/locales/en-XL.json +3 -6
- package/locales/es-419.json +64 -64
- package/locales/es.json +44 -44
- package/locales/et.json +48 -48
- package/locales/eu.json +18 -18
- package/locales/fa.json +39 -39
- package/locales/fi.json +11 -11
- package/locales/fil.json +34 -34
- package/locales/fr-CA.json +49 -49
- package/locales/fr.json +18 -18
- package/locales/gl.json +33 -33
- package/locales/gu.json +39 -39
- package/locales/he.json +72 -72
- package/locales/hi.json +40 -40
- package/locales/hr.json +26 -26
- package/locales/hu.json +56 -56
- package/locales/hy.json +19 -19
- package/locales/id.json +68 -68
- package/locales/is.json +11 -11
- package/locales/it.json +44 -44
- package/locales/ja.json +15 -15
- package/locales/ka.json +68 -68
- package/locales/kk.json +44 -44
- package/locales/km.json +18 -18
- package/locales/kn.json +28 -28
- package/locales/ko.json +11 -11
- package/locales/ky.json +22 -22
- package/locales/lo.json +33 -33
- package/locales/lt.json +9 -9
- package/locales/lv.json +35 -35
- package/locales/mk.json +18 -18
- package/locales/ml.json +19 -19
- package/locales/mn.json +40 -40
- package/locales/mr.json +12 -12
- package/locales/ms.json +15 -15
- package/locales/my.json +62 -62
- package/locales/ne.json +42 -42
- package/locales/nl.json +33 -33
- package/locales/no.json +17 -17
- package/locales/or.json +54 -54
- package/locales/pa.json +24 -24
- package/locales/pl.json +32 -32
- package/locales/pt-PT.json +12 -12
- package/locales/pt.json +41 -41
- package/locales/ro.json +11 -11
- package/locales/ru.json +40 -40
- package/locales/si.json +36 -36
- package/locales/sk.json +65 -65
- package/locales/sl.json +13 -13
- package/locales/sq.json +21 -21
- package/locales/sr-Latn.json +17 -17
- package/locales/sr.json +17 -17
- package/locales/sv.json +13 -13
- package/locales/sw.json +69 -69
- package/locales/ta.json +39 -39
- package/locales/te.json +38 -38
- package/locales/th.json +38 -38
- package/locales/tr.json +17 -17
- package/locales/uk.json +23 -23
- package/locales/ur.json +13 -13
- package/locales/uz.json +15 -15
- package/locales/vi.json +43 -43
- package/locales/zh-HK.json +38 -38
- package/locales/zh-TW.json +35 -35
- package/locales/zh.json +73 -73
- package/locales/zu.json +53 -53
- package/models/cpu_profile/CPUProfileDataModel.d.ts +0 -33
- package/models/cpu_profile/CPUProfileDataModel.js +14 -14
- package/models/cpu_profile/CPUProfileDataModel.js.map +1 -1
- package/models/cpu_profile/ProfileTreeModel.d.ts +1 -2
- package/models/cpu_profile/ProfileTreeModel.js +4 -4
- package/models/cpu_profile/ProfileTreeModel.js.map +1 -1
- package/models/trace/EventsSerializer.js +1 -13
- package/models/trace/EventsSerializer.js.map +1 -1
- package/models/trace/LanternComputationData.js +36 -10
- package/models/trace/LanternComputationData.js.map +1 -1
- package/models/trace/ModelImpl.js +0 -2
- package/models/trace/ModelImpl.js.map +1 -1
- package/models/trace/Processor.js +16 -8
- package/models/trace/Processor.js.map +1 -1
- package/models/trace/extras/ThirdParties.js +4 -6
- package/models/trace/extras/ThirdParties.js.map +1 -1
- package/models/trace/extras/TraceFilter.d.ts +1 -0
- package/models/trace/extras/TraceFilter.js +18 -8
- package/models/trace/extras/TraceFilter.js.map +1 -1
- package/models/trace/extras/TraceTree.d.ts +13 -16
- package/models/trace/extras/TraceTree.js +161 -110
- package/models/trace/extras/TraceTree.js.map +1 -1
- package/models/trace/handlers/ExtensionTraceDataHandler.d.ts +0 -5
- package/models/trace/handlers/ExtensionTraceDataHandler.js +0 -5
- package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
- package/models/trace/handlers/FlowsHandler.js +34 -19
- package/models/trace/handlers/FlowsHandler.js.map +1 -1
- package/models/trace/handlers/InitiatorsHandler.js +22 -34
- package/models/trace/handlers/InitiatorsHandler.js.map +1 -1
- package/models/trace/handlers/LayoutShiftsHandler.js +2 -6
- package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
- package/models/trace/handlers/MetaHandler.js +3 -0
- package/models/trace/handlers/MetaHandler.js.map +1 -1
- package/models/trace/handlers/NetworkRequestsHandler.js +12 -6
- package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
- package/models/trace/handlers/RendererHandler.js +7 -6
- package/models/trace/handlers/RendererHandler.js.map +1 -1
- package/models/trace/handlers/SamplesHandler.d.ts +0 -1
- package/models/trace/handlers/SamplesHandler.js +11 -6
- package/models/trace/handlers/SamplesHandler.js.map +1 -1
- package/models/trace/handlers/ScriptsHandler.js +24 -22
- package/models/trace/handlers/ScriptsHandler.js.map +1 -1
- package/models/trace/handlers/types.d.ts +15 -0
- package/models/trace/handlers/types.js.map +1 -1
- package/models/trace/helpers/Extensions.js +1 -3
- package/models/trace/helpers/Extensions.js.map +1 -1
- package/models/trace/helpers/SamplesIntegrator.d.ts +17 -14
- package/models/trace/helpers/SamplesIntegrator.js +147 -84
- package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
- package/models/trace/helpers/SyntheticEvents.d.ts +0 -8
- package/models/trace/helpers/SyntheticEvents.js +10 -33
- package/models/trace/helpers/SyntheticEvents.js.map +1 -1
- package/models/trace/helpers/Trace.js +19 -14
- package/models/trace/helpers/Trace.js.map +1 -1
- package/models/trace/helpers/TreeHelpers.d.ts +13 -1
- package/models/trace/helpers/TreeHelpers.js +35 -8
- package/models/trace/helpers/TreeHelpers.js.map +1 -1
- package/models/trace/insights/DuplicatedJavaScript.js +1 -2
- package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
- package/models/trace/insights/RenderBlocking.js +3 -1
- package/models/trace/insights/RenderBlocking.js.map +1 -1
- package/models/trace/insights/SlowCSSSelector.js +2 -2
- package/models/trace/insights/SlowCSSSelector.js.map +1 -1
- package/models/trace/lantern/metrics/LargestContentfulPaint.d.ts +6 -1
- package/models/trace/lantern/metrics/LargestContentfulPaint.js +130 -5
- package/models/trace/lantern/metrics/LargestContentfulPaint.js.map +1 -1
- package/models/trace/lantern/simulation/Simulator.d.ts +4 -0
- package/models/trace/lantern/simulation/Simulator.js +8 -1
- package/models/trace/lantern/simulation/Simulator.js.map +1 -1
- package/models/trace/lantern/types/Lantern.d.ts +4 -0
- package/models/trace/lantern/types/Lantern.js.map +1 -1
- package/models/trace/types/TraceEvents.d.ts +21 -19
- package/models/trace/types/TraceEvents.js.map +1 -1
- package/package.json +1 -1
- package/test/test-trace-engine.mjs +20 -17
- package/third_party/legacy-javascript/lib/legacy-javascript.js +2 -2
|
@@ -48,6 +48,12 @@ export declare const stripLineBreaks: (inputStr: string) => string;
|
|
|
48
48
|
* @returns `true` if the `inputStr` follows the extended Kebab Case convention.
|
|
49
49
|
*/
|
|
50
50
|
export declare const isExtendedKebabCase: (inputStr: string) => boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Replaces any sequence of non-alphanumeric characters with a single dash, strips leading and
|
|
53
|
+
* trailing dashes, and converts letters to lowercase, leaving a kebab-case identifier usable as viewId.
|
|
54
|
+
* If the input contains only non-alphanumeric characters, returns a falsy empty string.
|
|
55
|
+
*/
|
|
56
|
+
export declare const sanitizeIdentifier: (id: string) => Lowercase<string>;
|
|
51
57
|
export declare const toTitleCase: (inputStr: string) => string;
|
|
52
58
|
export declare const removeURLFragment: (inputStr: string) => string;
|
|
53
59
|
export declare const regexSpecialCharacters: () => string;
|
|
@@ -116,11 +122,16 @@ export declare const concatBase64: (lhs: string, rhs: string) => string;
|
|
|
116
122
|
* the value with a single quote (`'`) tells spreadsheet apps to treat the
|
|
117
123
|
* cell as literal text (and they hide the leading `'` when displaying it).
|
|
118
124
|
* - Example without commas: `=SUM(A1:A2)` -> `'=SUM(A1:A2)`
|
|
119
|
-
* 2. RFC 4180
|
|
120
|
-
* If the cell also contains commas (`,`),
|
|
121
|
-
* it is wrapped in `"..."` (with inner `"`
|
|
122
|
-
* do not split the cell across columns or
|
|
125
|
+
* 2. Structural CSV quoting (RFC 4180, extended):
|
|
126
|
+
* If the cell also contains commas (`,`), semicolons (`;`), tabs, double
|
|
127
|
+
* quotes (`"`), or newlines, it is wrapped in `"..."` (with inner `"`
|
|
128
|
+
* doubled to `""`) so CSV parsers do not split the cell across columns or
|
|
129
|
+
* rows. `;` and tab are included because spreadsheet apps can use them as
|
|
130
|
+
* the column separator (for example, Excel in many locales uses `;`).
|
|
131
|
+
* Without quotes, `x;=1+1` would split into a new cell that starts with
|
|
132
|
+
* `=` and skips the `'` prefix from step 1.
|
|
123
133
|
* - Example with commas: `=SUM(1,2)` -> `"'=SUM(1,2)"`
|
|
134
|
+
* - Example with a semicolon: `x;=1+1` -> `"x;=1+1"`
|
|
124
135
|
* - Example starting with a literal quote: `"=SUM(1,2)"` -> `"""=SUM(1,2)"""`
|
|
125
136
|
* (not treated as a formula since the first character is `"`, not `=`).
|
|
126
137
|
*/
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
let graphemeSegmenter = null;
|
|
5
|
+
// Excludes control characters (0x00-0x1F, 0x7F) to prevent splitting \r\n, which forms a single grapheme cluster.
|
|
6
|
+
const PRINTABLE_ASCII_REGEX = /^[\x20-\x7e]*$/;
|
|
7
|
+
function getGraphemeSegmenter() {
|
|
8
|
+
if (!graphemeSegmenter) {
|
|
9
|
+
graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
10
|
+
}
|
|
11
|
+
return graphemeSegmenter;
|
|
12
|
+
}
|
|
5
13
|
export const escapeCharacters = (inputString, charsToEscape) => {
|
|
6
14
|
let foundChar = false;
|
|
7
15
|
for (let i = 0; i < charsToEscape.length; ++i) {
|
|
@@ -291,6 +299,14 @@ const EXTENDED_KEBAB_CASE_REGEXP = /^([a-z0-9]+(?:-[a-z0-9]+)*\.)*[a-z0-9]+(?:-[
|
|
|
291
299
|
export const isExtendedKebabCase = (inputStr) => {
|
|
292
300
|
return EXTENDED_KEBAB_CASE_REGEXP.test(inputStr);
|
|
293
301
|
};
|
|
302
|
+
/**
|
|
303
|
+
* Replaces any sequence of non-alphanumeric characters with a single dash, strips leading and
|
|
304
|
+
* trailing dashes, and converts letters to lowercase, leaving a kebab-case identifier usable as viewId.
|
|
305
|
+
* If the input contains only non-alphanumeric characters, returns a falsy empty string.
|
|
306
|
+
*/
|
|
307
|
+
export const sanitizeIdentifier = (id) => {
|
|
308
|
+
return id.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
309
|
+
};
|
|
294
310
|
export const toTitleCase = (inputStr) => {
|
|
295
311
|
return inputStr.substring(0, 1).toUpperCase() + inputStr.substring(1);
|
|
296
312
|
};
|
|
@@ -377,7 +393,6 @@ export const trimMiddle = (str, maxLength) => {
|
|
|
377
393
|
if (str.length <= maxLength) {
|
|
378
394
|
return str;
|
|
379
395
|
}
|
|
380
|
-
const segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
381
396
|
// If the max length is so small it can't fit the ellipsis, just return the ellipsis.
|
|
382
397
|
const ellipsis = '…';
|
|
383
398
|
const ellipsisLength = 1;
|
|
@@ -388,6 +403,14 @@ export const trimMiddle = (str, maxLength) => {
|
|
|
388
403
|
const freeSpace = maxLength - ellipsisLength;
|
|
389
404
|
const leftCount = Math.ceil(freeSpace / 2);
|
|
390
405
|
const rightCount = Math.floor(freeSpace / 2);
|
|
406
|
+
// Printable ASCII characters (0x20-0x7E) cannot form multi-code-unit grapheme clusters.
|
|
407
|
+
// Checking one extra character inside each truncation boundary guarantees both slice boundaries
|
|
408
|
+
// fall between graphemes and the string contains at least maxLength + 1 graphemes.
|
|
409
|
+
if (PRINTABLE_ASCII_REGEX.test(str.slice(0, leftCount + 1)) &&
|
|
410
|
+
PRINTABLE_ASCII_REGEX.test(str.slice(str.length - rightCount - 1))) {
|
|
411
|
+
return str.slice(0, leftCount) + ellipsis + str.slice(str.length - rightCount);
|
|
412
|
+
}
|
|
413
|
+
const segmenter = getGraphemeSegmenter();
|
|
391
414
|
let currentGraphemeCount = 0;
|
|
392
415
|
let leftEndIndex = 0;
|
|
393
416
|
// Sliding Window Buffer
|
|
@@ -426,7 +449,15 @@ export const trimEndWithMaxLength = (str, maxLength) => {
|
|
|
426
449
|
}
|
|
427
450
|
const ellipsis = '…';
|
|
428
451
|
const ellipsisLength = 1;
|
|
429
|
-
|
|
452
|
+
if (maxLength <= ellipsisLength) {
|
|
453
|
+
return ellipsis;
|
|
454
|
+
}
|
|
455
|
+
// Printable ASCII characters (0x20-0x7E) cannot form multi-code-unit grapheme clusters.
|
|
456
|
+
// Checking up to maxLength + 1 characters guarantees at least maxLength + 1 graphemes in O(maxLength).
|
|
457
|
+
if (PRINTABLE_ASCII_REGEX.test(str.slice(0, maxLength + 1))) {
|
|
458
|
+
return str.slice(0, maxLength - ellipsisLength) + ellipsis;
|
|
459
|
+
}
|
|
460
|
+
const segmenter = getGraphemeSegmenter();
|
|
430
461
|
const iterator = segmenter.segment(str)[Symbol.iterator]();
|
|
431
462
|
let lastSegmentIndex = 0;
|
|
432
463
|
for (let i = 0; i <= maxLength - ellipsisLength; i++) {
|
|
@@ -463,11 +494,11 @@ export const truncateToCodeUnitLength = (str, maxCodeUnits) => {
|
|
|
463
494
|
if (str.length <= maxCodeUnits) {
|
|
464
495
|
return str;
|
|
465
496
|
}
|
|
466
|
-
if (
|
|
467
|
-
|
|
497
|
+
if (PRINTABLE_ASCII_REGEX.test(str.slice(0, maxCodeUnits + 1))) {
|
|
498
|
+
return str.slice(0, maxCodeUnits);
|
|
468
499
|
}
|
|
469
500
|
let lastSafeIndex = 0;
|
|
470
|
-
for (const { index, segment } of
|
|
501
|
+
for (const { index, segment } of getGraphemeSegmenter().segment(str)) {
|
|
471
502
|
if (index + segment.length > maxCodeUnits) {
|
|
472
503
|
break;
|
|
473
504
|
}
|
|
@@ -706,24 +737,29 @@ function isCsvFormula(value) {
|
|
|
706
737
|
* the value with a single quote (`'`) tells spreadsheet apps to treat the
|
|
707
738
|
* cell as literal text (and they hide the leading `'` when displaying it).
|
|
708
739
|
* - Example without commas: `=SUM(A1:A2)` -> `'=SUM(A1:A2)`
|
|
709
|
-
* 2. RFC 4180
|
|
710
|
-
* If the cell also contains commas (`,`),
|
|
711
|
-
* it is wrapped in `"..."` (with inner `"`
|
|
712
|
-
* do not split the cell across columns or
|
|
740
|
+
* 2. Structural CSV quoting (RFC 4180, extended):
|
|
741
|
+
* If the cell also contains commas (`,`), semicolons (`;`), tabs, double
|
|
742
|
+
* quotes (`"`), or newlines, it is wrapped in `"..."` (with inner `"`
|
|
743
|
+
* doubled to `""`) so CSV parsers do not split the cell across columns or
|
|
744
|
+
* rows. `;` and tab are included because spreadsheet apps can use them as
|
|
745
|
+
* the column separator (for example, Excel in many locales uses `;`).
|
|
746
|
+
* Without quotes, `x;=1+1` would split into a new cell that starts with
|
|
747
|
+
* `=` and skips the `'` prefix from step 1.
|
|
713
748
|
* - Example with commas: `=SUM(1,2)` -> `"'=SUM(1,2)"`
|
|
749
|
+
* - Example with a semicolon: `x;=1+1` -> `"x;=1+1"`
|
|
714
750
|
* - Example starting with a literal quote: `"=SUM(1,2)"` -> `"""=SUM(1,2)"""`
|
|
715
751
|
* (not treated as a formula since the first character is `"`, not `=`).
|
|
716
752
|
*/
|
|
717
753
|
export const escapeCsvCell = function (value) {
|
|
718
754
|
// Step 1: Prefix formula-like text with `'` so spreadsheets render it as literal text.
|
|
719
755
|
let escaped = isCsvFormula(value) ? `'${value}` : value;
|
|
720
|
-
// Step 2: Apply
|
|
721
|
-
//
|
|
756
|
+
// Step 2: Apply double-quoting if the cell contains quotes, any common
|
|
757
|
+
// column separator, or line breaks so the CSV structure stays intact.
|
|
722
758
|
if (escaped.includes('"')) {
|
|
723
759
|
escaped = escaped.replace(/"/g, '""');
|
|
724
760
|
return `"${escaped}"`;
|
|
725
761
|
}
|
|
726
|
-
if (
|
|
762
|
+
if (/[,;\t\r\n]/.test(escaped)) {
|
|
727
763
|
return `"${escaped}"`;
|
|
728
764
|
}
|
|
729
765
|
return escaped;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringUtilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/StringUtilities.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAI7B,IAAI,iBAAiB,GAAwB,IAAI,CAAC;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAmB,EAAE,aAAqB,EAAU,EAAE;IACrF,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAC9C,IAAI,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;YACxD,SAAS,GAAG,IAAI,CAAC;YACjB,MAAM;QACR,CAAC;IACH,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,WAAW,CAAC,CA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,EAAE,IAAI,CAAC,CAAC,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,6CAA6C,CAAC;AAEvE;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAa;IACjC,6EAA6E;IAC7E,+EAA+E;IAC/E,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAClC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjF,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAS,KAAa;IACjD,uFAAuF;IACvF,IAAI,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAExD,8EAA8E;IAC9E,4DAA4D;IAC5D,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACtC,OAAO,IAAI,OAAO,GAAG,CAAC;IACxB,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9E,OAAO,IAAI,OAAO,GAAG,CAAC;IACxB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// Copyright 2020 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type {Brand} from './Brand.js';\n\nlet graphemeSegmenter: Intl.Segmenter|null = null;\n\nexport const escapeCharacters = (inputString: string, charsToEscape: string): string => {\n let foundChar = false;\n for (let i = 0; i < charsToEscape.length; ++i) {\n if (inputString.indexOf(charsToEscape.charAt(i)) !== -1) {\n foundChar = true;\n break;\n }\n }\n\n if (!foundChar) {\n return String(inputString);\n }\n\n let result = '';\n for (let i = 0; i < inputString.length; ++i) {\n if (charsToEscape.indexOf(inputString.charAt(i)) !== -1) {\n result += '\\\\';\n }\n result += inputString.charAt(i);\n }\n\n return result;\n};\n\nconst toHexadecimal = (charCode: number, padToLength: number): string => {\n return charCode.toString(16).toUpperCase().padStart(padToLength, '0');\n};\n\n// Remember to update the third group in the regexps patternsToEscape and\n// patternsToEscapePlusSingleQuote when adding new entries in this map.\nconst escapedReplacements = new Map([\n ['\\b', '\\\\b'],\n ['\\f', '\\\\f'],\n ['\\n', '\\\\n'],\n ['\\r', '\\\\r'],\n ['\\t', '\\\\t'],\n ['\\v', '\\\\v'],\n ['\\'', '\\\\\\''],\n ['\\\\', '\\\\\\\\'],\n ['<!--', '\\\\x3C!--'],\n ['<script', '\\\\x3Cscript'],\n ['</script', '\\\\x3C/script'],\n]);\n\nconst UNICODE_ESCAPE_SOURCE = '[\\\\p{Format}\\\\p{Surrogate}]';\nconst UNICODE_ESCAPE_REGEX = new RegExp(UNICODE_ESCAPE_SOURCE, 'u');\nconst UNICODE_ESCAPE_GLOBAL_REGEX = new RegExp(UNICODE_ESCAPE_SOURCE, 'gu');\n\nconst UNICODE_ESCAPE_EXCEPT_ZWSP_SOURCE = '(?![\\\\u200B\\\\u200C\\\\u200D])[\\\\p{Format}]|\\\\p{Surrogate}';\nconst UNICODE_ESCAPE_EXCEPT_ZWSP_REGEX = new RegExp(UNICODE_ESCAPE_EXCEPT_ZWSP_SOURCE, 'u');\nconst UNICODE_ESCAPE_EXCEPT_ZWSP_GLOBAL_REGEX = new RegExp(UNICODE_ESCAPE_EXCEPT_ZWSP_SOURCE, 'gu');\n\n/**\n * Escapes formatting and surrogate characters in the string into literal Unicode escape sequences (e.g. \\u200B).\n * Use this when displaying strings to developers for inspection (e.g. in the Console or Object properties)\n * where you want hidden or invisible characters to be explicitly visible as literal text.\n */\nexport const escapeUnicodeAsText = (content: string): string => {\n if (!UNICODE_ESCAPE_REGEX.test(content)) {\n return content;\n }\n return content.replaceAll(UNICODE_ESCAPE_GLOBAL_REGEX, match => {\n return match.split('').map(char => '\\\\u' + toHexadecimal(char.charCodeAt(0), 4)).join('');\n });\n};\n\n/**\n * Escapes dangerous formatting and surrogate characters (like bidi override characters) to prevent\n * security and layout issues, but leaves safe, layout-critical zero-width formatting characters\n * (Zero Width Space \\u200B, Zero Width Non-Joiner \\u200C, and Zero Width Joiner \\u200D) untouched.\n * Use this when rendering user-controlled content inside templates or HTML markup where you want formatting\n * characters to function normally for word wrapping or rendering layout, rather than showing as literal text.\n */\nexport const safeEscapeUnicode = (content: string): string => {\n if (!UNICODE_ESCAPE_EXCEPT_ZWSP_REGEX.test(content)) {\n return content;\n }\n return content.replaceAll(UNICODE_ESCAPE_EXCEPT_ZWSP_GLOBAL_REGEX, match => {\n return match.split('').map(char => '\\\\u' + toHexadecimal(char.charCodeAt(0), 4)).join('');\n });\n};\n\nexport const formatAsJSLiteral = (content: string): string => {\n const patternsToEscape = /(\\\\|<(?:!--|\\/?script))|(\\p{Control}|\\p{Format})|(\\p{Surrogate})/giu;\n const patternsToEscapePlusSingleQuote = /(\\\\|'|<(?:!--|\\/?script))|(\\p{Control}|\\p{Format})|(\\p{Surrogate})/giu;\n const escapePattern = (match: string, pattern: string, controlChar: string, loneSurrogate: string): string => {\n if (controlChar) {\n if (escapedReplacements.has(controlChar)) {\n // @ts-expect-error https://github.com/microsoft/TypeScript/issues/13086\n return escapedReplacements.get(controlChar);\n }\n return controlChar.split('')\n .map(char => {\n const charCode = char.charCodeAt(0);\n if (controlChar.length === 1 && charCode <= 0xFF) {\n return '\\\\x' + toHexadecimal(charCode, 2);\n }\n return '\\\\u' + toHexadecimal(charCode, 4);\n })\n .join('');\n }\n if (loneSurrogate) {\n const fourDigitHex = toHexadecimal(loneSurrogate.charCodeAt(0), 4);\n return '\\\\u' + fourDigitHex;\n }\n if (pattern) {\n if (pattern.startsWith('<')) {\n return '\\\\x3C' + pattern.slice(1);\n }\n return escapedReplacements.get(pattern) || '';\n }\n return match;\n };\n\n let escapedContent = '';\n let quote = '';\n if (!content.includes('\\'')) {\n quote = '\\'';\n escapedContent = content.replaceAll(patternsToEscape, escapePattern);\n } else if (!content.includes('\"')) {\n quote = '\"';\n escapedContent = content.replaceAll(patternsToEscape, escapePattern);\n } else if (!content.includes('`') && !content.includes('${')) {\n quote = '`';\n escapedContent = content.replaceAll(patternsToEscape, escapePattern);\n } else {\n quote = '\\'';\n escapedContent = content.replaceAll(patternsToEscapePlusSingleQuote, escapePattern);\n }\n return `${quote}${escapedContent}${quote}`;\n};\n\n/**\n * This implements a subset of the sprintf() function described in the Single UNIX\n * Specification. It supports the %s, %f, %d, and %% formatting specifiers, and\n * understands the %m$d notation to select the m-th parameter for this substitution,\n * as well as the optional precision for %s, %f, and %d.\n *\n * @param fmt format string.\n * @param args parameters to the format string.\n * @returns the formatted output string.\n */\nexport const sprintf = (fmt: string, ...args: unknown[]): string => {\n let argIndex = 0;\n const RE = /%(?:(\\d+)\\$)?(?:\\.(\\d*))?([%dfs])/g;\n return fmt.replaceAll(RE, (_: string, index?: string, precision?: string, specifier?: string) => {\n if (specifier === '%') {\n return '%';\n }\n if (index !== undefined) {\n argIndex = parseInt(index, 10) - 1;\n if (argIndex < 0) {\n throw new RangeError(`Invalid parameter index ${argIndex + 1}`);\n }\n }\n if (argIndex >= args.length) {\n throw new RangeError(`Expected at least ${argIndex + 1} format parameters, but only ${args.length} where given.`);\n }\n if (specifier === 's') {\n const argValue = String(args[argIndex++]);\n if (precision !== undefined) {\n return argValue.substring(0, Number(precision));\n }\n return argValue;\n }\n let argValue = Number(args[argIndex++]);\n if (isNaN(argValue)) {\n argValue = 0;\n }\n if (specifier === 'd') {\n return String(Math.floor(argValue)).padStart(Number(precision), '0');\n }\n if (precision !== undefined) {\n return argValue.toFixed(Number(precision));\n }\n return String(argValue);\n });\n};\n\nexport const toBase64 = (inputString: string): string => {\n /* note to the reader: we can't use btoa here because we need to\n * support Unicode correctly. See the test cases for this function and\n * also\n * https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem\n */\n\n function encodeBits(b: number): number {\n return b < 26 ? b + 65 : b < 52 ? b + 71 : b < 62 ? b - 4 : b === 62 ? 43 : b === 63 ? 47 : 65;\n }\n const encoder = new TextEncoder();\n const data = encoder.encode(inputString.toString());\n const n = data.length;\n let encoded = '';\n if (n === 0) {\n return encoded;\n }\n let shift;\n let v = 0;\n for (let i = 0; i < n; i++) {\n shift = i % 3;\n v |= data[i] << (16 >>> shift & 24);\n if (shift === 2) {\n encoded += String.fromCharCode(encodeBits(v >>> 18 & 63), encodeBits(v >>> 12 & 63), encodeBits(v >>> 6 & 63),\n encodeBits(v & 63));\n v = 0;\n }\n }\n if (shift === 0) {\n encoded += String.fromCharCode(encodeBits(v >>> 18 & 63), encodeBits(v >>> 12 & 63), 61, 61);\n } else if (shift === 1) {\n encoded += String.fromCharCode(encodeBits(v >>> 18 & 63), encodeBits(v >>> 12 & 63), encodeBits(v >>> 6 & 63), 61);\n }\n return encoded;\n};\n\nexport const findIndexesOfSubString = (inputString: string, searchString: string): number[] => {\n const matches = [];\n let i = inputString.indexOf(searchString);\n while (i !== -1) {\n matches.push(i);\n i = inputString.indexOf(searchString, i + searchString.length);\n }\n return matches;\n};\n\nexport const findLineEndingIndexes = (inputString: string): number[] => {\n const endings = findIndexesOfSubString(inputString, '\\n');\n endings.push(inputString.length);\n return endings;\n};\n\nexport const isWhitespace = (inputString: string): boolean => {\n return /^\\s*$/.test(inputString);\n};\n\nexport const trimURL = (url: string, baseURLDomain?: string): string => {\n let result = url.replace(/^(https|http|file):\\/\\//i, '');\n if (baseURLDomain) {\n if (result.toLowerCase().startsWith(baseURLDomain.toLowerCase())) {\n result = result.substr(baseURLDomain.length);\n }\n }\n return result;\n};\n\nexport const collapseWhitespace = (inputString: string): string => {\n return inputString.replace(/[\\s\\xA0]+/g, ' ');\n};\n\nexport const reverse = (inputString: string): string => {\n return inputString.split('').reverse().join('');\n};\n\nexport const replaceControlCharacters = (inputString: string): string => {\n // Replace C0 and C1 control character sets with replacement character.\n // Do not replace '\\t', \\n' and '\\r'.\n return inputString.replace(/[\\0-\\x08\\x0B\\f\\x0E-\\x1F\\x80-\\x9F]/g, '\\uFFFD');\n};\n\nexport const countWtf8Bytes = (inputString: string): number => {\n let count = 0;\n for (let i = 0; i < inputString.length; i++) {\n const c = inputString.charCodeAt(i);\n if (c <= 0x7F) {\n count++;\n } else if (c <= 0x07FF) {\n count += 2;\n } else if (c < 0xD800 || 0xDFFF < c) {\n count += 3;\n } else {\n if (c <= 0xDBFF && i + 1 < inputString.length) {\n // The current character is a leading surrogate, and there is a\n // next character.\n const next = inputString.charCodeAt(i + 1);\n if (0xDC00 <= next && next <= 0xDFFF) {\n // The next character is a trailing surrogate, meaning this\n // is a surrogate pair.\n count += 4;\n i++;\n continue;\n }\n }\n count += 3;\n }\n }\n return count;\n};\n\nexport const stripLineBreaks = (inputStr: string): string => {\n return inputStr.replace(/(\\r)?\\n/g, '');\n};\n\nconst EXTENDED_KEBAB_CASE_REGEXP = /^([a-z0-9]+(?:-[a-z0-9]+)*\\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/**\n * Tests if the `inputStr` is following the extended Kebab Case naming convention,\n * where words are separated with either a dash (`-`) or a dot (`.`), and all\n * characters must be lower-case alphanumeric.\n *\n * For example, it will yield `true` for `'my.amazing-string.literal'`, but `false`\n * for `'Another.AmazingLiteral'` or '`another_amazing_literal'`.\n *\n * @param inputStr the input string to test.\n * @returns `true` if the `inputStr` follows the extended Kebab Case convention.\n */\nexport const isExtendedKebabCase = (inputStr: string): boolean => {\n return EXTENDED_KEBAB_CASE_REGEXP.test(inputStr);\n};\n\nexport const toTitleCase = (inputStr: string): string => {\n return inputStr.substring(0, 1).toUpperCase() + inputStr.substring(1);\n};\n\nexport const removeURLFragment = (inputStr: string): string => {\n const url = new URL(inputStr);\n url.hash = '';\n return url.toString();\n};\n\nconst SPECIAL_REGEX_CHARACTERS = '^[]{}()\\\\.^$*+?|-,';\nconst SPECIAL_URL_PATTERN_CHARACTERS = '?+*(){}\\\\:';\n\nexport const regexSpecialCharacters = function(): string {\n return SPECIAL_REGEX_CHARACTERS;\n};\n\nexport const filterRegex = function(query: string): RegExp {\n let regexString = '^(?:.*\\\\0)?'; // Start from beginning or after a \\0\n for (let i = 0; i < query.length; ++i) {\n let c = query.charAt(i);\n if (SPECIAL_REGEX_CHARACTERS.indexOf(c) !== -1) {\n c = '\\\\' + c;\n }\n regexString += '[^\\\\0' + c + ']*' + c;\n }\n return new RegExp(regexString, 'i');\n};\n\nexport const createSearchRegex = function(query: string, caseSensitive: boolean, isRegex: boolean,\n matchWholeWord = false): RegExp {\n const regexFlags = caseSensitive ? 'g' : 'gi';\n let regexObject;\n\n if (isRegex) {\n try {\n regexObject = new RegExp(query, regexFlags);\n } catch {\n // Silent catch.\n }\n }\n\n if (!regexObject) {\n regexObject = createPlainTextSearchRegex(query, regexFlags);\n }\n\n if (matchWholeWord && regexObject) {\n regexObject = new RegExp(`\\\\b${regexObject.source}\\\\b`, regexFlags);\n }\n\n return regexObject;\n};\n\nexport const caseInsensetiveComparator = function(a: string, b: string): number {\n a = a.toUpperCase();\n b = b.toUpperCase();\n if (a === b) {\n return 0;\n }\n return a > b ? 1 : -1;\n};\n\nexport const hashCode = function(string?: string): number {\n if (!string) {\n return 0;\n }\n // Hash algorithm for substrings is described in \"Über die Komplexität der Multiplikation in\n // eingeschränkten Branchingprogrammmodellen\" by Woelfe.\n // http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECTION00832000000000000000\n const p = ((1 << 30) * 4 - 5); // prime: 2^32 - 5\n const z = 0x5033d967; // 32 bits from random.org\n const z2 = 0x59d2f15d; // random odd 32 bit number\n let s = 0;\n let zi = 1;\n for (let i = 0; i < string.length; i++) {\n const xi = string.charCodeAt(i) * z2;\n s = (s + zi * xi) % p;\n zi = (zi * z) % p;\n }\n s = (s + zi * (p - 1)) % p;\n return Math.abs(s | 0);\n};\n\nexport const compare = (a: string, b: string): number => {\n if (a > b) {\n return 1;\n }\n if (a < b) {\n return -1;\n }\n return 0;\n};\n\n/** Returns a string that has no more than maxLength characters. Actual graphemes are used, not bytes. */\nexport const trimMiddle = (str: string, maxLength: number): string => {\n // Early return for the case where there are fewer bytes than the character limit.\n if (str.length <= maxLength) {\n return str;\n }\n\n const segmenter = new Intl.Segmenter(undefined, {granularity: 'grapheme'});\n\n // If the max length is so small it can't fit the ellipsis, just return the ellipsis.\n const ellipsis = '…';\n const ellipsisLength = 1;\n if (maxLength <= ellipsisLength) {\n return ellipsis;\n }\n\n // Calculate how many graphemes to keep on each side.\n const freeSpace = maxLength - ellipsisLength;\n const leftCount = Math.ceil(freeSpace / 2);\n const rightCount = Math.floor(freeSpace / 2);\n\n let currentGraphemeCount = 0;\n let leftEndIndex = 0;\n\n // Sliding Window Buffer\n // We need to know where the \"Right Half\" starts. Since we can't iterate backwards,\n // we keep track of the start index of the last N graphemes we've seen.\n const rightIndexBuffer: number[] = [];\n\n // This function would be significantly simpler if we created an array of all the\n // segments upfront, but could result in poor performance for large input strings.\n for (const {segment, index} of segmenter.segment(str)) {\n currentGraphemeCount++;\n\n // Mark the byte index where the \"Left Half\" ends\n if (currentGraphemeCount === leftCount) {\n leftEndIndex = index + segment.length;\n }\n\n // Maintain the buffer for the \"Right Half\"\n if (rightCount > 0) {\n rightIndexBuffer.push(index);\n if (rightIndexBuffer.length > rightCount) {\n rightIndexBuffer.shift(); // Remove the oldest index to keep buffer size constant.\n }\n }\n }\n\n // If the total grapheme count didn't exceed the limit, return the original string.\n if (currentGraphemeCount <= maxLength) {\n return str;\n }\n\n // The first item in our buffer is exactly 'rightCount' graphemes away from the end.\n const rightStartIndex = rightCount > 0 ? rightIndexBuffer[0] : str.length;\n return str.slice(0, leftEndIndex) + ellipsis + str.slice(rightStartIndex);\n};\n\n/** Returns a string that has no more than maxLength characters. Actual graphemes are used, not bytes. */\nexport const trimEndWithMaxLength = (str: string, maxLength: number): string => {\n // Early return for the case where there are fewer bytes than the character limit.\n if (str.length <= maxLength) {\n return str;\n }\n\n const ellipsis = '…';\n const ellipsisLength = 1;\n const segmenter = new Intl.Segmenter(undefined, {granularity: 'grapheme'});\n const iterator = segmenter.segment(str)[Symbol.iterator]();\n\n let lastSegmentIndex = 0;\n for (let i = 0; i <= maxLength - ellipsisLength; i++) {\n const result = iterator.next();\n if (result.done) {\n return str;\n }\n\n lastSegmentIndex = result.value.index;\n }\n\n for (let i = 0; i < ellipsisLength; i++) {\n if (iterator.next().done) {\n return str;\n }\n }\n\n return str.slice(0, lastSegmentIndex) + ellipsis;\n};\n\n/**\n * Truncates a string to not exceed a maximum number of UTF-16 code units (as measured by JS `string.length`).\n *\n * Unlike simple character limiters, this helper is grapheme-aware and uses `Intl.Segmenter` to prevent\n * slicing inside surrogate pairs (e.g. Plane 1+ characters or emojis like '𠜎' / '🥳') or combining characters\n * (e.g. 'é' represented in NFD as 'e' + combining acute accent). If the limit falls in the middle of a\n * grapheme cluster, the function backs off to drop the entire cluster, ensuring the result is always a valid\n * Unicode string.\n *\n * @param str The string to truncate.\n * @param maxCodeUnits The maximum allowed code unit length (must be >= 0).\n * @returns The truncated string, guaranteed to be <= maxCodeUnits in length and grapheme-safe.\n */\nexport const truncateToCodeUnitLength = (str: string, maxCodeUnits: number): string => {\n if (isNaN(maxCodeUnits) || maxCodeUnits <= 0) {\n return '';\n }\n if (str.length <= maxCodeUnits) {\n return str;\n }\n if (!graphemeSegmenter) {\n graphemeSegmenter = new Intl.Segmenter(undefined, {granularity: 'grapheme'});\n }\n let lastSafeIndex = 0;\n for (const {index, segment} of graphemeSegmenter.segment(str)) {\n if (index + segment.length > maxCodeUnits) {\n break;\n }\n lastSafeIndex = index + segment.length;\n }\n return str.slice(0, lastSafeIndex);\n};\n\nexport const escapeForRegExp = (str: string): string => {\n return escapeCharacters(str, SPECIAL_REGEX_CHARACTERS);\n};\n\nexport const escapeForURLPattern = (text: string): string => {\n return escapeCharacters(text, SPECIAL_URL_PATTERN_CHARACTERS);\n};\n\nexport const naturalOrderComparator = (a: string, b: string): number => {\n const chunk = /^\\d+|^\\D+/;\n let chunkA, chunkB, numA, numB;\n while (true) {\n if (a) {\n if (!b) {\n return 1;\n }\n } else {\n if (b) {\n return -1;\n }\n return 0;\n }\n chunkA = (a.match(chunk) as string[])[0];\n chunkB = (b.match(chunk) as string[])[0];\n numA = !Number.isNaN(Number(chunkA));\n numB = !Number.isNaN(Number(chunkB));\n if (numA && !numB) {\n return -1;\n }\n if (numB && !numA) {\n return 1;\n }\n if (numA && numB) {\n const diff = Number(chunkA) - Number(chunkB);\n if (diff) {\n return diff;\n }\n if (chunkA.length !== chunkB.length) {\n if (!Number(chunkA) && !Number(chunkB)) { // chunks are strings of all 0s (special case)\n return chunkA.length - chunkB.length;\n }\n return chunkB.length - chunkA.length;\n }\n } else if (chunkA !== chunkB) {\n return (chunkA < chunkB) ? -1 : 1;\n }\n a = a.substring(chunkA.length);\n b = b.substring(chunkB.length);\n }\n};\n\nexport const base64ToSize = function(content: string|null): number {\n if (!content) {\n return 0;\n }\n let size = content.length * 3 / 4;\n if (content[content.length - 1] === '=') {\n size--;\n }\n if (content.length > 1 && content[content.length - 2] === '=') {\n size--;\n }\n return size;\n};\n\nexport const SINGLE_QUOTE = '\\'';\nexport const DOUBLE_QUOTE = '\"';\nconst BACKSLASH = '\\\\';\n\nexport const findUnclosedCssQuote = function(str: string): string {\n let unmatchedQuote = '';\n for (let i = 0; i < str.length; ++i) {\n const char = str[i];\n if (char === BACKSLASH) {\n i++;\n continue;\n }\n if (char === SINGLE_QUOTE || char === DOUBLE_QUOTE) {\n if (unmatchedQuote === char) {\n unmatchedQuote = '';\n } else if (unmatchedQuote === '') {\n unmatchedQuote = char;\n }\n }\n }\n return unmatchedQuote;\n};\n\nexport const countUnmatchedLeftParentheses = (str: string): number => {\n const stringLiteralRegex = /'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"/g;\n // Remove all matched string literals from the original string.\n const strWithoutStrings = str.replace(stringLiteralRegex, '');\n\n let unmatchedCount = 0;\n for (const c of strWithoutStrings) {\n if (c === '(') {\n unmatchedCount++;\n } else if (c === ')' && unmatchedCount > 0) {\n unmatchedCount--;\n }\n }\n return unmatchedCount;\n};\n\nexport const createPlainTextSearchRegex = function(query: string, flags?: string): RegExp {\n // This should be kept the same as the one in StringUtil.cpp.\n let regex = '';\n for (let i = 0; i < query.length; ++i) {\n const c = query.charAt(i);\n if (regexSpecialCharacters().indexOf(c) !== -1) {\n regex += '\\\\';\n }\n regex += c;\n }\n return new RegExp(regex, flags || '');\n};\n\nexport type LowerCaseString = Brand<string, 'lowerCaseStringTag'>;\n\nexport const toLowerCaseString = function(input: string): LowerCaseString {\n return input.toLowerCase() as LowerCaseString;\n};\n\n/**\n * 1: two or more consecutive uppercase letters. This is useful for identifying acronyms\n * 2: lookahead assertion that matches a word boundary\n * 3: numeronym: single letter followed by number and another letter\n * 4: word starting with an optional uppercase letter\n * 5: single digit followed by word to handle '3D' or '2px' (this might be controverial)\n * 6: single uppercase letter or number\n * 7: a dot character. We extract it into a separate word and remove dashes around it later.\n * This is makes more sense conceptually and allows accounting for all possible word variants.\n * Making dot a part of a word prevent us from handling acronyms or numeronyms after the word\n * correctly without making the RegExp prohibitively complicated.\n * https://regex101.com/r/FhMVKc/1\n * <---1---><------------2-----------> <---------3--------> <-----4----> <------5-----> <-----6----> <7>\n */\nconst WORD = /[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\\b|_)|[A-Za-z][0-9]+[a-z]?|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g;\n\nexport const toKebabCase = function(input: string): Lowercase<string> {\n return (input.match?.(WORD)?.map(w => w.toLowerCase()).join('-').replaceAll('-.-', '.') || input) as\n Lowercase<string>;\n};\n\nexport function toKebabCaseKeys<T>(settingValue: Record<string, T>): Record<string, T> {\n return Object.fromEntries(Object.entries(settingValue).map(([key, value]) => [toKebabCase(key), value]));\n}\n\n/**\n * Converts a given string to snake_case.\n * This function handles camelCase, PascalCase, and acronyms, including transitions between letters and numbers.\n * It uses Unicode-aware regular expressions (`\\p{L}`, `\\p{N}`, `\\p{Lu}`, `\\p{Ll}` with the `u` flag)\n * to correctly process letters and numbers from various languages.\n *\n * @param text The input string to convert to snake_case.\n * @returns The snake_case version of the input string.\n */\nexport function toSnakeCase(text: string): string {\n if (!text) {\n return '';\n }\n // First, handle case-based transformations to insert underscores correctly.\n // 1. Add underscore between a letter and a number.\n // e.g., \"version2\" -> \"version_2\"\n // 2. Add underscore between an uppercase letter sequence and a following uppercase+lowercase sequence.\n // e.g., \"APIFlags\" -> \"API_Flags\"\n // 3. Add underscore between a lowercase/number and an uppercase letter.\n // e.g., \"lastName\" -> \"last_Name\", \"version_2Update\" -> \"version_2_Update\"\n // 4. Replace sequences of non-alphanumeric with a single underscore\n // 5. Remove any leading or trailing underscores.\n const result = text.replace(/(\\p{L})(\\p{N})/gu, '$1_$2') // 1\n .replace(/(\\p{Lu}+)(\\p{Lu}\\p{Ll})/gu, '$1_$2') // 2\n .replace(/(\\p{Ll}|\\p{N})(\\p{Lu})/gu, '$1_$2') // 3\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}]+/gu, '_') // 4\n .replace(/^_|_$/g, ''); // 5\n\n return result;\n}\n\n/** Replaces the last occurrence of parameter `search` with parameter `replacement` in `input` **/\nexport const replaceLast = function(input: string, search: string, replacement: string): string {\n const replacementStartIndex = input.lastIndexOf(search);\n if (replacementStartIndex === -1) {\n return input;\n }\n\n return input.slice(0, replacementStartIndex) + input.slice(replacementStartIndex).replace(search, replacement);\n};\n\nexport const stringifyWithPrecision = function stringifyWithPrecision(s: number, precision = 2): string {\n if (precision === 0) {\n return s.toFixed(0);\n }\n const string = s.toFixed(precision).replace(/\\.?0*$/, '');\n return string === '-0' ? '0' : string;\n};\n\n/**\n * Somewhat efficiently concatenates 2 base64 encoded strings.\n */\nexport const concatBase64 = function(lhs: string, rhs: string): string {\n if (lhs.length === 0 || !lhs.endsWith('=')) {\n // Empty string or no padding, we can straight-up concatenate.\n return lhs + rhs;\n }\n const lhsLeaveAsIs = lhs.substring(0, lhs.length - 4);\n const lhsToDecode = lhs.substring(lhs.length - 4);\n return lhsLeaveAsIs + globalThis.btoa(globalThis.atob(lhsToDecode) + globalThis.atob(rhs));\n};\n\n/**\n * Characters that cause spreadsheet viewers (Excel, Google Sheets, LibreOffice\n * Calc) to evaluate a cell as a formula rather than rendering it as plain text\n * when they appear at the start of a cell.\n */\nconst CSV_FORMULA_TRIGGERS = new Set(['=', '+', '-', '@', '\\t', '\\r']);\n\n/**\n * Matches plain numeric literals (e.g. `-42`, `+3.14`, `-1e-3`).\n * Even though negative/signed numbers start with `-` or `+`, spreadsheets parse\n * them as numbers rather than formulas, so we exempt them from `'` prefixing to\n * keep numeric columns usable.\n */\nconst CSV_PLAIN_NUMBER = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?$/;\n\n/**\n * Returns true if a spreadsheet viewer could interpret `value` as a formula\n * (for example `=SUM(A1:A2)`, `\"- Loading...\"`, or `\"@alice\"`).\n */\nfunction isCsvFormula(value: string): boolean {\n // Check both the raw string and the leading-whitespace-trimmed string, since\n // some spreadsheet parsers ignore leading spaces before `=`, `+`, `-`, or `@`.\n const trimmed = value.trimStart();\n if (!CSV_FORMULA_TRIGGERS.has(value[0]) && !CSV_FORMULA_TRIGGERS.has(trimmed[0])) {\n return false;\n }\n return !CSV_PLAIN_NUMBER.test(trimmed.trimEnd());\n}\n\n/**\n * Formats and escapes `value` so it can be safely written as a single CSV cell.\n *\n * This handles two separate layers of escaping:\n * 1. Spreadsheet formula escaping (CWE-1236 & viewer fidelity):\n * RFC 4180 double-quoting (`\"=1+1\"` or `\"- Loading...\"`) only groups text\n * into a single CSV column; spreadsheet apps strip the outer `\"` and still\n * evaluate cells starting with `=`, `+`, `-`, or `@` as formulas (often\n * resulting in `#NAME?` errors or unintended formula execution). Prefixing\n * the value with a single quote (`'`) tells spreadsheet apps to treat the\n * cell as literal text (and they hide the leading `'` when displaying it).\n * - Example without commas: `=SUM(A1:A2)` -> `'=SUM(A1:A2)`\n * 2. RFC 4180 structural CSV quoting:\n * If the cell also contains commas (`,`), double quotes (`\"`), or newlines,\n * it is wrapped in `\"...\"` (with inner `\"` doubled to `\"\"`) so CSV parsers\n * do not split the cell across columns or rows.\n * - Example with commas: `=SUM(1,2)` -> `\"'=SUM(1,2)\"`\n * - Example starting with a literal quote: `\"=SUM(1,2)\"` -> `\"\"\"=SUM(1,2)\"\"\"`\n * (not treated as a formula since the first character is `\"`, not `=`).\n */\nexport const escapeCsvCell = function(value: string): string {\n // Step 1: Prefix formula-like text with `'` so spreadsheets render it as literal text.\n let escaped = isCsvFormula(value) ? `'${value}` : value;\n\n // Step 2: Apply standard RFC 4180 double-quoting if the cell contains quotes,\n // commas, or line breaks so the CSV structure stays intact.\n if (escaped.includes('\"')) {\n escaped = escaped.replace(/\"/g, '\"\"');\n return `\"${escaped}\"`;\n }\n if (escaped.includes(',') || escaped.includes('\\n') || escaped.includes('\\r')) {\n return `\"${escaped}\"`;\n }\n return escaped;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"StringUtilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/StringUtilities.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,6BAA6B;AAI7B,IAAI,iBAAiB,GAAwB,IAAI,CAAC;AAClD,kHAAkH;AAClH,MAAM,qBAAqB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AC,CAAC;QACtC,OAAO,IAAI,OAAO,GAAG,CAAC;IACxB,CAAC;IACD,IAAI,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,OAAO,GAAG,CAAC;IACxB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["// Copyright 2020 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type {Brand} from './Brand.js';\n\nlet graphemeSegmenter: Intl.Segmenter|null = null;\n// Excludes control characters (0x00-0x1F, 0x7F) to prevent splitting \\r\\n, which forms a single grapheme cluster.\nconst PRINTABLE_ASCII_REGEX = /^[\\x20-\\x7e]*$/;\n\nfunction getGraphemeSegmenter(): Intl.Segmenter {\n if (!graphemeSegmenter) {\n graphemeSegmenter = new Intl.Segmenter(undefined, {granularity: 'grapheme'});\n }\n return graphemeSegmenter;\n}\n\nexport const escapeCharacters = (inputString: string, charsToEscape: string): string => {\n let foundChar = false;\n for (let i = 0; i < charsToEscape.length; ++i) {\n if (inputString.indexOf(charsToEscape.charAt(i)) !== -1) {\n foundChar = true;\n break;\n }\n }\n\n if (!foundChar) {\n return String(inputString);\n }\n\n let result = '';\n for (let i = 0; i < inputString.length; ++i) {\n if (charsToEscape.indexOf(inputString.charAt(i)) !== -1) {\n result += '\\\\';\n }\n result += inputString.charAt(i);\n }\n\n return result;\n};\n\nconst toHexadecimal = (charCode: number, padToLength: number): string => {\n return charCode.toString(16).toUpperCase().padStart(padToLength, '0');\n};\n\n// Remember to update the third group in the regexps patternsToEscape and\n// patternsToEscapePlusSingleQuote when adding new entries in this map.\nconst escapedReplacements = new Map([\n ['\\b', '\\\\b'],\n ['\\f', '\\\\f'],\n ['\\n', '\\\\n'],\n ['\\r', '\\\\r'],\n ['\\t', '\\\\t'],\n ['\\v', '\\\\v'],\n ['\\'', '\\\\\\''],\n ['\\\\', '\\\\\\\\'],\n ['<!--', '\\\\x3C!--'],\n ['<script', '\\\\x3Cscript'],\n ['</script', '\\\\x3C/script'],\n]);\n\nconst UNICODE_ESCAPE_SOURCE = '[\\\\p{Format}\\\\p{Surrogate}]';\nconst UNICODE_ESCAPE_REGEX = new RegExp(UNICODE_ESCAPE_SOURCE, 'u');\nconst UNICODE_ESCAPE_GLOBAL_REGEX = new RegExp(UNICODE_ESCAPE_SOURCE, 'gu');\n\nconst UNICODE_ESCAPE_EXCEPT_ZWSP_SOURCE = '(?![\\\\u200B\\\\u200C\\\\u200D])[\\\\p{Format}]|\\\\p{Surrogate}';\nconst UNICODE_ESCAPE_EXCEPT_ZWSP_REGEX = new RegExp(UNICODE_ESCAPE_EXCEPT_ZWSP_SOURCE, 'u');\nconst UNICODE_ESCAPE_EXCEPT_ZWSP_GLOBAL_REGEX = new RegExp(UNICODE_ESCAPE_EXCEPT_ZWSP_SOURCE, 'gu');\n\n/**\n * Escapes formatting and surrogate characters in the string into literal Unicode escape sequences (e.g. \\u200B).\n * Use this when displaying strings to developers for inspection (e.g. in the Console or Object properties)\n * where you want hidden or invisible characters to be explicitly visible as literal text.\n */\nexport const escapeUnicodeAsText = (content: string): string => {\n if (!UNICODE_ESCAPE_REGEX.test(content)) {\n return content;\n }\n return content.replaceAll(UNICODE_ESCAPE_GLOBAL_REGEX, match => {\n return match.split('').map(char => '\\\\u' + toHexadecimal(char.charCodeAt(0), 4)).join('');\n });\n};\n\n/**\n * Escapes dangerous formatting and surrogate characters (like bidi override characters) to prevent\n * security and layout issues, but leaves safe, layout-critical zero-width formatting characters\n * (Zero Width Space \\u200B, Zero Width Non-Joiner \\u200C, and Zero Width Joiner \\u200D) untouched.\n * Use this when rendering user-controlled content inside templates or HTML markup where you want formatting\n * characters to function normally for word wrapping or rendering layout, rather than showing as literal text.\n */\nexport const safeEscapeUnicode = (content: string): string => {\n if (!UNICODE_ESCAPE_EXCEPT_ZWSP_REGEX.test(content)) {\n return content;\n }\n return content.replaceAll(UNICODE_ESCAPE_EXCEPT_ZWSP_GLOBAL_REGEX, match => {\n return match.split('').map(char => '\\\\u' + toHexadecimal(char.charCodeAt(0), 4)).join('');\n });\n};\n\nexport const formatAsJSLiteral = (content: string): string => {\n const patternsToEscape = /(\\\\|<(?:!--|\\/?script))|(\\p{Control}|\\p{Format})|(\\p{Surrogate})/giu;\n const patternsToEscapePlusSingleQuote = /(\\\\|'|<(?:!--|\\/?script))|(\\p{Control}|\\p{Format})|(\\p{Surrogate})/giu;\n const escapePattern = (match: string, pattern: string, controlChar: string, loneSurrogate: string): string => {\n if (controlChar) {\n if (escapedReplacements.has(controlChar)) {\n // @ts-expect-error https://github.com/microsoft/TypeScript/issues/13086\n return escapedReplacements.get(controlChar);\n }\n return controlChar.split('')\n .map(char => {\n const charCode = char.charCodeAt(0);\n if (controlChar.length === 1 && charCode <= 0xFF) {\n return '\\\\x' + toHexadecimal(charCode, 2);\n }\n return '\\\\u' + toHexadecimal(charCode, 4);\n })\n .join('');\n }\n if (loneSurrogate) {\n const fourDigitHex = toHexadecimal(loneSurrogate.charCodeAt(0), 4);\n return '\\\\u' + fourDigitHex;\n }\n if (pattern) {\n if (pattern.startsWith('<')) {\n return '\\\\x3C' + pattern.slice(1);\n }\n return escapedReplacements.get(pattern) || '';\n }\n return match;\n };\n\n let escapedContent = '';\n let quote = '';\n if (!content.includes('\\'')) {\n quote = '\\'';\n escapedContent = content.replaceAll(patternsToEscape, escapePattern);\n } else if (!content.includes('\"')) {\n quote = '\"';\n escapedContent = content.replaceAll(patternsToEscape, escapePattern);\n } else if (!content.includes('`') && !content.includes('${')) {\n quote = '`';\n escapedContent = content.replaceAll(patternsToEscape, escapePattern);\n } else {\n quote = '\\'';\n escapedContent = content.replaceAll(patternsToEscapePlusSingleQuote, escapePattern);\n }\n return `${quote}${escapedContent}${quote}`;\n};\n\n/**\n * This implements a subset of the sprintf() function described in the Single UNIX\n * Specification. It supports the %s, %f, %d, and %% formatting specifiers, and\n * understands the %m$d notation to select the m-th parameter for this substitution,\n * as well as the optional precision for %s, %f, and %d.\n *\n * @param fmt format string.\n * @param args parameters to the format string.\n * @returns the formatted output string.\n */\nexport const sprintf = (fmt: string, ...args: unknown[]): string => {\n let argIndex = 0;\n const RE = /%(?:(\\d+)\\$)?(?:\\.(\\d*))?([%dfs])/g;\n return fmt.replaceAll(RE, (_: string, index?: string, precision?: string, specifier?: string) => {\n if (specifier === '%') {\n return '%';\n }\n if (index !== undefined) {\n argIndex = parseInt(index, 10) - 1;\n if (argIndex < 0) {\n throw new RangeError(`Invalid parameter index ${argIndex + 1}`);\n }\n }\n if (argIndex >= args.length) {\n throw new RangeError(`Expected at least ${argIndex + 1} format parameters, but only ${args.length} where given.`);\n }\n if (specifier === 's') {\n const argValue = String(args[argIndex++]);\n if (precision !== undefined) {\n return argValue.substring(0, Number(precision));\n }\n return argValue;\n }\n let argValue = Number(args[argIndex++]);\n if (isNaN(argValue)) {\n argValue = 0;\n }\n if (specifier === 'd') {\n return String(Math.floor(argValue)).padStart(Number(precision), '0');\n }\n if (precision !== undefined) {\n return argValue.toFixed(Number(precision));\n }\n return String(argValue);\n });\n};\n\nexport const toBase64 = (inputString: string): string => {\n /* note to the reader: we can't use btoa here because we need to\n * support Unicode correctly. See the test cases for this function and\n * also\n * https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem\n */\n\n function encodeBits(b: number): number {\n return b < 26 ? b + 65 : b < 52 ? b + 71 : b < 62 ? b - 4 : b === 62 ? 43 : b === 63 ? 47 : 65;\n }\n const encoder = new TextEncoder();\n const data = encoder.encode(inputString.toString());\n const n = data.length;\n let encoded = '';\n if (n === 0) {\n return encoded;\n }\n let shift;\n let v = 0;\n for (let i = 0; i < n; i++) {\n shift = i % 3;\n v |= data[i] << (16 >>> shift & 24);\n if (shift === 2) {\n encoded += String.fromCharCode(encodeBits(v >>> 18 & 63), encodeBits(v >>> 12 & 63), encodeBits(v >>> 6 & 63),\n encodeBits(v & 63));\n v = 0;\n }\n }\n if (shift === 0) {\n encoded += String.fromCharCode(encodeBits(v >>> 18 & 63), encodeBits(v >>> 12 & 63), 61, 61);\n } else if (shift === 1) {\n encoded += String.fromCharCode(encodeBits(v >>> 18 & 63), encodeBits(v >>> 12 & 63), encodeBits(v >>> 6 & 63), 61);\n }\n return encoded;\n};\n\nexport const findIndexesOfSubString = (inputString: string, searchString: string): number[] => {\n const matches = [];\n let i = inputString.indexOf(searchString);\n while (i !== -1) {\n matches.push(i);\n i = inputString.indexOf(searchString, i + searchString.length);\n }\n return matches;\n};\n\nexport const findLineEndingIndexes = (inputString: string): number[] => {\n const endings = findIndexesOfSubString(inputString, '\\n');\n endings.push(inputString.length);\n return endings;\n};\n\nexport const isWhitespace = (inputString: string): boolean => {\n return /^\\s*$/.test(inputString);\n};\n\nexport const trimURL = (url: string, baseURLDomain?: string): string => {\n let result = url.replace(/^(https|http|file):\\/\\//i, '');\n if (baseURLDomain) {\n if (result.toLowerCase().startsWith(baseURLDomain.toLowerCase())) {\n result = result.substr(baseURLDomain.length);\n }\n }\n return result;\n};\n\nexport const collapseWhitespace = (inputString: string): string => {\n return inputString.replace(/[\\s\\xA0]+/g, ' ');\n};\n\nexport const reverse = (inputString: string): string => {\n return inputString.split('').reverse().join('');\n};\n\nexport const replaceControlCharacters = (inputString: string): string => {\n // Replace C0 and C1 control character sets with replacement character.\n // Do not replace '\\t', \\n' and '\\r'.\n return inputString.replace(/[\\0-\\x08\\x0B\\f\\x0E-\\x1F\\x80-\\x9F]/g, '\\uFFFD');\n};\n\nexport const countWtf8Bytes = (inputString: string): number => {\n let count = 0;\n for (let i = 0; i < inputString.length; i++) {\n const c = inputString.charCodeAt(i);\n if (c <= 0x7F) {\n count++;\n } else if (c <= 0x07FF) {\n count += 2;\n } else if (c < 0xD800 || 0xDFFF < c) {\n count += 3;\n } else {\n if (c <= 0xDBFF && i + 1 < inputString.length) {\n // The current character is a leading surrogate, and there is a\n // next character.\n const next = inputString.charCodeAt(i + 1);\n if (0xDC00 <= next && next <= 0xDFFF) {\n // The next character is a trailing surrogate, meaning this\n // is a surrogate pair.\n count += 4;\n i++;\n continue;\n }\n }\n count += 3;\n }\n }\n return count;\n};\n\nexport const stripLineBreaks = (inputStr: string): string => {\n return inputStr.replace(/(\\r)?\\n/g, '');\n};\n\nconst EXTENDED_KEBAB_CASE_REGEXP = /^([a-z0-9]+(?:-[a-z0-9]+)*\\.)*[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/**\n * Tests if the `inputStr` is following the extended Kebab Case naming convention,\n * where words are separated with either a dash (`-`) or a dot (`.`), and all\n * characters must be lower-case alphanumeric.\n *\n * For example, it will yield `true` for `'my.amazing-string.literal'`, but `false`\n * for `'Another.AmazingLiteral'` or '`another_amazing_literal'`.\n *\n * @param inputStr the input string to test.\n * @returns `true` if the `inputStr` follows the extended Kebab Case convention.\n */\nexport const isExtendedKebabCase = (inputStr: string): boolean => {\n return EXTENDED_KEBAB_CASE_REGEXP.test(inputStr);\n};\n\n/**\n * Replaces any sequence of non-alphanumeric characters with a single dash, strips leading and\n * trailing dashes, and converts letters to lowercase, leaving a kebab-case identifier usable as viewId.\n * If the input contains only non-alphanumeric characters, returns a falsy empty string.\n */\nexport const sanitizeIdentifier = (id: string): Lowercase<string> => {\n return id.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') as Lowercase<string>;\n};\n\nexport const toTitleCase = (inputStr: string): string => {\n return inputStr.substring(0, 1).toUpperCase() + inputStr.substring(1);\n};\n\nexport const removeURLFragment = (inputStr: string): string => {\n const url = new URL(inputStr);\n url.hash = '';\n return url.toString();\n};\n\nconst SPECIAL_REGEX_CHARACTERS = '^[]{}()\\\\.^$*+?|-,';\nconst SPECIAL_URL_PATTERN_CHARACTERS = '?+*(){}\\\\:';\n\nexport const regexSpecialCharacters = function(): string {\n return SPECIAL_REGEX_CHARACTERS;\n};\n\nexport const filterRegex = function(query: string): RegExp {\n let regexString = '^(?:.*\\\\0)?'; // Start from beginning or after a \\0\n for (let i = 0; i < query.length; ++i) {\n let c = query.charAt(i);\n if (SPECIAL_REGEX_CHARACTERS.indexOf(c) !== -1) {\n c = '\\\\' + c;\n }\n regexString += '[^\\\\0' + c + ']*' + c;\n }\n return new RegExp(regexString, 'i');\n};\n\nexport const createSearchRegex = function(query: string, caseSensitive: boolean, isRegex: boolean,\n matchWholeWord = false): RegExp {\n const regexFlags = caseSensitive ? 'g' : 'gi';\n let regexObject;\n\n if (isRegex) {\n try {\n regexObject = new RegExp(query, regexFlags);\n } catch {\n // Silent catch.\n }\n }\n\n if (!regexObject) {\n regexObject = createPlainTextSearchRegex(query, regexFlags);\n }\n\n if (matchWholeWord && regexObject) {\n regexObject = new RegExp(`\\\\b${regexObject.source}\\\\b`, regexFlags);\n }\n\n return regexObject;\n};\n\nexport const caseInsensetiveComparator = function(a: string, b: string): number {\n a = a.toUpperCase();\n b = b.toUpperCase();\n if (a === b) {\n return 0;\n }\n return a > b ? 1 : -1;\n};\n\nexport const hashCode = function(string?: string): number {\n if (!string) {\n return 0;\n }\n // Hash algorithm for substrings is described in \"Über die Komplexität der Multiplikation in\n // eingeschränkten Branchingprogrammmodellen\" by Woelfe.\n // http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECTION00832000000000000000\n const p = ((1 << 30) * 4 - 5); // prime: 2^32 - 5\n const z = 0x5033d967; // 32 bits from random.org\n const z2 = 0x59d2f15d; // random odd 32 bit number\n let s = 0;\n let zi = 1;\n for (let i = 0; i < string.length; i++) {\n const xi = string.charCodeAt(i) * z2;\n s = (s + zi * xi) % p;\n zi = (zi * z) % p;\n }\n s = (s + zi * (p - 1)) % p;\n return Math.abs(s | 0);\n};\n\nexport const compare = (a: string, b: string): number => {\n if (a > b) {\n return 1;\n }\n if (a < b) {\n return -1;\n }\n return 0;\n};\n\n/** Returns a string that has no more than maxLength characters. Actual graphemes are used, not bytes. */\nexport const trimMiddle = (str: string, maxLength: number): string => {\n // Early return for the case where there are fewer bytes than the character limit.\n if (str.length <= maxLength) {\n return str;\n }\n\n // If the max length is so small it can't fit the ellipsis, just return the ellipsis.\n const ellipsis = '…';\n const ellipsisLength = 1;\n if (maxLength <= ellipsisLength) {\n return ellipsis;\n }\n\n // Calculate how many graphemes to keep on each side.\n const freeSpace = maxLength - ellipsisLength;\n const leftCount = Math.ceil(freeSpace / 2);\n const rightCount = Math.floor(freeSpace / 2);\n\n // Printable ASCII characters (0x20-0x7E) cannot form multi-code-unit grapheme clusters.\n // Checking one extra character inside each truncation boundary guarantees both slice boundaries\n // fall between graphemes and the string contains at least maxLength + 1 graphemes.\n if (PRINTABLE_ASCII_REGEX.test(str.slice(0, leftCount + 1)) &&\n PRINTABLE_ASCII_REGEX.test(str.slice(str.length - rightCount - 1))) {\n return str.slice(0, leftCount) + ellipsis + str.slice(str.length - rightCount);\n }\n\n const segmenter = getGraphemeSegmenter();\n\n let currentGraphemeCount = 0;\n let leftEndIndex = 0;\n\n // Sliding Window Buffer\n // We need to know where the \"Right Half\" starts. Since we can't iterate backwards,\n // we keep track of the start index of the last N graphemes we've seen.\n const rightIndexBuffer: number[] = [];\n\n // This function would be significantly simpler if we created an array of all the\n // segments upfront, but could result in poor performance for large input strings.\n for (const {segment, index} of segmenter.segment(str)) {\n currentGraphemeCount++;\n\n // Mark the byte index where the \"Left Half\" ends\n if (currentGraphemeCount === leftCount) {\n leftEndIndex = index + segment.length;\n }\n\n // Maintain the buffer for the \"Right Half\"\n if (rightCount > 0) {\n rightIndexBuffer.push(index);\n if (rightIndexBuffer.length > rightCount) {\n rightIndexBuffer.shift(); // Remove the oldest index to keep buffer size constant.\n }\n }\n }\n\n // If the total grapheme count didn't exceed the limit, return the original string.\n if (currentGraphemeCount <= maxLength) {\n return str;\n }\n\n // The first item in our buffer is exactly 'rightCount' graphemes away from the end.\n const rightStartIndex = rightCount > 0 ? rightIndexBuffer[0] : str.length;\n return str.slice(0, leftEndIndex) + ellipsis + str.slice(rightStartIndex);\n};\n\n/** Returns a string that has no more than maxLength characters. Actual graphemes are used, not bytes. */\nexport const trimEndWithMaxLength = (str: string, maxLength: number): string => {\n // Early return for the case where there are fewer bytes than the character limit.\n if (str.length <= maxLength) {\n return str;\n }\n\n const ellipsis = '…';\n const ellipsisLength = 1;\n if (maxLength <= ellipsisLength) {\n return ellipsis;\n }\n\n // Printable ASCII characters (0x20-0x7E) cannot form multi-code-unit grapheme clusters.\n // Checking up to maxLength + 1 characters guarantees at least maxLength + 1 graphemes in O(maxLength).\n if (PRINTABLE_ASCII_REGEX.test(str.slice(0, maxLength + 1))) {\n return str.slice(0, maxLength - ellipsisLength) + ellipsis;\n }\n\n const segmenter = getGraphemeSegmenter();\n const iterator = segmenter.segment(str)[Symbol.iterator]();\n\n let lastSegmentIndex = 0;\n for (let i = 0; i <= maxLength - ellipsisLength; i++) {\n const result = iterator.next();\n if (result.done) {\n return str;\n }\n\n lastSegmentIndex = result.value.index;\n }\n\n for (let i = 0; i < ellipsisLength; i++) {\n if (iterator.next().done) {\n return str;\n }\n }\n\n return str.slice(0, lastSegmentIndex) + ellipsis;\n};\n\n/**\n * Truncates a string to not exceed a maximum number of UTF-16 code units (as measured by JS `string.length`).\n *\n * Unlike simple character limiters, this helper is grapheme-aware and uses `Intl.Segmenter` to prevent\n * slicing inside surrogate pairs (e.g. Plane 1+ characters or emojis like '𠜎' / '🥳') or combining characters\n * (e.g. 'é' represented in NFD as 'e' + combining acute accent). If the limit falls in the middle of a\n * grapheme cluster, the function backs off to drop the entire cluster, ensuring the result is always a valid\n * Unicode string.\n *\n * @param str The string to truncate.\n * @param maxCodeUnits The maximum allowed code unit length (must be >= 0).\n * @returns The truncated string, guaranteed to be <= maxCodeUnits in length and grapheme-safe.\n */\nexport const truncateToCodeUnitLength = (str: string, maxCodeUnits: number): string => {\n if (isNaN(maxCodeUnits) || maxCodeUnits <= 0) {\n return '';\n }\n if (str.length <= maxCodeUnits) {\n return str;\n }\n if (PRINTABLE_ASCII_REGEX.test(str.slice(0, maxCodeUnits + 1))) {\n return str.slice(0, maxCodeUnits);\n }\n let lastSafeIndex = 0;\n for (const {index, segment} of getGraphemeSegmenter().segment(str)) {\n if (index + segment.length > maxCodeUnits) {\n break;\n }\n lastSafeIndex = index + segment.length;\n }\n return str.slice(0, lastSafeIndex);\n};\n\nexport const escapeForRegExp = (str: string): string => {\n return escapeCharacters(str, SPECIAL_REGEX_CHARACTERS);\n};\n\nexport const escapeForURLPattern = (text: string): string => {\n return escapeCharacters(text, SPECIAL_URL_PATTERN_CHARACTERS);\n};\n\nexport const naturalOrderComparator = (a: string, b: string): number => {\n const chunk = /^\\d+|^\\D+/;\n let chunkA, chunkB, numA, numB;\n while (true) {\n if (a) {\n if (!b) {\n return 1;\n }\n } else {\n if (b) {\n return -1;\n }\n return 0;\n }\n chunkA = (a.match(chunk) as string[])[0];\n chunkB = (b.match(chunk) as string[])[0];\n numA = !Number.isNaN(Number(chunkA));\n numB = !Number.isNaN(Number(chunkB));\n if (numA && !numB) {\n return -1;\n }\n if (numB && !numA) {\n return 1;\n }\n if (numA && numB) {\n const diff = Number(chunkA) - Number(chunkB);\n if (diff) {\n return diff;\n }\n if (chunkA.length !== chunkB.length) {\n if (!Number(chunkA) && !Number(chunkB)) { // chunks are strings of all 0s (special case)\n return chunkA.length - chunkB.length;\n }\n return chunkB.length - chunkA.length;\n }\n } else if (chunkA !== chunkB) {\n return (chunkA < chunkB) ? -1 : 1;\n }\n a = a.substring(chunkA.length);\n b = b.substring(chunkB.length);\n }\n};\n\nexport const base64ToSize = function(content: string|null): number {\n if (!content) {\n return 0;\n }\n let size = content.length * 3 / 4;\n if (content[content.length - 1] === '=') {\n size--;\n }\n if (content.length > 1 && content[content.length - 2] === '=') {\n size--;\n }\n return size;\n};\n\nexport const SINGLE_QUOTE = '\\'';\nexport const DOUBLE_QUOTE = '\"';\nconst BACKSLASH = '\\\\';\n\nexport const findUnclosedCssQuote = function(str: string): string {\n let unmatchedQuote = '';\n for (let i = 0; i < str.length; ++i) {\n const char = str[i];\n if (char === BACKSLASH) {\n i++;\n continue;\n }\n if (char === SINGLE_QUOTE || char === DOUBLE_QUOTE) {\n if (unmatchedQuote === char) {\n unmatchedQuote = '';\n } else if (unmatchedQuote === '') {\n unmatchedQuote = char;\n }\n }\n }\n return unmatchedQuote;\n};\n\nexport const countUnmatchedLeftParentheses = (str: string): number => {\n const stringLiteralRegex = /'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"/g;\n // Remove all matched string literals from the original string.\n const strWithoutStrings = str.replace(stringLiteralRegex, '');\n\n let unmatchedCount = 0;\n for (const c of strWithoutStrings) {\n if (c === '(') {\n unmatchedCount++;\n } else if (c === ')' && unmatchedCount > 0) {\n unmatchedCount--;\n }\n }\n return unmatchedCount;\n};\n\nexport const createPlainTextSearchRegex = function(query: string, flags?: string): RegExp {\n // This should be kept the same as the one in StringUtil.cpp.\n let regex = '';\n for (let i = 0; i < query.length; ++i) {\n const c = query.charAt(i);\n if (regexSpecialCharacters().indexOf(c) !== -1) {\n regex += '\\\\';\n }\n regex += c;\n }\n return new RegExp(regex, flags || '');\n};\n\nexport type LowerCaseString = Brand<string, 'lowerCaseStringTag'>;\n\nexport const toLowerCaseString = function(input: string): LowerCaseString {\n return input.toLowerCase() as LowerCaseString;\n};\n\n/**\n * 1: two or more consecutive uppercase letters. This is useful for identifying acronyms\n * 2: lookahead assertion that matches a word boundary\n * 3: numeronym: single letter followed by number and another letter\n * 4: word starting with an optional uppercase letter\n * 5: single digit followed by word to handle '3D' or '2px' (this might be controverial)\n * 6: single uppercase letter or number\n * 7: a dot character. We extract it into a separate word and remove dashes around it later.\n * This is makes more sense conceptually and allows accounting for all possible word variants.\n * Making dot a part of a word prevent us from handling acronyms or numeronyms after the word\n * correctly without making the RegExp prohibitively complicated.\n * https://regex101.com/r/FhMVKc/1\n * <---1---><------------2-----------> <---------3--------> <-----4----> <------5-----> <-----6----> <7>\n */\nconst WORD = /[A-Z]{2,}(?=[A-Z0-9][a-z0-9]+|\\b|_)|[A-Za-z][0-9]+[a-z]?|[A-Z]?[a-z]+|[0-9][A-Za-z]+|[A-Z]|[0-9]+|[.]/g;\n\nexport const toKebabCase = function(input: string): Lowercase<string> {\n return (input.match?.(WORD)?.map(w => w.toLowerCase()).join('-').replaceAll('-.-', '.') || input) as\n Lowercase<string>;\n};\n\nexport function toKebabCaseKeys<T>(settingValue: Record<string, T>): Record<string, T> {\n return Object.fromEntries(Object.entries(settingValue).map(([key, value]) => [toKebabCase(key), value]));\n}\n\n/**\n * Converts a given string to snake_case.\n * This function handles camelCase, PascalCase, and acronyms, including transitions between letters and numbers.\n * It uses Unicode-aware regular expressions (`\\p{L}`, `\\p{N}`, `\\p{Lu}`, `\\p{Ll}` with the `u` flag)\n * to correctly process letters and numbers from various languages.\n *\n * @param text The input string to convert to snake_case.\n * @returns The snake_case version of the input string.\n */\nexport function toSnakeCase(text: string): string {\n if (!text) {\n return '';\n }\n // First, handle case-based transformations to insert underscores correctly.\n // 1. Add underscore between a letter and a number.\n // e.g., \"version2\" -> \"version_2\"\n // 2. Add underscore between an uppercase letter sequence and a following uppercase+lowercase sequence.\n // e.g., \"APIFlags\" -> \"API_Flags\"\n // 3. Add underscore between a lowercase/number and an uppercase letter.\n // e.g., \"lastName\" -> \"last_Name\", \"version_2Update\" -> \"version_2_Update\"\n // 4. Replace sequences of non-alphanumeric with a single underscore\n // 5. Remove any leading or trailing underscores.\n const result = text.replace(/(\\p{L})(\\p{N})/gu, '$1_$2') // 1\n .replace(/(\\p{Lu}+)(\\p{Lu}\\p{Ll})/gu, '$1_$2') // 2\n .replace(/(\\p{Ll}|\\p{N})(\\p{Lu})/gu, '$1_$2') // 3\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}]+/gu, '_') // 4\n .replace(/^_|_$/g, ''); // 5\n\n return result;\n}\n\n/** Replaces the last occurrence of parameter `search` with parameter `replacement` in `input` **/\nexport const replaceLast = function(input: string, search: string, replacement: string): string {\n const replacementStartIndex = input.lastIndexOf(search);\n if (replacementStartIndex === -1) {\n return input;\n }\n\n return input.slice(0, replacementStartIndex) + input.slice(replacementStartIndex).replace(search, replacement);\n};\n\nexport const stringifyWithPrecision = function stringifyWithPrecision(s: number, precision = 2): string {\n if (precision === 0) {\n return s.toFixed(0);\n }\n const string = s.toFixed(precision).replace(/\\.?0*$/, '');\n return string === '-0' ? '0' : string;\n};\n\n/**\n * Somewhat efficiently concatenates 2 base64 encoded strings.\n */\nexport const concatBase64 = function(lhs: string, rhs: string): string {\n if (lhs.length === 0 || !lhs.endsWith('=')) {\n // Empty string or no padding, we can straight-up concatenate.\n return lhs + rhs;\n }\n const lhsLeaveAsIs = lhs.substring(0, lhs.length - 4);\n const lhsToDecode = lhs.substring(lhs.length - 4);\n return lhsLeaveAsIs + globalThis.btoa(globalThis.atob(lhsToDecode) + globalThis.atob(rhs));\n};\n\n/**\n * Characters that cause spreadsheet viewers (Excel, Google Sheets, LibreOffice\n * Calc) to evaluate a cell as a formula rather than rendering it as plain text\n * when they appear at the start of a cell.\n */\nconst CSV_FORMULA_TRIGGERS = new Set(['=', '+', '-', '@', '\\t', '\\r']);\n\n/**\n * Matches plain numeric literals (e.g. `-42`, `+3.14`, `-1e-3`).\n * Even though negative/signed numbers start with `-` or `+`, spreadsheets parse\n * them as numbers rather than formulas, so we exempt them from `'` prefixing to\n * keep numeric columns usable.\n */\nconst CSV_PLAIN_NUMBER = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?$/;\n\n/**\n * Returns true if a spreadsheet viewer could interpret `value` as a formula\n * (for example `=SUM(A1:A2)`, `\"- Loading...\"`, or `\"@alice\"`).\n */\nfunction isCsvFormula(value: string): boolean {\n // Check both the raw string and the leading-whitespace-trimmed string, since\n // some spreadsheet parsers ignore leading spaces before `=`, `+`, `-`, or `@`.\n const trimmed = value.trimStart();\n if (!CSV_FORMULA_TRIGGERS.has(value[0]) && !CSV_FORMULA_TRIGGERS.has(trimmed[0])) {\n return false;\n }\n return !CSV_PLAIN_NUMBER.test(trimmed.trimEnd());\n}\n\n/**\n * Formats and escapes `value` so it can be safely written as a single CSV cell.\n *\n * This handles two separate layers of escaping:\n * 1. Spreadsheet formula escaping (CWE-1236 & viewer fidelity):\n * RFC 4180 double-quoting (`\"=1+1\"` or `\"- Loading...\"`) only groups text\n * into a single CSV column; spreadsheet apps strip the outer `\"` and still\n * evaluate cells starting with `=`, `+`, `-`, or `@` as formulas (often\n * resulting in `#NAME?` errors or unintended formula execution). Prefixing\n * the value with a single quote (`'`) tells spreadsheet apps to treat the\n * cell as literal text (and they hide the leading `'` when displaying it).\n * - Example without commas: `=SUM(A1:A2)` -> `'=SUM(A1:A2)`\n * 2. Structural CSV quoting (RFC 4180, extended):\n * If the cell also contains commas (`,`), semicolons (`;`), tabs, double\n * quotes (`\"`), or newlines, it is wrapped in `\"...\"` (with inner `\"`\n * doubled to `\"\"`) so CSV parsers do not split the cell across columns or\n * rows. `;` and tab are included because spreadsheet apps can use them as\n * the column separator (for example, Excel in many locales uses `;`).\n * Without quotes, `x;=1+1` would split into a new cell that starts with\n * `=` and skips the `'` prefix from step 1.\n * - Example with commas: `=SUM(1,2)` -> `\"'=SUM(1,2)\"`\n * - Example with a semicolon: `x;=1+1` -> `\"x;=1+1\"`\n * - Example starting with a literal quote: `\"=SUM(1,2)\"` -> `\"\"\"=SUM(1,2)\"\"\"`\n * (not treated as a formula since the first character is `\"`, not `=`).\n */\nexport const escapeCsvCell = function(value: string): string {\n // Step 1: Prefix formula-like text with `'` so spreadsheets render it as literal text.\n let escaped = isCsvFormula(value) ? `'${value}` : value;\n\n // Step 2: Apply double-quoting if the cell contains quotes, any common\n // column separator, or line breaks so the CSV structure stays intact.\n if (escaped.includes('\"')) {\n escaped = escaped.replace(/\"/g, '\"\"');\n return `\"${escaped}\"`;\n }\n if (/[,;\\t\\r\\n]/.test(escaped)) {\n return `\"${escaped}\"`;\n }\n return escaped;\n};\n"]}
|