Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge package:source_maps #1262

Merged
merged 141 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
fa5c3a7
Move source maps package to the dart repo, so it can be used by other…
sigmundch Mar 20, 2013
9098804
lib/utf: remove codepointsToString
kevmoo Apr 9, 2013
5fd76a7
add installation instructions to pkg packages
sethladd Apr 19, 2013
2dc1edc
Fixes source map bug: getLocationMessage was incorrect on file segments
sigmundch Jul 3, 2013
d98bf46
Fixes in sourcemaps discovered in csslib
sigmundch Jul 10, 2013
920ff12
Fix bug in source-maps parsing: parser failed when most information c…
sigmundch Jul 12, 2013
f6c5549
Address hint discovered by dart2js: add hashCode to source_maps.Span
sigmundch Jul 16, 2013
df5c29e
Fix source spans hashcode implementation
sigmundch Jul 26, 2013
889b8ab
Make observable transform a barback transform.
sigmundch Aug 9, 2013
c931507
Fix source maps test (failed in checked mode).
sigmundch Aug 9, 2013
af8c728
Some more removals of dart:utf.
floitschG Aug 27, 2013
35a756b
Remove usage of dart:json.
floitschG Aug 28, 2013
d334494
Remove uses of Options from pkg, samples, tests, and third_party dire…
whesse Oct 30, 2013
5edd73d
add versions and constraints for packages and samples
Nov 6, 2013
20c0ed1
Revert "add versions and constraints for packages and samples"
Nov 6, 2013
7c4320e
Re-land r29957 (add versions and constraints for packages and samples…
dgrove Nov 6, 2013
274cc23
pkg/unittest: added LICENSE
kevmoo Jan 13, 2014
2f2fc20
Support unmapped areas in source maps.
szakarias Apr 23, 2014
4a16d39
Make source map location information more readable.
nex3 May 24, 2014
5c23769
Revert revision 36603
ricowind May 26, 2014
653f024
Make source map location information more readable.
nex3 May 27, 2014
eaf8323
Fix a couple more tests that were relying on sourcemap message format.
nex3 May 28, 2014
b1c2cb2
Add SpanException and SpanFormatException classes to source_maps.
nex3 Jun 19, 2014
36b7da2
Improve the readability of some human-consumed strings in source_maps.
nex3 Jun 20, 2014
23fa7bf
Fix a bug in FixedSpan.getLocationMessage.
nex3 Jun 20, 2014
7ea4039
Add implicit constraints from pub onto stack_trace and source_maps.
nex3 Jun 26, 2014
2cf49c5
Fix markdown in source_maps README.md so it renders correctly in pub …
sigmundch Jun 27, 2014
3fdc736
Moving logic for writing source maps from SourceMapBuilder into the M…
Jul 8, 2014
eb79592
Fix class implementing FormatException getting warnings.
lrhn Jul 14, 2014
74e08e7
Adding support for `sourceRoot` to the SingleMapping class.
Jul 15, 2014
91ea87a
Allow updating the `targetUrl` property of SingleMapping.
Jul 15, 2014
c106380
Rev source_maps patch number, package is now 0.9.3.
Jul 16, 2014
be186a1
Change "FormatException.position" to be named "offset".
lrhn Jul 18, 2014
af4e166
Use the new "offset" name in span.dart too.
lrhn Jul 18, 2014
b3e5fce
Change "FormatException.position" to be named "offset".
lrhn Jul 18, 2014
3928ed9
Change "FormatException.position" to be named "offset".
lrhn Jul 18, 2014
333a0e5
Deprecate the source_maps span classes.
nex3 Jul 23, 2014
96b1161
Remove support for the old Span classes from source_maps.
nex3 Jul 31, 2014
4cb3ede
Actually release source_maps 0.10.0.
nex3 Aug 1, 2014
266d348
Removing unnecessary warning when parsing Json.
Dec 4, 2014
769affb
Add gitignore, status, and codereview files.
nex3 Dec 19, 2014
fceb4f5
Update the pubspec's homepage link.
nex3 Dec 19, 2014
1411247
Fix sourcemap after changes in source_span
sigmundch Mar 28, 2015
96485a8
Add a mapUrl parameter to parse() and parseJson().
nex3 Apr 29, 2015
91d98d8
Upgrade to the new test runner.
nex3 Jul 16, 2015
8ba5f7c
Fix unused import
srawlins Mar 9, 2016
84b496e
Merge pull request dart-lang/source_maps#14 from srawlins/fix-unused-…
nex3 Mar 9, 2016
51e3022
Fix strong-mode warnings.
nex3 Mar 24, 2016
c5a436d
fixes dart-lang/source_maps#16
dam0vm3nt Aug 7, 2016
4e30af0
much better indeed
dam0vm3nt Aug 9, 2016
be39666
Merge pull request dart-lang/source_maps#17 from dam0vm3nt/strong_mod…
sigmundch Oct 13, 2016
d985314
Publish new version of source_maps with extra strong mode fixes
sigmundch Oct 31, 2016
5e3d46e
Support a new source map bundle format useful for the Dart Dev Compil…
jacob314 Dec 8, 2016
c05a686
Improve handling of locations not from the uris the source map is for.
jacob314 Dec 9, 2016
fb162a9
Fix strong mode error in test.
jacob314 Dec 12, 2016
6f9505f
Rev package version as the extended source map format is a new feature.
jacob314 Dec 14, 2016
78b28e9
Enabling adding and querying for source maps in a MappingBundle.
jacob314 Mar 7, 2017
8e233ce
Remove unused dependency on the path package.
jacob314 Mar 7, 2017
27f0d29
implement highlight for SourceMapFileSpan
jakemac53 Mar 23, 2017
06dea5e
update pubspec/changelog for 0.10.4
jakemac53 Mar 23, 2017
162b1a9
Fix analyzer warnings in parser_test.dart
davidmorgan Dec 12, 2017
dffd5c3
Update following review comments
davidmorgan Dec 12, 2017
1addd86
Merge pull request dart-lang/source_maps#25 from dart-lang/davidmorga…
davidmorgan Dec 12, 2017
14631cd
Enable Travis, rename analysis_options, update .gitignore
kevmoo Mar 11, 2018
83a6826
dartfmt
kevmoo Mar 11, 2018
70c30cd
Add support for the sourcesContent field (dart-lang/source_maps#28)
nex3 Apr 25, 2018
fbf2d23
Remove upper case constants (dart-lang/source_maps#27)
lrhn May 25, 2018
6245184
Prepare to publish 0.10.6 (dart-lang/source_maps#29)
sigmundch Jun 26, 2018
e3efcb3
chore: set max SDK version to <3.0.0 (dart-lang/source_maps#30)
chalin Jul 17, 2018
1c0a984
Preserve source-map extensions in SingleMapping (dart-lang/source_map…
sigmundch Sep 27, 2018
45587fe
Support dart-lang/source_spandart-lang/source_maps#25 (dart-lang/sour…
nex3 Jan 17, 2019
fc558d2
Support the latest source_span (dart-lang/source_maps#34)
nex3 Feb 16, 2019
ce9aa9d
Delete analysis_options.yaml
kevmoo Apr 12, 2019
86871c2
Delete codereview.settings
kevmoo Apr 12, 2019
cb144c7
Run dartfmt --fix (dart-lang/source_maps#35)
natebosch Dec 10, 2019
d92d0de
Migrate for deprecations from other packages (dart-lang/source_maps#36)
natebosch Dec 10, 2019
949aaed
Enforce and fix package:pedantic lints (dart-lang/source_maps#37)
natebosch Dec 12, 2019
303dd9f
Fix a number of doc comments
kevmoo Jan 22, 2020
27129d3
Drop author from pubspec (dart-lang/source_maps#39)
natebosch Jan 22, 2020
1731738
Handle null names field when parsing source map files (dart-lang/sour…
todbachman-wf Feb 11, 2020
87e2ef4
Fix homepage URL (dart-lang/source_maps#43)
kevmoo Feb 11, 2020
e03b48d
Remove an unnecessary test expectation (dart-lang/source_maps#42)
natebosch Feb 11, 2020
9bf6529
Prepare to publish (dart-lang/source_maps#41)
natebosch Feb 11, 2020
6dc79a7
Correct markdown in library dartdoc
srawlins May 30, 2020
8334a9f
Merge the null_safety branch into master (dart-lang/source_maps#49)
jakemac53 Jul 14, 2020
ead4b89
update for the 2.10 dev sdk (dart-lang/source_maps#50)
jakemac53 Jul 22, 2020
471c213
add back coverage override to fix travis (dart-lang/source_maps#51)
jakemac53 Jul 22, 2020
82232f3
Update travis-ci: test on dev (dart-lang/source_maps#52)
kevmoo Jul 28, 2020
1fb0604
Delete .test_config
kevmoo Jul 29, 2020
2ef6558
change version to be non-breaking (dart-lang/source_maps#53)
jakemac53 Jul 29, 2020
dce5cbe
version should be 0.10.10-nullsafety (dart-lang/source_maps#54)
jakemac53 Jul 29, 2020
618612d
Prepare for the 2.11 dev SDKs (dart-lang/source_maps#55)
natebosch Sep 22, 2020
8ad7c52
allow the 2.12 prerelease sdks (dart-lang/source_maps#56)
jakemac53 Oct 23, 2020
7cf6875
Bump SDK constraints for pub (dart-lang/source_maps#57)
natebosch Nov 3, 2020
21b831d
remove redundant experiment
pq Nov 11, 2020
cc4a14b
Merge pull request dart-lang/source_maps#58 from dart-lang/pq-patch-1
pq Nov 11, 2020
4576b85
Migrate to GitHub Actions (dart-lang/source_maps#60)
athomas Jan 20, 2021
e13c6af
Prepare to publish for stable null safety (dart-lang/source_maps#61)
natebosch Feb 3, 2021
1020d5a
fix latest lints (dart-lang/source_maps#62)
kevmoo Mar 11, 2021
8f45e2e
Update LICENSE
franklinyow Mar 30, 2021
4d29341
Merge pull request dart-lang/source_maps#63 from dart-lang/franklinyo…
franklinyow Mar 30, 2021
a4e89f0
update ci (dart-lang/source_maps#64)
kevmoo Apr 26, 2021
5bb1de7
Migrate to pkg:lints, fix related lints, cleanup in pubspec (dart-lan…
kevmoo Oct 4, 2021
bc7c7d0
Merge pull request dart-lang/source_maps#45 from dart-lang/srawlins-p…
devoncarew May 3, 2022
a0fdffc
populate the pubspec repository field
devoncarew May 3, 2022
a36e9ef
Merge pull request dart-lang/source_maps#66 from dart-lang/repository…
devoncarew May 3, 2022
35655f4
update ci; prep for publishing (dart-lang/source_maps#67)
devoncarew Oct 18, 2022
5125706
adjust the min sdk we test against (dart-lang/source_maps#68)
devoncarew Oct 18, 2022
3488a00
Update README.md (dart-lang/source_maps#69)
devoncarew Oct 19, 2022
0316157
Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/source_maps#70)
dependabot[bot] Jan 3, 2023
9fa02d2
Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/source_maps#71)
dependabot[bot] Feb 1, 2023
8ed4c0f
Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/source_maps#72)
dependabot[bot] Feb 1, 2023
82382c6
tighten up analysis; add types at the api boundaries (dart-lang/sourc…
devoncarew Feb 7, 2023
6555abe
configure publishing automation (dart-lang/source_maps#74)
devoncarew Feb 17, 2023
cb538c1
Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/source_maps#75)
dependabot[bot] Apr 3, 2023
d6d52d6
Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/source_maps#76)
dependabot[bot] Apr 3, 2023
b7769f1
Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/source_maps#77)
dependabot[bot] May 1, 2023
cee7105
blast_repo fixes (dart-lang/source_maps#78)
devoncarew May 23, 2023
a9e43f0
Require Dart 3, update lints (dart-lang/source_maps#79)
kevmoo Jun 12, 2023
79f9b55
Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/source_maps#80)
dependabot[bot] Jul 1, 2023
cc7051e
Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/source_maps#81)
dependabot[bot] Sep 1, 2023
48bbfc3
Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/source_maps#82)
dependabot[bot] Oct 1, 2023
475b676
Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/source_maps#83)
dependabot[bot] Oct 2, 2023
4235259
Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/source_maps#85)
dependabot[bot] Nov 1, 2023
07d3240
Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/source_maps#84)
dependabot[bot] Nov 1, 2023
07f93de
Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (dart-lang/source_maps#86)
dependabot[bot] Feb 1, 2024
d8dfdf3
Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/source_maps#87)
dependabot[bot] Apr 1, 2024
c1e39ed
Bump lints, require Dart 3.3 (dart-lang/source_maps#88)
kevmoo Apr 9, 2024
e7f1750
blast_repo fixes (dart-lang/source_maps#89)
kevmoo Apr 9, 2024
802e91d
Bump dart-lang/setup-dart from 1.6.3 to 1.6.4 (dart-lang/source_maps#90)
dependabot[bot] May 1, 2024
ea65ec8
Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/source_maps#91)
dependabot[bot] May 1, 2024
34ed8f1
blast_repo fixes (dart-lang/source_maps#92)
devoncarew May 13, 2024
9e7493f
Bump actions/checkout from 4.1.4 to 4.1.5 in the github-actions group…
dependabot[bot] May 13, 2024
e3e471c
Bump actions/checkout from 4.1.5 to 4.1.6 in the github-actions group…
dependabot[bot] Jun 1, 2024
d904e93
Bump the github-actions group with 2 updates (dart-lang/source_maps#95)
dependabot[bot] Jul 1, 2024
3e0f946
Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group…
dependabot[bot] Oct 1, 2024
2f6ae72
Bump actions/checkout from 4.2.0 to 4.2.2 in the github-actions group…
dependabot[bot] Nov 1, 2024
217ca18
Bump dart-lang/setup-dart in the github-actions group (dart-lang/sour…
dependabot[bot] Dec 1, 2024
c81f252
Merge package:source_maps into the tools monorepo
mosuem Dec 10, 2024
3453d0e
Add issue template and other fixes
mosuem Dec 10, 2024
e9fad4a
merge fixes
mosuem Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/source_maps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:source_maps"
about: "Create a bug or file a feature request against package:source_maps."
labels: "package:source_maps"
---
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
- changed-files:
- any-glob-to-any-file: 'pkgs/source_map_stack_trace/**'

'package:source_maps':
- changed-files:
- any-glob-to-any-file: 'pkgs/source_maps/**'

'package:unified_analytics':
- changed-files:
- any-glob-to-any-file: 'pkgs/unified_analytics/**'
72 changes: 72 additions & 0 deletions .github/workflows/source_maps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: package:source_maps

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
paths:
- '.github/workflows/source_maps.yaml'
- 'pkgs/source_maps/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/source_maps.yaml'
- 'pkgs/source_maps/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github


defaults:
run:
working-directory: pkgs/source_maps/

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

# Run tests on a matrix consisting of two dimensions:
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
# 2. release channel: dev
test:
needs: analyze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.3.0, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Run VM tests
run: dart test --platform vm
if: always() && steps.install.outcome == 'success'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ don't naturally belong to other topic monorepos (like
| [mime](pkgs/mime/) | Utilities for handling media (MIME) types, including determining a type from a file extension and file contents. | [![package issues](https://img.shields.io/badge/package:mime-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Amime) | [![pub package](https://img.shields.io/pub/v/mime.svg)](https://pub.dev/packages/mime) |
| [oauth2](pkgs/oauth2/) | A client library for authenticating with a remote service via OAuth2 on behalf of a user, and making authorized HTTP requests with the user's OAuth2 credentials. | [![package issues](https://img.shields.io/badge/package:oauth2-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aoauth2) | [![pub package](https://img.shields.io/pub/v/oauth2.svg)](https://pub.dev/packages/oauth2) |
| [source_map_stack_trace](pkgs/source_map_stack_trace/) | A package for applying source maps to stack traces. | [![package issues](https://img.shields.io/badge/package:source_map_stack_trace-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_map_stack_trace) | [![pub package](https://img.shields.io/pub/v/source_map_stack_trace.svg)](https://pub.dev/packages/source_map_stack_trace) |
| [source_maps](pkgs/source_maps/) | A library to programmatically manipulate source map files. | [![package issues](https://img.shields.io/badge/package:source_maps-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_maps) | [![pub package](https://img.shields.io/pub/v/source_maps.svg)](https://pub.dev/packages/source_maps) |
| [unified_analytics](pkgs/unified_analytics/) | A package for logging analytics for all Dart and Flutter related tooling to Google Analytics. | [![package issues](https://img.shields.io/badge/package:unified_analytics-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aunified_analytics) | [![pub package](https://img.shields.io/pub/v/unified_analytics.svg)](https://pub.dev/packages/unified_analytics) |

## Publishing automation
Expand Down
4 changes: 4 additions & 0 deletions pkgs/source_maps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.dart_tool/
.packages
.pub/
pubspec.lock
131 changes: 131 additions & 0 deletions pkgs/source_maps/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
## 0.10.13

* Require Dart 3.3
* Move to `dart-lang/tools` monorepo.

## 0.10.12

* Add additional types at API boundaries.

## 0.10.11

* Populate the pubspec `repository` field.
* Update the source map documentation link in the readme.

## 0.10.10

* Stable release for null safety.

## 0.10.9

* Fix a number of document comment issues.
* Allow parsing source map files with a missing `names` field.

## 0.10.8

* Preserve source-map extensions in `SingleMapping`. Extensions are keys in the
json map that start with `"x_"`.

## 0.10.7

* Set max SDK version to `<3.0.0`, and adjust other dependencies.

## 0.10.6

* Require version 2.0.0 of the Dart SDK.

## 0.10.5

* Add a `SingleMapping.files` field which provides access to `SourceFile`s
representing the `"sourcesContent"` fields in the source map.

* Add an `includeSourceContents` flag to `SingleMapping.toJson()` which
indicates whether to include source file contents in the source map.

## 0.10.4
* Implement `highlight` in `SourceMapFileSpan`.
* Require version `^1.3.0` of `source_span`.

## 0.10.3
* Add `addMapping` and `containsMapping` members to `MappingBundle`.

## 0.10.2
* Support for extended source map format.
* Polish `MappingBundle.spanFor` handling of URIs that have a suffix that
exactly match a source map in the MappingBundle.

## 0.10.1+5
* Fix strong mode warning in test.

## 0.10.1+4

* Extend `MappingBundle.spanFor` to accept requests for output files that
don't have source maps.

## 0.10.1+3

* Add `MappingBundle` class that handles extended source map format that
supports source maps for multiple output files in a single mapper.
Extend `Mapping.spanFor` API to accept a uri parameter that is optional
for normal source maps but required for MappingBundle source maps.

## 0.10.1+2

* Fix more strong mode warnings.

## 0.10.1+1

* Fix all strong mode warnings.

## 0.10.1

* Add a `mapUrl` named argument to `parse` and `parseJson`. This argument is
used to resolve source URLs for source spans.

## 0.10.0+2

* Fix analyzer error (FileSpan has a new field since `source_span` 1.1.1)

## 0.10.0+1

* Remove an unnecessary warning printed when the "file" field is missing from a
Json formatted source map. This field is optional and its absence is not
unusual.

## 0.10.0

* Remove the `Span`, `Location` and `SourceFile` classes. Use the
corresponding `source_span` classes instead.

## 0.9.4

* Update `SpanFormatException` with `source` and `offset`.

* All methods that take `Span`s, `Location`s, and `SourceFile`s as inputs now
also accept the corresponding `source_span` classes as well. Using the old
classes is now deprecated and will be unsupported in version 0.10.0.

## 0.9.3

* Support writing SingleMapping objects to source map version 3 format.
* Support the `sourceRoot` field in the SingleMapping class.
* Support updating the `targetUrl` field in the SingleMapping class.

## 0.9.2+2

* Fix a bug in `FixedSpan.getLocationMessage`.

## 0.9.2+1

* Minor readability improvements to `FixedSpan.getLocationMessage` and
`SpanException.toString`.

## 0.9.2

* Add `SpanException` and `SpanFormatException` classes.

## 0.9.1

* Support unmapped areas in source maps.

* Increase the readability of location messages.
27 changes: 27 additions & 0 deletions pkgs/source_maps/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2014, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 changes: 25 additions & 0 deletions pkgs/source_maps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[![Build Status](https://github.com/dart-lang/tools/actions/workflows/source_maps.yaml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/source_maps.yaml)
[![pub package](https://img.shields.io/pub/v/source_maps.svg)](https://pub.dev/packages/source_maps)
[![package publisher](https://img.shields.io/pub/publisher/source_maps.svg)](https://pub.dev/packages/source_maps/publisher)

This project implements a Dart pub package to work with source maps.

## Docs and usage

The implementation is based on the [source map version 3 spec][spec] which was
originated from the [Closure Compiler][closure] and has been implemented in
Chrome and Firefox.

In this package we provide:

* Data types defining file locations and spans: these are not part of the
original source map specification. These data types are great for tracking
source locations on source maps, but they can also be used by tools to
reporting useful error messages that include on source locations.
* A builder that creates a source map programmatically and produces the encoded
source map format.
* A parser that reads the source map format and provides APIs to read the
mapping information.

[closure]: https://github.com/google/closure-compiler/wiki/Source-Maps
[spec]: https://docs.google.com/a/google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
1 change: 1 addition & 0 deletions pkgs/source_maps/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:dart_flutter_team_lints/analysis_options.yaml
84 changes: 84 additions & 0 deletions pkgs/source_maps/lib/builder.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// Contains a builder object useful for creating source maps programatically.
library source_maps.builder;

// TODO(sigmund): add a builder for multi-section mappings.

import 'dart:convert';

import 'package:source_span/source_span.dart';

import 'parser.dart';
import 'src/source_map_span.dart';

/// Builds a source map given a set of mappings.
class SourceMapBuilder {
final List<Entry> _entries = <Entry>[];

/// Adds an entry mapping the [targetOffset] to [source].
void addFromOffset(SourceLocation source, SourceFile targetFile,
int targetOffset, String identifier) {
ArgumentError.checkNotNull(targetFile, 'targetFile');
_entries.add(Entry(source, targetFile.location(targetOffset), identifier));
}

/// Adds an entry mapping [target] to [source].
///
/// If [isIdentifier] is true or if [target] is a [SourceMapSpan] with
/// `isIdentifier` set to true, this entry is considered to represent an
/// identifier whose value will be stored in the source map. [isIdentifier]
/// takes precedence over [target]'s `isIdentifier` value.
void addSpan(SourceSpan source, SourceSpan target, {bool? isIdentifier}) {
isIdentifier ??= source is SourceMapSpan ? source.isIdentifier : false;

var name = isIdentifier ? source.text : null;
_entries.add(Entry(source.start, target.start, name));
}

/// Adds an entry mapping [target] to [source].
void addLocation(
SourceLocation source, SourceLocation target, String? identifier) {
_entries.add(Entry(source, target, identifier));
}

/// Encodes all mappings added to this builder as a json map.
Map<String, dynamic> build(String fileUrl) {
return SingleMapping.fromEntries(_entries, fileUrl).toJson();
}

/// Encodes all mappings added to this builder as a json string.
String toJson(String fileUrl) => jsonEncode(build(fileUrl));
}

/// An entry in the source map builder.
class Entry implements Comparable<Entry> {
/// Span denoting the original location in the input source file
final SourceLocation source;

/// Span indicating the corresponding location in the target file.
final SourceLocation target;

/// An identifier name, when this location is the start of an identifier.
final String? identifierName;

/// Creates a new [Entry] mapping [target] to [source].
Entry(this.source, this.target, this.identifierName);

/// Implements [Comparable] to ensure that entries are ordered by their
/// location in the target file. We sort primarily by the target offset
/// because source map files are encoded by printing each mapping in order as
/// they appear in the target file.
@override
int compareTo(Entry other) {
var res = target.compareTo(other.target);
if (res != 0) return res;
res = source.sourceUrl
.toString()
.compareTo(other.source.sourceUrl.toString());
if (res != 0) return res;
return source.compareTo(other.source);
}
}
Loading
Loading