@paulirish/trace_engine 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/analyze-trace.mjs +1 -1
  2. package/core/platform/DevToolsPath.d.ts +4 -13
  3. package/core/platform/DevToolsPath.js +7 -4
  4. package/core/platform/DevToolsPath.js.map +1 -7
  5. package/core/platform/MimeType.d.ts +27 -0
  6. package/core/platform/MimeType.js +119 -86
  7. package/core/platform/MimeType.js.map +1 -7
  8. package/core/platform/Timing.d.ts +7 -0
  9. package/core/platform/Timing.js +7 -4
  10. package/core/platform/Timing.js.map +1 -7
  11. package/core/platform/UIString.d.ts +2 -5
  12. package/core/platform/UIString.js +5 -2
  13. package/core/platform/UIString.js.map +1 -7
  14. package/core/platform/UserVisibleError.js +19 -10
  15. package/core/platform/UserVisibleError.js.map +1 -7
  16. package/core/platform/array-utilities.d.ts +48 -10
  17. package/core/platform/array-utilities.js +160 -124
  18. package/core/platform/array-utilities.js.map +1 -7
  19. package/core/platform/brand.d.ts +14 -0
  20. package/core/platform/brand.js +5 -1
  21. package/core/platform/brand.js.map +1 -7
  22. package/core/platform/date-utilities.js +10 -6
  23. package/core/platform/date-utilities.js.map +1 -7
  24. package/core/platform/dom-utilities.d.ts +3 -1
  25. package/core/platform/dom-utilities.js +94 -83
  26. package/core/platform/dom-utilities.js.map +1 -7
  27. package/core/platform/keyboard-utilities.d.ts +2 -0
  28. package/core/platform/keyboard-utilities.js +15 -24
  29. package/core/platform/keyboard-utilities.js.map +1 -7
  30. package/core/platform/map-utilities.d.ts +4 -0
  31. package/core/platform/map-utilities.js +66 -60
  32. package/core/platform/map-utilities.js.map +1 -7
  33. package/core/platform/number-utilities.js +66 -55
  34. package/core/platform/number-utilities.js.map +1 -7
  35. package/core/platform/platform.d.ts +5 -1
  36. package/core/platform/platform.js +54 -37
  37. package/core/platform/platform.js.map +1 -7
  38. package/core/platform/promise-utilities.d.ts +10 -0
  39. package/core/platform/promise-utilities.js +16 -8
  40. package/core/platform/promise-utilities.js.map +1 -7
  41. package/core/platform/set-utilities.js +20 -17
  42. package/core/platform/set-utilities.js.map +1 -7
  43. package/core/platform/string-utilities.d.ts +32 -1
  44. package/core/platform/string-utilities.js +453 -379
  45. package/core/platform/string-utilities.js.map +1 -7
  46. package/core/platform/typescript-utilities.d.ts +5 -5
  47. package/core/platform/typescript-utilities.js +19 -7
  48. package/core/platform/typescript-utilities.js.map +1 -7
  49. package/generated/protocol.d.ts +2081 -347
  50. package/generated/protocol.js +5 -2230
  51. package/models/cpu_profile/CPUProfileDataModel.d.ts +77 -0
  52. package/models/cpu_profile/CPUProfileDataModel.js +492 -359
  53. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -7
  54. package/models/cpu_profile/ProfileTreeModel.d.ts +29 -0
  55. package/models/cpu_profile/ProfileTreeModel.js +87 -82
  56. package/models/cpu_profile/ProfileTreeModel.js.map +1 -7
  57. package/models/cpu_profile/cpu_profile.d.ts +3 -0
  58. package/models/cpu_profile/cpu_profile.js +7 -7
  59. package/models/cpu_profile/cpu_profile.js.map +1 -7
  60. package/models/trace/EntriesFilter.d.ts +55 -0
  61. package/models/trace/EntriesFilter.js +227 -166
  62. package/models/trace/EntriesFilter.js.map +1 -7
  63. package/models/trace/LegacyTracingModel.js.map +1 -7
  64. package/models/trace/ModelImpl.d.ts +110 -0
  65. package/models/trace/ModelImpl.js +161 -102
  66. package/models/trace/ModelImpl.js.map +1 -7
  67. package/models/trace/Processor.d.ts +36 -0
  68. package/models/trace/Processor.js +197 -163
  69. package/models/trace/Processor.js.map +1 -7
  70. package/models/trace/TracingManager.js.map +1 -7
  71. package/models/trace/extras/FetchNodes.d.ts +46 -0
  72. package/models/trace/extras/FetchNodes.js +132 -91
  73. package/models/trace/extras/FetchNodes.js.map +1 -7
  74. package/models/trace/extras/FilmStrip.d.ts +19 -0
  75. package/models/trace/extras/FilmStrip.js +38 -31
  76. package/models/trace/extras/FilmStrip.js.map +1 -7
  77. package/models/trace/extras/MainThreadActivity.d.ts +2 -0
  78. package/models/trace/extras/MainThreadActivity.js +72 -56
  79. package/models/trace/extras/MainThreadActivity.js.map +1 -7
  80. package/models/trace/extras/Metadata.d.ts +2 -0
  81. package/models/trace/extras/Metadata.js +42 -26
  82. package/models/trace/extras/Metadata.js.map +1 -7
  83. package/models/trace/extras/extras.js.map +1 -7
  84. package/models/trace/handlers/AnimationHandler.d.ts +8 -0
  85. package/models/trace/handlers/AnimationHandler.js +22 -20
  86. package/models/trace/handlers/AnimationHandler.js.map +1 -7
  87. package/models/trace/handlers/AuctionWorkletsHandler.d.ts +8 -0
  88. package/models/trace/handlers/AuctionWorkletsHandler.js +143 -89
  89. package/models/trace/handlers/AuctionWorkletsHandler.js.map +1 -7
  90. package/models/trace/handlers/FramesHandler.d.ts +76 -0
  91. package/models/trace/handlers/FramesHandler.js +424 -355
  92. package/models/trace/handlers/FramesHandler.js.map +1 -7
  93. package/models/trace/handlers/GPUHandler.d.ts +11 -0
  94. package/models/trace/handlers/GPUHandler.js +41 -37
  95. package/models/trace/handlers/GPUHandler.js.map +1 -7
  96. package/models/trace/handlers/InitiatorsHandler.d.ts +10 -0
  97. package/models/trace/handlers/InitiatorsHandler.js +164 -113
  98. package/models/trace/handlers/InitiatorsHandler.js.map +1 -7
  99. package/models/trace/handlers/InvalidationsHandler.d.ts +10 -0
  100. package/models/trace/handlers/InvalidationsHandler.js +101 -79
  101. package/models/trace/handlers/InvalidationsHandler.js.map +1 -7
  102. package/models/trace/handlers/LargestImagePaintHandler.d.ts +5 -0
  103. package/models/trace/handlers/LargestImagePaintHandler.js +32 -12
  104. package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -7
  105. package/models/trace/handlers/LargestTextPaintHandler.d.ts +5 -0
  106. package/models/trace/handlers/LargestTextPaintHandler.js +20 -12
  107. package/models/trace/handlers/LargestTextPaintHandler.js.map +1 -7
  108. package/models/trace/handlers/LayerTreeHandler.d.ts +13 -0
  109. package/models/trace/handlers/LayerTreeHandler.js +96 -70
  110. package/models/trace/handlers/LayerTreeHandler.js.map +1 -7
  111. package/models/trace/handlers/LayoutShiftsHandler.d.ts +44 -0
  112. package/models/trace/handlers/LayoutShiftsHandler.js +304 -227
  113. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -7
  114. package/models/trace/handlers/MemoryHandler.d.ts +7 -0
  115. package/models/trace/handlers/MemoryHandler.js +14 -11
  116. package/models/trace/handlers/MemoryHandler.js.map +1 -7
  117. package/models/trace/handlers/MetaHandler.d.ts +37 -0
  118. package/models/trace/handlers/MetaHandler.js +314 -226
  119. package/models/trace/handlers/MetaHandler.js.map +1 -7
  120. package/models/trace/handlers/ModelHandlers.d.ts +21 -0
  121. package/models/trace/handlers/ModelHandlers.js +25 -22
  122. package/models/trace/handlers/ModelHandlers.js.map +1 -7
  123. package/models/trace/handlers/NetworkRequestsHandler.d.ts +17 -0
  124. package/models/trace/handlers/NetworkRequestsHandler.js +342 -218
  125. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -7
  126. package/models/trace/handlers/PageLoadMetricsHandler.d.ts +67 -0
  127. package/models/trace/handlers/PageLoadMetricsHandler.js +357 -284
  128. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -7
  129. package/models/trace/handlers/RendererHandler.d.ts +101 -0
  130. package/models/trace/handlers/RendererHandler.js +295 -191
  131. package/models/trace/handlers/RendererHandler.js.map +1 -7
  132. package/models/trace/handlers/SamplesHandler.d.ts +46 -0
  133. package/models/trace/handlers/SamplesHandler.js +195 -158
  134. package/models/trace/handlers/SamplesHandler.js.map +1 -7
  135. package/models/trace/handlers/ScreenshotsHandler.d.ts +7 -0
  136. package/models/trace/handlers/ScreenshotsHandler.js +63 -41
  137. package/models/trace/handlers/ScreenshotsHandler.js.map +1 -7
  138. package/models/trace/handlers/Threads.d.ts +33 -0
  139. package/models/trace/handlers/Threads.js +85 -67
  140. package/models/trace/handlers/Threads.js.map +1 -7
  141. package/models/trace/handlers/UserInteractionsHandler.d.ts +57 -0
  142. package/models/trace/handlers/UserInteractionsHandler.js +240 -141
  143. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -7
  144. package/models/trace/handlers/UserTimingsHandler.d.ts +28 -0
  145. package/models/trace/handlers/UserTimingsHandler.js +91 -80
  146. package/models/trace/handlers/UserTimingsHandler.js.map +1 -7
  147. package/models/trace/handlers/WarningsHandler.d.ts +14 -0
  148. package/models/trace/handlers/WarningsHandler.js +100 -62
  149. package/models/trace/handlers/WarningsHandler.js.map +1 -7
  150. package/models/trace/handlers/WorkersHandler.d.ts +11 -0
  151. package/models/trace/handlers/WorkersHandler.js +40 -38
  152. package/models/trace/handlers/WorkersHandler.js.map +1 -7
  153. package/models/trace/handlers/handlers.d.ts +3 -0
  154. package/models/trace/handlers/handlers.js +7 -4
  155. package/models/trace/handlers/handlers.js.map +1 -7
  156. package/models/trace/handlers/types.d.ts +45 -0
  157. package/models/trace/handlers/types.js +15 -15
  158. package/models/trace/handlers/types.js.map +1 -7
  159. package/models/trace/helpers/SamplesIntegrator.d.ts +49 -0
  160. package/models/trace/helpers/SamplesIntegrator.js +381 -204
  161. package/models/trace/helpers/SamplesIntegrator.js.map +1 -7
  162. package/models/trace/helpers/Timing.d.ts +26 -0
  163. package/models/trace/helpers/Timing.js +131 -110
  164. package/models/trace/helpers/Timing.js.map +1 -7
  165. package/models/trace/helpers/Trace.d.ts +37 -0
  166. package/models/trace/helpers/Trace.js +200 -166
  167. package/models/trace/helpers/Trace.js.map +1 -7
  168. package/models/trace/helpers/TreeHelpers.d.ts +90 -0
  169. package/models/trace/helpers/TreeHelpers.js +203 -100
  170. package/models/trace/helpers/TreeHelpers.js.map +1 -7
  171. package/models/trace/helpers/helpers.d.ts +4 -0
  172. package/models/trace/helpers/helpers.js +8 -5
  173. package/models/trace/helpers/helpers.js.map +1 -7
  174. package/models/trace/root-causes/LayoutShift.d.ts +119 -0
  175. package/models/trace/root-causes/LayoutShift.js +470 -323
  176. package/models/trace/root-causes/LayoutShift.js.map +1 -7
  177. package/models/trace/root-causes/RootCauses.d.ts +14 -0
  178. package/models/trace/root-causes/RootCauses.js +9 -6
  179. package/models/trace/root-causes/RootCauses.js.map +1 -7
  180. package/models/trace/root-causes/root-causes.d.ts +1 -0
  181. package/models/trace/root-causes/root-causes.js +5 -2
  182. package/models/trace/root-causes/root-causes.js.map +1 -7
  183. package/models/trace/trace.d.ts +11 -0
  184. package/models/trace/trace.js +17 -23
  185. package/models/trace/trace.js.map +1 -7
  186. package/models/trace/types/Configuration.d.ts +33 -0
  187. package/models/trace/types/Configuration.js +25 -14
  188. package/models/trace/types/Configuration.js.map +1 -7
  189. package/models/trace/types/File.d.ts +23 -0
  190. package/models/trace/types/File.js +5 -6
  191. package/models/trace/types/File.js.map +1 -7
  192. package/models/trace/types/Timing.d.ts +25 -0
  193. package/models/trace/types/Timing.js +10 -11
  194. package/models/trace/types/Timing.js.map +1 -7
  195. package/models/trace/types/TraceEvents.d.ts +1571 -0
  196. package/models/trace/types/TraceEvents.js +174 -381
  197. package/models/trace/types/TraceEvents.js.map +1 -7
  198. package/models/trace/types/types.d.ts +4 -0
  199. package/models/trace/types/types.js +8 -5
  200. package/models/trace/types/types.js.map +1 -7
  201. package/package.json +1 -1
  202. package/TracingManager.js +0 -0
  203. package/extras/extras.js +0 -0
  204. package/trace.mjs +0 -6980
  205. package/trace.mjs.map +0 -8
package/analyze-trace.mjs CHANGED
@@ -16,7 +16,7 @@ import zlib from 'node:zlib';
16
16
  // and https://github.com/GoogleChrome/lighthouse/pull/15703/files#diff-6dab4507247217209f5ab0f6c343ca2b00af1300878abba81fb74d51cdfbedf9
17
17
 
18
18
  /** @type {TraceEngine} */
19
- import * as TraceEngine from './trace.mjs';
19
+ import * as TraceEngine from './models/trace/trace.js';
20
20
 
21
21
  polyfillDOMRect();
22
22
 
@@ -1,32 +1,23 @@
1
- declare class UrlStringTag {
2
- private urlTag;
3
- }
1
+ import { type Brand } from './brand.js';
4
2
  /**
5
3
  * File paths in DevTools that are represented as URLs
6
4
  * @example
7
5
  * “file:///Hello%20World/file/js”
8
6
  */
9
- export declare type UrlString = string & UrlStringTag;
7
+ export type UrlString = Brand<string, 'UrlString'>;
10
8
  export declare const EmptyUrlString: UrlString;
11
- declare class RawPathStringTag {
12
- private rawPathTag;
13
- }
14
9
  /**
15
10
  * File paths in DevTools that are represented as unencoded absolute
16
11
  * or relative paths
17
12
  * @example
18
13
  * “/Hello World/file.js”
19
14
  */
20
- export declare type RawPathString = string & RawPathStringTag;
15
+ export type RawPathString = Brand<string, 'RawPathString'>;
21
16
  export declare const EmptyRawPathString: RawPathString;
22
- declare class EncodedPathStringTag {
23
- private encodedPathTag;
24
- }
25
17
  /**
26
18
  * File paths in DevTools that are represented as encoded paths
27
19
  * @example
28
20
  * “/Hello%20World/file.js”
29
21
  */
30
- export declare type EncodedPathString = string & EncodedPathStringTag;
22
+ export type EncodedPathString = Brand<string, 'EncodedPathString'>;
31
23
  export declare const EmptyEncodedPathString: EncodedPathString;
32
- export {};
@@ -1,4 +1,7 @@
1
- export const EmptyUrlString = "";
2
- export const EmptyRawPathString = "";
3
- export const EmptyEncodedPathString = "";
4
- //# sourceMappingURL=DevToolsPath.js.map
1
+ // Copyright 2021 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 EmptyUrlString = '';
5
+ export const EmptyRawPathString = '';
6
+ export const EmptyEncodedPathString = '';
7
+ //# sourceMappingURL=DevToolsPath.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../front_end/core/platform/DevToolsPath.ts"],
4
- "sourcesContent": ["// Copyright 2021 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\nimport {type Brand} from './brand.js';\n\n/**\n * File paths in DevTools that are represented as URLs\n * @example\n * \u201Cfile:///Hello%20World/file/js\u201D\n */\nexport type UrlString = Brand<string, 'UrlString'>;\nexport const EmptyUrlString = '' as UrlString;\n\n/**\n * File paths in DevTools that are represented as unencoded absolute\n * or relative paths\n * @example\n * \u201C/Hello World/file.js\u201D\n */\nexport type RawPathString = Brand<string, 'RawPathString'>;\nexport const EmptyRawPathString = '' as RawPathString;\n\n/**\n * File paths in DevTools that are represented as encoded paths\n * @example\n * \u201C/Hello%20World/file.js\u201D\n */\nexport type EncodedPathString = Brand<string, 'EncodedPathString'>;\nexport const EmptyEncodedPathString = '' as EncodedPathString;\n"],
5
- "mappings": "AAYO,aAAM,iBAAiB;AASvB,aAAM,qBAAqB;AAQ3B,aAAM,yBAAyB;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"DevToolsPath.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/DevToolsPath.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAU7B,MAAM,CAAC,MAAM,cAAc,GAAG,EAAe,CAAC;AAS9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAmB,CAAC;AAQtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAuB,CAAC","sourcesContent":["// Copyright 2021 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\nimport {type Brand} from './brand.js';\n\n/**\n * File paths in DevTools that are represented as URLs\n * @example\n * “file:///Hello%20World/file/js”\n */\nexport type UrlString = Brand<string, 'UrlString'>;\nexport const EmptyUrlString = '' as UrlString;\n\n/**\n * File paths in DevTools that are represented as unencoded absolute\n * or relative paths\n * @example\n * “/Hello World/file.js”\n */\nexport type RawPathString = Brand<string, 'RawPathString'>;\nexport const EmptyRawPathString = '' as RawPathString;\n\n/**\n * File paths in DevTools that are represented as encoded paths\n * @example\n * “/Hello%20World/file.js”\n */\nexport type EncodedPathString = Brand<string, 'EncodedPathString'>;\nexport const EmptyEncodedPathString = '' as EncodedPathString;\n"]}
@@ -0,0 +1,27 @@
1
+ export declare const enum MimeType {
2
+ HTML = "text/html",
3
+ XML = "text/xml",
4
+ PLAIN = "text/plain",
5
+ XHTML = "application/xhtml+xml",
6
+ SVG = "image/svg+xml",
7
+ CSS = "text/css",
8
+ XSL = "text/xsl",
9
+ VTT = "text/vtt",
10
+ PDF = "application/pdf",
11
+ EVENTSTREAM = "text/event-stream"
12
+ }
13
+ /**
14
+ * @returns true iff `mimeType` has textual content. Concretely we return true if:
15
+ * - `mimeType` starts with "text/"
16
+ * - `mimeType` ends with "+json" or "+xml"
17
+ * - if `mimeType` is one of a predefined list textual mime types.
18
+ */
19
+ export declare function isTextType(mimeType: string): boolean;
20
+ /**
21
+ * Port of net::HttpUtils::ParseContentType to extract mimeType and charset from
22
+ * the 'Content-Type' header.
23
+ */
24
+ export declare function parseContentType(contentType: string): {
25
+ mimeType: string | null;
26
+ charset: string | null;
27
+ };
@@ -1,104 +1,137 @@
1
- export var MimeType = /* @__PURE__ */ ((MimeType2) => {
2
- MimeType2["HTML"] = "text/html";
3
- MimeType2["XML"] = "text/xml";
4
- MimeType2["PLAIN"] = "text/plain";
5
- MimeType2["XHTML"] = "application/xhtml+xml";
6
- MimeType2["SVG"] = "image/svg+xml";
7
- MimeType2["CSS"] = "text/css";
8
- MimeType2["XSL"] = "text/xsl";
9
- MimeType2["VTT"] = "text/vtt";
10
- MimeType2["PDF"] = "application/pdf";
11
- MimeType2["EVENTSTREAM"] = "text/event-stream";
12
- return MimeType2;
13
- })(MimeType || {});
14
- const ADDITIONAL_TEXT_MIME_TYPES = /* @__PURE__ */ new Set([
15
- "application/ecmascript",
16
- "application/javascript",
17
- "application/json",
18
- "application/vnd.dart",
19
- "application/xml",
20
- "application/x-aspx",
21
- "application/x-javascript",
22
- "application/x-jsp",
23
- "application/x-httpd-php"
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
+ * MIME types other than the ones with the "text" type that have text content.
6
+ */
7
+ const ADDITIONAL_TEXT_MIME_TYPES = new Set([
8
+ 'application/ecmascript',
9
+ 'application/javascript',
10
+ 'application/json',
11
+ 'application/vnd.dart',
12
+ 'application/xml',
13
+ 'application/x-aspx',
14
+ 'application/x-javascript',
15
+ 'application/x-jsp',
16
+ 'application/x-httpd-php',
24
17
  ]);
18
+ /**
19
+ * @returns true iff `mimeType` has textual content. Concretely we return true if:
20
+ * - `mimeType` starts with "text/"
21
+ * - `mimeType` ends with "+json" or "+xml"
22
+ * - if `mimeType` is one of a predefined list textual mime types.
23
+ */
25
24
  export function isTextType(mimeType) {
26
- return mimeType.startsWith("text/") || mimeType.endsWith("+json") || mimeType.endsWith("+xml") || ADDITIONAL_TEXT_MIME_TYPES.has(mimeType);
25
+ return mimeType.startsWith('text/') || mimeType.endsWith('+json') || mimeType.endsWith('+xml') ||
26
+ ADDITIONAL_TEXT_MIME_TYPES.has(mimeType);
27
27
  }
28
+ /**
29
+ * Port of net::HttpUtils::ParseContentType to extract mimeType and charset from
30
+ * the 'Content-Type' header.
31
+ */
28
32
  export function parseContentType(contentType) {
29
- if (contentType === "*/*") {
30
- return { mimeType: null, charset: null };
31
- }
32
- const { mimeType, params } = parseMimeType(contentType);
33
- const charset = params.get("charset")?.toLowerCase().trim() ?? null;
34
- return { mimeType, charset };
33
+ if (contentType === '*/*') {
34
+ return { mimeType: null, charset: null };
35
+ }
36
+ const { mimeType, params } = parseMimeType(contentType);
37
+ const charset = params.get('charset')?.toLowerCase().trim() ?? null;
38
+ return { mimeType, charset };
35
39
  }
36
40
  function parseMimeType(contentType) {
37
- contentType = contentType.trim();
38
- let mimeTypeEnd = findFirstIndexOf(contentType, " ;(");
39
- if (mimeTypeEnd < 0) {
40
- mimeTypeEnd = contentType.length;
41
- }
42
- const slashPos = contentType.indexOf("/");
43
- if (slashPos < 0 || slashPos > mimeTypeEnd) {
44
- return { mimeType: null, params: /* @__PURE__ */ new Map() };
45
- }
46
- const mimeType = contentType.substring(0, mimeTypeEnd).toLowerCase();
47
- const params = /* @__PURE__ */ new Map();
48
- let offset = contentType.indexOf(";", mimeTypeEnd);
49
- while (offset >= 0 && offset < contentType.length) {
50
- ++offset;
51
- offset = findFirstIndexNotOf(contentType, " ", offset);
52
- if (offset < 0) {
53
- continue;
41
+ // Remove any leading and trailing whitespace. Note that String.prototype.trim removes a lot more
42
+ // than what the spec considers whitespace. We are fine with that.
43
+ contentType = contentType.trim();
44
+ // The mimetype is basically everything until the first ';' (but trimmed).
45
+ let mimeTypeEnd = findFirstIndexOf(contentType, ' \t;(');
46
+ if (mimeTypeEnd < 0) {
47
+ mimeTypeEnd = contentType.length;
54
48
  }
55
- const paramNameStart = offset;
56
- offset = findFirstIndexOf(contentType, ";=", offset);
57
- if (offset < 0 || contentType[offset] === ";") {
58
- continue;
49
+ const slashPos = contentType.indexOf('/');
50
+ if (slashPos < 0 || slashPos > mimeTypeEnd) {
51
+ return { mimeType: null, params: new Map() };
59
52
  }
60
- const paramName = contentType.substring(paramNameStart, offset).toLowerCase();
61
- ++offset;
62
- offset = findFirstIndexNotOf(contentType, " ", offset);
63
- let paramValue = "";
64
- if (offset < 0 || contentType[offset] === ";") {
65
- continue;
66
- } else if (contentType[offset] !== '"') {
67
- const valueStart = offset;
68
- offset = contentType.indexOf(";", offset);
69
- const valueEnd = offset >= 0 ? offset : contentType.length;
70
- paramValue = contentType.substring(valueStart, valueEnd).trimEnd();
71
- } else {
72
- ++offset;
73
- while (offset < contentType.length && contentType[offset] !== '"') {
74
- if (contentType[offset] === "\\" && offset + 1 < contentType.length) {
75
- ++offset;
53
+ const mimeType = contentType.substring(0, mimeTypeEnd).toLowerCase();
54
+ // Iterate over parameters. We can't split the string around semicolons because quoted
55
+ // strings may include semicolons.
56
+ const params = new Map();
57
+ let offset = contentType.indexOf(';', mimeTypeEnd);
58
+ while (offset >= 0 && offset < contentType.length) {
59
+ // Trim off the semicolon.
60
+ ++offset;
61
+ // Trim off whitespace
62
+ offset = findFirstIndexNotOf(contentType, ' \t', offset);
63
+ if (offset < 0) {
64
+ continue;
65
+ }
66
+ const paramNameStart = offset;
67
+ // Extend parameter name until we run into semicolon or equals sign.
68
+ offset = findFirstIndexOf(contentType, ';=', offset);
69
+ if (offset < 0 || contentType[offset] === ';') {
70
+ // Nothing more to do if no more input or there is no parameter value.
71
+ continue;
76
72
  }
77
- paramValue += contentType[offset];
73
+ const paramName = contentType.substring(paramNameStart, offset).toLowerCase();
74
+ // Trim off the '='.
78
75
  ++offset;
79
- }
80
- offset = contentType.indexOf(";", offset);
81
- }
82
- if (!params.has(paramName)) {
83
- params.set(paramName, paramValue);
76
+ // Trim off whitespace.
77
+ offset = findFirstIndexNotOf(contentType, ' \t', offset);
78
+ let paramValue = '';
79
+ if (offset < 0 || contentType[offset] === ';') {
80
+ // Nothing to do here: the value is an unquoted string of only whitespace.
81
+ continue;
82
+ }
83
+ else if (contentType[offset] !== '"') {
84
+ // Not a quote so we can copy the value as-is.
85
+ const valueStart = offset;
86
+ offset = contentType.indexOf(';', offset);
87
+ const valueEnd = offset >= 0 ? offset : contentType.length;
88
+ paramValue = contentType.substring(valueStart, valueEnd).trimEnd();
89
+ }
90
+ else {
91
+ // Otherwise append data with special handling for backslashes, until a close quote.
92
+ // Don't trim whitespace for quoted strings.
93
+ // Trim off the opening quote '"'
94
+ ++offset;
95
+ while (offset < contentType.length && contentType[offset] !== '"') {
96
+ // Skip over backslash and append the next character, when not at the end
97
+ // of the string. Otherwise, copy the next character (which may be a backslash).
98
+ if (contentType[offset] === '\\' && offset + 1 < contentType.length) {
99
+ ++offset;
100
+ }
101
+ paramValue += contentType[offset];
102
+ ++offset;
103
+ }
104
+ offset = contentType.indexOf(';', offset);
105
+ }
106
+ if (!params.has(paramName)) {
107
+ // The first one wins!
108
+ params.set(paramName, paramValue);
109
+ }
84
110
  }
85
- }
86
- return { mimeType, params };
111
+ return { mimeType, params };
87
112
  }
113
+ /**
114
+ * @returns the smallest index of any character in 'characters' or -1 if none of
115
+ * the characters occur in 'searchString'
116
+ */
88
117
  function findFirstIndexOf(searchString, characters, pos = 0) {
89
- for (let i = pos; i < searchString.length; i++) {
90
- if (characters.includes(searchString[i])) {
91
- return i;
118
+ for (let i = pos; i < searchString.length; i++) {
119
+ if (characters.includes(searchString[i])) {
120
+ return i;
121
+ }
92
122
  }
93
- }
94
- return -1;
123
+ return -1;
95
124
  }
125
+ /**
126
+ * @returns the smallest index of any character not in 'characters' or -1 if only
127
+ * 'characters' occur in 'searchString'
128
+ */
96
129
  function findFirstIndexNotOf(searchString, characters, pos = 0) {
97
- for (let i = pos; i < searchString.length; i++) {
98
- if (!characters.includes(searchString[i])) {
99
- return i;
130
+ for (let i = pos; i < searchString.length; i++) {
131
+ if (!characters.includes(searchString[i])) {
132
+ return i;
133
+ }
100
134
  }
101
- }
102
- return -1;
135
+ return -1;
103
136
  }
104
- //# sourceMappingURL=MimeType.js.map
137
+ //# sourceMappingURL=MimeType.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../front_end/core/platform/MimeType.ts"],
4
- "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\nexport const enum MimeType {\n HTML = 'text/html',\n XML = 'text/xml',\n PLAIN = 'text/plain',\n XHTML = 'application/xhtml+xml',\n SVG = 'image/svg+xml',\n CSS = 'text/css',\n XSL = 'text/xsl',\n VTT = 'text/vtt',\n PDF = 'application/pdf',\n EVENTSTREAM = 'text/event-stream',\n}\n\n/**\n * MIME types other than the ones with the \"text\" type that have text content.\n */\nconst ADDITIONAL_TEXT_MIME_TYPES = new Set([\n 'application/ecmascript',\n 'application/javascript',\n 'application/json',\n 'application/vnd.dart',\n 'application/xml',\n 'application/x-aspx',\n 'application/x-javascript',\n 'application/x-jsp',\n 'application/x-httpd-php',\n]);\n\n/**\n * @returns true iff `mimeType` has textual content. Concretely we return true if:\n * - `mimeType` starts with \"text/\"\n * - `mimeType` ends with \"+json\" or \"+xml\"\n * - if `mimeType` is one of a predefined list textual mime types.\n */\nexport function isTextType(mimeType: string): boolean {\n return mimeType.startsWith('text/') || mimeType.endsWith('+json') || mimeType.endsWith('+xml') ||\n ADDITIONAL_TEXT_MIME_TYPES.has(mimeType);\n}\n\n/**\n * Port of net::HttpUtils::ParseContentType to extract mimeType and charset from\n * the 'Content-Type' header.\n */\nexport function parseContentType(contentType: string): {mimeType: string|null, charset: string|null} {\n if (contentType === '*/*') {\n return {mimeType: null, charset: null};\n }\n\n const {mimeType, params} = parseMimeType(contentType);\n const charset = params.get('charset')?.toLowerCase().trim() ?? null;\n return {mimeType, charset};\n}\n\nfunction parseMimeType(contentType: string): {mimeType: string|null, params: Map<string, string>} {\n // Remove any leading and trailing whitespace. Note that String.prototype.trim removes a lot more\n // than what the spec considers whitespace. We are fine with that.\n contentType = contentType.trim();\n\n // The mimetype is basically everything until the first ';' (but trimmed).\n let mimeTypeEnd = findFirstIndexOf(contentType, ' \\t;(');\n if (mimeTypeEnd < 0) {\n mimeTypeEnd = contentType.length;\n }\n\n const slashPos = contentType.indexOf('/');\n if (slashPos < 0 || slashPos > mimeTypeEnd) {\n return {mimeType: null, params: new Map()};\n }\n const mimeType = contentType.substring(0, mimeTypeEnd).toLowerCase();\n\n // Iterate over parameters. We can't split the string around semicolons because quoted\n // strings may include semicolons.\n const params = new Map<string, string>();\n let offset = contentType.indexOf(';', mimeTypeEnd);\n while (offset >= 0 && offset < contentType.length) {\n // Trim off the semicolon.\n ++offset;\n\n // Trim off whitespace\n offset = findFirstIndexNotOf(contentType, ' \\t', offset);\n if (offset < 0) {\n continue;\n }\n const paramNameStart = offset;\n\n // Extend parameter name until we run into semicolon or equals sign.\n offset = findFirstIndexOf(contentType, ';=', offset);\n if (offset < 0 || contentType[offset] === ';') {\n // Nothing more to do if no more input or there is no parameter value.\n continue;\n }\n\n const paramName = contentType.substring(paramNameStart, offset).toLowerCase();\n\n // Trim off the '='.\n ++offset;\n\n // Trim off whitespace.\n offset = findFirstIndexNotOf(contentType, ' \\t', offset);\n\n let paramValue = '';\n if (offset < 0 || contentType[offset] === ';') {\n // Nothing to do here: the value is an unquoted string of only whitespace.\n continue;\n } else if (contentType[offset] !== '\"') {\n // Not a quote so we can copy the value as-is.\n const valueStart = offset;\n offset = contentType.indexOf(';', offset);\n const valueEnd = offset >= 0 ? offset : contentType.length;\n\n paramValue = contentType.substring(valueStart, valueEnd).trimEnd();\n } else {\n // Otherwise append data with special handling for backslashes, until a close quote.\n // Don't trim whitespace for quoted strings.\n\n // Trim off the opening quote '\"'\n ++offset;\n\n while (offset < contentType.length && contentType[offset] !== '\"') {\n // Skip over backslash and append the next character, when not at the end\n // of the string. Otherwise, copy the next character (which may be a backslash).\n if (contentType[offset] === '\\\\' && offset + 1 < contentType.length) {\n ++offset;\n }\n paramValue += contentType[offset];\n ++offset;\n }\n\n offset = contentType.indexOf(';', offset);\n }\n if (!params.has(paramName)) {\n // The first one wins!\n params.set(paramName, paramValue);\n }\n }\n\n return {mimeType, params};\n}\n\n/**\n * @returns the smallest index of any character in 'characters' or -1 if none of\n * the characters occur in 'searchString'\n */\nfunction findFirstIndexOf(searchString: string, characters: string, pos: number = 0): number {\n for (let i = pos; i < searchString.length; i++) {\n if (characters.includes(searchString[i])) {\n return i;\n }\n }\n return -1;\n}\n\n/**\n * @returns the smallest index of any character not in 'characters' or -1 if only\n * 'characters' occur in 'searchString'\n */\nfunction findFirstIndexNotOf(searchString: string, characters: string, pos: number = 0): number {\n for (let i = pos; i < searchString.length; i++) {\n if (!characters.includes(searchString[i])) {\n return i;\n }\n }\n return -1;\n}\n"],
5
- "mappings": "AAIO,WAAW,WAAX,kBAAW,cAAX;AACL,sBAAO;AACP,qBAAM;AACN,uBAAQ;AACR,uBAAQ;AACR,qBAAM;AACN,qBAAM;AACN,qBAAM;AACN,qBAAM;AACN,qBAAM;AACN,6BAAc;AAVE;AAAA;AAgBlB,MAAM,6BAA6B,oBAAI,IAAI;AAAA,EACzC;AAAA,E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AC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC9C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;YACzC,OAAO,CAAC,CAAC;SACV;KACF;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,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\nexport const enum MimeType {\n HTML = 'text/html',\n XML = 'text/xml',\n PLAIN = 'text/plain',\n XHTML = 'application/xhtml+xml',\n SVG = 'image/svg+xml',\n CSS = 'text/css',\n XSL = 'text/xsl',\n VTT = 'text/vtt',\n PDF = 'application/pdf',\n EVENTSTREAM = 'text/event-stream',\n}\n\n/**\n * MIME types other than the ones with the \"text\" type that have text content.\n */\nconst ADDITIONAL_TEXT_MIME_TYPES = new Set([\n 'application/ecmascript',\n 'application/javascript',\n 'application/json',\n 'application/vnd.dart',\n 'application/xml',\n 'application/x-aspx',\n 'application/x-javascript',\n 'application/x-jsp',\n 'application/x-httpd-php',\n]);\n\n/**\n * @returns true iff `mimeType` has textual content. Concretely we return true if:\n * - `mimeType` starts with \"text/\"\n * - `mimeType` ends with \"+json\" or \"+xml\"\n * - if `mimeType` is one of a predefined list textual mime types.\n */\nexport function isTextType(mimeType: string): boolean {\n return mimeType.startsWith('text/') || mimeType.endsWith('+json') || mimeType.endsWith('+xml') ||\n ADDITIONAL_TEXT_MIME_TYPES.has(mimeType);\n}\n\n/**\n * Port of net::HttpUtils::ParseContentType to extract mimeType and charset from\n * the 'Content-Type' header.\n */\nexport function parseContentType(contentType: string): {mimeType: string|null, charset: string|null} {\n if (contentType === '*/*') {\n return {mimeType: null, charset: null};\n }\n\n const {mimeType, params} = parseMimeType(contentType);\n const charset = params.get('charset')?.toLowerCase().trim() ?? null;\n return {mimeType, charset};\n}\n\nfunction parseMimeType(contentType: string): {mimeType: string|null, params: Map<string, string>} {\n // Remove any leading and trailing whitespace. Note that String.prototype.trim removes a lot more\n // than what the spec considers whitespace. We are fine with that.\n contentType = contentType.trim();\n\n // The mimetype is basically everything until the first ';' (but trimmed).\n let mimeTypeEnd = findFirstIndexOf(contentType, ' \\t;(');\n if (mimeTypeEnd < 0) {\n mimeTypeEnd = contentType.length;\n }\n\n const slashPos = contentType.indexOf('/');\n if (slashPos < 0 || slashPos > mimeTypeEnd) {\n return {mimeType: null, params: new Map()};\n }\n const mimeType = contentType.substring(0, mimeTypeEnd).toLowerCase();\n\n // Iterate over parameters. We can't split the string around semicolons because quoted\n // strings may include semicolons.\n const params = new Map<string, string>();\n let offset = contentType.indexOf(';', mimeTypeEnd);\n while (offset >= 0 && offset < contentType.length) {\n // Trim off the semicolon.\n ++offset;\n\n // Trim off whitespace\n offset = findFirstIndexNotOf(contentType, ' \\t', offset);\n if (offset < 0) {\n continue;\n }\n const paramNameStart = offset;\n\n // Extend parameter name until we run into semicolon or equals sign.\n offset = findFirstIndexOf(contentType, ';=', offset);\n if (offset < 0 || contentType[offset] === ';') {\n // Nothing more to do if no more input or there is no parameter value.\n continue;\n }\n\n const paramName = contentType.substring(paramNameStart, offset).toLowerCase();\n\n // Trim off the '='.\n ++offset;\n\n // Trim off whitespace.\n offset = findFirstIndexNotOf(contentType, ' \\t', offset);\n\n let paramValue = '';\n if (offset < 0 || contentType[offset] === ';') {\n // Nothing to do here: the value is an unquoted string of only whitespace.\n continue;\n } else if (contentType[offset] !== '\"') {\n // Not a quote so we can copy the value as-is.\n const valueStart = offset;\n offset = contentType.indexOf(';', offset);\n const valueEnd = offset >= 0 ? offset : contentType.length;\n\n paramValue = contentType.substring(valueStart, valueEnd).trimEnd();\n } else {\n // Otherwise append data with special handling for backslashes, until a close quote.\n // Don't trim whitespace for quoted strings.\n\n // Trim off the opening quote '\"'\n ++offset;\n\n while (offset < contentType.length && contentType[offset] !== '\"') {\n // Skip over backslash and append the next character, when not at the end\n // of the string. Otherwise, copy the next character (which may be a backslash).\n if (contentType[offset] === '\\\\' && offset + 1 < contentType.length) {\n ++offset;\n }\n paramValue += contentType[offset];\n ++offset;\n }\n\n offset = contentType.indexOf(';', offset);\n }\n if (!params.has(paramName)) {\n // The first one wins!\n params.set(paramName, paramValue);\n }\n }\n\n return {mimeType, params};\n}\n\n/**\n * @returns the smallest index of any character in 'characters' or -1 if none of\n * the characters occur in 'searchString'\n */\nfunction findFirstIndexOf(searchString: string, characters: string, pos: number = 0): number {\n for (let i = pos; i < searchString.length; i++) {\n if (characters.includes(searchString[i])) {\n return i;\n }\n }\n return -1;\n}\n\n/**\n * @returns the smallest index of any character not in 'characters' or -1 if only\n * 'characters' occur in 'searchString'\n */\nfunction findFirstIndexNotOf(searchString: string, characters: string, pos: number = 0): number {\n for (let i = pos; i < searchString.length; i++) {\n if (!characters.includes(searchString[i])) {\n return i;\n }\n }\n return -1;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { type Brand } from './brand.js';
2
+ export type Seconds = Brand<number, 'Seconds'>;
3
+ export type MilliSeconds = Brand<number, 'MilliSeconds'>;
4
+ export type MicroSeconds = Brand<number, 'MicroSeconds'>;
5
+ export declare function secondsToMilliSeconds(x: Seconds): MilliSeconds;
6
+ export declare function milliSecondsToSeconds(x: MilliSeconds): Seconds;
7
+ export declare function microSecondsToMilliSeconds(x: MicroSeconds): MilliSeconds;
@@ -1,10 +1,13 @@
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.
1
4
  export function secondsToMilliSeconds(x) {
2
- return x * 1e3;
5
+ return (x * 1000);
3
6
  }
4
7
  export function milliSecondsToSeconds(x) {
5
- return x / 1e3;
8
+ return (x / 1000);
6
9
  }
7
10
  export function microSecondsToMilliSeconds(x) {
8
- return x / 1e3;
11
+ return (x / 1000);
9
12
  }
10
- //# sourceMappingURL=Timing.js.map
13
+ //# sourceMappingURL=Timing.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../front_end/core/platform/Timing.ts"],
4
- "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\nimport {type Brand} from './brand.js';\n\nexport type Seconds = Brand<number, 'Seconds'>;\nexport type MilliSeconds = Brand<number, 'MilliSeconds'>;\nexport type MicroSeconds = Brand<number, 'MicroSeconds'>;\n\nexport function secondsToMilliSeconds(x: Seconds): MilliSeconds {\n return (x * 1000) as MilliSeconds;\n}\n\nexport function milliSecondsToSeconds(x: MilliSeconds): Seconds {\n return (x / 1000) as Seconds;\n}\n\nexport function microSecondsToMilliSeconds(x: MicroSeconds): MilliSeconds {\n return (x / 1000) as MilliSeconds;\n}\n"],
5
- "mappings": "AAUO,sCAA+B,GAA0B;AAC9D,SAAQ,IAAI;AAAA;AAGP,sCAA+B,GAA0B;AAC9D,SAAQ,IAAI;AAAA;AAGP,2CAAoC,GAA+B;AACxE,SAAQ,IAAI;AAAA;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"Timing.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/Timing.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAQ7B,MAAM,UAAU,qBAAqB,CAAC,CAAU;IAC9C,OAAO,CAAC,CAAC,GAAG,IAAI,CAAiB,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,CAAe;IACnD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAY,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,CAAe;IACxD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAiB,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\nimport {type Brand} from './brand.js';\n\nexport type Seconds = Brand<number, 'Seconds'>;\nexport type MilliSeconds = Brand<number, 'MilliSeconds'>;\nexport type MicroSeconds = Brand<number, 'MicroSeconds'>;\n\nexport function secondsToMilliSeconds(x: Seconds): MilliSeconds {\n return (x * 1000) as MilliSeconds;\n}\n\nexport function milliSecondsToSeconds(x: MilliSeconds): Seconds {\n return (x / 1000) as Seconds;\n}\n\nexport function microSecondsToMilliSeconds(x: MicroSeconds): MilliSeconds {\n return (x / 1000) as MilliSeconds;\n}\n"]}
@@ -1,6 +1,3 @@
1
- declare class LocalizedStringTag {
2
- private localizationTag;
3
- }
4
- export declare type LocalizedString = string & LocalizedStringTag;
1
+ import { type Brand } from './brand.js';
2
+ export type LocalizedString = Brand<string, 'LocalizedString'>;
5
3
  export declare const LocalizedEmptyString: LocalizedString;
6
- export {};
@@ -1,2 +1,5 @@
1
- export const LocalizedEmptyString = "";
2
- //# sourceMappingURL=UIString.js.map
1
+ // Copyright 2021 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 LocalizedEmptyString = '';
5
+ //# sourceMappingURL=UIString.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../front_end/core/platform/UIString.ts"],
4
- "sourcesContent": ["// Copyright 2021 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 * Copyright (C) 2011 Google Inc. All rights reserved.\n * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.\n * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).\n * Copyright (C) 2009 Joseph Pecoraro\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. Neither the name of Apple Computer, Inc. (\"Apple\") nor the names of\n * its contributors may be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS \"AS IS\" AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport {type Brand} from './brand.js';\n\nexport type LocalizedString = Brand<string, 'LocalizedString'>;\nexport const LocalizedEmptyString = '' as LocalizedString;\n"],
5
- "mappings": "AAsCO,aAAM,uBAAuB;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"UIString.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/UIString.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAoC7B,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAqB,CAAC","sourcesContent":["// Copyright 2021 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 * Copyright (C) 2011 Google Inc. All rights reserved.\n * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.\n * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).\n * Copyright (C) 2009 Joseph Pecoraro\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. Neither the name of Apple Computer, Inc. (\"Apple\") nor the names of\n * its contributors may be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS \"AS IS\" AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport {type Brand} from './brand.js';\n\nexport type LocalizedString = Brand<string, 'LocalizedString'>;\nexport const LocalizedEmptyString = '' as LocalizedString;\n"]}
@@ -1,14 +1,23 @@
1
+ // Copyright 2021 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
+ * Represents an error that might become visible to the user. Where errors
6
+ * might be surfaced to the user (such as by displaying the message to the
7
+ * console), this class should be used to enforce that the message is
8
+ * localized on the way in.
9
+ */
1
10
  export class UserVisibleError extends Error {
2
- message;
3
- constructor(message) {
4
- super(message);
5
- this.message = message;
6
- }
11
+ message;
12
+ constructor(message) {
13
+ super(message);
14
+ this.message = message;
15
+ }
7
16
  }
8
17
  export function isUserVisibleError(error) {
9
- if (typeof error === "object" && error !== null) {
10
- return error instanceof UserVisibleError;
11
- }
12
- return false;
18
+ if (typeof error === 'object' && error !== null) {
19
+ return error instanceof UserVisibleError;
20
+ }
21
+ return false;
13
22
  }
14
- //# sourceMappingURL=UserVisibleError.js.map
23
+ //# sourceMappingURL=UserVisibleError.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../../front_end/core/platform/UserVisibleError.ts"],
4
- "sourcesContent": ["// Copyright 2021 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\nimport {type LocalizedString} from './UIString.js';\n\n/**\n * Represents an error that might become visible to the user. Where errors\n * might be surfaced to the user (such as by displaying the message to the\n * console), this class should be used to enforce that the message is\n * localized on the way in.\n */\nexport class UserVisibleError extends Error {\n override readonly message: LocalizedString;\n\n constructor(message: LocalizedString) {\n super(message);\n this.message = message;\n }\n}\n\nexport function isUserVisibleError(error: unknown): error is UserVisibleError {\n if (typeof error === 'object' && error !== null) {\n return error instanceof UserVisibleError;\n }\n\n return false;\n}\n"],
5
- "mappings": "AAYO,sCAA+B,MAAM;AAAA,EACxB;AAAA,EAElB,YAAY,SAA0B;AACpC,UAAM;AACN,SAAK,UAAU;AAAA;AAAA;AAIZ,mCAA4B,OAA2C;AAC5E,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO,iBAAiB;AAAA;AAG1B,SAAO;AAAA;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"UserVisibleError.js","sourceRoot":"","sources":["../../../../../../front_end/core/platform/UserVisibleError.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAI7B;;;;;GAKG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACvB,OAAO,CAAkB;IAE3C,YAAY,OAAwB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE;QAC/C,OAAO,KAAK,YAAY,gBAAgB,CAAC;KAC1C;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright 2021 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\nimport {type LocalizedString} from './UIString.js';\n\n/**\n * Represents an error that might become visible to the user. Where errors\n * might be surfaced to the user (such as by displaying the message to the\n * console), this class should be used to enforce that the message is\n * localized on the way in.\n */\nexport class UserVisibleError extends Error {\n override readonly message: LocalizedString;\n\n constructor(message: LocalizedString) {\n super(message);\n this.message = message;\n }\n}\n\nexport function isUserVisibleError(error: unknown): error is UserVisibleError {\n if (typeof error === 'object' && error !== null) {\n return error instanceof UserVisibleError;\n }\n\n return false;\n}\n"]}
@@ -1,28 +1,66 @@
1
1
  export declare const removeElement: <T>(array: T[], element: T, firstOnly?: boolean) => boolean;
2
- declare type NumberComparator = (a: number, b: number) => number;
2
+ type NumberComparator = (a: number, b: number) => number;
3
3
  export declare function sortRange(array: number[], comparator: NumberComparator, leftBound: number, rightBound: number, sortWindowLeft: number, sortWindowRight: number): number[];
4
4
  export declare const binaryIndexOf: <T, S>(array: T[], value: S, comparator: (a: S, b: T) => number) => number;
5
5
  export declare const intersectOrdered: <T>(array1: T[], array2: T[], comparator: (a: T, b: T) => number) => T[];
6
6
  export declare const mergeOrdered: <T>(array1: T[], array2: T[], comparator: (a: T, b: T) => number) => T[];
7
- export declare const DEFAULT_COMPARATOR: (a: string | number, b: string | number) => number;
7
+ export declare const DEFAULT_COMPARATOR: (a: string | number, b: string | number) => -1 | 0 | 1;
8
8
  /**
9
- * Return index of the leftmost element that is equal or greater
10
- * than the specimen object. If there's no such element (i.e. all
11
- * elements are smaller than the specimen) returns right bound.
12
- * The function works for sorted array.
9
+ * Returns the index of the element closest to the needle that is equal to or
10
+ * greater than it. Assumes that the provided array is sorted.
11
+ *
12
+ * If no element is found, the right bound is returned.
13
+ *
14
+ * Uses the provided comparator function to determine if two items are equal or
15
+ * if one is greater than the other. If you are working with strings or
16
+ * numbers, you can use ArrayUtilities.DEFAULT_COMPARATOR. Otherwise, you
17
+ * should define one that takes the needle element and an element from the
18
+ * array and returns a positive or negative number to indicate which is greater
19
+ * than the other.
20
+ *
13
21
  * When specified, |left| (inclusive) and |right| (exclusive) indices
14
22
  * define the search window.
15
23
  */
16
24
  export declare function lowerBound<T>(array: Uint32Array | Int32Array, needle: T, comparator: (needle: T, b: number) => number, left?: number, right?: number): number;
17
25
  export declare function lowerBound<S, T>(array: S[], needle: T, comparator: (needle: T, b: S) => number, left?: number, right?: number): number;
26
+ export declare function lowerBound<S, T>(array: readonly S[], needle: T, comparator: (needle: T, b: S) => number, left?: number, right?: number): number;
18
27
  /**
19
- * Return index of the leftmost element that is greater
20
- * than the specimen object. If there's no such element (i.e. all
21
- * elements are smaller or equal to the specimen) returns right bound.
22
- * The function works for sorted array.
28
+ * Returns the index of the element closest to the needle that is greater than
29
+ * it. Assumes that the provided array is sorted.
30
+ *
31
+ * If no element is found, the right bound is returned.
32
+ *
33
+ * Uses the provided comparator function to determine if two items are equal or
34
+ * if one is greater than the other. If you are working with strings or
35
+ * numbers, you can use ArrayUtilities.DEFAULT_COMPARATOR. Otherwise, you
36
+ * should define one that takes the needle element and an element from the
37
+ * array and returns a positive or negative number to indicate which is greater
38
+ * than the other.
39
+ *
23
40
  * When specified, |left| (inclusive) and |right| (exclusive) indices
24
41
  * define the search window.
25
42
  */
26
43
  export declare function upperBound<T>(array: Uint32Array, needle: T, comparator: (needle: T, b: number) => number, left?: number, right?: number): number;
27
44
  export declare function upperBound<S, T>(array: S[], needle: T, comparator: (needle: T, b: S) => number, left?: number, right?: number): number;
45
+ /**
46
+ * Obtains the first item in the array that satisfies the predicate function.
47
+ * So, for example, if the array was arr = [2, 4, 6, 8, 10], and you are looking for
48
+ * the first item arr[i] such that arr[i] > 5 you would be returned 2, because
49
+ * array[2] is 6, the first item in the array that satisfies the
50
+ * predicate function.
51
+ *
52
+ * Please note: this presupposes that the array is already ordered.
53
+ */
54
+ export declare function nearestIndexFromBeginning<T>(arr: T[], predicate: (arrayItem: T) => boolean): number | null;
55
+ /**
56
+ * Obtains the last item in the array that satisfies the predicate function.
57
+ * So, for example, if the array was arr = [2, 4, 6, 8, 10], and you are looking for
58
+ * the last item arr[i] such that arr[i] < 5 you would be returned 1, because
59
+ * arr[1] is 4, the last item in the array that satisfies the
60
+ * predicate function.
61
+ *
62
+ * Please note: this presupposes that the array is already ordered.
63
+ */
64
+ export declare function nearestIndexFromEnd<T>(arr: readonly T[], predicate: (arrayItem: T) => boolean): number | null;
65
+ export declare function arrayDoesNotContainNullOrUndefined<T>(arr: (T | null | undefined)[]): arr is T[];
28
66
  export {};