@fulgurjs/federation 6.11.6 → 6.12.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 +13 -0
- package/README.en.md +2 -0
- package/README.md +3 -3
- package/dist/{application-core-DWI3eKme.d.ts → application-core-C72tVRT7.d.ts} +1 -1
- package/dist/{application-core-BuhXQmLF.d.cts → application-core-Coa0CIre.d.cts} +1 -1
- package/dist/bridge-app-react.d.cts +2 -2
- package/dist/bridge-app-react.d.ts +2 -2
- package/dist/bridge-app-react.js +1 -1
- package/dist/bridge-app-vue.d.cts +2 -2
- package/dist/bridge-app-vue.d.ts +2 -2
- package/dist/bridge-app-vue.js +1 -1
- package/dist/{bridge-core-77BT1__I.d.cts → bridge-core-CGFET9Qi.d.cts} +2 -1
- package/dist/{bridge-core-CoQRVgnZ.d.ts → bridge-core-Dm6ABUxQ.d.ts} +2 -1
- package/dist/bridge-core.cjs +4 -1
- package/dist/bridge-core.d.cts +1 -1
- package/dist/bridge-core.d.ts +1 -1
- package/dist/bridge-core.js +1 -1
- package/dist/bridge-host-react.cjs +4 -1
- package/dist/bridge-host-react.d.cts +2 -2
- package/dist/bridge-host-react.d.ts +2 -2
- package/dist/bridge-host-react.js +1 -1
- package/dist/bridge-host-vue.cjs +42 -5
- package/dist/bridge-host-vue.d.cts +12 -4
- package/dist/bridge-host-vue.d.ts +12 -4
- package/dist/bridge-host-vue.js +40 -5
- package/dist/bridge-session-auto.cjs +121 -0
- package/dist/bridge-session-auto.d.cts +21 -0
- package/dist/bridge-session-auto.d.ts +21 -0
- package/dist/bridge-session-auto.js +88 -0
- package/dist/{chunk-HDRZBSND.js → chunk-2MWIIRQZ.js} +4 -1
- package/dist/cli.js +67 -16
- package/dist/index.cjs +4 -3
- package/dist/index.js +4 -3
- package/dist/react-adapter.d.cts +2 -2
- package/dist/react-adapter.d.ts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{remote-types-COmBhjRc.d.ts → remote-types-CMtfvLcH.d.ts} +1 -1
- package/dist/{remote-types-CStGOJwu.d.cts → remote-types-Cf4SSzus.d.cts} +1 -1
- package/dist/runtime-entry.d.ts +2 -2
- package/dist/runtime.js +13 -13
- package/dist/vue-adapter.d.cts +2 -2
- package/dist/vue-adapter.d.ts +2 -2
- package/dist/vue.d.ts +10 -3
- package/dist/vue.js +2 -1
- package/docs/en/reference/api.md +15 -4
- package/docs/en/reference/errors.md +1 -1
- package/docs/en/reference/types.md +4 -2
- package/docs/zh/reference/api.md +16 -6
- package/docs/zh/reference/errors.md +1 -1
- package/docs/zh/reference/types.md +4 -2
- package/examples/templates/README.md +5 -1
- package/examples/templates/react-host-vue-remote/README.md +2 -2
- package/examples/templates/react-host-vue-remote/react-host/src/{application.tsx → fulgurjs/host/application.tsx} +2 -1
- package/examples/templates/react-host-vue-remote/react-host/src/{host-session.ts → fulgurjs/host/session.ts} +1 -1
- package/examples/templates/react-host-vue-remote/react-host/src/main.tsx +1 -1
- package/examples/templates/react-host-vue-remote/vue-remote/README.md +2 -2
- package/examples/templates/react-host-vue-remote/vue-remote/fulgurjs.config.ts +1 -1
- package/examples/templates/react-host-vue-remote/vue-remote/src/App.vue +1 -1
- package/examples/templates/react-host-vue-remote/vue-remote/src/{application.ts → fulgurjs/exposes/application.ts} +4 -3
- package/examples/templates/react-host-vue-remote/vue-remote/src/main.ts +1 -1
- package/examples/templates/react-react/README.md +5 -5
- package/examples/templates/react-react/host/README.md +1 -1
- package/examples/templates/react-react/host/src/{application.tsx → fulgurjs/host/application.tsx} +3 -2
- package/examples/templates/react-react/host/src/{remotePages.tsx → fulgurjs/host/remotePages.tsx} +1 -1
- package/examples/templates/react-react/host/src/main.tsx +1 -1
- package/examples/templates/react-react/remote/README.md +4 -4
- package/examples/templates/react-react/remote/fulgurjs.config.ts +4 -4
- package/examples/templates/react-react/remote/src/App.tsx +1 -1
- package/examples/templates/react-react/remote/src/{application.tsx → fulgurjs/exposes/application.tsx} +2 -1
- package/examples/templates/react-react/remote/src/main.tsx +1 -1
- package/examples/templates/showcase/README.md +13 -13
- package/examples/templates/showcase/react-host/src/GuardBanner.tsx +2 -2
- package/examples/templates/showcase/react-host/src/Layout.tsx +1 -1
- package/examples/templates/showcase/react-host/src/ObsPanel.tsx +2 -2
- package/examples/templates/showcase/react-host/src/{pages → fulgurjs/host}/BridgeVuePage.tsx +4 -4
- package/examples/templates/showcase/react-host/src/{application.tsx → fulgurjs/host/application.tsx} +5 -4
- package/examples/templates/showcase/react-host/src/{demo-log.ts → fulgurjs/host/demo-log.ts} +1 -1
- package/examples/templates/showcase/react-host/src/{routing.ts → fulgurjs/host/routing.ts} +1 -1
- package/examples/templates/showcase/react-host/src/main.tsx +1 -1
- package/examples/templates/showcase/react-remote/fulgurjs.config.ts +1 -1
- package/examples/templates/showcase/react-remote/src/{application.tsx → fulgurjs/exposes/application.tsx} +7 -6
- package/examples/templates/showcase/react-remote/src/main.tsx +1 -1
- package/examples/templates/showcase/vue-host/src/App.vue +1 -1
- package/examples/templates/showcase/vue-host/src/GuardBanner.vue +1 -1
- package/examples/templates/showcase/vue-host/src/ObsPanel.vue +2 -2
- package/examples/templates/showcase/vue-host/src/{pages → fulgurjs/host}/BridgeReactPage.vue +4 -4
- package/examples/templates/showcase/vue-host/src/{application.ts → fulgurjs/host/application.ts} +5 -4
- package/examples/templates/showcase/vue-host/src/{demo-log.ts → fulgurjs/host/demo-log.ts} +1 -1
- package/examples/templates/showcase/vue-host/src/{guard.ts → fulgurjs/host/guard.ts} +1 -1
- package/examples/templates/showcase/vue-host/src/{routing.ts → fulgurjs/host/routing.ts} +1 -1
- package/examples/templates/showcase/vue-host/src/main.ts +1 -1
- package/examples/templates/showcase/vue-remote/fulgurjs.config.ts +1 -1
- package/examples/templates/showcase/vue-remote/src/{application.ts → fulgurjs/exposes/application.ts} +7 -6
- package/examples/templates/showcase/vue-remote/src/main.ts +1 -1
- package/examples/templates/vue-host-react-remote/README.md +2 -2
- package/examples/templates/vue-host-react-remote/react-remote/README.md +2 -2
- package/examples/templates/vue-host-react-remote/react-remote/fulgurjs.config.ts +1 -1
- package/examples/templates/vue-host-react-remote/react-remote/src/{application.tsx → fulgurjs/exposes/application.tsx} +1 -0
- package/examples/templates/vue-host-react-remote/react-remote/src/main.tsx +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/README.md +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/src/App.vue +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/host/application.ts +6 -0
- package/examples/templates/vue-host-react-remote/vue-host/src/main.ts +1 -1
- package/examples/templates/vue-vue/README.md +6 -6
- package/examples/templates/vue-vue/host/src/{application.ts → fulgurjs/host/application.ts} +5 -4
- package/examples/templates/vue-vue/host/src/main.ts +1 -1
- package/examples/templates/vue-vue/host/src/pages/UtilsDemo.vue +1 -1
- package/examples/templates/vue-vue/remote/README.md +4 -4
- package/examples/templates/vue-vue/remote/fulgurjs.config.ts +4 -4
- package/examples/templates/vue-vue/remote/src/App.vue +1 -1
- package/examples/templates/vue-vue/remote/src/{application.ts → fulgurjs/exposes/application.ts} +2 -1
- package/examples/templates/vue-vue/remote/src/main.ts +1 -1
- package/package.json +6 -2
- package/examples/templates/vue-host-react-remote/vue-host/src/application.ts +0 -5
- /package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/ClickButton.tsx +0 -0
- /package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/pages/DetailPage.tsx +0 -0
- /package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/pages/HomePage.tsx +0 -0
- /package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/utils.ts +0 -0
- /package/examples/templates/vue-host-react-remote/vue-host/src/{host-session.ts → fulgurjs/host/session.ts} +0 -0
- /package/examples/templates/vue-vue/host/src/{type-demo.ts → fulgurjs/host/type-demo.ts} +0 -0
- /package/examples/templates/vue-vue/remote/src/{exposes → fulgurjs/exposes}/ClickButton.vue +0 -0
- /package/examples/templates/vue-vue/remote/src/{exposes → fulgurjs/exposes}/pages/DetailPage.vue +0 -0
- /package/examples/templates/vue-vue/remote/src/{exposes → fulgurjs/exposes}/pages/HomePage.vue +0 -0
- /package/examples/templates/vue-vue/remote/src/{exposes → fulgurjs/exposes}/utils.ts +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/bridge-session-auto.ts
|
|
21
|
+
var bridge_session_auto_exports = {};
|
|
22
|
+
__export(bridge_session_auto_exports, {
|
|
23
|
+
createAutomaticBridgeSession: () => createAutomaticBridgeSession
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(bridge_session_auto_exports);
|
|
26
|
+
var import_vue = require("vue");
|
|
27
|
+
|
|
28
|
+
// src/context.ts
|
|
29
|
+
var APP_CONTEXT_STORAGE_KEY = "__FULGURJS_APP_CONFIG__";
|
|
30
|
+
function clearAppContext() {
|
|
31
|
+
const g = globalThis;
|
|
32
|
+
delete g[APP_CONTEXT_STORAGE_KEY];
|
|
33
|
+
try {
|
|
34
|
+
g.__FULGURJS_RUNTIME__?.clearSessionState?.();
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/bridge-session-auto.ts
|
|
40
|
+
var PAGE_RECORDS = /* @__PURE__ */ Symbol.for("@fulgurjs/federation/automatic-sessions");
|
|
41
|
+
var sessions = /* @__PURE__ */ new WeakMap();
|
|
42
|
+
function records() {
|
|
43
|
+
const page = globalThis;
|
|
44
|
+
return page[PAGE_RECORDS] ??= /* @__PURE__ */ new Map();
|
|
45
|
+
}
|
|
46
|
+
function normalize(value) {
|
|
47
|
+
if (value === null || value === void 0) return value;
|
|
48
|
+
if (typeof value !== "string" && typeof value !== "number" || typeof value === "number" && !Number.isFinite(value) || !String(value).trim()) {
|
|
49
|
+
throw new TypeError("session \u5FC5\u987B\u540C\u6B65\u8FD4\u56DE\u975E\u7A7A\u7528\u6237\u6807\u8BC6\uFF08string/number\uFF09\u3001null\uFF08\u5DF2\u9000\u51FA\uFF09\u6216 undefined\uFF08\u8EAB\u4EFD\u521D\u59CB\u5316\u4E2D\uFF09\uFF1B\u4E0D\u8981\u8FD4\u56DE token\u3001\u5BF9\u8C61\u6216 Promise\u3002");
|
|
50
|
+
}
|
|
51
|
+
return String(value);
|
|
52
|
+
}
|
|
53
|
+
function createAutomaticBridgeSession(getIdentity, namespace) {
|
|
54
|
+
const key = `${namespace}:auto`;
|
|
55
|
+
const cached = sessions.get(getIdentity)?.get(key);
|
|
56
|
+
if (cached) return cached;
|
|
57
|
+
const sessionKey = (0, import_vue.ref)(null);
|
|
58
|
+
const error = (0, import_vue.shallowRef)();
|
|
59
|
+
const state = { sessionKey, error };
|
|
60
|
+
const entries = sessions.get(getIdentity) ?? /* @__PURE__ */ new Map();
|
|
61
|
+
entries.set(key, state);
|
|
62
|
+
sessions.set(getIdentity, entries);
|
|
63
|
+
const read = () => {
|
|
64
|
+
const memory = records().get(key);
|
|
65
|
+
if (memory) return memory;
|
|
66
|
+
try {
|
|
67
|
+
const saved = JSON.parse(sessionStorage.getItem(key) ?? "null");
|
|
68
|
+
if (saved && typeof saved === "object" && "identity" in saved && "sessionKey" in saved && typeof saved.identity === "string" && typeof saved.sessionKey === "string" && saved.sessionKey) {
|
|
69
|
+
const record = { identity: saved.identity, sessionKey: saved.sessionKey };
|
|
70
|
+
records().set(key, record);
|
|
71
|
+
return record;
|
|
72
|
+
}
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const save = (record) => {
|
|
77
|
+
if (record) records().set(key, record);
|
|
78
|
+
else records().delete(key);
|
|
79
|
+
try {
|
|
80
|
+
if (record) sessionStorage.setItem(key, JSON.stringify(record));
|
|
81
|
+
else sessionStorage.removeItem(key);
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const clearOwnedContext = (record) => {
|
|
86
|
+
const context = globalThis.__FULGURJS_APP_CONFIG__;
|
|
87
|
+
if (record && context?.sessionKey === record.sessionKey) clearAppContext();
|
|
88
|
+
};
|
|
89
|
+
(0, import_vue.effectScope)(true).run(() => (0, import_vue.watch)(() => {
|
|
90
|
+
try {
|
|
91
|
+
return { identity: normalize(getIdentity()), error: void 0 };
|
|
92
|
+
} catch (cause) {
|
|
93
|
+
return { identity: void 0, error: cause ?? new Error("session getter \u629B\u51FA\u4E86\u7A7A\u9519\u8BEF\u503C\u3002") };
|
|
94
|
+
}
|
|
95
|
+
}, (snapshot) => {
|
|
96
|
+
const saved = read();
|
|
97
|
+
error.value = snapshot.error;
|
|
98
|
+
if (snapshot.identity === void 0) {
|
|
99
|
+
sessionKey.value = null;
|
|
100
|
+
clearOwnedContext(saved);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (snapshot.identity === null) {
|
|
104
|
+
save(void 0);
|
|
105
|
+
sessionKey.value = null;
|
|
106
|
+
clearOwnedContext(saved);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const record = saved?.identity === snapshot.identity ? saved : {
|
|
110
|
+
identity: snapshot.identity,
|
|
111
|
+
sessionKey: `s-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`
|
|
112
|
+
};
|
|
113
|
+
if (record !== saved) save(record);
|
|
114
|
+
sessionKey.value = record.sessionKey;
|
|
115
|
+
}, { immediate: true, flush: "sync" }));
|
|
116
|
+
return state;
|
|
117
|
+
}
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {
|
|
120
|
+
createAutomaticBridgeSession
|
|
121
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Ref, ShallowRef } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author Jason.chen
|
|
5
|
+
* Vue 桥接的自动登录代次。调用方只提供响应式的业务身份,生成、恢复、换号和登出由插件管理。
|
|
6
|
+
*
|
|
7
|
+
* 不观察 token:同一用户的 token 轮换不应重挂。身份只能是非敏感业务标识,不能传凭据。
|
|
8
|
+
* 同页多个远程共用一个命名空间的记录;存储不可用时仍通过页面镜像保持相同代次。
|
|
9
|
+
* 观察器按身份getter/命名空间复用,生命周期属于宿主页面而非远程视图:离开远程页后登出
|
|
10
|
+
* 也必须清理上下文。业务应提供稳定的store getter,不捕获只在已卸载组件中更新的局部状态。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
type BridgeSessionIdentity = string | number | null | undefined;
|
|
14
|
+
interface AutomaticSession {
|
|
15
|
+
sessionKey: Ref<string | null>;
|
|
16
|
+
error: ShallowRef<unknown>;
|
|
17
|
+
}
|
|
18
|
+
/** 内部使用;不增加公共导入入口,不要求应用新建 session.ts。 */
|
|
19
|
+
declare function createAutomaticBridgeSession(getIdentity: () => BridgeSessionIdentity, namespace: string): AutomaticSession;
|
|
20
|
+
|
|
21
|
+
export { type BridgeSessionIdentity, createAutomaticBridgeSession };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Ref, ShallowRef } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author Jason.chen
|
|
5
|
+
* Vue 桥接的自动登录代次。调用方只提供响应式的业务身份,生成、恢复、换号和登出由插件管理。
|
|
6
|
+
*
|
|
7
|
+
* 不观察 token:同一用户的 token 轮换不应重挂。身份只能是非敏感业务标识,不能传凭据。
|
|
8
|
+
* 同页多个远程共用一个命名空间的记录;存储不可用时仍通过页面镜像保持相同代次。
|
|
9
|
+
* 观察器按身份getter/命名空间复用,生命周期属于宿主页面而非远程视图:离开远程页后登出
|
|
10
|
+
* 也必须清理上下文。业务应提供稳定的store getter,不捕获只在已卸载组件中更新的局部状态。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
type BridgeSessionIdentity = string | number | null | undefined;
|
|
14
|
+
interface AutomaticSession {
|
|
15
|
+
sessionKey: Ref<string | null>;
|
|
16
|
+
error: ShallowRef<unknown>;
|
|
17
|
+
}
|
|
18
|
+
/** 内部使用;不增加公共导入入口,不要求应用新建 session.ts。 */
|
|
19
|
+
declare function createAutomaticBridgeSession(getIdentity: () => BridgeSessionIdentity, namespace: string): AutomaticSession;
|
|
20
|
+
|
|
21
|
+
export { type BridgeSessionIdentity, createAutomaticBridgeSession };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clearAppContext
|
|
3
|
+
} from "./chunk-TSYLDY6H.js";
|
|
4
|
+
import "./chunk-OF2JCXTZ.js";
|
|
5
|
+
|
|
6
|
+
// src/bridge-session-auto.ts
|
|
7
|
+
import { effectScope, ref, shallowRef, watch } from "vue";
|
|
8
|
+
var PAGE_RECORDS = /* @__PURE__ */ Symbol.for("@fulgurjs/federation/automatic-sessions");
|
|
9
|
+
var sessions = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
function records() {
|
|
11
|
+
const page = globalThis;
|
|
12
|
+
return page[PAGE_RECORDS] ??= /* @__PURE__ */ new Map();
|
|
13
|
+
}
|
|
14
|
+
function normalize(value) {
|
|
15
|
+
if (value === null || value === void 0) return value;
|
|
16
|
+
if (typeof value !== "string" && typeof value !== "number" || typeof value === "number" && !Number.isFinite(value) || !String(value).trim()) {
|
|
17
|
+
throw new TypeError("session \u5FC5\u987B\u540C\u6B65\u8FD4\u56DE\u975E\u7A7A\u7528\u6237\u6807\u8BC6\uFF08string/number\uFF09\u3001null\uFF08\u5DF2\u9000\u51FA\uFF09\u6216 undefined\uFF08\u8EAB\u4EFD\u521D\u59CB\u5316\u4E2D\uFF09\uFF1B\u4E0D\u8981\u8FD4\u56DE token\u3001\u5BF9\u8C61\u6216 Promise\u3002");
|
|
18
|
+
}
|
|
19
|
+
return String(value);
|
|
20
|
+
}
|
|
21
|
+
function createAutomaticBridgeSession(getIdentity, namespace) {
|
|
22
|
+
const key = `${namespace}:auto`;
|
|
23
|
+
const cached = sessions.get(getIdentity)?.get(key);
|
|
24
|
+
if (cached) return cached;
|
|
25
|
+
const sessionKey = ref(null);
|
|
26
|
+
const error = shallowRef();
|
|
27
|
+
const state = { sessionKey, error };
|
|
28
|
+
const entries = sessions.get(getIdentity) ?? /* @__PURE__ */ new Map();
|
|
29
|
+
entries.set(key, state);
|
|
30
|
+
sessions.set(getIdentity, entries);
|
|
31
|
+
const read = () => {
|
|
32
|
+
const memory = records().get(key);
|
|
33
|
+
if (memory) return memory;
|
|
34
|
+
try {
|
|
35
|
+
const saved = JSON.parse(sessionStorage.getItem(key) ?? "null");
|
|
36
|
+
if (saved && typeof saved === "object" && "identity" in saved && "sessionKey" in saved && typeof saved.identity === "string" && typeof saved.sessionKey === "string" && saved.sessionKey) {
|
|
37
|
+
const record = { identity: saved.identity, sessionKey: saved.sessionKey };
|
|
38
|
+
records().set(key, record);
|
|
39
|
+
return record;
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const save = (record) => {
|
|
45
|
+
if (record) records().set(key, record);
|
|
46
|
+
else records().delete(key);
|
|
47
|
+
try {
|
|
48
|
+
if (record) sessionStorage.setItem(key, JSON.stringify(record));
|
|
49
|
+
else sessionStorage.removeItem(key);
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const clearOwnedContext = (record) => {
|
|
54
|
+
const context = globalThis.__FULGURJS_APP_CONFIG__;
|
|
55
|
+
if (record && context?.sessionKey === record.sessionKey) clearAppContext();
|
|
56
|
+
};
|
|
57
|
+
effectScope(true).run(() => watch(() => {
|
|
58
|
+
try {
|
|
59
|
+
return { identity: normalize(getIdentity()), error: void 0 };
|
|
60
|
+
} catch (cause) {
|
|
61
|
+
return { identity: void 0, error: cause ?? new Error("session getter \u629B\u51FA\u4E86\u7A7A\u9519\u8BEF\u503C\u3002") };
|
|
62
|
+
}
|
|
63
|
+
}, (snapshot) => {
|
|
64
|
+
const saved = read();
|
|
65
|
+
error.value = snapshot.error;
|
|
66
|
+
if (snapshot.identity === void 0) {
|
|
67
|
+
sessionKey.value = null;
|
|
68
|
+
clearOwnedContext(saved);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (snapshot.identity === null) {
|
|
72
|
+
save(void 0);
|
|
73
|
+
sessionKey.value = null;
|
|
74
|
+
clearOwnedContext(saved);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const record = saved?.identity === snapshot.identity ? saved : {
|
|
78
|
+
identity: snapshot.identity,
|
|
79
|
+
sessionKey: `s-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`
|
|
80
|
+
};
|
|
81
|
+
if (record !== saved) save(record);
|
|
82
|
+
sessionKey.value = record.sessionKey;
|
|
83
|
+
}, { immediate: true, flush: "sync" }));
|
|
84
|
+
return state;
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
createAutomaticBridgeSession
|
|
88
|
+
};
|
|
@@ -37,7 +37,7 @@ function releaseBridgeSession(sessionKey) {
|
|
|
37
37
|
if (n <= 1) activeBridgeSessions.delete(sessionKey);
|
|
38
38
|
else activeBridgeSessions.set(sessionKey, n - 1);
|
|
39
39
|
}
|
|
40
|
-
function resolveBridgeContext(spec, controlled, getContext) {
|
|
40
|
+
function resolveBridgeContext(spec, controlled, getContext, managedSession = false) {
|
|
41
41
|
if (getContext) {
|
|
42
42
|
let snapshot;
|
|
43
43
|
try {
|
|
@@ -48,6 +48,9 @@ function resolveBridgeContext(spec, controlled, getContext) {
|
|
|
48
48
|
if (snapshot === null || typeof snapshot !== "object" || typeof snapshot.then === "function") {
|
|
49
49
|
throw bridgeLifecycleError("getContext", spec, describeContextValue(snapshot));
|
|
50
50
|
}
|
|
51
|
+
if (managedSession && controlled !== void 0 && snapshot.sessionKey === void 0) {
|
|
52
|
+
snapshot = { ...snapshot, sessionKey: controlled };
|
|
53
|
+
}
|
|
51
54
|
if (controlled !== void 0 && snapshot.sessionKey !== controlled) {
|
|
52
55
|
throw bridgeSessionMismatchError(spec, controlled, snapshot.sessionKey, { reason: "getter-snapshot" });
|
|
53
56
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1804,6 +1804,26 @@ async function validateSource(file, source) {
|
|
|
1804
1804
|
const loader = /\.tsx$/.test(file) ? "tsx" : /\.jsx$/.test(file) ? "jsx" : /\.[cm]?ts$/.test(file) ? "ts" : "js";
|
|
1805
1805
|
await transform(source, { loader, sourcefile: file, format: "esm", target: "es2022", logLevel: "silent" });
|
|
1806
1806
|
}
|
|
1807
|
+
async function describeStartup(entry, application, source, framework) {
|
|
1808
|
+
const { transform } = requireHere("esbuild");
|
|
1809
|
+
const loader = /\.[jt]sx$/.test(entry) ? "tsx" : "ts";
|
|
1810
|
+
const output = await transform(source, { loader, sourcefile: entry, format: "esm", target: "es2022", logLevel: "silent" });
|
|
1811
|
+
await init;
|
|
1812
|
+
const [items] = parse(output.code);
|
|
1813
|
+
return {
|
|
1814
|
+
entry,
|
|
1815
|
+
application,
|
|
1816
|
+
imports: [...new Set(items.flatMap((item) => item.n ? [item.n] : []))],
|
|
1817
|
+
steps: [
|
|
1818
|
+
`\u53EA\u8BFB\u53D6 ${entry} \u4E0E\u4E0B\u5217\u5B9E\u9645\u5BFC\u5165\u7684\u88C5\u914D\u6A21\u5757\uFF0C\u5148\u4FDD\u7559\u539F\u6709\u8C03\u7528\u987A\u5E8F\u3001\u6837\u5F0F\u3001\u6743\u9650\u4E0E\u63D2\u4EF6\uFF1B\u4E0D\u6574\u6539\u5168\u4E1A\u52A1 TS\u3002`,
|
|
1819
|
+
`\u5728 ${application} \u9ED8\u8BA4\u5BFC\u51FA defineApplication \u5DE5\u5382\uFF1B\u5C06\u539F\u542F\u52A8\u51FD\u6570\u7684\u88C5\u914D\u642C\u5165\uFF0CApp/router/store \u6309\u5F53\u524D\u5B9E\u4F8B\u521B\u5EFA\uFF0C\u4E0D\u53E6\u5EFA bridge \u8F6C\u53D1\u58F3\u3002`,
|
|
1820
|
+
framework === "vue" ? "\u6309\u5DE5\u5382 mode \u9009\u62E9 memory/web history\uFF0C\u5B88\u536B\u5728\u8FD4\u56DE\u524D\u5B89\u88C5\uFF0C\u8FD4\u56DE { app, router }\uFF0C\u79FB\u9664\u5DE5\u5382\u5185 app.mount/app.use(router)\uFF1B\u4F7F\u7528 URL \u540C\u6B65\u65F6\u58F0\u660E { routing: true }\u3002" : "\u5DE5\u5382\u8FD4\u56DE JSX \u6216 { element, dispose }\uFF0C\u4FDD\u7559\u539F Provider\uFF1B\u72EC\u7ACB\u8FD0\u884C\u4F7F\u7528 browser router\uFF0C\u6865\u63A5\u4F7F\u7528\u53D7\u63A7 memory router\u3002",
|
|
1821
|
+
`\u5C06 ${entry} \u7CBE\u7B80\u4E3A\u5BFC\u5165\u8BE5\u5DE5\u5382\u5E76\u8C03\u7528 application.start(\u539F\u6302\u8F7D\u9009\u62E9\u5668)\uFF1B\u5148\u786E\u8BA4\u539F\u88C5\u914D\u5B8C\u6574\u8FC1\u5165\uFF0C\u518D\u5220\u9664\u65E7\u542F\u52A8\u4F53\u3002`,
|
|
1822
|
+
`\u91CD\u65B0\u6267\u884C\u539F\u8BA1\u5212\u5E76\u8FFD\u52A0 --application ${application}\uFF1B\u5DF2\u6709\u914D\u7F6E\u4E0D\u8986\u76D6\uFF0C\u6838\u5BF9 ./bridge \u662F\u5426\u76F4\u63A5\u6307\u5411\u8FD9\u4E00\u4E2A\u6587\u4EF6\u3002`,
|
|
1823
|
+
"\u6309\u201C\u5DF2\u6709\u5B8C\u6574\u5E94\u7528\u9996\u6B21\u63A5\u5165\u201D\u6307\u5357\u4F9D\u6B21\u786E\u8BA4\u72EC\u7ACB\u542F\u52A8\u3001\u6865\u63A5\u9996\u5C4F\u3001\u771F\u5B9E\u6570\u636E\u3001\u5BFC\u822A\u3001\u91CD\u8FDB\uFF1B\u9996\u6B21\u63A5\u901A\u4E0E\u751F\u4EA7\u4EA4\u4ED8\u5206\u5F00\u8BB0\u5F55\uFF0C\u4E0D\u80FD\u628A\u6784\u5EFA\u5F53\u9875\u9762\u901A\u8FC7\u3002"
|
|
1824
|
+
]
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1807
1827
|
function rejectSymlink(file, label) {
|
|
1808
1828
|
try {
|
|
1809
1829
|
if (fs2.lstatSync(file).isSymbolicLink()) throw new Error(`\u4E0D\u6539\u5199\u7B26\u53F7\u94FE\u63A5\uFF1A${label}`);
|
|
@@ -2011,7 +2031,7 @@ import fulgurjsConfig from './fulgurjs.config'
|
|
|
2011
2031
|
await validateSource(file, result);
|
|
2012
2032
|
return result;
|
|
2013
2033
|
}
|
|
2014
|
-
async function applicationFromEntry(file, source, framework) {
|
|
2034
|
+
async function applicationFromEntry(file, source, framework, appFile) {
|
|
2015
2035
|
await validateSource(file, source);
|
|
2016
2036
|
await init;
|
|
2017
2037
|
const header2 = source.match(/^\s*(?:(?:\/\/[^\n]*(?:\n|$)|\/\*[\s\S]*?\*\/)\s*)*/)?.[0] ?? "";
|
|
@@ -2033,7 +2053,14 @@ async function applicationFromEntry(file, source, framework) {
|
|
|
2033
2053
|
const spec = items[0].n;
|
|
2034
2054
|
if (/router|pinia|vuex|redux|zustand/i.test(spec)) throw new Error("\u5165\u53E3\u4F9D\u8D56\u4E1A\u52A1\u8DEF\u7531\u6216\u72B6\u6001\uFF1B\u6309 existing-apps \u6307\u5357\u5C06\u5B83\u4EEC\u5728\u5DE5\u5382\u5185\u6309\u5B9E\u4F8B\u521B\u5EFA\uFF0C\u4E0D\u81EA\u52A8\u6539\u5199");
|
|
2035
2055
|
importStatements.push({ spec, code: statement });
|
|
2036
|
-
if (spec !== "react-dom/client")
|
|
2056
|
+
if (spec !== "react-dom/client") {
|
|
2057
|
+
const edit = new MagicString(statement);
|
|
2058
|
+
if (spec.startsWith(".")) {
|
|
2059
|
+
const rebased = path2.posix.relative(path2.posix.dirname(appFile), path2.posix.join(path2.posix.dirname(file), spec));
|
|
2060
|
+
edit.overwrite(items[0].s, items[0].e, rebased.startsWith(".") ? rebased : "./" + rebased);
|
|
2061
|
+
}
|
|
2062
|
+
declarations.push(edit.toString());
|
|
2063
|
+
}
|
|
2037
2064
|
body = body.slice(match[0].length);
|
|
2038
2065
|
}
|
|
2039
2066
|
body = body.trim();
|
|
@@ -2061,9 +2088,10 @@ import { defineApplication } from '@fulgurjs/federation/${framework}'
|
|
|
2061
2088
|
|
|
2062
2089
|
export default defineApplication(() => ${expression})
|
|
2063
2090
|
`;
|
|
2091
|
+
const relativeApp = path2.posix.relative(path2.posix.dirname(file), appFile).replace(/\.tsx?$/, "");
|
|
2064
2092
|
const main2 = `${OWNER}
|
|
2065
|
-
${header2}// \u72EC\u7ACB\u5165\u53E3\
|
|
2066
|
-
import application from './
|
|
2093
|
+
${header2}// \u72EC\u7ACB\u5165\u53E3\u53EA\u8D1F\u8D23\u542F\u52A8\uFF1B\u72EC\u7ACB\u4E0E\u5D4C\u5165\u8FD0\u884C\u5171\u7528 fulgurjs/exposes/ \u4E2D\u7684\u540C\u4E00\u4EFD\u88C5\u914D\u3002
|
|
2094
|
+
import application from '${relativeApp.startsWith(".") ? relativeApp : "./" + relativeApp}'
|
|
2067
2095
|
void application.start(${JSON.stringify(target)}).catch(console.error)
|
|
2068
2096
|
`;
|
|
2069
2097
|
await validateSource(framework === "react" ? "application.tsx" : "application.ts", application);
|
|
@@ -2121,26 +2149,37 @@ async function planIntegration(input) {
|
|
|
2121
2149
|
}
|
|
2122
2150
|
const appExt = framework === "react" ? "tsx" : "ts";
|
|
2123
2151
|
let exposes = input.exposes ?? {};
|
|
2152
|
+
if (input.application && (plan.kind !== "app" || plan.role === "consumer")) task("--application", "\u4EC5\u7528\u4E8E --kind app \u4E14\u89D2\u8272\u4E3A provider/dual\uFF1B\u7EAF\u5BBF\u4E3B\u4E0D\u9700\u8981\u66B4\u9732\u5E94\u7528\u88C5\u914D\u3002");
|
|
2124
2153
|
if (plan.kind === "app" && plan.role !== "consumer") {
|
|
2125
|
-
const appFile = `src/application.${appExt}`;
|
|
2154
|
+
const appFile = input.application ? safe(input.application) : `src/fulgurjs/exposes/application.${appExt}`;
|
|
2126
2155
|
const existing = read(appFile);
|
|
2127
2156
|
if (existing) {
|
|
2128
|
-
|
|
2129
|
-
|
|
2157
|
+
try {
|
|
2158
|
+
await validateSource(appFile, existing);
|
|
2159
|
+
if (!/export\s+default\s+defineApplication(?:<[^;]+?>)?\s*\(/.test(existing)) throw new Error("\u65E0\u6CD5\u786E\u8BA4\u9ED8\u8BA4\u5BFC\u51FA\u7684 defineApplication \u5DE5\u5382\uFF1B\u4E0D\u6267\u884C\u4E1A\u52A1\u6A21\u5757\uFF0C\u4E0D\u6309\u6587\u4EF6\u540D\u731C\u5951\u7EA6");
|
|
2130
2160
|
exposes = { ...exposes, "./bridge": "./" + appFile };
|
|
2131
|
-
plan.evidence.push(`${appFile}\uFF1A\u4FDD\u7559\
|
|
2161
|
+
plan.evidence.push(`${appFile}\uFF1A\u590D\u7528\u5DF2\u6709\u7EDF\u4E00\u88C5\u914D\uFF0C\u4FDD\u7559\u539F\u5185\u5BB9\uFF0C\u4E0D\u751F\u6210\u8F6C\u53D1\u58F3`);
|
|
2162
|
+
task(input.entry ?? "src/main.ts(x)", `\u6838\u5BF9\u72EC\u7ACB\u5165\u53E3\u53EA\u8C03\u7528 ${appFile} \u7684 application.start\uFF1B--application \u4E0D\u5220\u9664\u6216\u8986\u76D6\u539F\u4E1A\u52A1\u542F\u52A8\u4F53\u3002`, false);
|
|
2163
|
+
} catch (error) {
|
|
2164
|
+
task(appFile, String(error.message));
|
|
2132
2165
|
}
|
|
2166
|
+
} else if (input.application) {
|
|
2167
|
+
task(appFile, "--application \u5FC5\u987B\u6307\u5411\u5B9E\u9645\u5B58\u5728\u7684\u88C5\u914D\u6587\u4EF6\uFF1B\u5148\u6309\u6574\u7406\u6E05\u5355\u8FC1\u5165\u539F\u542F\u52A8\u903B\u8F91\uFF0C\u4E0D\u751F\u6210\u5047\u4E1A\u52A1\u5DE5\u5382\u3002");
|
|
2133
2168
|
} else {
|
|
2134
2169
|
const candidates = input.entry ? [safe(input.entry)] : [`src/main.${framework === "react" ? "tsx" : "ts"}`, `src/main.${framework === "react" ? "jsx" : "js"}`].filter((f) => read(f) !== null);
|
|
2135
2170
|
if (candidates.length !== 1 || read(candidates[0]) === null) task("src/main", "\u65E0\u6CD5\u5B9A\u4F4D\u552F\u4E00\u542F\u52A8\u5165\u53E3\uFF0C\u8BF7\u663E\u5F0F\u6307\u5B9A --entry <\u5F53\u524D\u5E94\u7528\u5185\u8DEF\u5F84>");
|
|
2136
2171
|
else {
|
|
2137
2172
|
try {
|
|
2138
|
-
const entry = candidates[0], result = await applicationFromEntry(entry, read(entry), framework);
|
|
2173
|
+
const entry = candidates[0], result = await applicationFromEntry(entry, read(entry), framework, appFile);
|
|
2139
2174
|
add(appFile, result.application, "\u5C06\u53EF\u8BC1\u660E\u7684\u6700\u5C0F\u542F\u52A8\u903B\u8F91\u63D0\u53D6\u4E3A\u72EC\u7ACB/\u6865\u63A5\u5171\u7528\u5DE5\u5382");
|
|
2140
2175
|
add(entry, result.main, "\u72EC\u7ACB\u5165\u53E3\u6539\u4E3A application.start\uFF1B\u6302\u8F7D\u8D23\u4EFB\u4EA4\u7ED9\u63D2\u4EF6", true);
|
|
2141
2176
|
exposes = { ...exposes, "./bridge": "./" + appFile };
|
|
2142
2177
|
} catch (error) {
|
|
2143
|
-
|
|
2178
|
+
try {
|
|
2179
|
+
plan.startup = await describeStartup(candidates[0], appFile, read(candidates[0]), framework);
|
|
2180
|
+
} catch {
|
|
2181
|
+
}
|
|
2182
|
+
task(candidates[0], `${error.message}\u3002\u5B8C\u6574\u8DEF\u5F84\u89C1 docs/zh/guide/first-integration.md\uFF1B\u4E0B\u65B9\u9010\u6B65\u6574\u7406\u6E05\u5355\u53EA\u8FC1\u79FB\u63A5\u7EBF\uFF0C\u4E0D\u8981\u6C42\u5168\u9879\u76EE TS \u6E05\u96F6\u3002`);
|
|
2144
2183
|
}
|
|
2145
2184
|
}
|
|
2146
2185
|
}
|
|
@@ -2186,7 +2225,7 @@ export default ${JSON.stringify(body, null, 2)} satisfies FederationOptions
|
|
|
2186
2225
|
}
|
|
2187
2226
|
if (plan.kind === "app" && plan.role !== "provider") {
|
|
2188
2227
|
const remote = remoteEntries[0]?.[0];
|
|
2189
|
-
if (remote) add(`src/fulgurjs/RemoteApplication.${framework === "react" ? "tsx" : "vue"}`, hostView(framework, remote), "\
|
|
2228
|
+
if (remote) add(`src/fulgurjs/host/RemoteApplication.${framework === "react" ? "tsx" : "vue"}`, hostView(framework, remote), "\u5728 host/ \u96C6\u4E2D\u751F\u6210\u6302\u8F7D\u89C6\u56FE\uFF1B\u8DEF\u7531\u548C\u767B\u5F55\u4E0A\u4E0B\u6587\u7531\u5E94\u7528\u660E\u786E\u51B3\u5B9A");
|
|
2190
2229
|
task("\u5BBF\u4E3B\u8DEF\u7531", "\u5C06 RemoteApplication \u89C6\u56FE\u52A0\u5165\u5DF2\u6709\u9875\u9762/\u8DEF\u7531\u3002\u542F\u7528 URL \u540C\u6B65\u65F6\uFF0C\u6309\u6307\u5357\u7ED1\u5B9A\u5BBF\u4E3B\u5BFC\u822A\u7AEF\u53E3\u4E0E\u4E00\u4E2A\u9759\u6001\u6302\u8F7D\u524D\u7F00\uFF1B\u4E0D\u91CD\u590D\u767B\u8BB0\u5B50\u5E94\u7528\u83DC\u5355\u3002", false);
|
|
2191
2230
|
task("\u4F1A\u8BDD\u4E0E\u4E1A\u52A1\u4E0A\u4E0B\u6587", "\u6709\u767B\u5F55\u9700\u6C42\u65F6\u660E\u786E token getter/sessionKey\u3001\u6743\u9650\u4E0E\u4E3B\u9898\u5F52\u5C5E\uFF1B\u6CA1\u6709\u9700\u6C42\u4E0D\u589E\u52A0\u6587\u4EF6\u3002\u5DE5\u5177\u4E0D\u731C\u51ED\u636E\uFF0C\u4E5F\u4E0D\u590D\u5236\u6574\u4E2A\u4E1A\u52A1 app \u7684\u72B6\u6001\u3002", false);
|
|
2192
2231
|
} else if (plan.role !== "provider") {
|
|
@@ -2301,6 +2340,15 @@ function rollbackIntegration(cwd) {
|
|
|
2301
2340
|
}
|
|
2302
2341
|
function formatIntegrationPlan(plan) {
|
|
2303
2342
|
const lines = ["[fulgurjs:init] \u63A5\u5165\u9884\u89C8\uFF08\u9ED8\u8BA4\u4E0D\u5199\u5165\u3001\u4E0D\u5B89\u88C5\u4F9D\u8D56\u3001\u4E0D\u6267\u884C\u4E1A\u52A1\u4EE3\u7801\uFF09", ...plan.evidence];
|
|
2343
|
+
if (plan.startup) {
|
|
2344
|
+
lines.push(
|
|
2345
|
+
`
|
|
2346
|
+
\u542F\u52A8\u903B\u8F91\u6574\u7406\uFF1A${plan.startup.entry} \u2192 ${plan.startup.application}`,
|
|
2347
|
+
"\u5165\u53E3\u5B9E\u9645\u5BFC\u5165\uFF08\u4E0D\u4EE3\u8868\u8FD9\u4E9B\u4F9D\u8D56\u90FD\u5E94 shared\uFF09\uFF1A",
|
|
2348
|
+
...plan.startup.imports.map((item) => ` ${item}`),
|
|
2349
|
+
...plan.startup.steps.map((step, index) => `${index + 1}. ${step}`)
|
|
2350
|
+
);
|
|
2351
|
+
}
|
|
2304
2352
|
for (const edit of plan.edits) {
|
|
2305
2353
|
lines.push(`
|
|
2306
2354
|
--- ${edit.before === null ? "/dev/null" : edit.file}
|
|
@@ -3139,7 +3187,7 @@ var RUNTIME_VERSION;
|
|
|
3139
3187
|
var init_version = __esm({
|
|
3140
3188
|
"src/version.ts"() {
|
|
3141
3189
|
"use strict";
|
|
3142
|
-
RUNTIME_VERSION = "6.
|
|
3190
|
+
RUNTIME_VERSION = "6.12.0";
|
|
3143
3191
|
}
|
|
3144
3192
|
});
|
|
3145
3193
|
|
|
@@ -5892,9 +5940,12 @@ var HELP = `fulgurjs \u2014 Vite Module Federation CLI (@fulgurjs/federation)
|
|
|
5892
5940
|
\u5DF2\u6709\u9879\u76EE\uFF08\u5355\u9879\u76EE fulgurjs.config.ts \u5728\u5E94\u7528\u6839\u76EE\u5F55\uFF1B\u547D\u4EE4\u9ED8\u8BA4\u8BFB ./fulgurjs.config.ts\uFF09\uFF1A
|
|
5893
5941
|
fulgurjs init --plan [--kind component|app] [--role consumer|provider|dual]
|
|
5894
5942
|
[--remote \u540D\u79F0=http://\u5F00\u53D1\u5730\u5740] [--expose ./\u952E=./\u6E90\u6587\u4EF6]
|
|
5895
|
-
[--name \u5BB9\u5668\u540D] [--entry src/main.ts] [--
|
|
5943
|
+
[--name \u5BB9\u5668\u540D] [--entry src/main.ts] [--application src/fulgurjs/exposes/application.ts]
|
|
5944
|
+
[--framework vue|react] [--json]
|
|
5896
5945
|
\u53EA\u626B\u63CF\u5E76\u9884\u89C8\u5B8C\u6574\u5DEE\u5F02\u4E0E\u4EBA\u5DE5\u5F85\u529E\uFF1B\u53EF\u91CD\u590D remote/expose\u3002
|
|
5897
5946
|
--kind \u9ED8\u8BA4 component\uFF1Bapp \u652F\u6301\u7B80\u5355\u5165\u53E3\u63D0\u53D6\u4E0E\u5BBF\u4E3B\u89C6\u56FE\u3002
|
|
5947
|
+
\u5DF2\u6709\u590D\u6742\u88C5\u914D\u7528 --application \u590D\u7528\u771F\u5B9E\u9ED8\u8BA4\u5BFC\u51FA\uFF1B
|
|
5948
|
+
\u65E0\u6CD5\u81EA\u52A8\u63D0\u53D6\u65F6\u8F93\u51FA\u5F53\u524D\u5165\u53E3\u5BFC\u5165\u4E0E\u9010\u6B65\u6574\u7406\u6E05\u5355\uFF0C\u4E0D\u731C\u4E1A\u52A1\u3002
|
|
5898
5949
|
--write \u663E\u5F0F\u5E94\u7528\uFF1B\u963B\u65AD\u9879\u5B58\u5728\u65F6\u6574\u6279\u4E0D\u5199\uFF0C\u4E0D\u8986\u76D6\u5DF2\u6709\u914D\u7F6E\u3002
|
|
5899
5950
|
fulgurjs init --rollback \u6062\u590D\u88AB\u4E2D\u65AD\u7684\u8BA1\u5212\u5199\u5165\uFF1B\u6709\u540E\u7EED\u4EBA\u5DE5\u7F16\u8F91\u65F6\u62D2\u7EDD\u8986\u76D6\u3002
|
|
5900
5951
|
fulgurjs init [--out <\u8DEF\u5F84>] [--framework vue|react] [--role consumer|provider|dual] [--force]
|
|
@@ -5982,7 +6033,7 @@ async function main() {
|
|
|
5982
6033
|
if (has("--plan") || has("--write")) {
|
|
5983
6034
|
try {
|
|
5984
6035
|
if (has("--config") || has("--out") || has("--force")) throw new Error("\u63A5\u5165\u8BA1\u5212\u4E0D\u80FD\u540C\u65F6\u4F7F\u7528 --config/--out/--force\uFF1B\u5DF2\u6709\u914D\u7F6E\u8BF7\u5355\u72EC\u8FD0\u884C doctor --config \u68C0\u67E5\u3002");
|
|
5985
|
-
const values = ["--kind", "--role", "--framework", "--name", "--entry", "--remote", "--expose"];
|
|
6036
|
+
const values = ["--kind", "--role", "--framework", "--name", "--entry", "--application", "--remote", "--expose"];
|
|
5986
6037
|
for (let i = 1; i < argv.length; i++) {
|
|
5987
6038
|
if (["--plan", "--write", "--json"].includes(argv[i])) continue;
|
|
5988
6039
|
if (!values.includes(argv[i])) throw new Error(`\u672A\u77E5\u63A5\u5165\u8BA1\u5212\u53C2\u6570\uFF1A${argv[i]}`);
|
|
@@ -6006,7 +6057,7 @@ async function main() {
|
|
|
6006
6057
|
return result2;
|
|
6007
6058
|
};
|
|
6008
6059
|
const { planIntegration: planIntegration2, formatIntegrationPlan: formatIntegrationPlan2, applyIntegration: applyIntegration2 } = await Promise.resolve().then(() => (init_init_plan(), init_plan_exports));
|
|
6009
|
-
const plan = await planIntegration2({ cwd: process.cwd(), kind, role, framework: framework2, name: argOf("--name"), entry: argOf("--entry"), remotes: pairs("--remote"), exposes: pairs("--expose") });
|
|
6060
|
+
const plan = await planIntegration2({ cwd: process.cwd(), kind, role, framework: framework2, name: argOf("--name"), entry: argOf("--entry"), application: argOf("--application"), remotes: pairs("--remote"), exposes: pairs("--expose") });
|
|
6010
6061
|
const blocked = plan.tasks.some((task) => task.blocking);
|
|
6011
6062
|
if (has("--write") && !blocked) applyIntegration2(plan);
|
|
6012
6063
|
const written = has("--write") && !blocked;
|
|
@@ -6020,7 +6071,7 @@ async function main() {
|
|
|
6020
6071
|
return 1;
|
|
6021
6072
|
}
|
|
6022
6073
|
}
|
|
6023
|
-
if (["--kind", "--remote", "--expose", "--entry", "--name"].some(has)) {
|
|
6074
|
+
if (["--kind", "--remote", "--expose", "--entry", "--application", "--name"].some(has)) {
|
|
6024
6075
|
console.error("[fulgurjs:init] \u63A5\u5165\u8BA1\u5212\u53C2\u6570\u9700\u8981 --plan\uFF08\u9884\u89C8\uFF09\u6216 --write\uFF08\u663E\u5F0F\u5199\u5165\uFF09\u3002");
|
|
6025
6076
|
return 2;
|
|
6026
6077
|
}
|