rollup 1.25.2 → 1.26.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/dist/rollup.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v1.25.2
4
- Wed, 23 Oct 2019 05:48:50 GMT - commit b123169865e670d3b961d5afaef090aa4e019fef
3
+ Rollup.js v1.26.0
4
+ Sun, 27 Oct 2019 19:40:08 GMT - commit 53fb6fe344376cad0af73d43a6d9790cb7a1e2b9
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -13,6 +13,7 @@ import path, { relative as relative$1, extname, basename, dirname, resolve, sep
13
13
  import { writeFile as writeFile$1, readdirSync, mkdirSync, readFile as readFile$1, lstatSync, realpathSync, statSync, watch as watch$1 } from 'fs';
14
14
  import * as acorn__default from 'acorn';
15
15
  import { Parser } from 'acorn';
16
+ import { createHash as createHash$2 } from 'crypto';
16
17
  import { EventEmitter } from 'events';
17
18
  import module from 'module';
18
19
 
@@ -49,971 +50,424 @@ function __awaiter(thisArg, _arguments, P, generator) {
49
50
  });
50
51
  }
51
52
 
52
- var version = "1.25.2";
53
+ var version = "1.26.0";
53
54
 
54
- var minimalisticAssert = assert;
55
- function assert(val, msg) {
56
- if (!val)
57
- throw new Error(msg || 'Assertion failed');
58
- }
59
- assert.equal = function assertEqual(l, r, msg) {
60
- if (l != r)
61
- throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
62
- };
63
-
64
- function createCommonjsModule(fn, module) {
65
- return module = { exports: {} }, fn(module, module.exports), module.exports;
55
+ var charToInteger = {};
56
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
57
+ for (var i = 0; i < chars.length; i++) {
58
+ charToInteger[chars.charCodeAt(i)] = i;
66
59
  }
67
-
68
- var inherits_browser = createCommonjsModule(function (module) {
69
- if (typeof Object.create === 'function') {
70
- // implementation from standard node.js 'util' module
71
- module.exports = function inherits(ctor, superCtor) {
72
- ctor.super_ = superCtor;
73
- ctor.prototype = Object.create(superCtor.prototype, {
74
- constructor: {
75
- value: ctor,
76
- enumerable: false,
77
- writable: true,
78
- configurable: true
60
+ function decode(mappings) {
61
+ var generatedCodeColumn = 0; // first field
62
+ var sourceFileIndex = 0; // second field
63
+ var sourceCodeLine = 0; // third field
64
+ var sourceCodeColumn = 0; // fourth field
65
+ var nameIndex = 0; // fifth field
66
+ var decoded = [];
67
+ var line = [];
68
+ var segment = [];
69
+ for (var i = 0, j = 0, shift = 0, value = 0, len = mappings.length; i < len; i++) {
70
+ var c = mappings.charCodeAt(i);
71
+ if (c === 44) { // ","
72
+ if (segment.length)
73
+ line.push(segment);
74
+ segment = [];
75
+ j = 0;
76
+ }
77
+ else if (c === 59) { // ";"
78
+ if (segment.length)
79
+ line.push(segment);
80
+ segment = [];
81
+ j = 0;
82
+ decoded.push(line);
83
+ line = [];
84
+ generatedCodeColumn = 0;
85
+ }
86
+ else {
87
+ var integer = charToInteger[c];
88
+ if (integer === undefined) {
89
+ throw new Error('Invalid character (' + String.fromCharCode(c) + ')');
90
+ }
91
+ var hasContinuationBit = integer & 32;
92
+ integer &= 31;
93
+ value += integer << shift;
94
+ if (hasContinuationBit) {
95
+ shift += 5;
96
+ }
97
+ else {
98
+ var shouldNegate = value & 1;
99
+ value >>>= 1;
100
+ if (shouldNegate) {
101
+ value = -value;
102
+ if (value === 0)
103
+ value = -0x80000000;
79
104
  }
80
- });
81
- };
82
- }
83
- else {
84
- // old school shim for old browsers
85
- module.exports = function inherits(ctor, superCtor) {
86
- ctor.super_ = superCtor;
87
- var TempCtor = function () { };
88
- TempCtor.prototype = superCtor.prototype;
89
- ctor.prototype = new TempCtor();
90
- ctor.prototype.constructor = ctor;
91
- };
92
- }
93
- });
94
-
95
- var inherits = createCommonjsModule(function (module) {
96
- try {
97
- var util$1 = util;
98
- if (typeof util$1.inherits !== 'function')
99
- throw '';
100
- module.exports = util$1.inherits;
101
- }
102
- catch (e) {
103
- module.exports = inherits_browser;
104
- }
105
- });
106
-
107
- var inherits_1 = inherits;
108
- function isSurrogatePair(msg, i) {
109
- if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
110
- return false;
111
- }
112
- if (i < 0 || i + 1 >= msg.length) {
113
- return false;
114
- }
115
- return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
116
- }
117
- function toArray(msg, enc) {
118
- if (Array.isArray(msg))
119
- return msg.slice();
120
- if (!msg)
121
- return [];
122
- var res = [];
123
- if (typeof msg === 'string') {
124
- if (!enc) {
125
- // Inspired by stringToUtf8ByteArray() in closure-library by Google
126
- // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
127
- // Apache License 2.0
128
- // https://github.com/google/closure-library/blob/master/LICENSE
129
- var p = 0;
130
- for (var i = 0; i < msg.length; i++) {
131
- var c = msg.charCodeAt(i);
132
- if (c < 128) {
133
- res[p++] = c;
105
+ if (j == 0) {
106
+ generatedCodeColumn += value;
107
+ segment.push(generatedCodeColumn);
134
108
  }
135
- else if (c < 2048) {
136
- res[p++] = (c >> 6) | 192;
137
- res[p++] = (c & 63) | 128;
109
+ else if (j === 1) {
110
+ sourceFileIndex += value;
111
+ segment.push(sourceFileIndex);
138
112
  }
139
- else if (isSurrogatePair(msg, i)) {
140
- c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
141
- res[p++] = (c >> 18) | 240;
142
- res[p++] = ((c >> 12) & 63) | 128;
143
- res[p++] = ((c >> 6) & 63) | 128;
144
- res[p++] = (c & 63) | 128;
113
+ else if (j === 2) {
114
+ sourceCodeLine += value;
115
+ segment.push(sourceCodeLine);
145
116
  }
146
- else {
147
- res[p++] = (c >> 12) | 224;
148
- res[p++] = ((c >> 6) & 63) | 128;
149
- res[p++] = (c & 63) | 128;
117
+ else if (j === 3) {
118
+ sourceCodeColumn += value;
119
+ segment.push(sourceCodeColumn);
120
+ }
121
+ else if (j === 4) {
122
+ nameIndex += value;
123
+ segment.push(nameIndex);
150
124
  }
125
+ j++;
126
+ value = shift = 0; // reset
151
127
  }
152
128
  }
153
- else if (enc === 'hex') {
154
- msg = msg.replace(/[^a-z0-9]+/ig, '');
155
- if (msg.length % 2 !== 0)
156
- msg = '0' + msg;
157
- for (i = 0; i < msg.length; i += 2)
158
- res.push(parseInt(msg[i] + msg[i + 1], 16));
159
- }
160
- }
161
- else {
162
- for (i = 0; i < msg.length; i++)
163
- res[i] = msg[i] | 0;
164
129
  }
165
- return res;
166
- }
167
- var toArray_1 = toArray;
168
- function toHex(msg) {
169
- var res = '';
170
- for (var i = 0; i < msg.length; i++)
171
- res += zero2(msg[i].toString(16));
172
- return res;
173
- }
174
- var toHex_1 = toHex;
175
- function htonl(w) {
176
- var res = (w >>> 24) |
177
- ((w >>> 8) & 0xff00) |
178
- ((w << 8) & 0xff0000) |
179
- ((w & 0xff) << 24);
180
- return res >>> 0;
130
+ if (segment.length)
131
+ line.push(segment);
132
+ decoded.push(line);
133
+ return decoded;
181
134
  }
182
- var htonl_1 = htonl;
183
- function toHex32(msg, endian) {
184
- var res = '';
185
- for (var i = 0; i < msg.length; i++) {
186
- var w = msg[i];
187
- if (endian === 'little')
188
- w = htonl(w);
189
- res += zero8(w.toString(16));
135
+ function encode(decoded) {
136
+ var sourceFileIndex = 0; // second field
137
+ var sourceCodeLine = 0; // third field
138
+ var sourceCodeColumn = 0; // fourth field
139
+ var nameIndex = 0; // fifth field
140
+ var mappings = '';
141
+ for (var i = 0; i < decoded.length; i++) {
142
+ var line = decoded[i];
143
+ if (i > 0)
144
+ mappings += ';';
145
+ if (line.length === 0)
146
+ continue;
147
+ var generatedCodeColumn = 0; // first field
148
+ var lineMappings = [];
149
+ for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {
150
+ var segment = line_1[_i];
151
+ var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);
152
+ generatedCodeColumn = segment[0];
153
+ if (segment.length > 1) {
154
+ segmentMappings +=
155
+ encodeInteger(segment[1] - sourceFileIndex) +
156
+ encodeInteger(segment[2] - sourceCodeLine) +
157
+ encodeInteger(segment[3] - sourceCodeColumn);
158
+ sourceFileIndex = segment[1];
159
+ sourceCodeLine = segment[2];
160
+ sourceCodeColumn = segment[3];
161
+ }
162
+ if (segment.length === 5) {
163
+ segmentMappings += encodeInteger(segment[4] - nameIndex);
164
+ nameIndex = segment[4];
165
+ }
166
+ lineMappings.push(segmentMappings);
167
+ }
168
+ mappings += lineMappings.join(',');
190
169
  }
191
- return res;
170
+ return mappings;
192
171
  }
193
- var toHex32_1 = toHex32;
194
- function zero2(word) {
195
- if (word.length === 1)
196
- return '0' + word;
197
- else
198
- return word;
172
+ function encodeInteger(num) {
173
+ var result = '';
174
+ num = num < 0 ? (-num << 1) | 1 : num << 1;
175
+ do {
176
+ var clamped = num & 31;
177
+ num >>>= 5;
178
+ if (num > 0) {
179
+ clamped |= 32;
180
+ }
181
+ result += chars[clamped];
182
+ } while (num > 0);
183
+ return result;
199
184
  }
200
- var zero2_1 = zero2;
201
- function zero8(word) {
202
- if (word.length === 7)
203
- return '0' + word;
204
- else if (word.length === 6)
205
- return '00' + word;
206
- else if (word.length === 5)
207
- return '000' + word;
208
- else if (word.length === 4)
209
- return '0000' + word;
210
- else if (word.length === 3)
211
- return '00000' + word;
212
- else if (word.length === 2)
213
- return '000000' + word;
214
- else if (word.length === 1)
215
- return '0000000' + word;
216
- else
217
- return word;
218
- }
219
- var zero8_1 = zero8;
220
- function join32(msg, start, end, endian) {
221
- var len = end - start;
222
- minimalisticAssert(len % 4 === 0);
223
- var res = new Array(len / 4);
224
- for (var i = 0, k = start; i < res.length; i++, k += 4) {
225
- var w;
226
- if (endian === 'big')
227
- w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
228
- else
229
- w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
230
- res[i] = w >>> 0;
185
+
186
+ var Chunk = function Chunk(start, end, content) {
187
+ this.start = start;
188
+ this.end = end;
189
+ this.original = content;
190
+ this.intro = '';
191
+ this.outro = '';
192
+ this.content = content;
193
+ this.storeName = false;
194
+ this.edited = false;
195
+ // we make these non-enumerable, for sanity while debugging
196
+ Object.defineProperties(this, {
197
+ previous: { writable: true, value: null },
198
+ next: { writable: true, value: null }
199
+ });
200
+ };
201
+ Chunk.prototype.appendLeft = function appendLeft(content) {
202
+ this.outro += content;
203
+ };
204
+ Chunk.prototype.appendRight = function appendRight(content) {
205
+ this.intro = this.intro + content;
206
+ };
207
+ Chunk.prototype.clone = function clone() {
208
+ var chunk = new Chunk(this.start, this.end, this.original);
209
+ chunk.intro = this.intro;
210
+ chunk.outro = this.outro;
211
+ chunk.content = this.content;
212
+ chunk.storeName = this.storeName;
213
+ chunk.edited = this.edited;
214
+ return chunk;
215
+ };
216
+ Chunk.prototype.contains = function contains(index) {
217
+ return this.start < index && index < this.end;
218
+ };
219
+ Chunk.prototype.eachNext = function eachNext(fn) {
220
+ var chunk = this;
221
+ while (chunk) {
222
+ fn(chunk);
223
+ chunk = chunk.next;
231
224
  }
232
- return res;
233
- }
234
- var join32_1 = join32;
235
- function split32(msg, endian) {
236
- var res = new Array(msg.length * 4);
237
- for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
238
- var m = msg[i];
239
- if (endian === 'big') {
240
- res[k] = m >>> 24;
241
- res[k + 1] = (m >>> 16) & 0xff;
242
- res[k + 2] = (m >>> 8) & 0xff;
243
- res[k + 3] = m & 0xff;
225
+ };
226
+ Chunk.prototype.eachPrevious = function eachPrevious(fn) {
227
+ var chunk = this;
228
+ while (chunk) {
229
+ fn(chunk);
230
+ chunk = chunk.previous;
231
+ }
232
+ };
233
+ Chunk.prototype.edit = function edit(content, storeName, contentOnly) {
234
+ this.content = content;
235
+ if (!contentOnly) {
236
+ this.intro = '';
237
+ this.outro = '';
238
+ }
239
+ this.storeName = storeName;
240
+ this.edited = true;
241
+ return this;
242
+ };
243
+ Chunk.prototype.prependLeft = function prependLeft(content) {
244
+ this.outro = content + this.outro;
245
+ };
246
+ Chunk.prototype.prependRight = function prependRight(content) {
247
+ this.intro = content + this.intro;
248
+ };
249
+ Chunk.prototype.split = function split(index) {
250
+ var sliceIndex = index - this.start;
251
+ var originalBefore = this.original.slice(0, sliceIndex);
252
+ var originalAfter = this.original.slice(sliceIndex);
253
+ this.original = originalBefore;
254
+ var newChunk = new Chunk(index, this.end, originalAfter);
255
+ newChunk.outro = this.outro;
256
+ this.outro = '';
257
+ this.end = index;
258
+ if (this.edited) {
259
+ // TODO is this block necessary?...
260
+ newChunk.edit('', false);
261
+ this.content = '';
262
+ }
263
+ else {
264
+ this.content = originalBefore;
265
+ }
266
+ newChunk.next = this.next;
267
+ if (newChunk.next) {
268
+ newChunk.next.previous = newChunk;
269
+ }
270
+ newChunk.previous = this;
271
+ this.next = newChunk;
272
+ return newChunk;
273
+ };
274
+ Chunk.prototype.toString = function toString() {
275
+ return this.intro + this.content + this.outro;
276
+ };
277
+ Chunk.prototype.trimEnd = function trimEnd(rx) {
278
+ this.outro = this.outro.replace(rx, '');
279
+ if (this.outro.length) {
280
+ return true;
281
+ }
282
+ var trimmed = this.content.replace(rx, '');
283
+ if (trimmed.length) {
284
+ if (trimmed !== this.content) {
285
+ this.split(this.start + trimmed.length).edit('', undefined, true);
244
286
  }
245
- else {
246
- res[k + 3] = m >>> 24;
247
- res[k + 2] = (m >>> 16) & 0xff;
248
- res[k + 1] = (m >>> 8) & 0xff;
249
- res[k] = m & 0xff;
287
+ return true;
288
+ }
289
+ else {
290
+ this.edit('', undefined, true);
291
+ this.intro = this.intro.replace(rx, '');
292
+ if (this.intro.length) {
293
+ return true;
250
294
  }
251
295
  }
252
- return res;
253
- }
254
- var split32_1 = split32;
255
- function rotr32(w, b) {
256
- return (w >>> b) | (w << (32 - b));
257
- }
258
- var rotr32_1 = rotr32;
259
- function rotl32(w, b) {
260
- return (w << b) | (w >>> (32 - b));
296
+ };
297
+ Chunk.prototype.trimStart = function trimStart(rx) {
298
+ this.intro = this.intro.replace(rx, '');
299
+ if (this.intro.length) {
300
+ return true;
301
+ }
302
+ var trimmed = this.content.replace(rx, '');
303
+ if (trimmed.length) {
304
+ if (trimmed !== this.content) {
305
+ this.split(this.end - trimmed.length);
306
+ this.edit('', undefined, true);
307
+ }
308
+ return true;
309
+ }
310
+ else {
311
+ this.edit('', undefined, true);
312
+ this.outro = this.outro.replace(rx, '');
313
+ if (this.outro.length) {
314
+ return true;
315
+ }
316
+ }
317
+ };
318
+ var btoa = function () {
319
+ throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
320
+ };
321
+ if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
322
+ btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
261
323
  }
262
- var rotl32_1 = rotl32;
263
- function sum32(a, b) {
264
- return (a + b) >>> 0;
324
+ else if (typeof Buffer === 'function') {
325
+ btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
265
326
  }
266
- var sum32_1 = sum32;
267
- function sum32_3(a, b, c) {
268
- return (a + b + c) >>> 0;
327
+ var SourceMap = function SourceMap(properties) {
328
+ this.version = 3;
329
+ this.file = properties.file;
330
+ this.sources = properties.sources;
331
+ this.sourcesContent = properties.sourcesContent;
332
+ this.names = properties.names;
333
+ this.mappings = encode(properties.mappings);
334
+ };
335
+ SourceMap.prototype.toString = function toString() {
336
+ return JSON.stringify(this);
337
+ };
338
+ SourceMap.prototype.toUrl = function toUrl() {
339
+ return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
340
+ };
341
+ function guessIndent(code) {
342
+ var lines = code.split('\n');
343
+ var tabbed = lines.filter(function (line) { return /^\t+/.test(line); });
344
+ var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); });
345
+ if (tabbed.length === 0 && spaced.length === 0) {
346
+ return null;
347
+ }
348
+ // More lines tabbed than spaced? Assume tabs, and
349
+ // default to tabs in the case of a tie (or nothing
350
+ // to go on)
351
+ if (tabbed.length >= spaced.length) {
352
+ return '\t';
353
+ }
354
+ // Otherwise, we need to guess the multiple
355
+ var min = spaced.reduce(function (previous, current) {
356
+ var numSpaces = /^ +/.exec(current)[0].length;
357
+ return Math.min(numSpaces, previous);
358
+ }, Infinity);
359
+ return new Array(min + 1).join(' ');
269
360
  }
270
- var sum32_3_1 = sum32_3;
271
- function sum32_4(a, b, c, d) {
272
- return (a + b + c + d) >>> 0;
361
+ function getRelativePath(from, to) {
362
+ var fromParts = from.split(/[/\\]/);
363
+ var toParts = to.split(/[/\\]/);
364
+ fromParts.pop(); // get dirname
365
+ while (fromParts[0] === toParts[0]) {
366
+ fromParts.shift();
367
+ toParts.shift();
368
+ }
369
+ if (fromParts.length) {
370
+ var i = fromParts.length;
371
+ while (i--) {
372
+ fromParts[i] = '..';
373
+ }
374
+ }
375
+ return fromParts.concat(toParts).join('/');
273
376
  }
274
- var sum32_4_1 = sum32_4;
275
- function sum32_5(a, b, c, d, e) {
276
- return (a + b + c + d + e) >>> 0;
377
+ var toString = Object.prototype.toString;
378
+ function isObject(thing) {
379
+ return toString.call(thing) === '[object Object]';
277
380
  }
278
- var sum32_5_1 = sum32_5;
279
- function sum64(buf, pos, ah, al) {
280
- var bh = buf[pos];
281
- var bl = buf[pos + 1];
282
- var lo = (al + bl) >>> 0;
283
- var hi = (lo < al ? 1 : 0) + ah + bh;
284
- buf[pos] = hi >>> 0;
285
- buf[pos + 1] = lo;
286
- }
287
- var sum64_1 = sum64;
288
- function sum64_hi(ah, al, bh, bl) {
289
- var lo = (al + bl) >>> 0;
290
- var hi = (lo < al ? 1 : 0) + ah + bh;
291
- return hi >>> 0;
292
- }
293
- var sum64_hi_1 = sum64_hi;
294
- function sum64_lo(ah, al, bh, bl) {
295
- var lo = al + bl;
296
- return lo >>> 0;
297
- }
298
- var sum64_lo_1 = sum64_lo;
299
- function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
300
- var carry = 0;
301
- var lo = al;
302
- lo = (lo + bl) >>> 0;
303
- carry += lo < al ? 1 : 0;
304
- lo = (lo + cl) >>> 0;
305
- carry += lo < cl ? 1 : 0;
306
- lo = (lo + dl) >>> 0;
307
- carry += lo < dl ? 1 : 0;
308
- var hi = ah + bh + ch + dh + carry;
309
- return hi >>> 0;
310
- }
311
- var sum64_4_hi_1 = sum64_4_hi;
312
- function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
313
- var lo = al + bl + cl + dl;
314
- return lo >>> 0;
315
- }
316
- var sum64_4_lo_1 = sum64_4_lo;
317
- function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
318
- var carry = 0;
319
- var lo = al;
320
- lo = (lo + bl) >>> 0;
321
- carry += lo < al ? 1 : 0;
322
- lo = (lo + cl) >>> 0;
323
- carry += lo < cl ? 1 : 0;
324
- lo = (lo + dl) >>> 0;
325
- carry += lo < dl ? 1 : 0;
326
- lo = (lo + el) >>> 0;
327
- carry += lo < el ? 1 : 0;
328
- var hi = ah + bh + ch + dh + eh + carry;
329
- return hi >>> 0;
330
- }
331
- var sum64_5_hi_1 = sum64_5_hi;
332
- function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
333
- var lo = al + bl + cl + dl + el;
334
- return lo >>> 0;
335
- }
336
- var sum64_5_lo_1 = sum64_5_lo;
337
- function rotr64_hi(ah, al, num) {
338
- var r = (al << (32 - num)) | (ah >>> num);
339
- return r >>> 0;
340
- }
341
- var rotr64_hi_1 = rotr64_hi;
342
- function rotr64_lo(ah, al, num) {
343
- var r = (ah << (32 - num)) | (al >>> num);
344
- return r >>> 0;
345
- }
346
- var rotr64_lo_1 = rotr64_lo;
347
- function shr64_hi(ah, al, num) {
348
- return ah >>> num;
349
- }
350
- var shr64_hi_1 = shr64_hi;
351
- function shr64_lo(ah, al, num) {
352
- var r = (ah << (32 - num)) | (al >>> num);
353
- return r >>> 0;
381
+ function getLocator(source) {
382
+ var originalLines = source.split('\n');
383
+ var lineOffsets = [];
384
+ for (var i = 0, pos = 0; i < originalLines.length; i++) {
385
+ lineOffsets.push(pos);
386
+ pos += originalLines[i].length + 1;
387
+ }
388
+ return function locate(index) {
389
+ var i = 0;
390
+ var j = lineOffsets.length;
391
+ while (i < j) {
392
+ var m = (i + j) >> 1;
393
+ if (index < lineOffsets[m]) {
394
+ j = m;
395
+ }
396
+ else {
397
+ i = m + 1;
398
+ }
399
+ }
400
+ var line = i - 1;
401
+ var column = index - lineOffsets[line];
402
+ return { line: line, column: column };
403
+ };
354
404
  }
355
- var shr64_lo_1 = shr64_lo;
356
- var utils = {
357
- inherits: inherits_1,
358
- toArray: toArray_1,
359
- toHex: toHex_1,
360
- htonl: htonl_1,
361
- toHex32: toHex32_1,
362
- zero2: zero2_1,
363
- zero8: zero8_1,
364
- join32: join32_1,
365
- split32: split32_1,
366
- rotr32: rotr32_1,
367
- rotl32: rotl32_1,
368
- sum32: sum32_1,
369
- sum32_3: sum32_3_1,
370
- sum32_4: sum32_4_1,
371
- sum32_5: sum32_5_1,
372
- sum64: sum64_1,
373
- sum64_hi: sum64_hi_1,
374
- sum64_lo: sum64_lo_1,
375
- sum64_4_hi: sum64_4_hi_1,
376
- sum64_4_lo: sum64_4_lo_1,
377
- sum64_5_hi: sum64_5_hi_1,
378
- sum64_5_lo: sum64_5_lo_1,
379
- rotr64_hi: rotr64_hi_1,
380
- rotr64_lo: rotr64_lo_1,
381
- shr64_hi: shr64_hi_1,
382
- shr64_lo: shr64_lo_1
383
- };
384
-
385
- function BlockHash() {
405
+ var Mappings = function Mappings(hires) {
406
+ this.hires = hires;
407
+ this.generatedCodeLine = 0;
408
+ this.generatedCodeColumn = 0;
409
+ this.raw = [];
410
+ this.rawSegments = this.raw[this.generatedCodeLine] = [];
386
411
  this.pending = null;
387
- this.pendingTotal = 0;
388
- this.blockSize = this.constructor.blockSize;
389
- this.outSize = this.constructor.outSize;
390
- this.hmacStrength = this.constructor.hmacStrength;
391
- this.padLength = this.constructor.padLength / 8;
392
- this.endian = 'big';
393
- this._delta8 = this.blockSize / 8;
394
- this._delta32 = this.blockSize / 32;
395
- }
396
- var BlockHash_1 = BlockHash;
397
- BlockHash.prototype.update = function update(msg, enc) {
398
- // Convert message to array, pad it, and join into 32bit blocks
399
- msg = utils.toArray(msg, enc);
400
- if (!this.pending)
401
- this.pending = msg;
402
- else
403
- this.pending = this.pending.concat(msg);
404
- this.pendingTotal += msg.length;
405
- // Enough data, try updating
406
- if (this.pending.length >= this._delta8) {
407
- msg = this.pending;
408
- // Process pending data in blocks
409
- var r = msg.length % this._delta8;
410
- this.pending = msg.slice(msg.length - r, msg.length);
411
- if (this.pending.length === 0)
412
- this.pending = null;
413
- msg = utils.join32(msg, 0, msg.length - r, this.endian);
414
- for (var i = 0; i < msg.length; i += this._delta32)
415
- this._update(msg, i, i + this._delta32);
412
+ };
413
+ Mappings.prototype.addEdit = function addEdit(sourceIndex, content, loc, nameIndex) {
414
+ if (content.length) {
415
+ var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
416
+ if (nameIndex >= 0) {
417
+ segment.push(nameIndex);
418
+ }
419
+ this.rawSegments.push(segment);
416
420
  }
417
- return this;
421
+ else if (this.pending) {
422
+ this.rawSegments.push(this.pending);
423
+ }
424
+ this.advance(content);
425
+ this.pending = null;
418
426
  };
419
- BlockHash.prototype.digest = function digest(enc) {
420
- this.update(this._pad());
421
- minimalisticAssert(this.pending === null);
422
- return this._digest(enc);
427
+ Mappings.prototype.addUneditedChunk = function addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
428
+ var this$1 = this;
429
+ var originalCharIndex = chunk.start;
430
+ var first = true;
431
+ while (originalCharIndex < chunk.end) {
432
+ if (this$1.hires || first || sourcemapLocations[originalCharIndex]) {
433
+ this$1.rawSegments.push([this$1.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
434
+ }
435
+ if (original[originalCharIndex] === '\n') {
436
+ loc.line += 1;
437
+ loc.column = 0;
438
+ this$1.generatedCodeLine += 1;
439
+ this$1.raw[this$1.generatedCodeLine] = this$1.rawSegments = [];
440
+ this$1.generatedCodeColumn = 0;
441
+ }
442
+ else {
443
+ loc.column += 1;
444
+ this$1.generatedCodeColumn += 1;
445
+ }
446
+ originalCharIndex += 1;
447
+ first = false;
448
+ }
449
+ this.pending = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
423
450
  };
424
- BlockHash.prototype._pad = function pad() {
425
- var len = this.pendingTotal;
426
- var bytes = this._delta8;
427
- var k = bytes - ((len + this.padLength) % bytes);
428
- var res = new Array(k + this.padLength);
429
- res[0] = 0x80;
430
- for (var i = 1; i < k; i++)
431
- res[i] = 0;
432
- // Append length
433
- len <<= 3;
434
- if (this.endian === 'big') {
435
- for (var t = 8; t < this.padLength; t++)
436
- res[i++] = 0;
437
- res[i++] = 0;
438
- res[i++] = 0;
439
- res[i++] = 0;
440
- res[i++] = 0;
441
- res[i++] = (len >>> 24) & 0xff;
442
- res[i++] = (len >>> 16) & 0xff;
443
- res[i++] = (len >>> 8) & 0xff;
444
- res[i++] = len & 0xff;
451
+ Mappings.prototype.advance = function advance(str) {
452
+ var this$1 = this;
453
+ if (!str) {
454
+ return;
445
455
  }
446
- else {
447
- res[i++] = len & 0xff;
448
- res[i++] = (len >>> 8) & 0xff;
449
- res[i++] = (len >>> 16) & 0xff;
450
- res[i++] = (len >>> 24) & 0xff;
451
- res[i++] = 0;
452
- res[i++] = 0;
453
- res[i++] = 0;
454
- res[i++] = 0;
455
- for (t = 8; t < this.padLength; t++)
456
- res[i++] = 0;
456
+ var lines = str.split('\n');
457
+ if (lines.length > 1) {
458
+ for (var i = 0; i < lines.length - 1; i++) {
459
+ this$1.generatedCodeLine++;
460
+ this$1.raw[this$1.generatedCodeLine] = this$1.rawSegments = [];
461
+ }
462
+ this.generatedCodeColumn = 0;
457
463
  }
458
- return res;
464
+ this.generatedCodeColumn += lines[lines.length - 1].length;
459
465
  };
460
- var common = {
461
- BlockHash: BlockHash_1
462
- };
463
-
464
- var rotr32$1 = utils.rotr32;
465
- function ft_1(s, x, y, z) {
466
- if (s === 0)
467
- return ch32(x, y, z);
468
- if (s === 1 || s === 3)
469
- return p32(x, y, z);
470
- if (s === 2)
471
- return maj32(x, y, z);
472
- }
473
- var ft_1_1 = ft_1;
474
- function ch32(x, y, z) {
475
- return (x & y) ^ ((~x) & z);
476
- }
477
- var ch32_1 = ch32;
478
- function maj32(x, y, z) {
479
- return (x & y) ^ (x & z) ^ (y & z);
480
- }
481
- var maj32_1 = maj32;
482
- function p32(x, y, z) {
483
- return x ^ y ^ z;
484
- }
485
- var p32_1 = p32;
486
- function s0_256(x) {
487
- return rotr32$1(x, 2) ^ rotr32$1(x, 13) ^ rotr32$1(x, 22);
488
- }
489
- var s0_256_1 = s0_256;
490
- function s1_256(x) {
491
- return rotr32$1(x, 6) ^ rotr32$1(x, 11) ^ rotr32$1(x, 25);
492
- }
493
- var s1_256_1 = s1_256;
494
- function g0_256(x) {
495
- return rotr32$1(x, 7) ^ rotr32$1(x, 18) ^ (x >>> 3);
496
- }
497
- var g0_256_1 = g0_256;
498
- function g1_256(x) {
499
- return rotr32$1(x, 17) ^ rotr32$1(x, 19) ^ (x >>> 10);
500
- }
501
- var g1_256_1 = g1_256;
502
- var common$1 = {
503
- ft_1: ft_1_1,
504
- ch32: ch32_1,
505
- maj32: maj32_1,
506
- p32: p32_1,
507
- s0_256: s0_256_1,
508
- s1_256: s1_256_1,
509
- g0_256: g0_256_1,
510
- g1_256: g1_256_1
511
- };
512
-
513
- var sum32$1 = utils.sum32;
514
- var sum32_4$1 = utils.sum32_4;
515
- var sum32_5$1 = utils.sum32_5;
516
- var ch32$1 = common$1.ch32;
517
- var maj32$1 = common$1.maj32;
518
- var s0_256$1 = common$1.s0_256;
519
- var s1_256$1 = common$1.s1_256;
520
- var g0_256$1 = common$1.g0_256;
521
- var g1_256$1 = common$1.g1_256;
522
- var BlockHash$1 = common.BlockHash;
523
- var sha256_K = [
524
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
525
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
526
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
527
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
528
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
529
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
530
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
531
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
532
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
533
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
534
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
535
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
536
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
537
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
538
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
539
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
540
- ];
541
- function SHA256() {
542
- if (!(this instanceof SHA256))
543
- return new SHA256();
544
- BlockHash$1.call(this);
545
- this.h = [
546
- 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
547
- 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
548
- ];
549
- this.k = sha256_K;
550
- this.W = new Array(64);
551
- }
552
- utils.inherits(SHA256, BlockHash$1);
553
- var _256 = SHA256;
554
- SHA256.blockSize = 512;
555
- SHA256.outSize = 256;
556
- SHA256.hmacStrength = 192;
557
- SHA256.padLength = 64;
558
- SHA256.prototype._update = function _update(msg, start) {
559
- var W = this.W;
560
- for (var i = 0; i < 16; i++)
561
- W[i] = msg[start + i];
562
- for (; i < W.length; i++)
563
- W[i] = sum32_4$1(g1_256$1(W[i - 2]), W[i - 7], g0_256$1(W[i - 15]), W[i - 16]);
564
- var a = this.h[0];
565
- var b = this.h[1];
566
- var c = this.h[2];
567
- var d = this.h[3];
568
- var e = this.h[4];
569
- var f = this.h[5];
570
- var g = this.h[6];
571
- var h = this.h[7];
572
- minimalisticAssert(this.k.length === W.length);
573
- for (i = 0; i < W.length; i++) {
574
- var T1 = sum32_5$1(h, s1_256$1(e), ch32$1(e, f, g), this.k[i], W[i]);
575
- var T2 = sum32$1(s0_256$1(a), maj32$1(a, b, c));
576
- h = g;
577
- g = f;
578
- f = e;
579
- e = sum32$1(d, T1);
580
- d = c;
581
- c = b;
582
- b = a;
583
- a = sum32$1(T1, T2);
584
- }
585
- this.h[0] = sum32$1(this.h[0], a);
586
- this.h[1] = sum32$1(this.h[1], b);
587
- this.h[2] = sum32$1(this.h[2], c);
588
- this.h[3] = sum32$1(this.h[3], d);
589
- this.h[4] = sum32$1(this.h[4], e);
590
- this.h[5] = sum32$1(this.h[5], f);
591
- this.h[6] = sum32$1(this.h[6], g);
592
- this.h[7] = sum32$1(this.h[7], h);
593
- };
594
- SHA256.prototype._digest = function digest(enc) {
595
- if (enc === 'hex')
596
- return utils.toHex32(this.h, 'big');
597
- else
598
- return utils.split32(this.h, 'big');
599
- };
600
-
601
- var charToInteger = {};
602
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
603
- for (var i = 0; i < chars.length; i++) {
604
- charToInteger[chars.charCodeAt(i)] = i;
605
- }
606
- function decode(mappings) {
607
- var generatedCodeColumn = 0; // first field
608
- var sourceFileIndex = 0; // second field
609
- var sourceCodeLine = 0; // third field
610
- var sourceCodeColumn = 0; // fourth field
611
- var nameIndex = 0; // fifth field
612
- var decoded = [];
613
- var line = [];
614
- var segment = [];
615
- for (var i = 0, j = 0, shift = 0, value = 0, len = mappings.length; i < len; i++) {
616
- var c = mappings.charCodeAt(i);
617
- if (c === 44) { // ","
618
- if (segment.length)
619
- line.push(segment);
620
- segment = [];
621
- j = 0;
622
- }
623
- else if (c === 59) { // ";"
624
- if (segment.length)
625
- line.push(segment);
626
- segment = [];
627
- j = 0;
628
- decoded.push(line);
629
- line = [];
630
- generatedCodeColumn = 0;
631
- }
632
- else {
633
- var integer = charToInteger[c];
634
- if (integer === undefined) {
635
- throw new Error('Invalid character (' + String.fromCharCode(c) + ')');
636
- }
637
- var hasContinuationBit = integer & 32;
638
- integer &= 31;
639
- value += integer << shift;
640
- if (hasContinuationBit) {
641
- shift += 5;
642
- }
643
- else {
644
- var shouldNegate = value & 1;
645
- value >>>= 1;
646
- if (shouldNegate) {
647
- value = -value;
648
- if (value === 0)
649
- value = -0x80000000;
650
- }
651
- if (j == 0) {
652
- generatedCodeColumn += value;
653
- segment.push(generatedCodeColumn);
654
- }
655
- else if (j === 1) {
656
- sourceFileIndex += value;
657
- segment.push(sourceFileIndex);
658
- }
659
- else if (j === 2) {
660
- sourceCodeLine += value;
661
- segment.push(sourceCodeLine);
662
- }
663
- else if (j === 3) {
664
- sourceCodeColumn += value;
665
- segment.push(sourceCodeColumn);
666
- }
667
- else if (j === 4) {
668
- nameIndex += value;
669
- segment.push(nameIndex);
670
- }
671
- j++;
672
- value = shift = 0; // reset
673
- }
674
- }
675
- }
676
- if (segment.length)
677
- line.push(segment);
678
- decoded.push(line);
679
- return decoded;
680
- }
681
- function encode(decoded) {
682
- var sourceFileIndex = 0; // second field
683
- var sourceCodeLine = 0; // third field
684
- var sourceCodeColumn = 0; // fourth field
685
- var nameIndex = 0; // fifth field
686
- var mappings = '';
687
- for (var i = 0; i < decoded.length; i++) {
688
- var line = decoded[i];
689
- if (i > 0)
690
- mappings += ';';
691
- if (line.length === 0)
692
- continue;
693
- var generatedCodeColumn = 0; // first field
694
- var lineMappings = [];
695
- for (var _i = 0, line_1 = line; _i < line_1.length; _i++) {
696
- var segment = line_1[_i];
697
- var segmentMappings = encodeInteger(segment[0] - generatedCodeColumn);
698
- generatedCodeColumn = segment[0];
699
- if (segment.length > 1) {
700
- segmentMappings +=
701
- encodeInteger(segment[1] - sourceFileIndex) +
702
- encodeInteger(segment[2] - sourceCodeLine) +
703
- encodeInteger(segment[3] - sourceCodeColumn);
704
- sourceFileIndex = segment[1];
705
- sourceCodeLine = segment[2];
706
- sourceCodeColumn = segment[3];
707
- }
708
- if (segment.length === 5) {
709
- segmentMappings += encodeInteger(segment[4] - nameIndex);
710
- nameIndex = segment[4];
711
- }
712
- lineMappings.push(segmentMappings);
713
- }
714
- mappings += lineMappings.join(',');
715
- }
716
- return mappings;
717
- }
718
- function encodeInteger(num) {
719
- var result = '';
720
- num = num < 0 ? (-num << 1) | 1 : num << 1;
721
- do {
722
- var clamped = num & 31;
723
- num >>>= 5;
724
- if (num > 0) {
725
- clamped |= 32;
726
- }
727
- result += chars[clamped];
728
- } while (num > 0);
729
- return result;
730
- }
731
-
732
- var Chunk = function Chunk(start, end, content) {
733
- this.start = start;
734
- this.end = end;
735
- this.original = content;
736
- this.intro = '';
737
- this.outro = '';
738
- this.content = content;
739
- this.storeName = false;
740
- this.edited = false;
741
- // we make these non-enumerable, for sanity while debugging
742
- Object.defineProperties(this, {
743
- previous: { writable: true, value: null },
744
- next: { writable: true, value: null }
745
- });
746
- };
747
- Chunk.prototype.appendLeft = function appendLeft(content) {
748
- this.outro += content;
749
- };
750
- Chunk.prototype.appendRight = function appendRight(content) {
751
- this.intro = this.intro + content;
752
- };
753
- Chunk.prototype.clone = function clone() {
754
- var chunk = new Chunk(this.start, this.end, this.original);
755
- chunk.intro = this.intro;
756
- chunk.outro = this.outro;
757
- chunk.content = this.content;
758
- chunk.storeName = this.storeName;
759
- chunk.edited = this.edited;
760
- return chunk;
761
- };
762
- Chunk.prototype.contains = function contains(index) {
763
- return this.start < index && index < this.end;
764
- };
765
- Chunk.prototype.eachNext = function eachNext(fn) {
766
- var chunk = this;
767
- while (chunk) {
768
- fn(chunk);
769
- chunk = chunk.next;
770
- }
771
- };
772
- Chunk.prototype.eachPrevious = function eachPrevious(fn) {
773
- var chunk = this;
774
- while (chunk) {
775
- fn(chunk);
776
- chunk = chunk.previous;
777
- }
778
- };
779
- Chunk.prototype.edit = function edit(content, storeName, contentOnly) {
780
- this.content = content;
781
- if (!contentOnly) {
782
- this.intro = '';
783
- this.outro = '';
784
- }
785
- this.storeName = storeName;
786
- this.edited = true;
787
- return this;
788
- };
789
- Chunk.prototype.prependLeft = function prependLeft(content) {
790
- this.outro = content + this.outro;
791
- };
792
- Chunk.prototype.prependRight = function prependRight(content) {
793
- this.intro = content + this.intro;
794
- };
795
- Chunk.prototype.split = function split(index) {
796
- var sliceIndex = index - this.start;
797
- var originalBefore = this.original.slice(0, sliceIndex);
798
- var originalAfter = this.original.slice(sliceIndex);
799
- this.original = originalBefore;
800
- var newChunk = new Chunk(index, this.end, originalAfter);
801
- newChunk.outro = this.outro;
802
- this.outro = '';
803
- this.end = index;
804
- if (this.edited) {
805
- // TODO is this block necessary?...
806
- newChunk.edit('', false);
807
- this.content = '';
808
- }
809
- else {
810
- this.content = originalBefore;
811
- }
812
- newChunk.next = this.next;
813
- if (newChunk.next) {
814
- newChunk.next.previous = newChunk;
815
- }
816
- newChunk.previous = this;
817
- this.next = newChunk;
818
- return newChunk;
819
- };
820
- Chunk.prototype.toString = function toString() {
821
- return this.intro + this.content + this.outro;
822
- };
823
- Chunk.prototype.trimEnd = function trimEnd(rx) {
824
- this.outro = this.outro.replace(rx, '');
825
- if (this.outro.length) {
826
- return true;
827
- }
828
- var trimmed = this.content.replace(rx, '');
829
- if (trimmed.length) {
830
- if (trimmed !== this.content) {
831
- this.split(this.start + trimmed.length).edit('', undefined, true);
832
- }
833
- return true;
834
- }
835
- else {
836
- this.edit('', undefined, true);
837
- this.intro = this.intro.replace(rx, '');
838
- if (this.intro.length) {
839
- return true;
840
- }
841
- }
842
- };
843
- Chunk.prototype.trimStart = function trimStart(rx) {
844
- this.intro = this.intro.replace(rx, '');
845
- if (this.intro.length) {
846
- return true;
847
- }
848
- var trimmed = this.content.replace(rx, '');
849
- if (trimmed.length) {
850
- if (trimmed !== this.content) {
851
- this.split(this.end - trimmed.length);
852
- this.edit('', undefined, true);
853
- }
854
- return true;
855
- }
856
- else {
857
- this.edit('', undefined, true);
858
- this.outro = this.outro.replace(rx, '');
859
- if (this.outro.length) {
860
- return true;
861
- }
862
- }
863
- };
864
- var btoa = function () {
865
- throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
866
- };
867
- if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
868
- btoa = function (str) { return window.btoa(unescape(encodeURIComponent(str))); };
869
- }
870
- else if (typeof Buffer === 'function') {
871
- btoa = function (str) { return Buffer.from(str, 'utf-8').toString('base64'); };
872
- }
873
- var SourceMap = function SourceMap(properties) {
874
- this.version = 3;
875
- this.file = properties.file;
876
- this.sources = properties.sources;
877
- this.sourcesContent = properties.sourcesContent;
878
- this.names = properties.names;
879
- this.mappings = encode(properties.mappings);
880
- };
881
- SourceMap.prototype.toString = function toString() {
882
- return JSON.stringify(this);
883
- };
884
- SourceMap.prototype.toUrl = function toUrl() {
885
- return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
886
- };
887
- function guessIndent(code) {
888
- var lines = code.split('\n');
889
- var tabbed = lines.filter(function (line) { return /^\t+/.test(line); });
890
- var spaced = lines.filter(function (line) { return /^ {2,}/.test(line); });
891
- if (tabbed.length === 0 && spaced.length === 0) {
892
- return null;
893
- }
894
- // More lines tabbed than spaced? Assume tabs, and
895
- // default to tabs in the case of a tie (or nothing
896
- // to go on)
897
- if (tabbed.length >= spaced.length) {
898
- return '\t';
899
- }
900
- // Otherwise, we need to guess the multiple
901
- var min = spaced.reduce(function (previous, current) {
902
- var numSpaces = /^ +/.exec(current)[0].length;
903
- return Math.min(numSpaces, previous);
904
- }, Infinity);
905
- return new Array(min + 1).join(' ');
906
- }
907
- function getRelativePath(from, to) {
908
- var fromParts = from.split(/[/\\]/);
909
- var toParts = to.split(/[/\\]/);
910
- fromParts.pop(); // get dirname
911
- while (fromParts[0] === toParts[0]) {
912
- fromParts.shift();
913
- toParts.shift();
914
- }
915
- if (fromParts.length) {
916
- var i = fromParts.length;
917
- while (i--) {
918
- fromParts[i] = '..';
919
- }
920
- }
921
- return fromParts.concat(toParts).join('/');
922
- }
923
- var toString = Object.prototype.toString;
924
- function isObject(thing) {
925
- return toString.call(thing) === '[object Object]';
926
- }
927
- function getLocator(source) {
928
- var originalLines = source.split('\n');
929
- var lineOffsets = [];
930
- for (var i = 0, pos = 0; i < originalLines.length; i++) {
931
- lineOffsets.push(pos);
932
- pos += originalLines[i].length + 1;
933
- }
934
- return function locate(index) {
935
- var i = 0;
936
- var j = lineOffsets.length;
937
- while (i < j) {
938
- var m = (i + j) >> 1;
939
- if (index < lineOffsets[m]) {
940
- j = m;
941
- }
942
- else {
943
- i = m + 1;
944
- }
945
- }
946
- var line = i - 1;
947
- var column = index - lineOffsets[line];
948
- return { line: line, column: column };
949
- };
950
- }
951
- var Mappings = function Mappings(hires) {
952
- this.hires = hires;
953
- this.generatedCodeLine = 0;
954
- this.generatedCodeColumn = 0;
955
- this.raw = [];
956
- this.rawSegments = this.raw[this.generatedCodeLine] = [];
957
- this.pending = null;
958
- };
959
- Mappings.prototype.addEdit = function addEdit(sourceIndex, content, loc, nameIndex) {
960
- if (content.length) {
961
- var segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
962
- if (nameIndex >= 0) {
963
- segment.push(nameIndex);
964
- }
965
- this.rawSegments.push(segment);
966
- }
967
- else if (this.pending) {
968
- this.rawSegments.push(this.pending);
969
- }
970
- this.advance(content);
971
- this.pending = null;
972
- };
973
- Mappings.prototype.addUneditedChunk = function addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
974
- var this$1 = this;
975
- var originalCharIndex = chunk.start;
976
- var first = true;
977
- while (originalCharIndex < chunk.end) {
978
- if (this$1.hires || first || sourcemapLocations[originalCharIndex]) {
979
- this$1.rawSegments.push([this$1.generatedCodeColumn, sourceIndex, loc.line, loc.column]);
980
- }
981
- if (original[originalCharIndex] === '\n') {
982
- loc.line += 1;
983
- loc.column = 0;
984
- this$1.generatedCodeLine += 1;
985
- this$1.raw[this$1.generatedCodeLine] = this$1.rawSegments = [];
986
- this$1.generatedCodeColumn = 0;
987
- }
988
- else {
989
- loc.column += 1;
990
- this$1.generatedCodeColumn += 1;
991
- }
992
- originalCharIndex += 1;
993
- first = false;
994
- }
995
- this.pending = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
996
- };
997
- Mappings.prototype.advance = function advance(str) {
998
- var this$1 = this;
999
- if (!str) {
1000
- return;
1001
- }
1002
- var lines = str.split('\n');
1003
- if (lines.length > 1) {
1004
- for (var i = 0; i < lines.length - 1; i++) {
1005
- this$1.generatedCodeLine++;
1006
- this$1.raw[this$1.generatedCodeLine] = this$1.rawSegments = [];
1007
- }
1008
- this.generatedCodeColumn = 0;
1009
- }
1010
- this.generatedCodeColumn += lines[lines.length - 1].length;
1011
- };
1012
- var n = '\n';
1013
- var warned = {
1014
- insertLeft: false,
1015
- insertRight: false,
1016
- storeName: false
466
+ var n = '\n';
467
+ var warned = {
468
+ insertLeft: false,
469
+ insertRight: false,
470
+ storeName: false
1017
471
  };
1018
472
  var MagicString = function MagicString(string, options) {
1019
473
  if (options === void 0)
@@ -1714,162 +1168,711 @@ Bundle.prototype.generateDecodedMap = function generateDecodedMap(options) {
1714
1168
  if (this.intro) {
1715
1169
  mappings.advance(this.intro);
1716
1170
  }
1717
- this.sources.forEach(function (source, i) {
1718
- if (i > 0) {
1719
- mappings.advance(this$1.separator);
1720
- }
1721
- var sourceIndex = source.filename ? this$1.uniqueSourceIndexByFilename[source.filename] : -1;
1722
- var magicString = source.content;
1723
- var locate = getLocator(magicString.original);
1724
- if (magicString.intro) {
1725
- mappings.advance(magicString.intro);
1726
- }
1727
- magicString.firstChunk.eachNext(function (chunk) {
1728
- var loc = locate(chunk.start);
1729
- if (chunk.intro.length) {
1730
- mappings.advance(chunk.intro);
1731
- }
1732
- if (source.filename) {
1733
- if (chunk.edited) {
1734
- mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
1171
+ this.sources.forEach(function (source, i) {
1172
+ if (i > 0) {
1173
+ mappings.advance(this$1.separator);
1174
+ }
1175
+ var sourceIndex = source.filename ? this$1.uniqueSourceIndexByFilename[source.filename] : -1;
1176
+ var magicString = source.content;
1177
+ var locate = getLocator(magicString.original);
1178
+ if (magicString.intro) {
1179
+ mappings.advance(magicString.intro);
1180
+ }
1181
+ magicString.firstChunk.eachNext(function (chunk) {
1182
+ var loc = locate(chunk.start);
1183
+ if (chunk.intro.length) {
1184
+ mappings.advance(chunk.intro);
1185
+ }
1186
+ if (source.filename) {
1187
+ if (chunk.edited) {
1188
+ mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
1189
+ }
1190
+ else {
1191
+ mappings.addUneditedChunk(sourceIndex, chunk, magicString.original, loc, magicString.sourcemapLocations);
1192
+ }
1193
+ }
1194
+ else {
1195
+ mappings.advance(chunk.content);
1196
+ }
1197
+ if (chunk.outro.length) {
1198
+ mappings.advance(chunk.outro);
1199
+ }
1200
+ });
1201
+ if (magicString.outro) {
1202
+ mappings.advance(magicString.outro);
1203
+ }
1204
+ });
1205
+ return {
1206
+ file: options.file ? options.file.split(/[/\\]/).pop() : null,
1207
+ sources: this.uniqueSources.map(function (source) {
1208
+ return options.file ? getRelativePath(options.file, source.filename) : source.filename;
1209
+ }),
1210
+ sourcesContent: this.uniqueSources.map(function (source) {
1211
+ return options.includeContent ? source.content : null;
1212
+ }),
1213
+ names: names,
1214
+ mappings: mappings.raw
1215
+ };
1216
+ };
1217
+ Bundle.prototype.generateMap = function generateMap(options) {
1218
+ return new SourceMap(this.generateDecodedMap(options));
1219
+ };
1220
+ Bundle.prototype.getIndentString = function getIndentString() {
1221
+ var indentStringCounts = {};
1222
+ this.sources.forEach(function (source) {
1223
+ var indentStr = source.content.indentStr;
1224
+ if (indentStr === null) {
1225
+ return;
1226
+ }
1227
+ if (!indentStringCounts[indentStr]) {
1228
+ indentStringCounts[indentStr] = 0;
1229
+ }
1230
+ indentStringCounts[indentStr] += 1;
1231
+ });
1232
+ return (Object.keys(indentStringCounts).sort(function (a, b) {
1233
+ return indentStringCounts[a] - indentStringCounts[b];
1234
+ })[0] || '\t');
1235
+ };
1236
+ Bundle.prototype.indent = function indent(indentStr) {
1237
+ var this$1 = this;
1238
+ if (!arguments.length) {
1239
+ indentStr = this.getIndentString();
1240
+ }
1241
+ if (indentStr === '') {
1242
+ return this;
1243
+ } // noop
1244
+ var trailingNewline = !this.intro || this.intro.slice(-1) === '\n';
1245
+ this.sources.forEach(function (source, i) {
1246
+ var separator = source.separator !== undefined ? source.separator : this$1.separator;
1247
+ var indentStart = trailingNewline || (i > 0 && /\r?\n$/.test(separator));
1248
+ source.content.indent(indentStr, {
1249
+ exclude: source.indentExclusionRanges,
1250
+ indentStart: indentStart //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
1251
+ });
1252
+ trailingNewline = source.content.lastChar() === '\n';
1253
+ });
1254
+ if (this.intro) {
1255
+ this.intro =
1256
+ indentStr +
1257
+ this.intro.replace(/^[^\n]/gm, function (match, index) {
1258
+ return index > 0 ? indentStr + match : match;
1259
+ });
1260
+ }
1261
+ return this;
1262
+ };
1263
+ Bundle.prototype.prepend = function prepend(str) {
1264
+ this.intro = str + this.intro;
1265
+ return this;
1266
+ };
1267
+ Bundle.prototype.toString = function toString() {
1268
+ var this$1 = this;
1269
+ var body = this.sources
1270
+ .map(function (source, i) {
1271
+ var separator = source.separator !== undefined ? source.separator : this$1.separator;
1272
+ var str = (i > 0 ? separator : '') + source.content.toString();
1273
+ return str;
1274
+ })
1275
+ .join('');
1276
+ return this.intro + body;
1277
+ };
1278
+ Bundle.prototype.isEmpty = function isEmpty() {
1279
+ if (this.intro.length && this.intro.trim()) {
1280
+ return false;
1281
+ }
1282
+ if (this.sources.some(function (source) { return !source.content.isEmpty(); })) {
1283
+ return false;
1284
+ }
1285
+ return true;
1286
+ };
1287
+ Bundle.prototype.length = function length() {
1288
+ return this.sources.reduce(function (length, source) { return length + source.content.length(); }, this.intro.length);
1289
+ };
1290
+ Bundle.prototype.trimLines = function trimLines() {
1291
+ return this.trim('[\\r\\n]');
1292
+ };
1293
+ Bundle.prototype.trim = function trim(charType) {
1294
+ return this.trimStart(charType).trimEnd(charType);
1295
+ };
1296
+ Bundle.prototype.trimStart = function trimStart(charType) {
1297
+ var this$1 = this;
1298
+ var rx = new RegExp('^' + (charType || '\\s') + '+');
1299
+ this.intro = this.intro.replace(rx, '');
1300
+ if (!this.intro) {
1301
+ var source;
1302
+ var i = 0;
1303
+ do {
1304
+ source = this$1.sources[i++];
1305
+ if (!source) {
1306
+ break;
1307
+ }
1308
+ } while (!source.content.trimStartAborted(charType));
1309
+ }
1310
+ return this;
1311
+ };
1312
+ Bundle.prototype.trimEnd = function trimEnd(charType) {
1313
+ var this$1 = this;
1314
+ var rx = new RegExp((charType || '\\s') + '+$');
1315
+ var source;
1316
+ var i = this.sources.length - 1;
1317
+ do {
1318
+ source = this$1.sources[i--];
1319
+ if (!source) {
1320
+ this$1.intro = this$1.intro.replace(rx, '');
1321
+ break;
1322
+ }
1323
+ } while (!source.content.trimEndAborted(charType));
1324
+ return this;
1325
+ };
1326
+
1327
+ var minimalisticAssert = assert;
1328
+ function assert(val, msg) {
1329
+ if (!val)
1330
+ throw new Error(msg || 'Assertion failed');
1331
+ }
1332
+ assert.equal = function assertEqual(l, r, msg) {
1333
+ if (l != r)
1334
+ throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r));
1335
+ };
1336
+
1337
+ function createCommonjsModule(fn, module) {
1338
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
1339
+ }
1340
+
1341
+ var inherits_browser = createCommonjsModule(function (module) {
1342
+ if (typeof Object.create === 'function') {
1343
+ // implementation from standard node.js 'util' module
1344
+ module.exports = function inherits(ctor, superCtor) {
1345
+ ctor.super_ = superCtor;
1346
+ ctor.prototype = Object.create(superCtor.prototype, {
1347
+ constructor: {
1348
+ value: ctor,
1349
+ enumerable: false,
1350
+ writable: true,
1351
+ configurable: true
1352
+ }
1353
+ });
1354
+ };
1355
+ }
1356
+ else {
1357
+ // old school shim for old browsers
1358
+ module.exports = function inherits(ctor, superCtor) {
1359
+ ctor.super_ = superCtor;
1360
+ var TempCtor = function () { };
1361
+ TempCtor.prototype = superCtor.prototype;
1362
+ ctor.prototype = new TempCtor();
1363
+ ctor.prototype.constructor = ctor;
1364
+ };
1365
+ }
1366
+ });
1367
+
1368
+ var inherits = createCommonjsModule(function (module) {
1369
+ try {
1370
+ var util$1 = util;
1371
+ if (typeof util$1.inherits !== 'function')
1372
+ throw '';
1373
+ module.exports = util$1.inherits;
1374
+ }
1375
+ catch (e) {
1376
+ module.exports = inherits_browser;
1377
+ }
1378
+ });
1379
+
1380
+ var inherits_1 = inherits;
1381
+ function isSurrogatePair(msg, i) {
1382
+ if ((msg.charCodeAt(i) & 0xFC00) !== 0xD800) {
1383
+ return false;
1384
+ }
1385
+ if (i < 0 || i + 1 >= msg.length) {
1386
+ return false;
1387
+ }
1388
+ return (msg.charCodeAt(i + 1) & 0xFC00) === 0xDC00;
1389
+ }
1390
+ function toArray(msg, enc) {
1391
+ if (Array.isArray(msg))
1392
+ return msg.slice();
1393
+ if (!msg)
1394
+ return [];
1395
+ var res = [];
1396
+ if (typeof msg === 'string') {
1397
+ if (!enc) {
1398
+ // Inspired by stringToUtf8ByteArray() in closure-library by Google
1399
+ // https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
1400
+ // Apache License 2.0
1401
+ // https://github.com/google/closure-library/blob/master/LICENSE
1402
+ var p = 0;
1403
+ for (var i = 0; i < msg.length; i++) {
1404
+ var c = msg.charCodeAt(i);
1405
+ if (c < 128) {
1406
+ res[p++] = c;
1407
+ }
1408
+ else if (c < 2048) {
1409
+ res[p++] = (c >> 6) | 192;
1410
+ res[p++] = (c & 63) | 128;
1411
+ }
1412
+ else if (isSurrogatePair(msg, i)) {
1413
+ c = 0x10000 + ((c & 0x03FF) << 10) + (msg.charCodeAt(++i) & 0x03FF);
1414
+ res[p++] = (c >> 18) | 240;
1415
+ res[p++] = ((c >> 12) & 63) | 128;
1416
+ res[p++] = ((c >> 6) & 63) | 128;
1417
+ res[p++] = (c & 63) | 128;
1735
1418
  }
1736
1419
  else {
1737
- mappings.addUneditedChunk(sourceIndex, chunk, magicString.original, loc, magicString.sourcemapLocations);
1420
+ res[p++] = (c >> 12) | 224;
1421
+ res[p++] = ((c >> 6) & 63) | 128;
1422
+ res[p++] = (c & 63) | 128;
1738
1423
  }
1739
1424
  }
1740
- else {
1741
- mappings.advance(chunk.content);
1742
- }
1743
- if (chunk.outro.length) {
1744
- mappings.advance(chunk.outro);
1745
- }
1746
- });
1747
- if (magicString.outro) {
1748
- mappings.advance(magicString.outro);
1749
1425
  }
1750
- });
1751
- return {
1752
- file: options.file ? options.file.split(/[/\\]/).pop() : null,
1753
- sources: this.uniqueSources.map(function (source) {
1754
- return options.file ? getRelativePath(options.file, source.filename) : source.filename;
1755
- }),
1756
- sourcesContent: this.uniqueSources.map(function (source) {
1757
- return options.includeContent ? source.content : null;
1758
- }),
1759
- names: names,
1760
- mappings: mappings.raw
1761
- };
1762
- };
1763
- Bundle.prototype.generateMap = function generateMap(options) {
1764
- return new SourceMap(this.generateDecodedMap(options));
1765
- };
1766
- Bundle.prototype.getIndentString = function getIndentString() {
1767
- var indentStringCounts = {};
1768
- this.sources.forEach(function (source) {
1769
- var indentStr = source.content.indentStr;
1770
- if (indentStr === null) {
1771
- return;
1426
+ else if (enc === 'hex') {
1427
+ msg = msg.replace(/[^a-z0-9]+/ig, '');
1428
+ if (msg.length % 2 !== 0)
1429
+ msg = '0' + msg;
1430
+ for (i = 0; i < msg.length; i += 2)
1431
+ res.push(parseInt(msg[i] + msg[i + 1], 16));
1772
1432
  }
1773
- if (!indentStringCounts[indentStr]) {
1774
- indentStringCounts[indentStr] = 0;
1433
+ }
1434
+ else {
1435
+ for (i = 0; i < msg.length; i++)
1436
+ res[i] = msg[i] | 0;
1437
+ }
1438
+ return res;
1439
+ }
1440
+ var toArray_1 = toArray;
1441
+ function toHex(msg) {
1442
+ var res = '';
1443
+ for (var i = 0; i < msg.length; i++)
1444
+ res += zero2(msg[i].toString(16));
1445
+ return res;
1446
+ }
1447
+ var toHex_1 = toHex;
1448
+ function htonl(w) {
1449
+ var res = (w >>> 24) |
1450
+ ((w >>> 8) & 0xff00) |
1451
+ ((w << 8) & 0xff0000) |
1452
+ ((w & 0xff) << 24);
1453
+ return res >>> 0;
1454
+ }
1455
+ var htonl_1 = htonl;
1456
+ function toHex32(msg, endian) {
1457
+ var res = '';
1458
+ for (var i = 0; i < msg.length; i++) {
1459
+ var w = msg[i];
1460
+ if (endian === 'little')
1461
+ w = htonl(w);
1462
+ res += zero8(w.toString(16));
1463
+ }
1464
+ return res;
1465
+ }
1466
+ var toHex32_1 = toHex32;
1467
+ function zero2(word) {
1468
+ if (word.length === 1)
1469
+ return '0' + word;
1470
+ else
1471
+ return word;
1472
+ }
1473
+ var zero2_1 = zero2;
1474
+ function zero8(word) {
1475
+ if (word.length === 7)
1476
+ return '0' + word;
1477
+ else if (word.length === 6)
1478
+ return '00' + word;
1479
+ else if (word.length === 5)
1480
+ return '000' + word;
1481
+ else if (word.length === 4)
1482
+ return '0000' + word;
1483
+ else if (word.length === 3)
1484
+ return '00000' + word;
1485
+ else if (word.length === 2)
1486
+ return '000000' + word;
1487
+ else if (word.length === 1)
1488
+ return '0000000' + word;
1489
+ else
1490
+ return word;
1491
+ }
1492
+ var zero8_1 = zero8;
1493
+ function join32(msg, start, end, endian) {
1494
+ var len = end - start;
1495
+ minimalisticAssert(len % 4 === 0);
1496
+ var res = new Array(len / 4);
1497
+ for (var i = 0, k = start; i < res.length; i++, k += 4) {
1498
+ var w;
1499
+ if (endian === 'big')
1500
+ w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
1501
+ else
1502
+ w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
1503
+ res[i] = w >>> 0;
1504
+ }
1505
+ return res;
1506
+ }
1507
+ var join32_1 = join32;
1508
+ function split32(msg, endian) {
1509
+ var res = new Array(msg.length * 4);
1510
+ for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
1511
+ var m = msg[i];
1512
+ if (endian === 'big') {
1513
+ res[k] = m >>> 24;
1514
+ res[k + 1] = (m >>> 16) & 0xff;
1515
+ res[k + 2] = (m >>> 8) & 0xff;
1516
+ res[k + 3] = m & 0xff;
1775
1517
  }
1776
- indentStringCounts[indentStr] += 1;
1777
- });
1778
- return (Object.keys(indentStringCounts).sort(function (a, b) {
1779
- return indentStringCounts[a] - indentStringCounts[b];
1780
- })[0] || '\t');
1518
+ else {
1519
+ res[k + 3] = m >>> 24;
1520
+ res[k + 2] = (m >>> 16) & 0xff;
1521
+ res[k + 1] = (m >>> 8) & 0xff;
1522
+ res[k] = m & 0xff;
1523
+ }
1524
+ }
1525
+ return res;
1526
+ }
1527
+ var split32_1 = split32;
1528
+ function rotr32(w, b) {
1529
+ return (w >>> b) | (w << (32 - b));
1530
+ }
1531
+ var rotr32_1 = rotr32;
1532
+ function rotl32(w, b) {
1533
+ return (w << b) | (w >>> (32 - b));
1534
+ }
1535
+ var rotl32_1 = rotl32;
1536
+ function sum32(a, b) {
1537
+ return (a + b) >>> 0;
1538
+ }
1539
+ var sum32_1 = sum32;
1540
+ function sum32_3(a, b, c) {
1541
+ return (a + b + c) >>> 0;
1542
+ }
1543
+ var sum32_3_1 = sum32_3;
1544
+ function sum32_4(a, b, c, d) {
1545
+ return (a + b + c + d) >>> 0;
1546
+ }
1547
+ var sum32_4_1 = sum32_4;
1548
+ function sum32_5(a, b, c, d, e) {
1549
+ return (a + b + c + d + e) >>> 0;
1550
+ }
1551
+ var sum32_5_1 = sum32_5;
1552
+ function sum64(buf, pos, ah, al) {
1553
+ var bh = buf[pos];
1554
+ var bl = buf[pos + 1];
1555
+ var lo = (al + bl) >>> 0;
1556
+ var hi = (lo < al ? 1 : 0) + ah + bh;
1557
+ buf[pos] = hi >>> 0;
1558
+ buf[pos + 1] = lo;
1559
+ }
1560
+ var sum64_1 = sum64;
1561
+ function sum64_hi(ah, al, bh, bl) {
1562
+ var lo = (al + bl) >>> 0;
1563
+ var hi = (lo < al ? 1 : 0) + ah + bh;
1564
+ return hi >>> 0;
1565
+ }
1566
+ var sum64_hi_1 = sum64_hi;
1567
+ function sum64_lo(ah, al, bh, bl) {
1568
+ var lo = al + bl;
1569
+ return lo >>> 0;
1570
+ }
1571
+ var sum64_lo_1 = sum64_lo;
1572
+ function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
1573
+ var carry = 0;
1574
+ var lo = al;
1575
+ lo = (lo + bl) >>> 0;
1576
+ carry += lo < al ? 1 : 0;
1577
+ lo = (lo + cl) >>> 0;
1578
+ carry += lo < cl ? 1 : 0;
1579
+ lo = (lo + dl) >>> 0;
1580
+ carry += lo < dl ? 1 : 0;
1581
+ var hi = ah + bh + ch + dh + carry;
1582
+ return hi >>> 0;
1583
+ }
1584
+ var sum64_4_hi_1 = sum64_4_hi;
1585
+ function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
1586
+ var lo = al + bl + cl + dl;
1587
+ return lo >>> 0;
1588
+ }
1589
+ var sum64_4_lo_1 = sum64_4_lo;
1590
+ function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
1591
+ var carry = 0;
1592
+ var lo = al;
1593
+ lo = (lo + bl) >>> 0;
1594
+ carry += lo < al ? 1 : 0;
1595
+ lo = (lo + cl) >>> 0;
1596
+ carry += lo < cl ? 1 : 0;
1597
+ lo = (lo + dl) >>> 0;
1598
+ carry += lo < dl ? 1 : 0;
1599
+ lo = (lo + el) >>> 0;
1600
+ carry += lo < el ? 1 : 0;
1601
+ var hi = ah + bh + ch + dh + eh + carry;
1602
+ return hi >>> 0;
1603
+ }
1604
+ var sum64_5_hi_1 = sum64_5_hi;
1605
+ function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
1606
+ var lo = al + bl + cl + dl + el;
1607
+ return lo >>> 0;
1608
+ }
1609
+ var sum64_5_lo_1 = sum64_5_lo;
1610
+ function rotr64_hi(ah, al, num) {
1611
+ var r = (al << (32 - num)) | (ah >>> num);
1612
+ return r >>> 0;
1613
+ }
1614
+ var rotr64_hi_1 = rotr64_hi;
1615
+ function rotr64_lo(ah, al, num) {
1616
+ var r = (ah << (32 - num)) | (al >>> num);
1617
+ return r >>> 0;
1618
+ }
1619
+ var rotr64_lo_1 = rotr64_lo;
1620
+ function shr64_hi(ah, al, num) {
1621
+ return ah >>> num;
1622
+ }
1623
+ var shr64_hi_1 = shr64_hi;
1624
+ function shr64_lo(ah, al, num) {
1625
+ var r = (ah << (32 - num)) | (al >>> num);
1626
+ return r >>> 0;
1627
+ }
1628
+ var shr64_lo_1 = shr64_lo;
1629
+ var utils = {
1630
+ inherits: inherits_1,
1631
+ toArray: toArray_1,
1632
+ toHex: toHex_1,
1633
+ htonl: htonl_1,
1634
+ toHex32: toHex32_1,
1635
+ zero2: zero2_1,
1636
+ zero8: zero8_1,
1637
+ join32: join32_1,
1638
+ split32: split32_1,
1639
+ rotr32: rotr32_1,
1640
+ rotl32: rotl32_1,
1641
+ sum32: sum32_1,
1642
+ sum32_3: sum32_3_1,
1643
+ sum32_4: sum32_4_1,
1644
+ sum32_5: sum32_5_1,
1645
+ sum64: sum64_1,
1646
+ sum64_hi: sum64_hi_1,
1647
+ sum64_lo: sum64_lo_1,
1648
+ sum64_4_hi: sum64_4_hi_1,
1649
+ sum64_4_lo: sum64_4_lo_1,
1650
+ sum64_5_hi: sum64_5_hi_1,
1651
+ sum64_5_lo: sum64_5_lo_1,
1652
+ rotr64_hi: rotr64_hi_1,
1653
+ rotr64_lo: rotr64_lo_1,
1654
+ shr64_hi: shr64_hi_1,
1655
+ shr64_lo: shr64_lo_1
1781
1656
  };
1782
- Bundle.prototype.indent = function indent(indentStr) {
1783
- var this$1 = this;
1784
- if (!arguments.length) {
1785
- indentStr = this.getIndentString();
1786
- }
1787
- if (indentStr === '') {
1788
- return this;
1789
- } // noop
1790
- var trailingNewline = !this.intro || this.intro.slice(-1) === '\n';
1791
- this.sources.forEach(function (source, i) {
1792
- var separator = source.separator !== undefined ? source.separator : this$1.separator;
1793
- var indentStart = trailingNewline || (i > 0 && /\r?\n$/.test(separator));
1794
- source.content.indent(indentStr, {
1795
- exclude: source.indentExclusionRanges,
1796
- indentStart: indentStart //: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
1797
- });
1798
- trailingNewline = source.content.lastChar() === '\n';
1799
- });
1800
- if (this.intro) {
1801
- this.intro =
1802
- indentStr +
1803
- this.intro.replace(/^[^\n]/gm, function (match, index) {
1804
- return index > 0 ? indentStr + match : match;
1805
- });
1657
+
1658
+ function BlockHash() {
1659
+ this.pending = null;
1660
+ this.pendingTotal = 0;
1661
+ this.blockSize = this.constructor.blockSize;
1662
+ this.outSize = this.constructor.outSize;
1663
+ this.hmacStrength = this.constructor.hmacStrength;
1664
+ this.padLength = this.constructor.padLength / 8;
1665
+ this.endian = 'big';
1666
+ this._delta8 = this.blockSize / 8;
1667
+ this._delta32 = this.blockSize / 32;
1668
+ }
1669
+ var BlockHash_1 = BlockHash;
1670
+ BlockHash.prototype.update = function update(msg, enc) {
1671
+ // Convert message to array, pad it, and join into 32bit blocks
1672
+ msg = utils.toArray(msg, enc);
1673
+ if (!this.pending)
1674
+ this.pending = msg;
1675
+ else
1676
+ this.pending = this.pending.concat(msg);
1677
+ this.pendingTotal += msg.length;
1678
+ // Enough data, try updating
1679
+ if (this.pending.length >= this._delta8) {
1680
+ msg = this.pending;
1681
+ // Process pending data in blocks
1682
+ var r = msg.length % this._delta8;
1683
+ this.pending = msg.slice(msg.length - r, msg.length);
1684
+ if (this.pending.length === 0)
1685
+ this.pending = null;
1686
+ msg = utils.join32(msg, 0, msg.length - r, this.endian);
1687
+ for (var i = 0; i < msg.length; i += this._delta32)
1688
+ this._update(msg, i, i + this._delta32);
1806
1689
  }
1807
1690
  return this;
1808
1691
  };
1809
- Bundle.prototype.prepend = function prepend(str) {
1810
- this.intro = str + this.intro;
1811
- return this;
1812
- };
1813
- Bundle.prototype.toString = function toString() {
1814
- var this$1 = this;
1815
- var body = this.sources
1816
- .map(function (source, i) {
1817
- var separator = source.separator !== undefined ? source.separator : this$1.separator;
1818
- var str = (i > 0 ? separator : '') + source.content.toString();
1819
- return str;
1820
- })
1821
- .join('');
1822
- return this.intro + body;
1692
+ BlockHash.prototype.digest = function digest(enc) {
1693
+ this.update(this._pad());
1694
+ minimalisticAssert(this.pending === null);
1695
+ return this._digest(enc);
1823
1696
  };
1824
- Bundle.prototype.isEmpty = function isEmpty() {
1825
- if (this.intro.length && this.intro.trim()) {
1826
- return false;
1697
+ BlockHash.prototype._pad = function pad() {
1698
+ var len = this.pendingTotal;
1699
+ var bytes = this._delta8;
1700
+ var k = bytes - ((len + this.padLength) % bytes);
1701
+ var res = new Array(k + this.padLength);
1702
+ res[0] = 0x80;
1703
+ for (var i = 1; i < k; i++)
1704
+ res[i] = 0;
1705
+ // Append length
1706
+ len <<= 3;
1707
+ if (this.endian === 'big') {
1708
+ for (var t = 8; t < this.padLength; t++)
1709
+ res[i++] = 0;
1710
+ res[i++] = 0;
1711
+ res[i++] = 0;
1712
+ res[i++] = 0;
1713
+ res[i++] = 0;
1714
+ res[i++] = (len >>> 24) & 0xff;
1715
+ res[i++] = (len >>> 16) & 0xff;
1716
+ res[i++] = (len >>> 8) & 0xff;
1717
+ res[i++] = len & 0xff;
1827
1718
  }
1828
- if (this.sources.some(function (source) { return !source.content.isEmpty(); })) {
1829
- return false;
1719
+ else {
1720
+ res[i++] = len & 0xff;
1721
+ res[i++] = (len >>> 8) & 0xff;
1722
+ res[i++] = (len >>> 16) & 0xff;
1723
+ res[i++] = (len >>> 24) & 0xff;
1724
+ res[i++] = 0;
1725
+ res[i++] = 0;
1726
+ res[i++] = 0;
1727
+ res[i++] = 0;
1728
+ for (t = 8; t < this.padLength; t++)
1729
+ res[i++] = 0;
1830
1730
  }
1831
- return true;
1832
- };
1833
- Bundle.prototype.length = function length() {
1834
- return this.sources.reduce(function (length, source) { return length + source.content.length(); }, this.intro.length);
1835
- };
1836
- Bundle.prototype.trimLines = function trimLines() {
1837
- return this.trim('[\\r\\n]');
1731
+ return res;
1838
1732
  };
1839
- Bundle.prototype.trim = function trim(charType) {
1840
- return this.trimStart(charType).trimEnd(charType);
1733
+ var common = {
1734
+ BlockHash: BlockHash_1
1841
1735
  };
1842
- Bundle.prototype.trimStart = function trimStart(charType) {
1843
- var this$1 = this;
1844
- var rx = new RegExp('^' + (charType || '\\s') + '+');
1845
- this.intro = this.intro.replace(rx, '');
1846
- if (!this.intro) {
1847
- var source;
1848
- var i = 0;
1849
- do {
1850
- source = this$1.sources[i++];
1851
- if (!source) {
1852
- break;
1853
- }
1854
- } while (!source.content.trimStartAborted(charType));
1736
+
1737
+ var rotr32$1 = utils.rotr32;
1738
+ function ft_1(s, x, y, z) {
1739
+ if (s === 0)
1740
+ return ch32(x, y, z);
1741
+ if (s === 1 || s === 3)
1742
+ return p32(x, y, z);
1743
+ if (s === 2)
1744
+ return maj32(x, y, z);
1745
+ }
1746
+ var ft_1_1 = ft_1;
1747
+ function ch32(x, y, z) {
1748
+ return (x & y) ^ ((~x) & z);
1749
+ }
1750
+ var ch32_1 = ch32;
1751
+ function maj32(x, y, z) {
1752
+ return (x & y) ^ (x & z) ^ (y & z);
1753
+ }
1754
+ var maj32_1 = maj32;
1755
+ function p32(x, y, z) {
1756
+ return x ^ y ^ z;
1757
+ }
1758
+ var p32_1 = p32;
1759
+ function s0_256(x) {
1760
+ return rotr32$1(x, 2) ^ rotr32$1(x, 13) ^ rotr32$1(x, 22);
1761
+ }
1762
+ var s0_256_1 = s0_256;
1763
+ function s1_256(x) {
1764
+ return rotr32$1(x, 6) ^ rotr32$1(x, 11) ^ rotr32$1(x, 25);
1765
+ }
1766
+ var s1_256_1 = s1_256;
1767
+ function g0_256(x) {
1768
+ return rotr32$1(x, 7) ^ rotr32$1(x, 18) ^ (x >>> 3);
1769
+ }
1770
+ var g0_256_1 = g0_256;
1771
+ function g1_256(x) {
1772
+ return rotr32$1(x, 17) ^ rotr32$1(x, 19) ^ (x >>> 10);
1773
+ }
1774
+ var g1_256_1 = g1_256;
1775
+ var common$1 = {
1776
+ ft_1: ft_1_1,
1777
+ ch32: ch32_1,
1778
+ maj32: maj32_1,
1779
+ p32: p32_1,
1780
+ s0_256: s0_256_1,
1781
+ s1_256: s1_256_1,
1782
+ g0_256: g0_256_1,
1783
+ g1_256: g1_256_1
1784
+ };
1785
+
1786
+ var sum32$1 = utils.sum32;
1787
+ var sum32_4$1 = utils.sum32_4;
1788
+ var sum32_5$1 = utils.sum32_5;
1789
+ var ch32$1 = common$1.ch32;
1790
+ var maj32$1 = common$1.maj32;
1791
+ var s0_256$1 = common$1.s0_256;
1792
+ var s1_256$1 = common$1.s1_256;
1793
+ var g0_256$1 = common$1.g0_256;
1794
+ var g1_256$1 = common$1.g1_256;
1795
+ var BlockHash$1 = common.BlockHash;
1796
+ var sha256_K = [
1797
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
1798
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
1799
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
1800
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
1801
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
1802
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
1803
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
1804
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
1805
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
1806
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
1807
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
1808
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
1809
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
1810
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
1811
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
1812
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
1813
+ ];
1814
+ function SHA256() {
1815
+ if (!(this instanceof SHA256))
1816
+ return new SHA256();
1817
+ BlockHash$1.call(this);
1818
+ this.h = [
1819
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
1820
+ 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
1821
+ ];
1822
+ this.k = sha256_K;
1823
+ this.W = new Array(64);
1824
+ }
1825
+ utils.inherits(SHA256, BlockHash$1);
1826
+ var _256 = SHA256;
1827
+ SHA256.blockSize = 512;
1828
+ SHA256.outSize = 256;
1829
+ SHA256.hmacStrength = 192;
1830
+ SHA256.padLength = 64;
1831
+ SHA256.prototype._update = function _update(msg, start) {
1832
+ var W = this.W;
1833
+ for (var i = 0; i < 16; i++)
1834
+ W[i] = msg[start + i];
1835
+ for (; i < W.length; i++)
1836
+ W[i] = sum32_4$1(g1_256$1(W[i - 2]), W[i - 7], g0_256$1(W[i - 15]), W[i - 16]);
1837
+ var a = this.h[0];
1838
+ var b = this.h[1];
1839
+ var c = this.h[2];
1840
+ var d = this.h[3];
1841
+ var e = this.h[4];
1842
+ var f = this.h[5];
1843
+ var g = this.h[6];
1844
+ var h = this.h[7];
1845
+ minimalisticAssert(this.k.length === W.length);
1846
+ for (i = 0; i < W.length; i++) {
1847
+ var T1 = sum32_5$1(h, s1_256$1(e), ch32$1(e, f, g), this.k[i], W[i]);
1848
+ var T2 = sum32$1(s0_256$1(a), maj32$1(a, b, c));
1849
+ h = g;
1850
+ g = f;
1851
+ f = e;
1852
+ e = sum32$1(d, T1);
1853
+ d = c;
1854
+ c = b;
1855
+ b = a;
1856
+ a = sum32$1(T1, T2);
1855
1857
  }
1856
- return this;
1858
+ this.h[0] = sum32$1(this.h[0], a);
1859
+ this.h[1] = sum32$1(this.h[1], b);
1860
+ this.h[2] = sum32$1(this.h[2], c);
1861
+ this.h[3] = sum32$1(this.h[3], d);
1862
+ this.h[4] = sum32$1(this.h[4], e);
1863
+ this.h[5] = sum32$1(this.h[5], f);
1864
+ this.h[6] = sum32$1(this.h[6], g);
1865
+ this.h[7] = sum32$1(this.h[7], h);
1857
1866
  };
1858
- Bundle.prototype.trimEnd = function trimEnd(charType) {
1859
- var this$1 = this;
1860
- var rx = new RegExp((charType || '\\s') + '+$');
1861
- var source;
1862
- var i = this.sources.length - 1;
1863
- do {
1864
- source = this$1.sources[i--];
1865
- if (!source) {
1866
- this$1.intro = this$1.intro.replace(rx, '');
1867
- break;
1868
- }
1869
- } while (!source.content.trimEndAborted(charType));
1870
- return this;
1867
+ SHA256.prototype._digest = function digest(enc) {
1868
+ if (enc === 'hex')
1869
+ return utils.toHex32(this.h, 'big');
1870
+ else
1871
+ return utils.split32(this.h, 'big');
1871
1872
  };
1872
1873
 
1874
+ const createHash = () => _256();
1875
+
1873
1876
  function relative(from, to) {
1874
1877
  const fromParts = from.split(/[/\\]/).filter(Boolean);
1875
1878
  const toParts = to.split(/[/\\]/).filter(Boolean);
@@ -1938,11 +1941,9 @@ function createHasEffectsContext() {
1938
1941
  };
1939
1942
  }
1940
1943
 
1941
- const BLANK = Object.create(null);
1942
-
1943
1944
  const BlockStatement = 'BlockStatement';
1944
1945
  const CallExpression = 'CallExpression';
1945
- const ExportAllDeclaration = 'ExportAllDeclaration';
1946
+ const ExportNamespaceSpecifier = 'ExportNamespaceSpecifier';
1946
1947
  const ExpressionStatement = 'ExpressionStatement';
1947
1948
  const FunctionExpression = 'FunctionExpression';
1948
1949
  const Identifier = 'Identifier';
@@ -1951,7 +1952,6 @@ const ImportNamespaceSpecifier = 'ImportNamespaceSpecifier';
1951
1952
  const Program = 'Program';
1952
1953
  const Property = 'Property';
1953
1954
  const ReturnStatement = 'ReturnStatement';
1954
- const VariableDeclaration = 'VariableDeclaration';
1955
1955
 
1956
1956
  function treeshakeNode(node, code, start, end) {
1957
1957
  code.remove(start, end);
@@ -2674,19 +2674,18 @@ class ExternalVariable extends Variable {
2674
2674
 
2675
2675
  const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split(' ');
2676
2676
  const builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split(' ');
2677
- const blacklisted = Object.create(null);
2678
- reservedWords.concat(builtins).forEach(word => (blacklisted[word] = true));
2677
+ const blacklisted = new Set(reservedWords.concat(builtins));
2679
2678
  const illegalCharacters = /[^$_a-zA-Z0-9]/g;
2680
2679
  const startsWithDigit = (str) => /\d/.test(str[0]);
2681
2680
  function isLegal(str) {
2682
- if (startsWithDigit(str) || blacklisted[str]) {
2681
+ if (startsWithDigit(str) || blacklisted.has(str)) {
2683
2682
  return false;
2684
2683
  }
2685
2684
  return !illegalCharacters.test(str);
2686
2685
  }
2687
2686
  function makeLegal(str) {
2688
2687
  str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(illegalCharacters, '_');
2689
- if (startsWithDigit(str) || blacklisted[str])
2688
+ if (startsWithDigit(str) || blacklisted.has(str))
2690
2689
  str = `_${str}`;
2691
2690
  return str || '_';
2692
2691
  }
@@ -3500,6 +3499,8 @@ function isReference(node, parent) {
3500
3499
  return false;
3501
3500
  }
3502
3501
 
3502
+ const BLANK = Object.create(null);
3503
+
3503
3504
  const ValueProperties = Symbol('Value Properties');
3504
3505
  const PURE = { pure: true };
3505
3506
  const IMPURE = { pure: false };
@@ -4668,7 +4669,8 @@ class ExportDefaultDeclaration extends NodeBase {
4668
4669
  this.variable = this.scope.addExportDefaultDeclaration(this.declarationName || this.context.getModuleName(), this, this.context);
4669
4670
  this.context.addExport(this);
4670
4671
  }
4671
- render(code, options, { start, end } = BLANK) {
4672
+ render(code, options, nodeRenderOptions) {
4673
+ const { start, end } = nodeRenderOptions;
4672
4674
  const declarationStart = getDeclarationStart(code.original, this.start);
4673
4675
  if (this.declaration instanceof FunctionDeclaration) {
4674
4676
  this.renderNamedDeclaration(code, declarationStart, 'function', this.declaration.id === null, options);
@@ -4933,9 +4935,9 @@ function getExportBlock(exports, dependencies, namedExportsMode, interop, compac
4933
4935
  }
4934
4936
  let exportBlock = '';
4935
4937
  // star exports must always output first for precedence
4936
- dependencies.forEach(({ name, reexports }) => {
4938
+ for (const { name, reexports } of dependencies) {
4937
4939
  if (reexports && namedExportsMode) {
4938
- reexports.forEach(specifier => {
4940
+ for (const specifier of reexports) {
4939
4941
  if (specifier.reexported === '*') {
4940
4942
  if (exportBlock)
4941
4943
  exportBlock += n;
@@ -4954,9 +4956,9 @@ function getExportBlock(exports, dependencies, namedExportsMode, interop, compac
4954
4956
  `${t}if${_}(k${_}!==${_}'default')${_}exports[k]${_}=${_}${name}[k];${n}});`;
4955
4957
  }
4956
4958
  }
4957
- });
4959
+ }
4958
4960
  }
4959
- });
4961
+ }
4960
4962
  for (const { name, imports, reexports, isChunk, namedExportsMode: depNamedExportsMode, exportsNames } of dependencies) {
4961
4963
  if (reexports && namedExportsMode) {
4962
4964
  for (const specifier of reexports) {
@@ -5211,26 +5213,48 @@ function cjs(magicString, { accessedGlobals, dependencies, exports, hasExports,
5211
5213
  function esm(magicString, { intro, outro, dependencies, exports }, options) {
5212
5214
  const _ = options.compact ? '' : ' ';
5213
5215
  const n = options.compact ? '' : '\n';
5214
- const importBlock = dependencies
5215
- .map(({ id, reexports, imports, name }) => {
5216
+ const importBlock = getImportBlock(dependencies, _);
5217
+ if (importBlock.length > 0)
5218
+ intro += importBlock.join(n) + n + n;
5219
+ if (intro)
5220
+ magicString.prepend(intro);
5221
+ const exportBlock = getExportBlock$1(exports, _);
5222
+ if (exportBlock.length)
5223
+ magicString.append(n + n + exportBlock.join(n).trim());
5224
+ if (outro)
5225
+ magicString.append(outro);
5226
+ return magicString.trim();
5227
+ }
5228
+ function getImportBlock(dependencies, _) {
5229
+ const importBlock = [];
5230
+ for (const { id, reexports, imports, name } of dependencies) {
5216
5231
  if (!reexports && !imports) {
5217
- return `import${_}'${id}';`;
5232
+ importBlock.push(`import${_}'${id}';`);
5233
+ continue;
5218
5234
  }
5219
- let output = '';
5220
5235
  if (imports) {
5221
- const defaultImport = imports.find(specifier => specifier.imported === 'default');
5222
- const starImport = imports.find(specifier => specifier.imported === '*');
5236
+ let defaultImport = null;
5237
+ let starImport = null;
5238
+ const importedNames = [];
5239
+ for (const specifier of imports) {
5240
+ if (specifier.imported === 'default') {
5241
+ defaultImport = specifier;
5242
+ }
5243
+ else if (specifier.imported === '*') {
5244
+ starImport = specifier;
5245
+ }
5246
+ else {
5247
+ importedNames.push(specifier);
5248
+ }
5249
+ }
5223
5250
  if (starImport) {
5224
- output += `import${_}*${_}as ${starImport.local} from${_}'${id}';`;
5225
- if (imports.length > 1)
5226
- output += n;
5251
+ importBlock.push(`import${_}*${_}as ${starImport.local} from${_}'${id}';`);
5227
5252
  }
5228
- if (defaultImport && imports.length === 1) {
5229
- output += `import ${defaultImport.local} from${_}'${id}';`;
5253
+ if (defaultImport && importedNames.length === 0) {
5254
+ importBlock.push(`import ${defaultImport.local} from${_}'${id}';`);
5230
5255
  }
5231
- else if (!starImport || imports.length > 1) {
5232
- output += `import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${imports
5233
- .filter(specifier => specifier !== defaultImport && specifier !== starImport)
5256
+ else if (importedNames.length > 0) {
5257
+ importBlock.push(`import ${defaultImport ? `${defaultImport.local},${_}` : ''}{${_}${importedNames
5234
5258
  .map(specifier => {
5235
5259
  if (specifier.imported === specifier.local) {
5236
5260
  return specifier.imported;
@@ -5239,55 +5263,56 @@ function esm(magicString, { intro, outro, dependencies, exports }, options) {
5239
5263
  return `${specifier.imported} as ${specifier.local}`;
5240
5264
  }
5241
5265
  })
5242
- .join(`,${_}`)}${_}}${_}from${_}'${id}';`;
5266
+ .join(`,${_}`)}${_}}${_}from${_}'${id}';`);
5243
5267
  }
5244
5268
  }
5245
5269
  if (reexports) {
5246
- if (imports)
5247
- output += n;
5248
- const starExport = reexports.find(specifier => specifier.reexported === '*');
5249
- const namespaceReexport = reexports.find(specifier => specifier.imported === '*' && specifier.reexported !== '*');
5250
- if (starExport) {
5251
- output += `export${_}*${_}from${_}'${id}';`;
5252
- if (reexports.length === 1) {
5253
- return output;
5270
+ let starExport = null;
5271
+ const namespaceReexports = [];
5272
+ const namedReexports = [];
5273
+ for (const specifier of reexports) {
5274
+ if (specifier.reexported === '*') {
5275
+ starExport = specifier;
5254
5276
  }
5255
- output += n;
5256
- }
5257
- if (namespaceReexport) {
5258
- if (!imports ||
5259
- !imports.some(specifier => specifier.imported === '*' && specifier.local === name))
5260
- output += `import${_}*${_}as ${name} from${_}'${id}';${n}`;
5261
- output += `export${_}{${_}${name === namespaceReexport.reexported
5262
- ? name
5263
- : `${name} as ${namespaceReexport.reexported}`} };`;
5264
- if (reexports.length === (starExport ? 2 : 1)) {
5265
- return output;
5277
+ else if (specifier.imported === '*') {
5278
+ namespaceReexports.push(specifier);
5279
+ }
5280
+ else {
5281
+ namedReexports.push(specifier);
5266
5282
  }
5267
- output += n;
5268
5283
  }
5269
- output += `export${_}{${_}${reexports
5270
- .filter(specifier => specifier !== starExport && specifier !== namespaceReexport)
5271
- .map(specifier => {
5272
- if (specifier.imported === specifier.reexported) {
5273
- return specifier.imported;
5284
+ if (starExport) {
5285
+ importBlock.push(`export${_}*${_}from${_}'${id}';`);
5286
+ }
5287
+ if (namespaceReexports.length > 0) {
5288
+ if (!imports ||
5289
+ !imports.some(specifier => specifier.imported === '*' && specifier.local === name)) {
5290
+ importBlock.push(`import${_}*${_}as ${name} from${_}'${id}';`);
5274
5291
  }
5275
- else {
5276
- return `${specifier.imported} as ${specifier.reexported}`;
5292
+ for (const specifier of namespaceReexports) {
5293
+ importBlock.push(`export${_}{${_}${name === specifier.reexported ? name : `${name} as ${specifier.reexported}`} };`);
5277
5294
  }
5278
- })
5279
- .join(`,${_}`)}${_}}${_}from${_}'${id}';`;
5295
+ }
5296
+ if (namedReexports.length > 0) {
5297
+ importBlock.push(`export${_}{${_}${namedReexports
5298
+ .map(specifier => {
5299
+ if (specifier.imported === specifier.reexported) {
5300
+ return specifier.imported;
5301
+ }
5302
+ else {
5303
+ return `${specifier.imported} as ${specifier.reexported}`;
5304
+ }
5305
+ })
5306
+ .join(`,${_}`)}${_}}${_}from${_}'${id}';`);
5307
+ }
5280
5308
  }
5281
- return output;
5282
- })
5283
- .join(n);
5284
- if (importBlock)
5285
- intro += importBlock + n + n;
5286
- if (intro)
5287
- magicString.prepend(intro);
5309
+ }
5310
+ return importBlock;
5311
+ }
5312
+ function getExportBlock$1(exports, _) {
5288
5313
  const exportBlock = [];
5289
5314
  const exportDeclaration = [];
5290
- exports.forEach(specifier => {
5315
+ for (const specifier of exports) {
5291
5316
  if (specifier.exported === 'default') {
5292
5317
  exportBlock.push(`export default ${specifier.local};`);
5293
5318
  }
@@ -5296,15 +5321,11 @@ function esm(magicString, { intro, outro, dependencies, exports }, options) {
5296
5321
  ? specifier.local
5297
5322
  : `${specifier.local} as ${specifier.exported}`);
5298
5323
  }
5299
- });
5324
+ }
5300
5325
  if (exportDeclaration.length) {
5301
5326
  exportBlock.push(`export${_}{${_}${exportDeclaration.join(`,${_}`)}${_}};`);
5302
5327
  }
5303
- if (exportBlock.length)
5304
- magicString.append(n + n + exportBlock.join(n).trim());
5305
- if (outro)
5306
- magicString.append(outro);
5307
- return magicString.trim();
5328
+ return exportBlock;
5308
5329
  }
5309
5330
 
5310
5331
  function spaces(i) {
@@ -5595,7 +5616,7 @@ function iife(magicString, { dependencies, exports, hasExports, indentString: t,
5595
5616
  if (name && useVariableAssignment && !isLegal(name)) {
5596
5617
  error({
5597
5618
  code: 'ILLEGAL_IDENTIFIER_AS_NAME',
5598
- message: `Given name (${name}) is not legal JS identifier. If you need this you can try --extend option`
5619
+ message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`
5599
5620
  });
5600
5621
  }
5601
5622
  warnOnBuiltins(warn, dependencies);
@@ -5603,9 +5624,8 @@ function iife(magicString, { dependencies, exports, hasExports, indentString: t,
5603
5624
  const deps = external.map(dep => dep.globalName || 'null');
5604
5625
  const args = external.map(m => m.name);
5605
5626
  if (hasExports && !name) {
5606
- error({
5607
- code: 'INVALID_OPTION',
5608
- message: `You must supply "output.name" for IIFE bundles.`
5627
+ warn({
5628
+ message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.`
5609
5629
  });
5610
5630
  }
5611
5631
  if (namedExportsMode && hasExports) {
@@ -5620,7 +5640,7 @@ function iife(magicString, { dependencies, exports, hasExports, indentString: t,
5620
5640
  }
5621
5641
  const useStrict = options.strict !== false ? `${t}'use strict';${n}${n}` : ``;
5622
5642
  let wrapperIntro = `(function${_}(${args.join(`,${_}`)})${_}{${n}${useStrict}`;
5623
- if (hasExports && (!extend || !namedExportsMode)) {
5643
+ if (hasExports && (!extend || !namedExportsMode) && name) {
5624
5644
  wrapperIntro =
5625
5645
  (useVariableAssignment ? `${varOrConst} ${name}` : thisProp(name)) +
5626
5646
  `${_}=${_}${wrapperIntro}`;
@@ -5655,13 +5675,14 @@ function getStarExcludes({ dependencies, exports }) {
5655
5675
  if (!starExcludes.has('default'))
5656
5676
  starExcludes.add('default');
5657
5677
  // also include reexport names
5658
- dependencies.forEach(({ reexports }) => {
5659
- if (reexports)
5660
- reexports.forEach(reexport => {
5678
+ for (const { reexports } of dependencies) {
5679
+ if (reexports) {
5680
+ for (const reexport of reexports) {
5661
5681
  if (reexport.imported !== '*' && !starExcludes.has(reexport.reexported))
5662
5682
  starExcludes.add(reexport.reexported);
5663
- });
5664
- });
5683
+ }
5684
+ }
5685
+ }
5665
5686
  return starExcludes;
5666
5687
  }
5667
5688
  const getStarExcludesBlock = (starExcludes, varOrConst, _, t, n) => starExcludes
@@ -5692,10 +5713,10 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
5692
5713
  const importBindings = [];
5693
5714
  let starExcludes;
5694
5715
  const setters = [];
5695
- dependencies.forEach(({ imports, reexports }) => {
5716
+ for (const { imports, reexports } of dependencies) {
5696
5717
  const setter = [];
5697
5718
  if (imports) {
5698
- imports.forEach(specifier => {
5719
+ for (const specifier of imports) {
5699
5720
  importBindings.push(specifier.local);
5700
5721
  if (specifier.imported === '*') {
5701
5722
  setter.push(`${specifier.local}${_}=${_}module;`);
@@ -5703,7 +5724,7 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
5703
5724
  else {
5704
5725
  setter.push(`${specifier.local}${_}=${_}module.${specifier.imported};`);
5705
5726
  }
5706
- });
5727
+ }
5707
5728
  }
5708
5729
  if (reexports) {
5709
5730
  let createdSetter = false;
@@ -5712,9 +5733,9 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
5712
5733
  (reexports.length === 1 &&
5713
5734
  (reexports[0].reexported === '*' || reexports[0].imported === '*'))) {
5714
5735
  // star reexports
5715
- reexports.forEach(specifier => {
5736
+ for (const specifier of reexports) {
5716
5737
  if (specifier.reexported !== '*')
5717
- return;
5738
+ continue;
5718
5739
  // need own exports list for deduping in star export case
5719
5740
  if (!starExcludes) {
5720
5741
  starExcludes = getStarExcludes({ dependencies, exports });
@@ -5726,36 +5747,36 @@ function system(magicString, { accessedGlobals, dependencies, exports, hasExport
5726
5747
  setter.push(`for${_}(var _$p${_}in${_}module)${_}{`);
5727
5748
  setter.push(`${t}if${_}(!_starExcludes[_$p])${_}_setter[_$p]${_}=${_}module[_$p];`);
5728
5749
  setter.push('}');
5729
- });
5750
+ }
5730
5751
  // star import reexport
5731
- reexports.forEach(specifier => {
5752
+ for (const specifier of reexports) {
5732
5753
  if (specifier.imported !== '*' || specifier.reexported === '*')
5733
- return;
5754
+ continue;
5734
5755
  setter.push(`exports('${specifier.reexported}',${_}module);`);
5735
- });
5756
+ }
5736
5757
  // reexports
5737
- reexports.forEach(specifier => {
5758
+ for (const specifier of reexports) {
5738
5759
  if (specifier.reexported === '*' || specifier.imported === '*')
5739
- return;
5760
+ continue;
5740
5761
  if (!createdSetter) {
5741
5762
  setter.push(`${varOrConst} _setter${_}=${_}{};`);
5742
5763
  createdSetter = true;
5743
5764
  }
5744
5765
  setter.push(`_setter.${specifier.reexported}${_}=${_}module.${specifier.imported};`);
5745
- });
5766
+ }
5746
5767
  if (createdSetter) {
5747
5768
  setter.push('exports(_setter);');
5748
5769
  }
5749
5770
  }
5750
5771
  else {
5751
5772
  // single reexport
5752
- reexports.forEach(specifier => {
5773
+ for (const specifier of reexports) {
5753
5774
  setter.push(`exports('${specifier.reexported}',${_}module.${specifier.imported});`);
5754
- });
5775
+ }
5755
5776
  }
5756
5777
  }
5757
5778
  setters.push(setter.join(`${n}${t}${t}${t}`));
5758
- });
5779
+ }
5759
5780
  const registeredName = options.name ? `'${options.name}',${_}` : '';
5760
5781
  const wrapperParams = accessedGlobals.has('module')
5761
5782
  ? `exports,${_}module`
@@ -5928,6 +5949,15 @@ const extractAssignedNames = function extractAssignedNames(param) {
5928
5949
  return names;
5929
5950
  };
5930
5951
 
5952
+ class ExportAllDeclaration extends NodeBase {
5953
+ hasEffects() {
5954
+ return false;
5955
+ }
5956
+ initialise() {
5957
+ this.context.addExport(this);
5958
+ }
5959
+ }
5960
+
5931
5961
  class ArrayExpression extends NodeBase {
5932
5962
  bind() {
5933
5963
  super.bind();
@@ -6776,19 +6806,6 @@ class EmptyStatement extends NodeBase {
6776
6806
  }
6777
6807
  }
6778
6808
 
6779
- class ExportAllDeclaration$1 extends NodeBase {
6780
- hasEffects() {
6781
- return false;
6782
- }
6783
- initialise() {
6784
- this.context.addExport(this);
6785
- }
6786
- render(code, _options, { start, end } = BLANK) {
6787
- code.remove(start, end);
6788
- }
6789
- }
6790
- ExportAllDeclaration$1.prototype.needsBoundaries = true;
6791
-
6792
6809
  class ExportNamedDeclaration extends NodeBase {
6793
6810
  bind() {
6794
6811
  // Do not bind specifiers
@@ -6801,7 +6818,8 @@ class ExportNamedDeclaration extends NodeBase {
6801
6818
  initialise() {
6802
6819
  this.context.addExport(this);
6803
6820
  }
6804
- render(code, options, { start, end } = BLANK) {
6821
+ render(code, options, nodeRenderOptions) {
6822
+ const { start, end } = nodeRenderOptions;
6805
6823
  if (this.declaration === null) {
6806
6824
  code.remove(start, end);
6807
6825
  }
@@ -7059,8 +7077,8 @@ class ImportDeclaration extends NodeBase {
7059
7077
  initialise() {
7060
7078
  this.context.addImport(this);
7061
7079
  }
7062
- render(code, _options, { start, end } = BLANK) {
7063
- code.remove(start, end);
7080
+ render(code, _options, nodeRenderOptions) {
7081
+ code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
7064
7082
  }
7065
7083
  }
7066
7084
  ImportDeclaration.prototype.needsBoundaries = true;
@@ -8812,7 +8830,7 @@ function areAllDeclarationsIncludedAndNotExported(declarations) {
8812
8830
  }
8813
8831
  return true;
8814
8832
  }
8815
- class VariableDeclaration$1 extends NodeBase {
8833
+ class VariableDeclaration extends NodeBase {
8816
8834
  deoptimizePath() {
8817
8835
  for (const declarator of this.declarations) {
8818
8836
  declarator.deoptimizePath(EMPTY_PATH);
@@ -9043,7 +9061,7 @@ const nodeConstructors = {
9043
9061
  ContinueStatement,
9044
9062
  DoWhileStatement,
9045
9063
  EmptyStatement,
9046
- ExportAllDeclaration: ExportAllDeclaration$1,
9064
+ ExportAllDeclaration,
9047
9065
  ExportDefaultDeclaration,
9048
9066
  ExportNamedDeclaration,
9049
9067
  ExpressionStatement: ExpressionStatement$1,
@@ -9082,7 +9100,7 @@ const nodeConstructors = {
9082
9100
  UnaryExpression,
9083
9101
  UnknownNode,
9084
9102
  UpdateExpression,
9085
- VariableDeclaration: VariableDeclaration$1,
9103
+ VariableDeclaration,
9086
9104
  VariableDeclarator,
9087
9105
  WhileStatement,
9088
9106
  YieldExpression
@@ -9478,9 +9496,9 @@ function timeEndImpl(label, level = 3) {
9478
9496
  }
9479
9497
  function getTimings() {
9480
9498
  const newTimings = {};
9481
- Object.keys(timers).forEach(label => {
9499
+ for (const label of Object.keys(timers)) {
9482
9500
  newTimings[label] = [timers[label].time, timers[label].memory, timers[label].totalMemory];
9483
- });
9501
+ }
9484
9502
  return newTimings;
9485
9503
  }
9486
9504
  let timeStart = NOOP, timeEnd = NOOP;
@@ -9570,6 +9588,7 @@ const MISSING_EXPORT_SHIM_DESCRIPTION = {
9570
9588
  };
9571
9589
  class Module {
9572
9590
  constructor(graph, id, moduleSideEffects, isEntry) {
9591
+ this.chunk = null;
9573
9592
  this.chunkFileNames = new Set();
9574
9593
  this.chunkName = null;
9575
9594
  this.comments = [];
@@ -9579,8 +9598,8 @@ class Module {
9579
9598
  this.dynamicImports = [];
9580
9599
  this.entryPointsHash = new Uint8Array(10);
9581
9600
  this.execIndex = Infinity;
9582
- this.exportAllModules = null;
9583
- this.exportAllSources = [];
9601
+ this.exportAllModules = [];
9602
+ this.exportAllSources = new Set();
9584
9603
  this.exports = Object.create(null);
9585
9604
  this.exportsAll = Object.create(null);
9586
9605
  this.exportShimVariable = new ExportShimVariable(this);
@@ -9591,12 +9610,14 @@ class Module {
9591
9610
  this.isExecuted = false;
9592
9611
  this.isUserDefinedEntryPoint = false;
9593
9612
  this.manualChunkAlias = null;
9594
- this.reexports = Object.create(null);
9595
- this.sources = [];
9613
+ this.reexportDescriptions = Object.create(null);
9614
+ this.sources = new Set();
9596
9615
  this.userChunkNames = new Set();
9597
9616
  this.usesTopLevelAwait = false;
9598
- this.namespaceVariable = undefined;
9617
+ this.allExportNames = null;
9618
+ this.namespaceVariable = null;
9599
9619
  this.transformDependencies = [];
9620
+ this.transitiveReexports = null;
9600
9621
  this.id = id;
9601
9622
  this.graph = graph;
9602
9623
  this.excludeFromSourcemap = /\0/.test(id);
@@ -9649,7 +9670,7 @@ class Module {
9649
9670
  for (const name of Object.keys(this.exports)) {
9650
9671
  allExportNames.add(name);
9651
9672
  }
9652
- for (const name of Object.keys(this.reexports)) {
9673
+ for (const name of Object.keys(this.reexportDescriptions)) {
9653
9674
  allExportNames.add(name);
9654
9675
  }
9655
9676
  for (const module of this.exportAllModules) {
@@ -9713,7 +9734,7 @@ class Module {
9713
9734
  // to avoid infinite recursion when using circular `export * from X`
9714
9735
  this.transitiveReexports = [];
9715
9736
  const reexports = new Set();
9716
- for (const name in this.reexports) {
9737
+ for (const name in this.reexportDescriptions) {
9717
9738
  reexports.add(name);
9718
9739
  }
9719
9740
  for (const module of this.exportAllModules) {
@@ -9754,7 +9775,7 @@ class Module {
9754
9775
  }
9755
9776
  }
9756
9777
  // export { foo } from './other'
9757
- const reexportDeclaration = this.reexports[name];
9778
+ const reexportDeclaration = this.reexportDescriptions[name];
9758
9779
  if (reexportDeclaration) {
9759
9780
  const declaration = reexportDeclaration.module.getVariableForExportName(reexportDeclaration.localName);
9760
9781
  if (!declaration) {
@@ -9835,18 +9856,14 @@ class Module {
9835
9856
  this.dynamicDependencies.push(resolution);
9836
9857
  }
9837
9858
  }
9838
- this.addModulesToSpecifiers(this.importDescriptions);
9839
- this.addModulesToSpecifiers(this.reexports);
9840
- this.exportAllModules = this.exportAllSources
9841
- .map(source => {
9842
- const id = this.resolvedIds[source].id;
9843
- return this.graph.moduleById.get(id);
9844
- })
9845
- .sort((moduleA, moduleB) => {
9846
- const aExternal = moduleA instanceof ExternalModule;
9847
- const bExternal = moduleB instanceof ExternalModule;
9848
- return aExternal === bExternal ? 0 : aExternal ? 1 : -1;
9849
- });
9859
+ this.addModulesToImportDescriptions(this.importDescriptions);
9860
+ this.addModulesToImportDescriptions(this.reexportDescriptions);
9861
+ const externalExportAllModules = [];
9862
+ for (const source of this.exportAllSources) {
9863
+ const module = this.graph.moduleById.get(this.resolvedIds[source].id);
9864
+ (module instanceof ExternalModule ? externalExportAllModules : this.exportAllModules).push(module);
9865
+ }
9866
+ this.exportAllModules = this.exportAllModules.concat(externalExportAllModules);
9850
9867
  }
9851
9868
  render(options) {
9852
9869
  const magicString = this.magicString.clone();
@@ -9972,58 +9989,40 @@ class Module {
9972
9989
  this.dynamicImports.push({ node, resolution: null });
9973
9990
  }
9974
9991
  addExport(node) {
9975
- const source = node.source && node.source.value;
9976
- // export { name } from './other'
9977
- if (source) {
9978
- if (this.sources.indexOf(source) === -1)
9979
- this.sources.push(source);
9980
- if (node.type === ExportAllDeclaration) {
9981
- // Store `export * from '...'` statements in an array of delegates.
9982
- // When an unknown import is encountered, we see if one of them can satisfy it.
9983
- this.exportAllSources.push(source);
9984
- }
9985
- else {
9986
- for (const specifier of node.specifiers) {
9987
- const name = specifier.exported.name;
9988
- if (this.exports[name] || this.reexports[name]) {
9989
- this.error({
9990
- code: 'DUPLICATE_EXPORT',
9991
- message: `A module cannot have multiple exports with the same name ('${name}')`
9992
- }, specifier.start);
9993
- }
9994
- this.reexports[name] = {
9995
- localName: specifier.local.name,
9996
- module: null,
9997
- source,
9998
- start: specifier.start
9999
- };
10000
- }
10001
- }
10002
- }
10003
- else if (node instanceof ExportDefaultDeclaration) {
10004
- // export default function foo () {}
9992
+ if (node instanceof ExportDefaultDeclaration) {
10005
9993
  // export default foo;
10006
- // export default 42;
10007
- if (this.exports.default) {
10008
- this.error({
10009
- code: 'DUPLICATE_EXPORT',
10010
- message: `A module can only have one default export`
10011
- }, node.start);
10012
- }
10013
9994
  this.exports.default = {
10014
9995
  identifier: node.variable.getAssignedVariableName(),
10015
9996
  localName: 'default'
10016
9997
  };
10017
9998
  }
9999
+ else if (node instanceof ExportAllDeclaration) {
10000
+ // export * from './other'
10001
+ const source = node.source.value;
10002
+ this.sources.add(source);
10003
+ this.exportAllSources.add(source);
10004
+ }
10005
+ else if (node.source !== null) {
10006
+ // export { name } from './other'
10007
+ const source = node.source.value;
10008
+ this.sources.add(source);
10009
+ for (const specifier of node.specifiers) {
10010
+ const name = specifier.exported.name;
10011
+ this.reexportDescriptions[name] = {
10012
+ localName: specifier.type === ExportNamespaceSpecifier ? '*' : specifier.local.name,
10013
+ module: null,
10014
+ source,
10015
+ start: specifier.start
10016
+ };
10017
+ }
10018
+ }
10018
10019
  else if (node.declaration) {
10019
- // export var { foo, bar } = ...
10020
- // export var foo = 42;
10021
- // export var a = 1, b = 2, c = 3;
10022
- // export function foo () {}
10023
10020
  const declaration = node.declaration;
10024
- if (declaration.type === VariableDeclaration) {
10025
- for (const decl of declaration.declarations) {
10026
- for (const localName of extractAssignedNames(decl.id)) {
10021
+ if (declaration instanceof VariableDeclaration) {
10022
+ // export var { foo, bar } = ...
10023
+ // export var foo = 1, bar = 2;
10024
+ for (const declarator of declaration.declarations) {
10025
+ for (const localName of extractAssignedNames(declarator.id)) {
10027
10026
  this.exports[localName] = { identifier: null, localName };
10028
10027
  }
10029
10028
  }
@@ -10039,20 +10038,13 @@ class Module {
10039
10038
  for (const specifier of node.specifiers) {
10040
10039
  const localName = specifier.local.name;
10041
10040
  const exportedName = specifier.exported.name;
10042
- if (this.exports[exportedName] || this.reexports[exportedName]) {
10043
- this.error({
10044
- code: 'DUPLICATE_EXPORT',
10045
- message: `A module cannot have multiple exports with the same name ('${exportedName}')`
10046
- }, specifier.start);
10047
- }
10048
10041
  this.exports[exportedName] = { identifier: null, localName };
10049
10042
  }
10050
10043
  }
10051
10044
  }
10052
10045
  addImport(node) {
10053
10046
  const source = node.source.value;
10054
- if (this.sources.indexOf(source) === -1)
10055
- this.sources.push(source);
10047
+ this.sources.add(source);
10056
10048
  for (const specifier of node.specifiers) {
10057
10049
  const localName = specifier.local.name;
10058
10050
  if (this.importDescriptions[localName]) {
@@ -10074,9 +10066,9 @@ class Module {
10074
10066
  addImportMeta(node) {
10075
10067
  this.importMetas.push(node);
10076
10068
  }
10077
- addModulesToSpecifiers(specifiers) {
10078
- for (const name of Object.keys(specifiers)) {
10079
- const specifier = specifiers[name];
10069
+ addModulesToImportDescriptions(importDescription) {
10070
+ for (const name of Object.keys(importDescription)) {
10071
+ const specifier = importDescription[name];
10080
10072
  const id = this.resolvedIds[specifier.source].id;
10081
10073
  specifier.module = this.graph.moduleById.get(id);
10082
10074
  }
@@ -10775,7 +10767,7 @@ class Chunk$1 {
10775
10767
  return this.renderedHash;
10776
10768
  if (!this.renderedSource)
10777
10769
  return '';
10778
- const hash = _256();
10770
+ const hash = createHash();
10779
10771
  const hashAugmentation = this.calculateHashAugmentation();
10780
10772
  hash.update(hashAugmentation);
10781
10773
  hash.update(this.renderedSource.toString());
@@ -11187,7 +11179,7 @@ class Chunk$1 {
11187
11179
  return hashAugmentation;
11188
11180
  }
11189
11181
  computeContentHashWithDependencies(addons, options, existingNames) {
11190
- const hash = _256();
11182
+ const hash = createHash();
11191
11183
  hash.update([addons.intro, addons.outro, addons.banner, addons.footer].map(addon => addon || '').join(':'));
11192
11184
  hash.update(options.format);
11193
11185
  this.visitDependencies(dep => {
@@ -11467,8 +11459,8 @@ class Chunk$1 {
11467
11459
  }
11468
11460
  }
11469
11461
  if (module.getOrCreateNamespace().included) {
11470
- for (const reexportName of Object.keys(module.reexports)) {
11471
- const reexport = module.reexports[reexportName];
11462
+ for (const reexportName of Object.keys(module.reexportDescriptions)) {
11463
+ const reexport = module.reexportDescriptions[reexportName];
11472
11464
  const variable = reexport.module.getVariableForExportName(reexport.localName);
11473
11465
  if (variable.module.chunk !== this) {
11474
11466
  this.imports.add(variable);
@@ -11595,25 +11587,54 @@ function optimizeChunks(chunks, options, CHUNK_GROUPING_SIZE, inputBase) {
11595
11587
  return chunks;
11596
11588
  }
11597
11589
 
11598
- const tt = acorn__default.tokTypes;
11599
11590
  const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
11591
+ const tt = acorn__default.tokTypes;
11592
+ var acornExportNsFrom = function (Parser) {
11593
+ return class extends Parser {
11594
+ parseExport(node, exports) {
11595
+ skipWhiteSpace.lastIndex = this.pos;
11596
+ const skip = skipWhiteSpace.exec(this.input);
11597
+ const next = this.input.charAt(this.pos + skip[0].length);
11598
+ if (next !== "*")
11599
+ return super.parseExport(node, exports);
11600
+ this.next();
11601
+ const specifier = this.startNode();
11602
+ this.expect(tt.star);
11603
+ if (this.eatContextual("as")) {
11604
+ node.declaration = null;
11605
+ specifier.exported = this.parseIdent(true);
11606
+ this.checkExport(exports, specifier.exported.name, this.lastTokStart);
11607
+ node.specifiers = [this.finishNode(specifier, "ExportNamespaceSpecifier")];
11608
+ }
11609
+ this.expectContextual("from");
11610
+ if (this.type !== tt.string)
11611
+ this.unexpected();
11612
+ node.source = this.parseExprAtom();
11613
+ this.semicolon();
11614
+ return this.finishNode(node, node.specifiers ? "ExportNamedDeclaration" : "ExportAllDeclaration");
11615
+ }
11616
+ };
11617
+ };
11618
+
11619
+ const tt$1 = acorn__default.tokTypes;
11620
+ const skipWhiteSpace$1 = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
11600
11621
  const nextTokenIsDot = parser => {
11601
- skipWhiteSpace.lastIndex = parser.pos;
11602
- let skip = skipWhiteSpace.exec(parser.input);
11622
+ skipWhiteSpace$1.lastIndex = parser.pos;
11623
+ let skip = skipWhiteSpace$1.exec(parser.input);
11603
11624
  let next = parser.pos + skip[0].length;
11604
11625
  return parser.input.slice(next, next + 1) === ".";
11605
11626
  };
11606
11627
  var acornImportMeta = function (Parser) {
11607
11628
  return class extends Parser {
11608
11629
  parseExprAtom(refDestructuringErrors) {
11609
- if (this.type !== tt._import || !nextTokenIsDot(this))
11630
+ if (this.type !== tt$1._import || !nextTokenIsDot(this))
11610
11631
  return super.parseExprAtom(refDestructuringErrors);
11611
11632
  if (!this.options.allowImportExportEverywhere && !this.inModule) {
11612
11633
  this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
11613
11634
  }
11614
11635
  let node = this.startNode();
11615
11636
  node.meta = this.parseIdent(true);
11616
- this.expect(tt.dot);
11637
+ this.expect(tt$1.dot);
11617
11638
  node.property = this.parseIdent(true);
11618
11639
  if (node.property.name !== "meta") {
11619
11640
  this.raiseRecoverable(node.property.start, "The only valid meta property for import is import.meta");
@@ -11624,7 +11645,7 @@ var acornImportMeta = function (Parser) {
11624
11645
  return this.finishNode(node, "MetaProperty");
11625
11646
  }
11626
11647
  parseStatement(context, topLevel, exports) {
11627
- if (this.type !== tt._import || !nextTokenIsDot(this)) {
11648
+ if (this.type !== tt$1._import || !nextTokenIsDot(this)) {
11628
11649
  return super.parseStatement(context, topLevel, exports);
11629
11650
  }
11630
11651
  let node = this.startNode();
@@ -11665,11 +11686,13 @@ var BuildPhase;
11665
11686
  BuildPhase[BuildPhase["GENERATE"] = 2] = "GENERATE";
11666
11687
  })(BuildPhase || (BuildPhase = {}));
11667
11688
 
11689
+ const createHash$1 = () => createHash$2('sha256');
11690
+
11668
11691
  function generateAssetFileName(name, source, output) {
11669
11692
  const emittedName = name || 'asset';
11670
11693
  return makeUnique(renderNamePattern(output.assetFileNames, 'output.assetFileNames', {
11671
11694
  hash() {
11672
- const hash = _256();
11695
+ const hash = createHash$1();
11673
11696
  hash.update(emittedName);
11674
11697
  hash.update(':');
11675
11698
  hash.update(source);
@@ -11846,7 +11869,7 @@ class FileEmitter {
11846
11869
  assignReferenceId(file, idBase) {
11847
11870
  let referenceId;
11848
11871
  do {
11849
- const hash = _256();
11872
+ const hash = createHash$1();
11850
11873
  if (referenceId) {
11851
11874
  hash.update(referenceId);
11852
11875
  }
@@ -11993,7 +12016,7 @@ function createPluginDriver(graph, options, pluginCache, watcher) {
11993
12016
  id: foundModule.id,
11994
12017
  importedIds: foundModule instanceof ExternalModule
11995
12018
  ? []
11996
- : foundModule.sources.map(id => foundModule.resolvedIds[id].id),
12019
+ : Array.from(foundModule.sources).map(id => foundModule.resolvedIds[id].id),
11997
12020
  isEntry: foundModule instanceof Module && foundModule.isEntryPoint,
11998
12021
  isExternal: foundModule instanceof ExternalModule
11999
12022
  };
@@ -12582,26 +12605,29 @@ class ModuleLoader {
12582
12605
  return getCombinedPromise().then(() => loadNewModulesPromise);
12583
12606
  }
12584
12607
  fetchAllDependencies(module) {
12585
- const fetchDynamicImportsPromise = Promise.all(module.getDynamicImportExpressions().map((specifier, index) => this.resolveDynamicImport(module, specifier, module.id).then(resolvedId => {
12586
- if (resolvedId === null)
12587
- return;
12588
- const dynamicImport = module.dynamicImports[index];
12589
- if (typeof resolvedId === 'string') {
12590
- dynamicImport.resolution = resolvedId;
12591
- return;
12592
- }
12593
- return this.fetchResolvedDependency(relativeId(resolvedId.id), module.id, resolvedId).then(module => {
12594
- dynamicImport.resolution = module;
12595
- });
12596
- })));
12597
- fetchDynamicImportsPromise.catch(() => { });
12598
- return Promise.all(module.sources.map(source => this.resolveAndFetchDependency(module, source))).then(() => fetchDynamicImportsPromise);
12608
+ return Promise.all([
12609
+ ...Array.from(module.sources).map((source) => __awaiter(this, void 0, void 0, function* () {
12610
+ return this.fetchResolvedDependency(source, module.id, (module.resolvedIds[source] =
12611
+ module.resolvedIds[source] ||
12612
+ this.handleMissingImports(yield this.resolveId(source, module.id), source, module.id)));
12613
+ })),
12614
+ ...module.getDynamicImportExpressions().map((specifier, index) => this.resolveDynamicImport(module, specifier, module.id).then(resolvedId => {
12615
+ if (resolvedId === null)
12616
+ return;
12617
+ const dynamicImport = module.dynamicImports[index];
12618
+ if (typeof resolvedId === 'string') {
12619
+ dynamicImport.resolution = resolvedId;
12620
+ return;
12621
+ }
12622
+ return this.fetchResolvedDependency(relativeId(resolvedId.id), module.id, resolvedId).then(module => {
12623
+ dynamicImport.resolution = module;
12624
+ });
12625
+ }))
12626
+ ]);
12599
12627
  }
12600
12628
  fetchModule(id, importer, moduleSideEffects, isEntry) {
12601
12629
  const existingModule = this.modulesById.get(id);
12602
- if (existingModule) {
12603
- if (existingModule instanceof ExternalModule)
12604
- throw new Error(`Cannot fetch external module ${id}`);
12630
+ if (existingModule instanceof Module) {
12605
12631
  existingModule.isEntryPoint = existingModule.isEntryPoint || isEntry;
12606
12632
  return Promise.resolve(existingModule);
12607
12633
  }
@@ -12656,11 +12682,11 @@ class ModuleLoader {
12656
12682
  module.exportsAll[name] = module.id;
12657
12683
  }
12658
12684
  }
12659
- module.exportAllSources.forEach(source => {
12685
+ for (const source of module.exportAllSources) {
12660
12686
  const id = module.resolvedIds[source].id;
12661
12687
  const exportAllModule = this.modulesById.get(id);
12662
12688
  if (exportAllModule instanceof ExternalModule)
12663
- return;
12689
+ continue;
12664
12690
  for (const name in exportAllModule.exportsAll) {
12665
12691
  if (name in module.exportsAll) {
12666
12692
  this.graph.warn(errNamespaceConflict(name, module, exportAllModule));
@@ -12669,7 +12695,7 @@ class ModuleLoader {
12669
12695
  module.exportsAll[name] = exportAllModule.exportsAll[name];
12670
12696
  }
12671
12697
  }
12672
- });
12698
+ }
12673
12699
  return module;
12674
12700
  });
12675
12701
  });
@@ -12739,13 +12765,6 @@ class ModuleLoader {
12739
12765
  : this.hasModuleSideEffects(id, external)
12740
12766
  };
12741
12767
  }
12742
- resolveAndFetchDependency(module, source) {
12743
- return __awaiter(this, void 0, void 0, function* () {
12744
- return this.fetchResolvedDependency(source, module.id, (module.resolvedIds[source] =
12745
- module.resolvedIds[source] ||
12746
- this.handleMissingImports(yield this.resolveId(source, module.id), source, module.id)));
12747
- });
12748
- }
12749
12768
  resolveDynamicImport(module, specifier, importer) {
12750
12769
  return __awaiter(this, void 0, void 0, function* () {
12751
12770
  // TODO we only should expose the acorn AST here
@@ -12962,7 +12981,7 @@ class Graph {
12962
12981
  }
12963
12982
  this.acornOptions = options.acorn ? Object.assign({}, options.acorn) : {};
12964
12983
  const acornPluginsToInject = [];
12965
- acornPluginsToInject.push(acornImportMeta);
12984
+ acornPluginsToInject.push(acornImportMeta, acornExportNsFrom);
12966
12985
  if (options.experimentalTopLevelAwait) {
12967
12986
  this.acornOptions.allowAwaitOutsideFunction = true;
12968
12987
  }
@@ -16996,12 +17015,12 @@ class FileWatcher {
16996
17015
  }
16997
17016
  }
16998
17017
  trigger(id) {
16999
- this.tasks.forEach(task => {
17018
+ for (const task of this.tasks) {
17000
17019
  task.invalidate(id, false);
17001
- });
17002
- this.transformDependencyTasks.forEach(task => {
17020
+ }
17021
+ for (const task of this.transformDependencyTasks) {
17003
17022
  task.invalidate(id, true);
17004
- });
17023
+ }
17005
17024
  }
17006
17025
  }
17007
17026