@nuxt/kit 3.17.2 → 4.0.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,19 +1,19 @@
1
- import { promises, existsSync, readFileSync, lstatSync } from 'node:fs';
2
1
  import { performance } from 'node:perf_hooks';
3
- import defu$1, { defu } from 'defu';
2
+ import defu$1, { defu, createDefu } from 'defu';
4
3
  import { applyDefaults } from 'untyped';
5
- import { dirname, relative, join, resolve, normalize, isAbsolute, basename, parse } from 'pathe';
6
4
  import { consola } from 'consola';
7
5
  import { AsyncLocalStorage } from 'node:async_hooks';
8
6
  import { getContext, createContext } from 'unctx';
9
7
  import satisfies from 'semver/functions/satisfies.js';
10
8
  import { readPackageJSON, resolvePackageJSON } from 'pkg-types';
11
- import { genSafeVariableName, genDynamicImport, genImport } from 'knitwork';
9
+ import { existsSync, readFileSync, promises, lstatSync } from 'node:fs';
12
10
  import { pathToFileURL, fileURLToPath } from 'node:url';
11
+ import { relative, join, resolve, dirname, normalize, isAbsolute, basename, parse } from 'pathe';
13
12
  import { createJiti } from 'jiti';
14
13
  import { interopDefault, parseNodeModulePath, resolveModuleExportNames } from 'mlly';
15
14
  import { resolveModulePath, resolveModuleURL } from 'exsolve';
16
15
  import { isRelative, withTrailingSlash } from 'ufo';
16
+ import { captureStackTrace } from 'errx';
17
17
  import { glob } from 'tinyglobby';
18
18
  import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
19
19
  import ignore from 'ignore';
@@ -24,7 +24,6 @@ import { snakeCase, pascalCase, kebabCase } from 'scule';
24
24
  import { klona } from 'klona';
25
25
  import { hash } from 'ohash';
26
26
  import { gte } from 'semver';
27
- import { captureStackTrace } from 'errx';
28
27
  import { isAbsolute as isAbsolute$1 } from 'node:path';
29
28
 
30
29
  const logger = consola;
@@ -76,21 +75,6 @@ async function checkNuxtCompatibility(constraints, nuxt = useNuxt()) {
76
75
  });
77
76
  }
78
77
  }
79
- if (isNuxt2(nuxt)) {
80
- const bridgeRequirement = constraints.bridge;
81
- const hasBridge = !!nuxt.options.bridge;
82
- if (bridgeRequirement === true && !hasBridge) {
83
- issues.push({
84
- name: "bridge",
85
- message: "Nuxt bridge is required"
86
- });
87
- } else if (bridgeRequirement === false && hasBridge) {
88
- issues.push({
89
- name: "bridge",
90
- message: "Nuxt bridge is not supported"
91
- });
92
- }
93
- }
94
78
  if (constraints.builder && typeof nuxt.options.builder === "string") {
95
79
  const currentBuilder = builderMap[nuxt.options.builder] || nuxt.options.builder;
96
80
  if (currentBuilder in constraints.builder) {
@@ -150,1968 +134,6 @@ function getNuxtVersion(nuxt = useNuxt()) {
150
134
  return rawVersion.replace(NUXT_VERSION_RE, "");
151
135
  }
152
136
 
153
- /** Detect free variable `global` from Node.js. */
154
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
155
-
156
- /** Detect free variable `self`. */
157
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
158
-
159
- /** Used as a reference to the global object. */
160
- var root = freeGlobal || freeSelf || Function('return this')();
161
-
162
- /** Built-in value references. */
163
- var Symbol$1 = root.Symbol;
164
-
165
- /** Used for built-in method references. */
166
- var objectProto$b = Object.prototype;
167
-
168
- /** Used to check objects for own properties. */
169
- var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
170
-
171
- /**
172
- * Used to resolve the
173
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
174
- * of values.
175
- */
176
- var nativeObjectToString$1 = objectProto$b.toString;
177
-
178
- /** Built-in value references. */
179
- var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
180
-
181
- /**
182
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
183
- *
184
- * @private
185
- * @param {*} value The value to query.
186
- * @returns {string} Returns the raw `toStringTag`.
187
- */
188
- function getRawTag(value) {
189
- var isOwn = hasOwnProperty$9.call(value, symToStringTag$1),
190
- tag = value[symToStringTag$1];
191
-
192
- try {
193
- value[symToStringTag$1] = undefined;
194
- var unmasked = true;
195
- } catch (e) {}
196
-
197
- var result = nativeObjectToString$1.call(value);
198
- if (unmasked) {
199
- if (isOwn) {
200
- value[symToStringTag$1] = tag;
201
- } else {
202
- delete value[symToStringTag$1];
203
- }
204
- }
205
- return result;
206
- }
207
-
208
- /** Used for built-in method references. */
209
- var objectProto$a = Object.prototype;
210
-
211
- /**
212
- * Used to resolve the
213
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
214
- * of values.
215
- */
216
- var nativeObjectToString = objectProto$a.toString;
217
-
218
- /**
219
- * Converts `value` to a string using `Object.prototype.toString`.
220
- *
221
- * @private
222
- * @param {*} value The value to convert.
223
- * @returns {string} Returns the converted string.
224
- */
225
- function objectToString(value) {
226
- return nativeObjectToString.call(value);
227
- }
228
-
229
- /** `Object#toString` result references. */
230
- var nullTag = '[object Null]',
231
- undefinedTag = '[object Undefined]';
232
-
233
- /** Built-in value references. */
234
- var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
235
-
236
- /**
237
- * The base implementation of `getTag` without fallbacks for buggy environments.
238
- *
239
- * @private
240
- * @param {*} value The value to query.
241
- * @returns {string} Returns the `toStringTag`.
242
- */
243
- function baseGetTag(value) {
244
- if (value == null) {
245
- return value === undefined ? undefinedTag : nullTag;
246
- }
247
- return (symToStringTag && symToStringTag in Object(value))
248
- ? getRawTag(value)
249
- : objectToString(value);
250
- }
251
-
252
- /**
253
- * Checks if `value` is object-like. A value is object-like if it's not `null`
254
- * and has a `typeof` result of "object".
255
- *
256
- * @static
257
- * @memberOf _
258
- * @since 4.0.0
259
- * @category Lang
260
- * @param {*} value The value to check.
261
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
262
- * @example
263
- *
264
- * _.isObjectLike({});
265
- * // => true
266
- *
267
- * _.isObjectLike([1, 2, 3]);
268
- * // => true
269
- *
270
- * _.isObjectLike(_.noop);
271
- * // => false
272
- *
273
- * _.isObjectLike(null);
274
- * // => false
275
- */
276
- function isObjectLike(value) {
277
- return value != null && typeof value == 'object';
278
- }
279
-
280
- /** `Object#toString` result references. */
281
- var symbolTag = '[object Symbol]';
282
-
283
- /**
284
- * Checks if `value` is classified as a `Symbol` primitive or object.
285
- *
286
- * @static
287
- * @memberOf _
288
- * @since 4.0.0
289
- * @category Lang
290
- * @param {*} value The value to check.
291
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
292
- * @example
293
- *
294
- * _.isSymbol(Symbol.iterator);
295
- * // => true
296
- *
297
- * _.isSymbol('abc');
298
- * // => false
299
- */
300
- function isSymbol(value) {
301
- return typeof value == 'symbol' ||
302
- (isObjectLike(value) && baseGetTag(value) == symbolTag);
303
- }
304
-
305
- /**
306
- * A specialized version of `_.map` for arrays without support for iteratee
307
- * shorthands.
308
- *
309
- * @private
310
- * @param {Array} [array] The array to iterate over.
311
- * @param {Function} iteratee The function invoked per iteration.
312
- * @returns {Array} Returns the new mapped array.
313
- */
314
- function arrayMap(array, iteratee) {
315
- var index = -1,
316
- length = array == null ? 0 : array.length,
317
- result = Array(length);
318
-
319
- while (++index < length) {
320
- result[index] = iteratee(array[index], index, array);
321
- }
322
- return result;
323
- }
324
-
325
- /**
326
- * Checks if `value` is classified as an `Array` object.
327
- *
328
- * @static
329
- * @memberOf _
330
- * @since 0.1.0
331
- * @category Lang
332
- * @param {*} value The value to check.
333
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
334
- * @example
335
- *
336
- * _.isArray([1, 2, 3]);
337
- * // => true
338
- *
339
- * _.isArray(document.body.children);
340
- * // => false
341
- *
342
- * _.isArray('abc');
343
- * // => false
344
- *
345
- * _.isArray(_.noop);
346
- * // => false
347
- */
348
- var isArray = Array.isArray;
349
-
350
- /** Used to convert symbols to primitives and strings. */
351
- var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
352
- symbolToString = symbolProto ? symbolProto.toString : undefined;
353
-
354
- /**
355
- * The base implementation of `_.toString` which doesn't convert nullish
356
- * values to empty strings.
357
- *
358
- * @private
359
- * @param {*} value The value to process.
360
- * @returns {string} Returns the string.
361
- */
362
- function baseToString(value) {
363
- // Exit early for strings to avoid a performance hit in some environments.
364
- if (typeof value == 'string') {
365
- return value;
366
- }
367
- if (isArray(value)) {
368
- // Recursively convert values (susceptible to call stack limits).
369
- return arrayMap(value, baseToString) + '';
370
- }
371
- if (isSymbol(value)) {
372
- return symbolToString ? symbolToString.call(value) : '';
373
- }
374
- var result = (value + '');
375
- return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;
376
- }
377
-
378
- /**
379
- * Checks if `value` is the
380
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
381
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
382
- *
383
- * @static
384
- * @memberOf _
385
- * @since 0.1.0
386
- * @category Lang
387
- * @param {*} value The value to check.
388
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
389
- * @example
390
- *
391
- * _.isObject({});
392
- * // => true
393
- *
394
- * _.isObject([1, 2, 3]);
395
- * // => true
396
- *
397
- * _.isObject(_.noop);
398
- * // => true
399
- *
400
- * _.isObject(null);
401
- * // => false
402
- */
403
- function isObject(value) {
404
- var type = typeof value;
405
- return value != null && (type == 'object' || type == 'function');
406
- }
407
-
408
- /**
409
- * This method returns the first argument it receives.
410
- *
411
- * @static
412
- * @since 0.1.0
413
- * @memberOf _
414
- * @category Util
415
- * @param {*} value Any value.
416
- * @returns {*} Returns `value`.
417
- * @example
418
- *
419
- * var object = { 'a': 1 };
420
- *
421
- * console.log(_.identity(object) === object);
422
- * // => true
423
- */
424
- function identity(value) {
425
- return value;
426
- }
427
-
428
- /** `Object#toString` result references. */
429
- var asyncTag = '[object AsyncFunction]',
430
- funcTag$1 = '[object Function]',
431
- genTag = '[object GeneratorFunction]',
432
- proxyTag = '[object Proxy]';
433
-
434
- /**
435
- * Checks if `value` is classified as a `Function` object.
436
- *
437
- * @static
438
- * @memberOf _
439
- * @since 0.1.0
440
- * @category Lang
441
- * @param {*} value The value to check.
442
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
443
- * @example
444
- *
445
- * _.isFunction(_);
446
- * // => true
447
- *
448
- * _.isFunction(/abc/);
449
- * // => false
450
- */
451
- function isFunction(value) {
452
- if (!isObject(value)) {
453
- return false;
454
- }
455
- // The use of `Object#toString` avoids issues with the `typeof` operator
456
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
457
- var tag = baseGetTag(value);
458
- return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
459
- }
460
-
461
- /** Used to detect overreaching core-js shims. */
462
- var coreJsData = root['__core-js_shared__'];
463
-
464
- /** Used to detect methods masquerading as native. */
465
- var maskSrcKey = (function() {
466
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
467
- return uid ? ('Symbol(src)_1.' + uid) : '';
468
- }());
469
-
470
- /**
471
- * Checks if `func` has its source masked.
472
- *
473
- * @private
474
- * @param {Function} func The function to check.
475
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
476
- */
477
- function isMasked(func) {
478
- return !!maskSrcKey && (maskSrcKey in func);
479
- }
480
-
481
- /** Used for built-in method references. */
482
- var funcProto$2 = Function.prototype;
483
-
484
- /** Used to resolve the decompiled source of functions. */
485
- var funcToString$2 = funcProto$2.toString;
486
-
487
- /**
488
- * Converts `func` to its source code.
489
- *
490
- * @private
491
- * @param {Function} func The function to convert.
492
- * @returns {string} Returns the source code.
493
- */
494
- function toSource(func) {
495
- if (func != null) {
496
- try {
497
- return funcToString$2.call(func);
498
- } catch (e) {}
499
- try {
500
- return (func + '');
501
- } catch (e) {}
502
- }
503
- return '';
504
- }
505
-
506
- /**
507
- * Used to match `RegExp`
508
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
509
- */
510
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
511
-
512
- /** Used to detect host constructors (Safari). */
513
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
514
-
515
- /** Used for built-in method references. */
516
- var funcProto$1 = Function.prototype,
517
- objectProto$9 = Object.prototype;
518
-
519
- /** Used to resolve the decompiled source of functions. */
520
- var funcToString$1 = funcProto$1.toString;
521
-
522
- /** Used to check objects for own properties. */
523
- var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
524
-
525
- /** Used to detect if a method is native. */
526
- var reIsNative = RegExp('^' +
527
- funcToString$1.call(hasOwnProperty$8).replace(reRegExpChar, '\\$&')
528
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
529
- );
530
-
531
- /**
532
- * The base implementation of `_.isNative` without bad shim checks.
533
- *
534
- * @private
535
- * @param {*} value The value to check.
536
- * @returns {boolean} Returns `true` if `value` is a native function,
537
- * else `false`.
538
- */
539
- function baseIsNative(value) {
540
- if (!isObject(value) || isMasked(value)) {
541
- return false;
542
- }
543
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
544
- return pattern.test(toSource(value));
545
- }
546
-
547
- /**
548
- * Gets the value at `key` of `object`.
549
- *
550
- * @private
551
- * @param {Object} [object] The object to query.
552
- * @param {string} key The key of the property to get.
553
- * @returns {*} Returns the property value.
554
- */
555
- function getValue(object, key) {
556
- return object == null ? undefined : object[key];
557
- }
558
-
559
- /**
560
- * Gets the native function at `key` of `object`.
561
- *
562
- * @private
563
- * @param {Object} object The object to query.
564
- * @param {string} key The key of the method to get.
565
- * @returns {*} Returns the function if it's native, else `undefined`.
566
- */
567
- function getNative(object, key) {
568
- var value = getValue(object, key);
569
- return baseIsNative(value) ? value : undefined;
570
- }
571
-
572
- /**
573
- * A faster alternative to `Function#apply`, this function invokes `func`
574
- * with the `this` binding of `thisArg` and the arguments of `args`.
575
- *
576
- * @private
577
- * @param {Function} func The function to invoke.
578
- * @param {*} thisArg The `this` binding of `func`.
579
- * @param {Array} args The arguments to invoke `func` with.
580
- * @returns {*} Returns the result of `func`.
581
- */
582
- function apply(func, thisArg, args) {
583
- switch (args.length) {
584
- case 0: return func.call(thisArg);
585
- case 1: return func.call(thisArg, args[0]);
586
- case 2: return func.call(thisArg, args[0], args[1]);
587
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
588
- }
589
- return func.apply(thisArg, args);
590
- }
591
-
592
- /** Used to detect hot functions by number of calls within a span of milliseconds. */
593
- var HOT_COUNT = 800,
594
- HOT_SPAN = 16;
595
-
596
- /* Built-in method references for those with the same name as other `lodash` methods. */
597
- var nativeNow = Date.now;
598
-
599
- /**
600
- * Creates a function that'll short out and invoke `identity` instead
601
- * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
602
- * milliseconds.
603
- *
604
- * @private
605
- * @param {Function} func The function to restrict.
606
- * @returns {Function} Returns the new shortable function.
607
- */
608
- function shortOut(func) {
609
- var count = 0,
610
- lastCalled = 0;
611
-
612
- return function() {
613
- var stamp = nativeNow(),
614
- remaining = HOT_SPAN - (stamp - lastCalled);
615
-
616
- lastCalled = stamp;
617
- if (remaining > 0) {
618
- if (++count >= HOT_COUNT) {
619
- return arguments[0];
620
- }
621
- } else {
622
- count = 0;
623
- }
624
- return func.apply(undefined, arguments);
625
- };
626
- }
627
-
628
- /**
629
- * Creates a function that returns `value`.
630
- *
631
- * @static
632
- * @memberOf _
633
- * @since 2.4.0
634
- * @category Util
635
- * @param {*} value The value to return from the new function.
636
- * @returns {Function} Returns the new constant function.
637
- * @example
638
- *
639
- * var objects = _.times(2, _.constant({ 'a': 1 }));
640
- *
641
- * console.log(objects);
642
- * // => [{ 'a': 1 }, { 'a': 1 }]
643
- *
644
- * console.log(objects[0] === objects[1]);
645
- * // => true
646
- */
647
- function constant(value) {
648
- return function() {
649
- return value;
650
- };
651
- }
652
-
653
- var defineProperty = (function() {
654
- try {
655
- var func = getNative(Object, 'defineProperty');
656
- func({}, '', {});
657
- return func;
658
- } catch (e) {}
659
- }());
660
-
661
- /**
662
- * The base implementation of `setToString` without support for hot loop shorting.
663
- *
664
- * @private
665
- * @param {Function} func The function to modify.
666
- * @param {Function} string The `toString` result.
667
- * @returns {Function} Returns `func`.
668
- */
669
- var baseSetToString = !defineProperty ? identity : function(func, string) {
670
- return defineProperty(func, 'toString', {
671
- 'configurable': true,
672
- 'enumerable': false,
673
- 'value': constant(string),
674
- 'writable': true
675
- });
676
- };
677
-
678
- /**
679
- * Sets the `toString` method of `func` to return `string`.
680
- *
681
- * @private
682
- * @param {Function} func The function to modify.
683
- * @param {Function} string The `toString` result.
684
- * @returns {Function} Returns `func`.
685
- */
686
- var setToString = shortOut(baseSetToString);
687
-
688
- /** Used as references for various `Number` constants. */
689
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
690
-
691
- /** Used to detect unsigned integer values. */
692
- var reIsUint = /^(?:0|[1-9]\d*)$/;
693
-
694
- /**
695
- * Checks if `value` is a valid array-like index.
696
- *
697
- * @private
698
- * @param {*} value The value to check.
699
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
700
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
701
- */
702
- function isIndex(value, length) {
703
- var type = typeof value;
704
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
705
-
706
- return !!length &&
707
- (type == 'number' ||
708
- (type != 'symbol' && reIsUint.test(value))) &&
709
- (value > -1 && value % 1 == 0 && value < length);
710
- }
711
-
712
- /**
713
- * The base implementation of `assignValue` and `assignMergeValue` without
714
- * value checks.
715
- *
716
- * @private
717
- * @param {Object} object The object to modify.
718
- * @param {string} key The key of the property to assign.
719
- * @param {*} value The value to assign.
720
- */
721
- function baseAssignValue(object, key, value) {
722
- if (key == '__proto__' && defineProperty) {
723
- defineProperty(object, key, {
724
- 'configurable': true,
725
- 'enumerable': true,
726
- 'value': value,
727
- 'writable': true
728
- });
729
- } else {
730
- object[key] = value;
731
- }
732
- }
733
-
734
- /**
735
- * Performs a
736
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
737
- * comparison between two values to determine if they are equivalent.
738
- *
739
- * @static
740
- * @memberOf _
741
- * @since 4.0.0
742
- * @category Lang
743
- * @param {*} value The value to compare.
744
- * @param {*} other The other value to compare.
745
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
746
- * @example
747
- *
748
- * var object = { 'a': 1 };
749
- * var other = { 'a': 1 };
750
- *
751
- * _.eq(object, object);
752
- * // => true
753
- *
754
- * _.eq(object, other);
755
- * // => false
756
- *
757
- * _.eq('a', 'a');
758
- * // => true
759
- *
760
- * _.eq('a', Object('a'));
761
- * // => false
762
- *
763
- * _.eq(NaN, NaN);
764
- * // => true
765
- */
766
- function eq(value, other) {
767
- return value === other || (value !== value && other !== other);
768
- }
769
-
770
- /** Used for built-in method references. */
771
- var objectProto$8 = Object.prototype;
772
-
773
- /** Used to check objects for own properties. */
774
- var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
775
-
776
- /**
777
- * Assigns `value` to `key` of `object` if the existing value is not equivalent
778
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
779
- * for equality comparisons.
780
- *
781
- * @private
782
- * @param {Object} object The object to modify.
783
- * @param {string} key The key of the property to assign.
784
- * @param {*} value The value to assign.
785
- */
786
- function assignValue(object, key, value) {
787
- var objValue = object[key];
788
- if (!(hasOwnProperty$7.call(object, key) && eq(objValue, value)) ||
789
- (value === undefined && !(key in object))) {
790
- baseAssignValue(object, key, value);
791
- }
792
- }
793
-
794
- /**
795
- * Copies properties of `source` to `object`.
796
- *
797
- * @private
798
- * @param {Object} source The object to copy properties from.
799
- * @param {Array} props The property identifiers to copy.
800
- * @param {Object} [object={}] The object to copy properties to.
801
- * @param {Function} [customizer] The function to customize copied values.
802
- * @returns {Object} Returns `object`.
803
- */
804
- function copyObject(source, props, object, customizer) {
805
- var isNew = !object;
806
- object || (object = {});
807
-
808
- var index = -1,
809
- length = props.length;
810
-
811
- while (++index < length) {
812
- var key = props[index];
813
-
814
- var newValue = customizer
815
- ? customizer(object[key], source[key], key, object, source)
816
- : undefined;
817
-
818
- if (newValue === undefined) {
819
- newValue = source[key];
820
- }
821
- if (isNew) {
822
- baseAssignValue(object, key, newValue);
823
- } else {
824
- assignValue(object, key, newValue);
825
- }
826
- }
827
- return object;
828
- }
829
-
830
- /* Built-in method references for those with the same name as other `lodash` methods. */
831
- var nativeMax = Math.max;
832
-
833
- /**
834
- * A specialized version of `baseRest` which transforms the rest array.
835
- *
836
- * @private
837
- * @param {Function} func The function to apply a rest parameter to.
838
- * @param {number} [start=func.length-1] The start position of the rest parameter.
839
- * @param {Function} transform The rest array transform.
840
- * @returns {Function} Returns the new function.
841
- */
842
- function overRest(func, start, transform) {
843
- start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
844
- return function() {
845
- var args = arguments,
846
- index = -1,
847
- length = nativeMax(args.length - start, 0),
848
- array = Array(length);
849
-
850
- while (++index < length) {
851
- array[index] = args[start + index];
852
- }
853
- index = -1;
854
- var otherArgs = Array(start + 1);
855
- while (++index < start) {
856
- otherArgs[index] = args[index];
857
- }
858
- otherArgs[start] = transform(array);
859
- return apply(func, this, otherArgs);
860
- };
861
- }
862
-
863
- /**
864
- * The base implementation of `_.rest` which doesn't validate or coerce arguments.
865
- *
866
- * @private
867
- * @param {Function} func The function to apply a rest parameter to.
868
- * @param {number} [start=func.length-1] The start position of the rest parameter.
869
- * @returns {Function} Returns the new function.
870
- */
871
- function baseRest(func, start) {
872
- return setToString(overRest(func, start, identity), func + '');
873
- }
874
-
875
- /** Used as references for various `Number` constants. */
876
- var MAX_SAFE_INTEGER = 9007199254740991;
877
-
878
- /**
879
- * Checks if `value` is a valid array-like length.
880
- *
881
- * **Note:** This method is loosely based on
882
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
883
- *
884
- * @static
885
- * @memberOf _
886
- * @since 4.0.0
887
- * @category Lang
888
- * @param {*} value The value to check.
889
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
890
- * @example
891
- *
892
- * _.isLength(3);
893
- * // => true
894
- *
895
- * _.isLength(Number.MIN_VALUE);
896
- * // => false
897
- *
898
- * _.isLength(Infinity);
899
- * // => false
900
- *
901
- * _.isLength('3');
902
- * // => false
903
- */
904
- function isLength(value) {
905
- return typeof value == 'number' &&
906
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
907
- }
908
-
909
- /**
910
- * Checks if `value` is array-like. A value is considered array-like if it's
911
- * not a function and has a `value.length` that's an integer greater than or
912
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
913
- *
914
- * @static
915
- * @memberOf _
916
- * @since 4.0.0
917
- * @category Lang
918
- * @param {*} value The value to check.
919
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
920
- * @example
921
- *
922
- * _.isArrayLike([1, 2, 3]);
923
- * // => true
924
- *
925
- * _.isArrayLike(document.body.children);
926
- * // => true
927
- *
928
- * _.isArrayLike('abc');
929
- * // => true
930
- *
931
- * _.isArrayLike(_.noop);
932
- * // => false
933
- */
934
- function isArrayLike(value) {
935
- return value != null && isLength(value.length) && !isFunction(value);
936
- }
937
-
938
- /**
939
- * Checks if the given arguments are from an iteratee call.
940
- *
941
- * @private
942
- * @param {*} value The potential iteratee value argument.
943
- * @param {*} index The potential iteratee index or key argument.
944
- * @param {*} object The potential iteratee object argument.
945
- * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
946
- * else `false`.
947
- */
948
- function isIterateeCall(value, index, object) {
949
- if (!isObject(object)) {
950
- return false;
951
- }
952
- var type = typeof index;
953
- if (type == 'number'
954
- ? (isArrayLike(object) && isIndex(index, object.length))
955
- : (type == 'string' && index in object)
956
- ) {
957
- return eq(object[index], value);
958
- }
959
- return false;
960
- }
961
-
962
- /**
963
- * Creates a function like `_.assign`.
964
- *
965
- * @private
966
- * @param {Function} assigner The function to assign values.
967
- * @returns {Function} Returns the new assigner function.
968
- */
969
- function createAssigner(assigner) {
970
- return baseRest(function(object, sources) {
971
- var index = -1,
972
- length = sources.length,
973
- customizer = length > 1 ? sources[length - 1] : undefined,
974
- guard = length > 2 ? sources[2] : undefined;
975
-
976
- customizer = (assigner.length > 3 && typeof customizer == 'function')
977
- ? (length--, customizer)
978
- : undefined;
979
-
980
- if (guard && isIterateeCall(sources[0], sources[1], guard)) {
981
- customizer = length < 3 ? undefined : customizer;
982
- length = 1;
983
- }
984
- object = Object(object);
985
- while (++index < length) {
986
- var source = sources[index];
987
- if (source) {
988
- assigner(object, source, index, customizer);
989
- }
990
- }
991
- return object;
992
- });
993
- }
994
-
995
- /** Used for built-in method references. */
996
- var objectProto$7 = Object.prototype;
997
-
998
- /**
999
- * Checks if `value` is likely a prototype object.
1000
- *
1001
- * @private
1002
- * @param {*} value The value to check.
1003
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1004
- */
1005
- function isPrototype(value) {
1006
- var Ctor = value && value.constructor,
1007
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$7;
1008
-
1009
- return value === proto;
1010
- }
1011
-
1012
- /**
1013
- * The base implementation of `_.times` without support for iteratee shorthands
1014
- * or max array length checks.
1015
- *
1016
- * @private
1017
- * @param {number} n The number of times to invoke `iteratee`.
1018
- * @param {Function} iteratee The function invoked per iteration.
1019
- * @returns {Array} Returns the array of results.
1020
- */
1021
- function baseTimes(n, iteratee) {
1022
- var index = -1,
1023
- result = Array(n);
1024
-
1025
- while (++index < n) {
1026
- result[index] = iteratee(index);
1027
- }
1028
- return result;
1029
- }
1030
-
1031
- /** `Object#toString` result references. */
1032
- var argsTag$1 = '[object Arguments]';
1033
-
1034
- /**
1035
- * The base implementation of `_.isArguments`.
1036
- *
1037
- * @private
1038
- * @param {*} value The value to check.
1039
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1040
- */
1041
- function baseIsArguments(value) {
1042
- return isObjectLike(value) && baseGetTag(value) == argsTag$1;
1043
- }
1044
-
1045
- /** Used for built-in method references. */
1046
- var objectProto$6 = Object.prototype;
1047
-
1048
- /** Used to check objects for own properties. */
1049
- var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
1050
-
1051
- /** Built-in value references. */
1052
- var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
1053
-
1054
- /**
1055
- * Checks if `value` is likely an `arguments` object.
1056
- *
1057
- * @static
1058
- * @memberOf _
1059
- * @since 0.1.0
1060
- * @category Lang
1061
- * @param {*} value The value to check.
1062
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1063
- * else `false`.
1064
- * @example
1065
- *
1066
- * _.isArguments(function() { return arguments; }());
1067
- * // => true
1068
- *
1069
- * _.isArguments([1, 2, 3]);
1070
- * // => false
1071
- */
1072
- var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1073
- return isObjectLike(value) && hasOwnProperty$6.call(value, 'callee') &&
1074
- !propertyIsEnumerable.call(value, 'callee');
1075
- };
1076
-
1077
- /**
1078
- * This method returns `false`.
1079
- *
1080
- * @static
1081
- * @memberOf _
1082
- * @since 4.13.0
1083
- * @category Util
1084
- * @returns {boolean} Returns `false`.
1085
- * @example
1086
- *
1087
- * _.times(2, _.stubFalse);
1088
- * // => [false, false]
1089
- */
1090
- function stubFalse() {
1091
- return false;
1092
- }
1093
-
1094
- /** Detect free variable `exports`. */
1095
- var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
1096
-
1097
- /** Detect free variable `module`. */
1098
- var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
1099
-
1100
- /** Detect the popular CommonJS extension `module.exports`. */
1101
- var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
1102
-
1103
- /** Built-in value references. */
1104
- var Buffer = moduleExports$1 ? root.Buffer : undefined;
1105
-
1106
- /* Built-in method references for those with the same name as other `lodash` methods. */
1107
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
1108
-
1109
- /**
1110
- * Checks if `value` is a buffer.
1111
- *
1112
- * @static
1113
- * @memberOf _
1114
- * @since 4.3.0
1115
- * @category Lang
1116
- * @param {*} value The value to check.
1117
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1118
- * @example
1119
- *
1120
- * _.isBuffer(new Buffer(2));
1121
- * // => true
1122
- *
1123
- * _.isBuffer(new Uint8Array(2));
1124
- * // => false
1125
- */
1126
- var isBuffer = nativeIsBuffer || stubFalse;
1127
-
1128
- /** `Object#toString` result references. */
1129
- var argsTag = '[object Arguments]',
1130
- arrayTag = '[object Array]',
1131
- boolTag = '[object Boolean]',
1132
- dateTag = '[object Date]',
1133
- errorTag$1 = '[object Error]',
1134
- funcTag = '[object Function]',
1135
- mapTag = '[object Map]',
1136
- numberTag = '[object Number]',
1137
- objectTag$1 = '[object Object]',
1138
- regexpTag = '[object RegExp]',
1139
- setTag = '[object Set]',
1140
- stringTag = '[object String]',
1141
- weakMapTag = '[object WeakMap]';
1142
-
1143
- var arrayBufferTag = '[object ArrayBuffer]',
1144
- dataViewTag = '[object DataView]',
1145
- float32Tag = '[object Float32Array]',
1146
- float64Tag = '[object Float64Array]',
1147
- int8Tag = '[object Int8Array]',
1148
- int16Tag = '[object Int16Array]',
1149
- int32Tag = '[object Int32Array]',
1150
- uint8Tag = '[object Uint8Array]',
1151
- uint8ClampedTag = '[object Uint8ClampedArray]',
1152
- uint16Tag = '[object Uint16Array]',
1153
- uint32Tag = '[object Uint32Array]';
1154
-
1155
- /** Used to identify `toStringTag` values of typed arrays. */
1156
- var typedArrayTags = {};
1157
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
1158
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
1159
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
1160
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
1161
- typedArrayTags[uint32Tag] = true;
1162
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
1163
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
1164
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
1165
- typedArrayTags[errorTag$1] = typedArrayTags[funcTag] =
1166
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
1167
- typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
1168
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
1169
- typedArrayTags[weakMapTag] = false;
1170
-
1171
- /**
1172
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
1173
- *
1174
- * @private
1175
- * @param {*} value The value to check.
1176
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1177
- */
1178
- function baseIsTypedArray(value) {
1179
- return isObjectLike(value) &&
1180
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
1181
- }
1182
-
1183
- /**
1184
- * The base implementation of `_.unary` without support for storing metadata.
1185
- *
1186
- * @private
1187
- * @param {Function} func The function to cap arguments for.
1188
- * @returns {Function} Returns the new capped function.
1189
- */
1190
- function baseUnary(func) {
1191
- return function(value) {
1192
- return func(value);
1193
- };
1194
- }
1195
-
1196
- /** Detect free variable `exports`. */
1197
- var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
1198
-
1199
- /** Detect free variable `module`. */
1200
- var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
1201
-
1202
- /** Detect the popular CommonJS extension `module.exports`. */
1203
- var moduleExports = freeModule && freeModule.exports === freeExports;
1204
-
1205
- /** Detect free variable `process` from Node.js. */
1206
- var freeProcess = moduleExports && freeGlobal.process;
1207
-
1208
- /** Used to access faster Node.js helpers. */
1209
- var nodeUtil = (function() {
1210
- try {
1211
- // Use `util.types` for Node.js 10+.
1212
- var types = freeModule && freeModule.require && freeModule.require('util').types;
1213
-
1214
- if (types) {
1215
- return types;
1216
- }
1217
-
1218
- // Legacy `process.binding('util')` for Node.js < 10.
1219
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
1220
- } catch (e) {}
1221
- }());
1222
-
1223
- /* Node.js helper references. */
1224
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1225
-
1226
- /**
1227
- * Checks if `value` is classified as a typed array.
1228
- *
1229
- * @static
1230
- * @memberOf _
1231
- * @since 3.0.0
1232
- * @category Lang
1233
- * @param {*} value The value to check.
1234
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1235
- * @example
1236
- *
1237
- * _.isTypedArray(new Uint8Array);
1238
- * // => true
1239
- *
1240
- * _.isTypedArray([]);
1241
- * // => false
1242
- */
1243
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1244
-
1245
- /** Used for built-in method references. */
1246
- var objectProto$5 = Object.prototype;
1247
-
1248
- /** Used to check objects for own properties. */
1249
- var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
1250
-
1251
- /**
1252
- * Creates an array of the enumerable property names of the array-like `value`.
1253
- *
1254
- * @private
1255
- * @param {*} value The value to query.
1256
- * @param {boolean} inherited Specify returning inherited property names.
1257
- * @returns {Array} Returns the array of property names.
1258
- */
1259
- function arrayLikeKeys(value, inherited) {
1260
- var isArr = isArray(value),
1261
- isArg = !isArr && isArguments(value),
1262
- isBuff = !isArr && !isArg && isBuffer(value),
1263
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
1264
- skipIndexes = isArr || isArg || isBuff || isType,
1265
- result = skipIndexes ? baseTimes(value.length, String) : [],
1266
- length = result.length;
1267
-
1268
- for (var key in value) {
1269
- if ((inherited || hasOwnProperty$5.call(value, key)) &&
1270
- !(skipIndexes && (
1271
- // Safari 9 has enumerable `arguments.length` in strict mode.
1272
- key == 'length' ||
1273
- // Node.js 0.10 has enumerable non-index properties on buffers.
1274
- (isBuff && (key == 'offset' || key == 'parent')) ||
1275
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
1276
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
1277
- // Skip index properties.
1278
- isIndex(key, length)
1279
- ))) {
1280
- result.push(key);
1281
- }
1282
- }
1283
- return result;
1284
- }
1285
-
1286
- /**
1287
- * Creates a unary function that invokes `func` with its argument transformed.
1288
- *
1289
- * @private
1290
- * @param {Function} func The function to wrap.
1291
- * @param {Function} transform The argument transform.
1292
- * @returns {Function} Returns the new function.
1293
- */
1294
- function overArg(func, transform) {
1295
- return function(arg) {
1296
- return func(transform(arg));
1297
- };
1298
- }
1299
-
1300
- /* Built-in method references for those with the same name as other `lodash` methods. */
1301
- var nativeKeys = overArg(Object.keys, Object);
1302
-
1303
- /** Used for built-in method references. */
1304
- var objectProto$4 = Object.prototype;
1305
-
1306
- /** Used to check objects for own properties. */
1307
- var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
1308
-
1309
- /**
1310
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1311
- *
1312
- * @private
1313
- * @param {Object} object The object to query.
1314
- * @returns {Array} Returns the array of property names.
1315
- */
1316
- function baseKeys(object) {
1317
- if (!isPrototype(object)) {
1318
- return nativeKeys(object);
1319
- }
1320
- var result = [];
1321
- for (var key in Object(object)) {
1322
- if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
1323
- result.push(key);
1324
- }
1325
- }
1326
- return result;
1327
- }
1328
-
1329
- /**
1330
- * Creates an array of the own enumerable property names of `object`.
1331
- *
1332
- * **Note:** Non-object values are coerced to objects. See the
1333
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1334
- * for more details.
1335
- *
1336
- * @static
1337
- * @since 0.1.0
1338
- * @memberOf _
1339
- * @category Object
1340
- * @param {Object} object The object to query.
1341
- * @returns {Array} Returns the array of property names.
1342
- * @example
1343
- *
1344
- * function Foo() {
1345
- * this.a = 1;
1346
- * this.b = 2;
1347
- * }
1348
- *
1349
- * Foo.prototype.c = 3;
1350
- *
1351
- * _.keys(new Foo);
1352
- * // => ['a', 'b'] (iteration order is not guaranteed)
1353
- *
1354
- * _.keys('hi');
1355
- * // => ['0', '1']
1356
- */
1357
- function keys(object) {
1358
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1359
- }
1360
-
1361
- /**
1362
- * This function is like
1363
- * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1364
- * except that it includes inherited enumerable properties.
1365
- *
1366
- * @private
1367
- * @param {Object} object The object to query.
1368
- * @returns {Array} Returns the array of property names.
1369
- */
1370
- function nativeKeysIn(object) {
1371
- var result = [];
1372
- if (object != null) {
1373
- for (var key in Object(object)) {
1374
- result.push(key);
1375
- }
1376
- }
1377
- return result;
1378
- }
1379
-
1380
- /** Used for built-in method references. */
1381
- var objectProto$3 = Object.prototype;
1382
-
1383
- /** Used to check objects for own properties. */
1384
- var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
1385
-
1386
- /**
1387
- * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
1388
- *
1389
- * @private
1390
- * @param {Object} object The object to query.
1391
- * @returns {Array} Returns the array of property names.
1392
- */
1393
- function baseKeysIn(object) {
1394
- if (!isObject(object)) {
1395
- return nativeKeysIn(object);
1396
- }
1397
- var isProto = isPrototype(object),
1398
- result = [];
1399
-
1400
- for (var key in object) {
1401
- if (!(key == 'constructor' && (isProto || !hasOwnProperty$3.call(object, key)))) {
1402
- result.push(key);
1403
- }
1404
- }
1405
- return result;
1406
- }
1407
-
1408
- /**
1409
- * Creates an array of the own and inherited enumerable property names of `object`.
1410
- *
1411
- * **Note:** Non-object values are coerced to objects.
1412
- *
1413
- * @static
1414
- * @memberOf _
1415
- * @since 3.0.0
1416
- * @category Object
1417
- * @param {Object} object The object to query.
1418
- * @returns {Array} Returns the array of property names.
1419
- * @example
1420
- *
1421
- * function Foo() {
1422
- * this.a = 1;
1423
- * this.b = 2;
1424
- * }
1425
- *
1426
- * Foo.prototype.c = 3;
1427
- *
1428
- * _.keysIn(new Foo);
1429
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
1430
- */
1431
- function keysIn(object) {
1432
- return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
1433
- }
1434
-
1435
- /**
1436
- * This method is like `_.assignIn` except that it accepts `customizer`
1437
- * which is invoked to produce the assigned values. If `customizer` returns
1438
- * `undefined`, assignment is handled by the method instead. The `customizer`
1439
- * is invoked with five arguments: (objValue, srcValue, key, object, source).
1440
- *
1441
- * **Note:** This method mutates `object`.
1442
- *
1443
- * @static
1444
- * @memberOf _
1445
- * @since 4.0.0
1446
- * @alias extendWith
1447
- * @category Object
1448
- * @param {Object} object The destination object.
1449
- * @param {...Object} sources The source objects.
1450
- * @param {Function} [customizer] The function to customize assigned values.
1451
- * @returns {Object} Returns `object`.
1452
- * @see _.assignWith
1453
- * @example
1454
- *
1455
- * function customizer(objValue, srcValue) {
1456
- * return _.isUndefined(objValue) ? srcValue : objValue;
1457
- * }
1458
- *
1459
- * var defaults = _.partialRight(_.assignInWith, customizer);
1460
- *
1461
- * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
1462
- * // => { 'a': 1, 'b': 2 }
1463
- */
1464
- var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
1465
- copyObject(source, keysIn(source), object, customizer);
1466
- });
1467
-
1468
- /**
1469
- * Converts `value` to a string. An empty string is returned for `null`
1470
- * and `undefined` values. The sign of `-0` is preserved.
1471
- *
1472
- * @static
1473
- * @memberOf _
1474
- * @since 4.0.0
1475
- * @category Lang
1476
- * @param {*} value The value to convert.
1477
- * @returns {string} Returns the converted string.
1478
- * @example
1479
- *
1480
- * _.toString(null);
1481
- * // => ''
1482
- *
1483
- * _.toString(-0);
1484
- * // => '-0'
1485
- *
1486
- * _.toString([1, 2, 3]);
1487
- * // => '1,2,3'
1488
- */
1489
- function toString(value) {
1490
- return value == null ? '' : baseToString(value);
1491
- }
1492
-
1493
- /** Built-in value references. */
1494
- var getPrototype = overArg(Object.getPrototypeOf, Object);
1495
-
1496
- /** `Object#toString` result references. */
1497
- var objectTag = '[object Object]';
1498
-
1499
- /** Used for built-in method references. */
1500
- var funcProto = Function.prototype,
1501
- objectProto$2 = Object.prototype;
1502
-
1503
- /** Used to resolve the decompiled source of functions. */
1504
- var funcToString = funcProto.toString;
1505
-
1506
- /** Used to check objects for own properties. */
1507
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
1508
-
1509
- /** Used to infer the `Object` constructor. */
1510
- var objectCtorString = funcToString.call(Object);
1511
-
1512
- /**
1513
- * Checks if `value` is a plain object, that is, an object created by the
1514
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
1515
- *
1516
- * @static
1517
- * @memberOf _
1518
- * @since 0.8.0
1519
- * @category Lang
1520
- * @param {*} value The value to check.
1521
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
1522
- * @example
1523
- *
1524
- * function Foo() {
1525
- * this.a = 1;
1526
- * }
1527
- *
1528
- * _.isPlainObject(new Foo);
1529
- * // => false
1530
- *
1531
- * _.isPlainObject([1, 2, 3]);
1532
- * // => false
1533
- *
1534
- * _.isPlainObject({ 'x': 0, 'y': 0 });
1535
- * // => true
1536
- *
1537
- * _.isPlainObject(Object.create(null));
1538
- * // => true
1539
- */
1540
- function isPlainObject(value) {
1541
- if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
1542
- return false;
1543
- }
1544
- var proto = getPrototype(value);
1545
- if (proto === null) {
1546
- return true;
1547
- }
1548
- var Ctor = hasOwnProperty$2.call(proto, 'constructor') && proto.constructor;
1549
- return typeof Ctor == 'function' && Ctor instanceof Ctor &&
1550
- funcToString.call(Ctor) == objectCtorString;
1551
- }
1552
-
1553
- /** `Object#toString` result references. */
1554
- var domExcTag = '[object DOMException]',
1555
- errorTag = '[object Error]';
1556
-
1557
- /**
1558
- * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
1559
- * `SyntaxError`, `TypeError`, or `URIError` object.
1560
- *
1561
- * @static
1562
- * @memberOf _
1563
- * @since 3.0.0
1564
- * @category Lang
1565
- * @param {*} value The value to check.
1566
- * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
1567
- * @example
1568
- *
1569
- * _.isError(new Error);
1570
- * // => true
1571
- *
1572
- * _.isError(Error);
1573
- * // => false
1574
- */
1575
- function isError(value) {
1576
- if (!isObjectLike(value)) {
1577
- return false;
1578
- }
1579
- var tag = baseGetTag(value);
1580
- return tag == errorTag || tag == domExcTag ||
1581
- (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
1582
- }
1583
-
1584
- /**
1585
- * Attempts to invoke `func`, returning either the result or the caught error
1586
- * object. Any additional arguments are provided to `func` when it's invoked.
1587
- *
1588
- * @static
1589
- * @memberOf _
1590
- * @since 3.0.0
1591
- * @category Util
1592
- * @param {Function} func The function to attempt.
1593
- * @param {...*} [args] The arguments to invoke `func` with.
1594
- * @returns {*} Returns the `func` result or error object.
1595
- * @example
1596
- *
1597
- * // Avoid throwing errors for invalid selectors.
1598
- * var elements = _.attempt(function(selector) {
1599
- * return document.querySelectorAll(selector);
1600
- * }, '>_>');
1601
- *
1602
- * if (_.isError(elements)) {
1603
- * elements = [];
1604
- * }
1605
- */
1606
- var attempt = baseRest(function(func, args) {
1607
- try {
1608
- return apply(func, undefined, args);
1609
- } catch (e) {
1610
- return isError(e) ? e : new Error(e);
1611
- }
1612
- });
1613
-
1614
- /**
1615
- * The base implementation of `_.propertyOf` without support for deep paths.
1616
- *
1617
- * @private
1618
- * @param {Object} object The object to query.
1619
- * @returns {Function} Returns the new accessor function.
1620
- */
1621
- function basePropertyOf(object) {
1622
- return function(key) {
1623
- return object == null ? undefined : object[key];
1624
- };
1625
- }
1626
-
1627
- /** Used to map characters to HTML entities. */
1628
- var htmlEscapes = {
1629
- '&': '&amp;',
1630
- '<': '&lt;',
1631
- '>': '&gt;',
1632
- '"': '&quot;',
1633
- "'": '&#39;'
1634
- };
1635
-
1636
- /**
1637
- * Used by `_.escape` to convert characters to HTML entities.
1638
- *
1639
- * @private
1640
- * @param {string} chr The matched character to escape.
1641
- * @returns {string} Returns the escaped character.
1642
- */
1643
- var escapeHtmlChar = basePropertyOf(htmlEscapes);
1644
-
1645
- /** Used to match HTML entities and HTML characters. */
1646
- var reUnescapedHtml = /[&<>"']/g,
1647
- reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
1648
-
1649
- /**
1650
- * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
1651
- * corresponding HTML entities.
1652
- *
1653
- * **Note:** No other characters are escaped. To escape additional
1654
- * characters use a third-party library like [_he_](https://mths.be/he).
1655
- *
1656
- * Though the ">" character is escaped for symmetry, characters like
1657
- * ">" and "/" don't need escaping in HTML and have no special meaning
1658
- * unless they're part of a tag or unquoted attribute value. See
1659
- * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
1660
- * (under "semi-related fun fact") for more details.
1661
- *
1662
- * When working with HTML you should always
1663
- * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
1664
- * XSS vectors.
1665
- *
1666
- * @static
1667
- * @since 0.1.0
1668
- * @memberOf _
1669
- * @category String
1670
- * @param {string} [string=''] The string to escape.
1671
- * @returns {string} Returns the escaped string.
1672
- * @example
1673
- *
1674
- * _.escape('fred, barney, & pebbles');
1675
- * // => 'fred, barney, &amp; pebbles'
1676
- */
1677
- function escape(string) {
1678
- string = toString(string);
1679
- return (string && reHasUnescapedHtml.test(string))
1680
- ? string.replace(reUnescapedHtml, escapeHtmlChar)
1681
- : string;
1682
- }
1683
-
1684
- /**
1685
- * The base implementation of `_.values` and `_.valuesIn` which creates an
1686
- * array of `object` property values corresponding to the property names
1687
- * of `props`.
1688
- *
1689
- * @private
1690
- * @param {Object} object The object to query.
1691
- * @param {Array} props The property names to get values for.
1692
- * @returns {Object} Returns the array of property values.
1693
- */
1694
- function baseValues(object, props) {
1695
- return arrayMap(props, function(key) {
1696
- return object[key];
1697
- });
1698
- }
1699
-
1700
- /** Used for built-in method references. */
1701
- var objectProto$1 = Object.prototype;
1702
-
1703
- /** Used to check objects for own properties. */
1704
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
1705
-
1706
- /**
1707
- * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
1708
- * of source objects to the destination object for all destination properties
1709
- * that resolve to `undefined`.
1710
- *
1711
- * @private
1712
- * @param {*} objValue The destination value.
1713
- * @param {*} srcValue The source value.
1714
- * @param {string} key The key of the property to assign.
1715
- * @param {Object} object The parent object of `objValue`.
1716
- * @returns {*} Returns the value to assign.
1717
- */
1718
- function customDefaultsAssignIn(objValue, srcValue, key, object) {
1719
- if (objValue === undefined ||
1720
- (eq(objValue, objectProto$1[key]) && !hasOwnProperty$1.call(object, key))) {
1721
- return srcValue;
1722
- }
1723
- return objValue;
1724
- }
1725
-
1726
- /** Used to escape characters for inclusion in compiled string literals. */
1727
- var stringEscapes = {
1728
- '\\': '\\',
1729
- "'": "'",
1730
- '\n': 'n',
1731
- '\r': 'r',
1732
- '\u2028': 'u2028',
1733
- '\u2029': 'u2029'
1734
- };
1735
-
1736
- /**
1737
- * Used by `_.template` to escape characters for inclusion in compiled string literals.
1738
- *
1739
- * @private
1740
- * @param {string} chr The matched character to escape.
1741
- * @returns {string} Returns the escaped character.
1742
- */
1743
- function escapeStringChar(chr) {
1744
- return '\\' + stringEscapes[chr];
1745
- }
1746
-
1747
- /** Used to match template delimiters. */
1748
- var reInterpolate = /<%=([\s\S]+?)%>/g;
1749
-
1750
- /** Used to match template delimiters. */
1751
- var reEscape = /<%-([\s\S]+?)%>/g;
1752
-
1753
- /** Used to match template delimiters. */
1754
- var reEvaluate = /<%([\s\S]+?)%>/g;
1755
-
1756
- /**
1757
- * By default, the template delimiters used by lodash are like those in
1758
- * embedded Ruby (ERB) as well as ES2015 template strings. Change the
1759
- * following template settings to use alternative delimiters.
1760
- *
1761
- * @static
1762
- * @memberOf _
1763
- * @type {Object}
1764
- */
1765
- var templateSettings = {
1766
-
1767
- /**
1768
- * Used to detect `data` property values to be HTML-escaped.
1769
- *
1770
- * @memberOf _.templateSettings
1771
- * @type {RegExp}
1772
- */
1773
- 'escape': reEscape,
1774
-
1775
- /**
1776
- * Used to detect code to be evaluated.
1777
- *
1778
- * @memberOf _.templateSettings
1779
- * @type {RegExp}
1780
- */
1781
- 'evaluate': reEvaluate,
1782
-
1783
- /**
1784
- * Used to detect `data` property values to inject.
1785
- *
1786
- * @memberOf _.templateSettings
1787
- * @type {RegExp}
1788
- */
1789
- 'interpolate': reInterpolate,
1790
-
1791
- /**
1792
- * Used to reference the data object in the template text.
1793
- *
1794
- * @memberOf _.templateSettings
1795
- * @type {string}
1796
- */
1797
- 'variable': '',
1798
-
1799
- /**
1800
- * Used to import variables into the compiled template.
1801
- *
1802
- * @memberOf _.templateSettings
1803
- * @type {Object}
1804
- */
1805
- 'imports': {
1806
-
1807
- /**
1808
- * A reference to the `lodash` function.
1809
- *
1810
- * @memberOf _.templateSettings.imports
1811
- * @type {Function}
1812
- */
1813
- '_': { 'escape': escape }
1814
- }
1815
- };
1816
-
1817
- /** Error message constants. */
1818
- var INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`';
1819
-
1820
- /** Used to match empty string literals in compiled template source. */
1821
- var reEmptyStringLeading = /\b__p \+= '';/g,
1822
- reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
1823
- reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
1824
-
1825
- /**
1826
- * Used to validate the `validate` option in `_.template` variable.
1827
- *
1828
- * Forbids characters which could potentially change the meaning of the function argument definition:
1829
- * - "()," (modification of function parameters)
1830
- * - "=" (default value)
1831
- * - "[]{}" (destructuring of function parameters)
1832
- * - "/" (beginning of a comment)
1833
- * - whitespace
1834
- */
1835
- var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
1836
-
1837
- /**
1838
- * Used to match
1839
- * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
1840
- */
1841
- var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
1842
-
1843
- /** Used to ensure capturing order of template delimiters. */
1844
- var reNoMatch = /($^)/;
1845
-
1846
- /** Used to match unescaped characters in compiled string literals. */
1847
- var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
1848
-
1849
- /** Used for built-in method references. */
1850
- var objectProto = Object.prototype;
1851
-
1852
- /** Used to check objects for own properties. */
1853
- var hasOwnProperty = objectProto.hasOwnProperty;
1854
-
1855
- /**
1856
- * Creates a compiled template function that can interpolate data properties
1857
- * in "interpolate" delimiters, HTML-escape interpolated data properties in
1858
- * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
1859
- * properties may be accessed as free variables in the template. If a setting
1860
- * object is given, it takes precedence over `_.templateSettings` values.
1861
- *
1862
- * **Note:** In the development build `_.template` utilizes
1863
- * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
1864
- * for easier debugging.
1865
- *
1866
- * For more information on precompiling templates see
1867
- * [lodash's custom builds documentation](https://lodash.com/custom-builds).
1868
- *
1869
- * For more information on Chrome extension sandboxes see
1870
- * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
1871
- *
1872
- * @static
1873
- * @since 0.1.0
1874
- * @memberOf _
1875
- * @category String
1876
- * @param {string} [string=''] The template string.
1877
- * @param {Object} [options={}] The options object.
1878
- * @param {RegExp} [options.escape=_.templateSettings.escape]
1879
- * The HTML "escape" delimiter.
1880
- * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
1881
- * The "evaluate" delimiter.
1882
- * @param {Object} [options.imports=_.templateSettings.imports]
1883
- * An object to import into the template as free variables.
1884
- * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
1885
- * The "interpolate" delimiter.
1886
- * @param {string} [options.sourceURL='templateSources[n]']
1887
- * The sourceURL of the compiled template.
1888
- * @param {string} [options.variable='obj']
1889
- * The data object variable name.
1890
- * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
1891
- * @returns {Function} Returns the compiled template function.
1892
- * @example
1893
- *
1894
- * // Use the "interpolate" delimiter to create a compiled template.
1895
- * var compiled = _.template('hello <%= user %>!');
1896
- * compiled({ 'user': 'fred' });
1897
- * // => 'hello fred!'
1898
- *
1899
- * // Use the HTML "escape" delimiter to escape data property values.
1900
- * var compiled = _.template('<b><%- value %></b>');
1901
- * compiled({ 'value': '<script>' });
1902
- * // => '<b>&lt;script&gt;</b>'
1903
- *
1904
- * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
1905
- * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
1906
- * compiled({ 'users': ['fred', 'barney'] });
1907
- * // => '<li>fred</li><li>barney</li>'
1908
- *
1909
- * // Use the internal `print` function in "evaluate" delimiters.
1910
- * var compiled = _.template('<% print("hello " + user); %>!');
1911
- * compiled({ 'user': 'barney' });
1912
- * // => 'hello barney!'
1913
- *
1914
- * // Use the ES template literal delimiter as an "interpolate" delimiter.
1915
- * // Disable support by replacing the "interpolate" delimiter.
1916
- * var compiled = _.template('hello ${ user }!');
1917
- * compiled({ 'user': 'pebbles' });
1918
- * // => 'hello pebbles!'
1919
- *
1920
- * // Use backslashes to treat delimiters as plain text.
1921
- * var compiled = _.template('<%= "\\<%- value %\\>" %>');
1922
- * compiled({ 'value': 'ignored' });
1923
- * // => '<%- value %>'
1924
- *
1925
- * // Use the `imports` option to import `jQuery` as `jq`.
1926
- * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
1927
- * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
1928
- * compiled({ 'users': ['fred', 'barney'] });
1929
- * // => '<li>fred</li><li>barney</li>'
1930
- *
1931
- * // Use the `sourceURL` option to specify a custom sourceURL for the template.
1932
- * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
1933
- * compiled(data);
1934
- * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
1935
- *
1936
- * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
1937
- * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
1938
- * compiled.source;
1939
- * // => function(data) {
1940
- * // var __t, __p = '';
1941
- * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
1942
- * // return __p;
1943
- * // }
1944
- *
1945
- * // Use custom template delimiters.
1946
- * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
1947
- * var compiled = _.template('hello {{ user }}!');
1948
- * compiled({ 'user': 'mustache' });
1949
- * // => 'hello mustache!'
1950
- *
1951
- * // Use the `source` property to inline compiled templates for meaningful
1952
- * // line numbers in error messages and stack traces.
1953
- * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
1954
- * var JST = {\
1955
- * "main": ' + _.template(mainText).source + '\
1956
- * };\
1957
- * ');
1958
- */
1959
- function template(string, options, guard) {
1960
- // Based on John Resig's `tmpl` implementation
1961
- // (http://ejohn.org/blog/javascript-micro-templating/)
1962
- // and Laura Doktorova's doT.js (https://github.com/olado/doT).
1963
- var settings = templateSettings.imports._.templateSettings || templateSettings;
1964
- string = toString(string);
1965
- options = assignInWith({}, options, settings, customDefaultsAssignIn);
1966
-
1967
- var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
1968
- importsKeys = keys(imports),
1969
- importsValues = baseValues(imports, importsKeys);
1970
-
1971
- var isEscaping,
1972
- isEvaluating,
1973
- index = 0,
1974
- interpolate = options.interpolate || reNoMatch,
1975
- source = "__p += '";
1976
-
1977
- // Compile the regexp to match each delimiter.
1978
- var reDelimiters = RegExp(
1979
- (options.escape || reNoMatch).source + '|' +
1980
- interpolate.source + '|' +
1981
- (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
1982
- (options.evaluate || reNoMatch).source + '|$'
1983
- , 'g');
1984
-
1985
- // Use a sourceURL for easier debugging.
1986
- // The sourceURL gets injected into the source that's eval-ed, so be careful
1987
- // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in
1988
- // and escape the comment, thus injecting code that gets evaled.
1989
- var sourceURL = hasOwnProperty.call(options, 'sourceURL')
1990
- ? ('//# sourceURL=' +
1991
- (options.sourceURL + '').replace(/\s/g, ' ') +
1992
- '\n')
1993
- : '';
1994
-
1995
- string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
1996
- interpolateValue || (interpolateValue = esTemplateValue);
1997
-
1998
- // Escape characters that can't be included in string literals.
1999
- source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
2000
-
2001
- // Replace delimiters with snippets.
2002
- if (escapeValue) {
2003
- isEscaping = true;
2004
- source += "' +\n__e(" + escapeValue + ") +\n'";
2005
- }
2006
- if (evaluateValue) {
2007
- isEvaluating = true;
2008
- source += "';\n" + evaluateValue + ";\n__p += '";
2009
- }
2010
- if (interpolateValue) {
2011
- source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
2012
- }
2013
- index = offset + match.length;
2014
-
2015
- // The JS engine embedded in Adobe products needs `match` returned in
2016
- // order to produce the correct `offset` value.
2017
- return match;
2018
- });
2019
-
2020
- source += "';\n";
2021
-
2022
- // If `variable` is not specified wrap a with-statement around the generated
2023
- // code to add the data object to the top of the scope chain.
2024
- var variable = hasOwnProperty.call(options, 'variable') && options.variable;
2025
- if (!variable) {
2026
- source = 'with (obj) {\n' + source + '\n}\n';
2027
- }
2028
- // Throw an error if a forbidden character was found in `variable`, to prevent
2029
- // potential command injection attacks.
2030
- else if (reForbiddenIdentifierChars.test(variable)) {
2031
- throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT);
2032
- }
2033
-
2034
- // Cleanup code by stripping empty strings.
2035
- source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
2036
- .replace(reEmptyStringMiddle, '$1')
2037
- .replace(reEmptyStringTrailing, '$1;');
2038
-
2039
- // Frame code as the function body.
2040
- source = 'function(' + (variable || 'obj') + ') {\n' +
2041
- (variable
2042
- ? ''
2043
- : 'obj || (obj = {});\n'
2044
- ) +
2045
- "var __t, __p = ''" +
2046
- (isEscaping
2047
- ? ', __e = _.escape'
2048
- : ''
2049
- ) +
2050
- (isEvaluating
2051
- ? ', __j = Array.prototype.join;\n' +
2052
- "function print() { __p += __j.call(arguments, '') }\n"
2053
- : ';\n'
2054
- ) +
2055
- source +
2056
- 'return __p\n}';
2057
-
2058
- var result = attempt(function() {
2059
- return Function(importsKeys, sourceURL + 'return ' + source)
2060
- .apply(undefined, importsValues);
2061
- });
2062
-
2063
- // Provide the compiled function's source by its `toString` method or
2064
- // the `source` property as a convenience for inlining compiled templates.
2065
- result.source = source;
2066
- if (isError(result)) {
2067
- throw result;
2068
- }
2069
- return result;
2070
- }
2071
-
2072
- function toArray(value) {
2073
- return Array.isArray(value) ? value : [value];
2074
- }
2075
- function filterInPlace(array, predicate) {
2076
- for (let i = array.length; i--; i >= 0) {
2077
- if (!predicate(array[i], i, array)) {
2078
- array.splice(i, 1);
2079
- }
2080
- }
2081
- return array;
2082
- }
2083
- const MODE_RE = /\.(server|client)(\.\w+)*$/;
2084
- const distDirURL = new URL(".", import.meta.url);
2085
-
2086
- async function compileTemplate(template$1, ctx) {
2087
- const data = { ...ctx, options: template$1.options };
2088
- if (template$1.src) {
2089
- try {
2090
- const srcContents = await promises.readFile(template$1.src, "utf-8");
2091
- return template(srcContents, {})(data);
2092
- } catch (err) {
2093
- logger.error("Error compiling template: ", template$1);
2094
- throw err;
2095
- }
2096
- }
2097
- if (template$1.getContents) {
2098
- return template$1.getContents(data);
2099
- }
2100
- throw new Error("Invalid template: " + JSON.stringify(template$1));
2101
- }
2102
- const serialize = (data) => JSON.stringify(data, null, 2).replace(/"\{(.+)\}"(?=,?$)/gm, (r) => JSON.parse(r).replace(/^\{(.*)\}$/, "$1"));
2103
- const importSources = (sources, { lazy = false } = {}) => {
2104
- return toArray(sources).map((src) => {
2105
- const safeVariableName = genSafeVariableName(src);
2106
- if (lazy) {
2107
- return `const ${safeVariableName} = ${genDynamicImport(src, { comment: `webpackChunkName: ${JSON.stringify(src)}` })}`;
2108
- }
2109
- return genImport(src, safeVariableName);
2110
- }).join("\n");
2111
- };
2112
- const importName = genSafeVariableName;
2113
- const templateUtils = { serialize, importName, importSources };
2114
-
2115
137
  function defineNuxtModule(definition) {
2116
138
  if (definition) {
2117
139
  return _defineNuxtModule(definition);
@@ -2136,8 +158,10 @@ function _defineNuxtModule(definition) {
2136
158
  }
2137
159
  return Promise.resolve(options);
2138
160
  }
2139
- async function normalizedModule(inlineOptions, nuxt) {
2140
- nuxt ||= tryUseNuxt() || this.nuxt;
161
+ async function normalizedModule(inlineOptions, nuxt = tryUseNuxt()) {
162
+ if (!nuxt) {
163
+ throw new TypeError("Cannot use module outside of Nuxt context");
164
+ }
2141
165
  const uniqueKey = module.meta.name || module.meta.configKey;
2142
166
  if (uniqueKey) {
2143
167
  nuxt.options._requiredModules ||= {};
@@ -2160,7 +184,6 @@ ${issues.toString()}`;
2160
184
  return;
2161
185
  }
2162
186
  }
2163
- nuxt2Shims(nuxt);
2164
187
  const _options = await getOptions(inlineOptions, nuxt);
2165
188
  if (module.hooks) {
2166
189
  nuxt.hooks.addHooks(module.hooks);
@@ -2187,46 +210,6 @@ ${issues.toString()}`;
2187
210
  normalizedModule.getOptions = getOptions;
2188
211
  return normalizedModule;
2189
212
  }
2190
- const NUXT2_SHIMS_KEY = "__nuxt2_shims_key__";
2191
- function nuxt2Shims(nuxt) {
2192
- if (!isNuxt2(nuxt) || nuxt[NUXT2_SHIMS_KEY]) {
2193
- return;
2194
- }
2195
- nuxt[NUXT2_SHIMS_KEY] = true;
2196
- nuxt.hooks = nuxt;
2197
- if (!nuxtCtx.tryUse()) {
2198
- nuxtCtx.set(nuxt);
2199
- nuxt.hook("close", () => nuxtCtx.unset());
2200
- }
2201
- let virtualTemplates;
2202
- nuxt.hook("builder:prepared", (_builder, buildOptions) => {
2203
- virtualTemplates = buildOptions.templates.filter((t) => t.getContents);
2204
- for (const template of virtualTemplates) {
2205
- buildOptions.templates.splice(buildOptions.templates.indexOf(template), 1);
2206
- }
2207
- });
2208
- nuxt.hook("build:templates", async (templates) => {
2209
- const context = {
2210
- nuxt,
2211
- utils: templateUtils,
2212
- app: {
2213
- dir: nuxt.options.srcDir,
2214
- extensions: nuxt.options.extensions,
2215
- plugins: nuxt.options.plugins,
2216
- templates: [
2217
- ...templates.templatesFiles,
2218
- ...virtualTemplates
2219
- ],
2220
- templateVars: templates.templateVars
2221
- }
2222
- };
2223
- for await (const template of virtualTemplates) {
2224
- const contents = await compileTemplate({ ...template, src: "" }, context);
2225
- await promises.mkdir(dirname(template.dst), { recursive: true });
2226
- await promises.writeFile(template.dst, contents);
2227
- }
2228
- });
2229
- }
2230
213
 
2231
214
  function directoryToURL(dir) {
2232
215
  return pathToFileURL(dir + "/");
@@ -2256,9 +239,12 @@ function tryImportModule(id, opts) {
2256
239
  }
2257
240
  const warnings = /* @__PURE__ */ new Set();
2258
241
  function requireModule(id, opts) {
2259
- if (!warnings.has(id)) {
2260
- console.warn("[@nuxt/kit] `requireModule` is deprecated. Please use `importModule` instead.");
2261
- warnings.add(id);
242
+ const { source, line, column } = captureStackTrace().find((entry) => entry.source !== import.meta.url) ?? {};
243
+ const explanation = source ? ` (used at \`${fileURLToPath(source)}:${line}:${column}\`)` : "";
244
+ const warning = `[@nuxt/kit] \`requireModule\` is deprecated${explanation}. Please use \`importModule\` instead.`;
245
+ if (!warnings.has(warning)) {
246
+ console.warn(warning);
247
+ warnings.add(warning);
2262
248
  }
2263
249
  const resolvedPath = resolveModule(id, opts);
2264
250
  const jiti = createJiti(import.meta.url, {
@@ -2330,6 +316,20 @@ function resolveGroupSyntax(group) {
2330
316
  return groups;
2331
317
  }
2332
318
 
319
+ function toArray(value) {
320
+ return Array.isArray(value) ? value : [value];
321
+ }
322
+ function filterInPlace(array, predicate) {
323
+ for (let i = array.length; i--; i >= 0) {
324
+ if (!predicate(array[i], i, array)) {
325
+ array.splice(i, 1);
326
+ }
327
+ }
328
+ return array;
329
+ }
330
+ const MODE_RE = /\.(server|client)(\.\w+)*$/;
331
+ const distDirURL = new URL(".", import.meta.url);
332
+
2333
333
  async function resolvePath(path, opts = {}) {
2334
334
  const res = await _resolvePathGranularly(path, opts);
2335
335
  if (res.type === "file") {
@@ -2491,7 +491,7 @@ async function installModule(moduleToInstall, inlineOptions, nuxt = useNuxt()) {
2491
491
  localLayerModuleDirs.push(resolve(srcDir, l.config?.dir?.modules || "modules").replace(/\/?$/, "/"));
2492
492
  }
2493
493
  }
2494
- const res = (isNuxt2() ? await nuxtModule.call(nuxt.moduleContainer, inlineOptions, nuxt) : nuxt.options.experimental?.debugModuleMutation && nuxt._asyncLocalStorageModule ? await nuxt._asyncLocalStorageModule.run(nuxtModule, () => nuxtModule(inlineOptions || {}, nuxt)) : await nuxtModule(inlineOptions || {}, nuxt)) ?? {};
494
+ const res = nuxt.options.experimental?.debugModuleMutation && nuxt._asyncLocalStorageModule ? await nuxt._asyncLocalStorageModule.run(nuxtModule, () => nuxtModule(inlineOptions || {}, nuxt)) ?? {} : await nuxtModule(inlineOptions || {}, nuxt) ?? {};
2495
495
  if (res === false) {
2496
496
  return;
2497
497
  }
@@ -2617,20 +617,29 @@ async function getNuxtModuleVersion(module, nuxt = useNuxt()) {
2617
617
  return false;
2618
618
  }
2619
619
 
620
+ const merger = createDefu((obj, key, value) => {
621
+ if (Array.isArray(obj[key]) && Array.isArray(value)) {
622
+ obj[key] = obj[key].concat(value);
623
+ return true;
624
+ }
625
+ });
2620
626
  async function loadNuxtConfig(opts) {
2621
627
  const localLayers = (await glob("layers/*", { onlyDirectories: true, cwd: opts.cwd || process.cwd() })).map((d) => d.endsWith("/") ? d.substring(0, d.length - 1) : d);
2622
628
  opts.overrides = defu$1(opts.overrides, { _extends: localLayers });
2623
- globalThis.defineNuxtConfig = (c) => c;
629
+ const globalSelf = globalThis;
630
+ globalSelf.defineNuxtConfig = (c) => c;
2624
631
  const { configFile, layers = [], cwd, config: nuxtConfig, meta } = await loadConfig({
2625
632
  name: "nuxt",
2626
633
  configFile: "nuxt.config",
2627
634
  rcFile: ".nuxtrc",
2628
- extend: { extendKey: ["theme", "extends", "_extends"] },
635
+ extend: { extendKey: ["theme", "_extends", "extends"] },
2629
636
  dotenv: true,
2630
637
  globalRc: true,
638
+ merger,
639
+ // TODO: fix type in c12, it should accept createDefu directly
2631
640
  ...opts
2632
641
  });
2633
- delete globalThis.defineNuxtConfig;
642
+ delete globalSelf.defineNuxtConfig;
2634
643
  nuxtConfig.rootDir ||= cwd;
2635
644
  nuxtConfig._nuxtConfigFile = configFile;
2636
645
  nuxtConfig._nuxtConfigFiles = [configFile];
@@ -2641,7 +650,7 @@ async function loadNuxtConfig(opts) {
2641
650
  nuxtConfig.alias[alias] ||= nuxtConfig.rootDir;
2642
651
  }
2643
652
  const defaultBuildDir = join(nuxtConfig.rootDir, ".nuxt");
2644
- if (!opts.overrides?._prepare && !nuxtConfig.dev && !nuxtConfig.buildDir && nuxtConfig.future?.compatibilityVersion === 4 && existsSync(defaultBuildDir)) {
653
+ if (!opts.overrides?._prepare && !nuxtConfig.dev && !nuxtConfig.buildDir && existsSync(defaultBuildDir)) {
2645
654
  nuxtConfig.buildDir = join(nuxtConfig.rootDir, "node_modules/.cache/nuxt/.nuxt");
2646
655
  }
2647
656
  const NuxtConfigSchema = await loadNuxtSchema(nuxtConfig.rootDir || cwd || process.cwd());
@@ -2706,60 +715,29 @@ function extendNuxtSchema(def) {
2706
715
  }
2707
716
 
2708
717
  async function loadNuxt(opts) {
2709
- opts.cwd ||= opts.rootDir;
718
+ opts.cwd = resolve(opts.cwd || opts.rootDir || ".");
2710
719
  opts.overrides ||= opts.config || {};
2711
720
  opts.overrides.dev = !!opts.dev;
2712
- const resolvedPath = ["nuxt-nightly", "nuxt3", "nuxt", "nuxt-edge"].map((pkg2) => resolveModulePath(pkg2, { try: true, from: [directoryToURL(opts.cwd)] })).filter((p) => !!p).sort((a, b) => b.length - a.length)[0];
721
+ const resolvedPath = ["nuxt-nightly", "nuxt"].map((pkg) => resolveModulePath(pkg, { try: true, from: [directoryToURL(opts.cwd)] })).filter((p) => !!p).sort((a, b) => b.length - a.length)[0];
2713
722
  if (!resolvedPath) {
2714
723
  throw new Error(`Cannot find any nuxt version from ${opts.cwd}`);
2715
724
  }
2716
- const pkg = await readPackageJSON(resolvedPath);
2717
- const majorVersion = pkg.version ? Number.parseInt(pkg.version.split(".")[0]) : "";
2718
- if (majorVersion && majorVersion >= 3) {
2719
- const { loadNuxt: loadNuxt3 } = await import(pathToFileURL(resolvedPath).href).then((r) => interopDefault(r));
2720
- const nuxt2 = await loadNuxt3(opts);
2721
- return nuxt2;
2722
- }
2723
- const rootURL = directoryToURL(opts.cwd);
2724
- const { loadNuxt: loadNuxt2 } = await tryImportModule("nuxt-edge", { url: rootURL }) || await importModule("nuxt", { url: rootURL });
2725
- const nuxt = await loadNuxt2({
2726
- rootDir: opts.cwd,
2727
- for: opts.dev ? "dev" : "build",
2728
- configOverrides: opts.overrides,
2729
- ready: opts.ready,
2730
- envConfig: opts.dotenv
2731
- // TODO: Backward format conversion
2732
- });
2733
- nuxt.removeHook ||= nuxt.clearHook.bind(nuxt);
2734
- nuxt.removeAllHooks ||= nuxt.clearHooks.bind(nuxt);
2735
- nuxt.hookOnce ||= (name, fn, ...hookArgs) => {
2736
- const unsub = nuxt.hook(name, (...args) => {
2737
- unsub();
2738
- return fn(...args);
2739
- }, ...hookArgs);
2740
- return unsub;
2741
- };
2742
- nuxt.hooks ||= nuxt;
725
+ const { loadNuxt: loadNuxt2 } = await import(pathToFileURL(resolvedPath).href).then((r) => interopDefault(r));
726
+ const nuxt = await loadNuxt2(opts);
2743
727
  return nuxt;
2744
728
  }
2745
729
  async function buildNuxt(nuxt) {
2746
730
  const rootURL = directoryToURL(nuxt.options.rootDir);
2747
- if (nuxt.options._majorVersion === 3) {
2748
- const { build: build2 } = await tryImportModule("nuxt-nightly", { url: rootURL }) || await tryImportModule("nuxt3", { url: rootURL }) || await importModule("nuxt", { url: rootURL });
2749
- return runWithNuxtContext(nuxt, () => build2(nuxt));
2750
- }
2751
- const { build } = await tryImportModule("nuxt-edge", { url: rootURL }) || await importModule("nuxt", { url: rootURL });
731
+ const { build } = await tryImportModule("nuxt-nightly", { url: rootURL }) || await importModule("nuxt", { url: rootURL });
2752
732
  return runWithNuxtContext(nuxt, () => build(nuxt));
2753
733
  }
2754
734
 
2755
735
  function addImports(imports) {
2756
- assertNuxtCompatibility({ bridge: true });
2757
736
  useNuxt().hook("imports:extend", (_imports) => {
2758
737
  _imports.push(...toArray(imports));
2759
738
  });
2760
739
  }
2761
740
  function addImportsDir(dirs, opts = {}) {
2762
- assertNuxtCompatibility({ bridge: true });
2763
741
  useNuxt().hook("imports:dirs", (_dirs) => {
2764
742
  for (const dir of toArray(dirs)) {
2765
743
  _dirs[opts.prepend ? "unshift" : "push"](dir);
@@ -2767,7 +745,6 @@ function addImportsDir(dirs, opts = {}) {
2767
745
  });
2768
746
  }
2769
747
  function addImportsSources(presets) {
2770
- assertNuxtCompatibility({ bridge: true });
2771
748
  useNuxt().hook("imports:sources", (_presets) => {
2772
749
  for (const preset of toArray(presets)) {
2773
750
  _presets.push(preset);
@@ -2888,7 +865,7 @@ function applyEnv(obj, opts, parentKey = "") {
2888
865
  }
2889
866
  return obj;
2890
867
  }
2891
- const envExpandRx = /\{\{(.*?)\}\}/g;
868
+ const envExpandRx = /\{\{([^{}]*)\}\}/g;
2892
869
  function _expandFromEnv(value, env = process$1.env) {
2893
870
  return value.replace(envExpandRx, (match, key) => {
2894
871
  return env[key] || match;
@@ -2978,9 +955,6 @@ function addBuildPlugin(pluginFactory, options) {
2978
955
 
2979
956
  function addComponentsDir(dir, opts = {}) {
2980
957
  const nuxt = useNuxt();
2981
- if (!checkNuxtVersion(">=2.13", nuxt)) {
2982
- throw new Error(`\`addComponentsDir\` requires Nuxt 2.13 or higher.`);
2983
- }
2984
958
  nuxt.options.components ||= [];
2985
959
  dir.priority ||= 0;
2986
960
  nuxt.hook("components:dirs", (dirs) => {
@@ -3006,9 +980,6 @@ function addComponent(opts) {
3006
980
  }
3007
981
  function addComponents(addedComponents) {
3008
982
  const nuxt = useNuxt();
3009
- if (!checkNuxtVersion(">=2.13", nuxt)) {
3010
- throw new Error(`\`addComponent\` requires Nuxt 2.13 or higher.`);
3011
- }
3012
983
  nuxt.options.components ||= [];
3013
984
  nuxt.hook("components:extend", (components) => {
3014
985
  for (const component of addedComponents) {
@@ -3110,7 +1081,7 @@ function normalizeTemplate(template, buildDir) {
3110
1081
  }
3111
1082
  if (!template.filename) {
3112
1083
  const srcPath = parse(template.src);
3113
- template.filename = template.fileName || `${basename(srcPath.dir)}.${srcPath.name}.${hash(template.src)}${srcPath.ext}`;
1084
+ template.filename = template.fileName || `${basename(srcPath.dir)}.${srcPath.name}.${hash(template.src).replace(/-/g, "_")}${srcPath.ext}`;
3114
1085
  }
3115
1086
  }
3116
1087
  if (!template.src && !template.getContents) {
@@ -3337,7 +1308,6 @@ async function writeTypes(nuxt) {
3337
1308
  const declarationPath = resolve(nuxt.options.buildDir, "nuxt.d.ts");
3338
1309
  await promises.writeFile(declarationPath, GeneratedBy + "\n" + declaration);
3339
1310
  }
3340
- nuxt.hook("builder:prepared", writeFile);
3341
1311
  await writeFile();
3342
1312
  }
3343
1313
  function sortTsPaths(paths) {
@@ -3369,19 +1339,6 @@ function addLayout(template, name) {
3369
1339
  const nuxt = useNuxt();
3370
1340
  const { filename, src } = addTemplate(template);
3371
1341
  const layoutName = kebabCase(name || parse(filename).name).replace(LAYOUT_RE, "");
3372
- if (isNuxt2(nuxt)) {
3373
- const layout = nuxt.options.layouts[layoutName];
3374
- if (layout) {
3375
- return logger.warn(
3376
- `Not overriding \`${layoutName}\` (provided by \`${layout}\`) with \`${src || filename}\`.`
3377
- );
3378
- }
3379
- nuxt.options.layouts[layoutName] = `./${filename}`;
3380
- if (name === "error") {
3381
- this.addErrorLayout(filename);
3382
- }
3383
- return;
3384
- }
3385
1342
  nuxt.hook("app:templates", (app) => {
3386
1343
  if (layoutName in app.layouts) {
3387
1344
  const relativePath = relative(nuxt.options.srcDir, app.layouts[layoutName].file);
@@ -3397,12 +1354,7 @@ function addLayout(template, name) {
3397
1354
  }
3398
1355
 
3399
1356
  function extendPages(cb) {
3400
- const nuxt = useNuxt();
3401
- if (isNuxt2(nuxt)) {
3402
- nuxt.hook("build:extendRoutes", cb);
3403
- } else {
3404
- nuxt.hook("pages:extend", cb);
3405
- }
1357
+ useNuxt().hook("pages:extend", cb);
3406
1358
  }
3407
1359
  function extendRouteRules(route, rule, options = {}) {
3408
1360
  const nuxt = useNuxt();
@@ -3480,4 +1432,4 @@ function addPluginTemplate(plugin, opts = {}) {
3480
1432
  return addPlugin(normalizedPlugin, opts);
3481
1433
  }
3482
1434
 
3483
- export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, compileTemplate, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, runWithNuxtContext, templateUtils, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };
1435
+ export { addBuildPlugin, addComponent, addComponentExports, addComponentsDir, addDevServerHandler, addImports, addImportsDir, addImportsSources, addLayout, addPlugin, addPluginTemplate, addPrerenderRoutes, addRouteMiddleware, addRspackPlugin, addServerHandler, addServerImports, addServerImportsDir, addServerPlugin, addServerScanDir, addServerTemplate, addTemplate, addTypeTemplate, addVitePlugin, addWebpackPlugin, assertNuxtCompatibility, buildNuxt, checkNuxtCompatibility, createIsIgnored, createResolver, defineNuxtModule, directoryToURL, extendNuxtSchema, extendPages, extendRouteRules, extendRspackConfig, extendViteConfig, extendWebpackConfig, findPath, getDirectory, getNuxtCtx, getNuxtModuleVersion, getNuxtVersion, hasNuxtCompatibility, hasNuxtModule, hasNuxtModuleCompatibility, importModule, installModule, isIgnored, isNuxt2, isNuxt3, isNuxtMajorVersion, loadNuxt, loadNuxtConfig, loadNuxtModuleInstance, logger, normalizeModuleTranspilePath, normalizePlugin, normalizeSemanticVersion, normalizeTemplate, nuxtCtx, requireModule, resolveAlias, resolveFiles, resolveIgnorePatterns, resolveModule, resolveNuxtModule, resolvePath, runWithNuxtContext, tryImportModule, tryRequireModule, tryResolveModule, tryUseNuxt, updateRuntimeConfig, updateTemplates, useLogger, useNitro, useNuxt, useRuntimeConfig, writeTypes };