rollup 4.62.2 → 4.62.3
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/bin/rollup +13 -17
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +652 -889
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +4 -4
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.d.ts +6 -23
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +23 -23
- package/dist/shared/rollup.js +824 -1061
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +4 -4
- package/package.json +60 -60
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.62.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.62.3
|
|
4
|
+
Sun, 26 Jul 2026 14:58:21 GMT - commit a80a1974c584bfa8b694fb5d1a20f3fa75ebaf0a
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -42,7 +42,7 @@ function _mergeNamespaces(n, m) {
|
|
|
42
42
|
|
|
43
43
|
const promises__namespace = /*#__PURE__*/_interopNamespaceDefault(promises);
|
|
44
44
|
|
|
45
|
-
var version = "4.62.
|
|
45
|
+
var version = "4.62.3";
|
|
46
46
|
const package_ = {
|
|
47
47
|
version: version};
|
|
48
48
|
|
|
@@ -56,6 +56,170 @@ function ensureArray$1(items) {
|
|
|
56
56
|
return [];
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
const doNothing = () => { };
|
|
60
|
+
|
|
61
|
+
async function asyncFlatten(array) {
|
|
62
|
+
do {
|
|
63
|
+
array = (await Promise.all(array)).flat(Infinity);
|
|
64
|
+
} while (array.some((v) => v?.then));
|
|
65
|
+
return array;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
69
|
+
const { onwarn, onLog } = config;
|
|
70
|
+
const defaultOnLog = getDefaultOnLog(printLog, onwarn);
|
|
71
|
+
if (onLog) {
|
|
72
|
+
const minimalPriority = parseAst_js.logLevelPriority[logLevel];
|
|
73
|
+
return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
|
|
74
|
+
if (level === parseAst_js.LOGLEVEL_ERROR) {
|
|
75
|
+
return parseAst_js.error(normalizeLog(handledLog));
|
|
76
|
+
}
|
|
77
|
+
if (parseAst_js.logLevelPriority[level] >= minimalPriority) {
|
|
78
|
+
defaultOnLog(level, normalizeLog(handledLog));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return defaultOnLog;
|
|
83
|
+
};
|
|
84
|
+
const getDefaultOnLog = (printLog, onwarn) => onwarn
|
|
85
|
+
? (level, log) => {
|
|
86
|
+
if (level === parseAst_js.LOGLEVEL_WARN) {
|
|
87
|
+
onwarn(addLogToString(log), warning => printLog(parseAst_js.LOGLEVEL_WARN, normalizeLog(warning)));
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
printLog(level, log);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
: printLog;
|
|
94
|
+
const addLogToString = (log) => {
|
|
95
|
+
Object.defineProperty(log, 'toString', {
|
|
96
|
+
value: () => log.message,
|
|
97
|
+
writable: true
|
|
98
|
+
});
|
|
99
|
+
return log;
|
|
100
|
+
};
|
|
101
|
+
const normalizeLog = (log) => typeof log === 'string'
|
|
102
|
+
? { message: log }
|
|
103
|
+
: typeof log === 'function'
|
|
104
|
+
? normalizeLog(log())
|
|
105
|
+
: log;
|
|
106
|
+
const defaultPrintLog = (level, { message }) => {
|
|
107
|
+
switch (level) {
|
|
108
|
+
case parseAst_js.LOGLEVEL_WARN: {
|
|
109
|
+
return console.warn(message);
|
|
110
|
+
}
|
|
111
|
+
case parseAst_js.LOGLEVEL_DEBUG: {
|
|
112
|
+
return console.debug(message);
|
|
113
|
+
}
|
|
114
|
+
default: {
|
|
115
|
+
return console.info(message);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
function warnUnknownOptions(passedOptions, validOptions, optionType, log, ignoredKeys = /$./) {
|
|
120
|
+
const validOptionSet = new Set(validOptions);
|
|
121
|
+
const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
|
|
122
|
+
if (unknownOptions.length > 0) {
|
|
123
|
+
log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const treeshakePresets = {
|
|
127
|
+
recommended: {
|
|
128
|
+
annotations: true,
|
|
129
|
+
correctVarValueBeforeDeclaration: false,
|
|
130
|
+
manualPureFunctions: parseAst_js.EMPTY_ARRAY,
|
|
131
|
+
moduleSideEffects: () => true,
|
|
132
|
+
propertyReadSideEffects: true,
|
|
133
|
+
tryCatchDeoptimization: true,
|
|
134
|
+
unknownGlobalSideEffects: false
|
|
135
|
+
},
|
|
136
|
+
safest: {
|
|
137
|
+
annotations: true,
|
|
138
|
+
correctVarValueBeforeDeclaration: true,
|
|
139
|
+
manualPureFunctions: parseAst_js.EMPTY_ARRAY,
|
|
140
|
+
moduleSideEffects: () => true,
|
|
141
|
+
propertyReadSideEffects: true,
|
|
142
|
+
tryCatchDeoptimization: true,
|
|
143
|
+
unknownGlobalSideEffects: true
|
|
144
|
+
},
|
|
145
|
+
smallest: {
|
|
146
|
+
annotations: true,
|
|
147
|
+
correctVarValueBeforeDeclaration: false,
|
|
148
|
+
manualPureFunctions: parseAst_js.EMPTY_ARRAY,
|
|
149
|
+
moduleSideEffects: () => false,
|
|
150
|
+
propertyReadSideEffects: false,
|
|
151
|
+
tryCatchDeoptimization: false,
|
|
152
|
+
unknownGlobalSideEffects: false
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const jsxPresets = {
|
|
156
|
+
preserve: {
|
|
157
|
+
factory: null,
|
|
158
|
+
fragment: null,
|
|
159
|
+
importSource: null,
|
|
160
|
+
mode: 'preserve'
|
|
161
|
+
},
|
|
162
|
+
'preserve-react': {
|
|
163
|
+
factory: 'React.createElement',
|
|
164
|
+
fragment: 'React.Fragment',
|
|
165
|
+
importSource: 'react',
|
|
166
|
+
mode: 'preserve'
|
|
167
|
+
},
|
|
168
|
+
react: {
|
|
169
|
+
factory: 'React.createElement',
|
|
170
|
+
fragment: 'React.Fragment',
|
|
171
|
+
importSource: 'react',
|
|
172
|
+
mode: 'classic'
|
|
173
|
+
},
|
|
174
|
+
'react-jsx': {
|
|
175
|
+
factory: 'React.createElement',
|
|
176
|
+
importSource: 'react',
|
|
177
|
+
jsxImportSource: 'react/jsx-runtime',
|
|
178
|
+
mode: 'automatic'
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const generatedCodePresets = {
|
|
182
|
+
es2015: {
|
|
183
|
+
arrowFunctions: true,
|
|
184
|
+
constBindings: true,
|
|
185
|
+
objectShorthand: true,
|
|
186
|
+
reservedNamesAsProps: true,
|
|
187
|
+
symbols: true
|
|
188
|
+
},
|
|
189
|
+
es5: {
|
|
190
|
+
arrowFunctions: false,
|
|
191
|
+
constBindings: false,
|
|
192
|
+
objectShorthand: false,
|
|
193
|
+
reservedNamesAsProps: true,
|
|
194
|
+
symbols: false
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
|
|
198
|
+
const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
|
|
199
|
+
if (typeof value === 'string') {
|
|
200
|
+
const preset = presets[value];
|
|
201
|
+
if (preset) {
|
|
202
|
+
return preset;
|
|
203
|
+
}
|
|
204
|
+
parseAst_js.error(parseAst_js.logInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${parseAst_js.printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
|
|
205
|
+
}
|
|
206
|
+
return objectifyOption(value);
|
|
207
|
+
};
|
|
208
|
+
const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
|
|
209
|
+
const presetName = value?.preset;
|
|
210
|
+
if (presetName) {
|
|
211
|
+
const preset = presets[presetName];
|
|
212
|
+
if (preset) {
|
|
213
|
+
return { ...preset, ...value };
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
parseAst_js.error(parseAst_js.logInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${parseAst_js.printQuotedStringList(Object.keys(presets))}`, presetName));
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
|
|
220
|
+
};
|
|
221
|
+
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
222
|
+
|
|
59
223
|
var BuildPhase;
|
|
60
224
|
(function (BuildPhase) {
|
|
61
225
|
BuildPhase[BuildPhase["LOAD_AND_PARSE"] = 0] = "LOAD_AND_PARSE";
|
|
@@ -620,186 +784,22 @@ function getNamesFromAssets(consumedFiles) {
|
|
|
620
784
|
return { names, originalFileNames };
|
|
621
785
|
}
|
|
622
786
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
do {
|
|
627
|
-
array = (await Promise.all(array)).flat(Infinity);
|
|
628
|
-
} while (array.some((v) => v?.then));
|
|
629
|
-
return array;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
633
|
-
const { onwarn, onLog } = config;
|
|
634
|
-
const defaultOnLog = getDefaultOnLog(printLog, onwarn);
|
|
635
|
-
if (onLog) {
|
|
636
|
-
const minimalPriority = parseAst_js.logLevelPriority[logLevel];
|
|
637
|
-
return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
|
|
638
|
-
if (level === parseAst_js.LOGLEVEL_ERROR) {
|
|
639
|
-
return parseAst_js.error(normalizeLog(handledLog));
|
|
640
|
-
}
|
|
641
|
-
if (parseAst_js.logLevelPriority[level] >= minimalPriority) {
|
|
642
|
-
defaultOnLog(level, normalizeLog(handledLog));
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
return defaultOnLog;
|
|
647
|
-
};
|
|
648
|
-
const getDefaultOnLog = (printLog, onwarn) => onwarn
|
|
649
|
-
? (level, log) => {
|
|
650
|
-
if (level === parseAst_js.LOGLEVEL_WARN) {
|
|
651
|
-
onwarn(addLogToString(log), warning => printLog(parseAst_js.LOGLEVEL_WARN, normalizeLog(warning)));
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
printLog(level, log);
|
|
655
|
-
}
|
|
787
|
+
function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
788
|
+
if (parseAst_js.logLevelPriority[level] < parseAst_js.logLevelPriority[logLevel]) {
|
|
789
|
+
return doNothing;
|
|
656
790
|
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
value: () => log.message,
|
|
661
|
-
writable: true
|
|
662
|
-
});
|
|
663
|
-
return log;
|
|
664
|
-
};
|
|
665
|
-
const normalizeLog = (log) => typeof log === 'string'
|
|
666
|
-
? { message: log }
|
|
667
|
-
: typeof log === 'function'
|
|
668
|
-
? normalizeLog(log())
|
|
669
|
-
: log;
|
|
670
|
-
const defaultPrintLog = (level, { message }) => {
|
|
671
|
-
switch (level) {
|
|
672
|
-
case parseAst_js.LOGLEVEL_WARN: {
|
|
673
|
-
return console.warn(message);
|
|
674
|
-
}
|
|
675
|
-
case parseAst_js.LOGLEVEL_DEBUG: {
|
|
676
|
-
return console.debug(message);
|
|
791
|
+
return (log, pos) => {
|
|
792
|
+
if (pos != null) {
|
|
793
|
+
logger(parseAst_js.LOGLEVEL_WARN, parseAst_js.logInvalidLogPosition(pluginName));
|
|
677
794
|
}
|
|
678
|
-
|
|
679
|
-
|
|
795
|
+
log = normalizeLog(log);
|
|
796
|
+
if (log.code && !log.pluginCode) {
|
|
797
|
+
log.pluginCode = log.code;
|
|
680
798
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
|
|
686
|
-
if (unknownOptions.length > 0) {
|
|
687
|
-
log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
const treeshakePresets = {
|
|
691
|
-
recommended: {
|
|
692
|
-
annotations: true,
|
|
693
|
-
correctVarValueBeforeDeclaration: false,
|
|
694
|
-
manualPureFunctions: parseAst_js.EMPTY_ARRAY,
|
|
695
|
-
moduleSideEffects: () => true,
|
|
696
|
-
propertyReadSideEffects: true,
|
|
697
|
-
tryCatchDeoptimization: true,
|
|
698
|
-
unknownGlobalSideEffects: false
|
|
699
|
-
},
|
|
700
|
-
safest: {
|
|
701
|
-
annotations: true,
|
|
702
|
-
correctVarValueBeforeDeclaration: true,
|
|
703
|
-
manualPureFunctions: parseAst_js.EMPTY_ARRAY,
|
|
704
|
-
moduleSideEffects: () => true,
|
|
705
|
-
propertyReadSideEffects: true,
|
|
706
|
-
tryCatchDeoptimization: true,
|
|
707
|
-
unknownGlobalSideEffects: true
|
|
708
|
-
},
|
|
709
|
-
smallest: {
|
|
710
|
-
annotations: true,
|
|
711
|
-
correctVarValueBeforeDeclaration: false,
|
|
712
|
-
manualPureFunctions: parseAst_js.EMPTY_ARRAY,
|
|
713
|
-
moduleSideEffects: () => false,
|
|
714
|
-
propertyReadSideEffects: false,
|
|
715
|
-
tryCatchDeoptimization: false,
|
|
716
|
-
unknownGlobalSideEffects: false
|
|
717
|
-
}
|
|
718
|
-
};
|
|
719
|
-
const jsxPresets = {
|
|
720
|
-
preserve: {
|
|
721
|
-
factory: null,
|
|
722
|
-
fragment: null,
|
|
723
|
-
importSource: null,
|
|
724
|
-
mode: 'preserve'
|
|
725
|
-
},
|
|
726
|
-
'preserve-react': {
|
|
727
|
-
factory: 'React.createElement',
|
|
728
|
-
fragment: 'React.Fragment',
|
|
729
|
-
importSource: 'react',
|
|
730
|
-
mode: 'preserve'
|
|
731
|
-
},
|
|
732
|
-
react: {
|
|
733
|
-
factory: 'React.createElement',
|
|
734
|
-
fragment: 'React.Fragment',
|
|
735
|
-
importSource: 'react',
|
|
736
|
-
mode: 'classic'
|
|
737
|
-
},
|
|
738
|
-
'react-jsx': {
|
|
739
|
-
factory: 'React.createElement',
|
|
740
|
-
importSource: 'react',
|
|
741
|
-
jsxImportSource: 'react/jsx-runtime',
|
|
742
|
-
mode: 'automatic'
|
|
743
|
-
}
|
|
744
|
-
};
|
|
745
|
-
const generatedCodePresets = {
|
|
746
|
-
es2015: {
|
|
747
|
-
arrowFunctions: true,
|
|
748
|
-
constBindings: true,
|
|
749
|
-
objectShorthand: true,
|
|
750
|
-
reservedNamesAsProps: true,
|
|
751
|
-
symbols: true
|
|
752
|
-
},
|
|
753
|
-
es5: {
|
|
754
|
-
arrowFunctions: false,
|
|
755
|
-
constBindings: false,
|
|
756
|
-
objectShorthand: false,
|
|
757
|
-
reservedNamesAsProps: true,
|
|
758
|
-
symbols: false
|
|
759
|
-
}
|
|
760
|
-
};
|
|
761
|
-
const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
|
|
762
|
-
const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
|
|
763
|
-
if (typeof value === 'string') {
|
|
764
|
-
const preset = presets[value];
|
|
765
|
-
if (preset) {
|
|
766
|
-
return preset;
|
|
767
|
-
}
|
|
768
|
-
parseAst_js.error(parseAst_js.logInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${parseAst_js.printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
|
|
769
|
-
}
|
|
770
|
-
return objectifyOption(value);
|
|
771
|
-
};
|
|
772
|
-
const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
|
|
773
|
-
const presetName = value?.preset;
|
|
774
|
-
if (presetName) {
|
|
775
|
-
const preset = presets[presetName];
|
|
776
|
-
if (preset) {
|
|
777
|
-
return { ...preset, ...value };
|
|
778
|
-
}
|
|
779
|
-
else {
|
|
780
|
-
parseAst_js.error(parseAst_js.logInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${parseAst_js.printQuotedStringList(Object.keys(presets))}`, presetName));
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
|
|
784
|
-
};
|
|
785
|
-
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
|
|
786
|
-
|
|
787
|
-
function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
788
|
-
if (parseAst_js.logLevelPriority[level] < parseAst_js.logLevelPriority[logLevel]) {
|
|
789
|
-
return doNothing;
|
|
790
|
-
}
|
|
791
|
-
return (log, pos) => {
|
|
792
|
-
if (pos != null) {
|
|
793
|
-
logger(parseAst_js.LOGLEVEL_WARN, parseAst_js.logInvalidLogPosition(pluginName));
|
|
794
|
-
}
|
|
795
|
-
log = normalizeLog(log);
|
|
796
|
-
if (log.code && !log.pluginCode) {
|
|
797
|
-
log.pluginCode = log.code;
|
|
798
|
-
}
|
|
799
|
-
log.code = code;
|
|
800
|
-
log.plugin = pluginName;
|
|
801
|
-
logger(level, log);
|
|
802
|
-
};
|
|
799
|
+
log.code = code;
|
|
800
|
+
log.plugin = pluginName;
|
|
801
|
+
logger(level, log);
|
|
802
|
+
};
|
|
803
803
|
}
|
|
804
804
|
|
|
805
805
|
const ANONYMOUS_PLUGIN_PREFIX = 'at position ';
|
|
@@ -1881,7 +1881,15 @@ function requireParse () {
|
|
|
1881
1881
|
}
|
|
1882
1882
|
};
|
|
1883
1883
|
|
|
1884
|
-
const
|
|
1884
|
+
const buildCharClassStar = chars => {
|
|
1885
|
+
const source = chars.length === 1
|
|
1886
|
+
? utils.escapeRegex(chars[0])
|
|
1887
|
+
: `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
|
|
1888
|
+
|
|
1889
|
+
return `${source}*`;
|
|
1890
|
+
};
|
|
1891
|
+
|
|
1892
|
+
const getStarExtglobSequenceChars = pattern => {
|
|
1885
1893
|
let index = 0;
|
|
1886
1894
|
const chars = [];
|
|
1887
1895
|
|
|
@@ -1910,11 +1918,7 @@ function requireParse () {
|
|
|
1910
1918
|
return;
|
|
1911
1919
|
}
|
|
1912
1920
|
|
|
1913
|
-
|
|
1914
|
-
? utils.escapeRegex(chars[0])
|
|
1915
|
-
: `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
|
|
1916
|
-
|
|
1917
|
-
return `${source}*`;
|
|
1921
|
+
return chars;
|
|
1918
1922
|
};
|
|
1919
1923
|
|
|
1920
1924
|
const repeatedExtglobRecursion = pattern => {
|
|
@@ -1953,17 +1957,43 @@ function requireParse () {
|
|
|
1953
1957
|
}
|
|
1954
1958
|
}
|
|
1955
1959
|
|
|
1960
|
+
// A repeated extglob is "risky" (prone to catastrophic backtracking) when a
|
|
1961
|
+
// branch is itself a `*(...)` sequence, since that nests an unbounded quantifier
|
|
1962
|
+
// inside the outer `+(...)`/`*(...)`. When *every* branch reduces to single
|
|
1963
|
+
// characters we can emit one flat, ReDoS-safe character class that preserves the
|
|
1964
|
+
// meaning of ALL branches (e.g. `+(*(a)|*(b))` -> `[ab]*`), rather than dropping
|
|
1965
|
+
// every branch but the first.
|
|
1966
|
+
const safeChars = [];
|
|
1967
|
+
let sawStarSequence = false;
|
|
1968
|
+
let combinable = true;
|
|
1969
|
+
|
|
1956
1970
|
for (const branch of branches) {
|
|
1957
|
-
const
|
|
1958
|
-
if (
|
|
1959
|
-
|
|
1971
|
+
const chars = getStarExtglobSequenceChars(branch);
|
|
1972
|
+
if (chars) {
|
|
1973
|
+
sawStarSequence = true;
|
|
1974
|
+
safeChars.push(...chars);
|
|
1975
|
+
continue;
|
|
1960
1976
|
}
|
|
1961
1977
|
|
|
1978
|
+
const literal = normalizeSimpleBranch(branch);
|
|
1979
|
+
if (literal && literal.length === 1) {
|
|
1980
|
+
safeChars.push(literal);
|
|
1981
|
+
continue;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
combinable = false;
|
|
1985
|
+
|
|
1962
1986
|
if (repeatedExtglobRecursion(branch) > max) {
|
|
1963
1987
|
return { risky: true };
|
|
1964
1988
|
}
|
|
1965
1989
|
}
|
|
1966
1990
|
|
|
1991
|
+
if (sawStarSequence) {
|
|
1992
|
+
return combinable
|
|
1993
|
+
? { risky: true, safeOutput: buildCharClassStar([...new Set(safeChars)]) }
|
|
1994
|
+
: { risky: true };
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1967
1997
|
return { risky: false };
|
|
1968
1998
|
};
|
|
1969
1999
|
|
|
@@ -3065,6 +3095,18 @@ function requirePicomatch$1 () {
|
|
|
3065
3095
|
* const isMatch = picomatch('*.!(*a)');
|
|
3066
3096
|
* console.log(isMatch('a.a')); //=> false
|
|
3067
3097
|
* console.log(isMatch('a.b')); //=> true
|
|
3098
|
+
*
|
|
3099
|
+
* // For environments without `node.js`, `picomatch/posix` provides you a dependency-free matcher, without automatic OS detection.
|
|
3100
|
+
* const picomatch = require('picomatch/posix');
|
|
3101
|
+
* // the same API, defaulting to posix paths
|
|
3102
|
+
* const isMatch = picomatch('a/*');
|
|
3103
|
+
* console.log(isMatch('a\\b')); //=> false
|
|
3104
|
+
* console.log(isMatch('a/b')); //=> true
|
|
3105
|
+
*
|
|
3106
|
+
* // you can still configure the matcher function to accept windows paths
|
|
3107
|
+
* const isMatch = picomatch('a/*', { options: windows });
|
|
3108
|
+
* console.log(isMatch('a\\b')); //=> true
|
|
3109
|
+
* console.log(isMatch('a/b')); //=> true
|
|
3068
3110
|
* ```
|
|
3069
3111
|
* @name picomatch
|
|
3070
3112
|
* @param {String|Array} `globs` One or more glob patterns.
|
|
@@ -3202,9 +3244,9 @@ function requirePicomatch$1 () {
|
|
|
3202
3244
|
* @api public
|
|
3203
3245
|
*/
|
|
3204
3246
|
|
|
3205
|
-
picomatch.matchBase = (input, glob, options) => {
|
|
3247
|
+
picomatch.matchBase = (input, glob, options, posix = options && options.windows) => {
|
|
3206
3248
|
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
3207
|
-
return regex.test(utils.basename(input));
|
|
3249
|
+
return regex.test(utils.basename(input, { windows: posix }));
|
|
3208
3250
|
};
|
|
3209
3251
|
|
|
3210
3252
|
/**
|
|
@@ -4330,214 +4372,160 @@ function encode(decoded) {
|
|
|
4330
4372
|
return writer.flush();
|
|
4331
4373
|
}
|
|
4332
4374
|
|
|
4333
|
-
|
|
4375
|
+
//#region src/BitSet.ts
|
|
4376
|
+
var BitSet = class BitSet {
|
|
4334
4377
|
constructor(arg) {
|
|
4335
4378
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
4336
4379
|
}
|
|
4337
|
-
|
|
4338
4380
|
add(n) {
|
|
4339
4381
|
this.bits[n >> 5] |= 1 << (n & 31);
|
|
4340
4382
|
}
|
|
4341
|
-
|
|
4342
4383
|
has(n) {
|
|
4343
|
-
return !!(this.bits[n >> 5] &
|
|
4384
|
+
return !!(this.bits[n >> 5] & 1 << (n & 31));
|
|
4344
4385
|
}
|
|
4345
|
-
}
|
|
4346
|
-
|
|
4347
|
-
|
|
4386
|
+
};
|
|
4387
|
+
//#endregion
|
|
4388
|
+
//#region src/Chunk.ts
|
|
4389
|
+
var Chunk$1 = class Chunk {
|
|
4348
4390
|
constructor(start, end, content) {
|
|
4349
4391
|
this.start = start;
|
|
4350
4392
|
this.end = end;
|
|
4351
4393
|
this.original = content;
|
|
4352
|
-
|
|
4353
|
-
this.
|
|
4354
|
-
this.outro = '';
|
|
4355
|
-
|
|
4394
|
+
this.intro = "";
|
|
4395
|
+
this.outro = "";
|
|
4356
4396
|
this.content = content;
|
|
4357
4397
|
this.storeName = false;
|
|
4358
4398
|
this.edited = false;
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
this.previous = null;
|
|
4362
|
-
this.next = null;
|
|
4363
|
-
}
|
|
4399
|
+
this.previous = null;
|
|
4400
|
+
this.next = null;
|
|
4364
4401
|
}
|
|
4365
|
-
|
|
4366
4402
|
appendLeft(content) {
|
|
4367
4403
|
this.outro += content;
|
|
4368
4404
|
}
|
|
4369
|
-
|
|
4370
4405
|
appendRight(content) {
|
|
4371
4406
|
this.intro = this.intro + content;
|
|
4372
4407
|
}
|
|
4373
|
-
|
|
4374
4408
|
clone() {
|
|
4375
4409
|
const chunk = new Chunk(this.start, this.end, this.original);
|
|
4376
|
-
|
|
4377
4410
|
chunk.intro = this.intro;
|
|
4378
4411
|
chunk.outro = this.outro;
|
|
4379
4412
|
chunk.content = this.content;
|
|
4380
4413
|
chunk.storeName = this.storeName;
|
|
4381
4414
|
chunk.edited = this.edited;
|
|
4382
|
-
|
|
4383
4415
|
return chunk;
|
|
4384
4416
|
}
|
|
4385
|
-
|
|
4386
4417
|
contains(index) {
|
|
4387
4418
|
return this.start < index && index < this.end;
|
|
4388
4419
|
}
|
|
4389
|
-
|
|
4390
4420
|
eachNext(fn) {
|
|
4391
|
-
|
|
4421
|
+
fn(this);
|
|
4422
|
+
let chunk = this.next;
|
|
4392
4423
|
while (chunk) {
|
|
4393
4424
|
fn(chunk);
|
|
4394
4425
|
chunk = chunk.next;
|
|
4395
4426
|
}
|
|
4396
4427
|
}
|
|
4397
|
-
|
|
4398
4428
|
eachPrevious(fn) {
|
|
4399
|
-
|
|
4429
|
+
fn(this);
|
|
4430
|
+
let chunk = this.previous;
|
|
4400
4431
|
while (chunk) {
|
|
4401
4432
|
fn(chunk);
|
|
4402
4433
|
chunk = chunk.previous;
|
|
4403
4434
|
}
|
|
4404
4435
|
}
|
|
4405
|
-
|
|
4406
4436
|
edit(content, storeName, contentOnly) {
|
|
4407
4437
|
this.content = content;
|
|
4408
4438
|
if (!contentOnly) {
|
|
4409
|
-
this.intro =
|
|
4410
|
-
this.outro =
|
|
4439
|
+
this.intro = "";
|
|
4440
|
+
this.outro = "";
|
|
4411
4441
|
}
|
|
4412
4442
|
this.storeName = storeName;
|
|
4413
|
-
|
|
4414
4443
|
this.edited = true;
|
|
4415
|
-
|
|
4416
4444
|
return this;
|
|
4417
4445
|
}
|
|
4418
|
-
|
|
4419
4446
|
prependLeft(content) {
|
|
4420
4447
|
this.outro = content + this.outro;
|
|
4421
4448
|
}
|
|
4422
|
-
|
|
4423
4449
|
prependRight(content) {
|
|
4424
4450
|
this.intro = content + this.intro;
|
|
4425
4451
|
}
|
|
4426
|
-
|
|
4427
4452
|
reset() {
|
|
4428
|
-
this.intro =
|
|
4429
|
-
this.outro =
|
|
4453
|
+
this.intro = "";
|
|
4454
|
+
this.outro = "";
|
|
4430
4455
|
if (this.edited) {
|
|
4431
4456
|
this.content = this.original;
|
|
4432
4457
|
this.storeName = false;
|
|
4433
4458
|
this.edited = false;
|
|
4434
4459
|
}
|
|
4435
4460
|
}
|
|
4436
|
-
|
|
4437
4461
|
split(index) {
|
|
4438
4462
|
const sliceIndex = index - this.start;
|
|
4439
|
-
|
|
4440
4463
|
const originalBefore = this.original.slice(0, sliceIndex);
|
|
4441
4464
|
const originalAfter = this.original.slice(sliceIndex);
|
|
4442
|
-
|
|
4443
4465
|
this.original = originalBefore;
|
|
4444
|
-
|
|
4445
4466
|
const newChunk = new Chunk(index, this.end, originalAfter);
|
|
4446
4467
|
newChunk.outro = this.outro;
|
|
4447
|
-
this.outro =
|
|
4448
|
-
|
|
4468
|
+
this.outro = "";
|
|
4449
4469
|
this.end = index;
|
|
4450
|
-
|
|
4451
4470
|
if (this.edited) {
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
// ' test'.trim()
|
|
4456
|
-
// split -> ' ' + 'test'
|
|
4457
|
-
// ✔️ edit -> '' + 'test'
|
|
4458
|
-
// ✖️ edit -> 'test' + ''
|
|
4459
|
-
// TODO is this block necessary?...
|
|
4460
|
-
newChunk.edit('', false);
|
|
4461
|
-
this.content = '';
|
|
4462
|
-
} else {
|
|
4463
|
-
this.content = originalBefore;
|
|
4464
|
-
}
|
|
4465
|
-
|
|
4471
|
+
newChunk.edit("", false);
|
|
4472
|
+
this.content = "";
|
|
4473
|
+
} else this.content = originalBefore;
|
|
4466
4474
|
newChunk.next = this.next;
|
|
4467
4475
|
if (newChunk.next) newChunk.next.previous = newChunk;
|
|
4468
4476
|
newChunk.previous = this;
|
|
4469
4477
|
this.next = newChunk;
|
|
4470
|
-
|
|
4471
4478
|
return newChunk;
|
|
4472
4479
|
}
|
|
4473
|
-
|
|
4474
4480
|
toString() {
|
|
4475
4481
|
return this.intro + this.content + this.outro;
|
|
4476
4482
|
}
|
|
4477
|
-
|
|
4478
4483
|
trimEnd(rx) {
|
|
4479
|
-
this.outro = this.outro.replace(rx,
|
|
4484
|
+
this.outro = this.outro.replace(rx, "");
|
|
4480
4485
|
if (this.outro.length) return true;
|
|
4481
|
-
|
|
4482
|
-
const trimmed = this.content.replace(rx, '');
|
|
4483
|
-
|
|
4486
|
+
const trimmed = this.content.replace(rx, "");
|
|
4484
4487
|
if (trimmed.length) {
|
|
4485
4488
|
if (trimmed !== this.content) {
|
|
4486
|
-
this.split(this.start + trimmed.length).edit(
|
|
4487
|
-
if (this.edited)
|
|
4488
|
-
// save the change, if it has been edited
|
|
4489
|
-
this.edit(trimmed, this.storeName, true);
|
|
4490
|
-
}
|
|
4489
|
+
this.split(this.start + trimmed.length).edit("", void 0, true);
|
|
4490
|
+
if (this.edited) this.edit(trimmed, this.storeName, true);
|
|
4491
4491
|
}
|
|
4492
4492
|
return true;
|
|
4493
4493
|
} else {
|
|
4494
|
-
this.edit(
|
|
4495
|
-
|
|
4496
|
-
this.intro = this.intro.replace(rx, '');
|
|
4494
|
+
this.edit("", void 0, true);
|
|
4495
|
+
this.intro = this.intro.replace(rx, "");
|
|
4497
4496
|
if (this.intro.length) return true;
|
|
4498
4497
|
}
|
|
4499
4498
|
}
|
|
4500
|
-
|
|
4501
4499
|
trimStart(rx) {
|
|
4502
|
-
this.intro = this.intro.replace(rx,
|
|
4500
|
+
this.intro = this.intro.replace(rx, "");
|
|
4503
4501
|
if (this.intro.length) return true;
|
|
4504
|
-
|
|
4505
|
-
const trimmed = this.content.replace(rx, '');
|
|
4506
|
-
|
|
4502
|
+
const trimmed = this.content.replace(rx, "");
|
|
4507
4503
|
if (trimmed.length) {
|
|
4508
4504
|
if (trimmed !== this.content) {
|
|
4509
4505
|
const newChunk = this.split(this.end - trimmed.length);
|
|
4510
|
-
if (this.edited)
|
|
4511
|
-
|
|
4512
|
-
newChunk.edit(trimmed, this.storeName, true);
|
|
4513
|
-
}
|
|
4514
|
-
this.edit('', undefined, true);
|
|
4506
|
+
if (this.edited) newChunk.edit(trimmed, this.storeName, true);
|
|
4507
|
+
this.edit("", void 0, true);
|
|
4515
4508
|
}
|
|
4516
4509
|
return true;
|
|
4517
4510
|
} else {
|
|
4518
|
-
this.edit(
|
|
4519
|
-
|
|
4520
|
-
this.outro = this.outro.replace(rx, '');
|
|
4511
|
+
this.edit("", void 0, true);
|
|
4512
|
+
this.outro = this.outro.replace(rx, "");
|
|
4521
4513
|
if (this.outro.length) return true;
|
|
4522
4514
|
}
|
|
4523
4515
|
}
|
|
4524
4516
|
};
|
|
4525
|
-
|
|
4517
|
+
//#endregion
|
|
4518
|
+
//#region src/SourceMap.ts
|
|
4526
4519
|
function getBtoa() {
|
|
4527
|
-
if (typeof globalThis !==
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
|
|
4534
|
-
};
|
|
4535
|
-
}
|
|
4520
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.btoa === "function") return (str) => globalThis.btoa(unescape(encodeURIComponent(str)));
|
|
4521
|
+
const buffer = globalThis["Buffer"];
|
|
4522
|
+
if (buffer) return (str) => buffer.from(str, "utf-8").toString("base64");
|
|
4523
|
+
return () => {
|
|
4524
|
+
throw new Error("Unsupported environment: `window.btoa` or `Buffer` should be supported.");
|
|
4525
|
+
};
|
|
4536
4526
|
}
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
class SourceMap {
|
|
4527
|
+
const btoa = /* #__PURE__ */ getBtoa();
|
|
4528
|
+
var SourceMap = class {
|
|
4541
4529
|
constructor(properties) {
|
|
4542
4530
|
this.version = 3;
|
|
4543
4531
|
this.file = properties.file;
|
|
@@ -4545,103 +4533,87 @@ class SourceMap {
|
|
|
4545
4533
|
this.sourcesContent = properties.sourcesContent;
|
|
4546
4534
|
this.names = properties.names;
|
|
4547
4535
|
this.mappings = encode(properties.mappings);
|
|
4548
|
-
if (typeof properties.x_google_ignoreList !==
|
|
4549
|
-
|
|
4550
|
-
}
|
|
4551
|
-
if (typeof properties.debugId !== 'undefined') {
|
|
4552
|
-
this.debugId = properties.debugId;
|
|
4553
|
-
}
|
|
4536
|
+
if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
4537
|
+
if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
|
|
4554
4538
|
}
|
|
4555
|
-
|
|
4539
|
+
/**
|
|
4540
|
+
* Returns the equivalent of `JSON.stringify(map)`
|
|
4541
|
+
*/
|
|
4556
4542
|
toString() {
|
|
4557
4543
|
return JSON.stringify(this);
|
|
4558
4544
|
}
|
|
4559
|
-
|
|
4545
|
+
/**
|
|
4546
|
+
* Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
|
|
4547
|
+
* `generateMap(options?: SourceMapOptions): SourceMap;`
|
|
4548
|
+
*/
|
|
4560
4549
|
toUrl() {
|
|
4561
|
-
return
|
|
4550
|
+
return `data:application/json;charset=utf-8;base64,${btoa(this.toString())}`;
|
|
4562
4551
|
}
|
|
4563
|
-
}
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
const
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
return null;
|
|
4573
|
-
}
|
|
4574
|
-
|
|
4575
|
-
// More lines tabbed than spaced? Assume tabs, and
|
|
4576
|
-
// default to tabs in the case of a tie (or nothing
|
|
4577
|
-
// to go on)
|
|
4578
|
-
if (tabbed.length >= spaced.length) {
|
|
4579
|
-
return '\t';
|
|
4552
|
+
};
|
|
4553
|
+
//#endregion
|
|
4554
|
+
//#region src/utils/getLocator.ts
|
|
4555
|
+
function getLocator(source) {
|
|
4556
|
+
const originalLines = source.split("\n");
|
|
4557
|
+
const lineOffsets = [];
|
|
4558
|
+
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
4559
|
+
lineOffsets.push(pos);
|
|
4560
|
+
pos += originalLines[i].length + 1;
|
|
4580
4561
|
}
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4562
|
+
return function locate(index) {
|
|
4563
|
+
let i = 0;
|
|
4564
|
+
let j = lineOffsets.length;
|
|
4565
|
+
while (i < j) {
|
|
4566
|
+
const m = i + j >> 1;
|
|
4567
|
+
if (index < lineOffsets[m]) j = m;
|
|
4568
|
+
else i = m + 1;
|
|
4569
|
+
}
|
|
4570
|
+
const line = i - 1;
|
|
4571
|
+
return {
|
|
4572
|
+
line,
|
|
4573
|
+
column: index - lineOffsets[line]
|
|
4574
|
+
};
|
|
4575
|
+
};
|
|
4589
4576
|
}
|
|
4590
|
-
|
|
4577
|
+
//#endregion
|
|
4578
|
+
//#region src/utils/getRelativePath.ts
|
|
4591
4579
|
function getRelativePath(from, to) {
|
|
4592
4580
|
const fromParts = from.split(/[/\\]/);
|
|
4593
4581
|
const toParts = to.split(/[/\\]/);
|
|
4594
|
-
|
|
4595
|
-
fromParts.pop(); // get dirname
|
|
4596
|
-
|
|
4582
|
+
fromParts.pop();
|
|
4597
4583
|
while (fromParts[0] === toParts[0]) {
|
|
4598
4584
|
fromParts.shift();
|
|
4599
4585
|
toParts.shift();
|
|
4600
4586
|
}
|
|
4601
|
-
|
|
4602
4587
|
if (fromParts.length) {
|
|
4603
4588
|
let i = fromParts.length;
|
|
4604
|
-
while (i--) fromParts[i] =
|
|
4589
|
+
while (i--) fromParts[i] = "..";
|
|
4605
4590
|
}
|
|
4606
|
-
|
|
4607
|
-
return fromParts.concat(toParts).join('/');
|
|
4591
|
+
return fromParts.concat(toParts).join("/");
|
|
4608
4592
|
}
|
|
4609
|
-
|
|
4593
|
+
//#endregion
|
|
4594
|
+
//#region src/utils/guessIndent.ts
|
|
4595
|
+
function guessIndent(code) {
|
|
4596
|
+
const lines = code.split("\n");
|
|
4597
|
+
const tabbed = lines.filter((line) => /^\t+/.test(line));
|
|
4598
|
+
const spaced = lines.filter((line) => /^ {2,}/.test(line));
|
|
4599
|
+
if (tabbed.length === 0 && spaced.length === 0) return null;
|
|
4600
|
+
if (tabbed.length >= spaced.length) return " ";
|
|
4601
|
+
const min = spaced.reduce((previous, current) => {
|
|
4602
|
+
const numSpaces = /^ +/.exec(current)[0].length;
|
|
4603
|
+
return Math.min(numSpaces, previous);
|
|
4604
|
+
}, Infinity);
|
|
4605
|
+
return " ".repeat(min);
|
|
4606
|
+
}
|
|
4607
|
+
//#endregion
|
|
4608
|
+
//#region src/utils/isObject.ts
|
|
4610
4609
|
const toString = Object.prototype.toString;
|
|
4611
|
-
|
|
4612
4610
|
function isObject(thing) {
|
|
4613
|
-
return toString.call(thing) ===
|
|
4614
|
-
}
|
|
4615
|
-
|
|
4616
|
-
function getLocator(source) {
|
|
4617
|
-
const originalLines = source.split('\n');
|
|
4618
|
-
const lineOffsets = [];
|
|
4619
|
-
|
|
4620
|
-
for (let i = 0, pos = 0; i < originalLines.length; i++) {
|
|
4621
|
-
lineOffsets.push(pos);
|
|
4622
|
-
pos += originalLines[i].length + 1;
|
|
4623
|
-
}
|
|
4624
|
-
|
|
4625
|
-
return function locate(index) {
|
|
4626
|
-
let i = 0;
|
|
4627
|
-
let j = lineOffsets.length;
|
|
4628
|
-
while (i < j) {
|
|
4629
|
-
const m = (i + j) >> 1;
|
|
4630
|
-
if (index < lineOffsets[m]) {
|
|
4631
|
-
j = m;
|
|
4632
|
-
} else {
|
|
4633
|
-
i = m + 1;
|
|
4634
|
-
}
|
|
4635
|
-
}
|
|
4636
|
-
const line = i - 1;
|
|
4637
|
-
const column = index - lineOffsets[line];
|
|
4638
|
-
return { line, column };
|
|
4639
|
-
};
|
|
4611
|
+
return toString.call(thing) === "[object Object]";
|
|
4640
4612
|
}
|
|
4641
|
-
|
|
4613
|
+
//#endregion
|
|
4614
|
+
//#region src/utils/Mappings.ts
|
|
4642
4615
|
const wordRegex = /\w/;
|
|
4643
|
-
|
|
4644
|
-
class Mappings {
|
|
4616
|
+
var Mappings = class {
|
|
4645
4617
|
constructor(hires) {
|
|
4646
4618
|
this.hires = hires;
|
|
4647
4619
|
this.generatedCodeLine = 0;
|
|
@@ -4650,52 +4622,47 @@ class Mappings {
|
|
|
4650
4622
|
this.rawSegments = this.raw[this.generatedCodeLine] = [];
|
|
4651
4623
|
this.pending = null;
|
|
4652
4624
|
}
|
|
4653
|
-
|
|
4654
4625
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
4655
4626
|
if (content.length) {
|
|
4656
4627
|
const contentLengthMinusOne = content.length - 1;
|
|
4657
|
-
let contentLineEnd = content.indexOf(
|
|
4628
|
+
let contentLineEnd = content.indexOf("\n", 0);
|
|
4658
4629
|
let previousContentLineEnd = -1;
|
|
4659
|
-
// Loop through each line in the content and add a segment, but stop if the last line is empty,
|
|
4660
|
-
// else code afterwards would fill one line too many
|
|
4661
4630
|
while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
|
|
4662
|
-
const segment = [
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4631
|
+
const segment = [
|
|
4632
|
+
this.generatedCodeColumn,
|
|
4633
|
+
sourceIndex,
|
|
4634
|
+
loc.line,
|
|
4635
|
+
loc.column
|
|
4636
|
+
];
|
|
4637
|
+
if (nameIndex >= 0) segment.push(nameIndex);
|
|
4666
4638
|
this.rawSegments.push(segment);
|
|
4667
|
-
|
|
4668
4639
|
this.generatedCodeLine += 1;
|
|
4669
4640
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
4670
4641
|
this.generatedCodeColumn = 0;
|
|
4671
|
-
|
|
4672
4642
|
previousContentLineEnd = contentLineEnd;
|
|
4673
|
-
contentLineEnd = content.indexOf(
|
|
4674
|
-
}
|
|
4675
|
-
|
|
4676
|
-
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
4677
|
-
if (nameIndex >= 0) {
|
|
4678
|
-
segment.push(nameIndex);
|
|
4643
|
+
contentLineEnd = content.indexOf("\n", contentLineEnd + 1);
|
|
4679
4644
|
}
|
|
4645
|
+
const segment = [
|
|
4646
|
+
this.generatedCodeColumn,
|
|
4647
|
+
sourceIndex,
|
|
4648
|
+
loc.line,
|
|
4649
|
+
loc.column
|
|
4650
|
+
];
|
|
4651
|
+
if (nameIndex >= 0) segment.push(nameIndex);
|
|
4680
4652
|
this.rawSegments.push(segment);
|
|
4681
|
-
|
|
4682
4653
|
this.advance(content.slice(previousContentLineEnd + 1));
|
|
4683
4654
|
} else if (this.pending) {
|
|
4684
4655
|
this.rawSegments.push(this.pending);
|
|
4685
4656
|
this.advance(content);
|
|
4686
4657
|
}
|
|
4687
|
-
|
|
4688
4658
|
this.pending = null;
|
|
4689
4659
|
}
|
|
4690
|
-
|
|
4691
4660
|
addUneditedChunk(sourceIndex, chunk, original, loc, sourcemapLocations) {
|
|
4692
4661
|
let originalCharIndex = chunk.start;
|
|
4693
4662
|
let first = true;
|
|
4694
|
-
// when iterating each char, check if it's in a word boundary
|
|
4695
4663
|
let charInHiresBoundary = false;
|
|
4696
|
-
|
|
4697
4664
|
while (originalCharIndex < chunk.end) {
|
|
4698
|
-
if (original[originalCharIndex] ===
|
|
4665
|
+
if (original[originalCharIndex] === "\n") {
|
|
4699
4666
|
loc.line += 1;
|
|
4700
4667
|
loc.column = 0;
|
|
4701
4668
|
this.generatedCodeLine += 1;
|
|
@@ -4705,42 +4672,34 @@ class Mappings {
|
|
|
4705
4672
|
charInHiresBoundary = false;
|
|
4706
4673
|
} else {
|
|
4707
4674
|
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
4708
|
-
const segment = [
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
charInHiresBoundary = true;
|
|
4717
|
-
}
|
|
4718
|
-
} else {
|
|
4719
|
-
// for non-word char, end the boundary by pushing a segment
|
|
4675
|
+
const segment = [
|
|
4676
|
+
this.generatedCodeColumn,
|
|
4677
|
+
sourceIndex,
|
|
4678
|
+
loc.line,
|
|
4679
|
+
loc.column
|
|
4680
|
+
];
|
|
4681
|
+
if (this.hires === "boundary") if (wordRegex.test(original[originalCharIndex])) {
|
|
4682
|
+
if (!charInHiresBoundary) {
|
|
4720
4683
|
this.rawSegments.push(segment);
|
|
4721
|
-
charInHiresBoundary =
|
|
4684
|
+
charInHiresBoundary = true;
|
|
4722
4685
|
}
|
|
4723
4686
|
} else {
|
|
4724
4687
|
this.rawSegments.push(segment);
|
|
4688
|
+
charInHiresBoundary = false;
|
|
4725
4689
|
}
|
|
4690
|
+
else this.rawSegments.push(segment);
|
|
4726
4691
|
}
|
|
4727
|
-
|
|
4728
4692
|
loc.column += 1;
|
|
4729
4693
|
this.generatedCodeColumn += 1;
|
|
4730
4694
|
first = false;
|
|
4731
4695
|
}
|
|
4732
|
-
|
|
4733
4696
|
originalCharIndex += 1;
|
|
4734
4697
|
}
|
|
4735
|
-
|
|
4736
4698
|
this.pending = null;
|
|
4737
4699
|
}
|
|
4738
|
-
|
|
4739
4700
|
advance(str) {
|
|
4740
4701
|
if (!str) return;
|
|
4741
|
-
|
|
4742
|
-
const lines = str.split('\n');
|
|
4743
|
-
|
|
4702
|
+
const lines = str.split("\n");
|
|
4744
4703
|
if (lines.length > 1) {
|
|
4745
4704
|
for (let i = 0; i < lines.length - 1; i++) {
|
|
4746
4705
|
this.generatedCodeLine++;
|
|
@@ -4748,1029 +4707,872 @@ class Mappings {
|
|
|
4748
4707
|
}
|
|
4749
4708
|
this.generatedCodeColumn = 0;
|
|
4750
4709
|
}
|
|
4751
|
-
|
|
4752
4710
|
this.generatedCodeColumn += lines[lines.length - 1].length;
|
|
4753
4711
|
}
|
|
4754
|
-
}
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4712
|
+
};
|
|
4713
|
+
//#endregion
|
|
4714
|
+
//#region src/MagicString.ts
|
|
4715
|
+
const n = "\n";
|
|
4716
|
+
const NEWLINE_CHAR = "\n".charCodeAt(0);
|
|
4717
|
+
const CR_CHAR = "\r".charCodeAt(0);
|
|
4758
4718
|
const warned = {
|
|
4759
4719
|
insertLeft: false,
|
|
4760
4720
|
insertRight: false,
|
|
4761
|
-
storeName: false
|
|
4721
|
+
storeName: false
|
|
4762
4722
|
};
|
|
4763
|
-
|
|
4764
|
-
class MagicString {
|
|
4723
|
+
var MagicString = class MagicString {
|
|
4765
4724
|
constructor(string, options = {}) {
|
|
4766
4725
|
const chunk = new Chunk$1(0, string.length, string);
|
|
4767
|
-
|
|
4768
4726
|
Object.defineProperties(this, {
|
|
4769
|
-
original: {
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4727
|
+
original: {
|
|
4728
|
+
writable: true,
|
|
4729
|
+
value: string
|
|
4730
|
+
},
|
|
4731
|
+
outro: {
|
|
4732
|
+
writable: true,
|
|
4733
|
+
value: ""
|
|
4734
|
+
},
|
|
4735
|
+
intro: {
|
|
4736
|
+
writable: true,
|
|
4737
|
+
value: ""
|
|
4738
|
+
},
|
|
4739
|
+
firstChunk: {
|
|
4740
|
+
writable: true,
|
|
4741
|
+
value: chunk
|
|
4742
|
+
},
|
|
4743
|
+
lastChunk: {
|
|
4744
|
+
writable: true,
|
|
4745
|
+
value: chunk
|
|
4746
|
+
},
|
|
4747
|
+
lastSearchedChunk: {
|
|
4748
|
+
writable: true,
|
|
4749
|
+
value: chunk
|
|
4750
|
+
},
|
|
4751
|
+
byStart: {
|
|
4752
|
+
writable: true,
|
|
4753
|
+
value: {}
|
|
4754
|
+
},
|
|
4755
|
+
byEnd: {
|
|
4756
|
+
writable: true,
|
|
4757
|
+
value: {}
|
|
4758
|
+
},
|
|
4759
|
+
filename: {
|
|
4760
|
+
writable: true,
|
|
4761
|
+
value: options.filename
|
|
4762
|
+
},
|
|
4763
|
+
indentExclusionRanges: {
|
|
4764
|
+
writable: true,
|
|
4765
|
+
value: options.indentExclusionRanges
|
|
4766
|
+
},
|
|
4767
|
+
sourcemapLocations: {
|
|
4768
|
+
writable: true,
|
|
4769
|
+
value: new BitSet()
|
|
4770
|
+
},
|
|
4771
|
+
storedNames: {
|
|
4772
|
+
writable: true,
|
|
4773
|
+
value: {}
|
|
4774
|
+
},
|
|
4775
|
+
indentStr: {
|
|
4776
|
+
writable: true,
|
|
4777
|
+
value: void 0
|
|
4778
|
+
},
|
|
4779
|
+
ignoreList: {
|
|
4780
|
+
writable: true,
|
|
4781
|
+
value: options.ignoreList
|
|
4782
|
+
},
|
|
4783
|
+
offset: {
|
|
4784
|
+
writable: true,
|
|
4785
|
+
value: options.offset || 0
|
|
4786
|
+
}
|
|
4784
4787
|
});
|
|
4785
|
-
|
|
4786
4788
|
this.byStart[0] = chunk;
|
|
4787
4789
|
this.byEnd[string.length] = chunk;
|
|
4788
4790
|
}
|
|
4789
|
-
|
|
4791
|
+
/**
|
|
4792
|
+
* Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
|
|
4793
|
+
*/
|
|
4790
4794
|
addSourcemapLocation(char) {
|
|
4791
4795
|
this.sourcemapLocations.add(char);
|
|
4792
4796
|
}
|
|
4793
|
-
|
|
4797
|
+
/**
|
|
4798
|
+
* Appends the specified content to the end of the string.
|
|
4799
|
+
*/
|
|
4794
4800
|
append(content) {
|
|
4795
|
-
if (typeof content !==
|
|
4796
|
-
|
|
4801
|
+
if (typeof content !== "string") throw new TypeError("outro content must be a string");
|
|
4797
4802
|
this.outro += content;
|
|
4798
4803
|
return this;
|
|
4799
4804
|
}
|
|
4800
|
-
|
|
4805
|
+
/**
|
|
4806
|
+
* Appends the specified content at the index in the original string.
|
|
4807
|
+
* If a range *ending* with index is subsequently moved, the insert will be moved with it.
|
|
4808
|
+
* See also `s.prependLeft(...)`.
|
|
4809
|
+
*/
|
|
4801
4810
|
appendLeft(index, content) {
|
|
4802
4811
|
index = index + this.offset;
|
|
4803
|
-
|
|
4804
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
4805
|
-
|
|
4812
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
4806
4813
|
this._split(index);
|
|
4807
|
-
|
|
4808
4814
|
const chunk = this.byEnd[index];
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
chunk.appendLeft(content);
|
|
4812
|
-
} else {
|
|
4813
|
-
this.intro += content;
|
|
4814
|
-
}
|
|
4815
|
+
if (chunk) chunk.appendLeft(content);
|
|
4816
|
+
else this.intro += content;
|
|
4815
4817
|
return this;
|
|
4816
4818
|
}
|
|
4817
|
-
|
|
4819
|
+
/**
|
|
4820
|
+
* Appends the specified content at the index in the original string.
|
|
4821
|
+
* If a range *starting* with index is subsequently moved, the insert will be moved with it.
|
|
4822
|
+
* See also `s.prependRight(...)`.
|
|
4823
|
+
*/
|
|
4818
4824
|
appendRight(index, content) {
|
|
4819
4825
|
index = index + this.offset;
|
|
4820
|
-
|
|
4821
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
4822
|
-
|
|
4826
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
4823
4827
|
this._split(index);
|
|
4824
|
-
|
|
4825
4828
|
const chunk = this.byStart[index];
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
chunk.appendRight(content);
|
|
4829
|
-
} else {
|
|
4830
|
-
this.outro += content;
|
|
4831
|
-
}
|
|
4829
|
+
if (chunk) chunk.appendRight(content);
|
|
4830
|
+
else this.outro += content;
|
|
4832
4831
|
return this;
|
|
4833
4832
|
}
|
|
4834
|
-
|
|
4833
|
+
/**
|
|
4834
|
+
* Does what you'd expect.
|
|
4835
|
+
*/
|
|
4835
4836
|
clone() {
|
|
4836
|
-
const cloned = new MagicString(this.original, {
|
|
4837
|
-
|
|
4837
|
+
const cloned = new MagicString(this.original, {
|
|
4838
|
+
filename: this.filename,
|
|
4839
|
+
offset: this.offset
|
|
4840
|
+
});
|
|
4838
4841
|
let originalChunk = this.firstChunk;
|
|
4839
|
-
let clonedChunk =
|
|
4840
|
-
|
|
4842
|
+
let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
|
|
4841
4843
|
while (originalChunk) {
|
|
4842
4844
|
cloned.byStart[clonedChunk.start] = clonedChunk;
|
|
4843
4845
|
cloned.byEnd[clonedChunk.end] = clonedChunk;
|
|
4844
|
-
|
|
4845
4846
|
const nextOriginalChunk = originalChunk.next;
|
|
4846
4847
|
const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
|
|
4847
|
-
|
|
4848
4848
|
if (nextClonedChunk) {
|
|
4849
4849
|
clonedChunk.next = nextClonedChunk;
|
|
4850
4850
|
nextClonedChunk.previous = clonedChunk;
|
|
4851
|
-
|
|
4852
4851
|
clonedChunk = nextClonedChunk;
|
|
4853
4852
|
}
|
|
4854
|
-
|
|
4855
4853
|
originalChunk = nextOriginalChunk;
|
|
4856
4854
|
}
|
|
4857
|
-
|
|
4858
4855
|
cloned.lastChunk = clonedChunk;
|
|
4859
|
-
|
|
4860
|
-
if (this.indentExclusionRanges) {
|
|
4861
|
-
cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
4862
|
-
}
|
|
4863
|
-
|
|
4856
|
+
if (this.indentExclusionRanges) cloned.indentExclusionRanges = this.indentExclusionRanges.slice();
|
|
4864
4857
|
cloned.sourcemapLocations = new BitSet(this.sourcemapLocations);
|
|
4865
|
-
|
|
4866
4858
|
cloned.intro = this.intro;
|
|
4867
4859
|
cloned.outro = this.outro;
|
|
4868
|
-
|
|
4869
4860
|
return cloned;
|
|
4870
4861
|
}
|
|
4871
|
-
|
|
4862
|
+
/**
|
|
4863
|
+
* Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
|
|
4864
|
+
* Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
|
|
4865
|
+
*/
|
|
4872
4866
|
generateDecodedMap(options) {
|
|
4873
4867
|
options = options || {};
|
|
4874
|
-
|
|
4875
4868
|
const sourceIndex = 0;
|
|
4876
4869
|
const names = Object.keys(this.storedNames);
|
|
4877
4870
|
const mappings = new Mappings(options.hires);
|
|
4878
|
-
|
|
4879
4871
|
const locate = getLocator(this.original);
|
|
4880
|
-
|
|
4881
|
-
if (this.intro) {
|
|
4882
|
-
mappings.advance(this.intro);
|
|
4883
|
-
}
|
|
4884
|
-
|
|
4872
|
+
if (this.intro) mappings.advance(this.intro);
|
|
4885
4873
|
this.firstChunk.eachNext((chunk) => {
|
|
4886
4874
|
const loc = locate(chunk.start);
|
|
4887
|
-
|
|
4888
4875
|
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
mappings.addEdit(
|
|
4892
|
-
sourceIndex,
|
|
4893
|
-
chunk.content,
|
|
4894
|
-
loc,
|
|
4895
|
-
chunk.storeName ? names.indexOf(chunk.original) : -1,
|
|
4896
|
-
);
|
|
4897
|
-
} else {
|
|
4898
|
-
mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
4899
|
-
}
|
|
4900
|
-
|
|
4876
|
+
if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
|
|
4877
|
+
else mappings.addUneditedChunk(sourceIndex, chunk, this.original, loc, this.sourcemapLocations);
|
|
4901
4878
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
4902
4879
|
});
|
|
4903
|
-
|
|
4904
|
-
if (this.outro) {
|
|
4905
|
-
mappings.advance(this.outro);
|
|
4906
|
-
}
|
|
4907
|
-
|
|
4880
|
+
if (this.outro) mappings.advance(this.outro);
|
|
4908
4881
|
return {
|
|
4909
|
-
file: options.file ? options.file.split(/[/\\]/).pop() :
|
|
4910
|
-
sources: [
|
|
4911
|
-
|
|
4912
|
-
],
|
|
4913
|
-
sourcesContent: options.includeContent ? [this.original] : undefined,
|
|
4882
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
4883
|
+
sources: [options.source ? getRelativePath(options.file || "", options.source) : options.file || ""],
|
|
4884
|
+
sourcesContent: options.includeContent ? [this.original] : void 0,
|
|
4914
4885
|
names,
|
|
4915
4886
|
mappings: mappings.raw,
|
|
4916
|
-
x_google_ignoreList: this.ignoreList ? [sourceIndex] :
|
|
4887
|
+
x_google_ignoreList: this.ignoreList ? [sourceIndex] : void 0
|
|
4917
4888
|
};
|
|
4918
4889
|
}
|
|
4919
|
-
|
|
4890
|
+
/**
|
|
4891
|
+
* Generates a version 3 sourcemap.
|
|
4892
|
+
*/
|
|
4920
4893
|
generateMap(options) {
|
|
4921
4894
|
return new SourceMap(this.generateDecodedMap(options));
|
|
4922
4895
|
}
|
|
4923
|
-
|
|
4896
|
+
/** @internal */
|
|
4924
4897
|
_ensureindentStr() {
|
|
4925
|
-
if (this.indentStr ===
|
|
4926
|
-
this.indentStr = guessIndent(this.original);
|
|
4927
|
-
}
|
|
4898
|
+
if (this.indentStr === void 0) this.indentStr = guessIndent(this.original);
|
|
4928
4899
|
}
|
|
4929
|
-
|
|
4900
|
+
/** @internal */
|
|
4930
4901
|
_getRawIndentString() {
|
|
4931
4902
|
this._ensureindentStr();
|
|
4932
4903
|
return this.indentStr;
|
|
4933
4904
|
}
|
|
4934
|
-
|
|
4935
4905
|
getIndentString() {
|
|
4936
4906
|
this._ensureindentStr();
|
|
4937
|
-
return this.indentStr === null ?
|
|
4907
|
+
return this.indentStr === null ? " " : this.indentStr;
|
|
4938
4908
|
}
|
|
4939
|
-
|
|
4940
4909
|
indent(indentStr, options) {
|
|
4941
4910
|
const pattern = /^[^\r\n]/gm;
|
|
4942
|
-
|
|
4943
4911
|
if (isObject(indentStr)) {
|
|
4944
4912
|
options = indentStr;
|
|
4945
|
-
indentStr =
|
|
4913
|
+
indentStr = void 0;
|
|
4946
4914
|
}
|
|
4947
|
-
|
|
4948
|
-
if (indentStr === undefined) {
|
|
4915
|
+
if (indentStr === void 0) {
|
|
4949
4916
|
this._ensureindentStr();
|
|
4950
|
-
indentStr = this.indentStr ||
|
|
4917
|
+
indentStr = this.indentStr || " ";
|
|
4951
4918
|
}
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4919
|
+
if (indentStr === "") return this;
|
|
4920
|
+
const resolvedIndentStr = indentStr;
|
|
4955
4921
|
options = options || {};
|
|
4956
|
-
|
|
4957
|
-
// Process exclusion ranges
|
|
4958
4922
|
const isExcluded = {};
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
typeof options.exclude[0] === 'number' ? [options.exclude] : options.exclude;
|
|
4963
|
-
exclusions.forEach((exclusion) => {
|
|
4964
|
-
for (let i = exclusion[0]; i < exclusion[1]; i += 1) {
|
|
4965
|
-
isExcluded[i] = true;
|
|
4966
|
-
}
|
|
4967
|
-
});
|
|
4968
|
-
}
|
|
4969
|
-
|
|
4923
|
+
if (options.exclude) (typeof options.exclude[0] === "number" ? [options.exclude] : options.exclude).forEach((exclusion) => {
|
|
4924
|
+
for (let i = exclusion[0]; i < exclusion[1]; i += 1) isExcluded[i] = true;
|
|
4925
|
+
});
|
|
4970
4926
|
let shouldIndentNextCharacter = options.indentStart !== false;
|
|
4971
4927
|
const replacer = (match) => {
|
|
4972
|
-
if (shouldIndentNextCharacter) return `${
|
|
4928
|
+
if (shouldIndentNextCharacter) return `${resolvedIndentStr}${match}`;
|
|
4973
4929
|
shouldIndentNextCharacter = true;
|
|
4974
4930
|
return match;
|
|
4975
4931
|
};
|
|
4976
|
-
|
|
4977
4932
|
this.intro = this.intro.replace(pattern, replacer);
|
|
4978
|
-
|
|
4979
4933
|
let charIndex = 0;
|
|
4980
4934
|
let chunk = this.firstChunk;
|
|
4981
|
-
|
|
4935
|
+
const indentAt = (index) => {
|
|
4936
|
+
shouldIndentNextCharacter = false;
|
|
4937
|
+
if (index === chunk.start) chunk.prependRight(resolvedIndentStr);
|
|
4938
|
+
else {
|
|
4939
|
+
this._splitChunk(chunk, index);
|
|
4940
|
+
chunk = chunk.next;
|
|
4941
|
+
chunk.prependRight(resolvedIndentStr);
|
|
4942
|
+
}
|
|
4943
|
+
};
|
|
4982
4944
|
while (chunk) {
|
|
4983
4945
|
const end = chunk.end;
|
|
4984
|
-
|
|
4985
4946
|
if (chunk.edited) {
|
|
4986
4947
|
if (!isExcluded[charIndex]) {
|
|
4987
4948
|
chunk.content = chunk.content.replace(pattern, replacer);
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4949
|
+
if (chunk.content.length) shouldIndentNextCharacter = chunk.content[chunk.content.length - 1] === "\n";
|
|
4950
|
+
}
|
|
4951
|
+
} else if (options.exclude) {
|
|
4952
|
+
charIndex = chunk.start;
|
|
4953
|
+
while (charIndex < end) {
|
|
4954
|
+
if (!isExcluded[charIndex]) {
|
|
4955
|
+
const char = this.original.charCodeAt(charIndex);
|
|
4956
|
+
if (char === NEWLINE_CHAR) shouldIndentNextCharacter = true;
|
|
4957
|
+
else if (char !== CR_CHAR && shouldIndentNextCharacter) indentAt(charIndex);
|
|
4991
4958
|
}
|
|
4959
|
+
charIndex += 1;
|
|
4992
4960
|
}
|
|
4993
4961
|
} else {
|
|
4994
4962
|
charIndex = chunk.start;
|
|
4995
|
-
|
|
4996
4963
|
while (charIndex < end) {
|
|
4997
|
-
if (!
|
|
4998
|
-
const
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
shouldIndentNextCharacter = false;
|
|
5004
|
-
|
|
5005
|
-
if (charIndex === chunk.start) {
|
|
5006
|
-
chunk.prependRight(indentStr);
|
|
5007
|
-
} else {
|
|
5008
|
-
this._splitChunk(chunk, charIndex);
|
|
5009
|
-
chunk = chunk.next;
|
|
5010
|
-
chunk.prependRight(indentStr);
|
|
5011
|
-
}
|
|
5012
|
-
}
|
|
4964
|
+
if (!shouldIndentNextCharacter) {
|
|
4965
|
+
const nextLine = this.original.indexOf(n, charIndex);
|
|
4966
|
+
if (nextLine === -1 || nextLine >= end) break;
|
|
4967
|
+
shouldIndentNextCharacter = true;
|
|
4968
|
+
charIndex = nextLine + 1;
|
|
4969
|
+
continue;
|
|
5013
4970
|
}
|
|
5014
|
-
|
|
4971
|
+
const char = this.original.charCodeAt(charIndex);
|
|
4972
|
+
if (char === NEWLINE_CHAR || char === CR_CHAR) {
|
|
4973
|
+
charIndex += 1;
|
|
4974
|
+
continue;
|
|
4975
|
+
}
|
|
4976
|
+
indentAt(charIndex);
|
|
5015
4977
|
charIndex += 1;
|
|
5016
4978
|
}
|
|
5017
4979
|
}
|
|
5018
|
-
|
|
5019
4980
|
charIndex = chunk.end;
|
|
5020
4981
|
chunk = chunk.next;
|
|
5021
4982
|
}
|
|
5022
|
-
|
|
5023
4983
|
this.outro = this.outro.replace(pattern, replacer);
|
|
5024
|
-
|
|
5025
4984
|
return this;
|
|
5026
4985
|
}
|
|
5027
|
-
|
|
4986
|
+
/** @internal */
|
|
5028
4987
|
insert() {
|
|
5029
|
-
throw new Error(
|
|
5030
|
-
'magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)',
|
|
5031
|
-
);
|
|
4988
|
+
throw new Error("magicString.insert(...) is deprecated. Use prependRight(...) or appendLeft(...)");
|
|
5032
4989
|
}
|
|
5033
|
-
|
|
4990
|
+
/** @internal */
|
|
5034
4991
|
insertLeft(index, content) {
|
|
5035
4992
|
if (!warned.insertLeft) {
|
|
5036
|
-
console.warn(
|
|
5037
|
-
'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
|
|
5038
|
-
);
|
|
4993
|
+
console.warn("magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead");
|
|
5039
4994
|
warned.insertLeft = true;
|
|
5040
4995
|
}
|
|
5041
|
-
|
|
5042
4996
|
return this.appendLeft(index, content);
|
|
5043
4997
|
}
|
|
5044
|
-
|
|
4998
|
+
/** @internal */
|
|
5045
4999
|
insertRight(index, content) {
|
|
5046
5000
|
if (!warned.insertRight) {
|
|
5047
|
-
console.warn(
|
|
5048
|
-
'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
|
|
5049
|
-
);
|
|
5001
|
+
console.warn("magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead");
|
|
5050
5002
|
warned.insertRight = true;
|
|
5051
5003
|
}
|
|
5052
|
-
|
|
5053
5004
|
return this.prependRight(index, content);
|
|
5054
5005
|
}
|
|
5055
|
-
|
|
5006
|
+
/**
|
|
5007
|
+
* Moves the characters from `start` and `end` to `index`.
|
|
5008
|
+
*/
|
|
5056
5009
|
move(start, end, index) {
|
|
5057
5010
|
start = start + this.offset;
|
|
5058
5011
|
end = end + this.offset;
|
|
5059
5012
|
index = index + this.offset;
|
|
5060
|
-
|
|
5061
|
-
if (index >= start && index <= end) throw new Error(
|
|
5062
|
-
|
|
5013
|
+
if (start === end) return this;
|
|
5014
|
+
if (index >= start && index <= end) throw new Error("Cannot move a selection inside itself");
|
|
5063
5015
|
this._split(start);
|
|
5064
5016
|
this._split(end);
|
|
5065
5017
|
this._split(index);
|
|
5066
|
-
|
|
5067
5018
|
const first = this.byStart[start];
|
|
5068
5019
|
const last = this.byEnd[end];
|
|
5069
|
-
|
|
5070
5020
|
const oldLeft = first.previous;
|
|
5071
5021
|
const oldRight = last.next;
|
|
5072
|
-
|
|
5073
5022
|
const newRight = this.byStart[index];
|
|
5074
5023
|
if (!newRight && last === this.lastChunk) return this;
|
|
5075
5024
|
const newLeft = newRight ? newRight.previous : this.lastChunk;
|
|
5076
|
-
|
|
5077
5025
|
if (oldLeft) oldLeft.next = oldRight;
|
|
5078
5026
|
if (oldRight) oldRight.previous = oldLeft;
|
|
5079
|
-
|
|
5080
5027
|
if (newLeft) newLeft.next = first;
|
|
5081
5028
|
if (newRight) newRight.previous = last;
|
|
5082
|
-
|
|
5083
5029
|
if (!first.previous) this.firstChunk = last.next;
|
|
5084
5030
|
if (!last.next) {
|
|
5085
5031
|
this.lastChunk = first.previous;
|
|
5086
5032
|
this.lastChunk.next = null;
|
|
5087
5033
|
}
|
|
5088
|
-
|
|
5089
5034
|
first.previous = newLeft;
|
|
5090
5035
|
last.next = newRight || null;
|
|
5091
|
-
|
|
5092
5036
|
if (!newLeft) this.firstChunk = first;
|
|
5093
5037
|
if (!newRight) this.lastChunk = last;
|
|
5094
5038
|
return this;
|
|
5095
5039
|
}
|
|
5096
|
-
|
|
5040
|
+
/**
|
|
5041
|
+
* Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
|
|
5042
|
+
* that range. The same restrictions as `s.remove()` apply.
|
|
5043
|
+
*
|
|
5044
|
+
* The fourth argument is optional. It can have a storeName property - if true, the original name will be stored
|
|
5045
|
+
* for later inclusion in a sourcemap's names array - and a contentOnly property which determines whether only
|
|
5046
|
+
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
|
5047
|
+
*
|
|
5048
|
+
* It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
|
|
5049
|
+
*/
|
|
5097
5050
|
overwrite(start, end, content, options) {
|
|
5098
|
-
|
|
5099
|
-
return this.update(start, end, content, {
|
|
5051
|
+
const optionObject = typeof options === "object" && options ? options : {};
|
|
5052
|
+
return this.update(start, end, content, {
|
|
5053
|
+
...optionObject,
|
|
5054
|
+
overwrite: !optionObject.contentOnly
|
|
5055
|
+
});
|
|
5100
5056
|
}
|
|
5101
|
-
|
|
5057
|
+
/**
|
|
5058
|
+
* Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.
|
|
5059
|
+
*
|
|
5060
|
+
* The fourth argument is optional. It can have a storeName property - if true, the original name will be stored
|
|
5061
|
+
* for later inclusion in a sourcemap's names array - and an overwrite property which determines whether only
|
|
5062
|
+
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
|
5063
|
+
*/
|
|
5102
5064
|
update(start, end, content, options) {
|
|
5103
5065
|
start = start + this.offset;
|
|
5104
5066
|
end = end + this.offset;
|
|
5105
|
-
|
|
5106
|
-
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
|
5107
|
-
|
|
5067
|
+
if (typeof content !== "string") throw new TypeError("replacement content must be a string");
|
|
5108
5068
|
if (this.original.length !== 0) {
|
|
5109
5069
|
while (start < 0) start += this.original.length;
|
|
5110
5070
|
while (end < 0) end += this.original.length;
|
|
5111
5071
|
}
|
|
5112
|
-
|
|
5113
|
-
if (
|
|
5114
|
-
if (start === end)
|
|
5115
|
-
throw new Error(
|
|
5116
|
-
'Cannot overwrite a zero-length range – use appendLeft or prependRight instead',
|
|
5117
|
-
);
|
|
5118
|
-
|
|
5072
|
+
if (end > this.original.length) throw new Error("end is out of bounds");
|
|
5073
|
+
if (start === end) throw new Error("Cannot overwrite a zero-length range – use appendLeft or prependRight instead");
|
|
5119
5074
|
this._split(start);
|
|
5120
5075
|
this._split(end);
|
|
5121
|
-
|
|
5122
5076
|
if (options === true) {
|
|
5123
5077
|
if (!warned.storeName) {
|
|
5124
|
-
console.warn(
|
|
5125
|
-
'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
|
|
5126
|
-
);
|
|
5078
|
+
console.warn("The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string");
|
|
5127
5079
|
warned.storeName = true;
|
|
5128
5080
|
}
|
|
5129
|
-
|
|
5130
5081
|
options = { storeName: true };
|
|
5131
5082
|
}
|
|
5132
|
-
const
|
|
5133
|
-
const
|
|
5134
|
-
|
|
5083
|
+
const optionObject = typeof options === "object" && options ? options : {};
|
|
5084
|
+
const storeName = optionObject.storeName || false;
|
|
5085
|
+
const overwrite = optionObject.overwrite || false;
|
|
5135
5086
|
if (storeName) {
|
|
5136
5087
|
const original = this.original.slice(start, end);
|
|
5137
5088
|
Object.defineProperty(this.storedNames, original, {
|
|
5138
5089
|
writable: true,
|
|
5139
5090
|
value: true,
|
|
5140
|
-
enumerable: true
|
|
5091
|
+
enumerable: true
|
|
5141
5092
|
});
|
|
5142
5093
|
}
|
|
5143
|
-
|
|
5144
5094
|
const first = this.byStart[start];
|
|
5145
5095
|
const last = this.byEnd[end];
|
|
5146
|
-
|
|
5147
5096
|
if (first) {
|
|
5148
5097
|
let chunk = first;
|
|
5149
5098
|
while (chunk !== last) {
|
|
5150
|
-
if (chunk.next !== this.byStart[chunk.end])
|
|
5151
|
-
throw new Error('Cannot overwrite across a split point');
|
|
5152
|
-
}
|
|
5099
|
+
if (chunk.next !== this.byStart[chunk.end]) throw new Error("Cannot overwrite across a split point");
|
|
5153
5100
|
chunk = chunk.next;
|
|
5154
|
-
chunk.edit(
|
|
5101
|
+
chunk.edit("", false);
|
|
5155
5102
|
}
|
|
5156
|
-
|
|
5157
5103
|
first.edit(content, storeName, !overwrite);
|
|
5158
5104
|
} else {
|
|
5159
|
-
|
|
5160
|
-
const newChunk = new Chunk$1(start, end, '').edit(content, storeName);
|
|
5161
|
-
|
|
5162
|
-
// TODO last chunk in the array may not be the last chunk, if it's moved...
|
|
5105
|
+
const newChunk = new Chunk$1(start, end, "").edit(content, storeName);
|
|
5163
5106
|
last.next = newChunk;
|
|
5164
5107
|
newChunk.previous = last;
|
|
5165
5108
|
}
|
|
5166
5109
|
return this;
|
|
5167
5110
|
}
|
|
5168
|
-
|
|
5111
|
+
/**
|
|
5112
|
+
* Prepends the string with the specified content.
|
|
5113
|
+
*/
|
|
5169
5114
|
prepend(content) {
|
|
5170
|
-
if (typeof content !==
|
|
5171
|
-
|
|
5115
|
+
if (typeof content !== "string") throw new TypeError("outro content must be a string");
|
|
5172
5116
|
this.intro = content + this.intro;
|
|
5173
5117
|
return this;
|
|
5174
5118
|
}
|
|
5175
|
-
|
|
5119
|
+
/**
|
|
5120
|
+
* Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
|
|
5121
|
+
*/
|
|
5176
5122
|
prependLeft(index, content) {
|
|
5177
5123
|
index = index + this.offset;
|
|
5178
|
-
|
|
5179
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
5180
|
-
|
|
5124
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
5181
5125
|
this._split(index);
|
|
5182
|
-
|
|
5183
5126
|
const chunk = this.byEnd[index];
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
chunk.prependLeft(content);
|
|
5187
|
-
} else {
|
|
5188
|
-
this.intro = content + this.intro;
|
|
5189
|
-
}
|
|
5127
|
+
if (chunk) chunk.prependLeft(content);
|
|
5128
|
+
else this.intro = content + this.intro;
|
|
5190
5129
|
return this;
|
|
5191
5130
|
}
|
|
5192
|
-
|
|
5131
|
+
/**
|
|
5132
|
+
* Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
|
5133
|
+
*/
|
|
5193
5134
|
prependRight(index, content) {
|
|
5194
5135
|
index = index + this.offset;
|
|
5195
|
-
|
|
5196
|
-
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
5197
|
-
|
|
5136
|
+
if (typeof content !== "string") throw new TypeError("inserted content must be a string");
|
|
5198
5137
|
this._split(index);
|
|
5199
|
-
|
|
5200
5138
|
const chunk = this.byStart[index];
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
chunk.prependRight(content);
|
|
5204
|
-
} else {
|
|
5205
|
-
this.outro = content + this.outro;
|
|
5206
|
-
}
|
|
5139
|
+
if (chunk) chunk.prependRight(content);
|
|
5140
|
+
else this.outro = content + this.outro;
|
|
5207
5141
|
return this;
|
|
5208
5142
|
}
|
|
5209
|
-
|
|
5143
|
+
/**
|
|
5144
|
+
* Removes the characters from `start` to `end` (of the original string, **not** the generated string).
|
|
5145
|
+
* Removing the same content twice, or making removals that partially overlap, will cause an error.
|
|
5146
|
+
*/
|
|
5210
5147
|
remove(start, end) {
|
|
5211
5148
|
start = start + this.offset;
|
|
5212
5149
|
end = end + this.offset;
|
|
5213
|
-
|
|
5214
5150
|
if (this.original.length !== 0) {
|
|
5215
5151
|
while (start < 0) start += this.original.length;
|
|
5216
5152
|
while (end < 0) end += this.original.length;
|
|
5217
5153
|
}
|
|
5218
|
-
|
|
5219
5154
|
if (start === end) return this;
|
|
5220
|
-
|
|
5221
|
-
if (start
|
|
5222
|
-
if (start > end) throw new Error('end must be greater than start');
|
|
5223
|
-
|
|
5155
|
+
if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
|
|
5156
|
+
if (start > end) throw new Error("end must be greater than start");
|
|
5224
5157
|
this._split(start);
|
|
5225
5158
|
this._split(end);
|
|
5226
|
-
|
|
5227
5159
|
let chunk = this.byStart[start];
|
|
5228
|
-
|
|
5229
5160
|
while (chunk) {
|
|
5230
|
-
chunk.intro =
|
|
5231
|
-
chunk.outro =
|
|
5232
|
-
chunk.edit(
|
|
5233
|
-
|
|
5161
|
+
chunk.intro = "";
|
|
5162
|
+
chunk.outro = "";
|
|
5163
|
+
chunk.edit("");
|
|
5234
5164
|
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
5235
5165
|
}
|
|
5236
5166
|
return this;
|
|
5237
5167
|
}
|
|
5238
|
-
|
|
5168
|
+
/**
|
|
5169
|
+
* Reset the modified characters from `start` to `end` (of the original string, **not** the generated string).
|
|
5170
|
+
*/
|
|
5239
5171
|
reset(start, end) {
|
|
5240
5172
|
start = start + this.offset;
|
|
5241
5173
|
end = end + this.offset;
|
|
5242
|
-
|
|
5243
5174
|
if (this.original.length !== 0) {
|
|
5244
5175
|
while (start < 0) start += this.original.length;
|
|
5245
5176
|
while (end < 0) end += this.original.length;
|
|
5246
5177
|
}
|
|
5247
|
-
|
|
5248
5178
|
if (start === end) return this;
|
|
5249
|
-
|
|
5250
|
-
if (start
|
|
5251
|
-
if (start > end) throw new Error('end must be greater than start');
|
|
5252
|
-
|
|
5179
|
+
if (start < 0 || end > this.original.length) throw new Error("Character is out of bounds");
|
|
5180
|
+
if (start > end) throw new Error("end must be greater than start");
|
|
5253
5181
|
this._split(start);
|
|
5254
5182
|
this._split(end);
|
|
5255
|
-
|
|
5256
5183
|
let chunk = this.byStart[start];
|
|
5257
|
-
|
|
5258
5184
|
while (chunk) {
|
|
5259
5185
|
chunk.reset();
|
|
5260
|
-
|
|
5261
5186
|
chunk = end > chunk.end ? this.byStart[chunk.end] : null;
|
|
5262
5187
|
}
|
|
5263
5188
|
return this;
|
|
5264
5189
|
}
|
|
5265
|
-
|
|
5266
5190
|
lastChar() {
|
|
5267
5191
|
if (this.outro.length) return this.outro[this.outro.length - 1];
|
|
5268
5192
|
let chunk = this.lastChunk;
|
|
5269
|
-
|
|
5193
|
+
while (chunk) {
|
|
5270
5194
|
if (chunk.outro.length) return chunk.outro[chunk.outro.length - 1];
|
|
5271
5195
|
if (chunk.content.length) return chunk.content[chunk.content.length - 1];
|
|
5272
5196
|
if (chunk.intro.length) return chunk.intro[chunk.intro.length - 1];
|
|
5273
|
-
|
|
5197
|
+
chunk = chunk.previous;
|
|
5198
|
+
}
|
|
5274
5199
|
if (this.intro.length) return this.intro[this.intro.length - 1];
|
|
5275
|
-
return
|
|
5200
|
+
return "";
|
|
5276
5201
|
}
|
|
5277
|
-
|
|
5278
5202
|
lastLine() {
|
|
5279
5203
|
let lineIndex = this.outro.lastIndexOf(n);
|
|
5280
5204
|
if (lineIndex !== -1) return this.outro.substr(lineIndex + 1);
|
|
5281
5205
|
let lineStr = this.outro;
|
|
5282
5206
|
let chunk = this.lastChunk;
|
|
5283
|
-
|
|
5207
|
+
while (chunk) {
|
|
5284
5208
|
if (chunk.outro.length > 0) {
|
|
5285
5209
|
lineIndex = chunk.outro.lastIndexOf(n);
|
|
5286
5210
|
if (lineIndex !== -1) return chunk.outro.substr(lineIndex + 1) + lineStr;
|
|
5287
5211
|
lineStr = chunk.outro + lineStr;
|
|
5288
5212
|
}
|
|
5289
|
-
|
|
5290
5213
|
if (chunk.content.length > 0) {
|
|
5291
5214
|
lineIndex = chunk.content.lastIndexOf(n);
|
|
5292
5215
|
if (lineIndex !== -1) return chunk.content.substr(lineIndex + 1) + lineStr;
|
|
5293
5216
|
lineStr = chunk.content + lineStr;
|
|
5294
5217
|
}
|
|
5295
|
-
|
|
5296
5218
|
if (chunk.intro.length > 0) {
|
|
5297
5219
|
lineIndex = chunk.intro.lastIndexOf(n);
|
|
5298
5220
|
if (lineIndex !== -1) return chunk.intro.substr(lineIndex + 1) + lineStr;
|
|
5299
5221
|
lineStr = chunk.intro + lineStr;
|
|
5300
5222
|
}
|
|
5301
|
-
|
|
5223
|
+
chunk = chunk.previous;
|
|
5224
|
+
}
|
|
5302
5225
|
lineIndex = this.intro.lastIndexOf(n);
|
|
5303
5226
|
if (lineIndex !== -1) return this.intro.substr(lineIndex + 1) + lineStr;
|
|
5304
5227
|
return this.intro + lineStr;
|
|
5305
5228
|
}
|
|
5306
|
-
|
|
5229
|
+
/**
|
|
5230
|
+
* Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
|
|
5231
|
+
* Throws error if the indices are for characters that were already removed.
|
|
5232
|
+
*/
|
|
5307
5233
|
slice(start = 0, end = this.original.length - this.offset) {
|
|
5308
5234
|
start = start + this.offset;
|
|
5309
5235
|
end = end + this.offset;
|
|
5310
|
-
|
|
5311
5236
|
if (this.original.length !== 0) {
|
|
5312
5237
|
while (start < 0) start += this.original.length;
|
|
5313
5238
|
while (end < 0) end += this.original.length;
|
|
5314
5239
|
}
|
|
5315
|
-
|
|
5316
|
-
let result = '';
|
|
5317
|
-
|
|
5318
|
-
// find start chunk
|
|
5240
|
+
let result = "";
|
|
5319
5241
|
let chunk = this.firstChunk;
|
|
5320
5242
|
while (chunk && (chunk.start > start || chunk.end <= start)) {
|
|
5321
|
-
|
|
5322
|
-
if (chunk.start < end && chunk.end >= end) {
|
|
5323
|
-
return result;
|
|
5324
|
-
}
|
|
5325
|
-
|
|
5243
|
+
if (chunk.start < end && chunk.end >= end) return result;
|
|
5326
5244
|
chunk = chunk.next;
|
|
5327
5245
|
}
|
|
5328
|
-
|
|
5329
|
-
if (chunk && chunk.edited && chunk.start !== start)
|
|
5330
|
-
throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
5331
|
-
|
|
5246
|
+
if (chunk && chunk.edited && chunk.start !== start) throw new Error(`Cannot use replaced character ${start} as slice start anchor.`);
|
|
5332
5247
|
const startChunk = chunk;
|
|
5333
5248
|
while (chunk) {
|
|
5334
|
-
if (chunk.intro && (startChunk !== chunk || chunk.start === start))
|
|
5335
|
-
result += chunk.intro;
|
|
5336
|
-
}
|
|
5337
|
-
|
|
5249
|
+
if (chunk.intro && (startChunk !== chunk || chunk.start === start)) result += chunk.intro;
|
|
5338
5250
|
const containsEnd = chunk.start < end && chunk.end >= end;
|
|
5339
|
-
if (containsEnd && chunk.edited && chunk.end !== end)
|
|
5340
|
-
throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
5341
|
-
|
|
5251
|
+
if (containsEnd && chunk.edited && chunk.end !== end) throw new Error(`Cannot use replaced character ${end} as slice end anchor.`);
|
|
5342
5252
|
const sliceStart = startChunk === chunk ? start - chunk.start : 0;
|
|
5343
5253
|
const sliceEnd = containsEnd ? chunk.content.length + end - chunk.end : chunk.content.length;
|
|
5344
|
-
|
|
5345
5254
|
result += chunk.content.slice(sliceStart, sliceEnd);
|
|
5346
|
-
|
|
5347
|
-
if (
|
|
5348
|
-
result += chunk.outro;
|
|
5349
|
-
}
|
|
5350
|
-
|
|
5351
|
-
if (containsEnd) {
|
|
5352
|
-
break;
|
|
5353
|
-
}
|
|
5354
|
-
|
|
5255
|
+
if (chunk.outro && (!containsEnd || chunk.end === end)) result += chunk.outro;
|
|
5256
|
+
if (containsEnd) break;
|
|
5355
5257
|
chunk = chunk.next;
|
|
5356
5258
|
}
|
|
5357
|
-
|
|
5358
5259
|
return result;
|
|
5359
5260
|
}
|
|
5360
|
-
|
|
5361
|
-
|
|
5261
|
+
/**
|
|
5262
|
+
* Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
|
|
5263
|
+
*/
|
|
5362
5264
|
snip(start, end) {
|
|
5363
5265
|
const clone = this.clone();
|
|
5364
5266
|
clone.remove(0, start);
|
|
5365
5267
|
clone.remove(end, clone.original.length);
|
|
5366
|
-
|
|
5367
5268
|
return clone;
|
|
5368
5269
|
}
|
|
5369
|
-
|
|
5270
|
+
/** @internal */
|
|
5370
5271
|
_split(index) {
|
|
5371
5272
|
if (this.byStart[index] || this.byEnd[index]) return;
|
|
5372
|
-
|
|
5373
5273
|
let chunk = this.lastSearchedChunk;
|
|
5374
5274
|
let previousChunk = chunk;
|
|
5375
5275
|
const searchForward = index > chunk.end;
|
|
5376
|
-
|
|
5377
5276
|
while (chunk) {
|
|
5378
5277
|
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
5379
|
-
|
|
5380
5278
|
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
5381
|
-
|
|
5382
|
-
// Prevent infinite loop (e.g. via empty chunks, where start === end)
|
|
5383
5279
|
if (chunk === previousChunk) return;
|
|
5384
|
-
|
|
5385
5280
|
previousChunk = chunk;
|
|
5386
5281
|
}
|
|
5387
5282
|
}
|
|
5388
|
-
|
|
5283
|
+
/** @internal */
|
|
5389
5284
|
_splitChunk(chunk, index) {
|
|
5390
5285
|
if (chunk.edited && chunk.content.length) {
|
|
5391
|
-
// zero-length edited chunks are a special case (overlapping replacements)
|
|
5392
5286
|
const loc = getLocator(this.original)(index);
|
|
5393
|
-
throw new Error(
|
|
5394
|
-
`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`,
|
|
5395
|
-
);
|
|
5287
|
+
throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
|
|
5396
5288
|
}
|
|
5397
|
-
|
|
5398
5289
|
const newChunk = chunk.split(index);
|
|
5399
|
-
|
|
5400
5290
|
this.byEnd[index] = chunk;
|
|
5401
5291
|
this.byStart[index] = newChunk;
|
|
5402
5292
|
this.byEnd[newChunk.end] = newChunk;
|
|
5403
|
-
|
|
5404
5293
|
if (chunk === this.lastChunk) this.lastChunk = newChunk;
|
|
5405
|
-
|
|
5406
5294
|
this.lastSearchedChunk = chunk;
|
|
5407
5295
|
return true;
|
|
5408
5296
|
}
|
|
5409
|
-
|
|
5297
|
+
/**
|
|
5298
|
+
* Returns the generated string.
|
|
5299
|
+
*/
|
|
5410
5300
|
toString() {
|
|
5411
5301
|
let str = this.intro;
|
|
5412
|
-
|
|
5413
5302
|
let chunk = this.firstChunk;
|
|
5414
5303
|
while (chunk) {
|
|
5415
5304
|
str += chunk.toString();
|
|
5416
5305
|
chunk = chunk.next;
|
|
5417
5306
|
}
|
|
5418
|
-
|
|
5419
5307
|
return str + this.outro;
|
|
5420
5308
|
}
|
|
5421
|
-
|
|
5309
|
+
/**
|
|
5310
|
+
* Returns true if the resulting source is empty (disregarding white space).
|
|
5311
|
+
*/
|
|
5422
5312
|
isEmpty() {
|
|
5423
5313
|
let chunk = this.firstChunk;
|
|
5424
|
-
|
|
5425
|
-
if (
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
(chunk.outro.length && chunk.outro.trim())
|
|
5429
|
-
)
|
|
5430
|
-
return false;
|
|
5431
|
-
} while ((chunk = chunk.next));
|
|
5314
|
+
while (chunk) {
|
|
5315
|
+
if (chunk.intro.length && chunk.intro.trim() || chunk.content.length && chunk.content.trim() || chunk.outro.length && chunk.outro.trim()) return false;
|
|
5316
|
+
chunk = chunk.next;
|
|
5317
|
+
}
|
|
5432
5318
|
return true;
|
|
5433
5319
|
}
|
|
5434
|
-
|
|
5435
5320
|
length() {
|
|
5436
5321
|
let chunk = this.firstChunk;
|
|
5437
5322
|
let length = 0;
|
|
5438
|
-
|
|
5323
|
+
while (chunk) {
|
|
5439
5324
|
length += chunk.intro.length + chunk.content.length + chunk.outro.length;
|
|
5440
|
-
|
|
5325
|
+
chunk = chunk.next;
|
|
5326
|
+
}
|
|
5441
5327
|
return length;
|
|
5442
5328
|
}
|
|
5443
|
-
|
|
5329
|
+
/**
|
|
5330
|
+
* Removes empty lines from the start and end.
|
|
5331
|
+
*/
|
|
5444
5332
|
trimLines() {
|
|
5445
|
-
return this.trim(
|
|
5333
|
+
return this.trim("[\\r\\n]");
|
|
5446
5334
|
}
|
|
5447
|
-
|
|
5335
|
+
/**
|
|
5336
|
+
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end.
|
|
5337
|
+
*/
|
|
5448
5338
|
trim(charType) {
|
|
5449
5339
|
return this.trimStart(charType).trimEnd(charType);
|
|
5450
5340
|
}
|
|
5451
|
-
|
|
5341
|
+
/** @internal */
|
|
5452
5342
|
trimEndAborted(charType) {
|
|
5453
|
-
const rx = new RegExp(
|
|
5454
|
-
|
|
5455
|
-
this.outro = this.outro.replace(rx, '');
|
|
5343
|
+
const rx = new RegExp(`${charType || "\\s"}+$`);
|
|
5344
|
+
this.outro = this.outro.replace(rx, "");
|
|
5456
5345
|
if (this.outro.length) return true;
|
|
5457
|
-
|
|
5458
5346
|
let chunk = this.lastChunk;
|
|
5459
|
-
|
|
5460
5347
|
do {
|
|
5461
5348
|
const end = chunk.end;
|
|
5462
5349
|
const aborted = chunk.trimEnd(rx);
|
|
5463
|
-
|
|
5464
|
-
// if chunk was trimmed, we have a new lastChunk
|
|
5465
5350
|
if (chunk.end !== end) {
|
|
5466
|
-
if (this.lastChunk === chunk)
|
|
5467
|
-
this.lastChunk = chunk.next;
|
|
5468
|
-
}
|
|
5469
|
-
|
|
5351
|
+
if (this.lastChunk === chunk) this.lastChunk = chunk.next;
|
|
5470
5352
|
this.byEnd[chunk.end] = chunk;
|
|
5471
5353
|
this.byStart[chunk.next.start] = chunk.next;
|
|
5472
5354
|
this.byEnd[chunk.next.end] = chunk.next;
|
|
5473
5355
|
}
|
|
5474
|
-
|
|
5475
5356
|
if (aborted) return true;
|
|
5476
5357
|
chunk = chunk.previous;
|
|
5477
5358
|
} while (chunk);
|
|
5478
|
-
|
|
5479
5359
|
return false;
|
|
5480
5360
|
}
|
|
5481
|
-
|
|
5361
|
+
/**
|
|
5362
|
+
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
|
|
5363
|
+
*/
|
|
5482
5364
|
trimEnd(charType) {
|
|
5483
5365
|
this.trimEndAborted(charType);
|
|
5484
5366
|
return this;
|
|
5485
5367
|
}
|
|
5368
|
+
/** @internal */
|
|
5486
5369
|
trimStartAborted(charType) {
|
|
5487
|
-
const rx = new RegExp(
|
|
5488
|
-
|
|
5489
|
-
this.intro = this.intro.replace(rx, '');
|
|
5370
|
+
const rx = new RegExp(`^${charType || "\\s"}+`);
|
|
5371
|
+
this.intro = this.intro.replace(rx, "");
|
|
5490
5372
|
if (this.intro.length) return true;
|
|
5491
|
-
|
|
5492
5373
|
let chunk = this.firstChunk;
|
|
5493
|
-
|
|
5494
5374
|
do {
|
|
5495
5375
|
const end = chunk.end;
|
|
5496
5376
|
const aborted = chunk.trimStart(rx);
|
|
5497
|
-
|
|
5498
5377
|
if (chunk.end !== end) {
|
|
5499
|
-
// special case...
|
|
5500
5378
|
if (chunk === this.lastChunk) this.lastChunk = chunk.next;
|
|
5501
|
-
|
|
5502
5379
|
this.byEnd[chunk.end] = chunk;
|
|
5503
5380
|
this.byStart[chunk.next.start] = chunk.next;
|
|
5504
5381
|
this.byEnd[chunk.next.end] = chunk.next;
|
|
5505
5382
|
}
|
|
5506
|
-
|
|
5507
5383
|
if (aborted) return true;
|
|
5508
5384
|
chunk = chunk.next;
|
|
5509
5385
|
} while (chunk);
|
|
5510
|
-
|
|
5511
5386
|
return false;
|
|
5512
5387
|
}
|
|
5513
|
-
|
|
5388
|
+
/**
|
|
5389
|
+
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
|
|
5390
|
+
*/
|
|
5514
5391
|
trimStart(charType) {
|
|
5515
5392
|
this.trimStartAborted(charType);
|
|
5516
5393
|
return this;
|
|
5517
5394
|
}
|
|
5518
|
-
|
|
5395
|
+
/**
|
|
5396
|
+
* Indicates if the string has been changed.
|
|
5397
|
+
*/
|
|
5519
5398
|
hasChanged() {
|
|
5520
5399
|
return this.original !== this.toString();
|
|
5521
5400
|
}
|
|
5522
|
-
|
|
5401
|
+
/** @internal */
|
|
5523
5402
|
_replaceRegexp(searchValue, replacement) {
|
|
5524
5403
|
function getReplacement(match, str) {
|
|
5525
|
-
if (typeof replacement ===
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
return `$${i}`;
|
|
5533
|
-
});
|
|
5534
|
-
} else {
|
|
5535
|
-
return replacement(...match, match.index, str, match.groups);
|
|
5536
|
-
}
|
|
5404
|
+
if (typeof replacement === "string") return replacement.replace(/\$(\$|&|\d+)/g, (_, i) => {
|
|
5405
|
+
if (i === "$") return "$";
|
|
5406
|
+
if (i === "&") return match[0];
|
|
5407
|
+
if (+i < match.length) return match[+i];
|
|
5408
|
+
return `$${i}`;
|
|
5409
|
+
});
|
|
5410
|
+
else return replacement(match[0], ...match.slice(1), match.index, str, match.groups);
|
|
5537
5411
|
}
|
|
5538
5412
|
function matchAll(re, str) {
|
|
5539
|
-
let match;
|
|
5540
5413
|
const matches = [];
|
|
5541
|
-
while (
|
|
5414
|
+
while (true) {
|
|
5415
|
+
const match = re.exec(str);
|
|
5416
|
+
if (!match) break;
|
|
5542
5417
|
matches.push(match);
|
|
5543
5418
|
}
|
|
5544
5419
|
return matches;
|
|
5545
5420
|
}
|
|
5546
|
-
if (searchValue.global) {
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
if (match.index
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
}
|
|
5554
|
-
}
|
|
5555
|
-
});
|
|
5556
|
-
} else {
|
|
5421
|
+
if (searchValue.global) matchAll(searchValue, this.original).forEach((match) => {
|
|
5422
|
+
if (match.index != null) {
|
|
5423
|
+
const replacement = getReplacement(match, this.original);
|
|
5424
|
+
if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
5425
|
+
}
|
|
5426
|
+
});
|
|
5427
|
+
else {
|
|
5557
5428
|
const match = this.original.match(searchValue);
|
|
5558
5429
|
if (match && match.index != null) {
|
|
5559
5430
|
const replacement = getReplacement(match, this.original);
|
|
5560
|
-
if (replacement !== match[0])
|
|
5561
|
-
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
5562
|
-
}
|
|
5431
|
+
if (replacement !== match[0]) this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
5563
5432
|
}
|
|
5564
5433
|
}
|
|
5565
5434
|
return this;
|
|
5566
5435
|
}
|
|
5567
|
-
|
|
5436
|
+
/** @internal */
|
|
5568
5437
|
_replaceString(string, replacement) {
|
|
5569
5438
|
const { original } = this;
|
|
5570
5439
|
const index = original.indexOf(string);
|
|
5571
|
-
|
|
5572
5440
|
if (index !== -1) {
|
|
5573
|
-
if (typeof replacement ===
|
|
5574
|
-
|
|
5575
|
-
}
|
|
5576
|
-
if (string !== replacement) {
|
|
5577
|
-
this.overwrite(index, index + string.length, replacement);
|
|
5578
|
-
}
|
|
5441
|
+
if (typeof replacement === "function") replacement = replacement(string, index, original);
|
|
5442
|
+
if (string !== replacement) this.overwrite(index, index + string.length, replacement);
|
|
5579
5443
|
}
|
|
5580
|
-
|
|
5581
5444
|
return this;
|
|
5582
5445
|
}
|
|
5583
|
-
|
|
5446
|
+
/**
|
|
5447
|
+
* String replacement with RegExp or string.
|
|
5448
|
+
*/
|
|
5584
5449
|
replace(searchValue, replacement) {
|
|
5585
|
-
if (typeof searchValue ===
|
|
5586
|
-
return this._replaceString(searchValue, replacement);
|
|
5587
|
-
}
|
|
5588
|
-
|
|
5450
|
+
if (typeof searchValue === "string") return this._replaceString(searchValue, replacement);
|
|
5589
5451
|
return this._replaceRegexp(searchValue, replacement);
|
|
5590
5452
|
}
|
|
5591
|
-
|
|
5453
|
+
/** @internal */
|
|
5592
5454
|
_replaceAllString(string, replacement) {
|
|
5593
5455
|
const { original } = this;
|
|
5594
5456
|
const stringLength = string.length;
|
|
5595
|
-
for (
|
|
5596
|
-
let index = original.indexOf(string);
|
|
5597
|
-
index !== -1;
|
|
5598
|
-
index = original.indexOf(string, index + stringLength)
|
|
5599
|
-
) {
|
|
5457
|
+
for (let index = original.indexOf(string); index !== -1; index = original.indexOf(string, index + stringLength)) {
|
|
5600
5458
|
const previous = original.slice(index, index + stringLength);
|
|
5601
|
-
|
|
5602
|
-
if (typeof replacement === 'function') {
|
|
5603
|
-
_replacement = replacement(previous, index, original);
|
|
5604
|
-
}
|
|
5459
|
+
const _replacement = typeof replacement === "function" ? replacement(previous, index, original) : replacement;
|
|
5605
5460
|
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
5606
5461
|
}
|
|
5607
|
-
|
|
5608
5462
|
return this;
|
|
5609
5463
|
}
|
|
5610
|
-
|
|
5464
|
+
/**
|
|
5465
|
+
* Same as `s.replace`, but replace all matched strings instead of just one.
|
|
5466
|
+
*/
|
|
5611
5467
|
replaceAll(searchValue, replacement) {
|
|
5612
|
-
if (typeof searchValue ===
|
|
5613
|
-
|
|
5614
|
-
}
|
|
5615
|
-
|
|
5616
|
-
if (!searchValue.global) {
|
|
5617
|
-
throw new TypeError(
|
|
5618
|
-
'MagicString.prototype.replaceAll called with a non-global RegExp argument',
|
|
5619
|
-
);
|
|
5620
|
-
}
|
|
5621
|
-
|
|
5468
|
+
if (typeof searchValue === "string") return this._replaceAllString(searchValue, replacement);
|
|
5469
|
+
if (!searchValue.global) throw new TypeError("MagicString.prototype.replaceAll called with a non-global RegExp argument");
|
|
5622
5470
|
return this._replaceRegexp(searchValue, replacement);
|
|
5623
5471
|
}
|
|
5624
|
-
}
|
|
5625
|
-
|
|
5472
|
+
};
|
|
5473
|
+
//#endregion
|
|
5474
|
+
//#region src/Bundle.ts
|
|
5626
5475
|
const hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5627
|
-
|
|
5628
|
-
let Bundle$1 = class Bundle {
|
|
5476
|
+
var Bundle$1 = class Bundle {
|
|
5629
5477
|
constructor(options = {}) {
|
|
5630
|
-
this.intro = options.intro ||
|
|
5631
|
-
this.separator = options.separator !==
|
|
5478
|
+
this.intro = options.intro || "";
|
|
5479
|
+
this.separator = options.separator !== void 0 ? options.separator : "\n";
|
|
5632
5480
|
this.sources = [];
|
|
5633
5481
|
this.uniqueSources = [];
|
|
5634
5482
|
this.uniqueSourceIndexByFilename = {};
|
|
5635
5483
|
}
|
|
5636
|
-
|
|
5484
|
+
/**
|
|
5485
|
+
* Adds the specified source to the bundle, which can either be a `MagicString` object directly,
|
|
5486
|
+
* or an options object that holds a magic string `content` property and optionally provides
|
|
5487
|
+
* a `filename` for the source within the bundle, as well as an optional `ignoreList` hint
|
|
5488
|
+
* (which defaults to `false`). The `filename` is used when constructing the source map for the
|
|
5489
|
+
* bundle, to identify this `source` in the source map's `sources` field. The `ignoreList` hint
|
|
5490
|
+
* is used to populate the `x_google_ignoreList` extension field in the source map, which is a
|
|
5491
|
+
* mechanism for tools to signal to debuggers that certain sources should be ignored by default
|
|
5492
|
+
* (depending on user preferences).
|
|
5493
|
+
*/
|
|
5637
5494
|
addSource(source) {
|
|
5638
|
-
if (source instanceof MagicString) {
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
}
|
|
5651
|
-
|
|
5652
|
-
['filename', 'ignoreList', 'indentExclusionRanges', 'separator'].forEach((option) => {
|
|
5495
|
+
if (source instanceof MagicString) return this.addSource({
|
|
5496
|
+
content: source,
|
|
5497
|
+
filename: source.filename,
|
|
5498
|
+
separator: this.separator
|
|
5499
|
+
});
|
|
5500
|
+
if (!isObject(source) || !source.content) throw new Error("bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`");
|
|
5501
|
+
[
|
|
5502
|
+
"filename",
|
|
5503
|
+
"ignoreList",
|
|
5504
|
+
"indentExclusionRanges",
|
|
5505
|
+
"separator"
|
|
5506
|
+
].forEach((option) => {
|
|
5653
5507
|
if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
|
|
5654
5508
|
});
|
|
5655
|
-
|
|
5656
|
-
if (source.
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
} else {
|
|
5666
|
-
const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
5667
|
-
if (source.content.original !== uniqueSource.content) {
|
|
5668
|
-
throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
|
|
5669
|
-
}
|
|
5670
|
-
}
|
|
5509
|
+
if (source.separator === void 0) source.separator = this.separator;
|
|
5510
|
+
if (source.filename) if (!hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
|
|
5511
|
+
this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
|
|
5512
|
+
this.uniqueSources.push({
|
|
5513
|
+
filename: source.filename,
|
|
5514
|
+
content: source.content.original
|
|
5515
|
+
});
|
|
5516
|
+
} else {
|
|
5517
|
+
const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
|
|
5518
|
+
if (source.content.original !== uniqueSource.content) throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
|
|
5671
5519
|
}
|
|
5672
|
-
|
|
5673
5520
|
this.sources.push(source);
|
|
5674
5521
|
return this;
|
|
5675
5522
|
}
|
|
5676
|
-
|
|
5677
5523
|
append(str, options) {
|
|
5678
5524
|
this.addSource({
|
|
5679
5525
|
content: new MagicString(str),
|
|
5680
|
-
separator:
|
|
5526
|
+
separator: options && options.separator || ""
|
|
5681
5527
|
});
|
|
5682
|
-
|
|
5683
5528
|
return this;
|
|
5684
5529
|
}
|
|
5685
|
-
|
|
5686
5530
|
clone() {
|
|
5687
5531
|
const bundle = new Bundle({
|
|
5688
5532
|
intro: this.intro,
|
|
5689
|
-
separator: this.separator
|
|
5533
|
+
separator: this.separator
|
|
5690
5534
|
});
|
|
5691
|
-
|
|
5692
5535
|
this.sources.forEach((source) => {
|
|
5693
5536
|
bundle.addSource({
|
|
5694
5537
|
filename: source.filename,
|
|
5695
5538
|
content: source.content.clone(),
|
|
5696
|
-
separator: source.separator
|
|
5539
|
+
separator: source.separator
|
|
5697
5540
|
});
|
|
5698
5541
|
});
|
|
5699
|
-
|
|
5700
5542
|
return bundle;
|
|
5701
5543
|
}
|
|
5702
|
-
|
|
5703
5544
|
generateDecodedMap(options = {}) {
|
|
5704
5545
|
const names = [];
|
|
5705
|
-
let x_google_ignoreList
|
|
5546
|
+
let x_google_ignoreList;
|
|
5706
5547
|
this.sources.forEach((source) => {
|
|
5707
5548
|
Object.keys(source.content.storedNames).forEach((name) => {
|
|
5708
|
-
if (
|
|
5549
|
+
if (!names.includes(name)) names.push(name);
|
|
5709
5550
|
});
|
|
5710
5551
|
});
|
|
5711
|
-
|
|
5712
5552
|
const mappings = new Mappings(options.hires);
|
|
5713
|
-
|
|
5714
|
-
if (this.intro) {
|
|
5715
|
-
mappings.advance(this.intro);
|
|
5716
|
-
}
|
|
5717
|
-
|
|
5553
|
+
if (this.intro) mappings.advance(this.intro);
|
|
5718
5554
|
this.sources.forEach((source, i) => {
|
|
5719
|
-
if (i > 0)
|
|
5720
|
-
mappings.advance(this.separator);
|
|
5721
|
-
}
|
|
5722
|
-
|
|
5555
|
+
if (i > 0) mappings.advance(this.separator);
|
|
5723
5556
|
const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
|
|
5724
5557
|
const magicString = source.content;
|
|
5725
5558
|
const locate = getLocator(magicString.original);
|
|
5726
|
-
|
|
5727
|
-
if (magicString.intro) {
|
|
5728
|
-
mappings.advance(magicString.intro);
|
|
5729
|
-
}
|
|
5730
|
-
|
|
5559
|
+
if (magicString.intro) mappings.advance(magicString.intro);
|
|
5731
5560
|
magicString.firstChunk.eachNext((chunk) => {
|
|
5732
5561
|
const loc = locate(chunk.start);
|
|
5733
|
-
|
|
5734
5562
|
if (chunk.intro.length) mappings.advance(chunk.intro);
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
mappings.addEdit(
|
|
5739
|
-
sourceIndex,
|
|
5740
|
-
chunk.content,
|
|
5741
|
-
loc,
|
|
5742
|
-
chunk.storeName ? names.indexOf(chunk.original) : -1,
|
|
5743
|
-
);
|
|
5744
|
-
} else {
|
|
5745
|
-
mappings.addUneditedChunk(
|
|
5746
|
-
sourceIndex,
|
|
5747
|
-
chunk,
|
|
5748
|
-
magicString.original,
|
|
5749
|
-
loc,
|
|
5750
|
-
magicString.sourcemapLocations,
|
|
5751
|
-
);
|
|
5752
|
-
}
|
|
5753
|
-
} else {
|
|
5754
|
-
mappings.advance(chunk.content);
|
|
5755
|
-
}
|
|
5756
|
-
|
|
5563
|
+
if (source.filename) if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
|
|
5564
|
+
else mappings.addUneditedChunk(sourceIndex, chunk, magicString.original, loc, magicString.sourcemapLocations);
|
|
5565
|
+
else mappings.advance(chunk.content);
|
|
5757
5566
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
5758
5567
|
});
|
|
5759
|
-
|
|
5760
|
-
if (magicString.outro) {
|
|
5761
|
-
mappings.advance(magicString.outro);
|
|
5762
|
-
}
|
|
5763
|
-
|
|
5568
|
+
if (magicString.outro) mappings.advance(magicString.outro);
|
|
5764
5569
|
if (source.ignoreList && sourceIndex !== -1) {
|
|
5765
|
-
if (x_google_ignoreList ===
|
|
5766
|
-
x_google_ignoreList = [];
|
|
5767
|
-
}
|
|
5570
|
+
if (x_google_ignoreList === void 0) x_google_ignoreList = [];
|
|
5768
5571
|
x_google_ignoreList.push(sourceIndex);
|
|
5769
5572
|
}
|
|
5770
5573
|
});
|
|
5771
|
-
|
|
5772
5574
|
return {
|
|
5773
|
-
file: options.file ? options.file.split(/[/\\]/).pop() :
|
|
5575
|
+
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
5774
5576
|
sources: this.uniqueSources.map((source) => {
|
|
5775
5577
|
return options.file ? getRelativePath(options.file, source.filename) : source.filename;
|
|
5776
5578
|
}),
|
|
@@ -5779,137 +5581,91 @@ let Bundle$1 = class Bundle {
|
|
|
5779
5581
|
}),
|
|
5780
5582
|
names,
|
|
5781
5583
|
mappings: mappings.raw,
|
|
5782
|
-
x_google_ignoreList
|
|
5584
|
+
x_google_ignoreList
|
|
5783
5585
|
};
|
|
5784
5586
|
}
|
|
5785
|
-
|
|
5786
5587
|
generateMap(options) {
|
|
5787
5588
|
return new SourceMap(this.generateDecodedMap(options));
|
|
5788
5589
|
}
|
|
5789
|
-
|
|
5790
5590
|
getIndentString() {
|
|
5791
5591
|
const indentStringCounts = {};
|
|
5792
|
-
|
|
5793
5592
|
this.sources.forEach((source) => {
|
|
5794
5593
|
const indentStr = source.content._getRawIndentString();
|
|
5795
|
-
|
|
5796
5594
|
if (indentStr === null) return;
|
|
5797
|
-
|
|
5798
5595
|
if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
|
|
5799
5596
|
indentStringCounts[indentStr] += 1;
|
|
5800
5597
|
});
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
return indentStringCounts[a] - indentStringCounts[b];
|
|
5805
|
-
})[0] || '\t'
|
|
5806
|
-
);
|
|
5598
|
+
return Object.keys(indentStringCounts).sort((a, b) => {
|
|
5599
|
+
return indentStringCounts[a] - indentStringCounts[b];
|
|
5600
|
+
})[0] || " ";
|
|
5807
5601
|
}
|
|
5808
|
-
|
|
5809
5602
|
indent(indentStr) {
|
|
5810
|
-
if (!arguments.length)
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
if (indentStr === '') return this; // noop
|
|
5815
|
-
|
|
5816
|
-
let trailingNewline = !this.intro || this.intro.slice(-1) === '\n';
|
|
5817
|
-
|
|
5603
|
+
if (!arguments.length) indentStr = this.getIndentString();
|
|
5604
|
+
if (indentStr === "") return this;
|
|
5605
|
+
let trailingNewline = !this.intro || this.intro.slice(-1) === "\n";
|
|
5818
5606
|
this.sources.forEach((source, i) => {
|
|
5819
|
-
const separator = source.separator !==
|
|
5820
|
-
const indentStart = trailingNewline ||
|
|
5821
|
-
|
|
5607
|
+
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
5608
|
+
const indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
|
|
5822
5609
|
source.content.indent(indentStr, {
|
|
5823
5610
|
exclude: source.indentExclusionRanges,
|
|
5824
|
-
indentStart
|
|
5611
|
+
indentStart
|
|
5825
5612
|
});
|
|
5826
|
-
|
|
5827
|
-
|
|
5613
|
+
trailingNewline = source.content.lastChar() === "\n";
|
|
5614
|
+
});
|
|
5615
|
+
if (this.intro) this.intro = indentStr + this.intro.replace(/^[^\n]/gm, (match, index) => {
|
|
5616
|
+
return index > 0 ? indentStr + match : match;
|
|
5828
5617
|
});
|
|
5829
|
-
|
|
5830
|
-
if (this.intro) {
|
|
5831
|
-
this.intro =
|
|
5832
|
-
indentStr +
|
|
5833
|
-
this.intro.replace(/^[^\n]/gm, (match, index) => {
|
|
5834
|
-
return index > 0 ? indentStr + match : match;
|
|
5835
|
-
});
|
|
5836
|
-
}
|
|
5837
|
-
|
|
5838
5618
|
return this;
|
|
5839
5619
|
}
|
|
5840
|
-
|
|
5841
5620
|
prepend(str) {
|
|
5842
5621
|
this.intro = str + this.intro;
|
|
5843
5622
|
return this;
|
|
5844
5623
|
}
|
|
5845
|
-
|
|
5846
5624
|
toString() {
|
|
5847
|
-
const body = this.sources
|
|
5848
|
-
.
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
return str;
|
|
5853
|
-
})
|
|
5854
|
-
.join('');
|
|
5855
|
-
|
|
5625
|
+
const body = this.sources.map((source, i) => {
|
|
5626
|
+
const separator = source.separator !== void 0 ? source.separator : this.separator;
|
|
5627
|
+
return (i > 0 ? separator : "") + source.content.toString();
|
|
5628
|
+
}).join("");
|
|
5856
5629
|
return this.intro + body;
|
|
5857
5630
|
}
|
|
5858
|
-
|
|
5859
5631
|
isEmpty() {
|
|
5860
5632
|
if (this.intro.length && this.intro.trim()) return false;
|
|
5861
5633
|
if (this.sources.some((source) => !source.content.isEmpty())) return false;
|
|
5862
5634
|
return true;
|
|
5863
5635
|
}
|
|
5864
|
-
|
|
5865
5636
|
length() {
|
|
5866
|
-
return this.sources.reduce(
|
|
5867
|
-
(length, source) => length + source.content.length(),
|
|
5868
|
-
this.intro.length,
|
|
5869
|
-
);
|
|
5637
|
+
return this.sources.reduce((length, source) => length + source.content.length(), this.intro.length);
|
|
5870
5638
|
}
|
|
5871
|
-
|
|
5872
5639
|
trimLines() {
|
|
5873
|
-
return this.trim(
|
|
5640
|
+
return this.trim("[\\r\\n]");
|
|
5874
5641
|
}
|
|
5875
|
-
|
|
5876
5642
|
trim(charType) {
|
|
5877
5643
|
return this.trimStart(charType).trimEnd(charType);
|
|
5878
5644
|
}
|
|
5879
|
-
|
|
5880
5645
|
trimStart(charType) {
|
|
5881
|
-
const rx = new RegExp(
|
|
5882
|
-
this.intro = this.intro.replace(rx,
|
|
5883
|
-
|
|
5646
|
+
const rx = new RegExp(`^${charType || "\\s"}+`);
|
|
5647
|
+
this.intro = this.intro.replace(rx, "");
|
|
5884
5648
|
if (!this.intro) {
|
|
5885
5649
|
let source;
|
|
5886
5650
|
let i = 0;
|
|
5887
|
-
|
|
5888
5651
|
do {
|
|
5889
5652
|
source = this.sources[i++];
|
|
5890
|
-
if (!source)
|
|
5891
|
-
break;
|
|
5892
|
-
}
|
|
5653
|
+
if (!source) break;
|
|
5893
5654
|
} while (!source.content.trimStartAborted(charType));
|
|
5894
5655
|
}
|
|
5895
|
-
|
|
5896
5656
|
return this;
|
|
5897
5657
|
}
|
|
5898
|
-
|
|
5899
5658
|
trimEnd(charType) {
|
|
5900
|
-
const rx = new RegExp(
|
|
5901
|
-
|
|
5659
|
+
const rx = new RegExp(`${charType || "\\s"}+$`);
|
|
5902
5660
|
let source;
|
|
5903
5661
|
let i = this.sources.length - 1;
|
|
5904
|
-
|
|
5905
5662
|
do {
|
|
5906
5663
|
source = this.sources[i--];
|
|
5907
5664
|
if (!source) {
|
|
5908
|
-
this.intro = this.intro.replace(rx,
|
|
5665
|
+
this.intro = this.intro.replace(rx, "");
|
|
5909
5666
|
break;
|
|
5910
5667
|
}
|
|
5911
5668
|
} while (!source.content.trimEndAborted(charType));
|
|
5912
|
-
|
|
5913
5669
|
return this;
|
|
5914
5670
|
}
|
|
5915
5671
|
};
|
|
@@ -6669,13 +6425,14 @@ const RESERVED_NAMES = new Set([
|
|
|
6669
6425
|
]);
|
|
6670
6426
|
|
|
6671
6427
|
const illegalCharacters = /[^\w$]/g;
|
|
6428
|
+
const illegalCharacter = /[^\w$]/;
|
|
6672
6429
|
const startsWithDigit = (value) => /\d/.test(value[0]);
|
|
6673
6430
|
const needsEscape = (value) => startsWithDigit(value) || RESERVED_NAMES.has(value) || value === 'arguments';
|
|
6674
6431
|
function isLegal(value) {
|
|
6675
6432
|
if (needsEscape(value)) {
|
|
6676
6433
|
return false;
|
|
6677
6434
|
}
|
|
6678
|
-
return !
|
|
6435
|
+
return !illegalCharacter.test(value);
|
|
6679
6436
|
}
|
|
6680
6437
|
function makeLegal(value) {
|
|
6681
6438
|
value = value
|
|
@@ -9449,12 +9206,12 @@ class IdentifierBase extends NodeBase {
|
|
|
9449
9206
|
this.variable.module.hasTreeShakingPassStarted)) {
|
|
9450
9207
|
return (this.isTDZAccess = false);
|
|
9451
9208
|
}
|
|
9452
|
-
let
|
|
9209
|
+
let declaration_id;
|
|
9453
9210
|
if (this.variable.declarations &&
|
|
9454
9211
|
this.variable.declarations.length === 1 &&
|
|
9455
|
-
(
|
|
9456
|
-
this.start <
|
|
9457
|
-
closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(
|
|
9212
|
+
(declaration_id = this.variable.declarations[0]) &&
|
|
9213
|
+
this.start < declaration_id.start &&
|
|
9214
|
+
closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(declaration_id)) {
|
|
9458
9215
|
// a variable accessed before its declaration
|
|
9459
9216
|
// in the same function or at top level of module
|
|
9460
9217
|
return (this.isTDZAccess = true);
|
|
@@ -12336,13 +12093,13 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
|
|
|
12336
12093
|
}
|
|
12337
12094
|
let exportBlock = '';
|
|
12338
12095
|
if (namedExportsMode) {
|
|
12339
|
-
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode:
|
|
12096
|
+
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: dependencyNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
12340
12097
|
if (!reexports) {
|
|
12341
12098
|
continue;
|
|
12342
12099
|
}
|
|
12343
12100
|
for (const specifier of reexports) {
|
|
12344
12101
|
if (specifier.reexported !== '*') {
|
|
12345
|
-
const importName = getReexportedImportName(name, specifier.imported,
|
|
12102
|
+
const importName = getReexportedImportName(name, specifier.imported, dependencyNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
|
|
12346
12103
|
if (exportBlock)
|
|
12347
12104
|
exportBlock += n;
|
|
12348
12105
|
if (specifier.imported !== '*' && specifier.needsLiveBinding) {
|
|
@@ -12421,14 +12178,14 @@ function getSingleDefaultExport(exports, dependencies, interop, externalLiveBind
|
|
|
12421
12178
|
return exports[0].local;
|
|
12422
12179
|
}
|
|
12423
12180
|
else {
|
|
12424
|
-
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode:
|
|
12181
|
+
for (const { defaultVariableName, importPath, isChunk, name, namedExportsMode: dependencyNamedExportsMode, namespaceVariableName, reexports } of dependencies) {
|
|
12425
12182
|
if (reexports) {
|
|
12426
|
-
return getReexportedImportName(name, reexports[0].imported,
|
|
12183
|
+
return getReexportedImportName(name, reexports[0].imported, dependencyNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, importPath, externalLiveBindings, getPropertyAccess);
|
|
12427
12184
|
}
|
|
12428
12185
|
}
|
|
12429
12186
|
}
|
|
12430
12187
|
}
|
|
12431
|
-
function getReexportedImportName(moduleVariableName, imported,
|
|
12188
|
+
function getReexportedImportName(moduleVariableName, imported, dependencyNamedExportsMode, isChunk, defaultVariableName, namespaceVariableName, interop, moduleId, externalLiveBindings, getPropertyAccess) {
|
|
12432
12189
|
if (imported === 'default') {
|
|
12433
12190
|
if (!isChunk) {
|
|
12434
12191
|
const moduleInterop = interop(moduleId);
|
|
@@ -12439,12 +12196,14 @@ function getReexportedImportName(moduleVariableName, imported, depNamedExportsMo
|
|
|
12439
12196
|
? `${variableName}${getPropertyAccess('default')}`
|
|
12440
12197
|
: variableName;
|
|
12441
12198
|
}
|
|
12442
|
-
return
|
|
12199
|
+
return dependencyNamedExportsMode
|
|
12443
12200
|
? `${moduleVariableName}${getPropertyAccess('default')}`
|
|
12444
12201
|
: moduleVariableName;
|
|
12445
12202
|
}
|
|
12446
12203
|
if (imported === '*') {
|
|
12447
|
-
return (isChunk
|
|
12204
|
+
return (isChunk
|
|
12205
|
+
? !dependencyNamedExportsMode
|
|
12206
|
+
: namespaceInteropHelpersByInteropType[interop(moduleId)])
|
|
12448
12207
|
? namespaceVariableName
|
|
12449
12208
|
: moduleVariableName;
|
|
12450
12209
|
}
|
|
@@ -12669,6 +12428,7 @@ const builtinModules = [
|
|
|
12669
12428
|
"util/types",
|
|
12670
12429
|
"node:v8",
|
|
12671
12430
|
"v8",
|
|
12431
|
+
"node:vfs",
|
|
12672
12432
|
"node:vm",
|
|
12673
12433
|
"vm",
|
|
12674
12434
|
"node:wasi",
|
|
@@ -12958,7 +12718,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultE
|
|
|
12958
12718
|
}
|
|
12959
12719
|
warnOnBuiltins(log, dependencies);
|
|
12960
12720
|
const external = trimEmptyImports(dependencies);
|
|
12961
|
-
const deps = external.map(
|
|
12721
|
+
const deps = external.map(dependency => dependency.globalName || 'null');
|
|
12962
12722
|
const parameters = external.map(m => m.name);
|
|
12963
12723
|
if (hasExports && !name) {
|
|
12964
12724
|
log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logMissingNameOptionForIifeExport());
|
|
@@ -13179,21 +12939,21 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
13179
12939
|
}
|
|
13180
12940
|
throwOnPhase('umd', id, dependencies);
|
|
13181
12941
|
warnOnBuiltins(log, dependencies);
|
|
13182
|
-
const
|
|
13183
|
-
const
|
|
12942
|
+
const amdDependencies = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
|
|
12943
|
+
const cjsDependencies = dependencies.map(m => `require('${m.importPath}')`);
|
|
13184
12944
|
const trimmedImports = trimEmptyImports(dependencies);
|
|
13185
|
-
const
|
|
12945
|
+
const globalDependencies = trimmedImports.map(module => globalProperty(module.globalName, globalVariable, getPropertyAccess));
|
|
13186
12946
|
const factoryParameters = trimmedImports.map(m => m.name);
|
|
13187
12947
|
if ((hasExports || noConflict) &&
|
|
13188
12948
|
(namedExportsMode || (hasExports && exports[0]?.local === 'exports.default'))) {
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
12949
|
+
amdDependencies.unshift(`'exports'`);
|
|
12950
|
+
cjsDependencies.unshift(`exports`);
|
|
12951
|
+
globalDependencies.unshift(assignToDeepVariable(name, globalVariable, globals, `${extend ? `${globalProperty(name, globalVariable, getPropertyAccess)}${_}||${_}` : ''}{}`, snippets, log));
|
|
13192
12952
|
factoryParameters.unshift('exports');
|
|
13193
12953
|
}
|
|
13194
12954
|
const completeAmdId = getCompleteAmdId(amd, id);
|
|
13195
12955
|
const amdParameters = (completeAmdId ? `'${completeAmdId}',${_}` : ``) +
|
|
13196
|
-
(
|
|
12956
|
+
(amdDependencies.length > 0 ? `[${amdDependencies.join(`,${_}`)}],${_}` : ``);
|
|
13197
12957
|
const define = amd.define;
|
|
13198
12958
|
const cjsExport = !namedExportsMode && hasExports ? `module.exports${_}=${_}` : ``;
|
|
13199
12959
|
const useStrict = strict ? `${_}'use strict';${n}` : ``;
|
|
@@ -13202,13 +12962,13 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
13202
12962
|
const noConflictExportsVariable = compact ? 'e' : 'exports';
|
|
13203
12963
|
let factory;
|
|
13204
12964
|
if (!namedExportsMode && hasExports) {
|
|
13205
|
-
factory = `${cnst} ${noConflictExportsVariable}${_}=${_}${assignToDeepVariable(name, globalVariable, globals, `${factoryVariable}(${
|
|
12965
|
+
factory = `${cnst} ${noConflictExportsVariable}${_}=${_}${assignToDeepVariable(name, globalVariable, globals, `${factoryVariable}(${globalDependencies.join(`,${_}`)})`, snippets, log)};`;
|
|
13206
12966
|
}
|
|
13207
12967
|
else {
|
|
13208
|
-
const module =
|
|
12968
|
+
const module = globalDependencies.shift();
|
|
13209
12969
|
factory =
|
|
13210
12970
|
`${cnst} ${noConflictExportsVariable}${_}=${_}${module};${n}` +
|
|
13211
|
-
`${t}${t}${factoryVariable}(${[noConflictExportsVariable, ...
|
|
12971
|
+
`${t}${t}${factoryVariable}(${[noConflictExportsVariable, ...globalDependencies].join(`,${_}`)});`;
|
|
13212
12972
|
}
|
|
13213
12973
|
iifeExport =
|
|
13214
12974
|
`(${getFunctionIntro([], { isAsync: false, name: null })}{${n}` +
|
|
@@ -13222,12 +12982,12 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
13222
12982
|
`${t}})()`;
|
|
13223
12983
|
}
|
|
13224
12984
|
else {
|
|
13225
|
-
iifeExport = `${factoryVariable}(${
|
|
12985
|
+
iifeExport = `${factoryVariable}(${globalDependencies.join(`,${_}`)})`;
|
|
13226
12986
|
if (!namedExportsMode && hasExports) {
|
|
13227
12987
|
iifeExport = assignToDeepVariable(name, globalVariable, globals, iifeExport, snippets, log);
|
|
13228
12988
|
}
|
|
13229
12989
|
}
|
|
13230
|
-
const iifeNeedsGlobal = hasExports || (noConflict && namedExportsMode) ||
|
|
12990
|
+
const iifeNeedsGlobal = hasExports || (noConflict && namedExportsMode) || globalDependencies.length > 0;
|
|
13231
12991
|
const wrapperParameters = [factoryVariable];
|
|
13232
12992
|
if (iifeNeedsGlobal) {
|
|
13233
12993
|
wrapperParameters.unshift(globalVariable);
|
|
@@ -13239,7 +12999,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultEx
|
|
|
13239
12999
|
const iifeEnd = iifeNeedsGlobal ? ')' : '';
|
|
13240
13000
|
const cjsIntro = iifeNeedsGlobal
|
|
13241
13001
|
? `${t}typeof exports${_}===${_}'object'${_}&&${_}typeof module${_}!==${_}'undefined'${_}?` +
|
|
13242
|
-
`${_}${cjsExport}${factoryVariable}(${
|
|
13002
|
+
`${_}${cjsExport}${factoryVariable}(${cjsDependencies.join(`,${_}`)})${_}:${n}`
|
|
13243
13003
|
: '';
|
|
13244
13004
|
const wrapperIntro = `(${getNonArrowFunctionIntro(wrapperParameters, { isAsync: false, name: null })}{${n}` +
|
|
13245
13005
|
cjsIntro +
|
|
@@ -15300,19 +15060,19 @@ class ImportExpression extends NodeBase {
|
|
|
15300
15060
|
return null;
|
|
15301
15061
|
const chunkInfos = [];
|
|
15302
15062
|
const importerPath = ownChunk.getFileName();
|
|
15303
|
-
for (const
|
|
15304
|
-
const resolvedImportPath = `'${
|
|
15305
|
-
if (
|
|
15063
|
+
for (const dependency of targetChunk.dependencies) {
|
|
15064
|
+
const resolvedImportPath = `'${dependency.getImportPath(importerPath)}'`;
|
|
15065
|
+
if (dependency instanceof ExternalChunk) {
|
|
15306
15066
|
chunkInfos.push({
|
|
15307
|
-
fileName:
|
|
15067
|
+
fileName: dependency.getFileName(),
|
|
15308
15068
|
resolvedImportPath,
|
|
15309
15069
|
type: 'external'
|
|
15310
15070
|
});
|
|
15311
15071
|
}
|
|
15312
15072
|
else {
|
|
15313
15073
|
chunkInfos.push({
|
|
15314
|
-
chunk:
|
|
15315
|
-
fileName:
|
|
15074
|
+
chunk: dependency.getPreRenderedChunkInfo(),
|
|
15075
|
+
fileName: dependency.getFileName(),
|
|
15316
15076
|
resolvedImportPath,
|
|
15317
15077
|
type: 'internal'
|
|
15318
15078
|
});
|
|
@@ -20489,9 +20249,9 @@ class Chunk {
|
|
|
20489
20249
|
// for static and dynamic entry points, add transitive dependencies to this
|
|
20490
20250
|
// chunk's dependencies to avoid loading latency
|
|
20491
20251
|
if (hoistTransitiveImports && !preserveModules && facadeModule !== null) {
|
|
20492
|
-
for (const
|
|
20493
|
-
if (
|
|
20494
|
-
this.inlineChunkDependencies(
|
|
20252
|
+
for (const dependency of dependencies) {
|
|
20253
|
+
if (dependency instanceof Chunk)
|
|
20254
|
+
this.inlineChunkDependencies(dependency);
|
|
20495
20255
|
}
|
|
20496
20256
|
}
|
|
20497
20257
|
}
|
|
@@ -20663,11 +20423,11 @@ class Chunk {
|
|
|
20663
20423
|
if (!chunk || format !== 'es') {
|
|
20664
20424
|
continue;
|
|
20665
20425
|
}
|
|
20666
|
-
const
|
|
20667
|
-
if (!
|
|
20426
|
+
const chunkDependency = this.renderedDependencies.get(chunk);
|
|
20427
|
+
if (!chunkDependency) {
|
|
20668
20428
|
continue;
|
|
20669
20429
|
}
|
|
20670
|
-
const { imports, reexports } =
|
|
20430
|
+
const { imports, reexports } = chunkDependency;
|
|
20671
20431
|
const importedByReexported = reexports?.find(({ reexported }) => reexported === exportName);
|
|
20672
20432
|
const isImported = imports?.find(({ imported }) => imported === importedByReexported?.imported);
|
|
20673
20433
|
if (!isImported) {
|
|
@@ -20877,6 +20637,10 @@ class Chunk {
|
|
|
20877
20637
|
return predefinedChunkName;
|
|
20878
20638
|
const { preserveModulesRoot, sanitizeFileName } = this.outputOptions;
|
|
20879
20639
|
const sanitizedId = sanitizeFileName(parseAst_js.normalize(module.id.split(QUERY_HASH_REGEX, 1)[0]));
|
|
20640
|
+
// The module id was sanitized, so the base must be sanitized as well before
|
|
20641
|
+
// comparing paths; otherwise ids containing sanitized characters escape the
|
|
20642
|
+
// base via "../" and trip the placeholder validation (#5446).
|
|
20643
|
+
const sanitizedBase = sanitizeFileName(this.inputBase);
|
|
20880
20644
|
const extensionName = path.extname(sanitizedId);
|
|
20881
20645
|
const idWithoutExtension = NON_ASSET_EXTENSIONS.has(extensionName)
|
|
20882
20646
|
? sanitizedId.slice(0, -extensionName.length)
|
|
@@ -20887,10 +20651,10 @@ class Chunk {
|
|
|
20887
20651
|
}
|
|
20888
20652
|
else {
|
|
20889
20653
|
// handle edge case in Windows
|
|
20890
|
-
if (
|
|
20891
|
-
return parseAst_js.relative(
|
|
20654
|
+
if (sanitizedBase === '/' && idWithoutExtension[0] !== '/') {
|
|
20655
|
+
return parseAst_js.relative(sanitizedBase, idWithoutExtension.replace(/^[a-zA-Z]:[/\\]/, '/'));
|
|
20892
20656
|
}
|
|
20893
|
-
return parseAst_js.relative(
|
|
20657
|
+
return parseAst_js.relative(sanitizedBase, idWithoutExtension);
|
|
20894
20658
|
}
|
|
20895
20659
|
}
|
|
20896
20660
|
else {
|
|
@@ -21005,12 +20769,12 @@ class Chunk {
|
|
|
21005
20769
|
return (this.renderedDependencies = renderedDependencies);
|
|
21006
20770
|
}
|
|
21007
20771
|
inlineChunkDependencies(chunk) {
|
|
21008
|
-
for (const
|
|
21009
|
-
if (this.dependencies.has(
|
|
20772
|
+
for (const dependency of chunk.dependencies) {
|
|
20773
|
+
if (this.dependencies.has(dependency))
|
|
21010
20774
|
continue;
|
|
21011
|
-
this.dependencies.add(
|
|
21012
|
-
if (
|
|
21013
|
-
this.inlineChunkDependencies(
|
|
20775
|
+
this.dependencies.add(dependency);
|
|
20776
|
+
if (dependency instanceof Chunk) {
|
|
20777
|
+
this.inlineChunkDependencies(dependency);
|
|
21014
20778
|
}
|
|
21015
20779
|
}
|
|
21016
20780
|
}
|
|
@@ -22464,7 +22228,7 @@ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bun
|
|
|
22464
22228
|
finalSourcemapFileName = sourcemapFileName
|
|
22465
22229
|
? replacePlaceholders(sourcemapFileName, hashesByPlaceholder)
|
|
22466
22230
|
: `${finalFileName}.map`;
|
|
22467
|
-
map.file = replacePlaceholders(map.file, hashesByPlaceholder);
|
|
22231
|
+
map.file = replacePlaceholders(map.file ?? '', hashesByPlaceholder);
|
|
22468
22232
|
updatedCode += emitSourceMapAndGetComment(finalSourcemapFileName, map, pluginDriver, options);
|
|
22469
22233
|
}
|
|
22470
22234
|
bundle[finalFileName] = chunk.finalizeChunk(updatedCode, map, finalSourcemapFileName, hashesByPlaceholder);
|
|
@@ -22997,7 +22761,6 @@ async function transform(source, module, pluginDriver, options) {
|
|
|
22997
22761
|
}
|
|
22998
22762
|
return new SourceMap({
|
|
22999
22763
|
...combinedMap,
|
|
23000
|
-
file: null,
|
|
23001
22764
|
sourcesContent: combinedMap.sourcesContent
|
|
23002
22765
|
});
|
|
23003
22766
|
},
|