@axewo/fin-micro 2.0.0 → 2.0.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.
Files changed (59) hide show
  1. package/README.md +82 -3
  2. package/cli/index.mjs +22 -6
  3. package/dist/core.cjs +1 -1
  4. package/dist/core.mjs +131 -127
  5. package/dist/layout.cjs +1 -0
  6. package/dist/layout.css +1 -0
  7. package/dist/layout.mjs +719 -0
  8. package/dist/types/layout/HostShell.vue.d.ts +528 -0
  9. package/dist/types/layout/ShellHeader.vue.d.ts +46 -0
  10. package/dist/types/layout/ShellMenu.vue.d.ts +12 -0
  11. package/dist/types/layout/ShellTabs.vue.d.ts +23 -0
  12. package/dist/types/layout/StandaloneMenuItem.vue.d.ts +11 -0
  13. package/dist/types/layout/StandaloneShell.vue.d.ts +40 -0
  14. package/dist/types/layout/index.d.ts +5 -0
  15. package/dist/types/layout/types.d.ts +65 -0
  16. package/dist/types/sdk/index.d.ts +2 -0
  17. package/dist/types/watermark/FinWatermark.vue.d.ts +16 -0
  18. package/dist/types/watermark/config.d.ts +36 -0
  19. package/dist/types/watermark/index.d.ts +4 -0
  20. package/dist/watermark.cjs +2 -0
  21. package/dist/watermark.mjs +119 -0
  22. package/package.json +28 -3
  23. package/scaffold/base/index.html +2 -1
  24. package/scaffold/base/pnpm-workspace.yaml +6 -0
  25. package/scaffold/base/src/router/demo.ts +1 -1
  26. package/scaffold/base/src/utils/errorUtils.ts +19 -2
  27. package/scaffold/base/src/utils/watermarkConfig.ts +18 -0
  28. package/scaffold/base/src/views/{DemoView.vue → demo/index.vue} +1 -1
  29. package/scaffold/host/src/layout/HostMenu.vue +10 -2
  30. package/scaffold/host/src/layout/HostTabs.vue +55 -5
  31. package/scaffold/host/src/layout/HostWorkspace.vue +12 -2
  32. package/scaffold/host/src/localPages.ts +2 -2
  33. package/scaffold/host/src/platform.ts +12 -6
  34. package/scaffold/host/src/router/index.ts +3 -3
  35. package/scaffold/host/src/styles/shell.css +16 -1
  36. package/scaffold/host/src/views/{LoginView.vue → login/components/LoginForm.vue} +7 -12
  37. package/scaffold/host/src/views/{LoginRoute.vue → login/index.vue} +5 -5
  38. package/scaffold/host/src/views/{ProfileView.vue → profile/index.vue} +1 -1
  39. package/scaffold/host/src/views/{WorkspaceRoute.vue → workspace/index.vue} +3 -3
  40. package/scaffold/layouts/standard/host/src/layout/HostLayout.vue +116 -0
  41. package/scaffold/layouts/standard/host/src/styles/shell.css +168 -0
  42. package/scaffold/layouts/standard/vue/src/layout/StandaloneLayout.vue +26 -0
  43. package/scaffold/vue/src/App.vue +13 -7
  44. package/scaffold/vue/src/bootstrap.ts +7 -2
  45. package/scaffold/vue/src/layout/Header.vue +15 -0
  46. package/scaffold/vue/src/layout/Sidebar.vue +21 -0
  47. package/scaffold/vue/src/layout/SidebarItem.vue +21 -0
  48. package/scaffold/vue/src/layout/StandaloneLayout.vue +34 -0
  49. package/scaffold/vue/src/router/index.ts +8 -5
  50. package/scaffold/vue/src/router/menu.ts +38 -0
  51. package/scaffold/vue/src/views/demo/configs/table.ts +24 -0
  52. package/scaffold/vue/src/views/demo/hooks/useRecordNavigation.ts +32 -0
  53. package/scaffold/vue/src/views/demo/index.vue +17 -0
  54. package/scaffold/vue/src/views/{DetailView.vue → demo/modules/detail/index.vue} +2 -2
  55. package/scaffold/vue/src/views/demo/types.ts +5 -0
  56. package/scaffold/vue/src/views/ListView.vue +0 -55
  57. /package/scaffold/host/src/views/{HomeView.vue → home/index.vue} +0 -0
  58. /package/scaffold/host/src/views/{NotFoundView.vue → not-found/index.vue} +0 -0
  59. /package/scaffold/vue/src/views/{NotFoundView.vue → not-found/index.vue} +0 -0
package/dist/core.mjs CHANGED
@@ -1,34 +1,38 @@
1
- import { createNotificationBus as We, NavigationError as p, HostCallError as N } from "./sdk.mjs";
2
- function qe(Re, x = {}) {
1
+ import { createNotificationBus as We, NavigationError as p, HostCallError as z } from "./sdk.mjs";
2
+ function Ze(Ne, R = {}) {
3
3
  var Ae;
4
- const Z = /* @__PURE__ */ new Map(), pe = /* @__PURE__ */ new Map(), z = (e) => typeof e == "string" && !!e.trim() && !/[\u0000-\u001f\u007f]/.test(e), de = (e) => z(e) && e.startsWith("/") && !e.startsWith("//") && !e.includes("\\"), we = (e) => e.split(/[?#]/, 1)[0];
5
- for (const e of Re) {
4
+ const X = /* @__PURE__ */ new Map(), pe = /* @__PURE__ */ new Map(), x = (e) => typeof e == "string" && !!e.trim() && !/[\u0000-\u001f\u007f]/.test(e), de = (e) => x(e) && e.startsWith("/") && !e.startsWith("//") && !e.includes("\\"), we = (e) => e.split(/[?#]/, 1)[0];
5
+ for (const e of Ne) {
6
6
  let s = function(r) {
7
7
  if (!Array.isArray(r)) throw new Error("menus 必须为数组");
8
8
  return Object.freeze(
9
- r.map((i) => {
10
- if (!i || !z(i.menuId) || !z(i.name) || c.has(i.menuId))
9
+ r.map((a) => {
10
+ if (!a || !x(a.menuId) || !x(a.name) || c.has(a.menuId))
11
11
  throw new Error("菜单标识/名称无效或菜单标识重复");
12
- if (c.add(i.menuId), i.children !== void 0) {
13
- if (i.target !== void 0 || !Array.isArray(i.children) || !i.children.length)
12
+ if (c.add(a.menuId), a.icon !== void 0 && (typeof a.icon != "string" || !/^[A-Za-z][A-Za-z0-9-]{0,63}$/.test(a.icon)))
13
+ throw new Error("菜单图标标识无效");
14
+ if (a.children !== void 0) {
15
+ if (a.target !== void 0 || !Array.isArray(a.children) || !a.children.length)
14
16
  throw new Error("菜单分组需要非空 children 且不能配置 target");
15
17
  return Object.freeze({
16
- menuId: i.menuId,
17
- name: i.name,
18
- children: s(i.children)
18
+ menuId: a.menuId,
19
+ name: a.name,
20
+ ...a.icon === void 0 ? {} : { icon: a.icon },
21
+ children: s(a.children)
19
22
  });
20
23
  }
21
- if (!i.target || !z(i.target.tabId) || !de(i.target.route))
24
+ if (!a.target || !x(a.target.tabId) || !de(a.target.route))
22
25
  throw new Error("菜单叶节点需要有效 target");
23
- return h.add(i.menuId), b.push({ pathPrefix: we(i.target.route), menuId: i.menuId }), Object.freeze({
24
- menuId: i.menuId,
25
- name: i.name,
26
- target: Object.freeze({ tabId: i.target.tabId, route: i.target.route })
26
+ return h.add(a.menuId), b.push({ pathPrefix: we(a.target.route), menuId: a.menuId }), Object.freeze({
27
+ menuId: a.menuId,
28
+ name: a.name,
29
+ ...a.icon === void 0 ? {} : { icon: a.icon },
30
+ target: Object.freeze({ tabId: a.target.tabId, route: a.target.route })
27
31
  });
28
32
  })
29
33
  );
30
34
  };
31
- if (Z.has(e.appId)) throw new Error(`重复的 appId: ${e.appId}`);
35
+ if (X.has(e.appId)) throw new Error(`重复的 appId: ${e.appId}`);
32
36
  if (e.kind === "local") {
33
37
  if (e.entry !== void 0) throw new Error("本地应用不能配置 entry");
34
38
  } else {
@@ -53,8 +57,8 @@ function qe(Re, x = {}) {
53
57
  }
54
58
  pe.set(e.appId, {
55
59
  leaves: h,
56
- routes: b.sort((r, i) => i.pathPrefix.length - r.pathPrefix.length)
57
- }), Z.set(
60
+ routes: b.sort((r, a) => a.pathPrefix.length - r.pathPrefix.length)
61
+ }), X.set(
58
62
  e.appId,
59
63
  Object.freeze({
60
64
  appId: e.appId,
@@ -65,15 +69,15 @@ function qe(Re, x = {}) {
65
69
  })
66
70
  );
67
71
  }
68
- const ae = We(), xe = Object.freeze({ source: "host" }), le = {
72
+ const ae = We(), Re = Object.freeze({ source: "host" }), le = {
69
73
  on(e, s) {
70
- return ae.on(e, ({ payload: c, metadata: h }) => q(() => s(c, h)));
74
+ return ae.on(e, ({ payload: c, metadata: h }) => Z(() => s(c, h)));
71
75
  },
72
76
  emit(e, s) {
73
- ae.emit(e, { payload: s, metadata: xe });
77
+ ae.emit(e, { payload: s, metadata: Re });
74
78
  },
75
79
  clear: () => ae.clear()
76
- }, ie = x.callTimeoutMs ?? 3e4;
80
+ }, ie = R.callTimeoutMs ?? 3e4;
77
81
  if (!Number.isFinite(ie) || ie <= 0 || ie > 2147483647)
78
82
  throw new Error("callTimeoutMs 必须为不超过2147483647的正有限数");
79
83
  const K = /* @__PURE__ */ new Set();
@@ -87,18 +91,18 @@ function qe(Re, x = {}) {
87
91
  revision: s
88
92
  });
89
93
  }
90
- let ee = ke(x.session ?? { authenticated: !1, permissions: [] }, 0);
91
- function ze(e) {
94
+ let ee = ke(R.session ?? { authenticated: !1, permissions: [] }, 0);
95
+ function xe(e) {
92
96
  j(), ee = ke(e, ee.revision + 1);
93
97
  const s = ee;
94
98
  for (const c of [...K]) {
95
99
  if (s !== ee) break;
96
- K.has(c) && q(() => c(s));
100
+ K.has(c) && Z(() => c(s));
97
101
  }
98
102
  return s;
99
103
  }
100
104
  const te = /* @__PURE__ */ new Set(), re = /* @__PURE__ */ new Map(), ve = new Map(
101
- Object.entries(x.capabilities ?? {}).filter(([, e]) => e !== void 0).map(([e, s]) => {
105
+ Object.entries(R.capabilities ?? {}).filter(([, e]) => e !== void 0).map(([e, s]) => {
102
106
  const c = s;
103
107
  return [
104
108
  e,
@@ -110,10 +114,10 @@ function qe(Re, x = {}) {
110
114
  const oe = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Map(), _e = (e) => {
111
115
  var s;
112
116
  try {
113
- (s = x.onError) == null || s.call(x, e);
117
+ (s = R.onError) == null || s.call(R, e);
114
118
  } catch {
115
119
  }
116
- }, q = (e) => {
120
+ }, Z = (e) => {
117
121
  try {
118
122
  e();
119
123
  } catch (s) {
@@ -124,15 +128,15 @@ function qe(Re, x = {}) {
124
128
  }, ce = () => ({ tabs: [...d.tabs], activeTabId: d.activeTabId }), ne = () => {
125
129
  W++;
126
130
  for (const e of [...te])
127
- te.has(e) && q(() => e(ce()));
131
+ te.has(e) && Z(() => e(ce()));
128
132
  };
129
133
  function me(e) {
130
134
  return j(), te.add(e), () => {
131
135
  te.delete(e);
132
136
  };
133
137
  }
134
- const ue = x.canNavigate, ge = x.canOpen;
135
- function Y(e) {
138
+ const ue = R.canNavigate, ge = R.canOpen;
139
+ function q(e) {
136
140
  if (!ge) return;
137
141
  const s = Object.freeze({
138
142
  appId: e.appId,
@@ -152,10 +156,10 @@ function qe(Re, x = {}) {
152
156
  }
153
157
  function he(e, s = !1) {
154
158
  var o;
155
- if (j(), !e || !z(e.title) || e.title.length > 500)
159
+ if (j(), !e || !x(e.title) || e.title.length > 500)
156
160
  throw new Error("页签标题无效");
157
- if (!Z.has(e.appId)) throw new Error(`未知子应用: ${e.appId}`);
158
- if (!z(e.tabId) || !de(e.route))
161
+ if (!X.has(e.appId)) throw new Error(`未知子应用: ${e.appId}`);
162
+ if (!x(e.tabId) || !de(e.route))
159
163
  throw new Error("需要 tabId 与应用内绝对路由");
160
164
  const c = pe.get(e.appId);
161
165
  if (e.activeMenuId !== void 0 && !c.leaves.has(e.activeMenuId))
@@ -166,7 +170,7 @@ function qe(Re, x = {}) {
166
170
  let u = d.tabs.find((t) => t.tabId === e.tabId);
167
171
  if (u && (u.appId !== e.appId || u.route !== e.route && !s))
168
172
  throw new Error("tabId 已绑定到其他页面");
169
- return u && u.route !== e.route && (u = void 0), Y(u ?? { ...e, activeMenuId: b }), u || (u = Object.freeze({
173
+ return u && u.route !== e.route && (u = void 0), q(u ?? { ...e, activeMenuId: b }), u || (u = Object.freeze({
170
174
  appId: e.appId,
171
175
  tabId: e.tabId,
172
176
  title: e.title,
@@ -195,7 +199,7 @@ function qe(Re, x = {}) {
195
199
  function $e(e) {
196
200
  j();
197
201
  const s = d.tabs.find((c) => c.tabId === e);
198
- return s ? (Y(s), d = { ...d, activeTabId: e }, ne(), !0) : !1;
202
+ return s ? (q(s), d = { ...d, activeTabId: e }, ne(), !0) : !1;
199
203
  }
200
204
  function Ce(e, s) {
201
205
  var u;
@@ -209,20 +213,20 @@ function qe(Re, x = {}) {
209
213
  tabs: b,
210
214
  activeTabId: d.activeTabId === e ? ((u = b[Math.min(c, b.length - 1)]) == null ? void 0 : u.tabId) ?? null : d.activeTabId
211
215
  }, Oe(h.key), !b.some((o) => o.appId === h.appId)) {
212
- for (const o of [...G.get(h.appId) ?? []]) q(o);
216
+ for (const o of [...G.get(h.appId) ?? []]) Z(o);
213
217
  G.delete(h.appId), re.delete(h.appId);
214
218
  }
215
219
  return ne(), !0;
216
220
  }
217
221
  function Oe(e) {
218
222
  oe.delete(e), U.delete(e);
219
- for (const s of [...B.get(e) ?? []]) q(s);
223
+ for (const s of [...B.get(e) ?? []]) Z(s);
220
224
  B.delete(e);
221
225
  }
222
226
  function Ve(e) {
223
- return J(e);
227
+ return Y(e);
224
228
  }
225
- function J(e, s, c, h = !1, b, u = !1) {
229
+ function Y(e, s, c, h = !1, b, u = !1) {
226
230
  var o;
227
231
  try {
228
232
  if (D) throw new p("HOST_DISPOSED", "MicroHost 已销毁");
@@ -232,7 +236,7 @@ function qe(Re, x = {}) {
232
236
  ...e,
233
237
  ..."target" in e && e.target ? { target: { ...e.target } } : {},
234
238
  ..."anchor" in e && e.anchor ? { anchor: { ...e.anchor } } : {}
235
- }, r = (n) => !!n && z(n.tabId) && (n.key === void 0 || z(n.key));
239
+ }, r = (n) => !!n && x(n.tabId) && (n.key === void 0 || x(n.key));
236
240
  if (["activate", "refresh", "close"].includes(t.type) && (!("target" in t) || !r(t.target)))
237
241
  throw new p("INVALID_OPERATION", "导航需要合法目标引用");
238
242
  if ("target" in t && t.target !== void 0 && !r(t.target) || "anchor" in t && t.anchor !== void 0 && !r(t.anchor))
@@ -269,9 +273,9 @@ function qe(Re, x = {}) {
269
273
  t.closeFallback = Object.freeze({ tabId: n.tabId, key: n.key ?? ((o = d.tabs.find((g) => g.tabId === n.tabId)) == null ? void 0 : o.key) });
270
274
  }
271
275
  "fallback" in t && t.fallback && (t.fallback = Object.freeze({ ...t.fallback })), "target" in t && t.target && Object.freeze(t.target), "anchor" in t && t.anchor && Object.freeze(t.anchor), Object.freeze(t);
272
- const i = (n) => d.tabs.find(
276
+ const a = (n) => d.tabs.find(
273
277
  (g) => n ? g.tabId === n.tabId && (!n.key || g.key === n.key) : g.tabId === d.activeTabId
274
- ), w = "target" in t ? i(t.target) : void 0, v = t.type === "closeMany" && t.scope !== "all" ? t.anchor ? i(t.anchor) : c ? d.tabs.find((n) => n.key === c) : i() : void 0, S = i(), f = t.type === "open" ? d.tabs.find((n) => n.tabId === t.input.tabId) : void 0, I = u && c ? d.tabs.find((n) => n.key === c) : void 0, E = I && s ? Object.freeze({ appId: s, tab: Object.freeze({ ...I }) }) : void 0, _ = u && t.type === "open" && !!s && t.input.appId !== s, L = () => {
278
+ ), w = "target" in t ? a(t.target) : void 0, v = t.type === "closeMany" && t.scope !== "all" ? t.anchor ? a(t.anchor) : c ? d.tabs.find((n) => n.key === c) : a() : void 0, S = a(), f = t.type === "open" ? d.tabs.find((n) => n.tabId === t.input.tabId) : void 0, I = u && c ? d.tabs.find((n) => n.key === c) : void 0, E = I && s ? Object.freeze({ appId: s, tab: Object.freeze({ ...I }) }) : void 0, _ = u && t.type === "open" && !!s && t.input.appId !== s, L = () => {
275
279
  if (!(!_ || t.type !== "open")) {
276
280
  try {
277
281
  const n = E && (ue == null ? void 0 : ue(E, t.input));
@@ -287,107 +291,107 @@ function qe(Re, x = {}) {
287
291
  throw new p("FORBIDDEN", "页面只能操作本应用");
288
292
  if (t.type === "closeMany" && !["all", "others", "left", "right"].includes(t.scope))
289
293
  throw new p("INVALID_OPERATION", "批量范围无效");
290
- const F = v ? d.tabs.indexOf(v) : -1, Q = t.type === "closeMany" ? d.tabs.filter(
294
+ const F = v ? d.tabs.indexOf(v) : -1, J = t.type === "closeMany" ? d.tabs.filter(
291
295
  (n, g) => {
292
296
  var k;
293
297
  return H(n) && !((k = t.exclude) != null && k.some((C) => C.tabId === n.tabId && C.key === n.key)) && (t.scope === "all" || F >= 0 && (t.scope === "others" ? n.key !== v.key : t.scope === "left" ? g < F : g > F));
294
298
  }
295
299
  ) : [], m = t.type === "back" ? w ?? (!("target" in t) || !t.target ? S : void 0) : w, $ = async () => {
296
300
  var Te, Pe, De, Me, je, Se;
297
- const n = (a) => ({
298
- status: a,
301
+ const n = (i) => ({
302
+ status: i,
299
303
  affected: []
300
304
  });
301
305
  if (D) throw new p("HOST_DISPOSED", "MicroHost 已销毁");
302
306
  if ((Te = t.signal) != null && Te.aborted) return n("stale");
303
- if (c && !h && (b != null && b() || !d.tabs.some((a) => a.key === c)))
307
+ if (c && !h && (b != null && b() || !d.tabs.some((i) => i.key === c)))
304
308
  throw new p("PAGE_RELEASED", "页面上下文已释放");
305
- if (t.type === "open" && (f ? !d.tabs.some((a) => a.key === f.key) : d.tabs.some((a) => a.tabId === t.input.tabId)) || m && !d.tabs.some((a) => a.key === m.key) || v && !d.tabs.some((a) => a.key === v.key) || Q.some((a) => !d.tabs.some((O) => O.key === a.key)))
309
+ if (t.type === "open" && (f ? !d.tabs.some((i) => i.key === f.key) : d.tabs.some((i) => i.tabId === t.input.tabId)) || m && !d.tabs.some((i) => i.key === m.key) || v && !d.tabs.some((i) => i.key === v.key) || J.some((i) => !d.tabs.some((O) => O.key === i.key)))
306
310
  return n("stale");
307
311
  if (t.type !== "open" && t.type !== "closeMany" && !m) return n("noop");
308
312
  const g = W;
309
- if (L(), c && !h && (b != null && b() || !d.tabs.some((a) => a.key === c)))
313
+ if (L(), c && !h && (b != null && b() || !d.tabs.some((i) => i.key === c)))
310
314
  throw new p("PAGE_RELEASED", "页面上下文已释放");
311
315
  if (W !== g || D || (Pe = t.signal) != null && Pe.aborted) return n("stale");
312
316
  const k = d, C = W;
313
317
  let y = [...d.tabs], l, M = [], V = d.activeTabId;
314
318
  try {
315
- if (t.type === "open" && (l = he(t.input, !0), f && f.key !== l.key ? (M = [f], y = y.map((a) => a.key === f.key ? l : a)) : y.some((a) => a.key === l.key) || y.push(l), V = l.tabId), t.type === "activate" && (l = m, Y(l), V = l.tabId), t.type === "refresh" && (Y(m), M = [m], l = Object.freeze({
319
+ if (t.type === "open" && (l = he(t.input, !0), f && f.key !== l.key ? (M = [f], y = y.map((i) => i.key === f.key ? l : i)) : y.some((i) => i.key === l.key) || y.push(l), V = l.tabId), t.type === "activate" && (l = m, q(l), V = l.tabId), t.type === "refresh" && (q(m), M = [m], l = Object.freeze({
316
320
  ...m,
317
321
  key: `${m.tabId}:${++be}`
318
- }), y = y.map((a) => a.key === m.key ? l : a)), (t.type === "close" || t.type === "back") && (M = [m]), t.type === "closeMany" && (M = Q), M.length && t.type !== "refresh" && t.type !== "open") {
319
- const a = new Set(M.map((A) => A.key)), O = k.tabs.findIndex((A) => A.tabId === k.activeTabId);
320
- if (y = y.filter((A) => !a.has(A.key)), t.type === "back") {
322
+ }), y = y.map((i) => i.key === m.key ? l : i)), (t.type === "close" || t.type === "back") && (M = [m]), t.type === "closeMany" && (M = J), M.length && t.type !== "refresh" && t.type !== "open") {
323
+ const i = new Set(M.map((A) => A.key)), O = k.tabs.findIndex((A) => A.tabId === k.activeTabId);
324
+ if (y = y.filter((A) => !i.has(A.key)), t.type === "back") {
321
325
  const A = U.get(m.key);
322
- l = y.find((P) => P.key === A && H(P)), !l && t.fallback && (l = he(t.fallback), a.has(l.key) && (l = Object.freeze({ ...l, key: `${l.tabId}:${++be}` })), y.some((P) => P.key === l.key) || y.push(l));
323
- const T = k.tabs.filter((P) => H(P)), R = T.findIndex((P) => P.key === m.key);
324
- l ?? (l = T.slice(0, R).reverse().find((P) => y.some((se) => se.key === P.key)) ?? T.slice(R + 1).find((P) => y.some((se) => se.key === P.key))), l ?? (l = y[Math.min(O, y.length - 1)]), l && Y(l), V = (l == null ? void 0 : l.tabId) ?? null;
326
+ l = y.find((P) => P.key === A && H(P)), !l && t.fallback && (l = he(t.fallback), i.has(l.key) && (l = Object.freeze({ ...l, key: `${l.tabId}:${++be}` })), y.some((P) => P.key === l.key) || y.push(l));
327
+ const T = k.tabs.filter((P) => H(P)), N = T.findIndex((P) => P.key === m.key);
328
+ l ?? (l = T.slice(0, N).reverse().find((P) => y.some((se) => se.key === P.key)) ?? T.slice(N + 1).find((P) => y.some((se) => se.key === P.key))), l ?? (l = y[Math.min(O, y.length - 1)]), l && q(l), V = (l == null ? void 0 : l.tabId) ?? null;
325
329
  } else if (M.some((A) => A.tabId === V)) {
326
- const A = "closeFallback" in t ? t.closeFallback : void 0, T = A ? y.find((R) => R.tabId === A.tabId && R.key === A.key && H(R)) : void 0;
327
- T && (Y(T), l = T), V = ((De = T ?? y[Math.min(O, y.length - 1)]) == null ? void 0 : De.tabId) ?? null;
330
+ const A = "closeFallback" in t ? t.closeFallback : void 0, T = A ? y.find((N) => N.tabId === A.tabId && N.key === A.key && H(N)) : void 0;
331
+ T && (q(T), l = T), V = ((De = T ?? y[Math.min(O, y.length - 1)]) == null ? void 0 : De.tabId) ?? null;
328
332
  }
329
333
  }
330
- } catch (a) {
331
- throw a instanceof p ? a : new p("INVALID_OPERATION", "导航参数无效");
334
+ } catch (i) {
335
+ throw i instanceof p ? i : new p("INVALID_OPERATION", "导航参数无效");
332
336
  }
333
- if (y.length === k.tabs.length && y.every((a, O) => a.key === k.tabs[O].key) && V === k.activeTabId)
337
+ if (y.length === k.tabs.length && y.every((i, O) => i.key === k.tabs[O].key) && V === k.activeTabId)
334
338
  return n("noop");
335
- const Ie = [...M], fe = k.tabs.find((a) => a.tabId === k.activeTabId);
336
- fe && fe.tabId !== V && !Ie.some((a) => a.key === fe.key) && Ie.push(fe);
337
- for (const a of Ie)
338
- for (const O of [...oe.get(a.key) ?? []]) {
339
+ const Ie = [...M], fe = k.tabs.find((i) => i.tabId === k.activeTabId);
340
+ fe && fe.tabId !== V && !Ie.some((i) => i.key === fe.key) && Ie.push(fe);
341
+ for (const i of Ie)
342
+ for (const O of [...oe.get(i.key) ?? []]) {
339
343
  let A;
340
344
  const T = t.signal;
341
- let R = () => {
345
+ let N = () => {
342
346
  };
343
347
  try {
344
- const P = Promise.resolve(O({ operation: t, tab: a })), se = new Promise((Le) => {
348
+ const P = Promise.resolve(O({ operation: t, tab: i })), se = new Promise((Le) => {
345
349
  if (!T) return;
346
- const Ne = () => Le();
347
- T.addEventListener("abort", Ne, { once: !0 }), R = () => T.removeEventListener("abort", Ne), T.aborted && Le();
350
+ const ze = () => Le();
351
+ T.addEventListener("abort", ze, { once: !0 }), N = () => T.removeEventListener("abort", ze), T.aborted && Le();
348
352
  });
349
353
  A = await Promise.race([P, se]);
350
354
  } catch {
351
355
  if (T != null && T.aborted) return n("stale");
352
356
  throw new p("GUARD_FAILED", "离页守卫执行失败");
353
357
  } finally {
354
- R();
358
+ N();
355
359
  }
356
360
  if (W !== C || D || (Me = t.signal) != null && Me.aborted) return n("stale");
357
361
  if (A === !1) return n("cancelled");
358
362
  }
359
363
  if (W !== C || D || (je = t.signal) != null && je.aborted) return n("stale");
360
364
  if (b != null && b()) throw new p("PAGE_RELEASED", "页面上下文已释放");
361
- if (L(), l && Y(l), b != null && b()) throw new p("PAGE_RELEASED", "页面上下文已释放");
365
+ if (L(), l && q(l), b != null && b()) throw new p("PAGE_RELEASED", "页面上下文已释放");
362
366
  if (W !== C || D || (Se = t.signal) != null && Se.aborted) return n("stale");
363
367
  if (d = { tabs: y, activeTabId: V }, t.type === "open" && l && c && !_ && l.key !== c && !U.has(l.key) && U.set(l.key, c), t.type === "refresh" && l) {
364
- const a = U.get(m.key);
365
- a && U.set(l.key, a);
368
+ const i = U.get(m.key);
369
+ i && U.set(l.key, i);
366
370
  }
367
- for (const a of M) Oe(a.key);
368
- for (const a of new Set(M.map((O) => O.appId)))
369
- if (!y.some((O) => O.appId === a)) {
370
- for (const O of [...G.get(a) ?? []]) q(O);
371
- G.delete(a), re.delete(a);
371
+ for (const i of M) Oe(i.key);
372
+ for (const i of new Set(M.map((O) => O.appId)))
373
+ if (!y.some((O) => O.appId === i)) {
374
+ for (const O of [...G.get(i) ?? []]) Z(O);
375
+ G.delete(i), re.delete(i);
372
376
  }
373
377
  const ye = [
374
378
  ...M,
375
- ...y.filter((a) => !k.tabs.some((O) => O.key === a.key))
379
+ ...y.filter((i) => !k.tabs.some((O) => O.key === i.key))
376
380
  ];
377
381
  return !ye.length && l && ye.push(l), ne(), {
378
382
  status: "committed",
379
- affected: ye.map((a) => ({ tabId: a.tabId, key: a.key })),
383
+ affected: ye.map((i) => ({ tabId: i.tabId, key: i.key })),
380
384
  ...l ? { tab: l } : {}
381
385
  };
382
- }, X = Ee.then($);
383
- return Ee = X.catch(() => {
384
- }), X;
386
+ }, Q = Ee.then($);
387
+ return Ee = Q.catch(() => {
388
+ }), Q;
385
389
  } catch (t) {
386
390
  return Promise.reject(t);
387
391
  }
388
392
  }
389
393
  function Be(e) {
390
- if (j(), !Z.has(e)) throw new Error(`未知子应用: ${e}`);
394
+ if (j(), !X.has(e)) throw new Error(`未知子应用: ${e}`);
391
395
  const s = re.get(e);
392
396
  if (s) return s;
393
397
  let c = !0;
@@ -397,23 +401,23 @@ function qe(Re, x = {}) {
397
401
  }
398
402
  ]);
399
403
  G.set(e, h);
400
- async function b(o, t, r, i = {}) {
404
+ async function b(o, t, r, a = {}) {
401
405
  const w = () => {
402
- if (D) throw new N("HOST_DISPOSED", "MicroHost 已销毁");
406
+ if (D) throw new z("HOST_DISPOSED", "MicroHost 已销毁");
403
407
  if (r && (r.released() || !d.tabs.some((L) => L.key === r.key)))
404
- throw new N("PAGE_RELEASED", "页面上下文已释放");
405
- if (!c) throw new N("BRIDGE_RELEASED", "应用 bridge 已释放");
408
+ throw new z("PAGE_RELEASED", "页面上下文已释放");
409
+ if (!c) throw new z("BRIDGE_RELEASED", "应用 bridge 已释放");
406
410
  };
407
411
  w();
408
412
  const v = ve.get(o);
409
- if (!v) throw new N("UNKNOWN_CAPABILITY", `未注册宿主能力: ${o}`);
413
+ if (!v) throw new z("UNKNOWN_CAPABILITY", `未注册宿主能力: ${o}`);
410
414
  if (v.apps && !v.apps.has(e))
411
- throw new N("FORBIDDEN", `应用无权调用宿主能力: ${o}`);
412
- const S = i.timeoutMs ?? ie;
415
+ throw new z("FORBIDDEN", `应用无权调用宿主能力: ${o}`);
416
+ const S = a.timeoutMs ?? ie;
413
417
  if (!Number.isFinite(S) || S <= 0 || S > 2147483647)
414
418
  throw new TypeError("timeoutMs 必须为不超过2147483647的正有限数");
415
- const f = i.signal;
416
- if (f != null && f.aborted) throw new N("CANCELLED", "宿主能力调用已取消");
419
+ const f = a.signal;
420
+ if (f != null && f.aborted) throw new z("CANCELLED", "宿主能力调用已取消");
417
421
  const I = new AbortController(), E = r ? d.tabs.find((L) => L.key === r.key) : void 0, _ = Object.freeze({
418
422
  appId: e,
419
423
  signal: I.signal,
@@ -421,27 +425,27 @@ function qe(Re, x = {}) {
421
425
  isActive: () => !I.signal.aborted && !D && c && (!r || !r.released() && d.tabs.some((L) => L.key === r.key))
422
426
  });
423
427
  return new Promise((L, H) => {
424
- let F = !1, Q;
428
+ let F = !1, J;
425
429
  const m = () => {
426
- Q !== void 0 && clearTimeout(Q), f == null || f.removeEventListener("abort", X), h.delete(n), r == null || r.cleanups.delete(n);
430
+ J !== void 0 && clearTimeout(J), f == null || f.removeEventListener("abort", Q), h.delete(n), r == null || r.cleanups.delete(n);
427
431
  }, $ = (k) => {
428
432
  F || (F = !0, m(), H(k), I.abort());
429
- }, X = () => $(new N("CANCELLED", "宿主能力调用已取消")), n = () => {
433
+ }, Q = () => $(new z("CANCELLED", "宿主能力调用已取消")), n = () => {
430
434
  try {
431
435
  w();
432
436
  } catch (k) {
433
437
  $(k);
434
438
  }
435
439
  };
436
- if (h.add(n), r == null || r.cleanups.add(n), f == null || f.addEventListener("abort", X, { once: !0 }), Q = setTimeout(() => $(new N("TIMEOUT", "宿主能力调用超时")), S), f != null && f.aborted) {
437
- X();
440
+ if (h.add(n), r == null || r.cleanups.add(n), f == null || f.addEventListener("abort", Q, { once: !0 }), J = setTimeout(() => $(new z("TIMEOUT", "宿主能力调用超时")), S), f != null && f.aborted) {
441
+ Q();
438
442
  return;
439
443
  }
440
444
  let g;
441
445
  try {
442
446
  g = v.handler(_, ...t);
443
447
  } catch {
444
- $(new N("HANDLER_FAILED", `宿主能力执行失败: ${o}`));
448
+ $(new z("HANDLER_FAILED", `宿主能力执行失败: ${o}`));
445
449
  return;
446
450
  }
447
451
  Promise.resolve(g).then((k) => {
@@ -454,7 +458,7 @@ function qe(Re, x = {}) {
454
458
  }
455
459
  F = !0, m(), L(k);
456
460
  }
457
- }, () => $(new N("HANDLER_FAILED", `宿主能力执行失败: ${o}`)));
461
+ }, () => $(new z("HANDLER_FAILED", `宿主能力执行失败: ${o}`)));
458
462
  });
459
463
  }
460
464
  const u = {
@@ -475,7 +479,7 @@ function qe(Re, x = {}) {
475
479
  });
476
480
  },
477
481
  negotiate(o = {}) {
478
- const t = u.protocol(), r = Object.freeze((o.capabilities ?? []).filter((i) => !t.capabilities.includes(i)));
482
+ const t = u.protocol(), r = Object.freeze((o.capabilities ?? []).filter((a) => !t.capabilities.includes(a)));
479
483
  return Object.freeze({ compatible: (!o.version || o.version === t.version) && !r.length, protocol: t, missingCapabilities: r });
480
484
  },
481
485
  getSession() {
@@ -483,10 +487,10 @@ function qe(Re, x = {}) {
483
487
  return ee;
484
488
  },
485
489
  subscribeSession(o) {
486
- const t = u.getSession(), r = (w) => o(w), i = () => {
487
- K.delete(r), h.delete(i);
490
+ const t = u.getSession(), r = (w) => o(w), a = () => {
491
+ K.delete(r), h.delete(a);
488
492
  };
489
- return K.add(r), h.add(i), q(() => o(t)), i;
493
+ return K.add(r), h.add(a), Z(() => o(t)), a;
490
494
  },
491
495
  subscribe(o) {
492
496
  if (!c) throw new Error("应用 bridge 已释放");
@@ -496,16 +500,16 @@ function qe(Re, x = {}) {
496
500
  return h.add(r), r;
497
501
  },
498
502
  ready(o) {
499
- const t = (i) => {
500
- const w = i.tabs.find(
501
- (v) => v.tabId === i.activeTabId && v.appId === e
503
+ const t = (a) => {
504
+ const w = a.tabs.find(
505
+ (v) => v.tabId === a.activeTabId && v.appId === e
502
506
  );
503
507
  w && o(w);
504
508
  }, r = u.subscribe(t);
505
509
  try {
506
510
  t(ce());
507
- } catch (i) {
508
- throw r(), i;
511
+ } catch (a) {
512
+ throw r(), a;
509
513
  }
510
514
  return r;
511
515
  },
@@ -519,13 +523,13 @@ function qe(Re, x = {}) {
519
523
  const t = d.tabs.find((f) => f.key === o && f.appId === e);
520
524
  if (!t) throw new Error("页面上下文不存在或不属于该应用");
521
525
  let r = !1;
522
- const i = /* @__PURE__ */ new Set(), w = () => {
526
+ const a = /* @__PURE__ */ new Set(), w = () => {
523
527
  if (D) throw new p("HOST_DISPOSED", "MicroHost 已销毁");
524
528
  if (r || !d.tabs.some((f) => f.key === o))
525
529
  throw new p("PAGE_RELEASED", "页面上下文已释放");
526
530
  }, v = () => {
527
531
  var f;
528
- r = !0, i.forEach((I) => I()), i.clear(), (f = B.get(o)) == null || f.delete(v);
532
+ r = !0, a.forEach((I) => I()), a.clear(), (f = B.get(o)) == null || f.delete(v);
529
533
  };
530
534
  let S = B.get(o);
531
535
  return S || B.set(o, S = /* @__PURE__ */ new Set()), S.add(v), {
@@ -533,14 +537,14 @@ function qe(Re, x = {}) {
533
537
  return d.tabs.find((f) => f.key === o) ?? t;
534
538
  },
535
539
  callHost(f, ...I) {
536
- return b(f, I, { key: o, released: () => r, cleanups: i });
540
+ return b(f, I, { key: o, released: () => r, cleanups: a });
537
541
  },
538
542
  callHostWithOptions(f, I, ...E) {
539
- return b(f, E, { key: o, released: () => r, cleanups: i }, I);
543
+ return b(f, E, { key: o, released: () => r, cleanups: a }, I);
540
544
  },
541
545
  async openTab(f) {
542
546
  w();
543
- const I = await J(
547
+ const I = await Y(
544
548
  { type: "open", input: f },
545
549
  e,
546
550
  o,
@@ -558,7 +562,7 @@ function qe(Re, x = {}) {
558
562
  );
559
563
  },
560
564
  async navigateTo(f, I = {}) {
561
- return w(), J(
565
+ return w(), Y(
562
566
  { type: "open", input: f, signal: I.signal },
563
567
  e,
564
568
  o,
@@ -569,7 +573,7 @@ function qe(Re, x = {}) {
569
573
  },
570
574
  // 释放后仅允许关闭捕获的原 key;所有守卫仍然执行,不能误关同 id 新生命周期。
571
575
  async closeCurrent() {
572
- return D ? !1 : (await J(
576
+ return D ? !1 : (await Y(
573
577
  { type: "close", target: { tabId: t.tabId, key: o } },
574
578
  e,
575
579
  void 0,
@@ -582,12 +586,12 @@ function qe(Re, x = {}) {
582
586
  let I = oe.get(o);
583
587
  I || oe.set(o, I = /* @__PURE__ */ new Set()), I.add(f);
584
588
  const E = () => {
585
- I.delete(f), i.delete(E);
589
+ I.delete(f), a.delete(E);
586
590
  };
587
- return i.add(E), E;
591
+ return a.add(E), E;
588
592
  },
589
593
  async refreshCurrent() {
590
- return w(), J(
594
+ return w(), Y(
591
595
  { type: "refresh", target: { tabId: t.tabId, key: o } },
592
596
  e,
593
597
  o,
@@ -596,7 +600,7 @@ function qe(Re, x = {}) {
596
600
  );
597
601
  },
598
602
  async back(f) {
599
- return w(), J(
603
+ return w(), Y(
600
604
  { type: "back", target: { tabId: t.tabId, key: o }, fallback: f },
601
605
  e,
602
606
  o,
@@ -605,7 +609,7 @@ function qe(Re, x = {}) {
605
609
  );
606
610
  },
607
611
  async operate(f) {
608
- return w(), J(f, e, o, !1, () => r);
612
+ return w(), Y(f, e, o, !1, () => r);
609
613
  },
610
614
  emit(f, I) {
611
615
  w(), ae.emit(f, { payload: I, metadata: Object.freeze({ source: "app", appId: e, tabKey: o }) });
@@ -613,8 +617,8 @@ function qe(Re, x = {}) {
613
617
  on(f, I) {
614
618
  w();
615
619
  const E = le.on(f, I);
616
- return i.add(E), () => {
617
- E(), i.delete(E);
620
+ return a.add(E), () => {
621
+ E(), a.delete(E);
618
622
  };
619
623
  },
620
624
  dispose: v
@@ -634,14 +638,14 @@ function qe(Re, x = {}) {
634
638
  }
635
639
  return {
636
640
  /** 注册应用的冻结元信息;不暴露 capabilities 注册表。 */
637
- apps: [...Z.values()],
641
+ apps: [...X.values()],
638
642
  getState: ce,
639
643
  subscribe: me,
640
644
  openTab: He,
641
645
  activateTab: $e,
642
646
  closeTab: Ce,
643
647
  updateTab: Fe,
644
- updateSession: ze,
648
+ updateSession: xe,
645
649
  operate: Ve,
646
650
  bridge: Be,
647
651
  /** 宿主侧业务事件总线;无响应广播,来源元信息由宿主生成,异常通过 onError 隔离。 */
@@ -650,5 +654,5 @@ function qe(Re, x = {}) {
650
654
  };
651
655
  }
652
656
  export {
653
- qe as createMicroHost
657
+ Ze as createMicroHost
654
658
  };