@nuwatop/code-canvas-runtime 0.5.46 → 0.5.48

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/index.esm.js CHANGED
@@ -1,19 +1,19 @@
1
- var le = Object.defineProperty;
2
- var ie = (t, e, r) => e in t ? le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
1
+ var ce = Object.defineProperty;
2
+ var ie = (t, e, r) => e in t ? ce(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var z = (t, e, r) => ie(t, typeof e != "symbol" ? e + "" : e, r);
4
4
  import * as se from "@nuwatop/code-canvas-core";
5
- import { parseAction as ce, useAndStore as g, getCoreConfig as w, useStoreByName as de } from "@nuwatop/code-canvas-core";
5
+ import { parseAction as ue, useAndStore as y, getCoreConfig as w, useStoreByName as de, createWatchCommands as fe } from "@nuwatop/code-canvas-core";
6
6
  export * from "@nuwatop/code-canvas-core";
7
- import { jsx as a, jsxs as T, Fragment as ue } from "react/jsx-runtime";
8
- import P, { useState as V, useEffect as fe, useMemo as S, Suspense as L } from "react";
9
- import { Spin as F, ConfigProvider as G, message as pe, Modal as me, Drawer as he } from "antd";
10
- import { create as ye } from "zustand";
11
- import { produce as ge } from "immer";
12
- import { createRoot as J } from "react-dom/client";
13
- function be(t) {
7
+ import { jsx as c, jsxs as T, Fragment as pe } from "react/jsx-runtime";
8
+ import x, { useState as B, useEffect as me, useMemo as P, Suspense as F } from "react";
9
+ import { Spin as Y, ConfigProvider as J, message as he, Modal as ye, Drawer as ge } from "antd";
10
+ import { create as be } from "zustand";
11
+ import { produce as ve } from "immer";
12
+ import { createRoot as X } from "react-dom/client";
13
+ function Ce(t) {
14
14
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
15
15
  }
16
- var A = {}, X = { exports: {} };
16
+ var A = {}, Z = { exports: {} };
17
17
  (function(t) {
18
18
  function e(r) {
19
19
  return r && r.__esModule ? r : {
@@ -21,13 +21,13 @@ var A = {}, X = { exports: {} };
21
21
  };
22
22
  }
23
23
  t.exports = e, t.exports.__esModule = !0, t.exports.default = t.exports;
24
- })(X);
25
- var I = X.exports, D = {};
24
+ })(Z);
25
+ var q = Z.exports, D = {};
26
26
  Object.defineProperty(D, "__esModule", {
27
27
  value: !0
28
28
  });
29
29
  D.default = void 0;
30
- const ve = {
30
+ const we = {
31
31
  // Options
32
32
  items_per_page: "条/页",
33
33
  jump_to: "跳至",
@@ -42,8 +42,8 @@ const ve = {
42
42
  next_3: "向后 3 页",
43
43
  page_size: "页码"
44
44
  };
45
- D.default = ve;
46
- var N = {}, _ = {}, M = {}, R = {};
45
+ D.default = we;
46
+ var M = {}, _ = {}, N = {}, R = {};
47
47
  Object.defineProperty(R, "__esModule", {
48
48
  value: !0
49
49
  });
@@ -54,11 +54,11 @@ R.commonLocale = {
54
54
  cellMeridiemFormat: "A",
55
55
  monthBeforeYear: !0
56
56
  };
57
- Object.defineProperty(M, "__esModule", {
57
+ Object.defineProperty(N, "__esModule", {
58
58
  value: !0
59
59
  });
60
- M.default = void 0;
61
- var Ce = R;
60
+ N.default = void 0;
61
+ var _e = R;
62
62
  function C(t) {
63
63
  "@babel/helpers - typeof";
64
64
  return C = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
@@ -71,31 +71,31 @@ function Q(t, e) {
71
71
  var r = Object.keys(t);
72
72
  if (Object.getOwnPropertySymbols) {
73
73
  var n = Object.getOwnPropertySymbols(t);
74
- e && (n = n.filter(function(i) {
75
- return Object.getOwnPropertyDescriptor(t, i).enumerable;
74
+ e && (n = n.filter(function(o) {
75
+ return Object.getOwnPropertyDescriptor(t, o).enumerable;
76
76
  })), r.push.apply(r, n);
77
77
  }
78
78
  return r;
79
79
  }
80
- function B(t) {
80
+ function G(t) {
81
81
  for (var e = 1; e < arguments.length; e++) {
82
82
  var r = arguments[e] != null ? arguments[e] : {};
83
83
  e % 2 ? Q(Object(r), !0).forEach(function(n) {
84
- we(t, n, r[n]);
84
+ $e(t, n, r[n]);
85
85
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : Q(Object(r)).forEach(function(n) {
86
86
  Object.defineProperty(t, n, Object.getOwnPropertyDescriptor(r, n));
87
87
  });
88
88
  }
89
89
  return t;
90
90
  }
91
- function we(t, e, r) {
92
- return e = _e(e), e in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
91
+ function $e(t, e, r) {
92
+ return e = Se(e), e in t ? Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = r, t;
93
93
  }
94
- function _e(t) {
95
- var e = $e(t, "string");
94
+ function Se(t) {
95
+ var e = Pe(t, "string");
96
96
  return C(e) == "symbol" ? e : String(e);
97
97
  }
98
- function $e(t, e) {
98
+ function Pe(t, e) {
99
99
  if (C(t) != "object" || !t) return t;
100
100
  var r = t[Symbol.toPrimitive];
101
101
  if (r !== void 0) {
@@ -105,7 +105,7 @@ function $e(t, e) {
105
105
  }
106
106
  return (e === "string" ? String : Number)(t);
107
107
  }
108
- var xe = B(B({}, Ce.commonLocale), {}, {
108
+ var xe = G(G({}, _e.commonLocale), {}, {
109
109
  locale: "zh_CN",
110
110
  today: "今天",
111
111
  now: "此刻",
@@ -133,24 +133,24 @@ var xe = B(B({}, Ce.commonLocale), {}, {
133
133
  cellDateFormat: "D",
134
134
  monthBeforeYear: !1
135
135
  });
136
- M.default = xe;
136
+ N.default = xe;
137
137
  var $ = {};
138
138
  Object.defineProperty($, "__esModule", {
139
139
  value: !0
140
140
  });
141
141
  $.default = void 0;
142
- const Se = {
142
+ const Oe = {
143
143
  placeholder: "请选择时间",
144
144
  rangePlaceholder: ["开始时间", "结束时间"]
145
145
  };
146
- $.default = Se;
147
- var Z = I.default;
146
+ $.default = Oe;
147
+ var K = q.default;
148
148
  Object.defineProperty(_, "__esModule", {
149
149
  value: !0
150
150
  });
151
151
  _.default = void 0;
152
- var Pe = Z(M), Oe = Z($);
153
- const K = {
152
+ var je = K(N), Ae = K($);
153
+ const ee = {
154
154
  lang: {
155
155
  placeholder: "请选择日期",
156
156
  yearPlaceholder: "请选择年份",
@@ -162,33 +162,33 @@ const K = {
162
162
  rangeMonthPlaceholder: ["开始月份", "结束月份"],
163
163
  rangeQuarterPlaceholder: ["开始季度", "结束季度"],
164
164
  rangeWeekPlaceholder: ["开始周", "结束周"],
165
- ...Pe.default
165
+ ...je.default
166
166
  },
167
167
  timePickerLocale: {
168
- ...Oe.default
168
+ ...Ae.default
169
169
  }
170
170
  };
171
- K.lang.ok = "确定";
172
- _.default = K;
173
- var je = I.default;
174
- Object.defineProperty(N, "__esModule", {
171
+ ee.lang.ok = "确定";
172
+ _.default = ee;
173
+ var De = q.default;
174
+ Object.defineProperty(M, "__esModule", {
175
175
  value: !0
176
176
  });
177
- N.default = void 0;
178
- var Ae = je(_);
179
- N.default = Ae.default;
180
- var k = I.default;
177
+ M.default = void 0;
178
+ var Me = De(_);
179
+ M.default = Me.default;
180
+ var k = q.default;
181
181
  Object.defineProperty(A, "__esModule", {
182
182
  value: !0
183
183
  });
184
184
  A.default = void 0;
185
- var De = k(D), Ne = k(N), Me = k(_), Re = k($);
186
- const p = "${label}不是一个有效的${type}", ke = {
185
+ var Ne = k(D), Re = k(M), ke = k(_), ze = k($);
186
+ const p = "${label}不是一个有效的${type}", Te = {
187
187
  locale: "zh-cn",
188
- Pagination: De.default,
189
- DatePicker: Me.default,
190
- TimePicker: Re.default,
191
- Calendar: Ne.default,
188
+ Pagination: Ne.default,
189
+ DatePicker: ke.default,
190
+ TimePicker: ze.default,
191
+ Calendar: Re.default,
192
192
  // locales for all components
193
193
  global: {
194
194
  placeholder: "请选择",
@@ -323,9 +323,9 @@ const p = "${label}不是一个有效的${type}", ke = {
323
323
  gradientColor: "渐变色"
324
324
  }
325
325
  };
326
- A.default = ke;
327
- var ze = A;
328
- const Y = /* @__PURE__ */ be(ze), m = /* @__PURE__ */ new Map(), Te = () => {
326
+ A.default = Te;
327
+ var Le = A;
328
+ const U = /* @__PURE__ */ Ce(Le), m = /* @__PURE__ */ new Map(), Ee = () => {
329
329
  const t = se;
330
330
  Object.keys(t).forEach((e) => {
331
331
  if (e.startsWith("And") && typeof t[e] == "function") {
@@ -334,94 +334,94 @@ const Y = /* @__PURE__ */ be(ze), m = /* @__PURE__ */ new Map(), Te = () => {
334
334
  }
335
335
  });
336
336
  };
337
- Te();
338
- const Ee = (t, e) => {
337
+ Ee();
338
+ const Fe = (t, e) => {
339
339
  m.set(t, e), m.set(t.toLowerCase(), e);
340
- }, q = (t) => {
340
+ }, H = (t) => {
341
341
  let e = m.get(t);
342
342
  return e || (e = m.get(t.toLowerCase()), e) || !t.startsWith("And") && (e = m.get(`And${t}`), e) || t.startsWith("and-") || (e = m.get(`and-${t.toLowerCase()}`)), e;
343
- }, Le = () => Array.from(m.keys()), ft = {
344
- register: Ee,
345
- get: q,
346
- getAll: Le,
343
+ }, Ye = () => Array.from(m.keys()), ht = {
344
+ register: Fe,
345
+ get: H,
346
+ getAll: Ye,
347
347
  has: (t) => m.has(t) || m.has(t.toLowerCase())
348
- }, Fe = (t) => {
348
+ }, qe = (t) => {
349
349
  try {
350
350
  const e = JSON.parse(t);
351
- return Ie(e);
351
+ return Ue(e);
352
352
  } catch (e) {
353
353
  throw new Error(`Failed to parse page config: ${e}`);
354
354
  }
355
- }, Ie = (t) => {
355
+ }, Ue = (t) => {
356
356
  if (!t)
357
357
  throw new Error("Page config is empty");
358
358
  return t.html || t.components ? {
359
359
  id: t.id,
360
360
  title: t.title,
361
361
  style: t.style,
362
- components: E(t.components || []),
362
+ components: L(t.components || []),
363
363
  dataSets: t.dataSets || {},
364
364
  actions: t.actions || {}
365
365
  } : t;
366
- }, E = (t) => Array.isArray(t) ? t.map((e) => {
366
+ }, L = (t) => Array.isArray(t) ? t.map((e) => {
367
367
  var r;
368
368
  return e.tagName || e["data-gjs-type"] ? {
369
369
  id: ((r = e.attributes) == null ? void 0 : r.id) || e.id,
370
370
  type: e["data-gjs-type"] || e.tagName || "div",
371
371
  props: { ...e.attributes },
372
- children: e.components ? E(e.components) : void 0,
372
+ children: e.components ? L(e.components) : void 0,
373
373
  style: e.style
374
374
  } : {
375
375
  id: e.id,
376
376
  type: e.type,
377
377
  props: e.props || {},
378
- children: e.children ? E(e.children) : void 0,
378
+ children: e.children ? L(e.children) : void 0,
379
379
  style: e.style
380
380
  };
381
- }) : [], Ye = F, qe = G, pt = ({
381
+ }) : [], He = Y, We = J, yt = ({
382
382
  pageConfig: t,
383
383
  sessionId: e = `runtime_${Date.now()}`,
384
384
  develop: r = !1,
385
385
  theme: n,
386
- loading: i = !1,
387
- onError: l
386
+ loading: o = !1,
387
+ onError: a
388
388
  }) => {
389
- const [o, d] = V(null), [c, f] = V(null);
390
- fe(() => {
389
+ const [l, u] = B(null), [s, f] = B(null);
390
+ me(() => {
391
391
  try {
392
- const s = typeof t == "string" ? Fe(t) : t;
393
- d(s), f(null);
394
- } catch (s) {
395
- const u = s instanceof Error ? s : new Error(String(s));
396
- f(u), l == null || l(u);
392
+ const i = typeof t == "string" ? qe(t) : t;
393
+ u(i), f(null);
394
+ } catch (i) {
395
+ const d = i instanceof Error ? i : new Error(String(i));
396
+ f(d), a == null || a(d);
397
397
  }
398
- }, [t, l]);
399
- const h = (s, u) => {
400
- var W;
401
- const b = q(s.type);
398
+ }, [t, a]);
399
+ const h = (i, d) => {
400
+ var V;
401
+ const b = H(i.type);
402
402
  if (!b)
403
403
  return r ? /* @__PURE__ */ T("div", { style: { padding: 8, background: "#fff1f0", border: "1px solid #ffa39e", borderRadius: 4 }, children: [
404
404
  "未知组件: ",
405
- s.type
406
- ] }, s.id || u) : (console.warn(`Unknown component type: ${s.type}`), null);
405
+ i.type
406
+ ] }, i.id || d) : (console.warn(`Unknown component type: ${i.type}`), null);
407
407
  const v = {
408
- ...s.props,
409
- id: s.id,
408
+ ...i.props,
409
+ id: i.id,
410
410
  sessionId: e,
411
411
  develop: r,
412
- key: s.id || u
413
- }, ne = (W = s.children) == null ? void 0 : W.map((oe, ae) => h(oe, ae));
414
- return P.createElement(b, v, ne);
415
- }, y = S(() => i ? /* @__PURE__ */ a("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", minHeight: 200 }, children: /* @__PURE__ */ a(Ye, { size: "large" }) }) : c ? /* @__PURE__ */ T("div", { style: { padding: 24, background: "#fff2f0", border: "1px solid #ffccc7", borderRadius: 8 }, children: [
416
- /* @__PURE__ */ a("h3", { style: { color: "#cf1322" }, children: "渲染错误" }),
417
- /* @__PURE__ */ a("p", { children: c.message })
418
- ] }) : o ? /* @__PURE__ */ a("div", { className: "runtime-container", style: o.style, children: o.components.map((s, u) => h(s, u)) }) : null, [i, c, o, e, r]);
419
- return /* @__PURE__ */ a(qe, { locale: Y, theme: n, children: y });
420
- }, Ue = (t) => (e, r, n) => (n.setState = (i, l, ...o) => {
421
- const d = typeof i == "function" ? ge(i) : i;
422
- return e(d, l, ...o);
423
- }, t(n.setState, r, n)), He = Ue, mt = ye()(
424
- He((t) => ({
412
+ key: i.id || d
413
+ }, oe = (V = i.children) == null ? void 0 : V.map((ae, le) => h(ae, le));
414
+ return x.createElement(b, v, oe);
415
+ }, g = P(() => o ? /* @__PURE__ */ c("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", minHeight: 200 }, children: /* @__PURE__ */ c(He, { size: "large" }) }) : s ? /* @__PURE__ */ T("div", { style: { padding: 24, background: "#fff2f0", border: "1px solid #ffccc7", borderRadius: 8 }, children: [
416
+ /* @__PURE__ */ c("h3", { style: { color: "#cf1322" }, children: "渲染错误" }),
417
+ /* @__PURE__ */ c("p", { children: s.message })
418
+ ] }) : l ? /* @__PURE__ */ c("div", { className: "runtime-container", style: l.style, children: l.components.map((i, d) => h(i, d)) }) : null, [o, s, l, e, r]);
419
+ return /* @__PURE__ */ c(We, { locale: U, theme: n, children: g });
420
+ }, Ie = (t) => (e, r, n) => (n.setState = (o, a, ...l) => {
421
+ const u = typeof o == "function" ? ve(o) : o;
422
+ return e(u, a, ...l);
423
+ }, t(n.setState, r, n)), Ve = Ie, gt = be()(
424
+ Ve((t) => ({
425
425
  currentPageId: null,
426
426
  pageConfigs: {},
427
427
  loading: !1,
@@ -442,65 +442,65 @@ const Ee = (t, e) => {
442
442
  e.pageConfigs = {};
443
443
  })
444
444
  }))
445
- ), U = /* @__PURE__ */ new Map(), x = (t, e) => {
446
- U.set(t, e);
447
- }, We = async (t, e) => {
448
- const { actionName: r, arg: n } = ce(t, e.value), i = U.get(r);
449
- if (i)
450
- return i(e, n);
451
- const l = g.getState().addCommand;
452
- return l(e.sessionId, {
445
+ ), W = /* @__PURE__ */ new Map(), S = (t, e) => {
446
+ W.set(t, e);
447
+ }, Be = async (t, e) => {
448
+ const { actionName: r, arg: n } = ue(t, e.value), o = W.get(r);
449
+ if (o)
450
+ return o(e, n);
451
+ const a = y.getState().addCommand;
452
+ return a(e.sessionId, {
453
453
  actionName: r,
454
454
  arg: n,
455
455
  timestamp: Date.now()
456
456
  }), { actionName: r, arg: n };
457
457
  };
458
- x("setDataSet", (t, e) => {
459
- const { setDataSet: r } = g.getState();
458
+ S("setDataSet", (t, e) => {
459
+ const { setDataSet: r } = y.getState();
460
460
  e != null && e.dataSet && (e == null ? void 0 : e.field) !== void 0 && r(e.dataSet, e.field, e.value);
461
461
  });
462
- x("navigate", (t, e) => {
462
+ S("navigate", (t, e) => {
463
463
  typeof window < "u" && (e != null && e.url) && (e.target === "_blank" ? window.open(e.url, "_blank") : window.location.href = e.url);
464
464
  });
465
- x("alert", (t, e) => {
465
+ S("alert", (t, e) => {
466
466
  typeof window < "u" && window.alert((e == null ? void 0 : e.message) || e);
467
467
  });
468
- x("console", (t, e) => {
468
+ S("console", (t, e) => {
469
469
  });
470
- const ht = {
471
- execute: We,
472
- register: x,
473
- hasHandler: (t) => U.has(t)
474
- }, Ve = F, yt = ({
470
+ const bt = {
471
+ execute: Be,
472
+ register: S,
473
+ hasHandler: (t) => W.has(t)
474
+ }, Qe = Y, vt = ({
475
475
  componentName: t,
476
476
  componentProps: e = {},
477
477
  storePropsKey: r,
478
478
  sessionId: n,
479
- loadingFallback: i,
480
- notFoundFallback: l,
481
- onError: o
479
+ loadingFallback: o,
480
+ notFoundFallback: a,
481
+ onError: l
482
482
  }) => {
483
- const d = g((s) => {
483
+ const u = y((i) => {
484
484
  if (!r) return null;
485
485
  const b = r.split(".")[0];
486
- return s.dataSets[b];
487
- }), c = S(() => {
488
- if (!r || !d) return {};
489
- const u = r.split(".")[1];
490
- return u ? d[u] || {} : d;
491
- }, [r, d]), f = S(() => ({
492
- ...c,
486
+ return i.dataSets[b];
487
+ }), s = P(() => {
488
+ if (!r || !u) return {};
489
+ const d = r.split(".")[1];
490
+ return d ? u[d] || {} : u;
491
+ }, [r, u]), f = P(() => ({
492
+ ...s,
493
493
  ...e,
494
494
  sessionId: n
495
- }), [c, e, n]), h = S(() => {
495
+ }), [s, e, n]), h = P(() => {
496
496
  try {
497
- return q(t);
498
- } catch (s) {
499
- const u = s instanceof Error ? s : new Error(String(s));
500
- return o == null || o(u), null;
497
+ return H(t);
498
+ } catch (i) {
499
+ const d = i instanceof Error ? i : new Error(String(i));
500
+ return l == null || l(d), null;
501
501
  }
502
- }, [t, o]), y = /* @__PURE__ */ a("div", { style: { display: "flex", justifyContent: "center", padding: 24 }, children: /* @__PURE__ */ a(Ve, {}) });
503
- return h ? /* @__PURE__ */ a(L, { fallback: i || y, children: /* @__PURE__ */ a(h, { ...f }) }) : l ? /* @__PURE__ */ a(ue, { children: l }) : /* @__PURE__ */ T("div", { style: {
502
+ }, [t, l]), g = /* @__PURE__ */ c("div", { style: { display: "flex", justifyContent: "center", padding: 24 }, children: /* @__PURE__ */ c(Qe, {}) });
503
+ return h ? /* @__PURE__ */ c(F, { fallback: o || g, children: /* @__PURE__ */ c(h, { ...f }) }) : a ? /* @__PURE__ */ c(pe, { children: a }) : /* @__PURE__ */ T("div", { style: {
504
504
  padding: 16,
505
505
  background: "#fff7e6",
506
506
  border: "1px solid #ffd591",
@@ -511,8 +511,8 @@ const ht = {
511
511
  "组件未找到: ",
512
512
  t
513
513
  ] });
514
- }, Qe = he, Be = me, O = F, ee = G;
515
- class Ge {
514
+ }, Ge = ge, Je = ye, O = Y, te = J;
515
+ class Xe {
516
516
  constructor() {
517
517
  z(this, "drawers", /* @__PURE__ */ new Map());
518
518
  z(this, "isSetup", !1);
@@ -556,17 +556,17 @@ class Ge {
556
556
  }));
557
557
  }
558
558
  }
559
- const j = new Ge(), te = () => `drawer-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Je = ({ options: t, onClose: e, Component: r }) => {
560
- const [n, i] = P.useState(!0), l = w(), o = () => {
561
- var y;
562
- i(!1), (y = t.onClose) == null || y.call(t), setTimeout(() => {
559
+ const j = new Xe(), re = () => `drawer-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, Ze = ({ options: t, onClose: e, Component: r }) => {
560
+ const [n, o] = x.useState(!0), a = w(), l = () => {
561
+ var g;
562
+ o(!1), (g = t.onClose) == null || g.call(t), setTimeout(() => {
563
563
  e();
564
564
  }, 300);
565
- }, { component: d, componentName: c, componentProps: f, ...h } = t;
566
- return /* @__PURE__ */ a(ee, { locale: Y, theme: l.theme, children: /* @__PURE__ */ a(Qe, { ...h, open: n, onClose: o, destroyOnHidden: !0, children: r ? /* @__PURE__ */ a(
567
- L,
565
+ }, { component: u, componentName: s, componentProps: f, ...h } = t;
566
+ return /* @__PURE__ */ c(te, { locale: U, theme: a.theme, children: /* @__PURE__ */ c(Ge, { ...h, open: n, onClose: l, destroyOnHidden: !0, children: r ? /* @__PURE__ */ c(
567
+ F,
568
568
  {
569
- fallback: /* @__PURE__ */ a(
569
+ fallback: /* @__PURE__ */ c(
570
570
  "div",
571
571
  {
572
572
  style: {
@@ -574,12 +574,12 @@ const j = new Ge(), te = () => `drawer-${Date.now()}-${Math.random().toString(36
574
574
  justifyContent: "center",
575
575
  padding: 40
576
576
  },
577
- children: /* @__PURE__ */ a(O, {})
577
+ children: /* @__PURE__ */ c(O, {})
578
578
  }
579
579
  ),
580
- children: /* @__PURE__ */ a(r, { ...f || {}, onClose: o })
580
+ children: /* @__PURE__ */ c(r, { ...f || {}, onClose: l })
581
581
  }
582
- ) : /* @__PURE__ */ a(
582
+ ) : /* @__PURE__ */ c(
583
583
  "div",
584
584
  {
585
585
  style: {
@@ -588,41 +588,41 @@ const j = new Ge(), te = () => `drawer-${Date.now()}-${Math.random().toString(36
588
588
  alignItems: "center",
589
589
  height: "100%"
590
590
  },
591
- children: /* @__PURE__ */ a(O, { tip: "加载中..." })
591
+ children: /* @__PURE__ */ c(O, { tip: "加载中..." })
592
592
  }
593
593
  ) }) });
594
- }, Xe = ({ options: t, onClose: e, Component: r }) => {
595
- const [n, i] = P.useState(!0), [l, o] = P.useState(!1), d = w(), c = () => {
594
+ }, Ke = ({ options: t, onClose: e, Component: r }) => {
595
+ const [n, o] = x.useState(!0), [a, l] = x.useState(!1), u = w(), s = () => {
596
596
  var v;
597
- i(!1), (v = t.onClose) == null || v.call(t), setTimeout(() => {
597
+ o(!1), (v = t.onClose) == null || v.call(t), setTimeout(() => {
598
598
  e();
599
599
  }, 300);
600
600
  }, f = async () => {
601
601
  if (t.onOk) {
602
- o(!0);
602
+ l(!0);
603
603
  try {
604
- await t.onOk(), c();
604
+ await t.onOk(), s();
605
605
  } catch (v) {
606
606
  console.error("Modal onOk error:", v);
607
607
  } finally {
608
- o(!1);
608
+ l(!1);
609
609
  }
610
610
  } else
611
- c();
612
- }, { component: h, componentName: y, componentProps: s, onOk: u, ...b } = t;
613
- return /* @__PURE__ */ a(ee, { locale: Y, theme: d.theme, children: /* @__PURE__ */ a(
614
- Be,
611
+ s();
612
+ }, { component: h, componentName: g, componentProps: i, onOk: d, ...b } = t;
613
+ return /* @__PURE__ */ c(te, { locale: U, theme: u.theme, children: /* @__PURE__ */ c(
614
+ Je,
615
615
  {
616
616
  ...b,
617
617
  open: n,
618
- onCancel: c,
618
+ onCancel: s,
619
619
  onOk: f,
620
- confirmLoading: l,
620
+ confirmLoading: a,
621
621
  destroyOnHidden: !0,
622
- children: r ? /* @__PURE__ */ a(
623
- L,
622
+ children: r ? /* @__PURE__ */ c(
623
+ F,
624
624
  {
625
- fallback: /* @__PURE__ */ a(
625
+ fallback: /* @__PURE__ */ c(
626
626
  "div",
627
627
  {
628
628
  style: {
@@ -630,12 +630,12 @@ const j = new Ge(), te = () => `drawer-${Date.now()}-${Math.random().toString(36
630
630
  justifyContent: "center",
631
631
  padding: 40
632
632
  },
633
- children: /* @__PURE__ */ a(O, {})
633
+ children: /* @__PURE__ */ c(O, {})
634
634
  }
635
635
  ),
636
- children: /* @__PURE__ */ a(r, { ...s || {}, onClose: c })
636
+ children: /* @__PURE__ */ c(r, { ...i || {}, onClose: s })
637
637
  }
638
- ) : /* @__PURE__ */ a(
638
+ ) : /* @__PURE__ */ c(
639
639
  "div",
640
640
  {
641
641
  style: {
@@ -644,79 +644,79 @@ const j = new Ge(), te = () => `drawer-${Date.now()}-${Math.random().toString(36
644
644
  alignItems: "center",
645
645
  minHeight: 100
646
646
  },
647
- children: /* @__PURE__ */ a(O, { tip: "加载中..." })
647
+ children: /* @__PURE__ */ c(O, { tip: "加载中..." })
648
648
  }
649
649
  )
650
650
  }
651
651
  ) });
652
652
  };
653
- function Ze(t) {
654
- const e = te(), r = document.createElement("div");
653
+ function et(t) {
654
+ const e = re(), r = document.createElement("div");
655
655
  r.setAttribute("data-drawer-container", "true"), r.setAttribute("data-drawer-id", e), document.body.appendChild(r);
656
- const n = J(r), i = () => {
657
- var o;
656
+ const n = X(r), o = () => {
657
+ var l;
658
658
  try {
659
- j.remove(e), n.unmount(), r.remove(), (o = t.afterClose) == null || o.call(t);
660
- } catch (d) {
661
- console.error("Drawer cleanup failed:", d);
659
+ j.remove(e), n.unmount(), r.remove(), (l = t.afterClose) == null || l.call(t);
660
+ } catch (u) {
661
+ console.error("Drawer cleanup failed:", u);
662
662
  }
663
663
  };
664
- j.add({ id: e, root: n, mountNode: r, cleanup: i });
665
- let l = t.component || null;
666
- if (!l && t.componentName) {
667
- const o = w();
668
- o.componentResolver ? l = o.componentResolver(t.componentName) : console.warn(
664
+ j.add({ id: e, root: n, mountNode: r, cleanup: o });
665
+ let a = t.component || null;
666
+ if (!a && t.componentName) {
667
+ const l = w();
668
+ l.componentResolver ? a = l.componentResolver(t.componentName) : console.warn(
669
669
  "[UIUtils.showDrawer] componentResolver not configured. Cannot resolve component:",
670
670
  t.componentName
671
671
  );
672
672
  }
673
673
  return n.render(
674
- /* @__PURE__ */ a(Je, { options: t, onClose: i, Component: l })
675
- ), i;
674
+ /* @__PURE__ */ c(Ze, { options: t, onClose: o, Component: a })
675
+ ), o;
676
676
  }
677
- function Ke(t) {
678
- const e = te(), r = document.createElement("div");
677
+ function tt(t) {
678
+ const e = re(), r = document.createElement("div");
679
679
  r.setAttribute("data-modal-container", "true"), r.setAttribute("data-modal-id", e), document.body.appendChild(r);
680
- const n = J(r), i = () => {
680
+ const n = X(r), o = () => {
681
681
  try {
682
682
  n.unmount(), r.remove();
683
- } catch (o) {
684
- console.error("Modal cleanup failed:", o);
683
+ } catch (l) {
684
+ console.error("Modal cleanup failed:", l);
685
685
  }
686
686
  };
687
- let l = t.component || null;
688
- if (!l && t.componentName) {
689
- const o = w();
690
- o.componentResolver ? l = o.componentResolver(t.componentName) : console.warn(
687
+ let a = t.component || null;
688
+ if (!a && t.componentName) {
689
+ const l = w();
690
+ l.componentResolver ? a = l.componentResolver(t.componentName) : console.warn(
691
691
  "[UIUtils.showModal] componentResolver not configured. Cannot resolve component:",
692
692
  t.componentName
693
693
  );
694
694
  }
695
695
  return n.render(
696
- /* @__PURE__ */ a(Xe, { options: t, onClose: i, Component: l })
697
- ), i;
696
+ /* @__PURE__ */ c(Ke, { options: t, onClose: o, Component: a })
697
+ ), o;
698
698
  }
699
- function et() {
699
+ function rt() {
700
700
  j.cleanupAll();
701
701
  }
702
- function tt() {
702
+ function nt() {
703
703
  return j.count;
704
704
  }
705
- function rt(t, e, r, n) {
706
- pe[t](e, r, n);
705
+ function ot(t, e, r, n) {
706
+ he[t](e, r, n);
707
707
  }
708
- const gt = {
709
- showDrawer: Ze,
710
- showModal: Ke,
711
- cleanupAllDrawers: et,
712
- getDrawerCount: tt,
713
- msg: rt
714
- }, H = { module: "Module1" }, re = { router: void 0 }, bt = (t) => {
715
- H.module = t;
716
- }, vt = (t) => {
717
- re.router = t;
718
- }, nt = (t, e, r) => {
719
- r ? r(H.module).then((n) => {
708
+ const Ct = {
709
+ showDrawer: et,
710
+ showModal: tt,
711
+ cleanupAllDrawers: rt,
712
+ getDrawerCount: nt,
713
+ msg: ot
714
+ }, I = { module: "Module1" }, ne = { router: void 0 }, wt = (t) => {
715
+ I.module = t;
716
+ }, _t = (t) => {
717
+ ne.router = t;
718
+ }, at = (t, e, r) => {
719
+ r ? r(I.module).then((n) => {
720
720
  typeof n[t] == "function" ? n[t](e) : console.error(
721
721
  `Action "${t}" does not exist on the module.`
722
722
  );
@@ -725,67 +725,110 @@ const gt = {
725
725
  }) : console.warn(
726
726
  "Module loader not configured. Please provide moduleLoader in initRuntime options."
727
727
  );
728
- }, Ct = (t) => {
729
- const { sessionId: e = "default", utils: r, moduleLoader: n } = t || {}, i = w();
730
- let l = 0;
731
- return g.subscribe((d) => {
732
- const c = d.commandQueues[e] ?? [];
733
- if (c.length <= l) {
734
- l = c.length;
728
+ }, $t = (t) => {
729
+ const { sessionId: e = "default", utils: r, moduleLoader: n } = t || {}, o = w();
730
+ let a = 0;
731
+ return y.subscribe((u) => {
732
+ const s = u.commandQueues[e] ?? [];
733
+ if (s.length <= a) {
734
+ a = s.length;
735
735
  return;
736
736
  }
737
- const f = c[c.length - 1];
738
- !f || typeof f.actionName != "string" || (l = c.length, g.getState().popCommand(e), nt(
737
+ const f = s[s.length - 1];
738
+ !f || typeof f.actionName != "string" || (a = s.length, y.getState().popCommand(e), at(
739
739
  f.actionName,
740
740
  {
741
741
  ...f.arg,
742
- moduleName: H.module,
742
+ moduleName: I.module,
743
743
  ctx: {
744
744
  utils: r,
745
745
  useStoreByName: de,
746
- defHttp: i.request,
746
+ defHttp: o.request,
747
747
  useValidateWatchStore: void 0,
748
- router: re.router
748
+ router: ne.router
749
749
  }
750
750
  },
751
751
  n
752
752
  ));
753
753
  });
754
754
  };
755
- function wt(t) {
755
+ function St(t) {
756
756
  return t && typeof t == "object" ? Object.values(t).some(
757
757
  (e) => typeof e == "string" && e.trim().length > 0
758
758
  ) : !1;
759
759
  }
760
- function _t(t, e) {
761
- g.getState().addCommand(t, {
760
+ function Pt(t, e) {
761
+ y.getState().addCommand(t, {
762
762
  ...e,
763
763
  timestamp: Date.now()
764
764
  });
765
765
  }
766
- function $t(t, e) {
767
- return g.getState().getValidateResults(t, e) ?? {};
766
+ function xt(t, e) {
767
+ return y.getState().getValidateResults(t, e) ?? {};
768
+ }
769
+ const E = /* @__PURE__ */ new Map();
770
+ function lt(t) {
771
+ const e = E.get(t);
772
+ if (e) {
773
+ try {
774
+ e();
775
+ } catch (r) {
776
+ console.error("[PageScope] runPageScopeCleanups failed:", t, r);
777
+ }
778
+ E.delete(t);
779
+ }
780
+ }
781
+ function Ot(t) {
782
+ let e = [];
783
+ const r = () => {
784
+ for (; e.length; ) {
785
+ const n = e.pop();
786
+ try {
787
+ n == null || n();
788
+ } catch (o) {
789
+ console.error("[PageScope] cleanup failed:", t, o);
790
+ }
791
+ }
792
+ };
793
+ return {
794
+ sessionId: t,
795
+ setup(n, o) {
796
+ if (!(!t || !n)) {
797
+ if (lt(t), e = [], o != null && o.commands) {
798
+ const a = fe(o.commands)(n, t);
799
+ typeof a == "function" && e.push(a);
800
+ }
801
+ o != null && o.onLeave && e.push(o.onLeave), E.set(t, r);
802
+ }
803
+ },
804
+ subscribe(n, o) {
805
+ const a = y.subscribe(n, o);
806
+ typeof a == "function" && e.push(a);
807
+ }
808
+ };
768
809
  }
769
810
  export {
770
- ht as ActionExecutor,
771
- ft as ComponentRegistry,
772
- yt as DynamicContainer,
773
- pt as RuntimeRenderer,
774
- gt as UIUtils,
775
- _t as addCommand,
776
- et as cleanupAllDrawers,
777
- q as getComponent,
778
- tt as getDrawerCount,
779
- $t as getValidateResults,
780
- Ct as initRuntime,
781
- rt as msg,
782
- Fe as parsePageConfig,
783
- Ee as registerComponent,
784
- vt as setRoute,
785
- Ze as showDrawer,
786
- Ke as showModal,
787
- bt as useModule,
788
- mt as useRuntimeStore,
789
- wt as validateFailed
811
+ bt as ActionExecutor,
812
+ ht as ComponentRegistry,
813
+ vt as DynamicContainer,
814
+ yt as RuntimeRenderer,
815
+ Ct as UIUtils,
816
+ Pt as addCommand,
817
+ rt as cleanupAllDrawers,
818
+ Ot as createPageScope,
819
+ H as getComponent,
820
+ nt as getDrawerCount,
821
+ xt as getValidateResults,
822
+ $t as initRuntime,
823
+ ot as msg,
824
+ qe as parsePageConfig,
825
+ Fe as registerComponent,
826
+ lt as runPageScopeCleanups,
827
+ _t as setRoute,
828
+ et as showDrawer,
829
+ tt as showModal,
830
+ wt as useModule,
831
+ gt as useRuntimeStore,
832
+ St as validateFailed
790
833
  };
791
834
  //# sourceMappingURL=index.esm.js.map