@agile-team/mach-report 2.13.0 → 2.15.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 (260) hide show
  1. package/README.md +20 -7
  2. package/THIRD_PARTY_NOTICES.md +3 -1
  3. package/dist/ExcelBindingWizard-BKH1nGNS.js +1485 -0
  4. package/dist/ExcelBindingWizard-Bs43BGNp.cjs +1 -0
  5. package/dist/ParamEditor-Da4akw6V.cjs +1 -0
  6. package/dist/ParamEditor-DoAhzJsm.js +594 -0
  7. package/dist/{ReportBatchPanel-CW2HV9I8.js → ReportBatchPanel-BMf6boMA.js} +39 -39
  8. package/dist/ReportBatchPanel-wP9m9Pj1.cjs +1 -0
  9. package/dist/ReportPreview-ChV19HBp.js +4619 -0
  10. package/dist/ReportPreview-DbLvvOUT.cjs +6 -0
  11. package/dist/{ReportTemplateLibrary-BZB-XWjj.js → ReportTemplateLibrary-C9wutIiT.js} +1 -1
  12. package/dist/ReportTemplateLibrary-Sxr3eD0J.cjs +1 -0
  13. package/dist/RuleEditor-C_Clasvd.js +2037 -0
  14. package/dist/RuleEditor-XhGHK8DE.cjs +1 -0
  15. package/dist/TemplateOutlinePanel-D6Bkny59.js +96 -0
  16. package/dist/TemplateOutlinePanel-JTSR53vJ.cjs +1 -0
  17. package/dist/TemplateReusePanel-Kx35S0Ql.cjs +1 -0
  18. package/dist/TemplateReusePanel-rVuK1kTz.js +388 -0
  19. package/dist/TemplateReviewPanel-B0ar9_zf.js +592 -0
  20. package/dist/TemplateReviewPanel-Dn6X9UmY.cjs +1 -0
  21. package/dist/analytics.cjs +1 -1
  22. package/dist/analytics.d.cts +3 -1
  23. package/dist/analytics.d.ts +3 -1
  24. package/dist/analytics.js +154 -60
  25. package/dist/artifact-integrity.json +135 -0
  26. package/dist/assets-B9ImAi6_.cjs +1 -0
  27. package/dist/assets-DEaz4qsp.js +124 -0
  28. package/dist/batch-BaP6pWDE.cjs +1 -0
  29. package/dist/batch-BfZHN1do.js +220 -0
  30. package/dist/batch-CGyt-b2W.js +273 -0
  31. package/dist/batch-CLpELXBl.cjs +1 -0
  32. package/dist/capabilities-CAh2Nrue.cjs +1 -0
  33. package/dist/capabilities-DskCHs3V.js +69 -0
  34. package/dist/codes.d.cts +2 -0
  35. package/dist/codes.d.ts +2 -0
  36. package/dist/{computed-Bvk0W15F.js → computed-C-4C2S5h.js} +3 -3
  37. package/dist/config-BVsJXSqS.js +842 -0
  38. package/dist/config-D10us76d.cjs +1 -0
  39. package/dist/data-explanation-B8MZRYVS.js +16 -0
  40. package/dist/data-explanation-DE55G30w.cjs +1 -0
  41. package/dist/designer-2bDlcNXQ.js +5136 -0
  42. package/dist/designer-BT7XCdbW.cjs +2 -0
  43. package/dist/designer.cjs +1 -2
  44. package/dist/designer.d.cts +432 -17
  45. package/dist/designer.d.ts +432 -17
  46. package/dist/designer.js +21 -4312
  47. package/dist/drill-ByJviLXS.js +145 -0
  48. package/dist/drill-DYTxuL3A.cjs +1 -0
  49. package/dist/font-loader-B_UkxpzC.cjs +1 -0
  50. package/dist/font-loader-Q3bQjmrI.js +297 -0
  51. package/dist/index.cjs +8 -8
  52. package/dist/index.d.cts +239 -5
  53. package/dist/index.d.ts +239 -5
  54. package/dist/index.js +939 -893
  55. package/dist/json-snapshot-DFb2eWkf.js +1416 -0
  56. package/dist/json-snapshot-WWSGlaHG.cjs +2 -0
  57. package/dist/licenses/_bwip-js_generic-4.11.4.txt +24 -0
  58. package/dist/licenses/_fast-csv_format-4.3.5.txt +22 -0
  59. package/dist/licenses/_fast-csv_parse-4.3.6.txt +22 -0
  60. package/dist/licenses/_pdf-lib_fontkit-1.1.1.txt +326 -0
  61. package/dist/licenses/_pdf-lib_standard-fonts-1.0.0.txt +22 -0
  62. package/dist/licenses/_pdf-lib_upng-1.0.1.txt +22 -0
  63. package/dist/licenses/_types_node-14.18.63.txt +22 -0
  64. package/dist/licenses/_types_pako-2.0.3.txt +22 -0
  65. package/dist/licenses/_types_pegjs-0.10.6.txt +22 -0
  66. package/dist/licenses/archiver-5.3.2.txt +23 -0
  67. package/dist/licenses/archiver-utils-2.1.0.txt +23 -0
  68. package/dist/licenses/archiver-utils-3.0.4.txt +23 -0
  69. package/dist/licenses/async-3.2.6.txt +20 -0
  70. package/dist/licenses/balanced-match-1.0.2.txt +22 -0
  71. package/dist/licenses/base64-js-1.5.1.txt +22 -0
  72. package/dist/licenses/big-integer-1.6.52.txt +25 -0
  73. package/dist/licenses/binary-0.3.0.txt +178 -0
  74. package/dist/licenses/bl-4.1.0.txt +14 -0
  75. package/dist/licenses/bluebird-3.4.7.txt +22 -0
  76. package/dist/licenses/brace-expansion-1.1.21.txt +22 -0
  77. package/dist/licenses/brace-expansion-2.1.7.txt +22 -0
  78. package/dist/licenses/buffer-5.7.1.txt +22 -0
  79. package/dist/licenses/buffer-crc32-0.2.13.txt +20 -0
  80. package/dist/licenses/buffer-indexof-polyfill-1.0.2.txt +23 -0
  81. package/dist/licenses/buffers-0.1.1.txt +140 -0
  82. package/dist/licenses/chainsaw-0.1.0.txt +184 -0
  83. package/dist/licenses/compress-commons-4.1.2.txt +23 -0
  84. package/dist/licenses/concat-map-0.0.1.txt +19 -0
  85. package/dist/licenses/core-util-is-1.0.3.txt +20 -0
  86. package/dist/licenses/crc-32-1.2.2.txt +202 -0
  87. package/dist/licenses/crc32-stream-4.0.3.txt +23 -0
  88. package/dist/licenses/dayjs-1.11.23.txt +22 -0
  89. package/dist/licenses/duplexer2-0.1.4.txt +27 -0
  90. package/dist/licenses/end-of-stream-1.4.5.txt +22 -0
  91. package/dist/licenses/exceljs-4.4.0.txt +23 -0
  92. package/dist/licenses/fast-csv-4.3.6.txt +22 -0
  93. package/dist/licenses/fast-png-6.4.0.txt +22 -0
  94. package/dist/licenses/fs-constants-1.0.0.txt +22 -0
  95. package/dist/licenses/fs.realpath-1.0.0.txt +44 -0
  96. package/dist/licenses/fstream-1.0.12.txt +16 -0
  97. package/dist/licenses/glob-7.2.3.txt +22 -0
  98. package/dist/licenses/graceful-fs-4.2.11.txt +16 -0
  99. package/dist/licenses/ieee754-1.2.1.txt +12 -0
  100. package/dist/licenses/immediate-3.0.6.txt +21 -0
  101. package/dist/licenses/inflight-1.0.6.txt +16 -0
  102. package/dist/licenses/inherits-2.0.4.txt +17 -0
  103. package/dist/licenses/iobuffer-5.4.0.txt +23 -0
  104. package/dist/licenses/isarray-1.0.0.txt +61 -0
  105. package/dist/licenses/jszip-3.10.2.txt +652 -0
  106. package/dist/licenses/lazystream-1.0.1.txt +24 -0
  107. package/dist/licenses/lie-3.3.0.txt +8 -0
  108. package/dist/licenses/listenercount-1.0.1.txt +6 -0
  109. package/dist/licenses/lodash.defaults-4.2.0.txt +48 -0
  110. package/dist/licenses/lodash.difference-4.5.0.txt +48 -0
  111. package/dist/licenses/lodash.escaperegexp-4.1.2.txt +48 -0
  112. package/dist/licenses/lodash.flatten-4.4.0.txt +48 -0
  113. package/dist/licenses/lodash.groupby-4.6.0.txt +48 -0
  114. package/dist/licenses/lodash.isboolean-3.0.3.txt +23 -0
  115. package/dist/licenses/lodash.isequal-4.5.0.txt +48 -0
  116. package/dist/licenses/lodash.isfunction-3.0.9.txt +48 -0
  117. package/dist/licenses/lodash.isnil-4.0.0.txt +23 -0
  118. package/dist/licenses/lodash.isplainobject-4.0.6.txt +48 -0
  119. package/dist/licenses/lodash.isundefined-3.0.1.txt +23 -0
  120. package/dist/licenses/lodash.union-4.6.0.txt +48 -0
  121. package/dist/licenses/lodash.uniq-4.5.0.txt +48 -0
  122. package/dist/licenses/minimatch-3.1.5.txt +16 -0
  123. package/dist/licenses/minimatch-5.1.9.txt +16 -0
  124. package/dist/licenses/minimist-1.2.8.txt +19 -0
  125. package/dist/licenses/mkdirp-0.5.6.txt +22 -0
  126. package/dist/licenses/node-sql-parser-5.4.0.txt +202 -0
  127. package/dist/licenses/normalize-path-3.0.0.txt +22 -0
  128. package/dist/licenses/once-1.4.0.txt +16 -0
  129. package/dist/licenses/pako-1.0.11.txt +22 -0
  130. package/dist/licenses/pako-2.2.0.txt +22 -0
  131. package/dist/licenses/path-is-absolute-1.0.1.txt +22 -0
  132. package/dist/licenses/pdf-lib-1.17.1.txt +22 -0
  133. package/dist/licenses/process-nextick-args-2.0.1.txt +20 -0
  134. package/dist/licenses/readable-stream-2.3.8.txt +48 -0
  135. package/dist/licenses/readable-stream-3.6.2.txt +48 -0
  136. package/dist/licenses/readdir-glob-1.1.3.txt +202 -0
  137. package/dist/licenses/rimraf-2.7.1.txt +16 -0
  138. package/dist/licenses/safe-buffer-5.1.2.txt +22 -0
  139. package/dist/licenses/safe-buffer-5.2.1.txt +22 -0
  140. package/dist/licenses/saxes-5.0.1.txt +397 -0
  141. package/dist/licenses/setimmediate-1.0.5.txt +21 -0
  142. package/dist/licenses/string_decoder-1.1.1.txt +49 -0
  143. package/dist/licenses/string_decoder-1.3.0.txt +49 -0
  144. package/dist/licenses/tar-stream-2.2.0.txt +22 -0
  145. package/dist/licenses/tmp-0.2.7.txt +22 -0
  146. package/dist/licenses/traverse-0.3.9.txt +25 -0
  147. package/dist/licenses/tslib-1.14.1.txt +13 -0
  148. package/dist/licenses/unzipper-0.10.14.txt +26 -0
  149. package/dist/licenses/util-deprecate-1.0.2.txt +25 -0
  150. package/dist/licenses/uuid-11.1.1.txt +10 -0
  151. package/dist/licenses/wrappy-1.0.2.txt +16 -0
  152. package/dist/licenses/xmlchars-2.2.0.txt +19 -0
  153. package/dist/licenses/zip-stream-4.1.1.txt +23 -0
  154. package/dist/matrix-CGRGkn5s.js +112 -0
  155. package/dist/matrix-gEO7ZM_u.cjs +1 -0
  156. package/dist/media-B7vnpD8k.cjs +1 -0
  157. package/dist/media-Y90dHK9z.js +70 -0
  158. package/dist/param-validation-C3HlcLLO.cjs +1 -0
  159. package/dist/param-validation-Do7Eg8Zv.js +181 -0
  160. package/dist/pdf-BwNyeGpt.js +36352 -0
  161. package/dist/pdf-CvvrjPQg.cjs +103 -0
  162. package/dist/pdf.cjs +1 -101
  163. package/dist/pdf.d.cts +18 -3
  164. package/dist/pdf.d.ts +18 -3
  165. package/dist/pdf.js +9 -36579
  166. package/dist/plugin-Ca_XZG3l.js +22 -0
  167. package/dist/{plugin-DzS6pxTA.cjs → plugin-DHO7X8z2.cjs} +1 -1
  168. package/dist/prepared-CFy9B75C.cjs +1 -0
  169. package/dist/prepared-ajM-H-9B.js +69 -0
  170. package/dist/progress-B0ctFpKf.cjs +1 -0
  171. package/dist/progress-D-OTpEav.js +52 -0
  172. package/dist/{record-bindings-D-5jQlTj.js → record-bindings-Do_b3h4V.js} +1 -1
  173. package/dist/{region-binding-workflow-CcUq8W2Q.js → region-binding-workflow-BMhK_TjP.js} +1 -1
  174. package/dist/{region-binding-workflow-BzfbxRiR.cjs → region-binding-workflow-DIYJdCUr.cjs} +1 -1
  175. package/dist/{report-params-B44imUd4.js → report-params-B1RzkhJj.js} +1 -1
  176. package/dist/{report-params-SJfhKgaX.cjs → report-params-WDGrA4oP.cjs} +1 -1
  177. package/dist/sbom.cdx.json +3982 -0
  178. package/dist/server/node.d.cts +66 -12
  179. package/dist/server/node.d.ts +66 -12
  180. package/dist/server-node.cjs +1 -1
  181. package/dist/server-node.js +405 -381
  182. package/dist/server.cjs +1 -1
  183. package/dist/server.d.cts +878 -15
  184. package/dist/server.d.ts +878 -15
  185. package/dist/server.js +1034 -534
  186. package/dist/sha256-ArEYjaTI.cjs +1 -0
  187. package/dist/sha256-DPEuJ3nh.js +155 -0
  188. package/dist/style.css +1 -1
  189. package/dist/template-bindings-C2SpvsMU.js +58 -0
  190. package/dist/template-bindings-CEtWyiLX.cjs +1 -0
  191. package/dist/template-catalog-FJE_c9Qe.cjs +1 -0
  192. package/dist/template-catalog-j2B1MJlL.js +414 -0
  193. package/dist/template-fragments-BGbQLGlV.js +187 -0
  194. package/dist/template-fragments-DcKeiylI.cjs +1 -0
  195. package/dist/template-outline-BwRV_eRo.cjs +1 -0
  196. package/dist/template-outline-cnWfT_LK.js +88 -0
  197. package/dist/{template-registry-BjE1VS6g.js → template-registry-BtaKPELV.js} +364 -201
  198. package/dist/template-registry-Co1zPq5e.cjs +1 -0
  199. package/dist/textwrap-CWHyzkBH.cjs +4 -0
  200. package/dist/textwrap-DE1kgcJB.js +110 -0
  201. package/dist/{tree-CqcQ99NM.js → tree-CjVZLRw7.js} +1 -1
  202. package/dist/{useLocalDraft-C07SYRnC.js → useLocalDraft-BnhcxXk_.js} +1 -1
  203. package/dist/{useLocalDraft-Yiw1wFgI.cjs → useLocalDraft-CioIfDb6.cjs} +1 -1
  204. package/dist/vue/async.d.cts +190 -15
  205. package/dist/vue/async.d.ts +190 -15
  206. package/dist/vue/index.d.cts +274 -24
  207. package/dist/vue/index.d.ts +274 -24
  208. package/dist/vue-async.cjs +1 -1
  209. package/dist/vue-async.js +5 -5
  210. package/dist/vue.cjs +1 -1
  211. package/dist/vue.js +90 -81
  212. package/dist/{workbook-session-DNa2RHNG.cjs → workbook-session-Bjv1YCRK.cjs} +18 -18
  213. package/dist/{workbook-session-BPb3TMnT.js → workbook-session-BvToI-Fd.js} +5440 -5288
  214. package/dist/worker.cjs +1 -1
  215. package/dist/worker.d.cts +66 -12
  216. package/dist/worker.d.ts +66 -12
  217. package/dist/worker.js +61 -56
  218. package/dist/xlsx-node.cjs +34 -34
  219. package/dist/xlsx-node.js +878 -870
  220. package/dist/xlsx.cjs +3 -4
  221. package/dist/xlsx.d.cts +22 -10
  222. package/dist/xlsx.d.ts +22 -10
  223. package/dist/xlsx.js +261 -253
  224. package/package.json +2 -2
  225. package/dist/ExcelBindingWizard-CeAf4QSE.js +0 -1465
  226. package/dist/ExcelBindingWizard-y0mT-AHR.cjs +0 -1
  227. package/dist/ParamEditor-BLaE5q5W.js +0 -522
  228. package/dist/ParamEditor-MBBC7lUE.cjs +0 -1
  229. package/dist/ReportBatchPanel-Fp1ePFag.cjs +0 -1
  230. package/dist/ReportPreview-BN6fk7Wz.cjs +0 -6
  231. package/dist/ReportPreview-D2Jkyh1U.js +0 -4243
  232. package/dist/ReportTemplateLibrary-5fk5CQBO.cjs +0 -1
  233. package/dist/RuleEditor-ChRzNQuF.cjs +0 -1
  234. package/dist/RuleEditor-DzAmW5YH.js +0 -2024
  235. package/dist/TemplateReviewPanel-BKofGrV9.js +0 -222
  236. package/dist/TemplateReviewPanel-DwtOcLue.cjs +0 -1
  237. package/dist/assets-C2U-e-Sz.cjs +0 -4
  238. package/dist/assets-Q0wUwNrV.js +0 -217
  239. package/dist/batch-Bt3Fd27Z.cjs +0 -1
  240. package/dist/batch-mRqhhhjt.js +0 -364
  241. package/dist/capabilities-CK_7hizc.js +0 -63
  242. package/dist/capabilities-CsZ-pNHR.cjs +0 -1
  243. package/dist/config-Bb7RiIO5.cjs +0 -1
  244. package/dist/config-XVwG87IA.js +0 -529
  245. package/dist/matrix-DVyWiYsd.cjs +0 -1
  246. package/dist/matrix-yZsGnldA.js +0 -227
  247. package/dist/page-window-index-CIuT4BAv.js +0 -43
  248. package/dist/page-window-index-DEjnM6IB.cjs +0 -1
  249. package/dist/param-validation-BlHHXs6u.js +0 -153
  250. package/dist/param-validation-DCK039V1.cjs +0 -1
  251. package/dist/plugin-D4wizDXB.js +0 -22
  252. package/dist/progress-7OSZbFok.js +0 -39
  253. package/dist/progress-BnLiS5eH.cjs +0 -1
  254. package/dist/task-events-DQ276fn2.cjs +0 -1
  255. package/dist/task-events-Dpsvf_t2.js +0 -47
  256. package/dist/template-registry-D3SjENi6.cjs +0 -1
  257. package/dist/template-review-DGwWOoCv.cjs +0 -2
  258. package/dist/template-review-PgEe_Wr9.js +0 -1742
  259. package/dist/validate-BJ5HIWY8.cjs +0 -1
  260. package/dist/validate-DbgEM1Hh.js +0 -163
@@ -1,9 +1,9 @@
1
- import { parentPort as H, Worker as K } from "node:worker_threads";
1
+ import { parentPort as _, Worker as H } from "node:worker_threads";
2
2
  import { randomUUID as P, createHash as W } from "node:crypto";
3
3
  import { promises as h } from "node:fs";
4
- import S from "node:path";
5
- function Z(e, t, n) {
6
- if (!n?.aborted)
4
+ import v from "node:path";
5
+ function Z(e, t, r) {
6
+ if (!r?.aborted)
7
7
  try {
8
8
  const o = e?.({ ...t });
9
9
  o && typeof o.then == "function" && Promise.resolve(o).catch(() => {
@@ -11,43 +11,58 @@ function Z(e, t, n) {
11
11
  } catch {
12
12
  }
13
13
  }
14
- function Q(e, t, n) {
15
- e.editable !== void 0 && typeof e.editable != "boolean" && n.push({ path: `${t}.editable`, message: "编辑控制应为布尔值" }), e.valueType !== void 0 && !["text", "number", "boolean"].includes(e.valueType) && n.push({ path: `${t}.valueType`, message: "编辑类型应为 text、number 或 boolean" });
14
+ function Q(e) {
15
+ if (!e || typeof e != "object" || Array.isArray(e)) return !1;
16
+ const t = e, r = (o) => typeof o == "string" && o.trim().length > 0 && o.length <= 256;
17
+ return !r(t.datasetId) || !r(t.field) || t.tableId !== void 0 && !r(t.tableId) || t.reportScope !== void 0 && (typeof t.reportScope != "string" || !t.reportScope.trim() || t.reportScope.length > 4096) ? !1 : t.rowKey === void 0 ? !0 : typeof t.rowKey == "string" ? t.rowKey.trim().length > 0 && t.rowKey.length <= 1024 : typeof t.rowKey == "number" && Number.isFinite(t.rowKey);
16
18
  }
17
- function V(e, t, n) {
18
- Q(e, t, n), e.indentMm !== void 0 && (typeof e.indentMm != "number" || !Number.isFinite(e.indentMm) || e.indentMm < 0) && n.push({ path: `${t}.indentMm`, message: "单元格缩进应为有限非负数" }), e.derived !== void 0 && typeof e.derived != "boolean" && n.push({ path: `${t}.derived`, message: "派生结果标记应为布尔值" }), U(e.source, `${t}.source`, n, !0), e.formula !== void 0 && typeof e.formula != "string" && n.push({ path: `${t}.formula`, message: "单元格公式应为字符串" });
19
+ function V(e) {
20
+ return e === "missing-source" || e === "not-applicable" || e === "not-calculable";
19
21
  }
20
- function U(e, t, n, o = !1) {
22
+ function G(e) {
23
+ return e.target !== void 0 && !Q(e.target) ? !1 : e.valueState === void 0 || V(e.valueState) && e.target !== void 0;
24
+ }
25
+ function X(e, t, r) {
26
+ e !== void 0 && (typeof e != "string" || !e.trim() || e.length > 4096) && r.push({ path: t, message: "来源范围应为不超过 4096 字符的非空字符串" });
27
+ }
28
+ function Y(e, t, r) {
29
+ e.editable !== void 0 && typeof e.editable != "boolean" && r.push({ path: `${t}.editable`, message: "编辑控制应为布尔值" }), e.valueType !== void 0 && !["text", "number", "boolean"].includes(e.valueType) && r.push({ path: `${t}.valueType`, message: "编辑类型应为 text、number 或 boolean" });
30
+ }
31
+ function ee(e, t, r) {
32
+ Y(e, t, r), e.indentMm !== void 0 && (typeof e.indentMm != "number" || !Number.isFinite(e.indentMm) || e.indentMm < 0) && r.push({ path: `${t}.indentMm`, message: "单元格缩进应为有限非负数" }), e.derived !== void 0 && typeof e.derived != "boolean" && r.push({ path: `${t}.derived`, message: "派生结果标记应为布尔值" }), F(e.source, `${t}.source`, r, !0), e.formula !== void 0 && typeof e.formula != "string" && r.push({ path: `${t}.formula`, message: "单元格公式应为字符串" });
33
+ }
34
+ function F(e, t, r, o = !1) {
21
35
  if (e === void 0) return;
22
36
  if (!e || typeof e != "object" || Array.isArray(e)) {
23
- n.push({ path: t, message: "业务来源应为对象" });
37
+ r.push({ path: t, message: "业务来源应为对象" });
24
38
  return;
25
39
  }
26
- const r = e;
40
+ const n = e;
41
+ X(n.sourceScope, `${t}.sourceScope`, r);
27
42
  for (const s of ["datasetId", ...o ? ["field"] : []])
28
- (typeof r[s] != "string" || !r[s].trim()) && n.push({ path: `${t}.${s}`, message: "业务标识应为非空字符串" });
43
+ (typeof n[s] != "string" || !n[s].trim()) && r.push({ path: `${t}.${s}`, message: "业务标识应为非空字符串" });
29
44
  for (const s of ["rowKey", "revision"]) {
30
- const i = r[s];
31
- i === void 0 && !(o && s === "rowKey") || typeof i != "string" && !(typeof i == "number" && Number.isFinite(i)) && n.push({ path: `${t}.${s}`, message: "业务键及修订号应为字符串或有限数字" });
45
+ const i = n[s];
46
+ i === void 0 && !(o && s === "rowKey") || typeof i != "string" && !(typeof i == "number" && Number.isFinite(i)) && r.push({ path: `${t}.${s}`, message: "业务键及修订号应为字符串或有限数字" });
32
47
  }
33
- r.sourceToken !== void 0 && typeof r.sourceToken != "string" && n.push({ path: `${t}.sourceToken`, message: "来源令牌应为字符串" });
48
+ n.sourceToken !== void 0 && typeof n.sourceToken != "string" && r.push({ path: `${t}.sourceToken`, message: "来源令牌应为字符串" });
34
49
  }
35
- function G(e) {
50
+ function te(e) {
36
51
  const t = [];
37
52
  return e.value !== void 0 && typeof e.value != "string" && t.push({ path: "value", message: "Symbol value must be a string." }), e.symbology !== void 0 && !["code128", "code39", "ean13", "ean8"].includes(e.symbology) && t.push({ path: "symbology", message: "Unsupported barcode symbology." }), e.errorCorrection !== void 0 && !["L", "M", "Q", "H"].includes(e.errorCorrection) && t.push({ path: "errorCorrection", message: "Unsupported QR error correction." }), e.showText !== void 0 && typeof e.showText != "boolean" && t.push({ path: "showText", message: "showText must be a boolean." }), t;
38
53
  }
39
- function X(e, t) {
40
- const n = [];
41
- return t !== "barcode" && t !== "qrcode" && n.push({ path: "", message: "code is only supported by barcode and qrcode components." }), t === "qrcode" && e.symbology !== void 0 && n.push({ path: "symbology", message: "QR components do not use a linear symbology." }), t === "qrcode" && e.showText === !0 && n.push({ path: "showText", message: "Use a separate text component below a QR code." }), t === "barcode" && e.errorCorrection !== void 0 && n.push({ path: "errorCorrection", message: "Linear barcodes do not use QR error correction." }), n;
54
+ function re(e, t) {
55
+ const r = [];
56
+ return t !== "barcode" && t !== "qrcode" && r.push({ path: "", message: "code is only supported by barcode and qrcode components." }), t === "qrcode" && e.symbology !== void 0 && r.push({ path: "symbology", message: "QR components do not use a linear symbology." }), t === "qrcode" && e.showText === !0 && r.push({ path: "showText", message: "Use a separate text component below a QR code." }), t === "barcode" && e.errorCorrection !== void 0 && r.push({ path: "errorCorrection", message: "Linear barcodes do not use QR error correction." }), r;
42
57
  }
43
- function Y(e, t) {
58
+ function ne(e, t) {
44
59
  if (typeof e != "object" || e === null || Array.isArray(e)) return [{ path: "", message: "code must be an object." }];
45
- const n = e, o = [...G(n), ...X(n, t)];
46
- for (const i of Object.keys(n)) ["value", "symbology", "errorCorrection", "quietZoneModules", "showText"].includes(i) || o.push({ path: i, message: "Unknown symbol option." });
47
- const r = n.symbology === "ean13" || n.symbology === "ean8", s = t === "qrcode" ? 4 : r ? 11 : 10;
48
- return n.quietZoneModules !== void 0 && (!Number.isSafeInteger(n.quietZoneModules) || Number(n.quietZoneModules) < s || Number(n.quietZoneModules) > 64) && o.push({ path: "quietZoneModules", message: `Quiet zone must contain ${s}–64 whole modules.` }), o;
60
+ const r = e, o = [...te(r), ...re(r, t)];
61
+ for (const i of Object.keys(r)) ["value", "symbology", "errorCorrection", "quietZoneModules", "showText"].includes(i) || o.push({ path: i, message: "Unknown symbol option." });
62
+ const n = r.symbology === "ean13" || r.symbology === "ean8", s = t === "qrcode" ? 4 : n ? 11 : 10;
63
+ return r.quietZoneModules !== void 0 && (!Number.isSafeInteger(r.quietZoneModules) || Number(r.quietZoneModules) < s || Number(r.quietZoneModules) > 64) && o.push({ path: "quietZoneModules", message: `Quiet zone must contain ${s}–64 whole modules.` }), o;
49
64
  }
50
- const ee = /* @__PURE__ */ new Set([
65
+ const oe = /* @__PURE__ */ new Set([
51
66
  "text",
52
67
  "image",
53
68
  "barcode",
@@ -60,120 +75,221 @@ const ee = /* @__PURE__ */ new Set([
60
75
  function A(e) {
61
76
  return typeof e == "object" && e !== null && !Array.isArray(e);
62
77
  }
63
- function te(e, t, n, o) {
64
- const r = e[t];
65
- (typeof r != "number" || !Number.isFinite(r)) && o.push({ path: `${n}.${t}`, message: `应为有限数字,实际 ${JSON.stringify(r)}` });
78
+ function se(e, t, r, o) {
79
+ const n = e[t];
80
+ (typeof n != "number" || !Number.isFinite(n)) && o.push({ path: `${r}.${t}`, message: `应为有限数字,实际 ${JSON.stringify(n)}` });
66
81
  }
67
- function ne(e, t, n) {
82
+ function ie(e, t, r) {
68
83
  if (e !== void 0) {
69
84
  const o = `${t}.table`;
70
- if (!A(e)) n.push({ path: o, message: "逻辑表来源应为对象" });
85
+ if (!A(e)) r.push({ path: o, message: "逻辑表来源应为对象" });
71
86
  else {
72
- U(e.source, `${o}.source`, n), (typeof e.id != "string" || !e.id.trim()) && n.push({ path: `${o}.id`, message: "逻辑表 ID 应为非空字符串" });
73
- const r = e.role;
74
- ["header", "body", "group-header", "subtotal", "grand-total"].includes(r) || n.push({ path: `${o}.role`, message: "未知逻辑表行角色" });
87
+ F(e.source, `${o}.source`, r), (typeof e.id != "string" || !e.id.trim()) && r.push({ path: `${o}.id`, message: "逻辑表 ID 应为非空字符串" });
88
+ const n = e.role;
89
+ ["header", "body", "group-header", "subtotal", "grand-total"].includes(n) || r.push({ path: `${o}.role`, message: "未知逻辑表行角色" });
75
90
  const s = e.rowIndex;
76
- (typeof s != "number" || !Number.isInteger(s) || (r === "header" ? s !== -1 : s < 0)) && n.push({ path: `${o}.rowIndex`, message: "表头索引应为 -1,内容行索引应为非负整数" }), (!Array.isArray(e.columnKeys) || e.columnKeys.some((i) => typeof i != "string")) && n.push({ path: `${o}.columnKeys`, message: "逻辑列字段应为字符串数组" }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && n.push({ path: `${o}.layout`, message: "布局应为 page 或 wide" }), e.title !== void 0 && typeof e.title != "string" && n.push({ path: `${o}.title`, message: "逻辑表名称应为字符串" });
91
+ (typeof s != "number" || !Number.isInteger(s) || (n === "header" ? s !== -1 : s < 0)) && r.push({ path: `${o}.rowIndex`, message: "表头索引应为 -1,内容行索引应为非负整数" }), (!Array.isArray(e.columnKeys) || e.columnKeys.some((i) => typeof i != "string")) && r.push({ path: `${o}.columnKeys`, message: "逻辑列字段应为字符串数组" }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && r.push({ path: `${o}.layout`, message: "布局应为 page 或 wide" }), e.title !== void 0 && typeof e.title != "string" && r.push({ path: `${o}.title`, message: "逻辑表名称应为字符串" });
77
92
  }
78
93
  }
79
94
  }
80
- function re(e, t, n, o) {
95
+ function ae(e, t, r, o) {
81
96
  if (e !== void 0)
82
97
  if (!A(e) || !Array.isArray(e.cells))
83
- n.push({ path: `${t}.grid.cells`, message: "grid.cells 应为二维数组" });
98
+ r.push({ path: `${t}.grid.cells`, message: "grid.cells 应为二维数组" });
84
99
  else {
85
- const r = e.paddingMm;
86
- r !== void 0 && (typeof r != "number" || !Number.isFinite(r) || r < 0) && n.push({ path: `${t}.grid.paddingMm`, message: "单元格内距应为有限非负数" }), e.cells.forEach((s, i) => {
100
+ const n = e.paddingMm;
101
+ n !== void 0 && (typeof n != "number" || !Number.isFinite(n) || n < 0) && r.push({ path: `${t}.grid.paddingMm`, message: "单元格内距应为有限非负数" }), e.cells.forEach((s, i) => {
87
102
  if (!Array.isArray(s)) {
88
- n.push({ path: `${t}.grid.cells.${i}`, message: "行应为数组" });
103
+ r.push({ path: `${t}.grid.cells.${i}`, message: "行应为数组" });
89
104
  return;
90
105
  }
91
- s.forEach((d, y) => {
106
+ s.forEach((d, m) => {
92
107
  if (d == null) return;
93
- const u = `${t}.grid.cells.${i}.${y}`;
108
+ const u = `${t}.grid.cells.${i}.${m}`;
94
109
  if (!A(d)) {
95
- n.push({ path: u, message: "网格单元格应为对象或 null" });
110
+ r.push({ path: u, message: "网格单元格应为对象或 null" });
96
111
  return;
97
112
  }
98
- V(d, u, n), Array.isArray(d.children) && d.children.forEach((b, k) => {
99
- C(b, `${t}.grid.cells.${i}.${y}.children.${k}`, n, o);
113
+ ee(d, u, r), Array.isArray(d.children) && d.children.forEach((b, S) => {
114
+ U(b, `${t}.grid.cells.${i}.${m}.children.${S}`, r, o);
100
115
  });
101
116
  });
102
117
  });
103
118
  }
104
119
  }
105
- function oe(e, t, n) {
106
- e !== void 0 && (Array.isArray(e) ? e.forEach((o, r) => {
107
- (!A(o) || !Array.isArray(o.segments)) && n.push({ path: `${t}.richParagraphs.${r}`, message: "段落缺少 segments 数组" });
108
- }) : n.push({ path: `${t}.richParagraphs`, message: "richParagraphs 应为数组" }));
120
+ function ce(e, t, r) {
121
+ e !== void 0 && (Array.isArray(e) ? e.forEach((o, n) => {
122
+ (!A(o) || !Array.isArray(o.segments)) && r.push({ path: `${t}.richParagraphs.${n}`, message: "段落缺少 segments 数组" });
123
+ }) : r.push({ path: `${t}.richParagraphs`, message: "richParagraphs 应为数组" }));
109
124
  }
110
- function C(e, t, n, o = []) {
125
+ function U(e, t, r, o = []) {
111
126
  if (!A(e)) {
112
- n.push({ path: t, message: "组件应为对象" });
127
+ r.push({ path: t, message: "组件应为对象" });
113
128
  return;
114
129
  }
115
- const r = e.kind;
116
- typeof r != "string" ? n.push({ path: `${t}.kind`, message: "组件缺少 kind 字符串" }) : ee.has(r) || o.push({
130
+ const n = e.kind;
131
+ typeof n != "string" ? r.push({ path: `${t}.kind`, message: "组件缺少 kind 字符串" }) : oe.has(n) || o.push({
117
132
  path: `${t}.kind`,
118
- message: `未知组件类型 ${JSON.stringify(r)},将以兜底方式渲染`
133
+ message: `未知组件类型 ${JSON.stringify(n)},将以兜底方式渲染`
119
134
  });
120
135
  for (const s of ["leftMm", "topMm", "widthMm", "heightMm"])
121
- te(e, s, t, n);
122
- typeof e.leftMm == "number" && e.leftMm < -100 && n.push({ path: `${t}.leftMm`, message: "几何数值异常(leftMm<-100)" });
136
+ se(e, s, t, r);
137
+ typeof e.leftMm == "number" && e.leftMm < -100 && r.push({ path: `${t}.leftMm`, message: "几何数值异常(leftMm<-100)" });
123
138
  for (const s of ["widthMm", "heightMm"])
124
- typeof e[s] == "number" && e[s] < 0 && n.push({ path: `${t}.${s}`, message: "组件尺寸不能为负数" });
125
- ne(e.table, t, n), se(e.code, r, t, n), e.pageAnchor !== void 0 && !["header", "footer"].includes(e.pageAnchor) && n.push({ path: `${t}.pageAnchor`, message: "页面锚点应为 header 或 footer" }), e.lineDirection !== void 0 && !["down", "up"].includes(e.lineDirection) && n.push({ path: `${t}.lineDirection`, message: "线段方向应为 down 或 up" }), re(e.grid, t, n, o), oe(e.richParagraphs, t, n);
139
+ typeof e[s] == "number" && e[s] < 0 && r.push({ path: `${t}.${s}`, message: "组件尺寸不能为负数" });
140
+ ie(e.table, t, r), fe(e.code, n, t, r), e.pageAnchor !== void 0 && !["header", "footer"].includes(e.pageAnchor) && r.push({ path: `${t}.pageAnchor`, message: "页面锚点应为 header 或 footer" }), e.lineDirection !== void 0 && !["down", "up"].includes(e.lineDirection) && r.push({ path: `${t}.lineDirection`, message: "线段方向应为 down 或 up" }), ae(e.grid, t, r, o), ce(e.richParagraphs, t, r);
126
141
  }
127
- function se(e, t, n, o) {
142
+ function fe(e, t, r, o) {
128
143
  if (e !== void 0)
129
- for (const r of Y(e, t)) o.push({ path: `${n}.code${r.path ? `.${r.path}` : ""}`, message: r.message });
144
+ for (const n of ne(e, t)) o.push({ path: `${r}.code${n.path ? `.${n.path}` : ""}`, message: n.message });
130
145
  }
131
- function F(e, t, n) {
146
+ function C(e, t, r) {
132
147
  if (!A(e)) return;
133
- e.binding !== void 0 && n.push({ path: `${t}.binding`, message: "渲染计划不允许未解析字段绑定" });
148
+ e.binding !== void 0 && r.push({ path: `${t}.binding`, message: "渲染计划不允许未解析字段绑定" });
134
149
  const o = e.grid;
135
- !A(o) || !Array.isArray(o.cells) || o.cells.forEach((r, s) => {
136
- Array.isArray(r) && r.forEach((i, d) => {
137
- !A(i) || !Array.isArray(i.children) || i.children.forEach((y, u) => F(y, `${t}.grid.cells.${s}.${d}.children.${u}`, n));
150
+ !A(o) || !Array.isArray(o.cells) || o.cells.forEach((n, s) => {
151
+ Array.isArray(n) && n.forEach((i, d) => {
152
+ !A(i) || !Array.isArray(i.children) || i.children.forEach((m, u) => C(m, `${t}.grid.cells.${s}.${d}.children.${u}`, r));
138
153
  });
139
154
  });
140
155
  }
141
- function ie(e, t, n, o = []) {
156
+ function ue(e, t, r, o = []) {
142
157
  if (!A(e)) {
143
- n.push({ path: t, message: "页应为对象" });
158
+ r.push({ path: t, message: "页应为对象" });
144
159
  return;
145
160
  }
146
- const r = e.pageWidthMm, s = e.pageHeightMm;
147
- (typeof r != "number" || !Number.isFinite(r) || r <= 0) && n.push({ path: `${t}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(r)}` }), (typeof s != "number" || !(s > 0 && s < 5e3)) && n.push({ path: `${t}.pageHeightMm`, message: `页高非法: ${JSON.stringify(s)}` }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && n.push({ path: `${t}.layout`, message: "布局应为 page 或 wide" });
161
+ const n = e.pageWidthMm, s = e.pageHeightMm;
162
+ (typeof n != "number" || !Number.isFinite(n) || n <= 0) && r.push({ path: `${t}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(n)}` }), (typeof s != "number" || !(s > 0 && s < 5e3)) && r.push({ path: `${t}.pageHeightMm`, message: `页高非法: ${JSON.stringify(s)}` }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && r.push({ path: `${t}.layout`, message: "布局应为 page 或 wide" });
148
163
  const i = e.components;
149
- Array.isArray(i) ? Array.isArray(i) && i.forEach((d, y) => {
150
- C(d, `${t}.components.${y}`, n, o), F(d, `${t}.components.${y}`, n);
151
- }) : n.push({ path: `${t}.components`, message: "components 应为数组" });
164
+ Array.isArray(i) ? Array.isArray(i) && i.forEach((d, m) => {
165
+ U(d, `${t}.components.${m}`, r, o), C(d, `${t}.components.${m}`, r);
166
+ }) : r.push({ path: `${t}.components`, message: "components 应为数组" });
152
167
  }
153
- function ae(e) {
154
- const t = [], n = [], o = A(e) ? e.pages : void 0;
168
+ function pe(e) {
169
+ const t = [], r = [], o = A(e) ? e.pages : void 0;
155
170
  if (A(e) && e.requiresRecalculation !== void 0 && typeof e.requiresRecalculation != "boolean" && t.push({ path: "$.requiresRecalculation", message: "重算能力要求应为布尔值" }), !Array.isArray(o))
156
171
  t.push({
157
172
  path: "$.pages",
158
173
  message: e == null ? "渲染计划为空" : "渲染计划缺少 pages 数组"
159
174
  });
160
175
  else {
161
- o.forEach((s, i) => ie(s, `$.pages.${i}`, t, n)), o.length > 2e3 && n.push({
176
+ o.forEach((s, i) => ue(s, `$.pages.${i}`, t, r)), o.length > 2e3 && r.push({
162
177
  path: "$.pages",
163
178
  message: `页数异常大(${o.length} 页),渲染与打印耗时可能显著增加`
164
179
  });
165
- const r = o.reduce(
180
+ const n = o.reduce(
166
181
  (s, i) => s + (A(i) && Array.isArray(i.components) ? i.components.length : 0),
167
182
  0
168
183
  );
169
- r > 5e4 && n.push({
184
+ n > 5e4 && r.push({
170
185
  path: "$.pages",
171
- message: `组件总数异常大(${r} 个),可能触发浏览器性能限制`
186
+ message: `组件总数异常大(${n} 个),可能触发浏览器性能限制`
172
187
  });
173
188
  }
174
- return { ok: t.length === 0, errors: t, warnings: n };
189
+ return { ok: t.length === 0, errors: t, warnings: r };
190
+ }
191
+ const de = new Uint32Array([
192
+ 1116352408,
193
+ 1899447441,
194
+ 3049323471,
195
+ 3921009573,
196
+ 961987163,
197
+ 1508970993,
198
+ 2453635748,
199
+ 2870763221,
200
+ 3624381080,
201
+ 310598401,
202
+ 607225278,
203
+ 1426881987,
204
+ 1925078388,
205
+ 2162078206,
206
+ 2614888103,
207
+ 3248222580,
208
+ 3835390401,
209
+ 4022224774,
210
+ 264347078,
211
+ 604807628,
212
+ 770255983,
213
+ 1249150122,
214
+ 1555081692,
215
+ 1996064986,
216
+ 2554220882,
217
+ 2821834349,
218
+ 2952996808,
219
+ 3210313671,
220
+ 3336571891,
221
+ 3584528711,
222
+ 113926993,
223
+ 338241895,
224
+ 666307205,
225
+ 773529912,
226
+ 1294757372,
227
+ 1396182291,
228
+ 1695183700,
229
+ 1986661051,
230
+ 2177026350,
231
+ 2456956037,
232
+ 2730485921,
233
+ 2820302411,
234
+ 3259730800,
235
+ 3345764771,
236
+ 3516065817,
237
+ 3600352804,
238
+ 4094571909,
239
+ 275423344,
240
+ 430227734,
241
+ 506948616,
242
+ 659060556,
243
+ 883997877,
244
+ 958139571,
245
+ 1322822218,
246
+ 1537002063,
247
+ 1747873779,
248
+ 1955562222,
249
+ 2024104815,
250
+ 2227730452,
251
+ 2361852424,
252
+ 2428436474,
253
+ 2756734187,
254
+ 3204031479,
255
+ 3329325298
256
+ ]), $ = (e, t) => e >>> t | e << 32 - t;
257
+ function ye(e, t, r) {
258
+ const o = new DataView(e.buffer, e.byteOffset + t, 64);
259
+ for (let n = 0; n < 16; n++) r[n] = o.getUint32(n * 4);
260
+ for (let n = 16; n < 64; n++) {
261
+ const s = r[n - 15], i = r[n - 2], d = $(s, 7) ^ $(s, 18) ^ s >>> 3, m = $(i, 17) ^ $(i, 19) ^ i >>> 10;
262
+ r[n] = r[n - 16] + d + r[n - 7] + m;
263
+ }
264
+ }
265
+ function me(e, t) {
266
+ let r = e[0], o = e[1], n = e[2], s = e[3], i = e[4], d = e[5], m = e[6], u = e[7];
267
+ for (let b = 0; b < 64; b++) {
268
+ const S = $(i, 6) ^ $(i, 11) ^ $(i, 25), p = i & d ^ ~i & m, f = u + S + p + de[b] + t[b] >>> 0, c = $(r, 2) ^ $(r, 13) ^ $(r, 22), y = r & o ^ r & n ^ o & n, g = c + y >>> 0;
269
+ u = m, m = d, d = i, i = s + f >>> 0, s = n, n = o, o = r, r = f + g >>> 0;
270
+ }
271
+ e[0] = e[0] + r, e[1] = e[1] + o, e[2] = e[2] + n, e[3] = e[3] + s, e[4] = e[4] + i, e[5] = e[5] + d, e[6] = e[6] + m, e[7] = e[7] + u;
175
272
  }
176
- const M = "mach-report-worker/1";
273
+ function le(e) {
274
+ const t = new Uint8Array(Math.ceil((e.byteLength + 9) / 64) * 64);
275
+ t.set(e), t[e.byteLength] = 128;
276
+ const r = new DataView(t.buffer);
277
+ return r.setUint32(t.length - 8, Math.floor(e.byteLength / 536870912)), r.setUint32(t.length - 4, e.byteLength * 8 >>> 0), t;
278
+ }
279
+ const he = () => new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), ge = (e) => Array.from(e, (t) => t.toString(16).padStart(8, "0")).join("");
280
+ async function we(e) {
281
+ const t = le(e), r = he(), o = new Uint32Array(64);
282
+ for (let n = 0; n < t.length; n += 64)
283
+ n > 0 && n % 262144 === 0 && await new Promise((s) => setTimeout(s, 0)), ye(t, n, o), me(r, o);
284
+ return ge(r);
285
+ }
286
+ function be(e) {
287
+ if (e === void 0) return !0;
288
+ if (!Array.isArray(e)) return !1;
289
+ const t = /* @__PURE__ */ new Set();
290
+ return e.every((r) => !r || typeof r != "object" || Array.isArray(r) || typeof r.reportId != "string" || !r.reportId.trim() || !Number.isSafeInteger(r.reportIndex) || r.reportIndex < 0 || t.has(r.reportIndex) || typeof r.reportScope != "string" || !r.reportScope.trim() || r.reportScope.length > 4096 || r.revision !== void 0 && typeof r.revision != "string" || r.sourceToken !== void 0 && typeof r.sourceToken != "string" ? !1 : (t.add(r.reportIndex), !0));
291
+ }
292
+ const I = "mach-report-worker/1";
177
293
  class B extends Error {
178
294
  constructor(t) {
179
295
  super(t.message), this.name = t.name, this.code = t.code, this.path = t.path, this.issues = t.issues, this.diagnostics = t.diagnostics;
@@ -182,38 +298,41 @@ class B extends Error {
182
298
  function R(e) {
183
299
  return !!e && typeof e == "object" && !Array.isArray(e);
184
300
  }
185
- function ce(e) {
301
+ function Ae(e) {
186
302
  return R(e) ? ["rows", "pages", "cells"].every((t) => typeof e[t] == "number" && Number.isSafeInteger(e[t]) && e[t] >= 0) && typeof e.durationMs == "number" && Number.isFinite(e.durationMs) && e.durationMs >= 0 : !1;
187
303
  }
188
- function fe(e) {
189
- return Array.isArray(e) && e.every((t) => R(t) && typeof t.code == "string" && typeof t.message == "string" && ["info", "warning", "error"].includes(t.severity));
304
+ function xe(e) {
305
+ return Array.isArray(e) && e.every((t) => R(t) && typeof t.code == "string" && typeof t.message == "string" && ["info", "warning", "error"].includes(t.severity) && G(t));
190
306
  }
191
- function ue(e) {
307
+ function $e(e) {
192
308
  return R(e) && Object.values(e).every((t) => R(t) && (t.revision === void 0 || typeof t.revision == "string") && (t.sourceToken === void 0 || typeof t.sourceToken == "string"));
193
309
  }
194
- function pe(e, t) {
195
- if (!R(e) || !ce(e.stats) || !fe(e.diagnostics) || !ue(e.revisions)) return !1;
196
- if (t === "prepare") return ae(e.plan).ok;
197
- const n = e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
198
- return e.bytes instanceof Uint8Array && (e.format === "pdf" || e.format === "xlsx") && e.contentType === n;
310
+ function Se(e) {
311
+ return e === void 0 ? !0 : R(e) && ["heuristic", "provided", "font-bytes"].includes(e.textMetrics) && (e.fontFingerprint === void 0 || typeof e.fontFingerprint == "string" && /^[a-f0-9]{64}$/.test(e.fontFingerprint));
312
+ }
313
+ function ke(e, t) {
314
+ if (!R(e) || !Ae(e.stats) || !xe(e.diagnostics) || !$e(e.revisions) || !Se(e.layout) || !be(e.sources)) return !1;
315
+ if (t === "prepare") return pe(e.plan).ok;
316
+ const r = e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
317
+ return e.bytes instanceof Uint8Array && (e.format === "pdf" || e.format === "xlsx") && e.contentType === r;
199
318
  }
200
319
  function D(e) {
201
320
  if (!e || typeof e != "object") return { message: String(e) };
202
321
  const t = {};
203
- for (const n of ["code", "path", "field", "message"]) {
204
- const o = e[n];
205
- typeof o == "string" && (t[n] = o);
322
+ for (const r of ["code", "path", "field", "message"]) {
323
+ const o = e[r];
324
+ typeof o == "string" && (t[r] = o);
206
325
  }
207
326
  return t;
208
327
  }
209
- function de(e) {
328
+ function Ne(e) {
210
329
  const t = D(e);
211
330
  if (!R(e)) return t;
212
- for (const n of ["format", "severity", "kind", "nid"]) typeof e[n] == "string" && (t[n] = e[n]);
213
- for (const n of ["pageIndex", "componentIndex"]) Number.isSafeInteger(e[n]) && e[n] >= 0 && (t[n] = e[n]);
214
- return Array.isArray(e.componentPath) && e.componentPath.every((n) => Number.isSafeInteger(n) && n >= 0) && (t.componentPath = e.componentPath), t;
331
+ for (const r of ["format", "severity", "kind", "nid"]) typeof e[r] == "string" && (t[r] = e[r]);
332
+ for (const r of ["pageIndex", "componentIndex"]) Number.isSafeInteger(e[r]) && e[r] >= 0 && (t[r] = e[r]);
333
+ return Array.isArray(e.componentPath) && e.componentPath.every((r) => Number.isSafeInteger(r) && r >= 0) && (t.componentPath = e.componentPath), t;
215
334
  }
216
- function me(e) {
335
+ function ve(e) {
217
336
  if (!(e instanceof Error)) return { name: "Error", message: String(e) };
218
337
  const t = e;
219
338
  return {
@@ -222,45 +341,45 @@ function me(e) {
222
341
  ...typeof t.code == "string" ? { code: t.code } : {},
223
342
  ...typeof t.path == "string" ? { path: t.path } : {},
224
343
  ...Array.isArray(t.issues) ? { issues: t.issues.map(D) } : {},
225
- ...Array.isArray(t.diagnostics) ? { diagnostics: t.diagnostics.map(de) } : {}
344
+ ...Array.isArray(t.diagnostics) ? { diagnostics: t.diagnostics.map(Ne) } : {}
226
345
  };
227
346
  }
228
- function ye(e) {
347
+ function Re(e) {
229
348
  if (!e || typeof e != "object") return !1;
230
349
  const t = e;
231
- return t.protocol === M && typeof t.id == "string" && (t.operation === "prepare" || t.operation === "export") && !!t.input && typeof t.input == "object";
350
+ return t.protocol === I && typeof t.id == "string" && (t.operation === "prepare" || t.operation === "export" || t.operation === "exportPrepared") && !!t.input && typeof t.input == "object";
232
351
  }
233
- async function le(e, t, n) {
352
+ async function Ie(e, t, r) {
234
353
  try {
235
- const o = t.operation === "prepare" ? await e.prepare({ ...t.input, onEvent: n }) : await e.export({ ...t.input, onEvent: n });
236
- return { protocol: M, id: t.id, result: o };
354
+ const o = t.operation === "prepare" ? await e.prepare({ ...t.input, onEvent: r }) : t.operation === "exportPrepared" ? await e.exportPrepared({ ...t.input, onEvent: r }) : await e.export({ ...t.input, onEvent: r });
355
+ return { protocol: I, id: t.id, result: o };
237
356
  } catch (o) {
238
- return { protocol: M, id: t.id, error: me(o) };
357
+ return { protocol: I, id: t.id, error: ve(o) };
239
358
  }
240
359
  }
241
- function he(e) {
360
+ function Me(e) {
242
361
  const t = e.result;
243
362
  return !t || !("bytes" in t) || !(t.bytes.buffer instanceof ArrayBuffer) ? [] : [t.bytes.buffer];
244
363
  }
245
- function ge(e, t) {
246
- if (!R(e) || typeof e.taskId != "string" || !e.taskId || t.taskId !== void 0 && e.taskId !== t.taskId || e.correlationId !== t.correlationId || e.reportId !== void 0 && (typeof e.reportId != "string" || !t.reportIds.includes(e.reportId)) || !["query", "validate", "layout", "assets", "encode"].includes(e.stage) || !["started", "completed", "failed"].includes(e.status)) return !1;
247
- for (const n of ["completed", "total"]) if (e[n] !== void 0 && (typeof e[n] != "number" || !Number.isFinite(e[n]) || e[n] < 0)) return !1;
364
+ function Ee(e, t) {
365
+ if (!R(e) || typeof e.taskId != "string" || !e.taskId || t.taskId !== void 0 && e.taskId !== t.taskId || e.correlationId !== t.correlationId || e.reportId !== void 0 && (typeof e.reportId != "string" || !("reportIds" in t && t.reportIds.includes(e.reportId))) || !["query", "validate", "layout", "assets", "encode"].includes(e.stage) || !["started", "completed", "failed"].includes(e.status)) return !1;
366
+ for (const r of ["completed", "total"]) if (e[r] !== void 0 && (typeof e[r] != "number" || !Number.isFinite(e[r]) || e[r] < 0)) return !1;
248
367
  return e.completed === void 0 || e.total === void 0 || e.completed <= e.total;
249
368
  }
250
- let we = 0;
369
+ let Oe = 0;
251
370
  function J(e) {
252
371
  const t = new Error("报表 Worker 任务已取消");
253
372
  return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e }), t;
254
373
  }
255
- function be(e, t) {
374
+ function Te(e, t) {
256
375
  if (!e || typeof e != "object") return;
257
- const n = e;
258
- return n.protocol === M && n.id === t ? n : void 0;
376
+ const r = e;
377
+ return r.protocol === I && r.id === t ? r : void 0;
259
378
  }
260
- function Ae(e, t = {}) {
261
- const n = t.timeoutMs ?? 12e4;
262
- if (!Number.isFinite(n) || n <= 0 || n > 2147483647) throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");
263
- const o = (r, s, i, d) => i?.aborted ? Promise.reject(J(i.reason)) : new Promise((y, u) => {
379
+ function je(e, t = {}) {
380
+ const r = t.timeoutMs ?? 12e4;
381
+ if (!Number.isFinite(r) || r <= 0 || r > 2147483647) throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");
382
+ const o = (n, s, i, d) => i?.aborted ? Promise.reject(J(i.reason)) : new Promise((m, u) => {
264
383
  let b;
265
384
  try {
266
385
  b = e();
@@ -268,200 +387,105 @@ function Ae(e, t = {}) {
268
387
  u(l);
269
388
  return;
270
389
  }
271
- const k = `mach-report-${Date.now()}-${++we}`;
390
+ const S = `mach-report-${Date.now()}-${++Oe}`;
272
391
  let p = !1, f = () => {
273
392
  }, c;
274
- const m = (l, w) => {
393
+ const y = (l, w) => {
275
394
  p || (p = !0, c && clearTimeout(c), f(), i?.removeEventListener("abort", g), Promise.resolve().then(() => b.terminate()).then(
276
- () => l === void 0 ? y(w) : u(l),
277
- (N) => u(l ?? N)
395
+ () => l === void 0 ? m(w) : u(l),
396
+ (k) => u(l ?? k)
278
397
  ));
279
- }, g = () => m(J(i?.reason)), x = (l) => {
280
- const w = be(l, k);
398
+ }, g = () => y(J(i?.reason)), x = (l) => {
399
+ const w = Te(l, S);
281
400
  if (!(!w || p)) {
282
401
  if ("type" in w && w.type === "event") {
283
- const N = "event" in w ? w.event : void 0;
284
- ge(N, s) ? Z(d, N, i) : m(new Error("报表 Worker 返回无效阶段事件"));
402
+ const k = "event" in w ? w.event : void 0;
403
+ Ee(k, s) ? Z(d, k, i) : y(new Error("报表 Worker 返回无效阶段事件"));
285
404
  return;
286
405
  }
287
- w.error && typeof w.error.name == "string" && typeof w.error.message == "string" ? m(new B(w.error)) : pe(w.result, r) && (r !== "export" || "format" in w.result && "format" in s && w.result.format === s.format) ? m(void 0, w.result) : m(new Error("报表 Worker 返回无效响应"));
406
+ w.error && typeof w.error.name == "string" && typeof w.error.message == "string" ? y(new B(w.error)) : ke(w.result, n) && (n === "prepare" || "format" in w.result && "format" in s && w.result.format === s.format) ? y(void 0, w.result) : y(new Error("报表 Worker 返回无效响应"));
288
407
  }
289
408
  };
290
409
  try {
291
- if (f = b.subscribe(x, (l) => m(l ?? new Error("报表 Worker 执行失败"))), p) {
410
+ if (f = b.subscribe(x, (l) => y(l ?? new Error("报表 Worker 执行失败"))), p) {
292
411
  f();
293
412
  return;
294
413
  }
295
- if (i?.addEventListener("abort", g, { once: !0 }), c = setTimeout(() => m(new B({ name: "ReportRuntimeError", code: "timeout", message: `报表 Worker 执行超过 ${n}ms` })), n), i?.aborted) g();
414
+ if (i?.addEventListener("abort", g, { once: !0 }), c = setTimeout(() => y(new B({ name: "ReportRuntimeError", code: "timeout", message: `报表 Worker 执行超过 ${r}ms` })), r), i?.aborted) g();
296
415
  else {
297
- const { onEvent: l, signal: w, ...N } = s;
298
- b.postMessage({ protocol: M, id: k, operation: r, input: N });
416
+ const { onEvent: l, signal: w, ...k } = s;
417
+ b.postMessage({ protocol: I, id: S, operation: n, input: k });
299
418
  }
300
419
  } catch (l) {
301
- m(l);
420
+ y(l);
302
421
  }
303
422
  });
304
- return { prepare: (r, s, i) => o("prepare", r, s, i), export: (r, s, i) => o("export", r, s, i) };
305
- }
306
- const xe = new Uint32Array([
307
- 1116352408,
308
- 1899447441,
309
- 3049323471,
310
- 3921009573,
311
- 961987163,
312
- 1508970993,
313
- 2453635748,
314
- 2870763221,
315
- 3624381080,
316
- 310598401,
317
- 607225278,
318
- 1426881987,
319
- 1925078388,
320
- 2162078206,
321
- 2614888103,
322
- 3248222580,
323
- 3835390401,
324
- 4022224774,
325
- 264347078,
326
- 604807628,
327
- 770255983,
328
- 1249150122,
329
- 1555081692,
330
- 1996064986,
331
- 2554220882,
332
- 2821834349,
333
- 2952996808,
334
- 3210313671,
335
- 3336571891,
336
- 3584528711,
337
- 113926993,
338
- 338241895,
339
- 666307205,
340
- 773529912,
341
- 1294757372,
342
- 1396182291,
343
- 1695183700,
344
- 1986661051,
345
- 2177026350,
346
- 2456956037,
347
- 2730485921,
348
- 2820302411,
349
- 3259730800,
350
- 3345764771,
351
- 3516065817,
352
- 3600352804,
353
- 4094571909,
354
- 275423344,
355
- 430227734,
356
- 506948616,
357
- 659060556,
358
- 883997877,
359
- 958139571,
360
- 1322822218,
361
- 1537002063,
362
- 1747873779,
363
- 1955562222,
364
- 2024104815,
365
- 2227730452,
366
- 2361852424,
367
- 2428436474,
368
- 2756734187,
369
- 3204031479,
370
- 3329325298
371
- ]), $ = (e, t) => e >>> t | e << 32 - t;
372
- function $e(e, t, n) {
373
- const o = new DataView(e.buffer, e.byteOffset + t, 64);
374
- for (let r = 0; r < 16; r++) n[r] = o.getUint32(r * 4);
375
- for (let r = 16; r < 64; r++) {
376
- const s = n[r - 15], i = n[r - 2], d = $(s, 7) ^ $(s, 18) ^ s >>> 3, y = $(i, 17) ^ $(i, 19) ^ i >>> 10;
377
- n[r] = n[r - 16] + d + n[r - 7] + y;
378
- }
379
- }
380
- function ke(e, t) {
381
- let n = e[0], o = e[1], r = e[2], s = e[3], i = e[4], d = e[5], y = e[6], u = e[7];
382
- for (let b = 0; b < 64; b++) {
383
- const k = $(i, 6) ^ $(i, 11) ^ $(i, 25), p = i & d ^ ~i & y, f = u + k + p + xe[b] + t[b] >>> 0, c = $(n, 2) ^ $(n, 13) ^ $(n, 22), m = n & o ^ n & r ^ o & r, g = c + m >>> 0;
384
- u = y, y = d, d = i, i = s + f >>> 0, s = r, r = o, o = n, n = f + g >>> 0;
385
- }
386
- e[0] = e[0] + n, e[1] = e[1] + o, e[2] = e[2] + r, e[3] = e[3] + s, e[4] = e[4] + i, e[5] = e[5] + d, e[6] = e[6] + y, e[7] = e[7] + u;
387
- }
388
- function Ne(e) {
389
- const t = new Uint8Array(Math.ceil((e.byteLength + 9) / 64) * 64);
390
- t.set(e), t[e.byteLength] = 128;
391
- const n = new DataView(t.buffer);
392
- return n.setUint32(t.length - 8, Math.floor(e.byteLength / 536870912)), n.setUint32(t.length - 4, e.byteLength * 8 >>> 0), t;
393
- }
394
- const ve = () => new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), Se = (e) => Array.from(e, (t) => t.toString(16).padStart(8, "0")).join("");
395
- async function Re(e) {
396
- const t = Ne(e), n = ve(), o = new Uint32Array(64);
397
- for (let r = 0; r < t.length; r += 64)
398
- r > 0 && r % 262144 === 0 && await new Promise((s) => setTimeout(s, 0)), $e(t, r, o), ke(n, o);
399
- return Se(n);
423
+ return { exportPrepared: (n, s, i) => o("exportPrepared", n, s, i), prepare: (n, s, i) => o("prepare", n, s, i), export: (n, s, i) => o("export", n, s, i) };
400
424
  }
401
425
  class a extends Error {
402
- constructor(t, n) {
403
- super(n), this.code = t, this.name = "ReportJobError";
426
+ constructor(t, r) {
427
+ super(r), this.code = t, this.name = "ReportJobError";
404
428
  }
405
429
  }
406
430
  function T(e, t) {
407
431
  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 a("input", "任务范围应非空,ID应为1–128位安全标识");
408
432
  }
409
- function Me(e) {
410
- const t = Array.isArray(e), n = Object.getPrototypeOf(e), o = Object.keys(e);
411
- if (n !== (t ? Array.prototype : Object.prototype) && !(n === null && !t)) throw new a("input", "任务对象应为普通 JSON 对象");
433
+ function qe(e) {
434
+ const t = Array.isArray(e), r = Object.getPrototypeOf(e), o = Object.keys(e);
435
+ if (r !== (t ? Array.prototype : Object.prototype) && !(r === null && !t)) throw new a("input", "任务对象应为普通 JSON 对象");
412
436
  if (Object.getOwnPropertySymbols(e).length) throw new a("input", "任务不能包含Symbol");
413
437
  if (Object.getOwnPropertyNames(e).filter((s) => !(t && s === "length")).length !== o.length) throw new a("input", "任务不能包含不可枚举属性");
414
438
  if (t && (o.length !== e.length || o.some((s) => s !== String(Number(s)) || !Number.isSafeInteger(Number(s)) || Number(s) < 0 || Number(s) >= e.length))) throw new a("input", "任务数组不能稀疏或包含额外属性");
415
439
  return o.sort();
416
440
  }
417
- function Ee(e, t) {
418
- const n = Object.getOwnPropertyDescriptor(e, t);
419
- if (["__proto__", "prototype", "constructor"].includes(t) || n.get || n.set) throw new a("input", "任务不能包含危险键或访问器");
420
- return n.value;
421
- }
422
- function v(e, t = {}) {
423
- const n = t.maxNodes ?? 2e4, o = t.maxCharacters ?? 1e6;
424
- if (!Number.isSafeInteger(n) || n < 1 || n > 2e4 || !Number.isSafeInteger(o) || o < 1 || o > 1e6) throw new a("input", "任务JSON预算无效");
425
- let r = 0, s = 0;
441
+ function Be(e, t) {
442
+ const r = Object.getOwnPropertyDescriptor(e, t);
443
+ if (["__proto__", "prototype", "constructor"].includes(t) || r.get || r.set) throw new a("input", "任务不能包含危险键或访问器");
444
+ return r.value;
445
+ }
446
+ function N(e, t = {}) {
447
+ const r = t.maxNodes ?? 2e4, o = t.maxCharacters ?? 1e6;
448
+ if (!Number.isSafeInteger(r) || r < 1 || r > 2e4 || !Number.isSafeInteger(o) || o < 1 || o > 1e6) throw new a("input", "任务JSON预算无效");
449
+ let n = 0, s = 0;
426
450
  const i = /* @__PURE__ */ new Set();
427
451
  function d(u, b) {
428
- if (++r > n || b > 32) throw new a("input", "任务数据超过节点或深度预算");
452
+ if (++n > r || b > 32) throw new a("input", "任务数据超过节点或深度预算");
429
453
  if (typeof u == "string") {
430
454
  if (s += u.length, s > o) throw new a("input", "任务文本超过预算");
431
455
  return u;
432
456
  }
433
457
  if (u === null || typeof u == "boolean" || typeof u == "number" && Number.isFinite(u)) return u;
434
458
  if (!u || typeof u != "object" || i.has(u)) throw new a("input", "任务只允许无循环的有限 JSON 值");
435
- const k = Array.isArray(u), p = Me(u);
459
+ const S = Array.isArray(u), p = qe(u);
436
460
  i.add(u);
437
461
  const f = /* @__PURE__ */ Object.create(null);
438
462
  for (const c of p) {
439
463
  if (s += c.length, s > o) throw new a("input", "任务文本超过预算");
440
- f[c] = d(Ee(u, c), b + 1);
464
+ f[c] = d(Be(u, c), b + 1);
441
465
  }
442
- return i.delete(u), k ? Array.from({ length: u.length }, (c, m) => f[String(m)]) : f;
466
+ return i.delete(u), S ? Array.from({ length: u.length }, (c, y) => f[String(y)]) : f;
443
467
  }
444
- const y = JSON.stringify(d(e, 0));
445
- if (y.length > o) throw new a("input", "任务序列化数据超过字符预算");
446
- return y;
468
+ const m = JSON.stringify(d(e, 0));
469
+ if (m.length > o) throw new a("input", "任务序列化数据超过字符预算");
470
+ return m;
447
471
  }
448
472
  function j(e) {
449
473
  return JSON.parse(JSON.stringify(e));
450
474
  }
451
- function L(e, t, n, o) {
452
- if (T(t, n), e.scope !== t || e.id !== n || e.revision !== (o ?? 0) + 1 || !Number.isSafeInteger(e.revision)) throw new a("input", "任务身份或修订不匹配");
453
- if (![e.createdAt, e.updatedAt, e.attempt].every((r) => Number.isSafeInteger(r) && r >= 0) || !["queued", "running", "completed", "failed", "cancelled"].includes(e.status)) throw new a("input", "任务状态无效");
475
+ function K(e, t, r, o) {
476
+ if (T(t, r), e.scope !== t || e.id !== r || e.revision !== (o ?? 0) + 1 || !Number.isSafeInteger(e.revision)) throw new a("input", "任务身份或修订不匹配");
477
+ if (![e.createdAt, e.updatedAt, e.attempt].every((n) => Number.isSafeInteger(n) && n >= 0) || !["queued", "running", "completed", "failed", "cancelled"].includes(e.status)) throw new a("input", "任务状态无效");
454
478
  if (e.lease && (!e.lease.owner || !Number.isSafeInteger(e.lease.expiresAt))) throw new a("input", "任务租约无效");
455
479
  if (!e.request || typeof e.request.kind != "string" || !e.request.kind.trim() || e.request.kind.length > 128) throw new a("input", "任务类型无效");
456
- v(e.request.payload, { maxNodes: 19e3, maxCharacters: 75e4 }), v(e);
480
+ N(e.request.payload, { maxNodes: 19e3, maxCharacters: 75e4 }), N(e);
457
481
  }
458
- function Oe(e, t) {
459
- if (e && (e.createdAt !== t.createdAt || v(e.request) !== v(t.request))) throw new a("input", "任务创建时间与请求不可变更,请使用新任务ID");
482
+ function Je(e, t) {
483
+ if (e && (e.createdAt !== t.createdAt || N(e.request) !== N(t.request))) throw new a("input", "任务创建时间与请求不可变更,请使用新任务ID");
460
484
  }
461
- function Ie(e, t) {
485
+ function Pe(e, t) {
462
486
  return e.status === "queued" || e.status === "running" && (e.lease?.expiresAt ?? 0) <= t;
463
487
  }
464
- function Te(e = {}) {
488
+ function We(e = {}) {
465
489
  const t = {
466
490
  maxRecords: e.maxRecords ?? 1e4,
467
491
  maxBytes: e.maxBytes ?? 67108864,
@@ -470,145 +494,145 @@ function Te(e = {}) {
470
494
  maxTombstones: e.maxTombstones ?? 1e4,
471
495
  maxTombstoneBytes: e.maxTombstoneBytes ?? 16777216
472
496
  };
473
- if (!Object.values(t).every((n) => Number.isSafeInteger(n) && n > 0) || t.controlReserveBytes < 4096) throw new a("input", "任务容量应为正整数,控制状态预留至少4096字节");
497
+ if (!Object.values(t).every((r) => Number.isSafeInteger(r) && r > 0) || t.controlReserveBytes < 4096) throw new a("input", "任务容量应为正整数,控制状态预留至少4096字节");
474
498
  return t;
475
499
  }
476
- function E(e) {
477
- return new TextEncoder().encode(v(e)).byteLength;
500
+ function M(e) {
501
+ return new TextEncoder().encode(N(e)).byteLength;
478
502
  }
479
- function z(e, t) {
480
- const n = { scope: e.scope, id: e.id, revision: 1, request: e.request, status: "queued", createdAt: e.createdAt, updatedAt: e.createdAt, attempt: 0 }, o = { ...e };
503
+ function L(e, t) {
504
+ const r = { scope: e.scope, id: e.id, revision: 1, request: e.request, status: "queued", createdAt: e.createdAt, updatedAt: e.createdAt, attempt: 0 }, o = { ...e };
481
505
  delete o.result;
482
- const r = e.result === void 0 ? 0 : E(e.result);
483
- if (r > t.maxResultBytes) throw new a("capacity", "任务结果超过独立预算,请保存文件引用");
484
- return Math.max(E(n) + t.controlReserveBytes, E(o)) + r;
506
+ const n = e.result === void 0 ? 0 : M(e.result);
507
+ if (n > t.maxResultBytes) throw new a("capacity", "任务结果超过独立预算,请保存文件引用");
508
+ return Math.max(M(r) + t.controlReserveBytes, M(o)) + n;
485
509
  }
486
- function _(e) {
510
+ function z(e) {
487
511
  return e.status !== "queued" && e.status !== "running";
488
512
  }
489
- function je(e) {
513
+ function Fe(e) {
490
514
  const t = { ...e, tombstoneRetentionMs: e.tombstoneRetentionMs ?? 6048e5, limit: e.limit ?? 100 };
491
- if (![t.now, t.terminalBefore].every((n) => Number.isSafeInteger(n) && n >= 0) || t.terminalBefore > t.now) throw new a("input", "终态清理时间应为不超过当前时间的非负整数");
492
- if (![t.tombstoneRetentionMs, t.limit].every((n) => Number.isSafeInteger(n) && n > 0) || !Number.isSafeInteger(t.now + t.tombstoneRetentionMs)) throw new a("input", "幂等保留期与清理批量应为正整数");
515
+ if (![t.now, t.terminalBefore].every((r) => Number.isSafeInteger(r) && r >= 0) || t.terminalBefore > t.now) throw new a("input", "终态清理时间应为不超过当前时间的非负整数");
516
+ if (![t.tombstoneRetentionMs, t.limit].every((r) => Number.isSafeInteger(r) && r > 0) || !Number.isSafeInteger(t.now + t.tombstoneRetentionMs)) throw new a("input", "幂等保留期与清理批量应为正整数");
493
517
  return t;
494
518
  }
495
- async function qe(e) {
496
- const t = new TextEncoder().encode(v(e)), n = globalThis.crypto?.subtle;
497
- if (!n) return Re(t);
498
- const o = await n.digest("SHA-256", t);
499
- return Array.from(new Uint8Array(o), (r) => r.toString(16).padStart(2, "0")).join("");
519
+ async function Ue(e) {
520
+ const t = new TextEncoder().encode(N(e)), r = globalThis.crypto?.subtle;
521
+ if (!r) return we(t);
522
+ const o = await r.digest("SHA-256", t);
523
+ return Array.from(new Uint8Array(o), (n) => n.toString(16).padStart(2, "0")).join("");
500
524
  }
501
- async function Be(e, t) {
502
- if (!_(e)) throw new a("input", "只能归档终态任务");
503
- return { scope: e.scope, id: e.id, revision: e.revision, status: e.status, createdAt: e.createdAt, updatedAt: e.updatedAt, attempt: e.attempt, requestHash: await qe(e.request), expiresAt: t };
525
+ async function Ce(e, t) {
526
+ if (!z(e)) throw new a("input", "只能归档终态任务");
527
+ return { scope: e.scope, id: e.id, revision: e.revision, status: e.status, createdAt: e.createdAt, updatedAt: e.updatedAt, attempt: e.attempt, requestHash: await Ue(e.request), expiresAt: t };
504
528
  }
505
- function Je(e) {
529
+ function De(e) {
506
530
  if (!e || !["completed", "failed", "cancelled"].includes(e.status) || !/^[a-f0-9]{64}$/.test(e.requestHash)) throw new a("input", "任务幂等摘要无效");
507
531
  if (![e.revision, e.createdAt, e.updatedAt, e.attempt, e.expiresAt].every((t) => Number.isSafeInteger(t) && t >= 0) || e.revision < 1) throw new a("input", "任务幂等摘要时间或修订无效");
508
532
  }
509
- function I(e) {
533
+ function O(e) {
510
534
  return e?.code;
511
535
  }
512
- function O(e, t) {
536
+ function E(e, t) {
513
537
  return W("sha256").update(JSON.stringify([e, t])).digest("hex") + ".json";
514
538
  }
515
539
  async function q(e) {
516
540
  try {
517
541
  return await h.readFile(e, "utf8");
518
542
  } catch (t) {
519
- if (I(t) === "ENOENT") return;
543
+ if (O(t) === "ENOENT") return;
520
544
  throw t;
521
545
  }
522
546
  }
523
- async function Pe(e, t) {
524
- const n = await q(e);
525
- if (n === void 0) return;
547
+ async function Ke(e, t) {
548
+ const r = await q(e);
549
+ if (r === void 0) return;
526
550
  let o;
527
551
  try {
528
- o = JSON.parse(n);
552
+ o = JSON.parse(r);
529
553
  } catch {
530
554
  throw new a("conflict", "任务锁尚未完整写入或已损坏,拒绝自动移除");
531
555
  }
532
556
  if (!o || !Number.isSafeInteger(o.pid) || o.pid < 1) throw new a("conflict", "任务锁身份无效,拒绝自动移除");
533
557
  try {
534
558
  process.kill(o.pid, 0);
535
- } catch (r) {
536
- if (I(r) === "ESRCH") {
559
+ } catch (n) {
560
+ if (O(n) === "ESRCH") {
537
561
  await h.unlink(e);
538
562
  return;
539
563
  }
540
- throw r;
564
+ throw n;
541
565
  }
542
566
  throw new a("conflict", "任务目录的写入进程仍在运行");
543
567
  }
544
- async function We(e, t) {
568
+ async function Le(e, t) {
545
569
  if (!t) throw new a("conflict", "任务目录已有写入进程;多实例请使用数据库CAS适配器");
546
- const n = e + ".recovery";
570
+ const r = e + ".recovery";
547
571
  let o;
548
572
  try {
549
- o = await h.open(n, "wx", 384);
550
- } catch (r) {
551
- throw I(r) === "EEXIST" ? new a("conflict", "任务目录恢复正在进行,请稍后重试") : r;
573
+ o = await h.open(r, "wx", 384);
574
+ } catch (n) {
575
+ throw O(n) === "EEXIST" ? new a("conflict", "任务目录恢复正在进行,请稍后重试") : n;
552
576
  }
553
577
  try {
554
- return await o.writeFile(JSON.stringify({ pid: process.pid })), await Pe(e, !0), await h.open(e, "wx", 384);
578
+ return await o.writeFile(JSON.stringify({ pid: process.pid })), await Ke(e, !0), await h.open(e, "wx", 384);
555
579
  } finally {
556
- await o.close(), await h.unlink(n);
580
+ await o.close(), await h.unlink(r);
557
581
  }
558
582
  }
559
- async function Ue(e, t) {
560
- const n = S.join(e, ".writer-lock"), o = P();
561
- let r;
583
+ async function ze(e, t) {
584
+ const r = v.join(e, ".writer-lock"), o = P();
585
+ let n;
562
586
  try {
563
- r = await h.open(n, "wx", 384);
587
+ n = await h.open(r, "wx", 384);
564
588
  } catch (s) {
565
- if (I(s) !== "EEXIST") throw s;
566
- r = await We(n, t);
589
+ if (O(s) !== "EEXIST") throw s;
590
+ n = await Le(r, t);
567
591
  }
568
592
  try {
569
- await r.writeFile(JSON.stringify({ pid: process.pid, token: o })), await r.sync();
593
+ await n.writeFile(JSON.stringify({ pid: process.pid, token: o })), await n.sync();
570
594
  } catch (s) {
571
- throw await r.close(), await h.unlink(n).catch(() => {
595
+ throw await n.close(), await h.unlink(r).catch(() => {
572
596
  }), s;
573
597
  }
574
- return { file: n, token: o, handle: r };
575
- }
576
- function Ce(e, t, n, o) {
577
- if ("tombstone" in n) {
578
- const r = n.tombstone;
579
- if (Je(r), T(r.scope, r.id), O(r.scope, r.id) !== t) throw new a("input", "持久任务摘要身份不匹配");
580
- const s = E(r);
581
- e.tombstoneBytes += s, e.tombstones.set(t, { value: r, bytes: s });
598
+ return { file: r, token: o, handle: n };
599
+ }
600
+ function _e(e, t, r, o) {
601
+ if ("tombstone" in r) {
602
+ const n = r.tombstone;
603
+ if (De(n), T(n.scope, n.id), E(n.scope, n.id) !== t) throw new a("input", "持久任务摘要身份不匹配");
604
+ const s = M(n);
605
+ e.tombstoneBytes += s, e.tombstones.set(t, { value: n, bytes: s });
582
606
  } else {
583
- if (L(n, n.scope, n.id, n.revision - 1), O(n.scope, n.id) !== t) throw new a("input", "持久任务文件身份不匹配");
584
- const r = z(n, o);
585
- e.bytes += r, e.records.set(t, { record: n, bytes: r });
607
+ if (K(r, r.scope, r.id, r.revision - 1), E(r.scope, r.id) !== t) throw new a("input", "持久任务文件身份不匹配");
608
+ const n = L(r, o);
609
+ e.bytes += n, e.records.set(t, { record: r, bytes: n });
586
610
  }
587
611
  if (e.bytes > o.maxBytes || e.records.size > o.maxRecords || e.tombstoneBytes > o.maxTombstoneBytes || e.tombstones.size > o.maxTombstones) throw new a("capacity", "持久任务及控制状态预留超过目录预算");
588
612
  }
589
- async function Fe(e, t) {
590
- const n = await h.readdir(e);
591
- for (const s of n.filter((i) => /^\.pending-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(i))) await h.unlink(S.join(e, s));
592
- const o = n.filter((s) => /^[a-f0-9]{64}\.json$/.test(s));
613
+ async function He(e, t) {
614
+ const r = await h.readdir(e);
615
+ for (const s of r.filter((i) => /^\.pending-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(i))) await h.unlink(v.join(e, s));
616
+ const o = r.filter((s) => /^[a-f0-9]{64}\.json$/.test(s));
593
617
  if (o.length > t.maxRecords + t.maxTombstones) throw new a("capacity", "持久任务数量超过目录预算");
594
- const r = { records: /* @__PURE__ */ new Map(), tombstones: /* @__PURE__ */ new Map(), bytes: 0, tombstoneBytes: 0 };
618
+ const n = { records: /* @__PURE__ */ new Map(), tombstones: /* @__PURE__ */ new Map(), bytes: 0, tombstoneBytes: 0 };
595
619
  for (const s of o) {
596
- const i = S.join(e, s);
620
+ const i = v.join(e, s);
597
621
  if ((await h.stat(i)).size > 4e6) throw new a("capacity", "持久任务文件超过单文件预算");
598
- Ce(r, s, JSON.parse(await h.readFile(i, "utf8")), t);
622
+ _e(n, s, JSON.parse(await h.readFile(i, "utf8")), t);
599
623
  }
600
- return r;
624
+ return n;
601
625
  }
602
- async function De(e, t, n) {
603
- const o = S.join(e, `.pending-${P()}`);
626
+ async function Ze(e, t, r) {
627
+ const o = v.join(e, `.pending-${P()}`);
604
628
  try {
605
- const r = await h.open(o, "wx", 384);
629
+ const n = await h.open(o, "wx", 384);
606
630
  try {
607
- await r.writeFile(n), await r.sync();
631
+ await n.writeFile(r), await n.sync();
608
632
  } finally {
609
- await r.close();
633
+ await n.close();
610
634
  }
611
- await h.rename(o, S.join(e, t));
635
+ await h.rename(o, v.join(e, t));
612
636
  const s = await h.open(e, "r");
613
637
  try {
614
638
  await s.sync();
@@ -616,25 +640,25 @@ async function De(e, t, n) {
616
640
  await s.close();
617
641
  }
618
642
  } finally {
619
- await h.unlink(o).catch((r) => {
620
- if (I(r) !== "ENOENT") throw r;
643
+ await h.unlink(o).catch((n) => {
644
+ if (O(n) !== "ENOENT") throw n;
621
645
  });
622
646
  }
623
647
  }
624
- async function Ke(e) {
625
- const t = S.resolve(e.directory), n = Te(e);
648
+ async function Ye(e) {
649
+ const t = v.resolve(e.directory), r = We(e);
626
650
  await h.mkdir(t, { recursive: !0, mode: 448 });
627
- const o = await Ue(t, e.recoverDeadOwner ?? !1);
628
- let r;
651
+ const o = await ze(t, e.recoverDeadOwner ?? !1);
652
+ let n;
629
653
  try {
630
- r = await Fe(t, n);
654
+ n = await He(t, r);
631
655
  } catch (p) {
632
656
  throw await o.handle.close(), await h.unlink(o.file), p;
633
657
  }
634
658
  let s = !1, i = Promise.resolve();
635
659
  const d = () => {
636
660
  if (s) throw new a("closed", "持久任务存储已关闭");
637
- }, y = (p) => {
661
+ }, m = (p) => {
638
662
  d();
639
663
  const f = i.then(async () => {
640
664
  if (JSON.parse(await h.readFile(o.file, "utf8")).token !== o.token) throw new a("closed", "持久任务存储写入锁已失效");
@@ -645,57 +669,57 @@ async function Ke(e) {
645
669
  }), f;
646
670
  }, u = async (p, f, c) => {
647
671
  try {
648
- await De(t, p, f);
649
- } catch (m) {
650
- throw await q(S.join(t, p)) === f && c(), m;
672
+ await Ze(t, p, f);
673
+ } catch (y) {
674
+ throw await q(v.join(t, p)) === f && c(), y;
651
675
  }
652
676
  c();
653
677
  };
654
678
  return {
655
679
  read: async (p, f) => {
656
680
  d(), T(p, f), await i;
657
- const c = r.records.get(O(p, f));
681
+ const c = n.records.get(E(p, f));
658
682
  return c ? j(c.record) : void 0;
659
683
  },
660
684
  readTombstone: async (p, f) => {
661
685
  d(), T(p, f), await i;
662
- const c = r.tombstones.get(O(p, f));
686
+ const c = n.tombstones.get(E(p, f));
663
687
  return c ? j(c.value) : void 0;
664
688
  },
665
- candidates: async (p, f) => (d(), await i, Array.from(r.records.values(), (c) => c.record).filter((c) => Ie(c, p)).sort((c, m) => c.createdAt - m.createdAt).slice(0, f).map(j)),
666
- compareAndSwap: async (p, f, c, m) => {
667
- const g = JSON.parse(v(m));
668
- return L(g, p, f, c), y(async () => {
669
- const x = O(p, f), l = r.records.get(x);
670
- if ((l?.record.revision ?? null) !== c || r.tombstones.has(x)) return !1;
671
- Oe(l?.record, g);
672
- const w = z(g, n), N = r.bytes - (l?.bytes ?? 0) + w;
673
- if (N > n.maxBytes || !l && r.records.size >= n.maxRecords) throw new a("capacity", "持久任务容量已满,请清理终态任务或扩大显式预算");
674
- return await u(x, v(g), () => {
675
- r.records.set(x, { record: g, bytes: w }), r.bytes = N;
689
+ candidates: async (p, f) => (d(), await i, Array.from(n.records.values(), (c) => c.record).filter((c) => Pe(c, p)).sort((c, y) => c.createdAt - y.createdAt).slice(0, f).map(j)),
690
+ compareAndSwap: async (p, f, c, y) => {
691
+ const g = JSON.parse(N(y));
692
+ return K(g, p, f, c), m(async () => {
693
+ const x = E(p, f), l = n.records.get(x);
694
+ if ((l?.record.revision ?? null) !== c || n.tombstones.has(x)) return !1;
695
+ Je(l?.record, g);
696
+ const w = L(g, r), k = n.bytes - (l?.bytes ?? 0) + w;
697
+ if (k > r.maxBytes || !l && n.records.size >= r.maxRecords) throw new a("capacity", "持久任务容量已满,请清理终态任务或扩大显式预算");
698
+ return await u(x, N(g), () => {
699
+ n.records.set(x, { record: g, bytes: w }), n.bytes = k;
676
700
  }), !0;
677
701
  });
678
702
  },
679
703
  prune: async (p) => {
680
- const f = je(p);
681
- return y(async () => {
704
+ const f = Fe(p);
705
+ return m(async () => {
682
706
  const c = { archived: 0, expired: 0 };
683
- for (const [m, g] of r.tombstones)
684
- g.value.expiresAt > f.now || c.expired >= f.limit || (await h.unlink(S.join(t, m)), r.tombstones.delete(m), r.tombstoneBytes -= g.bytes, c.expired++);
685
- for (const [m, g] of r.records) {
686
- if (!_(g.record) || g.record.updatedAt > f.terminalBefore || c.archived + c.expired >= f.limit) continue;
687
- const x = await Be(g.record, f.now + f.tombstoneRetentionMs), l = E(x);
688
- if (r.tombstones.size >= n.maxTombstones || r.tombstoneBytes + l > n.maxTombstoneBytes) break;
689
- await u(m, v({ tombstone: x }), () => {
690
- r.tombstones.set(m, { value: x, bytes: l }), r.tombstoneBytes += l, r.records.delete(m), r.bytes -= g.bytes;
707
+ for (const [y, g] of n.tombstones)
708
+ g.value.expiresAt > f.now || c.expired >= f.limit || (await h.unlink(v.join(t, y)), n.tombstones.delete(y), n.tombstoneBytes -= g.bytes, c.expired++);
709
+ for (const [y, g] of n.records) {
710
+ if (!z(g.record) || g.record.updatedAt > f.terminalBefore || c.archived + c.expired >= f.limit) continue;
711
+ const x = await Ce(g.record, f.now + f.tombstoneRetentionMs), l = M(x);
712
+ if (n.tombstones.size >= r.maxTombstones || n.tombstoneBytes + l > r.maxTombstoneBytes) break;
713
+ await u(y, N({ tombstone: x }), () => {
714
+ n.tombstones.set(y, { value: x, bytes: l }), n.tombstoneBytes += l, n.records.delete(y), n.bytes -= g.bytes;
691
715
  }), c.archived++;
692
716
  }
693
717
  if (c.expired) {
694
- const m = await h.open(t, "r");
718
+ const y = await h.open(t, "r");
695
719
  try {
696
- await m.sync();
720
+ await y.sync();
697
721
  } finally {
698
- await m.close();
722
+ await y.close();
699
723
  }
700
724
  }
701
725
  return c;
@@ -709,38 +733,38 @@ async function Ke(e) {
709
733
  }
710
734
  };
711
735
  }
712
- function Ze(e) {
736
+ function et(e) {
713
737
  const t = e.filename ?? e.workerUrl;
714
738
  if (!t || e.filename && e.workerUrl) throw new TypeError("请且仅请指定 filename 或 workerUrl");
715
- return Ae(() => {
716
- const n = new K(t, e.workerOptions);
739
+ return je(() => {
740
+ const r = new H(t, e.workerOptions);
717
741
  return {
718
- postMessage: (o) => n.postMessage(o),
719
- terminate: () => n.terminate(),
720
- subscribe: (o, r) => {
721
- const s = (i) => r(new Error(`报表 Worker 在响应前退出(code ${i})`));
722
- return n.on("message", o), n.on("error", r), n.on("messageerror", r), n.on("exit", s), () => {
723
- n.off("message", o), n.off("error", r), n.off("messageerror", r), n.off("exit", s);
742
+ postMessage: (o) => r.postMessage(o),
743
+ terminate: () => r.terminate(),
744
+ subscribe: (o, n) => {
745
+ const s = (i) => n(new Error(`报表 Worker 在响应前退出(code ${i})`));
746
+ return r.on("message", o), r.on("error", n), r.on("messageerror", n), r.on("exit", s), () => {
747
+ r.off("message", o), r.off("error", n), r.off("messageerror", n), r.off("exit", s);
724
748
  };
725
749
  }
726
750
  };
727
751
  }, e);
728
752
  }
729
- function Qe(e) {
730
- const t = H;
753
+ function tt(e) {
754
+ const t = _;
731
755
  if (!t) throw new Error("serveNodeReportWorker 只能在 worker_threads 中调用");
732
- const n = (o) => {
733
- ye(o) && le(e, o, (r) => t.postMessage({ protocol: M, id: o.id, type: "event", event: r })).then((r) => t.postMessage(r, he(r)));
756
+ const r = (o) => {
757
+ Re(o) && Ie(e, o, (n) => t.postMessage({ protocol: I, id: o.id, type: "event", event: n })).then((n) => t.postMessage(n, Me(n)));
734
758
  };
735
- return t.on("message", n), () => t.off("message", n);
759
+ return t.on("message", r), () => t.off("message", r);
736
760
  }
737
- function Ve(e) {
761
+ function rt(e) {
738
762
  return W("sha256").update(e).digest("hex");
739
763
  }
740
764
  export {
741
765
  B as ReportWorkerError,
742
- Ze as createNodeReportExecutor,
743
- Ke as openFileReportJobStore,
744
- Ve as reportArtifactSha256,
745
- Qe as serveNodeReportWorker
766
+ et as createNodeReportExecutor,
767
+ Ye as openFileReportJobStore,
768
+ rt as reportArtifactSha256,
769
+ tt as serveNodeReportWorker
746
770
  };