路泰科技体检小程序UI设计新版本
1
wwl
2025-07-30 61b58bd03d04d2eb50ac2d93a188c819fe67e01e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
    MIT License http://www.opensource.org/licenses/mit-license.php
    Author Tobias Koppers @sokra
*/
 
"use strict";
 
const InitFragment = require("../InitFragment");
const RuntimeGlobals = require("../RuntimeGlobals");
const Template = require("../Template");
 
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
 
/**
 * @extends {InitFragment<GenerateContext>}
 */
class AwaitDependenciesInitFragment extends InitFragment {
    /**
     * @param {Map<string, string>} dependencies maps an import var to an async module that needs to be awaited
     */
    constructor(dependencies) {
        super(
            undefined,
            InitFragment.STAGE_ASYNC_DEPENDENCIES,
            0,
            "await-dependencies"
        );
        this.dependencies = dependencies;
    }
 
    /**
     * @param {AwaitDependenciesInitFragment} other other AwaitDependenciesInitFragment
     * @returns {AwaitDependenciesInitFragment} AwaitDependenciesInitFragment
     */
    merge(other) {
        const dependencies = new Map(other.dependencies);
        for (const [key, value] of this.dependencies) {
            dependencies.set(key, value);
        }
        return new AwaitDependenciesInitFragment(dependencies);
    }
 
    /**
     * @param {GenerateContext} context context
     * @returns {string | Source | undefined} the source code that will be included as initialization code
     */
    getContent({ runtimeRequirements, runtimeTemplate }) {
        runtimeRequirements.add(RuntimeGlobals.module);
        if (this.dependencies.size === 0) {
            return "";
        }
 
        const importVars = [...this.dependencies.keys()];
        const asyncModuleValues = [...this.dependencies.values()].join(", ");
 
        const templateInput = [
            `var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${asyncModuleValues}]);`
        ];
 
        if (
            this.dependencies.size === 1 ||
            !runtimeTemplate.supportsDestructuring()
        ) {
            for (const [index, importVar] of importVars.entries()) {
                templateInput.push(
                    `${importVar} = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[${index}];`
                );
            }
        } else {
            const importVarsStr = importVars.join(", ");
 
            templateInput.push(
                `([${importVarsStr}] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);`
            );
        }
 
        templateInput.push("");
 
        return Template.asString(templateInput);
    }
}
 
module.exports = AwaitDependenciesInitFragment;