@agile-team/mach-report 2.16.0 → 2.17.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 (128) hide show
  1. package/README.md +10 -6
  2. package/dist/{ExcelBindingWizard-CP6h2x1f.cjs → ExcelBindingWizard-Bq6FYME6.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-HhB3hAJE.js → ExcelBindingWizard-Co1svTsw.js} +3 -3
  4. package/dist/{ParamEditor-CUQLgoxa.cjs → ParamEditor-B5UZRgxv.cjs} +1 -1
  5. package/dist/{ParamEditor-OKesP_nO.js → ParamEditor-DNNARyeB.js} +1 -1
  6. package/dist/{ReportBatchPanel-cZCAMAwH.cjs → ReportBatchPanel-Ctvs2t_9.cjs} +1 -1
  7. package/dist/{ReportBatchPanel-ruxcbfY6.js → ReportBatchPanel-uQh06usx.js} +1 -1
  8. package/dist/ReportPreview-BdQawRh0.js +4879 -0
  9. package/dist/ReportPreview-CJC_-j2I.cjs +6 -0
  10. package/dist/{ReportTemplateLibrary-BDlNT8JN.cjs → ReportTemplateLibrary-CnP7_1pH.cjs} +1 -1
  11. package/dist/{ReportTemplateLibrary-DcwrH-63.js → ReportTemplateLibrary-TIL_Oj2l.js} +1 -1
  12. package/dist/RuleEditor-DkRjOLlr.js +2141 -0
  13. package/dist/RuleEditor-h5anGsDB.cjs +1 -0
  14. package/dist/{TemplateOutlinePanel-CGrT5DFN.cjs → TemplateOutlinePanel-BlLxRrfu.cjs} +1 -1
  15. package/dist/{TemplateOutlinePanel-SXCjaPKR.js → TemplateOutlinePanel-BouxsuqQ.js} +1 -1
  16. package/dist/{TemplateReusePanel-lHLOS9Wn.js → TemplateReusePanel-BEACLPaN.js} +2 -2
  17. package/dist/{TemplateReusePanel-6Z3wRFz8.cjs → TemplateReusePanel-yxsHSO40.cjs} +1 -1
  18. package/dist/{TemplateReviewPanel-CJ9PLc48.js → TemplateReviewPanel-B1OGRY2i.js} +1 -1
  19. package/dist/{TemplateReviewPanel-Dpk7sLcF.cjs → TemplateReviewPanel-D9Cx0m2N.cjs} +1 -1
  20. package/dist/analytics.cjs +1 -1
  21. package/dist/analytics.d.cts +63 -1
  22. package/dist/analytics.d.ts +63 -1
  23. package/dist/analytics.js +4 -4
  24. package/dist/artifact-integrity.json +86 -90
  25. package/dist/assets-BIMVwjQe.js +231 -0
  26. package/dist/assets-Dfs2ElxI.cjs +1 -0
  27. package/dist/{auto-YR7a4BtF.js → auto-BIOmtVhk.js} +14 -14
  28. package/dist/{auto-uVBjX1j5.cjs → auto-DDHflI9v.cjs} +1 -1
  29. package/dist/computed-BW5a8QFk.js +612 -0
  30. package/dist/computed-C2GD3XcE.cjs +1 -0
  31. package/dist/dataset-DL83majE.js +161 -0
  32. package/dist/dataset-IrlXbUvh.cjs +1 -0
  33. package/dist/{designer-BfQSahxq.js → designer-D9XAxqSc.js} +1194 -1179
  34. package/dist/designer-uCDo5XSK.cjs +2 -0
  35. package/dist/designer.cjs +1 -1
  36. package/dist/designer.d.cts +125 -3
  37. package/dist/designer.d.ts +125 -3
  38. package/dist/designer.js +1 -1
  39. package/dist/{drill-CsdjgkRM.cjs → drill-ByN8COs_.cjs} +1 -1
  40. package/dist/{drill-DIGsZfyB.js → drill-CKW3Xtfa.js} +11 -11
  41. package/dist/{encoding-BYF9ZTl9.cjs → encoding-BFMFIc4r.cjs} +1 -1
  42. package/dist/{encoding-BOGq4qYL.js → encoding-DP_Eaf0A.js} +2 -2
  43. package/dist/{font-loader-EKLzOJxf.cjs → font-loader-7FWVlykp.cjs} +1 -1
  44. package/dist/{font-loader-CzI1GuBc.js → font-loader-CQZowp0I.js} +1 -1
  45. package/dist/index.cjs +8 -8
  46. package/dist/index.d.cts +173 -1
  47. package/dist/index.d.ts +173 -1
  48. package/dist/index.js +1205 -808
  49. package/dist/json-snapshot-D7PE1NsU.cjs +2 -0
  50. package/dist/{json-snapshot-D6ioHth9.js → json-snapshot-DYmEe3sO.js} +769 -692
  51. package/dist/matrix-JLAXlux-.js +302 -0
  52. package/dist/matrix-gTHpDTGm.cjs +1 -0
  53. package/dist/{pdf-ByVCb1i6.cjs → pdf-B8JouyYv.cjs} +47 -47
  54. package/dist/{pdf-DJ5S6ukC.js → pdf-l3ea86di.js} +13 -15
  55. package/dist/pdf.cjs +1 -1
  56. package/dist/pdf.d.cts +12 -0
  57. package/dist/pdf.d.ts +12 -0
  58. package/dist/pdf.js +2 -2
  59. package/dist/{plugin-C2j5_mhx.js → plugin-BBp74CQZ.js} +1 -1
  60. package/dist/{plugin-Dr39GBRG.cjs → plugin-CtFX9PFG.cjs} +1 -1
  61. package/dist/{prepared-DqtpvRTn.js → prepared-CARicKYh.js} +1 -1
  62. package/dist/{prepared-DdrjLC7L.cjs → prepared-Ch1x_Gog.cjs} +1 -1
  63. package/dist/{protocol-BzwMP4Vw.cjs → protocol-B5A2uom4.cjs} +1 -1
  64. package/dist/{protocol-kt4Iy6-3.js → protocol-BaiWjq5w.js} +3 -3
  65. package/dist/{record-bindings-DUX1VMlR.cjs → record-bindings-B86Sur_y.cjs} +1 -1
  66. package/dist/{record-bindings-CZWBJ1fU.js → record-bindings-D4TuMzHs.js} +1 -1
  67. package/dist/{region-binding-workflow-CWNvIjkV.js → region-binding-workflow-BNasF5kz.js} +2 -2
  68. package/dist/{region-binding-workflow-CqSMxQ4p.cjs → region-binding-workflow-O2Cni3mF.cjs} +1 -1
  69. package/dist/report-encoding-worker.cjs +1 -1
  70. package/dist/report-encoding-worker.js +1 -1
  71. package/dist/runtime-DakRXui3.js +170 -0
  72. package/dist/runtime-dL5ygIfa.cjs +1 -0
  73. package/dist/sbom.cdx.json +1 -1
  74. package/dist/server/node.d.cts +46 -0
  75. package/dist/server/node.d.ts +46 -0
  76. package/dist/server-node.cjs +4 -4
  77. package/dist/server-node.js +2540 -1911
  78. package/dist/server.cjs +1 -1
  79. package/dist/server.d.cts +174 -1
  80. package/dist/server.d.ts +174 -1
  81. package/dist/server.js +787 -544
  82. package/dist/style.css +1 -1
  83. package/dist/template-catalog-Dua8h9ZA.cjs +1 -0
  84. package/dist/{template-catalog-BtR2JmCL.js → template-catalog-wT1fNeAP.js} +4 -4
  85. package/dist/{template-fragments-BVsbxs4a.cjs → template-fragments-BajTajb4.cjs} +1 -1
  86. package/dist/{template-fragments-By0aZC1D.js → template-fragments-DmX5XK4N.js} +1 -1
  87. package/dist/{template-registry-C62vpv4a.cjs → template-registry-CpysHAxy.cjs} +1 -1
  88. package/dist/{template-registry-Cw3vRTX2.js → template-registry-u11fPd8D.js} +5 -5
  89. package/dist/{tree-BX380Rr7.cjs → tree-CLpxYbKa.cjs} +1 -1
  90. package/dist/{tree-CjVZLRw7.js → tree-DNJorJUf.js} +1 -1
  91. package/dist/vue/async.d.cts +108 -2
  92. package/dist/vue/async.d.ts +108 -2
  93. package/dist/vue/index.d.cts +130 -3
  94. package/dist/vue/index.d.ts +130 -3
  95. package/dist/vue-async.cjs +1 -1
  96. package/dist/vue-async.js +3 -3
  97. package/dist/vue.cjs +1 -1
  98. package/dist/vue.js +4 -4
  99. package/dist/{workbook-session-BeSO8PFB.js → workbook-session-B8pNW24X.js} +1 -1
  100. package/dist/{workbook-session-Cbts-22R.cjs → workbook-session-DN5LSA5C.cjs} +1 -1
  101. package/dist/worker.cjs +1 -1
  102. package/dist/worker.js +4 -4
  103. package/dist/xlsx.cjs +4 -4
  104. package/dist/xlsx.d.cts +88 -2
  105. package/dist/xlsx.d.ts +88 -2
  106. package/dist/xlsx.js +232 -230
  107. package/package.json +1 -1
  108. package/dist/ReportPreview-BcDKCLiK.js +0 -4834
  109. package/dist/ReportPreview-Bk9nLfO9.cjs +0 -6
  110. package/dist/RuleEditor-BX5S8RSF.cjs +0 -1
  111. package/dist/RuleEditor-CGl9XY2s.js +0 -2037
  112. package/dist/assets-CqIbfbTr.js +0 -126
  113. package/dist/assets-e4YSke8n.cjs +0 -1
  114. package/dist/capabilities-DDwXr_cA.js +0 -103
  115. package/dist/capabilities-DNLyZdNw.cjs +0 -1
  116. package/dist/computed-C-4C2S5h.js +0 -521
  117. package/dist/computed-CGV2a809.cjs +0 -1
  118. package/dist/dataset-BkRmwgeJ.cjs +0 -1
  119. package/dist/dataset-H5pFuQGU.js +0 -121
  120. package/dist/designer-CPPdeM5_.cjs +0 -2
  121. package/dist/diagnostic-notification-B9K9We3h.cjs +0 -1
  122. package/dist/diagnostic-notification-qGAYZdkB.js +0 -7
  123. package/dist/json-snapshot-DknkjvxP.cjs +0 -2
  124. package/dist/matrix-CGRGkn5s.js +0 -112
  125. package/dist/matrix-gEO7ZM_u.cjs +0 -1
  126. package/dist/runtime-BjKBI530.js +0 -168
  127. package/dist/runtime-CBFEPKEs.cjs +0 -1
  128. package/dist/template-catalog-C2NLdrwB.cjs +0 -1
@@ -1,16 +1,16 @@
1
- import { s as A, c as C, a as q } from "./prepared-DqtpvRTn.js";
2
- import { E as U } from "./json-snapshot-D6ioHth9.js";
3
- import { b as T, R as S, v as I, c as $ } from "./protocol-kt4Iy6-3.js";
1
+ import { s as A, c as C, a as q } from "./prepared-CARicKYh.js";
2
+ import { F as U } from "./json-snapshot-DYmEe3sO.js";
3
+ import { b as T, R as S, v as I, c as $ } from "./protocol-BaiWjq5w.js";
4
4
  import { a as H } from "./progress-Hc2vxoCs.js";
5
- import { c as N, e as G } from "./runtime-BjKBI530.js";
6
- import { D as j, R as M, t as R, v as K, b as L, c as W } from "./sha256-DTG-Gq8i.js";
5
+ import { c as N, e as G } from "./runtime-DakRXui3.js";
6
+ import { D as j, R as M, t as R, v as K, b as F, c as L } from "./sha256-DTG-Gq8i.js";
7
7
  class O extends Error {
8
8
  constructor(r) {
9
9
  super("报表 Worker 无法启动"), this.cause = r, this.name = "ReportWorkerStartError";
10
10
  }
11
11
  }
12
12
  let X = 0;
13
- function D(e) {
13
+ function W(e) {
14
14
  const r = new Error("报表 Worker 任务已取消");
15
15
  return r.name = "AbortError", Object.defineProperty(r, "cause", { value: e }), r;
16
16
  }
@@ -22,7 +22,7 @@ function J(e, r) {
22
22
  function Q(e, r = {}) {
23
23
  const t = r.timeoutMs ?? 12e4;
24
24
  if (!Number.isFinite(t) || t <= 0 || t > 2147483647) throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");
25
- const n = (o, s, a, f) => a?.aborted ? Promise.reject(D(a.reason)) : new Promise((v, i) => {
25
+ const n = (o, s, a, f) => a?.aborted ? Promise.reject(W(a.reason)) : new Promise((v, i) => {
26
26
  let g;
27
27
  try {
28
28
  g = e();
@@ -46,7 +46,7 @@ function Q(e, r = {}) {
46
46
  () => l === void 0 ? v(c) : i(l),
47
47
  (E) => i(l ?? E)
48
48
  );
49
- }, x = () => p(D(a?.reason)), d = (l) => {
49
+ }, x = () => p(W(a?.reason)), d = (l) => {
50
50
  const c = J(l, w);
51
51
  if (!(!c || m)) {
52
52
  if ("type" in c && c.type === "event") {
@@ -101,7 +101,7 @@ function k(e) {
101
101
  function h(e) {
102
102
  return typeof e == "string" ? e.length * 2 : 0;
103
103
  }
104
- function F(e, r) {
104
+ function D(e, r) {
105
105
  for (const t of e ?? []) {
106
106
  if (!k(r)) return;
107
107
  for (const n of t.segments) {
@@ -116,7 +116,7 @@ function z(e, r, t) {
116
116
  return;
117
117
  }
118
118
  if (k(r)) {
119
- r.bytes += h(e.text) + h(e.rawText) + h(e.imageData), F(e.richParagraphs, r);
119
+ r.bytes += h(e.text) + h(e.rawText) + h(e.imageData), D(e.richParagraphs, r);
120
120
  for (const n of e.lines ?? []) {
121
121
  if (!k(r)) return;
122
122
  r.bytes += h(n);
@@ -126,7 +126,7 @@ function z(e, r, t) {
126
126
  for (const o of n) {
127
127
  if (!k(r)) return;
128
128
  if (o) {
129
- r.cells++, r.bytes += h(o.text) + h(o.rawText) + h(o.value), F(o.richParagraphs, r);
129
+ r.cells++, r.bytes += h(o.text) + h(o.rawText) + h(o.value), D(o.richParagraphs, r);
130
130
  for (const s of o.children ?? []) {
131
131
  if (P(r)) return;
132
132
  z(s, r, t + 1);
@@ -193,13 +193,13 @@ function se(e, r) {
193
193
  const d = r(m());
194
194
  if (!d.exportPrepared) throw new TypeError("隔离执行器缺少 exportPrepared");
195
195
  const { signal: l, onEvent: c, ...b } = p, E = await d.exportPrepared(b, l, c);
196
- return R(l), L(t.budget, "maxOutputBytes", E.bytes.byteLength), { ...E, execution: u };
196
+ return R(l), F(t.budget, "maxOutputBytes", E.bytes.byteLength), { ...E, execution: u };
197
197
  } catch (d) {
198
198
  if (!(d instanceof O) || !f) throw d;
199
199
  R(i.signal), u = B(u, "worker-start-failed"), _(t, u);
200
200
  }
201
- const x = g ? await W(i.signal, m(), (d) => g({ ...p, signal: d })) : await W(i.signal, m(), (d) => o.exportPrepared({ ...y.forward(), signal: d }));
202
- return R(i.signal), L(t.budget, "maxOutputBytes", x.bytes.byteLength), { ...x, execution: u };
201
+ const x = g ? await L(i.signal, m(), (d) => g({ ...p, signal: d })) : await L(i.signal, m(), (d) => o.exportPrepared({ ...y.forward(), signal: d }));
202
+ return R(i.signal), F(t.budget, "maxOutputBytes", x.bytes.byteLength), { ...x, execution: u };
203
203
  }
204
204
  return {
205
205
  async exportPrepared(i, g) {
@@ -1 +1 @@
1
- "use strict";const T=require("./prepared-DdrjLC7L.cjs"),S=require("./json-snapshot-DknkjvxP.cjs"),R=require("./protocol-BzwMP4Vw.cjs"),I=require("./progress-B0ctFpKf.cjs"),_=require("./runtime-CBFEPKEs.cjs"),d=require("./sha256-BshdOkCC.cjs");class M extends Error{constructor(r){super("报表 Worker 无法启动"),this.cause=r,this.name="ReportWorkerStartError"}}let j=0;function W(e){const r=new Error("报表 Worker 任务已取消");return r.name="AbortError",Object.defineProperty(r,"cause",{value:e}),r}function U(e,r){if(!e||typeof e!="object")return;const t=e;return t.protocol===R.REPORT_WORKER_PROTOCOL&&t.id===r?t:void 0}function C(e,r={}){const t=r.timeoutMs??12e4;if(!Number.isFinite(t)||t<=0||t>2147483647)throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");const n=(o,s,a,u)=>a?.aborted?Promise.reject(W(a.reason)):new Promise((v,c)=>{let w;try{w=e()}catch(l){c(new M(l));return}const E=`mach-report-${Date.now()}-${++j}`;let m=!1,f=()=>{},k;const b=(l,i)=>{if(m)return;m=!0,k&&clearTimeout(k);let g;try{f()}catch(h){g=h}a?.removeEventListener("abort",x),l??=g,Promise.resolve().then(()=>w.terminate()).then(()=>l===void 0?v(i):c(l),h=>c(l??h))},x=()=>b(W(a?.reason)),p=l=>{const i=U(l,E);if(!(!i||m)){if("type"in i&&i.type==="event"){const g="event"in i?i.event:void 0;R.validReportWorkerEvent(g,s)?S.notifyReportTaskEvent(u,g,a):b(new Error("报表 Worker 返回无效阶段事件"));return}i.error&&typeof i.error.name=="string"&&typeof i.error.message=="string"?b(new R.ReportWorkerError(i.error)):R.validReportWorkerResult(i.result,o)&&(o==="prepare"||"format"in i.result&&"format"in s&&i.result.format===s.format)?b(void 0,i.result):b(new Error("报表 Worker 返回无效响应"))}};try{if(f=w.subscribe(p,l=>b(l??new Error("报表 Worker 执行失败"))),m){f();return}if(a?.addEventListener("abort",x,{once:!0}),k=setTimeout(()=>b(new R.ReportWorkerError({name:"ReportRuntimeError",code:"timeout",message:`报表 Worker 执行超过 ${t}ms`})),t),a?.aborted)x();else{const{onEvent:l,signal:i,...g}=s,h=z(g);w.postMessage({protocol:R.REPORT_WORKER_PROTOCOL,id:E,operation:o,input:g,...r.budget?{budget:r.budget}:{}},h)}}catch(l){b(l)}});return{exportPrepared:(o,s,a)=>n("exportPrepared",o,s,a),prepare:(o,s,a)=>n("prepare",o,s,a),export:(o,s,a)=>n("export",o,s,a)}}function z(e){return e.pdf?(e.pdf=T.snapshotPdfFonts(e.pdf),(e.pdf?.customFontFaces?Object.values(e.pdf.customFontFaces):[e.pdf?.customFontBytes]).filter(t=>t instanceof Uint8Array).map(t=>t.buffer)):[]}function A(e,r={}){return C(()=>{const t=e();return{postMessage:(n,o)=>t.postMessage(n,o),terminate:()=>t.terminate(),subscribe:(n,o)=>{const s=u=>n(u.data),a=u=>o(u instanceof ErrorEvent?new Error(u.message):new Error("报表 Worker 消息无法解码"));return t.addEventListener("message",s),t.addEventListener("error",a),t.addEventListener("messageerror",a),()=>{t.removeEventListener("message",s),t.removeEventListener("error",a),t.removeEventListener("messageerror",a)}}}},r)}const N={cells:2e4,pages:20,bytes:2e6};function P(e){return e.cells>=e.limits.cells||e.pages>=e.limits.pages||e.bytes>=e.limits.bytes||e.capped}function O(e){return++e.visits>=1e5&&(e.capped=!0),!P(e)}function y(e){return typeof e=="string"?e.length*2:0}function L(e,r){for(const t of e??[]){if(!O(r))return;for(const n of t.segments){if(!O(r))return;r.bytes+=y(n.text)}}}function B(e,r,t){if(t>32){r.capped=!0;return}if(O(r)){r.bytes+=y(e.text)+y(e.rawText)+y(e.imageData),L(e.richParagraphs,r);for(const n of e.lines??[]){if(!O(r))return;r.bytes+=y(n)}for(const n of e.grid?.cells??[]){if(!O(r))return;for(const o of n){if(!O(r))return;if(o){r.cells++,r.bytes+=y(o.text)+y(o.rawText)+y(o.value),L(o.richParagraphs,r);for(const s of o.children??[]){if(P(r))return;B(s,r,t+1)}}}}}}function $(e){const r={...N,...e.thresholds};for(const t of Object.values(r))if(!Number.isSafeInteger(t)||t<=0)throw new RangeError("导出隔离阈值应为正安全整数");return r}function H(e,r){const t=$(r),n=e.pdf?.customFontFaces?Object.values(e.pdf.customFontFaces):[e.pdf?.customFontBytes],o={pages:e.prepared.plan.pages.length,cells:0,bytes:n.reduce((u,v)=>u+(v?.byteLength??0),0),visits:0,capped:!1,limits:t};for(const u of e.prepared.plan.pages){if(P(o))break;for(const v of u.components){if(P(o))break;B(v,o,0)}}let s=P(o)?"worker":"local",a=o.capped?"scan-limit":s==="worker"?"threshold":"small-task";return r.mode==="local"&&(s="local",a="explicit-local"),r.mode==="worker"&&(s="worker",a="explicit-worker"),Object.values(e.xlsx??{}).some(u=>typeof u=="function")&&(s="local",a="nonserializable-options"),{mode:s,reason:a,estimate:{pages:o.pages,cells:o.cells,bytes:o.bytes},hardCancellation:s==="worker"}}function G(e){if(e.mode!==void 0&&!["auto","local","worker"].includes(e.mode))throw new TypeError("无效的导出执行模式");if(e.fallback!==void 0&&!["local","error"].includes(e.fallback))throw new TypeError("无效的导出回退策略");d.validateBudget({...e.budget,maxDurationMs:e.timeoutMs??e.budget?.maxDurationMs??12e4})}function F(e,r){I.observeOutput(()=>e.onDecision?.({...r,estimate:{...r.estimate}}))}function D(e,r){return{...e,mode:"local",reason:r,hardCancellation:!1}}function K(e,r){const t={...d.DEFAULT_REPORT_RUNTIME_BUDGET,...r.budget},n=T.capturePreparedHandoff(e.prepared,t.maxPreparedBytes,e.signal),o=_.enforcePrepared(n.prepared,t);n.prepared.stats=o.stats;const s={...e,prepared:n.prepared,pdf:T.snapshotPdfFonts(e.pdf),xlsx:T.snapshotXlsxOptions(e.xlsx)};return{request:s,forward:()=>({...s,prepared:n.forward()})}}function X(e,r){G(e);const t={...e,thresholds:{...e.thresholds},budget:{...d.DEFAULT_REPORT_RUNTIME_BUDGET,...e.budget}},n=t.timeoutMs??t.budget.maxDurationMs??12e4,o=_.createReportRuntime({reports:{},budget:{...t.budget,maxDurationMs:n}}),s=new Set;let a=!1;const u=t.mode!=="worker"&&t.fallback!=="error";async function v(c,w){const E=Date.now(),m=()=>{const p=n-(Date.now()-E);if(p<=0)throw new d.ReportRuntimeError("timeout",`报表执行超过 ${n}ms`);return p};let f=H(c,t);if(f.reason==="nonserializable-options"&&t.mode==="worker")throw new TypeError("Worker 模式不接受函数选项;请使用本地模式或可序列化配置");if(f.mode==="worker"&&!r){if(!u)throw new M(new Error("未配置 workerFactory"));f=D(f,"worker-unavailable")}const k=K(c,t),b=k.request;if(F(t,f),d.throwIfAborted(c.signal),f.mode==="worker")try{const p=r(m());if(!p.exportPrepared)throw new TypeError("隔离执行器缺少 exportPrepared");const{signal:l,onEvent:i,...g}=b,h=await p.exportPrepared(g,l,i);return d.throwIfAborted(l),d.assertBudget(t.budget,"maxOutputBytes",h.bytes.byteLength),{...h,execution:f}}catch(p){if(!(p instanceof M)||!u)throw p;d.throwIfAborted(c.signal),f=D(f,"worker-start-failed"),F(t,f)}const x=w?await d.controlled(c.signal,m(),p=>w({...b,signal:p})):await d.controlled(c.signal,m(),p=>o.exportPrepared({...k.forward(),signal:p}));return d.throwIfAborted(c.signal),d.assertBudget(t.budget,"maxOutputBytes",x.bytes.byteLength),{...x,execution:f}}return{async exportPrepared(c,w){if(a)throw new d.ReportRuntimeError("closed","导出执行器已释放");if(d.throwIfAborted(c.signal),s.size>=2)throw new d.ReportRuntimeError("queue-full","同时导出的任务已达 2 个,请等待完成后重试");const E=new AbortController;s.add(E);const m=()=>E.abort(c.signal?.reason);c.signal?.addEventListener("abort",m,{once:!0});try{return await v({...c,signal:E.signal},w)}finally{c.signal?.removeEventListener("abort",m),s.delete(E)}},cancel(){for(const c of s)c.abort()},dispose(){a=!0;for(const c of s)c.abort()}}}function q(e={}){const r=e.workerFactory,t={timeoutMs:e.timeoutMs??e.budget?.maxDurationMs,budget:{...e.budget}};return X(e,r?n=>A(r,{...t,timeoutMs:n}):void 0)}const J=Object.freeze(Object.defineProperty({__proto__:null,createAutoReportExporter:q},Symbol.toStringTag,{value:"Module"}));exports.ReportWorkerStartError=M;exports.auto=J;exports.createAutoReportExporter=q;exports.createBrowserReportExecutor=A;
1
+ "use strict";const T=require("./prepared-Ch1x_Gog.cjs"),S=require("./json-snapshot-D7PE1NsU.cjs"),R=require("./protocol-B5A2uom4.cjs"),I=require("./progress-B0ctFpKf.cjs"),_=require("./runtime-dL5ygIfa.cjs"),d=require("./sha256-BshdOkCC.cjs");class M extends Error{constructor(r){super("报表 Worker 无法启动"),this.cause=r,this.name="ReportWorkerStartError"}}let j=0;function W(e){const r=new Error("报表 Worker 任务已取消");return r.name="AbortError",Object.defineProperty(r,"cause",{value:e}),r}function U(e,r){if(!e||typeof e!="object")return;const t=e;return t.protocol===R.REPORT_WORKER_PROTOCOL&&t.id===r?t:void 0}function C(e,r={}){const t=r.timeoutMs??12e4;if(!Number.isFinite(t)||t<=0||t>2147483647)throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");const n=(o,s,a,u)=>a?.aborted?Promise.reject(W(a.reason)):new Promise((v,c)=>{let w;try{w=e()}catch(l){c(new M(l));return}const E=`mach-report-${Date.now()}-${++j}`;let m=!1,f=()=>{},k;const b=(l,i)=>{if(m)return;m=!0,k&&clearTimeout(k);let g;try{f()}catch(h){g=h}a?.removeEventListener("abort",x),l??=g,Promise.resolve().then(()=>w.terminate()).then(()=>l===void 0?v(i):c(l),h=>c(l??h))},x=()=>b(W(a?.reason)),p=l=>{const i=U(l,E);if(!(!i||m)){if("type"in i&&i.type==="event"){const g="event"in i?i.event:void 0;R.validReportWorkerEvent(g,s)?S.notifyReportTaskEvent(u,g,a):b(new Error("报表 Worker 返回无效阶段事件"));return}i.error&&typeof i.error.name=="string"&&typeof i.error.message=="string"?b(new R.ReportWorkerError(i.error)):R.validReportWorkerResult(i.result,o)&&(o==="prepare"||"format"in i.result&&"format"in s&&i.result.format===s.format)?b(void 0,i.result):b(new Error("报表 Worker 返回无效响应"))}};try{if(f=w.subscribe(p,l=>b(l??new Error("报表 Worker 执行失败"))),m){f();return}if(a?.addEventListener("abort",x,{once:!0}),k=setTimeout(()=>b(new R.ReportWorkerError({name:"ReportRuntimeError",code:"timeout",message:`报表 Worker 执行超过 ${t}ms`})),t),a?.aborted)x();else{const{onEvent:l,signal:i,...g}=s,h=z(g);w.postMessage({protocol:R.REPORT_WORKER_PROTOCOL,id:E,operation:o,input:g,...r.budget?{budget:r.budget}:{}},h)}}catch(l){b(l)}});return{exportPrepared:(o,s,a)=>n("exportPrepared",o,s,a),prepare:(o,s,a)=>n("prepare",o,s,a),export:(o,s,a)=>n("export",o,s,a)}}function z(e){return e.pdf?(e.pdf=T.snapshotPdfFonts(e.pdf),(e.pdf?.customFontFaces?Object.values(e.pdf.customFontFaces):[e.pdf?.customFontBytes]).filter(t=>t instanceof Uint8Array).map(t=>t.buffer)):[]}function A(e,r={}){return C(()=>{const t=e();return{postMessage:(n,o)=>t.postMessage(n,o),terminate:()=>t.terminate(),subscribe:(n,o)=>{const s=u=>n(u.data),a=u=>o(u instanceof ErrorEvent?new Error(u.message):new Error("报表 Worker 消息无法解码"));return t.addEventListener("message",s),t.addEventListener("error",a),t.addEventListener("messageerror",a),()=>{t.removeEventListener("message",s),t.removeEventListener("error",a),t.removeEventListener("messageerror",a)}}}},r)}const N={cells:2e4,pages:20,bytes:2e6};function P(e){return e.cells>=e.limits.cells||e.pages>=e.limits.pages||e.bytes>=e.limits.bytes||e.capped}function O(e){return++e.visits>=1e5&&(e.capped=!0),!P(e)}function y(e){return typeof e=="string"?e.length*2:0}function L(e,r){for(const t of e??[]){if(!O(r))return;for(const n of t.segments){if(!O(r))return;r.bytes+=y(n.text)}}}function B(e,r,t){if(t>32){r.capped=!0;return}if(O(r)){r.bytes+=y(e.text)+y(e.rawText)+y(e.imageData),L(e.richParagraphs,r);for(const n of e.lines??[]){if(!O(r))return;r.bytes+=y(n)}for(const n of e.grid?.cells??[]){if(!O(r))return;for(const o of n){if(!O(r))return;if(o){r.cells++,r.bytes+=y(o.text)+y(o.rawText)+y(o.value),L(o.richParagraphs,r);for(const s of o.children??[]){if(P(r))return;B(s,r,t+1)}}}}}}function $(e){const r={...N,...e.thresholds};for(const t of Object.values(r))if(!Number.isSafeInteger(t)||t<=0)throw new RangeError("导出隔离阈值应为正安全整数");return r}function H(e,r){const t=$(r),n=e.pdf?.customFontFaces?Object.values(e.pdf.customFontFaces):[e.pdf?.customFontBytes],o={pages:e.prepared.plan.pages.length,cells:0,bytes:n.reduce((u,v)=>u+(v?.byteLength??0),0),visits:0,capped:!1,limits:t};for(const u of e.prepared.plan.pages){if(P(o))break;for(const v of u.components){if(P(o))break;B(v,o,0)}}let s=P(o)?"worker":"local",a=o.capped?"scan-limit":s==="worker"?"threshold":"small-task";return r.mode==="local"&&(s="local",a="explicit-local"),r.mode==="worker"&&(s="worker",a="explicit-worker"),Object.values(e.xlsx??{}).some(u=>typeof u=="function")&&(s="local",a="nonserializable-options"),{mode:s,reason:a,estimate:{pages:o.pages,cells:o.cells,bytes:o.bytes},hardCancellation:s==="worker"}}function G(e){if(e.mode!==void 0&&!["auto","local","worker"].includes(e.mode))throw new TypeError("无效的导出执行模式");if(e.fallback!==void 0&&!["local","error"].includes(e.fallback))throw new TypeError("无效的导出回退策略");d.validateBudget({...e.budget,maxDurationMs:e.timeoutMs??e.budget?.maxDurationMs??12e4})}function F(e,r){I.observeOutput(()=>e.onDecision?.({...r,estimate:{...r.estimate}}))}function D(e,r){return{...e,mode:"local",reason:r,hardCancellation:!1}}function K(e,r){const t={...d.DEFAULT_REPORT_RUNTIME_BUDGET,...r.budget},n=T.capturePreparedHandoff(e.prepared,t.maxPreparedBytes,e.signal),o=_.enforcePrepared(n.prepared,t);n.prepared.stats=o.stats;const s={...e,prepared:n.prepared,pdf:T.snapshotPdfFonts(e.pdf),xlsx:T.snapshotXlsxOptions(e.xlsx)};return{request:s,forward:()=>({...s,prepared:n.forward()})}}function X(e,r){G(e);const t={...e,thresholds:{...e.thresholds},budget:{...d.DEFAULT_REPORT_RUNTIME_BUDGET,...e.budget}},n=t.timeoutMs??t.budget.maxDurationMs??12e4,o=_.createReportRuntime({reports:{},budget:{...t.budget,maxDurationMs:n}}),s=new Set;let a=!1;const u=t.mode!=="worker"&&t.fallback!=="error";async function v(c,w){const E=Date.now(),m=()=>{const p=n-(Date.now()-E);if(p<=0)throw new d.ReportRuntimeError("timeout",`报表执行超过 ${n}ms`);return p};let f=H(c,t);if(f.reason==="nonserializable-options"&&t.mode==="worker")throw new TypeError("Worker 模式不接受函数选项;请使用本地模式或可序列化配置");if(f.mode==="worker"&&!r){if(!u)throw new M(new Error("未配置 workerFactory"));f=D(f,"worker-unavailable")}const k=K(c,t),b=k.request;if(F(t,f),d.throwIfAborted(c.signal),f.mode==="worker")try{const p=r(m());if(!p.exportPrepared)throw new TypeError("隔离执行器缺少 exportPrepared");const{signal:l,onEvent:i,...g}=b,h=await p.exportPrepared(g,l,i);return d.throwIfAborted(l),d.assertBudget(t.budget,"maxOutputBytes",h.bytes.byteLength),{...h,execution:f}}catch(p){if(!(p instanceof M)||!u)throw p;d.throwIfAborted(c.signal),f=D(f,"worker-start-failed"),F(t,f)}const x=w?await d.controlled(c.signal,m(),p=>w({...b,signal:p})):await d.controlled(c.signal,m(),p=>o.exportPrepared({...k.forward(),signal:p}));return d.throwIfAborted(c.signal),d.assertBudget(t.budget,"maxOutputBytes",x.bytes.byteLength),{...x,execution:f}}return{async exportPrepared(c,w){if(a)throw new d.ReportRuntimeError("closed","导出执行器已释放");if(d.throwIfAborted(c.signal),s.size>=2)throw new d.ReportRuntimeError("queue-full","同时导出的任务已达 2 个,请等待完成后重试");const E=new AbortController;s.add(E);const m=()=>E.abort(c.signal?.reason);c.signal?.addEventListener("abort",m,{once:!0});try{return await v({...c,signal:E.signal},w)}finally{c.signal?.removeEventListener("abort",m),s.delete(E)}},cancel(){for(const c of s)c.abort()},dispose(){a=!0;for(const c of s)c.abort()}}}function q(e={}){const r=e.workerFactory,t={timeoutMs:e.timeoutMs??e.budget?.maxDurationMs,budget:{...e.budget}};return X(e,r?n=>A(r,{...t,timeoutMs:n}):void 0)}const J=Object.freeze(Object.defineProperty({__proto__:null,createAutoReportExporter:q},Symbol.toStringTag,{value:"Module"}));exports.ReportWorkerStartError=M;exports.auto=J;exports.createAutoReportExporter=q;exports.createBrowserReportExecutor=A;