@xfe-repo/web-micro 1.1.7 → 1.2.1
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.ts +8 -1
- package/dist/index.js +51 -4
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as _micro_zoe_micro_app from '@micro-zoe/micro-app';
|
|
|
2
2
|
export * from '@micro-zoe/micro-app';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import React from 'react';
|
|
5
|
+
import { LinkProps } from '@xfe-repo/web-router';
|
|
5
6
|
|
|
6
7
|
type MicroAppProps = {
|
|
7
8
|
name: string;
|
|
@@ -15,6 +16,12 @@ type MicroAppProps = {
|
|
|
15
16
|
};
|
|
16
17
|
declare const MicroAppRoute: React.MemoExoticComponent<(props: MicroAppProps) => react_jsx_runtime.JSX.Element>;
|
|
17
18
|
|
|
19
|
+
type MicroAppLinkProps = LinkProps & {
|
|
20
|
+
to?: string;
|
|
21
|
+
microApp?: string;
|
|
22
|
+
};
|
|
23
|
+
declare const MicroAppLink: React.MemoExoticComponent<(props: MicroAppLinkProps) => react_jsx_runtime.JSX.Element>;
|
|
24
|
+
|
|
18
25
|
declare enum MicroAppEventEnum {
|
|
19
26
|
DISPATCH_ACTION = "dispatchAction"
|
|
20
27
|
}
|
|
@@ -51,4 +58,4 @@ declare class MicroAppEventCenter {
|
|
|
51
58
|
|
|
52
59
|
declare const microApp: _micro_zoe_micro_app.MicroApp;
|
|
53
60
|
|
|
54
|
-
export { type MicroAppActionMetaType, type MicroAppActionType, type MicroAppDispatchListener, MicroAppEventCenter, type MicroAppEventCenterConfig, MicroAppEventEnum, type MicroAppGlobalDataType, type MicroAppProps, MicroAppRoute, microApp };
|
|
61
|
+
export { type MicroAppActionMetaType, type MicroAppActionType, type MicroAppDispatchListener, MicroAppEventCenter, type MicroAppEventCenterConfig, MicroAppEventEnum, type MicroAppGlobalDataType, MicroAppLink, type MicroAppProps, MicroAppRoute, microApp };
|
package/dist/index.js
CHANGED
|
@@ -286,6 +286,9 @@ __export(src_exports, {
|
|
|
286
286
|
MicroAppEventEnum: function() {
|
|
287
287
|
return MicroAppEventEnum;
|
|
288
288
|
},
|
|
289
|
+
MicroAppLink: function() {
|
|
290
|
+
return MicroAppLink;
|
|
291
|
+
},
|
|
289
292
|
MicroAppRoute: function() {
|
|
290
293
|
return MicroAppRoute;
|
|
291
294
|
},
|
|
@@ -305,13 +308,19 @@ var import_micro_app = __toESM(require("@micro-zoe/micro-app"));
|
|
|
305
308
|
var import_jsx_custom_event = __toESM(require("@micro-zoe/micro-app/polyfill/jsx-custom-event.js"));
|
|
306
309
|
var MicroAppRoute = (0, import_react.memo)(function(props) {
|
|
307
310
|
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;
|
|
311
|
+
var navigate = (0, import_web_router.useNavigate)();
|
|
308
312
|
var location = (0, import_web_router.useLocation)();
|
|
309
|
-
var defaultPage = location.pathname + location.search;
|
|
310
313
|
var _ref = _sliced_to_array((0, import_react.useState)(false), 2), microAppIsShow = _ref[0], setMicroAppIsShow = _ref[1];
|
|
311
314
|
var _ref1 = _sliced_to_array((0, import_react.useState)(false), 2), microAppIsError = _ref1[0], setMicroAppIsError = _ref1[1];
|
|
312
315
|
var handleMicroAppMounted = (0, import_react.useCallback)(function() {
|
|
316
|
+
var path = location.pathname + location.search;
|
|
317
|
+
navigate(path, {
|
|
318
|
+
replace: true
|
|
319
|
+
});
|
|
313
320
|
setMicroAppIsShow(true);
|
|
314
|
-
}, [
|
|
321
|
+
}, [
|
|
322
|
+
location
|
|
323
|
+
]);
|
|
315
324
|
var handleMicroAppAfterShow = (0, import_react.useCallback)(function() {
|
|
316
325
|
var path = location.pathname + location.search;
|
|
317
326
|
import_micro_app.default.router.push({
|
|
@@ -319,7 +328,7 @@ var MicroAppRoute = (0, import_react.memo)(function(props) {
|
|
|
319
328
|
path: path,
|
|
320
329
|
replace: true
|
|
321
330
|
}).catch(function(e) {
|
|
322
|
-
return e;
|
|
331
|
+
return console.error(e);
|
|
323
332
|
});
|
|
324
333
|
setMicroAppIsShow(true);
|
|
325
334
|
}, [
|
|
@@ -332,6 +341,8 @@ var MicroAppRoute = (0, import_react.memo)(function(props) {
|
|
|
332
341
|
className: className
|
|
333
342
|
}, microAppIsError && errorFallback, !microAppIsShow && !microAppIsError && loadingFallback, /* @__PURE__ */ (0, import_jsx_custom_event.default)("micro-app", {
|
|
334
343
|
style: {
|
|
344
|
+
width: "100%",
|
|
345
|
+
height: "100%",
|
|
335
346
|
display: microAppIsShow ? "block" : "none"
|
|
336
347
|
},
|
|
337
348
|
url: url,
|
|
@@ -339,13 +350,48 @@ var MicroAppRoute = (0, import_react.memo)(function(props) {
|
|
|
339
350
|
"router-mode": "native",
|
|
340
351
|
baseroute: baseRoute ? baseRoute : "/".concat(name),
|
|
341
352
|
"keep-alive": keepAlive,
|
|
342
|
-
"default-page": defaultPage,
|
|
343
353
|
data: data,
|
|
344
354
|
onMounted: handleMicroAppMounted,
|
|
345
355
|
onAftershow: keepAlive ? handleMicroAppAfterShow : void 0,
|
|
346
356
|
onError: handleMicroAppError
|
|
347
357
|
}));
|
|
348
358
|
});
|
|
359
|
+
// src/MicroAppLink.tsx
|
|
360
|
+
var import_react2 = require("react");
|
|
361
|
+
var import_web_router2 = require("@xfe-repo/web-router");
|
|
362
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
363
|
+
var MicroAppLink = (0, import_react2.memo)(function(props) {
|
|
364
|
+
var microAppBaseName = props.microApp, to = props.to, children = props.children, replace = props.replace, className = props.className;
|
|
365
|
+
var navigate = (0, import_web_router2.useNavigate)();
|
|
366
|
+
var handleLink = (0, import_react2.useCallback)(function(e) {
|
|
367
|
+
e.preventDefault();
|
|
368
|
+
navigate(to, {
|
|
369
|
+
replace: replace
|
|
370
|
+
});
|
|
371
|
+
if (!microAppBaseName) return;
|
|
372
|
+
var activeApps = microApp2.getActiveApps({
|
|
373
|
+
excludeHiddenApp: true
|
|
374
|
+
});
|
|
375
|
+
if (activeApps.includes(microAppBaseName)) microApp2.router.push({
|
|
376
|
+
name: microAppBaseName,
|
|
377
|
+
path: to,
|
|
378
|
+
replace: replace
|
|
379
|
+
}).catch(function(e2) {
|
|
380
|
+
return e2;
|
|
381
|
+
});
|
|
382
|
+
}, [
|
|
383
|
+
navigate,
|
|
384
|
+
microAppBaseName,
|
|
385
|
+
to,
|
|
386
|
+
replace
|
|
387
|
+
]);
|
|
388
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
|
|
389
|
+
className: className,
|
|
390
|
+
href: to,
|
|
391
|
+
onClick: handleLink,
|
|
392
|
+
children: children
|
|
393
|
+
});
|
|
394
|
+
});
|
|
349
395
|
// src/index.ts
|
|
350
396
|
var MicroAppEventEnum = /* @__PURE__ */ function(MicroAppEventEnum2) {
|
|
351
397
|
MicroAppEventEnum2["DISPATCH_ACTION"] = "dispatchAction";
|
|
@@ -529,6 +575,7 @@ var microApp2 = import_micro_app2.default;
|
|
|
529
575
|
0 && (module.exports = _object_spread({
|
|
530
576
|
MicroAppEventCenter: MicroAppEventCenter,
|
|
531
577
|
MicroAppEventEnum: MicroAppEventEnum,
|
|
578
|
+
MicroAppLink: MicroAppLink,
|
|
532
579
|
MicroAppRoute: MicroAppRoute,
|
|
533
580
|
microApp: microApp
|
|
534
581
|
}, require("@micro-zoe/micro-app")));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/web-micro",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@micro-zoe/micro-app": "1.0.0-rc.13",
|
|
12
|
-
"@xfe-repo/web-router": "1.1
|
|
13
|
-
"@xfe-repo/web-utils": "1.1
|
|
12
|
+
"@xfe-repo/web-router": "1.2.1",
|
|
13
|
+
"@xfe-repo/web-utils": "1.2.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "^20.16.5",
|
|
17
17
|
"@types/react": "^18",
|
|
18
|
-
"@xfe-repo/eslint-config": "0.0.
|
|
18
|
+
"@xfe-repo/eslint-config": "0.0.5",
|
|
19
19
|
"@xfe-repo/typescript-config": "0.0.6"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|