@diffci.com/diffci 0.3.64 → 0.3.66
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.
- package/dist-client/src/client/isolated-worktree.d.ts +16 -0
- package/dist-client/src/client/isolated-worktree.js +67 -1
- package/dist-client/src/client/mcp.js +14 -0
- package/dist-client/src/client/telemetry.d.ts +1 -1
- package/dist-client/src/client/telemetry.js +2 -1
- package/dist-client/src/client/usage-signal.d.ts +10 -2
- package/dist-client/src/client/usage-signal.js +11 -0
- package/node_modules/@babel/helper-string-parser/lib/index.js +15 -6
- package/node_modules/@babel/helper-string-parser/lib/index.js.map +1 -1
- package/node_modules/@babel/helper-string-parser/package.json +1 -1
- package/node_modules/@babel/parser/lib/index.js +326 -93
- package/node_modules/@babel/parser/lib/index.js.map +1 -1
- package/node_modules/@babel/parser/package.json +3 -3
- package/node_modules/@babel/parser/typings/babel-parser.d.ts +23 -25
- package/node_modules/@babel/types/lib/ast-types/generated/index.js.map +1 -1
- package/node_modules/@babel/types/lib/clone/cloneNode.js.map +1 -1
- package/node_modules/@babel/types/lib/definitions/core.js +4 -0
- package/node_modules/@babel/types/lib/definitions/core.js.map +1 -1
- package/node_modules/@babel/types/lib/index-legacy.d.ts +1 -0
- package/node_modules/@babel/types/lib/index.d.ts +5 -5
- package/node_modules/@babel/types/lib/index.js.flow +1 -0
- package/node_modules/@babel/types/lib/validators/is.js.map +1 -1
- package/node_modules/@babel/types/lib/validators/isSpecifierDefault.js +5 -1
- package/node_modules/@babel/types/lib/validators/isSpecifierDefault.js.map +1 -1
- package/node_modules/@babel/types/package.json +4 -4
- package/node_modules/@diffci.com/core/README.md +1 -1
- package/node_modules/@diffci.com/core/dist/git/git-diff.js +7 -4
- package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/types.d.ts +4 -0
- package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js +16 -10
- package/node_modules/@diffci.com/core/dist/repo/adapters/maven.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/graph.js +8 -3
- package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.js +4 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/npm-lockfile.d.ts +11 -0
- package/node_modules/@diffci.com/core/dist/repo/npm-lockfile.js +45 -0
- package/node_modules/@diffci.com/core/dist/repo/npm-lockfile.js.map +1 -1
- package/node_modules/@diffci.com/core/package.json +1 -1
- package/node_modules/@diffci.com/core/src/git/git-diff.ts +6 -4
- package/node_modules/@diffci.com/core/src/git/types.ts +4 -0
- package/node_modules/@diffci.com/core/src/repo/adapters/maven.ts +16 -9
- package/node_modules/@diffci.com/core/src/repo/graph.ts +8 -3
- package/node_modules/@diffci.com/core/src/repo/impact.ts +4 -1
- package/node_modules/@diffci.com/core/src/repo/npm-lockfile.ts +39 -0
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +115 -71
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +2 -2
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +115 -71
- package/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js.map +2 -2
- package/node_modules/@jridgewell/sourcemap-codec/package.json +2 -1
- package/node_modules/@jridgewell/sourcemap-codec/src/range-mappings.ts +47 -0
- package/node_modules/@jridgewell/sourcemap-codec/src/scopes.ts +66 -46
- package/node_modules/@jridgewell/sourcemap-codec/src/sourcemap-codec.ts +27 -11
- package/node_modules/@jridgewell/sourcemap-codec/src/vlq.ts +13 -17
- package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.cts +5 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.cts.map +1 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.mts +5 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/range-mappings.d.mts.map +1 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.cts.map +1 -1
- package/node_modules/@jridgewell/sourcemap-codec/types/scopes.d.mts.map +1 -1
- package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts +2 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.cts.map +1 -1
- package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts +2 -0
- package/node_modules/@jridgewell/sourcemap-codec/types/sourcemap-codec.d.mts.map +1 -1
- package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts +4 -2
- package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.cts.map +1 -1
- package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts +4 -2
- package/node_modules/@jridgewell/sourcemap-codec/types/vlq.d.mts.map +1 -1
- package/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js +6 -2
- package/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6 -2
- package/node_modules/@vue/compiler-core/dist/compiler-core.esm-bundler.js +6 -2
- package/node_modules/@vue/compiler-core/package.json +4 -4
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js +8 -8
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +8 -8
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +14 -14
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +2 -2
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +1 -1
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.global.js +14 -14
- package/node_modules/@vue/compiler-dom/dist/compiler-dom.global.prod.js +2 -2
- package/node_modules/@vue/compiler-dom/package.json +3 -3
- package/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +1847 -1370
- package/node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +6462 -6187
- package/node_modules/@vue/compiler-sfc/package.json +11 -11
- package/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +32 -9
- package/node_modules/@vue/compiler-ssr/package.json +3 -3
- package/node_modules/@vue/shared/dist/shared.cjs.js +11 -15
- package/node_modules/@vue/shared/dist/shared.cjs.prod.js +11 -15
- package/node_modules/@vue/shared/dist/shared.esm-bundler.js +11 -15
- package/node_modules/@vue/shared/package.json +1 -1
- package/node_modules/postcss/lib/css-syntax-error.js +6 -4
- package/node_modules/postcss/lib/declaration.d.ts +2 -2
- package/node_modules/postcss/lib/map-generator.js +12 -2
- package/node_modules/postcss/lib/processor.js +1 -1
- package/node_modules/postcss/lib/tokenize.js +6 -13
- package/node_modules/postcss/package.json +1 -1
- package/node_modules/source-map-js/README.md +192 -176
- package/node_modules/source-map-js/lib/array-set.js +5 -3
- package/node_modules/source-map-js/lib/base64-vlq.js +5 -9
- package/node_modules/source-map-js/lib/base64.js +13 -12
- package/node_modules/source-map-js/lib/binary-search.js +10 -6
- package/node_modules/source-map-js/lib/mapping-list.js +12 -7
- package/node_modules/source-map-js/lib/quick-sort.js +93 -23
- package/node_modules/source-map-js/lib/source-map-consumer.js +272 -194
- package/node_modules/source-map-js/lib/source-map-generator.js +146 -106
- package/node_modules/source-map-js/lib/source-node.js +144 -118
- package/node_modules/source-map-js/lib/util.js +56 -37
- package/node_modules/source-map-js/package.json +14 -7
- package/node_modules/source-map-js/source-map.d.ts +177 -63
- package/node_modules/source-map-js/source-map.js +4 -2
- package/package.json +3 -3
|
@@ -18,7 +18,7 @@ More important that WASM version has some optimizations in JS code too. This is
|
|
|
18
18
|
|
|
19
19
|
I decided to fork the original source-map and port these optimizations from the article and several others PR from the original source-map.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
---
|
|
22
22
|
|
|
23
23
|
This is a library to generate and consume the source map format
|
|
24
24
|
[described here][format].
|
|
@@ -33,12 +33,13 @@ This is a library to generate and consume the source map format
|
|
|
33
33
|
|
|
34
34
|
<script src="https://raw.githubusercontent.com/mozilla/source-map/master/dist/source-map.min.js" defer></script> -->
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
---
|
|
37
37
|
|
|
38
38
|
<!-- `npm run toc` to regenerate the Table of Contents -->
|
|
39
39
|
|
|
40
40
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
41
41
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
42
|
+
|
|
42
43
|
## Table of Contents
|
|
43
44
|
|
|
44
45
|
- [Examples](#examples)
|
|
@@ -58,7 +59,7 @@ This is a library to generate and consume the source map format
|
|
|
58
59
|
- [SourceMapConsumer.prototype.eachMapping(callback, context, order)](#sourcemapconsumerprototypeeachmappingcallback-context-order)
|
|
59
60
|
- [SourceMapGenerator](#sourcemapgenerator)
|
|
60
61
|
- [new SourceMapGenerator([startOfSourceMap])](#new-sourcemapgeneratorstartofsourcemap)
|
|
61
|
-
- [SourceMapGenerator.fromSourceMap(sourceMapConsumer)](#sourcemapgeneratorfromsourcemapsourcemapconsumer)
|
|
62
|
+
- [SourceMapGenerator.fromSourceMap(sourceMapConsumer, sourceMapGeneratorOptions)](#sourcemapgeneratorfromsourcemapsourcemapconsumer-sourcemapgeneratoroptions)
|
|
62
63
|
- [SourceMapGenerator.prototype.addMapping(mapping)](#sourcemapgeneratorprototypeaddmappingmapping)
|
|
63
64
|
- [SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)](#sourcemapgeneratorprototypesetsourcecontentsourcefile-sourcecontent)
|
|
64
65
|
- [SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])](#sourcemapgeneratorprototypeapplysourcemapsourcemapconsumer-sourcefile-sourcemappath)
|
|
@@ -89,7 +90,8 @@ var rawSourceMap = {
|
|
|
89
90
|
names: ['bar', 'baz', 'n'],
|
|
90
91
|
sources: ['one.js', 'two.js'],
|
|
91
92
|
sourceRoot: 'http://example.com/www/js/',
|
|
92
|
-
mappings:
|
|
93
|
+
mappings:
|
|
94
|
+
'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA',
|
|
93
95
|
};
|
|
94
96
|
|
|
95
97
|
var smc = new SourceMapConsumer(rawSourceMap);
|
|
@@ -98,20 +100,24 @@ console.log(smc.sources);
|
|
|
98
100
|
// [ 'http://example.com/www/js/one.js',
|
|
99
101
|
// 'http://example.com/www/js/two.js' ]
|
|
100
102
|
|
|
101
|
-
console.log(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
console.log(
|
|
104
|
+
smc.originalPositionFor({
|
|
105
|
+
line: 2,
|
|
106
|
+
column: 28,
|
|
107
|
+
})
|
|
108
|
+
);
|
|
105
109
|
// { source: 'http://example.com/www/js/two.js',
|
|
106
110
|
// line: 2,
|
|
107
111
|
// column: 10,
|
|
108
112
|
// name: 'n' }
|
|
109
113
|
|
|
110
|
-
console.log(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
console.log(
|
|
115
|
+
smc.generatedPositionFor({
|
|
116
|
+
source: 'http://example.com/www/js/two.js',
|
|
117
|
+
line: 2,
|
|
118
|
+
column: 10,
|
|
119
|
+
})
|
|
120
|
+
);
|
|
115
121
|
// { line: 2, column: 28 }
|
|
116
122
|
|
|
117
123
|
smc.eachMapping(function (m) {
|
|
@@ -129,30 +135,32 @@ In depth guide:
|
|
|
129
135
|
```js
|
|
130
136
|
function compile(ast) {
|
|
131
137
|
switch (ast.type) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
138
|
+
case 'BinaryExpression':
|
|
139
|
+
return new SourceNode(
|
|
140
|
+
ast.location.line,
|
|
141
|
+
ast.location.column,
|
|
142
|
+
ast.location.source,
|
|
143
|
+
[compile(ast.left), ' + ', compile(ast.right)]
|
|
144
|
+
);
|
|
145
|
+
case 'Literal':
|
|
146
|
+
return new SourceNode(
|
|
147
|
+
ast.location.line,
|
|
148
|
+
ast.location.column,
|
|
149
|
+
ast.location.source,
|
|
150
|
+
String(ast.value)
|
|
151
|
+
);
|
|
152
|
+
// ...
|
|
153
|
+
default:
|
|
154
|
+
throw new Error('Bad AST');
|
|
149
155
|
}
|
|
150
156
|
}
|
|
151
157
|
|
|
152
|
-
var ast = parse(
|
|
153
|
-
console.log(
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
var ast = parse('40 + 2', 'add.js');
|
|
159
|
+
console.log(
|
|
160
|
+
compile(ast).toStringWithSourceMap({
|
|
161
|
+
file: 'add.js',
|
|
162
|
+
})
|
|
163
|
+
);
|
|
156
164
|
// { code: '40 + 2',
|
|
157
165
|
// map: [object SourceMapGenerator] }
|
|
158
166
|
```
|
|
@@ -161,20 +169,20 @@ console.log(compile(ast).toStringWithSourceMap({
|
|
|
161
169
|
|
|
162
170
|
```js
|
|
163
171
|
var map = new SourceMapGenerator({
|
|
164
|
-
file:
|
|
172
|
+
file: 'source-mapped.js',
|
|
165
173
|
});
|
|
166
174
|
|
|
167
175
|
map.addMapping({
|
|
168
176
|
generated: {
|
|
169
177
|
line: 10,
|
|
170
|
-
column: 35
|
|
178
|
+
column: 35,
|
|
171
179
|
},
|
|
172
|
-
source:
|
|
180
|
+
source: 'foo.js',
|
|
173
181
|
original: {
|
|
174
182
|
line: 33,
|
|
175
|
-
column: 2
|
|
183
|
+
column: 2,
|
|
176
184
|
},
|
|
177
|
-
name:
|
|
185
|
+
name: 'christopher',
|
|
178
186
|
});
|
|
179
187
|
|
|
180
188
|
console.log(map.toString());
|
|
@@ -193,7 +201,7 @@ var sourceMap = require('source-map');
|
|
|
193
201
|
var sourceMap = window.sourceMap;
|
|
194
202
|
|
|
195
203
|
// Inside Firefox
|
|
196
|
-
const sourceMap = require(
|
|
204
|
+
const sourceMap = require('devtools/toolkit/sourcemap/source-map.js');
|
|
197
205
|
```
|
|
198
206
|
|
|
199
207
|
### SourceMapConsumer
|
|
@@ -208,20 +216,20 @@ The only parameter is the raw source map (either as a string which can be
|
|
|
208
216
|
`JSON.parse`'d, or an object). According to the spec, source maps have the
|
|
209
217
|
following attributes:
|
|
210
218
|
|
|
211
|
-
|
|
219
|
+
- `version`: Which version of the source map spec this map is following.
|
|
212
220
|
|
|
213
|
-
|
|
221
|
+
- `sources`: An array of URLs to the original source files.
|
|
214
222
|
|
|
215
|
-
|
|
223
|
+
- `names`: An array of identifiers which can be referenced by individual
|
|
216
224
|
mappings.
|
|
217
225
|
|
|
218
|
-
|
|
226
|
+
- `sourceRoot`: Optional. The URL root from which all sources are relative.
|
|
219
227
|
|
|
220
|
-
|
|
228
|
+
- `sourcesContent`: Optional. An array of contents of the original source files.
|
|
221
229
|
|
|
222
|
-
|
|
230
|
+
- `mappings`: A string of base64 VLQs which contain the actual mappings.
|
|
223
231
|
|
|
224
|
-
|
|
232
|
+
- `file`: Optional. The generated filename this source map is associated with.
|
|
225
233
|
|
|
226
234
|
```js
|
|
227
235
|
var consumer = new sourceMap.SourceMapConsumer(rawSourceMapJsonData);
|
|
@@ -234,7 +242,7 @@ inclusive.
|
|
|
234
242
|
|
|
235
243
|
```js
|
|
236
244
|
// Before:
|
|
237
|
-
consumer.allGeneratedPositionsFor({ line: 2, source:
|
|
245
|
+
consumer.allGeneratedPositionsFor({ line: 2, source: 'foo.coffee' });
|
|
238
246
|
// [ { line: 2,
|
|
239
247
|
// column: 1 },
|
|
240
248
|
// { line: 2,
|
|
@@ -245,7 +253,7 @@ consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })
|
|
|
245
253
|
consumer.computeColumnSpans();
|
|
246
254
|
|
|
247
255
|
// After:
|
|
248
|
-
consumer.allGeneratedPositionsFor({ line: 2, source:
|
|
256
|
+
consumer.allGeneratedPositionsFor({ line: 2, source: 'foo.coffee' });
|
|
249
257
|
// [ { line: 2,
|
|
250
258
|
// column: 1,
|
|
251
259
|
// lastColumn: 9 },
|
|
@@ -255,7 +263,6 @@ consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })
|
|
|
255
263
|
// { line: 2,
|
|
256
264
|
// column: 20,
|
|
257
265
|
// lastColumn: Infinity } ]
|
|
258
|
-
|
|
259
266
|
```
|
|
260
267
|
|
|
261
268
|
#### SourceMapConsumer.prototype.originalPositionFor(generatedPosition)
|
|
@@ -264,41 +271,44 @@ Returns the original source, line, and column information for the generated
|
|
|
264
271
|
source's line and column positions provided. The only argument is an object with
|
|
265
272
|
the following properties:
|
|
266
273
|
|
|
267
|
-
|
|
274
|
+
- `line`: The line number in the generated source. Line numbers in
|
|
268
275
|
this library are 1-based (note that the underlying source map
|
|
269
276
|
specification uses 0-based line numbers -- this library handles the
|
|
270
277
|
translation).
|
|
271
278
|
|
|
272
|
-
|
|
279
|
+
- `column`: The column number in the generated source. Column numbers
|
|
273
280
|
in this library are 0-based.
|
|
274
281
|
|
|
275
|
-
|
|
282
|
+
- `bias`: Either `SourceMapConsumer.GREATEST_LOWER_BOUND` or
|
|
276
283
|
`SourceMapConsumer.LEAST_UPPER_BOUND`. Specifies whether to return the closest
|
|
277
284
|
element that is smaller than or greater than the one we are searching for,
|
|
278
|
-
respectively, if the exact element cannot be found.
|
|
285
|
+
respectively, if the exact element cannot be found. Defaults to
|
|
279
286
|
`SourceMapConsumer.GREATEST_LOWER_BOUND`.
|
|
280
287
|
|
|
281
288
|
and an object is returned with the following properties:
|
|
282
289
|
|
|
283
|
-
|
|
290
|
+
- `source`: The original source file, or null if this information is not
|
|
284
291
|
available.
|
|
285
292
|
|
|
286
|
-
|
|
287
|
-
not available.
|
|
293
|
+
- `line`: The line number in the original source, or null if this information is
|
|
294
|
+
not available. The line number is 1-based.
|
|
288
295
|
|
|
289
|
-
|
|
290
|
-
information is not available.
|
|
296
|
+
- `column`: The column number in the original source, or null if this
|
|
297
|
+
information is not available. The column number is 0-based.
|
|
291
298
|
|
|
292
|
-
|
|
299
|
+
- `name`: The original identifier, or null if this information is not available.
|
|
293
300
|
|
|
294
301
|
```js
|
|
295
|
-
consumer.originalPositionFor({ line: 2, column: 10 })
|
|
302
|
+
consumer.originalPositionFor({ line: 2, column: 10 });
|
|
296
303
|
// { source: 'foo.coffee',
|
|
297
304
|
// line: 2,
|
|
298
305
|
// column: 2,
|
|
299
306
|
// name: null }
|
|
300
307
|
|
|
301
|
-
consumer.originalPositionFor({
|
|
308
|
+
consumer.originalPositionFor({
|
|
309
|
+
line: 99999999999999999,
|
|
310
|
+
column: 999999999999999,
|
|
311
|
+
});
|
|
302
312
|
// { source: null,
|
|
303
313
|
// line: null,
|
|
304
314
|
// column: null,
|
|
@@ -311,24 +321,24 @@ Returns the generated line and column information for the original source,
|
|
|
311
321
|
line, and column positions provided. The only argument is an object with
|
|
312
322
|
the following properties:
|
|
313
323
|
|
|
314
|
-
|
|
324
|
+
- `source`: The filename of the original source.
|
|
315
325
|
|
|
316
|
-
|
|
326
|
+
- `line`: The line number in the original source. The line number is
|
|
317
327
|
1-based.
|
|
318
328
|
|
|
319
|
-
|
|
329
|
+
- `column`: The column number in the original source. The column
|
|
320
330
|
number is 0-based.
|
|
321
331
|
|
|
322
332
|
and an object is returned with the following properties:
|
|
323
333
|
|
|
324
|
-
|
|
334
|
+
- `line`: The line number in the generated source, or null. The line
|
|
325
335
|
number is 1-based.
|
|
326
336
|
|
|
327
|
-
|
|
337
|
+
- `column`: The column number in the generated source, or null. The
|
|
328
338
|
column number is 0-based.
|
|
329
339
|
|
|
330
340
|
```js
|
|
331
|
-
consumer.generatedPositionFor({ source:
|
|
341
|
+
consumer.generatedPositionFor({ source: 'example.js', line: 2, column: 10 });
|
|
332
342
|
// { line: 1,
|
|
333
343
|
// column: 56 }
|
|
334
344
|
```
|
|
@@ -344,24 +354,24 @@ that has any offsets.
|
|
|
344
354
|
|
|
345
355
|
The only argument is an object with the following properties:
|
|
346
356
|
|
|
347
|
-
|
|
357
|
+
- `source`: The filename of the original source.
|
|
348
358
|
|
|
349
|
-
|
|
359
|
+
- `line`: The line number in the original source. The line number is
|
|
350
360
|
1-based.
|
|
351
361
|
|
|
352
|
-
|
|
362
|
+
- `column`: Optional. The column number in the original source. The
|
|
353
363
|
column number is 0-based.
|
|
354
364
|
|
|
355
365
|
and an array of objects is returned, each with the following properties:
|
|
356
366
|
|
|
357
|
-
|
|
367
|
+
- `line`: The line number in the generated source, or null. The line
|
|
358
368
|
number is 1-based.
|
|
359
369
|
|
|
360
|
-
|
|
370
|
+
- `column`: The column number in the generated source, or null. The
|
|
361
371
|
column number is 0-based.
|
|
362
372
|
|
|
363
373
|
```js
|
|
364
|
-
consumer.allGeneratedpositionsfor({ line: 2, source:
|
|
374
|
+
consumer.allGeneratedpositionsfor({ line: 2, source: 'foo.coffee' });
|
|
365
375
|
// [ { line: 2,
|
|
366
376
|
// column: 1 },
|
|
367
377
|
// { line: 2,
|
|
@@ -399,16 +409,16 @@ thrown. Optionally, pass `true` as the second param to have `null` returned
|
|
|
399
409
|
instead.
|
|
400
410
|
|
|
401
411
|
```js
|
|
402
|
-
consumer.sources
|
|
412
|
+
consumer.sources;
|
|
403
413
|
// [ "my-cool-lib.clj" ]
|
|
404
414
|
|
|
405
|
-
consumer.sourceContentFor(
|
|
415
|
+
consumer.sourceContentFor('my-cool-lib.clj');
|
|
406
416
|
// "..."
|
|
407
417
|
|
|
408
|
-
consumer.sourceContentFor(
|
|
418
|
+
consumer.sourceContentFor('this is not in the source map');
|
|
409
419
|
// Error: "this is not in the source map" is not in the source map
|
|
410
420
|
|
|
411
|
-
consumer.sourceContentFor(
|
|
421
|
+
consumer.sourceContentFor('this is not in the source map', true);
|
|
412
422
|
// null
|
|
413
423
|
```
|
|
414
424
|
|
|
@@ -417,21 +427,23 @@ consumer.sourceContentFor("this is not in the source map", true);
|
|
|
417
427
|
Iterate over each mapping between an original source/line/column and a
|
|
418
428
|
generated line/column in this source map.
|
|
419
429
|
|
|
420
|
-
|
|
430
|
+
- `callback`: The function that is called with each mapping. Mappings have the
|
|
421
431
|
form `{ source, generatedLine, generatedColumn, originalLine, originalColumn,
|
|
422
|
-
|
|
432
|
+
name }`
|
|
423
433
|
|
|
424
|
-
|
|
434
|
+
- `context`: Optional. If specified, this object will be the value of `this`
|
|
425
435
|
every time that `callback` is called.
|
|
426
436
|
|
|
427
|
-
|
|
437
|
+
- `order`: Either `SourceMapConsumer.GENERATED_ORDER` or
|
|
428
438
|
`SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to iterate over
|
|
429
439
|
the mappings sorted by the generated file's line/column order or the
|
|
430
440
|
original's source/line/column order, respectively. Defaults to
|
|
431
441
|
`SourceMapConsumer.GENERATED_ORDER`.
|
|
432
442
|
|
|
433
443
|
```js
|
|
434
|
-
consumer.eachMapping(function (m) {
|
|
444
|
+
consumer.eachMapping(function (m) {
|
|
445
|
+
console.log(m);
|
|
446
|
+
});
|
|
435
447
|
// ...
|
|
436
448
|
// { source: 'illmatic.js',
|
|
437
449
|
// generatedLine: 1,
|
|
@@ -447,6 +459,7 @@ consumer.eachMapping(function (m) { console.log(m); })
|
|
|
447
459
|
// name: null }
|
|
448
460
|
// ...
|
|
449
461
|
```
|
|
462
|
+
|
|
450
463
|
### SourceMapGenerator
|
|
451
464
|
|
|
452
465
|
An instance of the SourceMapGenerator represents a source map which is being
|
|
@@ -456,23 +469,23 @@ built incrementally.
|
|
|
456
469
|
|
|
457
470
|
You may pass an object with the following properties:
|
|
458
471
|
|
|
459
|
-
|
|
472
|
+
- `file`: The filename of the generated source that this source map is
|
|
460
473
|
associated with.
|
|
461
474
|
|
|
462
|
-
|
|
475
|
+
- `sourceRoot`: A root for all relative URLs in this source map.
|
|
463
476
|
|
|
464
|
-
|
|
477
|
+
- `skipValidation`: Optional. When `true`, disables validation of mappings as
|
|
465
478
|
they are added. This can improve performance but should be used with
|
|
466
479
|
discretion, as a last resort. Even then, one should avoid using this flag when
|
|
467
480
|
running tests, if possible.
|
|
468
481
|
|
|
469
|
-
|
|
482
|
+
- `ignoreInvalidMapping`: Optional. When `true`, instead of throwing error on
|
|
470
483
|
invalid mapping, it will be ignored.
|
|
471
484
|
|
|
472
485
|
```js
|
|
473
486
|
var generator = new sourceMap.SourceMapGenerator({
|
|
474
|
-
file:
|
|
475
|
-
sourceRoot:
|
|
487
|
+
file: 'my-generated-javascript-file.js',
|
|
488
|
+
sourceRoot: 'http://example.com/app/js/',
|
|
476
489
|
});
|
|
477
490
|
```
|
|
478
491
|
|
|
@@ -480,9 +493,9 @@ var generator = new sourceMap.SourceMapGenerator({
|
|
|
480
493
|
|
|
481
494
|
Creates a new `SourceMapGenerator` from an existing `SourceMapConsumer` instance.
|
|
482
495
|
|
|
483
|
-
|
|
496
|
+
- `sourceMapConsumer` The SourceMap.
|
|
484
497
|
|
|
485
|
-
|
|
498
|
+
- `sourceMapGeneratorOptions` options that will be passed to the SourceMapGenerator constructor which used under the hood.
|
|
486
499
|
|
|
487
500
|
```js
|
|
488
501
|
var generator = sourceMap.SourceMapGenerator.fromSourceMap(consumer, {
|
|
@@ -496,33 +509,35 @@ Add a single mapping from original source line and column to the generated
|
|
|
496
509
|
source's line and column for this source map being created. The mapping object
|
|
497
510
|
should have the following properties:
|
|
498
511
|
|
|
499
|
-
|
|
512
|
+
- `generated`: An object with the generated line and column positions.
|
|
500
513
|
|
|
501
|
-
|
|
514
|
+
- `original`: An object with the original line and column positions.
|
|
502
515
|
|
|
503
|
-
|
|
516
|
+
- `source`: The original source file (relative to the sourceRoot).
|
|
504
517
|
|
|
505
|
-
|
|
518
|
+
- `name`: An optional original token name for this mapping.
|
|
506
519
|
|
|
507
520
|
```js
|
|
508
521
|
generator.addMapping({
|
|
509
|
-
source:
|
|
522
|
+
source: 'module-one.scm',
|
|
510
523
|
original: { line: 128, column: 0 },
|
|
511
|
-
generated: { line: 3, column: 456 }
|
|
512
|
-
})
|
|
524
|
+
generated: { line: 3, column: 456 },
|
|
525
|
+
});
|
|
513
526
|
```
|
|
514
527
|
|
|
515
528
|
#### SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)
|
|
516
529
|
|
|
517
530
|
Set the source content for an original source file.
|
|
518
531
|
|
|
519
|
-
|
|
532
|
+
- `sourceFile` the URL of the original source file.
|
|
520
533
|
|
|
521
|
-
|
|
534
|
+
- `sourceContent` the content of the source file.
|
|
522
535
|
|
|
523
536
|
```js
|
|
524
|
-
generator.setSourceContent(
|
|
525
|
-
|
|
537
|
+
generator.setSourceContent(
|
|
538
|
+
'module-one.scm',
|
|
539
|
+
fs.readFileSync('path/to/module-one.scm')
|
|
540
|
+
);
|
|
526
541
|
```
|
|
527
542
|
|
|
528
543
|
#### SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])
|
|
@@ -532,13 +547,13 @@ Each mapping to the supplied source file is rewritten using the
|
|
|
532
547
|
supplied SourceMap. Note: The resolution for the resulting mappings
|
|
533
548
|
is the minimum of this map and the supplied map.
|
|
534
549
|
|
|
535
|
-
|
|
550
|
+
- `sourceMapConsumer`: The SourceMap to be applied.
|
|
536
551
|
|
|
537
|
-
|
|
552
|
+
- `sourceFile`: Optional. The filename of the source file.
|
|
538
553
|
If omitted, sourceMapConsumer.file will be used, if it exists.
|
|
539
554
|
Otherwise an error will be thrown.
|
|
540
555
|
|
|
541
|
-
|
|
556
|
+
- `sourceMapPath`: Optional. The dirname of the path to the SourceMap
|
|
542
557
|
to be applied. If relative, it is relative to the SourceMap.
|
|
543
558
|
|
|
544
559
|
This parameter is needed when the two SourceMaps aren't in the same
|
|
@@ -554,7 +569,7 @@ is the minimum of this map and the supplied map.
|
|
|
554
569
|
Renders the source map being generated to a string.
|
|
555
570
|
|
|
556
571
|
```js
|
|
557
|
-
generator.toString()
|
|
572
|
+
generator.toString();
|
|
558
573
|
// '{"version":3,"sources":["module-one.scm"],"names":[],"mappings":"...snip...","file":"my-generated-javascript-file.js","sourceRoot":"http://example.com/app/js/"}'
|
|
559
574
|
```
|
|
560
575
|
|
|
@@ -568,25 +583,25 @@ use before outputting the generated JS and source map.
|
|
|
568
583
|
|
|
569
584
|
#### new SourceNode([line, column, source[, chunk[, name]]])
|
|
570
585
|
|
|
571
|
-
|
|
572
|
-
it isn't associated with an original line.
|
|
586
|
+
- `line`: The original line number associated with this source node, or null if
|
|
587
|
+
it isn't associated with an original line. The line number is 1-based.
|
|
573
588
|
|
|
574
|
-
|
|
575
|
-
if it isn't associated with an original column.
|
|
589
|
+
- `column`: The original column number associated with this source node, or null
|
|
590
|
+
if it isn't associated with an original column. The column number
|
|
576
591
|
is 0-based.
|
|
577
592
|
|
|
578
|
-
|
|
593
|
+
- `source`: The original source's filename; null if no filename is provided.
|
|
579
594
|
|
|
580
|
-
|
|
595
|
+
- `chunk`: Optional. Is immediately passed to `SourceNode.prototype.add`, see
|
|
581
596
|
below.
|
|
582
597
|
|
|
583
|
-
|
|
598
|
+
- `name`: Optional. The original identifier.
|
|
584
599
|
|
|
585
600
|
```js
|
|
586
|
-
var node = new SourceNode(1, 2,
|
|
587
|
-
new SourceNode(3, 4,
|
|
588
|
-
new SourceNode(5, 6,
|
|
589
|
-
new SourceNode(7, 8,
|
|
601
|
+
var node = new SourceNode(1, 2, 'a.cpp', [
|
|
602
|
+
new SourceNode(3, 4, 'b.cpp', 'extern int status;\n'),
|
|
603
|
+
new SourceNode(5, 6, 'c.cpp', 'std::string* make_string(size_t n);\n'),
|
|
604
|
+
new SourceNode(7, 8, 'd.cpp', 'int main(int argc, char** argv) {}\n'),
|
|
590
605
|
]);
|
|
591
606
|
```
|
|
592
607
|
|
|
@@ -594,41 +609,45 @@ var node = new SourceNode(1, 2, "a.cpp", [
|
|
|
594
609
|
|
|
595
610
|
Creates a SourceNode from generated code and a SourceMapConsumer.
|
|
596
611
|
|
|
597
|
-
|
|
612
|
+
- `code`: The generated code
|
|
598
613
|
|
|
599
|
-
|
|
614
|
+
- `sourceMapConsumer` The SourceMap for the generated code
|
|
600
615
|
|
|
601
|
-
|
|
616
|
+
- `relativePath` The optional path that relative sources in `sourceMapConsumer`
|
|
602
617
|
should be relative to.
|
|
603
618
|
|
|
604
619
|
```js
|
|
605
|
-
var consumer = new SourceMapConsumer(
|
|
606
|
-
|
|
607
|
-
|
|
620
|
+
var consumer = new SourceMapConsumer(
|
|
621
|
+
fs.readFileSync('path/to/my-file.js.map', 'utf8')
|
|
622
|
+
);
|
|
623
|
+
var node = SourceNode.fromStringWithSourceMap(
|
|
624
|
+
fs.readFileSync('path/to/my-file.js'),
|
|
625
|
+
consumer
|
|
626
|
+
);
|
|
608
627
|
```
|
|
609
628
|
|
|
610
629
|
#### SourceNode.prototype.add(chunk)
|
|
611
630
|
|
|
612
631
|
Add a chunk of generated JS to this source node.
|
|
613
632
|
|
|
614
|
-
|
|
615
|
-
|
|
633
|
+
- `chunk`: A string snippet of generated JS code, another instance of
|
|
634
|
+
`SourceNode`, or an array where each member is one of those things.
|
|
616
635
|
|
|
617
636
|
```js
|
|
618
|
-
node.add(
|
|
637
|
+
node.add(' + ');
|
|
619
638
|
node.add(otherNode);
|
|
620
|
-
node.add([leftHandOperandNode,
|
|
639
|
+
node.add([leftHandOperandNode, ' + ', rightHandOperandNode]);
|
|
621
640
|
```
|
|
622
641
|
|
|
623
642
|
#### SourceNode.prototype.prepend(chunk)
|
|
624
643
|
|
|
625
644
|
Prepend a chunk of generated JS to this source node.
|
|
626
645
|
|
|
627
|
-
|
|
628
|
-
|
|
646
|
+
- `chunk`: A string snippet of generated JS code, another instance of
|
|
647
|
+
`SourceNode`, or an array where each member is one of those things.
|
|
629
648
|
|
|
630
649
|
```js
|
|
631
|
-
node.prepend(
|
|
650
|
+
node.prepend('/** Build Id: f783haef86324gf **/\n\n');
|
|
632
651
|
```
|
|
633
652
|
|
|
634
653
|
#### SourceNode.prototype.setSourceContent(sourceFile, sourceContent)
|
|
@@ -636,13 +655,15 @@ node.prepend("/** Build Id: f783haef86324gf **/\n\n");
|
|
|
636
655
|
Set the source content for a source file. This will be added to the
|
|
637
656
|
`SourceMap` in the `sourcesContent` field.
|
|
638
657
|
|
|
639
|
-
|
|
658
|
+
- `sourceFile`: The filename of the source file
|
|
640
659
|
|
|
641
|
-
|
|
660
|
+
- `sourceContent`: The content of the source file
|
|
642
661
|
|
|
643
662
|
```js
|
|
644
|
-
node.setSourceContent(
|
|
645
|
-
|
|
663
|
+
node.setSourceContent(
|
|
664
|
+
'module-one.scm',
|
|
665
|
+
fs.readFileSync('path/to/module-one.scm')
|
|
666
|
+
);
|
|
646
667
|
```
|
|
647
668
|
|
|
648
669
|
#### SourceNode.prototype.walk(fn)
|
|
@@ -651,19 +672,18 @@ Walk over the tree of JS snippets in this node and its children. The walking
|
|
|
651
672
|
function is called once for each snippet of JS and is passed that snippet and
|
|
652
673
|
the its original associated source's line/column location.
|
|
653
674
|
|
|
654
|
-
|
|
675
|
+
- `fn`: The traversal function.
|
|
655
676
|
|
|
656
677
|
```js
|
|
657
|
-
var node = new SourceNode(1, 2,
|
|
658
|
-
new SourceNode(3, 4,
|
|
659
|
-
|
|
660
|
-
[
|
|
661
|
-
"tres",
|
|
662
|
-
new SourceNode(5, 6, "c.js", "quatro")
|
|
663
|
-
]
|
|
678
|
+
var node = new SourceNode(1, 2, 'a.js', [
|
|
679
|
+
new SourceNode(3, 4, 'b.js', 'uno'),
|
|
680
|
+
'dos',
|
|
681
|
+
['tres', new SourceNode(5, 6, 'c.js', 'quatro')],
|
|
664
682
|
]);
|
|
665
683
|
|
|
666
|
-
node.walk(function (code, loc) {
|
|
684
|
+
node.walk(function (code, loc) {
|
|
685
|
+
console.log('WALK:', code, loc);
|
|
686
|
+
});
|
|
667
687
|
// WALK: uno { source: 'b.js', line: 3, column: 4, name: null }
|
|
668
688
|
// WALK: dos { source: 'a.js', line: 1, column: 2, name: null }
|
|
669
689
|
// WALK: tres { source: 'a.js', line: 1, column: 2, name: null }
|
|
@@ -675,18 +695,20 @@ node.walk(function (code, loc) { console.log("WALK:", code, loc); })
|
|
|
675
695
|
Walk over the tree of SourceNodes. The walking function is called for each
|
|
676
696
|
source file content and is passed the filename and source content.
|
|
677
697
|
|
|
678
|
-
|
|
698
|
+
- `fn`: The traversal function.
|
|
679
699
|
|
|
680
700
|
```js
|
|
681
|
-
var a = new SourceNode(1, 2,
|
|
682
|
-
a.setSourceContent(
|
|
683
|
-
var b = new SourceNode(1, 2,
|
|
684
|
-
b.setSourceContent(
|
|
685
|
-
var c = new SourceNode(1, 2,
|
|
686
|
-
c.setSourceContent(
|
|
701
|
+
var a = new SourceNode(1, 2, 'a.js', 'generated from a');
|
|
702
|
+
a.setSourceContent('a.js', 'original a');
|
|
703
|
+
var b = new SourceNode(1, 2, 'b.js', 'generated from b');
|
|
704
|
+
b.setSourceContent('b.js', 'original b');
|
|
705
|
+
var c = new SourceNode(1, 2, 'c.js', 'generated from c');
|
|
706
|
+
c.setSourceContent('c.js', 'original c');
|
|
687
707
|
|
|
688
708
|
var node = new SourceNode(null, null, null, [a, b, c]);
|
|
689
|
-
node.walkSourceContents(function (source, contents) {
|
|
709
|
+
node.walkSourceContents(function (source, contents) {
|
|
710
|
+
console.log('WALK:', source, ':', contents);
|
|
711
|
+
});
|
|
690
712
|
// WALK: a.js : original a
|
|
691
713
|
// WALK: b.js : original b
|
|
692
714
|
// WALK: c.js : original c
|
|
@@ -697,15 +719,15 @@ node.walkSourceContents(function (source, contents) { console.log("WALK:", sourc
|
|
|
697
719
|
Like `Array.prototype.join` except for SourceNodes. Inserts the separator
|
|
698
720
|
between each of this source node's children.
|
|
699
721
|
|
|
700
|
-
|
|
722
|
+
- `sep`: The separator.
|
|
701
723
|
|
|
702
724
|
```js
|
|
703
|
-
var lhs = new SourceNode(1, 2,
|
|
704
|
-
var operand = new SourceNode(3, 4,
|
|
705
|
-
var rhs = new SourceNode(5, 6,
|
|
725
|
+
var lhs = new SourceNode(1, 2, 'a.rs', 'my_copy');
|
|
726
|
+
var operand = new SourceNode(3, 4, 'a.rs', '=');
|
|
727
|
+
var rhs = new SourceNode(5, 6, 'a.rs', 'orig.clone()');
|
|
706
728
|
|
|
707
|
-
var node = new SourceNode(null, null, null, [
|
|
708
|
-
var joinedNode = node.join(
|
|
729
|
+
var node = new SourceNode(null, null, null, [lhs, operand, rhs]);
|
|
730
|
+
var joinedNode = node.join(' ');
|
|
709
731
|
```
|
|
710
732
|
|
|
711
733
|
#### SourceNode.prototype.replaceRight(pattern, replacement)
|
|
@@ -713,13 +735,13 @@ var joinedNode = node.join(" ");
|
|
|
713
735
|
Call `String.prototype.replace` on the very right-most source snippet. Useful
|
|
714
736
|
for trimming white space from the end of a source node, etc.
|
|
715
737
|
|
|
716
|
-
|
|
738
|
+
- `pattern`: The pattern to replace.
|
|
717
739
|
|
|
718
|
-
|
|
740
|
+
- `replacement`: The thing to replace the pattern with.
|
|
719
741
|
|
|
720
742
|
```js
|
|
721
743
|
// Trim trailing white space.
|
|
722
|
-
node.replaceRight(/\s*$/,
|
|
744
|
+
node.replaceRight(/\s*$/, '');
|
|
723
745
|
```
|
|
724
746
|
|
|
725
747
|
#### SourceNode.prototype.toString()
|
|
@@ -728,16 +750,13 @@ Return the string representation of this source node. Walks over the tree and
|
|
|
728
750
|
concatenates all the various snippets together to one string.
|
|
729
751
|
|
|
730
752
|
```js
|
|
731
|
-
var node = new SourceNode(1, 2,
|
|
732
|
-
new SourceNode(3, 4,
|
|
733
|
-
|
|
734
|
-
[
|
|
735
|
-
"tres",
|
|
736
|
-
new SourceNode(5, 6, "c.js", "quatro")
|
|
737
|
-
]
|
|
753
|
+
var node = new SourceNode(1, 2, 'a.js', [
|
|
754
|
+
new SourceNode(3, 4, 'b.js', 'uno'),
|
|
755
|
+
'dos',
|
|
756
|
+
['tres', new SourceNode(5, 6, 'c.js', 'quatro')],
|
|
738
757
|
]);
|
|
739
758
|
|
|
740
|
-
node.toString()
|
|
759
|
+
node.toString();
|
|
741
760
|
// 'unodostresquatro'
|
|
742
761
|
```
|
|
743
762
|
|
|
@@ -750,16 +769,13 @@ original sources.
|
|
|
750
769
|
The arguments are the same as those to `new SourceMapGenerator`.
|
|
751
770
|
|
|
752
771
|
```js
|
|
753
|
-
var node = new SourceNode(1, 2,
|
|
754
|
-
new SourceNode(3, 4,
|
|
755
|
-
|
|
756
|
-
[
|
|
757
|
-
"tres",
|
|
758
|
-
new SourceNode(5, 6, "c.js", "quatro")
|
|
759
|
-
]
|
|
772
|
+
var node = new SourceNode(1, 2, 'a.js', [
|
|
773
|
+
new SourceNode(3, 4, 'b.js', 'uno'),
|
|
774
|
+
'dos',
|
|
775
|
+
['tres', new SourceNode(5, 6, 'c.js', 'quatro')],
|
|
760
776
|
]);
|
|
761
777
|
|
|
762
|
-
node.toStringWithSourceMap({ file:
|
|
778
|
+
node.toStringWithSourceMap({ file: 'my-output-file.js' });
|
|
763
779
|
// { code: 'unodostresquatro',
|
|
764
780
|
// map: [object SourceMapGenerator] }
|
|
765
781
|
```
|