| | |
| | | /** @typedef {import("../Compilation")} Compilation */ |
| | | /** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */ |
| | | |
| | | /** @typedef {string | SortableSet<string> | undefined} RuntimeSpec */ |
| | | /** @typedef {SortableSet<string>} RuntimeSpecSortableSet */ |
| | | /** @typedef {string | RuntimeSpecSortableSet | undefined} RuntimeSpec */ |
| | | /** @typedef {RuntimeSpec | boolean} RuntimeCondition */ |
| | | |
| | | /** |
| | | * Gets entry runtime. |
| | | * @param {Compilation} compilation the compilation |
| | | * @param {string} name name of the entry |
| | | * @param {EntryOptions=} options optionally already received entry options |
| | | * @returns {RuntimeSpec} runtime |
| | | */ |
| | | const getEntryRuntime = (compilation, name, options) => { |
| | | /** @type {EntryOptions["dependOn"]} */ |
| | | let dependOn; |
| | | /** @type {EntryOptions["runtime"]} */ |
| | | let runtime; |
| | | if (options) { |
| | | ({ dependOn, runtime } = options); |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Processes the provided runtime. |
| | | * @param {RuntimeSpec} runtime runtime |
| | | * @param {(runtime: string | undefined) => void} fn functor |
| | | * @param {boolean} deterministicOrder enforce a deterministic order |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns runtime key. |
| | | * @template T |
| | | * @param {SortableSet<T>} set set |
| | | * @param {Exclude<RuntimeSpec, undefined | string>} set set |
| | | * @returns {string} runtime key |
| | | */ |
| | | const getRuntimesKey = (set) => { |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns key of runtimes. |
| | | * @param {RuntimeSpec} runtime runtime(s) |
| | | * @returns {string} key of runtimes |
| | | */ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns runtime(s). |
| | | * @param {string} key key of runtimes |
| | | * @returns {RuntimeSpec} runtime(s) |
| | | */ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Gets runtimes string. |
| | | * @template T |
| | | * @param {SortableSet<T>} set set |
| | | * @param {Exclude<RuntimeSpec, undefined | string>} set set |
| | | * @returns {string} runtime string |
| | | */ |
| | | const getRuntimesString = (set) => { |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns readable version. |
| | | * @param {RuntimeSpec} runtime runtime(s) |
| | | * @returns {string} readable version |
| | | */ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Runtime condition to string. |
| | | * @param {RuntimeCondition} runtimeCondition runtime condition |
| | | * @returns {string} readable version |
| | | */ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns true, when they are equal. |
| | | * @param {RuntimeSpec} a first |
| | | * @param {RuntimeSpec} b second |
| | | * @returns {boolean} true, when they are equal |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Compares the provided values and returns their ordering. |
| | | * @param {RuntimeSpec} a first |
| | | * @param {RuntimeSpec} b second |
| | | * @returns {-1|0|1} compare |
| | | * @returns {-1 | 0 | 1} compare |
| | | */ |
| | | const compareRuntime = (a, b) => { |
| | | if (a === b) { |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Merges the provided values into a single result. |
| | | * @param {RuntimeSpec} a first |
| | | * @param {RuntimeSpec} b second |
| | | * @returns {RuntimeSpec} merged |
| | |
| | | return a; |
| | | } else if (typeof a === "string") { |
| | | if (typeof b === "string") { |
| | | /** @type {RuntimeSpecSortableSet} */ |
| | | const set = new SortableSet(); |
| | | set.add(a); |
| | | set.add(b); |
| | |
| | | } else if (b.has(a)) { |
| | | return b; |
| | | } |
| | | /** @type {RuntimeSpecSortableSet} */ |
| | | const set = new SortableSet(b); |
| | | set.add(a); |
| | | return set; |
| | | } |
| | | if (typeof b === "string") { |
| | | if (a.has(b)) return a; |
| | | /** @type {RuntimeSpecSortableSet} */ |
| | | const set = new SortableSet(a); |
| | | set.add(b); |
| | | return set; |
| | | } |
| | | /** @type {RuntimeSpecSortableSet} */ |
| | | const set = new SortableSet(a); |
| | | for (const item of b) set.add(item); |
| | | if (set.size === a.size) return a; |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Merges runtime condition. |
| | | * @param {RuntimeCondition} a first |
| | | * @param {RuntimeCondition} b second |
| | | * @param {RuntimeSpec} runtime full runtime |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Merges runtime condition non false. |
| | | * @param {RuntimeSpec | true} a first |
| | | * @param {RuntimeSpec | true} b second |
| | | * @param {RuntimeSpec} runtime full runtime |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Merges runtime owned. |
| | | * @param {RuntimeSpec} a first (may be modified) |
| | | * @param {RuntimeSpec} b second |
| | | * @returns {RuntimeSpec} merged |
| | |
| | | if (typeof b === "string") { |
| | | return b; |
| | | } |
| | | /** @type {RuntimeSpecSortableSet} */ |
| | | return new SortableSet(b); |
| | | } else if (typeof a === "string") { |
| | | if (typeof b === "string") { |
| | | /** @type {RuntimeSpecSortableSet} */ |
| | | const set = new SortableSet(); |
| | | set.add(a); |
| | | set.add(b); |
| | | return set; |
| | | } |
| | | /** @type {RuntimeSpecSortableSet} */ |
| | | const set = new SortableSet(b); |
| | | set.add(a); |
| | | return set; |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns merged. |
| | | * @param {RuntimeSpec} a first |
| | | * @param {RuntimeSpec} b second |
| | | * @returns {RuntimeSpec} merged |
| | |
| | | if (a.has(b)) return b; |
| | | return; |
| | | } |
| | | /** @type {RuntimeSpecSortableSet} */ |
| | | const set = new SortableSet(); |
| | | for (const item of b) { |
| | | if (a.has(item)) set.add(item); |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns result. |
| | | * @param {RuntimeSpec} a first |
| | | * @param {RuntimeSpec} b second |
| | | * @returns {RuntimeSpec} result |
| | |
| | | if (item !== b) return item; |
| | | } |
| | | } |
| | | /** @type {RuntimeSpecSortableSet} */ |
| | | const set = new SortableSet(a); |
| | | set.delete(b); |
| | | return set; |
| | | } |
| | | /** @type {RuntimeSpecSortableSet} */ |
| | | const set = new SortableSet(); |
| | | for (const item of a) { |
| | | if (!b.has(item)) set.add(item); |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Subtract runtime condition. |
| | | * @param {RuntimeCondition} a first |
| | | * @param {RuntimeCondition} b second |
| | | * @param {RuntimeSpec} runtime runtime |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns true/false if filter is constant for all runtimes, otherwise runtimes that are active. |
| | | * @param {RuntimeSpec} runtime runtime |
| | | * @param {(runtime?: RuntimeSpec) => boolean} filter filter function |
| | | * @returns {boolean | RuntimeSpec} true/false if filter is constant for all runtimes, otherwise runtimes that are active |
| | |
| | | if (typeof runtime === "string") return filter(runtime); |
| | | let some = false; |
| | | let every = true; |
| | | /** @type {RuntimeSpec} */ |
| | | let result; |
| | | for (const r of runtime) { |
| | | const v = filter(r); |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Defines the runtime spec map inner map type used by this module. |
| | | * @template T |
| | | * @typedef {Map<string, T>} RuntimeSpecMapInnerMap |
| | | */ |
| | | |
| | | /** |
| | | * Represents RuntimeSpecMap. |
| | | * @template T |
| | | * @template [R=T] |
| | | */ |
| | | class RuntimeSpecMap { |
| | | /** |
| | | * Creates an instance of RuntimeSpecMap. |
| | | * @param {RuntimeSpecMap<T, R>=} clone copy form this |
| | | */ |
| | | constructor(clone) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns value. |
| | | * @param {RuntimeSpec} runtime the runtimes |
| | | * @returns {R | undefined} value |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns true, when the runtime is stored. |
| | | * @param {RuntimeSpec} runtime the runtimes |
| | | * @returns {boolean} true, when the runtime is stored |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates default using the provided runtime. |
| | | * @param {RuntimeSpec} runtime the runtimes |
| | | * @param {R} value the value |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the new value. |
| | | * @param {RuntimeSpec} runtime the runtimes |
| | | * @param {() => R} computer function to compute the value |
| | | * @returns {R} the new value |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided runtime. |
| | | * @param {RuntimeSpec} runtime the runtimes |
| | | */ |
| | | delete(runtime) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided runtime. |
| | | * @param {RuntimeSpec} runtime the runtimes |
| | | * @param {(value: R | undefined) => R} fn function to update the value |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns values. |
| | | * @returns {IterableIterator<R>} values |
| | | */ |
| | | values() { |
| | |
| | | |
| | | class RuntimeSpecSet { |
| | | /** |
| | | * Creates an instance of RuntimeSpecSet. |
| | | * @param {Iterable<RuntimeSpec>=} iterable iterable |
| | | */ |
| | | constructor(iterable) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided runtime. |
| | | * @param {RuntimeSpec} runtime runtime |
| | | */ |
| | | add(runtime) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns true, when the runtime exists. |
| | | * @param {RuntimeSpec} runtime runtime |
| | | * @returns {boolean} true, when the runtime exists |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns iterable iterator. |
| | | * @returns {IterableIterator<RuntimeSpec>} iterable iterator |
| | | */ |
| | | [Symbol.iterator]() { |