@xfe-repo/web-micro 1.1.3 → 1.1.5

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/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # `@xfe-repo/web-register`
1
+ # `@xfe-repo/web-micro`
2
2
 
3
- web register库
3
+ web micro
package/dist/index.d.mts CHANGED
@@ -38,6 +38,7 @@ type MicroAppGlobalDataType = {
38
38
  };
39
39
  type MicroAppEventCenterConfig = {
40
40
  name: string;
41
+ isMain?: boolean;
41
42
  onGlobalStateChange?: (globalState: any) => void;
42
43
  };
43
44
  declare class MicroAppEventCenter {
package/dist/index.d.ts CHANGED
@@ -38,6 +38,7 @@ type MicroAppGlobalDataType = {
38
38
  };
39
39
  type MicroAppEventCenterConfig = {
40
40
  name: string;
41
+ isMain?: boolean;
41
42
  onGlobalStateChange?: (globalState: any) => void;
42
43
  };
43
44
  declare class MicroAppEventCenter {
package/dist/index.js CHANGED
@@ -330,7 +330,7 @@ var MicroAppRoute = (0, import_react.memo)(function(props) {
330
330
  }, []);
331
331
  return /* @__PURE__ */ (0, import_jsx_custom_event.default)("div", {
332
332
  className: className
333
- }, microAppIsError && errorFallback, !microAppIsShow && loadingFallback, /* @__PURE__ */ (0, import_jsx_custom_event.default)("micro-app", {
333
+ }, microAppIsError && errorFallback, !microAppIsShow && !microAppIsError && loadingFallback, /* @__PURE__ */ (0, import_jsx_custom_event.default)("micro-app", {
334
334
  style: {
335
335
  display: microAppIsShow ? "block" : "none"
336
336
  },
@@ -346,7 +346,6 @@ var MicroAppRoute = (0, import_react.memo)(function(props) {
346
346
  }));
347
347
  });
348
348
  // src/index.ts
349
- window.microGlobalEventCenter = new import_micro_app2.EventCenterForMicroApp("global");
350
349
  var MicroAppEventEnum = /* @__PURE__ */ function(MicroAppEventEnum2) {
351
350
  MicroAppEventEnum2["SET_GLOBAL_STATE"] = "setGlobalState";
352
351
  MicroAppEventEnum2["DISPATCH_ACTION"] = "dispatchAction";
@@ -359,6 +358,8 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
359
358
  this.dispatchListeners = {};
360
359
  this._globalState = {};
361
360
  this.config = config;
361
+ if (config.isMain) window.microGlobalEventCenter = new import_micro_app2.EventCenterForMicroApp("global");
362
+ if (!window.microGlobalEventCenter) throw new Error("microGlobalEventCenter is not defined, please check if the main app is loaded first");
362
363
  window.microGlobalEventCenter.addGlobalDataListener(function(globalData) {
363
364
  return _this.listener(globalData);
364
365
  });
package/dist/index.mjs CHANGED
@@ -252,7 +252,7 @@ var MicroAppRoute = memo(function(props) {
252
252
  }, []);
253
253
  return /* @__PURE__ */ jsxCustomEvent("div", {
254
254
  className: className
255
- }, microAppIsError && errorFallback, !microAppIsShow && loadingFallback, /* @__PURE__ */ jsxCustomEvent("micro-app", {
255
+ }, microAppIsError && errorFallback, !microAppIsShow && !microAppIsError && loadingFallback, /* @__PURE__ */ jsxCustomEvent("micro-app", {
256
256
  style: {
257
257
  display: microAppIsShow ? "block" : "none"
258
258
  },
@@ -268,7 +268,6 @@ var MicroAppRoute = memo(function(props) {
268
268
  }));
269
269
  });
270
270
  // src/index.ts
271
- window.microGlobalEventCenter = new EventCenterForMicroApp("global");
272
271
  var MicroAppEventEnum = /* @__PURE__ */ function(MicroAppEventEnum2) {
273
272
  MicroAppEventEnum2["SET_GLOBAL_STATE"] = "setGlobalState";
274
273
  MicroAppEventEnum2["DISPATCH_ACTION"] = "dispatchAction";
@@ -282,6 +281,8 @@ var MicroAppEventCenter = /*#__PURE__*/ function() {
282
281
  this.dispatchListeners = {};
283
282
  this._globalState = {};
284
283
  this.config = config;
284
+ if (config.isMain) window.microGlobalEventCenter = new EventCenterForMicroApp("global");
285
+ if (!window.microGlobalEventCenter) throw new Error("microGlobalEventCenter is not defined, please check if the main app is loaded first");
285
286
  window.microGlobalEventCenter.addGlobalDataListener(function(globalData) {
286
287
  return _this.listener(globalData);
287
288
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-micro",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "sideEffects": false,
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,8 +21,8 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@micro-zoe/micro-app": "1.0.0-rc.13",
24
- "@xfe-repo/web-router": "1.1.5",
25
- "@xfe-repo/web-utils": "1.1.3"
24
+ "@xfe-repo/web-utils": "1.1.3",
25
+ "@xfe-repo/web-router": "1.1.5"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^20.16.5",