路泰科技体检小程序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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
    MIT License http://www.opensource.org/licenses/mit-license.php
*/
 
"use strict";
 
const RuntimeGlobals = require("../RuntimeGlobals");
const Template = require("../Template");
const HelperRuntimeModule = require("./HelperRuntimeModule");
 
/**
 * @param {import("../Module").ExportsType} exportsType exports type
 * @returns {string} mode
 */
function getMakeDeferredNamespaceModeFromExportsType(exportsType) {
    if (exportsType === "namespace") return `/* ${exportsType} */ 0`;
    if (exportsType === "default-only") return `/* ${exportsType} */ 1`;
    if (exportsType === "default-with-named") return `/* ${exportsType} */ 2`;
    if (exportsType === "dynamic") return `/* ${exportsType} */ 3`;
    return "";
}
/**
 * @param {import("../ModuleTemplate").RuntimeTemplate} _runtimeTemplate runtimeTemplate
 * @param {import("../Module").ExportsType} exportsType exportsType
 * @param {string} moduleId moduleId
 * @param {(import("../ChunkGraph").ModuleId | null)[]} asyncDepsIds asyncDepsIds
 * @returns {string} function
 */
function getOptimizedDeferredModule(
    _runtimeTemplate,
    exportsType,
    moduleId,
    asyncDepsIds
) {
    const isAsync = asyncDepsIds && asyncDepsIds.length;
    const init = `${RuntimeGlobals.require}(${moduleId})${
        isAsync ? `[${RuntimeGlobals.asyncModuleExportSymbol}]` : ""
    }`;
    const props = [
        `/* ${exportsType} */ get a() {`,
        // if exportsType is "namespace" we can generate the most optimized code,
        // on the second access, we can avoid trigger the getter.
        // we can also do this if exportsType is "dynamic" and there is a "__esModule" property on it.
        exportsType === "namespace" || exportsType === "dynamic"
            ? Template.indent([
                    `var exports = ${init};`,
                    `${
                        exportsType === "dynamic" ? "if (exports.__esModule) " : ""
                    }Object.defineProperty(this, "a", { value: exports });`,
                    "return exports;"
                ])
            : Template.indent([`return ${init};`]),
        isAsync ? "}," : "}",
        isAsync
            ? `[${
                    RuntimeGlobals.makeDeferredNamespaceObjectSymbol
                }]: ${JSON.stringify(asyncDepsIds.filter((x) => x !== null))}`
            : ""
    ];
    return Template.asString(["{", Template.indent(props), "}"]);
}
 
const strictModuleCache = [
    "if (cachedModule && cachedModule.error === undefined) {",
    Template.indent([
        "var exports = cachedModule.exports;",
        "if (mode == 0) return exports;",
        `if (mode == 1) return ${RuntimeGlobals.createFakeNamespaceObject}(exports);`,
        `if (mode == 2) return ${RuntimeGlobals.createFakeNamespaceObject}(exports, 2);`,
        `if (mode == 3) return ${RuntimeGlobals.createFakeNamespaceObject}(exports, 6);` // 2 | 4
    ]),
    "}"
];
const nonStrictModuleCache = [
    "// optimization not applied when output.strictModuleErrorHandling is off"
];
 
class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
    /**
     * @param {boolean} hasAsyncRuntime if async module is used.
     */
    constructor(hasAsyncRuntime) {
        super("make deferred namespace object");
        this.hasAsyncRuntime = hasAsyncRuntime;
    }
 
    /**
     * @returns {string | null} runtime code
     */
    generate() {
        if (!this.compilation) return null;
        const { runtimeTemplate } = this.compilation;
        const fn = RuntimeGlobals.makeDeferredNamespaceObject;
        const hasAsync = this.hasAsyncRuntime;
        const strictError =
            this.compilation.options.output.strictModuleErrorHandling;
        const init = runtimeTemplate.supportsOptionalChaining()
            ? "init?.();"
            : "if (init) init();";
        return `${fn} = ${runtimeTemplate.basicFunction("moduleId, mode", [
            "// mode: 0 => namespace (esm)",
            "// mode: 1 => default-only (esm strict cjs)",
            "// mode: 2 => default-with-named (esm-cjs compat)",
            "// mode: 3 => dynamic (if exports has __esModule, then esm, otherwise default-with-named)",
            "",
            "var cachedModule = __webpack_module_cache__[moduleId];",
            ...(strictError ? strictModuleCache : nonStrictModuleCache),
            "",
            `var init = ${runtimeTemplate.basicFunction("", [
                `ns = ${RuntimeGlobals.require}(moduleId);`,
                hasAsync
                    ? `if (${RuntimeGlobals.asyncModuleExportSymbol} in ns) ns = ns[${RuntimeGlobals.asyncModuleExportSymbol}];`
                    : "",
                "init = null;",
                "if (mode == 0 || mode == 3 && ns.__esModule && typeof ns === 'object') {",
                Template.indent([
                    "delete handler.defineProperty;",
                    "delete handler.deleteProperty;",
                    "delete handler.set;",
                    "delete handler.get;",
                    "delete handler.has;",
                    "delete handler.ownKeys;",
                    "delete handler.getOwnPropertyDescriptor;"
                ]),
                "} else if (mode == 1) {",
                Template.indent([
                    `ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns);`
                ]),
                "} else if (mode == 2) {",
                Template.indent([
                    `ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns, 2);`
                ]),
                "} else if (mode == 3) {",
                Template.indent([
                    `ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns, 6);`
                ]),
                "}"
            ])};`,
            "",
            `var ns = ${
                strictError ? "" : "cachedModule && cachedModule.exports || "
            }__webpack_module_deferred_exports__[moduleId] || (__webpack_module_deferred_exports__[moduleId] = { __proto__: null });`,
            "var handler = {",
            Template.indent([
                "__proto__: null,",
                `get: ${runtimeTemplate.basicFunction("_, name", [
                    "switch (name) {",
                    Template.indent([
                        'case "__esModule": return true;',
                        'case Symbol.toStringTag: return "Deferred Module";',
                        'case "then": return undefined;'
                    ]),
                    "}",
                    init,
                    "return ns[name];"
                ])},`,
                `has: ${runtimeTemplate.basicFunction("_, name", [
                    "switch (name) {",
                    Template.indent(
                        [
                            'case "__esModule":',
                            "case Symbol.toStringTag:",
                            hasAsync
                                ? `case ${RuntimeGlobals.makeDeferredNamespaceObjectSymbol}:`
                                : "",
                            Template.indent("return true;"),
                            'case "then":',
                            Template.indent("return false;")
                        ].filter(Boolean)
                    ),
                    "}",
                    init,
                    "return name in ns;"
                ])},`,
                `ownKeys: ${runtimeTemplate.basicFunction("", [
                    init,
                    `var keys = Reflect.ownKeys(ns).filter(${runtimeTemplate.expressionFunction('x !== "then"', "x")}).concat([Symbol.toStringTag]);`,
                    "return keys;"
                ])},`,
                `getOwnPropertyDescriptor: ${runtimeTemplate.basicFunction("_, name", [
                    "switch (name) {",
                    Template.indent([
                        'case "__esModule": return { value: true, configurable: !!mode };',
                        'case Symbol.toStringTag: return { value: "Deferred Module", configurable: !!mode };',
                        'case "then": return undefined;'
                    ]),
                    "}",
                    init,
                    "var desc = Reflect.getOwnPropertyDescriptor(ns, name);",
                    'if (mode == 2 && name == "default" && !desc) {',
                    Template.indent("desc = { value: ns, configurable: true };"),
                    "}",
                    "return desc;"
                ])},`,
                `defineProperty: ${runtimeTemplate.basicFunction("_, name", [
                    init,
                    // Note: This behavior does not match the spec one, but since webpack does not do it either
                    // for a normal Module Namespace object (in MakeNamespaceObjectRuntimeModule), let's keep it simple.
                    "return false;"
                ])},`,
                `deleteProperty: ${runtimeTemplate.returningFunction("false")},`,
                `set: ${runtimeTemplate.returningFunction("false")},`
            ]),
            "}",
            // we don't fully emulate ES Module semantics in this Proxy to align with normal webpack esm namespace object.
            "return new Proxy(ns, handler);"
        ])};`;
    }
}
 
module.exports = MakeDeferredNamespaceObjectRuntimeModule;
module.exports.getMakeDeferredNamespaceModeFromExportsType =
    getMakeDeferredNamespaceModeFromExportsType;
module.exports.getOptimizedDeferredModule = getOptimizedDeferredModule;