Skip to content

Commit 7964259

Browse files
committed
Add README.md, CONTRIBUTING.md and export builders
1 parent f91705b commit 7964259

File tree

5 files changed

+94
-2
lines changed

5 files changed

+94
-2
lines changed

CONTRIBUTING.md

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.

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# 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+
TODO: Fill in once this package is published on JSR (and maybe NPM).
15+
16+
## Usage
17+
18+
Using the library is straight-forward:
19+
20+
```js
21+
import { encode } from "@chrome-devtools/source-map-scopes-codec";
22+
23+
const scopeInformation = ...;
24+
const map = encode(scopeInformation);
25+
26+
// Or with a pre-existing source map.
27+
const map = encode(scopeInformation, preExistingSourceMap);
28+
```
29+
30+
To decode:
31+
32+
```js
33+
import { decode } from "@chrome-devtools/source-map-scopes-codec";
34+
35+
const scopeInformation = decode(sourceMap);
36+
```
37+
38+
The library also contains a builder that makes creating structured scope information easier:
39+
40+
```js
41+
import { ScopeInfoBuilder } from "@chrome-devtools/source-map-scopes-codec";
42+
43+
const scopeInformation = new ScopeInfoBuilder()
44+
.addScope(0, 0, { kind: "Global" })
45+
.addScope(5, 10)
46+
.setScopeKind("Function") // Same as passing 'kind' to 'addScope'.
47+
.setScopeName("foo") // Same as passing 'name' to 'addScope'.
48+
.endScope(10, 5)
49+
.endScope(11, 1)
50+
.addRange(0, 0, { scope: 0 })
51+
.addRange(0, 10)
52+
.setRangeScopeDefinition(1) // Same as passing 'scope' to 'addRange'.
53+
.endRange(0, 15)
54+
.endRange(1, 1)
55+
.build();
56+
```

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@chrome-devtools/source-map-scopes-codec",
3-
"version": "1.0.0",
3+
"version": "0.1.0",
44
"exports": "./mod.ts",
55
"license": "BSD-3-Clause"
66
}

mod.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ export type {
1414

1515
export { encode } from "./src/encode/encode.ts";
1616
export { decode } from "./src/decode/decode.ts";
17+
18+
export { ScopeInfoBuilder } from "./src/builder/builder.ts";
19+
export { SafeScopeInfoBuilder } from "./src/builder/safe_builder.ts";

src/builder/safe_builder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import { beforeEach, describe, it } from "jsr:@std/testing/bdd";
66
import { SafeScopeInfoBuilder } from "./safe_builder.ts";
7-
import { assert, assertThrows } from "jsr:@std/assert";
7+
import { assertThrows } from "jsr:@std/assert";
88

99
describe("SafeScopeInfoBuilder", () => {
1010
let builder: SafeScopeInfoBuilder;

0 commit comments

Comments
 (0)