@modern-js/plugin-garfish 2.56.3-alpha.0 → 2.57.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/cjs/runtime/plugin.js +10 -10
- package/dist/cjs/runtime/provider.js +3 -15
- package/dist/esm/runtime/plugin.js +13 -13
- package/dist/esm/runtime/provider.js +3 -15
- package/dist/esm-node/runtime/plugin.js +10 -10
- package/dist/esm-node/runtime/provider.js +3 -15
- package/dist/types/runtime/plugin.d.ts +1 -1
- package/package.json +14 -12
|
@@ -35,6 +35,7 @@ module.exports = __toCommonJS(plugin_exports);
|
|
|
35
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
36
|
var import_garfish = __toESM(require("garfish"));
|
|
37
37
|
var import_react = __toESM(require("react"));
|
|
38
|
+
var import_merge = require("@modern-js/runtime-utils/merge");
|
|
38
39
|
var import_util = require("../util");
|
|
39
40
|
var import_Context = require("./utils/Context");
|
|
40
41
|
var import_setExternal = __toESM(require("./utils/setExternal"));
|
|
@@ -66,15 +67,17 @@ async function initOptions(manifest = {}, options) {
|
|
|
66
67
|
apps
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
|
-
const garfishPlugin = (
|
|
70
|
+
const garfishPlugin = (userConfig = {}) => ({
|
|
70
71
|
name: "@modern-js/garfish-plugin",
|
|
71
|
-
setup: () => {
|
|
72
|
+
setup: (api) => {
|
|
72
73
|
(0, import_setExternal.default)();
|
|
73
|
-
const { manifest, ...options } = config;
|
|
74
|
-
(0, import_util.logger)("createPlugin", config);
|
|
75
|
-
const promise = initOptions(manifest, options);
|
|
76
74
|
return {
|
|
77
|
-
|
|
75
|
+
wrapRoot(App) {
|
|
76
|
+
const pluginConfig = api.useRuntimeConfigContext();
|
|
77
|
+
const config = (0, import_merge.merge)(pluginConfig.garfish || {}, userConfig);
|
|
78
|
+
const { manifest, ...options } = config;
|
|
79
|
+
(0, import_util.logger)("createPlugin", config);
|
|
80
|
+
const promise = initOptions(manifest, options);
|
|
78
81
|
class GetMicroFrontendApp extends import_react.default.Component {
|
|
79
82
|
render() {
|
|
80
83
|
(0, import_util.logger)("GarfishProvider state", this.state);
|
|
@@ -130,10 +133,7 @@ const garfishPlugin = (config) => ({
|
|
|
130
133
|
load();
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
|
-
return
|
|
134
|
-
App: GetMicroFrontendApp,
|
|
135
|
-
config: config2
|
|
136
|
-
});
|
|
136
|
+
return GetMicroFrontendApp;
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
}
|
|
@@ -30,11 +30,7 @@ function createProvider(id, { customBootstrap, beforeRender } = {}) {
|
|
|
30
30
|
let root = null;
|
|
31
31
|
return {
|
|
32
32
|
async render({ basename: basename2, dom: dom2, props }) {
|
|
33
|
-
const ModernRoot = (0, import_react.createRoot)(null
|
|
34
|
-
router: {
|
|
35
|
-
basename: basename2
|
|
36
|
-
}
|
|
37
|
-
});
|
|
33
|
+
const ModernRoot = (0, import_react.createRoot)(null);
|
|
38
34
|
if (customBootstrap) {
|
|
39
35
|
root = await customBootstrap(ModernRoot, () => (0, import_browser.render)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModernRoot, {
|
|
40
36
|
basename: basename2,
|
|
@@ -65,22 +61,14 @@ function createProvider(id, { customBootstrap, beforeRender } = {}) {
|
|
|
65
61
|
},
|
|
66
62
|
// 兼容旧版本
|
|
67
63
|
SubModuleComponent: (props) => {
|
|
68
|
-
const ModernRoot = (0, import_react.createRoot)(null
|
|
69
|
-
router: {
|
|
70
|
-
basename
|
|
71
|
-
}
|
|
72
|
-
});
|
|
64
|
+
const ModernRoot = (0, import_react.createRoot)(null);
|
|
73
65
|
return /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModernRoot, {
|
|
74
66
|
basename,
|
|
75
67
|
...props
|
|
76
68
|
}), dom.querySelector(`#${id || "root"}`) || dom);
|
|
77
69
|
},
|
|
78
70
|
jupiter_submodule_app_key: (props) => {
|
|
79
|
-
const ModernRoot = (0, import_react.createRoot)(null
|
|
80
|
-
router: {
|
|
81
|
-
basename
|
|
82
|
-
}
|
|
83
|
-
});
|
|
71
|
+
const ModernRoot = (0, import_react.createRoot)(null);
|
|
84
72
|
return /* @__PURE__ */ (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModernRoot, {
|
|
85
73
|
basename,
|
|
86
74
|
...props
|
|
@@ -11,6 +11,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
import GarfishInstance from "garfish";
|
|
13
13
|
import React from "react";
|
|
14
|
+
import { merge } from "@modern-js/runtime-utils/merge";
|
|
14
15
|
import { logger } from "../util";
|
|
15
16
|
import { GarfishProvider } from "./utils/Context";
|
|
16
17
|
import setExternal from "./utils/setExternal";
|
|
@@ -67,19 +68,21 @@ function _initOptions() {
|
|
|
67
68
|
});
|
|
68
69
|
return _initOptions.apply(this, arguments);
|
|
69
70
|
}
|
|
70
|
-
var garfishPlugin = function(
|
|
71
|
+
var garfishPlugin = function() {
|
|
72
|
+
var userConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
71
73
|
return {
|
|
72
74
|
name: "@modern-js/garfish-plugin",
|
|
73
|
-
setup: function() {
|
|
75
|
+
setup: function(api) {
|
|
74
76
|
setExternal();
|
|
75
|
-
var manifest = config.manifest, options = _object_without_properties(config, [
|
|
76
|
-
"manifest"
|
|
77
|
-
]);
|
|
78
|
-
logger("createPlugin", config);
|
|
79
|
-
var promise = initOptions(manifest, options);
|
|
80
77
|
return {
|
|
81
|
-
|
|
82
|
-
var
|
|
78
|
+
wrapRoot: function wrapRoot(App) {
|
|
79
|
+
var pluginConfig = api.useRuntimeConfigContext();
|
|
80
|
+
var config = merge(pluginConfig.garfish || {}, userConfig);
|
|
81
|
+
var manifest = config.manifest, options = _object_without_properties(config, [
|
|
82
|
+
"manifest"
|
|
83
|
+
]);
|
|
84
|
+
logger("createPlugin", config);
|
|
85
|
+
var promise = initOptions(manifest, options);
|
|
83
86
|
var GetMicroFrontendApp = /* @__PURE__ */ function(_React_Component) {
|
|
84
87
|
"use strict";
|
|
85
88
|
_inherits(GetMicroFrontendApp2, _React_Component);
|
|
@@ -161,10 +164,7 @@ var garfishPlugin = function(config) {
|
|
|
161
164
|
};
|
|
162
165
|
return GetMicroFrontendApp2;
|
|
163
166
|
}(React.Component);
|
|
164
|
-
return
|
|
165
|
-
App: GetMicroFrontendApp,
|
|
166
|
-
config: _$config
|
|
167
|
-
});
|
|
167
|
+
return GetMicroFrontendApp;
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
170
|
}
|
|
@@ -18,11 +18,7 @@ function createProvider(id) {
|
|
|
18
18
|
return _ts_generator(this, function(_state) {
|
|
19
19
|
switch (_state.label) {
|
|
20
20
|
case 0:
|
|
21
|
-
ModernRoot = createRoot(null
|
|
22
|
-
router: {
|
|
23
|
-
basename: basename2
|
|
24
|
-
}
|
|
25
|
-
});
|
|
21
|
+
ModernRoot = createRoot(null);
|
|
26
22
|
if (!customBootstrap)
|
|
27
23
|
return [
|
|
28
24
|
3,
|
|
@@ -88,21 +84,13 @@ function createProvider(id) {
|
|
|
88
84
|
},
|
|
89
85
|
// 兼容旧版本
|
|
90
86
|
SubModuleComponent: function(props) {
|
|
91
|
-
var ModernRoot = createRoot(null
|
|
92
|
-
router: {
|
|
93
|
-
basename
|
|
94
|
-
}
|
|
95
|
-
});
|
|
87
|
+
var ModernRoot = createRoot(null);
|
|
96
88
|
return /* @__PURE__ */ createPortal(/* @__PURE__ */ _jsx(ModernRoot, _object_spread({
|
|
97
89
|
basename
|
|
98
90
|
}, props)), dom.querySelector("#".concat(id || "root")) || dom);
|
|
99
91
|
},
|
|
100
92
|
jupiter_submodule_app_key: function(props) {
|
|
101
|
-
var ModernRoot = createRoot(null
|
|
102
|
-
router: {
|
|
103
|
-
basename
|
|
104
|
-
}
|
|
105
|
-
});
|
|
93
|
+
var ModernRoot = createRoot(null);
|
|
106
94
|
return /* @__PURE__ */ createPortal(/* @__PURE__ */ _jsx(ModernRoot, _object_spread({
|
|
107
95
|
basename
|
|
108
96
|
}, props)), dom.querySelector("#".concat(id || "root")) || dom);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import GarfishInstance from "garfish";
|
|
3
3
|
import React from "react";
|
|
4
|
+
import { merge } from "@modern-js/runtime-utils/merge";
|
|
4
5
|
import { logger } from "../util";
|
|
5
6
|
import { GarfishProvider } from "./utils/Context";
|
|
6
7
|
import setExternal from "./utils/setExternal";
|
|
@@ -32,15 +33,17 @@ async function initOptions(manifest = {}, options) {
|
|
|
32
33
|
apps
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
|
-
const garfishPlugin = (
|
|
36
|
+
const garfishPlugin = (userConfig = {}) => ({
|
|
36
37
|
name: "@modern-js/garfish-plugin",
|
|
37
|
-
setup: () => {
|
|
38
|
+
setup: (api) => {
|
|
38
39
|
setExternal();
|
|
39
|
-
const { manifest, ...options } = config;
|
|
40
|
-
logger("createPlugin", config);
|
|
41
|
-
const promise = initOptions(manifest, options);
|
|
42
40
|
return {
|
|
43
|
-
|
|
41
|
+
wrapRoot(App) {
|
|
42
|
+
const pluginConfig = api.useRuntimeConfigContext();
|
|
43
|
+
const config = merge(pluginConfig.garfish || {}, userConfig);
|
|
44
|
+
const { manifest, ...options } = config;
|
|
45
|
+
logger("createPlugin", config);
|
|
46
|
+
const promise = initOptions(manifest, options);
|
|
44
47
|
class GetMicroFrontendApp extends React.Component {
|
|
45
48
|
render() {
|
|
46
49
|
logger("GarfishProvider state", this.state);
|
|
@@ -96,10 +99,7 @@ const garfishPlugin = (config) => ({
|
|
|
96
99
|
load();
|
|
97
100
|
}
|
|
98
101
|
}
|
|
99
|
-
return
|
|
100
|
-
App: GetMicroFrontendApp,
|
|
101
|
-
config: config2
|
|
102
|
-
});
|
|
102
|
+
return GetMicroFrontendApp;
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
}
|
|
@@ -7,11 +7,7 @@ function createProvider(id, { customBootstrap, beforeRender } = {}) {
|
|
|
7
7
|
let root = null;
|
|
8
8
|
return {
|
|
9
9
|
async render({ basename: basename2, dom: dom2, props }) {
|
|
10
|
-
const ModernRoot = createRoot(null
|
|
11
|
-
router: {
|
|
12
|
-
basename: basename2
|
|
13
|
-
}
|
|
14
|
-
});
|
|
10
|
+
const ModernRoot = createRoot(null);
|
|
15
11
|
if (customBootstrap) {
|
|
16
12
|
root = await customBootstrap(ModernRoot, () => render(/* @__PURE__ */ _jsx(ModernRoot, {
|
|
17
13
|
basename: basename2,
|
|
@@ -42,22 +38,14 @@ function createProvider(id, { customBootstrap, beforeRender } = {}) {
|
|
|
42
38
|
},
|
|
43
39
|
// 兼容旧版本
|
|
44
40
|
SubModuleComponent: (props) => {
|
|
45
|
-
const ModernRoot = createRoot(null
|
|
46
|
-
router: {
|
|
47
|
-
basename
|
|
48
|
-
}
|
|
49
|
-
});
|
|
41
|
+
const ModernRoot = createRoot(null);
|
|
50
42
|
return /* @__PURE__ */ createPortal(/* @__PURE__ */ _jsx(ModernRoot, {
|
|
51
43
|
basename,
|
|
52
44
|
...props
|
|
53
45
|
}), dom.querySelector(`#${id || "root"}`) || dom);
|
|
54
46
|
},
|
|
55
47
|
jupiter_submodule_app_key: (props) => {
|
|
56
|
-
const ModernRoot = createRoot(null
|
|
57
|
-
router: {
|
|
58
|
-
basename
|
|
59
|
-
}
|
|
60
|
-
});
|
|
48
|
+
const ModernRoot = createRoot(null);
|
|
61
49
|
return /* @__PURE__ */ createPortal(/* @__PURE__ */ _jsx(ModernRoot, {
|
|
62
50
|
basename,
|
|
63
51
|
...props
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.57.1",
|
|
19
19
|
"jsnext:source": "./src/cli/index.ts",
|
|
20
20
|
"types": "./dist/types/cli/index.d.ts",
|
|
21
21
|
"typesVersions": {
|
|
@@ -69,11 +69,12 @@
|
|
|
69
69
|
"garfish": "^1.8.1",
|
|
70
70
|
"react-loadable": "^5.5.0",
|
|
71
71
|
"@swc/helpers": "0.5.3",
|
|
72
|
-
"@modern-js/
|
|
73
|
-
"@modern-js/
|
|
72
|
+
"@modern-js/runtime-utils": "2.57.1",
|
|
73
|
+
"@modern-js/plugin": "2.57.1",
|
|
74
|
+
"@modern-js/utils": "2.57.1"
|
|
74
75
|
},
|
|
75
76
|
"peerDependencies": {
|
|
76
|
-
"@modern-js/runtime": "^2.
|
|
77
|
+
"@modern-js/runtime": "^2.57.1",
|
|
77
78
|
"react": ">=17",
|
|
78
79
|
"react-dom": ">=17"
|
|
79
80
|
},
|
|
@@ -92,18 +93,19 @@
|
|
|
92
93
|
"react-dom": "^18",
|
|
93
94
|
"react-router-dom": "6.22.0",
|
|
94
95
|
"typescript": "^5",
|
|
95
|
-
"@modern-js/
|
|
96
|
-
"@modern-js/
|
|
97
|
-
"@modern-js/core": "2.
|
|
98
|
-
"@modern-js/plugin-router-v5": "2.
|
|
99
|
-
"@modern-js/
|
|
100
|
-
"@scripts/build": "2.
|
|
101
|
-
"@scripts/jest-config": "2.
|
|
96
|
+
"@modern-js/app-tools": "2.57.1",
|
|
97
|
+
"@modern-js/runtime": "2.57.1",
|
|
98
|
+
"@modern-js/core": "2.57.1",
|
|
99
|
+
"@modern-js/plugin-router-v5": "2.57.1",
|
|
100
|
+
"@modern-js/types": "2.57.1",
|
|
101
|
+
"@scripts/build": "2.57.1",
|
|
102
|
+
"@scripts/jest-config": "2.57.1"
|
|
102
103
|
},
|
|
103
104
|
"sideEffects": false,
|
|
104
105
|
"publishConfig": {
|
|
105
106
|
"registry": "https://registry.npmjs.org/",
|
|
106
|
-
"access": "public"
|
|
107
|
+
"access": "public",
|
|
108
|
+
"provenance": true
|
|
107
109
|
},
|
|
108
110
|
"scripts": {
|
|
109
111
|
"new": "modern-lib new",
|