@agile-team/mach-report 2.5.0 → 2.7.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 (86) hide show
  1. package/README.md +126 -16
  2. package/dist/ReportPreview-BdvoqdOd.cjs +6 -0
  3. package/dist/ReportPreview-COFkbeEM.js +3719 -0
  4. package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
  5. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  6. package/dist/analytics.cjs +1 -0
  7. package/dist/analytics.d.cts +276 -0
  8. package/dist/analytics.d.ts +276 -0
  9. package/dist/analytics.js +223 -0
  10. package/dist/assets-B9qJku3V.js +160 -0
  11. package/dist/assets-RZan7EyL.cjs +1 -0
  12. package/dist/capabilities-joSutDF8.js +63 -0
  13. package/dist/capabilities-xGTpnPjJ.cjs +1 -0
  14. package/dist/designer.cjs +1 -0
  15. package/dist/designer.d.cts +869 -0
  16. package/dist/designer.d.ts +869 -0
  17. package/dist/designer.js +628 -0
  18. package/dist/index.cjs +8 -5
  19. package/dist/index.d.cts +497 -9
  20. package/dist/index.d.ts +497 -9
  21. package/dist/index.js +1088 -1499
  22. package/dist/param-validation-BWNjLcN0.js +116 -0
  23. package/dist/param-validation-CiTxFeZ8.cjs +1 -0
  24. package/dist/pdf.cjs +48 -48
  25. package/dist/pdf.d.cts +119 -1
  26. package/dist/pdf.d.ts +119 -1
  27. package/dist/pdf.js +3932 -3868
  28. package/dist/{plugin-DMPLDpBY.cjs → plugin-9t_ZFwhz.cjs} +1 -1
  29. package/dist/{plugin-DDLcFWlk.js → plugin-s8Ay8kKk.js} +2 -2
  30. package/dist/progress-DD964VAB.js +102 -0
  31. package/dist/progress-KvhwXZ1Q.cjs +1 -0
  32. package/dist/render-plan-CckPEQyf.cjs +1 -0
  33. package/dist/{render-plan-CXBWRog4.js → render-plan-uzZYYSy1.js} +11 -10
  34. package/dist/report-params-B_VCihAh.js +12 -0
  35. package/dist/report-params-CjWrjPl6.cjs +1 -0
  36. package/dist/report-source-BXHNy_AD.js +755 -0
  37. package/dist/report-source-CCAvFE3t.cjs +1 -0
  38. package/dist/server/node.d.cts +320 -0
  39. package/dist/server/node.d.ts +320 -0
  40. package/dist/server-node.cjs +1 -0
  41. package/dist/server-node.js +303 -0
  42. package/dist/server.cjs +1 -0
  43. package/dist/server.d.cts +668 -0
  44. package/dist/server.d.ts +668 -0
  45. package/dist/server.js +245 -0
  46. package/dist/style-CpwiOPyB.cjs +1 -0
  47. package/dist/style-Dv5o_x6b.js +67 -0
  48. package/dist/style.css +1 -1
  49. package/dist/task-events-DQ276fn2.cjs +1 -0
  50. package/dist/task-events-Dpsvf_t2.js +47 -0
  51. package/dist/template-registry-DWExx0gU.cjs +1 -0
  52. package/dist/template-registry-NpOakidD.js +354 -0
  53. package/dist/textwrap-CnGsEum6.cjs +4 -0
  54. package/dist/textwrap-DOl04hCQ.js +110 -0
  55. package/dist/validate-DfHPD8wX.cjs +1 -0
  56. package/dist/validate-S6CgIm5d.js +148 -0
  57. package/dist/vue/async.d.cts +1507 -1538
  58. package/dist/vue/async.d.ts +1507 -1538
  59. package/dist/vue/index.d.cts +2376 -2347
  60. package/dist/vue/index.d.ts +2376 -2347
  61. package/dist/vue-async.cjs +1 -1
  62. package/dist/vue-async.js +3 -3
  63. package/dist/vue.cjs +1 -1
  64. package/dist/vue.js +184 -75
  65. package/dist/worker.cjs +1 -0
  66. package/dist/worker.d.cts +325 -0
  67. package/dist/worker.d.ts +325 -0
  68. package/dist/worker.js +158 -0
  69. package/dist/xlsx/node.d.cts +47 -0
  70. package/dist/xlsx/node.d.ts +47 -0
  71. package/dist/xlsx-node.cjs +221 -0
  72. package/dist/xlsx-node.js +36409 -0
  73. package/dist/xlsx.cjs +20 -20
  74. package/dist/xlsx.d.cts +87 -2
  75. package/dist/xlsx.d.ts +87 -2
  76. package/dist/xlsx.js +5987 -5840
  77. package/package.json +63 -3
  78. package/dist/ReportPreview-CBKLI--k.js +0 -2188
  79. package/dist/ReportPreview-ClM8h0pM.cjs +0 -6
  80. package/dist/grid-geometry-BNIvw52m.cjs +0 -1
  81. package/dist/grid-geometry-C8hGoe9o.js +0 -130
  82. package/dist/render-plan-CCTL4F9v.cjs +0 -1
  83. package/dist/report-params-B3Fia6JO.js +0 -10
  84. package/dist/report-params-D1gZ1DME.cjs +0 -1
  85. package/dist/textwrap-nH0UYU6D.js +0 -108
  86. package/dist/textwrap-oD-t4b4B.cjs +0 -4
package/dist/worker.js ADDED
@@ -0,0 +1,158 @@
1
+ import { n as A } from "./task-events-Dpsvf_t2.js";
2
+ import { c as M } from "./validate-S6CgIm5d.js";
3
+ const u = "mach-report-worker/1";
4
+ class R extends Error {
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;
7
+ }
8
+ }
9
+ function p(e) {
10
+ return !!e && typeof e == "object" && !Array.isArray(e);
11
+ }
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;
14
+ }
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));
17
+ }
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"));
20
+ }
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;
26
+ }
27
+ function I(e) {
28
+ if (!e || typeof e != "object") return { message: String(e) };
29
+ const r = {};
30
+ for (const t of ["code", "path", "field", "message"]) {
31
+ const o = e[t];
32
+ typeof o == "string" && (r[t] = o);
33
+ }
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;
46
+ return {
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) } : {}
53
+ };
54
+ }
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";
59
+ }
60
+ async function S(e, r, t) {
61
+ try {
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) };
66
+ }
67
+ }
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;
76
+ }
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;
81
+ }
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;
86
+ }
87
+ function B(e, r = {}) {
88
+ const t = r.timeoutMs ?? 12e4;
89
+ if (!Number.isFinite(t) || t <= 0 || t > 2147483647) throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");
90
+ const o = (i, c, n, d) => n?.aborted ? Promise.reject(w(n.reason)) : new Promise((W, b) => {
91
+ let g;
92
+ try {
93
+ g = e();
94
+ } catch (a) {
95
+ b(a);
96
+ return;
97
+ }
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)
105
+ ));
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
+ }
116
+ };
117
+ try {
118
+ if (E = g.subscribe(x, (a) => f(a ?? new Error("报表 Worker 执行失败"))), y) {
119
+ E();
120
+ return;
121
+ }
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);
129
+ }
130
+ });
131
+ return { prepare: (i, c, n) => o("prepare", i, c, n), export: (i, c, n) => o("export", i, c, n) };
132
+ }
133
+ function C(e, r = {}) {
134
+ return B(() => {
135
+ const t = e();
136
+ return {
137
+ postMessage: (o) => t.postMessage(o),
138
+ terminate: () => t.terminate(),
139
+ subscribe: (o, i) => {
140
+ const c = (d) => o(d.data), n = (d) => i(d instanceof ErrorEvent ? new Error(d.message) : new Error("报表 Worker 消息无法解码"));
141
+ return t.addEventListener("message", c), t.addEventListener("error", n), t.addEventListener("messageerror", n), () => {
142
+ t.removeEventListener("message", c), t.removeEventListener("error", n), t.removeEventListener("messageerror", n);
143
+ };
144
+ }
145
+ };
146
+ }, r);
147
+ }
148
+ function K(e, r = globalThis) {
149
+ const t = (o) => {
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)));
151
+ };
152
+ return r.addEventListener("message", t), () => r.removeEventListener("message", t);
153
+ }
154
+ export {
155
+ R as ReportWorkerError,
156
+ C as createBrowserReportExecutor,
157
+ K as serveReportWorker
158
+ };
@@ -0,0 +1,47 @@
1
+ /// <reference types="node" />
2
+
3
+ import { Writable } from 'node:stream';
4
+
5
+ /**
6
+ * Commits each source row directly to ExcelJS WorkbookWriter. No RenderPlan, full row array,
7
+ * Workbook or Buffer is retained. Styles are column-scoped; shared strings are disabled.
8
+ * Destination is ended by the writer. An abort/error leaves a partial, unusable XLSX file.
9
+ */
10
+ export declare function writeRowsToXlsx<Row extends object>(rows: AsyncIterable<Row> | Iterable<Row>, options: XlsxStreamOptions<Row>): Promise<XlsxStreamProgress>;
11
+
12
+ export declare type XlsxRowValue = string | number | boolean | Date | null | undefined;
13
+
14
+ export declare interface XlsxStreamColumn<Row> {
15
+ key: keyof Row & string;
16
+ header?: string;
17
+ width?: number;
18
+ numberFormat?: string;
19
+ value?: (row: Row, rowIndex: number) => XlsxRowValue;
20
+ }
21
+
22
+ declare interface XlsxStreamCommonOptions<Row> {
23
+ columns: readonly XlsxStreamColumn<Row>[];
24
+ sheetName?: string;
25
+ signal?: AbortSignal;
26
+ /** Data rows, excluding the header. Excel's hard limit is always enforced. */
27
+ maxRows?: number;
28
+ maxDurationMs?: number;
29
+ /** Yield/check downstream backpressure after each batch (default 256). */
30
+ batchSize?: number;
31
+ onProgress?: (progress: XlsxStreamProgress) => void;
32
+ }
33
+
34
+ export declare type XlsxStreamOptions<Row> = XlsxStreamCommonOptions<Row> & ({
35
+ stream: Writable;
36
+ filename?: never;
37
+ } | {
38
+ filename: string;
39
+ stream?: never;
40
+ });
41
+
42
+ export declare interface XlsxStreamProgress {
43
+ rowsWritten: number;
44
+ elapsedMs: number;
45
+ }
46
+
47
+ export { }
@@ -0,0 +1,47 @@
1
+ /// <reference types="node" />
2
+
3
+ import { Writable } from 'node:stream';
4
+
5
+ /**
6
+ * Commits each source row directly to ExcelJS WorkbookWriter. No RenderPlan, full row array,
7
+ * Workbook or Buffer is retained. Styles are column-scoped; shared strings are disabled.
8
+ * Destination is ended by the writer. An abort/error leaves a partial, unusable XLSX file.
9
+ */
10
+ export declare function writeRowsToXlsx<Row extends object>(rows: AsyncIterable<Row> | Iterable<Row>, options: XlsxStreamOptions<Row>): Promise<XlsxStreamProgress>;
11
+
12
+ export declare type XlsxRowValue = string | number | boolean | Date | null | undefined;
13
+
14
+ export declare interface XlsxStreamColumn<Row> {
15
+ key: keyof Row & string;
16
+ header?: string;
17
+ width?: number;
18
+ numberFormat?: string;
19
+ value?: (row: Row, rowIndex: number) => XlsxRowValue;
20
+ }
21
+
22
+ declare interface XlsxStreamCommonOptions<Row> {
23
+ columns: readonly XlsxStreamColumn<Row>[];
24
+ sheetName?: string;
25
+ signal?: AbortSignal;
26
+ /** Data rows, excluding the header. Excel's hard limit is always enforced. */
27
+ maxRows?: number;
28
+ maxDurationMs?: number;
29
+ /** Yield/check downstream backpressure after each batch (default 256). */
30
+ batchSize?: number;
31
+ onProgress?: (progress: XlsxStreamProgress) => void;
32
+ }
33
+
34
+ export declare type XlsxStreamOptions<Row> = XlsxStreamCommonOptions<Row> & ({
35
+ stream: Writable;
36
+ filename?: never;
37
+ } | {
38
+ filename: string;
39
+ stream?: never;
40
+ });
41
+
42
+ export declare interface XlsxStreamProgress {
43
+ rowsWritten: number;
44
+ elapsedMs: number;
45
+ }
46
+
47
+ export { }