@teyik0/furin 0.5.0-alpha.1 → 0.6.0-alpha.1
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/adapter/runtime-build.d.ts +2 -0
- package/dist/build/entry-template.d.ts +2 -0
- package/dist/build/entry-template.ts +5 -1
- package/dist/build/index.js +8387 -6737
- package/dist/build/private-server-sourcemaps.d.ts +2 -0
- package/dist/build/request-keys.d.ts +4 -0
- package/dist/build/types.d.ts +2 -0
- package/dist/cli/index.js +8399 -6748
- package/dist/client/browser-events-runtime.d.ts +2 -1
- package/dist/client/define-route.d.ts +0 -1
- package/dist/client/dev-error-overlay.ts +1 -0
- package/dist/client/document.d.ts +3 -0
- package/dist/client/hmr.d.ts +1 -1
- package/dist/client/link.js +111 -60
- package/dist/client.js +23 -7
- package/dist/config.d.ts +7 -2
- package/dist/config.js +24 -1
- package/dist/define-route.d.ts +163 -101
- package/dist/furin.d.ts +3 -0
- package/dist/furin.js +7798 -6480
- package/dist/plugin/index.js +462 -127
- package/dist/plugin/transform-dev-page.d.ts +7 -0
- package/dist/rsc-client.js +9 -1
- package/dist/rsc.js +19 -7
- package/dist/server/auto-invalidate/registry.d.ts +4 -2
- package/dist/server/browser-events/plugin.d.ts +3 -0
- package/dist/server/browser-events/shutdown.d.ts +3 -0
- package/dist/server/cache/redis/index.d.ts +2 -0
- package/dist/server/cache/redis/index.js +67 -12
- package/dist/server/cache/redis/scripts.d.ts +5 -5
- package/dist/server/dev/plugin.d.ts +1 -0
- package/dist/server/dev/runtime.production.d.ts +1 -0
- package/dist/server/dev-page-plugin.d.ts +1 -0
- package/dist/server/evlog.d.ts +1 -1
- package/dist/server/internal.d.ts +2 -0
- package/dist/server/internal.js +70 -40
- package/dist/server/production-server.d.ts +13 -0
- package/dist/server/production-server.js +2934 -0
- package/dist/server/render/assemble.d.ts +6 -6
- package/dist/server/render/document.d.ts +1 -1
- package/dist/server/render/element.d.ts +1 -1
- package/dist/server/render/loaders.d.ts +11 -3
- package/dist/server/render/mixed-cache.d.ts +6 -0
- package/dist/server/render/ssr.d.ts +3 -3
- package/dist/server/router/discovery.d.ts +1 -0
- package/dist/server/router/hmr.d.ts +6 -0
- package/dist/server/router/hmr.production.d.ts +5 -0
- package/dist/server/router/patterns.d.ts +3 -0
- package/dist/server/router/plugin.d.ts +8 -1
- package/dist/server/router/types.d.ts +4 -0
- package/dist/server/security/csp.d.ts +12 -0
- package/dist/server/sync/index.js +70 -39
- package/dist/server/sync/postgres/index.js +8 -0
- package/dist/server/sync/stream.d.ts +4 -0
- package/dist/shared/production-build.d.ts +2 -0
- package/package.json +18 -12
- package/src/adapter/README.md +3 -0
- package/src/adapter/bun.ts +77 -15
- package/src/adapter/package.ts +4 -0
- package/src/adapter/runtime-build.ts +36 -2
- package/src/adapter/static.ts +10 -4
- package/src/adapter/vercel.ts +33 -11
- package/src/build/elysia-aot.ts +1 -1
- package/src/build/entry-template.ts +5 -1
- package/src/build/hydrate.ts +6 -1
- package/src/build/index.ts +5 -0
- package/src/build/private-server-sourcemaps.ts +20 -0
- package/src/build/request-keys.ts +93 -0
- package/src/build/server-app-entry.ts +3 -2
- package/src/build/ssg-cache.ts +9 -4
- package/src/build/types.ts +2 -0
- package/src/cli/index.ts +1 -0
- package/src/client/boundaries.tsx +1 -1
- package/src/client/browser-events-runtime.ts +69 -16
- package/src/client/define-route.ts +0 -1
- package/src/client/dev-error-overlay.ts +1 -0
- package/src/client/document.tsx +38 -2
- package/src/client/hmr.ts +3 -2
- package/src/client/router/boundary-tree.tsx +3 -4
- package/src/client/router/provider.tsx +109 -61
- package/src/config.ts +30 -2
- package/src/define-route.ts +356 -127
- package/src/furin.ts +165 -27
- package/src/plugin/route-config-autofix.ts +2 -2
- package/src/plugin/routes.ts +16 -5
- package/src/plugin/transform-dev-page.ts +231 -0
- package/src/rsc/codec.ts +11 -6
- package/src/rsc/render-error.ts +3 -1
- package/src/rsc/version.ts +5 -0
- package/src/server/auto-invalidate/registry.ts +53 -25
- package/src/server/browser-events/plugin.ts +119 -1
- package/src/server/browser-events/shutdown.ts +32 -0
- package/src/server/cache/dev-loader.ts +1 -1
- package/src/server/cache/invalidation.ts +2 -0
- package/src/server/cache/isr-ssg.ts +1 -1
- package/src/server/cache/redis/index.ts +19 -2
- package/src/server/cache/redis/scripts.ts +47 -7
- package/src/server/cache/ssg.ts +1 -1
- package/src/server/dev/diagnostics.ts +4 -2
- package/src/server/dev/error.ts +2 -1
- package/src/server/dev/graph.ts +55 -6
- package/src/server/dev/plugin.ts +10 -1
- package/src/server/dev/runtime.production.ts +4 -0
- package/src/server/dev/symbolicate.ts +2 -0
- package/src/server/dev-page-plugin.ts +67 -4
- package/src/server/evlog.ts +12 -5
- package/src/server/internal.ts +2 -0
- package/src/server/production-server.ts +135 -0
- package/src/server/render/assemble.ts +15 -11
- package/src/server/render/document.tsx +10 -2
- package/src/server/render/element.tsx +5 -5
- package/src/server/render/isr.ts +11 -5
- package/src/server/render/loaders.ts +243 -56
- package/src/server/render/mixed-cache.ts +298 -0
- package/src/server/render/not-found.ts +10 -4
- package/src/server/render/ppr-document.ts +45 -10
- package/src/server/render/ppr-route.ts +26 -12
- package/src/server/render/ssg.ts +2 -1
- package/src/server/render/ssr.ts +57 -32
- package/src/server/render/static-params.ts +1 -1
- package/src/server/render/template.ts +5 -1
- package/src/server/router/discovery.ts +17 -1
- package/src/server/router/hmr.production.ts +11 -0
- package/src/server/router/hmr.ts +185 -88
- package/src/server/router/patterns.ts +27 -0
- package/src/server/router/plugin.ts +145 -26
- package/src/server/router/schema-merge.ts +9 -2
- package/src/server/router/source-version.ts +20 -2
- package/src/server/router/types.ts +4 -0
- package/src/server/security/csp.ts +44 -0
- package/src/server/sync/postgres/index.ts +8 -0
- package/src/server/sync/stream.ts +43 -2
- package/src/shared/production-build.ts +20 -0
package/dist/plugin/index.js
CHANGED
|
@@ -35,7 +35,7 @@ function unwrapTSExpression(node) {
|
|
|
35
35
|
return current;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// ../../node_modules/.bun/@jridgewell+sourcemap-codec@1.
|
|
38
|
+
// ../../node_modules/.bun/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
39
39
|
var comma = 44;
|
|
40
40
|
var semicolon = 59;
|
|
41
41
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -46,17 +46,17 @@ for (let i = 0;i < chars.length; i++) {
|
|
|
46
46
|
intToChar[i] = c;
|
|
47
47
|
charToInt[c] = i;
|
|
48
48
|
}
|
|
49
|
-
function encodeInteger(builder, num
|
|
50
|
-
let delta = num - relative;
|
|
51
|
-
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
49
|
+
function encodeInteger(builder, num) {
|
|
52
50
|
do {
|
|
53
|
-
let clamped =
|
|
54
|
-
|
|
55
|
-
if (
|
|
51
|
+
let clamped = num & 31;
|
|
52
|
+
num >>>= 5;
|
|
53
|
+
if (num > 0)
|
|
56
54
|
clamped |= 32;
|
|
57
55
|
builder.write(intToChar[clamped]);
|
|
58
|
-
} while (
|
|
59
|
-
|
|
56
|
+
} while (num > 0);
|
|
57
|
+
}
|
|
58
|
+
function encodeSign(num) {
|
|
59
|
+
return num < 0 ? -num << 1 | 1 : num << 1;
|
|
60
60
|
}
|
|
61
61
|
var bufLength = 1024 * 16;
|
|
62
62
|
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder : typeof Buffer !== "undefined" ? {
|
|
@@ -92,6 +92,23 @@ var StringWriter = class {
|
|
|
92
92
|
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
|
+
function encodeRangeMappings(decoded) {
|
|
96
|
+
if (decoded.length === 0)
|
|
97
|
+
return "";
|
|
98
|
+
const writer = new StringWriter;
|
|
99
|
+
for (let i = 0;i < decoded.length; i++) {
|
|
100
|
+
const indices = decoded[i];
|
|
101
|
+
if (i > 0)
|
|
102
|
+
writer.write(semicolon);
|
|
103
|
+
let index = 0;
|
|
104
|
+
for (let j = 0;j < indices.length; j++) {
|
|
105
|
+
const offset = indices[j];
|
|
106
|
+
encodeInteger(writer, offset - index);
|
|
107
|
+
index = offset;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return writer.flush();
|
|
111
|
+
}
|
|
95
112
|
function encode(decoded) {
|
|
96
113
|
const writer = new StringWriter;
|
|
97
114
|
let sourcesIndex = 0;
|
|
@@ -109,21 +126,26 @@ function encode(decoded) {
|
|
|
109
126
|
const segment = line[j];
|
|
110
127
|
if (j > 0)
|
|
111
128
|
writer.write(comma);
|
|
112
|
-
|
|
129
|
+
encodeInteger(writer, encodeSign(segment[0] - genColumn));
|
|
130
|
+
genColumn = segment[0];
|
|
113
131
|
if (segment.length === 1)
|
|
114
132
|
continue;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
133
|
+
encodeInteger(writer, encodeSign(segment[1] - sourcesIndex));
|
|
134
|
+
encodeInteger(writer, encodeSign(segment[2] - sourceLine));
|
|
135
|
+
encodeInteger(writer, encodeSign(segment[3] - sourceColumn));
|
|
136
|
+
sourcesIndex = segment[1];
|
|
137
|
+
sourceLine = segment[2];
|
|
138
|
+
sourceColumn = segment[3];
|
|
118
139
|
if (segment.length === 4)
|
|
119
140
|
continue;
|
|
120
|
-
|
|
141
|
+
encodeInteger(writer, encodeSign(segment[4] - namesIndex));
|
|
142
|
+
namesIndex = segment[4];
|
|
121
143
|
}
|
|
122
144
|
}
|
|
123
145
|
return writer.flush();
|
|
124
146
|
}
|
|
125
147
|
|
|
126
|
-
// ../../node_modules/.bun/magic-string@1.2
|
|
148
|
+
// ../../node_modules/.bun/magic-string@1.4.2/node_modules/magic-string/dist/index.mjs
|
|
127
149
|
var BitSet = class BitSet {
|
|
128
150
|
constructor(arg) {
|
|
129
151
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
@@ -217,7 +239,7 @@ var Chunk = class Chunk {
|
|
|
217
239
|
this.outro = "";
|
|
218
240
|
this.end = index;
|
|
219
241
|
if (this.edited) {
|
|
220
|
-
newChunk.edit("", false);
|
|
242
|
+
newChunk.edit("", false, true);
|
|
221
243
|
this.content = "";
|
|
222
244
|
} else
|
|
223
245
|
this.content = originalBefore;
|
|
@@ -237,11 +259,12 @@ var Chunk = class Chunk {
|
|
|
237
259
|
return true;
|
|
238
260
|
const trimmed = this.content.replace(rx, "");
|
|
239
261
|
if (trimmed.length) {
|
|
240
|
-
if (trimmed !== this.content)
|
|
262
|
+
if (trimmed !== this.content) {
|
|
241
263
|
if (this.edited)
|
|
242
264
|
this.edit(trimmed, this.storeName, true);
|
|
243
265
|
else
|
|
244
266
|
this.split(this.start + trimmed.length).edit("", undefined, true);
|
|
267
|
+
}
|
|
245
268
|
return true;
|
|
246
269
|
} else {
|
|
247
270
|
this.edit("", undefined, true);
|
|
@@ -256,13 +279,14 @@ var Chunk = class Chunk {
|
|
|
256
279
|
return true;
|
|
257
280
|
const trimmed = this.content.replace(rx, "");
|
|
258
281
|
if (trimmed.length) {
|
|
259
|
-
if (trimmed !== this.content)
|
|
282
|
+
if (trimmed !== this.content) {
|
|
260
283
|
if (this.edited)
|
|
261
284
|
this.edit(trimmed, this.storeName, true);
|
|
262
285
|
else {
|
|
263
286
|
this.split(this.end - trimmed.length);
|
|
264
287
|
this.edit("", undefined, true);
|
|
265
288
|
}
|
|
289
|
+
}
|
|
266
290
|
return true;
|
|
267
291
|
} else {
|
|
268
292
|
this.edit("", undefined, true);
|
|
@@ -296,11 +320,21 @@ var SourceMap = class {
|
|
|
296
320
|
this.sources = properties.sources;
|
|
297
321
|
this.sourcesContent = properties.sourcesContent;
|
|
298
322
|
this.names = properties.names;
|
|
299
|
-
this.mappings = encode(properties.mappings);
|
|
323
|
+
this.mappings = typeof properties.mappings === "string" ? properties.mappings : encode(properties.mappings);
|
|
300
324
|
if (typeof properties.x_google_ignoreList !== "undefined")
|
|
301
325
|
this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
302
326
|
if (typeof properties.debugId !== "undefined")
|
|
303
327
|
this.debugId = properties.debugId;
|
|
328
|
+
if (typeof properties.rangeMappings !== "undefined") {
|
|
329
|
+
let shouldOutputRangeMapping = false;
|
|
330
|
+
for (const line of properties.rangeMappings)
|
|
331
|
+
if (line.length !== 0) {
|
|
332
|
+
shouldOutputRangeMapping = true;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
if (shouldOutputRangeMapping)
|
|
336
|
+
this.rangeMappings = encodeRangeMappings(properties.rangeMappings);
|
|
337
|
+
}
|
|
304
338
|
}
|
|
305
339
|
toString() {
|
|
306
340
|
return JSON.stringify(this);
|
|
@@ -310,13 +344,11 @@ var SourceMap = class {
|
|
|
310
344
|
}
|
|
311
345
|
};
|
|
312
346
|
function getLocator(source) {
|
|
313
|
-
const
|
|
314
|
-
`
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
lineOffsets.push(
|
|
318
|
-
pos += originalLines[i].length + 1;
|
|
319
|
-
}
|
|
347
|
+
const lineOffsets = [0];
|
|
348
|
+
for (let i = source.indexOf(`
|
|
349
|
+
`);i !== -1; i = source.indexOf(`
|
|
350
|
+
`, i + 1))
|
|
351
|
+
lineOffsets.push(i + 1);
|
|
320
352
|
return function locate(index) {
|
|
321
353
|
let i = 0;
|
|
322
354
|
let j = lineOffsets.length;
|
|
@@ -368,15 +400,127 @@ var toString = Object.prototype.toString;
|
|
|
368
400
|
function isObject(thing) {
|
|
369
401
|
return toString.call(thing) === "[object Object]";
|
|
370
402
|
}
|
|
371
|
-
var
|
|
403
|
+
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
404
|
+
var intToChar2 = /* @__PURE__ */ (() => {
|
|
405
|
+
const chars = /* @__PURE__ */ new Uint8Array(64);
|
|
406
|
+
for (let i = 0;i < 64; i++)
|
|
407
|
+
chars[i] = BASE64_CHARS.charCodeAt(i);
|
|
408
|
+
return chars;
|
|
409
|
+
})();
|
|
410
|
+
var COMMA = 44;
|
|
411
|
+
var SEMICOLON = 59;
|
|
412
|
+
var BUFFER_SIZE = 16384;
|
|
413
|
+
var FLUSH_THRESHOLD = 16348;
|
|
414
|
+
var scratch = /* @__PURE__ */ new Uint8Array(BUFFER_SIZE);
|
|
415
|
+
function writeVlq(pos, num) {
|
|
416
|
+
num = num < 0 ? -num << 1 | 1 : num << 1;
|
|
417
|
+
do {
|
|
418
|
+
let clamped = num & 31;
|
|
419
|
+
num >>>= 5;
|
|
420
|
+
if (num > 0)
|
|
421
|
+
clamped |= 32;
|
|
422
|
+
scratch[pos++] = intToChar2[clamped];
|
|
423
|
+
} while (num > 0);
|
|
424
|
+
return pos;
|
|
425
|
+
}
|
|
426
|
+
var decoder = /* @__PURE__ */ new TextDecoder;
|
|
427
|
+
var MappingsEncoder = class {
|
|
428
|
+
constructor() {
|
|
429
|
+
this.out = "";
|
|
430
|
+
this.pos = 0;
|
|
431
|
+
this.lines = [];
|
|
432
|
+
this.buffered = 0;
|
|
433
|
+
this.needsComma = false;
|
|
434
|
+
this.prevGenColumn = 0;
|
|
435
|
+
this.prevSourceIndex = 0;
|
|
436
|
+
this.prevSourceLine = 0;
|
|
437
|
+
this.prevSourceColumn = 0;
|
|
438
|
+
this.prevNameIndex = 0;
|
|
439
|
+
}
|
|
440
|
+
endLine(segments) {
|
|
441
|
+
this.lines.push(segments);
|
|
442
|
+
this.buffered += segments.length + 1;
|
|
443
|
+
if (this.buffered >= 4096)
|
|
444
|
+
this.drain(null);
|
|
445
|
+
}
|
|
446
|
+
segments(segments) {
|
|
447
|
+
this.drain(segments);
|
|
448
|
+
}
|
|
449
|
+
finish(segments) {
|
|
450
|
+
this.drain(segments);
|
|
451
|
+
this.flush();
|
|
452
|
+
return this.out;
|
|
453
|
+
}
|
|
454
|
+
drain(trailing) {
|
|
455
|
+
const lines = this.lines;
|
|
456
|
+
const lineCount = lines.length;
|
|
457
|
+
for (let l = 0;l <= lineCount; l++) {
|
|
458
|
+
const line = l < lineCount ? lines[l] : trailing;
|
|
459
|
+
if (line === null)
|
|
460
|
+
break;
|
|
461
|
+
for (let i = 0;i < line.length; i++) {
|
|
462
|
+
if (this.pos > FLUSH_THRESHOLD)
|
|
463
|
+
this.flush();
|
|
464
|
+
const segment = line[i];
|
|
465
|
+
if (this.needsComma)
|
|
466
|
+
scratch[this.pos++] = COMMA;
|
|
467
|
+
this.needsComma = true;
|
|
468
|
+
this.pos = writeVlq(this.pos, segment[0] - this.prevGenColumn);
|
|
469
|
+
this.prevGenColumn = segment[0];
|
|
470
|
+
this.pos = writeVlq(this.pos, segment[1] - this.prevSourceIndex);
|
|
471
|
+
this.prevSourceIndex = segment[1];
|
|
472
|
+
this.pos = writeVlq(this.pos, segment[2] - this.prevSourceLine);
|
|
473
|
+
this.prevSourceLine = segment[2];
|
|
474
|
+
this.pos = writeVlq(this.pos, segment[3] - this.prevSourceColumn);
|
|
475
|
+
this.prevSourceColumn = segment[3];
|
|
476
|
+
if (segment.length === 5) {
|
|
477
|
+
this.pos = writeVlq(this.pos, segment[4] - this.prevNameIndex);
|
|
478
|
+
this.prevNameIndex = segment[4];
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (l < lineCount) {
|
|
482
|
+
if (this.pos > FLUSH_THRESHOLD)
|
|
483
|
+
this.flush();
|
|
484
|
+
scratch[this.pos++] = SEMICOLON;
|
|
485
|
+
this.needsComma = false;
|
|
486
|
+
this.prevGenColumn = 0;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
lines.length = 0;
|
|
490
|
+
this.buffered = 0;
|
|
491
|
+
this.flush();
|
|
492
|
+
}
|
|
493
|
+
flush() {
|
|
494
|
+
this.out += decoder.decode(scratch.subarray(0, this.pos));
|
|
495
|
+
this.pos = 0;
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
var NEWLINE_CHAR$1 = 10;
|
|
499
|
+
function isWordCode(code) {
|
|
500
|
+
return code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57 || code === 95;
|
|
501
|
+
}
|
|
372
502
|
var Mappings = class {
|
|
373
|
-
constructor(hires) {
|
|
503
|
+
constructor(hires, encoder = null) {
|
|
374
504
|
this.hires = hires;
|
|
375
505
|
this.generatedCodeLine = 0;
|
|
376
506
|
this.generatedCodeColumn = 0;
|
|
377
507
|
this.raw = [];
|
|
378
508
|
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
379
|
-
this.
|
|
509
|
+
this.rawRangeMappings = [];
|
|
510
|
+
this.rawRangeMappingsIndices = this.rawRangeMappings[this.generatedCodeLine] = [];
|
|
511
|
+
this.encoder = encoder;
|
|
512
|
+
}
|
|
513
|
+
nextLine() {
|
|
514
|
+
if (this.encoder === null) {
|
|
515
|
+
this.generatedCodeLine += 1;
|
|
516
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
517
|
+
} else {
|
|
518
|
+
this.encoder.endLine(this.rawSegments);
|
|
519
|
+
this.rawSegments = [];
|
|
520
|
+
this.generatedCodeLine += 1;
|
|
521
|
+
}
|
|
522
|
+
this.generatedCodeColumn = 0;
|
|
523
|
+
this.rawRangeMappings[this.generatedCodeLine] = this.rawRangeMappingsIndices = [];
|
|
380
524
|
}
|
|
381
525
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
382
526
|
if (content.length) {
|
|
@@ -394,9 +538,7 @@ var Mappings = class {
|
|
|
394
538
|
if (nameIndex >= 0)
|
|
395
539
|
segment.push(nameIndex);
|
|
396
540
|
this.rawSegments.push(segment);
|
|
397
|
-
this.
|
|
398
|
-
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
399
|
-
this.generatedCodeColumn = 0;
|
|
541
|
+
this.nextLine();
|
|
400
542
|
previousContentLineEnd = contentLineEnd;
|
|
401
543
|
contentLineEnd = content.indexOf(`
|
|
402
544
|
`, contentLineEnd + 1);
|
|
@@ -411,68 +553,133 @@ var Mappings = class {
|
|
|
411
553
|
segment.push(nameIndex);
|
|
412
554
|
this.rawSegments.push(segment);
|
|
413
555
|
this.advance(content.slice(previousContentLineEnd + 1));
|
|
414
|
-
} else if (this.pending) {
|
|
415
|
-
this.rawSegments.push(this.pending);
|
|
416
|
-
this.advance(content);
|
|
417
556
|
}
|
|
418
|
-
this.pending = null;
|
|
419
557
|
}
|
|
420
558
|
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
421
|
-
|
|
422
|
-
let
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
this.
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
436
|
-
const segment = [
|
|
559
|
+
const end = chunk.end;
|
|
560
|
+
let i = chunk.start;
|
|
561
|
+
if (this.hires) {
|
|
562
|
+
const boundary = this.hires === "boundary";
|
|
563
|
+
const experimentalRange = this.hires === "experimental-range";
|
|
564
|
+
const encoder = experimentalRange ? null : this.encoder;
|
|
565
|
+
let charInHiresBoundary = false;
|
|
566
|
+
while (i < end) {
|
|
567
|
+
if (encoder !== null && this.rawSegments.length >= 4096) {
|
|
568
|
+
encoder.segments(this.rawSegments);
|
|
569
|
+
this.rawSegments.length = 0;
|
|
570
|
+
}
|
|
571
|
+
if (experimentalRange && i + 1 >= end)
|
|
572
|
+
this.rawSegments.push([
|
|
437
573
|
this.generatedCodeColumn,
|
|
438
574
|
sourceIndex,
|
|
439
575
|
loc.line,
|
|
440
576
|
loc.column
|
|
441
|
-
];
|
|
442
|
-
|
|
443
|
-
|
|
577
|
+
]);
|
|
578
|
+
const code = original.charCodeAt(i);
|
|
579
|
+
if (code === NEWLINE_CHAR$1) {
|
|
580
|
+
loc.line += 1;
|
|
581
|
+
loc.column = 0;
|
|
582
|
+
this.nextLine();
|
|
583
|
+
charInHiresBoundary = false;
|
|
584
|
+
} else {
|
|
585
|
+
if (boundary) {
|
|
586
|
+
if (isWordCode(code)) {
|
|
444
587
|
if (!charInHiresBoundary) {
|
|
445
|
-
this.rawSegments.push(
|
|
588
|
+
this.rawSegments.push([
|
|
589
|
+
this.generatedCodeColumn,
|
|
590
|
+
sourceIndex,
|
|
591
|
+
loc.line,
|
|
592
|
+
loc.column
|
|
593
|
+
]);
|
|
446
594
|
charInHiresBoundary = true;
|
|
447
595
|
}
|
|
448
596
|
} else {
|
|
449
|
-
this.rawSegments.push(
|
|
597
|
+
this.rawSegments.push([
|
|
598
|
+
this.generatedCodeColumn,
|
|
599
|
+
sourceIndex,
|
|
600
|
+
loc.line,
|
|
601
|
+
loc.column
|
|
602
|
+
]);
|
|
450
603
|
charInHiresBoundary = false;
|
|
451
604
|
}
|
|
452
|
-
else
|
|
453
|
-
|
|
605
|
+
} else if (experimentalRange) {
|
|
606
|
+
if (i === chunk.start) {
|
|
607
|
+
this.rawRangeMappingsIndices.push(this.rawSegments.length);
|
|
608
|
+
this.rawSegments.push([
|
|
609
|
+
this.generatedCodeColumn,
|
|
610
|
+
sourceIndex,
|
|
611
|
+
loc.line,
|
|
612
|
+
loc.column
|
|
613
|
+
]);
|
|
614
|
+
}
|
|
615
|
+
} else
|
|
616
|
+
this.rawSegments.push([
|
|
617
|
+
this.generatedCodeColumn,
|
|
618
|
+
sourceIndex,
|
|
619
|
+
loc.line,
|
|
620
|
+
loc.column
|
|
621
|
+
]);
|
|
622
|
+
loc.column += 1;
|
|
623
|
+
this.generatedCodeColumn += 1;
|
|
624
|
+
}
|
|
625
|
+
i += 1;
|
|
626
|
+
}
|
|
627
|
+
} else {
|
|
628
|
+
const bits = sourcemapLocations.bits;
|
|
629
|
+
while (i < end) {
|
|
630
|
+
let newline = original.indexOf(`
|
|
631
|
+
`, i);
|
|
632
|
+
if (newline === -1 || newline > end)
|
|
633
|
+
newline = end;
|
|
634
|
+
if (newline > i) {
|
|
635
|
+
this.rawSegments.push([
|
|
636
|
+
this.generatedCodeColumn,
|
|
637
|
+
sourceIndex,
|
|
638
|
+
loc.line,
|
|
639
|
+
loc.column
|
|
640
|
+
]);
|
|
641
|
+
for (let w = i + 1 >> 5, last = newline - 1 >> 5;w <= last; w++) {
|
|
642
|
+
let word = bits[w];
|
|
643
|
+
if (!word)
|
|
644
|
+
continue;
|
|
645
|
+
const base = w << 5;
|
|
646
|
+
while (word) {
|
|
647
|
+
const lowest = word & -word;
|
|
648
|
+
const index = base + 31 - Math.clz32(lowest);
|
|
649
|
+
if (index > i && index < newline) {
|
|
650
|
+
const offset = index - i;
|
|
651
|
+
this.rawSegments.push([
|
|
652
|
+
this.generatedCodeColumn + offset,
|
|
653
|
+
sourceIndex,
|
|
654
|
+
loc.line,
|
|
655
|
+
loc.column + offset
|
|
656
|
+
]);
|
|
657
|
+
}
|
|
658
|
+
word ^= lowest;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
loc.column += newline - i;
|
|
662
|
+
this.generatedCodeColumn += newline - i;
|
|
454
663
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
664
|
+
if (newline === end)
|
|
665
|
+
break;
|
|
666
|
+
loc.line += 1;
|
|
667
|
+
loc.column = 0;
|
|
668
|
+
this.nextLine();
|
|
669
|
+
i = newline + 1;
|
|
458
670
|
}
|
|
459
|
-
originalCharIndex += 1;
|
|
460
671
|
}
|
|
461
|
-
this.pending = null;
|
|
462
672
|
}
|
|
463
673
|
advance(str) {
|
|
464
674
|
if (!str)
|
|
465
675
|
return;
|
|
466
|
-
const
|
|
676
|
+
const lastNewline = str.lastIndexOf(`
|
|
467
677
|
`);
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
this.generatedCodeColumn = 0;
|
|
474
|
-
}
|
|
475
|
-
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
678
|
+
for (let i = str.indexOf(`
|
|
679
|
+
`);i !== -1; i = str.indexOf(`
|
|
680
|
+
`, i + 1))
|
|
681
|
+
this.nextLine();
|
|
682
|
+
this.generatedCodeColumn += str.length - lastNewline - 1;
|
|
476
683
|
}
|
|
477
684
|
};
|
|
478
685
|
var n = `
|
|
@@ -484,6 +691,55 @@ var warned = {
|
|
|
484
691
|
insertRight: false,
|
|
485
692
|
storeName: false
|
|
486
693
|
};
|
|
694
|
+
function expandReplacement(replacement, matched, position, str, captures, namedCaptures) {
|
|
695
|
+
if (!replacement.includes("$"))
|
|
696
|
+
return replacement;
|
|
697
|
+
let result = "";
|
|
698
|
+
let index = 0;
|
|
699
|
+
while (index < replacement.length) {
|
|
700
|
+
const dollar = replacement.indexOf("$", index);
|
|
701
|
+
if (dollar === -1) {
|
|
702
|
+
result += replacement.slice(index);
|
|
703
|
+
break;
|
|
704
|
+
}
|
|
705
|
+
result += replacement.slice(index, dollar);
|
|
706
|
+
const char = replacement[dollar + 1];
|
|
707
|
+
let expansion = "$";
|
|
708
|
+
let consumed = 1;
|
|
709
|
+
if (char === "$")
|
|
710
|
+
consumed = 2;
|
|
711
|
+
else if (char === "&") {
|
|
712
|
+
expansion = matched;
|
|
713
|
+
consumed = 2;
|
|
714
|
+
} else if (char === "`") {
|
|
715
|
+
expansion = str.slice(0, position);
|
|
716
|
+
consumed = 2;
|
|
717
|
+
} else if (char === "'") {
|
|
718
|
+
expansion = str.slice(position + matched.length);
|
|
719
|
+
consumed = 2;
|
|
720
|
+
} else if (char === "<" && namedCaptures !== undefined) {
|
|
721
|
+
const close = replacement.indexOf(">", dollar + 2);
|
|
722
|
+
if (close !== -1) {
|
|
723
|
+
expansion = namedCaptures[replacement.slice(dollar + 2, close)] ?? "";
|
|
724
|
+
consumed = close + 1 - dollar;
|
|
725
|
+
}
|
|
726
|
+
} else if (char >= "0" && char <= "9") {
|
|
727
|
+
const second = replacement[dollar + 2];
|
|
728
|
+
const double = second >= "0" && second <= "9" ? Number(char + second) : NaN;
|
|
729
|
+
const single = Number(char);
|
|
730
|
+
if (double >= 1 && double <= captures.length) {
|
|
731
|
+
expansion = captures[double - 1] ?? "";
|
|
732
|
+
consumed = 3;
|
|
733
|
+
} else if (single >= 1 && single <= captures.length) {
|
|
734
|
+
expansion = captures[single - 1] ?? "";
|
|
735
|
+
consumed = 2;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
result += expansion;
|
|
739
|
+
index = dollar + consumed;
|
|
740
|
+
}
|
|
741
|
+
return result;
|
|
742
|
+
}
|
|
487
743
|
var MagicString = class MagicString {
|
|
488
744
|
constructor(string, options = {}) {
|
|
489
745
|
const chunk = new Chunk(0, string.length, string);
|
|
@@ -619,9 +875,28 @@ var MagicString = class MagicString {
|
|
|
619
875
|
}
|
|
620
876
|
generateDecodedMap(options) {
|
|
621
877
|
options = options || {};
|
|
878
|
+
const mappings = new Mappings(options.hires);
|
|
879
|
+
const names = this._generateMappings(mappings);
|
|
880
|
+
return {
|
|
881
|
+
...this._mapProperties(options, names),
|
|
882
|
+
mappings: mappings.raw,
|
|
883
|
+
rangeMappings: mappings.rawRangeMappings
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
generateMap(options) {
|
|
887
|
+
options = options || {};
|
|
888
|
+
const encoder = new MappingsEncoder;
|
|
889
|
+
const mappings = new Mappings(options.hires, encoder);
|
|
890
|
+
const names = this._generateMappings(mappings);
|
|
891
|
+
return new SourceMap({
|
|
892
|
+
...this._mapProperties(options, names),
|
|
893
|
+
mappings: encoder.finish(mappings.rawSegments),
|
|
894
|
+
rangeMappings: mappings.rawRangeMappings
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
_generateMappings(mappings) {
|
|
622
898
|
const sourceIndex = 0;
|
|
623
899
|
const names = Object.keys(this.storedNames);
|
|
624
|
-
const mappings = new Mappings(options.hires);
|
|
625
900
|
const locate = getLocator(this.original);
|
|
626
901
|
if (this.intro)
|
|
627
902
|
mappings.advance(this.intro);
|
|
@@ -638,18 +913,17 @@ var MagicString = class MagicString {
|
|
|
638
913
|
});
|
|
639
914
|
if (this.outro)
|
|
640
915
|
mappings.advance(this.outro);
|
|
916
|
+
return names;
|
|
917
|
+
}
|
|
918
|
+
_mapProperties(options, names) {
|
|
641
919
|
return {
|
|
642
920
|
file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
|
|
643
921
|
sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
|
|
644
922
|
sourcesContent: options.includeContent ? [this.original] : undefined,
|
|
645
923
|
names,
|
|
646
|
-
|
|
647
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined
|
|
924
|
+
x_google_ignoreList: this.ignoreList ? [0] : undefined
|
|
648
925
|
};
|
|
649
926
|
}
|
|
650
|
-
generateMap(options) {
|
|
651
|
-
return new SourceMap(this.generateDecodedMap(options));
|
|
652
|
-
}
|
|
653
927
|
_ensureindentStr() {
|
|
654
928
|
if (this.indentStr === undefined)
|
|
655
929
|
this.indentStr = guessIndent(this.original);
|
|
@@ -683,19 +957,21 @@ var MagicString = class MagicString {
|
|
|
683
957
|
isExcluded[i] = true;
|
|
684
958
|
});
|
|
685
959
|
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
686
|
-
const
|
|
687
|
-
if (
|
|
688
|
-
return
|
|
689
|
-
|
|
690
|
-
|
|
960
|
+
const indentPiece = (str) => {
|
|
961
|
+
if (str === "")
|
|
962
|
+
return str;
|
|
963
|
+
const indented = str.replace(pattern, (match, offset) => offset > 0 || shouldIndentNextCharacter ? `${resolvedIndentStr}${match}` : match);
|
|
964
|
+
shouldIndentNextCharacter = str[str.length - 1] === `
|
|
965
|
+
`;
|
|
966
|
+
return indented;
|
|
691
967
|
};
|
|
692
|
-
this.intro = this.intro
|
|
968
|
+
this.intro = indentPiece(this.intro);
|
|
693
969
|
let charIndex = 0;
|
|
694
970
|
let chunk = this.firstChunk;
|
|
695
971
|
const indentAt = (index) => {
|
|
696
972
|
shouldIndentNextCharacter = false;
|
|
697
973
|
if (index === chunk.start)
|
|
698
|
-
chunk.
|
|
974
|
+
chunk.appendRight(resolvedIndentStr);
|
|
699
975
|
else {
|
|
700
976
|
this._splitChunk(chunk, index);
|
|
701
977
|
chunk = chunk.next;
|
|
@@ -704,13 +980,11 @@ var MagicString = class MagicString {
|
|
|
704
980
|
};
|
|
705
981
|
while (chunk) {
|
|
706
982
|
const end = chunk.end;
|
|
983
|
+
if (!isExcluded[chunk.start])
|
|
984
|
+
chunk.intro = indentPiece(chunk.intro);
|
|
707
985
|
if (chunk.edited) {
|
|
708
|
-
if (!isExcluded[charIndex])
|
|
709
|
-
chunk.content = chunk.content
|
|
710
|
-
if (chunk.content.length)
|
|
711
|
-
shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === `
|
|
712
|
-
`;
|
|
713
|
-
}
|
|
986
|
+
if (!isExcluded[charIndex])
|
|
987
|
+
chunk.content = indentPiece(chunk.content);
|
|
714
988
|
} else if (options.exclude) {
|
|
715
989
|
charIndex = chunk.start;
|
|
716
990
|
while (charIndex < end) {
|
|
@@ -743,10 +1017,12 @@ var MagicString = class MagicString {
|
|
|
743
1017
|
charIndex += 1;
|
|
744
1018
|
}
|
|
745
1019
|
}
|
|
1020
|
+
if (!isExcluded[chunk.end - 1])
|
|
1021
|
+
chunk.outro = indentPiece(chunk.outro);
|
|
746
1022
|
charIndex = chunk.end;
|
|
747
1023
|
chunk = chunk.next;
|
|
748
1024
|
}
|
|
749
|
-
this.outro = this.outro
|
|
1025
|
+
this.outro = indentPiece(this.outro);
|
|
750
1026
|
return this;
|
|
751
1027
|
}
|
|
752
1028
|
insert() {
|
|
@@ -766,7 +1042,7 @@ var MagicString = class MagicString {
|
|
|
766
1042
|
}
|
|
767
1043
|
return this.prependRight(index, content);
|
|
768
1044
|
}
|
|
769
|
-
move(start, end, index) {
|
|
1045
|
+
move(start, end, index, affinity = "right") {
|
|
770
1046
|
start = start + this.offset;
|
|
771
1047
|
end = end + this.offset;
|
|
772
1048
|
index = index + this.offset;
|
|
@@ -789,10 +1065,31 @@ var MagicString = class MagicString {
|
|
|
789
1065
|
}
|
|
790
1066
|
const oldLeft = first.previous;
|
|
791
1067
|
const oldRight = last.next;
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
1068
|
+
let newLeft;
|
|
1069
|
+
let newRight;
|
|
1070
|
+
if (affinity === "left") {
|
|
1071
|
+
newLeft = this.byEnd.get(index) ?? null;
|
|
1072
|
+
if (!newLeft) {
|
|
1073
|
+
if (first === this.firstChunk)
|
|
1074
|
+
return this;
|
|
1075
|
+
newRight = this.firstChunk;
|
|
1076
|
+
} else {
|
|
1077
|
+
if (newLeft.next === first)
|
|
1078
|
+
return this;
|
|
1079
|
+
newRight = newLeft.next;
|
|
1080
|
+
}
|
|
1081
|
+
} else {
|
|
1082
|
+
newRight = this.byStart.get(index) ?? null;
|
|
1083
|
+
if (!newRight) {
|
|
1084
|
+
if (last === this.lastChunk)
|
|
1085
|
+
return this;
|
|
1086
|
+
newLeft = this.lastChunk;
|
|
1087
|
+
} else {
|
|
1088
|
+
if (newRight.previous === last)
|
|
1089
|
+
return this;
|
|
1090
|
+
newLeft = newRight.previous;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
796
1093
|
if (oldLeft)
|
|
797
1094
|
oldLeft.next = oldRight;
|
|
798
1095
|
if (oldRight)
|
|
@@ -929,9 +1226,11 @@ var MagicString = class MagicString {
|
|
|
929
1226
|
this._split(end);
|
|
930
1227
|
let chunk = this.byStart.get(start);
|
|
931
1228
|
while (chunk) {
|
|
932
|
-
chunk.
|
|
933
|
-
|
|
934
|
-
chunk.
|
|
1229
|
+
if (chunk.start > start)
|
|
1230
|
+
chunk.intro = "";
|
|
1231
|
+
if (chunk.end < end)
|
|
1232
|
+
chunk.outro = "";
|
|
1233
|
+
chunk.edit("", false, true);
|
|
935
1234
|
chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
|
|
936
1235
|
}
|
|
937
1236
|
return this;
|
|
@@ -1021,7 +1320,7 @@ var MagicString = class MagicString {
|
|
|
1021
1320
|
let result = "";
|
|
1022
1321
|
let chunk = this.firstChunk;
|
|
1023
1322
|
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
1024
|
-
if (chunk.start < end && chunk.end >= end)
|
|
1323
|
+
if (chunk.start < end && chunk.end >= end || end === 0 && chunk.start === 0)
|
|
1025
1324
|
return result;
|
|
1026
1325
|
chunk = chunk.next;
|
|
1027
1326
|
}
|
|
@@ -1029,6 +1328,8 @@ var MagicString = class MagicString {
|
|
|
1029
1328
|
throw new MagicStringError(`cannot use edited character ${start} as slice start anchor`);
|
|
1030
1329
|
const startChunk = chunk;
|
|
1031
1330
|
while (chunk) {
|
|
1331
|
+
if (end === 0 && chunk.start === 0)
|
|
1332
|
+
break;
|
|
1032
1333
|
if (chunk.intro && (startChunk !== chunk || chunk.start === start))
|
|
1033
1334
|
result += chunk.intro;
|
|
1034
1335
|
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
@@ -1090,12 +1391,16 @@ var MagicString = class MagicString {
|
|
|
1090
1391
|
return str + this.outro;
|
|
1091
1392
|
}
|
|
1092
1393
|
isEmpty() {
|
|
1394
|
+
if (this.intro.length && this.intro.trim())
|
|
1395
|
+
return false;
|
|
1093
1396
|
let chunk = this.firstChunk;
|
|
1094
1397
|
while (chunk) {
|
|
1095
1398
|
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim())
|
|
1096
1399
|
return false;
|
|
1097
1400
|
chunk = chunk.next;
|
|
1098
1401
|
}
|
|
1402
|
+
if (this.outro.length && this.outro.trim())
|
|
1403
|
+
return false;
|
|
1099
1404
|
return true;
|
|
1100
1405
|
}
|
|
1101
1406
|
length() {
|
|
@@ -1133,7 +1438,8 @@ var MagicString = class MagicString {
|
|
|
1133
1438
|
return true;
|
|
1134
1439
|
chunk = chunk.previous;
|
|
1135
1440
|
} while (chunk);
|
|
1136
|
-
|
|
1441
|
+
this.intro = this.intro.replace(rx, "");
|
|
1442
|
+
return this.intro.length > 0;
|
|
1137
1443
|
}
|
|
1138
1444
|
trimEnd(charType) {
|
|
1139
1445
|
this.trimEndAborted(charType);
|
|
@@ -1159,7 +1465,8 @@ var MagicString = class MagicString {
|
|
|
1159
1465
|
return true;
|
|
1160
1466
|
chunk = chunk.next;
|
|
1161
1467
|
} while (chunk);
|
|
1162
|
-
|
|
1468
|
+
this.outro = this.outro.replace(rx, "");
|
|
1469
|
+
return this.outro.length > 0;
|
|
1163
1470
|
}
|
|
1164
1471
|
trimStart(charType) {
|
|
1165
1472
|
this.trimStartAborted(charType);
|
|
@@ -1184,31 +1491,43 @@ var MagicString = class MagicString {
|
|
|
1184
1491
|
}
|
|
1185
1492
|
return outputIndex !== this.original.length;
|
|
1186
1493
|
}
|
|
1494
|
+
_hasRemovedContent(start, end) {
|
|
1495
|
+
let chunk = this.byStart.get(start);
|
|
1496
|
+
if (!chunk) {
|
|
1497
|
+
chunk = this.lastSearchedChunk;
|
|
1498
|
+
const searchForward = start >= chunk.end;
|
|
1499
|
+
while (chunk && !chunk.contains(start))
|
|
1500
|
+
chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
|
|
1501
|
+
if (chunk)
|
|
1502
|
+
this.lastSearchedChunk = chunk;
|
|
1503
|
+
}
|
|
1504
|
+
while (chunk && chunk.start < end) {
|
|
1505
|
+
if (chunk.content === "")
|
|
1506
|
+
return true;
|
|
1507
|
+
chunk = this.byStart.get(chunk.end);
|
|
1508
|
+
}
|
|
1509
|
+
return false;
|
|
1510
|
+
}
|
|
1187
1511
|
_replaceRegexp(searchValue, replacement) {
|
|
1188
1512
|
function getReplacement(match, str) {
|
|
1189
1513
|
if (typeof replacement === "string")
|
|
1190
|
-
return replacement.
|
|
1191
|
-
if (i === "$")
|
|
1192
|
-
return "$";
|
|
1193
|
-
if (i === "&")
|
|
1194
|
-
return match[0];
|
|
1195
|
-
if (+i < match.length)
|
|
1196
|
-
return match[+i];
|
|
1197
|
-
return `$${i}`;
|
|
1198
|
-
});
|
|
1514
|
+
return expandReplacement(replacement, match[0], match.index, str, match.slice(1), match.groups);
|
|
1199
1515
|
else
|
|
1200
|
-
return replacement(match[0], ...match.slice(1), match.index, str, match.groups);
|
|
1516
|
+
return match.groups === undefined ? replacement(match[0], ...match.slice(1), match.index, str) : replacement(match[0], ...match.slice(1), match.index, str, match.groups);
|
|
1201
1517
|
}
|
|
1202
1518
|
const replaceMatch = (match) => {
|
|
1203
1519
|
if (match.index == null)
|
|
1204
|
-
return;
|
|
1520
|
+
return false;
|
|
1521
|
+
if (this._hasRemovedContent(match.index, match.index + match[0].length))
|
|
1522
|
+
return false;
|
|
1205
1523
|
const replacement = getReplacement(match, this.original);
|
|
1206
1524
|
if (replacement === match[0])
|
|
1207
|
-
return;
|
|
1525
|
+
return true;
|
|
1208
1526
|
if (match[0].length === 0)
|
|
1209
1527
|
this.appendRight(match.index, replacement);
|
|
1210
1528
|
else
|
|
1211
1529
|
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1530
|
+
return true;
|
|
1212
1531
|
};
|
|
1213
1532
|
if (searchValue.global) {
|
|
1214
1533
|
searchValue.lastIndex = 0;
|
|
@@ -1216,22 +1535,34 @@ var MagicString = class MagicString {
|
|
|
1216
1535
|
replaceMatch(match);
|
|
1217
1536
|
} else {
|
|
1218
1537
|
const match = this.original.match(searchValue);
|
|
1219
|
-
if (match)
|
|
1220
|
-
|
|
1538
|
+
if (match && !replaceMatch(match)) {
|
|
1539
|
+
const global = new RegExp(searchValue.source, `${searchValue.flags}g`);
|
|
1540
|
+
for (const next of this.original.matchAll(global))
|
|
1541
|
+
if (replaceMatch(next))
|
|
1542
|
+
break;
|
|
1543
|
+
}
|
|
1221
1544
|
}
|
|
1222
1545
|
return this;
|
|
1223
1546
|
}
|
|
1224
1547
|
_replaceString(string, replacement) {
|
|
1225
1548
|
const { original } = this;
|
|
1226
|
-
|
|
1227
|
-
|
|
1549
|
+
let index = original.indexOf(string);
|
|
1550
|
+
while (index !== -1) {
|
|
1551
|
+
if (this._hasRemovedContent(index, index + string.length)) {
|
|
1552
|
+
index = original.indexOf(string, index + string.length);
|
|
1553
|
+
continue;
|
|
1554
|
+
}
|
|
1228
1555
|
if (typeof replacement === "function")
|
|
1229
1556
|
replacement = replacement(string, index, original);
|
|
1230
|
-
|
|
1557
|
+
else
|
|
1558
|
+
replacement = expandReplacement(replacement, string, index, original, [], undefined);
|
|
1559
|
+
if (string !== replacement) {
|
|
1231
1560
|
if (string.length === 0)
|
|
1232
1561
|
this.appendRight(index, replacement);
|
|
1233
1562
|
else
|
|
1234
1563
|
this.overwrite(index, index + string.length, replacement);
|
|
1564
|
+
}
|
|
1565
|
+
break;
|
|
1235
1566
|
}
|
|
1236
1567
|
return this;
|
|
1237
1568
|
}
|
|
@@ -1245,15 +1576,19 @@ var MagicString = class MagicString {
|
|
|
1245
1576
|
const stringLength = string.length;
|
|
1246
1577
|
if (stringLength === 0) {
|
|
1247
1578
|
for (let index = 0;index <= original.length; index += 1) {
|
|
1248
|
-
|
|
1579
|
+
if (this._hasRemovedContent(index, index))
|
|
1580
|
+
continue;
|
|
1581
|
+
const _replacement = typeof replacement === "function" ? replacement("", index, original) : expandReplacement(replacement, "", index, original, [], undefined);
|
|
1249
1582
|
if (_replacement !== "")
|
|
1250
1583
|
this.appendRight(index, _replacement);
|
|
1251
1584
|
}
|
|
1252
1585
|
return this;
|
|
1253
1586
|
}
|
|
1254
1587
|
for (let index = original.indexOf(string);index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
1588
|
+
if (this._hasRemovedContent(index, index + stringLength))
|
|
1589
|
+
continue;
|
|
1255
1590
|
const previous = original.slice(index, index + stringLength);
|
|
1256
|
-
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : replacement;
|
|
1591
|
+
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : expandReplacement(replacement, previous, index, original, [], undefined);
|
|
1257
1592
|
if (previous !== _replacement)
|
|
1258
1593
|
this.overwrite(index, index + stringLength, _replacement);
|
|
1259
1594
|
}
|
|
@@ -1267,7 +1602,7 @@ var MagicString = class MagicString {
|
|
|
1267
1602
|
return this._replaceRegexp(searchValue, replacement);
|
|
1268
1603
|
}
|
|
1269
1604
|
};
|
|
1270
|
-
// ../../node_modules/.bun/yuku-ast@0.
|
|
1605
|
+
// ../../node_modules/.bun/yuku-ast@0.12.0/node_modules/yuku-ast/dist/aliases.js
|
|
1271
1606
|
var ALIAS_GROUPS = {
|
|
1272
1607
|
Expression: [
|
|
1273
1608
|
"Identifier",
|
|
@@ -1423,7 +1758,7 @@ var ALIAS_GROUPS = {
|
|
|
1423
1758
|
};
|
|
1424
1759
|
var ALIAS_NAMES = Object.keys(ALIAS_GROUPS);
|
|
1425
1760
|
|
|
1426
|
-
// ../../node_modules/.bun/yuku-ast@0.
|
|
1761
|
+
// ../../node_modules/.bun/yuku-ast@0.12.0/node_modules/yuku-ast/dist/context.js
|
|
1427
1762
|
class WalkContext {
|
|
1428
1763
|
_ancestors = [];
|
|
1429
1764
|
_node = null;
|
|
@@ -1491,7 +1826,7 @@ class WalkContext {
|
|
|
1491
1826
|
}
|
|
1492
1827
|
}
|
|
1493
1828
|
|
|
1494
|
-
// ../../node_modules/.bun/yuku-ast@0.
|
|
1829
|
+
// ../../node_modules/.bun/yuku-ast@0.12.0/node_modules/yuku-ast/dist/generated.js
|
|
1495
1830
|
var KEYS = Object.create(null);
|
|
1496
1831
|
function ck(type, keys) {
|
|
1497
1832
|
const prev = KEYS[type];
|
|
@@ -1863,7 +2198,7 @@ var TYPES = [
|
|
|
1863
2198
|
];
|
|
1864
2199
|
var NODE_TYPES = [...new Set(TYPES)];
|
|
1865
2200
|
|
|
1866
|
-
// ../../node_modules/.bun/yuku-ast@0.
|
|
2201
|
+
// ../../node_modules/.bun/yuku-ast@0.12.0/node_modules/yuku-ast/dist/walk.js
|
|
1867
2202
|
function createDispatch(visitors) {
|
|
1868
2203
|
let enter = null;
|
|
1869
2204
|
let leave = null;
|