@module-federation/data-prefetch 0.6.7 → 0.6.9

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.
@@ -1,349 +1,140 @@
1
1
  import { getRemoteInfo, getRemoteEntry } from '@module-federation/runtime';
2
2
  import { loadScript } from '@module-federation/sdk';
3
- import { g as getPrefetchId, c as compatGetPrefetchId } from './runtime-utils.esm.js';
3
+ import { b as getPrefetchId, c as compatGetPrefetchId } from './runtime-utils.esm.js';
4
4
 
5
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
6
- try {
7
- var info = gen[key](arg);
8
- var value = info.value;
9
- } catch (error) {
10
- reject(error);
11
- return;
5
+ var // @ts-ignore init global variable for test
6
+ _globalThis, _globalThis___FEDERATION__;
7
+ var ___FEDERATION__;
8
+ (___FEDERATION__ = (_globalThis = globalThis).__FEDERATION__) != null ? ___FEDERATION__ : _globalThis.__FEDERATION__ = {};
9
+ var ___PREFETCH__;
10
+ (___PREFETCH__ = (_globalThis___FEDERATION__ = globalThis.__FEDERATION__).__PREFETCH__) != null ? ___PREFETCH__ : _globalThis___FEDERATION__.__PREFETCH__ = {
11
+ entryLoading: {},
12
+ instance: new Map(),
13
+ __PREFETCH_EXPORTS__: {}
14
+ };
15
+ class MFDataPrefetch {
16
+ get global() {
17
+ return globalThis.__FEDERATION__.__PREFETCH__;
12
18
  }
13
- if (info.done) {
14
- resolve(value);
15
- } else {
16
- Promise.resolve(value).then(_next, _throw);
19
+ static getInstance(id) {
20
+ return globalThis.__FEDERATION__.__PREFETCH__.instance.get(id);
17
21
  }
18
- }
19
- function _async_to_generator(fn) {
20
- return function() {
21
- var self = this, args = arguments;
22
- return new Promise(function(resolve, reject) {
23
- var gen = fn.apply(self, args);
24
- function _next(value) {
25
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
26
- }
27
- function _throw(err) {
28
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
22
+ async loadEntry(entry) {
23
+ const { name, remoteSnapshot, remote, origin } = this._options;
24
+ if (entry) {
25
+ const { buildVersion, globalName } = remoteSnapshot;
26
+ const uniqueKey = globalName || `${name}:${buildVersion}`;
27
+ if (!this.global.entryLoading[uniqueKey]) {
28
+ this.global.entryLoading[uniqueKey] = loadScript(entry, {});
29
29
  }
30
- _next(undefined);
31
- });
32
- };
33
- }
34
- function _class_call_check(instance, Constructor) {
35
- if (!(instance instanceof Constructor)) {
36
- throw new TypeError("Cannot call a class as a function");
37
- }
38
- }
39
- function _defineProperties(target, props) {
40
- for(var i = 0; i < props.length; i++){
41
- var descriptor = props[i];
42
- descriptor.enumerable = descriptor.enumerable || false;
43
- descriptor.configurable = true;
44
- if ("value" in descriptor) descriptor.writable = true;
45
- Object.defineProperty(target, descriptor.key, descriptor);
30
+ return this.global.entryLoading[uniqueKey];
31
+ } else {
32
+ const remoteInfo = getRemoteInfo(remote);
33
+ const module = origin.moduleCache.get(remoteInfo.name);
34
+ return getRemoteEntry({
35
+ origin: origin,
36
+ remoteInfo,
37
+ remoteEntryExports: module ? module.remoteEntryExports : undefined
38
+ });
39
+ }
46
40
  }
47
- }
48
- function _create_class(Constructor, protoProps, staticProps) {
49
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
50
- if (staticProps) _defineProperties(Constructor, staticProps);
51
- return Constructor;
52
- }
53
- function _define_property(obj, key, value) {
54
- if (key in obj) {
55
- Object.defineProperty(obj, key, {
56
- value: value,
57
- enumerable: true,
58
- configurable: true,
59
- writable: true
41
+ getProjectExports() {
42
+ var _globalThis___FEDERATION_____PREFETCH_____PREFETCH_EXPORTS__;
43
+ if (Object.keys(this._exports).length > 0) {
44
+ return this._exports;
45
+ }
46
+ const { name } = this._options;
47
+ const exportsPromiseFn = (_globalThis___FEDERATION_____PREFETCH_____PREFETCH_EXPORTS__ = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) == null ? void 0 : _globalThis___FEDERATION_____PREFETCH_____PREFETCH_EXPORTS__[name];
48
+ const exportsPromise = typeof exportsPromiseFn === 'function' ? exportsPromiseFn() : Promise.resolve({});
49
+ const resolve = exportsPromise.then((exports = {})=>{
50
+ // Match prefetch based on the function name suffix so that other capabilities can be expanded later.
51
+ // Not all functions should be directly identified as prefetch functions
52
+ const memory = {};
53
+ Object.keys(exports).forEach((key)=>{
54
+ memory[key] = {};
55
+ const exportVal = exports[key];
56
+ Object.keys(exportVal).reduce((memo, current)=>{
57
+ if (current.toLocaleLowerCase().endsWith('prefetch') || current.toLocaleLowerCase() === 'default') {
58
+ memo[current] = exportVal[current];
59
+ }
60
+ return memo;
61
+ }, memory[key]);
62
+ });
63
+ this.memorizeExports(memory);
60
64
  });
61
- } else {
62
- obj[key] = value;
65
+ return resolve;
63
66
  }
64
- return obj;
65
- }
66
- function _ts_generator(thisArg, body) {
67
- var f, y, t, g, _ = {
68
- label: 0,
69
- sent: function() {
70
- if (t[0] & 1) throw t[1];
71
- return t[1];
72
- },
73
- trys: [],
74
- ops: []
75
- };
76
- return g = {
77
- next: verb(0),
78
- "throw": verb(1),
79
- "return": verb(2)
80
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
81
- return this;
82
- }), g;
83
- function verb(n) {
84
- return function(v) {
85
- return step([
86
- n,
87
- v
88
- ]);
89
- };
67
+ memorizeExports(exports) {
68
+ this._exports = exports;
90
69
  }
91
- function step(op) {
92
- if (f) throw new TypeError("Generator is already executing.");
93
- while(_)try {
94
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
95
- if (y = 0, t) op = [
96
- op[0] & 2,
97
- t.value
98
- ];
99
- switch(op[0]){
100
- case 0:
101
- case 1:
102
- t = op;
103
- break;
104
- case 4:
105
- _.label++;
106
- return {
107
- value: op[1],
108
- done: false
109
- };
110
- case 5:
111
- _.label++;
112
- y = op[1];
113
- op = [
114
- 0
115
- ];
116
- continue;
117
- case 7:
118
- op = _.ops.pop();
119
- _.trys.pop();
120
- continue;
121
- default:
122
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
123
- _ = 0;
124
- continue;
125
- }
126
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
127
- _.label = op[1];
128
- break;
129
- }
130
- if (op[0] === 6 && _.label < t[1]) {
131
- _.label = t[1];
132
- t = op;
133
- break;
134
- }
135
- if (t && _.label < t[2]) {
136
- _.label = t[2];
137
- _.ops.push(op);
138
- break;
139
- }
140
- if (t[2]) _.ops.pop();
141
- _.trys.pop();
142
- continue;
70
+ getExposeExports(id) {
71
+ const prefetchId = getPrefetchId(id);
72
+ const compatId = compatGetPrefetchId(id);
73
+ const prefetchExports = this._exports[prefetchId] || this._exports[compatId];
74
+ return prefetchExports || {};
75
+ }
76
+ prefetch(prefetchOptions) {
77
+ const { id, functionId = 'default', refetchParams } = prefetchOptions;
78
+ let prefetchResult;
79
+ const prefetchId = getPrefetchId(id);
80
+ const compatId = compatGetPrefetchId(id);
81
+ const memorizeId = id + functionId;
82
+ const memory = this.prefetchMemory.get(memorizeId);
83
+ if (!this.checkOutdate(prefetchOptions) && memory) {
84
+ return memory;
85
+ }
86
+ const prefetchExports = this._exports[prefetchId] || this._exports[compatId];
87
+ if (!prefetchExports) {
88
+ return;
89
+ }
90
+ const executePrefetch = prefetchExports[functionId];
91
+ if (typeof executePrefetch === 'function') {
92
+ if (refetchParams) {
93
+ prefetchResult = executePrefetch(refetchParams);
94
+ } else {
95
+ prefetchResult = executePrefetch();
143
96
  }
144
- op = body.call(thisArg, _);
145
- } catch (e) {
146
- op = [
147
- 6,
148
- e
149
- ];
150
- y = 0;
151
- } finally{
152
- f = t = 0;
97
+ } else {
98
+ throw new Error(`[Module Federation Data Prefetch]: No prefetch function called ${functionId} export in prefetch file`);
153
99
  }
154
- if (op[0] & 5) throw op[1];
155
- return {
156
- value: op[0] ? op[1] : void 0,
157
- done: true
158
- };
100
+ this.memorize(memorizeId, prefetchResult);
101
+ return prefetchResult;
159
102
  }
160
- }
161
- var // @ts-ignore init global variable for test
162
- _globalThis, _globalThis___FEDERATION__;
163
- var ___FEDERATION__;
164
- (___FEDERATION__ = (_globalThis = globalThis).__FEDERATION__) !== null && ___FEDERATION__ !== void 0 ? ___FEDERATION__ : _globalThis.__FEDERATION__ = {};
165
- var ___PREFETCH__;
166
- (___PREFETCH__ = (_globalThis___FEDERATION__ = globalThis.__FEDERATION__).__PREFETCH__) !== null && ___PREFETCH__ !== void 0 ? ___PREFETCH__ : _globalThis___FEDERATION__.__PREFETCH__ = {
167
- entryLoading: {},
168
- instance: new Map(),
169
- __PREFETCH_EXPORTS__: {}
170
- };
171
- var MFDataPrefetch = /*#__PURE__*/ function() {
172
- function MFDataPrefetch(options) {
173
- _class_call_check(this, MFDataPrefetch);
174
- _define_property(this, "prefetchMemory", void 0);
175
- _define_property(this, "recordOutdate", void 0);
176
- _define_property(this, "_exports", void 0);
177
- _define_property(this, "_options", void 0);
103
+ memorize(id, value) {
104
+ this.prefetchMemory.set(id, value);
105
+ }
106
+ markOutdate(markOptions, isOutdate) {
107
+ const { id, functionId = 'default' } = markOptions;
108
+ if (!this.recordOutdate[id]) {
109
+ this.recordOutdate[id] = {};
110
+ }
111
+ this.recordOutdate[id][functionId] = isOutdate;
112
+ }
113
+ checkOutdate(outdateOptions) {
114
+ const { id, functionId = 'default', cacheStrategy } = outdateOptions;
115
+ if (typeof cacheStrategy === 'function') {
116
+ return cacheStrategy();
117
+ }
118
+ if (!this.recordOutdate[id]) {
119
+ this.recordOutdate[id] = {};
120
+ }
121
+ if (this.recordOutdate[id][functionId]) {
122
+ this.markOutdate({
123
+ id,
124
+ functionId
125
+ }, false);
126
+ return true;
127
+ } else {
128
+ return false;
129
+ }
130
+ }
131
+ constructor(options){
178
132
  this.prefetchMemory = new Map();
179
133
  this.recordOutdate = {};
180
134
  this._exports = {};
181
135
  this._options = options;
182
136
  this.global.instance.set(options.name, this);
183
137
  }
184
- _create_class(MFDataPrefetch, [
185
- {
186
- key: "global",
187
- get: function get() {
188
- return globalThis.__FEDERATION__.__PREFETCH__;
189
- }
190
- },
191
- {
192
- key: "loadEntry",
193
- value: function loadEntry(entry) {
194
- var _this = this;
195
- return _async_to_generator(function() {
196
- var _this__options, name, remoteSnapshot, remote, origin, buildVersion, globalName, uniqueKey, remoteInfo, module;
197
- return _ts_generator(this, function(_state) {
198
- _this__options = _this._options, name = _this__options.name, remoteSnapshot = _this__options.remoteSnapshot, remote = _this__options.remote, origin = _this__options.origin;
199
- if (entry) {
200
- buildVersion = remoteSnapshot.buildVersion, globalName = remoteSnapshot.globalName;
201
- uniqueKey = globalName || "".concat(name, ":").concat(buildVersion);
202
- if (!_this.global.entryLoading[uniqueKey]) {
203
- _this.global.entryLoading[uniqueKey] = loadScript(entry, {});
204
- }
205
- return [
206
- 2,
207
- _this.global.entryLoading[uniqueKey]
208
- ];
209
- } else {
210
- remoteInfo = getRemoteInfo(remote);
211
- module = origin.moduleCache.get(remoteInfo.name);
212
- return [
213
- 2,
214
- getRemoteEntry({
215
- origin: origin,
216
- remoteInfo: remoteInfo,
217
- remoteEntryExports: module ? module.remoteEntryExports : undefined
218
- })
219
- ];
220
- }
221
- });
222
- })();
223
- }
224
- },
225
- {
226
- key: "getProjectExports",
227
- value: function getProjectExports() {
228
- var _this = this;
229
- var _globalThis___FEDERATION_____PREFETCH_____PREFETCH_EXPORTS__;
230
- if (Object.keys(this._exports).length > 0) {
231
- return this._exports;
232
- }
233
- var name = this._options.name;
234
- var exportsPromiseFn = (_globalThis___FEDERATION_____PREFETCH_____PREFETCH_EXPORTS__ = globalThis.__FEDERATION__.__PREFETCH__.__PREFETCH_EXPORTS__) === null || _globalThis___FEDERATION_____PREFETCH_____PREFETCH_EXPORTS__ === void 0 ? void 0 : _globalThis___FEDERATION_____PREFETCH_____PREFETCH_EXPORTS__[name];
235
- var exportsPromise = typeof exportsPromiseFn === 'function' ? exportsPromiseFn() : Promise.resolve({});
236
- var resolve = exportsPromise.then(function() {
237
- var exports = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
238
- // Match prefetch based on the function name suffix so that other capabilities can be expanded later.
239
- // Not all functions should be directly identified as prefetch functions
240
- var memory = {};
241
- Object.keys(exports).forEach(function(key) {
242
- memory[key] = {};
243
- var exportVal = exports[key];
244
- Object.keys(exportVal).reduce(function(memo, current) {
245
- if (current.toLocaleLowerCase().endsWith('prefetch') || current.toLocaleLowerCase() === 'default') {
246
- memo[current] = exportVal[current];
247
- }
248
- return memo;
249
- }, memory[key]);
250
- });
251
- _this.memorizeExports(memory);
252
- });
253
- return resolve;
254
- }
255
- },
256
- {
257
- key: "memorizeExports",
258
- value: function memorizeExports(exports) {
259
- this._exports = exports;
260
- }
261
- },
262
- {
263
- key: "getExposeExports",
264
- value: function getExposeExports(id) {
265
- var prefetchId = getPrefetchId(id);
266
- var compatId = compatGetPrefetchId(id);
267
- var prefetchExports = this._exports[prefetchId] || this._exports[compatId];
268
- return prefetchExports || {};
269
- }
270
- },
271
- {
272
- key: "prefetch",
273
- value: function prefetch(prefetchOptions) {
274
- var id = prefetchOptions.id, _prefetchOptions_functionId = prefetchOptions.functionId, functionId = _prefetchOptions_functionId === void 0 ? 'default' : _prefetchOptions_functionId, refetchParams = prefetchOptions.refetchParams;
275
- var prefetchResult;
276
- var prefetchId = getPrefetchId(id);
277
- var compatId = compatGetPrefetchId(id);
278
- var memorizeId = id + functionId;
279
- var memory = this.prefetchMemory.get(memorizeId);
280
- if (!this.checkOutdate(prefetchOptions) && memory) {
281
- return memory;
282
- }
283
- var prefetchExports = this._exports[prefetchId] || this._exports[compatId];
284
- if (!prefetchExports) {
285
- return;
286
- }
287
- var executePrefetch = prefetchExports[functionId];
288
- if (typeof executePrefetch === 'function') {
289
- if (refetchParams) {
290
- prefetchResult = executePrefetch(refetchParams);
291
- } else {
292
- prefetchResult = executePrefetch();
293
- }
294
- } else {
295
- throw new Error("[Module Federation Data Prefetch]: No prefetch function called ".concat(functionId, " export in prefetch file"));
296
- }
297
- this.memorize(memorizeId, prefetchResult);
298
- return prefetchResult;
299
- }
300
- },
301
- {
302
- key: "memorize",
303
- value: function memorize(id, value) {
304
- this.prefetchMemory.set(id, value);
305
- }
306
- },
307
- {
308
- key: "markOutdate",
309
- value: function markOutdate(markOptions, isOutdate) {
310
- var id = markOptions.id, _markOptions_functionId = markOptions.functionId, functionId = _markOptions_functionId === void 0 ? 'default' : _markOptions_functionId;
311
- if (!this.recordOutdate[id]) {
312
- this.recordOutdate[id] = {};
313
- }
314
- this.recordOutdate[id][functionId] = isOutdate;
315
- }
316
- },
317
- {
318
- key: "checkOutdate",
319
- value: function checkOutdate(outdateOptions) {
320
- var id = outdateOptions.id, _outdateOptions_functionId = outdateOptions.functionId, functionId = _outdateOptions_functionId === void 0 ? 'default' : _outdateOptions_functionId, cacheStrategy = outdateOptions.cacheStrategy;
321
- if (typeof cacheStrategy === 'function') {
322
- return cacheStrategy();
323
- }
324
- if (!this.recordOutdate[id]) {
325
- this.recordOutdate[id] = {};
326
- }
327
- if (this.recordOutdate[id][functionId]) {
328
- this.markOutdate({
329
- id: id,
330
- functionId: functionId
331
- }, false);
332
- return true;
333
- } else {
334
- return false;
335
- }
336
- }
337
- }
338
- ], [
339
- {
340
- key: "getInstance",
341
- value: function getInstance(id) {
342
- return globalThis.__FEDERATION__.__PREFETCH__.instance.get(id);
343
- }
344
- }
345
- ]);
346
- return MFDataPrefetch;
347
- }();
138
+ }
348
139
 
349
140
  export { MFDataPrefetch as M };
package/dist/react.cjs.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
3
+ var polyfills = require('./polyfills.cjs.js');
5
4
  var react = require('react');
6
5
  var index = require('./index.cjs2.js');
7
6
  var prefetch = require('./prefetch.cjs.js');
@@ -10,142 +9,57 @@ var runtimeUtils = require('./runtime-utils.cjs.js');
10
9
  require('@module-federation/sdk');
11
10
  require('@module-federation/runtime');
12
11
 
13
- var useFirstMounted = function() {
14
- var ref = react.useRef(true);
15
- react.useEffect(function() {
12
+ const useFirstMounted = ()=>{
13
+ const ref = react.useRef(true);
14
+ react.useEffect(()=>{
16
15
  ref.current = false;
17
16
  }, []);
18
17
  return ref.current;
19
18
  };
20
19
 
21
- function _array_like_to_array(arr, len) {
22
- if (len == null || len > arr.length) len = arr.length;
23
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
24
- return arr2;
25
- }
26
- function _array_with_holes(arr) {
27
- if (Array.isArray(arr)) return arr;
28
- }
29
- function _define_property(obj, key, value) {
30
- if (key in obj) {
31
- Object.defineProperty(obj, key, {
32
- value: value,
33
- enumerable: true,
34
- configurable: true,
35
- writable: true
36
- });
37
- } else {
38
- obj[key] = value;
39
- }
40
- return obj;
41
- }
42
- function _instanceof(left, right) {
43
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
44
- return !!right[Symbol.hasInstance](left);
45
- } else {
46
- return left instanceof right;
47
- }
48
- }
49
- function _iterable_to_array_limit(arr, i) {
50
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
51
- if (_i == null) return;
52
- var _arr = [];
53
- var _n = true;
54
- var _d = false;
55
- var _s, _e;
56
- try {
57
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
58
- _arr.push(_s.value);
59
- if (i && _arr.length === i) break;
60
- }
61
- } catch (err) {
62
- _d = true;
63
- _e = err;
64
- } finally{
65
- try {
66
- if (!_n && _i["return"] != null) _i["return"]();
67
- } finally{
68
- if (_d) throw _e;
69
- }
70
- }
71
- return _arr;
72
- }
73
- function _non_iterable_rest() {
74
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
75
- }
76
- function _object_spread(target) {
77
- for(var i = 1; i < arguments.length; i++){
78
- var source = arguments[i] != null ? arguments[i] : {};
79
- var ownKeys = Object.keys(source);
80
- if (typeof Object.getOwnPropertySymbols === "function") {
81
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
82
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
83
- }));
84
- }
85
- ownKeys.forEach(function(key) {
86
- _define_property(target, key, source[key]);
87
- });
88
- }
89
- return target;
90
- }
91
- function _sliced_to_array(arr, i) {
92
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
93
- }
94
- function _unsupported_iterable_to_array(o, minLen) {
95
- if (!o) return;
96
- if (typeof o === "string") return _array_like_to_array(o, minLen);
97
- var n = Object.prototype.toString.call(o).slice(8, -1);
98
- if (n === "Object" && o.constructor) n = o.constructor.name;
99
- if (n === "Map" || n === "Set") return Array.from(n);
100
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
101
- }
102
- var usePrefetch = function(options) {
103
- var isFirstMounted = useFirstMounted();
20
+ const usePrefetch = (options)=>{
21
+ const isFirstMounted = useFirstMounted();
104
22
  if (isFirstMounted) {
105
- var startTiming = performance.now();
106
- index.logger.info("2. Start Get Prefetch Data: ".concat(options.id, " - ").concat(options.functionId || 'default', " - ").concat(startTiming));
23
+ const startTiming = performance.now();
24
+ index.logger.info(`2. Start Get Prefetch Data: ${options.id} - ${options.functionId || 'default'} - ${startTiming}`);
107
25
  }
108
- var id = options.id, functionId = options.functionId, deferId = options.deferId;
109
- var prefetchInfo = {
110
- id: id,
111
- functionId: functionId
26
+ const { id, functionId, deferId } = options;
27
+ const prefetchInfo = {
28
+ id,
29
+ functionId
112
30
  };
113
- var mfScope = runtimeUtils.getScope();
114
- var state;
115
- var prefetchResult = universal.prefetch(options);
31
+ const mfScope = runtimeUtils.getScope();
32
+ let state;
33
+ const prefetchResult = universal.prefetch(options);
116
34
  if (deferId) {
117
- if (_instanceof(prefetchResult, Promise)) {
118
- state = prefetchResult.then(function(deferredData) {
119
- return deferredData.data[deferId];
120
- });
35
+ if (prefetchResult instanceof Promise) {
36
+ state = prefetchResult.then((deferredData)=>deferredData.data[deferId]);
121
37
  } else {
122
38
  state = prefetchResult.data[deferId];
123
39
  }
124
40
  } else {
125
41
  state = prefetchResult;
126
42
  }
127
- var _useState = _sliced_to_array(react.useState(state), 2), prefetchState = _useState[0], setPrefetchState = _useState[1];
128
- var prefetchInstance = prefetch.MFDataPrefetch.getInstance(mfScope);
129
- react.useEffect(function() {
130
- var useEffectTiming = performance.now();
131
- index.logger.info("3. Start Execute UseEffect: ".concat(options.id, " - ").concat(options.functionId || 'default', " - ").concat(useEffectTiming));
132
- return function() {
133
- prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
43
+ const [prefetchState, setPrefetchState] = react.useState(state);
44
+ const prefetchInstance = prefetch.MFDataPrefetch.getInstance(mfScope);
45
+ react.useEffect(()=>{
46
+ const useEffectTiming = performance.now();
47
+ index.logger.info(`3. Start Execute UseEffect: ${options.id} - ${options.functionId || 'default'} - ${useEffectTiming}`);
48
+ return ()=>{
49
+ prefetchInstance == null ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
134
50
  };
135
51
  }, []);
136
- var refreshExecutor = function(refetchParams) {
137
- var refetchOptions = _object_spread({}, options);
52
+ const refreshExecutor = (refetchParams)=>{
53
+ const refetchOptions = polyfills._extends({}, options);
138
54
  if (refetchParams) {
139
55
  refetchOptions.refetchParams = refetchParams;
140
56
  }
141
- prefetchInstance === null || prefetchInstance === void 0 ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
142
- var newVal = universal.prefetch(refetchOptions);
143
- var newState;
57
+ prefetchInstance == null ? void 0 : prefetchInstance.markOutdate(prefetchInfo, true);
58
+ const newVal = universal.prefetch(refetchOptions);
59
+ let newState;
144
60
  if (deferId) {
145
- if (_instanceof(newVal, Promise)) {
146
- newState = newVal.then(function(deferredData) {
147
- return deferredData.data[deferId];
148
- });
61
+ if (newVal instanceof Promise) {
62
+ newState = newVal.then((deferredData)=>deferredData.data[deferId]);
149
63
  } else {
150
64
  newState = newVal.data[deferId];
151
65
  }
@@ -0,0 +1 @@
1
+ export * from "./src/react/index";