@module-federation/data-prefetch 1.0.16 → 2.0.1

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.
Files changed (98) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -1
  3. package/dist/LICENSE +21 -0
  4. package/dist/babel.cjs +95 -0
  5. package/dist/babel.d.ts +1 -0
  6. package/dist/babel.js +5 -0
  7. package/dist/cli/babel.cjs +115 -0
  8. package/dist/cli/babel.d.ts +2 -4
  9. package/dist/cli/babel.js +50 -82
  10. package/dist/cli/index.cjs +217 -0
  11. package/dist/cli/index.d.ts +5 -8
  12. package/dist/cli/index.js +150 -197
  13. package/dist/cli.cjs +95 -0
  14. package/dist/cli.d.ts +1 -0
  15. package/dist/cli.js +5 -0
  16. package/dist/common/constant.cjs +51 -0
  17. package/dist/common/constant.d.ts +1 -0
  18. package/dist/common/constant.js +5 -0
  19. package/dist/common/index.cjs +95 -0
  20. package/dist/common/index.js +5 -0
  21. package/dist/common/node-utils.cjs +100 -0
  22. package/dist/common/node-utils.d.ts +2 -0
  23. package/dist/common/node-utils.js +35 -0
  24. package/dist/common/runtime-utils.cjs +84 -0
  25. package/dist/common/runtime-utils.d.ts +5 -0
  26. package/dist/common/runtime-utils.js +29 -0
  27. package/dist/constant.cjs +51 -0
  28. package/dist/constant.d.ts +1 -0
  29. package/dist/constant.js +5 -0
  30. package/dist/index.cjs +106 -0
  31. package/dist/index.d.ts +2 -5
  32. package/dist/index.js +3 -346
  33. package/dist/logger/index.cjs +60 -0
  34. package/dist/logger/index.d.ts +2 -0
  35. package/dist/logger/index.js +10 -0
  36. package/dist/plugin.cjs +234 -0
  37. package/dist/plugin.d.ts +3 -5
  38. package/dist/plugin.js +167 -340
  39. package/dist/prefetch.cjs +197 -0
  40. package/dist/{prefetch-4e9646e4.d.ts → prefetch.d.ts} +14 -17
  41. package/dist/prefetch.js +149 -0
  42. package/dist/react/hooks.cjs +144 -0
  43. package/dist/react/hooks.d.ts +11 -0
  44. package/dist/react/hooks.js +86 -0
  45. package/dist/react/index.cjs +95 -0
  46. package/dist/react/index.d.ts +1 -16
  47. package/dist/react/index.js +2 -283
  48. package/dist/react/utils.cjs +65 -0
  49. package/dist/react/utils.d.ts +1 -0
  50. package/dist/react/utils.js +15 -0
  51. package/dist/react.cjs +95 -0
  52. package/dist/react.d.ts +1 -0
  53. package/dist/react.js +5 -0
  54. package/dist/universal/index.cjs +81 -0
  55. package/dist/universal/index.d.ts +2 -8
  56. package/dist/universal/index.js +24 -196
  57. package/dist/universal.cjs +95 -0
  58. package/dist/universal.d.ts +1 -0
  59. package/dist/universal.js +5 -0
  60. package/package.json +76 -40
  61. package/CHANGELOG.md +0 -9
  62. package/__tests__/babel.spec.ts +0 -75
  63. package/__tests__/prefetch.spec.ts +0 -138
  64. package/__tests__/react.spec.ts +0 -119
  65. package/dist/esm/chunk-AJPO2B2T.js +0 -30
  66. package/dist/esm/chunk-EZUCZHGV.js +0 -11
  67. package/dist/esm/chunk-ISLXMAIA.js +0 -155
  68. package/dist/esm/chunk-KI4QGPIS.js +0 -32
  69. package/dist/esm/chunk-TTJJJ2WZ.js +0 -7
  70. package/dist/esm/chunk-VVZ6XIM6.js +0 -166
  71. package/dist/esm/cli/babel.js +0 -57
  72. package/dist/esm/cli/index.js +0 -178
  73. package/dist/esm/index.js +0 -13
  74. package/dist/esm/plugin.js +0 -12
  75. package/dist/esm/react/index.js +0 -94
  76. package/dist/esm/shared/index.js +0 -27
  77. package/dist/esm/universal/index.js +0 -9
  78. package/dist/shared/index.d.ts +0 -5
  79. package/dist/shared/index.js +0 -48
  80. package/jest.config.js +0 -29
  81. package/project.json +0 -21
  82. package/src/cli/babel.ts +0 -94
  83. package/src/cli/index.ts +0 -171
  84. package/src/common/constant.ts +0 -1
  85. package/src/common/node-utils.ts +0 -24
  86. package/src/common/runtime-utils.ts +0 -34
  87. package/src/index.ts +0 -2
  88. package/src/logger/index.ts +0 -3
  89. package/src/plugin.ts +0 -191
  90. package/src/prefetch.ts +0 -207
  91. package/src/react/hooks.ts +0 -95
  92. package/src/react/index.ts +0 -1
  93. package/src/react/utils.ts +0 -11
  94. package/src/shared/index.ts +0 -26
  95. package/src/universal/index.ts +0 -27
  96. package/tsconfig.json +0 -27
  97. package/tsup.config.ts +0 -35
  98. /package/{src/common/index.ts → dist/common/index.d.ts} +0 -0
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ var __webpack_modules__ = ({
10
+ "./hooks": (function (module) {
11
+ module.exports = require("./hooks.cjs");
12
+
13
+ }),
14
+
15
+ });
16
+ /************************************************************************/
17
+ // The module cache
18
+ var __webpack_module_cache__ = {};
19
+
20
+ // The require function
21
+ function __webpack_require__(moduleId) {
22
+
23
+ // Check if module is in cache
24
+ var cachedModule = __webpack_module_cache__[moduleId];
25
+ if (cachedModule !== undefined) {
26
+ return cachedModule.exports;
27
+ }
28
+ // Create a new module (and put it into the cache)
29
+ var module = (__webpack_module_cache__[moduleId] = {
30
+ exports: {}
31
+ });
32
+ // Execute the module function
33
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
34
+
35
+ // Return the exports of the module
36
+ return module.exports;
37
+
38
+ }
39
+
40
+ /************************************************************************/
41
+ // webpack/runtime/compat_get_default_export
42
+ (() => {
43
+ // getDefaultExport function for compatibility with non-ESM modules
44
+ __webpack_require__.n = (module) => {
45
+ var getter = module && module.__esModule ?
46
+ () => (module['default']) :
47
+ () => (module);
48
+ __webpack_require__.d(getter, { a: getter });
49
+ return getter;
50
+ };
51
+
52
+ })();
53
+ // webpack/runtime/define_property_getters
54
+ (() => {
55
+ __webpack_require__.d = (exports, definition) => {
56
+ for(var key in definition) {
57
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
58
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
59
+ }
60
+ }
61
+ };
62
+ })();
63
+ // webpack/runtime/has_own_property
64
+ (() => {
65
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
66
+ })();
67
+ // webpack/runtime/make_namespace_object
68
+ (() => {
69
+ // define __esModule on exports
70
+ __webpack_require__.r = (exports) => {
71
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
72
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
73
+ }
74
+ Object.defineProperty(exports, '__esModule', { value: true });
75
+ };
76
+ })();
77
+ /************************************************************************/
78
+ var __webpack_exports__ = {};
79
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
80
+ (() => {
81
+ __webpack_require__.r(__webpack_exports__);
82
+ /* ESM import */var _hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./hooks");
83
+ /* ESM import */var _hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_hooks__WEBPACK_IMPORTED_MODULE_0__);
84
+
85
+ /* ESM reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
86
+ /* ESM reexport (unknown) */ for( var __WEBPACK_IMPORT_KEY__ in _hooks__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== "default") __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] =function(key) { return _hooks__WEBPACK_IMPORTED_MODULE_0__[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)
87
+ /* ESM reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
88
+
89
+
90
+ })();
91
+
92
+ for(var __webpack_i__ in __webpack_exports__) {
93
+ exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
94
+ }
95
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,16 +1 @@
1
- import { p as prefetchOptions } from '../prefetch-4e9646e4.js';
2
- import '@module-federation/runtime';
3
- import '@module-federation/sdk';
4
- import '@module-federation/runtime/types';
5
-
6
- type refetchParams = any;
7
- type prefetchReturnType<T> = [
8
- Promise<T>,
9
- (refetchParams?: refetchParams) => void
10
- ];
11
- type UsePrefetchOptions = prefetchOptions & {
12
- deferId?: string;
13
- };
14
- declare const usePrefetch: <T>(options: UsePrefetchOptions) => prefetchReturnType<T>;
15
-
16
- export { usePrefetch };
1
+ export * from './hooks';
@@ -1,286 +1,5 @@
1
- "use strict";
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 });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ export * from "./hooks.js";
19
2
 
20
- // src/react/index.ts
21
- var react_exports = {};
22
- __export(react_exports, {
23
- usePrefetch: () => usePrefetch
24
- });
25
- module.exports = __toCommonJS(react_exports);
3
+ ;// CONCATENATED MODULE: ./src/react/index.ts
26
4
 
27
- // src/react/hooks.ts
28
- var import_react2 = require("react");
29
5
 
30
- // src/logger/index.ts
31
- var import_sdk = require("@module-federation/sdk");
32
- var logger_default = new import_sdk.Logger("[Module Federation Data Prefetch]");
33
-
34
- // src/prefetch.ts
35
- var import_runtime2 = require("@module-federation/runtime");
36
- var import_sdk3 = require("@module-federation/sdk");
37
-
38
- // src/common/runtime-utils.ts
39
- var import_runtime = require("@module-federation/runtime");
40
- var import_sdk2 = require("@module-federation/sdk");
41
- var getScope = () => {
42
- return (0, import_runtime.getInstance)().options.name;
43
- };
44
- var getPrefetchId = (id) => (0, import_sdk2.encodeName)(`${id}/${import_sdk2.MFPrefetchCommon.identifier}`);
45
- var compatGetPrefetchId = (id) => (0, import_sdk2.encodeName)(`${id}/VmokPrefetch`);
46
-
47
- // src/prefetch.ts
48
- globalThis.__FEDERATION__ ?? (globalThis.__FEDERATION__ = {});
49
- var _a;
50
- (_a = globalThis.__FEDERATION__).__PREFETCH__ ?? (_a.__PREFETCH__ = {
51
- entryLoading: {},
52
- instance: /* @__PURE__ */ new Map(),
53
- __PREFETCH_EXPORTS__: {}
54
- });
55
- var MFDataPrefetch = class {
56
- constructor(options) {
57
- this.prefetchMemory = /* @__PURE__ */ new Map();
58
- this.recordOutdate = {};
59
- this._exports = {};
60
- this._options = options;
61
- this.global.instance.set(options.name, this);
62
- }
63
- get global() {
64
- return globalThis.__FEDERATION__.__PREFETCH__;
65
- }
66
- static getInstance(id) {
67
- return globalThis.__FEDERATION__.__PREFETCH__.instance.get(id);
68
- }
69
- async loadEntry(entry) {
70
- const { name, remoteSnapshot, remote, origin } = this._options;
71
- if (entry) {
72
- const { buildVersion, globalName } = remoteSnapshot;
73
- const uniqueKey = globalName || `${name}:${buildVersion}`;
74
- if (!this.global.entryLoading[uniqueKey]) {
75
- this.global.entryLoading[uniqueKey] = (0, import_sdk3.loadScript)(entry, {});
76
- }
77
- return this.global.entryLoading[uniqueKey];
78
- } else {
79
- const remoteInfo = (0, import_runtime2.getRemoteInfo)(remote);
80
- const module2 = origin.moduleCache.get(remoteInfo.name);
81
- return (0, import_runtime2.getRemoteEntry)({
82
- origin,
83
- remoteInfo,
84
- remoteEntryExports: module2 ? module2.remoteEntryExports : void 0
85
- });
86
- }
87
- }
88
- getProjectExports() {
89
- var _a2;
90
- if (Object.keys(this._exports).length > 0) {
91
- return this._exports;
92
- }
93
- const { name } = this._options;
94
- const exportsPromise = (_a2 = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _a2[name];
95
- const resolve = exportsPromise.then(
96
- (exports = {}) => {
97
- const memory = {};
98
- Object.keys(exports).forEach((key) => {
99
- memory[key] = {};
100
- const exportVal = exports[key];
101
- Object.keys(exportVal).reduce(
102
- (memo, current) => {
103
- if (current.toLocaleLowerCase().endsWith("prefetch") || current.toLocaleLowerCase() === "default") {
104
- memo[current] = exportVal[current];
105
- }
106
- return memo;
107
- },
108
- memory[key]
109
- );
110
- });
111
- this.memorizeExports(memory);
112
- }
113
- );
114
- return resolve;
115
- }
116
- memorizeExports(exports) {
117
- this._exports = exports;
118
- }
119
- getExposeExports(id) {
120
- const prefetchId = getPrefetchId(id);
121
- const compatId = compatGetPrefetchId(id);
122
- const prefetchExports = this._exports[prefetchId] || this._exports[compatId];
123
- return prefetchExports || {};
124
- }
125
- prefetch(prefetchOptions) {
126
- const { id, functionId = "default", refetchParams } = prefetchOptions;
127
- let prefetchResult;
128
- const prefetchId = getPrefetchId(id);
129
- const compatId = compatGetPrefetchId(id);
130
- const memorizeId = id + functionId;
131
- const memory = this.prefetchMemory.get(memorizeId);
132
- if (!this.checkOutdate(prefetchOptions) && memory) {
133
- return memory;
134
- }
135
- const prefetchExports = this._exports[prefetchId] || this._exports[compatId];
136
- if (!prefetchExports) {
137
- return;
138
- }
139
- const executePrefetch = prefetchExports[functionId];
140
- if (typeof executePrefetch === "function") {
141
- if (refetchParams) {
142
- prefetchResult = executePrefetch(refetchParams);
143
- } else {
144
- prefetchResult = executePrefetch();
145
- }
146
- } else {
147
- throw new Error(
148
- `[Module Federation Data Prefetch]: No prefetch function called ${functionId} export in prefetch file`
149
- );
150
- }
151
- this.memorize(memorizeId, prefetchResult);
152
- return prefetchResult;
153
- }
154
- memorize(id, value) {
155
- this.prefetchMemory.set(id, value);
156
- }
157
- markOutdate(markOptions, isOutdate) {
158
- const { id, functionId = "default" } = markOptions;
159
- if (!this.recordOutdate[id]) {
160
- this.recordOutdate[id] = {};
161
- }
162
- this.recordOutdate[id][functionId] = isOutdate;
163
- }
164
- checkOutdate(outdateOptions) {
165
- const { id, functionId = "default", cacheStrategy } = outdateOptions;
166
- if (typeof cacheStrategy === "function") {
167
- return cacheStrategy();
168
- }
169
- if (!this.recordOutdate[id]) {
170
- this.recordOutdate[id] = {};
171
- }
172
- if (this.recordOutdate[id][functionId]) {
173
- this.markOutdate(
174
- {
175
- id,
176
- functionId
177
- },
178
- false
179
- );
180
- return true;
181
- } else {
182
- return false;
183
- }
184
- }
185
- };
186
-
187
- // src/universal/index.ts
188
- function prefetch(options) {
189
- const { id, functionId = "default" } = options;
190
- const mfScope = getScope();
191
- const prefetchInstance = MFDataPrefetch.getInstance(mfScope) || new MFDataPrefetch({
192
- name: mfScope
193
- });
194
- const res = prefetchInstance.getProjectExports();
195
- if (res instanceof Promise) {
196
- const promise = res.then(() => {
197
- const result = prefetchInstance.prefetch(options);
198
- prefetchInstance.memorize(id + functionId, result);
199
- return result;
200
- });
201
- return promise;
202
- } else {
203
- const result = prefetchInstance.prefetch(options);
204
- prefetchInstance.memorize(id + functionId, result);
205
- return result;
206
- }
207
- }
208
-
209
- // src/react/utils.ts
210
- var import_react = require("react");
211
- var useFirstMounted = () => {
212
- const ref = (0, import_react.useRef)(true);
213
- (0, import_react.useEffect)(() => {
214
- ref.current = false;
215
- }, []);
216
- return ref.current;
217
- };
218
-
219
- // src/react/hooks.ts
220
- var usePrefetch = (options) => {
221
- const isFirstMounted = useFirstMounted();
222
- if (isFirstMounted) {
223
- const startTiming = performance.now();
224
- logger_default.info(
225
- `2. Start Get Prefetch Data: ${options.id} - ${options.functionId || "default"} - ${startTiming}`
226
- );
227
- }
228
- const { id, functionId, deferId } = options;
229
- const prefetchInfo = {
230
- id,
231
- functionId
232
- };
233
- const mfScope = getScope();
234
- let state;
235
- const prefetchResult = prefetch(options);
236
- if (deferId) {
237
- if (prefetchResult instanceof Promise) {
238
- state = prefetchResult.then(
239
- (deferredData) => deferredData.data[deferId]
240
- );
241
- } else {
242
- state = prefetchResult.data[deferId];
243
- }
244
- } else {
245
- state = prefetchResult;
246
- }
247
- const [prefetchState, setPrefetchState] = (0, import_react2.useState)(
248
- state
249
- );
250
- const prefetchInstance = MFDataPrefetch.getInstance(mfScope);
251
- (0, import_react2.useEffect)(() => {
252
- const useEffectTiming = performance.now();
253
- logger_default.info(
254
- `3. Start Execute UseEffect: ${options.id} - ${options.functionId || "default"} - ${useEffectTiming}`
255
- );
256
- return () => {
257
- prefetchInstance == null ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
258
- };
259
- }, []);
260
- const refreshExecutor = (refetchParams) => {
261
- const refetchOptions = {
262
- ...options
263
- };
264
- if (refetchParams) {
265
- refetchOptions.refetchParams = refetchParams;
266
- }
267
- prefetchInstance == null ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
268
- const newVal = prefetch(refetchOptions);
269
- let newState;
270
- if (deferId) {
271
- if (newVal instanceof Promise) {
272
- newState = newVal.then((deferredData) => deferredData.data[deferId]);
273
- } else {
274
- newState = newVal.data[deferId];
275
- }
276
- } else {
277
- newState = newVal;
278
- }
279
- setPrefetchState(newState);
280
- };
281
- return [prefetchState, refreshExecutor];
282
- };
283
- // Annotate the CommonJS export names for ESM import in node:
284
- 0 && (module.exports = {
285
- usePrefetch
286
- });
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ // The require scope
10
+ var __webpack_require__ = {};
11
+
12
+ /************************************************************************/
13
+ // webpack/runtime/define_property_getters
14
+ (() => {
15
+ __webpack_require__.d = (exports, definition) => {
16
+ for(var key in definition) {
17
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
18
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
19
+ }
20
+ }
21
+ };
22
+ })();
23
+ // webpack/runtime/has_own_property
24
+ (() => {
25
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
26
+ })();
27
+ // webpack/runtime/make_namespace_object
28
+ (() => {
29
+ // define __esModule on exports
30
+ __webpack_require__.r = (exports) => {
31
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
32
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33
+ }
34
+ Object.defineProperty(exports, '__esModule', { value: true });
35
+ };
36
+ })();
37
+ /************************************************************************/
38
+ var __webpack_exports__ = {};
39
+ // ESM COMPAT FLAG
40
+ __webpack_require__.r(__webpack_exports__);
41
+
42
+ // EXPORTS
43
+ __webpack_require__.d(__webpack_exports__, {
44
+ useFirstMounted: () => (/* binding */ useFirstMounted)
45
+ });
46
+
47
+ ;// CONCATENATED MODULE: external "react"
48
+ const external_react_namespaceObject = require("react");
49
+ ;// CONCATENATED MODULE: ./src/react/utils.ts
50
+
51
+ const useFirstMounted = ()=>{
52
+ const ref = (0,external_react_namespaceObject.useRef)(true);
53
+ (0,external_react_namespaceObject.useEffect)(()=>{
54
+ ref.current = false;
55
+ }, []);
56
+ return ref.current;
57
+ };
58
+
59
+ exports.useFirstMounted = __webpack_exports__.useFirstMounted;
60
+ for(var __webpack_i__ in __webpack_exports__) {
61
+ if(["useFirstMounted"].indexOf(__webpack_i__) === -1) {
62
+ exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
63
+ }
64
+ }
65
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1 @@
1
+ export declare const useFirstMounted: () => boolean;
@@ -0,0 +1,15 @@
1
+ import { useEffect, useRef } from "react";
2
+
3
+ ;// CONCATENATED MODULE: external "react"
4
+
5
+ ;// CONCATENATED MODULE: ./src/react/utils.ts
6
+
7
+ const useFirstMounted = ()=>{
8
+ const ref = useRef(true);
9
+ useEffect(()=>{
10
+ ref.current = false;
11
+ }, []);
12
+ return ref.current;
13
+ };
14
+
15
+ export { useFirstMounted };
package/dist/react.cjs ADDED
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ var __webpack_modules__ = ({
10
+ "./react/index": (function (module) {
11
+ module.exports = require("./react/index.cjs");
12
+
13
+ }),
14
+
15
+ });
16
+ /************************************************************************/
17
+ // The module cache
18
+ var __webpack_module_cache__ = {};
19
+
20
+ // The require function
21
+ function __webpack_require__(moduleId) {
22
+
23
+ // Check if module is in cache
24
+ var cachedModule = __webpack_module_cache__[moduleId];
25
+ if (cachedModule !== undefined) {
26
+ return cachedModule.exports;
27
+ }
28
+ // Create a new module (and put it into the cache)
29
+ var module = (__webpack_module_cache__[moduleId] = {
30
+ exports: {}
31
+ });
32
+ // Execute the module function
33
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
34
+
35
+ // Return the exports of the module
36
+ return module.exports;
37
+
38
+ }
39
+
40
+ /************************************************************************/
41
+ // webpack/runtime/compat_get_default_export
42
+ (() => {
43
+ // getDefaultExport function for compatibility with non-ESM modules
44
+ __webpack_require__.n = (module) => {
45
+ var getter = module && module.__esModule ?
46
+ () => (module['default']) :
47
+ () => (module);
48
+ __webpack_require__.d(getter, { a: getter });
49
+ return getter;
50
+ };
51
+
52
+ })();
53
+ // webpack/runtime/define_property_getters
54
+ (() => {
55
+ __webpack_require__.d = (exports, definition) => {
56
+ for(var key in definition) {
57
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
58
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
59
+ }
60
+ }
61
+ };
62
+ })();
63
+ // webpack/runtime/has_own_property
64
+ (() => {
65
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
66
+ })();
67
+ // webpack/runtime/make_namespace_object
68
+ (() => {
69
+ // define __esModule on exports
70
+ __webpack_require__.r = (exports) => {
71
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
72
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
73
+ }
74
+ Object.defineProperty(exports, '__esModule', { value: true });
75
+ };
76
+ })();
77
+ /************************************************************************/
78
+ var __webpack_exports__ = {};
79
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
80
+ (() => {
81
+ __webpack_require__.r(__webpack_exports__);
82
+ /* ESM import */var _react_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./react/index");
83
+ /* ESM import */var _react_index__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_react_index__WEBPACK_IMPORTED_MODULE_0__);
84
+
85
+ /* ESM reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
86
+ /* ESM reexport (unknown) */ for( var __WEBPACK_IMPORT_KEY__ in _react_index__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== "default") __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] =function(key) { return _react_index__WEBPACK_IMPORTED_MODULE_0__[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)
87
+ /* ESM reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
88
+
89
+
90
+ })();
91
+
92
+ for(var __webpack_i__ in __webpack_exports__) {
93
+ exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
94
+ }
95
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1 @@
1
+ export * from './react/index';
package/dist/react.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./react/index.js";
2
+
3
+ ;// CONCATENATED MODULE: ./src/react.ts
4
+
5
+
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
7
+ })();
8
+ ;
9
+ // The require scope
10
+ var __webpack_require__ = {};
11
+
12
+ /************************************************************************/
13
+ // webpack/runtime/define_property_getters
14
+ (() => {
15
+ __webpack_require__.d = (exports, definition) => {
16
+ for(var key in definition) {
17
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
18
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
19
+ }
20
+ }
21
+ };
22
+ })();
23
+ // webpack/runtime/has_own_property
24
+ (() => {
25
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
26
+ })();
27
+ // webpack/runtime/make_namespace_object
28
+ (() => {
29
+ // define __esModule on exports
30
+ __webpack_require__.r = (exports) => {
31
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
32
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
33
+ }
34
+ Object.defineProperty(exports, '__esModule', { value: true });
35
+ };
36
+ })();
37
+ /************************************************************************/
38
+ var __webpack_exports__ = {};
39
+ // ESM COMPAT FLAG
40
+ __webpack_require__.r(__webpack_exports__);
41
+
42
+ // EXPORTS
43
+ __webpack_require__.d(__webpack_exports__, {
44
+ prefetch: () => (/* binding */ prefetch)
45
+ });
46
+
47
+ ;// CONCATENATED MODULE: external "../prefetch.cjs"
48
+ const external_prefetch_cjs_namespaceObject = require("../prefetch.cjs");
49
+ ;// CONCATENATED MODULE: external "../common/runtime-utils.cjs"
50
+ const runtime_utils_cjs_namespaceObject = require("../common/runtime-utils.cjs");
51
+ ;// CONCATENATED MODULE: ./src/universal/index.ts
52
+
53
+
54
+ function prefetch(options) {
55
+ const { id, functionId = 'default' } = options;
56
+ const mfScope = (0,runtime_utils_cjs_namespaceObject.getScope)();
57
+ const prefetchInstance = external_prefetch_cjs_namespaceObject.MFDataPrefetch.getInstance(mfScope) || new external_prefetch_cjs_namespaceObject.MFDataPrefetch({
58
+ name: mfScope
59
+ });
60
+ const res = prefetchInstance.getProjectExports();
61
+ if (res instanceof Promise) {
62
+ const promise = res.then(()=>{
63
+ const result = prefetchInstance.prefetch(options);
64
+ prefetchInstance.memorize(id + functionId, result);
65
+ return result;
66
+ });
67
+ return promise;
68
+ } else {
69
+ const result = prefetchInstance.prefetch(options);
70
+ prefetchInstance.memorize(id + functionId, result);
71
+ return result;
72
+ }
73
+ }
74
+
75
+ exports.prefetch = __webpack_exports__.prefetch;
76
+ for(var __webpack_i__ in __webpack_exports__) {
77
+ if(["prefetch"].indexOf(__webpack_i__) === -1) {
78
+ exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
79
+ }
80
+ }
81
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,8 +1,2 @@
1
- import { p as prefetchOptions } from '../prefetch-4e9646e4.js';
2
- import '@module-federation/runtime';
3
- import '@module-federation/sdk';
4
- import '@module-federation/runtime/types';
5
-
6
- declare function prefetch(options: prefetchOptions): Promise<any>;
7
-
8
- export { prefetch };
1
+ import { type prefetchOptions } from '../prefetch';
2
+ export declare function prefetch(options: prefetchOptions): Promise<any>;