@modern-js/plugin-garfish 2.4.0 → 2.5.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.
- package/CHANGELOG.md +26 -0
- package/dist/{js/node → cjs}/cli/index.js +10 -41
- package/dist/{js/node → cjs}/cli/utils.js +5 -2
- package/dist/{js/node → cjs}/deps/index.js +0 -0
- package/dist/{js/node → cjs}/index.js +0 -0
- package/dist/{js/node → cjs}/runtime/index.js +0 -0
- package/dist/{js/node → cjs}/runtime/loadable.js +11 -38
- package/dist/{js/node → cjs}/runtime/plugin.js +32 -79
- package/dist/{js/node → cjs}/runtime/useModuleApps.js +8 -20
- package/dist/{js/node → cjs}/runtime/utils/Context.js +0 -0
- package/dist/{js/node → cjs}/runtime/utils/MApp.js +4 -30
- package/dist/{js/node → cjs}/runtime/utils/apps.js +43 -88
- package/dist/{js/node → cjs}/runtime/utils/setExternal.js +0 -0
- package/dist/{js/node → cjs}/util.js +0 -0
- package/dist/{js/treeshaking → esm}/cli/index.js +22 -22
- package/dist/{js/treeshaking → esm}/cli/utils.js +8 -8
- package/dist/{js/treeshaking → esm}/deps/index.js +0 -0
- package/dist/{js/treeshaking → esm}/index.js +0 -0
- package/dist/{js/treeshaking → esm}/runtime/index.js +0 -0
- package/dist/{js/treeshaking → esm}/runtime/loadable.js +5 -5
- package/dist/{js/treeshaking → esm}/runtime/plugin.js +7 -7
- package/dist/{js/treeshaking → esm}/runtime/useModuleApps.js +1 -1
- package/dist/{js/treeshaking → esm}/runtime/utils/Context.js +0 -0
- package/dist/{js/treeshaking → esm}/runtime/utils/MApp.js +3 -3
- package/dist/{js/treeshaking → esm}/runtime/utils/apps.js +12 -12
- package/dist/{js/treeshaking → esm}/runtime/utils/setExternal.js +0 -0
- package/dist/{js/treeshaking → esm}/util.js +0 -0
- package/dist/{js/modern → esm-node}/cli/index.js +10 -43
- package/dist/{js/modern → esm-node}/cli/utils.js +5 -2
- package/dist/{js/modern → esm-node}/deps/index.js +0 -0
- package/dist/{js/modern → esm-node}/index.js +0 -0
- package/dist/{js/modern → esm-node}/runtime/index.js +0 -0
- package/dist/{js/modern → esm-node}/runtime/loadable.js +11 -40
- package/dist/esm-node/runtime/plugin.js +107 -0
- package/dist/esm-node/runtime/useModuleApps.js +36 -0
- package/dist/{js/modern → esm-node}/runtime/utils/Context.js +0 -0
- package/dist/{js/modern → esm-node}/runtime/utils/MApp.js +4 -32
- package/dist/{js/modern → esm-node}/runtime/utils/apps.js +43 -90
- package/dist/{js/modern → esm-node}/runtime/utils/setExternal.js +0 -0
- package/dist/{js/modern → esm-node}/util.js +0 -0
- package/package.json +16 -17
- package/dist/js/modern/runtime/plugin.js +0 -156
- package/dist/js/modern/runtime/useModuleApps.js +0 -50
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
var __objRest = (source, exclude) => {
|
|
21
|
-
var target = {};
|
|
22
|
-
for (var prop in source)
|
|
23
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
-
target[prop] = source[prop];
|
|
25
|
-
if (source != null && __getOwnPropSymbols)
|
|
26
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
-
target[prop] = source[prop];
|
|
29
|
-
}
|
|
30
|
-
return target;
|
|
31
|
-
};
|
|
32
|
-
var __async = (__this, __arguments, generator) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
var fulfilled = (value) => {
|
|
35
|
-
try {
|
|
36
|
-
step(generator.next(value));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
reject(e);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var rejected = (value) => {
|
|
42
|
-
try {
|
|
43
|
-
step(generator.throw(value));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
reject(e);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
import { jsx } from "react/jsx-runtime";
|
|
53
|
-
import GarfishInstance from "garfish";
|
|
54
|
-
import React from "react";
|
|
55
|
-
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
56
|
-
import { logger } from "../util";
|
|
57
|
-
import { GarfishProvider } from "./utils/Context";
|
|
58
|
-
import setExternal from "./utils/setExternal";
|
|
59
|
-
import { generateMApp } from "./utils/MApp";
|
|
60
|
-
import { generateApps } from "./utils/apps";
|
|
61
|
-
function initOptions() {
|
|
62
|
-
return __async(this, arguments, function* (manifest = {}, options) {
|
|
63
|
-
var _a, _b, _c;
|
|
64
|
-
let apps = options.apps || [];
|
|
65
|
-
if (manifest == null ? void 0 : manifest.modules) {
|
|
66
|
-
if ((manifest == null ? void 0 : manifest.modules.length) > 0) {
|
|
67
|
-
apps = manifest == null ? void 0 : manifest.modules;
|
|
68
|
-
}
|
|
69
|
-
logger("manifest modules", apps);
|
|
70
|
-
}
|
|
71
|
-
if (manifest == null ? void 0 : manifest.getAppList) {
|
|
72
|
-
const getAppList = yield manifest == null ? void 0 : manifest.getAppList(manifest);
|
|
73
|
-
if (getAppList.length > 0) {
|
|
74
|
-
apps = getAppList;
|
|
75
|
-
}
|
|
76
|
-
logger("getAppList modules", apps);
|
|
77
|
-
}
|
|
78
|
-
if (((_a = window == null ? void 0 : window.modern_manifest) == null ? void 0 : _a.modules) && ((_b = window == null ? void 0 : window.modern_manifest) == null ? void 0 : _b.modules.length) > 0) {
|
|
79
|
-
apps = (_c = window == null ? void 0 : window.modern_manifest) == null ? void 0 : _c.modules;
|
|
80
|
-
logger("modern_manifest", apps);
|
|
81
|
-
}
|
|
82
|
-
return __spreadProps(__spreadValues({}, options), {
|
|
83
|
-
apps
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
var plugin_default = (config) => ({
|
|
88
|
-
name: "@modern-js/garfish-plugin",
|
|
89
|
-
setup: () => {
|
|
90
|
-
setExternal();
|
|
91
|
-
const _a = config, { manifest } = _a, options = __objRest(_a, ["manifest"]);
|
|
92
|
-
logger("createPlugin", config);
|
|
93
|
-
const promise = initOptions(manifest, options);
|
|
94
|
-
return {
|
|
95
|
-
hoc({ App }, next) {
|
|
96
|
-
class GetMicroFrontendApp extends React.Component {
|
|
97
|
-
constructor(props) {
|
|
98
|
-
super(props);
|
|
99
|
-
this.state = {
|
|
100
|
-
MApp: () => {
|
|
101
|
-
logger("MApp init Component Render");
|
|
102
|
-
return React.createElement("div");
|
|
103
|
-
},
|
|
104
|
-
apps: new Proxy(
|
|
105
|
-
{},
|
|
106
|
-
{
|
|
107
|
-
get() {
|
|
108
|
-
return () => React.createElement("div");
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
),
|
|
112
|
-
appInfoList: []
|
|
113
|
-
};
|
|
114
|
-
const load = () => __async(this, null, function* () {
|
|
115
|
-
GarfishInstance.setOptions(__spreadProps(__spreadValues({}, options), {
|
|
116
|
-
insulationVariable: [
|
|
117
|
-
...options.insulationVariable || [],
|
|
118
|
-
"_SERVER_DATA"
|
|
119
|
-
],
|
|
120
|
-
apps: []
|
|
121
|
-
}));
|
|
122
|
-
const GarfishConfig = yield promise;
|
|
123
|
-
const { appInfoList, apps } = generateApps(
|
|
124
|
-
GarfishConfig,
|
|
125
|
-
manifest
|
|
126
|
-
);
|
|
127
|
-
GarfishInstance.registerApp(appInfoList);
|
|
128
|
-
const MApp = generateMApp(GarfishConfig, manifest);
|
|
129
|
-
logger("initOptions result", { manifest, GarfishConfig });
|
|
130
|
-
logger("generateApps", { MApp, apps, appInfoList });
|
|
131
|
-
this.setState({
|
|
132
|
-
MApp,
|
|
133
|
-
apps,
|
|
134
|
-
appInfoList
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
load();
|
|
138
|
-
}
|
|
139
|
-
render() {
|
|
140
|
-
logger("GarfishProvider state", this.state);
|
|
141
|
-
return /* @__PURE__ */ jsx(GarfishProvider, {
|
|
142
|
-
value: this.state,
|
|
143
|
-
children: /* @__PURE__ */ jsx(App, __spreadValues({}, this.props))
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return next({
|
|
148
|
-
App: hoistNonReactStatics(GetMicroFrontendApp, App)
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
export {
|
|
155
|
-
plugin_default as default
|
|
156
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
import React, { useContext } from "react";
|
|
18
|
-
import { logger } from "../util";
|
|
19
|
-
import { GarfishContext } from "./utils/Context";
|
|
20
|
-
function useModuleApps() {
|
|
21
|
-
const { apps, MApp, appInfoList } = useContext(GarfishContext);
|
|
22
|
-
logger("call useModuleApps", __spreadValues({
|
|
23
|
-
MApp,
|
|
24
|
-
apps: appInfoList
|
|
25
|
-
}, apps));
|
|
26
|
-
const Info = new Proxy(
|
|
27
|
-
__spreadValues({
|
|
28
|
-
MApp,
|
|
29
|
-
apps: appInfoList
|
|
30
|
-
}, apps),
|
|
31
|
-
{
|
|
32
|
-
get(target, p, receiver) {
|
|
33
|
-
if (typeof p === "string" && p in target) {
|
|
34
|
-
return Reflect.get(target, p, receiver);
|
|
35
|
-
}
|
|
36
|
-
return () => React.createElement("div");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
return Info;
|
|
41
|
-
}
|
|
42
|
-
function useModuleApp() {
|
|
43
|
-
const { MApp } = useContext(GarfishContext);
|
|
44
|
-
logger("call useModuleApps", MApp);
|
|
45
|
-
return MApp;
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
useModuleApp,
|
|
49
|
-
useModuleApps
|
|
50
|
-
};
|