nitro-nightly 4.0.0-20251030-091344-d4418b98 → 4.0.0-20251030-122334-09c1a7a8
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/_build/common.mjs +763 -0
- package/dist/_build/rolldown.mjs +216 -0
- package/dist/_build/rollup.mjs +359 -0
- package/dist/_build/vite.build.mjs +67 -0
- package/dist/_build/vite.plugin.mjs +762 -0
- package/dist/_chunks/B-7HiF0V.mjs +1303 -0
- package/dist/_chunks/B3asVbT4.mjs +151 -0
- package/dist/_chunks/B5ooyfLk.mjs +372 -0
- package/dist/_chunks/DXMHy5ca.mjs +43 -0
- package/dist/_dev.d.mts +12 -0
- package/dist/_dev.mjs +675 -0
- package/dist/_libs/acorn.mjs +5034 -0
- package/dist/_libs/c12.mjs +2798 -0
- package/dist/_libs/chokidar.mjs +1560 -0
- package/dist/_libs/citty.mjs +333 -0
- package/dist/_libs/commondir.mjs +22 -0
- package/dist/_libs/compatx.mjs +46 -0
- package/dist/_libs/confbox.mjs +2920 -0
- package/dist/_libs/debug.mjs +848 -0
- package/dist/_libs/deepmerge.mjs +86 -0
- package/dist/_libs/depd.mjs +314 -0
- package/dist/_libs/dot-prop.mjs +138 -0
- package/dist/_libs/duplexer.mjs +71 -0
- package/dist/_libs/ee-first.mjs +68 -0
- package/dist/_libs/encodeurl.mjs +49 -0
- package/dist/_libs/escape-html.mjs +58 -0
- package/dist/_libs/escape-string-regexp.mjs +8 -0
- package/dist/_libs/estree-walker.mjs +330 -0
- package/dist/_libs/etag.mjs +75 -0
- package/dist/{_chunks/_deps → _libs}/fdir.mjs +49 -104
- package/dist/_libs/fresh.mjs +85 -0
- package/dist/_libs/function-bind.mjs +63 -0
- package/dist/_libs/gen-mapping.mjs +612 -0
- package/dist/_libs/giget.mjs +19076 -0
- package/dist/_libs/gzip-size.mjs +21 -0
- package/dist/_libs/hasown.mjs +14 -0
- package/dist/_libs/http-errors.mjs +436 -0
- package/dist/_libs/httpxy.mjs +410 -0
- package/dist/_libs/is-core-module.mjs +220 -0
- package/dist/_libs/is-module.mjs +13 -0
- package/dist/_libs/is-reference.mjs +32 -0
- package/dist/{_chunks/_deps → _libs}/js-tokens.mjs +83 -112
- package/dist/_libs/klona.mjs +90 -0
- package/dist/_libs/knitwork.mjs +124 -0
- package/dist/_libs/local-pkg.mjs +1686 -0
- package/dist/{_chunks/_deps → _libs}/magic-string.mjs +272 -629
- package/dist/_libs/mime-db.mjs +7642 -0
- package/dist/_libs/mime-types.mjs +162 -0
- package/dist/_libs/mime.mjs +1391 -0
- package/dist/_libs/node-fetch-native.mjs +173 -0
- package/dist/_libs/on-finished.mjs +170 -0
- package/dist/_libs/parseurl.mjs +103 -0
- package/dist/_libs/path-parse.mjs +47 -0
- package/dist/_libs/pathe.mjs +41 -0
- package/dist/_libs/picomatch.mjs +1673 -0
- package/dist/_libs/plugin-alias.mjs +64 -0
- package/dist/_libs/plugin-commonjs.mjs +1489 -0
- package/dist/_libs/plugin-inject.mjs +135 -0
- package/dist/_libs/plugin-json.mjs +36 -0
- package/dist/_libs/plugin-node-resolve.mjs +1553 -0
- package/dist/_libs/plugin-replace.mjs +104 -0
- package/dist/_libs/pretty-bytes.mjs +116 -0
- package/dist/_libs/range-parser.mjs +102 -0
- package/dist/_libs/remapping.mjs +117 -0
- package/dist/{_chunks/_deps → _libs}/rou3.mjs +7 -22
- package/dist/_libs/send.mjs +857 -0
- package/dist/_libs/serve-static.mjs +124 -0
- package/dist/_libs/std-env.mjs +158 -0
- package/dist/_libs/strip-literal.mjs +51 -0
- package/dist/{_chunks/_deps → _libs}/tinyglobby.mjs +32 -33
- package/dist/_libs/ultrahtml.mjs +138 -0
- package/dist/_libs/unimport.mjs +3520 -0
- package/dist/_libs/untyped.mjs +271 -0
- package/dist/_libs/unwasm.mjs +5825 -0
- package/dist/{_chunks/_deps/@pi0 → _libs}/vite-plugin-fullstack.mjs +28 -42
- package/dist/_presets.mjs +1723 -0
- package/dist/builder.d.mts +37 -35
- package/dist/builder.mjs +45 -117
- package/dist/cli/_chunks/build.mjs +43 -0
- package/dist/cli/_chunks/common.mjs +15 -0
- package/dist/cli/_chunks/detect-acorn.mjs +12 -0
- package/dist/cli/_chunks/dev.mjs +79 -0
- package/dist/cli/_chunks/dist.mjs +3 -0
- package/dist/cli/_chunks/dist2.mjs +4 -0
- package/dist/cli/_chunks/esm.mjs +3 -0
- package/dist/cli/_chunks/json5.mjs +4 -0
- package/dist/cli/_chunks/jsonc.mjs +4 -0
- package/dist/cli/_chunks/list.mjs +27 -0
- package/dist/cli/_chunks/multipart-parser.mjs +6 -0
- package/dist/cli/_chunks/prepare.mjs +19 -0
- package/dist/cli/_chunks/run.mjs +55 -0
- package/dist/cli/_chunks/task.mjs +16 -0
- package/dist/cli/_chunks/toml.mjs +4 -0
- package/dist/cli/_chunks/yaml.mjs +4 -0
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +19 -18
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +42 -33
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +4 -8
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
- package/dist/presets/_nitro/runtime/service-worker.mjs +14 -11
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +6 -5
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
- package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +25 -27
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +7 -7
- package/dist/presets/azure/runtime/_utils.mjs +43 -43
- package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
- package/dist/presets/azure/runtime/azure-swa.mjs +22 -21
- package/dist/presets/bun/runtime/bun.d.mts +1 -0
- package/dist/presets/bun/runtime/bun.mjs +18 -17
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +78 -87
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +53 -58
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +12 -14
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +35 -39
- package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
- package/dist/presets/cloudflare/runtime/plugin.dev.mjs +86 -76
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
- package/dist/presets/deno/runtime/deno-deploy.mjs +12 -11
- package/dist/presets/deno/runtime/deno-server.d.mts +2 -1
- package/dist/presets/deno/runtime/deno-server.mjs +31 -39
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
- package/dist/presets/netlify/runtime/netlify-edge.mjs +14 -11
- package/dist/presets/netlify/runtime/netlify.mjs +11 -17
- package/dist/presets/node/runtime/node-cluster.mjs +49 -48
- package/dist/presets/node/runtime/node-middleware.d.mts +3 -2
- package/dist/presets/node/runtime/node-middleware.mjs +7 -6
- package/dist/presets/node/runtime/node-server.mjs +33 -23
- package/dist/presets/standard/runtime/server.d.mts +1 -3
- package/dist/presets/standard/runtime/server.mjs +1 -3
- package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
- package/dist/presets/stormkit/runtime/stormkit.mjs +20 -20
- package/dist/presets/vercel/runtime/vercel.d.mts +3 -3
- package/dist/presets/vercel/runtime/vercel.mjs +15 -14
- package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
- package/dist/presets/winterjs/runtime/winterjs.mjs +72 -68
- package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
- package/dist/runtime/index.d.mts +12 -1
- package/dist/runtime/index.mjs +12 -7
- package/dist/runtime/internal/app.mjs +175 -162
- package/dist/runtime/internal/cache.d.mts +10 -4
- package/dist/runtime/internal/cache.mjs +247 -216
- package/dist/runtime/internal/context.d.mts +9 -9
- package/dist/runtime/internal/context.mjs +17 -10
- package/dist/runtime/internal/database.mjs +8 -10
- package/dist/runtime/internal/error/dev.d.mts +5 -4
- package/dist/runtime/internal/error/dev.mjs +106 -105
- package/dist/runtime/internal/error/prod.d.mts +2 -2
- package/dist/runtime/internal/error/prod.mjs +48 -52
- package/dist/runtime/internal/error/utils.d.mts +4 -4
- package/dist/runtime/internal/error/utils.mjs +1 -1
- package/dist/runtime/internal/index.d.mts +2 -0
- package/dist/runtime/internal/index.mjs +2 -0
- package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +14 -14
- package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +248 -209
- package/dist/runtime/internal/meta.d.mts +1 -1
- package/dist/runtime/internal/meta.mjs +1 -1
- package/dist/runtime/internal/plugin.d.mts +2 -2
- package/dist/runtime/internal/plugin.mjs +1 -1
- package/dist/runtime/internal/renderer.mjs +39 -31
- package/dist/runtime/internal/route-rules.d.mts +8 -8
- package/dist/runtime/internal/route-rules.mjs +53 -51
- package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -30
- package/dist/runtime/internal/routes/dev-tasks.mjs +15 -17
- package/dist/runtime/internal/routes/openapi.d.mts +1 -0
- package/dist/runtime/internal/routes/openapi.mjs +81 -87
- package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
- package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +10 -17
- package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
- package/dist/runtime/internal/routes/scalar.d.mts +1 -0
- package/dist/runtime/internal/routes/scalar.mjs +22 -23
- package/dist/runtime/internal/routes/swagger.d.mts +1 -0
- package/dist/runtime/internal/routes/swagger.mjs +9 -11
- package/dist/runtime/internal/runtime-config.d.mts +4 -4
- package/dist/runtime/internal/runtime-config.mjs +40 -35
- package/dist/runtime/internal/shutdown.d.mts +2 -7
- package/dist/runtime/internal/shutdown.mjs +30 -29
- package/dist/runtime/internal/static.mjs +63 -74
- package/dist/runtime/internal/storage.mjs +2 -2
- package/dist/runtime/internal/task.d.mts +6 -6
- package/dist/runtime/internal/task.mjs +56 -59
- package/dist/runtime/internal/utils.d.mts +1 -1
- package/dist/runtime/internal/utils.mjs +4 -10
- package/dist/types/index.d.mts +2566 -3851
- package/dist/types/index.mjs +1 -1
- package/dist/vite.d.mts +61 -51
- package/dist/vite.mjs +55 -132
- package/package.json +10 -10
- package/dist/_build/build.mjs +0 -368
- package/dist/_build/build2.mjs +0 -556
- package/dist/_build/info.mjs +0 -1002
- package/dist/_build/prepare.mjs +0 -1511
- package/dist/_build/snapshot.mjs +0 -185
- package/dist/_build/vite.mjs +0 -959
- package/dist/_build/vite2.mjs +0 -149
- package/dist/_chunks/_deps/@jridgewell/gen-mapping.mjs +0 -189
- package/dist/_chunks/_deps/@jridgewell/remapping.mjs +0 -137
- package/dist/_chunks/_deps/@jridgewell/resolve-uri.mjs +0 -231
- package/dist/_chunks/_deps/@jridgewell/sourcemap-codec.mjs +0 -173
- package/dist/_chunks/_deps/@jridgewell/trace-mapping.mjs +0 -170
- package/dist/_chunks/_deps/@rollup/plugin-alias.mjs +0 -89
- package/dist/_chunks/_deps/@rollup/plugin-commonjs.mjs +0 -2376
- package/dist/_chunks/_deps/@rollup/plugin-inject.mjs +0 -212
- package/dist/_chunks/_deps/@rollup/plugin-json.mjs +0 -37
- package/dist/_chunks/_deps/@rollup/plugin-node-resolve.mjs +0 -1386
- package/dist/_chunks/_deps/@rollup/plugin-replace.mjs +0 -133
- package/dist/_chunks/_deps/@rollup/pluginutils.mjs +0 -346
- package/dist/_chunks/_deps/acorn.mjs +0 -6225
- package/dist/_chunks/_deps/c12.mjs +0 -510
- package/dist/_chunks/_deps/chokidar.mjs +0 -1428
- package/dist/_chunks/_deps/citty.mjs +0 -460
- package/dist/_chunks/_deps/commondir.mjs +0 -77
- package/dist/_chunks/_deps/compatx.mjs +0 -76
- package/dist/_chunks/_deps/confbox.mjs +0 -300
- package/dist/_chunks/_deps/debug.mjs +0 -885
- package/dist/_chunks/_deps/deepmerge.mjs +0 -147
- package/dist/_chunks/_deps/depd.mjs +0 -550
- package/dist/_chunks/_deps/dot-prop.mjs +0 -282
- package/dist/_chunks/_deps/dotenv.mjs +0 -555
- package/dist/_chunks/_deps/duplexer.mjs +0 -1
- package/dist/_chunks/_deps/ee-first.mjs +0 -104
- package/dist/_chunks/_deps/encodeurl.mjs +0 -69
- package/dist/_chunks/_deps/escape-html.mjs +0 -87
- package/dist/_chunks/_deps/escape-string-regexp.mjs +0 -13
- package/dist/_chunks/_deps/estree-walker.mjs +0 -433
- package/dist/_chunks/_deps/etag.mjs +0 -147
- package/dist/_chunks/_deps/exsolve.mjs +0 -1416
- package/dist/_chunks/_deps/fresh.mjs +0 -145
- package/dist/_chunks/_deps/function-bind.mjs +0 -106
- package/dist/_chunks/_deps/giget.mjs +0 -451
- package/dist/_chunks/_deps/gzip-size.mjs +0 -19
- package/dist/_chunks/_deps/hasown.mjs +0 -19
- package/dist/_chunks/_deps/http-errors.mjs +0 -307
- package/dist/_chunks/_deps/httpxy.mjs +0 -580
- package/dist/_chunks/_deps/inherits.mjs +0 -57
- package/dist/_chunks/_deps/is-core-module.mjs +0 -596
- package/dist/_chunks/_deps/is-module.mjs +0 -25
- package/dist/_chunks/_deps/is-reference.mjs +0 -31
- package/dist/_chunks/_deps/klona.mjs +0 -137
- package/dist/_chunks/_deps/knitwork.mjs +0 -172
- package/dist/_chunks/_deps/local-pkg.mjs +0 -163
- package/dist/_chunks/_deps/mime-db.mjs +0 -11685
- package/dist/_chunks/_deps/mime-types.mjs +0 -287
- package/dist/_chunks/_deps/mime.mjs +0 -1172
- package/dist/_chunks/_deps/mlly.mjs +0 -2413
- package/dist/_chunks/_deps/ms.mjs +0 -172
- package/dist/_chunks/_deps/node-fetch-native.mjs +0 -3
- package/dist/_chunks/_deps/nypm.mjs +0 -219
- package/dist/_chunks/_deps/on-finished.mjs +0 -246
- package/dist/_chunks/_deps/parseurl.mjs +0 -168
- package/dist/_chunks/_deps/path-parse.mjs +0 -85
- package/dist/_chunks/_deps/pathe.mjs +0 -251
- package/dist/_chunks/_deps/perfect-debounce.mjs +0 -88
- package/dist/_chunks/_deps/picomatch.mjs +0 -2144
- package/dist/_chunks/_deps/pkg-types.mjs +0 -247
- package/dist/_chunks/_deps/pretty-bytes.mjs +0 -180
- package/dist/_chunks/_deps/quansync.mjs +0 -99
- package/dist/_chunks/_deps/range-parser.mjs +0 -171
- package/dist/_chunks/_deps/rc9.mjs +0 -219
- package/dist/_chunks/_deps/readdirp.mjs +0 -245
- package/dist/_chunks/_deps/resolve.mjs +0 -1260
- package/dist/_chunks/_deps/send.mjs +0 -1022
- package/dist/_chunks/_deps/serve-static.mjs +0 -228
- package/dist/_chunks/_deps/setprototypeof.mjs +0 -26
- package/dist/_chunks/_deps/statuses.mjs +0 -457
- package/dist/_chunks/_deps/std-env.mjs +0 -3
- package/dist/_chunks/_deps/strip-literal.mjs +0 -67
- package/dist/_chunks/_deps/supports-color.mjs +0 -44
- package/dist/_chunks/_deps/tinyexec.mjs +0 -552
- package/dist/_chunks/_deps/toidentifier.mjs +0 -41
- package/dist/_chunks/_deps/ultrahtml.mjs +0 -3
- package/dist/_chunks/_deps/unimport.mjs +0 -2267
- package/dist/_chunks/_deps/unplugin-utils.mjs +0 -65
- package/dist/_chunks/_deps/unplugin.mjs +0 -1294
- package/dist/_chunks/_deps/untyped.mjs +0 -375
- package/dist/_chunks/_deps/unwasm.mjs +0 -6959
- package/dist/_chunks/_deps/webpack-virtual-modules.mjs +0 -360
- package/dist/_chunks/_presets/_all.mjs +0 -59
- package/dist/_chunks/_presets/_nitro.mjs +0 -74
- package/dist/_chunks/_presets/_resolve.mjs +0 -64
- package/dist/_chunks/_presets/_static.mjs +0 -69
- package/dist/_chunks/_presets/_types.mjs +0 -3
- package/dist/_chunks/_presets/_utils.mjs +0 -31
- package/dist/_chunks/_presets/alwaysdata.mjs +0 -17
- package/dist/_chunks/_presets/aws-amplify.mjs +0 -111
- package/dist/_chunks/_presets/aws-lambda.mjs +0 -23
- package/dist/_chunks/_presets/azure.mjs +0 -162
- package/dist/_chunks/_presets/bun.mjs +0 -19
- package/dist/_chunks/_presets/cleavr.mjs +0 -15
- package/dist/_chunks/_presets/cloudflare.mjs +0 -608
- package/dist/_chunks/_presets/deno.mjs +0 -196
- package/dist/_chunks/_presets/digitalocean.mjs +0 -14
- package/dist/_chunks/_presets/firebase.mjs +0 -47
- package/dist/_chunks/_presets/flightcontrol.mjs +0 -14
- package/dist/_chunks/_presets/genezio.mjs +0 -13
- package/dist/_chunks/_presets/heroku.mjs +0 -14
- package/dist/_chunks/_presets/iis.mjs +0 -194
- package/dist/_chunks/_presets/index.mjs +0 -62
- package/dist/_chunks/_presets/koyeb.mjs +0 -14
- package/dist/_chunks/_presets/netlify.mjs +0 -241
- package/dist/_chunks/_presets/node.mjs +0 -54
- package/dist/_chunks/_presets/platform.mjs +0 -14
- package/dist/_chunks/_presets/render.mjs +0 -14
- package/dist/_chunks/_presets/standard.mjs +0 -23
- package/dist/_chunks/_presets/stormkit.mjs +0 -18
- package/dist/_chunks/_presets/vercel.mjs +0 -375
- package/dist/_chunks/_presets/winterjs.mjs +0 -22
- package/dist/_chunks/_presets/zeabur.mjs +0 -69
- package/dist/_chunks/_presets/zerops.mjs +0 -27
- package/dist/_chunks/app.mjs +0 -600
- package/dist/_chunks/builder.mjs +0 -648
- package/dist/_chunks/server.mjs +0 -256
- package/dist/_cli/build.mjs +0 -49
- package/dist/_cli/common.mjs +0 -13
- package/dist/_cli/dev.mjs +0 -121
- package/dist/_cli/index.mjs +0 -16
- package/dist/_cli/list.mjs +0 -33
- package/dist/_cli/prepare.mjs +0 -23
- package/dist/_cli/run.mjs +0 -59
- package/dist/presets/cloudflare/runtime/shims/workers.dev.d.mts +0 -21
- package/dist/runtime/internal/empty.d.mts +0 -0
- package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
- package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
- package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
- package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
- /package/lib/{indexd.mts → index.d.mts} +0 -0
|
@@ -1,62 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { u as encode } from "./gen-mapping.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
//#region node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs
|
|
4
|
+
var BitSet = class BitSet {
|
|
4
5
|
constructor(arg) {
|
|
5
6
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.bits[n >> 5] |= 1 << (n & 31);
|
|
8
|
+
add(n$1) {
|
|
9
|
+
this.bits[n$1 >> 5] |= 1 << (n$1 & 31);
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return !!(this.bits[n >> 5] & (1 << (n & 31)));
|
|
11
|
+
has(n$1) {
|
|
12
|
+
return !!(this.bits[n$1 >> 5] & 1 << (n$1 & 31));
|
|
14
13
|
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
class Chunk {
|
|
14
|
+
};
|
|
15
|
+
var Chunk = class Chunk {
|
|
18
16
|
constructor(start, end, content) {
|
|
19
17
|
this.start = start;
|
|
20
18
|
this.end = end;
|
|
21
19
|
this.original = content;
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
this.outro = '';
|
|
25
|
-
|
|
20
|
+
this.intro = "";
|
|
21
|
+
this.outro = "";
|
|
26
22
|
this.content = content;
|
|
27
23
|
this.storeName = false;
|
|
28
24
|
this.edited = false;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.previous = null;
|
|
32
|
-
this.next = null;
|
|
33
|
-
}
|
|
25
|
+
this.previous = null;
|
|
26
|
+
this.next = null;
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
appendLeft(content) {
|
|
37
29
|
this.outro += content;
|
|
38
30
|
}
|
|
39
|
-
|
|
40
31
|
appendRight(content) {
|
|
41
32
|
this.intro = this.intro + content;
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
clone() {
|
|
45
35
|
const chunk = new Chunk(this.start, this.end, this.original);
|
|
46
|
-
|
|
47
36
|
chunk.intro = this.intro;
|
|
48
37
|
chunk.outro = this.outro;
|
|
49
38
|
chunk.content = this.content;
|
|
50
39
|
chunk.storeName = this.storeName;
|
|
51
40
|
chunk.edited = this.edited;
|
|
52
|
-
|
|
53
41
|
return chunk;
|
|
54
42
|
}
|
|
55
|
-
|
|
56
43
|
contains(index) {
|
|
57
44
|
return this.start < index && index < this.end;
|
|
58
45
|
}
|
|
59
|
-
|
|
60
46
|
eachNext(fn) {
|
|
61
47
|
let chunk = this;
|
|
62
48
|
while (chunk) {
|
|
@@ -64,7 +50,6 @@ class Chunk {
|
|
|
64
50
|
chunk = chunk.next;
|
|
65
51
|
}
|
|
66
52
|
}
|
|
67
|
-
|
|
68
53
|
eachPrevious(fn) {
|
|
69
54
|
let chunk = this;
|
|
70
55
|
while (chunk) {
|
|
@@ -72,142 +57,96 @@ class Chunk {
|
|
|
72
57
|
chunk = chunk.previous;
|
|
73
58
|
}
|
|
74
59
|
}
|
|
75
|
-
|
|
76
60
|
edit(content, storeName, contentOnly) {
|
|
77
61
|
this.content = content;
|
|
78
62
|
if (!contentOnly) {
|
|
79
|
-
this.intro =
|
|
80
|
-
this.outro =
|
|
63
|
+
this.intro = "";
|
|
64
|
+
this.outro = "";
|
|
81
65
|
}
|
|
82
66
|
this.storeName = storeName;
|
|
83
|
-
|
|
84
67
|
this.edited = true;
|
|
85
|
-
|
|
86
68
|
return this;
|
|
87
69
|
}
|
|
88
|
-
|
|
89
70
|
prependLeft(content) {
|
|
90
71
|
this.outro = content + this.outro;
|
|
91
72
|
}
|
|
92
|
-
|
|
93
73
|
prependRight(content) {
|
|
94
74
|
this.intro = content + this.intro;
|
|
95
75
|
}
|
|
96
|
-
|
|
97
76
|
reset() {
|
|
98
|
-
this.intro =
|
|
99
|
-
this.outro =
|
|
77
|
+
this.intro = "";
|
|
78
|
+
this.outro = "";
|
|
100
79
|
if (this.edited) {
|
|
101
80
|
this.content = this.original;
|
|
102
81
|
this.storeName = false;
|
|
103
82
|
this.edited = false;
|
|
104
83
|
}
|
|
105
84
|
}
|
|
106
|
-
|
|
107
85
|
split(index) {
|
|
108
86
|
const sliceIndex = index - this.start;
|
|
109
|
-
|
|
110
87
|
const originalBefore = this.original.slice(0, sliceIndex);
|
|
111
88
|
const originalAfter = this.original.slice(sliceIndex);
|
|
112
|
-
|
|
113
89
|
this.original = originalBefore;
|
|
114
|
-
|
|
115
90
|
const newChunk = new Chunk(index, this.end, originalAfter);
|
|
116
91
|
newChunk.outro = this.outro;
|
|
117
|
-
this.outro =
|
|
118
|
-
|
|
92
|
+
this.outro = "";
|
|
119
93
|
this.end = index;
|
|
120
|
-
|
|
121
94
|
if (this.edited) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// ' test'.trim()
|
|
126
|
-
// split -> ' ' + 'test'
|
|
127
|
-
// ✔️ edit -> '' + 'test'
|
|
128
|
-
// ✖️ edit -> 'test' + ''
|
|
129
|
-
// TODO is this block necessary?...
|
|
130
|
-
newChunk.edit('', false);
|
|
131
|
-
this.content = '';
|
|
132
|
-
} else {
|
|
133
|
-
this.content = originalBefore;
|
|
134
|
-
}
|
|
135
|
-
|
|
95
|
+
newChunk.edit("", false);
|
|
96
|
+
this.content = "";
|
|
97
|
+
} else this.content = originalBefore;
|
|
136
98
|
newChunk.next = this.next;
|
|
137
99
|
if (newChunk.next) newChunk.next.previous = newChunk;
|
|
138
100
|
newChunk.previous = this;
|
|
139
101
|
this.next = newChunk;
|
|
140
|
-
|
|
141
102
|
return newChunk;
|
|
142
103
|
}
|
|
143
|
-
|
|
144
104
|
toString() {
|
|
145
105
|
return this.intro + this.content + this.outro;
|
|
146
106
|
}
|
|
147
|
-
|
|
148
107
|
trimEnd(rx) {
|
|
149
|
-
this.outro = this.outro.replace(rx,
|
|
108
|
+
this.outro = this.outro.replace(rx, "");
|
|
150
109
|
if (this.outro.length) return true;
|
|
151
|
-
|
|
152
|
-
const trimmed = this.content.replace(rx, '');
|
|
153
|
-
|
|
110
|
+
const trimmed = this.content.replace(rx, "");
|
|
154
111
|
if (trimmed.length) {
|
|
155
112
|
if (trimmed !== this.content) {
|
|
156
|
-
this.split(this.start + trimmed.length).edit(
|
|
157
|
-
if (this.edited)
|
|
158
|
-
// save the change, if it has been edited
|
|
159
|
-
this.edit(trimmed, this.storeName, true);
|
|
160
|
-
}
|
|
113
|
+
this.split(this.start + trimmed.length).edit("", void 0, true);
|
|
114
|
+
if (this.edited) this.edit(trimmed, this.storeName, true);
|
|
161
115
|
}
|
|
162
116
|
return true;
|
|
163
117
|
} else {
|
|
164
|
-
this.edit(
|
|
165
|
-
|
|
166
|
-
this.intro = this.intro.replace(rx, '');
|
|
118
|
+
this.edit("", void 0, true);
|
|
119
|
+
this.intro = this.intro.replace(rx, "");
|
|
167
120
|
if (this.intro.length) return true;
|
|
168
121
|
}
|
|
169
122
|
}
|
|
170
|
-
|
|
171
123
|
trimStart(rx) {
|
|
172
|
-
this.intro = this.intro.replace(rx,
|
|
124
|
+
this.intro = this.intro.replace(rx, "");
|
|
173
125
|
if (this.intro.length) return true;
|
|
174
|
-
|
|
175
|
-
const trimmed = this.content.replace(rx, '');
|
|
176
|
-
|
|
126
|
+
const trimmed = this.content.replace(rx, "");
|
|
177
127
|
if (trimmed.length) {
|
|
178
128
|
if (trimmed !== this.content) {
|
|
179
129
|
const newChunk = this.split(this.end - trimmed.length);
|
|
180
|
-
if (this.edited)
|
|
181
|
-
|
|
182
|
-
newChunk.edit(trimmed, this.storeName, true);
|
|
183
|
-
}
|
|
184
|
-
this.edit('', undefined, true);
|
|
130
|
+
if (this.edited) newChunk.edit(trimmed, this.storeName, true);
|
|
131
|
+
this.edit("", void 0, true);
|
|
185
132
|
}
|
|
186
133
|
return true;
|
|
187
134
|
} else {
|
|
188
|
-
this.edit(
|
|
189
|
-
|
|
190
|
-
this.outro = this.outro.replace(rx, '');
|
|
135
|
+
this.edit("", void 0, true);
|
|
136
|
+
this.outro = this.outro.replace(rx, "");
|
|
191
137
|
if (this.outro.length) return true;
|
|
192
138
|
}
|
|
193
139
|
}
|
|
194
|
-
}
|
|
195
|
-
|
|
140
|
+
};
|
|
196
141
|
function getBtoa() {
|
|
197
|
-
if (typeof globalThis !==
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
return () => {
|
|
203
|
-
throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
|
|
204
|
-
};
|
|
205
|
-
}
|
|
142
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
143
|
+
else if (typeof Buffer === "function") return (str) => Buffer.from(str, "utf-8").toString("base64");
|
|
144
|
+
else return () => {
|
|
145
|
+
throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
|
|
146
|
+
};
|
|
206
147
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
class SourceMap {
|
|
148
|
+
const btoa = /* @__PURE__ */ getBtoa();
|
|
149
|
+
var SourceMap = class {
|
|
211
150
|
constructor(properties) {
|
|
212
151
|
this.version = 3;
|
|
213
152
|
this.file = properties.file;
|
|
@@ -215,103 +154,70 @@ class SourceMap {
|
|
|
215
154
|
this.sourcesContent = properties.sourcesContent;
|
|
216
155
|
this.names = properties.names;
|
|
217
156
|
this.mappings = encode(properties.mappings);
|
|
218
|
-
if (typeof properties.x_google_ignoreList !==
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
if (typeof properties.debugId !== 'undefined') {
|
|
222
|
-
this.debugId = properties.debugId;
|
|
223
|
-
}
|
|
157
|
+
if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
158
|
+
if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
|
|
224
159
|
}
|
|
225
|
-
|
|
226
160
|
toString() {
|
|
227
161
|
return JSON.stringify(this);
|
|
228
162
|
}
|
|
229
|
-
|
|
230
163
|
toUrl() {
|
|
231
|
-
return
|
|
164
|
+
return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
|
|
232
165
|
}
|
|
233
|
-
}
|
|
234
|
-
|
|
166
|
+
};
|
|
235
167
|
function guessIndent(code) {
|
|
236
|
-
const lines = code.split(
|
|
237
|
-
|
|
168
|
+
const lines = code.split("\n");
|
|
238
169
|
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
239
170
|
const spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
240
|
-
|
|
241
|
-
if (tabbed.length
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// More lines tabbed than spaced? Assume tabs, and
|
|
246
|
-
// default to tabs in the case of a tie (or nothing
|
|
247
|
-
// to go on)
|
|
248
|
-
if (tabbed.length >= spaced.length) {
|
|
249
|
-
return '\t';
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Otherwise, we need to guess the multiple
|
|
171
|
+
if (tabbed.length === 0 && spaced.length === 0) return null;
|
|
172
|
+
if (tabbed.length >= spaced.length) return " ";
|
|
253
173
|
const min = spaced.reduce((previous, current) => {
|
|
254
174
|
const numSpaces = /^ +/.exec(current)[0].length;
|
|
255
175
|
return Math.min(numSpaces, previous);
|
|
256
176
|
}, Infinity);
|
|
257
|
-
|
|
258
|
-
return new Array(min + 1).join(' ');
|
|
177
|
+
return new Array(min + 1).join(" ");
|
|
259
178
|
}
|
|
260
|
-
|
|
261
179
|
function getRelativePath(from, to) {
|
|
262
180
|
const fromParts = from.split(/[/\\]/);
|
|
263
181
|
const toParts = to.split(/[/\\]/);
|
|
264
|
-
|
|
265
|
-
fromParts.pop(); // get dirname
|
|
266
|
-
|
|
182
|
+
fromParts.pop();
|
|
267
183
|
while (fromParts[0] === toParts[0]) {
|
|
268
184
|
fromParts.shift();
|
|
269
185
|
toParts.shift();
|
|
270
186
|
}
|
|
271
|
-
|
|
272
187
|
if (fromParts.length) {
|
|
273
188
|
let i = fromParts.length;
|
|
274
|
-
while (i--) fromParts[i] =
|
|
189
|
+
while (i--) fromParts[i] = "..";
|
|
275
190
|
}
|
|
276
|
-
|
|
277
|
-
return fromParts.concat(toParts).join('/');
|
|
191
|
+
return fromParts.concat(toParts).join("/");
|
|
278
192
|
}
|
|
279
|
-
|
|
280
193
|
const toString = Object.prototype.toString;
|
|
281
|
-
|
|
282
194
|
function isObject(thing) {
|
|
283
|
-
return toString.call(thing) ===
|
|
195
|
+
return toString.call(thing) === "[object Object]";
|
|
284
196
|
}
|
|
285
|
-
|
|
286
197
|
function getLocator(source) {
|
|
287
|
-
const originalLines = source.split(
|
|
198
|
+
const originalLines = source.split("\n");
|
|
288
199
|
const lineOffsets = [];
|
|
289
|
-
|
|
290
200
|
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
291
201
|
lineOffsets.push(pos);
|
|
292
202
|
pos += originalLines[i].length + 1;
|
|
293
203
|
}
|
|
294
|
-
|
|
295
204
|
return function locate(index) {
|
|
296
205
|
let i = 0;
|
|
297
206
|
let j = lineOffsets.length;
|
|
298
207
|
while (i < j) {
|
|
299
|
-
const m =
|
|
300
|
-
if (index < lineOffsets[m])
|
|
301
|
-
|
|
302
|
-
} else {
|
|
303
|
-
i = m + 1;
|
|
304
|
-
}
|
|
208
|
+
const m = i + j >> 1;
|
|
209
|
+
if (index < lineOffsets[m]) j = m;
|
|
210
|
+
else i = m + 1;
|
|
305
211
|
}
|
|
306
212
|
const line = i - 1;
|
|
307
|
-
|
|
308
|
-
|
|
213
|
+
return {
|
|
214
|
+
line,
|
|
215
|
+
column: index - lineOffsets[line]
|
|
216
|
+
};
|
|
309
217
|
};
|
|
310
218
|
}
|
|
311
|
-
|
|
312
219
|
const wordRegex = /\w/;
|
|
313
|
-
|
|
314
|
-
class Mappings {
|
|
220
|
+
var Mappings = class {
|
|
315
221
|
constructor(hires) {
|
|
316
222
|
this.hires = hires;
|
|
317
223
|
this.generatedCodeLine = 0;
|
|
@@ -320,52 +226,47 @@ class Mappings {
|
|
|
320
226
|
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
321
227
|
this.pending = null;
|
|
322
228
|
}
|
|
323
|
-
|
|
324
229
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
325
230
|
if (content.length) {
|
|
326
231
|
const contentLengthMinusOne = content.length - 1;
|
|
327
|
-
let contentLineEnd = content.indexOf(
|
|
232
|
+
let contentLineEnd = content.indexOf("\n", 0);
|
|
328
233
|
let previousContentLineEnd = -1;
|
|
329
|
-
// Loop through each line in the content and add a segment, but stop if the last line is empty,
|
|
330
|
-
// else code afterwards would fill one line too many
|
|
331
234
|
while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
|
|
332
|
-
const segment = [
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
235
|
+
const segment$1 = [
|
|
236
|
+
this.generatedCodeColumn,
|
|
237
|
+
sourceIndex,
|
|
238
|
+
loc.line,
|
|
239
|
+
loc.column
|
|
240
|
+
];
|
|
241
|
+
if (nameIndex >= 0) segment$1.push(nameIndex);
|
|
242
|
+
this.rawSegments.push(segment$1);
|
|
338
243
|
this.generatedCodeLine += 1;
|
|
339
244
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
340
245
|
this.generatedCodeColumn = 0;
|
|
341
|
-
|
|
342
246
|
previousContentLineEnd = contentLineEnd;
|
|
343
|
-
contentLineEnd = content.indexOf(
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
347
|
-
if (nameIndex >= 0) {
|
|
348
|
-
segment.push(nameIndex);
|
|
247
|
+
contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
|
|
349
248
|
}
|
|
249
|
+
const segment = [
|
|
250
|
+
this.generatedCodeColumn,
|
|
251
|
+
sourceIndex,
|
|
252
|
+
loc.line,
|
|
253
|
+
loc.column
|
|
254
|
+
];
|
|
255
|
+
if (nameIndex >= 0) segment.push(nameIndex);
|
|
350
256
|
this.rawSegments.push(segment);
|
|
351
|
-
|
|
352
257
|
this.advance(content.slice(previousContentLineEnd + 1));
|
|
353
258
|
} else if (this.pending) {
|
|
354
259
|
this.rawSegments.push(this.pending);
|
|
355
260
|
this.advance(content);
|
|
356
261
|
}
|
|
357
|
-
|
|
358
262
|
this.pending = null;
|
|
359
263
|
}
|
|
360
|
-
|
|
361
264
|
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
362
265
|
let originalCharIndex = chunk.start;
|
|
363
266
|
let first = true;
|
|
364
|
-
// when iterating each char, check if it's in a word boundary
|
|
365
267
|
let charInHiresBoundary = false;
|
|
366
|
-
|
|
367
268
|
while (originalCharIndex < chunk.end) {
|
|
368
|
-
if (original[originalCharIndex] ===
|
|
269
|
+
if (original[originalCharIndex] === "\n") {
|
|
369
270
|
loc.line += 1;
|
|
370
271
|
loc.column = 0;
|
|
371
272
|
this.generatedCodeLine += 1;
|
|
@@ -375,42 +276,34 @@ class Mappings {
|
|
|
375
276
|
charInHiresBoundary = false;
|
|
376
277
|
} else {
|
|
377
278
|
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
378
|
-
const segment = [
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
charInHiresBoundary = true;
|
|
387
|
-
}
|
|
388
|
-
} else {
|
|
389
|
-
// for non-word char, end the boundary by pushing a segment
|
|
279
|
+
const segment = [
|
|
280
|
+
this.generatedCodeColumn,
|
|
281
|
+
sourceIndex,
|
|
282
|
+
loc.line,
|
|
283
|
+
loc.column
|
|
284
|
+
];
|
|
285
|
+
if (this.hires === "boundary") if (wordRegex.test(original[originalCharIndex])) {
|
|
286
|
+
if (!charInHiresBoundary) {
|
|
390
287
|
this.rawSegments.push(segment);
|
|
391
|
-
charInHiresBoundary =
|
|
288
|
+
charInHiresBoundary = true;
|
|
392
289
|
}
|
|
393
290
|
} else {
|
|
394
291
|
this.rawSegments.push(segment);
|
|
292
|
+
charInHiresBoundary = false;
|
|
395
293
|
}
|
|
294
|
+
else this.rawSegments.push(segment);
|
|
396
295
|
}
|
|
397
|
-
|
|
398
296
|
loc.column += 1;
|
|
399
297
|
this.generatedCodeColumn += 1;
|
|
400
298
|
first = false;
|
|
401
299
|
}
|
|
402
|
-
|
|
403
300
|
originalCharIndex += 1;
|
|
404
301
|
}
|
|
405
|
-
|
|
406
302
|
this.pending = null;
|
|
407
303
|
}
|
|
408
|
-
|
|
409
304
|
advance(str) {
|
|
410
305
|
if (!str) return;
|
|
411
|
-
|
|
412
|
-
const lines = str.split('\n');
|
|
413
|
-
|
|
306
|
+
const lines = str.split("\n");
|
|
414
307
|
if (lines.length > 1) {
|
|
415
308
|
for (let i = 0; i < lines.length - 1; i++) {
|
|
416
309
|
this.generatedCodeLine++;
|
|
@@ -418,521 +311,393 @@ class Mappings {
|
|
|
418
311
|
}
|
|
419
312
|
this.generatedCodeColumn = 0;
|
|
420
313
|
}
|
|
421
|
-
|
|
422
314
|
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
423
315
|
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
const n = '\n';
|
|
427
|
-
|
|
316
|
+
};
|
|
317
|
+
const n = "\n";
|
|
428
318
|
const warned = {
|
|
429
319
|
insertLeft: false,
|
|
430
320
|
insertRight: false,
|
|
431
|
-
storeName: false
|
|
321
|
+
storeName: false
|
|
432
322
|
};
|
|
433
|
-
|
|
434
|
-
class MagicString {
|
|
323
|
+
var MagicString = class MagicString {
|
|
435
324
|
constructor(string, options = {}) {
|
|
436
325
|
const chunk = new Chunk(0, string.length, string);
|
|
437
|
-
|
|
438
326
|
Object.defineProperties(this, {
|
|
439
|
-
original: {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
327
|
+
original: {
|
|
328
|
+
writable: true,
|
|
329
|
+
value: string
|
|
330
|
+
},
|
|
331
|
+
outro: {
|
|
332
|
+
writable: true,
|
|
333
|
+
value: ""
|
|
334
|
+
},
|
|
335
|
+
intro: {
|
|
336
|
+
writable: true,
|
|
337
|
+
value: ""
|
|
338
|
+
},
|
|
339
|
+
firstChunk: {
|
|
340
|
+
writable: true,
|
|
341
|
+
value: chunk
|
|
342
|
+
},
|
|
343
|
+
lastChunk: {
|
|
344
|
+
writable: true,
|
|
345
|
+
value: chunk
|
|
346
|
+
},
|
|
347
|
+
lastSearchedChunk: {
|
|
348
|
+
writable: true,
|
|
349
|
+
value: chunk
|
|
350
|
+
},
|
|
351
|
+
byStart: {
|
|
352
|
+
writable: true,
|
|
353
|
+
value: {}
|
|
354
|
+
},
|
|
355
|
+
byEnd: {
|
|
356
|
+
writable: true,
|
|
357
|
+
value: {}
|
|
358
|
+
},
|
|
359
|
+
filename: {
|
|
360
|
+
writable: true,
|
|
361
|
+
value: options.filename
|
|
362
|
+
},
|
|
363
|
+
indentExclusionRanges: {
|
|
364
|
+
writable: true,
|
|
365
|
+
value: options.indentExclusionRanges
|
|
366
|
+
},
|
|
367
|
+
sourcemapLocations: {
|
|
368
|
+
writable: true,
|
|
369
|
+
value: new BitSet()
|
|
370
|
+
},
|
|
371
|
+
storedNames: {
|
|
372
|
+
writable: true,
|
|
373
|
+
value: {}
|
|
374
|
+
},
|
|
375
|
+
indentStr: {
|
|
376
|
+
writable: true,
|
|
377
|
+
value: void 0
|
|
378
|
+
},
|
|
379
|
+
ignoreList: {
|
|
380
|
+
writable: true,
|
|
381
|
+
value: options.ignoreList
|
|
382
|
+
},
|
|
383
|
+
offset: {
|
|
384
|
+
writable: true,
|
|
385
|
+
value: options.offset || 0
|
|
386
|
+
}
|
|
454
387
|
});
|
|
455
|
-
|
|
456
388
|
this.byStart[0] = chunk;
|
|
457
389
|
this.byEnd[string.length] = chunk;
|
|
458
390
|
}
|
|
459
|
-
|
|
460
391
|
addSourcemapLocation(char) {
|
|
461
392
|
this.sourcemapLocations.add(char);
|
|
462
393
|
}
|
|
463
|
-
|
|
464
394
|
append(content) {
|
|
465
|
-
if (typeof content !==
|
|
466
|
-
|
|
395
|
+
if (typeof content !== "string") throw new TypeError("outro content must be a string");
|
|
467
396
|
this.outro += content;
|
|
468
397
|
return this;
|
|
469
398
|
}
|
|
470
|
-
|
|
471
399
|
appendLeft(index, content) {
|
|
472
400
|
index = index + this.offset;
|
|
473
|
-
|
|
474
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
475
|
-
|
|
401
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
476
402
|
this._split(index);
|
|
477
|
-
|
|
478
403
|
const chunk = this.byEnd[index];
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
chunk.appendLeft(content);
|
|
482
|
-
} else {
|
|
483
|
-
this.intro += content;
|
|
484
|
-
}
|
|
404
|
+
if (chunk) chunk.appendLeft(content);
|
|
405
|
+
else this.intro += content;
|
|
485
406
|
return this;
|
|
486
407
|
}
|
|
487
|
-
|
|
488
408
|
appendRight(index, content) {
|
|
489
409
|
index = index + this.offset;
|
|
490
|
-
|
|
491
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
492
|
-
|
|
410
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
493
411
|
this._split(index);
|
|
494
|
-
|
|
495
412
|
const chunk = this.byStart[index];
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
chunk.appendRight(content);
|
|
499
|
-
} else {
|
|
500
|
-
this.outro += content;
|
|
501
|
-
}
|
|
413
|
+
if (chunk) chunk.appendRight(content);
|
|
414
|
+
else this.outro += content;
|
|
502
415
|
return this;
|
|
503
416
|
}
|
|
504
|
-
|
|
505
417
|
clone() {
|
|
506
|
-
const cloned = new MagicString(this.original, {
|
|
507
|
-
|
|
418
|
+
const cloned = new MagicString(this.original, {
|
|
419
|
+
filename: this.filename,
|
|
420
|
+
offset: this.offset
|
|
421
|
+
});
|
|
508
422
|
let originalChunk = this.firstChunk;
|
|
509
|
-
let clonedChunk =
|
|
510
|
-
|
|
423
|
+
let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
|
|
511
424
|
while (originalChunk) {
|
|
512
425
|
cloned.byStart[clonedChunk.start] = clonedChunk;
|
|
513
426
|
cloned.byEnd[clonedChunk.end] = clonedChunk;
|
|
514
|
-
|
|
515
427
|
const nextOriginalChunk = originalChunk.next;
|
|
516
428
|
const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
|
|
517
|
-
|
|
518
429
|
if (nextClonedChunk) {
|
|
519
430
|
clonedChunk.next = nextClonedChunk;
|
|
520
431
|
nextClonedChunk.previous = clonedChunk;
|
|
521
|
-
|
|
522
432
|
clonedChunk = nextClonedChunk;
|
|
523
433
|
}
|
|
524
|
-
|
|
525
434
|
originalChunk = nextOriginalChunk;
|
|
526
435
|
}
|
|
527
|
-
|
|
528
436
|
cloned.lastChunk = clonedChunk;
|
|
529
|
-
|
|
530
|
-
if (this.indentExclusionRanges) {
|
|
531
|
-
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
532
|
-
}
|
|
533
|
-
|
|
437
|
+
if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
534
438
|
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
535
|
-
|
|
536
439
|
cloned.intro = this.intro;
|
|
537
440
|
cloned.outro = this.outro;
|
|
538
|
-
|
|
539
441
|
return cloned;
|
|
540
442
|
}
|
|
541
|
-
|
|
542
443
|
generateDecodedMap(options) {
|
|
543
444
|
options = options || {};
|
|
544
|
-
|
|
545
445
|
const sourceIndex = 0;
|
|
546
446
|
const names = Object.keys(this.storedNames);
|
|
547
447
|
const mappings = new Mappings(options.hires);
|
|
548
|
-
|
|
549
448
|
const locate = getLocator(this.original);
|
|
550
|
-
|
|
551
|
-
if (this.intro) {
|
|
552
|
-
mappings.advance(this.intro);
|
|
553
|
-
}
|
|
554
|
-
|
|
449
|
+
if (this.intro) mappings.advance(this.intro);
|
|
555
450
|
this.firstChunk.eachNext((chunk) => {
|
|
556
451
|
const loc = locate(chunk.start);
|
|
557
|
-
|
|
558
452
|
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
mappings.addEdit(
|
|
562
|
-
sourceIndex,
|
|
563
|
-
chunk.content,
|
|
564
|
-
loc,
|
|
565
|
-
chunk.storeName ? names.indexOf(chunk.original) : -1,
|
|
566
|
-
);
|
|
567
|
-
} else {
|
|
568
|
-
mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
569
|
-
}
|
|
570
|
-
|
|
453
|
+
if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
|
|
454
|
+
else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
571
455
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
572
456
|
});
|
|
573
|
-
|
|
574
|
-
if (this.outro) {
|
|
575
|
-
mappings.advance(this.outro);
|
|
576
|
-
}
|
|
577
|
-
|
|
457
|
+
if (this.outro) mappings.advance(this.outro);
|
|
578
458
|
return {
|
|
579
|
-
file: options.file ? options.file.split(/[/\\]/).pop() :
|
|
580
|
-
sources: [
|
|
581
|
-
|
|
582
|
-
],
|
|
583
|
-
sourcesContent: options.includeContent ? [this.original] : undefined,
|
|
459
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
460
|
+
sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
|
|
461
|
+
sourcesContent: options.includeContent ? [this.original] : void 0,
|
|
584
462
|
names,
|
|
585
463
|
mappings: mappings.raw,
|
|
586
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] :
|
|
464
|
+
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
|
|
587
465
|
};
|
|
588
466
|
}
|
|
589
|
-
|
|
590
467
|
generateMap(options) {
|
|
591
468
|
return new SourceMap(this.generateDecodedMap(options));
|
|
592
469
|
}
|
|
593
|
-
|
|
594
470
|
_ensureindentStr() {
|
|
595
|
-
if (this.indentStr ===
|
|
596
|
-
this.indentStr = guessIndent(this.original);
|
|
597
|
-
}
|
|
471
|
+
if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
|
|
598
472
|
}
|
|
599
|
-
|
|
600
473
|
_getRawIndentString() {
|
|
601
474
|
this._ensureindentStr();
|
|
602
475
|
return this.indentStr;
|
|
603
476
|
}
|
|
604
|
-
|
|
605
477
|
getIndentString() {
|
|
606
478
|
this._ensureindentStr();
|
|
607
|
-
return this.indentStr === null ?
|
|
479
|
+
return this.indentStr === null ? " " : this.indentStr;
|
|
608
480
|
}
|
|
609
|
-
|
|
610
481
|
indent(indentStr, options) {
|
|
611
482
|
const pattern = /^[^\r\n]/gm;
|
|
612
|
-
|
|
613
483
|
if (isObject(indentStr)) {
|
|
614
484
|
options = indentStr;
|
|
615
|
-
indentStr =
|
|
485
|
+
indentStr = void 0;
|
|
616
486
|
}
|
|
617
|
-
|
|
618
|
-
if (indentStr === undefined) {
|
|
487
|
+
if (indentStr === void 0) {
|
|
619
488
|
this._ensureindentStr();
|
|
620
|
-
indentStr = this.indentStr ||
|
|
489
|
+
indentStr = this.indentStr || " ";
|
|
621
490
|
}
|
|
622
|
-
|
|
623
|
-
if (indentStr === '') return this; // noop
|
|
624
|
-
|
|
491
|
+
if (indentStr === "") return this;
|
|
625
492
|
options = options || {};
|
|
626
|
-
|
|
627
|
-
// Process exclusion ranges
|
|
628
493
|
const isExcluded = {};
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
|
|
633
|
-
exclusions.forEach((exclusion) => {
|
|
634
|
-
for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
|
|
635
|
-
isExcluded[i] = true;
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
|
-
|
|
494
|
+
if (options.exclude) (typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
|
|
495
|
+
for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
|
|
496
|
+
});
|
|
640
497
|
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
641
498
|
const replacer = (match) => {
|
|
642
499
|
if (shouldIndentNextCharacter) return `${indentStr}${match}`;
|
|
643
500
|
shouldIndentNextCharacter = true;
|
|
644
501
|
return match;
|
|
645
502
|
};
|
|
646
|
-
|
|
647
503
|
this.intro = this.intro.replace(pattern, replacer);
|
|
648
|
-
|
|
649
504
|
let charIndex = 0;
|
|
650
505
|
let chunk = this.firstChunk;
|
|
651
|
-
|
|
652
506
|
while (chunk) {
|
|
653
507
|
const end = chunk.end;
|
|
654
|
-
|
|
655
508
|
if (chunk.edited) {
|
|
656
509
|
if (!isExcluded[charIndex]) {
|
|
657
510
|
chunk.content = chunk.content.replace(pattern, replacer);
|
|
658
|
-
|
|
659
|
-
if (chunk.content.length) {
|
|
660
|
-
shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === '\n';
|
|
661
|
-
}
|
|
511
|
+
if (chunk.content.length) shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
|
|
662
512
|
}
|
|
663
513
|
} else {
|
|
664
514
|
charIndex = chunk.start;
|
|
665
|
-
|
|
666
515
|
while (charIndex < end) {
|
|
667
516
|
if (!isExcluded[charIndex]) {
|
|
668
517
|
const char = this.original[charIndex];
|
|
669
|
-
|
|
670
|
-
if (char
|
|
671
|
-
shouldIndentNextCharacter = true;
|
|
672
|
-
} else if (char !== '\r' && shouldIndentNextCharacter) {
|
|
518
|
+
if (char === "\n") shouldIndentNextCharacter = true;
|
|
519
|
+
else if (char !== "\r" && shouldIndentNextCharacter) {
|
|
673
520
|
shouldIndentNextCharacter = false;
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
chunk.prependRight(indentStr);
|
|
677
|
-
} else {
|
|
521
|
+
if (charIndex === chunk.start) chunk.prependRight(indentStr);
|
|
522
|
+
else {
|
|
678
523
|
this._splitChunk(chunk, charIndex);
|
|
679
524
|
chunk = chunk.next;
|
|
680
525
|
chunk.prependRight(indentStr);
|
|
681
526
|
}
|
|
682
527
|
}
|
|
683
528
|
}
|
|
684
|
-
|
|
685
529
|
charIndex += 1;
|
|
686
530
|
}
|
|
687
531
|
}
|
|
688
|
-
|
|
689
532
|
charIndex = chunk.end;
|
|
690
533
|
chunk = chunk.next;
|
|
691
534
|
}
|
|
692
|
-
|
|
693
535
|
this.outro = this.outro.replace(pattern, replacer);
|
|
694
|
-
|
|
695
536
|
return this;
|
|
696
537
|
}
|
|
697
|
-
|
|
698
538
|
insert() {
|
|
699
|
-
throw new Error(
|
|
700
|
-
'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
|
|
701
|
-
);
|
|
539
|
+
throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)");
|
|
702
540
|
}
|
|
703
|
-
|
|
704
541
|
insertLeft(index, content) {
|
|
705
542
|
if (!warned.insertLeft) {
|
|
706
|
-
console.warn(
|
|
707
|
-
'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
|
|
708
|
-
);
|
|
543
|
+
console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead");
|
|
709
544
|
warned.insertLeft = true;
|
|
710
545
|
}
|
|
711
|
-
|
|
712
546
|
return this.appendLeft(index, content);
|
|
713
547
|
}
|
|
714
|
-
|
|
715
548
|
insertRight(index, content) {
|
|
716
549
|
if (!warned.insertRight) {
|
|
717
|
-
console.warn(
|
|
718
|
-
'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
|
|
719
|
-
);
|
|
550
|
+
console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead");
|
|
720
551
|
warned.insertRight = true;
|
|
721
552
|
}
|
|
722
|
-
|
|
723
553
|
return this.prependRight(index, content);
|
|
724
554
|
}
|
|
725
|
-
|
|
726
555
|
move(start, end, index) {
|
|
727
556
|
start = start + this.offset;
|
|
728
557
|
end = end + this.offset;
|
|
729
558
|
index = index + this.offset;
|
|
730
|
-
|
|
731
|
-
if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
|
|
732
|
-
|
|
559
|
+
if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
|
|
733
560
|
this._split(start);
|
|
734
561
|
this._split(end);
|
|
735
562
|
this._split(index);
|
|
736
|
-
|
|
737
563
|
const first = this.byStart[start];
|
|
738
564
|
const last = this.byEnd[end];
|
|
739
|
-
|
|
740
565
|
const oldLeft = first.previous;
|
|
741
566
|
const oldRight = last.next;
|
|
742
|
-
|
|
743
567
|
const newRight = this.byStart[index];
|
|
744
568
|
if (!newRight && last === this.lastChunk) return this;
|
|
745
569
|
const newLeft = newRight ? newRight.previous : this.lastChunk;
|
|
746
|
-
|
|
747
570
|
if (oldLeft) oldLeft.next = oldRight;
|
|
748
571
|
if (oldRight) oldRight.previous = oldLeft;
|
|
749
|
-
|
|
750
572
|
if (newLeft) newLeft.next = first;
|
|
751
573
|
if (newRight) newRight.previous = last;
|
|
752
|
-
|
|
753
574
|
if (!first.previous) this.firstChunk = last.next;
|
|
754
575
|
if (!last.next) {
|
|
755
576
|
this.lastChunk = first.previous;
|
|
756
577
|
this.lastChunk.next = null;
|
|
757
578
|
}
|
|
758
|
-
|
|
759
579
|
first.previous = newLeft;
|
|
760
580
|
last.next = newRight || null;
|
|
761
|
-
|
|
762
581
|
if (!newLeft) this.firstChunk = first;
|
|
763
582
|
if (!newRight) this.lastChunk = last;
|
|
764
583
|
return this;
|
|
765
584
|
}
|
|
766
|
-
|
|
767
585
|
overwrite(start, end, content, options) {
|
|
768
586
|
options = options || {};
|
|
769
|
-
return this.update(start, end, content, {
|
|
587
|
+
return this.update(start, end, content, {
|
|
588
|
+
...options,
|
|
589
|
+
overwrite: !options.contentOnly
|
|
590
|
+
});
|
|
770
591
|
}
|
|
771
|
-
|
|
772
592
|
update(start, end, content, options) {
|
|
773
593
|
start = start + this.offset;
|
|
774
594
|
end = end + this.offset;
|
|
775
|
-
|
|
776
|
-
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
|
777
|
-
|
|
595
|
+
if (typeof content !== "string") throw new TypeError("replacement content must be a string");
|
|
778
596
|
if (this.original.length !== 0) {
|
|
779
597
|
while (start < 0) start += this.original.length;
|
|
780
598
|
while (end < 0) end += this.original.length;
|
|
781
599
|
}
|
|
782
|
-
|
|
783
|
-
if (
|
|
784
|
-
if (start === end)
|
|
785
|
-
throw new Error(
|
|
786
|
-
'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
|
|
787
|
-
);
|
|
788
|
-
|
|
600
|
+
if (end > this.original.length) throw new Error("end is out of bounds");
|
|
601
|
+
if (start === end) throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");
|
|
789
602
|
this._split(start);
|
|
790
603
|
this._split(end);
|
|
791
|
-
|
|
792
604
|
if (options === true) {
|
|
793
605
|
if (!warned.storeName) {
|
|
794
|
-
console.warn(
|
|
795
|
-
'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
|
|
796
|
-
);
|
|
606
|
+
console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string");
|
|
797
607
|
warned.storeName = true;
|
|
798
608
|
}
|
|
799
|
-
|
|
800
609
|
options = { storeName: true };
|
|
801
610
|
}
|
|
802
|
-
const storeName = options !==
|
|
803
|
-
const overwrite = options !==
|
|
804
|
-
|
|
611
|
+
const storeName = options !== void 0 ? options.storeName : false;
|
|
612
|
+
const overwrite = options !== void 0 ? options.overwrite : false;
|
|
805
613
|
if (storeName) {
|
|
806
614
|
const original = this.original.slice(start, end);
|
|
807
615
|
Object.defineProperty(this.storedNames, original, {
|
|
808
616
|
writable: true,
|
|
809
617
|
value: true,
|
|
810
|
-
enumerable: true
|
|
618
|
+
enumerable: true
|
|
811
619
|
});
|
|
812
620
|
}
|
|
813
|
-
|
|
814
621
|
const first = this.byStart[start];
|
|
815
622
|
const last = this.byEnd[end];
|
|
816
|
-
|
|
817
623
|
if (first) {
|
|
818
624
|
let chunk = first;
|
|
819
625
|
while (chunk !== last) {
|
|
820
|
-
if (chunk.next !== this.byStart[chunk.end])
|
|
821
|
-
throw new Error('Cannot overwrite across a split point');
|
|
822
|
-
}
|
|
626
|
+
if (chunk.next !== this.byStart[chunk.end]) throw new Error("Cannot overwrite across a split point");
|
|
823
627
|
chunk = chunk.next;
|
|
824
|
-
chunk.edit(
|
|
628
|
+
chunk.edit("", false);
|
|
825
629
|
}
|
|
826
|
-
|
|
827
630
|
first.edit(content, storeName, !overwrite);
|
|
828
631
|
} else {
|
|
829
|
-
|
|
830
|
-
const newChunk = new Chunk(start, end, '').edit(content, storeName);
|
|
831
|
-
|
|
832
|
-
// TODO last chunk in the array may not be the last chunk, if it's moved...
|
|
632
|
+
const newChunk = new Chunk(start, end, "").edit(content, storeName);
|
|
833
633
|
last.next = newChunk;
|
|
834
634
|
newChunk.previous = last;
|
|
835
635
|
}
|
|
836
636
|
return this;
|
|
837
637
|
}
|
|
838
|
-
|
|
839
638
|
prepend(content) {
|
|
840
|
-
if (typeof content !==
|
|
841
|
-
|
|
639
|
+
if (typeof content !== "string") throw new TypeError("outro content must be a string");
|
|
842
640
|
this.intro = content + this.intro;
|
|
843
641
|
return this;
|
|
844
642
|
}
|
|
845
|
-
|
|
846
643
|
prependLeft(index, content) {
|
|
847
644
|
index = index + this.offset;
|
|
848
|
-
|
|
849
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
850
|
-
|
|
645
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
851
646
|
this._split(index);
|
|
852
|
-
|
|
853
647
|
const chunk = this.byEnd[index];
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
chunk.prependLeft(content);
|
|
857
|
-
} else {
|
|
858
|
-
this.intro = content + this.intro;
|
|
859
|
-
}
|
|
648
|
+
if (chunk) chunk.prependLeft(content);
|
|
649
|
+
else this.intro = content + this.intro;
|
|
860
650
|
return this;
|
|
861
651
|
}
|
|
862
|
-
|
|
863
652
|
prependRight(index, content) {
|
|
864
653
|
index = index + this.offset;
|
|
865
|
-
|
|
866
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
867
|
-
|
|
654
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
868
655
|
this._split(index);
|
|
869
|
-
|
|
870
656
|
const chunk = this.byStart[index];
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
chunk.prependRight(content);
|
|
874
|
-
} else {
|
|
875
|
-
this.outro = content + this.outro;
|
|
876
|
-
}
|
|
657
|
+
if (chunk) chunk.prependRight(content);
|
|
658
|
+
else this.outro = content + this.outro;
|
|
877
659
|
return this;
|
|
878
660
|
}
|
|
879
|
-
|
|
880
661
|
remove(start, end) {
|
|
881
662
|
start = start + this.offset;
|
|
882
663
|
end = end + this.offset;
|
|
883
|
-
|
|
884
664
|
if (this.original.length !== 0) {
|
|
885
665
|
while (start < 0) start += this.original.length;
|
|
886
666
|
while (end < 0) end += this.original.length;
|
|
887
667
|
}
|
|
888
|
-
|
|
889
668
|
if (start === end) return this;
|
|
890
|
-
|
|
891
|
-
if (start
|
|
892
|
-
if (start > end) throw new Error('end must be greater than start');
|
|
893
|
-
|
|
669
|
+
if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
|
|
670
|
+
if (start > end) throw new Error("end must be greater than start");
|
|
894
671
|
this._split(start);
|
|
895
672
|
this._split(end);
|
|
896
|
-
|
|
897
673
|
let chunk = this.byStart[start];
|
|
898
|
-
|
|
899
674
|
while (chunk) {
|
|
900
|
-
chunk.intro =
|
|
901
|
-
chunk.outro =
|
|
902
|
-
chunk.edit(
|
|
903
|
-
|
|
675
|
+
chunk.intro = "";
|
|
676
|
+
chunk.outro = "";
|
|
677
|
+
chunk.edit("");
|
|
904
678
|
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
905
679
|
}
|
|
906
680
|
return this;
|
|
907
681
|
}
|
|
908
|
-
|
|
909
682
|
reset(start, end) {
|
|
910
683
|
start = start + this.offset;
|
|
911
684
|
end = end + this.offset;
|
|
912
|
-
|
|
913
685
|
if (this.original.length !== 0) {
|
|
914
686
|
while (start < 0) start += this.original.length;
|
|
915
687
|
while (end < 0) end += this.original.length;
|
|
916
688
|
}
|
|
917
|
-
|
|
918
689
|
if (start === end) return this;
|
|
919
|
-
|
|
920
|
-
if (start
|
|
921
|
-
if (start > end) throw new Error('end must be greater than start');
|
|
922
|
-
|
|
690
|
+
if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
|
|
691
|
+
if (start > end) throw new Error("end must be greater than start");
|
|
923
692
|
this._split(start);
|
|
924
693
|
this._split(end);
|
|
925
|
-
|
|
926
694
|
let chunk = this.byStart[start];
|
|
927
|
-
|
|
928
695
|
while (chunk) {
|
|
929
696
|
chunk.reset();
|
|
930
|
-
|
|
931
697
|
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
932
698
|
}
|
|
933
699
|
return this;
|
|
934
700
|
}
|
|
935
|
-
|
|
936
701
|
lastChar() {
|
|
937
702
|
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
938
703
|
let chunk = this.lastChunk;
|
|
@@ -940,11 +705,10 @@ class MagicString {
|
|
|
940
705
|
if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
|
|
941
706
|
if (chunk.content.length) return chunk.content[chunk.content.length - 1];
|
|
942
707
|
if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
|
|
943
|
-
} while (
|
|
708
|
+
} while (chunk = chunk.previous);
|
|
944
709
|
if (this.intro.length) return this.intro[this.intro.length - 1];
|
|
945
|
-
return
|
|
710
|
+
return "";
|
|
946
711
|
}
|
|
947
|
-
|
|
948
712
|
lastLine() {
|
|
949
713
|
let lineIndex = this.outro.lastIndexOf(n);
|
|
950
714
|
if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
|
|
@@ -956,341 +720,220 @@ class MagicString {
|
|
|
956
720
|
if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
957
721
|
lineStr = chunk.outro + lineStr;
|
|
958
722
|
}
|
|
959
|
-
|
|
960
723
|
if (chunk.content.length > 0) {
|
|
961
724
|
lineIndex = chunk.content.lastIndexOf(n);
|
|
962
725
|
if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
|
|
963
726
|
lineStr = chunk.content + lineStr;
|
|
964
727
|
}
|
|
965
|
-
|
|
966
728
|
if (chunk.intro.length > 0) {
|
|
967
729
|
lineIndex = chunk.intro.lastIndexOf(n);
|
|
968
730
|
if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
969
731
|
lineStr = chunk.intro + lineStr;
|
|
970
732
|
}
|
|
971
|
-
} while (
|
|
733
|
+
} while (chunk = chunk.previous);
|
|
972
734
|
lineIndex = this.intro.lastIndexOf(n);
|
|
973
735
|
if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
|
|
974
736
|
return this.intro + lineStr;
|
|
975
737
|
}
|
|
976
|
-
|
|
977
738
|
slice(start = 0, end = this.original.length - this.offset) {
|
|
978
739
|
start = start + this.offset;
|
|
979
740
|
end = end + this.offset;
|
|
980
|
-
|
|
981
741
|
if (this.original.length !== 0) {
|
|
982
742
|
while (start < 0) start += this.original.length;
|
|
983
743
|
while (end < 0) end += this.original.length;
|
|
984
744
|
}
|
|
985
|
-
|
|
986
|
-
let result = '';
|
|
987
|
-
|
|
988
|
-
// find start chunk
|
|
745
|
+
let result = "";
|
|
989
746
|
let chunk = this.firstChunk;
|
|
990
747
|
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
991
|
-
|
|
992
|
-
if (chunk.start < end && chunk.end >= end) {
|
|
993
|
-
return result;
|
|
994
|
-
}
|
|
995
|
-
|
|
748
|
+
if (chunk.start < end && chunk.end >= end) return result;
|
|
996
749
|
chunk = chunk.next;
|
|
997
750
|
}
|
|
998
|
-
|
|
999
|
-
if (chunk && chunk.edited && chunk.start !== start)
|
|
1000
|
-
throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
1001
|
-
|
|
751
|
+
if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
1002
752
|
const startChunk = chunk;
|
|
1003
753
|
while (chunk) {
|
|
1004
|
-
if (chunk.intro && (startChunk !== chunk || chunk.start === start))
|
|
1005
|
-
result += chunk.intro;
|
|
1006
|
-
}
|
|
1007
|
-
|
|
754
|
+
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
|
|
1008
755
|
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
1009
|
-
if (containsEnd && chunk.edited && chunk.end !== end)
|
|
1010
|
-
throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
1011
|
-
|
|
756
|
+
if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
1012
757
|
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
1013
758
|
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
1014
|
-
|
|
1015
759
|
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
1016
|
-
|
|
1017
|
-
if (
|
|
1018
|
-
result += chunk.outro;
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
if (containsEnd) {
|
|
1022
|
-
break;
|
|
1023
|
-
}
|
|
1024
|
-
|
|
760
|
+
if (chunk.outro && (!containsEnd || chunk.end === end)) result += chunk.outro;
|
|
761
|
+
if (containsEnd) break;
|
|
1025
762
|
chunk = chunk.next;
|
|
1026
763
|
}
|
|
1027
|
-
|
|
1028
764
|
return result;
|
|
1029
765
|
}
|
|
1030
|
-
|
|
1031
|
-
// TODO deprecate this? not really very useful
|
|
1032
766
|
snip(start, end) {
|
|
1033
767
|
const clone = this.clone();
|
|
1034
768
|
clone.remove(0, start);
|
|
1035
769
|
clone.remove(end, clone.original.length);
|
|
1036
|
-
|
|
1037
770
|
return clone;
|
|
1038
771
|
}
|
|
1039
|
-
|
|
1040
772
|
_split(index) {
|
|
1041
773
|
if (this.byStart[index] || this.byEnd[index]) return;
|
|
1042
|
-
|
|
1043
774
|
let chunk = this.lastSearchedChunk;
|
|
1044
775
|
let previousChunk = chunk;
|
|
1045
776
|
const searchForward = index > chunk.end;
|
|
1046
|
-
|
|
1047
777
|
while (chunk) {
|
|
1048
778
|
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
1049
|
-
|
|
1050
779
|
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
1051
|
-
|
|
1052
|
-
// Prevent infinite loop (e.g. via empty chunks, where start === end)
|
|
1053
780
|
if (chunk === previousChunk) return;
|
|
1054
|
-
|
|
1055
781
|
previousChunk = chunk;
|
|
1056
782
|
}
|
|
1057
783
|
}
|
|
1058
|
-
|
|
1059
784
|
_splitChunk(chunk, index) {
|
|
1060
785
|
if (chunk.edited && chunk.content.length) {
|
|
1061
|
-
// zero-length edited chunks are a special case (overlapping replacements)
|
|
1062
786
|
const loc = getLocator(this.original)(index);
|
|
1063
|
-
throw new Error(
|
|
1064
|
-
`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
|
|
1065
|
-
);
|
|
787
|
+
throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
|
|
1066
788
|
}
|
|
1067
|
-
|
|
1068
789
|
const newChunk = chunk.split(index);
|
|
1069
|
-
|
|
1070
790
|
this.byEnd[index] = chunk;
|
|
1071
791
|
this.byStart[index] = newChunk;
|
|
1072
792
|
this.byEnd[newChunk.end] = newChunk;
|
|
1073
|
-
|
|
1074
793
|
if (chunk === this.lastChunk) this.lastChunk = newChunk;
|
|
1075
|
-
|
|
1076
794
|
this.lastSearchedChunk = chunk;
|
|
1077
795
|
return true;
|
|
1078
796
|
}
|
|
1079
|
-
|
|
1080
797
|
toString() {
|
|
1081
798
|
let str = this.intro;
|
|
1082
|
-
|
|
1083
799
|
let chunk = this.firstChunk;
|
|
1084
800
|
while (chunk) {
|
|
1085
801
|
str += chunk.toString();
|
|
1086
802
|
chunk = chunk.next;
|
|
1087
803
|
}
|
|
1088
|
-
|
|
1089
804
|
return str + this.outro;
|
|
1090
805
|
}
|
|
1091
|
-
|
|
1092
806
|
isEmpty() {
|
|
1093
807
|
let chunk = this.firstChunk;
|
|
1094
|
-
do
|
|
1095
|
-
if (
|
|
1096
|
-
|
|
1097
|
-
(chunk.content.length && chunk.content.trim()) ||
|
|
1098
|
-
(chunk.outro.length && chunk.outro.trim())
|
|
1099
|
-
)
|
|
1100
|
-
return false;
|
|
1101
|
-
} while ((chunk = chunk.next));
|
|
808
|
+
do
|
|
809
|
+
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
|
|
810
|
+
while (chunk = chunk.next);
|
|
1102
811
|
return true;
|
|
1103
812
|
}
|
|
1104
|
-
|
|
1105
813
|
length() {
|
|
1106
814
|
let chunk = this.firstChunk;
|
|
1107
815
|
let length = 0;
|
|
1108
|
-
do
|
|
816
|
+
do
|
|
1109
817
|
length += chunk.intro.length + chunk.content.length + chunk.outro.length;
|
|
1110
|
-
|
|
818
|
+
while (chunk = chunk.next);
|
|
1111
819
|
return length;
|
|
1112
820
|
}
|
|
1113
|
-
|
|
1114
821
|
trimLines() {
|
|
1115
|
-
return this.trim(
|
|
822
|
+
return this.trim("[\\r\\n]");
|
|
1116
823
|
}
|
|
1117
|
-
|
|
1118
824
|
trim(charType) {
|
|
1119
825
|
return this.trimStart(charType).trimEnd(charType);
|
|
1120
826
|
}
|
|
1121
|
-
|
|
1122
827
|
trimEndAborted(charType) {
|
|
1123
|
-
const rx = new RegExp((charType ||
|
|
1124
|
-
|
|
1125
|
-
this.outro = this.outro.replace(rx, '');
|
|
828
|
+
const rx = /* @__PURE__ */ new RegExp((charType || "\\s") + "+$");
|
|
829
|
+
this.outro = this.outro.replace(rx, "");
|
|
1126
830
|
if (this.outro.length) return true;
|
|
1127
|
-
|
|
1128
831
|
let chunk = this.lastChunk;
|
|
1129
|
-
|
|
1130
832
|
do {
|
|
1131
833
|
const end = chunk.end;
|
|
1132
834
|
const aborted = chunk.trimEnd(rx);
|
|
1133
|
-
|
|
1134
|
-
// if chunk was trimmed, we have a new lastChunk
|
|
1135
835
|
if (chunk.end !== end) {
|
|
1136
|
-
if (this.lastChunk === chunk)
|
|
1137
|
-
this.lastChunk = chunk.next;
|
|
1138
|
-
}
|
|
1139
|
-
|
|
836
|
+
if (this.lastChunk === chunk) this.lastChunk = chunk.next;
|
|
1140
837
|
this.byEnd[chunk.end] = chunk;
|
|
1141
838
|
this.byStart[chunk.next.start] = chunk.next;
|
|
1142
839
|
this.byEnd[chunk.next.end] = chunk.next;
|
|
1143
840
|
}
|
|
1144
|
-
|
|
1145
841
|
if (aborted) return true;
|
|
1146
842
|
chunk = chunk.previous;
|
|
1147
843
|
} while (chunk);
|
|
1148
|
-
|
|
1149
844
|
return false;
|
|
1150
845
|
}
|
|
1151
|
-
|
|
1152
846
|
trimEnd(charType) {
|
|
1153
847
|
this.trimEndAborted(charType);
|
|
1154
848
|
return this;
|
|
1155
849
|
}
|
|
1156
850
|
trimStartAborted(charType) {
|
|
1157
|
-
const rx = new RegExp(
|
|
1158
|
-
|
|
1159
|
-
this.intro = this.intro.replace(rx, '');
|
|
851
|
+
const rx = /* @__PURE__ */ new RegExp("^" + (charType || "\\s") + "+");
|
|
852
|
+
this.intro = this.intro.replace(rx, "");
|
|
1160
853
|
if (this.intro.length) return true;
|
|
1161
|
-
|
|
1162
854
|
let chunk = this.firstChunk;
|
|
1163
|
-
|
|
1164
855
|
do {
|
|
1165
856
|
const end = chunk.end;
|
|
1166
857
|
const aborted = chunk.trimStart(rx);
|
|
1167
|
-
|
|
1168
858
|
if (chunk.end !== end) {
|
|
1169
|
-
// special case...
|
|
1170
859
|
if (chunk === this.lastChunk) this.lastChunk = chunk.next;
|
|
1171
|
-
|
|
1172
860
|
this.byEnd[chunk.end] = chunk;
|
|
1173
861
|
this.byStart[chunk.next.start] = chunk.next;
|
|
1174
862
|
this.byEnd[chunk.next.end] = chunk.next;
|
|
1175
863
|
}
|
|
1176
|
-
|
|
1177
864
|
if (aborted) return true;
|
|
1178
865
|
chunk = chunk.next;
|
|
1179
866
|
} while (chunk);
|
|
1180
|
-
|
|
1181
867
|
return false;
|
|
1182
868
|
}
|
|
1183
|
-
|
|
1184
869
|
trimStart(charType) {
|
|
1185
870
|
this.trimStartAborted(charType);
|
|
1186
871
|
return this;
|
|
1187
872
|
}
|
|
1188
|
-
|
|
1189
873
|
hasChanged() {
|
|
1190
874
|
return this.original !== this.toString();
|
|
1191
875
|
}
|
|
1192
|
-
|
|
1193
876
|
_replaceRegexp(searchValue, replacement) {
|
|
1194
877
|
function getReplacement(match, str) {
|
|
1195
|
-
if (typeof replacement ===
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
return `$${i}`;
|
|
1203
|
-
});
|
|
1204
|
-
} else {
|
|
1205
|
-
return replacement(...match, match.index, str, match.groups);
|
|
1206
|
-
}
|
|
878
|
+
if (typeof replacement === "string") return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
879
|
+
if (i === "$") return "$";
|
|
880
|
+
if (i === "&") return match[0];
|
|
881
|
+
if (+i < match.length) return match[+i];
|
|
882
|
+
return `$${i}`;
|
|
883
|
+
});
|
|
884
|
+
else return replacement(...match, match.index, str, match.groups);
|
|
1207
885
|
}
|
|
1208
886
|
function matchAll(re, str) {
|
|
1209
887
|
let match;
|
|
1210
888
|
const matches = [];
|
|
1211
|
-
while (
|
|
1212
|
-
matches.push(match);
|
|
1213
|
-
}
|
|
889
|
+
while (match = re.exec(str)) matches.push(match);
|
|
1214
890
|
return matches;
|
|
1215
891
|
}
|
|
1216
|
-
if (searchValue.global) {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
if (match.index
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
});
|
|
1226
|
-
} else {
|
|
892
|
+
if (searchValue.global) matchAll(searchValue, this.original).forEach((match) => {
|
|
893
|
+
if (match.index != null) {
|
|
894
|
+
const replacement$1 = getReplacement(match, this.original);
|
|
895
|
+
if (replacement$1 !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement$1);
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
else {
|
|
1227
899
|
const match = this.original.match(searchValue);
|
|
1228
900
|
if (match && match.index != null) {
|
|
1229
|
-
const replacement = getReplacement(match, this.original);
|
|
1230
|
-
if (replacement !== match[0])
|
|
1231
|
-
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1232
|
-
}
|
|
901
|
+
const replacement$1 = getReplacement(match, this.original);
|
|
902
|
+
if (replacement$1 !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement$1);
|
|
1233
903
|
}
|
|
1234
904
|
}
|
|
1235
905
|
return this;
|
|
1236
906
|
}
|
|
1237
|
-
|
|
1238
907
|
_replaceString(string, replacement) {
|
|
1239
908
|
const { original } = this;
|
|
1240
909
|
const index = original.indexOf(string);
|
|
1241
|
-
|
|
1242
910
|
if (index !== -1) {
|
|
1243
|
-
if (typeof replacement ===
|
|
1244
|
-
|
|
1245
|
-
}
|
|
1246
|
-
if (string !== replacement) {
|
|
1247
|
-
this.overwrite(index, index + string.length, replacement);
|
|
1248
|
-
}
|
|
911
|
+
if (typeof replacement === "function") replacement = replacement(string, index, original);
|
|
912
|
+
if (string !== replacement) this.overwrite(index, index + string.length, replacement);
|
|
1249
913
|
}
|
|
1250
|
-
|
|
1251
914
|
return this;
|
|
1252
915
|
}
|
|
1253
|
-
|
|
1254
916
|
replace(searchValue, replacement) {
|
|
1255
|
-
if (typeof searchValue ===
|
|
1256
|
-
return this._replaceString(searchValue, replacement);
|
|
1257
|
-
}
|
|
1258
|
-
|
|
917
|
+
if (typeof searchValue === "string") return this._replaceString(searchValue, replacement);
|
|
1259
918
|
return this._replaceRegexp(searchValue, replacement);
|
|
1260
919
|
}
|
|
1261
|
-
|
|
1262
920
|
_replaceAllString(string, replacement) {
|
|
1263
921
|
const { original } = this;
|
|
1264
922
|
const stringLength = string.length;
|
|
1265
|
-
for (
|
|
1266
|
-
let index = original.indexOf(string);
|
|
1267
|
-
index !== -1;
|
|
1268
|
-
index = original.indexOf(string, index + stringLength)
|
|
1269
|
-
) {
|
|
923
|
+
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
1270
924
|
const previous = original.slice(index, index + stringLength);
|
|
1271
925
|
let _replacement = replacement;
|
|
1272
|
-
if (typeof replacement ===
|
|
1273
|
-
_replacement = replacement(previous, index, original);
|
|
1274
|
-
}
|
|
926
|
+
if (typeof replacement === "function") _replacement = replacement(previous, index, original);
|
|
1275
927
|
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
1276
928
|
}
|
|
1277
|
-
|
|
1278
929
|
return this;
|
|
1279
930
|
}
|
|
1280
|
-
|
|
1281
931
|
replaceAll(searchValue, replacement) {
|
|
1282
|
-
if (typeof searchValue ===
|
|
1283
|
-
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
if (!searchValue.global) {
|
|
1287
|
-
throw new TypeError(
|
|
1288
|
-
'MagicString.prototype.replaceAll called with a non-global RegExp argument',
|
|
1289
|
-
);
|
|
1290
|
-
}
|
|
1291
|
-
|
|
932
|
+
if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
|
|
933
|
+
if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
|
|
1292
934
|
return this._replaceRegexp(searchValue, replacement);
|
|
1293
935
|
}
|
|
1294
|
-
}
|
|
936
|
+
};
|
|
1295
937
|
|
|
1296
|
-
|
|
938
|
+
//#endregion
|
|
939
|
+
export { MagicString as t };
|