@paulirish/trace_engine 0.0.15 → 0.0.16
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/LICENSE +27 -0
- package/PAUL.readme.md +5 -0
- package/README.md +156 -0
- package/analyze-trace.mjs +184 -0
- package/core/platform/array-utilities.d.ts +66 -0
- package/core/platform/array-utilities.js +199 -0
- package/core/platform/array-utilities.js.map +1 -0
- package/core/platform/date-utilities.d.ts +2 -0
- package/core/platform/date-utilities.js +14 -0
- package/core/platform/date-utilities.js.map +1 -0
- package/core/platform/dcheck-tsconfig.json +8 -0
- package/core/platform/dcheck.d.ts +4 -0
- package/core/platform/dcheck.js +5 -0
- package/core/platform/dom-utilities.d.ts +8 -0
- package/core/platform/dom-utilities.js +109 -0
- package/core/platform/dom-utilities.js.map +1 -0
- package/core/platform/keyboard-utilities.d.ts +17 -0
- package/core/platform/keyboard-utilities.js +22 -0
- package/core/platform/keyboard-utilities.js.map +1 -0
- package/core/platform/map-utilities.d.ts +18 -0
- package/core/platform/map-utilities.js +76 -0
- package/core/platform/map-utilities.js.map +1 -0
- package/core/platform/number-utilities.d.ts +15 -0
- package/core/platform/number-utilities.js +82 -0
- package/core/platform/number-utilities.js.map +1 -0
- package/core/platform/promise-utilities.d.ts +10 -0
- package/core/platform/promise-utilities.js +18 -0
- package/core/platform/promise-utilities.js.map +1 -0
- package/core/platform/set-utilities.d.ts +2 -0
- package/core/platform/set-utilities.js +23 -0
- package/core/platform/set-utilities.js.map +1 -0
- package/core/platform/string-utilities.d.ts +71 -0
- package/core/platform/string-utilities.js +513 -0
- package/core/platform/string-utilities.js.map +1 -0
- package/core/platform/typescript-utilities.d.ts +56 -0
- package/core/platform/typescript-utilities.js +25 -0
- package/core/platform/typescript-utilities.js.map +1 -0
- package/models/trace/EntriesFilter.d.ts +6 -0
- package/models/trace/EntriesFilter.js +17 -0
- package/models/trace/EntriesFilter.js.map +1 -1
- package/package.json +7 -6
- package/test/invalid-animation-events.json.gz +0 -0
- package/test/test-trace-engine.mjs +52 -0
- /package/core/platform/{Brand.d.ts → brand.d.ts} +0 -0
- /package/core/platform/{Brand.js → brand.js} +0 -0
- /package/core/platform/{Brand.js.map → brand.js.map} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) 2020 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
export const isValid = (date) => {
|
|
5
|
+
return !isNaN(date.getTime());
|
|
6
|
+
};
|
|
7
|
+
export const toISO8601Compact = (date) => {
|
|
8
|
+
function leadZero(x) {
|
|
9
|
+
return (x > 9 ? '' : '0') + x;
|
|
10
|
+
}
|
|
11
|
+
return date.getFullYear() + leadZero(date.getMonth() + 1) + leadZero(date.getDate()) + 'T' +
|
|
12
|
+
leadZero(date.getHours()) + leadZero(date.getMinutes()) + leadZero(date.getSeconds());
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=date-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-utilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/date-utilities.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,6BAA6B;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAU,EAAW,EAAE;IAC7C,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAU,EAAU,EAAE;IACrD,SAAS,QAAQ,CAAC,CAAS;QACzB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC,WAAW,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,GAAG;QACtF,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;AAC5F,CAAC,CAAC","sourcesContent":["// Copyright (c) 2020 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nexport const isValid = (date: Date): boolean => {\n return !isNaN(date.getTime());\n};\n\nexport const toISO8601Compact = (date: Date): string => {\n function leadZero(x: number): string {\n return (x > 9 ? '' : '0') + x;\n }\n return date.getFullYear() + leadZero(date.getMonth() + 1) + leadZero(date.getDate()) + 'T' +\n leadZero(date.getHours()) + leadZero(date.getMinutes()) + leadZero(date.getSeconds());\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `document.activeElement` will not enter shadow roots to find the element
|
|
3
|
+
* that has focus; use this method if you need to traverse through any shadow
|
|
4
|
+
* roots to find the actual, specific focused element.
|
|
5
|
+
*/
|
|
6
|
+
export declare function deepActiveElement(doc: Document): Element | null;
|
|
7
|
+
export declare function getEnclosingShadowRootForNode(node: Node): Node | null;
|
|
8
|
+
export declare function rangeOfWord(rootNode: Node, offset: number, stopCharacters: string, stayWithinNode: Node, direction?: string): Range;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copyright 2022 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
/**
|
|
5
|
+
* `document.activeElement` will not enter shadow roots to find the element
|
|
6
|
+
* that has focus; use this method if you need to traverse through any shadow
|
|
7
|
+
* roots to find the actual, specific focused element.
|
|
8
|
+
*/
|
|
9
|
+
export function deepActiveElement(doc) {
|
|
10
|
+
let activeElement = doc.activeElement;
|
|
11
|
+
while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) {
|
|
12
|
+
activeElement = activeElement.shadowRoot.activeElement;
|
|
13
|
+
}
|
|
14
|
+
return activeElement;
|
|
15
|
+
}
|
|
16
|
+
export function getEnclosingShadowRootForNode(node) {
|
|
17
|
+
let parentNode = node.parentNodeOrShadowHost();
|
|
18
|
+
while (parentNode) {
|
|
19
|
+
if (parentNode instanceof ShadowRoot) {
|
|
20
|
+
return parentNode;
|
|
21
|
+
}
|
|
22
|
+
parentNode = parentNode.parentNodeOrShadowHost();
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
export function rangeOfWord(rootNode, offset, stopCharacters, stayWithinNode, direction) {
|
|
27
|
+
let startNode;
|
|
28
|
+
let startOffset = 0;
|
|
29
|
+
let endNode;
|
|
30
|
+
let endOffset = 0;
|
|
31
|
+
if (!stayWithinNode) {
|
|
32
|
+
stayWithinNode = rootNode;
|
|
33
|
+
}
|
|
34
|
+
if (!direction || direction === 'backward' || direction === 'both') {
|
|
35
|
+
let node = rootNode;
|
|
36
|
+
while (node) {
|
|
37
|
+
if (node === stayWithinNode) {
|
|
38
|
+
if (!startNode) {
|
|
39
|
+
startNode = stayWithinNode;
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
if (node.nodeType === Node.TEXT_NODE && node.nodeValue !== null) {
|
|
44
|
+
const start = (node === rootNode ? (offset - 1) : (node.nodeValue.length - 1));
|
|
45
|
+
for (let i = start; i >= 0; --i) {
|
|
46
|
+
if (stopCharacters.indexOf(node.nodeValue[i]) !== -1) {
|
|
47
|
+
startNode = node;
|
|
48
|
+
startOffset = i + 1;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (startNode) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
node = node.traversePreviousNode(stayWithinNode);
|
|
57
|
+
}
|
|
58
|
+
if (!startNode) {
|
|
59
|
+
startNode = stayWithinNode;
|
|
60
|
+
startOffset = 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
startNode = rootNode;
|
|
65
|
+
startOffset = offset;
|
|
66
|
+
}
|
|
67
|
+
if (!direction || direction === 'forward' || direction === 'both') {
|
|
68
|
+
let node = rootNode;
|
|
69
|
+
while (node) {
|
|
70
|
+
if (node === stayWithinNode) {
|
|
71
|
+
if (!endNode) {
|
|
72
|
+
endNode = stayWithinNode;
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
if (node.nodeType === Node.TEXT_NODE && node.nodeValue !== null) {
|
|
77
|
+
const start = (node === rootNode ? offset : 0);
|
|
78
|
+
for (let i = start; i < node.nodeValue.length; ++i) {
|
|
79
|
+
if (stopCharacters.indexOf(node.nodeValue[i]) !== -1) {
|
|
80
|
+
endNode = node;
|
|
81
|
+
endOffset = i;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (endNode) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
node = node.traverseNextNode(stayWithinNode);
|
|
90
|
+
}
|
|
91
|
+
if (!endNode) {
|
|
92
|
+
endNode = stayWithinNode;
|
|
93
|
+
endOffset = stayWithinNode.nodeType === Node.TEXT_NODE ? stayWithinNode.nodeValue?.length || 0 :
|
|
94
|
+
stayWithinNode.childNodes.length;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
endNode = rootNode;
|
|
99
|
+
endOffset = offset;
|
|
100
|
+
}
|
|
101
|
+
if (!rootNode.ownerDocument) {
|
|
102
|
+
throw new Error('No `ownerDocument` found for rootNode');
|
|
103
|
+
}
|
|
104
|
+
const result = rootNode.ownerDocument.createRange();
|
|
105
|
+
result.setStart(startNode, startOffset);
|
|
106
|
+
result.setEnd(endNode, endOffset);
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=dom-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-utilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/dom-utilities.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAa;IAC7C,IAAI,aAAa,GAAiB,GAAG,CAAC,aAAa,CAAC;IACpD,OAAO,aAAa,IAAI,aAAa,CAAC,UAAU,IAAI,aAAa,CAAC,UAAU,CAAC,aAAa,EAAE;QAC1F,aAAa,GAAG,aAAa,CAAC,UAAU,CAAC,aAAa,CAAC;KACxD;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,IAAU;IACtD,IAAI,UAAU,GAAG,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAC/C,OAAO,UAAU,EAAE;QACjB,IAAI,UAAU,YAAY,UAAU,EAAE;YACpC,OAAO,UAAU,CAAC;SACnB;QACD,UAAU,GAAG,UAAU,CAAC,sBAAsB,EAAE,CAAC;KAClD;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,WAAW,CACvB,QAAc,EAAE,MAAc,EAAE,cAAsB,EAAE,cAAoB,EAAE,SAAkB;IAClG,IAAI,SAAS,CAAC;IACd,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,OAAO,CAAC;IACZ,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,IAAI,CAAC,cAAc,EAAE;QACnB,cAAc,GAAG,QAAQ,CAAC;KAC3B;IAED,IAAI,CAAC,SAAS,IAAI,SAAS,KAAK,UAAU,IAAI,SAAS,KAAK,MAAM,EAAE;QAClE,IAAI,IAAI,GAAc,QAAQ,CAAC;QAC/B,OAAO,IAAI,EAAE;YACX,IA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IAElC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright 2022 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * `document.activeElement` will not enter shadow roots to find the element\n * that has focus; use this method if you need to traverse through any shadow\n * roots to find the actual, specific focused element.\n */\nexport function deepActiveElement(doc: Document): Element|null {\n let activeElement: Element|null = doc.activeElement;\n while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) {\n activeElement = activeElement.shadowRoot.activeElement;\n }\n return activeElement;\n}\n\nexport function getEnclosingShadowRootForNode(node: Node): Node|null {\n let parentNode = node.parentNodeOrShadowHost();\n while (parentNode) {\n if (parentNode instanceof ShadowRoot) {\n return parentNode;\n }\n parentNode = parentNode.parentNodeOrShadowHost();\n }\n return null;\n}\n\nexport function rangeOfWord(\n rootNode: Node, offset: number, stopCharacters: string, stayWithinNode: Node, direction?: string): Range {\n let startNode;\n let startOffset = 0;\n let endNode;\n let endOffset = 0;\n\n if (!stayWithinNode) {\n stayWithinNode = rootNode;\n }\n\n if (!direction || direction === 'backward' || direction === 'both') {\n let node: Node|null = rootNode;\n while (node) {\n if (node === stayWithinNode) {\n if (!startNode) {\n startNode = stayWithinNode;\n }\n break;\n }\n\n if (node.nodeType === Node.TEXT_NODE && node.nodeValue !== null) {\n const start = (node === rootNode ? (offset - 1) : (node.nodeValue.length - 1));\n for (let i = start; i >= 0; --i) {\n if (stopCharacters.indexOf(node.nodeValue[i]) !== -1) {\n startNode = node;\n startOffset = i + 1;\n break;\n }\n }\n }\n\n if (startNode) {\n break;\n }\n\n node = node.traversePreviousNode(stayWithinNode);\n }\n\n if (!startNode) {\n startNode = stayWithinNode;\n startOffset = 0;\n }\n } else {\n startNode = rootNode;\n startOffset = offset;\n }\n\n if (!direction || direction === 'forward' || direction === 'both') {\n let node: (Node|null)|Node = rootNode;\n while (node) {\n if (node === stayWithinNode) {\n if (!endNode) {\n endNode = stayWithinNode;\n }\n break;\n }\n\n if (node.nodeType === Node.TEXT_NODE && node.nodeValue !== null) {\n const start = (node === rootNode ? offset : 0);\n for (let i = start; i < node.nodeValue.length; ++i) {\n if (stopCharacters.indexOf(node.nodeValue[i]) !== -1) {\n endNode = node;\n endOffset = i;\n break;\n }\n }\n }\n\n if (endNode) {\n break;\n }\n\n node = node.traverseNextNode(stayWithinNode);\n }\n\n if (!endNode) {\n endNode = stayWithinNode;\n endOffset = stayWithinNode.nodeType === Node.TEXT_NODE ? stayWithinNode.nodeValue?.length || 0 :\n stayWithinNode.childNodes.length;\n }\n } else {\n endNode = rootNode;\n endOffset = offset;\n }\n\n if (!rootNode.ownerDocument) {\n throw new Error('No `ownerDocument` found for rootNode');\n }\n const result = rootNode.ownerDocument.createRange();\n result.setStart(startNode, startOffset);\n result.setEnd(endNode, endOffset);\n\n return result;\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const enum ArrowKey {
|
|
2
|
+
UP = "ArrowUp",
|
|
3
|
+
DOWN = "ArrowDown",
|
|
4
|
+
LEFT = "ArrowLeft",
|
|
5
|
+
RIGHT = "ArrowRight"
|
|
6
|
+
}
|
|
7
|
+
export declare const enum PageKey {
|
|
8
|
+
UP = "PageUp",
|
|
9
|
+
DOWN = "PageDown"
|
|
10
|
+
}
|
|
11
|
+
export declare const ENTER_KEY = "Enter";
|
|
12
|
+
export declare const ESCAPE_KEY = "Escape";
|
|
13
|
+
export declare const TAB_KEY = "Tab";
|
|
14
|
+
export declare const ARROW_KEYS: Set<ArrowKey>;
|
|
15
|
+
export declare function keyIsArrowKey(key: string): key is ArrowKey;
|
|
16
|
+
export declare function isEscKey(event: KeyboardEvent): boolean;
|
|
17
|
+
export declare function isEnterOrSpaceKey(event: KeyboardEvent): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) 2020 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
export const ENTER_KEY = 'Enter';
|
|
5
|
+
export const ESCAPE_KEY = 'Escape';
|
|
6
|
+
export const TAB_KEY = 'Tab';
|
|
7
|
+
export const ARROW_KEYS = new Set([
|
|
8
|
+
"ArrowUp" /* ArrowKey.UP */,
|
|
9
|
+
"ArrowDown" /* ArrowKey.DOWN */,
|
|
10
|
+
"ArrowLeft" /* ArrowKey.LEFT */,
|
|
11
|
+
"ArrowRight" /* ArrowKey.RIGHT */,
|
|
12
|
+
]);
|
|
13
|
+
export function keyIsArrowKey(key) {
|
|
14
|
+
return ARROW_KEYS.has(key);
|
|
15
|
+
}
|
|
16
|
+
export function isEscKey(event) {
|
|
17
|
+
return event.key === 'Escape';
|
|
18
|
+
}
|
|
19
|
+
export function isEnterOrSpaceKey(event) {
|
|
20
|
+
return event.key === 'Enter' || event.key === ' ';
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=keyboard-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard-utilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/keyboard-utilities.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,6BAA6B;AAc7B,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AACjC,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC;AACnC,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC;AAE7B,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAW;;;;;CAK3C,CAAC,CAAC;AAEH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,UAAU,CAAC,GAAG,CAAC,GAAe,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAoB;IACpD,OAAO,KAAK,CAAC,GAAG,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC;AACpD,CAAC","sourcesContent":["// Copyright (c) 2020 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nexport const enum ArrowKey {\n UP = 'ArrowUp',\n DOWN = 'ArrowDown',\n LEFT = 'ArrowLeft',\n RIGHT = 'ArrowRight',\n}\n\nexport const enum PageKey {\n UP = 'PageUp',\n DOWN = 'PageDown',\n}\n\nexport const ENTER_KEY = 'Enter';\nexport const ESCAPE_KEY = 'Escape';\nexport const TAB_KEY = 'Tab';\n\nexport const ARROW_KEYS = new Set<ArrowKey>([\n ArrowKey.UP,\n ArrowKey.DOWN,\n ArrowKey.LEFT,\n ArrowKey.RIGHT,\n]);\n\nexport function keyIsArrowKey(key: string): key is ArrowKey {\n return ARROW_KEYS.has(key as ArrowKey);\n}\n\nexport function isEscKey(event: KeyboardEvent): boolean {\n return event.key === 'Escape';\n}\n\nexport function isEnterOrSpaceKey(event: KeyboardEvent): boolean {\n return event.key === 'Enter' || event.key === ' ';\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const inverse: <K, V>(map: Map<K, V>) => Multimap<V, K>;
|
|
2
|
+
export declare class Multimap<K, V> {
|
|
3
|
+
private map;
|
|
4
|
+
set(key: K, value: V): void;
|
|
5
|
+
get(key: K): Set<V>;
|
|
6
|
+
has(key: K): boolean;
|
|
7
|
+
hasValue(key: K, value: V): boolean;
|
|
8
|
+
get size(): number;
|
|
9
|
+
delete(key: K, value: V): boolean;
|
|
10
|
+
deleteAll(key: K): void;
|
|
11
|
+
keysArray(): K[];
|
|
12
|
+
valuesArray(): V[];
|
|
13
|
+
clear(): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Gets value for key, assigning a default if value is falsy.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getWithDefault<K extends {}, V>(map: WeakMap<K, V> | Map<K, V>, key: K, defaultValueFactory: (key?: K) => V): V;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Copyright (c) 2020 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
export const inverse = function (map) {
|
|
5
|
+
const result = new Multimap();
|
|
6
|
+
for (const [key, value] of map.entries()) {
|
|
7
|
+
result.set(value, key);
|
|
8
|
+
}
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
export class Multimap {
|
|
12
|
+
map = new Map();
|
|
13
|
+
set(key, value) {
|
|
14
|
+
let set = this.map.get(key);
|
|
15
|
+
if (!set) {
|
|
16
|
+
set = new Set();
|
|
17
|
+
this.map.set(key, set);
|
|
18
|
+
}
|
|
19
|
+
set.add(value);
|
|
20
|
+
}
|
|
21
|
+
get(key) {
|
|
22
|
+
return this.map.get(key) || new Set();
|
|
23
|
+
}
|
|
24
|
+
has(key) {
|
|
25
|
+
return this.map.has(key);
|
|
26
|
+
}
|
|
27
|
+
hasValue(key, value) {
|
|
28
|
+
const set = this.map.get(key);
|
|
29
|
+
if (!set) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return set.has(value);
|
|
33
|
+
}
|
|
34
|
+
get size() {
|
|
35
|
+
return this.map.size;
|
|
36
|
+
}
|
|
37
|
+
delete(key, value) {
|
|
38
|
+
const values = this.get(key);
|
|
39
|
+
if (!values) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const result = values.delete(value);
|
|
43
|
+
if (!values.size) {
|
|
44
|
+
this.map.delete(key);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
deleteAll(key) {
|
|
49
|
+
this.map.delete(key);
|
|
50
|
+
}
|
|
51
|
+
keysArray() {
|
|
52
|
+
return [...this.map.keys()];
|
|
53
|
+
}
|
|
54
|
+
valuesArray() {
|
|
55
|
+
const result = [];
|
|
56
|
+
for (const set of this.map.values()) {
|
|
57
|
+
result.push(...set.values());
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
clear() {
|
|
62
|
+
this.map.clear();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Gets value for key, assigning a default if value is falsy.
|
|
67
|
+
*/
|
|
68
|
+
export function getWithDefault(map, key, defaultValueFactory) {
|
|
69
|
+
let value = map.get(key);
|
|
70
|
+
if (!value) {
|
|
71
|
+
value = defaultValueFactory(key);
|
|
72
|
+
map.set(key, value);
|
|
73
|
+
}
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=map-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-utilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/map-utilities.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,6BAA6B;AAE7B,MAAM,CAAC,MAAM,OAAO,GAAG,UAAe,GAAc;IAClD,MAAM,MAAM,GAAG,IAAI,QAAQ,EAAQ,CAAC;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE;QACxC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;KACxB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,OAAO,QAAQ;IACX,GAAG,GAAG,IAAI,GAAG,EAAa,CAAC;IAEnC,GAAG,CAAC,GAAM,EAAE,KAAQ;QAClB,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,GAAG,EAAE;YACR,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;YAChB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CA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AAM,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE;YACnC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;SAC9B;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC1B,GAA4B,EAAE,GAAM,EAAE,mBAAmC;IAC3E,IAAI,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,CAAC,KAAK,EAAE;QACV,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACjC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;KACrB;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright (c) 2020 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nexport const inverse = function<K, V>(map: Map<K, V>): Multimap<V, K> {\n const result = new Multimap<V, K>();\n for (const [key, value] of map.entries()) {\n result.set(value, key);\n }\n return result;\n};\n\nexport class Multimap<K, V> {\n private map = new Map<K, Set<V>>();\n\n set(key: K, value: V): void {\n let set = this.map.get(key);\n if (!set) {\n set = new Set();\n this.map.set(key, set);\n }\n set.add(value);\n }\n\n get(key: K): Set<V> {\n return this.map.get(key) || new Set();\n }\n\n has(key: K): boolean {\n return this.map.has(key);\n }\n\n hasValue(key: K, value: V): boolean {\n const set = this.map.get(key);\n if (!set) {\n return false;\n }\n return set.has(value);\n }\n\n get size(): number {\n return this.map.size;\n }\n\n delete(key: K, value: V): boolean {\n const values = this.get(key);\n if (!values) {\n return false;\n }\n const result = values.delete(value);\n if (!values.size) {\n this.map.delete(key);\n }\n return result;\n }\n\n deleteAll(key: K): void {\n this.map.delete(key);\n }\n\n keysArray(): K[] {\n return [...this.map.keys()];\n }\n\n valuesArray(): V[] {\n const result = [];\n for (const set of this.map.values()) {\n result.push(...set.values());\n }\n return result;\n }\n\n clear(): void {\n this.map.clear();\n }\n}\n\n/**\n * Gets value for key, assigning a default if value is falsy.\n */\nexport function getWithDefault<K extends {}, V>(\n map: WeakMap<K, V>|Map<K, V>, key: K, defaultValueFactory: (key?: K) => V): V {\n let value = map.get(key);\n if (!value) {\n value = defaultValueFactory(key);\n map.set(key, value);\n }\n\n return value;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const clamp: (num: number, min: number, max: number) => number;
|
|
2
|
+
export declare const mod: (m: number, n: number) => number;
|
|
3
|
+
export declare const bytesToString: (bytes: number) => string;
|
|
4
|
+
export declare const toFixedIfFloating: (value: string) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Rounds a number (including float) down.
|
|
7
|
+
*/
|
|
8
|
+
export declare const floor: (value: number, precision?: number) => number;
|
|
9
|
+
/**
|
|
10
|
+
* Computes the great common divisor for two numbers.
|
|
11
|
+
* If the numbers are floats, they will be rounded to an integer.
|
|
12
|
+
*/
|
|
13
|
+
export declare const greatestCommonDivisor: (a: number, b: number) => number;
|
|
14
|
+
export declare const aspectRatio: (width: number, height: number) => string;
|
|
15
|
+
export declare const withThousandsSeparator: (num: number) => string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Copyright (c) 2020 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
export const clamp = (num, min, max) => {
|
|
5
|
+
let clampedNumber = num;
|
|
6
|
+
if (num < min) {
|
|
7
|
+
clampedNumber = min;
|
|
8
|
+
}
|
|
9
|
+
else if (num > max) {
|
|
10
|
+
clampedNumber = max;
|
|
11
|
+
}
|
|
12
|
+
return clampedNumber;
|
|
13
|
+
};
|
|
14
|
+
export const mod = (m, n) => {
|
|
15
|
+
return ((m % n) + n) % n;
|
|
16
|
+
};
|
|
17
|
+
export const bytesToString = (bytes) => {
|
|
18
|
+
if (bytes < 1000) {
|
|
19
|
+
return `${bytes.toFixed(0)}\xA0B`;
|
|
20
|
+
}
|
|
21
|
+
const kilobytes = bytes / 1000;
|
|
22
|
+
if (kilobytes < 100) {
|
|
23
|
+
return `${kilobytes.toFixed(1)}\xA0kB`;
|
|
24
|
+
}
|
|
25
|
+
if (kilobytes < 1000) {
|
|
26
|
+
return `${kilobytes.toFixed(0)}\xA0kB`;
|
|
27
|
+
}
|
|
28
|
+
const megabytes = kilobytes / 1000;
|
|
29
|
+
if (megabytes < 100) {
|
|
30
|
+
return `${megabytes.toFixed(1)}\xA0MB`;
|
|
31
|
+
}
|
|
32
|
+
return `${megabytes.toFixed(0)}\xA0MB`;
|
|
33
|
+
};
|
|
34
|
+
export const toFixedIfFloating = (value) => {
|
|
35
|
+
if (!value || Number.isNaN(Number(value))) {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
const number = Number(value);
|
|
39
|
+
return number % 1 ? number.toFixed(3) : String(number);
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Rounds a number (including float) down.
|
|
43
|
+
*/
|
|
44
|
+
export const floor = (value, precision = 0) => {
|
|
45
|
+
const mult = Math.pow(10, precision);
|
|
46
|
+
return Math.floor(value * mult) / mult;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Computes the great common divisor for two numbers.
|
|
50
|
+
* If the numbers are floats, they will be rounded to an integer.
|
|
51
|
+
*/
|
|
52
|
+
export const greatestCommonDivisor = (a, b) => {
|
|
53
|
+
a = Math.round(a);
|
|
54
|
+
b = Math.round(b);
|
|
55
|
+
while (b !== 0) {
|
|
56
|
+
const t = b;
|
|
57
|
+
b = a % b;
|
|
58
|
+
a = t;
|
|
59
|
+
}
|
|
60
|
+
return a;
|
|
61
|
+
};
|
|
62
|
+
const commonRatios = new Map([
|
|
63
|
+
['8∶5', '16∶10'],
|
|
64
|
+
]);
|
|
65
|
+
export const aspectRatio = (width, height) => {
|
|
66
|
+
const divisor = greatestCommonDivisor(width, height);
|
|
67
|
+
if (divisor !== 0) {
|
|
68
|
+
width /= divisor;
|
|
69
|
+
height /= divisor;
|
|
70
|
+
}
|
|
71
|
+
const result = `${width}∶${height}`;
|
|
72
|
+
return commonRatios.get(result) || result;
|
|
73
|
+
};
|
|
74
|
+
export const withThousandsSeparator = function (num) {
|
|
75
|
+
let str = String(num);
|
|
76
|
+
const re = /(\d+)(\d{3})/;
|
|
77
|
+
while (str.match(re)) {
|
|
78
|
+
str = str.replace(re, '$1\xA0$2');
|
|
79
|
+
} // \xa0 is a non-breaking space
|
|
80
|
+
return str;
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=number-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-utilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/number-utilities.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,6BAA6B;AAE7B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,GAAW,EAAU,EAAE;IACrE,IAAI,aAAa,GAAG,GAAG,CAAC;IACxB,IAAI,GAAG,GAAG,GAAG,EAAE;QACb,aAAa,GAAG,GAAG,CAAC;KACrB;SAAM,IAAI,GAAG,GAAG,GAAG,EAAE;QACpB,aAAa,GAAG,GAAG,CAAC;KACrB;IACD,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE;IAClD,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAa,EAAU,EAAE;IACrD,IAAI,KAAK,GAAG,IAAI,EAAE;QAChB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ium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nexport const clamp = (num: number, min: number, max: number): number => {\n let clampedNumber = num;\n if (num < min) {\n clampedNumber = min;\n } else if (num > max) {\n clampedNumber = max;\n }\n return clampedNumber;\n};\n\nexport const mod = (m: number, n: number): number => {\n return ((m % n) + n) % n;\n};\n\nexport const bytesToString = (bytes: number): string => {\n if (bytes < 1000) {\n return `${bytes.toFixed(0)}\\xA0B`;\n }\n\n const kilobytes = bytes / 1000;\n if (kilobytes < 100) {\n return `${kilobytes.toFixed(1)}\\xA0kB`;\n }\n if (kilobytes < 1000) {\n return `${kilobytes.toFixed(0)}\\xA0kB`;\n }\n\n const megabytes = kilobytes / 1000;\n if (megabytes < 100) {\n return `${megabytes.toFixed(1)}\\xA0MB`;\n }\n return `${megabytes.toFixed(0)}\\xA0MB`;\n};\n\nexport const toFixedIfFloating = (value: string): string => {\n if (!value || Number.isNaN(Number(value))) {\n return value;\n }\n const number = Number(value);\n return number % 1 ? number.toFixed(3) : String(number);\n};\n\n/**\n * Rounds a number (including float) down.\n */\nexport const floor = (value: number, precision: number = 0): number => {\n const mult = Math.pow(10, precision);\n return Math.floor(value * mult) / mult;\n};\n\n/**\n * Computes the great common divisor for two numbers.\n * If the numbers are floats, they will be rounded to an integer.\n */\nexport const greatestCommonDivisor = (a: number, b: number): number => {\n a = Math.round(a);\n b = Math.round(b);\n while (b !== 0) {\n const t = b;\n b = a % b;\n a = t;\n }\n return a;\n};\n\nconst commonRatios = new Map([\n ['8∶5', '16∶10'],\n]);\n\nexport const aspectRatio = (width: number, height: number): string => {\n const divisor = greatestCommonDivisor(width, height);\n if (divisor !== 0) {\n width /= divisor;\n height /= divisor;\n }\n const result = `${width}∶${height}`;\n return commonRatios.get(result) || result;\n};\n\nexport const withThousandsSeparator = function(num: number): string {\n let str = String(num);\n const re = /(\\d+)(\\d{3})/;\n while (str.match(re)) {\n str = str.replace(re, '$1\\xA0$2');\n } // \\xa0 is a non-breaking space\n return str;\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a new pending promise together with it's resolve and reject functions.
|
|
3
|
+
*
|
|
4
|
+
* Polyfill for https://github.com/tc39/proposal-promise-with-resolvers.
|
|
5
|
+
*/
|
|
6
|
+
export declare function promiseWithResolvers<T = unknown>(): {
|
|
7
|
+
promise: Promise<T>;
|
|
8
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
9
|
+
reject: (error?: Error) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright 2023 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
/**
|
|
5
|
+
* Returns a new pending promise together with it's resolve and reject functions.
|
|
6
|
+
*
|
|
7
|
+
* Polyfill for https://github.com/tc39/proposal-promise-with-resolvers.
|
|
8
|
+
*/
|
|
9
|
+
export function promiseWithResolvers() {
|
|
10
|
+
let resolve;
|
|
11
|
+
let reject;
|
|
12
|
+
const promise = new Promise((res, rej) => {
|
|
13
|
+
resolve = res;
|
|
14
|
+
reject = rej;
|
|
15
|
+
});
|
|
16
|
+
return { promise, resolve, reject };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=promise-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-utilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/promise-utilities.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAKlC,IAAI,OAA2C,CAAC;IAChD,IAAI,MAAgC,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC1C,OAAO,GAAG,GAAG,CAAC;QACd,MAAM,GAAG,GAAG,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAC,CAAC;AACpC,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Returns a new pending promise together with it's resolve and reject functions.\n *\n * Polyfill for https://github.com/tc39/proposal-promise-with-resolvers.\n */\nexport function promiseWithResolvers<T = unknown>(): {\n promise: Promise<T>,\n resolve: (value: T|PromiseLike<T>) => void,\n reject: (error?: Error) => void,\n} {\n let resolve!: (value: T|PromiseLike<T>) => void;\n let reject!: (error?: Error) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return {promise, resolve, reject};\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) 2020 The Chromium Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
export const addAll = function (set, iterable) {
|
|
5
|
+
for (const item of iterable) {
|
|
6
|
+
set.add(item);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
export const isEqual = function (setA, setB) {
|
|
10
|
+
if (setA === setB) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (setA.size !== setB.size) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
for (const item of setA) {
|
|
17
|
+
if (!setB.has(item)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=set-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-utilities.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/set-utilities.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,yEAAyE;AACzE,6BAA6B;AAE7B,MAAM,CAAC,MAAM,MAAM,GAAG,UAAY,GAAW,EAAE,QAAqB;IAClE,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE;QAC3B,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;KACf;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,UAAY,IAAY,EAAE,IAAY;IAC3D,IAAI,IAAI,KAAK,IAAI,EAAE;QACjB,OAAO,IAAI,CAAC;KACb;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;QAC3B,OAAO,KAAK,CAAC;KACd;IACD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;QACvB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACnB,OAAO,KAAK,CAAC;SACd;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["// Copyright (c) 2020 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nexport const addAll = function<T>(set: Set<T>, iterable: Iterable<T>): void {\n for (const item of iterable) {\n set.add(item);\n }\n};\n\nexport const isEqual = function<T>(setA: Set<T>, setB: Set<T>): boolean {\n if (setA === setB) {\n return true;\n }\n if (setA.size !== setB.size) {\n return false;\n }\n for (const item of setA) {\n if (!setB.has(item)) {\n return false;\n }\n }\n return true;\n};\n"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export declare const escapeCharacters: (inputString: string, charsToEscape: string) => string;
|
|
2
|
+
export declare const formatAsJSLiteral: (content: string) => string;
|
|
3
|
+
/**
|
|
4
|
+
* This implements a subset of the sprintf() function described in the Single UNIX
|
|
5
|
+
* Specification. It supports the %s, %f, %d, and %% formatting specifiers, and
|
|
6
|
+
* understands the %m$d notation to select the m-th parameter for this substitution,
|
|
7
|
+
* as well as the optional precision for %s, %f, and %d.
|
|
8
|
+
*
|
|
9
|
+
* @param fmt format string.
|
|
10
|
+
* @param args parameters to the format string.
|
|
11
|
+
* @returns the formatted output string.
|
|
12
|
+
*/
|
|
13
|
+
export declare const sprintf: (fmt: string, ...args: unknown[]) => string;
|
|
14
|
+
export declare const toBase64: (inputString: string) => string;
|
|
15
|
+
export declare const findIndexesOfSubString: (inputString: string, searchString: string) => number[];
|
|
16
|
+
export declare const findLineEndingIndexes: (inputString: string) => number[];
|
|
17
|
+
export declare const isWhitespace: (inputString: string) => boolean;
|
|
18
|
+
export declare const trimURL: (url: string, baseURLDomain?: string) => string;
|
|
19
|
+
export declare const collapseWhitespace: (inputString: string) => string;
|
|
20
|
+
export declare const reverse: (inputString: string) => string;
|
|
21
|
+
export declare const replaceControlCharacters: (inputString: string) => string;
|
|
22
|
+
export declare const countWtf8Bytes: (inputString: string) => number;
|
|
23
|
+
export declare const stripLineBreaks: (inputStr: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Tests if the `inputStr` is following the extended Kebab Case naming convetion,
|
|
26
|
+
* where words are separated with either a dash (`-`) or a dot (`.`), and all
|
|
27
|
+
* characters must be lower-case alphanumeric.
|
|
28
|
+
*
|
|
29
|
+
* For example, it will yield `true` for `'my.amazing-string.literal'`, but `false`
|
|
30
|
+
* for `'Another.AmazingLiteral'` or '`another_amazing_literal'`.
|
|
31
|
+
*
|
|
32
|
+
* @param inputStr the input string to test.
|
|
33
|
+
* @return `true` if the `inputStr` follows the extended Kebab Case convention.
|
|
34
|
+
*/
|
|
35
|
+
export declare const isExtendedKebabCase: (inputStr: string) => boolean;
|
|
36
|
+
export declare const toTitleCase: (inputStr: string) => string;
|
|
37
|
+
export declare const removeURLFragment: (inputStr: string) => string;
|
|
38
|
+
export declare const regexSpecialCharacters: () => string;
|
|
39
|
+
export declare const filterRegex: (query: string) => RegExp;
|
|
40
|
+
export declare const createSearchRegex: (query: string, caseSensitive: boolean, isRegex: boolean, matchWholeWord?: boolean) => RegExp;
|
|
41
|
+
export declare const caseInsensetiveComparator: (a: string, b: string) => number;
|
|
42
|
+
export declare const hashCode: (string?: string) => number;
|
|
43
|
+
export declare const compare: (a: string, b: string) => number;
|
|
44
|
+
export declare const trimMiddle: (str: string, maxLength: number) => string;
|
|
45
|
+
export declare const trimEndWithMaxLength: (str: string, maxLength: number) => string;
|
|
46
|
+
export declare const escapeForRegExp: (str: string) => string;
|
|
47
|
+
export declare const naturalOrderComparator: (a: string, b: string) => number;
|
|
48
|
+
export declare const base64ToSize: (content: string | null) => number;
|
|
49
|
+
export declare const SINGLE_QUOTE = "'";
|
|
50
|
+
export declare const DOUBLE_QUOTE = "\"";
|
|
51
|
+
export declare const findUnclosedCssQuote: (str: string) => string;
|
|
52
|
+
export declare const countUnmatchedLeftParentheses: (str: string) => number;
|
|
53
|
+
export declare const createPlainTextSearchRegex: (query: string, flags?: string) => RegExp;
|
|
54
|
+
declare class LowerCaseStringTag {
|
|
55
|
+
private lowerCaseStringTag;
|
|
56
|
+
}
|
|
57
|
+
export type LowerCaseString = string & LowerCaseStringTag;
|
|
58
|
+
export declare const toLowerCaseString: (input: string) => LowerCaseString;
|
|
59
|
+
export declare const toKebabCase: (input: string) => Lowercase<string>;
|
|
60
|
+
export declare function toKebabCaseKeys(settingValue: {
|
|
61
|
+
[x: string]: any;
|
|
62
|
+
}): {
|
|
63
|
+
[x: string]: any;
|
|
64
|
+
};
|
|
65
|
+
export declare const replaceLast: (input: string, search: string, replacement: string) => string;
|
|
66
|
+
export declare const stringifyWithPrecision: (s: number, precision?: number) => string;
|
|
67
|
+
/**
|
|
68
|
+
* Somewhat efficiently concatenates 2 base64 encoded strings.
|
|
69
|
+
*/
|
|
70
|
+
export declare const concatBase64: (lhs: string, rhs: string) => string;
|
|
71
|
+
export {};
|