@modern-js/plugin-garfish 2.68.13 → 2.68.15-alpha.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.
|
@@ -56,13 +56,13 @@ function pathJoin(...args) {
|
|
|
56
56
|
return res || "/";
|
|
57
57
|
}
|
|
58
58
|
function getAppInstance(options, appInfo, manifest) {
|
|
59
|
-
let locationHref = "";
|
|
60
59
|
const componentSetterRegistry = {
|
|
61
60
|
current: null
|
|
62
61
|
};
|
|
63
62
|
function MicroApp(props) {
|
|
64
63
|
var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
|
|
65
64
|
const appRef = (0, import_react.useRef)(null);
|
|
65
|
+
const locationHrefRef = (0, import_react.useRef)("");
|
|
66
66
|
const domId = (0, import_util.generateSubAppContainerKey)(appInfo);
|
|
67
67
|
const [{ component: SubModuleComponent }, setSubModuleComponent] = (0, import_react.useState)({
|
|
68
68
|
component: null
|
|
@@ -117,16 +117,21 @@ or directly pass the "basename":
|
|
|
117
117
|
if (props.basename && typeof props.basename === "string") {
|
|
118
118
|
basename = props.basename;
|
|
119
119
|
}
|
|
120
|
+
const locationPathname = (0, import_react.useMemo)(function() {
|
|
121
|
+
return location ? location.pathname : "";
|
|
122
|
+
}, [
|
|
123
|
+
location ? location.pathname : ""
|
|
124
|
+
]);
|
|
120
125
|
(0, import_react.useEffect)(() => {
|
|
121
|
-
if (location &&
|
|
122
|
-
|
|
126
|
+
if (location && locationHrefRef.current !== location.pathname && !import_garfish.default.running) {
|
|
127
|
+
locationHrefRef.current = location.pathname;
|
|
123
128
|
const popStateEvent = new PopStateEvent("popstate");
|
|
124
129
|
popStateEvent.garfish = true;
|
|
125
130
|
dispatchEvent(popStateEvent);
|
|
126
131
|
(0, import_util.logger)(`MicroApp Garfish.loadApp popstate`);
|
|
127
132
|
}
|
|
128
133
|
}, [
|
|
129
|
-
|
|
134
|
+
locationPathname
|
|
130
135
|
]);
|
|
131
136
|
(0, import_react.useEffect)(() => {
|
|
132
137
|
componentSetterRegistry.current = setSubModuleComponent;
|
|
@@ -8,7 +8,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
8
8
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
9
|
import { RuntimeReactContext } from "@meta/runtime";
|
|
10
10
|
import Garfish from "garfish";
|
|
11
|
-
import { useContext, useEffect, useRef, useState } from "react";
|
|
11
|
+
import { useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
12
12
|
import { generateSubAppContainerKey, logger } from "../../util";
|
|
13
13
|
import { Loadable } from "../loadable";
|
|
14
14
|
function pathJoin() {
|
|
@@ -32,13 +32,13 @@ function pathJoin() {
|
|
|
32
32
|
return res || "/";
|
|
33
33
|
}
|
|
34
34
|
function getAppInstance(options, appInfo, manifest) {
|
|
35
|
-
var locationHref = "";
|
|
36
35
|
var componentSetterRegistry = {
|
|
37
36
|
current: null
|
|
38
37
|
};
|
|
39
38
|
function MicroApp(props) {
|
|
40
39
|
var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
|
|
41
40
|
var appRef = useRef(null);
|
|
41
|
+
var locationHrefRef = useRef("");
|
|
42
42
|
var domId = generateSubAppContainerKey(appInfo);
|
|
43
43
|
var _useState = _sliced_to_array(useState({
|
|
44
44
|
component: null
|
|
@@ -91,16 +91,21 @@ or directly pass the "basename":
|
|
|
91
91
|
if (props.basename && typeof props.basename === "string") {
|
|
92
92
|
basename = props.basename;
|
|
93
93
|
}
|
|
94
|
+
var locationPathname = useMemo(function() {
|
|
95
|
+
return location ? location.pathname : "";
|
|
96
|
+
}, [
|
|
97
|
+
location ? location.pathname : ""
|
|
98
|
+
]);
|
|
94
99
|
useEffect(function() {
|
|
95
|
-
if (location &&
|
|
96
|
-
|
|
100
|
+
if (location && locationHrefRef.current !== location.pathname && !Garfish.running) {
|
|
101
|
+
locationHrefRef.current = location.pathname;
|
|
97
102
|
var popStateEvent = new PopStateEvent("popstate");
|
|
98
103
|
popStateEvent.garfish = true;
|
|
99
104
|
dispatchEvent(popStateEvent);
|
|
100
105
|
logger("MicroApp Garfish.loadApp popstate");
|
|
101
106
|
}
|
|
102
107
|
}, [
|
|
103
|
-
|
|
108
|
+
locationPathname
|
|
104
109
|
]);
|
|
105
110
|
useEffect(function() {
|
|
106
111
|
var renderApp = function renderApp2() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { RuntimeReactContext } from "@meta/runtime";
|
|
3
3
|
import Garfish from "garfish";
|
|
4
|
-
import { useContext, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { generateSubAppContainerKey, logger } from "../../util";
|
|
6
6
|
import { Loadable } from "../loadable";
|
|
7
7
|
function pathJoin(...args) {
|
|
@@ -22,13 +22,13 @@ function pathJoin(...args) {
|
|
|
22
22
|
return res || "/";
|
|
23
23
|
}
|
|
24
24
|
function getAppInstance(options, appInfo, manifest) {
|
|
25
|
-
let locationHref = "";
|
|
26
25
|
const componentSetterRegistry = {
|
|
27
26
|
current: null
|
|
28
27
|
};
|
|
29
28
|
function MicroApp(props) {
|
|
30
29
|
var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
|
|
31
30
|
const appRef = useRef(null);
|
|
31
|
+
const locationHrefRef = useRef("");
|
|
32
32
|
const domId = generateSubAppContainerKey(appInfo);
|
|
33
33
|
const [{ component: SubModuleComponent }, setSubModuleComponent] = useState({
|
|
34
34
|
component: null
|
|
@@ -83,16 +83,21 @@ or directly pass the "basename":
|
|
|
83
83
|
if (props.basename && typeof props.basename === "string") {
|
|
84
84
|
basename = props.basename;
|
|
85
85
|
}
|
|
86
|
+
const locationPathname = useMemo(function() {
|
|
87
|
+
return location ? location.pathname : "";
|
|
88
|
+
}, [
|
|
89
|
+
location ? location.pathname : ""
|
|
90
|
+
]);
|
|
86
91
|
useEffect(() => {
|
|
87
|
-
if (location &&
|
|
88
|
-
|
|
92
|
+
if (location && locationHrefRef.current !== location.pathname && !Garfish.running) {
|
|
93
|
+
locationHrefRef.current = location.pathname;
|
|
89
94
|
const popStateEvent = new PopStateEvent("popstate");
|
|
90
95
|
popStateEvent.garfish = true;
|
|
91
96
|
dispatchEvent(popStateEvent);
|
|
92
97
|
logger(`MicroApp Garfish.loadApp popstate`);
|
|
93
98
|
}
|
|
94
99
|
}, [
|
|
95
|
-
|
|
100
|
+
locationPathname
|
|
96
101
|
]);
|
|
97
102
|
useEffect(() => {
|
|
98
103
|
componentSetterRegistry.current = setSubModuleComponent;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.68.
|
|
18
|
+
"version": "2.68.15-alpha.0",
|
|
19
19
|
"jsnext:source": "./src/cli/index.ts",
|
|
20
20
|
"types": "./dist/types/cli/index.d.ts",
|
|
21
21
|
"typesVersions": {
|
|
@@ -63,22 +63,29 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
+
"@modern-js/plugin-v2": "2.68.14",
|
|
67
|
+
"@modern-js/runtime-utils": "2.68.14",
|
|
68
|
+
"@modern-js/utils": "2.68.14",
|
|
66
69
|
"@swc/helpers": "^0.5.17",
|
|
67
70
|
"@types/debug": "4.1.12",
|
|
68
71
|
"@types/react-loadable": "^5.5.6",
|
|
69
72
|
"debug": "4.3.7",
|
|
70
73
|
"garfish": "^1.8.1",
|
|
71
|
-
"react-loadable": "^5.5.0"
|
|
72
|
-
"@modern-js/plugin-v2": "2.68.13",
|
|
73
|
-
"@modern-js/runtime-utils": "2.68.13",
|
|
74
|
-
"@modern-js/utils": "2.68.13"
|
|
74
|
+
"react-loadable": "^5.5.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@modern-js/runtime": "^2.68.
|
|
77
|
+
"@modern-js/runtime": "^2.68.14",
|
|
78
78
|
"react": ">=17",
|
|
79
79
|
"react-dom": ">=17"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
+
"@modern-js/app-tools": "2.68.14",
|
|
83
|
+
"@modern-js/core": "2.68.14",
|
|
84
|
+
"@modern-js/plugin-router-v5": "2.68.14",
|
|
85
|
+
"@modern-js/runtime": "2.68.14",
|
|
86
|
+
"@modern-js/types": "2.68.14",
|
|
87
|
+
"@scripts/build": "2.66.0",
|
|
88
|
+
"@scripts/jest-config": "2.66.0",
|
|
82
89
|
"@testing-library/dom": "^8.14.0",
|
|
83
90
|
"@testing-library/jest-dom": "^5.16.1",
|
|
84
91
|
"@testing-library/react": "^13.4.0",
|
|
@@ -92,14 +99,7 @@
|
|
|
92
99
|
"react": "^18.3.1",
|
|
93
100
|
"react-dom": "^18.3.1",
|
|
94
101
|
"react-router-dom": "6.27.0",
|
|
95
|
-
"typescript": "^5"
|
|
96
|
-
"@modern-js/app-tools": "2.68.13",
|
|
97
|
-
"@modern-js/core": "2.68.13",
|
|
98
|
-
"@modern-js/plugin-router-v5": "2.68.13",
|
|
99
|
-
"@modern-js/runtime": "2.68.13",
|
|
100
|
-
"@modern-js/types": "2.68.13",
|
|
101
|
-
"@scripts/build": "2.66.0",
|
|
102
|
-
"@scripts/jest-config": "2.66.0"
|
|
102
|
+
"typescript": "^5"
|
|
103
103
|
},
|
|
104
104
|
"sideEffects": false,
|
|
105
105
|
"publishConfig": {
|
|
@@ -112,5 +112,6 @@
|
|
|
112
112
|
"dev": "modern-lib build --watch",
|
|
113
113
|
"build:watch": "rm -rf ./dist && modern build --watch",
|
|
114
114
|
"test": "jest --passWithNoTests"
|
|
115
|
-
}
|
|
115
|
+
},
|
|
116
|
+
"readme": "<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n\n<h1 align=\"center\">Modern.js</h1>\n\n<p align=\"center\">\n A Progressive React Framework for modern web development.\n</p>\n\n## Getting Started\n\nPlease follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-start) to get started with Modern.js.\n\n## Documentation\n\n- [English Documentation](https://modernjs.dev/en/)\n- [中文文档](https://modernjs.dev)\n\n## Contributing\n\nPlease read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).\n\n## License\n\nModern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).\n"
|
|
116
117
|
}
|