vite 5.0.2 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +406 -12
- package/dist/node/chunks/{dep-ErEj4WmL.js → dep-4RECYSE1.js} +1670 -499
- package/dist/node/chunks/{dep-sKpqGbYj.js → dep-GiiHpyM6.js} +1 -1
- package/dist/node/chunks/{dep-CV-Y9tzJ.js → dep-nbvvoiwS.js} +1 -1
- package/dist/node/cli.js +6 -6
- package/dist/node/index.js +2 -2
- package/package.json +7 -7
|
@@ -6,8 +6,8 @@ import { promisify as promisify$4, format as format$2, inspect } from 'node:util
|
|
|
6
6
|
import { performance } from 'node:perf_hooks';
|
|
7
7
|
import { createRequire as createRequire$1, builtinModules } from 'node:module';
|
|
8
8
|
import require$$0$3 from 'tty';
|
|
9
|
-
import esbuild, { transform as transform$1, formatMessages, build as build$3 } from 'esbuild';
|
|
10
9
|
import require$$0$4, { win32, posix, isAbsolute as isAbsolute$1, resolve as resolve$3, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join as join$1, sep, normalize } from 'path';
|
|
10
|
+
import esbuild, { transform as transform$1, formatMessages, build as build$3 } from 'esbuild';
|
|
11
11
|
import * as require$$0$2 from 'fs';
|
|
12
12
|
import require$$0__default, { existsSync, readFileSync, statSync as statSync$1, readdirSync } from 'fs';
|
|
13
13
|
import require$$0$5 from 'events';
|
|
@@ -219,7 +219,16 @@ function alias$1(options = {}) {
|
|
|
219
219
|
if (matchedEntry.resolverFunction) {
|
|
220
220
|
return matchedEntry.resolverFunction.call(this, updatedId, importer, resolveOptions);
|
|
221
221
|
}
|
|
222
|
-
return this.resolve(updatedId, importer, Object.assign({ skipSelf: true }, resolveOptions)).then((resolved) =>
|
|
222
|
+
return this.resolve(updatedId, importer, Object.assign({ skipSelf: true }, resolveOptions)).then((resolved) => {
|
|
223
|
+
if (resolved)
|
|
224
|
+
return resolved;
|
|
225
|
+
if (!require$$0$4.isAbsolute(updatedId)) {
|
|
226
|
+
this.warn(`rewrote ${importee} to ${updatedId} but was not an abolute path and was not handled by other plugins. ` +
|
|
227
|
+
`This will lead to duplicated modules for the same path. ` +
|
|
228
|
+
`To avoid duplicating modules, you should resolve to an absolute path.`);
|
|
229
|
+
}
|
|
230
|
+
return { id: updatedId };
|
|
231
|
+
});
|
|
223
232
|
}
|
|
224
233
|
};
|
|
225
234
|
}
|
|
@@ -5298,7 +5307,7 @@ function makeres (key) {
|
|
|
5298
5307
|
return once(function RES () {
|
|
5299
5308
|
var cbs = reqs[key];
|
|
5300
5309
|
var len = cbs.length;
|
|
5301
|
-
var args = slice$
|
|
5310
|
+
var args = slice$3(arguments);
|
|
5302
5311
|
|
|
5303
5312
|
// XXX It's somewhat ambiguous whether a new callback added in this
|
|
5304
5313
|
// pass should be queued for later execution if something in the
|
|
@@ -5325,7 +5334,7 @@ function makeres (key) {
|
|
|
5325
5334
|
})
|
|
5326
5335
|
}
|
|
5327
5336
|
|
|
5328
|
-
function slice$
|
|
5337
|
+
function slice$3 (args) {
|
|
5329
5338
|
var length = args.length;
|
|
5330
5339
|
var array = [];
|
|
5331
5340
|
|
|
@@ -6556,10 +6565,10 @@ function getRelativePath(from, to) {
|
|
|
6556
6565
|
return fromParts.concat(toParts).join('/');
|
|
6557
6566
|
}
|
|
6558
6567
|
|
|
6559
|
-
const toString$
|
|
6568
|
+
const toString$3 = Object.prototype.toString;
|
|
6560
6569
|
|
|
6561
6570
|
function isObject$2(thing) {
|
|
6562
|
-
return toString$
|
|
6571
|
+
return toString$3.call(thing) === '[object Object]';
|
|
6563
6572
|
}
|
|
6564
6573
|
|
|
6565
6574
|
function getLocator(source) {
|
|
@@ -10657,7 +10666,7 @@ function remapping(input, loader, options) {
|
|
|
10657
10666
|
return new SourceMap(traceMappings(tree), opts);
|
|
10658
10667
|
}
|
|
10659
10668
|
|
|
10660
|
-
var src$
|
|
10669
|
+
var src$3 = {exports: {}};
|
|
10661
10670
|
|
|
10662
10671
|
var node$1 = {exports: {}};
|
|
10663
10672
|
|
|
@@ -11674,12 +11683,12 @@ function requireBrowser$1 () {
|
|
|
11674
11683
|
*/
|
|
11675
11684
|
|
|
11676
11685
|
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
|
11677
|
-
src$
|
|
11686
|
+
src$3.exports = requireBrowser$1();
|
|
11678
11687
|
} else {
|
|
11679
|
-
src$
|
|
11688
|
+
src$3.exports = requireNode$1();
|
|
11680
11689
|
}
|
|
11681
11690
|
|
|
11682
|
-
var srcExports$1 = src$
|
|
11691
|
+
var srcExports$1 = src$3.exports;
|
|
11683
11692
|
var debug$i = /*@__PURE__*/getDefaultExportFromCjs(srcExports$1);
|
|
11684
11693
|
|
|
11685
11694
|
let pnp;
|
|
@@ -12276,8 +12285,8 @@ function numberToPos(source, offset) {
|
|
|
12276
12285
|
return { line: line + 1, column };
|
|
12277
12286
|
}
|
|
12278
12287
|
function generateCodeFrame(source, start = 0, end) {
|
|
12279
|
-
start = posToNumber(source, start);
|
|
12280
|
-
end = end !== undefined ? posToNumber(source, end) : start;
|
|
12288
|
+
start = Math.max(posToNumber(source, start), 0);
|
|
12289
|
+
end = Math.min(end !== undefined ? posToNumber(source, end) : start, source.length);
|
|
12281
12290
|
const lines = source.split(splitRE);
|
|
12282
12291
|
let count = 0;
|
|
12283
12292
|
const res = [];
|
|
@@ -12681,6 +12690,7 @@ function arraify(target) {
|
|
|
12681
12690
|
const multilineCommentsRE$1 = /\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g;
|
|
12682
12691
|
const singlelineCommentsRE$1 = /\/\/.*/g;
|
|
12683
12692
|
const requestQuerySplitRE = /\?(?!.*[/|}])/;
|
|
12693
|
+
const requestQueryMaybeEscapedSplitRE = /\\?\?(?!.*[/|}])/;
|
|
12684
12694
|
function parseRequest(id) {
|
|
12685
12695
|
const [_, search] = id.split(requestQuerySplitRE, 2);
|
|
12686
12696
|
if (!search) {
|
|
@@ -12945,6 +12955,15 @@ function getPackageManagerCommand(type = 'install') {
|
|
|
12945
12955
|
function isDevServer(server) {
|
|
12946
12956
|
return 'pluginContainer' in server;
|
|
12947
12957
|
}
|
|
12958
|
+
function promiseWithResolvers() {
|
|
12959
|
+
let resolve;
|
|
12960
|
+
let reject;
|
|
12961
|
+
const promise = new Promise((_resolve, _reject) => {
|
|
12962
|
+
resolve = _resolve;
|
|
12963
|
+
reject = _reject;
|
|
12964
|
+
});
|
|
12965
|
+
return { promise, resolve, reject };
|
|
12966
|
+
}
|
|
12948
12967
|
|
|
12949
12968
|
/* eslint no-console: 0 */
|
|
12950
12969
|
const LogLevels = {
|
|
@@ -14919,86 +14938,1020 @@ function terserPlugin(config) {
|
|
|
14919
14938
|
};
|
|
14920
14939
|
}
|
|
14921
14940
|
|
|
14922
|
-
var
|
|
14941
|
+
var toString$2 = {}.toString;
|
|
14923
14942
|
|
|
14924
|
-
var
|
|
14925
|
-
|
|
14943
|
+
var isarray = Array.isArray || function (arr) {
|
|
14944
|
+
return toString$2.call(arr) == '[object Array]';
|
|
14926
14945
|
};
|
|
14927
14946
|
|
|
14928
|
-
var
|
|
14929
|
-
|
|
14930
|
-
|
|
14931
|
-
|
|
14932
|
-
|
|
14947
|
+
var toStr$2 = Object.prototype.toString;
|
|
14948
|
+
|
|
14949
|
+
var isArguments = function isArguments(value) {
|
|
14950
|
+
var str = toStr$2.call(value);
|
|
14951
|
+
var isArgs = str === '[object Arguments]';
|
|
14952
|
+
if (!isArgs) {
|
|
14953
|
+
isArgs = str !== '[object Array]' &&
|
|
14954
|
+
value !== null &&
|
|
14955
|
+
typeof value === 'object' &&
|
|
14956
|
+
typeof value.length === 'number' &&
|
|
14957
|
+
value.length >= 0 &&
|
|
14958
|
+
toStr$2.call(value.callee) === '[object Function]';
|
|
14959
|
+
}
|
|
14960
|
+
return isArgs;
|
|
14961
|
+
};
|
|
14962
|
+
|
|
14963
|
+
var implementation$4;
|
|
14964
|
+
var hasRequiredImplementation;
|
|
14965
|
+
|
|
14966
|
+
function requireImplementation () {
|
|
14967
|
+
if (hasRequiredImplementation) return implementation$4;
|
|
14968
|
+
hasRequiredImplementation = 1;
|
|
14969
|
+
|
|
14970
|
+
var keysShim;
|
|
14971
|
+
if (!Object.keys) {
|
|
14972
|
+
// modified from https://github.com/es-shims/es5-shim
|
|
14973
|
+
var has = Object.prototype.hasOwnProperty;
|
|
14974
|
+
var toStr = Object.prototype.toString;
|
|
14975
|
+
var isArgs = isArguments; // eslint-disable-line global-require
|
|
14976
|
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
14977
|
+
var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
|
|
14978
|
+
var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
|
|
14979
|
+
var dontEnums = [
|
|
14980
|
+
'toString',
|
|
14981
|
+
'toLocaleString',
|
|
14982
|
+
'valueOf',
|
|
14983
|
+
'hasOwnProperty',
|
|
14984
|
+
'isPrototypeOf',
|
|
14985
|
+
'propertyIsEnumerable',
|
|
14986
|
+
'constructor'
|
|
14987
|
+
];
|
|
14988
|
+
var equalsConstructorPrototype = function (o) {
|
|
14989
|
+
var ctor = o.constructor;
|
|
14990
|
+
return ctor && ctor.prototype === o;
|
|
14991
|
+
};
|
|
14992
|
+
var excludedKeys = {
|
|
14993
|
+
$applicationCache: true,
|
|
14994
|
+
$console: true,
|
|
14995
|
+
$external: true,
|
|
14996
|
+
$frame: true,
|
|
14997
|
+
$frameElement: true,
|
|
14998
|
+
$frames: true,
|
|
14999
|
+
$innerHeight: true,
|
|
15000
|
+
$innerWidth: true,
|
|
15001
|
+
$onmozfullscreenchange: true,
|
|
15002
|
+
$onmozfullscreenerror: true,
|
|
15003
|
+
$outerHeight: true,
|
|
15004
|
+
$outerWidth: true,
|
|
15005
|
+
$pageXOffset: true,
|
|
15006
|
+
$pageYOffset: true,
|
|
15007
|
+
$parent: true,
|
|
15008
|
+
$scrollLeft: true,
|
|
15009
|
+
$scrollTop: true,
|
|
15010
|
+
$scrollX: true,
|
|
15011
|
+
$scrollY: true,
|
|
15012
|
+
$self: true,
|
|
15013
|
+
$webkitIndexedDB: true,
|
|
15014
|
+
$webkitStorageInfo: true,
|
|
15015
|
+
$window: true
|
|
15016
|
+
};
|
|
15017
|
+
var hasAutomationEqualityBug = (function () {
|
|
15018
|
+
/* global window */
|
|
15019
|
+
if (typeof window === 'undefined') { return false; }
|
|
15020
|
+
for (var k in window) {
|
|
15021
|
+
try {
|
|
15022
|
+
if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
|
|
15023
|
+
try {
|
|
15024
|
+
equalsConstructorPrototype(window[k]);
|
|
15025
|
+
} catch (e) {
|
|
15026
|
+
return true;
|
|
15027
|
+
}
|
|
15028
|
+
}
|
|
15029
|
+
} catch (e) {
|
|
15030
|
+
return true;
|
|
15031
|
+
}
|
|
15032
|
+
}
|
|
15033
|
+
return false;
|
|
15034
|
+
}());
|
|
15035
|
+
var equalsConstructorPrototypeIfNotBuggy = function (o) {
|
|
15036
|
+
/* global window */
|
|
15037
|
+
if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
|
|
15038
|
+
return equalsConstructorPrototype(o);
|
|
15039
|
+
}
|
|
15040
|
+
try {
|
|
15041
|
+
return equalsConstructorPrototype(o);
|
|
15042
|
+
} catch (e) {
|
|
15043
|
+
return false;
|
|
15044
|
+
}
|
|
15045
|
+
};
|
|
15046
|
+
|
|
15047
|
+
keysShim = function keys(object) {
|
|
15048
|
+
var isObject = object !== null && typeof object === 'object';
|
|
15049
|
+
var isFunction = toStr.call(object) === '[object Function]';
|
|
15050
|
+
var isArguments = isArgs(object);
|
|
15051
|
+
var isString = isObject && toStr.call(object) === '[object String]';
|
|
15052
|
+
var theKeys = [];
|
|
15053
|
+
|
|
15054
|
+
if (!isObject && !isFunction && !isArguments) {
|
|
15055
|
+
throw new TypeError('Object.keys called on a non-object');
|
|
15056
|
+
}
|
|
15057
|
+
|
|
15058
|
+
var skipProto = hasProtoEnumBug && isFunction;
|
|
15059
|
+
if (isString && object.length > 0 && !has.call(object, 0)) {
|
|
15060
|
+
for (var i = 0; i < object.length; ++i) {
|
|
15061
|
+
theKeys.push(String(i));
|
|
15062
|
+
}
|
|
15063
|
+
}
|
|
15064
|
+
|
|
15065
|
+
if (isArguments && object.length > 0) {
|
|
15066
|
+
for (var j = 0; j < object.length; ++j) {
|
|
15067
|
+
theKeys.push(String(j));
|
|
15068
|
+
}
|
|
15069
|
+
} else {
|
|
15070
|
+
for (var name in object) {
|
|
15071
|
+
if (!(skipProto && name === 'prototype') && has.call(object, name)) {
|
|
15072
|
+
theKeys.push(String(name));
|
|
15073
|
+
}
|
|
15074
|
+
}
|
|
15075
|
+
}
|
|
15076
|
+
|
|
15077
|
+
if (hasDontEnumBug) {
|
|
15078
|
+
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
|
|
15079
|
+
|
|
15080
|
+
for (var k = 0; k < dontEnums.length; ++k) {
|
|
15081
|
+
if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
|
|
15082
|
+
theKeys.push(dontEnums[k]);
|
|
15083
|
+
}
|
|
15084
|
+
}
|
|
15085
|
+
}
|
|
15086
|
+
return theKeys;
|
|
15087
|
+
};
|
|
14933
15088
|
}
|
|
14934
|
-
|
|
14935
|
-
|
|
14936
|
-
|
|
14937
|
-
|
|
14938
|
-
|
|
14939
|
-
|
|
14940
|
-
|
|
14941
|
-
|
|
14942
|
-
|
|
14943
|
-
|
|
14944
|
-
|
|
14945
|
-
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
|
|
15089
|
+
implementation$4 = keysShim;
|
|
15090
|
+
return implementation$4;
|
|
15091
|
+
}
|
|
15092
|
+
|
|
15093
|
+
var slice$2 = Array.prototype.slice;
|
|
15094
|
+
var isArgs = isArguments;
|
|
15095
|
+
|
|
15096
|
+
var origKeys = Object.keys;
|
|
15097
|
+
var keysShim = origKeys ? function keys(o) { return origKeys(o); } : requireImplementation();
|
|
15098
|
+
|
|
15099
|
+
var originalKeys = Object.keys;
|
|
15100
|
+
|
|
15101
|
+
keysShim.shim = function shimObjectKeys() {
|
|
15102
|
+
if (Object.keys) {
|
|
15103
|
+
var keysWorksWithArguments = (function () {
|
|
15104
|
+
// Safari 5.0 bug
|
|
15105
|
+
var args = Object.keys(arguments);
|
|
15106
|
+
return args && args.length === arguments.length;
|
|
15107
|
+
}(1, 2));
|
|
15108
|
+
if (!keysWorksWithArguments) {
|
|
15109
|
+
Object.keys = function keys(object) { // eslint-disable-line func-name-matching
|
|
15110
|
+
if (isArgs(object)) {
|
|
15111
|
+
return originalKeys(slice$2.call(object));
|
|
15112
|
+
}
|
|
15113
|
+
return originalKeys(object);
|
|
14951
15114
|
};
|
|
15115
|
+
}
|
|
15116
|
+
} else {
|
|
15117
|
+
Object.keys = keysShim;
|
|
15118
|
+
}
|
|
15119
|
+
return Object.keys || keysShim;
|
|
15120
|
+
};
|
|
15121
|
+
|
|
15122
|
+
var objectKeys$1 = keysShim;
|
|
15123
|
+
|
|
15124
|
+
var callBind$1 = {exports: {}};
|
|
15125
|
+
|
|
15126
|
+
/* eslint no-invalid-this: 1 */
|
|
15127
|
+
|
|
15128
|
+
var ERROR_MESSAGE$1 = 'Function.prototype.bind called on incompatible ';
|
|
15129
|
+
var toStr$1 = Object.prototype.toString;
|
|
15130
|
+
var max = Math.max;
|
|
15131
|
+
var funcType$1 = '[object Function]';
|
|
15132
|
+
|
|
15133
|
+
var concatty = function concatty(a, b) {
|
|
15134
|
+
var arr = [];
|
|
15135
|
+
|
|
15136
|
+
for (var i = 0; i < a.length; i += 1) {
|
|
15137
|
+
arr[i] = a[i];
|
|
15138
|
+
}
|
|
15139
|
+
for (var j = 0; j < b.length; j += 1) {
|
|
15140
|
+
arr[j + a.length] = b[j];
|
|
15141
|
+
}
|
|
15142
|
+
|
|
15143
|
+
return arr;
|
|
15144
|
+
};
|
|
15145
|
+
|
|
15146
|
+
var slicy = function slicy(arrLike, offset) {
|
|
15147
|
+
var arr = [];
|
|
15148
|
+
for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
|
|
15149
|
+
arr[j] = arrLike[i];
|
|
15150
|
+
}
|
|
15151
|
+
return arr;
|
|
15152
|
+
};
|
|
15153
|
+
|
|
15154
|
+
var joiny = function (arr, joiner) {
|
|
15155
|
+
var str = '';
|
|
15156
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
15157
|
+
str += arr[i];
|
|
15158
|
+
if (i + 1 < arr.length) {
|
|
15159
|
+
str += joiner;
|
|
15160
|
+
}
|
|
15161
|
+
}
|
|
15162
|
+
return str;
|
|
15163
|
+
};
|
|
15164
|
+
|
|
15165
|
+
var implementation$3 = function bind(that) {
|
|
15166
|
+
var target = this;
|
|
15167
|
+
if (typeof target !== 'function' || toStr$1.apply(target) !== funcType$1) {
|
|
15168
|
+
throw new TypeError(ERROR_MESSAGE$1 + target);
|
|
15169
|
+
}
|
|
15170
|
+
var args = slicy(arguments, 1);
|
|
15171
|
+
|
|
15172
|
+
var bound;
|
|
15173
|
+
var binder = function () {
|
|
15174
|
+
if (this instanceof bound) {
|
|
15175
|
+
var result = target.apply(
|
|
15176
|
+
this,
|
|
15177
|
+
concatty(args, arguments)
|
|
15178
|
+
);
|
|
15179
|
+
if (Object(result) === result) {
|
|
15180
|
+
return result;
|
|
15181
|
+
}
|
|
15182
|
+
return this;
|
|
15183
|
+
}
|
|
15184
|
+
return target.apply(
|
|
15185
|
+
that,
|
|
15186
|
+
concatty(args, arguments)
|
|
15187
|
+
);
|
|
15188
|
+
|
|
15189
|
+
};
|
|
15190
|
+
|
|
15191
|
+
var boundLength = max(0, target.length - args.length);
|
|
15192
|
+
var boundArgs = [];
|
|
15193
|
+
for (var i = 0; i < boundLength; i++) {
|
|
15194
|
+
boundArgs[i] = '$' + i;
|
|
15195
|
+
}
|
|
15196
|
+
|
|
15197
|
+
bound = Function('binder', 'return function (' + joiny(boundArgs, ',') + '){ return binder.apply(this,arguments); }')(binder);
|
|
15198
|
+
|
|
15199
|
+
if (target.prototype) {
|
|
15200
|
+
var Empty = function Empty() {};
|
|
15201
|
+
Empty.prototype = target.prototype;
|
|
15202
|
+
bound.prototype = new Empty();
|
|
15203
|
+
Empty.prototype = null;
|
|
15204
|
+
}
|
|
15205
|
+
|
|
15206
|
+
return bound;
|
|
15207
|
+
};
|
|
15208
|
+
|
|
15209
|
+
var implementation$2 = implementation$3;
|
|
15210
|
+
|
|
15211
|
+
var functionBind$1 = Function.prototype.bind || implementation$2;
|
|
15212
|
+
|
|
15213
|
+
/* eslint complexity: [2, 18], max-statements: [2, 33] */
|
|
15214
|
+
var shams = function hasSymbols() {
|
|
15215
|
+
if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
|
|
15216
|
+
if (typeof Symbol.iterator === 'symbol') { return true; }
|
|
15217
|
+
|
|
15218
|
+
var obj = {};
|
|
15219
|
+
var sym = Symbol('test');
|
|
15220
|
+
var symObj = Object(sym);
|
|
15221
|
+
if (typeof sym === 'string') { return false; }
|
|
15222
|
+
|
|
15223
|
+
if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
|
|
15224
|
+
if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
|
|
15225
|
+
|
|
15226
|
+
// temp disabled per https://github.com/ljharb/object.assign/issues/17
|
|
15227
|
+
// if (sym instanceof Symbol) { return false; }
|
|
15228
|
+
// temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
|
|
15229
|
+
// if (!(symObj instanceof Symbol)) { return false; }
|
|
15230
|
+
|
|
15231
|
+
// if (typeof Symbol.prototype.toString !== 'function') { return false; }
|
|
15232
|
+
// if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
|
|
15233
|
+
|
|
15234
|
+
var symVal = 42;
|
|
15235
|
+
obj[sym] = symVal;
|
|
15236
|
+
for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
|
|
15237
|
+
if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
|
|
15238
|
+
|
|
15239
|
+
if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
|
|
15240
|
+
|
|
15241
|
+
var syms = Object.getOwnPropertySymbols(obj);
|
|
15242
|
+
if (syms.length !== 1 || syms[0] !== sym) { return false; }
|
|
15243
|
+
|
|
15244
|
+
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
|
|
15245
|
+
|
|
15246
|
+
if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
|
15247
|
+
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
|
15248
|
+
if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
|
|
15249
|
+
}
|
|
15250
|
+
|
|
15251
|
+
return true;
|
|
15252
|
+
};
|
|
15253
|
+
|
|
15254
|
+
var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
|
15255
|
+
var hasSymbolSham = shams;
|
|
15256
|
+
|
|
15257
|
+
var hasSymbols$1 = function hasNativeSymbols() {
|
|
15258
|
+
if (typeof origSymbol !== 'function') { return false; }
|
|
15259
|
+
if (typeof Symbol !== 'function') { return false; }
|
|
15260
|
+
if (typeof origSymbol('foo') !== 'symbol') { return false; }
|
|
15261
|
+
if (typeof Symbol('bar') !== 'symbol') { return false; }
|
|
15262
|
+
|
|
15263
|
+
return hasSymbolSham();
|
|
15264
|
+
};
|
|
15265
|
+
|
|
15266
|
+
var test = {
|
|
15267
|
+
foo: {}
|
|
15268
|
+
};
|
|
15269
|
+
|
|
15270
|
+
var $Object = Object;
|
|
15271
|
+
|
|
15272
|
+
var hasProto$1 = function hasProto() {
|
|
15273
|
+
return { __proto__: test }.foo === test.foo && !({ __proto__: null } instanceof $Object);
|
|
15274
|
+
};
|
|
15275
|
+
|
|
15276
|
+
/* eslint no-invalid-this: 1 */
|
|
15277
|
+
|
|
15278
|
+
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
|
|
15279
|
+
var slice$1 = Array.prototype.slice;
|
|
15280
|
+
var toStr = Object.prototype.toString;
|
|
15281
|
+
var funcType = '[object Function]';
|
|
15282
|
+
|
|
15283
|
+
var implementation$1 = function bind(that) {
|
|
15284
|
+
var target = this;
|
|
15285
|
+
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
|
|
15286
|
+
throw new TypeError(ERROR_MESSAGE + target);
|
|
15287
|
+
}
|
|
15288
|
+
var args = slice$1.call(arguments, 1);
|
|
15289
|
+
|
|
15290
|
+
var bound;
|
|
15291
|
+
var binder = function () {
|
|
15292
|
+
if (this instanceof bound) {
|
|
15293
|
+
var result = target.apply(
|
|
15294
|
+
this,
|
|
15295
|
+
args.concat(slice$1.call(arguments))
|
|
15296
|
+
);
|
|
15297
|
+
if (Object(result) === result) {
|
|
15298
|
+
return result;
|
|
15299
|
+
}
|
|
15300
|
+
return this;
|
|
15301
|
+
} else {
|
|
15302
|
+
return target.apply(
|
|
15303
|
+
that,
|
|
15304
|
+
args.concat(slice$1.call(arguments))
|
|
15305
|
+
);
|
|
15306
|
+
}
|
|
15307
|
+
};
|
|
15308
|
+
|
|
15309
|
+
var boundLength = Math.max(0, target.length - args.length);
|
|
15310
|
+
var boundArgs = [];
|
|
15311
|
+
for (var i = 0; i < boundLength; i++) {
|
|
15312
|
+
boundArgs.push('$' + i);
|
|
15313
|
+
}
|
|
15314
|
+
|
|
15315
|
+
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
|
|
15316
|
+
|
|
15317
|
+
if (target.prototype) {
|
|
15318
|
+
var Empty = function Empty() {};
|
|
15319
|
+
Empty.prototype = target.prototype;
|
|
15320
|
+
bound.prototype = new Empty();
|
|
15321
|
+
Empty.prototype = null;
|
|
15322
|
+
}
|
|
15323
|
+
|
|
15324
|
+
return bound;
|
|
15325
|
+
};
|
|
15326
|
+
|
|
15327
|
+
var implementation = implementation$1;
|
|
15328
|
+
|
|
15329
|
+
var functionBind = Function.prototype.bind || implementation;
|
|
15330
|
+
|
|
15331
|
+
var bind$1 = functionBind;
|
|
15332
|
+
|
|
15333
|
+
var src$2 = bind$1.call(Function.call, Object.prototype.hasOwnProperty);
|
|
15334
|
+
|
|
15335
|
+
var undefined$1;
|
|
15336
|
+
|
|
15337
|
+
var $SyntaxError$1 = SyntaxError;
|
|
15338
|
+
var $Function = Function;
|
|
15339
|
+
var $TypeError$2 = TypeError;
|
|
15340
|
+
|
|
15341
|
+
// eslint-disable-next-line consistent-return
|
|
15342
|
+
var getEvalledConstructor = function (expressionSyntax) {
|
|
15343
|
+
try {
|
|
15344
|
+
return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
|
15345
|
+
} catch (e) {}
|
|
15346
|
+
};
|
|
15347
|
+
|
|
15348
|
+
var $gOPD$1 = Object.getOwnPropertyDescriptor;
|
|
15349
|
+
|
|
15350
|
+
var throwTypeError = function () {
|
|
15351
|
+
throw new $TypeError$2();
|
|
15352
|
+
};
|
|
15353
|
+
var ThrowTypeError = $gOPD$1
|
|
15354
|
+
? (function () {
|
|
15355
|
+
try {
|
|
15356
|
+
return throwTypeError;
|
|
15357
|
+
} catch (calleeThrows) {
|
|
15358
|
+
try {
|
|
15359
|
+
// IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
|
|
15360
|
+
return $gOPD$1(arguments, 'callee').get;
|
|
15361
|
+
} catch (gOPDthrows) {
|
|
15362
|
+
return throwTypeError;
|
|
15363
|
+
}
|
|
15364
|
+
}
|
|
15365
|
+
}())
|
|
15366
|
+
: throwTypeError;
|
|
15367
|
+
|
|
15368
|
+
var hasSymbols = hasSymbols$1();
|
|
15369
|
+
var hasProto = hasProto$1();
|
|
15370
|
+
|
|
15371
|
+
var getProto = Object.getPrototypeOf || (
|
|
15372
|
+
hasProto
|
|
15373
|
+
? function (x) { return x.__proto__; } // eslint-disable-line no-proto
|
|
15374
|
+
: null
|
|
15375
|
+
);
|
|
15376
|
+
|
|
15377
|
+
var needsEval = {};
|
|
15378
|
+
|
|
15379
|
+
var TypedArray = typeof Uint8Array === 'undefined' || !getProto ? undefined$1 : getProto(Uint8Array);
|
|
15380
|
+
|
|
15381
|
+
var INTRINSICS = {
|
|
15382
|
+
'%AggregateError%': typeof AggregateError === 'undefined' ? undefined$1 : AggregateError,
|
|
15383
|
+
'%Array%': Array,
|
|
15384
|
+
'%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
|
|
15385
|
+
'%ArrayIteratorPrototype%': hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined$1,
|
|
15386
|
+
'%AsyncFromSyncIteratorPrototype%': undefined$1,
|
|
15387
|
+
'%AsyncFunction%': needsEval,
|
|
15388
|
+
'%AsyncGenerator%': needsEval,
|
|
15389
|
+
'%AsyncGeneratorFunction%': needsEval,
|
|
15390
|
+
'%AsyncIteratorPrototype%': needsEval,
|
|
15391
|
+
'%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
|
|
15392
|
+
'%BigInt%': typeof BigInt === 'undefined' ? undefined$1 : BigInt,
|
|
15393
|
+
'%BigInt64Array%': typeof BigInt64Array === 'undefined' ? undefined$1 : BigInt64Array,
|
|
15394
|
+
'%BigUint64Array%': typeof BigUint64Array === 'undefined' ? undefined$1 : BigUint64Array,
|
|
15395
|
+
'%Boolean%': Boolean,
|
|
15396
|
+
'%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
|
|
15397
|
+
'%Date%': Date,
|
|
15398
|
+
'%decodeURI%': decodeURI,
|
|
15399
|
+
'%decodeURIComponent%': decodeURIComponent,
|
|
15400
|
+
'%encodeURI%': encodeURI,
|
|
15401
|
+
'%encodeURIComponent%': encodeURIComponent,
|
|
15402
|
+
'%Error%': Error,
|
|
15403
|
+
'%eval%': eval, // eslint-disable-line no-eval
|
|
15404
|
+
'%EvalError%': EvalError,
|
|
15405
|
+
'%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
|
|
15406
|
+
'%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
|
|
15407
|
+
'%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined$1 : FinalizationRegistry,
|
|
15408
|
+
'%Function%': $Function,
|
|
15409
|
+
'%GeneratorFunction%': needsEval,
|
|
15410
|
+
'%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
|
|
15411
|
+
'%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
|
|
15412
|
+
'%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
|
|
15413
|
+
'%isFinite%': isFinite,
|
|
15414
|
+
'%isNaN%': isNaN,
|
|
15415
|
+
'%IteratorPrototype%': hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
|
|
15416
|
+
'%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
|
|
15417
|
+
'%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
|
|
15418
|
+
'%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols || !getProto ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
|
|
15419
|
+
'%Math%': Math,
|
|
15420
|
+
'%Number%': Number,
|
|
15421
|
+
'%Object%': Object,
|
|
15422
|
+
'%parseFloat%': parseFloat,
|
|
15423
|
+
'%parseInt%': parseInt,
|
|
15424
|
+
'%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
|
|
15425
|
+
'%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
|
|
15426
|
+
'%RangeError%': RangeError,
|
|
15427
|
+
'%ReferenceError%': ReferenceError,
|
|
15428
|
+
'%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
|
|
15429
|
+
'%RegExp%': RegExp,
|
|
15430
|
+
'%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
|
|
15431
|
+
'%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols || !getProto ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
|
|
15432
|
+
'%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
|
|
15433
|
+
'%String%': String,
|
|
15434
|
+
'%StringIteratorPrototype%': hasSymbols && getProto ? getProto(''[Symbol.iterator]()) : undefined$1,
|
|
15435
|
+
'%Symbol%': hasSymbols ? Symbol : undefined$1,
|
|
15436
|
+
'%SyntaxError%': $SyntaxError$1,
|
|
15437
|
+
'%ThrowTypeError%': ThrowTypeError,
|
|
15438
|
+
'%TypedArray%': TypedArray,
|
|
15439
|
+
'%TypeError%': $TypeError$2,
|
|
15440
|
+
'%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
|
|
15441
|
+
'%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
|
|
15442
|
+
'%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
|
|
15443
|
+
'%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
|
|
15444
|
+
'%URIError%': URIError,
|
|
15445
|
+
'%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
|
|
15446
|
+
'%WeakRef%': typeof WeakRef === 'undefined' ? undefined$1 : WeakRef,
|
|
15447
|
+
'%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet
|
|
15448
|
+
};
|
|
15449
|
+
|
|
15450
|
+
var doEval = function doEval(name) {
|
|
15451
|
+
var value;
|
|
15452
|
+
if (name === '%AsyncFunction%') {
|
|
15453
|
+
value = getEvalledConstructor('async function () {}');
|
|
15454
|
+
} else if (name === '%GeneratorFunction%') {
|
|
15455
|
+
value = getEvalledConstructor('function* () {}');
|
|
15456
|
+
} else if (name === '%AsyncGeneratorFunction%') {
|
|
15457
|
+
value = getEvalledConstructor('async function* () {}');
|
|
15458
|
+
} else if (name === '%AsyncGenerator%') {
|
|
15459
|
+
var fn = doEval('%AsyncGeneratorFunction%');
|
|
15460
|
+
if (fn) {
|
|
15461
|
+
value = fn.prototype;
|
|
15462
|
+
}
|
|
15463
|
+
} else if (name === '%AsyncIteratorPrototype%') {
|
|
15464
|
+
var gen = doEval('%AsyncGenerator%');
|
|
15465
|
+
if (gen && getProto) {
|
|
15466
|
+
value = getProto(gen.prototype);
|
|
15467
|
+
}
|
|
15468
|
+
}
|
|
15469
|
+
|
|
15470
|
+
INTRINSICS[name] = value;
|
|
15471
|
+
|
|
15472
|
+
return value;
|
|
15473
|
+
};
|
|
15474
|
+
|
|
15475
|
+
var LEGACY_ALIASES = {
|
|
15476
|
+
'%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
|
|
15477
|
+
'%ArrayPrototype%': ['Array', 'prototype'],
|
|
15478
|
+
'%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
|
|
15479
|
+
'%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
|
|
15480
|
+
'%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
|
|
15481
|
+
'%ArrayProto_values%': ['Array', 'prototype', 'values'],
|
|
15482
|
+
'%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
|
|
15483
|
+
'%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
|
|
15484
|
+
'%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
|
|
15485
|
+
'%BooleanPrototype%': ['Boolean', 'prototype'],
|
|
15486
|
+
'%DataViewPrototype%': ['DataView', 'prototype'],
|
|
15487
|
+
'%DatePrototype%': ['Date', 'prototype'],
|
|
15488
|
+
'%ErrorPrototype%': ['Error', 'prototype'],
|
|
15489
|
+
'%EvalErrorPrototype%': ['EvalError', 'prototype'],
|
|
15490
|
+
'%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
|
|
15491
|
+
'%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
|
|
15492
|
+
'%FunctionPrototype%': ['Function', 'prototype'],
|
|
15493
|
+
'%Generator%': ['GeneratorFunction', 'prototype'],
|
|
15494
|
+
'%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
|
|
15495
|
+
'%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
|
|
15496
|
+
'%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
|
|
15497
|
+
'%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
|
|
15498
|
+
'%JSONParse%': ['JSON', 'parse'],
|
|
15499
|
+
'%JSONStringify%': ['JSON', 'stringify'],
|
|
15500
|
+
'%MapPrototype%': ['Map', 'prototype'],
|
|
15501
|
+
'%NumberPrototype%': ['Number', 'prototype'],
|
|
15502
|
+
'%ObjectPrototype%': ['Object', 'prototype'],
|
|
15503
|
+
'%ObjProto_toString%': ['Object', 'prototype', 'toString'],
|
|
15504
|
+
'%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
|
|
15505
|
+
'%PromisePrototype%': ['Promise', 'prototype'],
|
|
15506
|
+
'%PromiseProto_then%': ['Promise', 'prototype', 'then'],
|
|
15507
|
+
'%Promise_all%': ['Promise', 'all'],
|
|
15508
|
+
'%Promise_reject%': ['Promise', 'reject'],
|
|
15509
|
+
'%Promise_resolve%': ['Promise', 'resolve'],
|
|
15510
|
+
'%RangeErrorPrototype%': ['RangeError', 'prototype'],
|
|
15511
|
+
'%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
|
|
15512
|
+
'%RegExpPrototype%': ['RegExp', 'prototype'],
|
|
15513
|
+
'%SetPrototype%': ['Set', 'prototype'],
|
|
15514
|
+
'%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
|
|
15515
|
+
'%StringPrototype%': ['String', 'prototype'],
|
|
15516
|
+
'%SymbolPrototype%': ['Symbol', 'prototype'],
|
|
15517
|
+
'%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
|
|
15518
|
+
'%TypedArrayPrototype%': ['TypedArray', 'prototype'],
|
|
15519
|
+
'%TypeErrorPrototype%': ['TypeError', 'prototype'],
|
|
15520
|
+
'%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
|
|
15521
|
+
'%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
|
|
15522
|
+
'%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
|
|
15523
|
+
'%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
|
|
15524
|
+
'%URIErrorPrototype%': ['URIError', 'prototype'],
|
|
15525
|
+
'%WeakMapPrototype%': ['WeakMap', 'prototype'],
|
|
15526
|
+
'%WeakSetPrototype%': ['WeakSet', 'prototype']
|
|
15527
|
+
};
|
|
15528
|
+
|
|
15529
|
+
var bind = functionBind$1;
|
|
15530
|
+
var hasOwn$1 = src$2;
|
|
15531
|
+
var $concat = bind.call(Function.call, Array.prototype.concat);
|
|
15532
|
+
var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
|
|
15533
|
+
var $replace = bind.call(Function.call, String.prototype.replace);
|
|
15534
|
+
var $strSlice = bind.call(Function.call, String.prototype.slice);
|
|
15535
|
+
var $exec = bind.call(Function.call, RegExp.prototype.exec);
|
|
15536
|
+
|
|
15537
|
+
/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
|
|
15538
|
+
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
15539
|
+
var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
|
|
15540
|
+
var stringToPath = function stringToPath(string) {
|
|
15541
|
+
var first = $strSlice(string, 0, 1);
|
|
15542
|
+
var last = $strSlice(string, -1);
|
|
15543
|
+
if (first === '%' && last !== '%') {
|
|
15544
|
+
throw new $SyntaxError$1('invalid intrinsic syntax, expected closing `%`');
|
|
15545
|
+
} else if (last === '%' && first !== '%') {
|
|
15546
|
+
throw new $SyntaxError$1('invalid intrinsic syntax, expected opening `%`');
|
|
15547
|
+
}
|
|
15548
|
+
var result = [];
|
|
15549
|
+
$replace(string, rePropName, function (match, number, quote, subString) {
|
|
15550
|
+
result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
|
|
15551
|
+
});
|
|
15552
|
+
return result;
|
|
15553
|
+
};
|
|
15554
|
+
/* end adaptation */
|
|
15555
|
+
|
|
15556
|
+
var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
|
15557
|
+
var intrinsicName = name;
|
|
15558
|
+
var alias;
|
|
15559
|
+
if (hasOwn$1(LEGACY_ALIASES, intrinsicName)) {
|
|
15560
|
+
alias = LEGACY_ALIASES[intrinsicName];
|
|
15561
|
+
intrinsicName = '%' + alias[0] + '%';
|
|
15562
|
+
}
|
|
15563
|
+
|
|
15564
|
+
if (hasOwn$1(INTRINSICS, intrinsicName)) {
|
|
15565
|
+
var value = INTRINSICS[intrinsicName];
|
|
15566
|
+
if (value === needsEval) {
|
|
15567
|
+
value = doEval(intrinsicName);
|
|
15568
|
+
}
|
|
15569
|
+
if (typeof value === 'undefined' && !allowMissing) {
|
|
15570
|
+
throw new $TypeError$2('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
|
15571
|
+
}
|
|
15572
|
+
|
|
15573
|
+
return {
|
|
15574
|
+
alias: alias,
|
|
15575
|
+
name: intrinsicName,
|
|
15576
|
+
value: value
|
|
15577
|
+
};
|
|
15578
|
+
}
|
|
15579
|
+
|
|
15580
|
+
throw new $SyntaxError$1('intrinsic ' + name + ' does not exist!');
|
|
15581
|
+
};
|
|
15582
|
+
|
|
15583
|
+
var getIntrinsic = function GetIntrinsic(name, allowMissing) {
|
|
15584
|
+
if (typeof name !== 'string' || name.length === 0) {
|
|
15585
|
+
throw new $TypeError$2('intrinsic name must be a non-empty string');
|
|
15586
|
+
}
|
|
15587
|
+
if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
|
|
15588
|
+
throw new $TypeError$2('"allowMissing" argument must be a boolean');
|
|
15589
|
+
}
|
|
15590
|
+
|
|
15591
|
+
if ($exec(/^%?[^%]*%?$/, name) === null) {
|
|
15592
|
+
throw new $SyntaxError$1('`%` may not be present anywhere but at the beginning and end of the intrinsic name');
|
|
15593
|
+
}
|
|
15594
|
+
var parts = stringToPath(name);
|
|
15595
|
+
var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
|
15596
|
+
|
|
15597
|
+
var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
|
|
15598
|
+
var intrinsicRealName = intrinsic.name;
|
|
15599
|
+
var value = intrinsic.value;
|
|
15600
|
+
var skipFurtherCaching = false;
|
|
15601
|
+
|
|
15602
|
+
var alias = intrinsic.alias;
|
|
15603
|
+
if (alias) {
|
|
15604
|
+
intrinsicBaseName = alias[0];
|
|
15605
|
+
$spliceApply(parts, $concat([0, 1], alias));
|
|
15606
|
+
}
|
|
15607
|
+
|
|
15608
|
+
for (var i = 1, isOwn = true; i < parts.length; i += 1) {
|
|
15609
|
+
var part = parts[i];
|
|
15610
|
+
var first = $strSlice(part, 0, 1);
|
|
15611
|
+
var last = $strSlice(part, -1);
|
|
15612
|
+
if (
|
|
15613
|
+
(
|
|
15614
|
+
(first === '"' || first === "'" || first === '`')
|
|
15615
|
+
|| (last === '"' || last === "'" || last === '`')
|
|
15616
|
+
)
|
|
15617
|
+
&& first !== last
|
|
15618
|
+
) {
|
|
15619
|
+
throw new $SyntaxError$1('property names with quotes must have matching quotes');
|
|
15620
|
+
}
|
|
15621
|
+
if (part === 'constructor' || !isOwn) {
|
|
15622
|
+
skipFurtherCaching = true;
|
|
15623
|
+
}
|
|
15624
|
+
|
|
15625
|
+
intrinsicBaseName += '.' + part;
|
|
15626
|
+
intrinsicRealName = '%' + intrinsicBaseName + '%';
|
|
15627
|
+
|
|
15628
|
+
if (hasOwn$1(INTRINSICS, intrinsicRealName)) {
|
|
15629
|
+
value = INTRINSICS[intrinsicRealName];
|
|
15630
|
+
} else if (value != null) {
|
|
15631
|
+
if (!(part in value)) {
|
|
15632
|
+
if (!allowMissing) {
|
|
15633
|
+
throw new $TypeError$2('base intrinsic for ' + name + ' exists, but the property is not available.');
|
|
15634
|
+
}
|
|
15635
|
+
return void undefined$1;
|
|
15636
|
+
}
|
|
15637
|
+
if ($gOPD$1 && (i + 1) >= parts.length) {
|
|
15638
|
+
var desc = $gOPD$1(value, part);
|
|
15639
|
+
isOwn = !!desc;
|
|
15640
|
+
|
|
15641
|
+
// By convention, when a data property is converted to an accessor
|
|
15642
|
+
// property to emulate a data property that does not suffer from
|
|
15643
|
+
// the override mistake, that accessor's getter is marked with
|
|
15644
|
+
// an `originalValue` property. Here, when we detect this, we
|
|
15645
|
+
// uphold the illusion by pretending to see that original data
|
|
15646
|
+
// property, i.e., returning the value rather than the getter
|
|
15647
|
+
// itself.
|
|
15648
|
+
if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
|
|
15649
|
+
value = desc.get;
|
|
15650
|
+
} else {
|
|
15651
|
+
value = value[part];
|
|
15652
|
+
}
|
|
15653
|
+
} else {
|
|
15654
|
+
isOwn = hasOwn$1(value, part);
|
|
15655
|
+
value = value[part];
|
|
15656
|
+
}
|
|
15657
|
+
|
|
15658
|
+
if (isOwn && !skipFurtherCaching) {
|
|
15659
|
+
INTRINSICS[intrinsicRealName] = value;
|
|
15660
|
+
}
|
|
15661
|
+
}
|
|
15662
|
+
}
|
|
15663
|
+
return value;
|
|
15664
|
+
};
|
|
15665
|
+
|
|
15666
|
+
var GetIntrinsic$3 = getIntrinsic;
|
|
15667
|
+
|
|
15668
|
+
var $defineProperty$1 = GetIntrinsic$3('%Object.defineProperty%', true);
|
|
15669
|
+
|
|
15670
|
+
var hasPropertyDescriptors$1 = function hasPropertyDescriptors() {
|
|
15671
|
+
if ($defineProperty$1) {
|
|
15672
|
+
try {
|
|
15673
|
+
$defineProperty$1({}, 'a', { value: 1 });
|
|
15674
|
+
return true;
|
|
15675
|
+
} catch (e) {
|
|
15676
|
+
// IE 8 has a broken defineProperty
|
|
15677
|
+
return false;
|
|
15678
|
+
}
|
|
15679
|
+
}
|
|
15680
|
+
return false;
|
|
15681
|
+
};
|
|
15682
|
+
|
|
15683
|
+
hasPropertyDescriptors$1.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
|
|
15684
|
+
// node v0.6 has a bug where array lengths can be Set but not Defined
|
|
15685
|
+
if (!hasPropertyDescriptors$1()) {
|
|
15686
|
+
return null;
|
|
15687
|
+
}
|
|
15688
|
+
try {
|
|
15689
|
+
return $defineProperty$1([], 'length', { value: 1 }).length !== 1;
|
|
15690
|
+
} catch (e) {
|
|
15691
|
+
// In Firefox 4-22, defining length on an array throws an exception.
|
|
15692
|
+
return true;
|
|
15693
|
+
}
|
|
15694
|
+
};
|
|
15695
|
+
|
|
15696
|
+
var hasPropertyDescriptors_1 = hasPropertyDescriptors$1;
|
|
15697
|
+
|
|
15698
|
+
var GetIntrinsic$2 = getIntrinsic;
|
|
15699
|
+
|
|
15700
|
+
var $gOPD = GetIntrinsic$2('%Object.getOwnPropertyDescriptor%', true);
|
|
15701
|
+
|
|
15702
|
+
if ($gOPD) {
|
|
15703
|
+
try {
|
|
15704
|
+
$gOPD([], 'length');
|
|
15705
|
+
} catch (e) {
|
|
15706
|
+
// IE 8 has a broken gOPD
|
|
15707
|
+
$gOPD = null;
|
|
15708
|
+
}
|
|
15709
|
+
}
|
|
15710
|
+
|
|
15711
|
+
var gopd$1 = $gOPD;
|
|
15712
|
+
|
|
15713
|
+
var hasPropertyDescriptors = hasPropertyDescriptors_1();
|
|
15714
|
+
|
|
15715
|
+
var GetIntrinsic$1 = getIntrinsic;
|
|
15716
|
+
|
|
15717
|
+
var $defineProperty = hasPropertyDescriptors && GetIntrinsic$1('%Object.defineProperty%', true);
|
|
15718
|
+
if ($defineProperty) {
|
|
15719
|
+
try {
|
|
15720
|
+
$defineProperty({}, 'a', { value: 1 });
|
|
15721
|
+
} catch (e) {
|
|
15722
|
+
// IE 8 has a broken defineProperty
|
|
15723
|
+
$defineProperty = false;
|
|
15724
|
+
}
|
|
15725
|
+
}
|
|
15726
|
+
|
|
15727
|
+
var $SyntaxError = GetIntrinsic$1('%SyntaxError%');
|
|
15728
|
+
var $TypeError$1 = GetIntrinsic$1('%TypeError%');
|
|
15729
|
+
|
|
15730
|
+
var gopd = gopd$1;
|
|
15731
|
+
|
|
15732
|
+
/** @type {(obj: Record<PropertyKey, unknown>, property: PropertyKey, value: unknown, nonEnumerable?: boolean | null, nonWritable?: boolean | null, nonConfigurable?: boolean | null, loose?: boolean) => void} */
|
|
15733
|
+
var defineDataProperty = function defineDataProperty(
|
|
15734
|
+
obj,
|
|
15735
|
+
property,
|
|
15736
|
+
value
|
|
15737
|
+
) {
|
|
15738
|
+
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
|
15739
|
+
throw new $TypeError$1('`obj` must be an object or a function`');
|
|
15740
|
+
}
|
|
15741
|
+
if (typeof property !== 'string' && typeof property !== 'symbol') {
|
|
15742
|
+
throw new $TypeError$1('`property` must be a string or a symbol`');
|
|
15743
|
+
}
|
|
15744
|
+
if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) {
|
|
15745
|
+
throw new $TypeError$1('`nonEnumerable`, if provided, must be a boolean or null');
|
|
15746
|
+
}
|
|
15747
|
+
if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) {
|
|
15748
|
+
throw new $TypeError$1('`nonWritable`, if provided, must be a boolean or null');
|
|
15749
|
+
}
|
|
15750
|
+
if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) {
|
|
15751
|
+
throw new $TypeError$1('`nonConfigurable`, if provided, must be a boolean or null');
|
|
15752
|
+
}
|
|
15753
|
+
if (arguments.length > 6 && typeof arguments[6] !== 'boolean') {
|
|
15754
|
+
throw new $TypeError$1('`loose`, if provided, must be a boolean');
|
|
15755
|
+
}
|
|
15756
|
+
|
|
15757
|
+
var nonEnumerable = arguments.length > 3 ? arguments[3] : null;
|
|
15758
|
+
var nonWritable = arguments.length > 4 ? arguments[4] : null;
|
|
15759
|
+
var nonConfigurable = arguments.length > 5 ? arguments[5] : null;
|
|
15760
|
+
var loose = arguments.length > 6 ? arguments[6] : false;
|
|
15761
|
+
|
|
15762
|
+
/* @type {false | TypedPropertyDescriptor<unknown>} */
|
|
15763
|
+
var desc = !!gopd && gopd(obj, property);
|
|
15764
|
+
|
|
15765
|
+
if ($defineProperty) {
|
|
15766
|
+
$defineProperty(obj, property, {
|
|
15767
|
+
configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable,
|
|
15768
|
+
enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable,
|
|
15769
|
+
value: value,
|
|
15770
|
+
writable: nonWritable === null && desc ? desc.writable : !nonWritable
|
|
15771
|
+
});
|
|
15772
|
+
} else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) {
|
|
15773
|
+
// must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable
|
|
15774
|
+
obj[property] = value; // eslint-disable-line no-param-reassign
|
|
15775
|
+
} else {
|
|
15776
|
+
throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.');
|
|
15777
|
+
}
|
|
15778
|
+
};
|
|
15779
|
+
|
|
15780
|
+
var GetIntrinsic = getIntrinsic;
|
|
15781
|
+
var define = defineDataProperty;
|
|
15782
|
+
var hasDescriptors = hasPropertyDescriptors_1();
|
|
15783
|
+
var gOPD = gopd$1;
|
|
15784
|
+
|
|
15785
|
+
var $TypeError = GetIntrinsic('%TypeError%');
|
|
15786
|
+
var $floor = GetIntrinsic('%Math.floor%');
|
|
15787
|
+
|
|
15788
|
+
var setFunctionLength = function setFunctionLength(fn, length) {
|
|
15789
|
+
if (typeof fn !== 'function') {
|
|
15790
|
+
throw new $TypeError('`fn` is not a function');
|
|
15791
|
+
}
|
|
15792
|
+
if (typeof length !== 'number' || length < 0 || length > 0xFFFFFFFF || $floor(length) !== length) {
|
|
15793
|
+
throw new $TypeError('`length` must be a positive 32-bit integer');
|
|
15794
|
+
}
|
|
15795
|
+
|
|
15796
|
+
var loose = arguments.length > 2 && !!arguments[2];
|
|
15797
|
+
|
|
15798
|
+
var functionLengthIsConfigurable = true;
|
|
15799
|
+
var functionLengthIsWritable = true;
|
|
15800
|
+
if ('length' in fn && gOPD) {
|
|
15801
|
+
var desc = gOPD(fn, 'length');
|
|
15802
|
+
if (desc && !desc.configurable) {
|
|
15803
|
+
functionLengthIsConfigurable = false;
|
|
15804
|
+
}
|
|
15805
|
+
if (desc && !desc.writable) {
|
|
15806
|
+
functionLengthIsWritable = false;
|
|
15807
|
+
}
|
|
15808
|
+
}
|
|
15809
|
+
|
|
15810
|
+
if (functionLengthIsConfigurable || functionLengthIsWritable || !loose) {
|
|
15811
|
+
if (hasDescriptors) {
|
|
15812
|
+
define(fn, 'length', length, true, true);
|
|
15813
|
+
} else {
|
|
15814
|
+
define(fn, 'length', length);
|
|
15815
|
+
}
|
|
15816
|
+
}
|
|
15817
|
+
return fn;
|
|
15818
|
+
};
|
|
15819
|
+
|
|
15820
|
+
(function (module) {
|
|
15821
|
+
|
|
15822
|
+
var bind = functionBind$1;
|
|
15823
|
+
var GetIntrinsic = getIntrinsic;
|
|
15824
|
+
var setFunctionLength$1 = setFunctionLength;
|
|
15825
|
+
|
|
15826
|
+
var $TypeError = GetIntrinsic('%TypeError%');
|
|
15827
|
+
var $apply = GetIntrinsic('%Function.prototype.apply%');
|
|
15828
|
+
var $call = GetIntrinsic('%Function.prototype.call%');
|
|
15829
|
+
var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
|
|
15830
|
+
|
|
15831
|
+
var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
|
|
15832
|
+
var $max = GetIntrinsic('%Math.max%');
|
|
15833
|
+
|
|
15834
|
+
if ($defineProperty) {
|
|
15835
|
+
try {
|
|
15836
|
+
$defineProperty({}, 'a', { value: 1 });
|
|
15837
|
+
} catch (e) {
|
|
15838
|
+
// IE 8 has a broken defineProperty
|
|
15839
|
+
$defineProperty = null;
|
|
15840
|
+
}
|
|
15841
|
+
}
|
|
15842
|
+
|
|
15843
|
+
module.exports = function callBind(originalFunction) {
|
|
15844
|
+
if (typeof originalFunction !== 'function') {
|
|
15845
|
+
throw new $TypeError('a function is required');
|
|
15846
|
+
}
|
|
15847
|
+
var func = $reflectApply(bind, $call, arguments);
|
|
15848
|
+
return setFunctionLength$1(
|
|
15849
|
+
func,
|
|
15850
|
+
1 + $max(0, originalFunction.length - (arguments.length - 1)),
|
|
15851
|
+
true
|
|
15852
|
+
);
|
|
15853
|
+
};
|
|
15854
|
+
|
|
15855
|
+
var applyBind = function applyBind() {
|
|
15856
|
+
return $reflectApply(bind, $apply, arguments);
|
|
15857
|
+
};
|
|
15858
|
+
|
|
15859
|
+
if ($defineProperty) {
|
|
15860
|
+
$defineProperty(module.exports, 'apply', { value: applyBind });
|
|
15861
|
+
} else {
|
|
15862
|
+
module.exports.apply = applyBind;
|
|
15863
|
+
}
|
|
15864
|
+
} (callBind$1));
|
|
15865
|
+
|
|
15866
|
+
var callBindExports = callBind$1.exports;
|
|
15867
|
+
|
|
15868
|
+
var jsonStringify = (typeof JSON !== 'undefined' ? JSON : JSON).stringify;
|
|
15869
|
+
|
|
15870
|
+
var isArray$1 = isarray;
|
|
15871
|
+
var objectKeys = objectKeys$1;
|
|
15872
|
+
var callBind = callBindExports;
|
|
15873
|
+
|
|
15874
|
+
var strRepeat = function repeat(n, char) {
|
|
15875
|
+
var str = '';
|
|
15876
|
+
for (var i = 0; i < n; i += 1) {
|
|
15877
|
+
str += char;
|
|
15878
|
+
}
|
|
15879
|
+
return str;
|
|
15880
|
+
};
|
|
15881
|
+
|
|
15882
|
+
var defaultReplacer = function (parent, key, value) { return value; };
|
|
15883
|
+
|
|
15884
|
+
var jsonStableStringify = function stableStringify(obj) {
|
|
15885
|
+
var opts = arguments.length > 1 ? arguments[1] : void undefined;
|
|
15886
|
+
var space = (opts && opts.space) || '';
|
|
15887
|
+
if (typeof space === 'number') { space = strRepeat(space, ' '); }
|
|
15888
|
+
var cycles = !!opts && typeof opts.cycles === 'boolean' && opts.cycles;
|
|
15889
|
+
var replacer = opts && opts.replacer ? callBind(opts.replacer) : defaultReplacer;
|
|
15890
|
+
|
|
15891
|
+
var cmpOpt = typeof opts === 'function' ? opts : opts && opts.cmp;
|
|
15892
|
+
var cmp = cmpOpt && function (node) {
|
|
15893
|
+
var get = cmpOpt.length > 2 && function get(k) { return node[k]; };
|
|
15894
|
+
return function (a, b) {
|
|
15895
|
+
return cmpOpt(
|
|
15896
|
+
{ key: a, value: node[a] },
|
|
15897
|
+
{ key: b, value: node[b] },
|
|
15898
|
+
get ? { __proto__: null, get: get } : void undefined
|
|
15899
|
+
);
|
|
14952
15900
|
};
|
|
14953
|
-
}
|
|
15901
|
+
};
|
|
14954
15902
|
|
|
14955
15903
|
var seen = [];
|
|
14956
15904
|
return (function stringify(parent, key, node, level) {
|
|
14957
|
-
var indent = space ? '\n' +
|
|
15905
|
+
var indent = space ? '\n' + strRepeat(level, space) : '';
|
|
14958
15906
|
var colonSeparator = space ? ': ' : ':';
|
|
14959
15907
|
|
|
14960
15908
|
if (node && node.toJSON && typeof node.toJSON === 'function') {
|
|
14961
15909
|
node = node.toJSON();
|
|
14962
15910
|
}
|
|
14963
15911
|
|
|
14964
|
-
node = replacer
|
|
15912
|
+
node = replacer(parent, key, node);
|
|
14965
15913
|
|
|
14966
15914
|
if (node === undefined) {
|
|
14967
15915
|
return;
|
|
14968
15916
|
}
|
|
14969
15917
|
if (typeof node !== 'object' || node === null) {
|
|
14970
|
-
return
|
|
15918
|
+
return jsonStringify(node);
|
|
14971
15919
|
}
|
|
14972
15920
|
if (isArray$1(node)) {
|
|
14973
|
-
var out =
|
|
15921
|
+
var out = '';
|
|
14974
15922
|
for (var i = 0; i < node.length; i++) {
|
|
14975
|
-
var item = stringify(node, i, node[i], level + 1) ||
|
|
14976
|
-
out
|
|
15923
|
+
var item = stringify(node, i, node[i], level + 1) || jsonStringify(null);
|
|
15924
|
+
out += indent + space + item;
|
|
15925
|
+
if ((i + 1) < node.length) {
|
|
15926
|
+
out += ',';
|
|
15927
|
+
}
|
|
14977
15928
|
}
|
|
14978
|
-
return '[' + out
|
|
15929
|
+
return '[' + out + indent + ']';
|
|
14979
15930
|
}
|
|
14980
15931
|
|
|
14981
15932
|
if (seen.indexOf(node) !== -1) {
|
|
14982
|
-
if (cycles) { return
|
|
15933
|
+
if (cycles) { return jsonStringify('__cycle__'); }
|
|
14983
15934
|
throw new TypeError('Converting circular structure to JSON');
|
|
14984
15935
|
} else { seen.push(node); }
|
|
14985
15936
|
|
|
14986
15937
|
var keys = objectKeys(node).sort(cmp && cmp(node));
|
|
14987
|
-
var out =
|
|
15938
|
+
var out = '';
|
|
15939
|
+
var needsComma = false;
|
|
14988
15940
|
for (var i = 0; i < keys.length; i++) {
|
|
14989
15941
|
var key = keys[i];
|
|
14990
15942
|
var value = stringify(node, key, node[key], level + 1);
|
|
14991
15943
|
|
|
14992
15944
|
if (!value) { continue; }
|
|
14993
15945
|
|
|
14994
|
-
var keyValue =
|
|
14995
|
-
|
|
14996
|
-
|
|
15946
|
+
var keyValue = jsonStringify(key)
|
|
15947
|
+
+ colonSeparator
|
|
15948
|
+
+ value;
|
|
14997
15949
|
|
|
14998
|
-
out
|
|
15950
|
+
out += (needsComma ? ',' : '') + indent + space + keyValue;
|
|
15951
|
+
needsComma = true;
|
|
14999
15952
|
}
|
|
15000
15953
|
seen.splice(seen.indexOf(node), 1);
|
|
15001
|
-
return '{' + out
|
|
15954
|
+
return '{' + out + indent + '}';
|
|
15002
15955
|
|
|
15003
15956
|
}({ '': obj }, '', obj, 0));
|
|
15004
15957
|
};
|
|
@@ -28037,49 +28990,18 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
28037
28990
|
if (data.exports) {
|
|
28038
28991
|
entryPoint = resolveExportsOrImports(data, '.', options, targetWeb, 'exports');
|
|
28039
28992
|
}
|
|
28040
|
-
// handle edge case with browser and module field semantics
|
|
28041
|
-
if (!entryPoint && targetWeb && options.mainFields.includes('browser')) {
|
|
28042
|
-
// check browser field
|
|
28043
|
-
// https://github.com/defunctzombie/package-browser-field-spec
|
|
28044
|
-
const browserEntry = typeof data.browser === 'string'
|
|
28045
|
-
? data.browser
|
|
28046
|
-
: isObject$1(data.browser) && data.browser['.'];
|
|
28047
|
-
if (browserEntry) {
|
|
28048
|
-
// check if the package also has a "module" field.
|
|
28049
|
-
if (!options.isRequire &&
|
|
28050
|
-
options.mainFields.includes('module') &&
|
|
28051
|
-
typeof data.module === 'string' &&
|
|
28052
|
-
data.module !== browserEntry) {
|
|
28053
|
-
// if both are present, we may have a problem: some package points both
|
|
28054
|
-
// to ESM, with "module" targeting Node.js, while some packages points
|
|
28055
|
-
// "module" to browser ESM and "browser" to UMD/IIFE.
|
|
28056
|
-
// the heuristics here is to actually read the browser entry when
|
|
28057
|
-
// possible and check for hints of ESM. If it is not ESM, prefer "module"
|
|
28058
|
-
// instead; Otherwise, assume it's ESM and use it.
|
|
28059
|
-
const resolvedBrowserEntry = tryFsResolve(path$o.join(dir, browserEntry), options);
|
|
28060
|
-
if (resolvedBrowserEntry) {
|
|
28061
|
-
const content = fs$l.readFileSync(resolvedBrowserEntry, 'utf-8');
|
|
28062
|
-
if (hasESMSyntax(content)) {
|
|
28063
|
-
// likely ESM, prefer browser
|
|
28064
|
-
entryPoint = browserEntry;
|
|
28065
|
-
}
|
|
28066
|
-
else {
|
|
28067
|
-
// non-ESM, UMD or IIFE or CJS(!!! e.g. firebase 7.x), prefer module
|
|
28068
|
-
entryPoint = data.module;
|
|
28069
|
-
}
|
|
28070
|
-
}
|
|
28071
|
-
}
|
|
28072
|
-
else {
|
|
28073
|
-
entryPoint = browserEntry;
|
|
28074
|
-
}
|
|
28075
|
-
}
|
|
28076
|
-
}
|
|
28077
28993
|
// fallback to mainFields if still not resolved
|
|
28078
28994
|
if (!entryPoint) {
|
|
28079
28995
|
for (const field of options.mainFields) {
|
|
28080
|
-
if (field === 'browser')
|
|
28081
|
-
|
|
28082
|
-
|
|
28996
|
+
if (field === 'browser') {
|
|
28997
|
+
if (targetWeb) {
|
|
28998
|
+
entryPoint = tryResolveBrowserEntry(dir, data, options);
|
|
28999
|
+
if (entryPoint) {
|
|
29000
|
+
break;
|
|
29001
|
+
}
|
|
29002
|
+
}
|
|
29003
|
+
}
|
|
29004
|
+
else if (typeof data[field] === 'string') {
|
|
28083
29005
|
entryPoint = data[field];
|
|
28084
29006
|
break;
|
|
28085
29007
|
}
|
|
@@ -28238,6 +29160,43 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
|
|
|
28238
29160
|
}
|
|
28239
29161
|
}
|
|
28240
29162
|
}
|
|
29163
|
+
function tryResolveBrowserEntry(dir, data, options) {
|
|
29164
|
+
// handle edge case with browser and module field semantics
|
|
29165
|
+
// check browser field
|
|
29166
|
+
// https://github.com/defunctzombie/package-browser-field-spec
|
|
29167
|
+
const browserEntry = typeof data.browser === 'string'
|
|
29168
|
+
? data.browser
|
|
29169
|
+
: isObject$1(data.browser) && data.browser['.'];
|
|
29170
|
+
if (browserEntry) {
|
|
29171
|
+
// check if the package also has a "module" field.
|
|
29172
|
+
if (!options.isRequire &&
|
|
29173
|
+
options.mainFields.includes('module') &&
|
|
29174
|
+
typeof data.module === 'string' &&
|
|
29175
|
+
data.module !== browserEntry) {
|
|
29176
|
+
// if both are present, we may have a problem: some package points both
|
|
29177
|
+
// to ESM, with "module" targeting Node.js, while some packages points
|
|
29178
|
+
// "module" to browser ESM and "browser" to UMD/IIFE.
|
|
29179
|
+
// the heuristics here is to actually read the browser entry when
|
|
29180
|
+
// possible and check for hints of ESM. If it is not ESM, prefer "module"
|
|
29181
|
+
// instead; Otherwise, assume it's ESM and use it.
|
|
29182
|
+
const resolvedBrowserEntry = tryFsResolve(path$o.join(dir, browserEntry), options);
|
|
29183
|
+
if (resolvedBrowserEntry) {
|
|
29184
|
+
const content = fs$l.readFileSync(resolvedBrowserEntry, 'utf-8');
|
|
29185
|
+
if (hasESMSyntax(content)) {
|
|
29186
|
+
// likely ESM, prefer browser
|
|
29187
|
+
return browserEntry;
|
|
29188
|
+
}
|
|
29189
|
+
else {
|
|
29190
|
+
// non-ESM, UMD or IIFE or CJS(!!! e.g. firebase 7.x), prefer module
|
|
29191
|
+
return data.module;
|
|
29192
|
+
}
|
|
29193
|
+
}
|
|
29194
|
+
}
|
|
29195
|
+
else {
|
|
29196
|
+
return browserEntry;
|
|
29197
|
+
}
|
|
29198
|
+
}
|
|
29199
|
+
}
|
|
28241
29200
|
/**
|
|
28242
29201
|
* given a relative path in pkg dir,
|
|
28243
29202
|
* return a relative path in pkg dir,
|
|
@@ -28281,22 +29240,17 @@ var dist = {};
|
|
|
28281
29240
|
'package.json',
|
|
28282
29241
|
`.${name}rc.json`,
|
|
28283
29242
|
`.${name}rc.js`,
|
|
28284
|
-
`${name}.config.js`,
|
|
28285
29243
|
`.${name}rc.cjs`,
|
|
29244
|
+
`.config/${name}rc`,
|
|
29245
|
+
`.config/${name}rc.json`,
|
|
29246
|
+
`.config/${name}rc.js`,
|
|
29247
|
+
`.config/${name}rc.cjs`,
|
|
29248
|
+
`${name}.config.js`,
|
|
28286
29249
|
`${name}.config.cjs`,
|
|
28287
29250
|
];
|
|
28288
29251
|
}
|
|
28289
|
-
function
|
|
28290
|
-
return
|
|
28291
|
-
.split(path.sep)
|
|
28292
|
-
.reduceRight((acc, _, ind, arr) => {
|
|
28293
|
-
const currentPath = arr.slice(0, ind + 1).join(path.sep);
|
|
28294
|
-
if (!acc.passedStopDir)
|
|
28295
|
-
acc.searchPlaces.push(currentPath || path.sep);
|
|
28296
|
-
if (currentPath === stopDir)
|
|
28297
|
-
acc.passedStopDir = true;
|
|
28298
|
-
return acc;
|
|
28299
|
-
}, { searchPlaces: [], passedStopDir: false }).searchPlaces;
|
|
29252
|
+
function parentDir(p) {
|
|
29253
|
+
return path.dirname(p) || path.sep;
|
|
28300
29254
|
}
|
|
28301
29255
|
exports.defaultLoaders = Object.freeze({
|
|
28302
29256
|
'.js': __require,
|
|
@@ -28314,6 +29268,7 @@ var dist = {};
|
|
|
28314
29268
|
stopDir: os.homedir(),
|
|
28315
29269
|
searchPlaces: getDefaultSearchPlaces(name),
|
|
28316
29270
|
ignoreEmptySearchPlaces: true,
|
|
29271
|
+
cache: true,
|
|
28317
29272
|
transform: (x) => x,
|
|
28318
29273
|
packageProp: [name],
|
|
28319
29274
|
...options,
|
|
@@ -28336,16 +29291,6 @@ var dist = {};
|
|
|
28336
29291
|
return obj[props];
|
|
28337
29292
|
return ((Array.isArray(props) ? props : props.split('.')).reduce((acc, prop) => (acc === undefined ? acc : acc[prop]), obj) || null);
|
|
28338
29293
|
}
|
|
28339
|
-
function getSearchItems(searchPlaces, searchPaths) {
|
|
28340
|
-
return searchPaths.reduce((acc, searchPath) => {
|
|
28341
|
-
searchPlaces.forEach(fileName => acc.push({
|
|
28342
|
-
fileName,
|
|
28343
|
-
filepath: path.join(searchPath, fileName),
|
|
28344
|
-
loaderKey: path.extname(fileName) || 'noExt',
|
|
28345
|
-
}));
|
|
28346
|
-
return acc;
|
|
28347
|
-
}, []);
|
|
28348
|
-
}
|
|
28349
29294
|
function validateFilePath(filepath) {
|
|
28350
29295
|
if (!filepath)
|
|
28351
29296
|
throw new Error('load must pass a non-empty string');
|
|
@@ -28356,56 +29301,88 @@ var dist = {};
|
|
|
28356
29301
|
if (typeof loader !== 'function')
|
|
28357
29302
|
throw new Error('loader is not a function');
|
|
28358
29303
|
}
|
|
29304
|
+
const makeEmplace = (enableCache) => (c, filepath, res) => {
|
|
29305
|
+
if (enableCache)
|
|
29306
|
+
c.set(filepath, res);
|
|
29307
|
+
return res;
|
|
29308
|
+
};
|
|
28359
29309
|
function lilconfig(name, options) {
|
|
28360
|
-
const { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, } = getOptions(name, options);
|
|
29310
|
+
const { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, cache, } = getOptions(name, options);
|
|
29311
|
+
const searchCache = new Map();
|
|
29312
|
+
const loadCache = new Map();
|
|
29313
|
+
const emplace = makeEmplace(cache);
|
|
28361
29314
|
return {
|
|
28362
29315
|
async search(searchFrom = process.cwd()) {
|
|
28363
|
-
const searchPaths = getSearchPaths(searchFrom, stopDir);
|
|
28364
29316
|
const result = {
|
|
28365
29317
|
config: null,
|
|
28366
29318
|
filepath: '',
|
|
28367
29319
|
};
|
|
28368
|
-
const
|
|
28369
|
-
|
|
28370
|
-
|
|
28371
|
-
|
|
28372
|
-
|
|
28373
|
-
|
|
28374
|
-
|
|
28375
|
-
|
|
28376
|
-
|
|
28377
|
-
const loader = loaders[loaderKey];
|
|
28378
|
-
if (fileName === 'package.json') {
|
|
28379
|
-
const pkg = await loader(filepath, content);
|
|
28380
|
-
const maybeConfig = getPackageProp(packageProp, pkg);
|
|
28381
|
-
if (maybeConfig != null) {
|
|
28382
|
-
result.config = maybeConfig;
|
|
28383
|
-
result.filepath = filepath;
|
|
28384
|
-
break;
|
|
29320
|
+
const visited = new Set();
|
|
29321
|
+
let dir = searchFrom;
|
|
29322
|
+
dirLoop: while (true) {
|
|
29323
|
+
if (cache) {
|
|
29324
|
+
const r = searchCache.get(dir);
|
|
29325
|
+
if (r !== undefined) {
|
|
29326
|
+
for (const p of visited)
|
|
29327
|
+
searchCache.set(p, r);
|
|
29328
|
+
return r;
|
|
28385
29329
|
}
|
|
28386
|
-
|
|
28387
|
-
}
|
|
28388
|
-
const isEmpty = content.trim() === '';
|
|
28389
|
-
if (isEmpty && ignoreEmptySearchPlaces)
|
|
28390
|
-
continue;
|
|
28391
|
-
if (isEmpty) {
|
|
28392
|
-
result.isEmpty = true;
|
|
28393
|
-
result.config = undefined;
|
|
29330
|
+
visited.add(dir);
|
|
28394
29331
|
}
|
|
28395
|
-
|
|
28396
|
-
|
|
28397
|
-
|
|
29332
|
+
for (const searchPlace of searchPlaces) {
|
|
29333
|
+
const filepath = path.join(dir, searchPlace);
|
|
29334
|
+
try {
|
|
29335
|
+
await fs.promises.access(filepath);
|
|
29336
|
+
}
|
|
29337
|
+
catch (_a) {
|
|
29338
|
+
continue;
|
|
29339
|
+
}
|
|
29340
|
+
const content = String(await fsReadFileAsync(filepath));
|
|
29341
|
+
const loaderKey = path.extname(searchPlace) || 'noExt';
|
|
29342
|
+
const loader = loaders[loaderKey];
|
|
29343
|
+
if (searchPlace === 'package.json') {
|
|
29344
|
+
const pkg = await loader(filepath, content);
|
|
29345
|
+
const maybeConfig = getPackageProp(packageProp, pkg);
|
|
29346
|
+
if (maybeConfig != null) {
|
|
29347
|
+
result.config = maybeConfig;
|
|
29348
|
+
result.filepath = filepath;
|
|
29349
|
+
break dirLoop;
|
|
29350
|
+
}
|
|
29351
|
+
continue;
|
|
29352
|
+
}
|
|
29353
|
+
const isEmpty = content.trim() === '';
|
|
29354
|
+
if (isEmpty && ignoreEmptySearchPlaces)
|
|
29355
|
+
continue;
|
|
29356
|
+
if (isEmpty) {
|
|
29357
|
+
result.isEmpty = true;
|
|
29358
|
+
result.config = undefined;
|
|
29359
|
+
}
|
|
29360
|
+
else {
|
|
29361
|
+
validateLoader(loader, loaderKey);
|
|
29362
|
+
result.config = await loader(filepath, content);
|
|
29363
|
+
}
|
|
29364
|
+
result.filepath = filepath;
|
|
29365
|
+
break dirLoop;
|
|
28398
29366
|
}
|
|
28399
|
-
|
|
28400
|
-
|
|
29367
|
+
if (dir === stopDir || dir === parentDir(dir))
|
|
29368
|
+
break dirLoop;
|
|
29369
|
+
dir = parentDir(dir);
|
|
28401
29370
|
}
|
|
28402
|
-
|
|
28403
|
-
|
|
28404
|
-
|
|
29371
|
+
const transformed = result.filepath === '' && result.config === null
|
|
29372
|
+
? transform(null)
|
|
29373
|
+
: transform(result);
|
|
29374
|
+
if (cache) {
|
|
29375
|
+
for (const p of visited)
|
|
29376
|
+
searchCache.set(p, transformed);
|
|
29377
|
+
}
|
|
29378
|
+
return transformed;
|
|
28405
29379
|
},
|
|
28406
29380
|
async load(filepath) {
|
|
28407
29381
|
validateFilePath(filepath);
|
|
28408
29382
|
const absPath = path.resolve(process.cwd(), filepath);
|
|
29383
|
+
if (cache && loadCache.has(absPath)) {
|
|
29384
|
+
return loadCache.get(absPath);
|
|
29385
|
+
}
|
|
28409
29386
|
const { base, ext } = path.parse(absPath);
|
|
28410
29387
|
const loaderKey = ext || 'noExt';
|
|
28411
29388
|
const loader = loaders[loaderKey];
|
|
@@ -28413,10 +29390,10 @@ var dist = {};
|
|
|
28413
29390
|
const content = String(await fsReadFileAsync(absPath));
|
|
28414
29391
|
if (base === 'package.json') {
|
|
28415
29392
|
const pkg = await loader(absPath, content);
|
|
28416
|
-
return transform({
|
|
29393
|
+
return emplace(loadCache, absPath, transform({
|
|
28417
29394
|
config: getPackageProp(packageProp, pkg),
|
|
28418
29395
|
filepath: absPath,
|
|
28419
|
-
});
|
|
29396
|
+
}));
|
|
28420
29397
|
}
|
|
28421
29398
|
const result = {
|
|
28422
29399
|
config: null,
|
|
@@ -28424,69 +29401,110 @@ var dist = {};
|
|
|
28424
29401
|
};
|
|
28425
29402
|
const isEmpty = content.trim() === '';
|
|
28426
29403
|
if (isEmpty && ignoreEmptySearchPlaces)
|
|
28427
|
-
return transform({
|
|
29404
|
+
return emplace(loadCache, absPath, transform({
|
|
28428
29405
|
config: undefined,
|
|
28429
29406
|
filepath: absPath,
|
|
28430
29407
|
isEmpty: true,
|
|
28431
|
-
});
|
|
29408
|
+
}));
|
|
28432
29409
|
result.config = isEmpty
|
|
28433
29410
|
? undefined
|
|
28434
29411
|
: await loader(absPath, content);
|
|
28435
|
-
return transform(isEmpty ? { ...result, isEmpty, config: undefined } : result);
|
|
29412
|
+
return emplace(loadCache, absPath, transform(isEmpty ? { ...result, isEmpty, config: undefined } : result));
|
|
29413
|
+
},
|
|
29414
|
+
clearLoadCache() {
|
|
29415
|
+
if (cache)
|
|
29416
|
+
loadCache.clear();
|
|
29417
|
+
},
|
|
29418
|
+
clearSearchCache() {
|
|
29419
|
+
if (cache)
|
|
29420
|
+
searchCache.clear();
|
|
29421
|
+
},
|
|
29422
|
+
clearCaches() {
|
|
29423
|
+
if (cache) {
|
|
29424
|
+
loadCache.clear();
|
|
29425
|
+
searchCache.clear();
|
|
29426
|
+
}
|
|
28436
29427
|
},
|
|
28437
29428
|
};
|
|
28438
29429
|
}
|
|
28439
29430
|
exports.lilconfig = lilconfig;
|
|
28440
29431
|
function lilconfigSync(name, options) {
|
|
28441
|
-
const { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, } = getOptions(name, options);
|
|
29432
|
+
const { ignoreEmptySearchPlaces, loaders, packageProp, searchPlaces, stopDir, transform, cache, } = getOptions(name, options);
|
|
29433
|
+
const searchCache = new Map();
|
|
29434
|
+
const loadCache = new Map();
|
|
29435
|
+
const emplace = makeEmplace(cache);
|
|
28442
29436
|
return {
|
|
28443
29437
|
search(searchFrom = process.cwd()) {
|
|
28444
|
-
const searchPaths = getSearchPaths(searchFrom, stopDir);
|
|
28445
29438
|
const result = {
|
|
28446
29439
|
config: null,
|
|
28447
29440
|
filepath: '',
|
|
28448
29441
|
};
|
|
28449
|
-
const
|
|
28450
|
-
|
|
28451
|
-
|
|
28452
|
-
|
|
28453
|
-
|
|
28454
|
-
|
|
28455
|
-
|
|
28456
|
-
|
|
28457
|
-
|
|
28458
|
-
const content = String(fs.readFileSync(filepath));
|
|
28459
|
-
if (fileName === 'package.json') {
|
|
28460
|
-
const pkg = loader(filepath, content);
|
|
28461
|
-
const maybeConfig = getPackageProp(packageProp, pkg);
|
|
28462
|
-
if (maybeConfig != null) {
|
|
28463
|
-
result.config = maybeConfig;
|
|
28464
|
-
result.filepath = filepath;
|
|
28465
|
-
break;
|
|
29442
|
+
const visited = new Set();
|
|
29443
|
+
let dir = searchFrom;
|
|
29444
|
+
dirLoop: while (true) {
|
|
29445
|
+
if (cache) {
|
|
29446
|
+
const r = searchCache.get(dir);
|
|
29447
|
+
if (r !== undefined) {
|
|
29448
|
+
for (const p of visited)
|
|
29449
|
+
searchCache.set(p, r);
|
|
29450
|
+
return r;
|
|
28466
29451
|
}
|
|
28467
|
-
|
|
28468
|
-
}
|
|
28469
|
-
const isEmpty = content.trim() === '';
|
|
28470
|
-
if (isEmpty && ignoreEmptySearchPlaces)
|
|
28471
|
-
continue;
|
|
28472
|
-
if (isEmpty) {
|
|
28473
|
-
result.isEmpty = true;
|
|
28474
|
-
result.config = undefined;
|
|
29452
|
+
visited.add(dir);
|
|
28475
29453
|
}
|
|
28476
|
-
|
|
28477
|
-
|
|
28478
|
-
|
|
29454
|
+
for (const searchPlace of searchPlaces) {
|
|
29455
|
+
const filepath = path.join(dir, searchPlace);
|
|
29456
|
+
try {
|
|
29457
|
+
fs.accessSync(filepath);
|
|
29458
|
+
}
|
|
29459
|
+
catch (_a) {
|
|
29460
|
+
continue;
|
|
29461
|
+
}
|
|
29462
|
+
const loaderKey = path.extname(searchPlace) || 'noExt';
|
|
29463
|
+
const loader = loaders[loaderKey];
|
|
29464
|
+
const content = String(fs.readFileSync(filepath));
|
|
29465
|
+
if (searchPlace === 'package.json') {
|
|
29466
|
+
const pkg = loader(filepath, content);
|
|
29467
|
+
const maybeConfig = getPackageProp(packageProp, pkg);
|
|
29468
|
+
if (maybeConfig != null) {
|
|
29469
|
+
result.config = maybeConfig;
|
|
29470
|
+
result.filepath = filepath;
|
|
29471
|
+
break dirLoop;
|
|
29472
|
+
}
|
|
29473
|
+
continue;
|
|
29474
|
+
}
|
|
29475
|
+
const isEmpty = content.trim() === '';
|
|
29476
|
+
if (isEmpty && ignoreEmptySearchPlaces)
|
|
29477
|
+
continue;
|
|
29478
|
+
if (isEmpty) {
|
|
29479
|
+
result.isEmpty = true;
|
|
29480
|
+
result.config = undefined;
|
|
29481
|
+
}
|
|
29482
|
+
else {
|
|
29483
|
+
validateLoader(loader, loaderKey);
|
|
29484
|
+
result.config = loader(filepath, content);
|
|
29485
|
+
}
|
|
29486
|
+
result.filepath = filepath;
|
|
29487
|
+
break dirLoop;
|
|
28479
29488
|
}
|
|
28480
|
-
|
|
28481
|
-
|
|
29489
|
+
if (dir === stopDir || dir === parentDir(dir))
|
|
29490
|
+
break dirLoop;
|
|
29491
|
+
dir = parentDir(dir);
|
|
29492
|
+
}
|
|
29493
|
+
const transformed = result.filepath === '' && result.config === null
|
|
29494
|
+
? transform(null)
|
|
29495
|
+
: transform(result);
|
|
29496
|
+
if (cache) {
|
|
29497
|
+
for (const p of visited)
|
|
29498
|
+
searchCache.set(p, transformed);
|
|
28482
29499
|
}
|
|
28483
|
-
|
|
28484
|
-
return transform(null);
|
|
28485
|
-
return transform(result);
|
|
29500
|
+
return transformed;
|
|
28486
29501
|
},
|
|
28487
29502
|
load(filepath) {
|
|
28488
29503
|
validateFilePath(filepath);
|
|
28489
29504
|
const absPath = path.resolve(process.cwd(), filepath);
|
|
29505
|
+
if (cache && loadCache.has(absPath)) {
|
|
29506
|
+
return loadCache.get(absPath);
|
|
29507
|
+
}
|
|
28490
29508
|
const { base, ext } = path.parse(absPath);
|
|
28491
29509
|
const loaderKey = ext || 'noExt';
|
|
28492
29510
|
const loader = loaders[loaderKey];
|
|
@@ -28505,13 +29523,27 @@ var dist = {};
|
|
|
28505
29523
|
};
|
|
28506
29524
|
const isEmpty = content.trim() === '';
|
|
28507
29525
|
if (isEmpty && ignoreEmptySearchPlaces)
|
|
28508
|
-
return transform({
|
|
29526
|
+
return emplace(loadCache, absPath, transform({
|
|
28509
29527
|
filepath: absPath,
|
|
28510
29528
|
config: undefined,
|
|
28511
29529
|
isEmpty: true,
|
|
28512
|
-
});
|
|
29530
|
+
}));
|
|
28513
29531
|
result.config = isEmpty ? undefined : loader(absPath, content);
|
|
28514
|
-
return transform(isEmpty ? { ...result, isEmpty, config: undefined } : result);
|
|
29532
|
+
return emplace(loadCache, absPath, transform(isEmpty ? { ...result, isEmpty, config: undefined } : result));
|
|
29533
|
+
},
|
|
29534
|
+
clearLoadCache() {
|
|
29535
|
+
if (cache)
|
|
29536
|
+
loadCache.clear();
|
|
29537
|
+
},
|
|
29538
|
+
clearSearchCache() {
|
|
29539
|
+
if (cache)
|
|
29540
|
+
searchCache.clear();
|
|
29541
|
+
},
|
|
29542
|
+
clearCaches() {
|
|
29543
|
+
if (cache) {
|
|
29544
|
+
loadCache.clear();
|
|
29545
|
+
searchCache.clear();
|
|
29546
|
+
}
|
|
28515
29547
|
},
|
|
28516
29548
|
};
|
|
28517
29549
|
}
|
|
@@ -28552,18 +29584,6 @@ function isNode$1(node) {
|
|
|
28552
29584
|
return false;
|
|
28553
29585
|
}
|
|
28554
29586
|
const hasAnchor = (node) => (isScalar$1(node) || isCollection$1(node)) && !!node.anchor;
|
|
28555
|
-
class NodeBase {
|
|
28556
|
-
constructor(type) {
|
|
28557
|
-
Object.defineProperty(this, NODE_TYPE, { value: type });
|
|
28558
|
-
}
|
|
28559
|
-
/** Create a copy of this node. */
|
|
28560
|
-
clone() {
|
|
28561
|
-
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
28562
|
-
if (this.range)
|
|
28563
|
-
copy.range = this.range.slice();
|
|
28564
|
-
return copy;
|
|
28565
|
-
}
|
|
28566
|
-
}
|
|
28567
29587
|
|
|
28568
29588
|
const BREAK$1 = Symbol('break visit');
|
|
28569
29589
|
const SKIP$1 = Symbol('skip children');
|
|
@@ -28910,12 +29930,19 @@ class Directives {
|
|
|
28910
29930
|
onError('Verbatim tags must end with a >');
|
|
28911
29931
|
return verbatim;
|
|
28912
29932
|
}
|
|
28913
|
-
const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/);
|
|
29933
|
+
const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s);
|
|
28914
29934
|
if (!suffix)
|
|
28915
29935
|
onError(`The ${source} tag has no suffix`);
|
|
28916
29936
|
const prefix = this.tags[handle];
|
|
28917
|
-
if (prefix)
|
|
28918
|
-
|
|
29937
|
+
if (prefix) {
|
|
29938
|
+
try {
|
|
29939
|
+
return prefix + decodeURIComponent(suffix);
|
|
29940
|
+
}
|
|
29941
|
+
catch (error) {
|
|
29942
|
+
onError(String(error));
|
|
29943
|
+
return null;
|
|
29944
|
+
}
|
|
29945
|
+
}
|
|
28919
29946
|
if (handle === '!')
|
|
28920
29947
|
return source; // local tag
|
|
28921
29948
|
onError(`Could not resolve tag: ${source}`);
|
|
@@ -29028,6 +30055,126 @@ function createNodeAnchors(doc, prefix) {
|
|
|
29028
30055
|
};
|
|
29029
30056
|
}
|
|
29030
30057
|
|
|
30058
|
+
/**
|
|
30059
|
+
* Applies the JSON.parse reviver algorithm as defined in the ECMA-262 spec,
|
|
30060
|
+
* in section 24.5.1.1 "Runtime Semantics: InternalizeJSONProperty" of the
|
|
30061
|
+
* 2021 edition: https://tc39.es/ecma262/#sec-json.parse
|
|
30062
|
+
*
|
|
30063
|
+
* Includes extensions for handling Map and Set objects.
|
|
30064
|
+
*/
|
|
30065
|
+
function applyReviver(reviver, obj, key, val) {
|
|
30066
|
+
if (val && typeof val === 'object') {
|
|
30067
|
+
if (Array.isArray(val)) {
|
|
30068
|
+
for (let i = 0, len = val.length; i < len; ++i) {
|
|
30069
|
+
const v0 = val[i];
|
|
30070
|
+
const v1 = applyReviver(reviver, val, String(i), v0);
|
|
30071
|
+
if (v1 === undefined)
|
|
30072
|
+
delete val[i];
|
|
30073
|
+
else if (v1 !== v0)
|
|
30074
|
+
val[i] = v1;
|
|
30075
|
+
}
|
|
30076
|
+
}
|
|
30077
|
+
else if (val instanceof Map) {
|
|
30078
|
+
for (const k of Array.from(val.keys())) {
|
|
30079
|
+
const v0 = val.get(k);
|
|
30080
|
+
const v1 = applyReviver(reviver, val, k, v0);
|
|
30081
|
+
if (v1 === undefined)
|
|
30082
|
+
val.delete(k);
|
|
30083
|
+
else if (v1 !== v0)
|
|
30084
|
+
val.set(k, v1);
|
|
30085
|
+
}
|
|
30086
|
+
}
|
|
30087
|
+
else if (val instanceof Set) {
|
|
30088
|
+
for (const v0 of Array.from(val)) {
|
|
30089
|
+
const v1 = applyReviver(reviver, val, v0, v0);
|
|
30090
|
+
if (v1 === undefined)
|
|
30091
|
+
val.delete(v0);
|
|
30092
|
+
else if (v1 !== v0) {
|
|
30093
|
+
val.delete(v0);
|
|
30094
|
+
val.add(v1);
|
|
30095
|
+
}
|
|
30096
|
+
}
|
|
30097
|
+
}
|
|
30098
|
+
else {
|
|
30099
|
+
for (const [k, v0] of Object.entries(val)) {
|
|
30100
|
+
const v1 = applyReviver(reviver, val, k, v0);
|
|
30101
|
+
if (v1 === undefined)
|
|
30102
|
+
delete val[k];
|
|
30103
|
+
else if (v1 !== v0)
|
|
30104
|
+
val[k] = v1;
|
|
30105
|
+
}
|
|
30106
|
+
}
|
|
30107
|
+
}
|
|
30108
|
+
return reviver.call(obj, key, val);
|
|
30109
|
+
}
|
|
30110
|
+
|
|
30111
|
+
/**
|
|
30112
|
+
* Recursively convert any node or its contents to native JavaScript
|
|
30113
|
+
*
|
|
30114
|
+
* @param value - The input value
|
|
30115
|
+
* @param arg - If `value` defines a `toJSON()` method, use this
|
|
30116
|
+
* as its first argument
|
|
30117
|
+
* @param ctx - Conversion context, originally set in Document#toJS(). If
|
|
30118
|
+
* `{ keep: true }` is not set, output should be suitable for JSON
|
|
30119
|
+
* stringification.
|
|
30120
|
+
*/
|
|
30121
|
+
function toJS(value, arg, ctx) {
|
|
30122
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
30123
|
+
if (Array.isArray(value))
|
|
30124
|
+
return value.map((v, i) => toJS(v, String(i), ctx));
|
|
30125
|
+
if (value && typeof value.toJSON === 'function') {
|
|
30126
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
30127
|
+
if (!ctx || !hasAnchor(value))
|
|
30128
|
+
return value.toJSON(arg, ctx);
|
|
30129
|
+
const data = { aliasCount: 0, count: 1, res: undefined };
|
|
30130
|
+
ctx.anchors.set(value, data);
|
|
30131
|
+
ctx.onCreate = res => {
|
|
30132
|
+
data.res = res;
|
|
30133
|
+
delete ctx.onCreate;
|
|
30134
|
+
};
|
|
30135
|
+
const res = value.toJSON(arg, ctx);
|
|
30136
|
+
if (ctx.onCreate)
|
|
30137
|
+
ctx.onCreate(res);
|
|
30138
|
+
return res;
|
|
30139
|
+
}
|
|
30140
|
+
if (typeof value === 'bigint' && !ctx?.keep)
|
|
30141
|
+
return Number(value);
|
|
30142
|
+
return value;
|
|
30143
|
+
}
|
|
30144
|
+
|
|
30145
|
+
class NodeBase {
|
|
30146
|
+
constructor(type) {
|
|
30147
|
+
Object.defineProperty(this, NODE_TYPE, { value: type });
|
|
30148
|
+
}
|
|
30149
|
+
/** Create a copy of this node. */
|
|
30150
|
+
clone() {
|
|
30151
|
+
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
30152
|
+
if (this.range)
|
|
30153
|
+
copy.range = this.range.slice();
|
|
30154
|
+
return copy;
|
|
30155
|
+
}
|
|
30156
|
+
/** A plain JavaScript representation of this node. */
|
|
30157
|
+
toJS(doc, { mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
|
|
30158
|
+
if (!isDocument(doc))
|
|
30159
|
+
throw new TypeError('A document argument is required');
|
|
30160
|
+
const ctx = {
|
|
30161
|
+
anchors: new Map(),
|
|
30162
|
+
doc,
|
|
30163
|
+
keep: true,
|
|
30164
|
+
mapAsMap: mapAsMap === true,
|
|
30165
|
+
mapKeyWarned: false,
|
|
30166
|
+
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
|
|
30167
|
+
};
|
|
30168
|
+
const res = toJS(this, '', ctx);
|
|
30169
|
+
if (typeof onAnchor === 'function')
|
|
30170
|
+
for (const { count, res } of ctx.anchors.values())
|
|
30171
|
+
onAnchor(res, count);
|
|
30172
|
+
return typeof reviver === 'function'
|
|
30173
|
+
? applyReviver(reviver, { '': res }, '', res)
|
|
30174
|
+
: res;
|
|
30175
|
+
}
|
|
30176
|
+
}
|
|
30177
|
+
|
|
29031
30178
|
class Alias extends NodeBase {
|
|
29032
30179
|
constructor(source) {
|
|
29033
30180
|
super(ALIAS);
|
|
@@ -29063,7 +30210,12 @@ class Alias extends NodeBase {
|
|
|
29063
30210
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
29064
30211
|
throw new ReferenceError(msg);
|
|
29065
30212
|
}
|
|
29066
|
-
|
|
30213
|
+
let data = anchors.get(source);
|
|
30214
|
+
if (!data) {
|
|
30215
|
+
// Resolve anchors for Node.prototype.toJS()
|
|
30216
|
+
toJS(source, null, ctx);
|
|
30217
|
+
data = anchors.get(source);
|
|
30218
|
+
}
|
|
29067
30219
|
/* istanbul ignore if */
|
|
29068
30220
|
if (!data || data.res === undefined) {
|
|
29069
30221
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
@@ -29117,40 +30269,6 @@ function getAliasCount(doc, node, anchors) {
|
|
|
29117
30269
|
return 1;
|
|
29118
30270
|
}
|
|
29119
30271
|
|
|
29120
|
-
/**
|
|
29121
|
-
* Recursively convert any node or its contents to native JavaScript
|
|
29122
|
-
*
|
|
29123
|
-
* @param value - The input value
|
|
29124
|
-
* @param arg - If `value` defines a `toJSON()` method, use this
|
|
29125
|
-
* as its first argument
|
|
29126
|
-
* @param ctx - Conversion context, originally set in Document#toJS(). If
|
|
29127
|
-
* `{ keep: true }` is not set, output should be suitable for JSON
|
|
29128
|
-
* stringification.
|
|
29129
|
-
*/
|
|
29130
|
-
function toJS(value, arg, ctx) {
|
|
29131
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
29132
|
-
if (Array.isArray(value))
|
|
29133
|
-
return value.map((v, i) => toJS(v, String(i), ctx));
|
|
29134
|
-
if (value && typeof value.toJSON === 'function') {
|
|
29135
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
29136
|
-
if (!ctx || !hasAnchor(value))
|
|
29137
|
-
return value.toJSON(arg, ctx);
|
|
29138
|
-
const data = { aliasCount: 0, count: 1, res: undefined };
|
|
29139
|
-
ctx.anchors.set(value, data);
|
|
29140
|
-
ctx.onCreate = res => {
|
|
29141
|
-
data.res = res;
|
|
29142
|
-
delete ctx.onCreate;
|
|
29143
|
-
};
|
|
29144
|
-
const res = value.toJSON(arg, ctx);
|
|
29145
|
-
if (ctx.onCreate)
|
|
29146
|
-
ctx.onCreate(res);
|
|
29147
|
-
return res;
|
|
29148
|
-
}
|
|
29149
|
-
if (typeof value === 'bigint' && !ctx?.keep)
|
|
29150
|
-
return Number(value);
|
|
29151
|
-
return value;
|
|
29152
|
-
}
|
|
29153
|
-
|
|
29154
30272
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
|
29155
30273
|
class Scalar extends NodeBase {
|
|
29156
30274
|
constructor(value) {
|
|
@@ -29194,7 +30312,7 @@ function createNode(value, tagName, ctx) {
|
|
|
29194
30312
|
if (value instanceof String ||
|
|
29195
30313
|
value instanceof Number ||
|
|
29196
30314
|
value instanceof Boolean ||
|
|
29197
|
-
(typeof BigInt
|
|
30315
|
+
(typeof BigInt !== 'undefined' && value instanceof BigInt) // not supported everywhere
|
|
29198
30316
|
) {
|
|
29199
30317
|
// https://tc39.es/ecma262/#sec-serializejsonproperty
|
|
29200
30318
|
value = value.valueOf();
|
|
@@ -29242,9 +30360,13 @@ function createNode(value, tagName, ctx) {
|
|
|
29242
30360
|
}
|
|
29243
30361
|
const node = tagObj?.createNode
|
|
29244
30362
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
29245
|
-
:
|
|
30363
|
+
: typeof tagObj?.nodeClass?.from === 'function'
|
|
30364
|
+
? tagObj.nodeClass.from(ctx.schema, value, ctx)
|
|
30365
|
+
: new Scalar(value);
|
|
29246
30366
|
if (tagName)
|
|
29247
30367
|
node.tag = tagName;
|
|
30368
|
+
else if (!tagObj.default)
|
|
30369
|
+
node.tag = tagObj.tag;
|
|
29248
30370
|
if (ref)
|
|
29249
30371
|
ref.node = node;
|
|
29250
30372
|
return node;
|
|
@@ -29546,8 +30668,8 @@ function consumeMoreIndentedLines(text, i) {
|
|
|
29546
30668
|
return i;
|
|
29547
30669
|
}
|
|
29548
30670
|
|
|
29549
|
-
const getFoldOptions = (ctx) => ({
|
|
29550
|
-
indentAtStart: ctx.indentAtStart,
|
|
30671
|
+
const getFoldOptions = (ctx, isBlock) => ({
|
|
30672
|
+
indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
|
|
29551
30673
|
lineWidth: ctx.options.lineWidth,
|
|
29552
30674
|
minContentWidth: ctx.options.minContentWidth
|
|
29553
30675
|
});
|
|
@@ -29660,7 +30782,7 @@ function doubleQuotedString(value, ctx) {
|
|
|
29660
30782
|
str = start ? str + json.slice(start) : json;
|
|
29661
30783
|
return implicitKey
|
|
29662
30784
|
? str
|
|
29663
|
-
: foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx));
|
|
30785
|
+
: foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
29664
30786
|
}
|
|
29665
30787
|
function singleQuotedString(value, ctx) {
|
|
29666
30788
|
if (ctx.options.singleQuote === false ||
|
|
@@ -29672,7 +30794,7 @@ function singleQuotedString(value, ctx) {
|
|
|
29672
30794
|
const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
|
|
29673
30795
|
return ctx.implicitKey
|
|
29674
30796
|
? res
|
|
29675
|
-
: foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx));
|
|
30797
|
+
: foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx, false));
|
|
29676
30798
|
}
|
|
29677
30799
|
function quotedString(value, ctx) {
|
|
29678
30800
|
const { singleQuote } = ctx.options;
|
|
@@ -29691,6 +30813,15 @@ function quotedString(value, ctx) {
|
|
|
29691
30813
|
}
|
|
29692
30814
|
return qs(value, ctx);
|
|
29693
30815
|
}
|
|
30816
|
+
// The negative lookbehind avoids a polynomial search,
|
|
30817
|
+
// but isn't supported yet on Safari: https://caniuse.com/js-regexp-lookbehind
|
|
30818
|
+
let blockEndNewlines;
|
|
30819
|
+
try {
|
|
30820
|
+
blockEndNewlines = new RegExp('(^|(?<!\n))\n+(?!\n|$)', 'g');
|
|
30821
|
+
}
|
|
30822
|
+
catch {
|
|
30823
|
+
blockEndNewlines = /\n+(?!\n|$)/g;
|
|
30824
|
+
}
|
|
29694
30825
|
function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
29695
30826
|
const { blockQuote, commentString, lineWidth } = ctx.options;
|
|
29696
30827
|
// 1. Block can't end in whitespace unless the last line is non-empty.
|
|
@@ -29734,7 +30865,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
|
29734
30865
|
value = value.slice(0, -end.length);
|
|
29735
30866
|
if (end[end.length - 1] === '\n')
|
|
29736
30867
|
end = end.slice(0, -1);
|
|
29737
|
-
end = end.replace(
|
|
30868
|
+
end = end.replace(blockEndNewlines, `$&${indent}`);
|
|
29738
30869
|
}
|
|
29739
30870
|
// determine indent indicator from whitespace at value start
|
|
29740
30871
|
let startWithSpace = false;
|
|
@@ -29770,13 +30901,13 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
|
29770
30901
|
.replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
|
|
29771
30902
|
// ^ more-ind. ^ empty ^ capture next empty lines only at end of indent
|
|
29772
30903
|
.replace(/\n+/g, `$&${indent}`);
|
|
29773
|
-
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx));
|
|
30904
|
+
const body = foldFlowLines(`${start}${value}${end}`, indent, FOLD_BLOCK, getFoldOptions(ctx, true));
|
|
29774
30905
|
return `${header}\n${indent}${body}`;
|
|
29775
30906
|
}
|
|
29776
30907
|
function plainString(item, ctx, onComment, onChompKeep) {
|
|
29777
30908
|
const { type, value } = item;
|
|
29778
|
-
const { actualString, implicitKey, indent, inFlow } = ctx;
|
|
29779
|
-
if ((implicitKey &&
|
|
30909
|
+
const { actualString, implicitKey, indent, indentStep, inFlow } = ctx;
|
|
30910
|
+
if ((implicitKey && value.includes('\n')) ||
|
|
29780
30911
|
(inFlow && /[[\]{},]/.test(value))) {
|
|
29781
30912
|
return quotedString(value, ctx);
|
|
29782
30913
|
}
|
|
@@ -29799,9 +30930,14 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
29799
30930
|
// Where allowed & type not set explicitly, prefer block style for multiline strings
|
|
29800
30931
|
return blockString(item, ctx, onComment, onChompKeep);
|
|
29801
30932
|
}
|
|
29802
|
-
if (
|
|
29803
|
-
|
|
29804
|
-
|
|
30933
|
+
if (containsDocumentMarker(value)) {
|
|
30934
|
+
if (indent === '') {
|
|
30935
|
+
ctx.forceBlockIndent = true;
|
|
30936
|
+
return blockString(item, ctx, onComment, onChompKeep);
|
|
30937
|
+
}
|
|
30938
|
+
else if (implicitKey && indent === indentStep) {
|
|
30939
|
+
return quotedString(value, ctx);
|
|
30940
|
+
}
|
|
29805
30941
|
}
|
|
29806
30942
|
const str = value.replace(/\n+/g, `$&\n${indent}`);
|
|
29807
30943
|
// Verify that output will be parsed as a string, as e.g. plain numbers and
|
|
@@ -29815,7 +30951,7 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
29815
30951
|
}
|
|
29816
30952
|
return implicitKey
|
|
29817
30953
|
? str
|
|
29818
|
-
: foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx));
|
|
30954
|
+
: foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx, false));
|
|
29819
30955
|
}
|
|
29820
30956
|
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
29821
30957
|
const { implicitKey, inFlow } = ctx;
|
|
@@ -29866,6 +31002,7 @@ function createStringifyContext(doc, options) {
|
|
|
29866
31002
|
doubleQuotedAsJSON: false,
|
|
29867
31003
|
doubleQuotedMinMultiLineLength: 40,
|
|
29868
31004
|
falseStr: 'false',
|
|
31005
|
+
flowCollectionPadding: true,
|
|
29869
31006
|
indentSeq: true,
|
|
29870
31007
|
lineWidth: 80,
|
|
29871
31008
|
minContentWidth: 20,
|
|
@@ -29889,6 +31026,7 @@ function createStringifyContext(doc, options) {
|
|
|
29889
31026
|
return {
|
|
29890
31027
|
anchors: new Set(),
|
|
29891
31028
|
doc,
|
|
31029
|
+
flowCollectionPadding: opt.flowCollectionPadding ? ' ' : '',
|
|
29892
31030
|
indent: '',
|
|
29893
31031
|
indentStep: typeof opt.indent === 'number' ? ' '.repeat(opt.indent) : ' ',
|
|
29894
31032
|
inFlow,
|
|
@@ -30032,19 +31170,18 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
30032
31170
|
if (keyComment)
|
|
30033
31171
|
str += lineComment(str, ctx.indent, commentString(keyComment));
|
|
30034
31172
|
}
|
|
30035
|
-
let vcb
|
|
30036
|
-
let valueComment = null;
|
|
31173
|
+
let vsb, vcb, valueComment;
|
|
30037
31174
|
if (isNode$1(value)) {
|
|
30038
|
-
|
|
30039
|
-
|
|
30040
|
-
if (value.commentBefore) {
|
|
30041
|
-
const cs = commentString(value.commentBefore);
|
|
30042
|
-
vcb += `\n${indentComment(cs, ctx.indent)}`;
|
|
30043
|
-
}
|
|
31175
|
+
vsb = !!value.spaceBefore;
|
|
31176
|
+
vcb = value.commentBefore;
|
|
30044
31177
|
valueComment = value.comment;
|
|
30045
31178
|
}
|
|
30046
|
-
else
|
|
30047
|
-
|
|
31179
|
+
else {
|
|
31180
|
+
vsb = false;
|
|
31181
|
+
vcb = null;
|
|
31182
|
+
valueComment = null;
|
|
31183
|
+
if (value && typeof value === 'object')
|
|
31184
|
+
value = doc.createNode(value);
|
|
30048
31185
|
}
|
|
30049
31186
|
ctx.implicitKey = false;
|
|
30050
31187
|
if (!explicitKey && !keyComment && isScalar$1(value))
|
|
@@ -30059,24 +31196,50 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
30059
31196
|
!value.tag &&
|
|
30060
31197
|
!value.anchor) {
|
|
30061
31198
|
// If indentSeq === false, consider '- ' as part of indentation where possible
|
|
30062
|
-
ctx.indent = ctx.indent.
|
|
31199
|
+
ctx.indent = ctx.indent.substring(2);
|
|
30063
31200
|
}
|
|
30064
31201
|
let valueCommentDone = false;
|
|
30065
31202
|
const valueStr = stringify$2(value, ctx, () => (valueCommentDone = true), () => (chompKeep = true));
|
|
30066
31203
|
let ws = ' ';
|
|
30067
|
-
if (
|
|
30068
|
-
|
|
30069
|
-
|
|
30070
|
-
|
|
30071
|
-
ws
|
|
31204
|
+
if (keyComment || vsb || vcb) {
|
|
31205
|
+
ws = vsb ? '\n' : '';
|
|
31206
|
+
if (vcb) {
|
|
31207
|
+
const cs = commentString(vcb);
|
|
31208
|
+
ws += `\n${indentComment(cs, ctx.indent)}`;
|
|
31209
|
+
}
|
|
31210
|
+
if (valueStr === '' && !ctx.inFlow) {
|
|
31211
|
+
if (ws === '\n')
|
|
31212
|
+
ws = '\n\n';
|
|
31213
|
+
}
|
|
31214
|
+
else {
|
|
31215
|
+
ws += `\n${ctx.indent}`;
|
|
31216
|
+
}
|
|
30072
31217
|
}
|
|
30073
31218
|
else if (!explicitKey && isCollection$1(value)) {
|
|
30074
|
-
const
|
|
30075
|
-
|
|
30076
|
-
|
|
31219
|
+
const vs0 = valueStr[0];
|
|
31220
|
+
const nl0 = valueStr.indexOf('\n');
|
|
31221
|
+
const hasNewline = nl0 !== -1;
|
|
31222
|
+
const flow = ctx.inFlow ?? value.flow ?? value.items.length === 0;
|
|
31223
|
+
if (hasNewline || !flow) {
|
|
31224
|
+
let hasPropsLine = false;
|
|
31225
|
+
if (hasNewline && (vs0 === '&' || vs0 === '!')) {
|
|
31226
|
+
let sp0 = valueStr.indexOf(' ');
|
|
31227
|
+
if (vs0 === '&' &&
|
|
31228
|
+
sp0 !== -1 &&
|
|
31229
|
+
sp0 < nl0 &&
|
|
31230
|
+
valueStr[sp0 + 1] === '!') {
|
|
31231
|
+
sp0 = valueStr.indexOf(' ', sp0 + 1);
|
|
31232
|
+
}
|
|
31233
|
+
if (sp0 === -1 || nl0 < sp0)
|
|
31234
|
+
hasPropsLine = true;
|
|
31235
|
+
}
|
|
31236
|
+
if (!hasPropsLine)
|
|
31237
|
+
ws = `\n${ctx.indent}`;
|
|
31238
|
+
}
|
|
30077
31239
|
}
|
|
30078
|
-
else if (valueStr === '' || valueStr[0] === '\n')
|
|
31240
|
+
else if (valueStr === '' || valueStr[0] === '\n') {
|
|
30079
31241
|
ws = '';
|
|
31242
|
+
}
|
|
30080
31243
|
str += ws + valueStr;
|
|
30081
31244
|
if (ctx.inFlow) {
|
|
30082
31245
|
if (valueCommentDone && onComment)
|
|
@@ -30093,6 +31256,8 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
30093
31256
|
|
|
30094
31257
|
function warn(logLevel, warning) {
|
|
30095
31258
|
if (logLevel === 'debug' || logLevel === 'warn') {
|
|
31259
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/7478
|
|
31260
|
+
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
|
30096
31261
|
if (typeof process !== 'undefined' && process.emitWarning)
|
|
30097
31262
|
process.emitWarning(warning);
|
|
30098
31263
|
else
|
|
@@ -30177,7 +31342,7 @@ function stringifyKey(key, jsKey, ctx) {
|
|
|
30177
31342
|
return '';
|
|
30178
31343
|
if (typeof jsKey !== 'object')
|
|
30179
31344
|
return String(jsKey);
|
|
30180
|
-
if (isNode$1(key) && ctx
|
|
31345
|
+
if (isNode$1(key) && ctx?.doc) {
|
|
30181
31346
|
const strCtx = createStringifyContext(ctx.doc, {});
|
|
30182
31347
|
strCtx.anchors = new Set();
|
|
30183
31348
|
for (const node of ctx.anchors.keys())
|
|
@@ -30284,7 +31449,7 @@ function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, fl
|
|
|
30284
31449
|
return str;
|
|
30285
31450
|
}
|
|
30286
31451
|
function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemIndent, onComment }) {
|
|
30287
|
-
const { indent, indentStep, options: { commentString } } = ctx;
|
|
31452
|
+
const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
|
|
30288
31453
|
itemIndent += indentStep;
|
|
30289
31454
|
const itemCtx = Object.assign({}, ctx, {
|
|
30290
31455
|
indent: itemIndent,
|
|
@@ -30320,7 +31485,7 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
|
|
|
30320
31485
|
if (iv.commentBefore)
|
|
30321
31486
|
reqNewline = true;
|
|
30322
31487
|
}
|
|
30323
|
-
else if (item.value == null && ik
|
|
31488
|
+
else if (item.value == null && ik?.comment) {
|
|
30324
31489
|
comment = ik.comment;
|
|
30325
31490
|
}
|
|
30326
31491
|
}
|
|
@@ -30353,11 +31518,11 @@ function stringifyFlowCollection({ comment, items }, ctx, { flowChars, itemInden
|
|
|
30353
31518
|
str += `\n${indent}${end}`;
|
|
30354
31519
|
}
|
|
30355
31520
|
else {
|
|
30356
|
-
str = `${start}
|
|
31521
|
+
str = `${start}${fcPadding}${lines.join(' ')}${fcPadding}${end}`;
|
|
30357
31522
|
}
|
|
30358
31523
|
}
|
|
30359
31524
|
if (comment) {
|
|
30360
|
-
str += lineComment(str, commentString(comment)
|
|
31525
|
+
str += lineComment(str, indent, commentString(comment));
|
|
30361
31526
|
if (onComment)
|
|
30362
31527
|
onComment();
|
|
30363
31528
|
}
|
|
@@ -30385,12 +31550,40 @@ function findPair(items, key) {
|
|
|
30385
31550
|
return undefined;
|
|
30386
31551
|
}
|
|
30387
31552
|
class YAMLMap extends Collection {
|
|
31553
|
+
static get tagName() {
|
|
31554
|
+
return 'tag:yaml.org,2002:map';
|
|
31555
|
+
}
|
|
30388
31556
|
constructor(schema) {
|
|
30389
31557
|
super(MAP, schema);
|
|
30390
31558
|
this.items = [];
|
|
30391
31559
|
}
|
|
30392
|
-
|
|
30393
|
-
|
|
31560
|
+
/**
|
|
31561
|
+
* A generic collection parsing method that can be extended
|
|
31562
|
+
* to other node classes that inherit from YAMLMap
|
|
31563
|
+
*/
|
|
31564
|
+
static from(schema, obj, ctx) {
|
|
31565
|
+
const { keepUndefined, replacer } = ctx;
|
|
31566
|
+
const map = new this(schema);
|
|
31567
|
+
const add = (key, value) => {
|
|
31568
|
+
if (typeof replacer === 'function')
|
|
31569
|
+
value = replacer.call(obj, key, value);
|
|
31570
|
+
else if (Array.isArray(replacer) && !replacer.includes(key))
|
|
31571
|
+
return;
|
|
31572
|
+
if (value !== undefined || keepUndefined)
|
|
31573
|
+
map.items.push(createPair(key, value, ctx));
|
|
31574
|
+
};
|
|
31575
|
+
if (obj instanceof Map) {
|
|
31576
|
+
for (const [key, value] of obj)
|
|
31577
|
+
add(key, value);
|
|
31578
|
+
}
|
|
31579
|
+
else if (obj && typeof obj === 'object') {
|
|
31580
|
+
for (const key of Object.keys(obj))
|
|
31581
|
+
add(key, obj[key]);
|
|
31582
|
+
}
|
|
31583
|
+
if (typeof schema.sortMapEntries === 'function') {
|
|
31584
|
+
map.items.sort(schema.sortMapEntries);
|
|
31585
|
+
}
|
|
31586
|
+
return map;
|
|
30394
31587
|
}
|
|
30395
31588
|
/**
|
|
30396
31589
|
* Adds a value to the collection.
|
|
@@ -30480,33 +31673,8 @@ class YAMLMap extends Collection {
|
|
|
30480
31673
|
}
|
|
30481
31674
|
}
|
|
30482
31675
|
|
|
30483
|
-
function createMap(schema, obj, ctx) {
|
|
30484
|
-
const { keepUndefined, replacer } = ctx;
|
|
30485
|
-
const map = new YAMLMap(schema);
|
|
30486
|
-
const add = (key, value) => {
|
|
30487
|
-
if (typeof replacer === 'function')
|
|
30488
|
-
value = replacer.call(obj, key, value);
|
|
30489
|
-
else if (Array.isArray(replacer) && !replacer.includes(key))
|
|
30490
|
-
return;
|
|
30491
|
-
if (value !== undefined || keepUndefined)
|
|
30492
|
-
map.items.push(createPair(key, value, ctx));
|
|
30493
|
-
};
|
|
30494
|
-
if (obj instanceof Map) {
|
|
30495
|
-
for (const [key, value] of obj)
|
|
30496
|
-
add(key, value);
|
|
30497
|
-
}
|
|
30498
|
-
else if (obj && typeof obj === 'object') {
|
|
30499
|
-
for (const key of Object.keys(obj))
|
|
30500
|
-
add(key, obj[key]);
|
|
30501
|
-
}
|
|
30502
|
-
if (typeof schema.sortMapEntries === 'function') {
|
|
30503
|
-
map.items.sort(schema.sortMapEntries);
|
|
30504
|
-
}
|
|
30505
|
-
return map;
|
|
30506
|
-
}
|
|
30507
31676
|
const map$1 = {
|
|
30508
31677
|
collection: 'map',
|
|
30509
|
-
createNode: createMap,
|
|
30510
31678
|
default: true,
|
|
30511
31679
|
nodeClass: YAMLMap,
|
|
30512
31680
|
tag: 'tag:yaml.org,2002:map',
|
|
@@ -30514,17 +31682,18 @@ const map$1 = {
|
|
|
30514
31682
|
if (!isMap(map))
|
|
30515
31683
|
onError('Expected a mapping for this tag');
|
|
30516
31684
|
return map;
|
|
30517
|
-
}
|
|
31685
|
+
},
|
|
31686
|
+
createNode: (schema, obj, ctx) => YAMLMap.from(schema, obj, ctx)
|
|
30518
31687
|
};
|
|
30519
31688
|
|
|
30520
31689
|
class YAMLSeq extends Collection {
|
|
31690
|
+
static get tagName() {
|
|
31691
|
+
return 'tag:yaml.org,2002:seq';
|
|
31692
|
+
}
|
|
30521
31693
|
constructor(schema) {
|
|
30522
31694
|
super(SEQ, schema);
|
|
30523
31695
|
this.items = [];
|
|
30524
31696
|
}
|
|
30525
|
-
static get tagName() {
|
|
30526
|
-
return 'tag:yaml.org,2002:seq';
|
|
30527
|
-
}
|
|
30528
31697
|
add(value) {
|
|
30529
31698
|
this.items.push(value);
|
|
30530
31699
|
}
|
|
@@ -30597,6 +31766,21 @@ class YAMLSeq extends Collection {
|
|
|
30597
31766
|
onComment
|
|
30598
31767
|
});
|
|
30599
31768
|
}
|
|
31769
|
+
static from(schema, obj, ctx) {
|
|
31770
|
+
const { replacer } = ctx;
|
|
31771
|
+
const seq = new this(schema);
|
|
31772
|
+
if (obj && Symbol.iterator in Object(obj)) {
|
|
31773
|
+
let i = 0;
|
|
31774
|
+
for (let it of obj) {
|
|
31775
|
+
if (typeof replacer === 'function') {
|
|
31776
|
+
const key = obj instanceof Set ? it : String(i++);
|
|
31777
|
+
it = replacer.call(obj, key, it);
|
|
31778
|
+
}
|
|
31779
|
+
seq.items.push(createNode(it, undefined, ctx));
|
|
31780
|
+
}
|
|
31781
|
+
}
|
|
31782
|
+
return seq;
|
|
31783
|
+
}
|
|
30600
31784
|
}
|
|
30601
31785
|
function asItemIndex(key) {
|
|
30602
31786
|
let idx = isScalar$1(key) ? key.value : key;
|
|
@@ -30607,24 +31791,8 @@ function asItemIndex(key) {
|
|
|
30607
31791
|
: null;
|
|
30608
31792
|
}
|
|
30609
31793
|
|
|
30610
|
-
function createSeq(schema, obj, ctx) {
|
|
30611
|
-
const { replacer } = ctx;
|
|
30612
|
-
const seq = new YAMLSeq(schema);
|
|
30613
|
-
if (obj && Symbol.iterator in Object(obj)) {
|
|
30614
|
-
let i = 0;
|
|
30615
|
-
for (let it of obj) {
|
|
30616
|
-
if (typeof replacer === 'function') {
|
|
30617
|
-
const key = obj instanceof Set ? it : String(i++);
|
|
30618
|
-
it = replacer.call(obj, key, it);
|
|
30619
|
-
}
|
|
30620
|
-
seq.items.push(createNode(it, undefined, ctx));
|
|
30621
|
-
}
|
|
30622
|
-
}
|
|
30623
|
-
return seq;
|
|
30624
|
-
}
|
|
30625
31794
|
const seq = {
|
|
30626
31795
|
collection: 'seq',
|
|
30627
|
-
createNode: createSeq,
|
|
30628
31796
|
default: true,
|
|
30629
31797
|
nodeClass: YAMLSeq,
|
|
30630
31798
|
tag: 'tag:yaml.org,2002:seq',
|
|
@@ -30632,7 +31800,8 @@ const seq = {
|
|
|
30632
31800
|
if (!isSeq(seq))
|
|
30633
31801
|
onError('Expected a sequence for this tag');
|
|
30634
31802
|
return seq;
|
|
30635
|
-
}
|
|
31803
|
+
},
|
|
31804
|
+
createNode: (schema, obj, ctx) => YAMLSeq.from(schema, obj, ctx)
|
|
30636
31805
|
};
|
|
30637
31806
|
|
|
30638
31807
|
const string = {
|
|
@@ -30957,8 +32126,9 @@ function createPairs(schema, iterable, ctx) {
|
|
|
30957
32126
|
key = keys[0];
|
|
30958
32127
|
value = it[key];
|
|
30959
32128
|
}
|
|
30960
|
-
else
|
|
30961
|
-
throw new TypeError(`Expected
|
|
32129
|
+
else {
|
|
32130
|
+
throw new TypeError(`Expected tuple with one key, not ${keys.length} keys`);
|
|
32131
|
+
}
|
|
30962
32132
|
}
|
|
30963
32133
|
else {
|
|
30964
32134
|
key = it;
|
|
@@ -31010,6 +32180,12 @@ class YAMLOMap extends YAMLSeq {
|
|
|
31010
32180
|
}
|
|
31011
32181
|
return map;
|
|
31012
32182
|
}
|
|
32183
|
+
static from(schema, iterable, ctx) {
|
|
32184
|
+
const pairs = createPairs(schema, iterable, ctx);
|
|
32185
|
+
const omap = new this();
|
|
32186
|
+
omap.items = pairs.items;
|
|
32187
|
+
return omap;
|
|
32188
|
+
}
|
|
31013
32189
|
}
|
|
31014
32190
|
YAMLOMap.tag = 'tag:yaml.org,2002:omap';
|
|
31015
32191
|
const omap = {
|
|
@@ -31033,12 +32209,7 @@ const omap = {
|
|
|
31033
32209
|
}
|
|
31034
32210
|
return Object.assign(new YAMLOMap(), pairs);
|
|
31035
32211
|
},
|
|
31036
|
-
createNode(schema, iterable, ctx)
|
|
31037
|
-
const pairs = createPairs(schema, iterable, ctx);
|
|
31038
|
-
const omap = new YAMLOMap();
|
|
31039
|
-
omap.items = pairs.items;
|
|
31040
|
-
return omap;
|
|
31041
|
-
}
|
|
32212
|
+
createNode: (schema, iterable, ctx) => YAMLOMap.from(schema, iterable, ctx)
|
|
31042
32213
|
};
|
|
31043
32214
|
|
|
31044
32215
|
function boolStringify({ value, source }, ctx) {
|
|
@@ -31183,7 +32354,8 @@ class YAMLSet extends YAMLMap {
|
|
|
31183
32354
|
let pair;
|
|
31184
32355
|
if (isPair(key))
|
|
31185
32356
|
pair = key;
|
|
31186
|
-
else if (
|
|
32357
|
+
else if (key &&
|
|
32358
|
+
typeof key === 'object' &&
|
|
31187
32359
|
'key' in key &&
|
|
31188
32360
|
'value' in key &&
|
|
31189
32361
|
key.value === null)
|
|
@@ -31228,6 +32400,17 @@ class YAMLSet extends YAMLMap {
|
|
|
31228
32400
|
else
|
|
31229
32401
|
throw new Error('Set items must all have null values');
|
|
31230
32402
|
}
|
|
32403
|
+
static from(schema, iterable, ctx) {
|
|
32404
|
+
const { replacer } = ctx;
|
|
32405
|
+
const set = new this(schema);
|
|
32406
|
+
if (iterable && Symbol.iterator in Object(iterable))
|
|
32407
|
+
for (let value of iterable) {
|
|
32408
|
+
if (typeof replacer === 'function')
|
|
32409
|
+
value = replacer.call(iterable, value, value);
|
|
32410
|
+
set.items.push(createPair(value, null, ctx));
|
|
32411
|
+
}
|
|
32412
|
+
return set;
|
|
32413
|
+
}
|
|
31231
32414
|
}
|
|
31232
32415
|
YAMLSet.tag = 'tag:yaml.org,2002:set';
|
|
31233
32416
|
const set = {
|
|
@@ -31236,6 +32419,7 @@ const set = {
|
|
|
31236
32419
|
nodeClass: YAMLSet,
|
|
31237
32420
|
default: false,
|
|
31238
32421
|
tag: 'tag:yaml.org,2002:set',
|
|
32422
|
+
createNode: (schema, iterable, ctx) => YAMLSet.from(schema, iterable, ctx),
|
|
31239
32423
|
resolve(map, onError) {
|
|
31240
32424
|
if (isMap(map)) {
|
|
31241
32425
|
if (map.hasAllNullValues(true))
|
|
@@ -31246,17 +32430,6 @@ const set = {
|
|
|
31246
32430
|
else
|
|
31247
32431
|
onError('Expected a mapping for this tag');
|
|
31248
32432
|
return map;
|
|
31249
|
-
},
|
|
31250
|
-
createNode(schema, iterable, ctx) {
|
|
31251
|
-
const { replacer } = ctx;
|
|
31252
|
-
const set = new YAMLSet(schema);
|
|
31253
|
-
if (iterable && Symbol.iterator in Object(iterable))
|
|
31254
|
-
for (let value of iterable) {
|
|
31255
|
-
if (typeof replacer === 'function')
|
|
31256
|
-
value = replacer.call(iterable, value, value);
|
|
31257
|
-
set.items.push(createPair(value, null, ctx));
|
|
31258
|
-
}
|
|
31259
|
-
return set;
|
|
31260
32433
|
}
|
|
31261
32434
|
};
|
|
31262
32435
|
|
|
@@ -31303,7 +32476,7 @@ function stringifySexagesimal(node) {
|
|
|
31303
32476
|
}
|
|
31304
32477
|
return (sign +
|
|
31305
32478
|
parts
|
|
31306
|
-
.map(n => (n
|
|
32479
|
+
.map(n => String(n).padStart(2, '0'))
|
|
31307
32480
|
.join(':')
|
|
31308
32481
|
.replace(/000000\d*$/, '') // % 60 may introduce error
|
|
31309
32482
|
);
|
|
@@ -31558,59 +32731,6 @@ function stringifyDocument(doc, options) {
|
|
|
31558
32731
|
return lines.join('\n') + '\n';
|
|
31559
32732
|
}
|
|
31560
32733
|
|
|
31561
|
-
/**
|
|
31562
|
-
* Applies the JSON.parse reviver algorithm as defined in the ECMA-262 spec,
|
|
31563
|
-
* in section 24.5.1.1 "Runtime Semantics: InternalizeJSONProperty" of the
|
|
31564
|
-
* 2021 edition: https://tc39.es/ecma262/#sec-json.parse
|
|
31565
|
-
*
|
|
31566
|
-
* Includes extensions for handling Map and Set objects.
|
|
31567
|
-
*/
|
|
31568
|
-
function applyReviver(reviver, obj, key, val) {
|
|
31569
|
-
if (val && typeof val === 'object') {
|
|
31570
|
-
if (Array.isArray(val)) {
|
|
31571
|
-
for (let i = 0, len = val.length; i < len; ++i) {
|
|
31572
|
-
const v0 = val[i];
|
|
31573
|
-
const v1 = applyReviver(reviver, val, String(i), v0);
|
|
31574
|
-
if (v1 === undefined)
|
|
31575
|
-
delete val[i];
|
|
31576
|
-
else if (v1 !== v0)
|
|
31577
|
-
val[i] = v1;
|
|
31578
|
-
}
|
|
31579
|
-
}
|
|
31580
|
-
else if (val instanceof Map) {
|
|
31581
|
-
for (const k of Array.from(val.keys())) {
|
|
31582
|
-
const v0 = val.get(k);
|
|
31583
|
-
const v1 = applyReviver(reviver, val, k, v0);
|
|
31584
|
-
if (v1 === undefined)
|
|
31585
|
-
val.delete(k);
|
|
31586
|
-
else if (v1 !== v0)
|
|
31587
|
-
val.set(k, v1);
|
|
31588
|
-
}
|
|
31589
|
-
}
|
|
31590
|
-
else if (val instanceof Set) {
|
|
31591
|
-
for (const v0 of Array.from(val)) {
|
|
31592
|
-
const v1 = applyReviver(reviver, val, v0, v0);
|
|
31593
|
-
if (v1 === undefined)
|
|
31594
|
-
val.delete(v0);
|
|
31595
|
-
else if (v1 !== v0) {
|
|
31596
|
-
val.delete(v0);
|
|
31597
|
-
val.add(v1);
|
|
31598
|
-
}
|
|
31599
|
-
}
|
|
31600
|
-
}
|
|
31601
|
-
else {
|
|
31602
|
-
for (const [k, v0] of Object.entries(val)) {
|
|
31603
|
-
const v1 = applyReviver(reviver, val, k, v0);
|
|
31604
|
-
if (v1 === undefined)
|
|
31605
|
-
delete val[k];
|
|
31606
|
-
else if (v1 !== v0)
|
|
31607
|
-
val[k] = v1;
|
|
31608
|
-
}
|
|
31609
|
-
}
|
|
31610
|
-
}
|
|
31611
|
-
return reviver.call(obj, key, val);
|
|
31612
|
-
}
|
|
31613
|
-
|
|
31614
32734
|
class Document {
|
|
31615
32735
|
constructor(value, replacer, options) {
|
|
31616
32736
|
/** A comment before this Document */
|
|
@@ -31649,11 +32769,9 @@ class Document {
|
|
|
31649
32769
|
else
|
|
31650
32770
|
this.directives = new Directives({ version });
|
|
31651
32771
|
this.setSchema(version, options);
|
|
31652
|
-
|
|
31653
|
-
|
|
31654
|
-
|
|
31655
|
-
this.contents = this.createNode(value, _replacer, options);
|
|
31656
|
-
}
|
|
32772
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
32773
|
+
this.contents =
|
|
32774
|
+
value === undefined ? null : this.createNode(value, _replacer, options);
|
|
31657
32775
|
}
|
|
31658
32776
|
/**
|
|
31659
32777
|
* Create a deep copy of this Document and its contents.
|
|
@@ -31672,6 +32790,7 @@ class Document {
|
|
|
31672
32790
|
if (this.directives)
|
|
31673
32791
|
copy.directives = this.directives.clone();
|
|
31674
32792
|
copy.schema = this.schema.clone();
|
|
32793
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
31675
32794
|
copy.contents = isNode$1(this.contents)
|
|
31676
32795
|
? this.contents.clone(copy.schema)
|
|
31677
32796
|
: this.contents;
|
|
@@ -31767,6 +32886,7 @@ class Document {
|
|
|
31767
32886
|
if (isEmptyPath(path)) {
|
|
31768
32887
|
if (this.contents == null)
|
|
31769
32888
|
return false;
|
|
32889
|
+
// @ts-expect-error Presumed impossible if Strict extends false
|
|
31770
32890
|
this.contents = null;
|
|
31771
32891
|
return true;
|
|
31772
32892
|
}
|
|
@@ -31818,6 +32938,7 @@ class Document {
|
|
|
31818
32938
|
*/
|
|
31819
32939
|
set(key, value) {
|
|
31820
32940
|
if (this.contents == null) {
|
|
32941
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
31821
32942
|
this.contents = collectionFromPath(this.schema, [key], value);
|
|
31822
32943
|
}
|
|
31823
32944
|
else if (assertCollection(this.contents)) {
|
|
@@ -31829,9 +32950,12 @@ class Document {
|
|
|
31829
32950
|
* boolean to add/remove the item from the set.
|
|
31830
32951
|
*/
|
|
31831
32952
|
setIn(path, value) {
|
|
31832
|
-
if (isEmptyPath(path))
|
|
32953
|
+
if (isEmptyPath(path)) {
|
|
32954
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
31833
32955
|
this.contents = value;
|
|
32956
|
+
}
|
|
31834
32957
|
else if (this.contents == null) {
|
|
32958
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
31835
32959
|
this.contents = collectionFromPath(this.schema, Array.from(path), value);
|
|
31836
32960
|
}
|
|
31837
32961
|
else if (assertCollection(this.contents)) {
|
|
@@ -31891,8 +33015,7 @@ class Document {
|
|
|
31891
33015
|
keep: !json,
|
|
31892
33016
|
mapAsMap: mapAsMap === true,
|
|
31893
33017
|
mapKeyWarned: false,
|
|
31894
|
-
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
|
|
31895
|
-
stringify: stringify$2
|
|
33018
|
+
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
|
|
31896
33019
|
};
|
|
31897
33020
|
const res = toJS(this.contents, jsonArg ?? '', ctx);
|
|
31898
33021
|
if (typeof onAnchor === 'function')
|
|
@@ -31978,7 +33101,7 @@ const prettifyError = (src, lc) => (error) => {
|
|
|
31978
33101
|
let count = 1;
|
|
31979
33102
|
const end = error.linePos[1];
|
|
31980
33103
|
if (end && end.line === line && end.col > col) {
|
|
31981
|
-
count = Math.min(end.col - col, 80 - ci);
|
|
33104
|
+
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
31982
33105
|
}
|
|
31983
33106
|
const pointer = ' '.repeat(ci) + '^'.repeat(count);
|
|
31984
33107
|
error.message += `:\n\n${lineStr}\n${pointer}\n`;
|
|
@@ -32178,11 +33301,13 @@ function mapIncludes(ctx, items, search) {
|
|
|
32178
33301
|
}
|
|
32179
33302
|
|
|
32180
33303
|
const startColMsg = 'All mapping items must start at the same column';
|
|
32181
|
-
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
32182
|
-
const
|
|
33304
|
+
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, tag) {
|
|
33305
|
+
const NodeClass = tag?.nodeClass ?? YAMLMap;
|
|
33306
|
+
const map = new NodeClass(ctx.schema);
|
|
32183
33307
|
if (ctx.atRoot)
|
|
32184
33308
|
ctx.atRoot = false;
|
|
32185
33309
|
let offset = bm.offset;
|
|
33310
|
+
let commentEnd = null;
|
|
32186
33311
|
for (const collItem of bm.items) {
|
|
32187
33312
|
const { start, key, sep, value } = collItem;
|
|
32188
33313
|
// key properties
|
|
@@ -32202,7 +33327,7 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
32202
33327
|
onError(offset, 'BAD_INDENT', startColMsg);
|
|
32203
33328
|
}
|
|
32204
33329
|
if (!keyProps.anchor && !keyProps.tag && !sep) {
|
|
32205
|
-
|
|
33330
|
+
commentEnd = keyProps.end;
|
|
32206
33331
|
if (keyProps.comment) {
|
|
32207
33332
|
if (map.comment)
|
|
32208
33333
|
map.comment += '\n' + keyProps.comment;
|
|
@@ -32272,15 +33397,19 @@ function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
|
32272
33397
|
map.items.push(pair);
|
|
32273
33398
|
}
|
|
32274
33399
|
}
|
|
32275
|
-
|
|
33400
|
+
if (commentEnd && commentEnd < offset)
|
|
33401
|
+
onError(commentEnd, 'IMPOSSIBLE', 'Map comment with trailing content');
|
|
33402
|
+
map.range = [bm.offset, offset, commentEnd ?? offset];
|
|
32276
33403
|
return map;
|
|
32277
33404
|
}
|
|
32278
33405
|
|
|
32279
|
-
function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
32280
|
-
const
|
|
33406
|
+
function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, tag) {
|
|
33407
|
+
const NodeClass = tag?.nodeClass ?? YAMLSeq;
|
|
33408
|
+
const seq = new NodeClass(ctx.schema);
|
|
32281
33409
|
if (ctx.atRoot)
|
|
32282
33410
|
ctx.atRoot = false;
|
|
32283
33411
|
let offset = bs.offset;
|
|
33412
|
+
let commentEnd = null;
|
|
32284
33413
|
for (const { start, value } of bs.items) {
|
|
32285
33414
|
const props = resolveProps(start, {
|
|
32286
33415
|
indicator: 'seq-item-ind',
|
|
@@ -32289,16 +33418,15 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
32289
33418
|
onError,
|
|
32290
33419
|
startOnNewline: true
|
|
32291
33420
|
});
|
|
32292
|
-
offset = props.end;
|
|
32293
33421
|
if (!props.found) {
|
|
32294
33422
|
if (props.anchor || props.tag || value) {
|
|
32295
33423
|
if (value && value.type === 'block-seq')
|
|
32296
|
-
onError(
|
|
33424
|
+
onError(props.end, 'BAD_INDENT', 'All sequence items must start at the same column');
|
|
32297
33425
|
else
|
|
32298
33426
|
onError(offset, 'MISSING_CHAR', 'Sequence item without - indicator');
|
|
32299
33427
|
}
|
|
32300
33428
|
else {
|
|
32301
|
-
|
|
33429
|
+
commentEnd = props.end;
|
|
32302
33430
|
if (props.comment)
|
|
32303
33431
|
seq.comment = props.comment;
|
|
32304
33432
|
continue;
|
|
@@ -32306,13 +33434,13 @@ function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
|
32306
33434
|
}
|
|
32307
33435
|
const node = value
|
|
32308
33436
|
? composeNode(ctx, value, props, onError)
|
|
32309
|
-
: composeEmptyNode(ctx,
|
|
33437
|
+
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
|
32310
33438
|
if (ctx.schema.compat)
|
|
32311
33439
|
flowIndentCheck(bs.indent, value, onError);
|
|
32312
33440
|
offset = node.range[2];
|
|
32313
33441
|
seq.items.push(node);
|
|
32314
33442
|
}
|
|
32315
|
-
seq.range = [bs.offset, offset, offset];
|
|
33443
|
+
seq.range = [bs.offset, offset, commentEnd ?? offset];
|
|
32316
33444
|
return seq;
|
|
32317
33445
|
}
|
|
32318
33446
|
|
|
@@ -32354,12 +33482,11 @@ function resolveEnd(end, offset, reqSpace, onError) {
|
|
|
32354
33482
|
|
|
32355
33483
|
const blockMsg = 'Block collections are not allowed within flow collections';
|
|
32356
33484
|
const isBlock$1 = (token) => token && (token.type === 'block-map' || token.type === 'block-seq');
|
|
32357
|
-
function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError) {
|
|
33485
|
+
function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError, tag) {
|
|
32358
33486
|
const isMap = fc.start.source === '{';
|
|
32359
33487
|
const fcName = isMap ? 'flow map' : 'flow sequence';
|
|
32360
|
-
const
|
|
32361
|
-
|
|
32362
|
-
: new YAMLSeq(ctx.schema);
|
|
33488
|
+
const NodeClass = (tag?.nodeClass ?? (isMap ? YAMLMap : YAMLSeq));
|
|
33489
|
+
const coll = new NodeClass(ctx.schema);
|
|
32363
33490
|
coll.flow = true;
|
|
32364
33491
|
const atRoot = ctx.atRoot;
|
|
32365
33492
|
if (atRoot)
|
|
@@ -32542,35 +33669,45 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
32542
33669
|
return coll;
|
|
32543
33670
|
}
|
|
32544
33671
|
|
|
32545
|
-
function
|
|
32546
|
-
|
|
32547
|
-
|
|
32548
|
-
|
|
32549
|
-
|
|
32550
|
-
|
|
32551
|
-
}
|
|
32552
|
-
case 'block-seq': {
|
|
32553
|
-
coll = resolveBlockSeq(CN, ctx, token, onError);
|
|
32554
|
-
break;
|
|
32555
|
-
}
|
|
32556
|
-
case 'flow-collection': {
|
|
32557
|
-
coll = resolveFlowCollection(CN, ctx, token, onError);
|
|
32558
|
-
break;
|
|
32559
|
-
}
|
|
32560
|
-
}
|
|
32561
|
-
if (!tagToken)
|
|
32562
|
-
return coll;
|
|
32563
|
-
const tagName = ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg));
|
|
32564
|
-
if (!tagName)
|
|
32565
|
-
return coll;
|
|
32566
|
-
// Cast needed due to: https://github.com/Microsoft/TypeScript/issues/3841
|
|
33672
|
+
function resolveCollection(CN, ctx, token, onError, tagName, tag) {
|
|
33673
|
+
const coll = token.type === 'block-map'
|
|
33674
|
+
? resolveBlockMap(CN, ctx, token, onError, tag)
|
|
33675
|
+
: token.type === 'block-seq'
|
|
33676
|
+
? resolveBlockSeq(CN, ctx, token, onError, tag)
|
|
33677
|
+
: resolveFlowCollection(CN, ctx, token, onError, tag);
|
|
32567
33678
|
const Coll = coll.constructor;
|
|
33679
|
+
// If we got a tagName matching the class, or the tag name is '!',
|
|
33680
|
+
// then use the tagName from the node class used to create it.
|
|
32568
33681
|
if (tagName === '!' || tagName === Coll.tagName) {
|
|
32569
33682
|
coll.tag = Coll.tagName;
|
|
32570
33683
|
return coll;
|
|
32571
33684
|
}
|
|
32572
|
-
|
|
32573
|
-
|
|
33685
|
+
if (tagName)
|
|
33686
|
+
coll.tag = tagName;
|
|
33687
|
+
return coll;
|
|
33688
|
+
}
|
|
33689
|
+
function composeCollection(CN, ctx, token, tagToken, onError) {
|
|
33690
|
+
const tagName = !tagToken
|
|
33691
|
+
? null
|
|
33692
|
+
: ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg));
|
|
33693
|
+
const expType = token.type === 'block-map'
|
|
33694
|
+
? 'map'
|
|
33695
|
+
: token.type === 'block-seq'
|
|
33696
|
+
? 'seq'
|
|
33697
|
+
: token.start.source === '{'
|
|
33698
|
+
? 'map'
|
|
33699
|
+
: 'seq';
|
|
33700
|
+
// shortcut: check if it's a generic YAMLMap or YAMLSeq
|
|
33701
|
+
// before jumping into the custom tag logic.
|
|
33702
|
+
if (!tagToken ||
|
|
33703
|
+
!tagName ||
|
|
33704
|
+
tagName === '!' ||
|
|
33705
|
+
(tagName === YAMLMap.tagName && expType === 'map') ||
|
|
33706
|
+
(tagName === YAMLSeq.tagName && expType === 'seq') ||
|
|
33707
|
+
!expType) {
|
|
33708
|
+
return resolveCollection(CN, ctx, token, onError, tagName);
|
|
33709
|
+
}
|
|
33710
|
+
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
|
|
32574
33711
|
if (!tag) {
|
|
32575
33712
|
const kt = ctx.schema.knownTags[tagName];
|
|
32576
33713
|
if (kt && kt.collection === expType) {
|
|
@@ -32578,12 +33715,17 @@ function composeCollection(CN, ctx, token, tagToken, onError) {
|
|
|
32578
33715
|
tag = kt;
|
|
32579
33716
|
}
|
|
32580
33717
|
else {
|
|
32581
|
-
|
|
32582
|
-
|
|
32583
|
-
|
|
33718
|
+
if (kt?.collection) {
|
|
33719
|
+
onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection}`, true);
|
|
33720
|
+
}
|
|
33721
|
+
else {
|
|
33722
|
+
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, true);
|
|
33723
|
+
}
|
|
33724
|
+
return resolveCollection(CN, ctx, token, onError, tagName);
|
|
32584
33725
|
}
|
|
32585
33726
|
}
|
|
32586
|
-
const
|
|
33727
|
+
const coll = resolveCollection(CN, ctx, token, onError, tagName, tag);
|
|
33728
|
+
const res = tag.resolve?.(coll, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg), ctx.options) ?? coll;
|
|
32587
33729
|
const node = isNode$1(res)
|
|
32588
33730
|
? res
|
|
32589
33731
|
: new Scalar(res);
|
|
@@ -33154,7 +34296,7 @@ function composeNode(ctx, token, props, onError) {
|
|
|
33154
34296
|
node.srcToken = token;
|
|
33155
34297
|
return node;
|
|
33156
34298
|
}
|
|
33157
|
-
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag }, onError) {
|
|
34299
|
+
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) {
|
|
33158
34300
|
const token = {
|
|
33159
34301
|
type: 'scalar',
|
|
33160
34302
|
offset: emptyScalarPosition(offset, before, pos),
|
|
@@ -33169,8 +34311,10 @@ function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anch
|
|
|
33169
34311
|
}
|
|
33170
34312
|
if (spaceBefore)
|
|
33171
34313
|
node.spaceBefore = true;
|
|
33172
|
-
if (comment)
|
|
34314
|
+
if (comment) {
|
|
33173
34315
|
node.comment = comment;
|
|
34316
|
+
node.range[2] = end;
|
|
34317
|
+
}
|
|
33174
34318
|
return node;
|
|
33175
34319
|
}
|
|
33176
34320
|
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
@@ -33210,6 +34354,7 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
|
|
|
33210
34354
|
!props.hasNewline)
|
|
33211
34355
|
onError(props.end, 'MISSING_CHAR', 'Block collection cannot start on same line with directives-end marker');
|
|
33212
34356
|
}
|
|
34357
|
+
// @ts-expect-error If Contents is set, let's trust the user
|
|
33213
34358
|
doc.contents = value
|
|
33214
34359
|
? composeNode(ctx, value, props, onError)
|
|
33215
34360
|
: composeEmptyNode(ctx, props.end, start, null, props, onError);
|
|
@@ -36006,6 +37151,7 @@ const withTypeScriptLoader = (rcFunc) => {
|
|
|
36006
37151
|
try {
|
|
36007
37152
|
// Register TypeScript compiler instance
|
|
36008
37153
|
registerer = __require('ts-node').register({
|
|
37154
|
+
// transpile to cjs even if compilerOptions.module in tsconfig is not Node16/NodeNext.
|
|
36009
37155
|
moduleTypes: { '**/*.cts': 'cjs' }
|
|
36010
37156
|
});
|
|
36011
37157
|
|
|
@@ -37857,11 +39003,12 @@ function cssPostPlugin(config) {
|
|
|
37857
39003
|
? rollupOptionsOutput[0]
|
|
37858
39004
|
: rollupOptionsOutput)?.assetFileNames;
|
|
37859
39005
|
const getCssAssetDirname = (cssAssetName) => {
|
|
39006
|
+
const cssAssetNameDir = path$o.dirname(cssAssetName);
|
|
37860
39007
|
if (!assetFileNames) {
|
|
37861
|
-
return config.build.assetsDir;
|
|
39008
|
+
return path$o.join(config.build.assetsDir, cssAssetNameDir);
|
|
37862
39009
|
}
|
|
37863
39010
|
else if (typeof assetFileNames === 'string') {
|
|
37864
|
-
return path$o.dirname(assetFileNames);
|
|
39011
|
+
return path$o.join(path$o.dirname(assetFileNames), cssAssetNameDir);
|
|
37865
39012
|
}
|
|
37866
39013
|
else {
|
|
37867
39014
|
return path$o.dirname(assetFileNames({
|
|
@@ -37997,7 +39144,7 @@ function cssPostPlugin(config) {
|
|
|
37997
39144
|
const encodedPublicUrls = encodePublicUrlsInCSS(config);
|
|
37998
39145
|
const relative = config.base === './' || config.base === '';
|
|
37999
39146
|
const cssAssetDirname = encodedPublicUrls || relative
|
|
38000
|
-
? getCssAssetDirname(cssAssetName)
|
|
39147
|
+
? slash$1(getCssAssetDirname(cssAssetName))
|
|
38001
39148
|
: undefined;
|
|
38002
39149
|
const toRelative = (filename) => {
|
|
38003
39150
|
// relative base + extracted CSS
|
|
@@ -38030,7 +39177,14 @@ function cssPostPlugin(config) {
|
|
|
38030
39177
|
pureCssChunks.add(chunk);
|
|
38031
39178
|
}
|
|
38032
39179
|
const isEntry = chunk.isEntry && isPureCssChunk;
|
|
38033
|
-
const
|
|
39180
|
+
const cssFullAssetName = ensureFileExt(chunk.name, '.css');
|
|
39181
|
+
// if facadeModuleId doesn't exist or doesn't have a CSS extension,
|
|
39182
|
+
// that means a JS entry file imports a CSS file.
|
|
39183
|
+
// in this case, only use the filename for the CSS chunk name like JS chunks.
|
|
39184
|
+
const cssAssetName = chunk.isEntry &&
|
|
39185
|
+
(!chunk.facadeModuleId || !isCSSRequest(chunk.facadeModuleId))
|
|
39186
|
+
? path$o.basename(cssFullAssetName)
|
|
39187
|
+
: cssFullAssetName;
|
|
38034
39188
|
const originalFilename = getChunkOriginalFileName(chunk, config.root, opts.format);
|
|
38035
39189
|
chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName);
|
|
38036
39190
|
const previousTask = emitTasks[emitTasks.length - 1];
|
|
@@ -38509,8 +39663,8 @@ function createCachedImport(imp) {
|
|
|
38509
39663
|
return cached;
|
|
38510
39664
|
};
|
|
38511
39665
|
}
|
|
38512
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
38513
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
39666
|
+
const importPostcssImport = createCachedImport(() => import('./dep-nbvvoiwS.js').then(function (n) { return n.i; }));
|
|
39667
|
+
const importPostcssModules = createCachedImport(() => import('./dep-GiiHpyM6.js').then(function (n) { return n.i; }));
|
|
38514
39668
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
38515
39669
|
/**
|
|
38516
39670
|
* @experimental
|
|
@@ -58787,25 +59941,37 @@ async function restartServer(server) {
|
|
|
58787
59941
|
},
|
|
58788
59942
|
});
|
|
58789
59943
|
}
|
|
58790
|
-
|
|
58791
|
-
|
|
58792
|
-
|
|
58793
|
-
|
|
58794
|
-
|
|
58795
|
-
|
|
58796
|
-
|
|
58797
|
-
|
|
58798
|
-
|
|
58799
|
-
|
|
58800
|
-
|
|
59944
|
+
// Reinit the server by creating a new instance using the same inlineConfig
|
|
59945
|
+
// This will triger a reload of the config file and re-create the plugins and
|
|
59946
|
+
// middlewares. We then assign all properties of the new server to the existing
|
|
59947
|
+
// server instance and set the user instance to be used in the new server.
|
|
59948
|
+
// This allows us to keep the same server instance for the user.
|
|
59949
|
+
{
|
|
59950
|
+
let newServer = null;
|
|
59951
|
+
try {
|
|
59952
|
+
// delay ws server listen
|
|
59953
|
+
newServer = await _createServer(inlineConfig, { ws: false });
|
|
59954
|
+
}
|
|
59955
|
+
catch (err) {
|
|
59956
|
+
server.config.logger.error(err.message, {
|
|
59957
|
+
timestamp: true,
|
|
59958
|
+
});
|
|
59959
|
+
server.config.logger.error('server restart failed', { timestamp: true });
|
|
59960
|
+
return;
|
|
59961
|
+
}
|
|
59962
|
+
await server.close();
|
|
59963
|
+
// Assign new server props to existing server instance
|
|
59964
|
+
const middlewares = server.middlewares;
|
|
59965
|
+
newServer._configServerPort = server._configServerPort;
|
|
59966
|
+
newServer._currentServerPort = server._currentServerPort;
|
|
59967
|
+
Object.assign(server, newServer);
|
|
59968
|
+
// Keep the same connect instance so app.use(vite.middlewares) works
|
|
59969
|
+
// after a restart in middlewareMode (.route is always '/')
|
|
59970
|
+
middlewares.stack = newServer.middlewares.stack;
|
|
59971
|
+
server.middlewares = middlewares;
|
|
59972
|
+
// Rebind internal server variable so functions reference the user server
|
|
59973
|
+
newServer._setInternalServer(server);
|
|
58801
59974
|
}
|
|
58802
|
-
await server.close();
|
|
58803
|
-
// Assign new server props to existing server instance
|
|
58804
|
-
newServer._configServerPort = server._configServerPort;
|
|
58805
|
-
newServer._currentServerPort = server._currentServerPort;
|
|
58806
|
-
Object.assign(server, newServer);
|
|
58807
|
-
// Rebind internal server variable so functions reference the user server
|
|
58808
|
-
newServer._setInternalServer(server);
|
|
58809
59975
|
const { logger, server: { port, middlewareMode }, } = server.config;
|
|
58810
59976
|
if (!middlewareMode) {
|
|
58811
59977
|
await server.listen(port, true);
|
|
@@ -58816,7 +59982,7 @@ async function restartServer(server) {
|
|
|
58816
59982
|
logger.info('server restarted.', { timestamp: true });
|
|
58817
59983
|
if (shortcutsOptions) {
|
|
58818
59984
|
shortcutsOptions.print = false;
|
|
58819
|
-
bindCLIShortcuts(
|
|
59985
|
+
bindCLIShortcuts(server, shortcutsOptions);
|
|
58820
59986
|
}
|
|
58821
59987
|
}
|
|
58822
59988
|
/**
|
|
@@ -59317,15 +60483,12 @@ function definePlugin(config) {
|
|
|
59317
60483
|
const isBuildLib = isBuild && config.build.lib;
|
|
59318
60484
|
// ignore replace process.env in lib build
|
|
59319
60485
|
const processEnv = {};
|
|
59320
|
-
const processNodeEnv = {};
|
|
59321
60486
|
if (!isBuildLib) {
|
|
59322
60487
|
const nodeEnv = process.env.NODE_ENV || config.mode;
|
|
59323
60488
|
Object.assign(processEnv, {
|
|
59324
60489
|
'process.env': `{}`,
|
|
59325
60490
|
'global.process.env': `{}`,
|
|
59326
60491
|
'globalThis.process.env': `{}`,
|
|
59327
|
-
});
|
|
59328
|
-
Object.assign(processNodeEnv, {
|
|
59329
60492
|
'process.env.NODE_ENV': JSON.stringify(nodeEnv),
|
|
59330
60493
|
'global.process.env.NODE_ENV': JSON.stringify(nodeEnv),
|
|
59331
60494
|
'globalThis.process.env.NODE_ENV': JSON.stringify(nodeEnv),
|
|
@@ -59358,11 +60521,10 @@ function definePlugin(config) {
|
|
|
59358
60521
|
function generatePattern(ssr) {
|
|
59359
60522
|
const replaceProcessEnv = !ssr || config.ssr?.target === 'webworker';
|
|
59360
60523
|
const define = {
|
|
59361
|
-
...(replaceProcessEnv ?
|
|
60524
|
+
...(replaceProcessEnv ? processEnv : {}),
|
|
59362
60525
|
...importMetaKeys,
|
|
59363
60526
|
...userDefine,
|
|
59364
60527
|
...importMetaFallbackKeys,
|
|
59365
|
-
...(replaceProcessEnv ? processEnv : {}),
|
|
59366
60528
|
};
|
|
59367
60529
|
// Additional define fixes based on `ssr` value
|
|
59368
60530
|
if ('import.meta.env.SSR' in define) {
|
|
@@ -61094,10 +62256,11 @@ class VariableDynamicImportError extends Error {}
|
|
|
61094
62256
|
const example = 'For example: import(`./foo/${bar}.js`).';
|
|
61095
62257
|
|
|
61096
62258
|
function sanitizeString(str) {
|
|
62259
|
+
if (str === '') return str;
|
|
61097
62260
|
if (str.includes('*')) {
|
|
61098
62261
|
throw new VariableDynamicImportError('A dynamic import cannot contain * characters.');
|
|
61099
62262
|
}
|
|
61100
|
-
return str;
|
|
62263
|
+
return glob.escapePath(str);
|
|
61101
62264
|
}
|
|
61102
62265
|
|
|
61103
62266
|
function templateLiteralToGlob(node) {
|
|
@@ -61238,7 +62401,9 @@ function parseDynamicImportPattern(strings) {
|
|
|
61238
62401
|
if (!userPatternQuery) {
|
|
61239
62402
|
return null;
|
|
61240
62403
|
}
|
|
61241
|
-
const [userPattern] = userPatternQuery.split(
|
|
62404
|
+
const [userPattern] = userPatternQuery.split(
|
|
62405
|
+
// ? is escaped on posix OS
|
|
62406
|
+
requestQueryMaybeEscapedSplitRE, 2);
|
|
61242
62407
|
const [rawPattern] = filename.split(requestQuerySplitRE, 2);
|
|
61243
62408
|
const as = ['worker', 'url', 'raw'].find((key) => rawQuery && key in rawQuery);
|
|
61244
62409
|
if (as) {
|
|
@@ -61627,6 +62792,20 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
61627
62792
|
_addedImports = null;
|
|
61628
62793
|
constructor(initialPlugin) {
|
|
61629
62794
|
this._activePlugin = initialPlugin || null;
|
|
62795
|
+
this.parse = this.parse.bind(this);
|
|
62796
|
+
this.resolve = this.resolve.bind(this);
|
|
62797
|
+
this.load = this.load.bind(this);
|
|
62798
|
+
this.getModuleInfo = this.getModuleInfo.bind(this);
|
|
62799
|
+
this.getModuleIds = this.getModuleIds.bind(this);
|
|
62800
|
+
this.addWatchFile = this.addWatchFile.bind(this);
|
|
62801
|
+
this.getWatchFiles = this.getWatchFiles.bind(this);
|
|
62802
|
+
this.emitFile = this.emitFile.bind(this);
|
|
62803
|
+
this.setAssetSource = this.setAssetSource.bind(this);
|
|
62804
|
+
this.getFileName = this.getFileName.bind(this);
|
|
62805
|
+
this.warn = this.warn.bind(this);
|
|
62806
|
+
this.error = this.error.bind(this);
|
|
62807
|
+
this.debug = this.debug.bind(this);
|
|
62808
|
+
this.info = this.info.bind(this);
|
|
61630
62809
|
}
|
|
61631
62810
|
parse(code, opts) {
|
|
61632
62811
|
return parseAst(code, opts);
|
|
@@ -62778,7 +63957,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
62778
63957
|
newDepsToLog = [];
|
|
62779
63958
|
}
|
|
62780
63959
|
};
|
|
62781
|
-
let depOptimizationProcessing =
|
|
63960
|
+
let depOptimizationProcessing = promiseWithResolvers();
|
|
62782
63961
|
let depOptimizationProcessingQueue = [];
|
|
62783
63962
|
const resolveEnqueuedProcessingPromises = () => {
|
|
62784
63963
|
// Resolve all the processings (including the ones which were delayed)
|
|
@@ -62873,7 +64052,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
62873
64052
|
depOptimizationProcessingQueue.push(depOptimizationProcessing);
|
|
62874
64053
|
// Create a new promise for the next rerun, discovered missing
|
|
62875
64054
|
// dependencies will be assigned this promise from this point
|
|
62876
|
-
depOptimizationProcessing =
|
|
64055
|
+
depOptimizationProcessing = promiseWithResolvers();
|
|
62877
64056
|
}
|
|
62878
64057
|
function prepareKnownDeps() {
|
|
62879
64058
|
const knownDeps = {};
|
|
@@ -63780,13 +64959,6 @@ async function addManuallyIncludedOptimizeDeps(deps, config, ssr, extra = [], fi
|
|
|
63780
64959
|
}
|
|
63781
64960
|
}
|
|
63782
64961
|
}
|
|
63783
|
-
function newDepOptimizationProcessing() {
|
|
63784
|
-
let resolve;
|
|
63785
|
-
const promise = new Promise((_resolve) => {
|
|
63786
|
-
resolve = _resolve;
|
|
63787
|
-
});
|
|
63788
|
-
return { promise, resolve: resolve };
|
|
63789
|
-
}
|
|
63790
64962
|
// Convert to { id: src }
|
|
63791
64963
|
function depsFromOptimizedDepInfo(depsInfo) {
|
|
63792
64964
|
const obj = {};
|
|
@@ -64153,7 +65325,6 @@ var index = {
|
|
|
64153
65325
|
initDepsOptimizerMetadata: initDepsOptimizerMetadata,
|
|
64154
65326
|
initDevSsrDepsOptimizer: initDevSsrDepsOptimizer,
|
|
64155
65327
|
loadCachedDepOptimizationMetadata: loadCachedDepOptimizationMetadata,
|
|
64156
|
-
newDepOptimizationProcessing: newDepOptimizationProcessing,
|
|
64157
65328
|
optimizeDeps: optimizeDeps,
|
|
64158
65329
|
optimizeServerSsrDeps: optimizeServerSsrDeps,
|
|
64159
65330
|
optimizedDepInfoFromFile: optimizedDepInfoFromFile,
|