@modern-js/plugin-garfish 2.54.3 → 2.54.4
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/cjs/cli/utils.js +1 -1
- package/dist/esm/cli/utils.js +80 -1
- package/dist/esm-node/cli/utils.js +1 -1
- package/package.json +11 -11
package/dist/cjs/cli/utils.js
CHANGED
|
@@ -80,7 +80,7 @@ function canContinueRender ({ dom, appName }) {
|
|
|
80
80
|
|
|
81
81
|
function generateRouterPlugin (basename,routerConfig) {
|
|
82
82
|
if (basename) {
|
|
83
|
-
routerConfig.originalBaseUrl = basename;
|
|
83
|
+
routerConfig.originalBaseUrl = basename.replace(/^\\/*/, "/");
|
|
84
84
|
// for compatibility with react router v5
|
|
85
85
|
routerConfig.basename = basename;
|
|
86
86
|
if (routerConfig.supportHtml5History !== false) {
|
package/dist/esm/cli/utils.js
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
var makeProvider = function() {
|
|
2
|
-
return
|
|
2
|
+
return `
|
|
3
|
+
export const provider = function ({basename, dom}) {
|
|
4
|
+
return {
|
|
5
|
+
render({basename, dom, props, appName}) {
|
|
6
|
+
render({ props, basename, dom, appName });
|
|
7
|
+
},
|
|
8
|
+
destroy({ dom }) {
|
|
9
|
+
const node = dom.querySelector('#' + MOUNT_ID) || dom;
|
|
10
|
+
|
|
11
|
+
if (node) {
|
|
12
|
+
if (IS_REACT18) {
|
|
13
|
+
root.unmount();
|
|
14
|
+
} else {
|
|
15
|
+
unmountComponentAtNode(node);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
SubModuleComponent: (props) => {
|
|
20
|
+
const SubApp = render({props, basename});
|
|
21
|
+
|
|
22
|
+
return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);
|
|
23
|
+
},
|
|
24
|
+
jupiter_submodule_app_key: (props) => {
|
|
25
|
+
const SubApp = render({props, basename});
|
|
26
|
+
|
|
27
|
+
return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (typeof __GARFISH_EXPORTS__ !== 'undefined') {
|
|
33
|
+
__GARFISH_EXPORTS__.provider = provider;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function canContinueRender ({ dom, appName }) {
|
|
37
|
+
var renderByGarfish =
|
|
38
|
+
typeof __GARFISH_EXPORTS__ !== 'undefined'
|
|
39
|
+
|| typeof window !== 'undefined' && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.some((app)=>app.appInfo.name === appName);
|
|
40
|
+
let renderByProvider = dom || appName;
|
|
41
|
+
if (renderByGarfish) {
|
|
42
|
+
// Runs in the Garfish environment and is rendered by the provider
|
|
43
|
+
if (renderByProvider) {
|
|
44
|
+
return true;
|
|
45
|
+
} else {
|
|
46
|
+
// Runs in the Garfish environment and is not rendered by the provider
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
// Running in a non-Garfish environment
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function generateRouterPlugin (basename,routerConfig) {
|
|
56
|
+
if (basename) {
|
|
57
|
+
routerConfig.originalBaseUrl = basename.replace(/^\\/*/, "/");
|
|
58
|
+
// for compatibility with react router v5
|
|
59
|
+
routerConfig.basename = basename;
|
|
60
|
+
if (routerConfig.supportHtml5History !== false) {
|
|
61
|
+
if (!routerConfig.historyOptions) {
|
|
62
|
+
routerConfig.historyOptions = {
|
|
63
|
+
basename: basename
|
|
64
|
+
};
|
|
65
|
+
} else {
|
|
66
|
+
routerConfig.historyOptions.basename = basename;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return router(routerConfig);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function generateRootDom ({ dom, props, basename }) {
|
|
74
|
+
const mountNode = dom ? (dom.querySelector('#' + MOUNT_ID) || dom) : document.getElementById(MOUNT_ID);
|
|
75
|
+
const mergedProps = {
|
|
76
|
+
...props,
|
|
77
|
+
basename,
|
|
78
|
+
}
|
|
79
|
+
return { mountNode, props: mergedProps }
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
3
82
|
};
|
|
4
83
|
var makeRenderFunction = function(code) {
|
|
5
84
|
var inGarfishToRender = "\n let { basename, props, dom, appName } = typeof arguments[0] === 'object' && arguments[0] || {};\n if (!canContinueRender({ dom, appName })) return null;\n const rootDomInfo = generateRootDom({dom, props, basename});\n let mountNode = rootDomInfo.mountNode;\n props = rootDomInfo.props;\n ";
|
|
@@ -53,7 +53,7 @@ function canContinueRender ({ dom, appName }) {
|
|
|
53
53
|
|
|
54
54
|
function generateRouterPlugin (basename,routerConfig) {
|
|
55
55
|
if (basename) {
|
|
56
|
-
routerConfig.originalBaseUrl = basename;
|
|
56
|
+
routerConfig.originalBaseUrl = basename.replace(/^\\/*/, "/");
|
|
57
57
|
// for compatibility with react router v5
|
|
58
58
|
routerConfig.basename = basename;
|
|
59
59
|
if (routerConfig.supportHtml5History !== false) {
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.54.
|
|
18
|
+
"version": "2.54.4",
|
|
19
19
|
"jsnext:source": "./src/cli/index.ts",
|
|
20
20
|
"types": "./dist/types/cli/index.d.ts",
|
|
21
21
|
"typesVersions": {
|
|
@@ -70,15 +70,15 @@
|
|
|
70
70
|
"hoist-non-react-statics": "^3.3.2",
|
|
71
71
|
"react-loadable": "^5.5.0",
|
|
72
72
|
"@swc/helpers": "0.5.3",
|
|
73
|
-
"@modern-js/utils": "2.54.
|
|
73
|
+
"@modern-js/utils": "2.54.4"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@modern-js/runtime": "^2.54.
|
|
76
|
+
"@modern-js/runtime": "^2.54.4",
|
|
77
77
|
"react": ">=17",
|
|
78
78
|
"react-dom": ">=17"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@rsbuild/shared": "0.7.
|
|
81
|
+
"@rsbuild/shared": "0.7.10",
|
|
82
82
|
"@testing-library/dom": "^8.14.0",
|
|
83
83
|
"@testing-library/jest-dom": "^5.16.1",
|
|
84
84
|
"@testing-library/react": "^13.4.0",
|
|
@@ -93,13 +93,13 @@
|
|
|
93
93
|
"react-dom": "^18",
|
|
94
94
|
"react-router-dom": "6.22.0",
|
|
95
95
|
"typescript": "^5",
|
|
96
|
-
"@modern-js/
|
|
97
|
-
"@modern-js/
|
|
98
|
-
"@modern-js/
|
|
99
|
-
"@modern-js/
|
|
100
|
-
"@
|
|
101
|
-
"@
|
|
102
|
-
"@scripts/jest-config": "2.54.
|
|
96
|
+
"@modern-js/app-tools": "2.54.4",
|
|
97
|
+
"@modern-js/core": "2.54.4",
|
|
98
|
+
"@modern-js/plugin-router-v5": "2.54.4",
|
|
99
|
+
"@modern-js/types": "2.54.4",
|
|
100
|
+
"@scripts/build": "2.54.4",
|
|
101
|
+
"@modern-js/runtime": "2.54.4",
|
|
102
|
+
"@scripts/jest-config": "2.54.4"
|
|
103
103
|
},
|
|
104
104
|
"sideEffects": false,
|
|
105
105
|
"publishConfig": {
|