@agile-team/mach-report 2.6.1 → 2.8.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 (61) hide show
  1. package/README.md +59 -8
  2. package/dist/ReportPreview-BKKDAv8e.js +4481 -0
  3. package/dist/ReportPreview-E3cm67Tk.cjs +6 -0
  4. package/dist/{assets-NVA_sftu.js → assets-B9qJku3V.js} +54 -57
  5. package/dist/assets-RZan7EyL.cjs +1 -0
  6. package/dist/capabilities-joSutDF8.js +63 -0
  7. package/dist/capabilities-xGTpnPjJ.cjs +1 -0
  8. package/dist/designer.cjs +1 -1
  9. package/dist/designer.d.cts +922 -753
  10. package/dist/designer.d.ts +922 -753
  11. package/dist/designer.js +490 -234
  12. package/dist/index.cjs +8 -8
  13. package/dist/index.d.cts +128 -3
  14. package/dist/index.d.ts +128 -3
  15. package/dist/index.js +971 -699
  16. package/dist/pdf.cjs +30 -30
  17. package/dist/pdf.d.cts +11 -3
  18. package/dist/pdf.d.ts +11 -3
  19. package/dist/pdf.js +1501 -1500
  20. package/dist/{plugin-Ds10VnQO.js → plugin-PCgxBVB2.js} +1 -1
  21. package/dist/{plugin-BqBkn_kI.cjs → plugin-mAfvgSey.cjs} +1 -1
  22. package/dist/progress-DD964VAB.js +102 -0
  23. package/dist/progress-KvhwXZ1Q.cjs +1 -0
  24. package/dist/{report-source-B9bENO0F.js → report-source-BXHNy_AD.js} +337 -332
  25. package/dist/report-source-CCAvFE3t.cjs +1 -0
  26. package/dist/server/node.d.cts +26 -3
  27. package/dist/server/node.d.ts +26 -3
  28. package/dist/server-node.cjs +1 -1
  29. package/dist/server-node.js +125 -92
  30. package/dist/server.cjs +1 -1
  31. package/dist/server.d.cts +28 -3
  32. package/dist/server.d.ts +28 -3
  33. package/dist/server.js +172 -164
  34. package/dist/style.css +1 -1
  35. package/dist/task-events-DQ276fn2.cjs +1 -0
  36. package/dist/task-events-Dpsvf_t2.js +47 -0
  37. package/dist/vue/async.d.cts +1553 -2083
  38. package/dist/vue/async.d.ts +1553 -2083
  39. package/dist/vue/index.d.cts +2465 -3310
  40. package/dist/vue/index.d.ts +2465 -3310
  41. package/dist/vue-async.cjs +1 -1
  42. package/dist/vue-async.js +3 -3
  43. package/dist/vue.cjs +1 -1
  44. package/dist/vue.js +159 -132
  45. package/dist/worker.cjs +1 -1
  46. package/dist/worker.d.cts +26 -3
  47. package/dist/worker.d.ts +26 -3
  48. package/dist/worker.js +110 -85
  49. package/dist/xlsx.cjs +14 -14
  50. package/dist/xlsx.d.cts +11 -3
  51. package/dist/xlsx.d.ts +11 -3
  52. package/dist/xlsx.js +656 -652
  53. package/package.json +2 -2
  54. package/dist/ReportPreview-Dk-28QAi.js +0 -2946
  55. package/dist/ReportPreview-FSvcBLjH.cjs +0 -6
  56. package/dist/assets-66UBlhES.cjs +0 -1
  57. package/dist/capabilities-CNjIirfo.js +0 -36
  58. package/dist/capabilities-D4xeVYSR.cjs +0 -1
  59. package/dist/grid-geometry-BNptEcMm.js +0 -65
  60. package/dist/grid-geometry-CZ_cYB6O.cjs +0 -1
  61. package/dist/report-source-BbNkkBDy.cjs +0 -1
package/dist/worker.js CHANGED
@@ -1,133 +1,158 @@
1
- import { c as v } from "./validate-S6CgIm5d.js";
1
+ import { n as A } from "./task-events-Dpsvf_t2.js";
2
+ import { c as M } from "./validate-S6CgIm5d.js";
2
3
  const u = "mach-report-worker/1";
3
4
  class R extends Error {
4
- constructor(e) {
5
- super(e.message), this.name = e.name, this.code = e.code, this.path = e.path, this.issues = e.issues;
5
+ constructor(r) {
6
+ super(r.message), this.name = r.name, this.code = r.code, this.path = r.path, this.issues = r.issues, this.diagnostics = r.diagnostics;
6
7
  }
7
8
  }
8
- function m(r) {
9
- return !!r && typeof r == "object" && !Array.isArray(r);
9
+ function p(e) {
10
+ return !!e && typeof e == "object" && !Array.isArray(e);
10
11
  }
11
- function x(r) {
12
- return m(r) ? ["rows", "pages", "cells"].every((e) => typeof r[e] == "number" && Number.isSafeInteger(r[e]) && r[e] >= 0) && typeof r.durationMs == "number" && Number.isFinite(r.durationMs) && r.durationMs >= 0 : !1;
12
+ function L(e) {
13
+ return p(e) ? ["rows", "pages", "cells"].every((r) => typeof e[r] == "number" && Number.isSafeInteger(e[r]) && e[r] >= 0) && typeof e.durationMs == "number" && Number.isFinite(e.durationMs) && e.durationMs >= 0 : !1;
13
14
  }
14
- function M(r) {
15
- return Array.isArray(r) && r.every((e) => m(e) && typeof e.code == "string" && typeof e.message == "string" && ["info", "warning", "error"].includes(e.severity));
15
+ function P(e) {
16
+ return Array.isArray(e) && e.every((r) => p(r) && typeof r.code == "string" && typeof r.message == "string" && ["info", "warning", "error"].includes(r.severity));
16
17
  }
17
- function L(r) {
18
- return m(r) && Object.values(r).every((e) => m(e) && (e.revision === void 0 || typeof e.revision == "string") && (e.sourceToken === void 0 || typeof e.sourceToken == "string"));
18
+ function T(e) {
19
+ return p(e) && Object.values(e).every((r) => p(r) && (r.revision === void 0 || typeof r.revision == "string") && (r.sourceToken === void 0 || typeof r.sourceToken == "string"));
19
20
  }
20
- function A(r, e) {
21
- if (!m(r) || !x(r.stats) || !M(r.diagnostics) || !L(r.revisions)) return !1;
22
- if (e === "prepare") return v(r.plan).ok;
23
- const t = r.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
24
- return r.bytes instanceof Uint8Array && (r.format === "pdf" || r.format === "xlsx") && r.contentType === t;
21
+ function j(e, r) {
22
+ if (!p(e) || !L(e.stats) || !P(e.diagnostics) || !T(e.revisions)) return !1;
23
+ if (r === "prepare") return M(e.plan).ok;
24
+ const t = e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
25
+ return e.bytes instanceof Uint8Array && (e.format === "pdf" || e.format === "xlsx") && e.contentType === t;
25
26
  }
26
- function T(r) {
27
- if (!r || typeof r != "object") return { message: String(r) };
28
- const e = {};
27
+ function I(e) {
28
+ if (!e || typeof e != "object") return { message: String(e) };
29
+ const r = {};
29
30
  for (const t of ["code", "path", "field", "message"]) {
30
- const o = r[t];
31
- typeof o == "string" && (e[t] = o);
31
+ const o = e[t];
32
+ typeof o == "string" && (r[t] = o);
32
33
  }
33
- return e;
34
- }
35
- function j(r) {
36
- if (!(r instanceof Error)) return { name: "Error", message: String(r) };
37
- const e = r;
34
+ return r;
35
+ }
36
+ function O(e) {
37
+ const r = I(e);
38
+ if (!p(e)) return r;
39
+ for (const t of ["format", "severity", "kind", "nid"]) typeof e[t] == "string" && (r[t] = e[t]);
40
+ for (const t of ["pageIndex", "componentIndex"]) Number.isSafeInteger(e[t]) && e[t] >= 0 && (r[t] = e[t]);
41
+ return Array.isArray(e.componentPath) && e.componentPath.every((t) => Number.isSafeInteger(t) && t >= 0) && (r.componentPath = e.componentPath), r;
42
+ }
43
+ function N(e) {
44
+ if (!(e instanceof Error)) return { name: "Error", message: String(e) };
45
+ const r = e;
38
46
  return {
39
- name: r.name,
40
- message: r.message,
41
- ...typeof e.code == "string" ? { code: e.code } : {},
42
- ...typeof e.path == "string" ? { path: e.path } : {},
43
- ...Array.isArray(e.issues) ? { issues: e.issues.map(T) } : {}
47
+ name: e.name,
48
+ message: e.message,
49
+ ...typeof r.code == "string" ? { code: r.code } : {},
50
+ ...typeof r.path == "string" ? { path: r.path } : {},
51
+ ...Array.isArray(r.issues) ? { issues: r.issues.map(I) } : {},
52
+ ...Array.isArray(r.diagnostics) ? { diagnostics: r.diagnostics.map(O) } : {}
44
53
  };
45
54
  }
46
- function O(r) {
47
- if (!r || typeof r != "object") return !1;
48
- const e = r;
49
- return e.protocol === u && typeof e.id == "string" && (e.operation === "prepare" || e.operation === "export") && !!e.input && typeof e.input == "object";
55
+ function v(e) {
56
+ if (!e || typeof e != "object") return !1;
57
+ const r = e;
58
+ return r.protocol === u && typeof r.id == "string" && (r.operation === "prepare" || r.operation === "export") && !!r.input && typeof r.input == "object";
50
59
  }
51
- async function P(r, e) {
60
+ async function S(e, r, t) {
52
61
  try {
53
- const t = e.operation === "prepare" ? await r.prepare(e.input) : await r.export(e.input);
54
- return { protocol: u, id: e.id, result: t };
55
- } catch (t) {
56
- return { protocol: u, id: e.id, error: j(t) };
62
+ const o = r.operation === "prepare" ? await e.prepare({ ...r.input, onEvent: t }) : await e.export({ ...r.input, onEvent: t });
63
+ return { protocol: u, id: r.id, result: o };
64
+ } catch (o) {
65
+ return { protocol: u, id: r.id, error: N(o) };
57
66
  }
58
67
  }
59
- function N(r) {
60
- const e = r.result;
61
- return !e || !("bytes" in e) || !(e.bytes.buffer instanceof ArrayBuffer) ? [] : [e.bytes.buffer];
68
+ function z(e) {
69
+ const r = e.result;
70
+ return !r || !("bytes" in r) || !(r.bytes.buffer instanceof ArrayBuffer) ? [] : [r.bytes.buffer];
71
+ }
72
+ function _(e, r) {
73
+ if (!p(e) || typeof e.taskId != "string" || !e.taskId || r.taskId !== void 0 && e.taskId !== r.taskId || e.correlationId !== r.correlationId || e.reportId !== void 0 && (typeof e.reportId != "string" || !r.reportIds.includes(e.reportId)) || !["query", "validate", "layout", "encode"].includes(e.stage) || !["started", "completed", "failed"].includes(e.status)) return !1;
74
+ for (const t of ["completed", "total"]) if (e[t] !== void 0 && (typeof e[t] != "number" || !Number.isFinite(e[t]) || e[t] < 0)) return !1;
75
+ return e.completed === void 0 || e.total === void 0 || e.completed <= e.total;
62
76
  }
63
- let S = 0;
64
- function w(r) {
65
- const e = new Error("报表 Worker 任务已取消");
66
- return e.name = "AbortError", Object.defineProperty(e, "cause", { value: r }), e;
77
+ let F = 0;
78
+ function w(e) {
79
+ const r = new Error("报表 Worker 任务已取消");
80
+ return r.name = "AbortError", Object.defineProperty(r, "cause", { value: e }), r;
67
81
  }
68
- function $(r, e) {
69
- if (!r || typeof r != "object") return;
70
- const t = r;
71
- return t.protocol === u && t.id === e ? t : void 0;
82
+ function $(e, r) {
83
+ if (!e || typeof e != "object") return;
84
+ const t = e;
85
+ return t.protocol === u && t.id === r ? t : void 0;
72
86
  }
73
- function z(r, e = {}) {
74
- const t = e.timeoutMs ?? 12e4;
87
+ function B(e, r = {}) {
88
+ const t = r.timeoutMs ?? 12e4;
75
89
  if (!Number.isFinite(t) || t <= 0 || t > 2147483647) throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");
76
- const o = (s, c, n) => n?.aborted ? Promise.reject(w(n.reason)) : new Promise((p, g) => {
77
- let d;
90
+ const o = (i, c, n, d) => n?.aborted ? Promise.reject(w(n.reason)) : new Promise((W, b) => {
91
+ let g;
78
92
  try {
79
- d = r();
80
- } catch (i) {
81
- g(i);
93
+ g = e();
94
+ } catch (a) {
95
+ b(a);
82
96
  return;
83
97
  }
84
- const l = `mach-report-${Date.now()}-${++S}`;
85
- let b = !1, y = () => {
86
- }, E;
87
- const f = (i, a) => {
88
- b || (b = !0, E && clearTimeout(E), y(), n?.removeEventListener("abort", h), Promise.resolve().then(() => d.terminate()).then(
89
- () => i === void 0 ? p(a) : g(i),
90
- (W) => g(i ?? W)
98
+ const l = `mach-report-${Date.now()}-${++F}`;
99
+ let y = !1, E = () => {
100
+ }, h;
101
+ const f = (a, s) => {
102
+ y || (y = !0, h && clearTimeout(h), E(), n?.removeEventListener("abort", k), Promise.resolve().then(() => g.terminate()).then(
103
+ () => a === void 0 ? W(s) : b(a),
104
+ (m) => b(a ?? m)
91
105
  ));
92
- }, h = () => f(w(n?.reason)), k = (i) => {
93
- const a = $(i, l);
94
- a && (a.error && typeof a.error.name == "string" && typeof a.error.message == "string" ? f(new R(a.error)) : A(a.result, s) && (s !== "export" || "format" in a.result && "format" in c && a.result.format === c.format) ? f(void 0, a.result) : f(new Error("报表 Worker 返回无效响应")));
106
+ }, k = () => f(w(n?.reason)), x = (a) => {
107
+ const s = $(a, l);
108
+ if (!(!s || y)) {
109
+ if ("type" in s && s.type === "event") {
110
+ const m = "event" in s ? s.event : void 0;
111
+ _(m, c) ? A(d, m, n) : f(new Error("报表 Worker 返回无效阶段事件"));
112
+ return;
113
+ }
114
+ s.error && typeof s.error.name == "string" && typeof s.error.message == "string" ? f(new R(s.error)) : j(s.result, i) && (i !== "export" || "format" in s.result && "format" in c && s.result.format === c.format) ? f(void 0, s.result) : f(new Error("报表 Worker 返回无效响应"));
115
+ }
95
116
  };
96
117
  try {
97
- if (y = d.subscribe(k, (i) => f(i ?? new Error("报表 Worker 执行失败"))), b) {
98
- y();
118
+ if (E = g.subscribe(x, (a) => f(a ?? new Error("报表 Worker 执行失败"))), y) {
119
+ E();
99
120
  return;
100
121
  }
101
- n?.addEventListener("abort", h, { once: !0 }), E = setTimeout(() => f(new R({ name: "ReportRuntimeError", code: "timeout", message: `报表 Worker 执行超过 ${t}ms` })), t), n?.aborted ? h() : d.postMessage({ protocol: u, id: l, operation: s, input: c });
102
- } catch (i) {
103
- f(i);
122
+ if (n?.addEventListener("abort", k, { once: !0 }), h = setTimeout(() => f(new R({ name: "ReportRuntimeError", code: "timeout", message: `报表 Worker 执行超过 ${t}ms` })), t), n?.aborted) k();
123
+ else {
124
+ const { onEvent: a, signal: s, ...m } = c;
125
+ g.postMessage({ protocol: u, id: l, operation: i, input: m });
126
+ }
127
+ } catch (a) {
128
+ f(a);
104
129
  }
105
130
  });
106
- return { prepare: (s, c) => o("prepare", s, c), export: (s, c) => o("export", s, c) };
131
+ return { prepare: (i, c, n) => o("prepare", i, c, n), export: (i, c, n) => o("export", i, c, n) };
107
132
  }
108
- function F(r, e = {}) {
109
- return z(() => {
110
- const t = r();
133
+ function C(e, r = {}) {
134
+ return B(() => {
135
+ const t = e();
111
136
  return {
112
137
  postMessage: (o) => t.postMessage(o),
113
138
  terminate: () => t.terminate(),
114
- subscribe: (o, s) => {
115
- const c = (p) => o(p.data), n = (p) => s(p instanceof ErrorEvent ? new Error(p.message) : new Error("报表 Worker 消息无法解码"));
139
+ subscribe: (o, i) => {
140
+ const c = (d) => o(d.data), n = (d) => i(d instanceof ErrorEvent ? new Error(d.message) : new Error("报表 Worker 消息无法解码"));
116
141
  return t.addEventListener("message", c), t.addEventListener("error", n), t.addEventListener("messageerror", n), () => {
117
142
  t.removeEventListener("message", c), t.removeEventListener("error", n), t.removeEventListener("messageerror", n);
118
143
  };
119
144
  }
120
145
  };
121
- }, e);
146
+ }, r);
122
147
  }
123
- function I(r, e = globalThis) {
148
+ function K(e, r = globalThis) {
124
149
  const t = (o) => {
125
- O(o.data) && P(r, o.data).then((s) => e.postMessage(s, N(s)));
150
+ v(o.data) && S(e, o.data, (i) => r.postMessage({ protocol: u, id: o.data.id, type: "event", event: i })).then((i) => r.postMessage(i, z(i)));
126
151
  };
127
- return e.addEventListener("message", t), () => e.removeEventListener("message", t);
152
+ return r.addEventListener("message", t), () => r.removeEventListener("message", t);
128
153
  }
129
154
  export {
130
155
  R as ReportWorkerError,
131
- F as createBrowserReportExecutor,
132
- I as serveReportWorker
156
+ C as createBrowserReportExecutor,
157
+ K as serveReportWorker
133
158
  };