@module-federation/data-prefetch 0.0.0-fix-lazy-comile-20250925082726

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 (71) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/LICENSE +21 -0
  4. package/dist/babel.cjs.cjs +46 -0
  5. package/dist/babel.cjs.cjs.map +1 -0
  6. package/dist/babel.cjs.d.ts +2 -0
  7. package/dist/babel.d.ts +2 -0
  8. package/dist/babel.esm.js +44 -0
  9. package/dist/babel.esm.js.map +1 -0
  10. package/dist/cli.cjs.cjs +154 -0
  11. package/dist/cli.cjs.cjs.map +1 -0
  12. package/dist/cli.cjs.d.ts +1 -0
  13. package/dist/cli.d.ts +1 -0
  14. package/dist/cli.esm.js +151 -0
  15. package/dist/cli.esm.js.map +1 -0
  16. package/dist/constant.cjs.cjs +6 -0
  17. package/dist/constant.cjs.cjs.map +1 -0
  18. package/dist/constant.esm.js +4 -0
  19. package/dist/constant.esm.js.map +1 -0
  20. package/dist/index.cjs.cjs +10 -0
  21. package/dist/index.cjs.cjs.map +1 -0
  22. package/dist/index.cjs.d.ts +1 -0
  23. package/dist/index.cjs2.cjs +8 -0
  24. package/dist/index.cjs2.cjs.map +1 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.esm.js +3 -0
  27. package/dist/index.esm.js.map +1 -0
  28. package/dist/index.esm2.js +6 -0
  29. package/dist/index.esm2.js.map +1 -0
  30. package/dist/plugin.cjs.cjs +155 -0
  31. package/dist/plugin.cjs.cjs.map +1 -0
  32. package/dist/plugin.cjs.d.ts +2 -0
  33. package/dist/plugin.d.ts +2 -0
  34. package/dist/plugin.esm.js +150 -0
  35. package/dist/plugin.esm.js.map +1 -0
  36. package/dist/prefetch.cjs.cjs +194 -0
  37. package/dist/prefetch.cjs.cjs.map +1 -0
  38. package/dist/prefetch.esm.js +191 -0
  39. package/dist/prefetch.esm.js.map +1 -0
  40. package/dist/react.cjs.cjs +75 -0
  41. package/dist/react.cjs.cjs.map +1 -0
  42. package/dist/react.cjs.d.ts +1 -0
  43. package/dist/react.d.ts +1 -0
  44. package/dist/react.esm.js +73 -0
  45. package/dist/react.esm.js.map +1 -0
  46. package/dist/runtime-utils.cjs.cjs +28 -0
  47. package/dist/runtime-utils.cjs.cjs.map +1 -0
  48. package/dist/runtime-utils.esm.js +23 -0
  49. package/dist/runtime-utils.esm.js.map +1 -0
  50. package/dist/src/cli/babel.d.ts +37 -0
  51. package/dist/src/cli/index.d.ts +16 -0
  52. package/dist/src/common/constant.d.ts +1 -0
  53. package/dist/src/common/index.d.ts +1 -0
  54. package/dist/src/common/node-utils.d.ts +2 -0
  55. package/dist/src/common/runtime-utils.d.ts +5 -0
  56. package/dist/src/constant.d.ts +1 -0
  57. package/dist/src/index.d.ts +2 -0
  58. package/dist/src/logger/index.d.ts +2 -0
  59. package/dist/src/plugin.d.ts +3 -0
  60. package/dist/src/prefetch.d.ts +42 -0
  61. package/dist/src/react/hooks.d.ts +11 -0
  62. package/dist/src/react/index.d.ts +1 -0
  63. package/dist/src/react/utils.d.ts +1 -0
  64. package/dist/src/universal/index.d.ts +2 -0
  65. package/dist/universal.cjs.cjs +28 -0
  66. package/dist/universal.cjs.cjs.map +1 -0
  67. package/dist/universal.cjs.d.ts +1 -0
  68. package/dist/universal.d.ts +1 -0
  69. package/dist/universal.esm.js +26 -0
  70. package/dist/universal.esm.js.map +1 -0
  71. package/package.json +98 -0
@@ -0,0 +1,191 @@
1
+ import { getRemoteInfo, getRemoteEntry } from '@module-federation/runtime';
2
+ import { loadScript } from '@module-federation/sdk';
3
+ import { b as getPrefetchId, c as compatGetPrefetchId } from './runtime-utils.esm.js';
4
+
5
+ /******************************************************************************
6
+ Copyright (c) Microsoft Corporation.
7
+
8
+ Permission to use, copy, modify, and/or distribute this software for any
9
+ purpose with or without fee is hereby granted.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ function _instanceof(left, right) {
19
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
20
+ return !!right[Symbol.hasInstance](left);
21
+ } else {
22
+ return left instanceof right;
23
+ }
24
+ }
25
+ function __awaiter(thisArg, _arguments, P, generator) {
26
+ function adopt(value) {
27
+ return _instanceof(value, P) ? value : new P(function(resolve) {
28
+ resolve(value);
29
+ });
30
+ }
31
+ return new (P || (P = Promise))(function(resolve, reject) {
32
+ function fulfilled(value) {
33
+ try {
34
+ step(generator.next(value));
35
+ } catch (e) {
36
+ reject(e);
37
+ }
38
+ }
39
+ function rejected(value) {
40
+ try {
41
+ step(generator["throw"](value));
42
+ } catch (e) {
43
+ reject(e);
44
+ }
45
+ }
46
+ function step(result) {
47
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
48
+ }
49
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
50
+ });
51
+ }
52
+ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
53
+ var e = new Error(message);
54
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
55
+ };
56
+
57
+ var _a, _b;
58
+ var _c;
59
+ (_a = globalThis.__FEDERATION__) !== null && _a !== void 0 ? _a : globalThis.__FEDERATION__ = {};
60
+ (_b = (_c = globalThis.__FEDERATION__).__PREFETCH__) !== null && _b !== void 0 ? _b : _c.__PREFETCH__ = {
61
+ entryLoading: {},
62
+ instance: new Map(),
63
+ __PREFETCH_EXPORTS__: {}
64
+ };
65
+ class MFDataPrefetch {
66
+ get global() {
67
+ return globalThis.__FEDERATION__.__PREFETCH__;
68
+ }
69
+ static getInstance(id) {
70
+ return globalThis.__FEDERATION__.__PREFETCH__.instance.get(id);
71
+ }
72
+ loadEntry(entry) {
73
+ return __awaiter(this, void 0, void 0, function*() {
74
+ const { name, remoteSnapshot, remote, origin } = this._options;
75
+ if (entry) {
76
+ const { buildVersion, globalName } = remoteSnapshot;
77
+ const uniqueKey = globalName || `${name}:${buildVersion}`;
78
+ if (!this.global.entryLoading[uniqueKey]) {
79
+ this.global.entryLoading[uniqueKey] = loadScript(entry, {});
80
+ }
81
+ return this.global.entryLoading[uniqueKey];
82
+ } else {
83
+ const remoteInfo = getRemoteInfo(remote);
84
+ const module = origin.moduleCache.get(remoteInfo.name);
85
+ return getRemoteEntry({
86
+ origin: origin,
87
+ remoteInfo,
88
+ remoteEntryExports: module ? module.remoteEntryExports : undefined
89
+ });
90
+ }
91
+ });
92
+ }
93
+ getProjectExports() {
94
+ var _a;
95
+ if (Object.keys(this._exports).length > 0) {
96
+ return this._exports;
97
+ }
98
+ const { name } = this._options;
99
+ const exportsPromiseFn = (_a = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) === null || _a === void 0 ? void 0 : _a[name];
100
+ const exportsPromise = typeof exportsPromiseFn === 'function' ? exportsPromiseFn() : exportsPromiseFn;
101
+ const resolve = exportsPromise.then((exports = {})=>{
102
+ const memory = {};
103
+ Object.keys(exports).forEach((key)=>{
104
+ memory[key] = {};
105
+ const exportVal = exports[key];
106
+ Object.keys(exportVal).reduce((memo, current)=>{
107
+ if (current.toLocaleLowerCase().endsWith('prefetch') || current.toLocaleLowerCase() === 'default') {
108
+ memo[current] = exportVal[current];
109
+ }
110
+ return memo;
111
+ }, memory[key]);
112
+ });
113
+ this.memorizeExports(memory);
114
+ });
115
+ return resolve;
116
+ }
117
+ memorizeExports(exports) {
118
+ this._exports = exports;
119
+ }
120
+ getExposeExports(id) {
121
+ const prefetchId = getPrefetchId(id);
122
+ const compatId = compatGetPrefetchId(id);
123
+ const prefetchExports = this._exports[prefetchId] || this._exports[compatId];
124
+ return prefetchExports || {};
125
+ }
126
+ prefetch(prefetchOptions) {
127
+ const { id, functionId = 'default', refetchParams } = prefetchOptions;
128
+ let prefetchResult;
129
+ const prefetchId = getPrefetchId(id);
130
+ const compatId = compatGetPrefetchId(id);
131
+ const memorizeId = id + functionId;
132
+ const memory = this.prefetchMemory.get(memorizeId);
133
+ if (!this.checkOutdate(prefetchOptions) && memory) {
134
+ return memory;
135
+ }
136
+ const prefetchExports = this._exports[prefetchId] || this._exports[compatId];
137
+ if (!prefetchExports) {
138
+ return;
139
+ }
140
+ const executePrefetch = prefetchExports[functionId];
141
+ if (typeof executePrefetch === 'function') {
142
+ if (refetchParams) {
143
+ prefetchResult = executePrefetch(refetchParams);
144
+ } else {
145
+ prefetchResult = executePrefetch();
146
+ }
147
+ } else {
148
+ throw new Error(`[Module Federation Data Prefetch]: No prefetch function called ${functionId} export in prefetch file`);
149
+ }
150
+ this.memorize(memorizeId, prefetchResult);
151
+ return prefetchResult;
152
+ }
153
+ memorize(id, value) {
154
+ this.prefetchMemory.set(id, value);
155
+ }
156
+ markOutdate(markOptions, isOutdate) {
157
+ const { id, functionId = 'default' } = markOptions;
158
+ if (!this.recordOutdate[id]) {
159
+ this.recordOutdate[id] = {};
160
+ }
161
+ this.recordOutdate[id][functionId] = isOutdate;
162
+ }
163
+ checkOutdate(outdateOptions) {
164
+ const { id, functionId = 'default', cacheStrategy } = outdateOptions;
165
+ if (typeof cacheStrategy === 'function') {
166
+ return cacheStrategy();
167
+ }
168
+ if (!this.recordOutdate[id]) {
169
+ this.recordOutdate[id] = {};
170
+ }
171
+ if (this.recordOutdate[id][functionId]) {
172
+ this.markOutdate({
173
+ id,
174
+ functionId
175
+ }, false);
176
+ return true;
177
+ } else {
178
+ return false;
179
+ }
180
+ }
181
+ constructor(options){
182
+ this.prefetchMemory = new Map();
183
+ this.recordOutdate = {};
184
+ this._exports = {};
185
+ this._options = options;
186
+ this.global.instance.set(options.name, this);
187
+ }
188
+ }
189
+
190
+ export { MFDataPrefetch as M, __awaiter as _ };
191
+ //# sourceMappingURL=prefetch.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefetch.esm.js","sources":["../src/prefetch.ts"],"sourcesContent":["var _a, _b;\nvar _c;\nimport { __awaiter } from \"tslib\";\nimport { getRemoteEntry, getRemoteInfo, } from '@module-federation/runtime';\nimport { loadScript, } from '@module-federation/sdk';\nimport { getPrefetchId, compatGetPrefetchId } from './common/runtime-utils';\n(_a = globalThis.__FEDERATION__) !== null && _a !== void 0 ? _a : (globalThis.__FEDERATION__ = {});\n(_b = (_c = globalThis.__FEDERATION__).__PREFETCH__) !== null && _b !== void 0 ? _b : (_c.__PREFETCH__ = {\n entryLoading: {},\n instance: new Map(),\n __PREFETCH_EXPORTS__: {},\n});\nexport class MFDataPrefetch {\n constructor(options) {\n this.prefetchMemory = new Map();\n this.recordOutdate = {};\n this._exports = {};\n this._options = options;\n this.global.instance.set(options.name, this);\n }\n get global() {\n return globalThis.__FEDERATION__\n .__PREFETCH__;\n }\n static getInstance(id) {\n return globalThis.__FEDERATION__.__PREFETCH__.instance.get(id);\n }\n loadEntry(entry) {\n return __awaiter(this, void 0, void 0, function* () {\n const { name, remoteSnapshot, remote, origin } = this._options;\n if (entry) {\n const { buildVersion, globalName } = remoteSnapshot;\n const uniqueKey = globalName || `${name}:${buildVersion}`;\n if (!this.global.entryLoading[uniqueKey]) {\n this.global.entryLoading[uniqueKey] = loadScript(entry, {});\n }\n return this.global.entryLoading[uniqueKey];\n }\n else {\n const remoteInfo = getRemoteInfo(remote);\n const module = origin.moduleCache.get(remoteInfo.name);\n return getRemoteEntry({\n origin: origin,\n remoteInfo,\n remoteEntryExports: module ? module.remoteEntryExports : undefined,\n });\n }\n });\n }\n getProjectExports() {\n var _a;\n if (Object.keys(this._exports).length > 0) {\n return this._exports;\n }\n const { name } = this._options;\n const exportsPromiseFn = (_a = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) === null || _a === void 0 ? void 0 : _a[name];\n const exportsPromise = typeof exportsPromiseFn === 'function'\n ? exportsPromiseFn()\n : exportsPromiseFn;\n const resolve = exportsPromise.then((exports = {}) => {\n const memory = {};\n Object.keys(exports).forEach((key) => {\n memory[key] = {};\n const exportVal = exports[key];\n Object.keys(exportVal).reduce((memo, current) => {\n if (current.toLocaleLowerCase().endsWith('prefetch') ||\n current.toLocaleLowerCase() === 'default') {\n memo[current] = exportVal[current];\n }\n return memo;\n }, memory[key]);\n });\n this.memorizeExports(memory);\n });\n return resolve;\n }\n memorizeExports(exports) {\n this._exports = exports;\n }\n getExposeExports(id) {\n const prefetchId = getPrefetchId(id);\n const compatId = compatGetPrefetchId(id);\n const prefetchExports = this._exports[prefetchId] || this._exports[compatId];\n return prefetchExports || {};\n }\n prefetch(prefetchOptions) {\n const { id, functionId = 'default', refetchParams } = prefetchOptions;\n let prefetchResult;\n const prefetchId = getPrefetchId(id);\n const compatId = compatGetPrefetchId(id);\n const memorizeId = id + functionId;\n const memory = this.prefetchMemory.get(memorizeId);\n if (!this.checkOutdate(prefetchOptions) && memory) {\n return memory;\n }\n const prefetchExports = this._exports[prefetchId] || this._exports[compatId];\n if (!prefetchExports) {\n return;\n }\n const executePrefetch = prefetchExports[functionId];\n if (typeof executePrefetch === 'function') {\n if (refetchParams) {\n prefetchResult = executePrefetch(refetchParams);\n }\n else {\n prefetchResult = executePrefetch();\n }\n }\n else {\n throw new Error(`[Module Federation Data Prefetch]: No prefetch function called ${functionId} export in prefetch file`);\n }\n this.memorize(memorizeId, prefetchResult);\n return prefetchResult;\n }\n memorize(id, value) {\n this.prefetchMemory.set(id, value);\n }\n markOutdate(markOptions, isOutdate) {\n const { id, functionId = 'default' } = markOptions;\n if (!this.recordOutdate[id]) {\n this.recordOutdate[id] = {};\n }\n this.recordOutdate[id][functionId] = isOutdate;\n }\n checkOutdate(outdateOptions) {\n const { id, functionId = 'default', cacheStrategy } = outdateOptions;\n if (typeof cacheStrategy === 'function') {\n return cacheStrategy();\n }\n if (!this.recordOutdate[id]) {\n this.recordOutdate[id] = {};\n }\n if (this.recordOutdate[id][functionId]) {\n this.markOutdate({\n id,\n functionId,\n }, false);\n return true;\n }\n else {\n return false;\n }\n }\n}\n"],"names":["_a","_b","_c","globalThis","__FEDERATION__","__PREFETCH__","entryLoading","instance","Map","__PREFETCH_EXPORTS__","MFDataPrefetch","global","getInstance","id","get","loadEntry","entry","__awaiter","name","remoteSnapshot","remote","origin","_options","buildVersion","globalName","uniqueKey","loadScript","remoteInfo","getRemoteInfo","module","moduleCache","getRemoteEntry","remoteEntryExports","undefined","getProjectExports","Object","keys","_exports","length","exportsPromiseFn","exportsPromise","resolve","then","exports","memory","forEach","key","exportVal","reduce","memo","current","toLocaleLowerCase","endsWith","memorizeExports","getExposeExports","prefetchId","getPrefetchId","compatId","compatGetPrefetchId","prefetchExports","prefetch","prefetchOptions","functionId","refetchParams","prefetchResult","memorizeId","prefetchMemory","checkOutdate","executePrefetch","Error","memorize","value","set","markOutdate","markOptions","isOutdate","recordOutdate","outdateOptions","cacheStrategy","constructor","options"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAIA,EAAIC,EAAAA,EAAAA;AACR,IAAIC,EAAAA;AAKHF,CAAAA,EAAKG,GAAAA,UAAAA,CAAWC,cAAa,MAAO,IAAA,IAAQJ,EAAO,KAAA,MAASA,GAAAA,EAAAA,GAAMG,UAAWC,CAAAA,cAAc,GAAG,EAAC;AAC/FH,CAAAA,KAAK,CAACC,KAAKC,UAAWC,CAAAA,cAAc,EAAEC,YAA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;AACA,QAAA,IAAI,CAAC,IAAI,CAACF,aAAa,CAAC/D,GAAG,EAAE;AACzB,YAAA,IAAI,CAAC+D,aAAa,CAAC/D,EAAAA,CAAG,GAAG,EAAC;AAC9B;AACA,QAAA,IAAI,IAAI,CAAC+D,aAAa,CAAC/D,EAAG,CAAA,CAACiD,WAAW,EAAE;YACpC,IAAI,CAACW,WAAW,CAAC;AACb5D,gBAAAA,EAAAA;AACAiD,gBAAAA;aACD,EAAA,KAAA,CAAA;YACH,OAAO,IAAA;SAEN,MAAA;YACD,OAAO,KAAA;AACX;AACJ;AAjIAiB,IAAAA,WAAAA,CAAYC,OAAO,CAAE;QACjB,IAAI,CAACd,cAAc,GAAG,IAAI1D,GAAAA,EAAAA;QAC1B,IAAI,CAACoE,aAAa,GAAG,EAAC;QACtB,IAAI,CAACvC,QAAQ,GAAG,EAAC;QACjB,IAAI,CAACf,QAAQ,GAAG0D,OAAAA;QAChB,IAAI,CAACrE,MAAM,CAACJ,QAAQ,CAACiE,GAAG,CAACQ,OAAAA,CAAQ9D,IAAI,EAAE,IAAI,CAAA;AAC/C;AA4HJ;;;;"}
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var index = require('./index.cjs2.cjs');
5
+ var prefetch = require('./prefetch.cjs.cjs');
6
+ var universal = require('./universal.cjs.cjs');
7
+ var runtimeUtils = require('./runtime-utils.cjs.cjs');
8
+
9
+ const useFirstMounted = ()=>{
10
+ const ref = react.useRef(true);
11
+ react.useEffect(()=>{
12
+ ref.current = false;
13
+ }, []);
14
+ return ref.current;
15
+ };
16
+
17
+ const usePrefetch = (options)=>{
18
+ const isFirstMounted = useFirstMounted();
19
+ if (isFirstMounted) {
20
+ const startTiming = performance.now();
21
+ index.logger.info(`2. Start Get Prefetch Data: ${options.id} - ${options.functionId || 'default'} - ${startTiming}`);
22
+ }
23
+ const { id, functionId, deferId } = options;
24
+ const prefetchInfo = {
25
+ id,
26
+ functionId
27
+ };
28
+ const mfScope = runtimeUtils.getScope();
29
+ let state;
30
+ const prefetchResult = universal.prefetch(options);
31
+ if (deferId) {
32
+ if (prefetchResult instanceof Promise) {
33
+ state = prefetchResult.then((deferredData)=>deferredData.data[deferId]);
34
+ } else {
35
+ state = prefetchResult.data[deferId];
36
+ }
37
+ } else {
38
+ state = prefetchResult;
39
+ }
40
+ const [prefetchState, setPrefetchState] = react.useState(state);
41
+ const prefetchInstance = prefetch.MFDataPrefetch.getInstance(mfScope);
42
+ react.useEffect(()=>{
43
+ const useEffectTiming = performance.now();
44
+ index.logger.info(`3. Start Execute UseEffect: ${options.id} - ${options.functionId || 'default'} - ${useEffectTiming}`);
45
+ return ()=>{
46
+ prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
47
+ };
48
+ }, []);
49
+ const refreshExecutor = (refetchParams)=>{
50
+ const refetchOptions = Object.assign({}, options);
51
+ if (refetchParams) {
52
+ refetchOptions.refetchParams = refetchParams;
53
+ }
54
+ prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
55
+ const newVal = universal.prefetch(refetchOptions);
56
+ let newState;
57
+ if (deferId) {
58
+ if (newVal instanceof Promise) {
59
+ newState = newVal.then((deferredData)=>deferredData.data[deferId]);
60
+ } else {
61
+ newState = newVal.data[deferId];
62
+ }
63
+ } else {
64
+ newState = newVal;
65
+ }
66
+ setPrefetchState(newState);
67
+ };
68
+ return [
69
+ prefetchState,
70
+ refreshExecutor
71
+ ];
72
+ };
73
+
74
+ exports.usePrefetch = usePrefetch;
75
+ //# sourceMappingURL=react.cjs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.cjs.cjs","sources":["../src/react/utils.ts","../src/react/hooks.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nexport const useFirstMounted = () => {\n const ref = useRef(true);\n useEffect(() => {\n ref.current = false;\n }, []);\n return ref.current;\n};\n","import { useEffect, useState } from 'react';\nimport logger from '../logger';\nimport { MFDataPrefetch } from '../prefetch';\nimport { prefetch } from '../universal';\nimport { getScope } from '../common/runtime-utils';\nimport { useFirstMounted } from './utils';\nexport const usePrefetch = (options) => {\n const isFirstMounted = useFirstMounted();\n if (isFirstMounted) {\n const startTiming = performance.now();\n logger.info(`2. Start Get Prefetch Data: ${options.id} - ${options.functionId || 'default'} - ${startTiming}`);\n }\n const { id, functionId, deferId } = options;\n const prefetchInfo = {\n id,\n functionId,\n };\n const mfScope = getScope();\n let state;\n const prefetchResult = prefetch(options);\n if (deferId) {\n if (prefetchResult instanceof Promise) {\n state = prefetchResult.then((deferredData) => deferredData.data[deferId]);\n }\n else {\n state = prefetchResult.data[deferId];\n }\n }\n else {\n state = prefetchResult;\n }\n const [prefetchState, setPrefetchState] = useState(state);\n const prefetchInstance = MFDataPrefetch.getInstance(mfScope);\n useEffect(() => {\n const useEffectTiming = performance.now();\n logger.info(`3. Start Execute UseEffect: ${options.id} - ${options.functionId || 'default'} - ${useEffectTiming}`);\n return () => {\n prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);\n };\n }, []);\n const refreshExecutor = (refetchParams) => {\n const refetchOptions = Object.assign({}, options);\n if (refetchParams) {\n refetchOptions.refetchParams = refetchParams;\n }\n prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);\n const newVal = prefetch(refetchOptions);\n let newState;\n if (deferId) {\n if (newVal instanceof Promise) {\n newState = newVal.then((deferredData) => deferredData.data[deferId]);\n }\n else {\n newState = newVal.data[deferId];\n }\n }\n else {\n newState = newVal;\n }\n setPrefetchState(newState);\n };\n return [prefetchState, refreshExecutor];\n};\n"],"names":["useFirstMounted","ref","useRef","useEffect","current","usePrefetch","options","isFirstMounted","startTiming","performance","now","logger","info","id","functionId","deferId","prefetchInfo","mfScope","getScope","state","prefetchResult","prefetch","Promise","then","deferredData","data","prefetchState","setPrefetchState","useState","prefetchInstance","MFDataPrefetch","getInstance","useEffectTiming","markOutdate","refreshExecutor","refetchParams","refetchOptions","Object","assign","newVal","newState"],"mappings":";;;;;;;;AACO,MAAMA,eAAkB,GAAA,IAAA;AAC3B,IAAA,MAAMC,MAAMC,YAAO,CAAA,IAAA,CAAA;IACnBC,eAAU,CAAA,IAAA;AACNF,QAAAA,GAAAA,CAAIG,OAAO,GAAG,KAAA;AAClB,KAAA,EAAG,EAAE,CAAA;AACL,IAAA,OAAOH,IAAIG,OAAO;AACtB,CAAE;;ACDK,MAAMC,cAAc,CAACC,OAAAA,GAAAA;AACxB,IAAA,MAAMC,cAAiBP,GAAAA,eAAAA,EAAAA;AACvB,IAAA,IAAIO,cAAgB,EAAA;QAChB,MAAMC,WAAAA,GAAcC,YAAYC,GAAG,EAAA;AACnCC,QAAAA,YAAAA,CAAOC,IAAI,CAAC,CAAC,4BAA4B,EAAEN,QAAQO,EAAE,CAAC,GAAG,EAAEP,QAAQQ,UAAU,IAAI,UAAU,GAAG,EAAEN,YAAY,CAAC,CAAA;AACjH;AACA,IAAA,MAAM,EAAEK,EAAE,EAAEC,UAAU,EAAEC,OAAO,EAAE,GAAGT,OAAAA;AACpC,IAAA,MAAMU,YAAe,GAAA;AACjBH,QAAAA,EAAAA;AACAC,QAAAA;AACJ,KAAA;AACA,IAAA,MAAMG,OAAUC,GAAAA,qBAAAA,EAAAA;IAChB,IAAIC,KAAAA;AACJ,IAAA,MAAMC,iBAAiBC,kBAASf,CAAAA,OAAAA,CAAAA;AAChC,IAAA,IAAIS,OAAS,EAAA;AACT,QAAA,IAAIK,0BAA0BE,OAAS,EAAA;YACnCH,KAAQC,GAAAA,cAAAA,CAAeG,IAAI,CAAC,CAACC,eAAiBA,YAAaC,CAAAA,IAAI,CAACV,OAAQ,CAAA,CAAA;SAEvE,MAAA;YACDI,KAAQC,GAAAA,cAAAA,CAAeK,IAAI,CAACV,OAAQ,CAAA;AACxC;KAEC,MAAA;QACDI,KAAQC,GAAAA,cAAAA;AACZ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d,IAAI,CAACV,OAAQ,CAAA;AACnC;SAEC,MAAA;YACDyB,QAAWD,GAAAA,MAAAA;AACf;QACAZ,gBAAiBa,CAAAA,QAAAA,CAAAA;AACrB,KAAA;IACA,OAAO;AAACd,QAAAA,aAAAA;AAAeQ,QAAAA;AAAgB,KAAA;AAC3C;;;;"}
@@ -0,0 +1 @@
1
+ export * from "./src/react/index";
@@ -0,0 +1 @@
1
+ export * from "./src/react/index";
@@ -0,0 +1,73 @@
1
+ import { useRef, useEffect, useState } from 'react';
2
+ import { l as logger } from './index.esm2.js';
3
+ import { M as MFDataPrefetch } from './prefetch.esm.js';
4
+ import { prefetch } from './universal.esm.js';
5
+ import { g as getScope } from './runtime-utils.esm.js';
6
+
7
+ const useFirstMounted = ()=>{
8
+ const ref = useRef(true);
9
+ useEffect(()=>{
10
+ ref.current = false;
11
+ }, []);
12
+ return ref.current;
13
+ };
14
+
15
+ const usePrefetch = (options)=>{
16
+ const isFirstMounted = useFirstMounted();
17
+ if (isFirstMounted) {
18
+ const startTiming = performance.now();
19
+ logger.info(`2. Start Get Prefetch Data: ${options.id} - ${options.functionId || 'default'} - ${startTiming}`);
20
+ }
21
+ const { id, functionId, deferId } = options;
22
+ const prefetchInfo = {
23
+ id,
24
+ functionId
25
+ };
26
+ const mfScope = getScope();
27
+ let state;
28
+ const prefetchResult = prefetch(options);
29
+ if (deferId) {
30
+ if (prefetchResult instanceof Promise) {
31
+ state = prefetchResult.then((deferredData)=>deferredData.data[deferId]);
32
+ } else {
33
+ state = prefetchResult.data[deferId];
34
+ }
35
+ } else {
36
+ state = prefetchResult;
37
+ }
38
+ const [prefetchState, setPrefetchState] = useState(state);
39
+ const prefetchInstance = MFDataPrefetch.getInstance(mfScope);
40
+ useEffect(()=>{
41
+ const useEffectTiming = performance.now();
42
+ logger.info(`3. Start Execute UseEffect: ${options.id} - ${options.functionId || 'default'} - ${useEffectTiming}`);
43
+ return ()=>{
44
+ prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
45
+ };
46
+ }, []);
47
+ const refreshExecutor = (refetchParams)=>{
48
+ const refetchOptions = Object.assign({}, options);
49
+ if (refetchParams) {
50
+ refetchOptions.refetchParams = refetchParams;
51
+ }
52
+ prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
53
+ const newVal = prefetch(refetchOptions);
54
+ let newState;
55
+ if (deferId) {
56
+ if (newVal instanceof Promise) {
57
+ newState = newVal.then((deferredData)=>deferredData.data[deferId]);
58
+ } else {
59
+ newState = newVal.data[deferId];
60
+ }
61
+ } else {
62
+ newState = newVal;
63
+ }
64
+ setPrefetchState(newState);
65
+ };
66
+ return [
67
+ prefetchState,
68
+ refreshExecutor
69
+ ];
70
+ };
71
+
72
+ export { usePrefetch };
73
+ //# sourceMappingURL=react.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.esm.js","sources":["../src/react/utils.ts","../src/react/hooks.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nexport const useFirstMounted = () => {\n const ref = useRef(true);\n useEffect(() => {\n ref.current = false;\n }, []);\n return ref.current;\n};\n","import { useEffect, useState } from 'react';\nimport logger from '../logger';\nimport { MFDataPrefetch } from '../prefetch';\nimport { prefetch } from '../universal';\nimport { getScope } from '../common/runtime-utils';\nimport { useFirstMounted } from './utils';\nexport const usePrefetch = (options) => {\n const isFirstMounted = useFirstMounted();\n if (isFirstMounted) {\n const startTiming = performance.now();\n logger.info(`2. Start Get Prefetch Data: ${options.id} - ${options.functionId || 'default'} - ${startTiming}`);\n }\n const { id, functionId, deferId } = options;\n const prefetchInfo = {\n id,\n functionId,\n };\n const mfScope = getScope();\n let state;\n const prefetchResult = prefetch(options);\n if (deferId) {\n if (prefetchResult instanceof Promise) {\n state = prefetchResult.then((deferredData) => deferredData.data[deferId]);\n }\n else {\n state = prefetchResult.data[deferId];\n }\n }\n else {\n state = prefetchResult;\n }\n const [prefetchState, setPrefetchState] = useState(state);\n const prefetchInstance = MFDataPrefetch.getInstance(mfScope);\n useEffect(() => {\n const useEffectTiming = performance.now();\n logger.info(`3. Start Execute UseEffect: ${options.id} - ${options.functionId || 'default'} - ${useEffectTiming}`);\n return () => {\n prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);\n };\n }, []);\n const refreshExecutor = (refetchParams) => {\n const refetchOptions = Object.assign({}, options);\n if (refetchParams) {\n refetchOptions.refetchParams = refetchParams;\n }\n prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);\n const newVal = prefetch(refetchOptions);\n let newState;\n if (deferId) {\n if (newVal instanceof Promise) {\n newState = newVal.then((deferredData) => deferredData.data[deferId]);\n }\n else {\n newState = newVal.data[deferId];\n }\n }\n else {\n newState = newVal;\n }\n setPrefetchState(newState);\n };\n return [prefetchState, refreshExecutor];\n};\n"],"names":["useFirstMounted","ref","useRef","useEffect","current","usePrefetch","options","isFirstMounted","startTiming","performance","now","logger","info","id","functionId","deferId","prefetchInfo","mfScope","getScope","state","prefetchResult","prefetch","Promise","then","deferredData","data","prefetchState","setPrefetchState","useState","prefetchInstance","MFDataPrefetch","getInstance","useEffectTiming","markOutdate","refreshExecutor","refetchParams","refetchOptions","Object","assign","newVal","newState"],"mappings":";;;;;;AACO,MAAMA,eAAkB,GAAA,IAAA;AAC3B,IAAA,MAAMC,MAAMC,MAAO,CAAA,IAAA,CAAA;IACnBC,SAAU,CAAA,IAAA;AACNF,QAAAA,GAAAA,CAAIG,OAAO,GAAG,KAAA;AAClB,KAAA,EAAG,EAAE,CAAA;AACL,IAAA,OAAOH,IAAIG,OAAO;AACtB,CAAE;;ACDK,MAAMC,cAAc,CAACC,OAAAA,GAAAA;AACxB,IAAA,MAAMC,cAAiBP,GAAAA,eAAAA,EAAAA;AACvB,IAAA,IAAIO,cAAgB,EAAA;QAChB,MAAMC,WAAAA,GAAcC,YAAYC,GAAG,EA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iBI,WAAW,CAACjB,YAAc,EAAA,IAAA,CAAA;AACnH,SAAA;AACJ,KAAA,EAAG,EAAE,CAAA;AACL,IAAA,MAAMkB,kBAAkB,CAACC,aAAAA,GAAAA;AACrB,QAAA,MAAMC,cAAiBC,GAAAA,MAAAA,CAAOC,MAAM,CAAC,EAAIhC,EAAAA,OAAAA,CAAAA;AACzC,QAAA,IAAI6B,aAAe,EAAA;AACfC,YAAAA,cAAAA,CAAeD,aAAa,GAAGA,aAAAA;AACnC;QACAN,gBAAqB,KAAA,IAAA,IAAQA,qBAAqB,MAAK,GAAI,MAASA,GAAAA,gBAAAA,CAAiBI,WAAW,CAACjB,YAAc,EAAA,IAAA,CAAA;AAC/G,QAAA,MAAMuB,SAASlB,QAASe,CAAAA,cAAAA,CAAAA;QACxB,IAAII,QAAAA;AACJ,QAAA,IAAIzB,OAAS,EAAA;AACT,YAAA,IAAIwB,kBAAkBjB,OAAS,EAAA;gBAC3BkB,QAAWD,GAAAA,MAAAA,CAAOhB,IAAI,CAAC,CAACC,eAAiBA,YAAaC,CAAAA,IAAI,CAACV,OAAQ,CAAA,CAAA;aAElE,MAAA;gBACDyB,QAAWD,GAAAA,MAAAA,CAAOd,IAAI,CAACV,OAAQ,CAAA;AACnC;SAEC,MAAA;YACDyB,QAAWD,GAAAA,MAAAA;AACf;QACAZ,gBAAiBa,CAAAA,QAAAA,CAAAA;AACrB,KAAA;IACA,OAAO;AAACd,QAAAA,aAAAA;AAAeQ,QAAAA;AAAgB,KAAA;AAC3C;;;;"}
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var runtime = require('@module-federation/runtime');
4
+ var sdk = require('@module-federation/sdk');
5
+
6
+ const getScope = ()=>{
7
+ return runtime.getInstance().options.name;
8
+ };
9
+ const getPrefetchId = (id)=>sdk.encodeName(`${id}/${sdk.MFPrefetchCommon.identifier}`);
10
+ const compatGetPrefetchId = (id)=>sdk.encodeName(`${id}/VmokPrefetch`);
11
+ const getSignalFromManifest = (remoteSnapshot)=>{
12
+ if (!remoteSnapshot) {
13
+ return false;
14
+ }
15
+ if (!('prefetchEntry' in remoteSnapshot) && !('prefetchInterface' in remoteSnapshot)) {
16
+ return false;
17
+ }
18
+ if (!remoteSnapshot.prefetchEntry && !remoteSnapshot.prefetchInterface) {
19
+ return false;
20
+ }
21
+ return true;
22
+ };
23
+
24
+ exports.compatGetPrefetchId = compatGetPrefetchId;
25
+ exports.getPrefetchId = getPrefetchId;
26
+ exports.getScope = getScope;
27
+ exports.getSignalFromManifest = getSignalFromManifest;
28
+ //# sourceMappingURL=runtime-utils.cjs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-utils.cjs.cjs","sources":["../src/common/runtime-utils.ts"],"sourcesContent":["import { getInstance } from '@module-federation/runtime';\nimport { encodeName, MFPrefetchCommon, } from '@module-federation/sdk';\nexport const getScope = () => {\n return getInstance().options.name;\n};\nexport const getPrefetchId = (id) => encodeName(`${id}/${MFPrefetchCommon.identifier}`);\nexport const compatGetPrefetchId = (id) => encodeName(`${id}/VmokPrefetch`);\nexport const getSignalFromManifest = (remoteSnapshot) => {\n if (!remoteSnapshot) {\n return false;\n }\n if (!('prefetchEntry' in remoteSnapshot) &&\n !('prefetchInterface' in remoteSnapshot)) {\n return false;\n }\n if (!remoteSnapshot.prefetchEntry && !remoteSnapshot.prefetchInterface) {\n return false;\n }\n return true;\n};\n"],"names":["getScope","getInstance","options","name","getPrefetchId","id","encodeName","MFPrefetchCommon","identifier","compatGetPrefetchId","getSignalFromManifest","remoteSnapshot","prefetchEntry","prefetchInterface"],"mappings":";;;;;MAEaA,QAAW,GAAA,IAAA;IACpB,OAAOC,mBAAAA,EAAAA,CAAcC,OAAO,CAACC,IAAI;AACrC;AACaC,MAAAA,aAAAA,GAAgB,CAACC,EAAAA,GAAOC,eAAW,CAAC,EAAED,EAAG,CAAA,CAAC,EAAEE,oBAAAA,CAAiBC,UAAU,CAAC,CAAC;AAC/E,MAAMC,mBAAsB,GAAA,CAACJ,EAAOC,GAAAA,cAAAA,CAAW,CAAC,EAAED,EAAAA,CAAG,aAAa,CAAC;AACnE,MAAMK,wBAAwB,CAACC,cAAAA,GAAAA;AAClC,IAAA,IAAI,CAACA,cAAgB,EAAA;QACjB,OAAO,KAAA;AACX;IACA,IAAI,EAAE,eAAmBA,IAAAA,cAAa,KAClC,EAAE,mBAAuBA,IAAAA,cAAa,CAAI,EAAA;QAC1C,OAAO,KAAA;AACX;AACA,IAAA,IAAI,CAACA,cAAeC,CAAAA,aAAa,IAAI,CAACD,cAAAA,CAAeE,iBAAiB,EAAE;QACpE,OAAO,KAAA;AACX;IACA,OAAO,IAAA;AACX;;;;;;;"}
@@ -0,0 +1,23 @@
1
+ import { getInstance } from '@module-federation/runtime';
2
+ import { encodeName, MFPrefetchCommon } from '@module-federation/sdk';
3
+
4
+ const getScope = ()=>{
5
+ return getInstance().options.name;
6
+ };
7
+ const getPrefetchId = (id)=>encodeName(`${id}/${MFPrefetchCommon.identifier}`);
8
+ const compatGetPrefetchId = (id)=>encodeName(`${id}/VmokPrefetch`);
9
+ const getSignalFromManifest = (remoteSnapshot)=>{
10
+ if (!remoteSnapshot) {
11
+ return false;
12
+ }
13
+ if (!('prefetchEntry' in remoteSnapshot) && !('prefetchInterface' in remoteSnapshot)) {
14
+ return false;
15
+ }
16
+ if (!remoteSnapshot.prefetchEntry && !remoteSnapshot.prefetchInterface) {
17
+ return false;
18
+ }
19
+ return true;
20
+ };
21
+
22
+ export { getSignalFromManifest as a, getPrefetchId as b, compatGetPrefetchId as c, getScope as g };
23
+ //# sourceMappingURL=runtime-utils.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-utils.esm.js","sources":["../src/common/runtime-utils.ts"],"sourcesContent":["import { getInstance } from '@module-federation/runtime';\nimport { encodeName, MFPrefetchCommon, } from '@module-federation/sdk';\nexport const getScope = () => {\n return getInstance().options.name;\n};\nexport const getPrefetchId = (id) => encodeName(`${id}/${MFPrefetchCommon.identifier}`);\nexport const compatGetPrefetchId = (id) => encodeName(`${id}/VmokPrefetch`);\nexport const getSignalFromManifest = (remoteSnapshot) => {\n if (!remoteSnapshot) {\n return false;\n }\n if (!('prefetchEntry' in remoteSnapshot) &&\n !('prefetchInterface' in remoteSnapshot)) {\n return false;\n }\n if (!remoteSnapshot.prefetchEntry && !remoteSnapshot.prefetchInterface) {\n return false;\n }\n return true;\n};\n"],"names":["getScope","getInstance","options","name","getPrefetchId","id","encodeName","MFPrefetchCommon","identifier","compatGetPrefetchId","getSignalFromManifest","remoteSnapshot","prefetchEntry","prefetchInterface"],"mappings":";;;MAEaA,QAAW,GAAA,IAAA;IACpB,OAAOC,WAAAA,EAAAA,CAAcC,OAAO,CAACC,IAAI;AACrC;AACaC,MAAAA,aAAAA,GAAgB,CAACC,EAAAA,GAAOC,WAAW,CAAC,EAAED,EAAG,CAAA,CAAC,EAAEE,gBAAAA,CAAiBC,UAAU,CAAC,CAAC;AAC/E,MAAMC,mBAAsB,GAAA,CAACJ,EAAOC,GAAAA,UAAAA,CAAW,CAAC,EAAED,EAAAA,CAAG,aAAa,CAAC;AACnE,MAAMK,wBAAwB,CAACC,cAAAA,GAAAA;AAClC,IAAA,IAAI,CAACA,cAAgB,EAAA;QACjB,OAAO,KAAA;AACX;IACA,IAAI,EAAE,eAAmBA,IAAAA,cAAa,KAClC,EAAE,mBAAuBA,IAAAA,cAAa,CAAI,EAAA;QAC1C,OAAO,KAAA;AACX;AACA,IAAA,IAAI,CAACA,cAAeC,CAAAA,aAAa,IAAI,CAACD,cAAAA,CAAeE,iBAAiB,EAAE;QACpE,OAAO,KAAA;AACX;IACA,OAAO,IAAA;AACX;;;;"}
@@ -0,0 +1,37 @@
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ interface BabelPluginOptions {
3
+ hook_id: string;
4
+ import_pkg: string;
5
+ attribute: string;
6
+ name: string;
7
+ exposes: moduleFederationPlugin.ModuleFederationPluginOptions['exposes'];
8
+ }
9
+ declare const _default: (babel: {
10
+ types: any;
11
+ }, options: BabelPluginOptions) => {
12
+ visitor?: undefined;
13
+ } | {
14
+ visitor: {
15
+ ImportDeclaration(nodePath: {
16
+ node: {
17
+ source: {
18
+ value: any;
19
+ };
20
+ specifiers: any;
21
+ };
22
+ }, state: {
23
+ file: {
24
+ opts: {
25
+ filename: any;
26
+ };
27
+ };
28
+ }): void;
29
+ CallExpression(nodePath: {
30
+ node: {
31
+ callee: any;
32
+ arguments: string | any[];
33
+ };
34
+ }): void;
35
+ };
36
+ };
37
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import { moduleFederationPlugin } from '@module-federation/sdk';
2
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
3
+ declare const RuntimeGlobals: typeof import("webpack").RuntimeGlobals;
4
+ export declare function getFederationGlobalScope(runtimeGlobals: typeof RuntimeGlobals): string;
5
+ export declare class PrefetchPlugin implements WebpackPluginInstance {
6
+ options: moduleFederationPlugin.ModuleFederationPluginOptions;
7
+ private _reWriteExports;
8
+ constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions);
9
+ apply(compiler: Compiler): void;
10
+ static addRuntime(compiler: Compiler, options: {
11
+ name: string;
12
+ }): string;
13
+ static setRemoteIdentifier(): string;
14
+ static removeRemoteIdentifier(): string;
15
+ }
16
+ export {};
@@ -0,0 +1 @@
1
+ export declare const TEMP_DIR = ".mf";
@@ -0,0 +1 @@
1
+ export * from './constant';
@@ -0,0 +1,2 @@
1
+ export declare const fileExistsWithCaseSync: (filepath: string) => boolean;
2
+ export declare const fixPrefetchPath: (exposePath: string) => Array<string>;
@@ -0,0 +1,5 @@
1
+ import { ModuleInfo } from '@module-federation/sdk';
2
+ export declare const getScope: () => string;
3
+ export declare const getPrefetchId: (id: string) => string;
4
+ export declare const compatGetPrefetchId: (id: string) => string;
5
+ export declare const getSignalFromManifest: (remoteSnapshot: ModuleInfo) => boolean;
@@ -0,0 +1 @@
1
+ export declare const SHARED_STRATEGY = "loaded-first";
@@ -0,0 +1,2 @@
1
+ export * from './prefetch';
2
+ export * from './plugin';
@@ -0,0 +1,2 @@
1
+ declare const logger: import("@module-federation/sdk").Logger;
2
+ export default logger;
@@ -0,0 +1,3 @@
1
+ import type { ModuleFederationRuntimePlugin } from '@module-federation/runtime/types';
2
+ export declare const prefetchPlugin: () => ModuleFederationRuntimePlugin;
3
+ export default prefetchPlugin;
@@ -0,0 +1,42 @@
1
+ import { ModuleFederation } from '@module-federation/runtime';
2
+ import { ModuleInfo } from '@module-federation/sdk';
3
+ import { Remote } from '@module-federation/runtime/types';
4
+ import type { Federation } from '@module-federation/runtime';
5
+ interface FederationWithPrefetch extends Federation {
6
+ __PREFETCH__: {
7
+ entryLoading: Record<string, undefined | Promise<void>>;
8
+ instance: Map<string, MFDataPrefetch>;
9
+ __PREFETCH_EXPORTS__: Record<string, () => Promise<Record<string, any>>>;
10
+ };
11
+ }
12
+ type PrefetchExports = Record<string, any>;
13
+ export interface DataPrefetchOptions {
14
+ name: string;
15
+ remote?: Remote;
16
+ origin?: ModuleFederation;
17
+ remoteSnapshot?: ModuleInfo;
18
+ }
19
+ export interface prefetchOptions {
20
+ id: string;
21
+ functionId?: string;
22
+ cacheStrategy?: () => boolean;
23
+ refetchParams?: any;
24
+ }
25
+ export declare class MFDataPrefetch {
26
+ prefetchMemory: Map<string, Promise<any>>;
27
+ recordOutdate: Record<string, Record<string, boolean>>;
28
+ private _exports;
29
+ private _options;
30
+ constructor(options: DataPrefetchOptions);
31
+ get global(): FederationWithPrefetch['__PREFETCH__'];
32
+ static getInstance(id: string): MFDataPrefetch | undefined;
33
+ loadEntry(entry: string | undefined): Promise<any>;
34
+ getProjectExports(): Promise<void> | Record<string, any>;
35
+ memorizeExports(exports: Record<string, any>): void;
36
+ getExposeExports(id: string): PrefetchExports;
37
+ prefetch(prefetchOptions: prefetchOptions): any;
38
+ memorize(id: string, value: any): void;
39
+ markOutdate(markOptions: Omit<prefetchOptions, 'cacheStrategy'>, isOutdate: boolean): void;
40
+ checkOutdate(outdateOptions: prefetchOptions): boolean;
41
+ }
42
+ export {};
@@ -0,0 +1,11 @@
1
+ import { type prefetchOptions } from '../prefetch';
2
+ type refetchParams = any;
3
+ type prefetchReturnType<T> = [
4
+ Promise<T>,
5
+ (refetchParams?: refetchParams) => void
6
+ ];
7
+ type UsePrefetchOptions = prefetchOptions & {
8
+ deferId?: string;
9
+ };
10
+ export declare const usePrefetch: <T>(options: UsePrefetchOptions) => prefetchReturnType<T>;
11
+ export {};
@@ -0,0 +1 @@
1
+ export * from './hooks';
@@ -0,0 +1 @@
1
+ export declare const useFirstMounted: () => boolean;
@@ -0,0 +1,2 @@
1
+ import { type prefetchOptions } from '../prefetch';
2
+ export declare function prefetch(options: prefetchOptions): Promise<any>;