@modern-js/plugin-garfish 2.35.1 → 2.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli/index.js +62 -63
- package/dist/cjs/cli/utils.js +31 -24
- package/dist/cjs/deps/index.js +35 -9
- package/dist/cjs/index.js +37 -10
- package/dist/cjs/runtime/index.js +43 -28
- package/dist/cjs/runtime/loadable.js +35 -18
- package/dist/cjs/runtime/plugin.js +62 -45
- package/dist/cjs/runtime/useModuleApps.js +43 -24
- package/dist/cjs/runtime/utils/Context.js +37 -18
- package/dist/cjs/runtime/utils/MApp.js +61 -35
- package/dist/cjs/runtime/utils/apps.js +61 -43
- package/dist/cjs/runtime/utils/setExternal.js +40 -18
- package/dist/cjs/util.js +39 -21
- package/dist/esm/cli/index.js +37 -40
- package/dist/esm/cli/utils.js +12 -5
- package/dist/esm/deps/index.js +4 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/runtime/index.js +10 -3
- package/dist/esm/runtime/loadable.js +8 -5
- package/dist/esm/runtime/plugin.js +13 -10
- package/dist/esm/runtime/useModuleApps.js +8 -4
- package/dist/esm/runtime/utils/Context.js +4 -1
- package/dist/esm/runtime/utils/MApp.js +8 -5
- package/dist/esm/runtime/utils/apps.js +12 -8
- package/dist/esm/runtime/utils/setExternal.js +4 -1
- package/dist/esm/util.js +8 -3
- package/dist/esm-node/cli/index.js +23 -25
- package/dist/esm-node/cli/utils.js +12 -5
- package/dist/esm-node/deps/index.js +4 -1
- package/dist/esm-node/index.js +4 -1
- package/dist/esm-node/runtime/index.js +10 -3
- package/dist/esm-node/runtime/loadable.js +4 -1
- package/dist/esm-node/runtime/plugin.js +4 -1
- package/dist/esm-node/runtime/useModuleApps.js +6 -2
- package/dist/esm-node/runtime/utils/Context.js +4 -1
- package/dist/esm-node/runtime/utils/MApp.js +4 -1
- package/dist/esm-node/runtime/utils/apps.js +6 -2
- package/dist/esm-node/runtime/utils/setExternal.js +4 -1
- package/dist/esm-node/util.js +8 -3
- package/package.json +10 -10
package/dist/cjs/cli/index.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return externals;
|
|
15
|
-
},
|
|
16
|
-
getDefaultMicroFrontedConfig: function() {
|
|
17
|
-
return getDefaultMicroFrontedConfig;
|
|
18
|
-
},
|
|
19
|
-
garfishPlugin: function() {
|
|
20
|
-
return garfishPlugin;
|
|
21
|
-
},
|
|
22
|
-
default: function() {
|
|
23
|
-
return _default;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cli_exports = {};
|
|
20
|
+
__export(cli_exports, {
|
|
21
|
+
default: () => cli_default,
|
|
22
|
+
externals: () => externals,
|
|
23
|
+
garfishPlugin: () => garfishPlugin,
|
|
24
|
+
getDefaultMicroFrontedConfig: () => getDefaultMicroFrontedConfig
|
|
25
25
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
module.exports = __toCommonJS(cli_exports);
|
|
27
|
+
var import_utils = require("@modern-js/utils");
|
|
28
|
+
var import_util = require("../util");
|
|
29
|
+
var import_utils2 = require("./utils");
|
|
29
30
|
const externals = {
|
|
30
31
|
"react-dom": "react-dom",
|
|
31
32
|
react: "react"
|
|
@@ -81,7 +82,7 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
81
82
|
},
|
|
82
83
|
resolvedConfig: async (config) => {
|
|
83
84
|
const { resolved } = config;
|
|
84
|
-
const { masterApp, router } = (0,
|
|
85
|
+
const { masterApp, router } = (0, import_utils2.getRuntimeConfig)(resolved);
|
|
85
86
|
const nConfig = {
|
|
86
87
|
resolved: {
|
|
87
88
|
...resolved
|
|
@@ -94,13 +95,13 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
94
95
|
if (Array.isArray(baseUrl)) {
|
|
95
96
|
throw new Error("Now Micro-Front-End mode dose not support multiple baseUrl, you can set it as a string");
|
|
96
97
|
}
|
|
97
|
-
(0,
|
|
98
|
+
(0, import_utils2.setRuntimeConfig)(nConfig.resolved, "masterApp", Object.assign(typeof masterApp === "object" ? {
|
|
98
99
|
...masterApp
|
|
99
100
|
} : {}, {
|
|
100
101
|
basename: baseUrl || (router === null || router === void 0 ? void 0 : (_router_historyOptions = router.historyOptions) === null || _router_historyOptions === void 0 ? void 0 : _router_historyOptions.basename) || (router === null || router === void 0 ? void 0 : router.basename) || "/"
|
|
101
102
|
}));
|
|
102
103
|
}
|
|
103
|
-
(0,
|
|
104
|
+
(0, import_util.logger)(`resolvedConfig`, {
|
|
104
105
|
output: nConfig.resolved.output,
|
|
105
106
|
runtime: nConfig.resolved.runtime,
|
|
106
107
|
deploy: nConfig.resolved.deploy,
|
|
@@ -111,9 +112,9 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
111
112
|
config() {
|
|
112
113
|
var _useConfig_output, _useConfig_deploy;
|
|
113
114
|
const useConfig = useConfigContext();
|
|
114
|
-
(0,
|
|
115
|
+
(0, import_util.logger)("useConfig", useConfig);
|
|
115
116
|
const config = useAppContext();
|
|
116
|
-
pluginsExportsUtils = (0,
|
|
117
|
+
pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(config.internalDirectory, "plugins");
|
|
117
118
|
let disableCssExtract = ((_useConfig_output = useConfig.output) === null || _useConfig_output === void 0 ? void 0 : _useConfig_output.disableCssExtract) || false;
|
|
118
119
|
if ((_useConfig_deploy = useConfig.deploy) === null || _useConfig_deploy === void 0 ? void 0 : _useConfig_deploy.microFrontend) {
|
|
119
120
|
var _useConfig_deploy1;
|
|
@@ -138,15 +139,6 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
138
139
|
"Access-Control-Allow-Origin": "*"
|
|
139
140
|
}
|
|
140
141
|
},
|
|
141
|
-
webpackChain: (chain, { webpack, CHAIN_ID }) => {
|
|
142
|
-
if (webpack.BannerPlugin) {
|
|
143
|
-
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [
|
|
144
|
-
{
|
|
145
|
-
banner: "Micro front-end"
|
|
146
|
-
}
|
|
147
|
-
]);
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
142
|
rspack: (config2) => {
|
|
151
143
|
var _resolveOptions_deploy;
|
|
152
144
|
var _config;
|
|
@@ -156,23 +148,24 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
156
148
|
if ((resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) && !config2.externalsType) {
|
|
157
149
|
config2.externalsType = "commonjs";
|
|
158
150
|
}
|
|
159
|
-
const banner = config2.builtins.banner || [];
|
|
160
|
-
config2.builtins.banner = [
|
|
161
|
-
...Array.isArray(banner) ? banner : [
|
|
162
|
-
banner
|
|
163
|
-
],
|
|
164
|
-
{
|
|
165
|
-
banner: "Micro front-end"
|
|
166
|
-
}
|
|
167
|
-
];
|
|
168
151
|
},
|
|
169
|
-
bundlerChain: (chain, { env, CHAIN_ID }) => {
|
|
152
|
+
bundlerChain: (chain, { env, CHAIN_ID, bundler }) => {
|
|
170
153
|
var _resolveOptions_deploy, _resolveConfig_resolve;
|
|
154
|
+
if (bundler.BannerPlugin) {
|
|
155
|
+
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(bundler.BannerPlugin, [
|
|
156
|
+
{
|
|
157
|
+
banner: "Micro front-end"
|
|
158
|
+
}
|
|
159
|
+
]);
|
|
160
|
+
}
|
|
171
161
|
const resolveOptions = useResolvedConfigContext();
|
|
172
162
|
if (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
|
|
173
|
-
var _useConfig_dev, _resolveOptions_server, _resolveOptions_deploy1;
|
|
163
|
+
var _resolveOptions_dev, _useConfig_dev, _resolveOptions_server, _resolveOptions_deploy1;
|
|
174
164
|
chain.output.libraryTarget("umd");
|
|
175
|
-
|
|
165
|
+
const DEFAULT_ASSET_PREFIX = "/";
|
|
166
|
+
const resolvedAssetPrefix = (_resolveOptions_dev = resolveOptions.dev) === null || _resolveOptions_dev === void 0 ? void 0 : _resolveOptions_dev.assetPrefix;
|
|
167
|
+
const isUsingDefaultAssetPrefix = !((_useConfig_dev = useConfig.dev) === null || _useConfig_dev === void 0 ? void 0 : _useConfig_dev.assetPrefix) && (!resolvedAssetPrefix || resolvedAssetPrefix === DEFAULT_ASSET_PREFIX);
|
|
168
|
+
if (isUsingDefaultAssetPrefix && (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_server = resolveOptions.server) === null || _resolveOptions_server === void 0 ? void 0 : _resolveOptions_server.port) && env === "development") {
|
|
176
169
|
chain.output.publicPath(`//localhost:${resolveOptions.server.port}/`);
|
|
177
170
|
}
|
|
178
171
|
const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig((_resolveOptions_deploy1 = resolveOptions.deploy) === null || _resolveOptions_deploy1 === void 0 ? void 0 : _resolveOptions_deploy1.microFrontend);
|
|
@@ -193,7 +186,7 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
193
186
|
chain.output.uniqueName(config.packageName);
|
|
194
187
|
}
|
|
195
188
|
const resolveConfig = chain.toConfig();
|
|
196
|
-
(0,
|
|
189
|
+
(0, import_util.logger)("bundlerConfig", {
|
|
197
190
|
output: resolveConfig.output,
|
|
198
191
|
externals: resolveConfig.externals,
|
|
199
192
|
env,
|
|
@@ -206,19 +199,19 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
206
199
|
},
|
|
207
200
|
addRuntimeExports() {
|
|
208
201
|
const config = useResolvedConfigContext();
|
|
209
|
-
const { masterApp } = (0,
|
|
202
|
+
const { masterApp } = (0, import_utils2.getRuntimeConfig)(config);
|
|
210
203
|
if (masterApp) {
|
|
211
204
|
const addExportStatement = `export { default as garfish, default as masterApp } from '${pluginName}/runtime'`;
|
|
212
|
-
(0,
|
|
205
|
+
(0, import_util.logger)("exportStatement", addExportStatement);
|
|
213
206
|
pluginsExportsUtils.addExport(addExportStatement);
|
|
214
207
|
}
|
|
215
208
|
const otherExportStatement = `export { hoistNonReactStatics } from '${pluginName}/deps'`;
|
|
216
|
-
(0,
|
|
209
|
+
(0, import_util.logger)("otherExportStatement", otherExportStatement);
|
|
217
210
|
pluginsExportsUtils.addExport(otherExportStatement);
|
|
218
211
|
},
|
|
219
212
|
modifyEntryImports({ entrypoint, imports }) {
|
|
220
213
|
const config = useResolvedConfigContext();
|
|
221
|
-
const { masterApp } = (0,
|
|
214
|
+
const { masterApp } = (0, import_utils2.getRuntimeConfig)(config);
|
|
222
215
|
if (masterApp) {
|
|
223
216
|
imports.push({
|
|
224
217
|
value: runtimePluginName,
|
|
@@ -263,9 +256,9 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
263
256
|
},
|
|
264
257
|
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
|
265
258
|
const config = useResolvedConfigContext();
|
|
266
|
-
const { masterApp } = (0,
|
|
259
|
+
const { masterApp } = (0, import_utils2.getRuntimeConfig)(config);
|
|
267
260
|
if (masterApp) {
|
|
268
|
-
(0,
|
|
261
|
+
(0, import_util.logger)("garfishPlugin options", masterApp);
|
|
269
262
|
plugins.push({
|
|
270
263
|
name: "garfish",
|
|
271
264
|
args: "masterApp",
|
|
@@ -286,8 +279,8 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
286
279
|
code
|
|
287
280
|
};
|
|
288
281
|
}
|
|
289
|
-
const nCode = (0,
|
|
290
|
-
(0,
|
|
282
|
+
const nCode = (0, import_utils2.makeRenderFunction)(code);
|
|
283
|
+
(0, import_util.logger)("makeRenderFunction", nCode);
|
|
291
284
|
return {
|
|
292
285
|
entrypoint,
|
|
293
286
|
code: nCode
|
|
@@ -298,7 +291,7 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
298
291
|
const config = useResolvedConfigContext();
|
|
299
292
|
let finalCode = code;
|
|
300
293
|
if ((config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) && (config === null || config === void 0 ? void 0 : (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.enableAsyncEntry)) {
|
|
301
|
-
finalCode = (0,
|
|
294
|
+
finalCode = (0, import_utils2.generateAsyncEntry)(code);
|
|
302
295
|
return {
|
|
303
296
|
entrypoint,
|
|
304
297
|
code: `${finalCode}`
|
|
@@ -313,8 +306,8 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
313
306
|
var _config_deploy;
|
|
314
307
|
const config = useResolvedConfigContext();
|
|
315
308
|
if (config === null || config === void 0 ? void 0 : (_config_deploy = config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
|
|
316
|
-
const exportStatementCode = (0,
|
|
317
|
-
(0,
|
|
309
|
+
const exportStatementCode = (0, import_utils2.makeProvider)();
|
|
310
|
+
(0, import_util.logger)("exportStatement", exportStatementCode);
|
|
318
311
|
return {
|
|
319
312
|
entrypoint,
|
|
320
313
|
exportStatement: exportStatementCode
|
|
@@ -328,4 +321,10 @@ const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePlugin
|
|
|
328
321
|
};
|
|
329
322
|
}
|
|
330
323
|
});
|
|
331
|
-
|
|
324
|
+
var cli_default = garfishPlugin;
|
|
325
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
326
|
+
0 && (module.exports = {
|
|
327
|
+
externals,
|
|
328
|
+
garfishPlugin,
|
|
329
|
+
getDefaultMicroFrontedConfig
|
|
330
|
+
});
|
package/dist/cjs/cli/utils.js
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return makeProvider;
|
|
15
|
-
},
|
|
16
|
-
makeRenderFunction: function() {
|
|
17
|
-
return makeRenderFunction;
|
|
18
|
-
},
|
|
19
|
-
getRuntimeConfig: function() {
|
|
20
|
-
return getRuntimeConfig;
|
|
21
|
-
},
|
|
22
|
-
setRuntimeConfig: function() {
|
|
23
|
-
return setRuntimeConfig;
|
|
24
|
-
},
|
|
25
|
-
generateAsyncEntry: function() {
|
|
26
|
-
return generateAsyncEntry;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
generateAsyncEntry: () => generateAsyncEntry,
|
|
22
|
+
getRuntimeConfig: () => getRuntimeConfig,
|
|
23
|
+
makeProvider: () => makeProvider,
|
|
24
|
+
makeRenderFunction: () => makeRenderFunction,
|
|
25
|
+
setRuntimeConfig: () => setRuntimeConfig
|
|
28
26
|
});
|
|
27
|
+
module.exports = __toCommonJS(utils_exports);
|
|
29
28
|
const makeProvider = () => `
|
|
30
29
|
export const provider = function ({basename, dom}) {
|
|
31
30
|
return {
|
|
@@ -147,3 +146,11 @@ const generateAsyncEntry = (code) => {
|
|
|
147
146
|
}
|
|
148
147
|
`;
|
|
149
148
|
};
|
|
149
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
150
|
+
0 && (module.exports = {
|
|
151
|
+
generateAsyncEntry,
|
|
152
|
+
getRuntimeConfig,
|
|
153
|
+
makeProvider,
|
|
154
|
+
makeRenderFunction,
|
|
155
|
+
setRuntimeConfig
|
|
156
|
+
});
|
package/dist/cjs/deps/index.js
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var deps_exports = {};
|
|
30
|
+
__export(deps_exports, {
|
|
31
|
+
hoistNonReactStatics: () => import_hoist_non_react_statics.default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(deps_exports);
|
|
34
|
+
var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
hoistNonReactStatics
|
|
10
38
|
});
|
|
11
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
12
|
-
const _hoistnonreactstatics = /* @__PURE__ */ _interop_require_default._(require("hoist-non-react-statics"));
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,13 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var src_exports = {};
|
|
31
|
+
__export(src_exports, {
|
|
32
|
+
default: () => import_runtime.default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(src_exports);
|
|
35
|
+
var import_runtime = __toESM(require("./runtime"));
|
|
36
|
+
__reExport(src_exports, require("./runtime"), module.exports);
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
...require("./runtime")
|
|
10
40
|
});
|
|
11
|
-
const _export_star = require("@swc/helpers/_/_export_star");
|
|
12
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
13
|
-
const _runtime = /* @__PURE__ */ _interop_require_default._(_export_star._(require("./runtime"), exports));
|
|
@@ -1,32 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return _plugin.default;
|
|
15
|
-
},
|
|
16
|
-
useModuleApps: function() {
|
|
17
|
-
return _useModuleApps.useModuleApps;
|
|
18
|
-
},
|
|
19
|
-
useModuleApp: function() {
|
|
20
|
-
return _useModuleApps.useModuleApp;
|
|
21
|
-
},
|
|
22
|
-
Garfish: function() {
|
|
23
|
-
return _garfish.default;
|
|
24
|
-
},
|
|
25
|
-
garfish: function() {
|
|
26
|
-
return _garfish.default;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var runtime_exports = {};
|
|
30
|
+
__export(runtime_exports, {
|
|
31
|
+
Garfish: () => import_garfish.default,
|
|
32
|
+
default: () => import_plugin.default,
|
|
33
|
+
garfish: () => import_garfish.default,
|
|
34
|
+
useModuleApp: () => import_useModuleApps.useModuleApp,
|
|
35
|
+
useModuleApps: () => import_useModuleApps.useModuleApps
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
38
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
39
|
+
var import_useModuleApps = require("./useModuleApps");
|
|
40
|
+
var import_garfish = __toESM(require("garfish"));
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
Garfish,
|
|
44
|
+
garfish,
|
|
45
|
+
useModuleApp,
|
|
46
|
+
useModuleApps
|
|
28
47
|
});
|
|
29
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
30
|
-
const _plugin = /* @__PURE__ */ _interop_require_default._(require("./plugin"));
|
|
31
|
-
const _useModuleApps = require("./useModuleApps");
|
|
32
|
-
const _garfish = /* @__PURE__ */ _interop_require_default._(require("garfish"));
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var loadable_exports = {};
|
|
20
|
+
__export(loadable_exports, {
|
|
21
|
+
Loadable: () => Loadable
|
|
10
22
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
module.exports = __toCommonJS(loadable_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_util = require("../util");
|
|
14
27
|
const DEFAULT_LOADABLE = {
|
|
15
28
|
delay: 200,
|
|
16
29
|
timeout: 1e4,
|
|
@@ -23,7 +36,7 @@ function Loadable(WrapComponent) {
|
|
|
23
36
|
const { loadable = defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE, ...otherProps } = props;
|
|
24
37
|
let delayTimer = null;
|
|
25
38
|
let timeoutTimer = null;
|
|
26
|
-
const [state, setState] = (0,
|
|
39
|
+
const [state, setState] = (0, import_react.useState)(() => {
|
|
27
40
|
const { delay, timeout } = loadable;
|
|
28
41
|
const initState = {
|
|
29
42
|
error: null,
|
|
@@ -52,8 +65,8 @@ function Loadable(WrapComponent) {
|
|
|
52
65
|
return initState;
|
|
53
66
|
});
|
|
54
67
|
const LoadingComponent = (_props_loadable = props.loadable) === null || _props_loadable === void 0 ? void 0 : _props_loadable.loading;
|
|
55
|
-
(0,
|
|
56
|
-
(0,
|
|
68
|
+
(0, import_react.useEffect)(() => {
|
|
69
|
+
(0, import_util.logger)("Loadable render state", {
|
|
57
70
|
state,
|
|
58
71
|
props: otherProps,
|
|
59
72
|
loadable,
|
|
@@ -74,7 +87,7 @@ function Loadable(WrapComponent) {
|
|
|
74
87
|
}
|
|
75
88
|
};
|
|
76
89
|
}, []);
|
|
77
|
-
const retry = (0,
|
|
90
|
+
const retry = (0, import_react.useCallback)(() => {
|
|
78
91
|
setState({
|
|
79
92
|
...state,
|
|
80
93
|
error: null,
|
|
@@ -84,7 +97,7 @@ function Loadable(WrapComponent) {
|
|
|
84
97
|
}, [
|
|
85
98
|
state
|
|
86
99
|
]);
|
|
87
|
-
const setStateWithMountCheck = (0,
|
|
100
|
+
const setStateWithMountCheck = (0, import_react.useCallback)((newState) => {
|
|
88
101
|
setState((state2) => ({
|
|
89
102
|
...state2,
|
|
90
103
|
...newState
|
|
@@ -93,16 +106,16 @@ function Loadable(WrapComponent) {
|
|
|
93
106
|
state
|
|
94
107
|
]);
|
|
95
108
|
const showLoading = (state.isLoading || state.error) && LoadingComponent;
|
|
96
|
-
return /* @__PURE__ */ (0,
|
|
109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
97
110
|
children: [
|
|
98
|
-
showLoading && /* @__PURE__ */ (0,
|
|
111
|
+
showLoading && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingComponent, {
|
|
99
112
|
isLoading: state.isLoading,
|
|
100
113
|
pastDelay: state.pastDelay,
|
|
101
114
|
timedOut: state.timedOut,
|
|
102
115
|
error: state === null || state === void 0 ? void 0 : state.error,
|
|
103
116
|
retry
|
|
104
117
|
}),
|
|
105
|
-
/* @__PURE__ */ (0,
|
|
118
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(WrapComponent, {
|
|
106
119
|
style: {
|
|
107
120
|
display: showLoading ? "none" : "block"
|
|
108
121
|
},
|
|
@@ -119,3 +132,7 @@ function Loadable(WrapComponent) {
|
|
|
119
132
|
};
|
|
120
133
|
};
|
|
121
134
|
}
|
|
135
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
+
0 && (module.exports = {
|
|
137
|
+
Loadable
|
|
138
|
+
});
|