chrome-devtools-frontend 1.0.1626437 → 1.0.1628368
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/front_end/core/common/VersionController.ts +33 -1
- package/front_end/core/host/UserMetrics.ts +11 -8
- package/front_end/core/root/ExperimentNames.ts +1 -3
- package/front_end/core/sdk/CSSContainerQuery.ts +3 -1
- package/front_end/core/sdk/CSSModel.ts +23 -0
- package/front_end/core/sdk/HeapProfilerModel.ts +1 -11
- package/front_end/entrypoints/formatter_worker/AcornTokenizer.ts +2 -1
- package/front_end/entrypoints/formatter_worker/CSSFormatter.ts +2 -4
- package/front_end/entrypoints/formatter_worker/ESTreeWalker.ts +3 -2
- package/front_end/entrypoints/formatter_worker/JavaScriptFormatter.ts +13 -0
- package/front_end/entrypoints/formatter_worker/Substitute.ts +1 -1
- package/front_end/entrypoints/greendev_floaty/FloatyEntrypoint.ts +0 -1
- package/front_end/entrypoints/greendev_floaty/greendev_floaty.ts +0 -1
- package/front_end/entrypoints/main/MainImpl.ts +4 -36
- package/front_end/generated/InspectorBackendCommands.ts +4 -3
- package/front_end/generated/protocol-mapping.d.ts +5 -0
- package/front_end/generated/protocol-proxy-api.d.ts +4 -0
- package/front_end/generated/protocol.ts +22 -0
- package/front_end/models/ai_assistance/agents/AiAgent.ts +2 -1
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +11 -5
- package/front_end/models/javascript_metadata/NativeFunctions.js +4 -0
- package/front_end/models/lighthouse/RunTypes.ts +1 -1
- package/front_end/models/workspace/UISourceCode.ts +0 -1
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +4 -3
- package/front_end/panels/common/AiCodeCompletionTeaser.ts +9 -0
- package/front_end/panels/common/common.ts +1 -1
- package/front_end/panels/console/ConsoleView.ts +2 -2
- package/front_end/panels/elements/StylePropertiesSection.ts +6 -2
- package/front_end/panels/elements/StylesAiCodeCompletionProvider.ts +1 -1
- package/front_end/panels/elements/StylesSidebarPane.ts +8 -7
- package/front_end/panels/emulation/DeviceModeToolbar.ts +20 -26
- package/front_end/panels/emulation/DeviceModeView.ts +2 -2
- package/front_end/panels/lighthouse/LighthouseController.ts +18 -0
- package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +9 -4
- package/front_end/panels/profiler/profiler-meta.ts +0 -71
- package/front_end/panels/profiler/profiler.ts +0 -2
- package/front_end/panels/sources/AiCodeCompletionPlugin.ts +7 -6
- package/front_end/panels/sources/ProfilePlugin.ts +12 -65
- package/front_end/panels/sources/UISourceCodeFrame.ts +1 -2
- package/front_end/panels/timeline/TimelineController.ts +1 -2
- package/front_end/panels/timeline/TimelinePanel.ts +1 -1
- package/front_end/panels/timeline/TimelineUIUtils.ts +2 -10
- package/front_end/panels/timeline/timeline-meta.ts +26 -0
- package/front_end/third_party/acorn/README.chromium +1 -1
- package/front_end/third_party/acorn/acorn.ts +1 -1
- package/front_end/third_party/acorn/package/CHANGELOG.md +128 -0
- package/front_end/third_party/acorn/package/README.md +42 -19
- package/front_end/third_party/acorn/package/dist/acorn.d.mts +883 -26
- package/front_end/third_party/acorn/package/dist/acorn.d.ts +859 -268
- package/front_end/third_party/acorn/package/dist/acorn.js +420 -115
- package/front_end/third_party/acorn/package/dist/acorn.mjs +420 -115
- package/front_end/third_party/acorn/package/dist/bin.js +1 -1
- package/front_end/third_party/acorn/package/package.json +3 -3
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/lighthouse/README.chromium +2 -2
- package/front_end/third_party/lighthouse/lighthouse-dt-bundle.js +4213 -4208
- package/front_end/third_party/lighthouse/locales/en-US.json +26 -8
- package/front_end/third_party/lighthouse/locales/en-XL.json +26 -8
- package/front_end/third_party/lighthouse/report-assets/report-generator.mjs +1 -1
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.js +7 -7
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/BrowserContext.js +4 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Frame.d.ts +15 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Frame.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Frame.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/JSHandle.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/JSHandle.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.js +4 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Frame.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Frame.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Frame.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/ExecutionContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/ExecutionContext.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/ExecutionContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Frame.d.ts +2 -5
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Frame.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Frame.js +4 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Frame.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/FrameManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/FrameManager.js +3 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/FrameManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/IsolatedWorld.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/IsolatedWorld.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js +3 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.d.ts +4 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.d.ts +5 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.js +9 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/BrowserConnector.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/EventEmitter.d.ts +5 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/EventEmitter.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/EventEmitter.js +7 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/EventEmitter.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.js +6 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ScreenRecorder.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ScreenRecorder.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ScreenRecorder.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +23 -2
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +171 -149
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.js +7 -7
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/BrowserContext.js +4 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Frame.d.ts +15 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Frame.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Frame.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/JSHandle.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/JSHandle.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.js +4 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Frame.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Frame.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Frame.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/ExecutionContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/ExecutionContext.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/ExecutionContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Frame.d.ts +2 -5
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Frame.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Frame.js +4 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Frame.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/FrameManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/FrameManager.js +3 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/FrameManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/IsolatedWorld.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/IsolatedWorld.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js +3 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.d.ts +4 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.d.ts +5 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.js +8 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/BrowserConnector.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/EventEmitter.d.ts +5 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/EventEmitter.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/EventEmitter.js +8 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/EventEmitter.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.js +6 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ScreenRecorder.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ScreenRecorder.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ScreenRecorder.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/types.d.ts +23 -2
- package/front_end/third_party/puppeteer/package/package.json +2 -2
- package/front_end/third_party/puppeteer/package/src/api/Browser.ts +6 -7
- package/front_end/third_party/puppeteer/package/src/api/BrowserContext.ts +4 -3
- package/front_end/third_party/puppeteer/package/src/api/Frame.ts +21 -1
- package/front_end/third_party/puppeteer/package/src/api/JSHandle.ts +1 -1
- package/front_end/third_party/puppeteer/package/src/api/Page.ts +9 -4
- package/front_end/third_party/puppeteer/package/src/bidi/Frame.ts +2 -1
- package/front_end/third_party/puppeteer/package/src/cdp/ExecutionContext.ts +1 -0
- package/front_end/third_party/puppeteer/package/src/cdp/Frame.ts +9 -5
- package/front_end/third_party/puppeteer/package/src/cdp/FrameManager.ts +3 -1
- package/front_end/third_party/puppeteer/package/src/cdp/IsolatedWorld.ts +1 -1
- package/front_end/third_party/puppeteer/package/src/cdp/Page.ts +4 -0
- package/front_end/third_party/puppeteer/package/src/cdp/TargetManager.ts +2 -2
- package/front_end/third_party/puppeteer/package/src/common/BrowserConnector.ts +19 -3
- package/front_end/third_party/puppeteer/package/src/common/EventEmitter.ts +10 -1
- package/front_end/third_party/puppeteer/package/src/node/BrowserLauncher.ts +7 -3
- package/front_end/third_party/puppeteer/package/src/node/ScreenRecorder.ts +1 -0
- package/front_end/third_party/puppeteer/package/src/revisions.ts +1 -1
- package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
- package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +7 -1
- package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +8 -1
- package/front_end/ui/legacy/components/perf_ui/LineLevelProfile.ts +0 -56
- package/front_end/ui/legacy/components/perf_ui/perf_ui-meta.ts +0 -35
- package/front_end/ui/legacy/components/perf_ui/perf_ui.ts +0 -2
- package/front_end/ui/visual_logging/KnownContextValues.ts +1 -0
- package/package.json +1 -1
- package/front_end/panels/profiler/LiveHeapProfileView.ts +0 -405
- package/front_end/panels/profiler/liveHeapProfile.css +0 -22
- package/front_end/ui/legacy/components/perf_ui/LiveHeapProfile.ts +0 -113
|
@@ -20,58 +20,16 @@ const UIStrings = {
|
|
|
20
20
|
* @description The milisecond unit
|
|
21
21
|
*/
|
|
22
22
|
ms: 'ms',
|
|
23
|
-
/**
|
|
24
|
-
* @description Unit for data size in DevTools
|
|
25
|
-
*/
|
|
26
|
-
mb: 'MB',
|
|
27
|
-
/**
|
|
28
|
-
* @description A unit
|
|
29
|
-
*/
|
|
30
|
-
kb: 'kB',
|
|
31
23
|
} as const;
|
|
32
24
|
const str_ = i18n.i18n.registerUIStrings('panels/sources/ProfilePlugin.ts', UIStrings);
|
|
33
25
|
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
34
26
|
|
|
35
|
-
class MemoryMarker extends CodeMirror.GutterMarker {
|
|
36
|
-
constructor(readonly value: number) {
|
|
37
|
-
super();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
override eq(other: MemoryMarker): boolean {
|
|
41
|
-
return this.value === other.value;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
override toDOM(): HTMLElement {
|
|
45
|
-
const element = document.createElement('div');
|
|
46
|
-
element.className = 'cm-profileMarker';
|
|
47
|
-
let value = this.value;
|
|
48
|
-
const intensity = Platform.NumberUtilities.clamp(Math.log10(1 + 2e-3 * value) / 5, 0.02, 1);
|
|
49
|
-
element.style.backgroundColor = `hsla(217, 100%, 70%, ${intensity.toFixed(3)})`;
|
|
50
|
-
value /= 1e3;
|
|
51
|
-
let units;
|
|
52
|
-
let fractionDigits;
|
|
53
|
-
if (value >= 1e3) {
|
|
54
|
-
units = i18nString(UIStrings.mb);
|
|
55
|
-
value /= 1e3;
|
|
56
|
-
fractionDigits = value >= 20 ? 0 : 1;
|
|
57
|
-
} else {
|
|
58
|
-
units = i18nString(UIStrings.kb);
|
|
59
|
-
fractionDigits = 0;
|
|
60
|
-
}
|
|
61
|
-
element.textContent = value.toFixed(fractionDigits);
|
|
62
|
-
const unitElement = element.appendChild(document.createElement('span'));
|
|
63
|
-
unitElement.className = 'cm-units';
|
|
64
|
-
unitElement.textContent = units;
|
|
65
|
-
return element;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
27
|
class PerformanceMarker extends CodeMirror.GutterMarker {
|
|
70
28
|
constructor(readonly value: number) {
|
|
71
29
|
super();
|
|
72
30
|
}
|
|
73
31
|
|
|
74
|
-
override eq(other:
|
|
32
|
+
override eq(other: PerformanceMarker): boolean {
|
|
75
33
|
return this.value === other.value;
|
|
76
34
|
}
|
|
77
35
|
|
|
@@ -89,10 +47,8 @@ class PerformanceMarker extends CodeMirror.GutterMarker {
|
|
|
89
47
|
}
|
|
90
48
|
}
|
|
91
49
|
|
|
92
|
-
function markersFromProfileData(
|
|
93
|
-
|
|
94
|
-
type: Workspace.UISourceCode.DecoratorType): CodeMirror.RangeSet<CodeMirror.GutterMarker> {
|
|
95
|
-
const markerType = type === Workspace.UISourceCode.DecoratorType.PERFORMANCE ? PerformanceMarker : MemoryMarker;
|
|
50
|
+
function markersFromProfileData(map: Workspace.UISourceCode.LineColumnProfileMap, state: CodeMirror.EditorState):
|
|
51
|
+
CodeMirror.RangeSet<CodeMirror.GutterMarker> {
|
|
96
52
|
const markers: Array<CodeMirror.Range<CodeMirror.GutterMarker>> = [];
|
|
97
53
|
const aggregatedByLine = new Map<number, number>();
|
|
98
54
|
for (const [line, value] of map) {
|
|
@@ -104,13 +60,12 @@ function markersFromProfileData(
|
|
|
104
60
|
}
|
|
105
61
|
for (const [line, value] of aggregatedByLine) {
|
|
106
62
|
const {from} = state.doc.line(line);
|
|
107
|
-
markers.push(new
|
|
63
|
+
markers.push(new PerformanceMarker(value).range(from));
|
|
108
64
|
}
|
|
109
65
|
return CodeMirror.RangeSet.of(markers, true);
|
|
110
66
|
}
|
|
111
67
|
|
|
112
|
-
|
|
113
|
-
class ProfilePlugin extends Plugin {
|
|
68
|
+
export class PerformanceProfilePlugin extends Plugin {
|
|
114
69
|
updateEffect = CodeMirror.StateEffect.define<Workspace.UISourceCode.LineColumnProfileMap>();
|
|
115
70
|
field: CodeMirror.StateField<CodeMirror.RangeSet<CodeMirror.GutterMarker>>;
|
|
116
71
|
gutter: CodeMirror.Extension;
|
|
@@ -126,14 +81,14 @@ const makeLineLevelProfilePlugin = (type: Workspace.UISourceCode.DecoratorType):
|
|
|
126
81
|
},
|
|
127
82
|
update: (markers, tr) => {
|
|
128
83
|
return tr.effects.reduce((markers, effect) => {
|
|
129
|
-
return effect.is(this.updateEffect) ? markersFromProfileData(effect.value, tr.state
|
|
84
|
+
return effect.is(this.updateEffect) ? markersFromProfileData(effect.value, tr.state) : markers;
|
|
130
85
|
}, markers.map(tr.changes));
|
|
131
86
|
},
|
|
132
87
|
});
|
|
133
88
|
|
|
134
89
|
this.gutter = CodeMirror.gutter({
|
|
135
90
|
markers: view => view.state.field(this.field),
|
|
136
|
-
class: `cm-${
|
|
91
|
+
class: `cm-${Workspace.UISourceCode.DecoratorType.PERFORMANCE}Gutter`,
|
|
137
92
|
});
|
|
138
93
|
|
|
139
94
|
this.#transformer = transformer;
|
|
@@ -144,7 +99,8 @@ const makeLineLevelProfilePlugin = (type: Workspace.UISourceCode.DecoratorType):
|
|
|
144
99
|
}
|
|
145
100
|
|
|
146
101
|
private getLineMap(): Workspace.UISourceCode.LineColumnProfileMap|undefined {
|
|
147
|
-
const uiSourceCodeProfileMap =
|
|
102
|
+
const uiSourceCodeProfileMap =
|
|
103
|
+
this.uiSourceCode.getDecorationData(Workspace.UISourceCode.DecoratorType.PERFORMANCE);
|
|
148
104
|
if (!uiSourceCodeProfileMap) {
|
|
149
105
|
return undefined;
|
|
150
106
|
}
|
|
@@ -158,7 +114,7 @@ const makeLineLevelProfilePlugin = (type: Workspace.UISourceCode.DecoratorType):
|
|
|
158
114
|
override editorExtension(): CodeMirror.Extension {
|
|
159
115
|
const map = this.getLineMap();
|
|
160
116
|
return this.compartment.of(
|
|
161
|
-
!map ? [] : [this.field.init(state => markersFromProfileData(map, state
|
|
117
|
+
!map ? [] : [this.field.init(state => markersFromProfileData(map, state)), this.gutter, theme]);
|
|
162
118
|
}
|
|
163
119
|
|
|
164
120
|
override decorationChanged(type: Workspace.UISourceCode.DecoratorType, editor: TextEditor.TextEditor.TextEditor):
|
|
@@ -172,13 +128,13 @@ const makeLineLevelProfilePlugin = (type: Workspace.UISourceCode.DecoratorType):
|
|
|
172
128
|
} else if (!installed) {
|
|
173
129
|
editor.dispatch({
|
|
174
130
|
effects: this.compartment.reconfigure(
|
|
175
|
-
[this.field.init(state => markersFromProfileData(map, state
|
|
131
|
+
[this.field.init(state => markersFromProfileData(map, state)), this.gutter, theme]),
|
|
176
132
|
});
|
|
177
133
|
} else {
|
|
178
134
|
editor.dispatch({effects: this.updateEffect.of(map)});
|
|
179
135
|
}
|
|
180
136
|
}
|
|
181
|
-
}
|
|
137
|
+
}
|
|
182
138
|
|
|
183
139
|
const theme = CodeMirror.EditorView.baseTheme({
|
|
184
140
|
'.cm-line::selection': {
|
|
@@ -190,11 +146,6 @@ const theme = CodeMirror.EditorView.baseTheme({
|
|
|
190
146
|
backgroundColor: 'var(--sys-color-cdt-base-container)',
|
|
191
147
|
marginLeft: '3px',
|
|
192
148
|
},
|
|
193
|
-
'.cm-memoryGutter': {
|
|
194
|
-
width: '48px',
|
|
195
|
-
backgroundColor: 'var(--sys-color-cdt-base-container)',
|
|
196
|
-
marginLeft: '3px',
|
|
197
|
-
},
|
|
198
149
|
'.cm-profileMarker': {
|
|
199
150
|
textAlign: 'right',
|
|
200
151
|
paddingRight: '3px',
|
|
@@ -205,7 +156,3 @@ const theme = CodeMirror.EditorView.baseTheme({
|
|
|
205
156
|
marginLeft: '3px',
|
|
206
157
|
},
|
|
207
158
|
});
|
|
208
|
-
|
|
209
|
-
export const MemoryProfilePlugin = makeLineLevelProfilePlugin(Workspace.UISourceCode.DecoratorType.MEMORY);
|
|
210
|
-
|
|
211
|
-
export const PerformanceProfilePlugin = makeLineLevelProfilePlugin(Workspace.UISourceCode.DecoratorType.PERFORMANCE);
|
|
@@ -25,7 +25,7 @@ import {CoveragePlugin} from './CoveragePlugin.js';
|
|
|
25
25
|
import {CSSPlugin} from './CSSPlugin.js';
|
|
26
26
|
import {DebuggerPlugin} from './DebuggerPlugin.js';
|
|
27
27
|
import type {Plugin} from './Plugin.js';
|
|
28
|
-
import {
|
|
28
|
+
import {PerformanceProfilePlugin} from './ProfilePlugin.js';
|
|
29
29
|
import {ResourceOriginPlugin} from './ResourceOriginPlugin.js';
|
|
30
30
|
import {SnippetsPlugin} from './SnippetsPlugin.js';
|
|
31
31
|
import {SourcesPanel} from './SourcesPanel.js';
|
|
@@ -321,7 +321,6 @@ export class UISourceCodeFrame extends Common.ObjectWrapper
|
|
|
321
321
|
SnippetsPlugin,
|
|
322
322
|
ResourceOriginPlugin,
|
|
323
323
|
CoveragePlugin,
|
|
324
|
-
MemoryProfilePlugin,
|
|
325
324
|
PerformanceProfilePlugin,
|
|
326
325
|
AiWarningInfobarPlugin,
|
|
327
326
|
];
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import * as Common from '../../core/common/common.js';
|
|
6
6
|
import * as i18n from '../../core/i18n/i18n.js';
|
|
7
7
|
import type * as Platform from '../../core/platform/platform.js';
|
|
8
|
-
import * as Root from '../../core/root/root.js';
|
|
9
8
|
import * as SDK from '../../core/sdk/sdk.js';
|
|
10
9
|
import type * as Protocol from '../../generated/protocol.js';
|
|
11
10
|
import * as CrUXManager from '../../models/crux-manager/crux-manager.js';
|
|
@@ -254,7 +253,7 @@ export class TimelineController implements Tracing.TracingManager.TracingManager
|
|
|
254
253
|
if (options.enableJSSampling) {
|
|
255
254
|
categoriesArray.push(disabledByDefault('v8.cpu_profiler'));
|
|
256
255
|
}
|
|
257
|
-
if (
|
|
256
|
+
if (Common.Settings.Settings.instance().moduleSetting('timeline-invalidation-tracking').get() as boolean) {
|
|
258
257
|
categoriesArray.push(disabledByDefault('devtools.timeline.invalidationTracking'));
|
|
259
258
|
}
|
|
260
259
|
if (options.capturePictures) {
|
|
@@ -740,7 +740,7 @@ export class TimelinePanel extends Common.ObjectWrapper.eventMixin<EventTypes, t
|
|
|
740
740
|
#instantiateNewModel(): Trace.TraceModel.Model {
|
|
741
741
|
const config = Trace.Types.Configuration.defaults();
|
|
742
742
|
config.showAllEvents = Common.Settings.Settings.instance().moduleSetting('timeline-show-all-events').get();
|
|
743
|
-
config.debugMode =
|
|
743
|
+
config.debugMode = Common.Settings.Settings.instance().moduleSetting('timeline-debug-mode').get() as boolean;
|
|
744
744
|
|
|
745
745
|
const traceEngineModel = Trace.TraceModel.Model.createWithAllHandlers(config);
|
|
746
746
|
|
|
@@ -497,16 +497,8 @@ type TimeRangeCategoryStats = Record<string, number>;
|
|
|
497
497
|
const {SamplesIntegrator} = Trace.Helpers.SamplesIntegrator;
|
|
498
498
|
|
|
499
499
|
export class TimelineUIUtils {
|
|
500
|
-
/**
|
|
501
|
-
* use getGetDebugModeEnabled() to query this variable.
|
|
502
|
-
*/
|
|
503
|
-
static debugModeEnabled: boolean|undefined = undefined;
|
|
504
500
|
static getGetDebugModeEnabled(): boolean {
|
|
505
|
-
|
|
506
|
-
TimelineUIUtils.debugModeEnabled =
|
|
507
|
-
Root.Runtime.experiments.isEnabled(Root.ExperimentNames.ExperimentName.TIMELINE_DEBUG_MODE);
|
|
508
|
-
}
|
|
509
|
-
return TimelineUIUtils.debugModeEnabled;
|
|
501
|
+
return Common.Settings.Settings.instance().moduleSetting('timeline-debug-mode').get() as boolean;
|
|
510
502
|
}
|
|
511
503
|
static frameDisplayName(frame: Protocol.Runtime.CallFrame): string {
|
|
512
504
|
const maybeResolvedData = SourceMapsResolver.SourceMapsResolver.resolvedCodeLocationForCallFrame(frame);
|
|
@@ -1527,7 +1519,7 @@ export class TimelineUIUtils {
|
|
|
1527
1519
|
await TimelineUIUtils.generateCauses(event, contentHelper, parsedTrace);
|
|
1528
1520
|
}
|
|
1529
1521
|
|
|
1530
|
-
if (
|
|
1522
|
+
if (TimelineUIUtils.getGetDebugModeEnabled()) {
|
|
1531
1523
|
TimelineUIUtils.renderEventJson(event, contentHelper);
|
|
1532
1524
|
}
|
|
1533
1525
|
|
|
@@ -66,6 +66,14 @@ const UIStrings = {
|
|
|
66
66
|
* @description Title of a setting under the Performance category in Settings
|
|
67
67
|
*/
|
|
68
68
|
timelineShowAllEvents: 'Show all events',
|
|
69
|
+
/**
|
|
70
|
+
* @description Title of a setting under the Performance category in Settings
|
|
71
|
+
*/
|
|
72
|
+
timelineDebugMode: 'Timeline debug mode (trace event details, etc.)',
|
|
73
|
+
/**
|
|
74
|
+
* @description Title of a setting under the Performance category in Settings
|
|
75
|
+
*/
|
|
76
|
+
timelineInvalidationTracking: 'Invalidation tracking',
|
|
69
77
|
} as const;
|
|
70
78
|
const str_ = i18n.i18n.registerUIStrings('panels/timeline/timeline-meta.ts', UIStrings);
|
|
71
79
|
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
|
|
@@ -327,6 +335,24 @@ Common.Settings.registerSettingExtension({
|
|
|
327
335
|
defaultValue: false,
|
|
328
336
|
});
|
|
329
337
|
|
|
338
|
+
Common.Settings.registerSettingExtension({
|
|
339
|
+
category: Common.Settings.SettingCategory.PERFORMANCE,
|
|
340
|
+
storageType: Common.Settings.SettingStorageType.SYNCED,
|
|
341
|
+
title: i18nLazyString(UIStrings.timelineDebugMode),
|
|
342
|
+
settingName: 'timeline-debug-mode',
|
|
343
|
+
settingType: Common.Settings.SettingType.BOOLEAN,
|
|
344
|
+
defaultValue: false,
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
Common.Settings.registerSettingExtension({
|
|
348
|
+
category: Common.Settings.SettingCategory.PERFORMANCE,
|
|
349
|
+
storageType: Common.Settings.SettingStorageType.SYNCED,
|
|
350
|
+
title: i18nLazyString(UIStrings.timelineInvalidationTracking),
|
|
351
|
+
settingName: 'timeline-invalidation-tracking',
|
|
352
|
+
settingType: Common.Settings.SettingType.BOOLEAN,
|
|
353
|
+
defaultValue: false,
|
|
354
|
+
});
|
|
355
|
+
|
|
330
356
|
// IMPORTANT: if you are updating this, you should also update the setting in
|
|
331
357
|
// js_timeline-meta.
|
|
332
358
|
Common.Settings.registerSettingExtension({
|
|
@@ -7,7 +7,7 @@ import * as acorn from './package/dist/acorn.mjs';
|
|
|
7
7
|
import type * as ESTree from './estree-legacy.js';
|
|
8
8
|
export {ESTree};
|
|
9
9
|
|
|
10
|
-
export { type Comment, defaultOptions, getLineInfo,
|
|
10
|
+
export { type Comment, defaultOptions, getLineInfo, Node, SourceLocation, Token, tokTypes} from './package/dist/acorn.mjs';
|
|
11
11
|
|
|
12
12
|
export const Parser = acorn.Parser;
|
|
13
13
|
export const tokenizer = acorn.Parser.tokenizer.bind(acorn.Parser);
|
|
@@ -1,3 +1,131 @@
|
|
|
1
|
+
## 8.16.0 (2026-02-19)
|
|
2
|
+
|
|
3
|
+
### New features
|
|
4
|
+
|
|
5
|
+
The `sourceType` option can now be set to `"commonjs"` to have the parser treat the top level scope as a function scope.
|
|
6
|
+
|
|
7
|
+
Add support for Unicode 17.
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Don't recognize `await using` as contextual keywords when followed directly by a backslash.
|
|
12
|
+
|
|
13
|
+
Fix an issue where the parser would allow `return` statements in `static` blocks when `allowReturnOutsideFunction` was enabled.
|
|
14
|
+
|
|
15
|
+
Properly reject `using` declarations that appear directly in `switch` or `for` head scopes.
|
|
16
|
+
|
|
17
|
+
Fix some corner case issues in the recognition of `using` syntax.
|
|
18
|
+
|
|
19
|
+
## 8.15.0 (2025-06-08)
|
|
20
|
+
|
|
21
|
+
### New features
|
|
22
|
+
|
|
23
|
+
Support `using` and `await using` syntax.
|
|
24
|
+
|
|
25
|
+
The `AnyNode` type is now defined in such a way that plugins can extend it.
|
|
26
|
+
|
|
27
|
+
### Bug fixes
|
|
28
|
+
|
|
29
|
+
Fix an issue where the `bigint` property of literal nodes for non-decimal bigints had the wrong format.
|
|
30
|
+
|
|
31
|
+
The `acorn` CLI tool no longer crashes when emitting a tree that contains a bigint.
|
|
32
|
+
|
|
33
|
+
## 8.14.1 (2025-03-05)
|
|
34
|
+
|
|
35
|
+
### Bug fixes
|
|
36
|
+
|
|
37
|
+
Fix an issue where `await` expressions in class field initializers were inappropriately allowed.
|
|
38
|
+
|
|
39
|
+
Properly allow await inside an async arrow function inside a class field initializer.
|
|
40
|
+
|
|
41
|
+
Mention the source file name in syntax error messages when given.
|
|
42
|
+
|
|
43
|
+
Properly add an empty `attributes` property to every form of `ExportNamedDeclaration`.
|
|
44
|
+
|
|
45
|
+
## 8.14.0 (2024-10-27)
|
|
46
|
+
|
|
47
|
+
### New features
|
|
48
|
+
|
|
49
|
+
Support ES2025 import attributes.
|
|
50
|
+
|
|
51
|
+
Support ES2025 RegExp modifiers.
|
|
52
|
+
|
|
53
|
+
### Bug fixes
|
|
54
|
+
|
|
55
|
+
Support some missing Unicode properties.
|
|
56
|
+
|
|
57
|
+
## 8.13.0 (2024-10-16)
|
|
58
|
+
|
|
59
|
+
### New features
|
|
60
|
+
|
|
61
|
+
Upgrade to Unicode 16.0.
|
|
62
|
+
|
|
63
|
+
## 8.12.1 (2024-07-03)
|
|
64
|
+
|
|
65
|
+
### Bug fixes
|
|
66
|
+
|
|
67
|
+
Fix a regression that caused Acorn to no longer run on Node versions <8.10.
|
|
68
|
+
|
|
69
|
+
## 8.12.0 (2024-06-14)
|
|
70
|
+
|
|
71
|
+
### New features
|
|
72
|
+
|
|
73
|
+
Support ES2025 duplicate capture group names in regular expressions.
|
|
74
|
+
|
|
75
|
+
### Bug fixes
|
|
76
|
+
|
|
77
|
+
Include `VariableDeclarator` in the `AnyNode` type so that walker objects can refer to it without getting a type error.
|
|
78
|
+
|
|
79
|
+
Properly raise a parse error for invalid `for`/`of` statements using `async` as binding name.
|
|
80
|
+
|
|
81
|
+
Properly recognize \"use strict\" when preceded by a string with an escaped newline.
|
|
82
|
+
|
|
83
|
+
Mark the `Parser` constructor as protected, not private, so plugins can extend it without type errors.
|
|
84
|
+
|
|
85
|
+
Fix a bug where some invalid `delete` expressions were let through when the operand was parenthesized and `preserveParens` was enabled.
|
|
86
|
+
|
|
87
|
+
Properly normalize line endings in raw strings of invalid template tokens.
|
|
88
|
+
|
|
89
|
+
Properly track line numbers for escaped newlines in strings.
|
|
90
|
+
|
|
91
|
+
Fix a bug that broke line number accounting after a template literal with invalid escape sequences.
|
|
92
|
+
|
|
93
|
+
## 8.11.3 (2023-12-29)
|
|
94
|
+
|
|
95
|
+
### Bug fixes
|
|
96
|
+
|
|
97
|
+
Add `Function` and `Class` to the `AggregateType` type, so that they can be used in walkers without raising a type error.
|
|
98
|
+
|
|
99
|
+
Make sure `onToken` get an `import` keyword token when parsing `import.meta`.
|
|
100
|
+
|
|
101
|
+
Fix a bug where `.loc.start` could be undefined for `new.target` `meta` nodes.
|
|
102
|
+
|
|
103
|
+
## 8.11.2 (2023-10-27)
|
|
104
|
+
|
|
105
|
+
### Bug fixes
|
|
106
|
+
|
|
107
|
+
Fix a bug that caused regular expressions after colon tokens to not be properly tokenized in some circumstances.
|
|
108
|
+
|
|
109
|
+
## 8.11.1 (2023-10-26)
|
|
110
|
+
|
|
111
|
+
### Bug fixes
|
|
112
|
+
|
|
113
|
+
Fix a regression where `onToken` would receive 'name' tokens for 'new' keyword tokens.
|
|
114
|
+
|
|
115
|
+
## 8.11.0 (2023-10-26)
|
|
116
|
+
|
|
117
|
+
### Bug fixes
|
|
118
|
+
|
|
119
|
+
Fix an issue where tokenizing (without parsing) an object literal with a property named `class` or `function` could, in some circumstance, put the tokenizer into an invalid state.
|
|
120
|
+
|
|
121
|
+
Fix an issue where a slash after a call to a propery named the same as some keywords would be tokenized as a regular expression.
|
|
122
|
+
|
|
123
|
+
### New features
|
|
124
|
+
|
|
125
|
+
Upgrade to Unicode 15.1.
|
|
126
|
+
|
|
127
|
+
Use a set of new, much more precise, TypeScript types.
|
|
128
|
+
|
|
1
129
|
## 8.10.0 (2023-07-05)
|
|
2
130
|
|
|
3
131
|
### New features
|
|
@@ -9,9 +9,7 @@ Acorn is open source software released under an
|
|
|
9
9
|
|
|
10
10
|
You are welcome to
|
|
11
11
|
[report bugs](https://github.com/acornjs/acorn/issues) or create pull
|
|
12
|
-
requests on [github](https://github.com/acornjs/acorn).
|
|
13
|
-
and discussion, please use the
|
|
14
|
-
[Tern discussion forum](https://discuss.ternjs.net).
|
|
12
|
+
requests on [github](https://github.com/acornjs/acorn).
|
|
15
13
|
|
|
16
14
|
## Installation
|
|
17
15
|
|
|
@@ -28,6 +26,24 @@ git clone https://github.com/acornjs/acorn.git
|
|
|
28
26
|
cd acorn
|
|
29
27
|
npm install
|
|
30
28
|
```
|
|
29
|
+
## Importing acorn
|
|
30
|
+
|
|
31
|
+
ESM as well as CommonJS is supported for all 3: `acorn`, `acorn-walk` and `acorn-loose`.
|
|
32
|
+
|
|
33
|
+
ESM example for `acorn`:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import * as acorn from "acorn"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
CommonJS example for `acorn`:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
let acorn = require("acorn")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
ESM is preferred, as it allows better editor auto-completions by offering TypeScript support.
|
|
46
|
+
For this reason, following examples will use ESM imports.
|
|
31
47
|
|
|
32
48
|
## Interface
|
|
33
49
|
|
|
@@ -38,8 +54,8 @@ syntax tree object as specified by the [ESTree
|
|
|
38
54
|
spec](https://github.com/estree/estree).
|
|
39
55
|
|
|
40
56
|
```javascript
|
|
41
|
-
|
|
42
|
-
console.log(acorn.parse("1 + 1", {ecmaVersion: 2020}))
|
|
57
|
+
import * as acorn from "acorn"
|
|
58
|
+
console.log(acorn.parse("1 + 1", {ecmaVersion: 2020}))
|
|
43
59
|
```
|
|
44
60
|
|
|
45
61
|
When encountering a syntax error, the parser will raise a
|
|
@@ -52,23 +68,23 @@ Options are provided by in a second argument, which should be an
|
|
|
52
68
|
object containing any of these fields (only `ecmaVersion` is
|
|
53
69
|
required):
|
|
54
70
|
|
|
55
|
-
- **ecmaVersion**: Indicates the ECMAScript version to parse.
|
|
56
|
-
either
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
features.
|
|
71
|
+
- **ecmaVersion**: Indicates the ECMAScript version to parse. Can be a
|
|
72
|
+
number, either in year (`2022`) or plain version number (`6`) form,
|
|
73
|
+
or `"latest"` (the latest the library supports). This influences
|
|
74
|
+
support for strict mode, the set of reserved words, and support for
|
|
75
|
+
new syntax features.
|
|
61
76
|
|
|
62
77
|
**NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
|
|
63
78
|
implemented by Acorn. Other proposed new features must be
|
|
64
79
|
implemented through plugins.
|
|
65
80
|
|
|
66
81
|
- **sourceType**: Indicate the mode the code should be parsed in. Can be
|
|
67
|
-
either `"script"` or `"
|
|
82
|
+
either `"script"`, `"module"` or `"commonjs"`. This influences global strict mode
|
|
68
83
|
and parsing of `import` and `export` declarations.
|
|
69
84
|
|
|
70
85
|
**NOTE**: If set to `"module"`, then static `import` / `export` syntax
|
|
71
|
-
will be valid, even if `ecmaVersion` is less than 6.
|
|
86
|
+
will be valid, even if `ecmaVersion` is less than 6. If set to `"commonjs"`,
|
|
87
|
+
it is the same as `"script"` except that the top-level scope behaves like a function.
|
|
72
88
|
|
|
73
89
|
- **onInsertedSemicolon**: If given a callback, that callback will be
|
|
74
90
|
called whenever a missing semicolon is inserted by the parser. The
|
|
@@ -100,7 +116,7 @@ required):
|
|
|
100
116
|
for `ecmaVersion` 2022 and later, `false` for lower versions.
|
|
101
117
|
Setting this option to `true` allows to have top-level `await`
|
|
102
118
|
expressions. They are still not allowed in non-`async` functions,
|
|
103
|
-
though.
|
|
119
|
+
though. Setting this option to `true` is not allowed when `sourceType: "commonjs"`.
|
|
104
120
|
|
|
105
121
|
- **allowSuperOutsideMethod**: By default, `super` outside a method
|
|
106
122
|
raises an error. Set this to `true` to accept such code.
|
|
@@ -204,6 +220,13 @@ option is enabled). When the token's type is `tokTypes.eof`, you
|
|
|
204
220
|
should stop calling the method, since it will keep returning that same
|
|
205
221
|
token forever.
|
|
206
222
|
|
|
223
|
+
Note that tokenizing JavaScript without parsing it is, in modern
|
|
224
|
+
versions of the language, not really possible due to the way syntax is
|
|
225
|
+
overloaded in ways that can only be disambiguated by the parse
|
|
226
|
+
context. This package applies a bunch of heuristics to try and do a
|
|
227
|
+
reasonable job, but you are advised to use `parse` with the `onToken`
|
|
228
|
+
option instead of this.
|
|
229
|
+
|
|
207
230
|
In ES6 environment, returned result can be used as any other
|
|
208
231
|
protocol-compliant iterable:
|
|
209
232
|
|
|
@@ -213,7 +236,7 @@ for (let token of acorn.tokenizer(str)) {
|
|
|
213
236
|
}
|
|
214
237
|
|
|
215
238
|
// transform code to array of tokens:
|
|
216
|
-
var tokens = [...acorn.tokenizer(str)]
|
|
239
|
+
var tokens = [...acorn.tokenizer(str)]
|
|
217
240
|
```
|
|
218
241
|
|
|
219
242
|
**tokTypes** holds an object mapping names to the token type objects
|
|
@@ -234,10 +257,10 @@ on the extended version of the class. To extend a parser with plugins,
|
|
|
234
257
|
you can use its static `extend` method.
|
|
235
258
|
|
|
236
259
|
```javascript
|
|
237
|
-
var acorn = require("acorn")
|
|
238
|
-
var jsx = require("acorn-jsx")
|
|
239
|
-
var JSXParser = acorn.Parser.extend(jsx())
|
|
240
|
-
JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020})
|
|
260
|
+
var acorn = require("acorn")
|
|
261
|
+
var jsx = require("acorn-jsx")
|
|
262
|
+
var JSXParser = acorn.Parser.extend(jsx())
|
|
263
|
+
JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020})
|
|
241
264
|
```
|
|
242
265
|
|
|
243
266
|
The `extend` method takes any number of plugin values, and returns a
|