@duxweb/dvha-core 1.1.30 → 1.2.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.
Files changed (159) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -0
  2. package/dist/cjs/components/auth/can.cjs +1 -1
  3. package/dist/cjs/components/auth/index.cjs +1 -0
  4. package/dist/cjs/components/common/icon.cjs +1 -1
  5. package/dist/cjs/components/common/index.cjs +1 -0
  6. package/dist/cjs/components/common/logo.cjs +1 -1
  7. package/dist/cjs/components/index.cjs +1 -0
  8. package/dist/cjs/components/loader/iframe.cjs +1 -1
  9. package/dist/cjs/components/loader/index.cjs +1 -0
  10. package/dist/cjs/components/loader/loader.cjs +1 -1
  11. package/dist/cjs/components/loader/remote/index.cjs +1 -0
  12. package/dist/cjs/components/loader/remote/loader.cjs +1 -1
  13. package/dist/cjs/components/loader/remote/render.cjs +1 -1
  14. package/dist/cjs/components/overlay/index.cjs +1 -0
  15. package/dist/cjs/components/overlay/overlay.cjs +1 -1
  16. package/dist/cjs/components/status/error.cjs +1 -1
  17. package/dist/cjs/components/status/exception.cjs +1 -1
  18. package/dist/cjs/components/status/index.cjs +1 -0
  19. package/dist/cjs/components/status/notAuthorized.cjs +1 -1
  20. package/dist/cjs/components/status/notFound.cjs +1 -1
  21. package/dist/cjs/config/color.cjs +1 -1
  22. package/dist/cjs/directive/index.cjs +1 -0
  23. package/dist/cjs/directive/permission.cjs +1 -1
  24. package/dist/cjs/hooks/auth.cjs +1 -1
  25. package/dist/cjs/hooks/config.cjs +1 -1
  26. package/dist/cjs/hooks/data.cjs +1 -1
  27. package/dist/cjs/hooks/export.cjs +1 -1
  28. package/dist/cjs/hooks/exportCsv.cjs +2 -2
  29. package/dist/cjs/hooks/form.cjs +1 -1
  30. package/dist/cjs/hooks/formExtend.cjs +1 -1
  31. package/dist/cjs/hooks/formValidate.cjs +1 -1
  32. package/dist/cjs/hooks/i18n.cjs +1 -1
  33. package/dist/cjs/hooks/import.cjs +1 -1
  34. package/dist/cjs/hooks/importCsv.cjs +2 -2
  35. package/dist/cjs/hooks/index.cjs +1 -0
  36. package/dist/cjs/hooks/json/index.cjs +1 -1
  37. package/dist/cjs/hooks/json/utils/contextManager.cjs +1 -1
  38. package/dist/cjs/hooks/json/utils/expressionParser.cjs +1 -1
  39. package/dist/cjs/hooks/json/vFor.cjs +1 -1
  40. package/dist/cjs/hooks/json/vIf.cjs +1 -1
  41. package/dist/cjs/hooks/json/vModel.cjs +1 -1
  42. package/dist/cjs/hooks/json/vOn.cjs +1 -1
  43. package/dist/cjs/hooks/json/vShow.cjs +1 -1
  44. package/dist/cjs/hooks/json/vText.cjs +1 -1
  45. package/dist/cjs/hooks/json.cjs +1 -1
  46. package/dist/cjs/hooks/list.cjs +1 -1
  47. package/dist/cjs/hooks/manage.cjs +1 -1
  48. package/dist/cjs/hooks/menu.cjs +1 -1
  49. package/dist/cjs/hooks/overlay.cjs +1 -1
  50. package/dist/cjs/hooks/select.cjs +1 -1
  51. package/dist/cjs/hooks/theme.cjs +4 -8
  52. package/dist/cjs/hooks/tree.cjs +1 -1
  53. package/dist/cjs/hooks/upload/index.cjs +1 -0
  54. package/dist/cjs/hooks/upload/local.cjs +1 -1
  55. package/dist/cjs/hooks/upload/s3.cjs +1 -1
  56. package/dist/cjs/hooks/upload.cjs +1 -1
  57. package/dist/cjs/index.cjs +1 -1
  58. package/dist/cjs/main.cjs +1 -1
  59. package/dist/cjs/preset/authProvider.cjs +1 -1
  60. package/dist/cjs/preset/dataProvider.cjs +1 -1
  61. package/dist/cjs/preset/i18nProvider.cjs +1 -1
  62. package/dist/cjs/preset/index.cjs +1 -0
  63. package/dist/cjs/provider/app.cjs +1 -1
  64. package/dist/cjs/provider/index.cjs +1 -0
  65. package/dist/cjs/provider/tab.cjs +1 -1
  66. package/dist/cjs/router/index.cjs +1 -0
  67. package/dist/cjs/router/route.cjs +1 -1
  68. package/dist/cjs/stores/auth.cjs +1 -1
  69. package/dist/cjs/stores/i18n.cjs +1 -1
  70. package/dist/cjs/stores/index.cjs +1 -0
  71. package/dist/cjs/stores/jsonSchema.cjs +1 -1
  72. package/dist/cjs/stores/manage.cjs +1 -1
  73. package/dist/cjs/stores/route.cjs +1 -1
  74. package/dist/cjs/stores/tab.cjs +1 -1
  75. package/dist/cjs/stores/theme.cjs +1 -1
  76. package/dist/cjs/utils/bus.cjs +1 -1
  77. package/dist/cjs/utils/index.cjs +1 -0
  78. package/dist/cjs/utils/theme.cjs +8 -8
  79. package/dist/cjs/utils/tree.cjs +1 -1
  80. package/dist/esm/_virtual/_rolldown/runtime.js +9 -0
  81. package/dist/esm/components/auth/can.js +17 -36
  82. package/dist/esm/components/auth/index.js +1 -0
  83. package/dist/esm/components/common/icon.js +16 -24
  84. package/dist/esm/components/common/index.js +2 -0
  85. package/dist/esm/components/common/logo.js +50 -49
  86. package/dist/esm/components/index.js +14 -0
  87. package/dist/esm/components/loader/iframe.js +16 -18
  88. package/dist/esm/components/loader/index.js +1 -0
  89. package/dist/esm/components/loader/loader.js +11 -40
  90. package/dist/esm/components/loader/remote/index.js +2 -0
  91. package/dist/esm/components/loader/remote/loader.js +118 -156
  92. package/dist/esm/components/loader/remote/render.js +12 -17
  93. package/dist/esm/components/overlay/index.js +1 -0
  94. package/dist/esm/components/overlay/overlay.js +54 -70
  95. package/dist/esm/components/status/error.js +7 -9
  96. package/dist/esm/components/status/exception.js +21 -37
  97. package/dist/esm/components/status/index.js +4 -0
  98. package/dist/esm/components/status/notAuthorized.js +7 -9
  99. package/dist/esm/components/status/notFound.js +7 -9
  100. package/dist/esm/config/color.js +288 -290
  101. package/dist/esm/directive/index.js +1 -0
  102. package/dist/esm/directive/permission.js +7 -27
  103. package/dist/esm/hooks/auth.js +154 -120
  104. package/dist/esm/hooks/config.js +11 -9
  105. package/dist/esm/hooks/data.js +416 -415
  106. package/dist/esm/hooks/export.js +32 -36
  107. package/dist/esm/hooks/exportCsv.js +42 -46
  108. package/dist/esm/hooks/form.js +86 -95
  109. package/dist/esm/hooks/formExtend.js +36 -40
  110. package/dist/esm/hooks/formValidate.js +22 -25
  111. package/dist/esm/hooks/i18n.js +14 -18
  112. package/dist/esm/hooks/import.js +45 -54
  113. package/dist/esm/hooks/importCsv.js +90 -83
  114. package/dist/esm/hooks/index.js +31 -0
  115. package/dist/esm/hooks/json/index.js +14 -22
  116. package/dist/esm/hooks/json/utils/contextManager.js +35 -26
  117. package/dist/esm/hooks/json/utils/expressionParser.js +100 -123
  118. package/dist/esm/hooks/json/vFor.js +50 -55
  119. package/dist/esm/hooks/json/vIf.js +17 -16
  120. package/dist/esm/hooks/json/vModel.js +96 -106
  121. package/dist/esm/hooks/json/vOn.js +30 -32
  122. package/dist/esm/hooks/json/vShow.js +20 -22
  123. package/dist/esm/hooks/json/vText.js +44 -51
  124. package/dist/esm/hooks/json.js +131 -132
  125. package/dist/esm/hooks/list.js +150 -184
  126. package/dist/esm/hooks/manage.js +25 -22
  127. package/dist/esm/hooks/menu.js +57 -61
  128. package/dist/esm/hooks/overlay.js +6 -23
  129. package/dist/esm/hooks/select.js +84 -94
  130. package/dist/esm/hooks/theme.js +289 -219
  131. package/dist/esm/hooks/tree.js +43 -47
  132. package/dist/esm/hooks/upload/index.js +2 -0
  133. package/dist/esm/hooks/upload/local.js +24 -30
  134. package/dist/esm/hooks/upload/s3.js +70 -80
  135. package/dist/esm/hooks/upload.js +256 -272
  136. package/dist/esm/index.js +150 -141
  137. package/dist/esm/main.js +24 -45
  138. package/dist/esm/preset/authProvider.js +62 -68
  139. package/dist/esm/preset/dataProvider.js +154 -180
  140. package/dist/esm/preset/i18nProvider.js +28 -30
  141. package/dist/esm/preset/index.js +3 -0
  142. package/dist/esm/provider/app.js +124 -151
  143. package/dist/esm/provider/index.js +2 -0
  144. package/dist/esm/provider/tab.js +49 -66
  145. package/dist/esm/router/index.js +1 -0
  146. package/dist/esm/router/route.js +39 -46
  147. package/dist/esm/stores/auth.js +51 -46
  148. package/dist/esm/stores/i18n.js +32 -29
  149. package/dist/esm/stores/index.js +7 -0
  150. package/dist/esm/stores/jsonSchema.js +47 -34
  151. package/dist/esm/stores/manage.js +63 -48
  152. package/dist/esm/stores/route.js +60 -56
  153. package/dist/esm/stores/tab.js +55 -60
  154. package/dist/esm/stores/theme.js +48 -55
  155. package/dist/esm/utils/bus.js +3 -5
  156. package/dist/esm/utils/index.js +3 -0
  157. package/dist/esm/utils/theme.js +110 -93
  158. package/dist/esm/utils/tree.js +28 -37
  159. package/package.json +1 -1
@@ -1,84 +1,91 @@
1
- import { useFileDialog as b } from "@vueuse/core";
2
- import { csv2json as A } from "json-2-csv";
3
- import { computed as g } from "vue";
4
- import { useImport as C } from "./import.js";
5
- function V(n) {
6
- const h = g(() => {
7
- const { csvOptions: e, ...o } = n;
8
- return o;
9
- }), E = g(() => {
10
- const e = n.csvOptions || {};
11
- return {
12
- delimiter: {
13
- field: e.delimiter || ",",
14
- wrap: e.wrap || '"',
15
- eol: e.eol || `
16
- `
17
- },
18
- excelBOM: e.excelBOM || !1,
19
- headerFields: e.headerFields,
20
- keys: e.keys,
21
- trimHeaderFields: e.trimHeaderFields || !1,
22
- trimFieldValues: e.trimFieldValues || !1
23
- };
24
- }), u = C({
25
- ...h.value
26
- }), y = async (e) => {
27
- const o = await e.arrayBuffer(), t = new Uint8Array(o), w = t.length >= 3 && t[0] === 239 && t[1] === 187 && t[2] === 191, B = t.length >= 2 && t[0] === 255 && t[1] === 254, M = t.length >= 2 && t[0] === 254 && t[1] === 255, m = n.encoding || "auto", c = (r, s) => {
28
- try {
29
- return new TextDecoder(r, { fatal: !1 }).decode(s || t);
30
- } catch {
31
- return "";
32
- }
33
- }, x = (r) => {
34
- if (!r) return { rep: Number.MAX_SAFE_INTEGER, ctrl: Number.MAX_SAFE_INTEGER };
35
- let s = 0, i = 0;
36
- for (let f = 0; f < r.length; f++) {
37
- const l = r.charCodeAt(f);
38
- l === 65533 && s++, l < 32 && l !== 9 && l !== 10 && l !== 13 && i++;
39
- }
40
- return { rep: s, ctrl: i };
41
- }, a = (r) => r.replace(/^\ufeff/, "");
42
- if (w)
43
- return a(c("utf-8"));
44
- if (B)
45
- return a(c("utf-16le"));
46
- if (M)
47
- return a(c("utf-16be"));
48
- if (m !== "auto")
49
- return a(c(m));
50
- const p = ["utf-8", "gb18030", "gbk"].map((r) => {
51
- const s = c(r), i = x(s);
52
- return { enc: r, text: s, sc: i };
53
- });
54
- return p.sort((r, s) => r.sc.rep - s.sc.rep || r.sc.ctrl - s.sc.ctrl), a(p[0].text);
55
- }, d = async (e) => {
56
- try {
57
- const o = await y(e), t = await A(o, E.value);
58
- t && t.length > 0 ? await u.trigger(t) : n.onError?.({
59
- message: "CSV 文件为空或格式不正确",
60
- status: 400
61
- });
62
- } catch (o) {
63
- n.onError?.({
64
- message: `CSV 解析错误: ${o}`,
65
- status: 500
66
- });
67
- }
68
- }, { open: O, reset: v, onChange: F } = b({
69
- accept: ".csv",
70
- multiple: !1
71
- });
72
- return F((e) => {
73
- e && e.length > 0 && d(e[0]);
74
- }), {
75
- ...u,
76
- open: () => {
77
- v(), O();
78
- },
79
- readFile: d
80
- };
1
+ import { useImport as e } from "./import.js";
2
+ import { computed as t } from "vue";
3
+ import { csv2json as n } from "json-2-csv";
4
+ import { useFileDialog as r } from "@vueuse/core";
5
+ function i(i) {
6
+ let a = t(() => {
7
+ let { csvOptions: e, ...t } = i;
8
+ return t;
9
+ }), o = t(() => {
10
+ let e = i.csvOptions || {};
11
+ return {
12
+ delimiter: {
13
+ field: e.delimiter || ",",
14
+ wrap: e.wrap || "\"",
15
+ eol: e.eol || "\n"
16
+ },
17
+ excelBOM: e.excelBOM || !1,
18
+ headerFields: e.headerFields,
19
+ keys: e.keys,
20
+ trimHeaderFields: e.trimHeaderFields || !1,
21
+ trimFieldValues: e.trimFieldValues || !1
22
+ };
23
+ }), s = e({ ...a.value }), c = async (e) => {
24
+ let t = await e.arrayBuffer(), n = new Uint8Array(t), r = n.length >= 3 && n[0] === 239 && n[1] === 187 && n[2] === 191, a = n.length >= 2 && n[0] === 255 && n[1] === 254, o = n.length >= 2 && n[0] === 254 && n[1] === 255, s = i.encoding || "auto", c = (e, t) => {
25
+ try {
26
+ return new TextDecoder(e, { fatal: !1 }).decode(t || n);
27
+ } catch {
28
+ return "";
29
+ }
30
+ }, l = (e) => {
31
+ if (!e) return {
32
+ rep: 2 ** 53 - 1,
33
+ ctrl: 2 ** 53 - 1
34
+ };
35
+ let t = 0, n = 0;
36
+ for (let r = 0; r < e.length; r++) {
37
+ let i = e.charCodeAt(r);
38
+ i === 65533 && t++, i < 32 && i !== 9 && i !== 10 && i !== 13 && n++;
39
+ }
40
+ return {
41
+ rep: t,
42
+ ctrl: n
43
+ };
44
+ }, u = (e) => e.replace(/^\ufeff/, "");
45
+ if (r) return u(c("utf-8"));
46
+ if (a) return u(c("utf-16le"));
47
+ if (o) return u(c("utf-16be"));
48
+ if (s !== "auto") return u(c(s));
49
+ let d = [
50
+ "utf-8",
51
+ "gb18030",
52
+ "gbk"
53
+ ].map((e) => {
54
+ let t = c(e);
55
+ return {
56
+ enc: e,
57
+ text: t,
58
+ sc: l(t)
59
+ };
60
+ });
61
+ return d.sort((e, t) => e.sc.rep - t.sc.rep || e.sc.ctrl - t.sc.ctrl), u(d[0].text);
62
+ }, l = async (e) => {
63
+ try {
64
+ let t = await n(await c(e), o.value);
65
+ t && t.length > 0 ? await s.trigger(t) : i.onError?.({
66
+ message: "CSV 文件为空或格式不正确",
67
+ status: 400
68
+ });
69
+ } catch (e) {
70
+ i.onError?.({
71
+ message: `CSV 解析错误: ${e}`,
72
+ status: 500
73
+ });
74
+ }
75
+ }, { open: u, reset: d, onChange: f } = r({
76
+ accept: ".csv",
77
+ multiple: !1
78
+ });
79
+ f((e) => {
80
+ e && e.length > 0 && l(e[0]);
81
+ });
82
+ let p = () => {
83
+ d(), u();
84
+ };
85
+ return {
86
+ ...s,
87
+ open: p,
88
+ readFile: l
89
+ };
81
90
  }
82
- export {
83
- V as useImportCsv
84
- };
91
+ export { i as useImportCsv };
@@ -0,0 +1,31 @@
1
+ import "../config/color.js";
2
+ import "./manage.js";
3
+ import "./auth.js";
4
+ import "./config.js";
5
+ import "./data.js";
6
+ import "./export.js";
7
+ import "./exportCsv.js";
8
+ import "./form.js";
9
+ import "./formValidate.js";
10
+ import "./formExtend.js";
11
+ import "./i18n.js";
12
+ import "./import.js";
13
+ import "./importCsv.js";
14
+ import "./json/vFor.js";
15
+ import "./json/vIf.js";
16
+ import "./json/vModel.js";
17
+ import "./json/vOn.js";
18
+ import "./json/vShow.js";
19
+ import "./json/vText.js";
20
+ import "./json/index.js";
21
+ import "./json.js";
22
+ import "./list.js";
23
+ import "./menu.js";
24
+ import "./overlay.js";
25
+ import "./select.js";
26
+ import "./theme.js";
27
+ import "./tree.js";
28
+ import "./upload/local.js";
29
+ import "./upload.js";
30
+ import "./upload/s3.js";
31
+ import "./upload/index.js";
@@ -1,23 +1,15 @@
1
- import { vForAdaptor as t } from "./vFor.js";
2
- import { vIfAdaptor as p } from "./vIf.js";
3
- import { vModelAdaptor as m } from "./vModel.js";
4
- import { vOnAdaptor as i } from "./vOn.js";
5
- import { vShowAdaptor as d } from "./vShow.js";
1
+ import { vForAdaptor as e } from "./vFor.js";
2
+ import { vIfAdaptor as t } from "./vIf.js";
3
+ import { vModelAdaptor as n } from "./vModel.js";
4
+ import { vOnAdaptor as r } from "./vOn.js";
5
+ import { vShowAdaptor as i } from "./vShow.js";
6
6
  import { vTextAdaptor as a } from "./vText.js";
7
- const n = [
8
- p,
9
- d,
10
- t,
11
- m,
12
- i,
13
- a
14
- ].sort((o, r) => r.priority - o.priority);
15
- export {
16
- n as defaultAdaptors,
17
- t as vForAdaptor,
18
- p as vIfAdaptor,
19
- m as vModelAdaptor,
20
- i as vOnAdaptor,
21
- d as vShowAdaptor,
22
- a as vTextAdaptor
23
- };
7
+ const o = [
8
+ t,
9
+ i,
10
+ e,
11
+ n,
12
+ r,
13
+ a
14
+ ].sort((e, t) => t.priority - e.priority);
15
+ export { o as defaultAdaptors };
@@ -1,31 +1,40 @@
1
- function o(e) {
2
- return e._context || {};
1
+ /**
2
+ * 从属性中提取上下文
3
+ */
4
+ function e(e) {
5
+ return e._context || {};
3
6
  }
4
- function c(e, n) {
5
- return Object.keys(n).length === 0 ? e : {
6
- ...e,
7
- _context: n
8
- };
7
+ /**
8
+ * 注入上下文到属性
9
+ */
10
+ function t(e, t) {
11
+ return Object.keys(t).length === 0 ? e : {
12
+ ...e,
13
+ _context: t
14
+ };
9
15
  }
10
- function u(e) {
11
- const { _context: n, ...t } = e;
12
- return t;
16
+ /**
17
+ * 清理属性中的内部字段
18
+ */
19
+ function n(e) {
20
+ let { _context: t, ...n } = e;
21
+ return n;
13
22
  }
14
- function a(e, n = {}) {
15
- const t = { ...e };
16
- return n.cleanKeys && n.cleanKeys.forEach((r) => delete t[r]), {
17
- props: t,
18
- skip: n.skip,
19
- nodes: n.nodes
20
- };
23
+ /**
24
+ * 创建适配器处理结果
25
+ */
26
+ function r(e, t = {}) {
27
+ let n = { ...e };
28
+ return t.cleanKeys && t.cleanKeys.forEach((e) => delete n[e]), {
29
+ props: n,
30
+ skip: t.skip,
31
+ nodes: t.nodes
32
+ };
21
33
  }
22
- function i(e, n, t) {
23
- return typeof e == "string" ? !!t(e, n) : !!e;
34
+ /**
35
+ * 通用条件求值函数
36
+ */
37
+ function i(e, t, n) {
38
+ return typeof e == "string" ? !!n(e, t) : !!e;
24
39
  }
25
- export {
26
- u as cleanProps,
27
- a as createAdaptorResult,
28
- i as evaluateCondition,
29
- o as extractContext,
30
- c as injectContext
31
- };
40
+ export { n as cleanProps, r as createAdaptorResult, i as evaluateCondition, e as extractContext, t as injectContext };
@@ -1,128 +1,105 @@
1
- import l from "jsep";
2
- import { unref as n } from "vue";
3
- l.addIdentifierChar("$");
4
- l.addIdentifierChar("@");
5
- function y(r) {
6
- try {
7
- return l(r);
8
- } catch (e) {
9
- return console.warn(`Expression parsing failed: ${r}`, e), null;
10
- }
1
+ import { unref as e } from "vue";
2
+ import t from "jsep";
3
+ t.addIdentifierChar("$"), t.addIdentifierChar("@");
4
+ function n(e) {
5
+ try {
6
+ return t(e);
7
+ } catch (t) {
8
+ return console.warn(`Expression parsing failed: ${e}`, t), null;
9
+ }
11
10
  }
12
- function m(r, e) {
13
- const t = y(r);
14
- if (t)
15
- return i(t, e);
11
+ function r(e, t) {
12
+ let r = n(e);
13
+ if (r) return i(r, t);
16
14
  }
17
- function i(r, e) {
18
- if (!(!r || typeof r != "object"))
19
- switch (r.type) {
20
- case "Literal":
21
- return r.value;
22
- case "Identifier":
23
- return v(e, r.name);
24
- case "MemberExpression": {
25
- const t = i(r.object, e);
26
- if (t == null)
27
- return;
28
- const s = r.computed ? i(r.property, e) : r.property?.name;
29
- return n(t)?.[s];
30
- }
31
- case "BinaryExpression": {
32
- const t = i(r.left, e), s = i(r.right, e);
33
- return {
34
- "+": () => t + s,
35
- "-": () => t - s,
36
- "*": () => t * s,
37
- "/": () => t / s,
38
- "%": () => t % s,
39
- "==": () => t === s,
40
- "===": () => t === s,
41
- "!=": () => t !== s,
42
- "!==": () => t !== s,
43
- "<": () => t < s,
44
- ">": () => t > s,
45
- "<=": () => t <= s,
46
- ">=": () => t >= s
47
- }[r.operator]?.() ?? void 0;
48
- }
49
- case "LogicalExpression": {
50
- const t = i(r.left, e);
51
- return r.operator === "&&" ? t && i(r.right, e) : r.operator === "||" ? t || i(r.right, e) : r.operator === "??" ? t ?? i(r.right, e) : void 0;
52
- }
53
- case "UnaryExpression": {
54
- const t = i(r.argument, e);
55
- return r.operator === "!" ? !t : r.operator === "-" ? -t : r.operator === "+" ? +t : void 0;
56
- }
57
- case "ConditionalExpression": {
58
- const t = i(r.test, e);
59
- return i(t ? r.consequent : r.alternate, e);
60
- }
61
- case "CallExpression": {
62
- const t = i(r.callee, e), s = n(t);
63
- if (typeof s != "function") {
64
- console.warn("Attempting to call non-function value:", s);
65
- return;
66
- }
67
- const u = Array.isArray(r.arguments) ? r.arguments.map((a) => {
68
- const p = i(a, e);
69
- return n(p);
70
- }) : [];
71
- try {
72
- let a;
73
- if (r.callee.type === "MemberExpression") {
74
- const p = i(r.callee.object, e);
75
- a = n(p);
76
- }
77
- return s.apply(a, u);
78
- } catch (a) {
79
- console.warn("Function call error:", a);
80
- return;
81
- }
82
- }
83
- case "ArrayExpression":
84
- return Array.isArray(r.elements) ? r.elements.map((t) => {
85
- if (!t)
86
- return;
87
- const s = i(t, e);
88
- return n(s);
89
- }) : [];
90
- default:
91
- console.warn(`Unsupported expression type: ${r.type}`);
92
- return;
93
- }
15
+ function i(t, n) {
16
+ if (!(!t || typeof t != "object")) switch (t.type) {
17
+ case "Literal": return t.value;
18
+ case "Identifier": return a(n, t.name);
19
+ case "MemberExpression": {
20
+ let r = i(t.object, n);
21
+ if (r == null) return;
22
+ let a = t.computed ? i(t.property, n) : t.property?.name;
23
+ return e(r)?.[a];
24
+ }
25
+ case "BinaryExpression": {
26
+ let e = i(t.left, n), r = i(t.right, n);
27
+ return {
28
+ "+": () => e + r,
29
+ "-": () => e - r,
30
+ "*": () => e * r,
31
+ "/": () => e / r,
32
+ "%": () => e % r,
33
+ "==": () => e === r,
34
+ "===": () => e === r,
35
+ "!=": () => e !== r,
36
+ "!==": () => e !== r,
37
+ "<": () => e < r,
38
+ ">": () => e > r,
39
+ "<=": () => e <= r,
40
+ ">=": () => e >= r
41
+ }[t.operator]?.() ?? void 0;
42
+ }
43
+ case "LogicalExpression": {
44
+ let e = i(t.left, n);
45
+ return t.operator === "&&" ? e && i(t.right, n) : t.operator === "||" ? e || i(t.right, n) : t.operator === "??" ? e ?? i(t.right, n) : void 0;
46
+ }
47
+ case "UnaryExpression": {
48
+ let e = i(t.argument, n);
49
+ return t.operator === "!" ? !e : t.operator === "-" ? -e : t.operator === "+" ? +e : void 0;
50
+ }
51
+ case "ConditionalExpression": return i(t.test, n) ? i(t.consequent, n) : i(t.alternate, n);
52
+ case "CallExpression": {
53
+ let r = e(i(t.callee, n));
54
+ if (typeof r != "function") {
55
+ console.warn("Attempting to call non-function value:", r);
56
+ return;
57
+ }
58
+ let a = Array.isArray(t.arguments) ? t.arguments.map((t) => e(i(t, n))) : [];
59
+ try {
60
+ let o;
61
+ return t.callee.type === "MemberExpression" && (o = e(i(t.callee.object, n))), r.apply(o, a);
62
+ } catch (e) {
63
+ console.warn("Function call error:", e);
64
+ return;
65
+ }
66
+ }
67
+ case "ArrayExpression": return Array.isArray(t.elements) ? t.elements.map((t) => {
68
+ if (t) return e(i(t, n));
69
+ }) : [];
70
+ default:
71
+ console.warn(`Unsupported expression type: ${t.type}`);
72
+ return;
73
+ }
94
74
  }
95
- function v(r, e) {
96
- if (!(!e || !r))
97
- try {
98
- return e.split(".").reduce((t, s) => t == null ? void 0 : n(t)?.[s], r);
99
- } catch {
100
- return;
101
- }
75
+ function a(t, n) {
76
+ if (!(!n || !t)) try {
77
+ return n.split(".").reduce((t, n) => {
78
+ if (t != null) return e(t)?.[n];
79
+ }, t);
80
+ } catch {
81
+ return;
82
+ }
102
83
  }
103
- function E(r, e) {
104
- const t = r.trim(), s = t.match(/^\((\w+),\s*(\w+)\) in (.+)$/);
105
- if (s) {
106
- const [, a, p, c] = s, o = m(c, e), f = n(o);
107
- return {
108
- items: Array.isArray(f) ? f : [],
109
- itemName: a,
110
- indexName: p
111
- };
112
- }
113
- const u = t.match(/^(\w+) in (.+)$/);
114
- if (u) {
115
- const [, a, p] = u, c = m(p, e), o = n(c);
116
- return {
117
- items: Array.isArray(o) ? o : [],
118
- itemName: a,
119
- indexName: "index"
120
- };
121
- }
122
- throw new Error(`Invalid v-for expression: ${r}`);
84
+ function o(t, n) {
85
+ let i = t.trim(), a = i.match(/^\((\w+),\s*(\w+)\) in (.+)$/);
86
+ if (a) {
87
+ let [, t, i, o] = a, s = e(r(o, n));
88
+ return {
89
+ items: Array.isArray(s) ? s : [],
90
+ itemName: t,
91
+ indexName: i
92
+ };
93
+ }
94
+ let o = i.match(/^(\w+) in (.+)$/);
95
+ if (o) {
96
+ let [, t, i] = o, a = e(r(i, n));
97
+ return {
98
+ items: Array.isArray(a) ? a : [],
99
+ itemName: t,
100
+ indexName: "index"
101
+ };
102
+ }
103
+ throw Error(`Invalid v-for expression: ${t}`);
123
104
  }
124
- export {
125
- m as evaluateExpression,
126
- y as parseExpression,
127
- E as parseVForExpression
128
- };
105
+ export { r as evaluateExpression, o as parseVForExpression };
@@ -1,56 +1,51 @@
1
- import { extractContext as c, injectContext as f, cleanProps as x } from "./utils/contextManager.js";
2
- import { parseVForExpression as u } from "./utils/expressionParser.js";
3
- const y = {
4
- name: "v-for",
5
- priority: 90,
6
- process(r, n) {
7
- const e = r.attrs?.["v-for"] || r.attrs?.vFor;
8
- if (!e)
9
- return null;
10
- const o = { ...r.attrs };
11
- delete o["v-for"], delete o.vFor;
12
- const i = c(n);
13
- let t;
14
- try {
15
- if (Array.isArray(e))
16
- t = {
17
- items: e,
18
- itemName: "item",
19
- indexName: "index"
20
- };
21
- else if (typeof e == "object" && e.list)
22
- t = {
23
- items: Array.isArray(e.list) ? e.list : [],
24
- itemName: e.item || "item",
25
- indexName: e.index || "index"
26
- };
27
- else if (typeof e == "string")
28
- t = u(e, i);
29
- else
30
- return console.warn("Unsupported v-for format:", e), null;
31
- } catch (s) {
32
- return console.warn("v-for parsing failed:", s), null;
33
- }
34
- const m = t.items.map((s, a) => {
35
- const l = {
36
- [t.itemName]: s,
37
- [t.indexName]: a
38
- }, p = { ...i, ...l };
39
- return {
40
- ...r,
41
- attrs: {
42
- ...o,
43
- key: `${t.itemName}_${a}`,
44
- ...f({}, p)
45
- }
46
- };
47
- });
48
- return {
49
- props: x(n),
50
- nodes: m
51
- };
52
- }
53
- };
54
- export {
55
- y as vForAdaptor
1
+ import { cleanProps as e, extractContext as t, injectContext as n } from "./utils/contextManager.js";
2
+ import { parseVForExpression as r } from "./utils/expressionParser.js";
3
+ const i = {
4
+ name: "v-for",
5
+ priority: 90,
6
+ process(i, a) {
7
+ let o = i.attrs?.["v-for"] || i.attrs?.vFor;
8
+ if (!o) return null;
9
+ let s = { ...i.attrs };
10
+ delete s["v-for"], delete s.vFor;
11
+ let c = t(a), l;
12
+ try {
13
+ if (Array.isArray(o)) l = {
14
+ items: o,
15
+ itemName: "item",
16
+ indexName: "index"
17
+ };
18
+ else if (typeof o == "object" && o.list) l = {
19
+ items: Array.isArray(o.list) ? o.list : [],
20
+ itemName: o.item || "item",
21
+ indexName: o.index || "index"
22
+ };
23
+ else if (typeof o == "string") l = r(o, c);
24
+ else return console.warn("Unsupported v-for format:", o), null;
25
+ } catch (e) {
26
+ return console.warn("v-for parsing failed:", e), null;
27
+ }
28
+ let u = l.items.map((e, t) => {
29
+ let r = {
30
+ [l.itemName]: e,
31
+ [l.indexName]: t
32
+ }, a = {
33
+ ...c,
34
+ ...r
35
+ };
36
+ return {
37
+ ...i,
38
+ attrs: {
39
+ ...s,
40
+ key: `${l.itemName}_${t}`,
41
+ ...n({}, a)
42
+ }
43
+ };
44
+ });
45
+ return {
46
+ props: e(a),
47
+ nodes: u
48
+ };
49
+ }
56
50
  };
51
+ export { i as vForAdaptor };