@xfe-repo/web-micro 1.2.4 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -13,6 +13,7 @@ type MicroAppProps = {
13
13
  data?: Record<string, any>;
14
14
  loadingFallback?: React.ReactNode;
15
15
  errorFallback?: React.ReactNode;
16
+ aHrefResolver?: (hrefValue: string) => string;
16
17
  };
17
18
  declare const MicroAppRoute: React.MemoExoticComponent<(props: MicroAppProps) => react_jsx_runtime.JSX.Element>;
18
19
 
@@ -60,7 +61,9 @@ declare class MicroAppEventCenter {
60
61
  addDispatchListener(type: string, listener: MicroAppDispatchListener): void;
61
62
  removeDispatchListener(type: string, listener?: MicroAppDispatchListener): boolean | undefined;
62
63
  }
64
+ type AHrefResolverType = (hrefValue: string) => string;
65
+ declare const aHrefResolverCollector: Record<string, AHrefResolverType>;
63
66
 
64
67
  declare const microApp: _micro_zoe_micro_app.MicroApp;
65
68
 
66
- export { type MicroAppActionMetaType, type MicroAppActionType, type MicroAppDispatchListener, MicroAppEventCenter, type MicroAppEventCenterConfig, MicroAppEventEnum, type MicroAppGlobalDataType, MicroAppLink, type MicroAppProps, MicroAppRoute, type NavigateToWithMicroAppOptions, microApp, navigateToWithMicroApp };
69
+ export { type MicroAppActionMetaType, type MicroAppActionType, type MicroAppDispatchListener, MicroAppEventCenter, type MicroAppEventCenterConfig, MicroAppEventEnum, type MicroAppGlobalDataType, MicroAppLink, type MicroAppProps, MicroAppRoute, type NavigateToWithMicroAppOptions, aHrefResolverCollector, microApp, navigateToWithMicroApp };
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ type MicroAppProps = {
13
13
  data?: Record<string, any>;
14
14
  loadingFallback?: React.ReactNode;
15
15
  errorFallback?: React.ReactNode;
16
+ aHrefResolver?: (hrefValue: string) => string;
16
17
  };
17
18
  declare const MicroAppRoute: React.MemoExoticComponent<(props: MicroAppProps) => react_jsx_runtime.JSX.Element>;
18
19
 
@@ -60,7 +61,9 @@ declare class MicroAppEventCenter {
60
61
  addDispatchListener(type: string, listener: MicroAppDispatchListener): void;
61
62
  removeDispatchListener(type: string, listener?: MicroAppDispatchListener): boolean | undefined;
62
63
  }
64
+ type AHrefResolverType = (hrefValue: string) => string;
65
+ declare const aHrefResolverCollector: Record<string, AHrefResolverType>;
63
66
 
64
67
  declare const microApp: _micro_zoe_micro_app.MicroApp;
65
68
 
66
- export { type MicroAppActionMetaType, type MicroAppActionType, type MicroAppDispatchListener, MicroAppEventCenter, type MicroAppEventCenterConfig, MicroAppEventEnum, type MicroAppGlobalDataType, MicroAppLink, type MicroAppProps, MicroAppRoute, type NavigateToWithMicroAppOptions, microApp, navigateToWithMicroApp };
69
+ export { type MicroAppActionMetaType, type MicroAppActionType, type MicroAppDispatchListener, MicroAppEventCenter, type MicroAppEventCenterConfig, MicroAppEventEnum, type MicroAppGlobalDataType, MicroAppLink, type MicroAppProps, MicroAppRoute, type NavigateToWithMicroAppOptions, aHrefResolverCollector, microApp, navigateToWithMicroApp };
package/dist/index.js CHANGED
@@ -113,6 +113,10 @@ function _object_spread(target) {
113
113
  function _sliced_to_array(arr, i) {
114
114
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
115
115
  }
116
+ function _type_of(obj) {
117
+ "@swc/helpers - typeof";
118
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
119
+ }
116
120
  function _unsupported_iterable_to_array(o, minLen) {
117
121
  if (!o) return;
118
122
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -122,7 +126,7 @@ function _unsupported_iterable_to_array(o, minLen) {
122
126
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
123
127
  }
124
128
  function _ts_generator(thisArg, body) {
125
- var f, y, t, g, _ = {
129
+ var f, y, t, _ = {
126
130
  label: 0,
127
131
  sent: function() {
128
132
  if (t[0] & 1) throw t[1];
@@ -130,13 +134,17 @@ function _ts_generator(thisArg, body) {
130
134
  },
131
135
  trys: [],
132
136
  ops: []
133
- };
134
- return g = {
135
- next: verb(0),
136
- "throw": verb(1),
137
- "return": verb(2)
138
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
139
- return this;
137
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
138
+ return d(g, "next", {
139
+ value: verb(0)
140
+ }), d(g, "throw", {
141
+ value: verb(1)
142
+ }), d(g, "return", {
143
+ value: verb(2)
144
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
145
+ value: function() {
146
+ return this;
147
+ }
140
148
  }), g;
141
149
  function verb(n) {
142
150
  return function(v) {
@@ -148,7 +156,7 @@ function _ts_generator(thisArg, body) {
148
156
  }
149
157
  function step(op) {
150
158
  if (f) throw new TypeError("Generator is already executing.");
151
- while(_)try {
159
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
152
160
  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;
153
161
  if (y = 0, t) op = [
154
162
  op[0] & 2,
@@ -222,20 +230,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
222
230
  var __getOwnPropNames = Object.getOwnPropertyNames;
223
231
  var __getProtoOf = Object.getPrototypeOf;
224
232
  var __hasOwnProp = Object.prototype.hasOwnProperty;
225
- var __export = function(target, all) {
233
+ var __export = function __export(target, all) {
226
234
  for(var name in all)__defProp(target, name, {
227
235
  get: all[name],
228
236
  enumerable: true
229
237
  });
230
238
  };
231
- var __copyProps = function(to, from, except, desc) {
232
- if (from && typeof from === "object" || typeof from === "function") {
239
+ var __copyProps = function __copyProps(to, from, except, desc) {
240
+ if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
233
241
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
234
242
  try {
235
243
  var _loop = function() {
236
244
  var key = _step.value;
237
245
  if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
238
- get: function() {
246
+ get: function get() {
239
247
  return from[key];
240
248
  },
241
249
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
@@ -259,10 +267,10 @@ var __copyProps = function(to, from, except, desc) {
259
267
  }
260
268
  return to;
261
269
  };
262
- var __reExport = function(target, mod, secondTarget) {
270
+ var __reExport = function __reExport(target, mod, secondTarget) {
263
271
  return __copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default");
264
272
  };
265
- var __toESM = function(mod, isNodeMode, target) {
273
+ var __toESM = function __toESM(mod, isNodeMode, target) {
266
274
  return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
267
275
  // file that has been converted to a CommonJS file using a Babel-
268
276
  // compatible transform (i.e. "__esModule" has not been set), then set
@@ -272,45 +280,48 @@ var __toESM = function(mod, isNodeMode, target) {
272
280
  enumerable: true
273
281
  }) : target, mod);
274
282
  };
275
- var __toCommonJS = function(mod) {
283
+ var __toCommonJS = function __toCommonJS(mod) {
276
284
  return __copyProps(__defProp({}, "__esModule", {
277
285
  value: true
278
286
  }), mod);
279
287
  };
280
288
  // src/index.ts
281
- var src_exports = {};
282
- __export(src_exports, {
283
- MicroAppEventCenter: function() {
289
+ var index_exports = {};
290
+ __export(index_exports, {
291
+ MicroAppEventCenter: function MicroAppEventCenter1() {
284
292
  return MicroAppEventCenter;
285
293
  },
286
- MicroAppEventEnum: function() {
294
+ MicroAppEventEnum: function MicroAppEventEnum1() {
287
295
  return MicroAppEventEnum;
288
296
  },
289
- MicroAppLink: function() {
297
+ MicroAppLink: function MicroAppLink1() {
290
298
  return MicroAppLink;
291
299
  },
292
- MicroAppRoute: function() {
300
+ MicroAppRoute: function MicroAppRoute1() {
293
301
  return MicroAppRoute;
294
302
  },
295
- microApp: function() {
296
- return microApp2;
303
+ aHrefResolverCollector: function aHrefResolverCollector1() {
304
+ return aHrefResolverCollector;
305
+ },
306
+ microApp: function microApp1() {
307
+ return microApp;
297
308
  },
298
- navigateToWithMicroApp: function() {
309
+ navigateToWithMicroApp: function navigateToWithMicroApp1() {
299
310
  return navigateToWithMicroApp;
300
311
  }
301
312
  });
302
- module.exports = __toCommonJS(src_exports);
313
+ module.exports = __toCommonJS(index_exports);
303
314
  var import_env = require("@xfe-repo/web-utils/env");
304
315
  var import_tools = require("@xfe-repo/web-utils/tools");
305
- var import_micro_app2 = __toESM(require("@micro-zoe/micro-app"));
306
- __reExport(src_exports, require("@micro-zoe/micro-app"), module.exports);
316
+ var import_micro_app = __toESM(require("@micro-zoe/micro-app"));
317
+ __reExport(index_exports, require("@micro-zoe/micro-app"), module.exports);
307
318
  // src/MicroAppRoute.tsx
308
319
  var import_react = require("react");
309
320
  var import_web_router = require("@xfe-repo/web-router");
310
- var import_micro_app = __toESM(require("@micro-zoe/micro-app"));
311
321
  var import_jsx_custom_event = __toESM(require("@micro-zoe/micro-app/polyfill/jsx-custom-event.js"));
312
322
  var MicroAppRoute = (0, import_react.memo)(function(props) {
313
- var name = props.name, baseRoute = props.baseRoute, url = props.url, keepAlive = props.keepAlive, className = props.className, data = props.data, loadingFallback = props.loadingFallback, errorFallback = props.errorFallback;
323
+ var name = props.name, baseRoute = props.baseRoute, url = props.url, keepAlive = props.keepAlive, className = props.className, data = props.data, loadingFallback = props.loadingFallback, errorFallback = props.errorFallback, aHrefResolver = props.aHrefResolver;
324
+ if (aHrefResolver) aHrefResolverCollector[name] = aHrefResolver;
314
325
  var _ref = _sliced_to_array((0, import_react.useState)(false), 2), microAppIsShow = _ref[0], setMicroAppIsShow = _ref[1];
315
326
  var _ref1 = _sliced_to_array((0, import_react.useState)(false), 2), microAppIsError = _ref1[0], setMicroAppIsError = _ref1[1];
316
327
  var handleMicroAppMounted = (0, import_react.useCallback)(function() {
@@ -320,7 +331,7 @@ var MicroAppRoute = (0, import_react.memo)(function(props) {
320
331
  }, []);
321
332
  var handleMicroAppAfterShow = (0, import_react.useCallback)(function() {
322
333
  var path = location.pathname + location.search;
323
- import_micro_app.default.router.push({
334
+ microApp.router.push({
324
335
  name: "dashboard",
325
336
  path: path,
326
337
  replace: true
@@ -373,16 +384,16 @@ var MicroAppLink = (0, import_react2.memo)(function(props) {
373
384
  children: children
374
385
  });
375
386
  });
376
- var navigateToWithMicroApp = function(to, options) {
387
+ var navigateToWithMicroApp = function navigateToWithMicroApp(to, options) {
377
388
  var _ref = options || {}, replace = _ref.replace, state = _ref.state;
378
389
  var navigator = (0, import_web_router2.getClientNavigator)();
379
390
  replace ? navigator.replace(to, state) : navigator.push(to, state);
380
391
  var microAppBaseName = to.split("/")[1];
381
392
  if (!microAppBaseName) return;
382
- var activeApps = microApp2.getActiveApps({
393
+ var activeApps = microApp.getActiveApps({
383
394
  excludeHiddenApp: true
384
395
  });
385
- if (activeApps.includes(microAppBaseName)) microApp2.router.push({
396
+ if (activeApps.includes(microAppBaseName)) microApp.router.push({
386
397
  name: microAppBaseName,
387
398
  path: to,
388
399
  replace: replace,
@@ -402,7 +413,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
402
413
  _class_call_check(this, MicroAppEventCenter);
403
414
  this.dispatchListeners = {};
404
415
  this.config = config;
405
- if (config.isMain) window.microGlobalEventCenter = new import_micro_app2.EventCenterForMicroApp("global");
416
+ if (config.isMain) window.microGlobalEventCenter = new import_micro_app.EventCenterForMicroApp("global");
406
417
  if (!window.microGlobalEventCenter) throw new Error("microGlobalEventCenter is not defined, please check if the main app is loaded first");
407
418
  window.microGlobalEventCenter.addGlobalDataListener(function(globalData) {
408
419
  return _this.listener(globalData);
@@ -425,6 +436,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
425
436
  // 触发事件
426
437
  key: "emitDispatchListener",
427
438
  value: function emitDispatchListener(action) {
439
+ var _this = this;
428
440
  var _this_dispatchListeners_type;
429
441
  var name = this.config.name;
430
442
  if (!action) return console.error("MicroAppMessage [".concat(name, "]: 未知消息类型 缺少action"));
@@ -435,9 +447,8 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
435
447
  if (target !== "all" && target !== name) return;
436
448
  if (!((_this_dispatchListeners_type = this.dispatchListeners[type]) === null || _this_dispatchListeners_type === void 0 ? void 0 : _this_dispatchListeners_type.length)) return;
437
449
  var actionResponseType = "".concat(type, "___").concat(transId, "___response");
438
- var _this = this;
439
- this.dispatchListeners[type].forEach(function() {
440
- var _ref = _async_to_generator(function(listener) {
450
+ this.dispatchListeners[type].forEach(function(listener) {
451
+ return _async_to_generator(function() {
441
452
  var responseAction, error, isBroadcast, isResponse;
442
453
  return _ts_generator(this, function(_state) {
443
454
  switch(_state.label){
@@ -483,7 +494,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
483
494
  ];
484
495
  return [
485
496
  4,
486
- _this.dispatch(source, responseAction)
497
+ this.dispatch(source, responseAction)
487
498
  ];
488
499
  case 5:
489
500
  _state.sent();
@@ -492,22 +503,19 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
492
503
  ];
493
504
  }
494
505
  });
495
- });
496
- return function(listener) {
497
- return _ref.apply(this, arguments);
498
- };
499
- }());
506
+ }).call(_this);
507
+ });
500
508
  }
501
509
  },
502
510
  {
503
511
  key: "dispatch",
504
512
  value: // 远程调用
505
513
  function dispatch(target, action) {
506
- var _this = this;
507
514
  return _async_to_generator(function() {
508
- var name, type, payload, meta, transId, newAction, globalData, isBroadcast, isResponse, actionResponseType, actionResponsePromise;
515
+ var _this, name, type, payload, meta, transId, newAction, globalData, isBroadcast, isResponse, actionResponseType, actionResponsePromise;
509
516
  return _ts_generator(this, function(_state) {
510
- name = _this.config.name;
517
+ _this = this;
518
+ name = this.config.name;
511
519
  type = action.type, payload = action.payload, meta = action.meta;
512
520
  transId = (meta === null || meta === void 0 ? void 0 : meta.transId) || (0, import_tools.uuid)();
513
521
  newAction = {
@@ -532,7 +540,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
532
540
  ];
533
541
  actionResponseType = "".concat(type, "___").concat(transId, "___response");
534
542
  actionResponsePromise = new Promise(function(resolve, reject) {
535
- var listener = function(responseAction) {
543
+ var listener = function listener1(responseAction) {
536
544
  var payload2 = responseAction.payload, meta2 = responseAction.meta;
537
545
  (meta2 === null || meta2 === void 0 ? void 0 : meta2.error) ? reject(meta2.error) : resolve(payload2);
538
546
  _this.removeDispatchListener(actionResponseType, listener);
@@ -545,7 +553,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
545
553
  actionResponsePromise
546
554
  ];
547
555
  });
548
- })();
556
+ }).call(this);
549
557
  }
550
558
  },
551
559
  {
@@ -569,13 +577,19 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
569
577
  ]);
570
578
  return MicroAppEventCenter;
571
579
  }();
572
- var microApp2 = import_micro_app2.default;
580
+ var aHrefResolverCollector = {};
581
+ import_micro_app.default.options.aHrefResolver = function(hrefValue, appName) {
582
+ var _aHrefResolverCollector_appName;
583
+ return ((_aHrefResolverCollector_appName = aHrefResolverCollector[appName]) === null || _aHrefResolverCollector_appName === void 0 ? void 0 : _aHrefResolverCollector_appName.call(aHrefResolverCollector, hrefValue)) || hrefValue;
584
+ };
585
+ var microApp = import_micro_app.default;
573
586
  // Annotate the CommonJS export names for ESM import in node:
574
587
  0 && (module.exports = _object_spread({
575
588
  MicroAppEventCenter: MicroAppEventCenter,
576
589
  MicroAppEventEnum: MicroAppEventEnum,
577
590
  MicroAppLink: MicroAppLink,
578
591
  MicroAppRoute: MicroAppRoute,
592
+ aHrefResolverCollector: aHrefResolverCollector,
579
593
  microApp: microApp,
580
594
  navigateToWithMicroApp: navigateToWithMicroApp
581
595
  }, require("@micro-zoe/micro-app")));
package/dist/index.mjs CHANGED
@@ -1,4 +1,3 @@
1
- // src/index.ts
2
1
  function _array_like_to_array(arr, len) {
3
2
  if (len == null || len > arr.length) len = arr.length;
4
3
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
@@ -122,7 +121,7 @@ function _unsupported_iterable_to_array(o, minLen) {
122
121
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
123
122
  }
124
123
  function _ts_generator(thisArg, body) {
125
- var f, y, t, g, _ = {
124
+ var f, y, t, _ = {
126
125
  label: 0,
127
126
  sent: function() {
128
127
  if (t[0] & 1) throw t[1];
@@ -130,13 +129,17 @@ function _ts_generator(thisArg, body) {
130
129
  },
131
130
  trys: [],
132
131
  ops: []
133
- };
134
- return g = {
135
- next: verb(0),
136
- "throw": verb(1),
137
- "return": verb(2)
138
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
139
- return this;
132
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
133
+ return d(g, "next", {
134
+ value: verb(0)
135
+ }), d(g, "throw", {
136
+ value: verb(1)
137
+ }), d(g, "return", {
138
+ value: verb(2)
139
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
140
+ value: function() {
141
+ return this;
142
+ }
140
143
  }), g;
141
144
  function verb(n) {
142
145
  return function(v) {
@@ -148,7 +151,7 @@ function _ts_generator(thisArg, body) {
148
151
  }
149
152
  function step(op) {
150
153
  if (f) throw new TypeError("Generator is already executing.");
151
- while(_)try {
154
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
152
155
  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;
153
156
  if (y = 0, t) op = [
154
157
  op[0] & 2,
@@ -216,6 +219,7 @@ function _ts_generator(thisArg, body) {
216
219
  };
217
220
  }
218
221
  }
222
+ // src/index.ts
219
223
  import { isProduction } from "@xfe-repo/web-utils/env";
220
224
  import { uuid } from "@xfe-repo/web-utils/tools";
221
225
  import originMicroApp, { EventCenterForMicroApp } from "@micro-zoe/micro-app";
@@ -223,10 +227,10 @@ export * from "@micro-zoe/micro-app";
223
227
  // src/MicroAppRoute.tsx
224
228
  import { memo, useCallback, useState } from "react";
225
229
  import { getClientNavigator } from "@xfe-repo/web-router";
226
- import microApp from "@micro-zoe/micro-app";
227
230
  import jsxCustomEvent from "@micro-zoe/micro-app/polyfill/jsx-custom-event.js";
228
231
  var MicroAppRoute = memo(function(props) {
229
- var name = props.name, baseRoute = props.baseRoute, url = props.url, keepAlive = props.keepAlive, className = props.className, data = props.data, loadingFallback = props.loadingFallback, errorFallback = props.errorFallback;
232
+ var name = props.name, baseRoute = props.baseRoute, url = props.url, keepAlive = props.keepAlive, className = props.className, data = props.data, loadingFallback = props.loadingFallback, errorFallback = props.errorFallback, aHrefResolver = props.aHrefResolver;
233
+ if (aHrefResolver) aHrefResolverCollector[name] = aHrefResolver;
230
234
  var _useState = _sliced_to_array(useState(false), 2), microAppIsShow = _useState[0], setMicroAppIsShow = _useState[1];
231
235
  var _useState1 = _sliced_to_array(useState(false), 2), microAppIsError = _useState1[0], setMicroAppIsError = _useState1[1];
232
236
  var handleMicroAppMounted = useCallback(function() {
@@ -289,16 +293,16 @@ var MicroAppLink = memo2(function(props) {
289
293
  children: children
290
294
  });
291
295
  });
292
- var navigateToWithMicroApp = function(to, options) {
296
+ var navigateToWithMicroApp = function navigateToWithMicroApp(to, options) {
293
297
  var _ref = options || {}, replace = _ref.replace, state = _ref.state;
294
298
  var navigator = getClientNavigator2();
295
299
  replace ? navigator.replace(to, state) : navigator.push(to, state);
296
300
  var microAppBaseName = to.split("/")[1];
297
301
  if (!microAppBaseName) return;
298
- var activeApps = microApp2.getActiveApps({
302
+ var activeApps = microApp.getActiveApps({
299
303
  excludeHiddenApp: true
300
304
  });
301
- if (activeApps.includes(microAppBaseName)) microApp2.router.push({
305
+ if (activeApps.includes(microAppBaseName)) microApp.router.push({
302
306
  name: microAppBaseName,
303
307
  path: to,
304
308
  replace: replace,
@@ -342,6 +346,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
342
346
  // 触发事件
343
347
  key: "emitDispatchListener",
344
348
  value: function emitDispatchListener(action) {
349
+ var _this = this;
345
350
  var _this_dispatchListeners_type;
346
351
  var name = this.config.name;
347
352
  if (!action) return console.error("MicroAppMessage [".concat(name, "]: 未知消息类型 缺少action"));
@@ -352,9 +357,8 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
352
357
  if (target !== "all" && target !== name) return;
353
358
  if (!((_this_dispatchListeners_type = this.dispatchListeners[type]) === null || _this_dispatchListeners_type === void 0 ? void 0 : _this_dispatchListeners_type.length)) return;
354
359
  var actionResponseType = "".concat(type, "___").concat(transId, "___response");
355
- var _this = this;
356
- this.dispatchListeners[type].forEach(function() {
357
- var _ref = _async_to_generator(function(listener) {
360
+ this.dispatchListeners[type].forEach(function(listener) {
361
+ return _async_to_generator(function() {
358
362
  var responseAction, error, isBroadcast, isResponse;
359
363
  return _ts_generator(this, function(_state) {
360
364
  switch(_state.label){
@@ -400,7 +404,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
400
404
  ];
401
405
  return [
402
406
  4,
403
- _this.dispatch(source, responseAction)
407
+ this.dispatch(source, responseAction)
404
408
  ];
405
409
  case 5:
406
410
  _state.sent();
@@ -409,22 +413,19 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
409
413
  ];
410
414
  }
411
415
  });
412
- });
413
- return function(listener) {
414
- return _ref.apply(this, arguments);
415
- };
416
- }());
416
+ }).call(_this);
417
+ });
417
418
  }
418
419
  },
419
420
  {
420
421
  key: "dispatch",
421
422
  value: // 远程调用
422
423
  function dispatch(target, action) {
423
- var _this = this;
424
424
  return _async_to_generator(function() {
425
- var name, type, payload, meta, transId, newAction, globalData, isBroadcast, isResponse, actionResponseType, actionResponsePromise;
425
+ var _this, name, type, payload, meta, transId, newAction, globalData, isBroadcast, isResponse, actionResponseType, actionResponsePromise;
426
426
  return _ts_generator(this, function(_state) {
427
- name = _this.config.name;
427
+ _this = this;
428
+ name = this.config.name;
428
429
  type = action.type, payload = action.payload, meta = action.meta;
429
430
  transId = (meta === null || meta === void 0 ? void 0 : meta.transId) || uuid();
430
431
  newAction = {
@@ -449,7 +450,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
449
450
  ];
450
451
  actionResponseType = "".concat(type, "___").concat(transId, "___response");
451
452
  actionResponsePromise = new Promise(function(resolve, reject) {
452
- var listener = function(responseAction) {
453
+ var listener = function listener1(responseAction) {
453
454
  var payload2 = responseAction.payload, meta2 = responseAction.meta;
454
455
  (meta2 === null || meta2 === void 0 ? void 0 : meta2.error) ? reject(meta2.error) : resolve(payload2);
455
456
  _this.removeDispatchListener(actionResponseType, listener);
@@ -462,7 +463,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
462
463
  actionResponsePromise
463
464
  ];
464
465
  });
465
- })();
466
+ }).call(this);
466
467
  }
467
468
  },
468
469
  {
@@ -486,5 +487,10 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
486
487
  ]);
487
488
  return MicroAppEventCenter;
488
489
  }();
489
- var microApp2 = originMicroApp;
490
- export { MicroAppEventCenter, MicroAppEventEnum, MicroAppLink, MicroAppRoute, microApp2 as microApp, navigateToWithMicroApp };
490
+ var aHrefResolverCollector = {};
491
+ originMicroApp.options.aHrefResolver = function(hrefValue, appName) {
492
+ var _aHrefResolverCollector_appName;
493
+ return ((_aHrefResolverCollector_appName = aHrefResolverCollector[appName]) === null || _aHrefResolverCollector_appName === void 0 ? void 0 : _aHrefResolverCollector_appName.call(aHrefResolverCollector, hrefValue)) || hrefValue;
494
+ };
495
+ var microApp = originMicroApp;
496
+ export { MicroAppEventCenter, MicroAppEventEnum, MicroAppLink, MicroAppRoute, aHrefResolverCollector, microApp, navigateToWithMicroApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-micro",
3
- "version": "1.2.4",
3
+ "version": "1.5.0",
4
4
  "sideEffects": false,
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,15 +20,18 @@
20
20
  "dist"
21
21
  ],
22
22
  "dependencies": {
23
- "@micro-zoe/micro-app": "1.0.0-rc.20",
24
- "@xfe-repo/web-router": "1.2.2",
25
- "@xfe-repo/web-utils": "1.3.6"
23
+ "@micro-zoe/micro-app": "1.0.0-rc.24",
24
+ "@xfe-repo/web-utils": "1.5.0"
26
25
  },
27
26
  "devDependencies": {
28
- "@types/node": "^20.16.5",
27
+ "@types/node": "^20.17.0",
29
28
  "@types/react": "^18",
30
- "@xfe-repo/typescript-config": "0.0.6",
31
- "@xfe-repo/eslint-config": "0.0.5"
29
+ "eslint": "8.57.1",
30
+ "@xfe-repo/typescript-config": "1.5.0",
31
+ "@xfe-repo/eslint-config": "1.5.0"
32
+ },
33
+ "peerDependencies": {
34
+ "@xfe-repo/web-router": "1.5.0"
32
35
  },
33
36
  "publishConfig": {
34
37
  "registry": "https://registry.npmjs.org/"
@@ -36,7 +39,7 @@
36
39
  "scripts": {
37
40
  "build": "tsup",
38
41
  "dev": "tsup --watch",
39
- "lint": "eslint \"src/**/*.ts*\"",
42
+ "lint": "eslint \"src/**/*.ts*\" --fix",
40
43
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
41
44
  }
42
45
  }