@contentrain/mcp 0.3.1 → 1.0.0
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/LICENSE +1 -1
- package/README.md +147 -238
- package/dist/apply-manager-CaTuu7Lj.mjs +751 -0
- package/dist/apply-manager-CaTuu7Lj.mjs.map +1 -0
- package/dist/astro-parser-RofKmKQi.mjs +166 -0
- package/dist/astro-parser-RofKmKQi.mjs.map +1 -0
- package/dist/branch-lifecycle-DB6sgeJi.mjs +97 -0
- package/dist/branch-lifecycle-DB6sgeJi.mjs.map +1 -0
- package/dist/chunk-BEJ448es.mjs +35 -0
- package/dist/compiler-rIC4ETHv.mjs +44509 -0
- package/dist/compiler-rIC4ETHv.mjs.map +1 -0
- package/dist/compiler-sfc.cjs-BbD04rn_.mjs +50279 -0
- package/dist/compiler-sfc.cjs-BbD04rn_.mjs.map +1 -0
- package/dist/config-CPlhDwsv.mjs +27 -0
- package/dist/config-CPlhDwsv.mjs.map +1 -0
- package/dist/context-yh3cuw5N.mjs +46 -0
- package/dist/context-yh3cuw5N.mjs.map +1 -0
- package/dist/core/apply-manager.d.mts +144 -0
- package/dist/core/apply-manager.d.mts.map +1 -0
- package/dist/core/apply-manager.mjs +6 -0
- package/dist/core/config.d.mts +8 -0
- package/dist/core/config.d.mts.map +1 -0
- package/dist/core/config.mjs +2 -0
- package/dist/core/content-manager.d.mts +53 -0
- package/dist/core/content-manager.d.mts.map +1 -0
- package/dist/core/content-manager.mjs +2 -0
- package/dist/core/context.d.mts +13 -0
- package/dist/core/context.d.mts.map +1 -0
- package/dist/core/context.mjs +3 -0
- package/dist/core/graph-builder.d.mts +12 -0
- package/dist/core/graph-builder.d.mts.map +1 -0
- package/dist/core/graph-builder.mjs +2 -0
- package/dist/core/meta-manager.d.mts +14 -0
- package/dist/core/meta-manager.d.mts.map +1 -0
- package/dist/core/meta-manager.mjs +2 -0
- package/dist/core/model-manager.d.mts +44 -0
- package/dist/core/model-manager.d.mts.map +1 -0
- package/dist/core/model-manager.mjs +2 -0
- package/dist/core/scan-config.d.mts +24 -0
- package/dist/core/scan-config.d.mts.map +1 -0
- package/dist/core/scan-config.mjs +2 -0
- package/dist/core/scanner.d.mts +25 -0
- package/dist/core/scanner.d.mts.map +1 -0
- package/dist/core/scanner.mjs +3 -0
- package/dist/core/validator.d.mts +23 -0
- package/dist/core/validator.d.mts.map +1 -0
- package/dist/core/validator.mjs +3 -0
- package/dist/detect-C8XmJ4S6.mjs +362 -0
- package/dist/detect-C8XmJ4S6.mjs.map +1 -0
- package/dist/fs-BbuGnVcG.mjs +52 -0
- package/dist/fs-BbuGnVcG.mjs.map +1 -0
- package/dist/git/branch-lifecycle.d.mts +28 -0
- package/dist/git/branch-lifecycle.d.mts.map +1 -0
- package/dist/git/branch-lifecycle.mjs +2 -0
- package/dist/git/transaction.d.mts +25 -0
- package/dist/git/transaction.d.mts.map +1 -0
- package/dist/git/transaction.mjs +4 -0
- package/dist/graph-builder-fPrDDwnu.mjs +162 -0
- package/dist/graph-builder-fPrDDwnu.mjs.map +1 -0
- package/dist/id-BdD4HvMY.mjs +12 -0
- package/dist/id-BdD4HvMY.mjs.map +1 -0
- package/dist/index.d.mts +1 -359
- package/dist/index.mjs +15 -2161
- package/dist/index.mjs.map +1 -1
- package/dist/meta-manager-CECrfsKm.mjs +53 -0
- package/dist/meta-manager-CECrfsKm.mjs.map +1 -0
- package/dist/model-manager-BcWWu5l2.mjs +963 -0
- package/dist/model-manager-BcWWu5l2.mjs.map +1 -0
- package/dist/node-Cbq5eR5i.mjs +300 -0
- package/dist/node-Cbq5eR5i.mjs.map +1 -0
- package/dist/scan-config-AJGxCdNd.mjs +159 -0
- package/dist/scan-config-AJGxCdNd.mjs.map +1 -0
- package/dist/scanner-BdTiv8sw.mjs +619 -0
- package/dist/scanner-BdTiv8sw.mjs.map +1 -0
- package/dist/serializer-Dueih-i2.mjs +33 -0
- package/dist/serializer-Dueih-i2.mjs.map +1 -0
- package/dist/server-CTcDpxwW.mjs +1861 -0
- package/dist/server-CTcDpxwW.mjs.map +1 -0
- package/dist/server.d.mts +7 -0
- package/dist/server.d.mts.map +1 -0
- package/dist/server.mjs +11 -0
- package/dist/source-map-generator-DpO-ejrt.mjs +893 -0
- package/dist/source-map-generator-DpO-ejrt.mjs.map +1 -0
- package/dist/svelte-parser-COTNG92w.mjs +225 -0
- package/dist/svelte-parser-COTNG92w.mjs.map +1 -0
- package/dist/templates/index.d.mts +8 -0
- package/dist/templates/index.d.mts.map +1 -0
- package/dist/templates/index.mjs +2 -0
- package/dist/templates-3HWi-PTu.mjs +824 -0
- package/dist/templates-3HWi-PTu.mjs.map +1 -0
- package/dist/transaction-BsECnmL5.mjs +128 -0
- package/dist/transaction-BsECnmL5.mjs.map +1 -0
- package/dist/tsx-parser-Bf8Firrq.mjs +2 -0
- package/dist/tsx-parser-CYVyBWjn.mjs +234 -0
- package/dist/tsx-parser-CYVyBWjn.mjs.map +1 -0
- package/dist/util/detect.d.mts +20 -0
- package/dist/util/detect.d.mts.map +1 -0
- package/dist/util/detect.mjs +2 -0
- package/dist/util/fs.d.mts +12 -0
- package/dist/util/fs.d.mts.map +1 -0
- package/dist/util/fs.mjs +2 -0
- package/dist/util/id.d.mts +6 -0
- package/dist/util/id.d.mts.map +1 -0
- package/dist/util/id.mjs +2 -0
- package/dist/util/serializer.d.mts +14 -0
- package/dist/util/serializer.d.mts.map +1 -0
- package/dist/util/serializer.mjs +2 -0
- package/dist/validator-ku84AyFr.mjs +755 -0
- package/dist/validator-ku84AyFr.mjs.map +1 -0
- package/dist/vue-parser-CjS4YAoQ.mjs +225 -0
- package/dist/vue-parser-CjS4YAoQ.mjs.map +1 -0
- package/package.json +107 -43
- package/dist/fs-D83-Ii_y.mjs +0 -75
- package/dist/fs-D83-Ii_y.mjs.map +0 -1
- package/dist/index.d.mts.map +0 -1
|
@@ -0,0 +1,893 @@
|
|
|
1
|
+
import { t as __commonJSMin } from "./chunk-BEJ448es.mjs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64.js
|
|
3
|
+
var require_base64 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
4
|
+
var intToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
|
|
5
|
+
/**
|
|
6
|
+
* Encode an integer in the range of 0 to 63 to a single base 64 digit.
|
|
7
|
+
*/
|
|
8
|
+
exports.encode = function(number) {
|
|
9
|
+
if (0 <= number && number < intToCharMap.length) return intToCharMap[number];
|
|
10
|
+
throw new TypeError("Must be between 0 and 63: " + number);
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Decode a single base 64 character code digit to an integer. Returns -1 on
|
|
14
|
+
* failure.
|
|
15
|
+
*/
|
|
16
|
+
exports.decode = function(charCode) {
|
|
17
|
+
var bigA = 65;
|
|
18
|
+
var bigZ = 90;
|
|
19
|
+
var littleA = 97;
|
|
20
|
+
var littleZ = 122;
|
|
21
|
+
var zero = 48;
|
|
22
|
+
var nine = 57;
|
|
23
|
+
var plus = 43;
|
|
24
|
+
var slash = 47;
|
|
25
|
+
var littleOffset = 26;
|
|
26
|
+
var numberOffset = 52;
|
|
27
|
+
if (bigA <= charCode && charCode <= bigZ) return charCode - bigA;
|
|
28
|
+
if (littleA <= charCode && charCode <= littleZ) return charCode - littleA + littleOffset;
|
|
29
|
+
if (zero <= charCode && charCode <= nine) return charCode - zero + numberOffset;
|
|
30
|
+
if (charCode == plus) return 62;
|
|
31
|
+
if (charCode == slash) return 63;
|
|
32
|
+
return -1;
|
|
33
|
+
};
|
|
34
|
+
}));
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/base64-vlq.js
|
|
37
|
+
var require_base64_vlq = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
38
|
+
var base64 = require_base64();
|
|
39
|
+
var VLQ_BASE_SHIFT = 5;
|
|
40
|
+
var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
|
|
41
|
+
var VLQ_BASE_MASK = VLQ_BASE - 1;
|
|
42
|
+
var VLQ_CONTINUATION_BIT = VLQ_BASE;
|
|
43
|
+
/**
|
|
44
|
+
* Converts from a two-complement value to a value where the sign bit is
|
|
45
|
+
* placed in the least significant bit. For example, as decimals:
|
|
46
|
+
* 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
|
|
47
|
+
* 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
|
|
48
|
+
*/
|
|
49
|
+
function toVLQSigned(aValue) {
|
|
50
|
+
return aValue < 0 ? (-aValue << 1) + 1 : (aValue << 1) + 0;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Converts to a two-complement value from a value where the sign bit is
|
|
54
|
+
* placed in the least significant bit. For example, as decimals:
|
|
55
|
+
* 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
|
|
56
|
+
* 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
|
|
57
|
+
*/
|
|
58
|
+
function fromVLQSigned(aValue) {
|
|
59
|
+
var isNegative = (aValue & 1) === 1;
|
|
60
|
+
var shifted = aValue >> 1;
|
|
61
|
+
return isNegative ? -shifted : shifted;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns the base 64 VLQ encoded value.
|
|
65
|
+
*/
|
|
66
|
+
exports.encode = function base64VLQ_encode(aValue) {
|
|
67
|
+
var encoded = "";
|
|
68
|
+
var digit;
|
|
69
|
+
var vlq = toVLQSigned(aValue);
|
|
70
|
+
do {
|
|
71
|
+
digit = vlq & VLQ_BASE_MASK;
|
|
72
|
+
vlq >>>= VLQ_BASE_SHIFT;
|
|
73
|
+
if (vlq > 0) digit |= VLQ_CONTINUATION_BIT;
|
|
74
|
+
encoded += base64.encode(digit);
|
|
75
|
+
} while (vlq > 0);
|
|
76
|
+
return encoded;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Decodes the next base 64 VLQ value from the given string and returns the
|
|
80
|
+
* value and the rest of the string via the out parameter.
|
|
81
|
+
*/
|
|
82
|
+
exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
|
|
83
|
+
var strLen = aStr.length;
|
|
84
|
+
var result = 0;
|
|
85
|
+
var shift = 0;
|
|
86
|
+
var continuation, digit;
|
|
87
|
+
do {
|
|
88
|
+
if (aIndex >= strLen) throw new Error("Expected more digits in base 64 VLQ value.");
|
|
89
|
+
digit = base64.decode(aStr.charCodeAt(aIndex++));
|
|
90
|
+
if (digit === -1) throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
|
|
91
|
+
continuation = !!(digit & VLQ_CONTINUATION_BIT);
|
|
92
|
+
digit &= VLQ_BASE_MASK;
|
|
93
|
+
result = result + (digit << shift);
|
|
94
|
+
shift += VLQ_BASE_SHIFT;
|
|
95
|
+
} while (continuation);
|
|
96
|
+
aOutParam.value = fromVLQSigned(result);
|
|
97
|
+
aOutParam.rest = aIndex;
|
|
98
|
+
};
|
|
99
|
+
}));
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region ../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/util.js
|
|
102
|
+
var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
103
|
+
/**
|
|
104
|
+
* This is a helper function for getting values from parameter/options
|
|
105
|
+
* objects.
|
|
106
|
+
*
|
|
107
|
+
* @param args The object we are extracting values from
|
|
108
|
+
* @param name The name of the property we are getting.
|
|
109
|
+
* @param defaultValue An optional value to return if the property is missing
|
|
110
|
+
* from the object. If this is not specified and the property is missing, an
|
|
111
|
+
* error will be thrown.
|
|
112
|
+
*/
|
|
113
|
+
function getArg(aArgs, aName, aDefaultValue) {
|
|
114
|
+
if (aName in aArgs) return aArgs[aName];
|
|
115
|
+
else if (arguments.length === 3) return aDefaultValue;
|
|
116
|
+
else throw new Error("\"" + aName + "\" is a required argument.");
|
|
117
|
+
}
|
|
118
|
+
exports.getArg = getArg;
|
|
119
|
+
var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/;
|
|
120
|
+
var dataUrlRegexp = /^data:.+\,.+$/;
|
|
121
|
+
function urlParse(aUrl) {
|
|
122
|
+
var match = aUrl.match(urlRegexp);
|
|
123
|
+
if (!match) return null;
|
|
124
|
+
return {
|
|
125
|
+
scheme: match[1],
|
|
126
|
+
auth: match[2],
|
|
127
|
+
host: match[3],
|
|
128
|
+
port: match[4],
|
|
129
|
+
path: match[5]
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
exports.urlParse = urlParse;
|
|
133
|
+
function urlGenerate(aParsedUrl) {
|
|
134
|
+
var url = "";
|
|
135
|
+
if (aParsedUrl.scheme) url += aParsedUrl.scheme + ":";
|
|
136
|
+
url += "//";
|
|
137
|
+
if (aParsedUrl.auth) url += aParsedUrl.auth + "@";
|
|
138
|
+
if (aParsedUrl.host) url += aParsedUrl.host;
|
|
139
|
+
if (aParsedUrl.port) url += ":" + aParsedUrl.port;
|
|
140
|
+
if (aParsedUrl.path) url += aParsedUrl.path;
|
|
141
|
+
return url;
|
|
142
|
+
}
|
|
143
|
+
exports.urlGenerate = urlGenerate;
|
|
144
|
+
var MAX_CACHED_INPUTS = 32;
|
|
145
|
+
/**
|
|
146
|
+
* Takes some function `f(input) -> result` and returns a memoized version of
|
|
147
|
+
* `f`.
|
|
148
|
+
*
|
|
149
|
+
* We keep at most `MAX_CACHED_INPUTS` memoized results of `f` alive. The
|
|
150
|
+
* memoization is a dumb-simple, linear least-recently-used cache.
|
|
151
|
+
*/
|
|
152
|
+
function lruMemoize(f) {
|
|
153
|
+
var cache = [];
|
|
154
|
+
return function(input) {
|
|
155
|
+
for (var i = 0; i < cache.length; i++) if (cache[i].input === input) {
|
|
156
|
+
var temp = cache[0];
|
|
157
|
+
cache[0] = cache[i];
|
|
158
|
+
cache[i] = temp;
|
|
159
|
+
return cache[0].result;
|
|
160
|
+
}
|
|
161
|
+
var result = f(input);
|
|
162
|
+
cache.unshift({
|
|
163
|
+
input,
|
|
164
|
+
result
|
|
165
|
+
});
|
|
166
|
+
if (cache.length > MAX_CACHED_INPUTS) cache.pop();
|
|
167
|
+
return result;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Normalizes a path, or the path portion of a URL:
|
|
172
|
+
*
|
|
173
|
+
* - Replaces consecutive slashes with one slash.
|
|
174
|
+
* - Removes unnecessary '.' parts.
|
|
175
|
+
* - Removes unnecessary '<dir>/..' parts.
|
|
176
|
+
*
|
|
177
|
+
* Based on code in the Node.js 'path' core module.
|
|
178
|
+
*
|
|
179
|
+
* @param aPath The path or url to normalize.
|
|
180
|
+
*/
|
|
181
|
+
var normalize = lruMemoize(function normalize(aPath) {
|
|
182
|
+
var path = aPath;
|
|
183
|
+
var url = urlParse(aPath);
|
|
184
|
+
if (url) {
|
|
185
|
+
if (!url.path) return aPath;
|
|
186
|
+
path = url.path;
|
|
187
|
+
}
|
|
188
|
+
var isAbsolute = exports.isAbsolute(path);
|
|
189
|
+
var parts = [];
|
|
190
|
+
var start = 0;
|
|
191
|
+
var i = 0;
|
|
192
|
+
while (true) {
|
|
193
|
+
start = i;
|
|
194
|
+
i = path.indexOf("/", start);
|
|
195
|
+
if (i === -1) {
|
|
196
|
+
parts.push(path.slice(start));
|
|
197
|
+
break;
|
|
198
|
+
} else {
|
|
199
|
+
parts.push(path.slice(start, i));
|
|
200
|
+
while (i < path.length && path[i] === "/") i++;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
|
|
204
|
+
part = parts[i];
|
|
205
|
+
if (part === ".") parts.splice(i, 1);
|
|
206
|
+
else if (part === "..") up++;
|
|
207
|
+
else if (up > 0) if (part === "") {
|
|
208
|
+
parts.splice(i + 1, up);
|
|
209
|
+
up = 0;
|
|
210
|
+
} else {
|
|
211
|
+
parts.splice(i, 2);
|
|
212
|
+
up--;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
path = parts.join("/");
|
|
216
|
+
if (path === "") path = isAbsolute ? "/" : ".";
|
|
217
|
+
if (url) {
|
|
218
|
+
url.path = path;
|
|
219
|
+
return urlGenerate(url);
|
|
220
|
+
}
|
|
221
|
+
return path;
|
|
222
|
+
});
|
|
223
|
+
exports.normalize = normalize;
|
|
224
|
+
/**
|
|
225
|
+
* Joins two paths/URLs.
|
|
226
|
+
*
|
|
227
|
+
* @param aRoot The root path or URL.
|
|
228
|
+
* @param aPath The path or URL to be joined with the root.
|
|
229
|
+
*
|
|
230
|
+
* - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
|
|
231
|
+
* scheme-relative URL: Then the scheme of aRoot, if any, is prepended
|
|
232
|
+
* first.
|
|
233
|
+
* - Otherwise aPath is a path. If aRoot is a URL, then its path portion
|
|
234
|
+
* is updated with the result and aRoot is returned. Otherwise the result
|
|
235
|
+
* is returned.
|
|
236
|
+
* - If aPath is absolute, the result is aPath.
|
|
237
|
+
* - Otherwise the two paths are joined with a slash.
|
|
238
|
+
* - Joining for example 'http://' and 'www.example.com' is also supported.
|
|
239
|
+
*/
|
|
240
|
+
function join(aRoot, aPath) {
|
|
241
|
+
if (aRoot === "") aRoot = ".";
|
|
242
|
+
if (aPath === "") aPath = ".";
|
|
243
|
+
var aPathUrl = urlParse(aPath);
|
|
244
|
+
var aRootUrl = urlParse(aRoot);
|
|
245
|
+
if (aRootUrl) aRoot = aRootUrl.path || "/";
|
|
246
|
+
if (aPathUrl && !aPathUrl.scheme) {
|
|
247
|
+
if (aRootUrl) aPathUrl.scheme = aRootUrl.scheme;
|
|
248
|
+
return urlGenerate(aPathUrl);
|
|
249
|
+
}
|
|
250
|
+
if (aPathUrl || aPath.match(dataUrlRegexp)) return aPath;
|
|
251
|
+
if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
|
|
252
|
+
aRootUrl.host = aPath;
|
|
253
|
+
return urlGenerate(aRootUrl);
|
|
254
|
+
}
|
|
255
|
+
var joined = aPath.charAt(0) === "/" ? aPath : normalize(aRoot.replace(/\/+$/, "") + "/" + aPath);
|
|
256
|
+
if (aRootUrl) {
|
|
257
|
+
aRootUrl.path = joined;
|
|
258
|
+
return urlGenerate(aRootUrl);
|
|
259
|
+
}
|
|
260
|
+
return joined;
|
|
261
|
+
}
|
|
262
|
+
exports.join = join;
|
|
263
|
+
exports.isAbsolute = function(aPath) {
|
|
264
|
+
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Make a path relative to a URL or another path.
|
|
268
|
+
*
|
|
269
|
+
* @param aRoot The root path or URL.
|
|
270
|
+
* @param aPath The path or URL to be made relative to aRoot.
|
|
271
|
+
*/
|
|
272
|
+
function relative(aRoot, aPath) {
|
|
273
|
+
if (aRoot === "") aRoot = ".";
|
|
274
|
+
aRoot = aRoot.replace(/\/$/, "");
|
|
275
|
+
var level = 0;
|
|
276
|
+
while (aPath.indexOf(aRoot + "/") !== 0) {
|
|
277
|
+
var index = aRoot.lastIndexOf("/");
|
|
278
|
+
if (index < 0) return aPath;
|
|
279
|
+
aRoot = aRoot.slice(0, index);
|
|
280
|
+
if (aRoot.match(/^([^\/]+:\/)?\/*$/)) return aPath;
|
|
281
|
+
++level;
|
|
282
|
+
}
|
|
283
|
+
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
|
|
284
|
+
}
|
|
285
|
+
exports.relative = relative;
|
|
286
|
+
var supportsNullProto = function() {
|
|
287
|
+
return !("__proto__" in Object.create(null));
|
|
288
|
+
}();
|
|
289
|
+
function identity(s) {
|
|
290
|
+
return s;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Because behavior goes wacky when you set `__proto__` on objects, we
|
|
294
|
+
* have to prefix all the strings in our set with an arbitrary character.
|
|
295
|
+
*
|
|
296
|
+
* See https://github.com/mozilla/source-map/pull/31 and
|
|
297
|
+
* https://github.com/mozilla/source-map/issues/30
|
|
298
|
+
*
|
|
299
|
+
* @param String aStr
|
|
300
|
+
*/
|
|
301
|
+
function toSetString(aStr) {
|
|
302
|
+
if (isProtoString(aStr)) return "$" + aStr;
|
|
303
|
+
return aStr;
|
|
304
|
+
}
|
|
305
|
+
exports.toSetString = supportsNullProto ? identity : toSetString;
|
|
306
|
+
function fromSetString(aStr) {
|
|
307
|
+
if (isProtoString(aStr)) return aStr.slice(1);
|
|
308
|
+
return aStr;
|
|
309
|
+
}
|
|
310
|
+
exports.fromSetString = supportsNullProto ? identity : fromSetString;
|
|
311
|
+
function isProtoString(s) {
|
|
312
|
+
if (!s) return false;
|
|
313
|
+
var length = s.length;
|
|
314
|
+
if (length < 9) return false;
|
|
315
|
+
if (s.charCodeAt(length - 1) !== 95 || s.charCodeAt(length - 2) !== 95 || s.charCodeAt(length - 3) !== 111 || s.charCodeAt(length - 4) !== 116 || s.charCodeAt(length - 5) !== 111 || s.charCodeAt(length - 6) !== 114 || s.charCodeAt(length - 7) !== 112 || s.charCodeAt(length - 8) !== 95 || s.charCodeAt(length - 9) !== 95) return false;
|
|
316
|
+
for (var i = length - 10; i >= 0; i--) if (s.charCodeAt(i) !== 36) return false;
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Comparator between two mappings where the original positions are compared.
|
|
321
|
+
*
|
|
322
|
+
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
|
323
|
+
* mappings with the same original source/line/column, but different generated
|
|
324
|
+
* line and column the same. Useful when searching for a mapping with a
|
|
325
|
+
* stubbed out mapping.
|
|
326
|
+
*/
|
|
327
|
+
function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
|
|
328
|
+
var cmp = strcmp(mappingA.source, mappingB.source);
|
|
329
|
+
if (cmp !== 0) return cmp;
|
|
330
|
+
cmp = mappingA.originalLine - mappingB.originalLine;
|
|
331
|
+
if (cmp !== 0) return cmp;
|
|
332
|
+
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
|
333
|
+
if (cmp !== 0 || onlyCompareOriginal) return cmp;
|
|
334
|
+
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
|
335
|
+
if (cmp !== 0) return cmp;
|
|
336
|
+
cmp = mappingA.generatedLine - mappingB.generatedLine;
|
|
337
|
+
if (cmp !== 0) return cmp;
|
|
338
|
+
return strcmp(mappingA.name, mappingB.name);
|
|
339
|
+
}
|
|
340
|
+
exports.compareByOriginalPositions = compareByOriginalPositions;
|
|
341
|
+
function compareByOriginalPositionsNoSource(mappingA, mappingB, onlyCompareOriginal) {
|
|
342
|
+
var cmp = mappingA.originalLine - mappingB.originalLine;
|
|
343
|
+
if (cmp !== 0) return cmp;
|
|
344
|
+
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
|
345
|
+
if (cmp !== 0 || onlyCompareOriginal) return cmp;
|
|
346
|
+
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
|
347
|
+
if (cmp !== 0) return cmp;
|
|
348
|
+
cmp = mappingA.generatedLine - mappingB.generatedLine;
|
|
349
|
+
if (cmp !== 0) return cmp;
|
|
350
|
+
return strcmp(mappingA.name, mappingB.name);
|
|
351
|
+
}
|
|
352
|
+
exports.compareByOriginalPositionsNoSource = compareByOriginalPositionsNoSource;
|
|
353
|
+
/**
|
|
354
|
+
* Comparator between two mappings with deflated source and name indices where
|
|
355
|
+
* the generated positions are compared.
|
|
356
|
+
*
|
|
357
|
+
* Optionally pass in `true` as `onlyCompareGenerated` to consider two
|
|
358
|
+
* mappings with the same generated line and column, but different
|
|
359
|
+
* source/name/original line and column the same. Useful when searching for a
|
|
360
|
+
* mapping with a stubbed out mapping.
|
|
361
|
+
*/
|
|
362
|
+
function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
|
|
363
|
+
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
|
364
|
+
if (cmp !== 0) return cmp;
|
|
365
|
+
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
|
366
|
+
if (cmp !== 0 || onlyCompareGenerated) return cmp;
|
|
367
|
+
cmp = strcmp(mappingA.source, mappingB.source);
|
|
368
|
+
if (cmp !== 0) return cmp;
|
|
369
|
+
cmp = mappingA.originalLine - mappingB.originalLine;
|
|
370
|
+
if (cmp !== 0) return cmp;
|
|
371
|
+
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
|
372
|
+
if (cmp !== 0) return cmp;
|
|
373
|
+
return strcmp(mappingA.name, mappingB.name);
|
|
374
|
+
}
|
|
375
|
+
exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
|
|
376
|
+
function compareByGeneratedPositionsDeflatedNoLine(mappingA, mappingB, onlyCompareGenerated) {
|
|
377
|
+
var cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
|
378
|
+
if (cmp !== 0 || onlyCompareGenerated) return cmp;
|
|
379
|
+
cmp = strcmp(mappingA.source, mappingB.source);
|
|
380
|
+
if (cmp !== 0) return cmp;
|
|
381
|
+
cmp = mappingA.originalLine - mappingB.originalLine;
|
|
382
|
+
if (cmp !== 0) return cmp;
|
|
383
|
+
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
|
384
|
+
if (cmp !== 0) return cmp;
|
|
385
|
+
return strcmp(mappingA.name, mappingB.name);
|
|
386
|
+
}
|
|
387
|
+
exports.compareByGeneratedPositionsDeflatedNoLine = compareByGeneratedPositionsDeflatedNoLine;
|
|
388
|
+
function strcmp(aStr1, aStr2) {
|
|
389
|
+
if (aStr1 === aStr2) return 0;
|
|
390
|
+
if (aStr1 === null) return 1;
|
|
391
|
+
if (aStr2 === null) return -1;
|
|
392
|
+
if (aStr1 > aStr2) return 1;
|
|
393
|
+
return -1;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Comparator between two mappings with inflated source and name strings where
|
|
397
|
+
* the generated positions are compared.
|
|
398
|
+
*/
|
|
399
|
+
function compareByGeneratedPositionsInflated(mappingA, mappingB) {
|
|
400
|
+
var cmp = mappingA.generatedLine - mappingB.generatedLine;
|
|
401
|
+
if (cmp !== 0) return cmp;
|
|
402
|
+
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
|
|
403
|
+
if (cmp !== 0) return cmp;
|
|
404
|
+
cmp = strcmp(mappingA.source, mappingB.source);
|
|
405
|
+
if (cmp !== 0) return cmp;
|
|
406
|
+
cmp = mappingA.originalLine - mappingB.originalLine;
|
|
407
|
+
if (cmp !== 0) return cmp;
|
|
408
|
+
cmp = mappingA.originalColumn - mappingB.originalColumn;
|
|
409
|
+
if (cmp !== 0) return cmp;
|
|
410
|
+
return strcmp(mappingA.name, mappingB.name);
|
|
411
|
+
}
|
|
412
|
+
exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
|
|
413
|
+
/**
|
|
414
|
+
* Strip any JSON XSSI avoidance prefix from the string (as documented
|
|
415
|
+
* in the source maps specification), and then parse the string as
|
|
416
|
+
* JSON.
|
|
417
|
+
*/
|
|
418
|
+
function parseSourceMapInput(str) {
|
|
419
|
+
return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, ""));
|
|
420
|
+
}
|
|
421
|
+
exports.parseSourceMapInput = parseSourceMapInput;
|
|
422
|
+
/**
|
|
423
|
+
* Compute the URL of a source given the the source root, the source's
|
|
424
|
+
* URL, and the source map's URL.
|
|
425
|
+
*/
|
|
426
|
+
function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
|
|
427
|
+
sourceURL = sourceURL || "";
|
|
428
|
+
if (sourceRoot) {
|
|
429
|
+
if (sourceRoot[sourceRoot.length - 1] !== "/" && sourceURL[0] !== "/") sourceRoot += "/";
|
|
430
|
+
sourceURL = sourceRoot + sourceURL;
|
|
431
|
+
}
|
|
432
|
+
if (sourceMapURL) {
|
|
433
|
+
var parsed = urlParse(sourceMapURL);
|
|
434
|
+
if (!parsed) throw new Error("sourceMapURL could not be parsed");
|
|
435
|
+
if (parsed.path) {
|
|
436
|
+
var index = parsed.path.lastIndexOf("/");
|
|
437
|
+
if (index >= 0) parsed.path = parsed.path.substring(0, index + 1);
|
|
438
|
+
}
|
|
439
|
+
sourceURL = join(urlGenerate(parsed), sourceURL);
|
|
440
|
+
}
|
|
441
|
+
return normalize(sourceURL);
|
|
442
|
+
}
|
|
443
|
+
exports.computeSourceURL = computeSourceURL;
|
|
444
|
+
}));
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region ../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/array-set.js
|
|
447
|
+
var require_array_set = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
448
|
+
var util = require_util();
|
|
449
|
+
var has = Object.prototype.hasOwnProperty;
|
|
450
|
+
var hasNativeMap = typeof Map !== "undefined";
|
|
451
|
+
/**
|
|
452
|
+
* A data structure which is a combination of an array and a set. Adding a new
|
|
453
|
+
* member is O(1), testing for membership is O(1), and finding the index of an
|
|
454
|
+
* element is O(1). Removing elements from the set is not supported. Only
|
|
455
|
+
* strings are supported for membership.
|
|
456
|
+
*/
|
|
457
|
+
function ArraySet() {
|
|
458
|
+
this._array = [];
|
|
459
|
+
this._set = hasNativeMap ? /* @__PURE__ */ new Map() : Object.create(null);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Static method for creating ArraySet instances from an existing array.
|
|
463
|
+
*/
|
|
464
|
+
ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
|
|
465
|
+
var set = new ArraySet();
|
|
466
|
+
for (var i = 0, len = aArray.length; i < len; i++) set.add(aArray[i], aAllowDuplicates);
|
|
467
|
+
return set;
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* Return how many unique items are in this ArraySet. If duplicates have been
|
|
471
|
+
* added, than those do not count towards the size.
|
|
472
|
+
*
|
|
473
|
+
* @returns Number
|
|
474
|
+
*/
|
|
475
|
+
ArraySet.prototype.size = function ArraySet_size() {
|
|
476
|
+
return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* Add the given string to this set.
|
|
480
|
+
*
|
|
481
|
+
* @param String aStr
|
|
482
|
+
*/
|
|
483
|
+
ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
|
|
484
|
+
var sStr = hasNativeMap ? aStr : util.toSetString(aStr);
|
|
485
|
+
var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);
|
|
486
|
+
var idx = this._array.length;
|
|
487
|
+
if (!isDuplicate || aAllowDuplicates) this._array.push(aStr);
|
|
488
|
+
if (!isDuplicate) if (hasNativeMap) this._set.set(aStr, idx);
|
|
489
|
+
else this._set[sStr] = idx;
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* Is the given string a member of this set?
|
|
493
|
+
*
|
|
494
|
+
* @param String aStr
|
|
495
|
+
*/
|
|
496
|
+
ArraySet.prototype.has = function ArraySet_has(aStr) {
|
|
497
|
+
if (hasNativeMap) return this._set.has(aStr);
|
|
498
|
+
else {
|
|
499
|
+
var sStr = util.toSetString(aStr);
|
|
500
|
+
return has.call(this._set, sStr);
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* What is the index of the given string in the array?
|
|
505
|
+
*
|
|
506
|
+
* @param String aStr
|
|
507
|
+
*/
|
|
508
|
+
ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
|
|
509
|
+
if (hasNativeMap) {
|
|
510
|
+
var idx = this._set.get(aStr);
|
|
511
|
+
if (idx >= 0) return idx;
|
|
512
|
+
} else {
|
|
513
|
+
var sStr = util.toSetString(aStr);
|
|
514
|
+
if (has.call(this._set, sStr)) return this._set[sStr];
|
|
515
|
+
}
|
|
516
|
+
throw new Error("\"" + aStr + "\" is not in the set.");
|
|
517
|
+
};
|
|
518
|
+
/**
|
|
519
|
+
* What is the element at the given index?
|
|
520
|
+
*
|
|
521
|
+
* @param Number aIdx
|
|
522
|
+
*/
|
|
523
|
+
ArraySet.prototype.at = function ArraySet_at(aIdx) {
|
|
524
|
+
if (aIdx >= 0 && aIdx < this._array.length) return this._array[aIdx];
|
|
525
|
+
throw new Error("No element indexed by " + aIdx);
|
|
526
|
+
};
|
|
527
|
+
/**
|
|
528
|
+
* Returns the array representation of this set (which has the proper indices
|
|
529
|
+
* indicated by indexOf). Note that this is a copy of the internal array used
|
|
530
|
+
* for storing the members so that no one can mess with internal state.
|
|
531
|
+
*/
|
|
532
|
+
ArraySet.prototype.toArray = function ArraySet_toArray() {
|
|
533
|
+
return this._array.slice();
|
|
534
|
+
};
|
|
535
|
+
exports.ArraySet = ArraySet;
|
|
536
|
+
}));
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region ../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/mapping-list.js
|
|
539
|
+
var require_mapping_list = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
540
|
+
var util = require_util();
|
|
541
|
+
/**
|
|
542
|
+
* Determine whether mappingB is after mappingA with respect to generated
|
|
543
|
+
* position.
|
|
544
|
+
*/
|
|
545
|
+
function generatedPositionAfter(mappingA, mappingB) {
|
|
546
|
+
var lineA = mappingA.generatedLine;
|
|
547
|
+
var lineB = mappingB.generatedLine;
|
|
548
|
+
var columnA = mappingA.generatedColumn;
|
|
549
|
+
var columnB = mappingB.generatedColumn;
|
|
550
|
+
return lineB > lineA || lineB == lineA && columnB >= columnA || util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* A data structure to provide a sorted view of accumulated mappings in a
|
|
554
|
+
* performance conscious manner. It trades a neglibable overhead in general
|
|
555
|
+
* case for a large speedup in case of mappings being added in order.
|
|
556
|
+
*/
|
|
557
|
+
function MappingList() {
|
|
558
|
+
this._array = [];
|
|
559
|
+
this._sorted = true;
|
|
560
|
+
this._last = {
|
|
561
|
+
generatedLine: -1,
|
|
562
|
+
generatedColumn: 0
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Iterate through internal items. This method takes the same arguments that
|
|
567
|
+
* `Array.prototype.forEach` takes.
|
|
568
|
+
*
|
|
569
|
+
* NOTE: The order of the mappings is NOT guaranteed.
|
|
570
|
+
*/
|
|
571
|
+
MappingList.prototype.unsortedForEach = function MappingList_forEach(aCallback, aThisArg) {
|
|
572
|
+
this._array.forEach(aCallback, aThisArg);
|
|
573
|
+
};
|
|
574
|
+
/**
|
|
575
|
+
* Add the given source mapping.
|
|
576
|
+
*
|
|
577
|
+
* @param Object aMapping
|
|
578
|
+
*/
|
|
579
|
+
MappingList.prototype.add = function MappingList_add(aMapping) {
|
|
580
|
+
if (generatedPositionAfter(this._last, aMapping)) {
|
|
581
|
+
this._last = aMapping;
|
|
582
|
+
this._array.push(aMapping);
|
|
583
|
+
} else {
|
|
584
|
+
this._sorted = false;
|
|
585
|
+
this._array.push(aMapping);
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
/**
|
|
589
|
+
* Returns the flat, sorted array of mappings. The mappings are sorted by
|
|
590
|
+
* generated position.
|
|
591
|
+
*
|
|
592
|
+
* WARNING: This method returns internal data without copying, for
|
|
593
|
+
* performance. The return value must NOT be mutated, and should be treated as
|
|
594
|
+
* an immutable borrow. If you want to take ownership, you must make your own
|
|
595
|
+
* copy.
|
|
596
|
+
*/
|
|
597
|
+
MappingList.prototype.toArray = function MappingList_toArray() {
|
|
598
|
+
if (!this._sorted) {
|
|
599
|
+
this._array.sort(util.compareByGeneratedPositionsInflated);
|
|
600
|
+
this._sorted = true;
|
|
601
|
+
}
|
|
602
|
+
return this._array;
|
|
603
|
+
};
|
|
604
|
+
exports.MappingList = MappingList;
|
|
605
|
+
}));
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region ../../node_modules/.pnpm/source-map-js@1.2.1/node_modules/source-map-js/lib/source-map-generator.js
|
|
608
|
+
var require_source_map_generator = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
609
|
+
var base64VLQ = require_base64_vlq();
|
|
610
|
+
var util = require_util();
|
|
611
|
+
var ArraySet = require_array_set().ArraySet;
|
|
612
|
+
var MappingList = require_mapping_list().MappingList;
|
|
613
|
+
/**
|
|
614
|
+
* An instance of the SourceMapGenerator represents a source map which is
|
|
615
|
+
* being built incrementally. You may pass an object with the following
|
|
616
|
+
* properties:
|
|
617
|
+
*
|
|
618
|
+
* - file: The filename of the generated source.
|
|
619
|
+
* - sourceRoot: A root for all relative URLs in this source map.
|
|
620
|
+
*/
|
|
621
|
+
function SourceMapGenerator(aArgs) {
|
|
622
|
+
if (!aArgs) aArgs = {};
|
|
623
|
+
this._file = util.getArg(aArgs, "file", null);
|
|
624
|
+
this._sourceRoot = util.getArg(aArgs, "sourceRoot", null);
|
|
625
|
+
this._skipValidation = util.getArg(aArgs, "skipValidation", false);
|
|
626
|
+
this._ignoreInvalidMapping = util.getArg(aArgs, "ignoreInvalidMapping", false);
|
|
627
|
+
this._sources = new ArraySet();
|
|
628
|
+
this._names = new ArraySet();
|
|
629
|
+
this._mappings = new MappingList();
|
|
630
|
+
this._sourcesContents = null;
|
|
631
|
+
}
|
|
632
|
+
SourceMapGenerator.prototype._version = 3;
|
|
633
|
+
/**
|
|
634
|
+
* Creates a new SourceMapGenerator based on a SourceMapConsumer
|
|
635
|
+
*
|
|
636
|
+
* @param aSourceMapConsumer The SourceMap.
|
|
637
|
+
*/
|
|
638
|
+
SourceMapGenerator.fromSourceMap = function SourceMapGenerator_fromSourceMap(aSourceMapConsumer, generatorOps) {
|
|
639
|
+
var sourceRoot = aSourceMapConsumer.sourceRoot;
|
|
640
|
+
var generator = new SourceMapGenerator(Object.assign(generatorOps || {}, {
|
|
641
|
+
file: aSourceMapConsumer.file,
|
|
642
|
+
sourceRoot
|
|
643
|
+
}));
|
|
644
|
+
aSourceMapConsumer.eachMapping(function(mapping) {
|
|
645
|
+
var newMapping = { generated: {
|
|
646
|
+
line: mapping.generatedLine,
|
|
647
|
+
column: mapping.generatedColumn
|
|
648
|
+
} };
|
|
649
|
+
if (mapping.source != null) {
|
|
650
|
+
newMapping.source = mapping.source;
|
|
651
|
+
if (sourceRoot != null) newMapping.source = util.relative(sourceRoot, newMapping.source);
|
|
652
|
+
newMapping.original = {
|
|
653
|
+
line: mapping.originalLine,
|
|
654
|
+
column: mapping.originalColumn
|
|
655
|
+
};
|
|
656
|
+
if (mapping.name != null) newMapping.name = mapping.name;
|
|
657
|
+
}
|
|
658
|
+
generator.addMapping(newMapping);
|
|
659
|
+
});
|
|
660
|
+
aSourceMapConsumer.sources.forEach(function(sourceFile) {
|
|
661
|
+
var sourceRelative = sourceFile;
|
|
662
|
+
if (sourceRoot !== null) sourceRelative = util.relative(sourceRoot, sourceFile);
|
|
663
|
+
if (!generator._sources.has(sourceRelative)) generator._sources.add(sourceRelative);
|
|
664
|
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
|
665
|
+
if (content != null) generator.setSourceContent(sourceFile, content);
|
|
666
|
+
});
|
|
667
|
+
return generator;
|
|
668
|
+
};
|
|
669
|
+
/**
|
|
670
|
+
* Add a single mapping from original source line and column to the generated
|
|
671
|
+
* source's line and column for this source map being created. The mapping
|
|
672
|
+
* object should have the following properties:
|
|
673
|
+
*
|
|
674
|
+
* - generated: An object with the generated line and column positions.
|
|
675
|
+
* - original: An object with the original line and column positions.
|
|
676
|
+
* - source: The original source file (relative to the sourceRoot).
|
|
677
|
+
* - name: An optional original token name for this mapping.
|
|
678
|
+
*/
|
|
679
|
+
SourceMapGenerator.prototype.addMapping = function SourceMapGenerator_addMapping(aArgs) {
|
|
680
|
+
var generated = util.getArg(aArgs, "generated");
|
|
681
|
+
var original = util.getArg(aArgs, "original", null);
|
|
682
|
+
var source = util.getArg(aArgs, "source", null);
|
|
683
|
+
var name = util.getArg(aArgs, "name", null);
|
|
684
|
+
if (!this._skipValidation) {
|
|
685
|
+
if (this._validateMapping(generated, original, source, name) === false) return;
|
|
686
|
+
}
|
|
687
|
+
if (source != null) {
|
|
688
|
+
source = String(source);
|
|
689
|
+
if (!this._sources.has(source)) this._sources.add(source);
|
|
690
|
+
}
|
|
691
|
+
if (name != null) {
|
|
692
|
+
name = String(name);
|
|
693
|
+
if (!this._names.has(name)) this._names.add(name);
|
|
694
|
+
}
|
|
695
|
+
this._mappings.add({
|
|
696
|
+
generatedLine: generated.line,
|
|
697
|
+
generatedColumn: generated.column,
|
|
698
|
+
originalLine: original != null && original.line,
|
|
699
|
+
originalColumn: original != null && original.column,
|
|
700
|
+
source,
|
|
701
|
+
name
|
|
702
|
+
});
|
|
703
|
+
};
|
|
704
|
+
/**
|
|
705
|
+
* Set the source content for a source file.
|
|
706
|
+
*/
|
|
707
|
+
SourceMapGenerator.prototype.setSourceContent = function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
|
|
708
|
+
var source = aSourceFile;
|
|
709
|
+
if (this._sourceRoot != null) source = util.relative(this._sourceRoot, source);
|
|
710
|
+
if (aSourceContent != null) {
|
|
711
|
+
if (!this._sourcesContents) this._sourcesContents = Object.create(null);
|
|
712
|
+
this._sourcesContents[util.toSetString(source)] = aSourceContent;
|
|
713
|
+
} else if (this._sourcesContents) {
|
|
714
|
+
delete this._sourcesContents[util.toSetString(source)];
|
|
715
|
+
if (Object.keys(this._sourcesContents).length === 0) this._sourcesContents = null;
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
/**
|
|
719
|
+
* Applies the mappings of a sub-source-map for a specific source file to the
|
|
720
|
+
* source map being generated. Each mapping to the supplied source file is
|
|
721
|
+
* rewritten using the supplied source map. Note: The resolution for the
|
|
722
|
+
* resulting mappings is the minimium of this map and the supplied map.
|
|
723
|
+
*
|
|
724
|
+
* @param aSourceMapConsumer The source map to be applied.
|
|
725
|
+
* @param aSourceFile Optional. The filename of the source file.
|
|
726
|
+
* If omitted, SourceMapConsumer's file property will be used.
|
|
727
|
+
* @param aSourceMapPath Optional. The dirname of the path to the source map
|
|
728
|
+
* to be applied. If relative, it is relative to the SourceMapConsumer.
|
|
729
|
+
* This parameter is needed when the two source maps aren't in the same
|
|
730
|
+
* directory, and the source map to be applied contains relative source
|
|
731
|
+
* paths. If so, those relative source paths need to be rewritten
|
|
732
|
+
* relative to the SourceMapGenerator.
|
|
733
|
+
*/
|
|
734
|
+
SourceMapGenerator.prototype.applySourceMap = function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
|
|
735
|
+
var sourceFile = aSourceFile;
|
|
736
|
+
if (aSourceFile == null) {
|
|
737
|
+
if (aSourceMapConsumer.file == null) throw new Error("SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's \"file\" property. Both were omitted.");
|
|
738
|
+
sourceFile = aSourceMapConsumer.file;
|
|
739
|
+
}
|
|
740
|
+
var sourceRoot = this._sourceRoot;
|
|
741
|
+
if (sourceRoot != null) sourceFile = util.relative(sourceRoot, sourceFile);
|
|
742
|
+
var newSources = new ArraySet();
|
|
743
|
+
var newNames = new ArraySet();
|
|
744
|
+
this._mappings.unsortedForEach(function(mapping) {
|
|
745
|
+
if (mapping.source === sourceFile && mapping.originalLine != null) {
|
|
746
|
+
var original = aSourceMapConsumer.originalPositionFor({
|
|
747
|
+
line: mapping.originalLine,
|
|
748
|
+
column: mapping.originalColumn
|
|
749
|
+
});
|
|
750
|
+
if (original.source != null) {
|
|
751
|
+
mapping.source = original.source;
|
|
752
|
+
if (aSourceMapPath != null) mapping.source = util.join(aSourceMapPath, mapping.source);
|
|
753
|
+
if (sourceRoot != null) mapping.source = util.relative(sourceRoot, mapping.source);
|
|
754
|
+
mapping.originalLine = original.line;
|
|
755
|
+
mapping.originalColumn = original.column;
|
|
756
|
+
if (original.name != null) mapping.name = original.name;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
var source = mapping.source;
|
|
760
|
+
if (source != null && !newSources.has(source)) newSources.add(source);
|
|
761
|
+
var name = mapping.name;
|
|
762
|
+
if (name != null && !newNames.has(name)) newNames.add(name);
|
|
763
|
+
}, this);
|
|
764
|
+
this._sources = newSources;
|
|
765
|
+
this._names = newNames;
|
|
766
|
+
aSourceMapConsumer.sources.forEach(function(sourceFile) {
|
|
767
|
+
var content = aSourceMapConsumer.sourceContentFor(sourceFile);
|
|
768
|
+
if (content != null) {
|
|
769
|
+
if (aSourceMapPath != null) sourceFile = util.join(aSourceMapPath, sourceFile);
|
|
770
|
+
if (sourceRoot != null) sourceFile = util.relative(sourceRoot, sourceFile);
|
|
771
|
+
this.setSourceContent(sourceFile, content);
|
|
772
|
+
}
|
|
773
|
+
}, this);
|
|
774
|
+
};
|
|
775
|
+
/**
|
|
776
|
+
* A mapping can have one of the three levels of data:
|
|
777
|
+
*
|
|
778
|
+
* 1. Just the generated position.
|
|
779
|
+
* 2. The Generated position, original position, and original source.
|
|
780
|
+
* 3. Generated and original position, original source, as well as a name
|
|
781
|
+
* token.
|
|
782
|
+
*
|
|
783
|
+
* To maintain consistency, we validate that any new mapping being added falls
|
|
784
|
+
* in to one of these categories.
|
|
785
|
+
*/
|
|
786
|
+
SourceMapGenerator.prototype._validateMapping = function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, aName) {
|
|
787
|
+
if (aOriginal && typeof aOriginal.line !== "number" && typeof aOriginal.column !== "number") {
|
|
788
|
+
var message = "original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.";
|
|
789
|
+
if (this._ignoreInvalidMapping) {
|
|
790
|
+
if (typeof console !== "undefined" && console.warn) console.warn(message);
|
|
791
|
+
return false;
|
|
792
|
+
} else throw new Error(message);
|
|
793
|
+
}
|
|
794
|
+
if (aGenerated && "line" in aGenerated && "column" in aGenerated && aGenerated.line > 0 && aGenerated.column >= 0 && !aOriginal && !aSource && !aName) return;
|
|
795
|
+
else if (aGenerated && "line" in aGenerated && "column" in aGenerated && aOriginal && "line" in aOriginal && "column" in aOriginal && aGenerated.line > 0 && aGenerated.column >= 0 && aOriginal.line > 0 && aOriginal.column >= 0 && aSource) return;
|
|
796
|
+
else {
|
|
797
|
+
var message = "Invalid mapping: " + JSON.stringify({
|
|
798
|
+
generated: aGenerated,
|
|
799
|
+
source: aSource,
|
|
800
|
+
original: aOriginal,
|
|
801
|
+
name: aName
|
|
802
|
+
});
|
|
803
|
+
if (this._ignoreInvalidMapping) {
|
|
804
|
+
if (typeof console !== "undefined" && console.warn) console.warn(message);
|
|
805
|
+
return false;
|
|
806
|
+
} else throw new Error(message);
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
/**
|
|
810
|
+
* Serialize the accumulated mappings in to the stream of base 64 VLQs
|
|
811
|
+
* specified by the source map format.
|
|
812
|
+
*/
|
|
813
|
+
SourceMapGenerator.prototype._serializeMappings = function SourceMapGenerator_serializeMappings() {
|
|
814
|
+
var previousGeneratedColumn = 0;
|
|
815
|
+
var previousGeneratedLine = 1;
|
|
816
|
+
var previousOriginalColumn = 0;
|
|
817
|
+
var previousOriginalLine = 0;
|
|
818
|
+
var previousName = 0;
|
|
819
|
+
var previousSource = 0;
|
|
820
|
+
var result = "";
|
|
821
|
+
var next;
|
|
822
|
+
var mapping;
|
|
823
|
+
var nameIdx;
|
|
824
|
+
var sourceIdx;
|
|
825
|
+
var mappings = this._mappings.toArray();
|
|
826
|
+
for (var i = 0, len = mappings.length; i < len; i++) {
|
|
827
|
+
mapping = mappings[i];
|
|
828
|
+
next = "";
|
|
829
|
+
if (mapping.generatedLine !== previousGeneratedLine) {
|
|
830
|
+
previousGeneratedColumn = 0;
|
|
831
|
+
while (mapping.generatedLine !== previousGeneratedLine) {
|
|
832
|
+
next += ";";
|
|
833
|
+
previousGeneratedLine++;
|
|
834
|
+
}
|
|
835
|
+
} else if (i > 0) {
|
|
836
|
+
if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) continue;
|
|
837
|
+
next += ",";
|
|
838
|
+
}
|
|
839
|
+
next += base64VLQ.encode(mapping.generatedColumn - previousGeneratedColumn);
|
|
840
|
+
previousGeneratedColumn = mapping.generatedColumn;
|
|
841
|
+
if (mapping.source != null) {
|
|
842
|
+
sourceIdx = this._sources.indexOf(mapping.source);
|
|
843
|
+
next += base64VLQ.encode(sourceIdx - previousSource);
|
|
844
|
+
previousSource = sourceIdx;
|
|
845
|
+
next += base64VLQ.encode(mapping.originalLine - 1 - previousOriginalLine);
|
|
846
|
+
previousOriginalLine = mapping.originalLine - 1;
|
|
847
|
+
next += base64VLQ.encode(mapping.originalColumn - previousOriginalColumn);
|
|
848
|
+
previousOriginalColumn = mapping.originalColumn;
|
|
849
|
+
if (mapping.name != null) {
|
|
850
|
+
nameIdx = this._names.indexOf(mapping.name);
|
|
851
|
+
next += base64VLQ.encode(nameIdx - previousName);
|
|
852
|
+
previousName = nameIdx;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
result += next;
|
|
856
|
+
}
|
|
857
|
+
return result;
|
|
858
|
+
};
|
|
859
|
+
SourceMapGenerator.prototype._generateSourcesContent = function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
|
|
860
|
+
return aSources.map(function(source) {
|
|
861
|
+
if (!this._sourcesContents) return null;
|
|
862
|
+
if (aSourceRoot != null) source = util.relative(aSourceRoot, source);
|
|
863
|
+
var key = util.toSetString(source);
|
|
864
|
+
return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) ? this._sourcesContents[key] : null;
|
|
865
|
+
}, this);
|
|
866
|
+
};
|
|
867
|
+
/**
|
|
868
|
+
* Externalize the source map.
|
|
869
|
+
*/
|
|
870
|
+
SourceMapGenerator.prototype.toJSON = function SourceMapGenerator_toJSON() {
|
|
871
|
+
var map = {
|
|
872
|
+
version: this._version,
|
|
873
|
+
sources: this._sources.toArray(),
|
|
874
|
+
names: this._names.toArray(),
|
|
875
|
+
mappings: this._serializeMappings()
|
|
876
|
+
};
|
|
877
|
+
if (this._file != null) map.file = this._file;
|
|
878
|
+
if (this._sourceRoot != null) map.sourceRoot = this._sourceRoot;
|
|
879
|
+
if (this._sourcesContents) map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
|
|
880
|
+
return map;
|
|
881
|
+
};
|
|
882
|
+
/**
|
|
883
|
+
* Render the source map being generated to a string.
|
|
884
|
+
*/
|
|
885
|
+
SourceMapGenerator.prototype.toString = function SourceMapGenerator_toString() {
|
|
886
|
+
return JSON.stringify(this.toJSON());
|
|
887
|
+
};
|
|
888
|
+
exports.SourceMapGenerator = SourceMapGenerator;
|
|
889
|
+
}));
|
|
890
|
+
//#endregion
|
|
891
|
+
export { require_base64_vlq as i, require_array_set as n, require_util as r, require_source_map_generator as t };
|
|
892
|
+
|
|
893
|
+
//# sourceMappingURL=source-map-generator-DpO-ejrt.mjs.map
|