Skip to content

Commit 3b97fd8

Browse files
szuendDevtools-frontend LUCI CQ
authored andcommitted
[deps] Add 'source-map-scopes-codec' as a shipped library
This CL pulls in the published tarball of the 'source-map-scopes-codec' package. We use the standard 'devtools_module' and 'devtools_entrypoint' to build the library from source. The CL already adds a dependency on the library via `sdk` so we can test building the library. Follow-up CLs will implement the existing scopes decoder with the library. [email protected] Bug: 368222773 Change-Id: I82e27990c01a386bf56fdbc64310d82df3a1016e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6684887 Reviewed-by: Alex Rudenko <[email protected]> Commit-Queue: Simon Zünd <[email protected]>
1 parent 02c4378 commit 3b97fd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3216
-0
lines changed

config/gni/devtools_grd_files.gni

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ grd_files_bundled_sources = [
740740
"front_end/third_party/marked/marked.js",
741741
"front_end/third_party/puppeteer-replay/puppeteer-replay.js",
742742
"front_end/third_party/puppeteer/puppeteer.js",
743+
"front_end/third_party/source-map-scopes-codec/source-map-scopes-codec.js",
743744
"front_end/third_party/third-party-web/third-party-web.js",
744745
"front_end/third_party/wasmparser/wasmparser.js",
745746
"front_end/third_party/web-vitals/web-vitals.js",
@@ -2228,6 +2229,15 @@ grd_files_unbundled_sources = [
22282229
"front_end/third_party/puppeteer/package/lib/esm/third_party/mitt/mitt.js",
22292230
"front_end/third_party/puppeteer/package/lib/esm/third_party/parsel-js/parsel-js.js",
22302231
"front_end/third_party/puppeteer/package/lib/esm/third_party/rxjs/rxjs.js",
2232+
"front_end/third_party/source-map-scopes-codec/package/src/builder/builder.js",
2233+
"front_end/third_party/source-map-scopes-codec/package/src/builder/safe_builder.js",
2234+
"front_end/third_party/source-map-scopes-codec/package/src/codec.js",
2235+
"front_end/third_party/source-map-scopes-codec/package/src/decode/decode.js",
2236+
"front_end/third_party/source-map-scopes-codec/package/src/encode/encode.js",
2237+
"front_end/third_party/source-map-scopes-codec/package/src/encode/encoder.js",
2238+
"front_end/third_party/source-map-scopes-codec/package/src/mod.js",
2239+
"front_end/third_party/source-map-scopes-codec/package/src/util.js",
2240+
"front_end/third_party/source-map-scopes-codec/package/src/vlq.js",
22312241
"front_end/third_party/third-party-web/lib/nostats-subset.js",
22322242
"front_end/third_party/wasmparser/package/dist/esm/WasmDis.js",
22332243
"front_end/third_party/wasmparser/package/dist/esm/WasmParser.js",

front_end/core/sdk/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ devtools_module("sdk") {
103103
"../../generated:protocol",
104104
"../../models/cpu_profile:bundle",
105105
"../../models/text_utils:bundle",
106+
"../../third_party/source-map-scopes-codec:bundle",
106107
]
107108
}
108109

front_end/third_party/additional_readme_paths.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"puppeteer/third_party/parsel",
1818
"puppeteer/third_party/rxjs",
1919
"puppeteer-replay",
20+
"source-map-scopes-codec",
2021
"third-party-web",
2122
"wasmparser",
2223
"web-vitals"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2025 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+
import("../../../scripts/build/ninja/devtools_entrypoint.gni")
6+
7+
devtools_entrypoint("bundle") {
8+
entrypoint = "source-map-scopes-codec.ts"
9+
10+
deps = [ "./package/src:source-map-scopes-codec" ]
11+
12+
visibility = [ "*" ]
13+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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).
65+
66+
## Missing features
67+
68+
The library is currently missing support for encoding/decoding sub-range bindings. It will be added in the next release.

0 commit comments

Comments
 (0)