{"id":28573807,"url":"https://github.com/chromedevtools/source-map-scopes-codec","last_synced_at":"2025-06-10T21:19:56.725Z","repository":{"id":284490895,"uuid":"947909525","full_name":"ChromeDevTools/source-map-scopes-codec","owner":"ChromeDevTools","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-23T12:27:38.000Z","size":11543,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T13:49:03.288Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChromeDevTools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-13T12:47:25.000Z","updated_at":"2025-04-23T12:27:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"2585b311-6848-45a5-ba67-310a3f6ac0e6","html_url":"https://github.com/ChromeDevTools/source-map-scopes-codec","commit_stats":null,"previous_names":["chromedevtools/source-map-scopes-codec"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChromeDevTools%2Fsource-map-scopes-codec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChromeDevTools%2Fsource-map-scopes-codec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChromeDevTools%2Fsource-map-scopes-codec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChromeDevTools%2Fsource-map-scopes-codec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChromeDevTools","download_url":"https://codeload.github.com/ChromeDevTools/source-map-scopes-codec/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChromeDevTools%2Fsource-map-scopes-codec/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259152886,"owners_count":22813239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-10T21:19:26.311Z","updated_at":"2025-06-10T21:19:56.703Z","avatar_url":"https://github.com/ChromeDevTools.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# source-map-scopes-codec [![JSR](https://jsr.io/badges/@chrome-devtools/source-map-scopes-codec)](https://jsr.io/@chrome-devtools/source-map-scopes-codec)\n\nThis library hosts a production ready implementation of the source map [\"Scopes\" proposal](https://github.com/tc39/ecma426/blob/main/proposals/scopes.md).\n\nThe library contains:\n  * Type definitions for structured scope information\n  * 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.\n  * A builder that helps with building the structured scope information.\n\nThis 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\".\n\n## Installation\n\nWith NPM:\n\n```sh\nnpx jsr add @chrome-devtools/source-map-scopes-codec\n```\n\n## Usage\n\nUsing the library is straight-forward:\n\n```js\nimport { encode } from \"@chrome-devtools/source-map-scopes-codec\";\n\nconst scopeInformation = ...;\nconst map = encode(scopeInformation);\n\n// Or with a pre-existing source map.\nconst map = encode(scopeInformation, preExistingSourceMap);\n```\n\nTo decode:\n\n```js\nimport { decode } from \"@chrome-devtools/source-map-scopes-codec\";\n\nconst scopeInformation = decode(sourceMap);\n```\n\n### Scope Builder\n\nThe library also contains a builder that makes creating structured scope information easier:\n\n```js\nimport { ScopeInfoBuilder } from \"@chrome-devtools/source-map-scopes-codec\";\n\nconst scopeInformation = new ScopeInfoBuilder()\n    .startScope(0, 0, { kind: \"Global\" })\n        .startScope(5, 10)\n        .setScopeKind(\"Function\")      // Same as passing 'kind' to 'startScope'.\n        .setScopeName(\"foo\")           // Same as passing 'name' to 'startScope'.\n        .endScope(10, 5)\n    .endScope(11, 1)\n    .startRange(0, 0, { scope: 0 })\n        .startRange(0, 10)\n        .setRangeScopeDefinition(1)    // Same as passing 'scope' to 'startRange'.\n        .endRange(0, 15)\n    .endRange(1, 1)\n    .build();\n```\n\nThere is also a `SafeScopeInfoBuilder` that checks that scopes and ranges are well nested and some other integrity constraints (e.g. definition scopes are known).\n\n## Missing features\n\nThe library is currently missing support for encoding/decoding sub-range bindings. It will be added in the next release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchromedevtools%2Fsource-map-scopes-codec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchromedevtools%2Fsource-map-scopes-codec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchromedevtools%2Fsource-map-scopes-codec/lists"}