jass-vue 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jass/vue/version.rb +1 -1
  3. data/lib/jass/vue.rb +1 -0
  4. data/vendor/node_modules/balanced-match/index.js +59 -0
  5. data/vendor/node_modules/balanced-match/package.json +49 -0
  6. data/vendor/node_modules/brace-expansion/index.js +201 -0
  7. data/vendor/node_modules/brace-expansion/package.json +47 -0
  8. data/vendor/node_modules/concat-map/index.js +13 -0
  9. data/vendor/node_modules/concat-map/package.json +43 -0
  10. data/vendor/node_modules/minimatch/minimatch.js +923 -0
  11. data/vendor/node_modules/minimatch/package.json +30 -0
  12. data/vendor/node_modules/rollup-plugin-replace/dist/rollup-plugin-replace.cjs.js +88 -0
  13. data/vendor/node_modules/rollup-plugin-replace/dist/rollup-plugin-replace.es.js +84 -0
  14. data/vendor/node_modules/rollup-plugin-replace/node_modules/estree-walker/dist/estree-walker.es.js +57 -0
  15. data/vendor/node_modules/rollup-plugin-replace/node_modules/estree-walker/dist/estree-walker.umd.js +68 -0
  16. data/vendor/node_modules/rollup-plugin-replace/node_modules/estree-walker/index.d.ts +17 -0
  17. data/vendor/node_modules/rollup-plugin-replace/node_modules/estree-walker/package.json +35 -0
  18. data/vendor/node_modules/rollup-plugin-replace/node_modules/estree-walker/src/estree-walker.js +51 -0
  19. data/vendor/node_modules/rollup-plugin-replace/node_modules/magic-string/dist/magic-string.cjs.js +1300 -0
  20. data/vendor/node_modules/rollup-plugin-replace/node_modules/magic-string/dist/magic-string.es.js +1296 -0
  21. data/vendor/node_modules/rollup-plugin-replace/node_modules/magic-string/dist/magic-string.umd.js +1352 -0
  22. data/vendor/node_modules/rollup-plugin-replace/node_modules/magic-string/index.d.ts +83 -0
  23. data/vendor/node_modules/rollup-plugin-replace/node_modules/magic-string/package.json +55 -0
  24. data/vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/dist/pluginutils.cjs.js +302 -0
  25. data/vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/dist/pluginutils.es.js +292 -0
  26. data/vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/package.json +46 -0
  27. data/vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/src/addExtension.js +6 -0
  28. data/vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/src/attachScopes.js +155 -0
  29. data/vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/src/createFilter.js +33 -0
  30. data/vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/src/dataToEsm.js +69 -0
  31. data/vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/src/index.js +5 -0
  32. data/vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/src/makeLegalIdentifier.js +15 -0
  33. data/vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/src/utils/ensureArray.js +5 -0
  34. data/vendor/node_modules/rollup-plugin-replace/package.json +43 -0
  35. data/vendor/node_modules/rollup-plugin-replace/src/index.js +80 -0
  36. data/vendor/package.json +1 -0
  37. data/vendor/yarn.lock +47 -1
  38. metadata +36 -4
@@ -0,0 +1,1296 @@
1
+ import { encode } from 'vlq';
2
+
3
+ function Chunk ( start, end, content ) {
4
+ this.start = start;
5
+ this.end = end;
6
+ this.original = content;
7
+
8
+ this.intro = '';
9
+ this.outro = '';
10
+
11
+ this.content = content;
12
+ this.storeName = false;
13
+ this.edited = false;
14
+
15
+ // we make these non-enumerable, for sanity while debugging
16
+ Object.defineProperties( this, {
17
+ previous: { writable: true, value: null },
18
+ next: { writable: true, value: null }
19
+ });
20
+ }
21
+
22
+ Chunk.prototype = {
23
+ appendLeft: function appendLeft ( content ) {
24
+ this.outro += content;
25
+ },
26
+
27
+ appendRight: function appendRight ( content ) {
28
+ this.intro = this.intro + content;
29
+ },
30
+
31
+ clone: function clone () {
32
+ var chunk = new Chunk( this.start, this.end, this.original );
33
+
34
+ chunk.intro = this.intro;
35
+ chunk.outro = this.outro;
36
+ chunk.content = this.content;
37
+ chunk.storeName = this.storeName;
38
+ chunk.edited = this.edited;
39
+
40
+ return chunk;
41
+ },
42
+
43
+ contains: function contains ( index ) {
44
+ return this.start < index && index < this.end;
45
+ },
46
+
47
+ eachNext: function eachNext ( fn ) {
48
+ var chunk = this;
49
+ while ( chunk ) {
50
+ fn( chunk );
51
+ chunk = chunk.next;
52
+ }
53
+ },
54
+
55
+ eachPrevious: function eachPrevious ( fn ) {
56
+ var chunk = this;
57
+ while ( chunk ) {
58
+ fn( chunk );
59
+ chunk = chunk.previous;
60
+ }
61
+ },
62
+
63
+ edit: function edit ( content, storeName, contentOnly ) {
64
+ this.content = content;
65
+ if ( !contentOnly ) {
66
+ this.intro = '';
67
+ this.outro = '';
68
+ }
69
+ this.storeName = storeName;
70
+
71
+ this.edited = true;
72
+
73
+ return this;
74
+ },
75
+
76
+ prependLeft: function prependLeft ( content ) {
77
+ this.outro = content + this.outro;
78
+ },
79
+
80
+ prependRight: function prependRight ( content ) {
81
+ this.intro = content + this.intro;
82
+ },
83
+
84
+ split: function split ( index ) {
85
+ var sliceIndex = index - this.start;
86
+
87
+ var originalBefore = this.original.slice( 0, sliceIndex );
88
+ var originalAfter = this.original.slice( sliceIndex );
89
+
90
+ this.original = originalBefore;
91
+
92
+ var newChunk = new Chunk( index, this.end, originalAfter );
93
+ newChunk.outro = this.outro;
94
+ this.outro = '';
95
+
96
+ this.end = index;
97
+
98
+ if ( this.edited ) {
99
+ // TODO is this block necessary?...
100
+ newChunk.edit( '', false );
101
+ this.content = '';
102
+ } else {
103
+ this.content = originalBefore;
104
+ }
105
+
106
+ newChunk.next = this.next;
107
+ if ( newChunk.next ) { newChunk.next.previous = newChunk; }
108
+ newChunk.previous = this;
109
+ this.next = newChunk;
110
+
111
+ return newChunk;
112
+ },
113
+
114
+ toString: function toString () {
115
+ return this.intro + this.content + this.outro;
116
+ },
117
+
118
+ trimEnd: function trimEnd ( rx ) {
119
+ this.outro = this.outro.replace( rx, '' );
120
+ if ( this.outro.length ) { return true; }
121
+
122
+ var trimmed = this.content.replace( rx, '' );
123
+
124
+ if ( trimmed.length ) {
125
+ if ( trimmed !== this.content ) {
126
+ this.split( this.start + trimmed.length ).edit( '', false );
127
+ }
128
+
129
+ return true;
130
+ } else {
131
+ this.edit( '', false );
132
+
133
+ this.intro = this.intro.replace( rx, '' );
134
+ if ( this.intro.length ) { return true; }
135
+ }
136
+ },
137
+
138
+ trimStart: function trimStart ( rx ) {
139
+ this.intro = this.intro.replace( rx, '' );
140
+ if ( this.intro.length ) { return true; }
141
+
142
+ var trimmed = this.content.replace( rx, '' );
143
+
144
+ if ( trimmed.length ) {
145
+ if ( trimmed !== this.content ) {
146
+ this.split( this.end - trimmed.length );
147
+ this.edit( '', false );
148
+ }
149
+
150
+ return true;
151
+ } else {
152
+ this.edit( '', false );
153
+
154
+ this.outro = this.outro.replace( rx, '' );
155
+ if ( this.outro.length ) { return true; }
156
+ }
157
+ }
158
+ };
159
+
160
+ var _btoa;
161
+
162
+ if ( typeof window !== 'undefined' && typeof window.btoa === 'function' ) {
163
+ _btoa = window.btoa;
164
+ } else if ( typeof Buffer === 'function' ) {
165
+ _btoa = function (str) { return new Buffer( str ).toString( 'base64' ); };
166
+ } else {
167
+ _btoa = function () {
168
+ throw new Error( 'Unsupported environment: `window.btoa` or `Buffer` should be supported.' );
169
+ };
170
+ }
171
+
172
+ var btoa = _btoa;
173
+
174
+ function SourceMap ( properties ) {
175
+ this.version = 3;
176
+
177
+ this.file = properties.file;
178
+ this.sources = properties.sources;
179
+ this.sourcesContent = properties.sourcesContent;
180
+ this.names = properties.names;
181
+ this.mappings = properties.mappings;
182
+ }
183
+
184
+ SourceMap.prototype = {
185
+ toString: function toString () {
186
+ return JSON.stringify( this );
187
+ },
188
+
189
+ toUrl: function toUrl () {
190
+ return 'data:application/json;charset=utf-8;base64,' + btoa( this.toString() );
191
+ }
192
+ };
193
+
194
+ function guessIndent ( code ) {
195
+ var lines = code.split( '\n' );
196
+
197
+ var tabbed = lines.filter( function (line) { return /^\t+/.test( line ); } );
198
+ var spaced = lines.filter( function (line) { return /^ {2,}/.test( line ); } );
199
+
200
+ if ( tabbed.length === 0 && spaced.length === 0 ) {
201
+ return null;
202
+ }
203
+
204
+ // More lines tabbed than spaced? Assume tabs, and
205
+ // default to tabs in the case of a tie (or nothing
206
+ // to go on)
207
+ if ( tabbed.length >= spaced.length ) {
208
+ return '\t';
209
+ }
210
+
211
+ // Otherwise, we need to guess the multiple
212
+ var min = spaced.reduce( function ( previous, current ) {
213
+ var numSpaces = /^ +/.exec( current )[0].length;
214
+ return Math.min( numSpaces, previous );
215
+ }, Infinity );
216
+
217
+ return new Array( min + 1 ).join( ' ' );
218
+ }
219
+
220
+ function getRelativePath ( from, to ) {
221
+ var fromParts = from.split( /[\/\\]/ );
222
+ var toParts = to.split( /[\/\\]/ );
223
+
224
+ fromParts.pop(); // get dirname
225
+
226
+ while ( fromParts[0] === toParts[0] ) {
227
+ fromParts.shift();
228
+ toParts.shift();
229
+ }
230
+
231
+ if ( fromParts.length ) {
232
+ var i = fromParts.length;
233
+ while ( i-- ) { fromParts[i] = '..'; }
234
+ }
235
+
236
+ return fromParts.concat( toParts ).join( '/' );
237
+ }
238
+
239
+ var toString = Object.prototype.toString;
240
+
241
+ function isObject ( thing ) {
242
+ return toString.call( thing ) === '[object Object]';
243
+ }
244
+
245
+ function getLocator ( source ) {
246
+ var originalLines = source.split( '\n' );
247
+
248
+ var start = 0;
249
+ var lineRanges = originalLines.map( function ( line, i ) {
250
+ var end = start + line.length + 1;
251
+ var range = { start: start, end: end, line: i };
252
+
253
+ start = end;
254
+ return range;
255
+ });
256
+
257
+ var i = 0;
258
+
259
+ function rangeContains ( range, index ) {
260
+ return range.start <= index && index < range.end;
261
+ }
262
+
263
+ function getLocation ( range, index ) {
264
+ return { line: range.line, column: index - range.start };
265
+ }
266
+
267
+ return function locate ( index ) {
268
+ var range = lineRanges[i];
269
+
270
+ var d = index >= range.end ? 1 : -1;
271
+
272
+ while ( range ) {
273
+ if ( rangeContains( range, index ) ) { return getLocation( range, index ); }
274
+
275
+ i += d;
276
+ range = lineRanges[i];
277
+ }
278
+ };
279
+ }
280
+
281
+ function Mappings ( hires ) {
282
+ var this$1 = this;
283
+
284
+ var offsets = {
285
+ generatedCodeColumn: 0,
286
+ sourceIndex: 0,
287
+ sourceCodeLine: 0,
288
+ sourceCodeColumn: 0,
289
+ sourceCodeName: 0
290
+ };
291
+
292
+ var generatedCodeLine = 0;
293
+ var generatedCodeColumn = 0;
294
+
295
+ this.raw = [];
296
+ var rawSegments = this.raw[ generatedCodeLine ] = [];
297
+
298
+ var pending = null;
299
+
300
+ this.addEdit = function ( sourceIndex, content, original, loc, nameIndex ) {
301
+ if ( content.length ) {
302
+ rawSegments.push([
303
+ generatedCodeColumn,
304
+ sourceIndex,
305
+ loc.line,
306
+ loc.column,
307
+ nameIndex ]);
308
+ } else if ( pending ) {
309
+ rawSegments.push( pending );
310
+ }
311
+
312
+ this$1.advance( content );
313
+ pending = null;
314
+ };
315
+
316
+ this.addUneditedChunk = function ( sourceIndex, chunk, original, loc, sourcemapLocations ) {
317
+ var originalCharIndex = chunk.start;
318
+ var first = true;
319
+
320
+ while ( originalCharIndex < chunk.end ) {
321
+ if ( hires || first || sourcemapLocations[ originalCharIndex ] ) {
322
+ rawSegments.push([
323
+ generatedCodeColumn,
324
+ sourceIndex,
325
+ loc.line,
326
+ loc.column,
327
+ -1
328
+ ]);
329
+ }
330
+
331
+ if ( original[ originalCharIndex ] === '\n' ) {
332
+ loc.line += 1;
333
+ loc.column = 0;
334
+ generatedCodeLine += 1;
335
+ this$1.raw[ generatedCodeLine ] = rawSegments = [];
336
+ generatedCodeColumn = 0;
337
+ } else {
338
+ loc.column += 1;
339
+ generatedCodeColumn += 1;
340
+ }
341
+
342
+ originalCharIndex += 1;
343
+ first = false;
344
+ }
345
+
346
+ pending = [
347
+ generatedCodeColumn,
348
+ sourceIndex,
349
+ loc.line,
350
+ loc.column,
351
+ -1 ];
352
+ };
353
+
354
+ this.advance = function (str) {
355
+ if ( !str ) { return; }
356
+
357
+ var lines = str.split( '\n' );
358
+ var lastLine = lines.pop();
359
+
360
+ if ( lines.length ) {
361
+ generatedCodeLine += lines.length;
362
+ this$1.raw[ generatedCodeLine ] = rawSegments = [];
363
+ generatedCodeColumn = lastLine.length;
364
+ } else {
365
+ generatedCodeColumn += lastLine.length;
366
+ }
367
+ };
368
+
369
+ this.encode = function () {
370
+ return this$1.raw.map( function (segments) {
371
+ var generatedCodeColumn = 0;
372
+
373
+ return segments.map( function (segment) {
374
+ var arr = [
375
+ segment[0] - generatedCodeColumn,
376
+ segment[1] - offsets.sourceIndex,
377
+ segment[2] - offsets.sourceCodeLine,
378
+ segment[3] - offsets.sourceCodeColumn
379
+ ];
380
+
381
+ generatedCodeColumn = segment[0];
382
+ offsets.sourceIndex = segment[1];
383
+ offsets.sourceCodeLine = segment[2];
384
+ offsets.sourceCodeColumn = segment[3];
385
+
386
+ if ( ~segment[4] ) {
387
+ arr.push( segment[4] - offsets.sourceCodeName );
388
+ offsets.sourceCodeName = segment[4];
389
+ }
390
+
391
+ return encode( arr );
392
+ }).join( ',' );
393
+ }).join( ';' );
394
+ };
395
+ }
396
+
397
+ var Stats = function Stats () {
398
+ Object.defineProperties( this, {
399
+ startTimes: { value: {} }
400
+ });
401
+ };
402
+
403
+ Stats.prototype.time = function time ( label ) {
404
+ this.startTimes[ label ] = process.hrtime();
405
+ };
406
+
407
+ Stats.prototype.timeEnd = function timeEnd ( label ) {
408
+ var elapsed = process.hrtime( this.startTimes[ label ] );
409
+
410
+ if ( !this[ label ] ) { this[ label ] = 0; }
411
+ this[ label ] += elapsed[0] * 1e3 + elapsed[1] * 1e-6;
412
+ };
413
+
414
+ var warned = {
415
+ insertLeft: false,
416
+ insertRight: false,
417
+ storeName: false
418
+ };
419
+
420
+ function MagicString$1 ( string, options ) {
421
+ if ( options === void 0 ) options = {};
422
+
423
+ var chunk = new Chunk( 0, string.length, string );
424
+
425
+ Object.defineProperties( this, {
426
+ original: { writable: true, value: string },
427
+ outro: { writable: true, value: '' },
428
+ intro: { writable: true, value: '' },
429
+ firstChunk: { writable: true, value: chunk },
430
+ lastChunk: { writable: true, value: chunk },
431
+ lastSearchedChunk: { writable: true, value: chunk },
432
+ byStart: { writable: true, value: {} },
433
+ byEnd: { writable: true, value: {} },
434
+ filename: { writable: true, value: options.filename },
435
+ indentExclusionRanges: { writable: true, value: options.indentExclusionRanges },
436
+ sourcemapLocations: { writable: true, value: {} },
437
+ storedNames: { writable: true, value: {} },
438
+ indentStr: { writable: true, value: guessIndent( string ) }
439
+ });
440
+
441
+ this.byStart[ 0 ] = chunk;
442
+ this.byEnd[ string.length ] = chunk;
443
+ }
444
+
445
+ MagicString$1.prototype = {
446
+ addSourcemapLocation: function addSourcemapLocation ( char ) {
447
+ this.sourcemapLocations[ char ] = true;
448
+ },
449
+
450
+ append: function append ( content ) {
451
+ if ( typeof content !== 'string' ) { throw new TypeError( 'outro content must be a string' ); }
452
+
453
+ this.outro += content;
454
+ return this;
455
+ },
456
+
457
+ appendLeft: function appendLeft ( index, content ) {
458
+ if ( typeof content !== 'string' ) { throw new TypeError( 'inserted content must be a string' ); }
459
+
460
+ this._split( index );
461
+
462
+ var chunk = this.byEnd[ index ];
463
+
464
+ if ( chunk ) {
465
+ chunk.appendLeft( content );
466
+ } else {
467
+ this.intro += content;
468
+ }
469
+
470
+ return this;
471
+ },
472
+
473
+ appendRight: function appendRight ( index, content ) {
474
+ if ( typeof content !== 'string' ) { throw new TypeError( 'inserted content must be a string' ); }
475
+
476
+ this._split( index );
477
+
478
+ var chunk = this.byStart[ index ];
479
+
480
+ if ( chunk ) {
481
+ chunk.appendRight( content );
482
+ } else {
483
+ this.outro += content;
484
+ }
485
+
486
+ return this;
487
+ },
488
+
489
+ clone: function clone () {
490
+ var cloned = new MagicString$1( this.original, { filename: this.filename });
491
+
492
+ var originalChunk = this.firstChunk;
493
+ var clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
494
+
495
+ while ( originalChunk ) {
496
+ cloned.byStart[ clonedChunk.start ] = clonedChunk;
497
+ cloned.byEnd[ clonedChunk.end ] = clonedChunk;
498
+
499
+ var nextOriginalChunk = originalChunk.next;
500
+ var nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
501
+
502
+ if ( nextClonedChunk ) {
503
+ clonedChunk.next = nextClonedChunk;
504
+ nextClonedChunk.previous = clonedChunk;
505
+
506
+ clonedChunk = nextClonedChunk;
507
+ }
508
+
509
+ originalChunk = nextOriginalChunk;
510
+ }
511
+
512
+ cloned.lastChunk = clonedChunk;
513
+
514
+ if ( this.indentExclusionRanges ) {
515
+ cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
516
+ }
517
+
518
+ Object.keys( this.sourcemapLocations ).forEach( function (loc) {
519
+ cloned.sourcemapLocations[ loc ] = true;
520
+ });
521
+
522
+ return cloned;
523
+ },
524
+
525
+ generateMap: function generateMap ( options ) {
526
+ var this$1 = this;
527
+
528
+ options = options || {};
529
+
530
+ var sourceIndex = 0;
531
+ var names = Object.keys( this.storedNames );
532
+ var mappings = new Mappings( options.hires );
533
+
534
+ var locate = getLocator( this.original );
535
+
536
+ if ( this.intro ) {
537
+ mappings.advance( this.intro );
538
+ }
539
+
540
+ this.firstChunk.eachNext( function (chunk) {
541
+ var loc = locate( chunk.start );
542
+
543
+ if ( chunk.intro.length ) { mappings.advance( chunk.intro ); }
544
+
545
+ if ( chunk.edited ) {
546
+ mappings.addEdit( sourceIndex, chunk.content, chunk.original, loc, chunk.storeName ? names.indexOf( chunk.original ) : -1 );
547
+ } else {
548
+ mappings.addUneditedChunk( sourceIndex, chunk, this$1.original, loc, this$1.sourcemapLocations );
549
+ }
550
+
551
+ if ( chunk.outro.length ) { mappings.advance( chunk.outro ); }
552
+ });
553
+
554
+ var map = new SourceMap({
555
+ file: ( options.file ? options.file.split( /[\/\\]/ ).pop() : null ),
556
+ sources: [ options.source ? getRelativePath( options.file || '', options.source ) : null ],
557
+ sourcesContent: options.includeContent ? [ this.original ] : [ null ],
558
+ names: names,
559
+ mappings: mappings.encode()
560
+ });
561
+ return map;
562
+ },
563
+
564
+ getIndentString: function getIndentString () {
565
+ return this.indentStr === null ? '\t' : this.indentStr;
566
+ },
567
+
568
+ indent: function indent ( indentStr, options ) {
569
+ var this$1 = this;
570
+
571
+ var pattern = /^[^\r\n]/gm;
572
+
573
+ if ( isObject( indentStr ) ) {
574
+ options = indentStr;
575
+ indentStr = undefined;
576
+ }
577
+
578
+ indentStr = indentStr !== undefined ? indentStr : ( this.indentStr || '\t' );
579
+
580
+ if ( indentStr === '' ) { return this; } // noop
581
+
582
+ options = options || {};
583
+
584
+ // Process exclusion ranges
585
+ var isExcluded = {};
586
+
587
+ if ( options.exclude ) {
588
+ var exclusions = typeof options.exclude[0] === 'number' ? [ options.exclude ] : options.exclude;
589
+ exclusions.forEach( function (exclusion) {
590
+ for ( var i = exclusion[0]; i < exclusion[1]; i += 1 ) {
591
+ isExcluded[i] = true;
592
+ }
593
+ });
594
+ }
595
+
596
+ var shouldIndentNextCharacter = options.indentStart !== false;
597
+ var replacer = function (match) {
598
+ if ( shouldIndentNextCharacter ) { return ("" + indentStr + match); }
599
+ shouldIndentNextCharacter = true;
600
+ return match;
601
+ };
602
+
603
+ this.intro = this.intro.replace( pattern, replacer );
604
+
605
+ var charIndex = 0;
606
+
607
+ var chunk = this.firstChunk;
608
+
609
+ while ( chunk ) {
610
+ var end = chunk.end;
611
+
612
+ if ( chunk.edited ) {
613
+ if ( !isExcluded[ charIndex ] ) {
614
+ chunk.content = chunk.content.replace( pattern, replacer );
615
+
616
+ if ( chunk.content.length ) {
617
+ shouldIndentNextCharacter = chunk.content[ chunk.content.length - 1 ] === '\n';
618
+ }
619
+ }
620
+ } else {
621
+ charIndex = chunk.start;
622
+
623
+ while ( charIndex < end ) {
624
+ if ( !isExcluded[ charIndex ] ) {
625
+ var char = this$1.original[ charIndex ];
626
+
627
+ if ( char === '\n' ) {
628
+ shouldIndentNextCharacter = true;
629
+ } else if ( char !== '\r' && shouldIndentNextCharacter ) {
630
+ shouldIndentNextCharacter = false;
631
+
632
+ if ( charIndex === chunk.start ) {
633
+ chunk.prependRight( indentStr );
634
+ } else {
635
+ this$1._splitChunk( chunk, charIndex );
636
+ chunk = chunk.next;
637
+ chunk.prependRight( indentStr );
638
+ }
639
+ }
640
+ }
641
+
642
+ charIndex += 1;
643
+ }
644
+ }
645
+
646
+ charIndex = chunk.end;
647
+ chunk = chunk.next;
648
+ }
649
+
650
+ this.outro = this.outro.replace( pattern, replacer );
651
+
652
+ return this;
653
+ },
654
+
655
+ insert: function insert () {
656
+ throw new Error( 'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)' );
657
+ },
658
+
659
+ insertLeft: function insertLeft ( index, content ) {
660
+ if ( !warned.insertLeft ) {
661
+ console.warn( 'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead' ); // eslint-disable-line no-console
662
+ warned.insertLeft = true;
663
+ }
664
+
665
+ return this.appendLeft( index, content );
666
+ },
667
+
668
+ insertRight: function insertRight ( index, content ) {
669
+ if ( !warned.insertRight ) {
670
+ console.warn( 'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead' ); // eslint-disable-line no-console
671
+ warned.insertRight = true;
672
+ }
673
+
674
+ return this.prependRight( index, content );
675
+ },
676
+
677
+ move: function move ( start, end, index ) {
678
+ if ( index >= start && index <= end ) { throw new Error( 'Cannot move a selection inside itself' ); }
679
+
680
+ this._split( start );
681
+ this._split( end );
682
+ this._split( index );
683
+
684
+ var first = this.byStart[ start ];
685
+ var last = this.byEnd[ end ];
686
+
687
+ var oldLeft = first.previous;
688
+ var oldRight = last.next;
689
+
690
+ var newRight = this.byStart[ index ];
691
+ if ( !newRight && last === this.lastChunk ) { return this; }
692
+ var newLeft = newRight ? newRight.previous : this.lastChunk;
693
+
694
+ if ( oldLeft ) { oldLeft.next = oldRight; }
695
+ if ( oldRight ) { oldRight.previous = oldLeft; }
696
+
697
+ if ( newLeft ) { newLeft.next = first; }
698
+ if ( newRight ) { newRight.previous = last; }
699
+
700
+ if ( !first.previous ) { this.firstChunk = last.next; }
701
+ if ( !last.next ) {
702
+ this.lastChunk = first.previous;
703
+ this.lastChunk.next = null;
704
+ }
705
+
706
+ first.previous = newLeft;
707
+ last.next = newRight || null;
708
+
709
+ if ( !newLeft ) { this.firstChunk = first; }
710
+ if ( !newRight ) { this.lastChunk = last; }
711
+
712
+ return this;
713
+ },
714
+
715
+ overwrite: function overwrite ( start, end, content, options ) {
716
+ var this$1 = this;
717
+
718
+ if ( typeof content !== 'string' ) { throw new TypeError( 'replacement content must be a string' ); }
719
+
720
+ while ( start < 0 ) { start += this$1.original.length; }
721
+ while ( end < 0 ) { end += this$1.original.length; }
722
+
723
+ if ( end > this.original.length ) { throw new Error( 'end is out of bounds' ); }
724
+ if ( start === end ) { throw new Error( 'Cannot overwrite a zero-length range – use appendLeft or prependRight instead' ); }
725
+
726
+ this._split( start );
727
+ this._split( end );
728
+
729
+ if ( options === true ) {
730
+ if ( !warned.storeName ) {
731
+ console.warn( 'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string' ); // eslint-disable-line no-console
732
+ warned.storeName = true;
733
+ }
734
+
735
+ options = { storeName: true };
736
+ }
737
+ var storeName = options !== undefined ? options.storeName : false;
738
+ var contentOnly = options !== undefined ? options.contentOnly : false;
739
+
740
+ if ( storeName ) {
741
+ var original = this.original.slice( start, end );
742
+ this.storedNames[ original ] = true;
743
+ }
744
+
745
+ var first = this.byStart[ start ];
746
+ var last = this.byEnd[ end ];
747
+
748
+ if ( first ) {
749
+ if ( end > first.end && first.next !== this.byStart[ first.end ] ) {
750
+ throw new Error( 'Cannot overwrite across a split point' );
751
+ }
752
+
753
+ first.edit( content, storeName, contentOnly );
754
+
755
+ if ( first !== last ) {
756
+ var chunk = first.next;
757
+ while ( chunk !== last ) {
758
+ chunk.edit( '', false );
759
+ chunk = chunk.next;
760
+ }
761
+
762
+ chunk.edit( '', false );
763
+ }
764
+ }
765
+
766
+ else {
767
+ // must be inserting at the end
768
+ var newChunk = new Chunk( start, end, '' ).edit( content, storeName );
769
+
770
+ // TODO last chunk in the array may not be the last chunk, if it's moved...
771
+ last.next = newChunk;
772
+ newChunk.previous = last;
773
+ }
774
+
775
+ return this;
776
+ },
777
+
778
+ prepend: function prepend ( content ) {
779
+ if ( typeof content !== 'string' ) { throw new TypeError( 'outro content must be a string' ); }
780
+
781
+ this.intro = content + this.intro;
782
+ return this;
783
+ },
784
+
785
+ prependLeft: function prependLeft ( index, content ) {
786
+ if ( typeof content !== 'string' ) { throw new TypeError( 'inserted content must be a string' ); }
787
+
788
+ this._split( index );
789
+
790
+ var chunk = this.byEnd[ index ];
791
+
792
+ if ( chunk ) {
793
+ chunk.prependLeft( content );
794
+ } else {
795
+ this.intro = content + this.intro;
796
+ }
797
+
798
+ return this;
799
+ },
800
+
801
+ prependRight: function prependRight ( index, content ) {
802
+ if ( typeof content !== 'string' ) { throw new TypeError( 'inserted content must be a string' ); }
803
+
804
+ this._split( index );
805
+
806
+ var chunk = this.byStart[ index ];
807
+
808
+ if ( chunk ) {
809
+ chunk.prependRight( content );
810
+ } else {
811
+ this.outro = content + this.outro;
812
+ }
813
+
814
+ return this;
815
+ },
816
+
817
+ remove: function remove ( start, end ) {
818
+ var this$1 = this;
819
+
820
+ while ( start < 0 ) { start += this$1.original.length; }
821
+ while ( end < 0 ) { end += this$1.original.length; }
822
+
823
+ if ( start === end ) { return this; }
824
+
825
+ if ( start < 0 || end > this.original.length ) { throw new Error( 'Character is out of bounds' ); }
826
+ if ( start > end ) { throw new Error( 'end must be greater than start' ); }
827
+
828
+ this._split( start );
829
+ this._split( end );
830
+
831
+ var chunk = this.byStart[ start ];
832
+
833
+ while ( chunk ) {
834
+ chunk.intro = '';
835
+ chunk.outro = '';
836
+ chunk.edit( '' );
837
+
838
+ chunk = end > chunk.end ? this$1.byStart[ chunk.end ] : null;
839
+ }
840
+
841
+ return this;
842
+ },
843
+
844
+ slice: function slice ( start, end ) {
845
+ var this$1 = this;
846
+ if ( start === void 0 ) start = 0;
847
+ if ( end === void 0 ) end = this.original.length;
848
+
849
+ while ( start < 0 ) { start += this$1.original.length; }
850
+ while ( end < 0 ) { end += this$1.original.length; }
851
+
852
+ var result = '';
853
+
854
+ // find start chunk
855
+ var chunk = this.firstChunk;
856
+ while ( chunk && ( chunk.start > start || chunk.end <= start ) ) {
857
+
858
+ // found end chunk before start
859
+ if ( chunk.start < end && chunk.end >= end ) {
860
+ return result;
861
+ }
862
+
863
+ chunk = chunk.next;
864
+ }
865
+
866
+ if ( chunk && chunk.edited && chunk.start !== start ) { throw new Error(("Cannot use replaced character " + start + " as slice start anchor.")); }
867
+
868
+ var startChunk = chunk;
869
+ while ( chunk ) {
870
+ if ( chunk.intro && ( startChunk !== chunk || chunk.start === start ) ) {
871
+ result += chunk.intro;
872
+ }
873
+
874
+ var containsEnd = chunk.start < end && chunk.end >= end;
875
+ if ( containsEnd && chunk.edited && chunk.end !== end ) { throw new Error(("Cannot use replaced character " + end + " as slice end anchor.")); }
876
+
877
+ var sliceStart = startChunk === chunk ? start - chunk.start : 0;
878
+ var sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
879
+
880
+ result += chunk.content.slice( sliceStart, sliceEnd );
881
+
882
+ if ( chunk.outro && ( !containsEnd || chunk.end === end ) ) {
883
+ result += chunk.outro;
884
+ }
885
+
886
+ if ( containsEnd ) {
887
+ break;
888
+ }
889
+
890
+ chunk = chunk.next;
891
+ }
892
+
893
+ return result;
894
+ },
895
+
896
+ // TODO deprecate this? not really very useful
897
+ snip: function snip ( start, end ) {
898
+ var clone = this.clone();
899
+ clone.remove( 0, start );
900
+ clone.remove( end, clone.original.length );
901
+
902
+ return clone;
903
+ },
904
+
905
+ _split: function _split ( index ) {
906
+ var this$1 = this;
907
+
908
+ if ( this.byStart[ index ] || this.byEnd[ index ] ) { return; }
909
+
910
+ var chunk = this.lastSearchedChunk;
911
+ var searchForward = index > chunk.end;
912
+
913
+ while ( true ) {
914
+ if ( chunk.contains( index ) ) { return this$1._splitChunk( chunk, index ); }
915
+
916
+ chunk = searchForward ?
917
+ this$1.byStart[ chunk.end ] :
918
+ this$1.byEnd[ chunk.start ];
919
+ }
920
+ },
921
+
922
+ _splitChunk: function _splitChunk ( chunk, index ) {
923
+ if ( chunk.edited && chunk.content.length ) { // zero-length edited chunks are a special case (overlapping replacements)
924
+ var loc = getLocator( this.original )( index );
925
+ throw new Error( ("Cannot split a chunk that has already been edited (" + (loc.line) + ":" + (loc.column) + " – \"" + (chunk.original) + "\")") );
926
+ }
927
+
928
+ var newChunk = chunk.split( index );
929
+
930
+ this.byEnd[ index ] = chunk;
931
+ this.byStart[ index ] = newChunk;
932
+ this.byEnd[ newChunk.end ] = newChunk;
933
+
934
+ if ( chunk === this.lastChunk ) { this.lastChunk = newChunk; }
935
+
936
+ this.lastSearchedChunk = chunk;
937
+ return true;
938
+ },
939
+
940
+ toString: function toString () {
941
+ var str = this.intro;
942
+
943
+ var chunk = this.firstChunk;
944
+ while ( chunk ) {
945
+ str += chunk.toString();
946
+ chunk = chunk.next;
947
+ }
948
+
949
+ return str + this.outro;
950
+ },
951
+
952
+ trimLines: function trimLines () {
953
+ return this.trim('[\\r\\n]');
954
+ },
955
+
956
+ trim: function trim ( charType ) {
957
+ return this.trimStart( charType ).trimEnd( charType );
958
+ },
959
+
960
+ trimEnd: function trimEnd ( charType ) {
961
+ var this$1 = this;
962
+
963
+ var rx = new RegExp( ( charType || '\\s' ) + '+$' );
964
+
965
+ this.outro = this.outro.replace( rx, '' );
966
+ if ( this.outro.length ) { return this; }
967
+
968
+ var chunk = this.lastChunk;
969
+
970
+ do {
971
+ var end = chunk.end;
972
+ var aborted = chunk.trimEnd( rx );
973
+
974
+ // if chunk was trimmed, we have a new lastChunk
975
+ if ( chunk.end !== end ) {
976
+ if ( this$1.lastChunk === chunk ) {
977
+ this$1.lastChunk = chunk.next;
978
+ }
979
+
980
+ this$1.byEnd[ chunk.end ] = chunk;
981
+ this$1.byStart[ chunk.next.start ] = chunk.next;
982
+ this$1.byEnd[ chunk.next.end ] = chunk.next;
983
+ }
984
+
985
+ if ( aborted ) { return this$1; }
986
+ chunk = chunk.previous;
987
+ } while ( chunk );
988
+
989
+ return this;
990
+ },
991
+
992
+ trimStart: function trimStart ( charType ) {
993
+ var this$1 = this;
994
+
995
+ var rx = new RegExp( '^' + ( charType || '\\s' ) + '+' );
996
+
997
+ this.intro = this.intro.replace( rx, '' );
998
+ if ( this.intro.length ) { return this; }
999
+
1000
+ var chunk = this.firstChunk;
1001
+
1002
+ do {
1003
+ var end = chunk.end;
1004
+ var aborted = chunk.trimStart( rx );
1005
+
1006
+ if ( chunk.end !== end ) {
1007
+ // special case...
1008
+ if ( chunk === this$1.lastChunk ) { this$1.lastChunk = chunk.next; }
1009
+
1010
+ this$1.byEnd[ chunk.end ] = chunk;
1011
+ this$1.byStart[ chunk.next.start ] = chunk.next;
1012
+ this$1.byEnd[ chunk.next.end ] = chunk.next;
1013
+ }
1014
+
1015
+ if ( aborted ) { return this$1; }
1016
+ chunk = chunk.next;
1017
+ } while ( chunk );
1018
+
1019
+ return this;
1020
+ }
1021
+ };
1022
+
1023
+ var hasOwnProp = Object.prototype.hasOwnProperty;
1024
+
1025
+ function Bundle ( options ) {
1026
+ if ( options === void 0 ) options = {};
1027
+
1028
+ this.intro = options.intro || '';
1029
+ this.separator = options.separator !== undefined ? options.separator : '\n';
1030
+
1031
+ this.sources = [];
1032
+
1033
+ this.uniqueSources = [];
1034
+ this.uniqueSourceIndexByFilename = {};
1035
+ }
1036
+
1037
+ Bundle.prototype = {
1038
+ addSource: function addSource ( source ) {
1039
+ if ( source instanceof MagicString$1 ) {
1040
+ return this.addSource({
1041
+ content: source,
1042
+ filename: source.filename,
1043
+ separator: this.separator
1044
+ });
1045
+ }
1046
+
1047
+ if ( !isObject( source ) || !source.content ) {
1048
+ throw new Error( 'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`' );
1049
+ }
1050
+
1051
+ [ 'filename', 'indentExclusionRanges', 'separator' ].forEach( function (option) {
1052
+ if ( !hasOwnProp.call( source, option ) ) { source[ option ] = source.content[ option ]; }
1053
+ });
1054
+
1055
+ if ( source.separator === undefined ) { // TODO there's a bunch of this sort of thing, needs cleaning up
1056
+ source.separator = this.separator;
1057
+ }
1058
+
1059
+ if ( source.filename ) {
1060
+ if ( !hasOwnProp.call( this.uniqueSourceIndexByFilename, source.filename ) ) {
1061
+ this.uniqueSourceIndexByFilename[ source.filename ] = this.uniqueSources.length;
1062
+ this.uniqueSources.push({ filename: source.filename, content: source.content.original });
1063
+ } else {
1064
+ var uniqueSource = this.uniqueSources[ this.uniqueSourceIndexByFilename[ source.filename ] ];
1065
+ if ( source.content.original !== uniqueSource.content ) {
1066
+ throw new Error( ("Illegal source: same filename (" + (source.filename) + "), different contents") );
1067
+ }
1068
+ }
1069
+ }
1070
+
1071
+ this.sources.push( source );
1072
+ return this;
1073
+ },
1074
+
1075
+ append: function append ( str, options ) {
1076
+ this.addSource({
1077
+ content: new MagicString$1( str ),
1078
+ separator: ( options && options.separator ) || ''
1079
+ });
1080
+
1081
+ return this;
1082
+ },
1083
+
1084
+ clone: function clone () {
1085
+ var bundle = new Bundle({
1086
+ intro: this.intro,
1087
+ separator: this.separator
1088
+ });
1089
+
1090
+ this.sources.forEach( function (source) {
1091
+ bundle.addSource({
1092
+ filename: source.filename,
1093
+ content: source.content.clone(),
1094
+ separator: source.separator
1095
+ });
1096
+ });
1097
+
1098
+ return bundle;
1099
+ },
1100
+
1101
+ generateMap: function generateMap ( options ) {
1102
+ var this$1 = this;
1103
+ if ( options === void 0 ) options = {};
1104
+
1105
+ var names = [];
1106
+ this.sources.forEach( function (source) {
1107
+ Object.keys( source.content.storedNames ).forEach( function (name) {
1108
+ if ( !~names.indexOf( name ) ) { names.push( name ); }
1109
+ });
1110
+ });
1111
+
1112
+ var mappings = new Mappings( options.hires );
1113
+
1114
+ if ( this.intro ) {
1115
+ mappings.advance( this.intro );
1116
+ }
1117
+
1118
+ this.sources.forEach( function ( source, i ) {
1119
+ if ( i > 0 ) {
1120
+ mappings.advance( this$1.separator );
1121
+ }
1122
+
1123
+ var sourceIndex = source.filename ? this$1.uniqueSourceIndexByFilename[ source.filename ] : -1;
1124
+ var magicString = source.content;
1125
+ var locate = getLocator( magicString.original );
1126
+
1127
+ if ( magicString.intro ) {
1128
+ mappings.advance( magicString.intro );
1129
+ }
1130
+
1131
+ magicString.firstChunk.eachNext( function (chunk) {
1132
+ var loc = locate( chunk.start );
1133
+
1134
+ if ( chunk.intro.length ) { mappings.advance( chunk.intro ); }
1135
+
1136
+ if ( source.filename ) {
1137
+ if ( chunk.edited ) {
1138
+ mappings.addEdit( sourceIndex, chunk.content, chunk.original, loc, chunk.storeName ? names.indexOf( chunk.original ) : -1 );
1139
+ } else {
1140
+ mappings.addUneditedChunk( sourceIndex, chunk, magicString.original, loc, magicString.sourcemapLocations );
1141
+ }
1142
+ }
1143
+
1144
+ else {
1145
+ mappings.advance( chunk.content );
1146
+ }
1147
+
1148
+ if ( chunk.outro.length ) { mappings.advance( chunk.outro ); }
1149
+ });
1150
+
1151
+ if ( magicString.outro ) {
1152
+ mappings.advance( magicString.outro );
1153
+ }
1154
+ });
1155
+
1156
+ return new SourceMap({
1157
+ file: ( options.file ? options.file.split( /[\/\\]/ ).pop() : null ),
1158
+ sources: this.uniqueSources.map( function (source) {
1159
+ return options.file ? getRelativePath( options.file, source.filename ) : source.filename;
1160
+ }),
1161
+ sourcesContent: this.uniqueSources.map( function (source) {
1162
+ return options.includeContent ? source.content : null;
1163
+ }),
1164
+ names: names,
1165
+ mappings: mappings.encode()
1166
+ });
1167
+ },
1168
+
1169
+ getIndentString: function getIndentString () {
1170
+ var indentStringCounts = {};
1171
+
1172
+ this.sources.forEach( function (source) {
1173
+ var indentStr = source.content.indentStr;
1174
+
1175
+ if ( indentStr === null ) { return; }
1176
+
1177
+ if ( !indentStringCounts[ indentStr ] ) { indentStringCounts[ indentStr ] = 0; }
1178
+ indentStringCounts[ indentStr ] += 1;
1179
+ });
1180
+
1181
+ return ( Object.keys( indentStringCounts ).sort( function ( a, b ) {
1182
+ return indentStringCounts[a] - indentStringCounts[b];
1183
+ })[0] ) || '\t';
1184
+ },
1185
+
1186
+ indent: function indent ( indentStr ) {
1187
+ var this$1 = this;
1188
+
1189
+ if ( !arguments.length ) {
1190
+ indentStr = this.getIndentString();
1191
+ }
1192
+
1193
+ if ( indentStr === '' ) { return this; } // noop
1194
+
1195
+ var trailingNewline = !this.intro || this.intro.slice( -1 ) === '\n';
1196
+
1197
+ this.sources.forEach( function ( source, i ) {
1198
+ var separator = source.separator !== undefined ? source.separator : this$1.separator;
1199
+ var indentStart = trailingNewline || ( i > 0 && /\r?\n$/.test( separator ) );
1200
+
1201
+ source.content.indent( indentStr, {
1202
+ exclude: source.indentExclusionRanges,
1203
+ indentStart: indentStart//: trailingNewline || /\r?\n$/.test( separator ) //true///\r?\n/.test( separator )
1204
+ });
1205
+
1206
+ // TODO this is a very slow way to determine this
1207
+ trailingNewline = source.content.toString().slice( 0, -1 ) === '\n';
1208
+ });
1209
+
1210
+ if ( this.intro ) {
1211
+ this.intro = indentStr + this.intro.replace( /^[^\n]/gm, function ( match, index ) {
1212
+ return index > 0 ? indentStr + match : match;
1213
+ });
1214
+ }
1215
+
1216
+ return this;
1217
+ },
1218
+
1219
+ prepend: function prepend ( str ) {
1220
+ this.intro = str + this.intro;
1221
+ return this;
1222
+ },
1223
+
1224
+ toString: function toString () {
1225
+ var this$1 = this;
1226
+
1227
+ var body = this.sources.map( function ( source, i ) {
1228
+ var separator = source.separator !== undefined ? source.separator : this$1.separator;
1229
+ var str = ( i > 0 ? separator : '' ) + source.content.toString();
1230
+
1231
+ return str;
1232
+ }).join( '' );
1233
+
1234
+ return this.intro + body;
1235
+ },
1236
+
1237
+ trimLines: function trimLines () {
1238
+ return this.trim('[\\r\\n]');
1239
+ },
1240
+
1241
+ trim: function trim ( charType ) {
1242
+ return this.trimStart( charType ).trimEnd( charType );
1243
+ },
1244
+
1245
+ trimStart: function trimStart ( charType ) {
1246
+ var this$1 = this;
1247
+
1248
+ var rx = new RegExp( '^' + ( charType || '\\s' ) + '+' );
1249
+ this.intro = this.intro.replace( rx, '' );
1250
+
1251
+ if ( !this.intro ) {
1252
+ var source;
1253
+ var i = 0;
1254
+
1255
+ do {
1256
+ source = this$1.sources[i];
1257
+
1258
+ if ( !source ) {
1259
+ break;
1260
+ }
1261
+
1262
+ source.content.trimStart( charType );
1263
+ i += 1;
1264
+ } while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?
1265
+ }
1266
+
1267
+ return this;
1268
+ },
1269
+
1270
+ trimEnd: function trimEnd ( charType ) {
1271
+ var this$1 = this;
1272
+
1273
+ var rx = new RegExp( ( charType || '\\s' ) + '+$' );
1274
+
1275
+ var source;
1276
+ var i = this.sources.length - 1;
1277
+
1278
+ do {
1279
+ source = this$1.sources[i];
1280
+
1281
+ if ( !source ) {
1282
+ this$1.intro = this$1.intro.replace( rx, '' );
1283
+ break;
1284
+ }
1285
+
1286
+ source.content.trimEnd( charType );
1287
+ i -= 1;
1288
+ } while ( source.content.toString() === '' ); // TODO faster way to determine non-empty source?
1289
+
1290
+ return this;
1291
+ }
1292
+ };
1293
+
1294
+ export { Bundle };
1295
+ export default MagicString$1;
1296
+ //# sourceMappingURL=magic-string.es.js.map