@agile-team/mach-report 2.12.0 → 2.14.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 (97) hide show
  1. package/README.md +27 -3
  2. package/dist/ExcelBindingWizard-CLT2p7P3.cjs +1 -0
  3. package/dist/ExcelBindingWizard-CvsWR8Ga.js +1485 -0
  4. package/dist/{ParamEditor-BLaE5q5W.js → ParamEditor-CflQV3eQ.js} +191 -187
  5. package/dist/ParamEditor-vIDzvpPV.cjs +1 -0
  6. package/dist/ReportBatchPanel-DkxTzBkD.cjs +1 -0
  7. package/dist/{ReportBatchPanel-B5ClP9tm.js → ReportBatchPanel-LqVgiqp7.js} +3 -3
  8. package/dist/ReportPreview-CvbqLUzM.cjs +6 -0
  9. package/dist/ReportPreview-D_ywJ_-H.js +4533 -0
  10. package/dist/{ReportTemplateLibrary-BZB-XWjj.js → ReportTemplateLibrary-MjWEtc7X.js} +1 -1
  11. package/dist/ReportTemplateLibrary-cQ1sqNYo.cjs +1 -0
  12. package/dist/RuleEditor-BaR6xUiI.cjs +1 -0
  13. package/dist/RuleEditor-ChuXMlei.js +2037 -0
  14. package/dist/TemplateOutlinePanel-BHKP89Xz.cjs +1 -0
  15. package/dist/TemplateOutlinePanel-Dci6aRn1.js +96 -0
  16. package/dist/TemplateReusePanel-B7Gmyc1z.js +388 -0
  17. package/dist/TemplateReusePanel-CY5eO2Sh.cjs +1 -0
  18. package/dist/TemplateReviewPanel-DjlX3xpt.js +592 -0
  19. package/dist/TemplateReviewPanel-JvZe9_4G.cjs +1 -0
  20. package/dist/{batch-mRqhhhjt.js → batch-DzaTNLWI.js} +23 -16
  21. package/dist/batch-xMkqYiTr.cjs +1 -0
  22. package/dist/config-0UIohTS7.cjs +1 -0
  23. package/dist/{config-B612mw0x.js → config-Dt9NtCPl.js} +227 -186
  24. package/dist/data-explanation-BktvER5B.cjs +1 -0
  25. package/dist/data-explanation-C_J6jYNi.js +16 -0
  26. package/dist/designer-Ci1LizA9.js +5020 -0
  27. package/dist/designer-rtmVIIdN.cjs +2 -0
  28. package/dist/designer.cjs +1 -2
  29. package/dist/designer.d.cts +306 -3
  30. package/dist/designer.d.ts +306 -3
  31. package/dist/designer.js +21 -4266
  32. package/dist/font-loader-DHto6Lra.js +297 -0
  33. package/dist/font-loader-vhCT8znW.cjs +1 -0
  34. package/dist/index.cjs +8 -8
  35. package/dist/index.d.cts +182 -1
  36. package/dist/index.d.ts +182 -1
  37. package/dist/index.js +728 -628
  38. package/dist/{template-review-BzpcI-tR.js → json-snapshot-BeFT3Tso.js} +867 -637
  39. package/dist/json-snapshot-D1NTP2oI.cjs +2 -0
  40. package/dist/pdf-8UPQebOE.js +36288 -0
  41. package/dist/pdf-AyJGb22z.cjs +101 -0
  42. package/dist/pdf.cjs +1 -101
  43. package/dist/pdf.js +9 -36579
  44. package/dist/plugin-BGKf-Tqg.js +22 -0
  45. package/dist/{plugin-BDTU4D94.cjs → plugin-CktLH_Iy.cjs} +1 -1
  46. package/dist/{region-binding-workflow-CcUq8W2Q.js → region-binding-workflow-DEJbhpCv.js} +1 -1
  47. package/dist/server/node.d.cts +46 -11
  48. package/dist/server/node.d.ts +46 -11
  49. package/dist/server-node.cjs +1 -1
  50. package/dist/server-node.js +294 -280
  51. package/dist/server.cjs +1 -1
  52. package/dist/server.d.cts +107 -12
  53. package/dist/server.d.ts +107 -12
  54. package/dist/server.js +713 -453
  55. package/dist/style.css +1 -1
  56. package/dist/template-bindings-BJR4k7qZ.cjs +1 -0
  57. package/dist/template-bindings-Daui7hLF.js +252 -0
  58. package/dist/template-fragments-CLkGo6To.js +187 -0
  59. package/dist/template-fragments-DFUpq5QM.cjs +1 -0
  60. package/dist/template-outline-B3xVkzSv.cjs +1 -0
  61. package/dist/template-outline-CFenM1PV.js +88 -0
  62. package/dist/{template-registry-BjE1VS6g.js → template-registry-COXDEJEM.js} +1 -1
  63. package/dist/{useLocalDraft-C07SYRnC.js → useLocalDraft-BnhcxXk_.js} +1 -1
  64. package/dist/{useLocalDraft-Yiw1wFgI.cjs → useLocalDraft-CioIfDb6.cjs} +1 -1
  65. package/dist/{validate-DbgEM1Hh.js → validate-CkQBWCeg.js} +3 -3
  66. package/dist/vue/async.d.cts +72 -2
  67. package/dist/vue/async.d.ts +72 -2
  68. package/dist/vue/index.d.cts +124 -5
  69. package/dist/vue/index.d.ts +124 -5
  70. package/dist/vue-async.cjs +1 -1
  71. package/dist/vue-async.js +5 -5
  72. package/dist/vue.cjs +1 -1
  73. package/dist/vue.js +78 -71
  74. package/dist/{workbook-session-BPb3TMnT.js → workbook-session-BfK1yHOO.js} +1 -1
  75. package/dist/worker.cjs +1 -1
  76. package/dist/worker.d.cts +46 -11
  77. package/dist/worker.d.ts +46 -11
  78. package/dist/worker.js +59 -55
  79. package/dist/xlsx.js +3 -3
  80. package/package.json +1 -1
  81. package/dist/ExcelBindingWizard-CeAf4QSE.js +0 -1465
  82. package/dist/ExcelBindingWizard-y0mT-AHR.cjs +0 -1
  83. package/dist/ParamEditor-MBBC7lUE.cjs +0 -1
  84. package/dist/ReportBatchPanel-Dc-SDkYA.cjs +0 -1
  85. package/dist/ReportPreview-DWXROHBP.cjs +0 -6
  86. package/dist/ReportPreview-DiNXhQI0.js +0 -4138
  87. package/dist/ReportTemplateLibrary-5fk5CQBO.cjs +0 -1
  88. package/dist/RuleEditor-ChRzNQuF.cjs +0 -1
  89. package/dist/RuleEditor-DzAmW5YH.js +0 -2024
  90. package/dist/TemplateReviewPanel-BKofGrV9.js +0 -222
  91. package/dist/TemplateReviewPanel-DwtOcLue.cjs +0 -1
  92. package/dist/batch-Bt3Fd27Z.cjs +0 -1
  93. package/dist/config-BRoLo2oj.cjs +0 -1
  94. package/dist/plugin-Cd5G2QQn.js +0 -22
  95. package/dist/record-bindings-By_UKZ2g.cjs +0 -1
  96. package/dist/record-bindings-D-5jQlTj.js +0 -196
  97. package/dist/template-review-BfCC8Ng9.cjs +0 -2
package/dist/server.js CHANGED
@@ -1,34 +1,110 @@
1
- import { A as ce, b as k, k as le, B as ue, a as de, P as fe, n as pe, y as ge } from "./template-review-BzpcI-tR.js";
2
- import { g as F } from "./report-params-B44imUd4.js";
3
- import { d as X, r as we, R as te } from "./param-validation-BlHHXs6u.js";
4
- import { v as me, c as z, a as R, t as x, R as A, b, d as L, s as I, e as T, j as ye, f as he } from "./batch-mRqhhhjt.js";
5
- import { g as at, r as ot, h as it, i as ct, k as lt, l as ut } from "./batch-mRqhhhjt.js";
6
- import { c as re } from "./validate-DbgEM1Hh.js";
7
- import { r as G, c as C, n as _ } from "./task-events-Dpsvf_t2.js";
8
- import { T as ve } from "./tree-CqcQ99NM.js";
9
- import { r as be } from "./assets-Q0wUwNrV.js";
10
- import { p as xe } from "./template-registry-BjE1VS6g.js";
11
- function se(e, t) {
12
- if (t.length === 0) throw new k("config", "缺少报表 ID");
1
+ import { R as P, s as xe, C as Re, l as Se, E as Ie, b as Oe, P as Pe, n as ke, z as Ae } from "./json-snapshot-BeFT3Tso.js";
2
+ import { g as X } from "./report-params-B44imUd4.js";
3
+ import { d as Z, r as Be, R as le } from "./param-validation-BlHHXs6u.js";
4
+ import { t as v, a as O, R as k, p as Y, v as Ee, c as j, b as x, d as Q, s as F, e as U, j as Ne, f as Fe, r as je } from "./batch-DzaTNLWI.js";
5
+ import { g as Ft, h as jt, i as Mt, k as $t, l as Jt } from "./batch-DzaTNLWI.js";
6
+ import { v as fe } from "./validate-CkQBWCeg.js";
7
+ import { c as $, r as V, n as q } from "./task-events-Dpsvf_t2.js";
8
+ import { T as Me } from "./tree-CqcQ99NM.js";
9
+ import { r as ee } from "./assets-Q0wUwNrV.js";
10
+ import { h as $e } from "./data-explanation-C_J6jYNi.js";
11
+ import { p as Je, v as Ce } from "./template-registry-COXDEJEM.js";
12
+ import { h as pe } from "./template-bindings-Daui7hLF.js";
13
+ function z(e = []) {
14
+ return e.map(({ code: t, message: r, severity: a, pageIndex: s, componentIndex: n }) => ({ code: t, message: r, severity: a, path: `$.pages.${s}.components.${n}` }));
15
+ }
16
+ async function te(e, t, r = Date.now()) {
17
+ const a = e.prepared, s = e.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
18
+ v(e.signal);
19
+ const n = e.pdf?.customFontFaces ?? (e.pdf?.customFontBytes ? { regular: e.pdf.customFontBytes } : void 0), o = s && n ? s.createFontBytesMeasurer(n) : void 0, d = $(e), c = await d.run("encode", async () => {
20
+ let u;
21
+ if (e.format === "pdf") {
22
+ v(e.signal);
23
+ const l = await s.renderPlanToPdf(a.plan, { ...e.pdf, ...o ? { measurer: o } : {}, fidelity: e.fidelity, signal: e.signal, onProgress: (w, p) => d.progress("encode", w, p) });
24
+ u = l.bytes, a.diagnostics.push(...z(l.diagnostics)), a.diagnostics.push(...l.fidelityWarnings.map((w) => ({ code: "pdf-fidelity", message: w, severity: "warning" })), ...l.pageErrors.map((w) => ({ code: "pdf-page", message: w, severity: "error" }))), l.unsupportedTextCount && a.diagnostics.push({ code: "pdf-font", message: `${l.unsupportedTextCount} 段文本包含当前字体不支持的字符`, severity: "warning" });
25
+ } else {
26
+ const { renderPlanToXlsx: l } = await import("@agile-team/mach-report/xlsx");
27
+ v(e.signal);
28
+ const w = await l(a.plan, { ...e.xlsx, fidelity: e.fidelity, signal: e.signal, onProgress: (p, g) => d.progress("encode", p, g) });
29
+ u = new Uint8Array(w.buffer), a.diagnostics.push(...z(w.diagnostics)), a.diagnostics.push(...w.warnings.map((p) => ({ code: "xlsx-fidelity", message: p, severity: "warning" })));
30
+ }
31
+ return v(e.signal), u;
32
+ });
33
+ O(t, "maxOutputBytes", c.byteLength);
34
+ const { plan: i, ...f } = a;
35
+ return { ...f, bytes: c, format: e.format, contentType: e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", stats: { ...f.stats, durationMs: Date.now() - r, outputBytes: c.byteLength } };
36
+ }
37
+ function G(e) {
38
+ return e && { ...e };
39
+ }
40
+ function C(e) {
41
+ if (!e) return;
42
+ const t = (r) => {
43
+ if (!(r instanceof Uint8Array) && !(r instanceof ArrayBuffer)) throw new P("validate", "字体应为 Uint8Array 或 ArrayBuffer");
44
+ if (r.byteLength > 32e6) throw new k("budget", "单份字体超过 32 MB", "$.pdf");
45
+ return new Uint8Array(r instanceof Uint8Array ? r : new Uint8Array(r));
46
+ };
47
+ if (e.customFontFaces) {
48
+ const r = e.customFontFaces;
49
+ return { customFontName: e.customFontName, customFontFaces: { regular: t(r.regular), ...r.bold ? { bold: t(r.bold) } : {}, ...r.italic ? { italic: t(r.italic) } : {}, ...r.boldItalic ? { boldItalic: t(r.boldItalic) } : {} } };
50
+ }
51
+ return { customFontName: e.customFontName, ...e.customFontBytes ? { customFontBytes: t(e.customFontBytes) } : {} };
52
+ }
53
+ function we(e) {
54
+ const t = e?.customFontFaces ?? (e?.customFontBytes ? { regular: e.customFontBytes } : void 0);
55
+ if (!t) return;
56
+ const r = ["regular", "bold", "italic", "boldItalic"].map((a) => {
57
+ const s = t[a];
58
+ if (!s) return [a, null];
59
+ const n = s instanceof Uint8Array ? s : new Uint8Array(s);
60
+ if (n.byteLength > 32e6) throw new k("budget", "单份字体超过 32 MB", "$.pdf");
61
+ return [a, Y(n)];
62
+ });
63
+ return Y(new TextEncoder().encode(JSON.stringify(r)));
64
+ }
65
+ function De(e, t, r) {
66
+ const a = xe(e, {
67
+ maxBytes: t,
68
+ check: () => v(r),
69
+ error: (s, n) => s === "budget" ? new k("budget", n, "$.budget.maxPreparedBytes") : new P("validate", n)
70
+ });
71
+ return ge(a), a;
72
+ }
73
+ function ge(e) {
74
+ if (!e?.stats || ["rows", "pages", "cells"].some((t) => !Number.isSafeInteger(e.stats[t]) || e.stats[t] < 0) || !Number.isFinite(e.stats.durationMs) || e.stats.durationMs < 0) throw new P("validate", "准备结果统计无效");
75
+ if (!Array.isArray(e.diagnostics) || e.diagnostics.some((t) => !t || typeof t.code != "string" || typeof t.message != "string" || !["info", "warning", "error"].includes(t.severity) || !$e(t))) throw new P("validate", "准备结果诊断无效");
76
+ if (!e.revisions || typeof e.revisions != "object" || Array.isArray(e.revisions) || Object.values(e.revisions).some((t) => !t || typeof t != "object" || t.revision !== void 0 && typeof t.revision != "string" || t.sourceToken !== void 0 && typeof t.sourceToken != "string")) throw new P("validate", "准备结果修订无效");
77
+ if (e.layout && (!["heuristic", "provided", "font-bytes"].includes(e.layout.textMetrics) || e.layout.fontFingerprint !== void 0 && !/^[a-f0-9]{64}$/.test(e.layout.fontFingerprint))) throw new P("validate", "准备结果字体度量标识无效");
78
+ }
79
+ function Te(e) {
80
+ if (e.format !== "pdf") return;
81
+ const t = e.prepared.layout?.fontFingerprint, r = we(e.pdf);
82
+ if (t === r && (t !== void 0 || e.prepared.layout?.textMetrics === "heuristic" && !r)) return;
83
+ const a = "已准备计划的字体度量无法与本次 PDF 字体确认一致;保持现有分页,未重新查询或排版。请在 prepare 和 exportPrepared 提供相同字体字节。";
84
+ if (e.fidelity === "strict") throw new P("validate", a);
85
+ e.prepared.diagnostics.push({ code: "prepared-font-metrics", severity: "warning", message: a });
86
+ }
87
+ function me(e, t) {
88
+ if (t.length === 0) throw new P("config", "缺少报表 ID");
13
89
  return t.map((r) => {
14
- if (!Object.prototype.hasOwnProperty.call(e, r)) throw new k("config", `未注册报表 ${r}`);
90
+ if (!Object.prototype.hasOwnProperty.call(e, r)) throw new P("config", `未注册报表 ${r}`);
15
91
  return e[r];
16
92
  });
17
93
  }
18
- function $(e) {
19
- return e.grid?.cells.reduce((t, r) => t + r.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((n, i) => n + $(i), 0) ?? 0) : 0), 0), 0) ?? 0;
94
+ function H(e) {
95
+ return e.grid?.cells.reduce((t, r) => t + r.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((n, o) => n + H(o), 0) ?? 0) : 0), 0), 0) ?? 0;
20
96
  }
21
- function Se(e, t, r) {
22
- return e.pages.reduce((a, s) => a + s.components.reduce((n, i) => i.kind !== "list" ? n + $(i) : n + pe(i, t, r), 0), 0);
97
+ function Le(e, t, r) {
98
+ return e.pages.reduce((a, s) => a + s.components.reduce((n, o) => o.kind !== "list" ? n + H(o) : n + ke(o, t, r), 0), 0);
23
99
  }
24
- function Re(e, t = Object.keys(e)) {
25
- return se(e, t).map((r, a) => {
26
- const s = t[a], n = F(e, [s]);
100
+ function qe(e, t = Object.keys(e)) {
101
+ return me(e, t).map((r, a) => {
102
+ const s = t[a], n = X(e, [s]);
27
103
  return {
28
104
  id: s,
29
105
  params: JSON.parse(JSON.stringify(n)),
30
- paramsSchema: we(n),
31
- datasetsSchema: Object.fromEntries(Object.entries(r.dataSchema ?? {}).map(([i, l]) => [i, ce(typeof r.template == "function" ? void 0 : r.template, i, l)])),
106
+ paramsSchema: Be(n),
107
+ datasetsSchema: Object.fromEntries(Object.entries(r.dataSchema ?? {}).map(([o, d]) => [o, Re(typeof r.template == "function" ? void 0 : r.template, o, d)])),
32
108
  capabilities: {
33
109
  save: !!r.provider?.save,
34
110
  export: !!r.provider?.export,
@@ -37,104 +113,108 @@ function Re(e, t = Object.keys(e)) {
37
113
  };
38
114
  });
39
115
  }
40
- function ne(e, t) {
41
- se(e, t.reportIds);
42
- const r = X(F(e, t.reportIds), t.params), a = t.reportIds.flatMap((n) => X(F(e, [n]), t.params).issues), s = new Map(a.map((n) => [JSON.stringify(n), n]));
116
+ function ye(e, t) {
117
+ me(e, t.reportIds);
118
+ const r = Z(X(e, t.reportIds), t.params), a = t.reportIds.flatMap((n) => Z(X(e, [n]), t.params).issues), s = new Map(a.map((n) => [JSON.stringify(n), n]));
43
119
  return { ...r, ok: s.size === 0, issues: [...s.values()] };
44
120
  }
45
- function Ie(e, t) {
46
- const r = re(e.plan);
47
- if (!r.ok) throw new k("validate", `执行器返回无效计划:${r.errors[0]?.path}`);
48
- const a = e.plan.pages.length, s = e.plan.pages.reduce((n, i) => n + i.components.reduce((l, f) => l + $(f), 0), 0);
49
- return R(t, "maxRows", e.stats.rows), R(t, "maxPages", a), R(t, "maxCells", s), { ...e, stats: { ...e.stats, pages: a, cells: s } };
50
- }
51
- function U(e, t) {
52
- const r = ne(e.reports, t);
53
- if (!r.ok) throw new te(r.issues);
121
+ function re(e, t) {
122
+ const r = fe(e.plan);
123
+ if (!r.ok) throw new P("validate", `执行器返回无效计划:${r.errors[0]?.path}`);
124
+ const a = e.plan.pages.length, s = e.plan.pages.reduce((n, o) => n + o.components.reduce((d, c) => d + H(c), 0), 0);
125
+ return O(t, "maxRows", e.stats.rows), O(t, "maxPages", a), O(t, "maxCells", s), { ...e, stats: { ...e.stats, pages: a, cells: s } };
54
126
  }
55
- function q(e = []) {
56
- return e.map(({ code: t, message: r, severity: a, pageIndex: s, componentIndex: n }) => ({ code: t, message: r, severity: a, path: `$.pages.${s}.components.${n}` }));
127
+ function se(e, t) {
128
+ const r = ye(e.reports, t);
129
+ if (!r.ok) throw new le(r.issues);
57
130
  }
58
- function Oe(e) {
59
- const t = { maxRows: 1e5, maxPages: 1e4, maxCells: 2e6, maxOutputBytes: 1e8, maxDurationMs: 12e4, ...e.budget };
60
- me(t);
131
+ function he(e) {
132
+ const t = { maxRows: 1e5, maxPages: 1e4, maxCells: 2e6, maxOutputBytes: 1e8, maxPreparedBytes: 64e6, maxDurationMs: 12e4, ...e.budget };
133
+ Ee(t);
61
134
  const r = async (s, n) => {
62
- const i = Date.now();
63
- let l = 0, f = 0;
64
- const o = [], d = {}, c = Object.fromEntries(Object.entries(e.reports).map(([p, v]) => [p, {
65
- ...v,
66
- pagination: { ...e.pagination, ...v.pagination, ...n ? { measurer: n } : {} },
135
+ const o = Date.now();
136
+ let d = 0, c = 0;
137
+ const i = [], f = {}, u = Object.fromEntries(Object.entries(e.reports).map(([b, S]) => [b, {
138
+ ...S,
139
+ pagination: { ...e.pagination, ...S.pagination, ...n ? { measurer: n } : {} },
67
140
  dataValidation: {
68
- ...v.dataValidation,
69
- maxRows: Math.min(t.maxRows ?? 1e5, v.dataValidation?.maxRows ?? 1 / 0),
70
- maxCells: Math.min(t.maxCells ?? 2e6, v.dataValidation?.maxCells ?? 1 / 0)
141
+ ...S.dataValidation,
142
+ maxRows: Math.min(t.maxRows ?? 1e5, S.dataValidation?.maxRows ?? 1 / 0),
143
+ maxCells: Math.min(t.maxCells ?? 2e6, S.dataValidation?.maxCells ?? 1 / 0)
71
144
  }
72
- }])), y = await le(c, { maxPages: t.maxPages, maxCells: t.maxCells, onDatasets: (p, v, j) => {
145
+ }])), w = await Se(u, { maxPages: t.maxPages, maxCells: t.maxCells, onDatasets: (b, S, I) => {
73
146
  try {
74
- l += ue(j, v, { maxRows: t.maxRows, signal: s.signal });
75
- } catch (P) {
76
- throw P instanceof ve ? new A("budget", P.message, "$.budget.maxRows") : P;
147
+ d += Ie(I, S, { maxRows: t.maxRows, signal: s.signal });
148
+ } catch (E) {
149
+ throw E instanceof Me ? new k("budget", E.message, "$.budget.maxRows") : E;
77
150
  }
78
- R(t, "maxRows", l), f += Se(j, v, c[p]?.pagination), R(t, "maxCells", f);
79
- } })({ ...s, params: s.params ?? {}, onWarning: (p) => o.push({ code: "layout", message: p, severity: "warning" }), onQueryResult: (p, v) => {
80
- Object.defineProperty(d, p, { value: { revision: v.revision, sourceToken: v.sourceToken }, enumerable: !0, writable: !0 }), o.push(...v.diagnostics ?? []);
81
- } }).catch((p) => {
82
- throw p instanceof k && p.cause instanceof de ? new A("budget", p.cause.message, "$.budget.maxPages") : p instanceof k && p.cause instanceof fe ? new A("budget", p.cause.message, "$.budget.maxCells") : p;
151
+ O(t, "maxRows", d), c += Le(I, S, u[b]?.pagination), O(t, "maxCells", c);
152
+ } })({ ...s, params: s.params ?? {}, onWarning: (b) => i.push({ code: "layout", message: b, severity: "warning" }), onQueryResult: (b, S) => {
153
+ Object.defineProperty(f, b, { value: { revision: S.revision, sourceToken: S.sourceToken }, enumerable: !0, writable: !0 }), i.push(...S.diagnostics ?? []);
154
+ } }).catch((b) => {
155
+ throw b instanceof P && b.cause instanceof Oe ? new k("budget", b.cause.message, "$.budget.maxPages") : b instanceof P && b.cause instanceof Pe ? new k("budget", b.cause.message, "$.budget.maxCells") : b;
83
156
  });
84
- x(s.signal);
85
- const h = e.assets ? await C(s).run("assets", () => be(y, { ...e.assets, signal: s.signal })) : { plan: y, diagnostics: [] }, w = h.plan;
86
- o.push(...q(h.diagnostics));
87
- const g = w.pages.reduce((p, v) => p + v.components.reduce((j, P) => j + $(P), 0), 0);
88
- return R(t, "maxPages", w.pages.length), R(t, "maxCells", g), { plan: w, diagnostics: o, revisions: d, stats: { rows: l, pages: w.pages.length, cells: g, durationMs: Date.now() - i } };
157
+ v(s.signal);
158
+ const p = e.assets ? await $(s).run("assets", () => ee(w, { ...e.assets, signal: s.signal })) : { plan: w, diagnostics: [] }, g = p.plan;
159
+ i.push(...z(p.diagnostics));
160
+ const m = g.pages.reduce((b, S) => b + S.components.reduce((I, E) => I + H(E), 0), 0);
161
+ O(t, "maxPages", g.pages.length), O(t, "maxCells", m);
162
+ const y = we(s.pdf), A = e.pagination?.measurer || Object.values(e.reports).some((b) => b.pagination?.measurer);
163
+ return { plan: g, diagnostics: i, revisions: f, layout: { textMetrics: y ? "font-bytes" : A ? "provided" : "heuristic", ...y ? { fontFingerprint: y } : {} }, stats: { rows: d, pages: g.pages.length, cells: m, durationMs: Date.now() - o } };
89
164
  }, a = async (s) => {
90
165
  const n = Date.now();
91
- if (s.format !== "pdf" && s.format !== "xlsx") throw new k("config", "不支持的报表导出格式");
92
- const i = s.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
93
- x(s.signal);
94
- const l = s.pdf?.customFontFaces ?? (s.pdf?.customFontBytes ? { regular: s.pdf.customFontBytes } : void 0), f = i && l ? i.createFontBytesMeasurer(l) : void 0, o = await r(s, f);
95
- x(s.signal);
96
- const d = C(s), c = await d.run("encode", async () => {
97
- let h;
98
- if (s.format === "pdf") {
99
- x(s.signal);
100
- const w = await i.renderPlanToPdf(o.plan, { ...s.pdf, ...f ? { measurer: f } : {}, fidelity: s.fidelity, signal: s.signal, onProgress: (g, p) => d.progress("encode", g, p) });
101
- h = w.bytes, o.diagnostics.push(...q(w.diagnostics)), o.diagnostics.push(...w.fidelityWarnings.map((g) => ({ code: "pdf-fidelity", message: g, severity: "warning" })), ...w.pageErrors.map((g) => ({ code: "pdf-page", message: g, severity: "error" }))), w.unsupportedTextCount && o.diagnostics.push({ code: "pdf-font", message: `${w.unsupportedTextCount} 段文本包含当前字体不支持的字符`, severity: "warning" });
102
- } else {
103
- const { renderPlanToXlsx: w } = await import("@agile-team/mach-report/xlsx");
104
- x(s.signal);
105
- const g = await w(o.plan, { ...s.xlsx, fidelity: s.fidelity, signal: s.signal, onProgress: (p, v) => d.progress("encode", p, v) });
106
- h = new Uint8Array(g.buffer), o.diagnostics.push(...q(g.diagnostics)), o.diagnostics.push(...g.warnings.map((p) => ({ code: "xlsx-fidelity", message: p, severity: "warning" })));
107
- }
108
- return x(s.signal), h;
109
- });
110
- R(t, "maxOutputBytes", c.byteLength);
111
- const { plan: u, ...y } = o;
112
- return { ...y, bytes: c, format: s.format, contentType: s.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", stats: { ...y.stats, durationMs: Date.now() - n, outputBytes: c.byteLength } };
166
+ if (s.format !== "pdf" && s.format !== "xlsx") throw new P("config", "不支持的报表导出格式");
167
+ const o = s.format === "pdf" ? await import("@agile-team/mach-report/pdf") : void 0;
168
+ v(s.signal);
169
+ const d = s.pdf?.customFontFaces ?? (s.pdf?.customFontBytes ? { regular: s.pdf.customFontBytes } : void 0), c = o && d ? o.createFontBytesMeasurer(d) : void 0, i = await r(s, c);
170
+ return v(s.signal), te({ ...s, prepared: i }, t, n);
113
171
  };
114
172
  return {
115
- describe: (s) => Re(e.reports, s),
116
- validate: (s) => ne(e.reports, s),
117
- prepare: (s) => z(s.signal, t.maxDurationMs, async (n) => {
118
- const { signal: i, onEvent: l, ...f } = s, o = { ...f, taskId: f.taskId ?? G() }, d = l ? (y) => _(l, y, n) : void 0, c = { ...o, signal: n, onEvent: d };
119
- C(c).runSync("validate", () => U(e, o));
120
- const u = e.executor ? await e.executor.prepare(o, n, d) : await r(c);
121
- return Ie(u, t);
173
+ describe: (s) => qe(e.reports, s),
174
+ validate: (s) => ye(e.reports, s),
175
+ prepare: (s) => j(s.signal, t.maxDurationMs, async (n) => {
176
+ const { signal: o, onEvent: d, ...c } = s, i = { ...c, ...c.pdf ? { pdf: C(c.pdf) } : {}, taskId: c.taskId ?? V() }, f = d ? (g) => q(d, g, n) : void 0, u = { ...i, signal: n, onEvent: f };
177
+ $(u).runSync("validate", () => se(e, i));
178
+ let l;
179
+ const w = i.pdf?.customFontFaces ?? (i.pdf?.customFontBytes ? { regular: i.pdf.customFontBytes } : void 0);
180
+ if (!e.executor && w) {
181
+ const g = await import("@agile-team/mach-report/pdf");
182
+ v(n), l = g.createFontBytesMeasurer(w);
183
+ }
184
+ const p = e.executor ? await e.executor.prepare(i, n, f) : await r(u, l);
185
+ return re(p, t);
122
186
  }),
123
- export: (s) => z(s.signal, t.maxDurationMs, async (n) => {
124
- const { signal: i, onEvent: l, ...f } = s, o = { ...f, taskId: f.taskId ?? G() }, d = l ? (y) => _(l, y, n) : void 0, c = { ...o, signal: n, onEvent: d };
125
- if (C(c).runSync("validate", () => U(e, o)), o.format !== "pdf" && o.format !== "xlsx") throw new k("config", "不支持的报表导出格式");
126
- const u = e.executor ? await e.executor.export(o, n, d) : await a(c);
127
- return R(t, "maxRows", u.stats.rows), R(t, "maxPages", u.stats.pages), R(t, "maxCells", u.stats.cells), R(t, "maxOutputBytes", u.bytes.byteLength), { ...u, stats: { ...u.stats, outputBytes: u.bytes.byteLength } };
187
+ exportPrepared: (s) => j(s.signal, t.maxDurationMs, async (n) => {
188
+ const o = Date.now(), { signal: d, onEvent: c, ...i } = s, f = re(De(s.prepared, t.maxPreparedBytes ?? 64e6, n), t), u = { ...i, xlsx: G(i.xlsx), prepared: f, ...i.pdf ? { pdf: C(i.pdf) } : {}, taskId: i.taskId ?? V() };
189
+ if (u.format !== "pdf" && u.format !== "xlsx") throw new P("config", "不支持的报表导出格式");
190
+ const l = c ? (p) => q(c, p, n) : void 0;
191
+ if (e.executor) {
192
+ if (!e.executor.exportPrepared) throw new P("config", "执行器未实现 exportPrepared;请升级执行器或显式使用本地运行时");
193
+ const p = await e.executor.exportPrepared(u, n, l);
194
+ return O(t, "maxRows", p.stats.rows), O(t, "maxPages", p.stats.pages), O(t, "maxCells", p.stats.cells), O(t, "maxOutputBytes", p.bytes.byteLength), { ...p, stats: { ...p.stats, outputBytes: p.bytes.byteLength } };
195
+ }
196
+ const w = { ...u, signal: n, onEvent: l };
197
+ if ($(w).runSync("validate", () => Te(w)), e.assets) {
198
+ const p = await $(w).run("assets", () => ee(f.plan, { ...e.assets, signal: n }));
199
+ f.plan = p.plan, f.diagnostics.push(...z(p.diagnostics));
200
+ }
201
+ return te(w, t, o);
202
+ }),
203
+ export: (s) => j(s.signal, t.maxDurationMs, async (n) => {
204
+ const { signal: o, onEvent: d, ...c } = s, i = { ...c, xlsx: G(c.xlsx), ...c.pdf ? { pdf: C(c.pdf) } : {}, taskId: c.taskId ?? V() }, f = d ? (w) => q(d, w, n) : void 0, u = { ...i, signal: n, onEvent: f };
205
+ if ($(u).runSync("validate", () => se(e, i)), i.format !== "pdf" && i.format !== "xlsx") throw new P("config", "不支持的报表导出格式");
206
+ const l = e.executor ? await e.executor.export(i, n, f) : await a(u);
207
+ return O(t, "maxRows", l.stats.rows), O(t, "maxPages", l.stats.pages), O(t, "maxCells", l.stats.cells), O(t, "maxOutputBytes", l.bytes.byteLength), { ...l, stats: { ...l.stats, outputBytes: l.bytes.byteLength } };
128
208
  })
129
209
  };
130
210
  }
131
- function Ze(e = {}) {
211
+ function St(e = {}) {
132
212
  const t = e.concurrency ?? 1, r = e.maxQueued ?? 20;
133
- if (!Number.isSafeInteger(t) || t < 1 || !Number.isSafeInteger(r) || r < 0) throw new A("budget", "队列并发应为正整数,排队上限应为非负整数");
213
+ if (!Number.isSafeInteger(t) || t < 1 || !Number.isSafeInteger(r) || r < 0) throw new k("budget", "队列并发应为正整数,排队上限应为非负整数");
134
214
  const a = [], s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
135
- let i = !1, l = 0;
136
- const f = () => {
137
- for (; !i && s.size < t && a.length; ) a.shift().start();
215
+ let o = !1, d = 0;
216
+ const c = () => {
217
+ for (; !o && s.size < t && a.length; ) a.shift().start();
138
218
  };
139
219
  return {
140
220
  get active() {
@@ -143,65 +223,65 @@ function Ze(e = {}) {
143
223
  get pending() {
144
224
  return a.length;
145
225
  },
146
- enqueue: (d, c = {}) => {
147
- if (i) throw new A("closed", "任务队列已关闭");
148
- if (x(c.signal), s.size >= t && a.length >= r) throw new A("queue-full", "报表任务队列已满");
149
- const u = c.id ?? `report-${++l}`;
150
- if (n.has(u)) throw new A("queue-full", "任务 ID 正在执行或排队");
151
- const y = new AbortController();
152
- let h = "queued", w, g, p, v;
153
- const j = new Promise((S, O) => {
154
- p = S, v = O;
155
- }), P = () => {
156
- c.signal?.removeEventListener("abort", H), n.delete(u);
157
- }, J = (S) => {
158
- if (h !== "queued" && h !== "running") return;
159
- const O = h === "queued";
160
- h = "cancelled", y.abort(S);
226
+ enqueue: (f, u = {}) => {
227
+ if (o) throw new k("closed", "任务队列已关闭");
228
+ if (v(u.signal), s.size >= t && a.length >= r) throw new k("queue-full", "报表任务队列已满");
229
+ const l = u.id ?? `report-${++d}`;
230
+ if (n.has(l)) throw new k("queue-full", "任务 ID 正在执行或排队");
231
+ const w = new AbortController();
232
+ let p = "queued", g, m, y, A;
233
+ const b = new Promise((R, N) => {
234
+ y = R, A = N;
235
+ }), S = () => {
236
+ u.signal?.removeEventListener("abort", E), n.delete(l);
237
+ }, I = (R) => {
238
+ if (p !== "queued" && p !== "running") return;
239
+ const N = p === "queued";
240
+ p = "cancelled", w.abort(R);
161
241
  try {
162
- x(y.signal);
163
- } catch (D) {
164
- v(D);
242
+ v(w.signal);
243
+ } catch (T) {
244
+ A(T);
165
245
  }
166
- if (O) {
167
- const D = a.indexOf(N);
168
- D >= 0 && a.splice(D, 1), P(), f();
246
+ if (N) {
247
+ const T = a.indexOf(B);
248
+ T >= 0 && a.splice(T, 1), S(), c();
169
249
  }
170
- }, H = () => J(c.signal?.reason), Q = (S, O) => {
171
- h === "running" && (!Number.isFinite(S) || S < 0 || O !== void 0 && (!Number.isFinite(O) || O < S) || (w = { completed: S, ...O === void 0 ? {} : { total: O } }));
172
- }, ie = (S) => {
173
- h !== "running" || y.signal.aborted || (g = { ...S, taskId: u }, S.completed !== void 0 && Q(S.completed, S.total), _(c.onEvent, g, y.signal));
174
- }, N = {
175
- cancel: J,
250
+ }, E = () => I(u.signal?.reason), K = (R, N) => {
251
+ p === "running" && (!Number.isFinite(R) || R < 0 || N !== void 0 && (!Number.isFinite(N) || N < R) || (g = { completed: R, ...N === void 0 ? {} : { total: N } }));
252
+ }, M = (R) => {
253
+ p !== "running" || w.signal.aborted || (m = { ...R, taskId: l }, R.completed !== void 0 && K(R.completed, R.total), q(u.onEvent, m, w.signal));
254
+ }, B = {
255
+ cancel: I,
176
256
  start: () => {
177
- h === "queued" && (h = "running", s.add(N), Promise.resolve().then(() => (x(y.signal), d({ taskId: u, signal: y.signal, reportProgress: Q, onEvent: ie }))).then(
178
- (S) => {
179
- h === "running" && (h = "completed", p(S));
257
+ p === "queued" && (p = "running", s.add(B), Promise.resolve().then(() => (v(w.signal), f({ taskId: l, signal: w.signal, reportProgress: K, onEvent: M }))).then(
258
+ (R) => {
259
+ p === "running" && (p = "completed", y(R));
180
260
  },
181
- (S) => {
182
- h === "running" && (h = "failed", v(S));
261
+ (R) => {
262
+ p === "running" && (p = "failed", A(R));
183
263
  }
184
264
  ).finally(() => {
185
- s.delete(N), P(), f();
265
+ s.delete(B), S(), c();
186
266
  }));
187
267
  }
188
268
  };
189
- return n.add(u), c.signal?.addEventListener("abort", H, { once: !0 }), c.signal?.aborted ? J(c.signal.reason) : s.size < t ? N.start() : a.push(N), { id: u, get status() {
190
- return h;
269
+ return n.add(l), u.signal?.addEventListener("abort", E, { once: !0 }), u.signal?.aborted ? I(u.signal.reason) : s.size < t ? B.start() : a.push(B), { id: l, get status() {
270
+ return p;
191
271
  }, get progress() {
192
- return w;
193
- }, get event() {
194
272
  return g;
195
- }, result: j, cancel: J };
273
+ }, get event() {
274
+ return m;
275
+ }, result: b, cancel: I };
196
276
  },
197
- close: (d = {}) => {
198
- i = !0;
199
- for (const c of [...a]) c.cancel(new A("closed", "任务队列已关闭"));
200
- if (d.cancelRunning) for (const c of s) c.cancel(new A("closed", "任务队列已关闭"));
277
+ close: (f = {}) => {
278
+ o = !0;
279
+ for (const u of [...a]) u.cancel(new k("closed", "任务队列已关闭"));
280
+ if (f.cancelRunning) for (const u of s) u.cancel(new k("closed", "任务队列已关闭"));
201
281
  }
202
282
  };
203
283
  }
204
- function Ae(e) {
284
+ function ze(e) {
205
285
  let t, r;
206
286
  const a = new Promise((s, n) => {
207
287
  t = s, r = n;
@@ -209,45 +289,45 @@ function Ae(e) {
209
289
  return a.catch(() => {
210
290
  }), { progress: e, promise: a, resolve: t, reject: r };
211
291
  }
212
- function W(e) {
292
+ function ne(e) {
213
293
  const t = Promise.reject(e);
214
294
  return t.catch(() => {
215
295
  }), t;
216
296
  }
217
- function Pe(e, t) {
297
+ function _e(e, t) {
218
298
  let r, a, s = !0, n;
219
- function i(o) {
220
- n ??= o ?? new Error("任务心跳更新失败"), a?.reject(n), a = void 0, t(n);
299
+ function o(i) {
300
+ n ??= i ?? new Error("任务心跳更新失败"), a?.reject(n), a = void 0, t(n);
221
301
  }
222
- function l(o) {
223
- const d = Promise.resolve().then(() => e(o?.progress)).then(
224
- () => o?.resolve(),
225
- (c) => {
226
- o?.reject(c), i(c);
302
+ function d(i) {
303
+ const f = Promise.resolve().then(() => e(i?.progress)).then(
304
+ () => i?.resolve(),
305
+ (u) => {
306
+ i?.reject(u), o(u);
227
307
  }
228
308
  ).finally(() => {
229
309
  r = void 0;
230
- const c = a;
231
- a = void 0, c && n === void 0 && l(c);
310
+ const u = a;
311
+ a = void 0, u && n === void 0 && d(u);
232
312
  });
233
- r = d, d.catch((c) => {
234
- i(c);
313
+ r = f, f.catch((u) => {
314
+ o(u);
235
315
  });
236
316
  }
237
- function f(o) {
317
+ function c(i) {
238
318
  if (!s)
239
- return W(
240
- new b("closed", "任务进度上报已结束")
319
+ return ne(
320
+ new x("closed", "任务进度上报已结束")
241
321
  );
242
- if (n !== void 0) return W(n);
243
- a ? a.progress = o : a = Ae(o);
244
- const d = a;
245
- return r || (a = void 0, l(d)), d.promise;
322
+ if (n !== void 0) return ne(n);
323
+ a ? a.progress = i : a = ze(i);
324
+ const f = a;
325
+ return r || (a = void 0, d(f)), f.promise;
246
326
  }
247
327
  return {
248
- progress: f,
328
+ progress: c,
249
329
  pulse() {
250
- s && !r && n === void 0 && l();
330
+ s && !r && n === void 0 && d();
251
331
  },
252
332
  async finish() {
253
333
  for (s = !1; r; ) await r;
@@ -255,39 +335,39 @@ function Pe(e, t) {
255
335
  }
256
336
  };
257
337
  }
258
- class Z extends b {
338
+ class ae extends x {
259
339
  constructor() {
260
340
  super("capacity", "任务结果超过独立预算,请保存文件引用");
261
341
  }
262
342
  }
263
- function ke(e) {
343
+ function Ue(e) {
264
344
  const t = e.concurrency ?? 1, r = e.leaseMs ?? 3e4, a = e.heartbeatMs ?? 1e4, s = e.maxResultBytes ?? 256 * 1024;
265
345
  if (![t, r, a, s].every(
266
- (i) => Number.isSafeInteger(i) && i > 0
346
+ (o) => Number.isSafeInteger(o) && o > 0
267
347
  ) || a * 2 > r)
268
- throw new b(
348
+ throw new x(
269
349
  "input",
270
350
  "并发、租约、心跳应为正整数,租约至少为心跳的两倍"
271
351
  );
272
352
  if (a > 2147483647)
273
- throw new b(
353
+ throw new x(
274
354
  "input",
275
355
  "心跳间隔超过平台定时器上限(2147483647毫秒)"
276
356
  );
277
357
  return { concurrency: t, leaseMs: r, heartbeatMs: a, maxResultBytes: s, now: () => {
278
- const i = (e.now ?? Date.now)();
279
- if (!Number.isSafeInteger(i) || i < 0)
280
- throw new b("input", "任务时钟应返回非负整数毫秒");
281
- return i;
358
+ const o = (e.now ?? Date.now)();
359
+ if (!Number.isSafeInteger(o) || o < 0)
360
+ throw new x("input", "任务时钟应返回非负整数毫秒");
361
+ return o;
282
362
  } };
283
363
  }
284
- async function M(e, t, r) {
285
- L(t, r);
364
+ async function _(e, t, r) {
365
+ Q(t, r);
286
366
  const a = await e.read(t, r);
287
- if (!a) throw new b("missing", "报表任务不存在");
367
+ if (!a) throw new x("missing", "报表任务不存在");
288
368
  return a;
289
369
  }
290
- async function B(e, t, r, a = []) {
370
+ async function D(e, t, r, a = []) {
291
371
  const s = { ...t, ...r, revision: t.revision + 1 };
292
372
  for (const n of a) delete s[n];
293
373
  if (!await e.compareAndSwap(
@@ -296,12 +376,12 @@ async function B(e, t, r, a = []) {
296
376
  t.revision,
297
377
  s
298
378
  ))
299
- throw new b("conflict", "报表任务已被其他请求更新");
300
- return T(s);
379
+ throw new x("conflict", "报表任务已被其他请求更新");
380
+ return U(s);
301
381
  }
302
- async function je(e, t, r, a) {
382
+ async function He(e, t, r, a) {
303
383
  if (!t.trim() || t.length > 128)
304
- throw new b("input", "workerId应为1–128位标识");
384
+ throw new x("input", "workerId应为1–128位标识");
305
385
  for (const s of await e.store.candidates(a, 100)) {
306
386
  const n = s.cancelRequested ? {
307
387
  ...s,
@@ -325,199 +405,199 @@ async function je(e, t, r, a) {
325
405
  return n;
326
406
  }
327
407
  }
328
- function K(e, t, r, a) {
408
+ function oe(e, t, r, a) {
329
409
  return e.status === "running" && e.attempt === a && e.lease?.owner === t && e.lease.expiresAt > r;
330
410
  }
331
- async function Ne(e, t, r, a) {
332
- const { scope: s, id: n } = r, i = r.lease.owner;
333
- let l;
334
- const f = Pe(
335
- async (g) => {
336
- const p = await M(e.store, s, n), v = t.now();
337
- if (!K(p, i, v, r.attempt))
338
- throw new b("lease", "报表任务租约已失效");
339
- if (p.cancelRequested) {
340
- a.abort(new b("closed", "任务已请求取消"));
411
+ async function Ke(e, t, r, a) {
412
+ const { scope: s, id: n } = r, o = r.lease.owner;
413
+ let d;
414
+ const c = _e(
415
+ async (m) => {
416
+ const y = await _(e.store, s, n), A = t.now();
417
+ if (!oe(y, o, A, r.attempt))
418
+ throw new x("lease", "报表任务租约已失效");
419
+ if (y.cancelRequested) {
420
+ a.abort(new x("closed", "任务已请求取消"));
341
421
  return;
342
422
  }
343
- await B(e.store, p, {
344
- updatedAt: v,
345
- lease: { owner: i, expiresAt: v + t.leaseMs },
346
- ...g ? { progress: g } : {}
423
+ await D(e.store, y, {
424
+ updatedAt: A,
425
+ lease: { owner: o, expiresAt: A + t.leaseMs },
426
+ ...m ? { progress: m } : {}
347
427
  });
348
428
  },
349
- (g) => {
350
- l = g, a.abort(g);
429
+ (m) => {
430
+ d = m, a.abort(m);
351
431
  }
352
- ), o = (g, p) => !Number.isFinite(g) || g < 0 || p !== void 0 && (!Number.isFinite(p) || p < g) ? Promise.reject(new b("input", "任务进度无效")) : f.progress({
353
- completed: g,
354
- ...p === void 0 ? {} : { total: p }
355
- }), d = setInterval(() => {
356
- f.pulse();
432
+ ), i = (m, y) => !Number.isFinite(m) || m < 0 || y !== void 0 && (!Number.isFinite(y) || y < m) ? Promise.reject(new x("input", "任务进度无效")) : c.progress({
433
+ completed: m,
434
+ ...y === void 0 ? {} : { total: y }
435
+ }), f = setInterval(() => {
436
+ c.pulse();
357
437
  }, t.heartbeatMs);
358
- let c, u;
438
+ let u, l;
359
439
  try {
360
- const g = Object.prototype.hasOwnProperty.call(
440
+ const m = Object.prototype.hasOwnProperty.call(
361
441
  e.handlers,
362
442
  r.request.kind
363
443
  ) ? e.handlers[r.request.kind] : void 0;
364
- if (!g) throw new b("input", "报表任务处理器未注册");
444
+ if (!m) throw new x("input", "报表任务处理器未注册");
365
445
  if (!a.signal.aborted) {
366
- const p = await g(T(r.request.payload), {
446
+ const y = await m(U(r.request.payload), {
367
447
  scope: s,
368
448
  taskId: n,
369
449
  signal: a.signal,
370
- reportProgress: o
450
+ reportProgress: i
371
451
  });
372
- if (c = JSON.parse(I(p)), ye(c) > t.maxResultBytes) throw new Z();
452
+ if (u = JSON.parse(F(y)), Ne(u) > t.maxResultBytes) throw new ae();
373
453
  }
374
- } catch (g) {
375
- u = g ?? new Error("报表任务执行失败");
454
+ } catch (m) {
455
+ l = m ?? new Error("报表任务执行失败");
376
456
  } finally {
377
- clearInterval(d), await f.finish().catch(() => {
457
+ clearInterval(f), await c.finish().catch(() => {
378
458
  });
379
459
  }
380
- const y = await M(e.store, s, n), h = t.now();
381
- if (!K(y, i, h, r.attempt))
382
- throw new b("lease", "任务租约已失效,迟到结果不会写回");
383
- const w = { ...y, updatedAt: h };
384
- delete w.lease, u ??= l, y.cancelRequested || a.signal.aborted && l === void 0 ? w.status = "cancelled" : u !== void 0 ? (w.status = "failed", w.error = {
385
- code: u instanceof Z ? "result-budget" : u instanceof b ? u.code : "execution",
386
- message: u instanceof Error ? u.message.slice(0, 500) : "报表任务执行失败"
387
- }) : (w.status = "completed", w.result = c);
460
+ const w = await _(e.store, s, n), p = t.now();
461
+ if (!oe(w, o, p, r.attempt))
462
+ throw new x("lease", "任务租约已失效,迟到结果不会写回");
463
+ const g = { ...w, updatedAt: p };
464
+ delete g.lease, l ??= d, w.cancelRequested || a.signal.aborted && d === void 0 ? g.status = "cancelled" : l !== void 0 ? (g.status = "failed", g.error = {
465
+ code: l instanceof ae ? "result-budget" : l instanceof x ? l.code : "execution",
466
+ message: l instanceof Error ? l.message.slice(0, 500) : "报表任务执行失败"
467
+ }) : (g.status = "completed", g.result = u);
388
468
  try {
389
- I(w);
469
+ F(g);
390
470
  } catch {
391
- delete w.result, w.status = "failed", w.error = {
471
+ delete g.result, g.status = "failed", g.error = {
392
472
  code: "result-budget",
393
473
  message: "任务结果与请求的组合超过存储预算,请保存文件引用而非文件内容"
394
474
  };
395
475
  }
396
- return Ee(e.store, y, w);
476
+ return Ve(e.store, w, g);
397
477
  }
398
- async function Ee(e, t, r) {
478
+ async function Ve(e, t, r) {
399
479
  try {
400
- return await B(e, t, r, ["lease"]);
480
+ return await D(e, t, r, ["lease"]);
401
481
  } catch (a) {
402
- if (!(a instanceof b) || a.code !== "capacity" || r.status !== "completed") throw a;
403
- return delete r.result, r.status = "failed", r.error = { code: "result-budget", message: "任务结果超过存储剩余预算,请保存文件引用而非文件内容" }, B(e, t, r, ["lease", "result"]);
482
+ if (!(a instanceof x) || a.code !== "capacity" || r.status !== "completed") throw a;
483
+ return delete r.result, r.status = "failed", r.error = { code: "result-budget", message: "任务结果超过存储剩余预算,请保存文件引用而非文件内容" }, D(e, t, r, ["lease", "result"]);
404
484
  }
405
485
  }
406
- async function Y(e, t, r, a) {
486
+ async function ie(e, t, r, a) {
407
487
  const s = await e.readTombstone?.(t, r);
408
488
  if (s) {
409
- if (s.requestHash !== await he(a)) throw new b("conflict", "相同任务ID不能提交不同内容(幂等保留期内)");
410
- return { scope: t, id: r, revision: s.revision, request: T(a), status: s.status, createdAt: s.createdAt, updatedAt: s.updatedAt, attempt: s.attempt, archived: !0 };
489
+ if (s.requestHash !== await Fe(a)) throw new x("conflict", "相同任务ID不能提交不同内容(幂等保留期内)");
490
+ return { scope: t, id: r, revision: s.revision, request: U(a), status: s.status, createdAt: s.createdAt, updatedAt: s.updatedAt, attempt: s.attempt, archived: !0 };
411
491
  }
412
492
  }
413
- function Ke(e) {
493
+ function It(e) {
414
494
  e = { ...e, handlers: { ...e.handlers } };
415
- const t = ke(e), r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
495
+ const t = Ue(e), r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
416
496
  let s = !1, n = 0;
417
- const i = (o, d) => (L(o, d), e.store.read(o, d));
497
+ const o = (i, f) => (Q(i, f), e.store.read(i, f));
418
498
  return {
419
- submit: async (o) => {
420
- if (o = { ...o }, L(o.scope, o.id), !Object.prototype.hasOwnProperty.call(e.handlers, o.kind) || typeof e.handlers[o.kind] != "function")
421
- throw new b("input", "报表任务处理器未注册");
422
- const d = {
423
- kind: o.kind,
499
+ submit: async (i) => {
500
+ if (i = { ...i }, Q(i.scope, i.id), !Object.prototype.hasOwnProperty.call(e.handlers, i.kind) || typeof e.handlers[i.kind] != "function")
501
+ throw new x("input", "报表任务处理器未注册");
502
+ const f = {
503
+ kind: i.kind,
424
504
  payload: JSON.parse(
425
- I(o.payload, {
505
+ F(i.payload, {
426
506
  maxNodes: 19e3,
427
507
  maxCharacters: 75e4
428
508
  })
429
509
  )
430
- }, c = await i(o.scope, o.id);
431
- if (c) {
432
- if (I(c.request) !== I(d))
433
- throw new b("conflict", "相同任务ID不能提交不同内容");
434
- return c;
510
+ }, u = await o(i.scope, i.id);
511
+ if (u) {
512
+ if (F(u.request) !== F(f))
513
+ throw new x("conflict", "相同任务ID不能提交不同内容");
514
+ return u;
435
515
  }
436
- const u = await Y(e.store, o.scope, o.id, d);
437
- if (u) return u;
438
- const y = t.now(), h = {
439
- scope: o.scope,
440
- id: o.id,
516
+ const l = await ie(e.store, i.scope, i.id, f);
517
+ if (l) return l;
518
+ const w = t.now(), p = {
519
+ scope: i.scope,
520
+ id: i.id,
441
521
  revision: 1,
442
- request: d,
522
+ request: f,
443
523
  status: "queued",
444
- createdAt: y,
445
- updatedAt: y,
524
+ createdAt: w,
525
+ updatedAt: w,
446
526
  attempt: 0
447
527
  };
448
- if (!await e.store.compareAndSwap(o.scope, o.id, null, h)) {
449
- const w = await i(o.scope, o.id);
450
- if (w && I(w.request) === I(d))
451
- return w;
452
- const g = await Y(e.store, o.scope, o.id, d);
453
- if (g) return g;
454
- throw new b("conflict", "报表任务提交发生冲突");
528
+ if (!await e.store.compareAndSwap(i.scope, i.id, null, p)) {
529
+ const g = await o(i.scope, i.id);
530
+ if (g && F(g.request) === F(f))
531
+ return g;
532
+ const m = await ie(e.store, i.scope, i.id, f);
533
+ if (m) return m;
534
+ throw new x("conflict", "报表任务提交发生冲突");
455
535
  }
456
- return T(h);
536
+ return U(p);
457
537
  },
458
- get: i,
459
- runNext: (o) => {
538
+ get: o,
539
+ runNext: (i) => {
460
540
  if (s)
461
- return Promise.reject(new b("closed", "报表任务服务已关闭"));
541
+ return Promise.reject(new x("closed", "报表任务服务已关闭"));
462
542
  if (n >= t.concurrency)
463
543
  return Promise.reject(
464
- new b("capacity", "报表任务执行槽位已满")
544
+ new x("capacity", "报表任务执行槽位已满")
465
545
  );
466
546
  n++;
467
- const d = new AbortController();
468
- r.add(d);
469
- const c = (async () => {
547
+ const f = new AbortController();
548
+ r.add(f);
549
+ const u = (async () => {
470
550
  try {
471
- const u = await je(
551
+ const l = await He(
472
552
  e,
473
- o,
553
+ i,
474
554
  t.leaseMs,
475
555
  t.now()
476
556
  );
477
- return u?.status === "running" ? await Ne(e, t, u, d) : u;
557
+ return l?.status === "running" ? await Ke(e, t, l, f) : l;
478
558
  } finally {
479
- n--, r.delete(d);
559
+ n--, r.delete(f);
480
560
  }
481
561
  })();
482
- return a.add(c), c.then(
483
- () => a.delete(c),
484
- () => a.delete(c)
485
- ), c;
562
+ return a.add(u), u.then(
563
+ () => a.delete(u),
564
+ () => a.delete(u)
565
+ ), u;
486
566
  },
487
567
  get active() {
488
568
  return n;
489
569
  },
490
- cancel: async (o, d) => {
491
- const c = await M(e.store, o, d);
492
- return c.status !== "queued" && c.status !== "running" ? c : B(e.store, c, {
570
+ cancel: async (i, f) => {
571
+ const u = await _(e.store, i, f);
572
+ return u.status !== "queued" && u.status !== "running" ? u : D(e.store, u, {
493
573
  updatedAt: t.now(),
494
- ...c.status === "queued" ? { status: "cancelled" } : { cancelRequested: !0 }
574
+ ...u.status === "queued" ? { status: "cancelled" } : { cancelRequested: !0 }
495
575
  });
496
576
  },
497
- retry: async (o, d, c) => {
498
- const u = await M(e.store, o, d);
499
- if (u.revision !== c || u.status !== "failed")
500
- throw new b("conflict", "仅可重试当前修订的失败任务");
501
- const y = {
502
- ...u,
577
+ retry: async (i, f, u) => {
578
+ const l = await _(e.store, i, f);
579
+ if (l.revision !== u || l.status !== "failed")
580
+ throw new x("conflict", "仅可重试当前修订的失败任务");
581
+ const w = {
582
+ ...l,
503
583
  status: "queued",
504
584
  updatedAt: t.now()
505
585
  };
506
- return delete y.error, delete y.progress, B(e.store, u, y, ["error", "progress"]);
586
+ return delete w.error, delete w.progress, D(e.store, l, w, ["error", "progress"]);
507
587
  },
508
- prune: async (o) => {
509
- if (!e.store.prune || !e.store.readTombstone) throw new b("input", "当前任务适配器未实现可选终态保留能力");
510
- return e.store.prune({ ...o, now: t.now() });
588
+ prune: async (i) => {
589
+ if (!e.store.prune || !e.store.readTombstone) throw new x("input", "当前任务适配器未实现可选终态保留能力");
590
+ return e.store.prune({ ...i, now: t.now() });
511
591
  },
512
592
  close: async () => {
513
593
  s = !0;
514
- for (const o of r)
515
- o.abort(new b("closed", "任务服务正在关闭"));
594
+ for (const i of r)
595
+ i.abort(new x("closed", "任务服务正在关闭"));
516
596
  await Promise.allSettled([...a]);
517
597
  }
518
598
  };
519
599
  }
520
- function ae(e, t) {
600
+ function ve(e, t) {
521
601
  const r = e.assets, a = e[t];
522
602
  if (!(!r && !a?.assetRenderers))
523
603
  return {
@@ -528,15 +608,15 @@ function ae(e, t) {
528
608
  assetBudget: { ...r?.assetBudget, ...a?.assetBudget }
529
609
  };
530
610
  }
531
- function ee(e, t) {
532
- return !e || e.code !== "missing-image" || e.format !== "pdf" && e.format !== "xlsx" ? !1 : typeof ae(t, e.format)?.assetRenderers?.[e.kind] == "function";
611
+ function ce(e, t) {
612
+ return !e || e.code !== "missing-image" || e.format !== "pdf" && e.format !== "xlsx" ? !1 : typeof ve(t, e.format)?.assetRenderers?.[e.kind] == "function";
533
613
  }
534
- function Be(e, t) {
535
- const r = ge(e, t), a = r.issues.filter((n) => !ee(n.diagnostic, t)), s = r.samples.map((n) => ({ ...n, diagnostics: n.diagnostics.filter((i) => !ee(i, t)) }));
614
+ function Xe(e, t) {
615
+ const r = Ae(e, t), a = r.issues.filter((n) => !ce(n.diagnostic, t)), s = r.samples.map((n) => ({ ...n, diagnostics: n.diagnostics.filter((o) => !ce(o, t)) }));
536
616
  return { ...r, issues: a, samples: s, ok: a.every((n) => n.severity !== "error"), artifacts: [] };
537
617
  }
538
- async function Je(e, t, r, a, s) {
539
- const n = Oe({ reports: { sample: { template: r, datasets: e.datasets } }, assets: ae(a, t), budget: {
618
+ async function Qe(e, t, r, a, s) {
619
+ const n = he({ reports: { sample: { template: r, datasets: e.datasets } }, assets: ve(a, t), budget: {
540
620
  maxRows: a.maxSampleRows ?? 1e3,
541
621
  maxPages: a.maxPages ?? 100,
542
622
  maxCells: a.maxCells ?? 25e4,
@@ -544,227 +624,407 @@ async function Je(e, t, r, a, s) {
544
624
  maxDurationMs: a.maxDurationMs ?? 3e4
545
625
  } });
546
626
  try {
547
- const { result: i, digest: l } = await z(a.signal, a.maxDurationMs ?? 3e4, async (f) => {
548
- const o = await n.export({ reportIds: ["sample"], params: e.params, format: t, signal: f, fidelity: a.strictOutputs ? "strict" : "warn", pdf: a.pdf, xlsx: a.xlsx }), d = o.diagnostics.filter((u) => u.severity !== "info");
549
- if (a.strictOutputs && d.length) throw new Error(`Strict ${t} encoding found fidelity issues: ${d.slice(0, 3).map((u) => u.message).join("; ")}`);
550
- const c = await a.digest?.(o.bytes);
551
- return x(f), await a.onArtifact?.(e.name, o), x(f), { result: o, digest: c };
627
+ const { result: o, digest: d } = await j(a.signal, a.maxDurationMs ?? 3e4, async (c) => {
628
+ const i = await n.export({ reportIds: ["sample"], params: e.params, format: t, signal: c, fidelity: a.strictOutputs ? "strict" : "warn", pdf: a.pdf, xlsx: a.xlsx }), f = i.diagnostics.filter((l) => l.severity !== "info");
629
+ if (a.strictOutputs && f.length) throw new Error(`Strict ${t} encoding found fidelity issues: ${f.slice(0, 3).map((l) => l.message).join("; ")}`);
630
+ const u = await a.digest?.(i.bytes);
631
+ return v(c), await a.onArtifact?.(e.name, i), v(c), { result: i, digest: u };
552
632
  });
553
- s.artifacts.push({ fixture: e.name, format: t, bytes: i.bytes.byteLength, pages: i.stats.pages, ...l ? { digest: l } : {} }), s.issues.push(...i.diagnostics.map((f) => ({ code: "output", severity: a.strictOutputs || f.severity === "error" ? "error" : "warning", path: "$.template", fixture: e.name, message: `${t}: ${f.message}` })));
554
- } catch (i) {
555
- x(a.signal), s.issues.push({ code: "output", severity: "error", path: "$.template", fixture: e.name, message: `${t}: ${i instanceof Error ? i.message : String(i)}` });
633
+ s.artifacts.push({ fixture: e.name, format: t, bytes: o.bytes.byteLength, pages: o.stats.pages, ...d ? { digest: d } : {} }), s.issues.push(...o.diagnostics.map((c) => ({ code: "output", severity: a.strictOutputs || c.severity === "error" ? "error" : "warning", path: "$.template", fixture: e.name, message: `${t}: ${c.message}` })));
634
+ } catch (o) {
635
+ v(a.signal), s.issues.push({ code: "output", severity: "error", path: "$.template", fixture: e.name, message: `${t}: ${o instanceof Error ? o.message : String(o)}` });
556
636
  }
557
637
  }
558
- async function Ye(e, t = {}) {
559
- x(t.signal);
560
- const r = Be(e, t);
638
+ async function Ot(e, t = {}) {
639
+ v(t.signal);
640
+ const r = Xe(e, t);
561
641
  if (!r.ok) return r;
562
- const a = xe(e).template, s = [...new Set(t.formats ?? ["pdf", "xlsx"])];
642
+ const a = Je(e).template, s = [...new Set(t.formats ?? ["pdf", "xlsx"])];
563
643
  if (!s.length || s.some((n) => n !== "pdf" && n !== "xlsx"))
564
644
  return r.issues.push({ code: "output", severity: "error", path: "$.formats", message: "真实文件验收应至少选择PDF/XLSX之一" }), r.ok = !1, r;
565
645
  for (const n of t.fixtures ?? [])
566
- for (const i of s)
567
- x(t.signal), !(i !== "pdf" && i !== "xlsx") && await Je(n, i, a, t, r);
646
+ for (const o of s)
647
+ v(t.signal), !(o !== "pdf" && o !== "xlsx") && await Qe(n, o, a, t, r);
568
648
  return r.ok = r.issues.every((n) => n.severity !== "error"), r;
569
649
  }
570
- class m extends Error {
650
+ class h extends Error {
571
651
  constructor(t, r) {
572
652
  super(r), this.code = t, this.name = "ReportInstanceError";
573
653
  }
574
654
  }
575
- function E(e, t) {
576
- if (typeof e != "string" || !e.trim() || e.length > 256 || typeof t != "string" || t !== t.trim() || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(t)) throw new m("input", "实例范围应非空,ID 应为安全标识");
655
+ function J(e, t) {
656
+ if (typeof e != "string" || !e.trim() || e.length > 256 || typeof t != "string" || t !== t.trim() || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(t)) throw new h("input", "实例范围应非空,ID 应为安全标识");
577
657
  }
578
- function De(e, t) {
658
+ function Ge(e, t) {
579
659
  const r = Object.getPrototypeOf(e);
580
- if (r !== (t ? Array.prototype : Object.prototype) && !(r === null && !t) || Object.getOwnPropertySymbols(e).length) throw new m("input", "实例应为普通 JSON 对象");
581
- if (t && Object.keys(e).some((s) => s !== String(Number(s)) || !Number.isSafeInteger(Number(s)) || Number(s) < 0 || Number(s) >= e.length)) throw new m("input", "实例数组不能包含额外属性");
582
- if (Object.getOwnPropertyNames(e).filter((s) => !(t && s === "length")).length !== Object.keys(e).length) throw new m("input", "实例不能包含不可枚举属性");
660
+ if (r !== (t ? Array.prototype : Object.prototype) && !(r === null && !t) || Object.getOwnPropertySymbols(e).length) throw new h("input", "实例应为普通 JSON 对象");
661
+ if (t && Object.keys(e).some((s) => s !== String(Number(s)) || !Number.isSafeInteger(Number(s)) || Number(s) < 0 || Number(s) >= e.length)) throw new h("input", "实例数组不能包含额外属性");
662
+ if (Object.getOwnPropertyNames(e).filter((s) => !(t && s === "length")).length !== Object.keys(e).length) throw new h("input", "实例不能包含不可枚举属性");
583
663
  }
584
- function Ce(e) {
585
- if (!Number.isSafeInteger(e.revision) || e.revision < 1 || typeof e.title != "string" || !e.title.trim() || e.title.length > 512) throw new m("input", "实例修订或标题无效");
586
- if (typeof e.generatedAt != "string" || !Number.isFinite(Date.parse(e.generatedAt)) || new Date(e.generatedAt).toISOString() !== e.generatedAt) throw new m("input", "实例生成时间应为 ISO UTC 字符串");
587
- if (!Array.isArray(e.reportIds) || !e.reportIds.length || e.reportIds.length > 100 || e.reportIds.some((t) => typeof t != "string" || !t.trim()) || new Set(e.reportIds).size !== e.reportIds.length) throw new m("input", "实例报表 ID 应非空且唯一");
664
+ function We(e) {
665
+ if (!Number.isSafeInteger(e.revision) || e.revision < 1 || typeof e.title != "string" || !e.title.trim() || e.title.length > 512) throw new h("input", "实例修订或标题无效");
666
+ if (typeof e.generatedAt != "string" || !Number.isFinite(Date.parse(e.generatedAt)) || new Date(e.generatedAt).toISOString() !== e.generatedAt) throw new h("input", "实例生成时间应为 ISO UTC 字符串");
667
+ if (!Array.isArray(e.reportIds) || !e.reportIds.length || e.reportIds.length > 100 || e.reportIds.some((t) => typeof t != "string" || !t.trim()) || new Set(e.reportIds).size !== e.reportIds.length) throw new h("input", "实例报表 ID 应非空且唯一");
588
668
  }
589
- function Me(e) {
669
+ function Ze(e) {
590
670
  return e === null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" && Number.isFinite(e);
591
671
  }
592
- function oe(e, t) {
593
- if (!Number.isSafeInteger(t) || t < 1) throw new m("input", "实例快照字节预算应为正安全整数");
672
+ function be(e, t) {
673
+ if (!Number.isSafeInteger(t) || t < 1) throw new h("input", "实例快照字节预算应为正安全整数");
594
674
  let r = 0, a = 0;
595
675
  const s = /* @__PURE__ */ new Set();
596
- function n(l, f) {
597
- if (++r > 1e6 || f > 64) throw new m("capacity", "实例节点或嵌套深度超过预算");
598
- if (typeof l == "string" && (a += l.length, a > t))
599
- throw new m("capacity", "实例文本超过预算");
600
- if (Me(l)) return l;
601
- if (!l || typeof l != "object" || s.has(l)) throw new m("input", "实例只允许无循环的有限 JSON 值");
602
- const o = Array.isArray(l);
603
- De(l, o), s.add(l);
604
- const d = /* @__PURE__ */ Object.create(null);
605
- for (const c of Object.keys(l)) {
606
- if (a += c.length, a > t) throw new m("capacity", "实例文本超过预算");
607
- const u = Object.getOwnPropertyDescriptor(l, c);
608
- if (u.get || u.set || ["__proto__", "constructor", "prototype"].includes(c)) throw new m("input", "实例不能包含访问器或危险键");
609
- u.value !== void 0 && (d[c] = n(u.value, f + 1));
676
+ function n(d, c) {
677
+ if (++r > 1e6 || c > 64) throw new h("capacity", "实例节点或嵌套深度超过预算");
678
+ if (typeof d == "string" && (a += d.length, a > t))
679
+ throw new h("capacity", "实例文本超过预算");
680
+ if (Ze(d)) return d;
681
+ if (!d || typeof d != "object" || s.has(d)) throw new h("input", "实例只允许无循环的有限 JSON 值");
682
+ const i = Array.isArray(d);
683
+ Ge(d, i), s.add(d);
684
+ const f = /* @__PURE__ */ Object.create(null);
685
+ for (const u of Object.keys(d)) {
686
+ if (a += u.length, a > t) throw new h("capacity", "实例文本超过预算");
687
+ const l = Object.getOwnPropertyDescriptor(d, u);
688
+ if (l.get || l.set || ["__proto__", "constructor", "prototype"].includes(u)) throw new h("input", "实例不能包含访问器或危险键");
689
+ l.value !== void 0 && (f[u] = n(l.value, c + 1));
610
690
  }
611
- if (s.delete(l), o) {
612
- if (Object.keys(d).length !== l.length) throw new m("input", "实例数组不能稀疏或包含额外属性");
613
- return Array.from({ length: l.length }, (c, u) => d[String(u)]);
691
+ if (s.delete(d), i) {
692
+ if (Object.keys(f).length !== d.length) throw new h("input", "实例数组不能稀疏或包含额外属性");
693
+ return Array.from({ length: d.length }, (u, l) => f[String(l)]);
614
694
  }
615
- return d;
695
+ return f;
616
696
  }
617
- const i = JSON.stringify(n(e, 0));
618
- if (new TextEncoder().encode(i).byteLength > t) throw new m("capacity", "实例快照超过单条字节预算");
619
- return i;
620
- }
621
- function V(e, t = 8e6) {
622
- const r = JSON.parse(oe(e, t));
623
- E(r.scope, r.id);
624
- const a = /* @__PURE__ */ new Set(["scope", "id", "revision", "title", "generatedAt", "reportIds", "params", "templateRevisions", "sourceRevisions", "plan", "artifacts"]);
625
- if (Object.keys(r).some((n) => !a.has(n))) throw new m("input", "实例包含未知字段");
626
- Ce(r);
697
+ const o = JSON.stringify(n(e, 0));
698
+ if (new TextEncoder().encode(o).byteLength > t) throw new h("capacity", "实例快照超过单条字节预算");
699
+ return o;
700
+ }
701
+ function W(e, t = 8e6) {
702
+ const r = JSON.parse(be(e, t));
703
+ J(r.scope, r.id);
704
+ const a = /* @__PURE__ */ new Set(["scope", "id", "revision", "title", "generatedAt", "reportIds", "params", "templateRevisions", "sourceRevisions", "plan", "artifacts", "output"]);
705
+ if (Object.keys(r).some((n) => !a.has(n))) throw new h("input", "实例包含未知字段");
706
+ We(r);
627
707
  for (const n of [r.params, r.templateRevisions, r.sourceRevisions])
628
- if (!n || typeof n != "object" || Array.isArray(n) || Object.values(n).some((i) => typeof i != "string")) throw new m("input", "实例参数和修订应为字符串字典");
629
- if (r.reportIds.some((n) => !r.templateRevisions[n])) throw new m("input", "每张报表都应记录生成时的模板修订");
630
- const s = re(r.plan);
631
- if (!s.ok) throw new m("input", `实例渲染计划无效:${s.errors[0]?.path}`);
632
- return r.artifacts !== void 0 && Te(r.artifacts), r;
708
+ if (!n || typeof n != "object" || Array.isArray(n) || Object.values(n).some((o) => typeof o != "string")) throw new h("input", "实例参数和修订应为字符串字典");
709
+ if (r.reportIds.some((n) => !r.templateRevisions[n])) throw new h("input", "每张报表都应记录生成时的模板修订");
710
+ const s = fe(r.plan);
711
+ if (!s.ok) throw new h("input", `实例渲染计划无效:${s.errors[0]?.path}`);
712
+ if (r.output !== void 0) {
713
+ if (!r.output || Object.keys(r.output).some((n) => !["stats", "diagnostics", "layout"].includes(n))) throw new h("input", "实例输出元数据只允许统计、诊断和字体度量;不保存来源令牌");
714
+ ge({ ...r.output, plan: r.plan, revisions: {} });
715
+ }
716
+ return r.artifacts !== void 0 && Ye(r.artifacts), r;
633
717
  }
634
- function Te(e) {
635
- if (!Array.isArray(e) || e.length > 100) throw new m("input", "实例文件列表无效");
718
+ function Ye(e) {
719
+ if (!Array.isArray(e) || e.length > 100) throw new h("input", "实例文件列表无效");
636
720
  const t = /* @__PURE__ */ new Set();
637
721
  for (const r of e) {
638
- if (!r || typeof r.key != "string" || !r.key.trim() || r.key.length > 1024 || t.has(r.key) || !["pdf", "xlsx"].includes(r.format) || !Number.isSafeInteger(r.bytes) || r.bytes < 0 || r.sha256 !== void 0 && (typeof r.sha256 != "string" || r.sha256.length !== 64 || !/^[a-f0-9]{64}$/i.test(r.sha256))) throw new m("input", "实例文件应包含唯一存储键、格式、大小和可选 SHA256");
722
+ if (!r || typeof r.key != "string" || !r.key.trim() || r.key.length > 1024 || t.has(r.key) || !["pdf", "xlsx"].includes(r.format) || !Number.isSafeInteger(r.bytes) || r.bytes < 0 || r.sha256 !== void 0 && (typeof r.sha256 != "string" || r.sha256.length !== 64 || !/^[a-f0-9]{64}$/i.test(r.sha256))) throw new h("input", "实例文件应包含唯一存储键、格式、大小和可选 SHA256");
639
723
  t.add(r.key);
640
724
  }
641
725
  }
642
- function $e(e) {
643
- const { scope: t, id: r, revision: a, title: s, generatedAt: n, reportIds: i, params: l, templateRevisions: f, sourceRevisions: o } = e;
644
- return JSON.parse(JSON.stringify({ scope: t, id: r, revision: a, title: s, generatedAt: n, reportIds: i, params: l, templateRevisions: f, sourceRevisions: o }));
726
+ function et(e) {
727
+ const { scope: t, id: r, revision: a, title: s, generatedAt: n, reportIds: o, params: d, templateRevisions: c, sourceRevisions: i } = e;
728
+ return JSON.parse(JSON.stringify({ scope: t, id: r, revision: a, title: s, generatedAt: n, reportIds: o, params: d, templateRevisions: c, sourceRevisions: i }));
645
729
  }
646
- function qe(e) {
730
+ function tt(e) {
647
731
  const t = { maxInstances: 100, maxRevisions: 20, maxBytes: 64e6, maxSnapshotBytes: 8e6, ...e };
648
- if (Object.values(t).some((r) => !Number.isSafeInteger(r) || r < 1)) throw new m("input", "实例存储预算应为正安全整数");
732
+ if (Object.values(t).some((r) => !Number.isSafeInteger(r) || r < 1)) throw new h("input", "实例存储预算应为正安全整数");
649
733
  return t;
650
734
  }
651
- function et(e = {}) {
652
- const t = qe(e), r = /* @__PURE__ */ new Map();
735
+ function Pt(e = {}) {
736
+ const t = tt(e), r = /* @__PURE__ */ new Map();
653
737
  let a = 0;
654
738
  return {
655
- read: async (s, n, i, l) => {
656
- x(l), E(s, n);
657
- const f = r.get(JSON.stringify([s, n])), o = f?.get(i ?? f.size);
658
- return o ? V(o, t.maxSnapshotBytes) : void 0;
739
+ read: async (s, n, o, d) => {
740
+ v(d), J(s, n);
741
+ const c = r.get(JSON.stringify([s, n])), i = c?.get(o ?? c.size);
742
+ return i ? W(i, t.maxSnapshotBytes) : void 0;
659
743
  },
660
744
  list: async (s, n = {}) => {
661
- x(n.signal), E(s, "list");
662
- const i = n.limit ?? 25;
663
- if (!Number.isSafeInteger(i) || i < 1 || i > 100) throw new m("input", "实例每页数量应为 1–100");
664
- const l = Array.from(r.values(), (f) => f.get(f.size)).filter((f) => f.scope === s && (!n.after || f.id > n.after) && (!n.reportId || f.reportIds.includes(n.reportId))).sort((f, o) => f.id < o.id ? -1 : 1).slice(0, i + 1);
665
- return { items: l.slice(0, i).map($e), ...l.length > i ? { next: l[i - 1].id } : {} };
745
+ v(n.signal), J(s, "list");
746
+ const o = n.limit ?? 25;
747
+ if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new h("input", "实例每页数量应为 1–100");
748
+ const d = Array.from(r.values(), (c) => c.get(c.size)).filter((c) => c.scope === s && (!n.after || c.id > n.after) && (!n.reportId || c.reportIds.includes(n.reportId))).sort((c, i) => c.id < i.id ? -1 : 1).slice(0, o + 1);
749
+ return { items: d.slice(0, o).map(et), ...d.length > o ? { next: d[o - 1].id } : {} };
666
750
  },
667
- compareAndSwap: async (s, n, i, l, f) => {
668
- x(f), E(s, n);
669
- const o = V(l, t.maxSnapshotBytes);
670
- if (o.scope !== s || o.id !== n || o.revision !== (i ?? 0) + 1) throw new m("input", "实例身份或修订不一致");
671
- const d = JSON.stringify([s, n]), c = r.get(d) ?? /* @__PURE__ */ new Map();
672
- if ((c.size || null) !== i) return !1;
673
- const u = new TextEncoder().encode(JSON.stringify(o)).byteLength;
674
- if (c.size >= t.maxRevisions || a + u > t.maxBytes || !c.size && r.size >= t.maxInstances) throw new m("capacity", "实例存储达到预算,请使用持久化归档策略或显式调整容量");
675
- return c.set(o.revision, o), r.set(d, c), a += u, !0;
751
+ compareAndSwap: async (s, n, o, d, c) => {
752
+ v(c), J(s, n);
753
+ const i = W(d, t.maxSnapshotBytes);
754
+ if (i.scope !== s || i.id !== n || i.revision !== (o ?? 0) + 1) throw new h("input", "实例身份或修订不一致");
755
+ const f = JSON.stringify([s, n]), u = r.get(f) ?? /* @__PURE__ */ new Map();
756
+ if ((u.size || null) !== o) return !1;
757
+ const l = new TextEncoder().encode(JSON.stringify(i)).byteLength;
758
+ if (u.size >= t.maxRevisions || a + l > t.maxBytes || !u.size && r.size >= t.maxInstances) throw new h("capacity", "实例存储达到预算,请使用持久化归档策略或显式调整容量");
759
+ return u.set(i.revision, i), r.set(f, u), a += l, !0;
676
760
  }
677
761
  };
678
762
  }
679
- function Fe(e, t = {}) {
763
+ function rt(e, t = {}) {
680
764
  const r = t.maxSnapshotBytes ?? 8e6;
681
- if (!Number.isSafeInteger(r) || r < 1) throw new m("input", "实例快照字节预算应为正安全整数");
765
+ if (!Number.isSafeInteger(r) || r < 1) throw new h("input", "实例快照字节预算应为正安全整数");
682
766
  return {
683
767
  read: e.read.bind(e),
684
768
  list: e.list.bind(e),
685
769
  save: async (a, s) => {
686
770
  const n = s.expectedRevision;
687
- if (n !== null && (!Number.isSafeInteger(n) || n < 1 || n >= Number.MAX_SAFE_INTEGER)) throw new m("input", "实例预期修订无效");
688
- const i = JSON.parse(oe(a, r)), l = V({ ...i, revision: (n ?? 0) + 1 }, r);
689
- if (x(s.signal), !await e.compareAndSwap(l.scope, l.id, n, l, s.signal)) throw new m("conflict", "实例已存在或已变化,请显式确认修订后保存");
690
- return l;
771
+ if (n !== null && (!Number.isSafeInteger(n) || n < 1 || n >= Number.MAX_SAFE_INTEGER)) throw new h("input", "实例预期修订无效");
772
+ const o = JSON.parse(be(a, r)), d = W({ ...o, revision: (n ?? 0) + 1 }, r);
773
+ if (v(s.signal), !await e.compareAndSwap(d.scope, d.id, n, d, s.signal)) throw new h("conflict", "实例已存在或已变化,请显式确认修订后保存");
774
+ return d;
691
775
  }
692
776
  };
693
777
  }
694
- function tt(e, t) {
695
- return I({ reportIds: e, params: t });
778
+ function kt(e, t) {
779
+ return F({ reportIds: e, params: t });
696
780
  }
697
- function ze(e) {
698
- if (!e || typeof e != "object" || Object.getOwnPropertySymbols(e).length) throw new m("input", "生成请求应为普通对象");
781
+ function st(e) {
782
+ if (!e || typeof e != "object" || Object.getOwnPropertySymbols(e).length) throw new h("input", "生成请求应为普通对象");
699
783
  const t = /* @__PURE__ */ Object.create(null);
700
784
  let r;
701
785
  const a = /* @__PURE__ */ new Set(["scope", "id", "title", "reportIds", "params", "expectedRevision", "signal"]);
702
786
  for (const s of Object.getOwnPropertyNames(e)) {
703
787
  const n = Object.getOwnPropertyDescriptor(e, s);
704
- if (!a.has(s) || !n.enumerable || n.get || n.set) throw new m("input", "生成请求不能包含未知字段或访问器");
788
+ if (!a.has(s) || !n.enumerable || n.get || n.set) throw new h("input", "生成请求不能包含未知字段或访问器");
705
789
  s === "signal" ? r = n.value : n.value !== void 0 && (t[s] = n.value);
706
790
  }
707
- return { signal: r, request: JSON.parse(I(t)) };
791
+ return { signal: r, request: JSON.parse(F(t)) };
708
792
  }
709
- function rt(e) {
710
- const t = JSON.parse(I(e.templateRevisions)), r = Fe(e.instances, { maxSnapshotBytes: e.maxSnapshotBytes });
793
+ function At(e) {
794
+ const t = JSON.parse(F(e.templateRevisions)), r = C(e.pdf), a = rt(e.instances, { maxSnapshotBytes: e.maxSnapshotBytes });
711
795
  return {
712
- async generate(a) {
713
- const { signal: s, request: n } = ze(a);
714
- if (E(n.scope, n.id), n.expectedRevision !== null && (!Number.isSafeInteger(n.expectedRevision) || n.expectedRevision < 1)) throw new m("input", "实例预期修订无效");
715
- const i = e.runtime.validate(n);
716
- if (!i.ok) throw new te(i.issues);
717
- const l = /* @__PURE__ */ Object.create(null);
718
- for (const c of n.reportIds) {
719
- if (typeof t[c] != "string" || !t[c]) throw new TypeError(`报表 ${c} 缺少生成时的模板修订`);
720
- l[c] = t[c];
796
+ async generate(s) {
797
+ const { signal: n, request: o } = st(s);
798
+ if (J(o.scope, o.id), o.expectedRevision !== null && (!Number.isSafeInteger(o.expectedRevision) || o.expectedRevision < 1)) throw new h("input", "实例预期修订无效");
799
+ const d = e.runtime.validate(o);
800
+ if (!d.ok) throw new le(d.issues);
801
+ const c = /* @__PURE__ */ Object.create(null);
802
+ for (const g of o.reportIds) {
803
+ if (typeof t[g] != "string" || !t[g]) throw new TypeError(`报表 ${g} 缺少生成时的模板修订`);
804
+ c[g] = t[g];
721
805
  }
722
- if (x(s), ((await e.instances.read(n.scope, n.id, void 0, s))?.revision ?? null) !== n.expectedRevision)
723
- throw new m("conflict", "实例已存在或已变化,请显式确认修订后生成");
724
- const o = await e.runtime.prepare({ reportIds: n.reportIds, params: i.values, signal: s });
725
- x(s);
726
- const d = /* @__PURE__ */ Object.create(null);
727
- for (const [c, u] of Object.entries(o.revisions)) u.revision !== void 0 && (d[c] = u.revision);
728
- return r.save({
729
- scope: n.scope,
730
- id: n.id,
731
- title: n.title,
732
- reportIds: n.reportIds,
733
- params: i.values,
734
- templateRevisions: l,
735
- sourceRevisions: d,
806
+ if (v(n), ((await e.instances.read(o.scope, o.id, void 0, n))?.revision ?? null) !== o.expectedRevision)
807
+ throw new h("conflict", "实例已存在或已变化,请显式确认修订后生成");
808
+ const f = await e.runtime.prepare({ reportIds: o.reportIds, params: d.values, pdf: r, signal: n });
809
+ v(n);
810
+ const u = /* @__PURE__ */ Object.create(null);
811
+ for (const [g, m] of Object.entries(f.revisions)) m.revision !== void 0 && (u[g] = m.revision);
812
+ const { plan: l, revisions: w, ...p } = f;
813
+ return a.save({
814
+ scope: o.scope,
815
+ id: o.id,
816
+ title: o.title,
817
+ reportIds: o.reportIds,
818
+ params: d.values,
819
+ templateRevisions: c,
820
+ sourceRevisions: u,
736
821
  generatedAt: (e.now?.() ?? /* @__PURE__ */ new Date()).toISOString(),
737
- plan: o.plan
738
- }, { expectedRevision: n.expectedRevision, signal: s });
822
+ plan: l,
823
+ output: p
824
+ }, { expectedRevision: o.expectedRevision, signal: n });
825
+ },
826
+ read: a.read,
827
+ list: a.list,
828
+ /** Read an immutable saved revision and encode its plan, never re-query the business source. */
829
+ async exportInstance(s) {
830
+ const { scope: n, id: o, revision: d, signal: c, format: i, fidelity: f, taskId: u, correlationId: l, onEvent: w } = s, p = C(s.pdf ?? r), g = G(s.xlsx);
831
+ J(n, o), v(c);
832
+ const m = await a.read(n, o, d, c);
833
+ if (!m) throw new h("input", "报表实例不存在");
834
+ const y = {
835
+ plan: m.plan,
836
+ revisions: Object.fromEntries(m.reportIds.map((A) => [A, { revision: m.sourceRevisions[A] }])),
837
+ diagnostics: [{ code: "instance-row-count", severity: "info", message: "历史实例未保存原始取数行数;本次 rows 统计为 0,页面及单元格数由已保存计划校验。" }],
838
+ stats: { rows: 0, pages: m.plan.pages.length, cells: 0, durationMs: 0 },
839
+ ...m.output
840
+ };
841
+ return e.runtime.exportPrepared({ prepared: y, format: i, fidelity: f, pdf: p, xlsx: g, signal: c, taskId: u, correlationId: l, onEvent: w });
739
842
  },
740
- read: r.read,
741
- list: r.list,
742
843
  /** Instance edits are explicit snapshots; source business persistence remains the Provider.save responsibility. */
743
- save: r.save
844
+ save: a.save
845
+ };
846
+ }
847
+ function L(e, t, r) {
848
+ if (!Number.isSafeInteger(e) || e < 1 || e > t) throw new RangeError(`${r} 应为 1–${t} 的安全整数`);
849
+ return e;
850
+ }
851
+ function ue(e) {
852
+ if (!e || typeof e.key != "string" || !e.key.trim() || e.key.length > 1024 || !["pdf", "xlsx"].includes(e.format) || !Number.isSafeInteger(e.bytes) || e.bytes < 0 || e.sha256 !== void 0 && !/^[a-f0-9]{64}$/i.test(e.sha256)) throw new TypeError("分批归档回执应包含存储键、格式、大小和可选 SHA256");
853
+ return { key: e.key, format: e.format, bytes: e.bytes, ...e.sha256 ? { sha256: e.sha256 } : {} };
854
+ }
855
+ function nt(e) {
856
+ if (!Ce(e).ok || !e.repeat) throw new TypeError("分批生成仅支持有效的逐记录固定标签模板");
857
+ return JSON.parse(JSON.stringify(e));
858
+ }
859
+ function at(e) {
860
+ const t = /* @__PURE__ */ new Set(), r = e.repeat;
861
+ r.rowKey && t.add(r.rowKey), typeof r.copies == "object" && t.add(r.copies.field);
862
+ const a = (s) => {
863
+ s.binding && t.add(s.binding.field);
864
+ for (const n of s.grid?.cells ?? []) for (const o of n) o?.children?.forEach(a);
744
865
  };
866
+ return e.pages.forEach((s) => s.components.forEach((n) => a(n))), [...t];
867
+ }
868
+ function ot(e, t, r, a) {
869
+ if (!e || typeof e != "object" || Array.isArray(e)) throw new TypeError(`标签记录 ${a} 应为对象`);
870
+ const s = /* @__PURE__ */ Object.create(null);
871
+ for (const n of t) {
872
+ const o = pe(e, n, { dataset: r, rowIndex: a });
873
+ if (typeof o == "string" && o.length > 1e6) throw new k("budget", "标签字段超过 1 MB 字符预算", `$.datasets.${r}[${a}].${n}`);
874
+ o !== void 0 && (s[n] = o);
875
+ }
876
+ return s;
877
+ }
878
+ function it(e, t, r, a) {
879
+ const s = t.repeat;
880
+ if (!s.rowKey) return;
881
+ const n = pe(e, s.rowKey, { rowIndex: a, dataset: s.dataset });
882
+ if (!(typeof n == "string" && n.trim() || typeof n == "number" && Number.isFinite(n))) throw new TypeError(`标签记录 ${a} 的业务主键无效`);
883
+ const o = JSON.stringify([typeof n, n]);
884
+ if (r.keys.has(o)) throw new TypeError(`标签记录 ${a} 的业务主键重复(包含先前批次)`);
885
+ r.bytes += o.length * 2 + 64, r.keys.add(o);
886
+ }
887
+ function ct(e) {
888
+ return Object.entries(e).reduce((t, [r, a]) => t + 64 + r.length * 2 + (typeof a == "string" ? a.length * 2 : 8), 0);
889
+ }
890
+ function ut(e, t) {
891
+ if (!t) return e;
892
+ for (const r of e.plan.pages) {
893
+ const a = r.meta?.record;
894
+ a && typeof a == "object" && "rowIndex" in a && typeof a.rowIndex == "number" && (a.rowIndex += t);
895
+ }
896
+ return e;
897
+ }
898
+ async function dt(e, t) {
899
+ if (!e.return) return;
900
+ const r = Promise.resolve(e.return());
901
+ if (t.aborted) {
902
+ r.catch(() => {
903
+ });
904
+ return;
905
+ }
906
+ await j(t, void 0, () => r);
907
+ }
908
+ async function de(e, t, r) {
909
+ const a = Promise.resolve().then(() => e.onReceipt?.(t, r));
910
+ a.catch(() => {
911
+ }), await j(r.signal, void 0, () => a);
912
+ }
913
+ function lt(e, t, r) {
914
+ return new Promise((a, s) => {
915
+ let n = !1, o = !1, d;
916
+ const c = () => {
917
+ clearTimeout(d), t.removeEventListener("abort", i);
918
+ }, i = () => {
919
+ n || d !== void 0 || (d = setTimeout(() => {
920
+ if (!n) {
921
+ n = !0, o = !0, c();
922
+ try {
923
+ v(t);
924
+ } catch (f) {
925
+ s(f);
926
+ }
927
+ }
928
+ }, 0));
929
+ };
930
+ e.then((f) => {
931
+ if (o) {
932
+ Promise.resolve().then(() => r(f)).catch(() => {
933
+ });
934
+ return;
935
+ }
936
+ n || (n = !0, c(), a(f));
937
+ }, (f) => {
938
+ n || (n = !0, c(), s(f));
939
+ }), t.addEventListener("abort", i, { once: !0 }), t.aborted && i();
940
+ });
941
+ }
942
+ async function Bt(e, t) {
943
+ const r = L(t.batchSize ?? 100, 1e3, "batchSize"), a = L(t.maxRows ?? 1e5, 1e6, "maxRows"), s = L(t.maxChunks ?? 1e3, 1e4, "maxChunks"), n = L(t.maxRetainedBytes ?? 16e6, 64e6, "maxRetainedBytes"), o = nt(t.template), d = at(o);
944
+ if (!e || typeof e[Symbol.asyncIterator] != "function") throw new TypeError("标签来源应为 AsyncIterable");
945
+ return j(t.signal, t.runtime?.budget?.maxDurationMs ?? 12e4, async (c) => {
946
+ const i = { rows: 0, chunks: [] }, f = { keys: /* @__PURE__ */ new Set(), bytes: 0 }, u = e[Symbol.asyncIterator]();
947
+ let l = !1, w = !1, p;
948
+ const g = () => p ??= dt(u, c), m = () => {
949
+ l || g().catch(() => {
950
+ });
951
+ };
952
+ c.addEventListener("abort", m, { once: !0 });
953
+ try {
954
+ for (; !l; ) {
955
+ v(c);
956
+ const y = [];
957
+ let A = 0;
958
+ for (; y.length < r; ) {
959
+ const B = await j(c, void 0, () => Promise.resolve(u.next()));
960
+ if (B.done) {
961
+ l = !0;
962
+ break;
963
+ }
964
+ if (i.rows + y.length >= a) throw new k("budget", "标签来源行数超过预算", "$.maxRows");
965
+ if (i.chunks.length >= s) throw new k("budget", "标签分块数量超过预算", "$.maxChunks");
966
+ const R = ot(B.value, d, o.repeat.dataset, i.rows + y.length);
967
+ if (it(R, o, f, i.rows + y.length), A += ct(R), f.bytes + A > n) throw new k("budget", "标签当前块字段与全局主键索引超过内存预算", "$.maxRetainedBytes");
968
+ y.push(R);
969
+ }
970
+ if (!y.length) break;
971
+ const b = he({ ...t.runtime, reports: { labels: { template: o, datasets: { [o.repeat.dataset]: y } } } });
972
+ let S;
973
+ const I = {
974
+ index: i.chunks.length,
975
+ rowOffset: i.rows,
976
+ rowCount: y.length,
977
+ signal: c,
978
+ export: (B) => b.exportPrepared({ pdf: t.pdf, ...B, prepared: S, signal: c })
979
+ };
980
+ let E;
981
+ const M = (await je([{ id: `labels-${I.index}`, params: {} }], async () => {
982
+ try {
983
+ S = ut(await b.prepare({ reportIds: ["labels"], pdf: t.pdf, signal: c }), I.rowOffset), v(c);
984
+ const B = Promise.resolve(t.execute(S, I)), R = await lt(B, c, (N) => de(t, ue(N), I));
985
+ return ue(R);
986
+ } catch (B) {
987
+ throw E = B, B;
988
+ }
989
+ }, { concurrency: 1, signal: c, failure: "stop" }))[0];
990
+ if (M.status === "cancelled")
991
+ throw v(c), new Error("标签分批任务已取消");
992
+ if (M.status === "failed") throw E ?? new Error(M.error.message);
993
+ i.chunks.push({ ...M.value, index: I.index, rowOffset: I.rowOffset, rowCount: I.rowCount }), i.rows += y.length, await de(t, M.value, I);
994
+ }
995
+ return i;
996
+ } catch (y) {
997
+ throw w = !0, y;
998
+ } finally {
999
+ c.removeEventListener("abort", m), l || await g().catch((y) => {
1000
+ if (!w) throw y;
1001
+ });
1002
+ }
1003
+ });
745
1004
  }
746
1005
  export {
747
- m as ReportInstanceError,
748
- b as ReportJobError,
749
- A as ReportRuntimeError,
750
- E as checkInstanceIdentity,
751
- L as checkJobIdentity,
752
- T as cloneJob,
753
- et as createMemoryReportInstanceStore,
754
- at as createMemoryReportJobStore,
755
- rt as createReportGenerationService,
756
- Fe as createReportInstanceManager,
757
- Ke as createReportJobService,
758
- Oe as createReportRuntime,
759
- Ze as createReportTaskQueue,
760
- tt as reportInstanceParameterKey,
761
- $e as reportInstanceSummary,
762
- Ye as reviewReportPublication,
763
- ot as runReportBatch,
764
- it as runnableJob,
765
- I as serializeJobJson,
766
- ct as snapshotReportBatchCases,
767
- V as snapshotReportInstance,
768
- lt as validateJobRecord,
769
- ut as validateJobTransition
1006
+ h as ReportInstanceError,
1007
+ x as ReportJobError,
1008
+ k as ReportRuntimeError,
1009
+ J as checkInstanceIdentity,
1010
+ Q as checkJobIdentity,
1011
+ U as cloneJob,
1012
+ Pt as createMemoryReportInstanceStore,
1013
+ Ft as createMemoryReportJobStore,
1014
+ At as createReportGenerationService,
1015
+ rt as createReportInstanceManager,
1016
+ It as createReportJobService,
1017
+ he as createReportRuntime,
1018
+ St as createReportTaskQueue,
1019
+ kt as reportInstanceParameterKey,
1020
+ et as reportInstanceSummary,
1021
+ Ot as reviewReportPublication,
1022
+ Bt as runLabelStream,
1023
+ je as runReportBatch,
1024
+ jt as runnableJob,
1025
+ F as serializeJobJson,
1026
+ Mt as snapshotReportBatchCases,
1027
+ W as snapshotReportInstance,
1028
+ $t as validateJobRecord,
1029
+ Jt as validateJobTransition
770
1030
  };