| | |
| | | /** @typedef {string} InitFragmentKey */ |
| | | |
| | | /** |
| | | * Defines the maybe mergeable init fragment type used by this module. |
| | | * @template GenerateContext |
| | | * @typedef {object} MaybeMergeableInitFragment |
| | | * @property {InitFragmentKey=} key |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Extract fragment index. |
| | | * @template T |
| | | * @param {T} fragment the init fragment |
| | | * @param {number} index index |
| | |
| | | const extractFragmentIndex = (fragment, index) => [fragment, index]; |
| | | |
| | | /** |
| | | * Sorts fragment with index. |
| | | * @template T |
| | | * @param {[MaybeMergeableInitFragment<T>, number]} a first pair |
| | | * @param {[MaybeMergeableInitFragment<T>, number]} b second pair |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Represents InitFragment. |
| | | * @template GenerateContext |
| | | * @implements {MaybeMergeableInitFragment<GenerateContext>} |
| | | */ |
| | | class InitFragment { |
| | | /** |
| | | * Creates an instance of InitFragment. |
| | | * @param {string | Source | undefined} content the source code that will be included as initialization code |
| | | * @param {number} stage category of initialization code (contribute to order) |
| | | * @param {number} position position in the category (contribute to order) |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the source code that will be included as initialization code. |
| | | * @param {GenerateContext} context context |
| | | * @returns {string | Source | undefined} the source code that will be included as initialization code |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the source code that will be included at the end of the module. |
| | | * @param {GenerateContext} context context |
| | | * @returns {string | Source | undefined} the source code that will be included at the end of the module |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds the provided source to the init fragment. |
| | | * @template Context |
| | | * @param {Source} source sources |
| | | * @param {MaybeMergeableInitFragment<Context>[]} initFragments init fragments |
| | |
| | | } |
| | | |
| | | const concatSource = new ConcatSource(); |
| | | /** @type {(string | Source)[]} */ |
| | | const endContents = []; |
| | | for (let fragment of keyedFragments.values()) { |
| | | if (Array.isArray(fragment)) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Serializes this instance into the provided serializer context. |
| | | * @param {ObjectSerializerContext} context context |
| | | */ |
| | | serialize(context) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Restores this instance from the provided deserializer context. |
| | | * @param {ObjectDeserializerContext} context context |
| | | */ |
| | | deserialize(context) { |