devtools-tracing 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +4 -0
  2. package/generate.ts +32 -26
  3. package/index.ts +2 -1
  4. package/lib/extension-api/ExtensionAPI.d.ts +357 -0
  5. package/lib/front_end/models/bindings/CSSWorkspaceBinding.ts +318 -0
  6. package/lib/front_end/models/bindings/CompilerScriptMapping.ts +536 -0
  7. package/lib/front_end/models/bindings/ContentProviderBasedProject.ts +187 -0
  8. package/lib/front_end/models/bindings/DebuggerLanguagePlugins.ts +1197 -0
  9. package/lib/front_end/models/bindings/DebuggerWorkspaceBinding.ts +733 -0
  10. package/lib/front_end/models/bindings/DefaultScriptMapping.ts +141 -0
  11. package/lib/front_end/models/bindings/FileUtils.ts +228 -0
  12. package/lib/front_end/models/bindings/LiveLocation.ts +81 -0
  13. package/lib/front_end/models/bindings/NetworkProject.ts +157 -0
  14. package/lib/front_end/models/bindings/PresentationConsoleMessageHelper.ts +312 -0
  15. package/lib/front_end/models/bindings/ResourceMapping.ts +539 -0
  16. package/lib/front_end/models/bindings/ResourceScriptMapping.ts +491 -0
  17. package/lib/front_end/models/bindings/ResourceUtils.ts +103 -0
  18. package/lib/front_end/models/bindings/SASSSourceMapping.ts +222 -0
  19. package/lib/front_end/models/bindings/StylesSourceMapping.ts +316 -0
  20. package/lib/front_end/models/bindings/TempFile.ts +67 -0
  21. package/lib/front_end/models/bindings/bindings.ts +39 -0
  22. package/lib/front_end/models/source_map_scopes/NamesResolver.ts +765 -0
  23. package/lib/front_end/models/source_map_scopes/ScopeChainModel.ts +84 -0
  24. package/lib/front_end/models/source_map_scopes/source_map_scopes.ts +11 -0
  25. package/lib/front_end/models/stack_trace/StackTrace.ts +53 -0
  26. package/lib/front_end/models/stack_trace/StackTraceImpl.ts +85 -0
  27. package/lib/front_end/models/stack_trace/StackTraceModel.ts +128 -0
  28. package/lib/front_end/models/stack_trace/Trie.ts +163 -0
  29. package/lib/front_end/models/stack_trace/stack_trace.ts +9 -0
  30. package/lib/front_end/models/stack_trace/stack_trace_impl.ts +13 -0
  31. package/lib/front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts +240 -0
  32. package/lib/front_end/models/trace_source_maps_resolver/trace_source_maps_resolver.ts +5 -0
  33. package/lib/front_end/models/workspace/FileManager.ts +97 -0
  34. package/lib/front_end/models/workspace/IgnoreListManager.ts +628 -0
  35. package/lib/front_end/models/workspace/SearchConfig.ts +149 -0
  36. package/lib/front_end/models/workspace/UISourceCode.ts +698 -0
  37. package/lib/front_end/models/workspace/WorkspaceImpl.ts +339 -0
  38. package/lib/front_end/models/workspace/workspace.ts +17 -0
  39. package/lib/front_end/panels/timeline/TimelineUIUtils.ts +1029 -0
  40. package/lib/front_end/panels/timeline/extensions/ExtensionUI.ts +49 -0
  41. package/lib/front_end/panels/timeline/extensions/extensions.ts +9 -0
  42. package/lib/front_end/third_party/codemirror.next/LICENSE +21 -0
  43. package/lib/front_end/third_party/codemirror.next/README.chromium +30 -0
  44. package/lib/front_end/third_party/codemirror.next/bundle-tsconfig.json +24 -0
  45. package/lib/front_end/third_party/codemirror.next/bundle.ts +135 -0
  46. package/lib/front_end/third_party/codemirror.next/chunk/angular.js +2 -0
  47. package/lib/front_end/third_party/codemirror.next/chunk/angular.js.map +1 -0
  48. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js +2 -0
  49. package/lib/front_end/third_party/codemirror.next/chunk/codemirror.js.map +1 -0
  50. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js +2 -0
  51. package/lib/front_end/third_party/codemirror.next/chunk/cpp.js.map +1 -0
  52. package/lib/front_end/third_party/codemirror.next/chunk/css.js +2 -0
  53. package/lib/front_end/third_party/codemirror.next/chunk/html.js +4 -0
  54. package/lib/front_end/third_party/codemirror.next/chunk/java.js +2 -0
  55. package/lib/front_end/third_party/codemirror.next/chunk/java.js.map +1 -0
  56. package/lib/front_end/third_party/codemirror.next/chunk/javascript.js +2 -0
  57. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js +2 -0
  58. package/lib/front_end/third_party/codemirror.next/chunk/legacy.js.map +1 -0
  59. package/lib/front_end/third_party/codemirror.next/chunk/less.js +2 -0
  60. package/lib/front_end/third_party/codemirror.next/chunk/less.js.map +1 -0
  61. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js +2 -0
  62. package/lib/front_end/third_party/codemirror.next/chunk/markdown.js.map +1 -0
  63. package/lib/front_end/third_party/codemirror.next/chunk/php.js +2 -0
  64. package/lib/front_end/third_party/codemirror.next/chunk/php.js.map +1 -0
  65. package/lib/front_end/third_party/codemirror.next/chunk/python.js +2 -0
  66. package/lib/front_end/third_party/codemirror.next/chunk/python.js.map +1 -0
  67. package/lib/front_end/third_party/codemirror.next/chunk/sass.js +2 -0
  68. package/lib/front_end/third_party/codemirror.next/chunk/sass.js.map +1 -0
  69. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js +2 -0
  70. package/lib/front_end/third_party/codemirror.next/chunk/svelte.js.map +1 -0
  71. package/lib/front_end/third_party/codemirror.next/chunk/vue.js +2 -0
  72. package/lib/front_end/third_party/codemirror.next/chunk/vue.js.map +1 -0
  73. package/lib/front_end/third_party/codemirror.next/chunk/wast.js +2 -0
  74. package/lib/front_end/third_party/codemirror.next/chunk/wast.js.map +1 -0
  75. package/lib/front_end/third_party/codemirror.next/chunk/xml.js +2 -0
  76. package/lib/front_end/third_party/codemirror.next/chunk/xml.js.map +1 -0
  77. package/lib/front_end/third_party/codemirror.next/codemirror.next.d.ts +8057 -0
  78. package/lib/front_end/third_party/codemirror.next/codemirror.next.js +2 -0
  79. package/lib/front_end/third_party/codemirror.next/codemirror.next.js.map +1 -0
  80. package/lib/front_end/third_party/codemirror.next/package.json +43 -0
  81. package/lib/front_end/third_party/codemirror.next/rebuild.sh +6 -0
  82. package/lib/front_end/third_party/codemirror.next/rollup.config.mjs +49 -0
  83. package/lib/front_end/third_party/source-map-scopes-codec/LICENSE +26 -0
  84. package/lib/front_end/third_party/source-map-scopes-codec/README.chromium +31 -0
  85. package/lib/front_end/third_party/source-map-scopes-codec/package/CONTRIBUTING.md +33 -0
  86. package/lib/front_end/third_party/source-map-scopes-codec/package/LICENSE +26 -0
  87. package/lib/front_end/third_party/source-map-scopes-codec/package/README.md +64 -0
  88. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts +62 -0
  89. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/builder.d.ts.map +1 -0
  90. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts +37 -0
  91. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/builder/safe_builder.d.ts.map +1 -0
  92. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts +29 -0
  93. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/decode/decode.d.ts.map +1 -0
  94. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts +8 -0
  95. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/encode/encode.d.ts.map +1 -0
  96. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts +6 -0
  97. package/lib/front_end/third_party/source-map-scopes-codec/package/_dist/src/mod.d.ts.map +1 -0
  98. package/lib/front_end/third_party/source-map-scopes-codec/package/deno.json +21 -0
  99. package/lib/front_end/third_party/source-map-scopes-codec/package/package.json +14 -0
  100. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js +196 -0
  101. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js.map +1 -0
  102. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/builder.ts +262 -0
  103. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js +235 -0
  104. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js.map +1 -0
  105. package/lib/front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.ts +359 -0
  106. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js +39 -0
  107. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.js.map +1 -0
  108. package/lib/front_end/third_party/source-map-scopes-codec/package/src/codec.ts +53 -0
  109. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js +438 -0
  110. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js.map +1 -0
  111. package/lib/front_end/third_party/source-map-scopes-codec/package/src/decode/decode.ts +539 -0
  112. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js +23 -0
  113. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js.map +1 -0
  114. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encode.ts +35 -0
  115. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js +257 -0
  116. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js.map +1 -0
  117. package/lib/front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.ts +348 -0
  118. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js +8 -0
  119. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.js.map +1 -0
  120. package/lib/front_end/third_party/source-map-scopes-codec/package/src/mod.ts +20 -0
  121. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes-tsconfig.json +8 -0
  122. package/lib/front_end/third_party/source-map-scopes-codec/package/src/scopes.d.ts +184 -0
  123. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js +9 -0
  124. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.js.map +1 -0
  125. package/lib/front_end/third_party/source-map-scopes-codec/package/src/util.ts +12 -0
  126. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js +82 -0
  127. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.js.map +1 -0
  128. package/lib/front_end/third_party/source-map-scopes-codec/package/src/vlq.ts +99 -0
  129. package/lib/front_end/third_party/source-map-scopes-codec/source-map-scopes-codec.ts +5 -0
  130. package/lib/front_end/ui/legacy/theme_support/ThemeSupport.ts +222 -0
  131. package/lib/front_end/ui/legacy/theme_support/theme_support.ts +5 -0
  132. package/package.json +11 -5
  133. package/patches/chrome-devtools-frontend+1.0.1533544.patch +1549 -20
@@ -0,0 +1,2 @@
1
+ export{b5 as Annotation,b6 as AnnotationType,b7 as ChangeDesc,b8 as ChangeSet,b9 as Compartment,C as CompletionContext,bm as Decoration,v as EditorSelection,D as EditorState,S as EditorView,ba as Facet,bp as GutterMarker,aY as HighlightStyle,b as LRParser,o as Language,a as LanguageSupport,bb as Line,bc as MapMode,bu as MatchDecorator,l as NodeProp,m as NodeSet,N as NodeType,P as Parser,x as Prec,bd as Range,be as RangeSet,bf as RangeSetBuilder,bg as SelectionRange,bh as StateEffect,bi as StateEffectType,bj as StateField,a_ as StreamLanguage,a$ as StringStream,bG as StyleModule,T as Tag,bk as Text,bl as Transaction,n as Tree,bE as TreeCursor,bB as ViewPlugin,bC as ViewUpdate,bD as WidgetType,aj as acceptCompletion,Z as angular,ak as autocompletion,aU as bidiIsolates,aS as bracketMatching,_ as clojure,al as closeBrackets,am as closeBracketsKeymap,an as closeCompletion,aT as codeFolding,$ as coffeescript,ao as completeAnyWord,ap as completionStatus,a0 as cpp,a1 as css,af as cssStreamParser,aq as currentCompletions,aw as cursorGroupLeft,ax as cursorGroupRight,av as cursorMatchingBracket,ay as cursorSyntaxLeft,az as cursorSyntaxRight,a2 as dart,bn as drawSelection,aV as ensureSyntaxTree,aW as foldGutter,aX as foldKeymap,b2 as forceParsing,a4 as go,a3 as gss,bo as gutter,bq as gutters,b3 as highlightSelectionMatches,br as highlightSpecialChars,bF as highlightTree,aA as history,aB as historyKeymap,aQ as html,I as ifNotIn,aC as indentLess,aD as indentMore,aZ as indentOnInput,z as indentUnit,bH as indentationMarkers,aE as insertNewlineAndIndent,a5 as java,aR as javascript,y as keymap,a6 as kotlin,a7 as less,bs as lineNumberMarkers,bt as lineNumbers,a8 as markdown,ar as moveCompletionSelection,a9 as php,bv as placeholder,aa as python,aF as redo,aG as redoSelection,bw as repositionTooltips,ab as sass,ac as scala,bx as scrollPastEnd,aI as selectGroupLeft,aJ as selectGroupRight,aH as selectMatchingBracket,b4 as selectNextOccurrence,aK as selectSyntaxLeft,aL as selectSyntaxRight,as as selectedCompletion,at as selectedCompletionIndex,ad as shell,by as showPanel,bz as showTooltip,aM as standardKeymap,au as startCompletion,ae as svelte,b0 as syntaxHighlighting,b1 as syntaxParserRunning,u as syntaxTree,t as tags,aN as toggleComment,bA as tooltips,aO as undo,aP as undoSelection,ag as vue,ah as wast,ai as xml}from"./chunk/codemirror.js";
2
+ //# sourceMappingURL=codemirror.next.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codemirror.next.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ {
2
+ "description": "Package list used when building/upgrading CodeMirror 6",
3
+ "name": "codemirror.next",
4
+ "version": "0.19.0",
5
+ "private": true,
6
+ "dependencies": {
7
+ "@codemirror/autocomplete": "6.18.2",
8
+ "@codemirror/commands": "6.3.0",
9
+ "@codemirror/lang-angular": "0.1.3",
10
+ "@codemirror/lang-cpp": "6.0.2",
11
+ "@codemirror/lang-css": "6.3.0",
12
+ "@codemirror/lang-html": "6.4.10",
13
+ "@codemirror/lang-java": "6.0.1",
14
+ "@codemirror/lang-javascript": "6.2.1",
15
+ "@codemirror/lang-less": "6.0.2",
16
+ "@codemirror/lang-markdown": "6.2.2",
17
+ "@codemirror/lang-php": "6.0.1",
18
+ "@codemirror/lang-python": "6.1.3",
19
+ "@codemirror/lang-sass": "6.0.2",
20
+ "@codemirror/lang-vue": "0.1.3",
21
+ "@codemirror/lang-wast": "6.0.2",
22
+ "@codemirror/lang-xml": "6.0.2",
23
+ "@codemirror/language": "6.10.2",
24
+ "@codemirror/legacy-modes": "6.3.3",
25
+ "@codemirror/lint": "6.4.2",
26
+ "@codemirror/search": "6.5.4",
27
+ "@codemirror/view": "6.23.0",
28
+ "@lezer/common": "1.2.3",
29
+ "@lezer/css": "1.3.0",
30
+ "@lezer/highlight": "1.2.1",
31
+ "@lezer/html": "1.3.10",
32
+ "@lezer/javascript": "1.5.4",
33
+ "@lezer/lr": "1.4.2",
34
+ "@replit/codemirror-indentation-markers": "6.5.0",
35
+ "@replit/codemirror-lang-svelte": "6.0.0",
36
+ "style-mod": "4.1.0"
37
+ },
38
+ "devDependencies": {
39
+ "rollup": "4.50.2",
40
+ "rollup-plugin-dts": "6.1.1",
41
+ "typescript": "5.9.2"
42
+ }
43
+ }
@@ -0,0 +1,6 @@
1
+ npm install
2
+ ../../../node_modules/.bin/tsc -d -t esnext -m esnext --moduleResolution node bundle.ts
3
+ ../../../node_modules/@rollup/wasm-node/dist/bin/rollup -c
4
+ rm -rf node_modules bundle.js bundle.d.ts
5
+ # Because there's a bug in clang causing it to reformat import lists even where formatting is disabled, run it right away
6
+ git cl format --js
@@ -0,0 +1,49 @@
1
+ import {nodeResolve} from '@rollup/plugin-node-resolve';
2
+ import terser from '@rollup/plugin-terser';
3
+ import dts from 'rollup-plugin-dts';
4
+
5
+ export default [{
6
+ input: './bundle.js',
7
+ output: {
8
+ format: 'es',
9
+ dir: '.',
10
+ manualChunks(id) {
11
+ if (/legacy-modes/.test(id)) return 'chunk/legacy';
12
+ },
13
+ chunkFileNames(info) {
14
+ for (let mod of info.moduleIds) {
15
+ const match = /(@codemirror\/|@replit\/codemirror-)(?<name>[\w-]+)/.exec(mod);
16
+ if (match) {
17
+ const {name} = match.groups;
18
+ if (name === 'view') return 'chunk/codemirror.js';
19
+ if (/lang-/.test(name)) return `chunk/${name.slice(5)}.js`;
20
+ if (name === 'legacy-modes') return 'chunk/legacy.js';
21
+ }
22
+ }
23
+ throw new Error('Failed to determine a chunk name for ' + Object.keys(info.modules));
24
+ },
25
+ entryFileNames: 'codemirror.next.js',
26
+ sourcemap: true,
27
+ },
28
+ plugins: [
29
+ nodeResolve(),
30
+ terser()
31
+ ]
32
+ }, {
33
+ input: './bundle.d.ts',
34
+ output: {
35
+ file: './codemirror.next.d.ts',
36
+ format: 'es'
37
+ },
38
+ plugins: [
39
+ dts({respectExternal: true}),
40
+ {
41
+ name: 'delete-trailing-whitespace',
42
+ generateBundle(options, bundle) {
43
+ for (let file of Object.values(bundle)) {
44
+ if (file.code) file.code = file.code.replace(/[ \t]+(\n|$)/g, '$1');
45
+ }
46
+ }
47
+ }
48
+ ]
49
+ }];
@@ -0,0 +1,26 @@
1
+ Copyright 2025 The Chromium Authors
2
+
3
+ Redistribution and use in source and binary forms, with or without modification,
4
+ are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this
7
+ list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ 3. Neither the name of the copyright holder nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software without
15
+ specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,31 @@
1
+ Name: source-map-scopes-codec
2
+ Short Name: source-map-scopes-codec
3
+ URL: https://github.com/ChromeDevTools/source-map-scopes-codec
4
+ Version: 0.3.1
5
+ Revision: a171786509be39fab374b8c8b85063b172065fb1
6
+ License: BSD-3-Clause
7
+ License File: LICENSE
8
+ Security Critical: no
9
+ Shipped: yes
10
+ Update Mechanism: Manual (https://crbug.com/430416494)
11
+
12
+ Description:
13
+ This library hosts a production ready implementation of the source map "Scopes" proposal.
14
+
15
+ To update this package run:
16
+
17
+ ```sh
18
+ npx jsr info @chrome-devtools/source-map-scopes-codec
19
+ ```
20
+
21
+ to retrieve the tarball URL.
22
+
23
+ then (use the URL shown by the above command)
24
+
25
+ ```sh
26
+ rm -rf package
27
+ wget -qO- https://npm.jsr.io/\~/11/@jsr/chrome-devtools__source-map-scopes-codec/0.3.1.tgz | tar xzf -
28
+ ```
29
+
30
+ Modifications:
31
+ Added a BUILD.gn file to package/src as esbuild would place output files otherwise in the wrong location.
@@ -0,0 +1,33 @@
1
+ # How to contribute
2
+
3
+ We'd love to accept your patches and contributions to this project.
4
+
5
+ ## Before you begin
6
+
7
+ ### Sign our Contributor License Agreement
8
+
9
+ Contributions to this project must be accompanied by a
10
+ [Contributor License Agreement](https://cla.developers.google.com/about) (CLA).
11
+ You (or your employer) retain the copyright to your contribution; this simply
12
+ gives us permission to use and redistribute your contributions as part of the
13
+ project.
14
+
15
+ If you or your current employer have already signed the Google CLA (even if it
16
+ was for a different project), you probably don't need to do it again.
17
+
18
+ Visit <https://cla.developers.google.com/> to see your current agreements or to
19
+ sign a new one.
20
+
21
+ ### Review our community guidelines
22
+
23
+ This project follows
24
+ [Google's Open Source Community Guidelines](https://opensource.google/conduct/).
25
+
26
+ ## Contribution process
27
+
28
+ ### Code reviews
29
+
30
+ All submissions, including submissions by project members, require review. We
31
+ use GitHub pull requests for this purpose. Consult
32
+ [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
33
+ information on using pull requests.
@@ -0,0 +1,26 @@
1
+ Copyright 2025 The Chromium Authors
2
+
3
+ Redistribution and use in source and binary forms, with or without modification,
4
+ are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this
7
+ list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ 3. Neither the name of the copyright holder nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software without
15
+ specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,64 @@
1
+ # source-map-scopes-codec [![JSR](https://jsr.io/badges/@chrome-devtools/source-map-scopes-codec)](https://jsr.io/@chrome-devtools/source-map-scopes-codec)
2
+
3
+ This library hosts a production ready implementation of the source map ["Scopes" proposal](https://github.com/tc39/ecma426/blob/main/proposals/scopes.md).
4
+
5
+ The library contains:
6
+ * Type definitions for structured scope information
7
+ * Encode and decode functions that can encode structured scope information into an already existing source map, or decode the structured scope information from a source map.
8
+ * A builder that helps with building the structured scope information.
9
+
10
+ This library doesn't implement mappings encoding/decoding, but it does support encoding the scopes information into an already existing source map with "mappings" and "names".
11
+
12
+ ## Installation
13
+
14
+ With NPM:
15
+
16
+ ```sh
17
+ npx jsr add @chrome-devtools/source-map-scopes-codec
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Using the library is straight-forward:
23
+
24
+ ```js
25
+ import { encode } from "@chrome-devtools/source-map-scopes-codec";
26
+
27
+ const scopeInformation = ...;
28
+ const map = encode(scopeInformation);
29
+
30
+ // Or with a pre-existing source map.
31
+ const map = encode(scopeInformation, preExistingSourceMap);
32
+ ```
33
+
34
+ To decode:
35
+
36
+ ```js
37
+ import { decode } from "@chrome-devtools/source-map-scopes-codec";
38
+
39
+ const scopeInformation = decode(sourceMap);
40
+ ```
41
+
42
+ ### Scope Builder
43
+
44
+ The library also contains a builder that makes creating structured scope information easier:
45
+
46
+ ```js
47
+ import { ScopeInfoBuilder } from "@chrome-devtools/source-map-scopes-codec";
48
+
49
+ const scopeInformation = new ScopeInfoBuilder()
50
+ .startScope(0, 0, { kind: "Global" })
51
+ .startScope(5, 10)
52
+ .setScopeKind("Function") // Same as passing 'kind' to 'startScope'.
53
+ .setScopeName("foo") // Same as passing 'name' to 'startScope'.
54
+ .endScope(10, 5)
55
+ .endScope(11, 1)
56
+ .startRange(0, 0, { scope: 0 })
57
+ .startRange(0, 10)
58
+ .setRangeScopeDefinition(1) // Same as passing 'scope' to 'startRange'.
59
+ .endRange(0, 15)
60
+ .endRange(1, 1)
61
+ .build();
62
+ ```
63
+
64
+ There is also a `SafeScopeInfoBuilder` that checks that scopes and ranges are well nested and some other integrity constraints (e.g. definition scopes are known).
@@ -0,0 +1,62 @@
1
+ import type { Binding, GeneratedRange, OriginalPosition, OriginalScope, ScopeInfo } from "../../../src/scopes.js";
2
+ /**
3
+ * Small utility class to build scope and range trees.
4
+ *
5
+ * This class allows construction of scope/range trees that will be rejected by the encoder.
6
+ * Use this class if you guarantee proper nesting yourself and don't want to pay for the
7
+ * checks, otherwise use the `SafeScopeInfoBuilder`.
8
+ *
9
+ * This class will also silently ignore calls that would fail otherwise. E.g. calling
10
+ * `end*` without a matching `start*`.
11
+ */ export declare class ScopeInfoBuilder {
12
+ addNullScope(): this;
13
+ startScope(line: number, column: number, options?: {
14
+ name?: string;
15
+ kind?: string;
16
+ isStackFrame?: boolean;
17
+ variables?: string[];
18
+ key?: ScopeKey;
19
+ }): this;
20
+ setScopeName(name: string): this;
21
+ setScopeKind(kind: string): this;
22
+ setScopeStackFrame(isStackFrame: boolean): this;
23
+ setScopeVariables(variables: string[]): this;
24
+ endScope(line: number, column: number): this;
25
+ /**
26
+ * @returns The OriginalScope opened with the most recent `startScope` call, but not yet closed.
27
+ */ currentScope(): OriginalScope | null;
28
+ /**
29
+ * @returns The most recent OriginalScope closed with `endScope`.
30
+ */ lastScope(): OriginalScope | null;
31
+ /**
32
+ * @param option The definition 'scope' of this range can either be the "OriginalScope" directly
33
+ * (produced by this builder) or the scope's key set while building the scope.
34
+ */ startRange(line: number, column: number, options?: {
35
+ scope?: OriginalScope;
36
+ scopeKey?: ScopeKey;
37
+ isStackFrame?: boolean;
38
+ isHidden?: boolean;
39
+ values?: Binding[];
40
+ callSite?: OriginalPosition;
41
+ }): this;
42
+ setRangeDefinitionScope(scope: OriginalScope): this;
43
+ setRangeDefinitionScopeKey(scopeKey: ScopeKey): this;
44
+ setRangeStackFrame(isStackFrame: boolean): this;
45
+ setRangeHidden(isHidden: boolean): this;
46
+ setRangeValues(values: Binding[]): this;
47
+ setRangeCallSite(callSite: OriginalPosition): this;
48
+ endRange(line: number, column: number): this;
49
+ build(): ScopeInfo;
50
+ protected get scopeStack(): ReadonlyArray<OriginalScope>;
51
+ protected get rangeStack(): ReadonlyArray<GeneratedRange>;
52
+ protected isKnownScope(scope: OriginalScope): boolean;
53
+ protected isValidScopeKey(key: ScopeKey): boolean;
54
+ protected getScopeByValidKey(key: ScopeKey): OriginalScope;
55
+ }
56
+ /**
57
+ * Users of the {@link ScopeInfoBuilder} can provide their own keys to uniquely identify a scope,
58
+ * and use the key later when building the corresponding range to connect them.
59
+ *
60
+ * The only requirement for ScopeKey is that it can be used as a key in a `Map`.
61
+ */ export type ScopeKey = unknown;
62
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sources":["../../../src/builder/builder.ts"],"names":[],"mappings":"AAIA,cACE,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,SAAS,iCACa;AAExB;;;;;;;;;CASC,GACD,OAAO,cAAM;EAWX,gBAAgB,IAAI;EAKpB,WACE,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd;IACE,OAAO,MAAM;IACb,OAAO,MAAM;IACb,eAAe,OAAO;IACtB,YAAY,MAAM;IAClB,MAAM;GACP,GACA,IAAI;EAsBP,aAAa,MAAM,MAAM,GAAG,IAAI;EAMhC,aAAa,MAAM,MAAM,GAAG,IAAI;EAMhC,mBAAmB,cAAc,OAAO,GAAG,IAAI;EAM/C,kBAAkB,WAAW,MAAM,EAAE,GAAG,IAAI;EAO5C,SAAS,MAAM,MAAM,EAAE,QAAQ,MAAM,GAAG,IAAI;EAgB5C;;GAEC,GACD,gBAAgB,gBAAgB,IAAI;EAIpC;;GAEC,GACD,aAAa,gBAAgB,IAAI;EAIjC;;;GAGC,GACD,WACE,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd;IACE,QAAQ;IACR,WAAW;IACX,eAAe,OAAO;IACtB,WAAW,OAAO;IAClB,SAAS;IACT,WAAW;GACZ,GACA,IAAI;EA6BP,wBAAwB,OAAO,aAAa,GAAG,IAAI;EAMnD,2BAA2B,UAAU,QAAQ,GAAG,IAAI;EAMpD,mBAAmB,cAAc,OAAO,GAAG,IAAI;EAO/C,eAAe,UAAU,OAAO,GAAG,IAAI;EAOvC,eAAe,QAAQ,SAAS,GAAG,IAAI;EAOvC,iBAAiB,UAAU,gBAAgB,GAAG,IAAI;EAOlD,SAAS,MAAM,MAAM,EAAE,QAAQ,MAAM,GAAG,IAAI;EAe5C,SAAS;EAUT,cAAc,cAAc,cAAc;EAI1C,cAAc,cAAc,cAAc;EAI1C,UAAU,aAAa,OAAO,aAAa,GAAG,OAAO;EAIrD,UAAU,gBAAgB,KAAK,QAAQ,GAAG,OAAO;EAIjD,UAAU,mBAAmB,KAAK,QAAQ,GAAG;AAG/C;AAEA;;;;;CAKC,GACD,YAAY,WAAW,OAAO"}
@@ -0,0 +1,37 @@
1
+ import type { Binding, OriginalPosition, OriginalScope, ScopeInfo } from "../../../src/scopes.js";
2
+ import { ScopeInfoBuilder, type ScopeKey } from "./builder.js";
3
+ /**
4
+ * Similar to `ScopeInfoBuilder`, but with checks that scopes/ranges are well
5
+ * nested and don't partially overlap.
6
+ */ export declare class SafeScopeInfoBuilder extends ScopeInfoBuilder {
7
+ override addNullScope(): this;
8
+ override startScope(line: number, column: number, options?: {
9
+ name?: string;
10
+ kind?: string;
11
+ isStackFrame?: boolean;
12
+ variables?: string[];
13
+ key?: ScopeKey;
14
+ }): this;
15
+ override setScopeName(name: string): this;
16
+ override setScopeKind(kind: string): this;
17
+ override setScopeStackFrame(isStackFrame: boolean): this;
18
+ override setScopeVariables(variables: string[]): this;
19
+ override endScope(line: number, column: number): this;
20
+ override startRange(line: number, column: number, options?: {
21
+ scope?: OriginalScope;
22
+ scopeKey?: ScopeKey;
23
+ isStackFrame?: boolean;
24
+ isHidden?: boolean;
25
+ values?: Binding[];
26
+ callSite?: OriginalPosition;
27
+ }): this;
28
+ override setRangeDefinitionScope(scope: OriginalScope): this;
29
+ override setRangeDefinitionScopeKey(scopeKey: ScopeKey): this;
30
+ override setRangeStackFrame(isStackFrame: boolean): this;
31
+ override setRangeHidden(isHidden: boolean): this;
32
+ override setRangeValues(values: Binding[]): this;
33
+ override setRangeCallSite(callSite: OriginalPosition): this;
34
+ override endRange(line: number, column: number): this;
35
+ override build(): ScopeInfo;
36
+ }
37
+ //# sourceMappingURL=safe_builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe_builder.d.ts","sources":["../../../src/builder/safe_builder.ts"],"names":[],"mappings":"AAIA,cACE,OAAO,EACP,gBAAgB,EAChB,aAAa,EAEb,SAAS,iCACa;AAExB,SAAS,gBAAgB,EAAE,KAAK,QAAQ,uBAAuB;AAE/D;;;CAGC,GACD,OAAO,cAAM,6BAA6B;EACxC,SAAS,gBAAgB,IAAI;EAQ7B,SAAS,WACP,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd;IACE,OAAO,MAAM;IACb,OAAO,MAAM;IACb,eAAe,OAAO;IACtB,YAAY,MAAM;IAClB,MAAM;GACP,GACA,IAAI;EA2BP,SAAS,aAAa,MAAM,MAAM,GAAG,IAAI;EAQzC,SAAS,aAAa,MAAM,MAAM,GAAG,IAAI;EAQzC,SAAS,mBAAmB,cAAc,OAAO,GAAG,IAAI;EAQxD,SAAS,kBAAkB,WAAW,MAAM,EAAE,GAAG,IAAI;EAQrD,SAAS,SAAS,MAAM,MAAM,EAAE,QAAQ,MAAM,GAAG,IAAI;EAkBrD,SAAS,WACP,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd;IACE,QAAQ;IACR,WAAW;IACX,eAAe,OAAO;IACtB,WAAW,OAAO;IAClB,SAAS;IACT,WAAW;GACZ,GACA,IAAI;EA6DP,SAAS,wBAAwB,OAAO,aAAa,GAAG,IAAI;EAc5D,SAAS,2BAA2B,UAAU,QAAQ,GAAG,IAAI;EAc7D,SAAS,mBAAmB,cAAc,OAAO,GAAG,IAAI;EAQxD,SAAS,eAAe,UAAU,OAAO,GAAG,IAAI;EAQhD,SAAS,eAAe,QAAQ,SAAS,GAAG,IAAI;EAmBhD,SAAS,iBAAiB,UAAU,gBAAgB,GAAG,IAAI;EAQ3D,SAAS,SAAS,MAAM,MAAM,EAAE,QAAQ,MAAM,GAAG,IAAI;EAmBrD,SAAS,SAAS;AAkFpB"}
@@ -0,0 +1,29 @@
1
+ import type { Position, ScopeInfo, SourceMap } from "../../../src/scopes.js";
2
+ /**
3
+ * The mode decides how well-formed the encoded scopes have to be, to be accepted by the decoder.
4
+ *
5
+ * LAX is the default and is much more lenient. It's still best effort though and the decoder doesn't
6
+ * implement any error recovery: e.g. superfluous "start" items can lead to whole trees being omitted.
7
+ *
8
+ * STRICT mode will throw in the following situations:
9
+ *
10
+ * - Encountering ORIGINAL_SCOPE_END, or GENERATED_RANGE_END items that don't have matching *_START items.
11
+ * - Encountering ORIGINAL_SCOPE_VARIABLES items outside a surrounding scope START/END.
12
+ * - Encountering GENERATED_RANGE_BINDINGS items outside a surrounding range START/END.
13
+ * - Miss-matches between the number of variables in a scope vs the number of value expressions in the ranges.
14
+ * - Out-of-bound indices into the "names" array.
15
+ */ export declare const enum DecodeMode {
16
+ STRICT = 1,
17
+ LAX = 2
18
+ }
19
+ export interface DecodeOptions {
20
+ mode: DecodeMode;
21
+ /**
22
+ * Offsets `start` and `end` of all generated ranges by the specified amount.
23
+ * Intended to be used when decoding sections of index source maps one-by-one.
24
+ *
25
+ * Has no effect when passing a {@link IndexSourceMapJson} directly to {@link decode}.
26
+ */ generatedOffset: Position;
27
+ }
28
+ export declare function decode(sourceMap: SourceMap, options?: Partial<DecodeOptions>): ScopeInfo;
29
+ //# sourceMappingURL=decode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode.d.ts","sources":["../../../src/decode/decode.ts"],"names":[],"mappings":"AAWA,cAIE,QAAQ,EACR,SAAS,EACT,SAAS,iCAGa;AAGxB;;;;;;;;;;;;;CAaC,GACD,0BAAkB;EAChB,SAAS;EACT,MAAM;;AAGR,iBAAiB;EACf,MAAM;EAEN;;;;;GAKC,GACD,iBAAiB;;AAQnB,OAAO,iBAAS,OACd,WAAW,SAAS,EACpB,UAAS,QAAQ,cAAuC,GACvD"}
@@ -0,0 +1,8 @@
1
+ import type { ScopeInfo, SourceMapJson } from "../../../src/scopes.js";
2
+ /**
3
+ * Encodes the `ScopeInfo` into a source map JSON object.
4
+ *
5
+ * If `inputSourceMap` is provided, `encode` will augment the "names" array and
6
+ * overwrite the "scopes" field, before returning the provided `inputSourceMap` again.
7
+ */ export declare function encode(scopesInfo: ScopeInfo, inputSourceMap?: SourceMapJson): SourceMapJson;
8
+ //# sourceMappingURL=encode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode.d.ts","sources":["../../../src/encode/encode.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,EAAE,aAAa,iCAAyB;AAG/D;;;;;CAKC,GACD,OAAO,iBAAS,OACd,YAAY,SAAS,EACrB,iBAAiB,aAAa,GAC7B"}
@@ -0,0 +1,6 @@
1
+ export type { Binding, GeneratedRange, OriginalPosition, OriginalScope, Position, ScopeInfo, SourceMapJson, SubRangeBinding } from "../../src/scopes.js";
2
+ export { encode } from "./encode/encode.js";
3
+ export { decode, DecodeMode } from "./decode/decode.js";
4
+ export { ScopeInfoBuilder } from "./builder/builder.js";
5
+ export { SafeScopeInfoBuilder } from "./builder/safe_builder.js";
6
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../../src/mod.ts"],"names":[],"mappings":"AAIA,cACE,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,SAAS,EACT,aAAa,EACb,eAAe,8BACM;AAEvB,SAAS,MAAM,6BAA6B;AAC5C,SAAS,MAAM,EAAE,UAAU,6BAA6B;AAExD,SAAS,gBAAgB,+BAA+B;AACxD,SAAS,oBAAoB,oCAAoC"}
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@chrome-devtools/source-map-scopes-codec",
3
+ "version": "0.5.0",
4
+ "exports": "./src/mod.ts",
5
+ "license": "BSD-3-Clause",
6
+ "fmt": {
7
+ "exclude": ["README.md", "CONTRIBUTING.md"]
8
+ },
9
+ "publish": {
10
+ "include": [
11
+ "CONTRIBUTING.md",
12
+ "LICENSE",
13
+ "README.md",
14
+ "src/**/*.ts"
15
+ ],
16
+ "exclude": [
17
+ "bench",
18
+ "src/**/*.test.ts"
19
+ ]
20
+ }
21
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@jsr/chrome-devtools__source-map-scopes-codec",
3
+ "version": "0.5.0",
4
+ "homepage": "https://jsr.io/@chrome-devtools/source-map-scopes-codec",
5
+ "type": "module",
6
+ "dependencies": {},
7
+ "exports": {
8
+ ".": {
9
+ "types": "./_dist/src/mod.d.ts",
10
+ "default": "./src/mod.js"
11
+ }
12
+ },
13
+ "_jsr_revision": 11
14
+ }