WXL
3 天以前 9bce51f651aad297ef9eb6df832bfdaf1de05d84
node_modules/webpack/lib/util/cleverMerge.js
@@ -7,7 +7,8 @@
/** @type {WeakMap<EXPECTED_OBJECT, WeakMap<EXPECTED_OBJECT, EXPECTED_OBJECT>>} */
const mergeCache = new WeakMap();
/** @type {WeakMap<EXPECTED_OBJECT, Map<string, Map<string | number | boolean, EXPECTED_OBJECT>>>} */
/** @typedef {Map<string, Map<string | number | boolean, EXPECTED_OBJECT>>} InnerPropertyCache */
/** @type {WeakMap<EXPECTED_OBJECT, InnerPropertyCache>} */
const setPropertyCache = new WeakMap();
const DELETE = Symbol("DELETE");
const DYNAMIC_INFO = Symbol("cleverMerge dynamic info");
@@ -50,6 +51,7 @@
};
/**
 * Caches d set property.
 * @template T
 * @param {Partial<T>} obj object
 * @param {string} property property
@@ -85,10 +87,12 @@
};
/**
 * Defines the by values type used by this module.
 * @typedef {Map<string, EXPECTED_ANY>} ByValues
 */
/**
 * Defines the object parsed property entry type used by this module.
 * @template T
 * @typedef {object} ObjectParsedPropertyEntry
 * @property {T[keyof T] | undefined} base base value
@@ -99,16 +103,19 @@
/** @typedef {(function(...EXPECTED_ANY): object) & { [DYNAMIC_INFO]: [DynamicFunction, object] }} DynamicFunction */
/**
 * Defines the parsed object static type used by this module.
 * @template {object} T
 * @typedef {Map<keyof T, ObjectParsedPropertyEntry<T>>} ParsedObjectStatic
 */
/**
 * Defines the parsed object dynamic type used by this module.
 * @template {object} T
 * @typedef {{ byProperty: `by${string}`, fn: DynamicFunction }} ParsedObjectDynamic
 */
/**
 * Defines the parsed object type used by this module.
 * @template {object} T
 * @typedef {object} ParsedObject
 * @property {ParsedObjectStatic<T>} static static properties (key is property name)
@@ -119,6 +126,7 @@
const parseCache = new WeakMap();
/**
 * Caches d parse object.
 * @template {object} T
 * @param {T} obj the object
 * @returns {ParsedObject<T>} parsed object
@@ -134,6 +142,7 @@
/** @typedef {{ [p: string]: { [p: string]: EXPECTED_ANY } } | DynamicFunction} ByObject */
/**
 * Returns parsed object.
 * @template {object} T
 * @param {T} obj the object
 * @returns {ParsedObject<T>} parsed object
@@ -144,6 +153,7 @@
   /** @type {ParsedObjectDynamic<T> | undefined} */
   let dynamicInfo;
   /**
    * Returns object parsed property entry.
    * @param {keyof T} p path
    * @returns {Partial<ObjectParsedPropertyEntry<T>>} object parsed property entry
    */
@@ -220,6 +230,7 @@
};
/**
 * Returns the object.
 * @template {object} T
 * @param {ParsedObjectStatic<T>} info static properties (key is property name)
 * @param {{ byProperty: `by${string}`, fn: DynamicFunction } | undefined} dynamicInfo dynamic part
@@ -268,6 +279,7 @@
const VALUE_TYPE_DELETE = 4;
/**
 * Returns value type.
 * @template T
 * @param {T} value a single value
 * @returns {VALUE_TYPE_UNDEFINED | VALUE_TYPE_ATOM | VALUE_TYPE_ARRAY_EXTEND | VALUE_TYPE_OBJECT | VALUE_TYPE_DELETE} value type
@@ -310,6 +322,7 @@
};
/**
 * Returns merged object of first and second object.
 * @template {object} T
 * @template {object} O
 * Merges two objects. Objects are deeply clever merged.
@@ -377,6 +390,7 @@
};
/**
 * Merges the provided values into a single result.
 * @template T, O
 * @param {ObjectParsedPropertyEntry<T>} firstEntry a
 * @param {ObjectParsedPropertyEntry<O>} secondEntry b
@@ -406,6 +420,7 @@
         } else {
            // = first.base + (first.byProperty + second.byProperty)
            // need to merge first and second byValues
            /** @type {Map<string, T & O>} */
            const newByValues = new Map(firstEntry.byValues);
            for (const [key, value] of /** @type {ByValues} */ (
               secondEntry.byValues
@@ -444,7 +459,9 @@
               byValues: secondEntry.byValues
            };
         }
         /** @type {O[keyof O] | T[keyof T] | (T[keyof T] & O[keyof O]) | (T[keyof T] | undefined)[] | (O[keyof O] | undefined)[] | (O[keyof O] | T[keyof T] | undefined)[] | undefined} */
         let newBase;
         /** @type {Map<string, (T & O) | O[keyof O] | (O[keyof O] | undefined)[] | ((T & O) | undefined)[] | (T & O & O[keyof O]) | ((T & O) | O[keyof O] | undefined)[] | undefined>} */
         const intermediateByValues = new Map(firstEntry.byValues);
         for (const [key, value] of intermediateByValues) {
            intermediateByValues.set(
@@ -485,6 +502,7 @@
               `${firstEntry.byProperty} and ${secondEntry.byProperty} for a single property is not supported`
            );
         }
         /** @type {Map<string, (T & O) | O[keyof O] | (O[keyof O] | undefined)[] | (T & O & O[keyof O]) | ((T & O) | undefined)[] | ((T & O) | O[keyof O] | undefined)[] | undefined>} */
         const newByValues = new Map(intermediateByValues);
         for (const [key, value] of /** @type {ByValues} */ (
            secondEntry.byValues
@@ -505,6 +523,7 @@
};
/**
 * Gets from by values.
 * @template V
 * @param {ByValues} byValues all values
 * @param {string} key value of the selector
@@ -518,6 +537,7 @@
};
/**
 * Merges single value.
 * @template A
 * @template B
 * @param {A | A[]} a value
@@ -580,6 +600,7 @@
};
/**
 * Removes operations.
 * @template {object} T
 * @param {T} obj the object
 * @param {(keyof T)[]=} keysToKeepOriginalValue keys to keep original value
@@ -627,6 +648,7 @@
};
/**
 * Resolves by property.
 * @template T
 * @template {keyof T} P
 * @template V