@xfe-repo/web-micro 1.2.5 → 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.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,41 +280,41 @@ 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
- aHrefResolverCollector: function() {
303
+ aHrefResolverCollector: function aHrefResolverCollector1() {
296
304
  return aHrefResolverCollector;
297
305
  },
298
- microApp: function() {
306
+ microApp: function microApp1() {
299
307
  return microApp;
300
308
  },
301
- navigateToWithMicroApp: function() {
309
+ navigateToWithMicroApp: function navigateToWithMicroApp1() {
302
310
  return navigateToWithMicroApp;
303
311
  }
304
312
  });
305
- module.exports = __toCommonJS(src_exports);
313
+ module.exports = __toCommonJS(index_exports);
306
314
  var import_env = require("@xfe-repo/web-utils/env");
307
315
  var import_tools = require("@xfe-repo/web-utils/tools");
308
316
  var import_micro_app = __toESM(require("@micro-zoe/micro-app"));
309
- __reExport(src_exports, require("@micro-zoe/micro-app"), module.exports);
317
+ __reExport(index_exports, require("@micro-zoe/micro-app"), module.exports);
310
318
  // src/MicroAppRoute.tsx
311
319
  var import_react = require("react");
312
320
  var import_web_router = require("@xfe-repo/web-router");
@@ -376,7 +384,7 @@ var MicroAppLink = (0, import_react2.memo)(function(props) {
376
384
  children: children
377
385
  });
378
386
  });
379
- var navigateToWithMicroApp = function(to, options) {
387
+ var navigateToWithMicroApp = function navigateToWithMicroApp(to, options) {
380
388
  var _ref = options || {}, replace = _ref.replace, state = _ref.state;
381
389
  var navigator = (0, import_web_router2.getClientNavigator)();
382
390
  replace ? navigator.replace(to, state) : navigator.push(to, state);
@@ -428,6 +436,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
428
436
  // 触发事件
429
437
  key: "emitDispatchListener",
430
438
  value: function emitDispatchListener(action) {
439
+ var _this = this;
431
440
  var _this_dispatchListeners_type;
432
441
  var name = this.config.name;
433
442
  if (!action) return console.error("MicroAppMessage [".concat(name, "]: 未知消息类型 缺少action"));
@@ -438,9 +447,8 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
438
447
  if (target !== "all" && target !== name) return;
439
448
  if (!((_this_dispatchListeners_type = this.dispatchListeners[type]) === null || _this_dispatchListeners_type === void 0 ? void 0 : _this_dispatchListeners_type.length)) return;
440
449
  var actionResponseType = "".concat(type, "___").concat(transId, "___response");
441
- var _this = this;
442
- this.dispatchListeners[type].forEach(function() {
443
- var _ref = _async_to_generator(function(listener) {
450
+ this.dispatchListeners[type].forEach(function(listener) {
451
+ return _async_to_generator(function() {
444
452
  var responseAction, error, isBroadcast, isResponse;
445
453
  return _ts_generator(this, function(_state) {
446
454
  switch(_state.label){
@@ -486,7 +494,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
486
494
  ];
487
495
  return [
488
496
  4,
489
- _this.dispatch(source, responseAction)
497
+ this.dispatch(source, responseAction)
490
498
  ];
491
499
  case 5:
492
500
  _state.sent();
@@ -495,22 +503,19 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
495
503
  ];
496
504
  }
497
505
  });
498
- });
499
- return function(listener) {
500
- return _ref.apply(this, arguments);
501
- };
502
- }());
506
+ }).call(_this);
507
+ });
503
508
  }
504
509
  },
505
510
  {
506
511
  key: "dispatch",
507
512
  value: // 远程调用
508
513
  function dispatch(target, action) {
509
- var _this = this;
510
514
  return _async_to_generator(function() {
511
- 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;
512
516
  return _ts_generator(this, function(_state) {
513
- name = _this.config.name;
517
+ _this = this;
518
+ name = this.config.name;
514
519
  type = action.type, payload = action.payload, meta = action.meta;
515
520
  transId = (meta === null || meta === void 0 ? void 0 : meta.transId) || (0, import_tools.uuid)();
516
521
  newAction = {
@@ -535,7 +540,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
535
540
  ];
536
541
  actionResponseType = "".concat(type, "___").concat(transId, "___response");
537
542
  actionResponsePromise = new Promise(function(resolve, reject) {
538
- var listener = function(responseAction) {
543
+ var listener = function listener1(responseAction) {
539
544
  var payload2 = responseAction.payload, meta2 = responseAction.meta;
540
545
  (meta2 === null || meta2 === void 0 ? void 0 : meta2.error) ? reject(meta2.error) : resolve(payload2);
541
546
  _this.removeDispatchListener(actionResponseType, listener);
@@ -548,7 +553,7 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
548
553
  actionResponsePromise
549
554
  ];
550
555
  });
551
- })();
556
+ }).call(this);
552
557
  }
553
558
  },
554
559
  {
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";
@@ -289,7 +293,7 @@ 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);
@@ -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
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-micro",
3
- "version": "1.2.5",
3
+ "version": "1.5.0",
4
4
  "sideEffects": false,
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,16 +21,17 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@micro-zoe/micro-app": "1.0.0-rc.24",
24
- "@xfe-repo/web-utils": "1.3.7"
24
+ "@xfe-repo/web-utils": "1.5.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@types/node": "^20.16.5",
27
+ "@types/node": "^20.17.0",
28
28
  "@types/react": "^18",
29
- "@xfe-repo/typescript-config": "0.0.6",
30
- "@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"
31
32
  },
32
33
  "peerDependencies": {
33
- "@xfe-repo/web-router": "1.2.3"
34
+ "@xfe-repo/web-router": "1.5.0"
34
35
  },
35
36
  "publishConfig": {
36
37
  "registry": "https://registry.npmjs.org/"
@@ -38,7 +39,7 @@
38
39
  "scripts": {
39
40
  "build": "tsup",
40
41
  "dev": "tsup --watch",
41
- "lint": "eslint \"src/**/*.ts*\"",
42
+ "lint": "eslint \"src/**/*.ts*\" --fix",
42
43
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
43
44
  }
44
45
  }