@voidzero-dev/vite-plus-test 0.0.0-0bfcc90f.20260209-0731
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +691 -0
- package/browser/context.d.ts +4 -0
- package/browser/context.js +20 -0
- package/config.d.ts +3 -0
- package/coverage.d.ts +1 -0
- package/dist/@vitest/browser/client/.vite/manifest.json +24 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +57 -0
- package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/@vitest/browser/client/__vitest__/bg.png +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
- package/dist/@vitest/browser/client/__vitest__/favicon.svg +5 -0
- package/dist/@vitest/browser/client/__vitest__/index.html +32 -0
- package/dist/@vitest/browser/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
- package/dist/@vitest/browser/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
- package/dist/@vitest/browser/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
- package/dist/@vitest/browser/client/error-catcher.js +82 -0
- package/dist/@vitest/browser/client/esm-client-injector.js +67 -0
- package/dist/@vitest/browser/client/favicon.svg +5 -0
- package/dist/@vitest/browser/client/orchestrator.html +35 -0
- package/dist/@vitest/browser/client/tester/tester.html +13 -0
- package/dist/@vitest/browser/client.js +456 -0
- package/dist/@vitest/browser/context.d.ts +792 -0
- package/dist/@vitest/browser/context.js +541 -0
- package/dist/@vitest/browser/expect-element.js +32 -0
- package/dist/@vitest/browser/index-D6m36C6U.js +11 -0
- package/dist/@vitest/browser/index.d.ts +73 -0
- package/dist/@vitest/browser/index.js +3513 -0
- package/dist/@vitest/browser/jest-dom.d.ts +724 -0
- package/dist/@vitest/browser/locators.d.ts +354 -0
- package/dist/@vitest/browser/locators.js +1 -0
- package/dist/@vitest/browser/matchers.d.ts +29 -0
- package/dist/@vitest/browser/shared/screenshotMatcher/types.d.ts +22 -0
- package/dist/@vitest/browser/state.js +280 -0
- package/dist/@vitest/browser/types.d.ts +69 -0
- package/dist/@vitest/browser-playwright/context.d.ts +1 -0
- package/dist/@vitest/browser-playwright/index.d.ts +106 -0
- package/dist/@vitest/browser-playwright/index.js +1111 -0
- package/dist/@vitest/browser-playwright/locators.js +114 -0
- package/dist/@vitest/browser-preview/context.d.ts +1 -0
- package/dist/@vitest/browser-preview/index.d.ts +19 -0
- package/dist/@vitest/browser-preview/index.js +148 -0
- package/dist/@vitest/browser-preview/locators.js +79 -0
- package/dist/@vitest/browser-webdriverio/context.d.ts +1 -0
- package/dist/@vitest/browser-webdriverio/index.d.ts +63 -0
- package/dist/@vitest/browser-webdriverio/index.js +600 -0
- package/dist/@vitest/browser-webdriverio/locators.js +163 -0
- package/dist/@vitest/expect/index.d.ts +807 -0
- package/dist/@vitest/expect/index.js +1875 -0
- package/dist/@vitest/mocker/auto-register.d.ts +2 -0
- package/dist/@vitest/mocker/auto-register.js +9 -0
- package/dist/@vitest/mocker/automock.d.ts +12 -0
- package/dist/@vitest/mocker/automock.js +1 -0
- package/dist/@vitest/mocker/browser.d.ts +53 -0
- package/dist/@vitest/mocker/browser.js +91 -0
- package/dist/@vitest/mocker/chunk-automock.js +354 -0
- package/dist/@vitest/mocker/chunk-interceptor-native.js +15 -0
- package/dist/@vitest/mocker/chunk-mocker.js +521 -0
- package/dist/@vitest/mocker/chunk-pathe.M-eThtNZ.js +174 -0
- package/dist/@vitest/mocker/chunk-registry.js +185 -0
- package/dist/@vitest/mocker/chunk-utils.js +16 -0
- package/dist/@vitest/mocker/index.d-C-sLYZi-.d.ts +25 -0
- package/dist/@vitest/mocker/index.d.ts +2 -0
- package/dist/@vitest/mocker/index.js +185 -0
- package/dist/@vitest/mocker/mocker.d-TnKRhz7N.d.ts +81 -0
- package/dist/@vitest/mocker/node.d.ts +800 -0
- package/dist/@vitest/mocker/node.js +966 -0
- package/dist/@vitest/mocker/redirect.d.ts +3 -0
- package/dist/@vitest/mocker/redirect.js +79 -0
- package/dist/@vitest/mocker/register.d.ts +9 -0
- package/dist/@vitest/mocker/register.js +41 -0
- package/dist/@vitest/mocker/types.d-B8CCKmHt.d.ts +107 -0
- package/dist/@vitest/pretty-format/index.d.ts +124 -0
- package/dist/@vitest/pretty-format/index.js +1022 -0
- package/dist/@vitest/runner/chunk-tasks.js +340 -0
- package/dist/@vitest/runner/index.d.ts +180 -0
- package/dist/@vitest/runner/index.js +2114 -0
- package/dist/@vitest/runner/tasks.d-C7UxawJ9.d.ts +834 -0
- package/dist/@vitest/runner/types.d.ts +183 -0
- package/dist/@vitest/runner/types.js +1 -0
- package/dist/@vitest/runner/utils.d.ts +45 -0
- package/dist/@vitest/runner/utils.js +5 -0
- package/dist/@vitest/snapshot/environment.d-DHdQ1Csl.d.ts +22 -0
- package/dist/@vitest/snapshot/environment.d.ts +16 -0
- package/dist/@vitest/snapshot/environment.js +40 -0
- package/dist/@vitest/snapshot/index.d.ts +130 -0
- package/dist/@vitest/snapshot/index.js +1437 -0
- package/dist/@vitest/snapshot/manager.d.ts +18 -0
- package/dist/@vitest/snapshot/manager.js +73 -0
- package/dist/@vitest/snapshot/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
- package/dist/@vitest/spy/index.d.ts +384 -0
- package/dist/@vitest/spy/index.js +433 -0
- package/dist/@vitest/utils/chunk-_commonjsHelpers.js +5 -0
- package/dist/@vitest/utils/chunk-pathe.M-eThtNZ.js +156 -0
- package/dist/@vitest/utils/constants.d.ts +21 -0
- package/dist/@vitest/utils/constants.js +49 -0
- package/dist/@vitest/utils/diff.d.ts +93 -0
- package/dist/@vitest/utils/diff.js +2199 -0
- package/dist/@vitest/utils/display.d.ts +29 -0
- package/dist/@vitest/utils/display.js +742 -0
- package/dist/@vitest/utils/error.d.ts +7 -0
- package/dist/@vitest/utils/error.js +42 -0
- package/dist/@vitest/utils/helpers.d.ts +73 -0
- package/dist/@vitest/utils/helpers.js +295 -0
- package/dist/@vitest/utils/highlight.d.ts +9 -0
- package/dist/@vitest/utils/highlight.js +538 -0
- package/dist/@vitest/utils/index.d.ts +5 -0
- package/dist/@vitest/utils/index.js +1 -0
- package/dist/@vitest/utils/offset.d.ts +5 -0
- package/dist/@vitest/utils/offset.js +32 -0
- package/dist/@vitest/utils/resolver.d.ts +7 -0
- package/dist/@vitest/utils/resolver.js +71 -0
- package/dist/@vitest/utils/serialize.d.ts +3 -0
- package/dist/@vitest/utils/serialize.js +118 -0
- package/dist/@vitest/utils/source-map.d.ts +55 -0
- package/dist/@vitest/utils/source-map.js +478 -0
- package/dist/@vitest/utils/timers.d.ts +33 -0
- package/dist/@vitest/utils/timers.js +49 -0
- package/dist/@vitest/utils/types.d-BCElaP-c.d.ts +53 -0
- package/dist/@vitest/utils/types.d.ts +34 -0
- package/dist/@vitest/utils/types.js +1 -0
- package/dist/browser-compat.js +3 -0
- package/dist/browser.d.ts +46 -0
- package/dist/browser.js +20 -0
- package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
- package/dist/chunks/base.CJ0Y4ePK.js +165 -0
- package/dist/chunks/benchmark.B3N2zMcH.js +40 -0
- package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +24 -0
- package/dist/chunks/browser.d.ChKACdzH.d.ts +59 -0
- package/dist/chunks/cac.DVeoLl0M.js +1409 -0
- package/dist/chunks/cli-api.B7PN_QUv.js +13672 -0
- package/dist/chunks/config.d.Cy95HiCx.d.ts +210 -0
- package/dist/chunks/console.Cf-YriPC.js +146 -0
- package/dist/chunks/constants.D_Q9UYh-.js +36 -0
- package/dist/chunks/coverage.AVPTjMgw.js +3292 -0
- package/dist/chunks/coverage.D_JHT54q.js +25 -0
- package/dist/chunks/coverage.d.BZtK59WP.d.ts +37 -0
- package/dist/chunks/creator.DAmOKTvJ.js +673 -0
- package/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/dist/chunks/defaults.BOqNVLsY.js +74 -0
- package/dist/chunks/env.D4Lgay0q.js +8 -0
- package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
- package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
- package/dist/chunks/evaluatedModules.d.BxJ5omdx.d.ts +7 -0
- package/dist/chunks/git.Bm2pzPAa.js +71 -0
- package/dist/chunks/global.d.B15mdLcR.d.ts +99 -0
- package/dist/chunks/globals.DOayXfHP.js +30 -0
- package/dist/chunks/index.6Qv1eEA6.js +109 -0
- package/dist/chunks/index.C5r1PdPD.js +231 -0
- package/dist/chunks/index.Chj8NDwU.js +206 -0
- package/dist/chunks/index.CyBMJtT7.js +727 -0
- package/dist/chunks/index.D3XRDfWc.js +213 -0
- package/dist/chunks/index.D4KonVSU.js +6343 -0
- package/dist/chunks/index.M8mOzt4Y.js +3839 -0
- package/dist/chunks/index.Z5E_ObnR.js +37 -0
- package/dist/chunks/init-forks._y3TW739.js +41 -0
- package/dist/chunks/init-threads.DBO2kn-p.js +18 -0
- package/dist/chunks/init.B6MLFIaN.js +334 -0
- package/dist/chunks/inspector.CvyFGlXm.js +53 -0
- package/dist/chunks/modules.BJuCwlRJ.js +36 -0
- package/dist/chunks/node.Ce0vMQM7.js +14 -0
- package/dist/chunks/plugin.d.CtqpEehP.d.ts +38 -0
- package/dist/chunks/reporters.d.CWXNI2jG.d.ts +3271 -0
- package/dist/chunks/rpc.BoxB0q7B.js +76 -0
- package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
- package/dist/chunks/setup-common.Cm-kSBVi.js +60 -0
- package/dist/chunks/startModuleRunner.DEj0jb3e.js +861 -0
- package/dist/chunks/suite.d.BJWk38HB.d.ts +10 -0
- package/dist/chunks/test.B8ej_ZHS.js +254 -0
- package/dist/chunks/traces.CCmnQaNT.js +217 -0
- package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
- package/dist/chunks/utils.DvEY5TfP.js +52 -0
- package/dist/chunks/vi.2VT5v0um.js +3919 -0
- package/dist/chunks/vm.D3epNOPZ.js +744 -0
- package/dist/chunks/worker.d.Dyxm8DEL.d.ts +255 -0
- package/dist/cli.js +28 -0
- package/dist/client/.vite/manifest.json +24 -0
- package/dist/client/__vitest__/assets/index-BUCFJtth.js +57 -0
- package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/client/__vitest__/bg.png +0 -0
- package/dist/client/__vitest__/favicon.ico +0 -0
- package/dist/client/__vitest__/favicon.svg +5 -0
- package/dist/client/__vitest__/index.html +32 -0
- package/dist/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
- package/dist/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
- package/dist/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
- package/dist/client/error-catcher.js +82 -0
- package/dist/client/esm-client-injector.js +67 -0
- package/dist/client/favicon.svg +5 -0
- package/dist/client/orchestrator.html +35 -0
- package/dist/client/tester/tester.html +13 -0
- package/dist/client.js +456 -0
- package/dist/config.cjs +94 -0
- package/dist/config.d.ts +104 -0
- package/dist/config.js +15 -0
- package/dist/context.js +541 -0
- package/dist/coverage.d.ts +118 -0
- package/dist/coverage.js +23 -0
- package/dist/dummy.js +2 -0
- package/dist/environments.d.ts +22 -0
- package/dist/environments.js +3 -0
- package/dist/expect-element.js +27 -0
- package/dist/index-D6m36C6U.js +6 -0
- package/dist/index-node.js +7 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +19 -0
- package/dist/locators.d.ts +354 -0
- package/dist/locators.js +1 -0
- package/dist/mocker.d.ts +1 -0
- package/dist/mocker.js +1 -0
- package/dist/module-evaluator.d.ts +124 -0
- package/dist/module-evaluator.js +343 -0
- package/dist/module-runner-stub.js +44 -0
- package/dist/module-runner.js +17 -0
- package/dist/node.d.ts +251 -0
- package/dist/node.js +98 -0
- package/dist/path.js +7 -0
- package/dist/plugins/browser-client.mjs +2 -0
- package/dist/plugins/browser-context.mjs +2 -0
- package/dist/plugins/browser-locators.mjs +2 -0
- package/dist/plugins/browser-playwright.mjs +2 -0
- package/dist/plugins/browser-preview.mjs +2 -0
- package/dist/plugins/browser-webdriverio.mjs +2 -0
- package/dist/plugins/browser.mjs +2 -0
- package/dist/plugins/expect.mjs +2 -0
- package/dist/plugins/mocker-automock.mjs +2 -0
- package/dist/plugins/mocker-browser.mjs +2 -0
- package/dist/plugins/mocker-node.mjs +2 -0
- package/dist/plugins/mocker-redirect.mjs +2 -0
- package/dist/plugins/mocker-register.mjs +2 -0
- package/dist/plugins/mocker.mjs +2 -0
- package/dist/plugins/pretty-format.mjs +2 -0
- package/dist/plugins/runner-types.mjs +2 -0
- package/dist/plugins/runner-utils.mjs +2 -0
- package/dist/plugins/runner.mjs +2 -0
- package/dist/plugins/snapshot-environment.mjs +2 -0
- package/dist/plugins/snapshot-manager.mjs +2 -0
- package/dist/plugins/snapshot.mjs +2 -0
- package/dist/plugins/spy.mjs +2 -0
- package/dist/plugins/utils-constants.mjs +2 -0
- package/dist/plugins/utils-diff.mjs +2 -0
- package/dist/plugins/utils-display.mjs +2 -0
- package/dist/plugins/utils-error.mjs +2 -0
- package/dist/plugins/utils-helpers.mjs +2 -0
- package/dist/plugins/utils-highlight.mjs +2 -0
- package/dist/plugins/utils-offset.mjs +2 -0
- package/dist/plugins/utils-resolver.mjs +2 -0
- package/dist/plugins/utils-serialize.mjs +2 -0
- package/dist/plugins/utils-source-map.mjs +2 -0
- package/dist/plugins/utils-timers.mjs +2 -0
- package/dist/plugins/utils.mjs +2 -0
- package/dist/reporters.d.ts +27 -0
- package/dist/reporters.js +24 -0
- package/dist/runners.d.ts +50 -0
- package/dist/runners.js +19 -0
- package/dist/shared/screenshotMatcher/types.d.ts +22 -0
- package/dist/snapshot.d.ts +9 -0
- package/dist/snapshot.js +4 -0
- package/dist/spy.js +1 -0
- package/dist/state.js +280 -0
- package/dist/suite.d.ts +5 -0
- package/dist/suite.js +6 -0
- package/dist/types.d.ts +69 -0
- package/dist/vendor/chai.d.mts +1 -0
- package/dist/vendor/chai.mjs +3577 -0
- package/dist/vendor/es-module-lexer.d.mts +193 -0
- package/dist/vendor/es-module-lexer.mjs +79 -0
- package/dist/vendor/estree-walker.d.mts +583 -0
- package/dist/vendor/estree-walker.mjs +339 -0
- package/dist/vendor/expect-type.d.mts +1574 -0
- package/dist/vendor/expect-type.mjs +214 -0
- package/dist/vendor/magic-string.d.mts +261 -0
- package/dist/vendor/magic-string.mjs +1700 -0
- package/dist/vendor/obug.d.mts +56 -0
- package/dist/vendor/obug.mjs +276 -0
- package/dist/vendor/pathe.d.mts +46 -0
- package/dist/vendor/pathe.mjs +496 -0
- package/dist/vendor/picomatch.d.mts +1 -0
- package/dist/vendor/picomatch.mjs +1855 -0
- package/dist/vendor/shared-3g9mwCWP.mjs +31 -0
- package/dist/vendor/std-env.d.mts +88 -0
- package/dist/vendor/std-env.mjs +159 -0
- package/dist/vendor/tinybench.d.mts +317 -0
- package/dist/vendor/tinybench.mjs +504 -0
- package/dist/vendor/tinyexec.d.mts +72 -0
- package/dist/vendor/tinyexec.mjs +637 -0
- package/dist/vendor/tinyglobby.d.mts +157 -0
- package/dist/vendor/tinyglobby.mjs +832 -0
- package/dist/vendor/tinyrainbow.d.mts +60 -0
- package/dist/vendor/tinyrainbow.mjs +93 -0
- package/dist/vendor/vitest_browser.mjs +2 -0
- package/dist/vendor/vitest_internal_browser.mjs +2 -0
- package/dist/vendor/vitest_runner.mjs +2 -0
- package/dist/vendor/vitest_runners.mjs +2 -0
- package/dist/worker.d.ts +32 -0
- package/dist/worker.js +48 -0
- package/dist/workers/forks.js +54 -0
- package/dist/workers/runVmTests.js +95 -0
- package/dist/workers/threads.js +55 -0
- package/dist/workers/vmForks.js +36 -0
- package/dist/workers/vmThreads.js +37 -0
- package/environments.d.ts +1 -0
- package/globals.d.ts +20 -0
- package/import-meta.d.ts +5 -0
- package/importMeta.d.ts +4 -0
- package/index.cjs +5 -0
- package/index.d.cts +1 -0
- package/jsdom.d.ts +6 -0
- package/mocker.d.ts +1 -0
- package/node.d.ts +1 -0
- package/optional-types.d.ts +7 -0
- package/package.json +335 -0
- package/reporters.d.ts +1 -0
- package/runners.d.ts +1 -0
- package/snapshot.d.ts +1 -0
- package/suite.d.ts +1 -0
- package/suppress-warnings.cjs +21 -0
- package/vitest.mjs +2 -0
- package/worker.d.ts +1 -0
|
@@ -0,0 +1,1700 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
2
|
+
var comma = ",".charCodeAt(0);
|
|
3
|
+
var semicolon = ";".charCodeAt(0);
|
|
4
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
5
|
+
var intToChar = new Uint8Array(64);
|
|
6
|
+
var charToInt = new Uint8Array(128);
|
|
7
|
+
for (let i = 0; i < chars.length; i++) {
|
|
8
|
+
const c = chars.charCodeAt(i);
|
|
9
|
+
intToChar[i] = c;
|
|
10
|
+
charToInt[c] = i;
|
|
11
|
+
}
|
|
12
|
+
function decodeInteger(reader, relative) {
|
|
13
|
+
let value = 0;
|
|
14
|
+
let shift = 0;
|
|
15
|
+
let integer = 0;
|
|
16
|
+
do {
|
|
17
|
+
const c = reader.next();
|
|
18
|
+
integer = charToInt[c];
|
|
19
|
+
value |= (integer & 31) << shift;
|
|
20
|
+
shift += 5;
|
|
21
|
+
} while (integer & 32);
|
|
22
|
+
const shouldNegate = value & 1;
|
|
23
|
+
value >>>= 1;
|
|
24
|
+
if (shouldNegate) {
|
|
25
|
+
value = -2147483648 | -value;
|
|
26
|
+
}
|
|
27
|
+
return relative + value;
|
|
28
|
+
}
|
|
29
|
+
function encodeInteger(builder, num, relative) {
|
|
30
|
+
let delta = num - relative;
|
|
31
|
+
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
32
|
+
do {
|
|
33
|
+
let clamped = delta & 31;
|
|
34
|
+
delta >>>= 5;
|
|
35
|
+
if (delta > 0) clamped |= 32;
|
|
36
|
+
builder.write(intToChar[clamped]);
|
|
37
|
+
} while (delta > 0);
|
|
38
|
+
return num;
|
|
39
|
+
}
|
|
40
|
+
function hasMoreVlq(reader, max) {
|
|
41
|
+
if (reader.pos >= max) return false;
|
|
42
|
+
return reader.peek() !== comma;
|
|
43
|
+
}
|
|
44
|
+
var bufLength = 1024 * 16;
|
|
45
|
+
var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { decode(buf) {
|
|
46
|
+
const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
47
|
+
return out.toString();
|
|
48
|
+
} } : { decode(buf) {
|
|
49
|
+
let out = "";
|
|
50
|
+
for (let i = 0; i < buf.length; i++) {
|
|
51
|
+
out += String.fromCharCode(buf[i]);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
} };
|
|
55
|
+
var StringWriter = class {
|
|
56
|
+
constructor() {
|
|
57
|
+
this.pos = 0;
|
|
58
|
+
this.out = "";
|
|
59
|
+
this.buffer = new Uint8Array(bufLength);
|
|
60
|
+
}
|
|
61
|
+
write(v) {
|
|
62
|
+
const { buffer } = this;
|
|
63
|
+
buffer[this.pos++] = v;
|
|
64
|
+
if (this.pos === bufLength) {
|
|
65
|
+
this.out += td.decode(buffer);
|
|
66
|
+
this.pos = 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
flush() {
|
|
70
|
+
const { buffer, out, pos } = this;
|
|
71
|
+
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var StringReader = class {
|
|
75
|
+
constructor(buffer) {
|
|
76
|
+
this.pos = 0;
|
|
77
|
+
this.buffer = buffer;
|
|
78
|
+
}
|
|
79
|
+
next() {
|
|
80
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
81
|
+
}
|
|
82
|
+
peek() {
|
|
83
|
+
return this.buffer.charCodeAt(this.pos);
|
|
84
|
+
}
|
|
85
|
+
indexOf(char) {
|
|
86
|
+
const { buffer, pos } = this;
|
|
87
|
+
const idx = buffer.indexOf(char, pos);
|
|
88
|
+
return idx === -1 ? buffer.length : idx;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var EMPTY = [];
|
|
92
|
+
function decodeOriginalScopes(input) {
|
|
93
|
+
const { length } = input;
|
|
94
|
+
const reader = new StringReader(input);
|
|
95
|
+
const scopes = [];
|
|
96
|
+
const stack = [];
|
|
97
|
+
let line = 0;
|
|
98
|
+
for (; reader.pos < length; reader.pos++) {
|
|
99
|
+
line = decodeInteger(reader, line);
|
|
100
|
+
const column = decodeInteger(reader, 0);
|
|
101
|
+
if (!hasMoreVlq(reader, length)) {
|
|
102
|
+
const last = stack.pop();
|
|
103
|
+
last[2] = line;
|
|
104
|
+
last[3] = column;
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const kind = decodeInteger(reader, 0);
|
|
108
|
+
const fields = decodeInteger(reader, 0);
|
|
109
|
+
const hasName = fields & 1;
|
|
110
|
+
const scope = hasName ? [
|
|
111
|
+
line,
|
|
112
|
+
column,
|
|
113
|
+
0,
|
|
114
|
+
0,
|
|
115
|
+
kind,
|
|
116
|
+
decodeInteger(reader, 0)
|
|
117
|
+
] : [
|
|
118
|
+
line,
|
|
119
|
+
column,
|
|
120
|
+
0,
|
|
121
|
+
0,
|
|
122
|
+
kind
|
|
123
|
+
];
|
|
124
|
+
let vars = EMPTY;
|
|
125
|
+
if (hasMoreVlq(reader, length)) {
|
|
126
|
+
vars = [];
|
|
127
|
+
do {
|
|
128
|
+
const varsIndex = decodeInteger(reader, 0);
|
|
129
|
+
vars.push(varsIndex);
|
|
130
|
+
} while (hasMoreVlq(reader, length));
|
|
131
|
+
}
|
|
132
|
+
scope.vars = vars;
|
|
133
|
+
scopes.push(scope);
|
|
134
|
+
stack.push(scope);
|
|
135
|
+
}
|
|
136
|
+
return scopes;
|
|
137
|
+
}
|
|
138
|
+
function encodeOriginalScopes(scopes) {
|
|
139
|
+
const writer = new StringWriter();
|
|
140
|
+
for (let i = 0; i < scopes.length;) {
|
|
141
|
+
i = _encodeOriginalScopes(scopes, i, writer, [0]);
|
|
142
|
+
}
|
|
143
|
+
return writer.flush();
|
|
144
|
+
}
|
|
145
|
+
function _encodeOriginalScopes(scopes, index, writer, state) {
|
|
146
|
+
const scope = scopes[index];
|
|
147
|
+
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, 4: kind, vars } = scope;
|
|
148
|
+
if (index > 0) writer.write(comma);
|
|
149
|
+
state[0] = encodeInteger(writer, startLine, state[0]);
|
|
150
|
+
encodeInteger(writer, startColumn, 0);
|
|
151
|
+
encodeInteger(writer, kind, 0);
|
|
152
|
+
const fields = scope.length === 6 ? 1 : 0;
|
|
153
|
+
encodeInteger(writer, fields, 0);
|
|
154
|
+
if (scope.length === 6) encodeInteger(writer, scope[5], 0);
|
|
155
|
+
for (const v of vars) {
|
|
156
|
+
encodeInteger(writer, v, 0);
|
|
157
|
+
}
|
|
158
|
+
for (index++; index < scopes.length;) {
|
|
159
|
+
const next = scopes[index];
|
|
160
|
+
const { 0: l, 1: c } = next;
|
|
161
|
+
if (l > endLine || l === endLine && c >= endColumn) {
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
index = _encodeOriginalScopes(scopes, index, writer, state);
|
|
165
|
+
}
|
|
166
|
+
writer.write(comma);
|
|
167
|
+
state[0] = encodeInteger(writer, endLine, state[0]);
|
|
168
|
+
encodeInteger(writer, endColumn, 0);
|
|
169
|
+
return index;
|
|
170
|
+
}
|
|
171
|
+
function decodeGeneratedRanges(input) {
|
|
172
|
+
const { length } = input;
|
|
173
|
+
const reader = new StringReader(input);
|
|
174
|
+
const ranges = [];
|
|
175
|
+
const stack = [];
|
|
176
|
+
let genLine = 0;
|
|
177
|
+
let definitionSourcesIndex = 0;
|
|
178
|
+
let definitionScopeIndex = 0;
|
|
179
|
+
let callsiteSourcesIndex = 0;
|
|
180
|
+
let callsiteLine = 0;
|
|
181
|
+
let callsiteColumn = 0;
|
|
182
|
+
let bindingLine = 0;
|
|
183
|
+
let bindingColumn = 0;
|
|
184
|
+
do {
|
|
185
|
+
const semi = reader.indexOf(";");
|
|
186
|
+
let genColumn = 0;
|
|
187
|
+
for (; reader.pos < semi; reader.pos++) {
|
|
188
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
189
|
+
if (!hasMoreVlq(reader, semi)) {
|
|
190
|
+
const last = stack.pop();
|
|
191
|
+
last[2] = genLine;
|
|
192
|
+
last[3] = genColumn;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const fields = decodeInteger(reader, 0);
|
|
196
|
+
const hasDefinition = fields & 1;
|
|
197
|
+
const hasCallsite = fields & 2;
|
|
198
|
+
const hasScope = fields & 4;
|
|
199
|
+
let callsite = null;
|
|
200
|
+
let bindings = EMPTY;
|
|
201
|
+
let range;
|
|
202
|
+
if (hasDefinition) {
|
|
203
|
+
const defSourcesIndex = decodeInteger(reader, definitionSourcesIndex);
|
|
204
|
+
definitionScopeIndex = decodeInteger(reader, definitionSourcesIndex === defSourcesIndex ? definitionScopeIndex : 0);
|
|
205
|
+
definitionSourcesIndex = defSourcesIndex;
|
|
206
|
+
range = [
|
|
207
|
+
genLine,
|
|
208
|
+
genColumn,
|
|
209
|
+
0,
|
|
210
|
+
0,
|
|
211
|
+
defSourcesIndex,
|
|
212
|
+
definitionScopeIndex
|
|
213
|
+
];
|
|
214
|
+
} else {
|
|
215
|
+
range = [
|
|
216
|
+
genLine,
|
|
217
|
+
genColumn,
|
|
218
|
+
0,
|
|
219
|
+
0
|
|
220
|
+
];
|
|
221
|
+
}
|
|
222
|
+
range.isScope = !!hasScope;
|
|
223
|
+
if (hasCallsite) {
|
|
224
|
+
const prevCsi = callsiteSourcesIndex;
|
|
225
|
+
const prevLine = callsiteLine;
|
|
226
|
+
callsiteSourcesIndex = decodeInteger(reader, callsiteSourcesIndex);
|
|
227
|
+
const sameSource = prevCsi === callsiteSourcesIndex;
|
|
228
|
+
callsiteLine = decodeInteger(reader, sameSource ? callsiteLine : 0);
|
|
229
|
+
callsiteColumn = decodeInteger(reader, sameSource && prevLine === callsiteLine ? callsiteColumn : 0);
|
|
230
|
+
callsite = [
|
|
231
|
+
callsiteSourcesIndex,
|
|
232
|
+
callsiteLine,
|
|
233
|
+
callsiteColumn
|
|
234
|
+
];
|
|
235
|
+
}
|
|
236
|
+
range.callsite = callsite;
|
|
237
|
+
if (hasMoreVlq(reader, semi)) {
|
|
238
|
+
bindings = [];
|
|
239
|
+
do {
|
|
240
|
+
bindingLine = genLine;
|
|
241
|
+
bindingColumn = genColumn;
|
|
242
|
+
const expressionsCount = decodeInteger(reader, 0);
|
|
243
|
+
let expressionRanges;
|
|
244
|
+
if (expressionsCount < -1) {
|
|
245
|
+
expressionRanges = [[decodeInteger(reader, 0)]];
|
|
246
|
+
for (let i = -1; i > expressionsCount; i--) {
|
|
247
|
+
const prevBl = bindingLine;
|
|
248
|
+
bindingLine = decodeInteger(reader, bindingLine);
|
|
249
|
+
bindingColumn = decodeInteger(reader, bindingLine === prevBl ? bindingColumn : 0);
|
|
250
|
+
const expression = decodeInteger(reader, 0);
|
|
251
|
+
expressionRanges.push([
|
|
252
|
+
expression,
|
|
253
|
+
bindingLine,
|
|
254
|
+
bindingColumn
|
|
255
|
+
]);
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
expressionRanges = [[expressionsCount]];
|
|
259
|
+
}
|
|
260
|
+
bindings.push(expressionRanges);
|
|
261
|
+
} while (hasMoreVlq(reader, semi));
|
|
262
|
+
}
|
|
263
|
+
range.bindings = bindings;
|
|
264
|
+
ranges.push(range);
|
|
265
|
+
stack.push(range);
|
|
266
|
+
}
|
|
267
|
+
genLine++;
|
|
268
|
+
reader.pos = semi + 1;
|
|
269
|
+
} while (reader.pos < length);
|
|
270
|
+
return ranges;
|
|
271
|
+
}
|
|
272
|
+
function encodeGeneratedRanges(ranges) {
|
|
273
|
+
if (ranges.length === 0) return "";
|
|
274
|
+
const writer = new StringWriter();
|
|
275
|
+
for (let i = 0; i < ranges.length;) {
|
|
276
|
+
i = _encodeGeneratedRanges(ranges, i, writer, [
|
|
277
|
+
0,
|
|
278
|
+
0,
|
|
279
|
+
0,
|
|
280
|
+
0,
|
|
281
|
+
0,
|
|
282
|
+
0,
|
|
283
|
+
0
|
|
284
|
+
]);
|
|
285
|
+
}
|
|
286
|
+
return writer.flush();
|
|
287
|
+
}
|
|
288
|
+
function _encodeGeneratedRanges(ranges, index, writer, state) {
|
|
289
|
+
const range = ranges[index];
|
|
290
|
+
const { 0: startLine, 1: startColumn, 2: endLine, 3: endColumn, isScope, callsite, bindings } = range;
|
|
291
|
+
if (state[0] < startLine) {
|
|
292
|
+
catchupLine(writer, state[0], startLine);
|
|
293
|
+
state[0] = startLine;
|
|
294
|
+
state[1] = 0;
|
|
295
|
+
} else if (index > 0) {
|
|
296
|
+
writer.write(comma);
|
|
297
|
+
}
|
|
298
|
+
state[1] = encodeInteger(writer, range[1], state[1]);
|
|
299
|
+
const fields = (range.length === 6 ? 1 : 0) | (callsite ? 2 : 0) | (isScope ? 4 : 0);
|
|
300
|
+
encodeInteger(writer, fields, 0);
|
|
301
|
+
if (range.length === 6) {
|
|
302
|
+
const { 4: sourcesIndex, 5: scopesIndex } = range;
|
|
303
|
+
if (sourcesIndex !== state[2]) {
|
|
304
|
+
state[3] = 0;
|
|
305
|
+
}
|
|
306
|
+
state[2] = encodeInteger(writer, sourcesIndex, state[2]);
|
|
307
|
+
state[3] = encodeInteger(writer, scopesIndex, state[3]);
|
|
308
|
+
}
|
|
309
|
+
if (callsite) {
|
|
310
|
+
const { 0: sourcesIndex, 1: callLine, 2: callColumn } = range.callsite;
|
|
311
|
+
if (sourcesIndex !== state[4]) {
|
|
312
|
+
state[5] = 0;
|
|
313
|
+
state[6] = 0;
|
|
314
|
+
} else if (callLine !== state[5]) {
|
|
315
|
+
state[6] = 0;
|
|
316
|
+
}
|
|
317
|
+
state[4] = encodeInteger(writer, sourcesIndex, state[4]);
|
|
318
|
+
state[5] = encodeInteger(writer, callLine, state[5]);
|
|
319
|
+
state[6] = encodeInteger(writer, callColumn, state[6]);
|
|
320
|
+
}
|
|
321
|
+
if (bindings) {
|
|
322
|
+
for (const binding of bindings) {
|
|
323
|
+
if (binding.length > 1) encodeInteger(writer, -binding.length, 0);
|
|
324
|
+
const expression = binding[0][0];
|
|
325
|
+
encodeInteger(writer, expression, 0);
|
|
326
|
+
let bindingStartLine = startLine;
|
|
327
|
+
let bindingStartColumn = startColumn;
|
|
328
|
+
for (let i = 1; i < binding.length; i++) {
|
|
329
|
+
const expRange = binding[i];
|
|
330
|
+
bindingStartLine = encodeInteger(writer, expRange[1], bindingStartLine);
|
|
331
|
+
bindingStartColumn = encodeInteger(writer, expRange[2], bindingStartColumn);
|
|
332
|
+
encodeInteger(writer, expRange[0], 0);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
for (index++; index < ranges.length;) {
|
|
337
|
+
const next = ranges[index];
|
|
338
|
+
const { 0: l, 1: c } = next;
|
|
339
|
+
if (l > endLine || l === endLine && c >= endColumn) {
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
index = _encodeGeneratedRanges(ranges, index, writer, state);
|
|
343
|
+
}
|
|
344
|
+
if (state[0] < endLine) {
|
|
345
|
+
catchupLine(writer, state[0], endLine);
|
|
346
|
+
state[0] = endLine;
|
|
347
|
+
state[1] = 0;
|
|
348
|
+
} else {
|
|
349
|
+
writer.write(comma);
|
|
350
|
+
}
|
|
351
|
+
state[1] = encodeInteger(writer, endColumn, state[1]);
|
|
352
|
+
return index;
|
|
353
|
+
}
|
|
354
|
+
function catchupLine(writer, lastLine, line) {
|
|
355
|
+
do {
|
|
356
|
+
writer.write(semicolon);
|
|
357
|
+
} while (++lastLine < line);
|
|
358
|
+
}
|
|
359
|
+
function decode(mappings) {
|
|
360
|
+
const { length } = mappings;
|
|
361
|
+
const reader = new StringReader(mappings);
|
|
362
|
+
const decoded = [];
|
|
363
|
+
let genColumn = 0;
|
|
364
|
+
let sourcesIndex = 0;
|
|
365
|
+
let sourceLine = 0;
|
|
366
|
+
let sourceColumn = 0;
|
|
367
|
+
let namesIndex = 0;
|
|
368
|
+
do {
|
|
369
|
+
const semi = reader.indexOf(";");
|
|
370
|
+
const line = [];
|
|
371
|
+
let sorted = true;
|
|
372
|
+
let lastCol = 0;
|
|
373
|
+
genColumn = 0;
|
|
374
|
+
while (reader.pos < semi) {
|
|
375
|
+
let seg;
|
|
376
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
377
|
+
if (genColumn < lastCol) sorted = false;
|
|
378
|
+
lastCol = genColumn;
|
|
379
|
+
if (hasMoreVlq(reader, semi)) {
|
|
380
|
+
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
381
|
+
sourceLine = decodeInteger(reader, sourceLine);
|
|
382
|
+
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
383
|
+
if (hasMoreVlq(reader, semi)) {
|
|
384
|
+
namesIndex = decodeInteger(reader, namesIndex);
|
|
385
|
+
seg = [
|
|
386
|
+
genColumn,
|
|
387
|
+
sourcesIndex,
|
|
388
|
+
sourceLine,
|
|
389
|
+
sourceColumn,
|
|
390
|
+
namesIndex
|
|
391
|
+
];
|
|
392
|
+
} else {
|
|
393
|
+
seg = [
|
|
394
|
+
genColumn,
|
|
395
|
+
sourcesIndex,
|
|
396
|
+
sourceLine,
|
|
397
|
+
sourceColumn
|
|
398
|
+
];
|
|
399
|
+
}
|
|
400
|
+
} else {
|
|
401
|
+
seg = [genColumn];
|
|
402
|
+
}
|
|
403
|
+
line.push(seg);
|
|
404
|
+
reader.pos++;
|
|
405
|
+
}
|
|
406
|
+
if (!sorted) sort(line);
|
|
407
|
+
decoded.push(line);
|
|
408
|
+
reader.pos = semi + 1;
|
|
409
|
+
} while (reader.pos <= length);
|
|
410
|
+
return decoded;
|
|
411
|
+
}
|
|
412
|
+
function sort(line) {
|
|
413
|
+
line.sort(sortComparator);
|
|
414
|
+
}
|
|
415
|
+
function sortComparator(a, b) {
|
|
416
|
+
return a[0] - b[0];
|
|
417
|
+
}
|
|
418
|
+
function encode(decoded) {
|
|
419
|
+
const writer = new StringWriter();
|
|
420
|
+
let sourcesIndex = 0;
|
|
421
|
+
let sourceLine = 0;
|
|
422
|
+
let sourceColumn = 0;
|
|
423
|
+
let namesIndex = 0;
|
|
424
|
+
for (let i = 0; i < decoded.length; i++) {
|
|
425
|
+
const line = decoded[i];
|
|
426
|
+
if (i > 0) writer.write(semicolon);
|
|
427
|
+
if (line.length === 0) continue;
|
|
428
|
+
let genColumn = 0;
|
|
429
|
+
for (let j = 0; j < line.length; j++) {
|
|
430
|
+
const segment = line[j];
|
|
431
|
+
if (j > 0) writer.write(comma);
|
|
432
|
+
genColumn = encodeInteger(writer, segment[0], genColumn);
|
|
433
|
+
if (segment.length === 1) continue;
|
|
434
|
+
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
|
435
|
+
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
|
436
|
+
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
|
437
|
+
if (segment.length === 4) continue;
|
|
438
|
+
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return writer.flush();
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region ../../node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs
|
|
446
|
+
var BitSet = class BitSet {
|
|
447
|
+
constructor(arg) {
|
|
448
|
+
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
449
|
+
}
|
|
450
|
+
add(n) {
|
|
451
|
+
this.bits[n >> 5] |= 1 << (n & 31);
|
|
452
|
+
}
|
|
453
|
+
has(n) {
|
|
454
|
+
return !!(this.bits[n >> 5] & 1 << (n & 31));
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
var Chunk = class Chunk {
|
|
458
|
+
constructor(start, end, content) {
|
|
459
|
+
this.start = start;
|
|
460
|
+
this.end = end;
|
|
461
|
+
this.original = content;
|
|
462
|
+
this.intro = "";
|
|
463
|
+
this.outro = "";
|
|
464
|
+
this.content = content;
|
|
465
|
+
this.storeName = false;
|
|
466
|
+
this.edited = false;
|
|
467
|
+
{
|
|
468
|
+
this.previous = null;
|
|
469
|
+
this.next = null;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
appendLeft(content) {
|
|
473
|
+
this.outro += content;
|
|
474
|
+
}
|
|
475
|
+
appendRight(content) {
|
|
476
|
+
this.intro = this.intro + content;
|
|
477
|
+
}
|
|
478
|
+
clone() {
|
|
479
|
+
const chunk = new Chunk(this.start, this.end, this.original);
|
|
480
|
+
chunk.intro = this.intro;
|
|
481
|
+
chunk.outro = this.outro;
|
|
482
|
+
chunk.content = this.content;
|
|
483
|
+
chunk.storeName = this.storeName;
|
|
484
|
+
chunk.edited = this.edited;
|
|
485
|
+
return chunk;
|
|
486
|
+
}
|
|
487
|
+
contains(index) {
|
|
488
|
+
return this.start < index && index < this.end;
|
|
489
|
+
}
|
|
490
|
+
eachNext(fn) {
|
|
491
|
+
let chunk = this;
|
|
492
|
+
while (chunk) {
|
|
493
|
+
fn(chunk);
|
|
494
|
+
chunk = chunk.next;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
eachPrevious(fn) {
|
|
498
|
+
let chunk = this;
|
|
499
|
+
while (chunk) {
|
|
500
|
+
fn(chunk);
|
|
501
|
+
chunk = chunk.previous;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
edit(content, storeName, contentOnly) {
|
|
505
|
+
this.content = content;
|
|
506
|
+
if (!contentOnly) {
|
|
507
|
+
this.intro = "";
|
|
508
|
+
this.outro = "";
|
|
509
|
+
}
|
|
510
|
+
this.storeName = storeName;
|
|
511
|
+
this.edited = true;
|
|
512
|
+
return this;
|
|
513
|
+
}
|
|
514
|
+
prependLeft(content) {
|
|
515
|
+
this.outro = content + this.outro;
|
|
516
|
+
}
|
|
517
|
+
prependRight(content) {
|
|
518
|
+
this.intro = content + this.intro;
|
|
519
|
+
}
|
|
520
|
+
reset() {
|
|
521
|
+
this.intro = "";
|
|
522
|
+
this.outro = "";
|
|
523
|
+
if (this.edited) {
|
|
524
|
+
this.content = this.original;
|
|
525
|
+
this.storeName = false;
|
|
526
|
+
this.edited = false;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
split(index) {
|
|
530
|
+
const sliceIndex = index - this.start;
|
|
531
|
+
const originalBefore = this.original.slice(0, sliceIndex);
|
|
532
|
+
const originalAfter = this.original.slice(sliceIndex);
|
|
533
|
+
this.original = originalBefore;
|
|
534
|
+
const newChunk = new Chunk(index, this.end, originalAfter);
|
|
535
|
+
newChunk.outro = this.outro;
|
|
536
|
+
this.outro = "";
|
|
537
|
+
this.end = index;
|
|
538
|
+
if (this.edited) {
|
|
539
|
+
newChunk.edit("", false);
|
|
540
|
+
this.content = "";
|
|
541
|
+
} else {
|
|
542
|
+
this.content = originalBefore;
|
|
543
|
+
}
|
|
544
|
+
newChunk.next = this.next;
|
|
545
|
+
if (newChunk.next) newChunk.next.previous = newChunk;
|
|
546
|
+
newChunk.previous = this;
|
|
547
|
+
this.next = newChunk;
|
|
548
|
+
return newChunk;
|
|
549
|
+
}
|
|
550
|
+
toString() {
|
|
551
|
+
return this.intro + this.content + this.outro;
|
|
552
|
+
}
|
|
553
|
+
trimEnd(rx) {
|
|
554
|
+
this.outro = this.outro.replace(rx, "");
|
|
555
|
+
if (this.outro.length) return true;
|
|
556
|
+
const trimmed = this.content.replace(rx, "");
|
|
557
|
+
if (trimmed.length) {
|
|
558
|
+
if (trimmed !== this.content) {
|
|
559
|
+
this.split(this.start + trimmed.length).edit("", undefined, true);
|
|
560
|
+
if (this.edited) {
|
|
561
|
+
this.edit(trimmed, this.storeName, true);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return true;
|
|
565
|
+
} else {
|
|
566
|
+
this.edit("", undefined, true);
|
|
567
|
+
this.intro = this.intro.replace(rx, "");
|
|
568
|
+
if (this.intro.length) return true;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
trimStart(rx) {
|
|
572
|
+
this.intro = this.intro.replace(rx, "");
|
|
573
|
+
if (this.intro.length) return true;
|
|
574
|
+
const trimmed = this.content.replace(rx, "");
|
|
575
|
+
if (trimmed.length) {
|
|
576
|
+
if (trimmed !== this.content) {
|
|
577
|
+
const newChunk = this.split(this.end - trimmed.length);
|
|
578
|
+
if (this.edited) {
|
|
579
|
+
newChunk.edit(trimmed, this.storeName, true);
|
|
580
|
+
}
|
|
581
|
+
this.edit("", undefined, true);
|
|
582
|
+
}
|
|
583
|
+
return true;
|
|
584
|
+
} else {
|
|
585
|
+
this.edit("", undefined, true);
|
|
586
|
+
this.outro = this.outro.replace(rx, "");
|
|
587
|
+
if (this.outro.length) return true;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
function getBtoa() {
|
|
592
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") {
|
|
593
|
+
return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
594
|
+
} else if (typeof Buffer === "function") {
|
|
595
|
+
return (str) => Buffer.from(str, "utf-8").toString("base64");
|
|
596
|
+
} else {
|
|
597
|
+
return () => {
|
|
598
|
+
throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
const btoa = /* @__PURE__ */ getBtoa();
|
|
603
|
+
var SourceMap = class {
|
|
604
|
+
constructor(properties) {
|
|
605
|
+
this.version = 3;
|
|
606
|
+
this.file = properties.file;
|
|
607
|
+
this.sources = properties.sources;
|
|
608
|
+
this.sourcesContent = properties.sourcesContent;
|
|
609
|
+
this.names = properties.names;
|
|
610
|
+
this.mappings = encode(properties.mappings);
|
|
611
|
+
if (typeof properties.x_google_ignoreList !== "undefined") {
|
|
612
|
+
this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
613
|
+
}
|
|
614
|
+
if (typeof properties.debugId !== "undefined") {
|
|
615
|
+
this.debugId = properties.debugId;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
toString() {
|
|
619
|
+
return JSON.stringify(this);
|
|
620
|
+
}
|
|
621
|
+
toUrl() {
|
|
622
|
+
return "data:application/json;charset=utf-8;base64," + btoa(this.toString());
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
function guessIndent(code) {
|
|
626
|
+
const lines = code.split("\n");
|
|
627
|
+
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
628
|
+
const spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
629
|
+
if (tabbed.length === 0 && spaced.length === 0) {
|
|
630
|
+
return null;
|
|
631
|
+
}
|
|
632
|
+
if (tabbed.length >= spaced.length) {
|
|
633
|
+
return " ";
|
|
634
|
+
}
|
|
635
|
+
const min = spaced.reduce((previous, current) => {
|
|
636
|
+
const numSpaces = /^ +/.exec(current)[0].length;
|
|
637
|
+
return Math.min(numSpaces, previous);
|
|
638
|
+
}, Infinity);
|
|
639
|
+
return new Array(min + 1).join(" ");
|
|
640
|
+
}
|
|
641
|
+
function getRelativePath(from, to) {
|
|
642
|
+
const fromParts = from.split(/[/\\]/);
|
|
643
|
+
const toParts = to.split(/[/\\]/);
|
|
644
|
+
fromParts.pop();
|
|
645
|
+
while (fromParts[0] === toParts[0]) {
|
|
646
|
+
fromParts.shift();
|
|
647
|
+
toParts.shift();
|
|
648
|
+
}
|
|
649
|
+
if (fromParts.length) {
|
|
650
|
+
let i = fromParts.length;
|
|
651
|
+
while (i--) fromParts[i] = "..";
|
|
652
|
+
}
|
|
653
|
+
return fromParts.concat(toParts).join("/");
|
|
654
|
+
}
|
|
655
|
+
const toString = Object.prototype.toString;
|
|
656
|
+
function isObject(thing) {
|
|
657
|
+
return toString.call(thing) === "[object Object]";
|
|
658
|
+
}
|
|
659
|
+
function getLocator(source) {
|
|
660
|
+
const originalLines = source.split("\n");
|
|
661
|
+
const lineOffsets = [];
|
|
662
|
+
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
663
|
+
lineOffsets.push(pos);
|
|
664
|
+
pos += originalLines[i].length + 1;
|
|
665
|
+
}
|
|
666
|
+
return function locate(index) {
|
|
667
|
+
let i = 0;
|
|
668
|
+
let j = lineOffsets.length;
|
|
669
|
+
while (i < j) {
|
|
670
|
+
const m = i + j >> 1;
|
|
671
|
+
if (index < lineOffsets[m]) {
|
|
672
|
+
j = m;
|
|
673
|
+
} else {
|
|
674
|
+
i = m + 1;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
const line = i - 1;
|
|
678
|
+
const column = index - lineOffsets[line];
|
|
679
|
+
return {
|
|
680
|
+
line,
|
|
681
|
+
column
|
|
682
|
+
};
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
const wordRegex = /\w/;
|
|
686
|
+
var Mappings = class {
|
|
687
|
+
constructor(hires) {
|
|
688
|
+
this.hires = hires;
|
|
689
|
+
this.generatedCodeLine = 0;
|
|
690
|
+
this.generatedCodeColumn = 0;
|
|
691
|
+
this.raw = [];
|
|
692
|
+
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
693
|
+
this.pending = null;
|
|
694
|
+
}
|
|
695
|
+
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
696
|
+
if (content.length) {
|
|
697
|
+
const contentLengthMinusOne = content.length - 1;
|
|
698
|
+
let contentLineEnd = content.indexOf("\n", 0);
|
|
699
|
+
let previousContentLineEnd = -1;
|
|
700
|
+
while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
|
|
701
|
+
const segment = [
|
|
702
|
+
this.generatedCodeColumn,
|
|
703
|
+
sourceIndex,
|
|
704
|
+
loc.line,
|
|
705
|
+
loc.column
|
|
706
|
+
];
|
|
707
|
+
if (nameIndex >= 0) {
|
|
708
|
+
segment.push(nameIndex);
|
|
709
|
+
}
|
|
710
|
+
this.rawSegments.push(segment);
|
|
711
|
+
this.generatedCodeLine += 1;
|
|
712
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
713
|
+
this.generatedCodeColumn = 0;
|
|
714
|
+
previousContentLineEnd = contentLineEnd;
|
|
715
|
+
contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
|
|
716
|
+
}
|
|
717
|
+
const segment = [
|
|
718
|
+
this.generatedCodeColumn,
|
|
719
|
+
sourceIndex,
|
|
720
|
+
loc.line,
|
|
721
|
+
loc.column
|
|
722
|
+
];
|
|
723
|
+
if (nameIndex >= 0) {
|
|
724
|
+
segment.push(nameIndex);
|
|
725
|
+
}
|
|
726
|
+
this.rawSegments.push(segment);
|
|
727
|
+
this.advance(content.slice(previousContentLineEnd + 1));
|
|
728
|
+
} else if (this.pending) {
|
|
729
|
+
this.rawSegments.push(this.pending);
|
|
730
|
+
this.advance(content);
|
|
731
|
+
}
|
|
732
|
+
this.pending = null;
|
|
733
|
+
}
|
|
734
|
+
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
735
|
+
let originalCharIndex = chunk.start;
|
|
736
|
+
let first = true;
|
|
737
|
+
let charInHiresBoundary = false;
|
|
738
|
+
while (originalCharIndex < chunk.end) {
|
|
739
|
+
if (original[originalCharIndex] === "\n") {
|
|
740
|
+
loc.line += 1;
|
|
741
|
+
loc.column = 0;
|
|
742
|
+
this.generatedCodeLine += 1;
|
|
743
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
744
|
+
this.generatedCodeColumn = 0;
|
|
745
|
+
first = true;
|
|
746
|
+
charInHiresBoundary = false;
|
|
747
|
+
} else {
|
|
748
|
+
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
749
|
+
const segment = [
|
|
750
|
+
this.generatedCodeColumn,
|
|
751
|
+
sourceIndex,
|
|
752
|
+
loc.line,
|
|
753
|
+
loc.column
|
|
754
|
+
];
|
|
755
|
+
if (this.hires === "boundary") {
|
|
756
|
+
if (wordRegex.test(original[originalCharIndex])) {
|
|
757
|
+
if (!charInHiresBoundary) {
|
|
758
|
+
this.rawSegments.push(segment);
|
|
759
|
+
charInHiresBoundary = true;
|
|
760
|
+
}
|
|
761
|
+
} else {
|
|
762
|
+
this.rawSegments.push(segment);
|
|
763
|
+
charInHiresBoundary = false;
|
|
764
|
+
}
|
|
765
|
+
} else {
|
|
766
|
+
this.rawSegments.push(segment);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
loc.column += 1;
|
|
770
|
+
this.generatedCodeColumn += 1;
|
|
771
|
+
first = false;
|
|
772
|
+
}
|
|
773
|
+
originalCharIndex += 1;
|
|
774
|
+
}
|
|
775
|
+
this.pending = null;
|
|
776
|
+
}
|
|
777
|
+
advance(str) {
|
|
778
|
+
if (!str) return;
|
|
779
|
+
const lines = str.split("\n");
|
|
780
|
+
if (lines.length > 1) {
|
|
781
|
+
for (let i = 0; i < lines.length - 1; i++) {
|
|
782
|
+
this.generatedCodeLine++;
|
|
783
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
784
|
+
}
|
|
785
|
+
this.generatedCodeColumn = 0;
|
|
786
|
+
}
|
|
787
|
+
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
const n = "\n";
|
|
791
|
+
const warned = {
|
|
792
|
+
insertLeft: false,
|
|
793
|
+
insertRight: false,
|
|
794
|
+
storeName: false
|
|
795
|
+
};
|
|
796
|
+
var MagicString = class MagicString {
|
|
797
|
+
constructor(string, options = {}) {
|
|
798
|
+
const chunk = new Chunk(0, string.length, string);
|
|
799
|
+
Object.defineProperties(this, {
|
|
800
|
+
original: {
|
|
801
|
+
writable: true,
|
|
802
|
+
value: string
|
|
803
|
+
},
|
|
804
|
+
outro: {
|
|
805
|
+
writable: true,
|
|
806
|
+
value: ""
|
|
807
|
+
},
|
|
808
|
+
intro: {
|
|
809
|
+
writable: true,
|
|
810
|
+
value: ""
|
|
811
|
+
},
|
|
812
|
+
firstChunk: {
|
|
813
|
+
writable: true,
|
|
814
|
+
value: chunk
|
|
815
|
+
},
|
|
816
|
+
lastChunk: {
|
|
817
|
+
writable: true,
|
|
818
|
+
value: chunk
|
|
819
|
+
},
|
|
820
|
+
lastSearchedChunk: {
|
|
821
|
+
writable: true,
|
|
822
|
+
value: chunk
|
|
823
|
+
},
|
|
824
|
+
byStart: {
|
|
825
|
+
writable: true,
|
|
826
|
+
value: {}
|
|
827
|
+
},
|
|
828
|
+
byEnd: {
|
|
829
|
+
writable: true,
|
|
830
|
+
value: {}
|
|
831
|
+
},
|
|
832
|
+
filename: {
|
|
833
|
+
writable: true,
|
|
834
|
+
value: options.filename
|
|
835
|
+
},
|
|
836
|
+
indentExclusionRanges: {
|
|
837
|
+
writable: true,
|
|
838
|
+
value: options.indentExclusionRanges
|
|
839
|
+
},
|
|
840
|
+
sourcemapLocations: {
|
|
841
|
+
writable: true,
|
|
842
|
+
value: new BitSet()
|
|
843
|
+
},
|
|
844
|
+
storedNames: {
|
|
845
|
+
writable: true,
|
|
846
|
+
value: {}
|
|
847
|
+
},
|
|
848
|
+
indentStr: {
|
|
849
|
+
writable: true,
|
|
850
|
+
value: undefined
|
|
851
|
+
},
|
|
852
|
+
ignoreList: {
|
|
853
|
+
writable: true,
|
|
854
|
+
value: options.ignoreList
|
|
855
|
+
},
|
|
856
|
+
offset: {
|
|
857
|
+
writable: true,
|
|
858
|
+
value: options.offset || 0
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
this.byStart[0] = chunk;
|
|
862
|
+
this.byEnd[string.length] = chunk;
|
|
863
|
+
}
|
|
864
|
+
addSourcemapLocation(char) {
|
|
865
|
+
this.sourcemapLocations.add(char);
|
|
866
|
+
}
|
|
867
|
+
append(content) {
|
|
868
|
+
if (typeof content !== "string") throw new TypeError("outro content must be a string");
|
|
869
|
+
this.outro += content;
|
|
870
|
+
return this;
|
|
871
|
+
}
|
|
872
|
+
appendLeft(index, content) {
|
|
873
|
+
index = index + this.offset;
|
|
874
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
875
|
+
this._split(index);
|
|
876
|
+
const chunk = this.byEnd[index];
|
|
877
|
+
if (chunk) {
|
|
878
|
+
chunk.appendLeft(content);
|
|
879
|
+
} else {
|
|
880
|
+
this.intro += content;
|
|
881
|
+
}
|
|
882
|
+
return this;
|
|
883
|
+
}
|
|
884
|
+
appendRight(index, content) {
|
|
885
|
+
index = index + this.offset;
|
|
886
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
887
|
+
this._split(index);
|
|
888
|
+
const chunk = this.byStart[index];
|
|
889
|
+
if (chunk) {
|
|
890
|
+
chunk.appendRight(content);
|
|
891
|
+
} else {
|
|
892
|
+
this.outro += content;
|
|
893
|
+
}
|
|
894
|
+
return this;
|
|
895
|
+
}
|
|
896
|
+
clone() {
|
|
897
|
+
const cloned = new MagicString(this.original, {
|
|
898
|
+
filename: this.filename,
|
|
899
|
+
offset: this.offset
|
|
900
|
+
});
|
|
901
|
+
let originalChunk = this.firstChunk;
|
|
902
|
+
let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
|
|
903
|
+
while (originalChunk) {
|
|
904
|
+
cloned.byStart[clonedChunk.start] = clonedChunk;
|
|
905
|
+
cloned.byEnd[clonedChunk.end] = clonedChunk;
|
|
906
|
+
const nextOriginalChunk = originalChunk.next;
|
|
907
|
+
const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
|
|
908
|
+
if (nextClonedChunk) {
|
|
909
|
+
clonedChunk.next = nextClonedChunk;
|
|
910
|
+
nextClonedChunk.previous = clonedChunk;
|
|
911
|
+
clonedChunk = nextClonedChunk;
|
|
912
|
+
}
|
|
913
|
+
originalChunk = nextOriginalChunk;
|
|
914
|
+
}
|
|
915
|
+
cloned.lastChunk = clonedChunk;
|
|
916
|
+
if (this.indentExclusionRanges) {
|
|
917
|
+
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
918
|
+
}
|
|
919
|
+
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
920
|
+
cloned.intro = this.intro;
|
|
921
|
+
cloned.outro = this.outro;
|
|
922
|
+
return cloned;
|
|
923
|
+
}
|
|
924
|
+
generateDecodedMap(options) {
|
|
925
|
+
options = options || {};
|
|
926
|
+
const sourceIndex = 0;
|
|
927
|
+
const names = Object.keys(this.storedNames);
|
|
928
|
+
const mappings = new Mappings(options.hires);
|
|
929
|
+
const locate = getLocator(this.original);
|
|
930
|
+
if (this.intro) {
|
|
931
|
+
mappings.advance(this.intro);
|
|
932
|
+
}
|
|
933
|
+
this.firstChunk.eachNext((chunk) => {
|
|
934
|
+
const loc = locate(chunk.start);
|
|
935
|
+
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
936
|
+
if (chunk.edited) {
|
|
937
|
+
mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
|
|
938
|
+
} else {
|
|
939
|
+
mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
940
|
+
}
|
|
941
|
+
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
942
|
+
});
|
|
943
|
+
if (this.outro) {
|
|
944
|
+
mappings.advance(this.outro);
|
|
945
|
+
}
|
|
946
|
+
return {
|
|
947
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
|
|
948
|
+
sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
|
|
949
|
+
sourcesContent: options.includeContent ? [this.original] : undefined,
|
|
950
|
+
names,
|
|
951
|
+
mappings: mappings.raw,
|
|
952
|
+
x_google_ignoreList: this.ignoreList ? [sourceIndex] : undefined
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
generateMap(options) {
|
|
956
|
+
return new SourceMap(this.generateDecodedMap(options));
|
|
957
|
+
}
|
|
958
|
+
_ensureindentStr() {
|
|
959
|
+
if (this.indentStr === undefined) {
|
|
960
|
+
this.indentStr = guessIndent(this.original);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
_getRawIndentString() {
|
|
964
|
+
this._ensureindentStr();
|
|
965
|
+
return this.indentStr;
|
|
966
|
+
}
|
|
967
|
+
getIndentString() {
|
|
968
|
+
this._ensureindentStr();
|
|
969
|
+
return this.indentStr === null ? " " : this.indentStr;
|
|
970
|
+
}
|
|
971
|
+
indent(indentStr, options) {
|
|
972
|
+
const pattern = /^[^\r\n]/gm;
|
|
973
|
+
if (isObject(indentStr)) {
|
|
974
|
+
options = indentStr;
|
|
975
|
+
indentStr = undefined;
|
|
976
|
+
}
|
|
977
|
+
if (indentStr === undefined) {
|
|
978
|
+
this._ensureindentStr();
|
|
979
|
+
indentStr = this.indentStr || " ";
|
|
980
|
+
}
|
|
981
|
+
if (indentStr === "") return this;
|
|
982
|
+
options = options || {};
|
|
983
|
+
const isExcluded = {};
|
|
984
|
+
if (options.exclude) {
|
|
985
|
+
const exclusions = typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude;
|
|
986
|
+
exclusions.forEach((exclusion) => {
|
|
987
|
+
for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
|
|
988
|
+
isExcluded[i] = true;
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
993
|
+
const replacer = (match) => {
|
|
994
|
+
if (shouldIndentNextCharacter) return `${indentStr}${match}`;
|
|
995
|
+
shouldIndentNextCharacter = true;
|
|
996
|
+
return match;
|
|
997
|
+
};
|
|
998
|
+
this.intro = this.intro.replace(pattern, replacer);
|
|
999
|
+
let charIndex = 0;
|
|
1000
|
+
let chunk = this.firstChunk;
|
|
1001
|
+
while (chunk) {
|
|
1002
|
+
const end = chunk.end;
|
|
1003
|
+
if (chunk.edited) {
|
|
1004
|
+
if (!isExcluded[charIndex]) {
|
|
1005
|
+
chunk.content = chunk.content.replace(pattern, replacer);
|
|
1006
|
+
if (chunk.content.length) {
|
|
1007
|
+
shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
} else {
|
|
1011
|
+
charIndex = chunk.start;
|
|
1012
|
+
while (charIndex < end) {
|
|
1013
|
+
if (!isExcluded[charIndex]) {
|
|
1014
|
+
const char = this.original[charIndex];
|
|
1015
|
+
if (char === "\n") {
|
|
1016
|
+
shouldIndentNextCharacter = true;
|
|
1017
|
+
} else if (char !== "\r" && shouldIndentNextCharacter) {
|
|
1018
|
+
shouldIndentNextCharacter = false;
|
|
1019
|
+
if (charIndex === chunk.start) {
|
|
1020
|
+
chunk.prependRight(indentStr);
|
|
1021
|
+
} else {
|
|
1022
|
+
this._splitChunk(chunk, charIndex);
|
|
1023
|
+
chunk = chunk.next;
|
|
1024
|
+
chunk.prependRight(indentStr);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
charIndex += 1;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
charIndex = chunk.end;
|
|
1032
|
+
chunk = chunk.next;
|
|
1033
|
+
}
|
|
1034
|
+
this.outro = this.outro.replace(pattern, replacer);
|
|
1035
|
+
return this;
|
|
1036
|
+
}
|
|
1037
|
+
insert() {
|
|
1038
|
+
throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)");
|
|
1039
|
+
}
|
|
1040
|
+
insertLeft(index, content) {
|
|
1041
|
+
if (!warned.insertLeft) {
|
|
1042
|
+
console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead");
|
|
1043
|
+
warned.insertLeft = true;
|
|
1044
|
+
}
|
|
1045
|
+
return this.appendLeft(index, content);
|
|
1046
|
+
}
|
|
1047
|
+
insertRight(index, content) {
|
|
1048
|
+
if (!warned.insertRight) {
|
|
1049
|
+
console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead");
|
|
1050
|
+
warned.insertRight = true;
|
|
1051
|
+
}
|
|
1052
|
+
return this.prependRight(index, content);
|
|
1053
|
+
}
|
|
1054
|
+
move(start, end, index) {
|
|
1055
|
+
start = start + this.offset;
|
|
1056
|
+
end = end + this.offset;
|
|
1057
|
+
index = index + this.offset;
|
|
1058
|
+
if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
|
|
1059
|
+
this._split(start);
|
|
1060
|
+
this._split(end);
|
|
1061
|
+
this._split(index);
|
|
1062
|
+
const first = this.byStart[start];
|
|
1063
|
+
const last = this.byEnd[end];
|
|
1064
|
+
const oldLeft = first.previous;
|
|
1065
|
+
const oldRight = last.next;
|
|
1066
|
+
const newRight = this.byStart[index];
|
|
1067
|
+
if (!newRight && last === this.lastChunk) return this;
|
|
1068
|
+
const newLeft = newRight ? newRight.previous : this.lastChunk;
|
|
1069
|
+
if (oldLeft) oldLeft.next = oldRight;
|
|
1070
|
+
if (oldRight) oldRight.previous = oldLeft;
|
|
1071
|
+
if (newLeft) newLeft.next = first;
|
|
1072
|
+
if (newRight) newRight.previous = last;
|
|
1073
|
+
if (!first.previous) this.firstChunk = last.next;
|
|
1074
|
+
if (!last.next) {
|
|
1075
|
+
this.lastChunk = first.previous;
|
|
1076
|
+
this.lastChunk.next = null;
|
|
1077
|
+
}
|
|
1078
|
+
first.previous = newLeft;
|
|
1079
|
+
last.next = newRight || null;
|
|
1080
|
+
if (!newLeft) this.firstChunk = first;
|
|
1081
|
+
if (!newRight) this.lastChunk = last;
|
|
1082
|
+
return this;
|
|
1083
|
+
}
|
|
1084
|
+
overwrite(start, end, content, options) {
|
|
1085
|
+
options = options || {};
|
|
1086
|
+
return this.update(start, end, content, {
|
|
1087
|
+
...options,
|
|
1088
|
+
overwrite: !options.contentOnly
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
update(start, end, content, options) {
|
|
1092
|
+
start = start + this.offset;
|
|
1093
|
+
end = end + this.offset;
|
|
1094
|
+
if (typeof content !== "string") throw new TypeError("replacement content must be a string");
|
|
1095
|
+
if (this.original.length !== 0) {
|
|
1096
|
+
while (start < 0) start += this.original.length;
|
|
1097
|
+
while (end < 0) end += this.original.length;
|
|
1098
|
+
}
|
|
1099
|
+
if (end > this.original.length) throw new Error("end is out of bounds");
|
|
1100
|
+
if (start === end) throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");
|
|
1101
|
+
this._split(start);
|
|
1102
|
+
this._split(end);
|
|
1103
|
+
if (options === true) {
|
|
1104
|
+
if (!warned.storeName) {
|
|
1105
|
+
console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string");
|
|
1106
|
+
warned.storeName = true;
|
|
1107
|
+
}
|
|
1108
|
+
options = { storeName: true };
|
|
1109
|
+
}
|
|
1110
|
+
const storeName = options !== undefined ? options.storeName : false;
|
|
1111
|
+
const overwrite = options !== undefined ? options.overwrite : false;
|
|
1112
|
+
if (storeName) {
|
|
1113
|
+
const original = this.original.slice(start, end);
|
|
1114
|
+
Object.defineProperty(this.storedNames, original, {
|
|
1115
|
+
writable: true,
|
|
1116
|
+
value: true,
|
|
1117
|
+
enumerable: true
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
const first = this.byStart[start];
|
|
1121
|
+
const last = this.byEnd[end];
|
|
1122
|
+
if (first) {
|
|
1123
|
+
let chunk = first;
|
|
1124
|
+
while (chunk !== last) {
|
|
1125
|
+
if (chunk.next !== this.byStart[chunk.end]) {
|
|
1126
|
+
throw new Error("Cannot overwrite across a split point");
|
|
1127
|
+
}
|
|
1128
|
+
chunk = chunk.next;
|
|
1129
|
+
chunk.edit("", false);
|
|
1130
|
+
}
|
|
1131
|
+
first.edit(content, storeName, !overwrite);
|
|
1132
|
+
} else {
|
|
1133
|
+
const newChunk = new Chunk(start, end, "").edit(content, storeName);
|
|
1134
|
+
last.next = newChunk;
|
|
1135
|
+
newChunk.previous = last;
|
|
1136
|
+
}
|
|
1137
|
+
return this;
|
|
1138
|
+
}
|
|
1139
|
+
prepend(content) {
|
|
1140
|
+
if (typeof content !== "string") throw new TypeError("outro content must be a string");
|
|
1141
|
+
this.intro = content + this.intro;
|
|
1142
|
+
return this;
|
|
1143
|
+
}
|
|
1144
|
+
prependLeft(index, content) {
|
|
1145
|
+
index = index + this.offset;
|
|
1146
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
1147
|
+
this._split(index);
|
|
1148
|
+
const chunk = this.byEnd[index];
|
|
1149
|
+
if (chunk) {
|
|
1150
|
+
chunk.prependLeft(content);
|
|
1151
|
+
} else {
|
|
1152
|
+
this.intro = content + this.intro;
|
|
1153
|
+
}
|
|
1154
|
+
return this;
|
|
1155
|
+
}
|
|
1156
|
+
prependRight(index, content) {
|
|
1157
|
+
index = index + this.offset;
|
|
1158
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
1159
|
+
this._split(index);
|
|
1160
|
+
const chunk = this.byStart[index];
|
|
1161
|
+
if (chunk) {
|
|
1162
|
+
chunk.prependRight(content);
|
|
1163
|
+
} else {
|
|
1164
|
+
this.outro = content + this.outro;
|
|
1165
|
+
}
|
|
1166
|
+
return this;
|
|
1167
|
+
}
|
|
1168
|
+
remove(start, end) {
|
|
1169
|
+
start = start + this.offset;
|
|
1170
|
+
end = end + this.offset;
|
|
1171
|
+
if (this.original.length !== 0) {
|
|
1172
|
+
while (start < 0) start += this.original.length;
|
|
1173
|
+
while (end < 0) end += this.original.length;
|
|
1174
|
+
}
|
|
1175
|
+
if (start === end) return this;
|
|
1176
|
+
if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
|
|
1177
|
+
if (start > end) throw new Error("end must be greater than start");
|
|
1178
|
+
this._split(start);
|
|
1179
|
+
this._split(end);
|
|
1180
|
+
let chunk = this.byStart[start];
|
|
1181
|
+
while (chunk) {
|
|
1182
|
+
chunk.intro = "";
|
|
1183
|
+
chunk.outro = "";
|
|
1184
|
+
chunk.edit("");
|
|
1185
|
+
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
1186
|
+
}
|
|
1187
|
+
return this;
|
|
1188
|
+
}
|
|
1189
|
+
reset(start, end) {
|
|
1190
|
+
start = start + this.offset;
|
|
1191
|
+
end = end + this.offset;
|
|
1192
|
+
if (this.original.length !== 0) {
|
|
1193
|
+
while (start < 0) start += this.original.length;
|
|
1194
|
+
while (end < 0) end += this.original.length;
|
|
1195
|
+
}
|
|
1196
|
+
if (start === end) return this;
|
|
1197
|
+
if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
|
|
1198
|
+
if (start > end) throw new Error("end must be greater than start");
|
|
1199
|
+
this._split(start);
|
|
1200
|
+
this._split(end);
|
|
1201
|
+
let chunk = this.byStart[start];
|
|
1202
|
+
while (chunk) {
|
|
1203
|
+
chunk.reset();
|
|
1204
|
+
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
1205
|
+
}
|
|
1206
|
+
return this;
|
|
1207
|
+
}
|
|
1208
|
+
lastChar() {
|
|
1209
|
+
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
1210
|
+
let chunk = this.lastChunk;
|
|
1211
|
+
do {
|
|
1212
|
+
if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
|
|
1213
|
+
if (chunk.content.length) return chunk.content[chunk.content.length - 1];
|
|
1214
|
+
if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
|
|
1215
|
+
} while (chunk = chunk.previous);
|
|
1216
|
+
if (this.intro.length) return this.intro[this.intro.length - 1];
|
|
1217
|
+
return "";
|
|
1218
|
+
}
|
|
1219
|
+
lastLine() {
|
|
1220
|
+
let lineIndex = this.outro.lastIndexOf(n);
|
|
1221
|
+
if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
|
|
1222
|
+
let lineStr = this.outro;
|
|
1223
|
+
let chunk = this.lastChunk;
|
|
1224
|
+
do {
|
|
1225
|
+
if (chunk.outro.length > 0) {
|
|
1226
|
+
lineIndex = chunk.outro.lastIndexOf(n);
|
|
1227
|
+
if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
1228
|
+
lineStr = chunk.outro + lineStr;
|
|
1229
|
+
}
|
|
1230
|
+
if (chunk.content.length > 0) {
|
|
1231
|
+
lineIndex = chunk.content.lastIndexOf(n);
|
|
1232
|
+
if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
|
|
1233
|
+
lineStr = chunk.content + lineStr;
|
|
1234
|
+
}
|
|
1235
|
+
if (chunk.intro.length > 0) {
|
|
1236
|
+
lineIndex = chunk.intro.lastIndexOf(n);
|
|
1237
|
+
if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
1238
|
+
lineStr = chunk.intro + lineStr;
|
|
1239
|
+
}
|
|
1240
|
+
} while (chunk = chunk.previous);
|
|
1241
|
+
lineIndex = this.intro.lastIndexOf(n);
|
|
1242
|
+
if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
|
|
1243
|
+
return this.intro + lineStr;
|
|
1244
|
+
}
|
|
1245
|
+
slice(start = 0, end = this.original.length - this.offset) {
|
|
1246
|
+
start = start + this.offset;
|
|
1247
|
+
end = end + this.offset;
|
|
1248
|
+
if (this.original.length !== 0) {
|
|
1249
|
+
while (start < 0) start += this.original.length;
|
|
1250
|
+
while (end < 0) end += this.original.length;
|
|
1251
|
+
}
|
|
1252
|
+
let result = "";
|
|
1253
|
+
let chunk = this.firstChunk;
|
|
1254
|
+
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
1255
|
+
if (chunk.start < end && chunk.end >= end) {
|
|
1256
|
+
return result;
|
|
1257
|
+
}
|
|
1258
|
+
chunk = chunk.next;
|
|
1259
|
+
}
|
|
1260
|
+
if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
1261
|
+
const startChunk = chunk;
|
|
1262
|
+
while (chunk) {
|
|
1263
|
+
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) {
|
|
1264
|
+
result += chunk.intro;
|
|
1265
|
+
}
|
|
1266
|
+
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
1267
|
+
if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
1268
|
+
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
1269
|
+
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
1270
|
+
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
1271
|
+
if (chunk.outro && (!containsEnd || chunk.end === end)) {
|
|
1272
|
+
result += chunk.outro;
|
|
1273
|
+
}
|
|
1274
|
+
if (containsEnd) {
|
|
1275
|
+
break;
|
|
1276
|
+
}
|
|
1277
|
+
chunk = chunk.next;
|
|
1278
|
+
}
|
|
1279
|
+
return result;
|
|
1280
|
+
}
|
|
1281
|
+
snip(start, end) {
|
|
1282
|
+
const clone = this.clone();
|
|
1283
|
+
clone.remove(0, start);
|
|
1284
|
+
clone.remove(end, clone.original.length);
|
|
1285
|
+
return clone;
|
|
1286
|
+
}
|
|
1287
|
+
_split(index) {
|
|
1288
|
+
if (this.byStart[index] || this.byEnd[index]) return;
|
|
1289
|
+
let chunk = this.lastSearchedChunk;
|
|
1290
|
+
let previousChunk = chunk;
|
|
1291
|
+
const searchForward = index > chunk.end;
|
|
1292
|
+
while (chunk) {
|
|
1293
|
+
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
1294
|
+
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
1295
|
+
if (chunk === previousChunk) return;
|
|
1296
|
+
previousChunk = chunk;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
_splitChunk(chunk, index) {
|
|
1300
|
+
if (chunk.edited && chunk.content.length) {
|
|
1301
|
+
const loc = getLocator(this.original)(index);
|
|
1302
|
+
throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
|
|
1303
|
+
}
|
|
1304
|
+
const newChunk = chunk.split(index);
|
|
1305
|
+
this.byEnd[index] = chunk;
|
|
1306
|
+
this.byStart[index] = newChunk;
|
|
1307
|
+
this.byEnd[newChunk.end] = newChunk;
|
|
1308
|
+
if (chunk === this.lastChunk) this.lastChunk = newChunk;
|
|
1309
|
+
this.lastSearchedChunk = chunk;
|
|
1310
|
+
return true;
|
|
1311
|
+
}
|
|
1312
|
+
toString() {
|
|
1313
|
+
let str = this.intro;
|
|
1314
|
+
let chunk = this.firstChunk;
|
|
1315
|
+
while (chunk) {
|
|
1316
|
+
str += chunk.toString();
|
|
1317
|
+
chunk = chunk.next;
|
|
1318
|
+
}
|
|
1319
|
+
return str + this.outro;
|
|
1320
|
+
}
|
|
1321
|
+
isEmpty() {
|
|
1322
|
+
let chunk = this.firstChunk;
|
|
1323
|
+
do {
|
|
1324
|
+
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
|
|
1325
|
+
} while (chunk = chunk.next);
|
|
1326
|
+
return true;
|
|
1327
|
+
}
|
|
1328
|
+
length() {
|
|
1329
|
+
let chunk = this.firstChunk;
|
|
1330
|
+
let length = 0;
|
|
1331
|
+
do {
|
|
1332
|
+
length += chunk.intro.length + chunk.content.length + chunk.outro.length;
|
|
1333
|
+
} while (chunk = chunk.next);
|
|
1334
|
+
return length;
|
|
1335
|
+
}
|
|
1336
|
+
trimLines() {
|
|
1337
|
+
return this.trim("[\\r\\n]");
|
|
1338
|
+
}
|
|
1339
|
+
trim(charType) {
|
|
1340
|
+
return this.trimStart(charType).trimEnd(charType);
|
|
1341
|
+
}
|
|
1342
|
+
trimEndAborted(charType) {
|
|
1343
|
+
const rx = new RegExp((charType || "\\s") + "+$");
|
|
1344
|
+
this.outro = this.outro.replace(rx, "");
|
|
1345
|
+
if (this.outro.length) return true;
|
|
1346
|
+
let chunk = this.lastChunk;
|
|
1347
|
+
do {
|
|
1348
|
+
const end = chunk.end;
|
|
1349
|
+
const aborted = chunk.trimEnd(rx);
|
|
1350
|
+
if (chunk.end !== end) {
|
|
1351
|
+
if (this.lastChunk === chunk) {
|
|
1352
|
+
this.lastChunk = chunk.next;
|
|
1353
|
+
}
|
|
1354
|
+
this.byEnd[chunk.end] = chunk;
|
|
1355
|
+
this.byStart[chunk.next.start] = chunk.next;
|
|
1356
|
+
this.byEnd[chunk.next.end] = chunk.next;
|
|
1357
|
+
}
|
|
1358
|
+
if (aborted) return true;
|
|
1359
|
+
chunk = chunk.previous;
|
|
1360
|
+
} while (chunk);
|
|
1361
|
+
return false;
|
|
1362
|
+
}
|
|
1363
|
+
trimEnd(charType) {
|
|
1364
|
+
this.trimEndAborted(charType);
|
|
1365
|
+
return this;
|
|
1366
|
+
}
|
|
1367
|
+
trimStartAborted(charType) {
|
|
1368
|
+
const rx = new RegExp("^" + (charType || "\\s") + "+");
|
|
1369
|
+
this.intro = this.intro.replace(rx, "");
|
|
1370
|
+
if (this.intro.length) return true;
|
|
1371
|
+
let chunk = this.firstChunk;
|
|
1372
|
+
do {
|
|
1373
|
+
const end = chunk.end;
|
|
1374
|
+
const aborted = chunk.trimStart(rx);
|
|
1375
|
+
if (chunk.end !== end) {
|
|
1376
|
+
if (chunk === this.lastChunk) this.lastChunk = chunk.next;
|
|
1377
|
+
this.byEnd[chunk.end] = chunk;
|
|
1378
|
+
this.byStart[chunk.next.start] = chunk.next;
|
|
1379
|
+
this.byEnd[chunk.next.end] = chunk.next;
|
|
1380
|
+
}
|
|
1381
|
+
if (aborted) return true;
|
|
1382
|
+
chunk = chunk.next;
|
|
1383
|
+
} while (chunk);
|
|
1384
|
+
return false;
|
|
1385
|
+
}
|
|
1386
|
+
trimStart(charType) {
|
|
1387
|
+
this.trimStartAborted(charType);
|
|
1388
|
+
return this;
|
|
1389
|
+
}
|
|
1390
|
+
hasChanged() {
|
|
1391
|
+
return this.original !== this.toString();
|
|
1392
|
+
}
|
|
1393
|
+
_replaceRegexp(searchValue, replacement) {
|
|
1394
|
+
function getReplacement(match, str) {
|
|
1395
|
+
if (typeof replacement === "string") {
|
|
1396
|
+
return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
1397
|
+
if (i === "$") return "$";
|
|
1398
|
+
if (i === "&") return match[0];
|
|
1399
|
+
const num = +i;
|
|
1400
|
+
if (num < match.length) return match[+i];
|
|
1401
|
+
return `$${i}`;
|
|
1402
|
+
});
|
|
1403
|
+
} else {
|
|
1404
|
+
return replacement(...match, match.index, str, match.groups);
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
function matchAll(re, str) {
|
|
1408
|
+
let match;
|
|
1409
|
+
const matches = [];
|
|
1410
|
+
while (match = re.exec(str)) {
|
|
1411
|
+
matches.push(match);
|
|
1412
|
+
}
|
|
1413
|
+
return matches;
|
|
1414
|
+
}
|
|
1415
|
+
if (searchValue.global) {
|
|
1416
|
+
const matches = matchAll(searchValue, this.original);
|
|
1417
|
+
matches.forEach((match) => {
|
|
1418
|
+
if (match.index != null) {
|
|
1419
|
+
const replacement = getReplacement(match, this.original);
|
|
1420
|
+
if (replacement !== match[0]) {
|
|
1421
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1425
|
+
} else {
|
|
1426
|
+
const match = this.original.match(searchValue);
|
|
1427
|
+
if (match && match.index != null) {
|
|
1428
|
+
const replacement = getReplacement(match, this.original);
|
|
1429
|
+
if (replacement !== match[0]) {
|
|
1430
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
return this;
|
|
1435
|
+
}
|
|
1436
|
+
_replaceString(string, replacement) {
|
|
1437
|
+
const { original } = this;
|
|
1438
|
+
const index = original.indexOf(string);
|
|
1439
|
+
if (index !== -1) {
|
|
1440
|
+
if (typeof replacement === "function") {
|
|
1441
|
+
replacement = replacement(string, index, original);
|
|
1442
|
+
}
|
|
1443
|
+
if (string !== replacement) {
|
|
1444
|
+
this.overwrite(index, index + string.length, replacement);
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
return this;
|
|
1448
|
+
}
|
|
1449
|
+
replace(searchValue, replacement) {
|
|
1450
|
+
if (typeof searchValue === "string") {
|
|
1451
|
+
return this._replaceString(searchValue, replacement);
|
|
1452
|
+
}
|
|
1453
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
1454
|
+
}
|
|
1455
|
+
_replaceAllString(string, replacement) {
|
|
1456
|
+
const { original } = this;
|
|
1457
|
+
const stringLength = string.length;
|
|
1458
|
+
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
1459
|
+
const previous = original.slice(index, index + stringLength);
|
|
1460
|
+
let _replacement = replacement;
|
|
1461
|
+
if (typeof replacement === "function") {
|
|
1462
|
+
_replacement = replacement(previous, index, original);
|
|
1463
|
+
}
|
|
1464
|
+
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
1465
|
+
}
|
|
1466
|
+
return this;
|
|
1467
|
+
}
|
|
1468
|
+
replaceAll(searchValue, replacement) {
|
|
1469
|
+
if (typeof searchValue === "string") {
|
|
1470
|
+
return this._replaceAllString(searchValue, replacement);
|
|
1471
|
+
}
|
|
1472
|
+
if (!searchValue.global) {
|
|
1473
|
+
throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
|
|
1474
|
+
}
|
|
1475
|
+
return this._replaceRegexp(searchValue, replacement);
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1479
|
+
var Bundle = class Bundle {
|
|
1480
|
+
constructor(options = {}) {
|
|
1481
|
+
this.intro = options.intro || "";
|
|
1482
|
+
this.separator = options.separator !== undefined ? options.separator : "\n";
|
|
1483
|
+
this.sources = [];
|
|
1484
|
+
this.uniqueSources = [];
|
|
1485
|
+
this.uniqueSourceIndexByFilename = {};
|
|
1486
|
+
}
|
|
1487
|
+
addSource(source) {
|
|
1488
|
+
if (source instanceof MagicString) {
|
|
1489
|
+
return this.addSource({
|
|
1490
|
+
content: source,
|
|
1491
|
+
filename: source.filename,
|
|
1492
|
+
separator: this.separator
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
if (!isObject(source) || !source.content) {
|
|
1496
|
+
throw new Error("bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`");
|
|
1497
|
+
}
|
|
1498
|
+
[
|
|
1499
|
+
"filename",
|
|
1500
|
+
"ignoreList",
|
|
1501
|
+
"indentExclusionRanges",
|
|
1502
|
+
"separator"
|
|
1503
|
+
].forEach((option) => {
|
|
1504
|
+
if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
|
|
1505
|
+
});
|
|
1506
|
+
if (source.separator === undefined) {
|
|
1507
|
+
source.separator = this.separator;
|
|
1508
|
+
}
|
|
1509
|
+
if (source.filename) {
|
|
1510
|
+
if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
|
|
1511
|
+
this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
|
|
1512
|
+
this.uniqueSources.push({
|
|
1513
|
+
filename: source.filename,
|
|
1514
|
+
content: source.content.original
|
|
1515
|
+
});
|
|
1516
|
+
} else {
|
|
1517
|
+
const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
1518
|
+
if (source.content.original !== uniqueSource.content) {
|
|
1519
|
+
throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
this.sources.push(source);
|
|
1524
|
+
return this;
|
|
1525
|
+
}
|
|
1526
|
+
append(str, options) {
|
|
1527
|
+
this.addSource({
|
|
1528
|
+
content: new MagicString(str),
|
|
1529
|
+
separator: options && options.separator || ""
|
|
1530
|
+
});
|
|
1531
|
+
return this;
|
|
1532
|
+
}
|
|
1533
|
+
clone() {
|
|
1534
|
+
const bundle = new Bundle({
|
|
1535
|
+
intro: this.intro,
|
|
1536
|
+
separator: this.separator
|
|
1537
|
+
});
|
|
1538
|
+
this.sources.forEach((source) => {
|
|
1539
|
+
bundle.addSource({
|
|
1540
|
+
filename: source.filename,
|
|
1541
|
+
content: source.content.clone(),
|
|
1542
|
+
separator: source.separator
|
|
1543
|
+
});
|
|
1544
|
+
});
|
|
1545
|
+
return bundle;
|
|
1546
|
+
}
|
|
1547
|
+
generateDecodedMap(options = {}) {
|
|
1548
|
+
const names = [];
|
|
1549
|
+
let x_google_ignoreList = undefined;
|
|
1550
|
+
this.sources.forEach((source) => {
|
|
1551
|
+
Object.keys(source.content.storedNames).forEach((name) => {
|
|
1552
|
+
if (!~names.indexOf(name)) names.push(name);
|
|
1553
|
+
});
|
|
1554
|
+
});
|
|
1555
|
+
const mappings = new Mappings(options.hires);
|
|
1556
|
+
if (this.intro) {
|
|
1557
|
+
mappings.advance(this.intro);
|
|
1558
|
+
}
|
|
1559
|
+
this.sources.forEach((source, i) => {
|
|
1560
|
+
if (i > 0) {
|
|
1561
|
+
mappings.advance(this.separator);
|
|
1562
|
+
}
|
|
1563
|
+
const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
|
|
1564
|
+
const magicString = source.content;
|
|
1565
|
+
const locate = getLocator(magicString.original);
|
|
1566
|
+
if (magicString.intro) {
|
|
1567
|
+
mappings.advance(magicString.intro);
|
|
1568
|
+
}
|
|
1569
|
+
magicString.firstChunk.eachNext((chunk) => {
|
|
1570
|
+
const loc = locate(chunk.start);
|
|
1571
|
+
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
1572
|
+
if (source.filename) {
|
|
1573
|
+
if (chunk.edited) {
|
|
1574
|
+
mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
|
|
1575
|
+
} else {
|
|
1576
|
+
mappings.addUneditedChunk(sourceIndex, chunk, magicString.original, loc, magicString.sourcemapLocations);
|
|
1577
|
+
}
|
|
1578
|
+
} else {
|
|
1579
|
+
mappings.advance(chunk.content);
|
|
1580
|
+
}
|
|
1581
|
+
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
1582
|
+
});
|
|
1583
|
+
if (magicString.outro) {
|
|
1584
|
+
mappings.advance(magicString.outro);
|
|
1585
|
+
}
|
|
1586
|
+
if (source.ignoreList && sourceIndex !== -1) {
|
|
1587
|
+
if (x_google_ignoreList === undefined) {
|
|
1588
|
+
x_google_ignoreList = [];
|
|
1589
|
+
}
|
|
1590
|
+
x_google_ignoreList.push(sourceIndex);
|
|
1591
|
+
}
|
|
1592
|
+
});
|
|
1593
|
+
return {
|
|
1594
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : undefined,
|
|
1595
|
+
sources: this.uniqueSources.map((source) => {
|
|
1596
|
+
return options.file ? getRelativePath(options.file, source.filename) : source.filename;
|
|
1597
|
+
}),
|
|
1598
|
+
sourcesContent: this.uniqueSources.map((source) => {
|
|
1599
|
+
return options.includeContent ? source.content : null;
|
|
1600
|
+
}),
|
|
1601
|
+
names,
|
|
1602
|
+
mappings: mappings.raw,
|
|
1603
|
+
x_google_ignoreList
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
generateMap(options) {
|
|
1607
|
+
return new SourceMap(this.generateDecodedMap(options));
|
|
1608
|
+
}
|
|
1609
|
+
getIndentString() {
|
|
1610
|
+
const indentStringCounts = {};
|
|
1611
|
+
this.sources.forEach((source) => {
|
|
1612
|
+
const indentStr = source.content._getRawIndentString();
|
|
1613
|
+
if (indentStr === null) return;
|
|
1614
|
+
if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
|
|
1615
|
+
indentStringCounts[indentStr] += 1;
|
|
1616
|
+
});
|
|
1617
|
+
return Object.keys(indentStringCounts).sort((a, b) => {
|
|
1618
|
+
return indentStringCounts[a] - indentStringCounts[b];
|
|
1619
|
+
})[0] || " ";
|
|
1620
|
+
}
|
|
1621
|
+
indent(indentStr) {
|
|
1622
|
+
if (!arguments.length) {
|
|
1623
|
+
indentStr = this.getIndentString();
|
|
1624
|
+
}
|
|
1625
|
+
if (indentStr === "") return this;
|
|
1626
|
+
let trailingNewline = !this.intro || this.intro.slice(-1) === "\n";
|
|
1627
|
+
this.sources.forEach((source, i) => {
|
|
1628
|
+
const separator = source.separator !== undefined ? source.separator : this.separator;
|
|
1629
|
+
const indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
|
|
1630
|
+
source.content.indent(indentStr, {
|
|
1631
|
+
exclude: source.indentExclusionRanges,
|
|
1632
|
+
indentStart
|
|
1633
|
+
});
|
|
1634
|
+
trailingNewline = source.content.lastChar() === "\n";
|
|
1635
|
+
});
|
|
1636
|
+
if (this.intro) {
|
|
1637
|
+
this.intro = indentStr + this.intro.replace(/^[^\n]/gm, (match, index) => {
|
|
1638
|
+
return index > 0 ? indentStr + match : match;
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
return this;
|
|
1642
|
+
}
|
|
1643
|
+
prepend(str) {
|
|
1644
|
+
this.intro = str + this.intro;
|
|
1645
|
+
return this;
|
|
1646
|
+
}
|
|
1647
|
+
toString() {
|
|
1648
|
+
const body = this.sources.map((source, i) => {
|
|
1649
|
+
const separator = source.separator !== undefined ? source.separator : this.separator;
|
|
1650
|
+
const str = (i > 0 ? separator : "") + source.content.toString();
|
|
1651
|
+
return str;
|
|
1652
|
+
}).join("");
|
|
1653
|
+
return this.intro + body;
|
|
1654
|
+
}
|
|
1655
|
+
isEmpty() {
|
|
1656
|
+
if (this.intro.length && this.intro.trim()) return false;
|
|
1657
|
+
if (this.sources.some((source) => !source.content.isEmpty())) return false;
|
|
1658
|
+
return true;
|
|
1659
|
+
}
|
|
1660
|
+
length() {
|
|
1661
|
+
return this.sources.reduce((length, source) => length + source.content.length(), this.intro.length);
|
|
1662
|
+
}
|
|
1663
|
+
trimLines() {
|
|
1664
|
+
return this.trim("[\\r\\n]");
|
|
1665
|
+
}
|
|
1666
|
+
trim(charType) {
|
|
1667
|
+
return this.trimStart(charType).trimEnd(charType);
|
|
1668
|
+
}
|
|
1669
|
+
trimStart(charType) {
|
|
1670
|
+
const rx = new RegExp("^" + (charType || "\\s") + "+");
|
|
1671
|
+
this.intro = this.intro.replace(rx, "");
|
|
1672
|
+
if (!this.intro) {
|
|
1673
|
+
let source;
|
|
1674
|
+
let i = 0;
|
|
1675
|
+
do {
|
|
1676
|
+
source = this.sources[i++];
|
|
1677
|
+
if (!source) {
|
|
1678
|
+
break;
|
|
1679
|
+
}
|
|
1680
|
+
} while (!source.content.trimStartAborted(charType));
|
|
1681
|
+
}
|
|
1682
|
+
return this;
|
|
1683
|
+
}
|
|
1684
|
+
trimEnd(charType) {
|
|
1685
|
+
const rx = new RegExp((charType || "\\s") + "+$");
|
|
1686
|
+
let source;
|
|
1687
|
+
let i = this.sources.length - 1;
|
|
1688
|
+
do {
|
|
1689
|
+
source = this.sources[i--];
|
|
1690
|
+
if (!source) {
|
|
1691
|
+
this.intro = this.intro.replace(rx, "");
|
|
1692
|
+
break;
|
|
1693
|
+
}
|
|
1694
|
+
} while (!source.content.trimEndAborted(charType));
|
|
1695
|
+
return this;
|
|
1696
|
+
}
|
|
1697
|
+
};
|
|
1698
|
+
|
|
1699
|
+
//#endregion
|
|
1700
|
+
export { Bundle, SourceMap, MagicString as default };
|