@modern-js/plugin-garfish 2.54.6 → 2.55.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/dist/cjs/cli/code.js +75 -0
- package/dist/cjs/cli/index.js +45 -123
- package/dist/cjs/cli/template.js +48 -0
- package/dist/cjs/cli/utils.js +7 -100
- package/dist/cjs/runtime/index.js +8 -0
- package/dist/cjs/runtime/plugin.js +9 -4
- package/dist/cjs/runtime/provider.js +79 -0
- package/dist/cjs/runtime/render.js +81 -0
- package/dist/esm/cli/code.js +80 -0
- package/dist/esm/cli/index.js +72 -136
- package/dist/esm/cli/template.js +20 -0
- package/dist/esm/cli/utils.js +4 -92
- package/dist/esm/runtime/index.js +6 -1
- package/dist/esm/runtime/plugin.js +6 -6
- package/dist/esm/runtime/provider.js +74 -0
- package/dist/esm/runtime/render.js +77 -0
- package/dist/esm-node/cli/code.js +40 -0
- package/dist/esm-node/cli/index.js +47 -125
- package/dist/esm-node/cli/template.js +24 -0
- package/dist/esm-node/cli/utils.js +6 -97
- package/dist/esm-node/runtime/index.js +6 -1
- package/dist/esm-node/runtime/plugin.js +5 -4
- package/dist/esm-node/runtime/provider.js +55 -0
- package/dist/esm-node/runtime/render.js +56 -0
- package/dist/types/cli/code.d.ts +7 -0
- package/dist/types/cli/index.d.ts +12 -5
- package/dist/types/cli/template.d.ts +11 -0
- package/dist/types/cli/utils.d.ts +1 -3
- package/dist/types/runtime/index.d.ts +3 -1
- package/dist/types/runtime/plugin.d.ts +2 -2
- package/dist/types/runtime/provider.d.ts +17 -0
- package/dist/types/runtime/render.d.ts +5 -0
- package/package.json +13 -23
- package/type.d.ts +8 -1
- package/dist/cjs/deps/index.js +0 -38
- package/dist/cjs/index.js +0 -40
- package/dist/esm/deps/index.js +0 -4
- package/dist/esm/index.js +0 -5
- package/dist/esm-node/deps/index.js +0 -4
- package/dist/esm-node/index.js +0 -5
- package/dist/types/deps/index.d.ts +0 -2
- package/dist/types/index.d.ts +0 -2
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from "@modern-js/runtime/browser";
|
|
3
|
+
import { createRoot } from "@modern-js/runtime/react";
|
|
4
|
+
function isRenderGarfish(params) {
|
|
5
|
+
const renderByGarfish = typeof __GARFISH_EXPORTS__ !== "undefined" || typeof window !== "undefined" && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.some((app) => {
|
|
6
|
+
var _app_appInfo;
|
|
7
|
+
return ((_app_appInfo = app.appInfo) === null || _app_appInfo === void 0 ? void 0 : _app_appInfo.name) === (params === null || params === void 0 ? void 0 : params.appName);
|
|
8
|
+
});
|
|
9
|
+
return renderByGarfish;
|
|
10
|
+
}
|
|
11
|
+
function canContinueRender({ dom, appName }) {
|
|
12
|
+
const renderByGarfish = isRenderGarfish({
|
|
13
|
+
appName
|
|
14
|
+
});
|
|
15
|
+
const renderByProvider = dom || appName;
|
|
16
|
+
if (renderByGarfish) {
|
|
17
|
+
if (renderByProvider) {
|
|
18
|
+
return true;
|
|
19
|
+
} else {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function garfishRender(mountId, customBootstrap, _params) {
|
|
27
|
+
const { basename, props, dom, appName } = (
|
|
28
|
+
// eslint-disable-next-line prefer-rest-params
|
|
29
|
+
typeof arguments[2] === "object" && arguments[2] || {}
|
|
30
|
+
);
|
|
31
|
+
if (canContinueRender({
|
|
32
|
+
dom,
|
|
33
|
+
appName
|
|
34
|
+
})) {
|
|
35
|
+
const ModernRoot = createRoot(null, {
|
|
36
|
+
router: {
|
|
37
|
+
basename
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
if (customBootstrap) {
|
|
41
|
+
return customBootstrap(ModernRoot, () => render(/* @__PURE__ */ _jsx(ModernRoot, {
|
|
42
|
+
basename,
|
|
43
|
+
...props
|
|
44
|
+
}), dom || mountId));
|
|
45
|
+
}
|
|
46
|
+
return render(/* @__PURE__ */ _jsx(ModernRoot, {
|
|
47
|
+
basename,
|
|
48
|
+
...props
|
|
49
|
+
}), dom || mountId);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
garfishRender,
|
|
55
|
+
isRenderGarfish
|
|
56
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AppTools, IAppContext, NormalizedConfig } from '@modern-js/app-tools';
|
|
2
|
+
import { Entrypoint } from '@modern-js/types';
|
|
3
|
+
import type { MaybeAsync } from '@modern-js/core';
|
|
4
|
+
export declare const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.jsx";
|
|
5
|
+
export declare const generateCode: (entrypoints: Entrypoint[], appContext: IAppContext, config: NormalizedConfig<AppTools>, appendEntryCode: (input: {
|
|
6
|
+
entrypoint: Entrypoint;
|
|
7
|
+
}) => MaybeAsync<string[]>) => Promise<void>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { AsyncWorkflow, type CliHookCallbacks, type useConfigContext } from '@modern-js/core';
|
|
2
2
|
import type { CliPlugin, AppTools } from '@modern-js/app-tools';
|
|
3
|
+
import { Entrypoint } from '@modern-js/types';
|
|
3
4
|
export type UseConfig = ReturnType<typeof useConfigContext>;
|
|
4
5
|
export declare const externals: {
|
|
5
6
|
'react-dom': string;
|
|
@@ -8,8 +9,14 @@ export declare const externals: {
|
|
|
8
9
|
export type LifeCycle = CliHookCallbacks;
|
|
9
10
|
type NonInValidAble<T> = T extends null | undefined | false ? never : T;
|
|
10
11
|
export declare function getDefaultMicroFrontedConfig(microFrontend: NonInValidAble<NonNullable<UseConfig['deploy']>['microFrontend']>): any;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
declare const appendEntryCode: AsyncWorkflow<{
|
|
13
|
+
entrypoint: Entrypoint;
|
|
14
|
+
}, string>;
|
|
15
|
+
export declare const garfishPlugin: () => CliPlugin<AppTools & {
|
|
16
|
+
hooks: {
|
|
17
|
+
appendEntryCode: AsyncWorkflow<{
|
|
18
|
+
entrypoint: Entrypoint;
|
|
19
|
+
}, string>;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
15
22
|
export default garfishPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const index: ({ srcDirectory, internalSrcAlias, metaName, entry, entryName, customEntry, customBootstrap, mountId, appendCode, }: {
|
|
2
|
+
srcDirectory: string;
|
|
3
|
+
internalSrcAlias: string;
|
|
4
|
+
metaName: string;
|
|
5
|
+
entry: string;
|
|
6
|
+
entryName: string;
|
|
7
|
+
customEntry?: boolean | undefined;
|
|
8
|
+
customBootstrap?: string | false | undefined;
|
|
9
|
+
mountId?: string | undefined;
|
|
10
|
+
appendCode?: string[] | undefined;
|
|
11
|
+
}) => string;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { AppNormalizedConfig } from '@modern-js/app-tools';
|
|
2
|
-
export declare const makeProvider: () => string;
|
|
3
|
-
export declare const makeRenderFunction: (code: string) => string;
|
|
4
2
|
export declare function getRuntimeConfig(config: Partial<AppNormalizedConfig>): any;
|
|
5
3
|
export declare function setRuntimeConfig(config: Partial<AppNormalizedConfig>, key: string, value: any): undefined;
|
|
6
|
-
export declare const
|
|
4
|
+
export declare const generateAsyncEntryCode: (appendCode?: string[]) => string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export { default } from './plugin';
|
|
1
|
+
export { default, garfishPlugin } from './plugin';
|
|
2
2
|
export { useModuleApps, useModuleApp } from './useModuleApps';
|
|
3
3
|
export type { Manifest, ModuleInfo, Config } from './useModuleApps';
|
|
4
4
|
export { default as Garfish, default as garfish } from 'garfish';
|
|
5
|
+
export { garfishRender } from './render';
|
|
6
|
+
export { createProvider } from './provider';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Plugin } from '@modern-js/runtime';
|
|
2
2
|
import { Config } from './useModuleApps';
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
export declare const garfishPlugin: (config: Config) => Plugin;
|
|
4
|
+
export default garfishPlugin;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function createProvider(id?: string, customBootstrap?: (App: React.ComponentType, render: () => void) => HTMLElement | null): ({ basename, dom }: {
|
|
3
|
+
basename: string;
|
|
4
|
+
dom: HTMLElement;
|
|
5
|
+
}) => {
|
|
6
|
+
render({ basename, dom, props, appName, }: {
|
|
7
|
+
basename: string;
|
|
8
|
+
dom: HTMLElement;
|
|
9
|
+
props: any;
|
|
10
|
+
appName?: string | undefined;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
destroy({ dom }: {
|
|
13
|
+
dom: HTMLElement;
|
|
14
|
+
}): void;
|
|
15
|
+
SubModuleComponent: (props: any) => import("react").ReactPortal;
|
|
16
|
+
jupiter_submodule_app_key: (props: any) => import("react").ReactPortal;
|
|
17
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function isRenderGarfish(params?: {
|
|
3
|
+
appName?: string;
|
|
4
|
+
}): boolean;
|
|
5
|
+
export declare function garfishRender(mountId?: string, customBootstrap?: (App: React.ComponentType, render: () => void) => HTMLElement | null, _params?: any): Promise<HTMLElement | import("react-dom/client").Root | null>;
|
package/package.json
CHANGED
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.55.0",
|
|
19
19
|
"jsnext:source": "./src/cli/index.ts",
|
|
20
20
|
"types": "./dist/types/cli/index.d.ts",
|
|
21
21
|
"typesVersions": {
|
|
22
22
|
"*": {
|
|
23
23
|
".": [
|
|
24
|
-
"./dist/types/
|
|
24
|
+
"./dist/types/cli/index.d.ts"
|
|
25
25
|
],
|
|
26
26
|
"cli": [
|
|
27
27
|
"./dist/types/cli/index.d.ts"
|
|
@@ -29,9 +29,6 @@
|
|
|
29
29
|
"runtime": [
|
|
30
30
|
"./dist/types/runtime/index.d.ts"
|
|
31
31
|
],
|
|
32
|
-
"deps": [
|
|
33
|
-
"./dist/types/deps/index.d.ts"
|
|
34
|
-
],
|
|
35
32
|
"types": [
|
|
36
33
|
"./type.d.ts"
|
|
37
34
|
]
|
|
@@ -42,7 +39,7 @@
|
|
|
42
39
|
"exports": {
|
|
43
40
|
"./types": "./type.d.ts",
|
|
44
41
|
".": {
|
|
45
|
-
"types": "./dist/types/
|
|
42
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
46
43
|
"jsnext:source": "./src/cli/index.ts",
|
|
47
44
|
"default": "./dist/cjs/cli/index.js"
|
|
48
45
|
},
|
|
@@ -51,14 +48,9 @@
|
|
|
51
48
|
"jsnext:source": "./src/cli/index.ts",
|
|
52
49
|
"default": "./dist/cjs/cli/index.js"
|
|
53
50
|
},
|
|
54
|
-
"./deps": {
|
|
55
|
-
"types": "./dist/types/deps/index.d.ts",
|
|
56
|
-
"jsnext:source": "./src/deps/index.ts",
|
|
57
|
-
"default": "./dist/esm/deps/index.js"
|
|
58
|
-
},
|
|
59
51
|
"./runtime": {
|
|
60
52
|
"types": "./dist/types/runtime/index.d.ts",
|
|
61
|
-
"jsnext:source": "./src/index.ts",
|
|
53
|
+
"jsnext:source": "./src/runtime/index.ts",
|
|
62
54
|
"default": "./dist/esm/runtime/index.js"
|
|
63
55
|
}
|
|
64
56
|
},
|
|
@@ -67,18 +59,16 @@
|
|
|
67
59
|
"@types/react-loadable": "^5.5.6",
|
|
68
60
|
"debug": "4.3.4",
|
|
69
61
|
"garfish": "^1.8.1",
|
|
70
|
-
"hoist-non-react-statics": "^3.3.2",
|
|
71
62
|
"react-loadable": "^5.5.0",
|
|
72
63
|
"@swc/helpers": "0.5.3",
|
|
73
|
-
"@modern-js/utils": "2.
|
|
64
|
+
"@modern-js/utils": "2.55.0"
|
|
74
65
|
},
|
|
75
66
|
"peerDependencies": {
|
|
76
|
-
"@modern-js/runtime": "^2.
|
|
67
|
+
"@modern-js/runtime": "^2.55.0",
|
|
77
68
|
"react": ">=17",
|
|
78
69
|
"react-dom": ">=17"
|
|
79
70
|
},
|
|
80
71
|
"devDependencies": {
|
|
81
|
-
"@rsbuild/shared": "0.7.10",
|
|
82
72
|
"@testing-library/dom": "^8.14.0",
|
|
83
73
|
"@testing-library/jest-dom": "^5.16.1",
|
|
84
74
|
"@testing-library/react": "^13.4.0",
|
|
@@ -93,13 +83,13 @@
|
|
|
93
83
|
"react-dom": "^18",
|
|
94
84
|
"react-router-dom": "6.22.0",
|
|
95
85
|
"typescript": "^5",
|
|
96
|
-
"@modern-js/
|
|
97
|
-
"@modern-js/core": "2.
|
|
98
|
-
"@modern-js/
|
|
99
|
-
"@
|
|
100
|
-
"@
|
|
101
|
-
"@scripts/jest-config": "2.
|
|
102
|
-
"@modern-js/
|
|
86
|
+
"@modern-js/plugin-router-v5": "2.55.0",
|
|
87
|
+
"@modern-js/core": "2.55.0",
|
|
88
|
+
"@modern-js/runtime": "2.55.0",
|
|
89
|
+
"@scripts/build": "2.55.0",
|
|
90
|
+
"@modern-js/types": "2.55.0",
|
|
91
|
+
"@scripts/jest-config": "2.55.0",
|
|
92
|
+
"@modern-js/app-tools": "2.55.0"
|
|
103
93
|
},
|
|
104
94
|
"sideEffects": false,
|
|
105
95
|
"publishConfig": {
|
package/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@modern-js/plugin-router-v5';
|
|
2
|
-
import { Config } from './dist/types';
|
|
2
|
+
import { Config } from './dist/types/runtime';
|
|
3
3
|
declare module '@modern-js/runtime/garfish' {
|
|
4
4
|
export const useModuleApp: typeof import('./dist/types/runtime').useModuleApp;
|
|
5
5
|
export const useModuleApps: typeof import('./dist/types/runtime').useModuleApps;
|
|
@@ -9,6 +9,13 @@ declare module '@modern-js/runtime' {
|
|
|
9
9
|
interface AppConfig {
|
|
10
10
|
masterApp?: Config;
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
interface RuntimeConfig {
|
|
14
|
+
garfish?: Config;
|
|
15
|
+
garfishByEntries?: {
|
|
16
|
+
[name: string]: Config
|
|
17
|
+
};
|
|
18
|
+
}
|
|
12
19
|
}
|
|
13
20
|
declare module '@modern-js/app-tools' {
|
|
14
21
|
interface RuntimeUserConfig {
|
package/dist/cjs/deps/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var deps_exports = {};
|
|
30
|
-
__export(deps_exports, {
|
|
31
|
-
hoistNonReactStatics: () => import_hoist_non_react_statics.default
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(deps_exports);
|
|
34
|
-
var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
hoistNonReactStatics
|
|
38
|
-
});
|
package/dist/cjs/index.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var src_exports = {};
|
|
31
|
-
__export(src_exports, {
|
|
32
|
-
default: () => import_runtime.default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(src_exports);
|
|
35
|
-
var import_runtime = __toESM(require("./runtime"));
|
|
36
|
-
__reExport(src_exports, require("./runtime"), module.exports);
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
...require("./runtime")
|
|
40
|
-
});
|
package/dist/esm/deps/index.js
DELETED
package/dist/esm/index.js
DELETED
package/dist/esm-node/index.js
DELETED
package/dist/types/index.d.ts
DELETED