@module-federation/utilities 3.1.61 → 3.1.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,5 +1,57 @@
1
1
  'use strict';
2
2
 
3
+ /******************************************************************************
4
+ Copyright (c) Microsoft Corporation.
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
16
+ ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ function _instanceof(left, right) {
17
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
18
+ return !!right[Symbol.hasInstance](left);
19
+ } else {
20
+ return left instanceof right;
21
+ }
22
+ }
23
+ function __awaiter(thisArg, _arguments, P, generator) {
24
+ function adopt(value) {
25
+ return _instanceof(value, P) ? value : new P(function(resolve) {
26
+ resolve(value);
27
+ });
28
+ }
29
+ return new (P || (P = Promise))(function(resolve, reject) {
30
+ function fulfilled(value) {
31
+ try {
32
+ step(generator.next(value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ }
37
+ function rejected(value) {
38
+ try {
39
+ step(generator["throw"](value));
40
+ } catch (e) {
41
+ reject(e);
42
+ }
43
+ }
44
+ function step(result) {
45
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
46
+ }
47
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
48
+ });
49
+ }
50
+ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
51
+ var e = new Error(message);
52
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
53
+ };
54
+
3
55
  function _array_like_to_array$3(arr, len) {
4
56
  if (len == null || len > arr.length) len = arr.length;
5
57
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -194,35 +246,6 @@ var getRuntimeRemotes$1 = function() {
194
246
  function _array_with_holes$2(arr) {
195
247
  if (Array.isArray(arr)) return arr;
196
248
  }
197
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
198
- try {
199
- var info = gen[key](arg);
200
- var value = info.value;
201
- } catch (error) {
202
- reject(error);
203
- return;
204
- }
205
- if (info.done) {
206
- resolve(value);
207
- } else {
208
- Promise.resolve(value).then(_next, _throw);
209
- }
210
- }
211
- function _async_to_generator$2(fn) {
212
- return function() {
213
- var self = this, args = arguments;
214
- return new Promise(function(resolve, reject) {
215
- var gen = fn.apply(self, args);
216
- function _next(value) {
217
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
218
- }
219
- function _throw(err) {
220
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
221
- }
222
- _next(undefined);
223
- });
224
- };
225
- }
226
249
  function _iterable_to_array_limit$2(arr, i) {
227
250
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
228
251
  if (_i == null) return;
@@ -394,8 +417,8 @@ var createContainerSharingScope = function(asyncContainer) {
394
417
  * { global, url } - values obtained from webpack remotes option `global@url`
395
418
  * or
396
419
  * { asyncContainer } - async container is a promise that resolves to the remote container
397
- */ var injectScript = /*#__PURE__*/ function() {
398
- var _ref = _async_to_generator$2(function(keyOrRuntimeRemoteItem) {
420
+ */ var injectScript = function(keyOrRuntimeRemoteItem) {
421
+ return __awaiter(void 0, void 0, void 0, function() {
399
422
  var asyncContainer;
400
423
  return _ts_generator$2(this, function(_state) {
401
424
  asyncContainer = loadScript(keyOrRuntimeRemoteItem);
@@ -405,10 +428,7 @@ var createContainerSharingScope = function(asyncContainer) {
405
428
  ];
406
429
  });
407
430
  });
408
- return function injectScript(keyOrRuntimeRemoteItem) {
409
- return _ref.apply(this, arguments);
410
- };
411
- }();
431
+ };
412
432
  /**
413
433
  * Creates runtime variables from the provided remotes.
414
434
  * If the value of a remote starts with 'promise ' or 'external ', it is transformed into a function that returns the promise call.
@@ -433,8 +453,8 @@ var createContainerSharingScope = function(asyncContainer) {
433
453
  /**
434
454
  * Returns initialized webpack RemoteContainer.
435
455
  * If its' script does not loaded - then load & init it firstly.
436
- */ var getContainer = /*#__PURE__*/ function() {
437
- var _ref = _async_to_generator$2(function(remoteContainer) {
456
+ */ var getContainer = function(remoteContainer) {
457
+ return __awaiter(void 0, void 0, void 0, function() {
438
458
  var containerScope, containerKey, container;
439
459
  return _ts_generator$2(this, function(_state) {
440
460
  switch(_state.label){
@@ -479,18 +499,17 @@ var createContainerSharingScope = function(asyncContainer) {
479
499
  }
480
500
  });
481
501
  });
482
- return function getContainer(remoteContainer) {
483
- return _ref.apply(this, arguments);
484
- };
485
- }();
502
+ };
486
503
  /**
487
504
  * Return remote module from container.
488
505
  * If you provide `exportName` it automatically return exact property value from module.
489
506
  *
490
507
  * @example
491
508
  * remote.getModule('./pages/index', 'default')
492
- */ var getModule = /*#__PURE__*/ function() {
493
- var _ref = _async_to_generator$2(function(param) {
509
+ */ var getModule = function(_a) {
510
+ return __awaiter(void 0, [
511
+ _a
512
+ ], void 0, function(param) {
494
513
  var remoteContainer, modulePath, exportName, container, modFactory, mod, error;
495
514
  return _ts_generator$2(this, function(_state) {
496
515
  switch(_state.label){
@@ -548,10 +567,7 @@ var createContainerSharingScope = function(asyncContainer) {
548
567
  }
549
568
  });
550
569
  });
551
- return function getModule(_) {
552
- return _ref.apply(this, arguments);
553
- };
554
- }();
570
+ };
555
571
 
556
572
  var isObjectEmpty = function(obj) {
557
573
  for(var x in obj){
@@ -568,48 +584,6 @@ function _array_like_to_array$1(arr, len) {
568
584
  function _array_with_holes$1(arr) {
569
585
  if (Array.isArray(arr)) return arr;
570
586
  }
571
- function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
572
- try {
573
- var info = gen[key](arg);
574
- var value = info.value;
575
- } catch (error) {
576
- reject(error);
577
- return;
578
- }
579
- if (info.done) {
580
- resolve(value);
581
- } else {
582
- Promise.resolve(value).then(_next, _throw);
583
- }
584
- }
585
- function _async_to_generator$1(fn) {
586
- return function() {
587
- var self = this, args = arguments;
588
- return new Promise(function(resolve, reject) {
589
- var gen = fn.apply(self, args);
590
- function _next(value) {
591
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
592
- }
593
- function _throw(err) {
594
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
595
- }
596
- _next(undefined);
597
- });
598
- };
599
- }
600
- function _define_property$1(obj, key, value) {
601
- if (key in obj) {
602
- Object.defineProperty(obj, key, {
603
- value: value,
604
- enumerable: true,
605
- configurable: true,
606
- writable: true
607
- });
608
- } else {
609
- obj[key] = value;
610
- }
611
- return obj;
612
- }
613
587
  function _iterable_to_array_limit$1(arr, i) {
614
588
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
615
589
  if (_i == null) return;
@@ -637,40 +611,6 @@ function _iterable_to_array_limit$1(arr, i) {
637
611
  function _non_iterable_rest$1() {
638
612
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
639
613
  }
640
- function _object_spread(target) {
641
- for(var i = 1; i < arguments.length; i++){
642
- var source = arguments[i] != null ? arguments[i] : {};
643
- var ownKeys = Object.keys(source);
644
- if (typeof Object.getOwnPropertySymbols === "function") {
645
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
646
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
647
- }));
648
- }
649
- ownKeys.forEach(function(key) {
650
- _define_property$1(target, key, source[key]);
651
- });
652
- }
653
- return target;
654
- }
655
- function ownKeys(object, enumerableOnly) {
656
- var keys = Object.keys(object);
657
- if (Object.getOwnPropertySymbols) {
658
- var symbols = Object.getOwnPropertySymbols(object);
659
- keys.push.apply(keys, symbols);
660
- }
661
- return keys;
662
- }
663
- function _object_spread_props(target, source) {
664
- source = source != null ? source : {};
665
- if (Object.getOwnPropertyDescriptors) {
666
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
667
- } else {
668
- ownKeys(Object(source)).forEach(function(key) {
669
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
670
- });
671
- }
672
- return target;
673
- }
674
614
  function _sliced_to_array$1(arr, i) {
675
615
  return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
676
616
  }
@@ -793,12 +733,12 @@ function _ts_generator$1(thisArg, body) {
793
733
  var timestamp = bustRemoteEntryCache ? "?t=".concat(new Date().getTime()) : '';
794
734
  var webpackRequire = __webpack_require__;
795
735
  webpackRequire.l("".concat(url).concat(timestamp), function(event) {
796
- var _event_target;
736
+ var _a;
797
737
  if ((event === null || event === void 0 ? void 0 : event.type) === 'load') {
798
738
  // Script loaded successfully:
799
739
  return resolve();
800
740
  }
801
- var realSrc = event === null || event === void 0 ? void 0 : (_event_target = event.target) === null || _event_target === void 0 ? void 0 : _event_target.src;
741
+ var realSrc = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.src;
802
742
  var error = new Error();
803
743
  error.message = 'Loading script failed.\n(missing: ' + realSrc + ')';
804
744
  error.name = 'ScriptExternalLoadError';
@@ -806,8 +746,8 @@ function _ts_generator$1(thisArg, body) {
806
746
  }, scope);
807
747
  });
808
748
  };
809
- var loadEsmRemote = /*#__PURE__*/ function() {
810
- var _ref = _async_to_generator$1(function(url, scope) {
749
+ var loadEsmRemote = function(url, scope) {
750
+ return __awaiter(void 0, void 0, void 0, function() {
811
751
  var module;
812
752
  return _ts_generator$1(this, function(_state) {
813
753
  switch(_state.label){
@@ -821,7 +761,7 @@ var loadEsmRemote = /*#__PURE__*/ function() {
821
761
  if (!module) {
822
762
  throw new Error("Unable to load requested remote from ".concat(url, " with scope ").concat(scope));
823
763
  }
824
- window[scope] = _object_spread_props(_object_spread({}, module), {
764
+ window[scope] = Object.assign(Object.assign({}, module), {
825
765
  __initializing: false,
826
766
  __initialized: false
827
767
  });
@@ -831,16 +771,13 @@ var loadEsmRemote = /*#__PURE__*/ function() {
831
771
  }
832
772
  });
833
773
  });
834
- return function loadEsmRemote(url, scope) {
835
- return _ref.apply(this, arguments);
836
- };
837
- }();
774
+ };
838
775
  /**
839
776
  * Function to initialize sharing
840
777
  * @async
841
778
  * @function
842
- */ var initSharing = /*#__PURE__*/ function() {
843
- var _ref = _async_to_generator$1(function() {
779
+ */ var initSharing = function() {
780
+ return __awaiter(void 0, void 0, void 0, function() {
844
781
  var webpackShareScopes;
845
782
  return _ts_generator$1(this, function(_state) {
846
783
  switch(_state.label){
@@ -864,17 +801,14 @@ var loadEsmRemote = /*#__PURE__*/ function() {
864
801
  }
865
802
  });
866
803
  });
867
- return function initSharing() {
868
- return _ref.apply(this, arguments);
869
- };
870
- }();
804
+ };
871
805
  /**
872
806
  * Function to initialize container
873
807
  * @async
874
808
  * @function
875
809
  * @param {WebpackRemoteContainer} containerScope - The container scope
876
- */ var initContainer = /*#__PURE__*/ function() {
877
- var _ref = _async_to_generator$1(function(containerScope) {
810
+ */ var initContainer = function(containerScope) {
811
+ return __awaiter(void 0, void 0, void 0, function() {
878
812
  var webpackShareScopes, error;
879
813
  return _ts_generator$1(this, function(_state) {
880
814
  switch(_state.label){
@@ -919,18 +853,17 @@ var loadEsmRemote = /*#__PURE__*/ function() {
919
853
  }
920
854
  });
921
855
  });
922
- return function initContainer(containerScope) {
923
- return _ref.apply(this, arguments);
924
- };
925
- }();
856
+ };
926
857
  /**
927
858
  * Function to import remote
928
859
  * @async
929
860
  * @function
930
861
  * @param {ImportRemoteOptions} options - The options for importing the remote
931
862
  * @returns {Promise<T>} A promise that resolves with the imported module
932
- */ var importRemote = /*#__PURE__*/ function() {
933
- var _ref = _async_to_generator$1(function(param) {
863
+ */ var importRemote = function(_a) {
864
+ return __awaiter(void 0, [
865
+ _a
866
+ ], void 0, function(param) {
934
867
  var url, scope, module, _param_remoteEntryFileName, remoteEntryFileName, _param_bustRemoteEntryCache, bustRemoteEntryCache, _param_esm, esm, remoteScope, remoteUrl, remoteUrlWithEntryFile, asyncContainer, _ref, moduleFactory, moduleFactory1;
935
868
  return _ts_generator$1(this, function(_state) {
936
869
  switch(_state.label){
@@ -1009,10 +942,7 @@ var loadEsmRemote = /*#__PURE__*/ function() {
1009
942
  }
1010
943
  });
1011
944
  });
1012
- return function importRemote(_) {
1013
- return _ref.apply(this, arguments);
1014
- };
1015
- }();
945
+ };
1016
946
 
1017
947
  function _class_call_check(instance, Constructor) {
1018
948
  if (!(instance instanceof Constructor)) {
@@ -1032,19 +962,6 @@ function _create_class(Constructor, protoProps, staticProps) {
1032
962
  if (staticProps) _defineProperties(Constructor, staticProps);
1033
963
  return Constructor;
1034
964
  }
1035
- function _define_property(obj, key, value) {
1036
- if (key in obj) {
1037
- Object.defineProperty(obj, key, {
1038
- value: value,
1039
- enumerable: true,
1040
- configurable: true,
1041
- writable: true
1042
- });
1043
- } else {
1044
- obj[key] = value;
1045
- }
1046
- return obj;
1047
- }
1048
965
  var Logger = /*#__PURE__*/ function() {
1049
966
  function Logger() {
1050
967
  _class_call_check(this, Logger);
@@ -1066,7 +983,7 @@ var Logger = /*#__PURE__*/ function() {
1066
983
  ]);
1067
984
  return Logger;
1068
985
  }();
1069
- _define_property(Logger, "loggerInstance", console);
986
+ Logger.loggerInstance = console;
1070
987
 
1071
988
  function _array_like_to_array(arr, len) {
1072
989
  if (len == null || len > arr.length) len = arr.length;
@@ -1163,35 +1080,6 @@ var getRuntimeRemotes = function() {
1163
1080
  return {};
1164
1081
  };
1165
1082
 
1166
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1167
- try {
1168
- var info = gen[key](arg);
1169
- var value = info.value;
1170
- } catch (error) {
1171
- reject(error);
1172
- return;
1173
- }
1174
- if (info.done) {
1175
- resolve(value);
1176
- } else {
1177
- Promise.resolve(value).then(_next, _throw);
1178
- }
1179
- }
1180
- function _async_to_generator(fn) {
1181
- return function() {
1182
- var self = this, args = arguments;
1183
- return new Promise(function(resolve, reject) {
1184
- var gen = fn.apply(self, args);
1185
- function _next(value) {
1186
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1187
- }
1188
- function _throw(err) {
1189
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1190
- }
1191
- _next(undefined);
1192
- });
1193
- };
1194
- }
1195
1083
  function _ts_generator(thisArg, body) {
1196
1084
  var f, y, t, g, _ = {
1197
1085
  label: 0,
@@ -1287,8 +1175,8 @@ function _ts_generator(thisArg, body) {
1287
1175
  };
1288
1176
  }
1289
1177
  }
1290
- var importDelegatedModule = /*#__PURE__*/ function() {
1291
- var _ref = _async_to_generator(function(keyOrRuntimeRemoteItem) {
1178
+ var importDelegatedModule = function(keyOrRuntimeRemoteItem) {
1179
+ return __awaiter(void 0, void 0, void 0, function() {
1292
1180
  return _ts_generator(this, function(_state) {
1293
1181
  // @ts-ignore
1294
1182
  return [
@@ -1365,10 +1253,7 @@ var importDelegatedModule = /*#__PURE__*/ function() {
1365
1253
  ];
1366
1254
  });
1367
1255
  });
1368
- return function importDelegatedModule(keyOrRuntimeRemoteItem) {
1369
- return _ref.apply(this, arguments);
1370
- };
1371
- }();
1256
+ };
1372
1257
 
1373
1258
  exports.Logger = Logger;
1374
1259
  exports.createRuntimeVariables = createRuntimeVariables;
package/dist/index.esm.js CHANGED
@@ -1,3 +1,55 @@
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ function _instanceof(left, right) {
15
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
16
+ return !!right[Symbol.hasInstance](left);
17
+ } else {
18
+ return left instanceof right;
19
+ }
20
+ }
21
+ function __awaiter(thisArg, _arguments, P, generator) {
22
+ function adopt(value) {
23
+ return _instanceof(value, P) ? value : new P(function(resolve) {
24
+ resolve(value);
25
+ });
26
+ }
27
+ return new (P || (P = Promise))(function(resolve, reject) {
28
+ function fulfilled(value) {
29
+ try {
30
+ step(generator.next(value));
31
+ } catch (e) {
32
+ reject(e);
33
+ }
34
+ }
35
+ function rejected(value) {
36
+ try {
37
+ step(generator["throw"](value));
38
+ } catch (e) {
39
+ reject(e);
40
+ }
41
+ }
42
+ function step(result) {
43
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
44
+ }
45
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
46
+ });
47
+ }
48
+ typeof SuppressedError === "function" ? SuppressedError : function _SuppressedError(error, suppressed, message) {
49
+ var e = new Error(message);
50
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
51
+ };
52
+
1
53
  function _array_like_to_array$3(arr, len) {
2
54
  if (len == null || len > arr.length) len = arr.length;
3
55
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -192,35 +244,6 @@ var getRuntimeRemotes$1 = function() {
192
244
  function _array_with_holes$2(arr) {
193
245
  if (Array.isArray(arr)) return arr;
194
246
  }
195
- function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
196
- try {
197
- var info = gen[key](arg);
198
- var value = info.value;
199
- } catch (error) {
200
- reject(error);
201
- return;
202
- }
203
- if (info.done) {
204
- resolve(value);
205
- } else {
206
- Promise.resolve(value).then(_next, _throw);
207
- }
208
- }
209
- function _async_to_generator$2(fn) {
210
- return function() {
211
- var self = this, args = arguments;
212
- return new Promise(function(resolve, reject) {
213
- var gen = fn.apply(self, args);
214
- function _next(value) {
215
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
216
- }
217
- function _throw(err) {
218
- asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
219
- }
220
- _next(undefined);
221
- });
222
- };
223
- }
224
247
  function _iterable_to_array_limit$2(arr, i) {
225
248
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
226
249
  if (_i == null) return;
@@ -392,8 +415,8 @@ var createContainerSharingScope = function(asyncContainer) {
392
415
  * { global, url } - values obtained from webpack remotes option `global@url`
393
416
  * or
394
417
  * { asyncContainer } - async container is a promise that resolves to the remote container
395
- */ var injectScript = /*#__PURE__*/ function() {
396
- var _ref = _async_to_generator$2(function(keyOrRuntimeRemoteItem) {
418
+ */ var injectScript = function(keyOrRuntimeRemoteItem) {
419
+ return __awaiter(void 0, void 0, void 0, function() {
397
420
  var asyncContainer;
398
421
  return _ts_generator$2(this, function(_state) {
399
422
  asyncContainer = loadScript(keyOrRuntimeRemoteItem);
@@ -403,10 +426,7 @@ var createContainerSharingScope = function(asyncContainer) {
403
426
  ];
404
427
  });
405
428
  });
406
- return function injectScript(keyOrRuntimeRemoteItem) {
407
- return _ref.apply(this, arguments);
408
- };
409
- }();
429
+ };
410
430
  /**
411
431
  * Creates runtime variables from the provided remotes.
412
432
  * If the value of a remote starts with 'promise ' or 'external ', it is transformed into a function that returns the promise call.
@@ -431,8 +451,8 @@ var createContainerSharingScope = function(asyncContainer) {
431
451
  /**
432
452
  * Returns initialized webpack RemoteContainer.
433
453
  * If its' script does not loaded - then load & init it firstly.
434
- */ var getContainer = /*#__PURE__*/ function() {
435
- var _ref = _async_to_generator$2(function(remoteContainer) {
454
+ */ var getContainer = function(remoteContainer) {
455
+ return __awaiter(void 0, void 0, void 0, function() {
436
456
  var containerScope, containerKey, container;
437
457
  return _ts_generator$2(this, function(_state) {
438
458
  switch(_state.label){
@@ -477,18 +497,17 @@ var createContainerSharingScope = function(asyncContainer) {
477
497
  }
478
498
  });
479
499
  });
480
- return function getContainer(remoteContainer) {
481
- return _ref.apply(this, arguments);
482
- };
483
- }();
500
+ };
484
501
  /**
485
502
  * Return remote module from container.
486
503
  * If you provide `exportName` it automatically return exact property value from module.
487
504
  *
488
505
  * @example
489
506
  * remote.getModule('./pages/index', 'default')
490
- */ var getModule = /*#__PURE__*/ function() {
491
- var _ref = _async_to_generator$2(function(param) {
507
+ */ var getModule = function(_a) {
508
+ return __awaiter(void 0, [
509
+ _a
510
+ ], void 0, function(param) {
492
511
  var remoteContainer, modulePath, exportName, container, modFactory, mod, error;
493
512
  return _ts_generator$2(this, function(_state) {
494
513
  switch(_state.label){
@@ -546,10 +565,7 @@ var createContainerSharingScope = function(asyncContainer) {
546
565
  }
547
566
  });
548
567
  });
549
- return function getModule(_) {
550
- return _ref.apply(this, arguments);
551
- };
552
- }();
568
+ };
553
569
 
554
570
  var isObjectEmpty = function(obj) {
555
571
  for(var x in obj){
@@ -566,48 +582,6 @@ function _array_like_to_array$1(arr, len) {
566
582
  function _array_with_holes$1(arr) {
567
583
  if (Array.isArray(arr)) return arr;
568
584
  }
569
- function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
570
- try {
571
- var info = gen[key](arg);
572
- var value = info.value;
573
- } catch (error) {
574
- reject(error);
575
- return;
576
- }
577
- if (info.done) {
578
- resolve(value);
579
- } else {
580
- Promise.resolve(value).then(_next, _throw);
581
- }
582
- }
583
- function _async_to_generator$1(fn) {
584
- return function() {
585
- var self = this, args = arguments;
586
- return new Promise(function(resolve, reject) {
587
- var gen = fn.apply(self, args);
588
- function _next(value) {
589
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
590
- }
591
- function _throw(err) {
592
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
593
- }
594
- _next(undefined);
595
- });
596
- };
597
- }
598
- function _define_property$1(obj, key, value) {
599
- if (key in obj) {
600
- Object.defineProperty(obj, key, {
601
- value: value,
602
- enumerable: true,
603
- configurable: true,
604
- writable: true
605
- });
606
- } else {
607
- obj[key] = value;
608
- }
609
- return obj;
610
- }
611
585
  function _iterable_to_array_limit$1(arr, i) {
612
586
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
613
587
  if (_i == null) return;
@@ -635,40 +609,6 @@ function _iterable_to_array_limit$1(arr, i) {
635
609
  function _non_iterable_rest$1() {
636
610
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
637
611
  }
638
- function _object_spread(target) {
639
- for(var i = 1; i < arguments.length; i++){
640
- var source = arguments[i] != null ? arguments[i] : {};
641
- var ownKeys = Object.keys(source);
642
- if (typeof Object.getOwnPropertySymbols === "function") {
643
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
644
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
645
- }));
646
- }
647
- ownKeys.forEach(function(key) {
648
- _define_property$1(target, key, source[key]);
649
- });
650
- }
651
- return target;
652
- }
653
- function ownKeys(object, enumerableOnly) {
654
- var keys = Object.keys(object);
655
- if (Object.getOwnPropertySymbols) {
656
- var symbols = Object.getOwnPropertySymbols(object);
657
- keys.push.apply(keys, symbols);
658
- }
659
- return keys;
660
- }
661
- function _object_spread_props(target, source) {
662
- source = source != null ? source : {};
663
- if (Object.getOwnPropertyDescriptors) {
664
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
665
- } else {
666
- ownKeys(Object(source)).forEach(function(key) {
667
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
668
- });
669
- }
670
- return target;
671
- }
672
612
  function _sliced_to_array$1(arr, i) {
673
613
  return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
674
614
  }
@@ -791,12 +731,12 @@ function _ts_generator$1(thisArg, body) {
791
731
  var timestamp = bustRemoteEntryCache ? "?t=".concat(new Date().getTime()) : '';
792
732
  var webpackRequire = __webpack_require__;
793
733
  webpackRequire.l("".concat(url).concat(timestamp), function(event) {
794
- var _event_target;
734
+ var _a;
795
735
  if ((event === null || event === void 0 ? void 0 : event.type) === 'load') {
796
736
  // Script loaded successfully:
797
737
  return resolve();
798
738
  }
799
- var realSrc = event === null || event === void 0 ? void 0 : (_event_target = event.target) === null || _event_target === void 0 ? void 0 : _event_target.src;
739
+ var realSrc = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.src;
800
740
  var error = new Error();
801
741
  error.message = 'Loading script failed.\n(missing: ' + realSrc + ')';
802
742
  error.name = 'ScriptExternalLoadError';
@@ -804,8 +744,8 @@ function _ts_generator$1(thisArg, body) {
804
744
  }, scope);
805
745
  });
806
746
  };
807
- var loadEsmRemote = /*#__PURE__*/ function() {
808
- var _ref = _async_to_generator$1(function(url, scope) {
747
+ var loadEsmRemote = function(url, scope) {
748
+ return __awaiter(void 0, void 0, void 0, function() {
809
749
  var module;
810
750
  return _ts_generator$1(this, function(_state) {
811
751
  switch(_state.label){
@@ -819,7 +759,7 @@ var loadEsmRemote = /*#__PURE__*/ function() {
819
759
  if (!module) {
820
760
  throw new Error("Unable to load requested remote from ".concat(url, " with scope ").concat(scope));
821
761
  }
822
- window[scope] = _object_spread_props(_object_spread({}, module), {
762
+ window[scope] = Object.assign(Object.assign({}, module), {
823
763
  __initializing: false,
824
764
  __initialized: false
825
765
  });
@@ -829,16 +769,13 @@ var loadEsmRemote = /*#__PURE__*/ function() {
829
769
  }
830
770
  });
831
771
  });
832
- return function loadEsmRemote(url, scope) {
833
- return _ref.apply(this, arguments);
834
- };
835
- }();
772
+ };
836
773
  /**
837
774
  * Function to initialize sharing
838
775
  * @async
839
776
  * @function
840
- */ var initSharing = /*#__PURE__*/ function() {
841
- var _ref = _async_to_generator$1(function() {
777
+ */ var initSharing = function() {
778
+ return __awaiter(void 0, void 0, void 0, function() {
842
779
  var webpackShareScopes;
843
780
  return _ts_generator$1(this, function(_state) {
844
781
  switch(_state.label){
@@ -862,17 +799,14 @@ var loadEsmRemote = /*#__PURE__*/ function() {
862
799
  }
863
800
  });
864
801
  });
865
- return function initSharing() {
866
- return _ref.apply(this, arguments);
867
- };
868
- }();
802
+ };
869
803
  /**
870
804
  * Function to initialize container
871
805
  * @async
872
806
  * @function
873
807
  * @param {WebpackRemoteContainer} containerScope - The container scope
874
- */ var initContainer = /*#__PURE__*/ function() {
875
- var _ref = _async_to_generator$1(function(containerScope) {
808
+ */ var initContainer = function(containerScope) {
809
+ return __awaiter(void 0, void 0, void 0, function() {
876
810
  var webpackShareScopes, error;
877
811
  return _ts_generator$1(this, function(_state) {
878
812
  switch(_state.label){
@@ -917,18 +851,17 @@ var loadEsmRemote = /*#__PURE__*/ function() {
917
851
  }
918
852
  });
919
853
  });
920
- return function initContainer(containerScope) {
921
- return _ref.apply(this, arguments);
922
- };
923
- }();
854
+ };
924
855
  /**
925
856
  * Function to import remote
926
857
  * @async
927
858
  * @function
928
859
  * @param {ImportRemoteOptions} options - The options for importing the remote
929
860
  * @returns {Promise<T>} A promise that resolves with the imported module
930
- */ var importRemote = /*#__PURE__*/ function() {
931
- var _ref = _async_to_generator$1(function(param) {
861
+ */ var importRemote = function(_a) {
862
+ return __awaiter(void 0, [
863
+ _a
864
+ ], void 0, function(param) {
932
865
  var url, scope, module, _param_remoteEntryFileName, remoteEntryFileName, _param_bustRemoteEntryCache, bustRemoteEntryCache, _param_esm, esm, remoteScope, remoteUrl, remoteUrlWithEntryFile, asyncContainer, _ref, moduleFactory, moduleFactory1;
933
866
  return _ts_generator$1(this, function(_state) {
934
867
  switch(_state.label){
@@ -1007,10 +940,7 @@ var loadEsmRemote = /*#__PURE__*/ function() {
1007
940
  }
1008
941
  });
1009
942
  });
1010
- return function importRemote(_) {
1011
- return _ref.apply(this, arguments);
1012
- };
1013
- }();
943
+ };
1014
944
 
1015
945
  function _class_call_check(instance, Constructor) {
1016
946
  if (!(instance instanceof Constructor)) {
@@ -1030,19 +960,6 @@ function _create_class(Constructor, protoProps, staticProps) {
1030
960
  if (staticProps) _defineProperties(Constructor, staticProps);
1031
961
  return Constructor;
1032
962
  }
1033
- function _define_property(obj, key, value) {
1034
- if (key in obj) {
1035
- Object.defineProperty(obj, key, {
1036
- value: value,
1037
- enumerable: true,
1038
- configurable: true,
1039
- writable: true
1040
- });
1041
- } else {
1042
- obj[key] = value;
1043
- }
1044
- return obj;
1045
- }
1046
963
  var Logger = /*#__PURE__*/ function() {
1047
964
  function Logger() {
1048
965
  _class_call_check(this, Logger);
@@ -1064,7 +981,7 @@ var Logger = /*#__PURE__*/ function() {
1064
981
  ]);
1065
982
  return Logger;
1066
983
  }();
1067
- _define_property(Logger, "loggerInstance", console);
984
+ Logger.loggerInstance = console;
1068
985
 
1069
986
  function _array_like_to_array(arr, len) {
1070
987
  if (len == null || len > arr.length) len = arr.length;
@@ -1161,35 +1078,6 @@ var getRuntimeRemotes = function() {
1161
1078
  return {};
1162
1079
  };
1163
1080
 
1164
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
1165
- try {
1166
- var info = gen[key](arg);
1167
- var value = info.value;
1168
- } catch (error) {
1169
- reject(error);
1170
- return;
1171
- }
1172
- if (info.done) {
1173
- resolve(value);
1174
- } else {
1175
- Promise.resolve(value).then(_next, _throw);
1176
- }
1177
- }
1178
- function _async_to_generator(fn) {
1179
- return function() {
1180
- var self = this, args = arguments;
1181
- return new Promise(function(resolve, reject) {
1182
- var gen = fn.apply(self, args);
1183
- function _next(value) {
1184
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
1185
- }
1186
- function _throw(err) {
1187
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
1188
- }
1189
- _next(undefined);
1190
- });
1191
- };
1192
- }
1193
1081
  function _ts_generator(thisArg, body) {
1194
1082
  var f, y, t, g, _ = {
1195
1083
  label: 0,
@@ -1285,8 +1173,8 @@ function _ts_generator(thisArg, body) {
1285
1173
  };
1286
1174
  }
1287
1175
  }
1288
- var importDelegatedModule = /*#__PURE__*/ function() {
1289
- var _ref = _async_to_generator(function(keyOrRuntimeRemoteItem) {
1176
+ var importDelegatedModule = function(keyOrRuntimeRemoteItem) {
1177
+ return __awaiter(void 0, void 0, void 0, function() {
1290
1178
  return _ts_generator(this, function(_state) {
1291
1179
  // @ts-ignore
1292
1180
  return [
@@ -1363,9 +1251,6 @@ var importDelegatedModule = /*#__PURE__*/ function() {
1363
1251
  ];
1364
1252
  });
1365
1253
  });
1366
- return function importDelegatedModule(keyOrRuntimeRemoteItem) {
1367
- return _ref.apply(this, arguments);
1368
- };
1369
- }();
1254
+ };
1370
1255
 
1371
1256
  export { Logger, createRuntimeVariables, extractUrlAndGlobal, getContainer, getModule, getRuntimeRemotes, importDelegatedModule, importRemote, injectScript, isObjectEmpty, loadScript };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@module-federation/utilities",
3
- "version": "3.1.61",
3
+ "version": "3.1.62",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.esm.js",
6
- "types": "./dist/index.cjs.d.ts",
6
+ "types": "./dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -18,10 +18,11 @@
18
18
  "directory": "packages/utilities"
19
19
  },
20
20
  "devDependencies": {
21
- "react": "18.3.1"
21
+ "react": "18.3.1",
22
+ "@types/react": "^18.3.11"
22
23
  },
23
24
  "dependencies": {
24
- "@module-federation/sdk": "0.17.0"
25
+ "@module-federation/sdk": "0.17.1"
25
26
  },
26
27
  "peerDependencies": {
27
28
  "react": "^16 || ^17 || ^18",
@@ -41,7 +42,7 @@
41
42
  },
42
43
  "exports": {
43
44
  ".": {
44
- "types": "./dist/index.cjs.d.ts",
45
+ "types": "./dist/index.d.ts",
45
46
  "import": "./dist/index.esm.js",
46
47
  "require": "./dist/index.cjs.js"
47
48
  },
@@ -50,10 +51,10 @@
50
51
  "typesVersions": {
51
52
  "*": {
52
53
  ".": [
53
- "./dist/index.cjs.d.ts"
54
+ "./dist/index.d.ts"
54
55
  ],
55
56
  "type": [
56
- "./dist/type.cjs.d.ts"
57
+ "./dist/type.d.ts"
57
58
  ]
58
59
  }
59
60
  }
@@ -1 +0,0 @@
1
- export * from "./src/index";
File without changes