@agile-team/mach-report 2.15.0 → 2.16.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 (155) hide show
  1. package/README.md +14 -9
  2. package/dist/{ExcelBindingWizard-Bs43BGNp.cjs → ExcelBindingWizard-CP6h2x1f.cjs} +1 -1
  3. package/dist/{ExcelBindingWizard-BKH1nGNS.js → ExcelBindingWizard-HhB3hAJE.js} +3 -3
  4. package/dist/{ParamEditor-Da4akw6V.cjs → ParamEditor-CUQLgoxa.cjs} +1 -1
  5. package/dist/{ParamEditor-DoAhzJsm.js → ParamEditor-OKesP_nO.js} +1 -1
  6. package/dist/{ReportBatchPanel-wP9m9Pj1.cjs → ReportBatchPanel-cZCAMAwH.cjs} +1 -1
  7. package/dist/{ReportBatchPanel-BMf6boMA.js → ReportBatchPanel-ruxcbfY6.js} +3 -3
  8. package/dist/ReportPreview-BcDKCLiK.js +4834 -0
  9. package/dist/ReportPreview-Bk9nLfO9.cjs +6 -0
  10. package/dist/{ReportTemplateLibrary-Sxr3eD0J.cjs → ReportTemplateLibrary-BDlNT8JN.cjs} +1 -1
  11. package/dist/{ReportTemplateLibrary-C9wutIiT.js → ReportTemplateLibrary-DcwrH-63.js} +1 -1
  12. package/dist/{RuleEditor-XhGHK8DE.cjs → RuleEditor-BX5S8RSF.cjs} +1 -1
  13. package/dist/{RuleEditor-C_Clasvd.js → RuleEditor-CGl9XY2s.js} +2 -2
  14. package/dist/{TemplateOutlinePanel-JTSR53vJ.cjs → TemplateOutlinePanel-CGrT5DFN.cjs} +1 -1
  15. package/dist/{TemplateOutlinePanel-D6Bkny59.js → TemplateOutlinePanel-SXCjaPKR.js} +1 -1
  16. package/dist/{TemplateReusePanel-Kx35S0Ql.cjs → TemplateReusePanel-6Z3wRFz8.cjs} +1 -1
  17. package/dist/{TemplateReusePanel-rVuK1kTz.js → TemplateReusePanel-lHLOS9Wn.js} +2 -2
  18. package/dist/{TemplateReviewPanel-B0ar9_zf.js → TemplateReviewPanel-CJ9PLc48.js} +1 -1
  19. package/dist/{TemplateReviewPanel-Dn6X9UmY.cjs → TemplateReviewPanel-Dpk7sLcF.cjs} +1 -1
  20. package/dist/analytics.d.cts +2 -0
  21. package/dist/analytics.d.ts +2 -0
  22. package/dist/artifact-integrity.json +99 -91
  23. package/dist/{assets-DEaz4qsp.js → assets-CqIbfbTr.js} +24 -22
  24. package/dist/assets-e4YSke8n.cjs +1 -0
  25. package/dist/auto-YR7a4BtF.js +240 -0
  26. package/dist/auto-uVBjX1j5.cjs +1 -0
  27. package/dist/{batch-BfZHN1do.js → batch-WzDIXJAt.js} +1 -1
  28. package/dist/{batch-CLpELXBl.cjs → batch-z6Aw5GEY.cjs} +1 -1
  29. package/dist/capabilities-DDwXr_cA.js +103 -0
  30. package/dist/capabilities-DNLyZdNw.cjs +1 -0
  31. package/dist/codes.d.cts +2 -0
  32. package/dist/codes.d.ts +2 -0
  33. package/dist/component-tree-Ca6YYfHq.js +61 -0
  34. package/dist/component-tree-DkGLEfZC.cjs +1 -0
  35. package/dist/config-Dg_o8e7m.cjs +1 -0
  36. package/dist/{config-BVsJXSqS.js → config-XQ4qrQ7Q.js} +66 -64
  37. package/dist/designer-BfQSahxq.js +5163 -0
  38. package/dist/designer-CPPdeM5_.cjs +2 -0
  39. package/dist/designer.cjs +1 -1
  40. package/dist/designer.d.cts +53 -0
  41. package/dist/designer.d.ts +53 -0
  42. package/dist/designer.js +1 -1
  43. package/dist/diagnostic-notification-B9K9We3h.cjs +1 -0
  44. package/dist/diagnostic-notification-qGAYZdkB.js +7 -0
  45. package/dist/drill-CsdjgkRM.cjs +1 -0
  46. package/dist/{drill-ByJviLXS.js → drill-DIGsZfyB.js} +11 -11
  47. package/dist/encoding-BOGq4qYL.js +21 -0
  48. package/dist/encoding-BYF9ZTl9.cjs +1 -0
  49. package/dist/{font-loader-Q3bQjmrI.js → font-loader-CzI1GuBc.js} +1 -1
  50. package/dist/{font-loader-B_UkxpzC.cjs → font-loader-EKLzOJxf.cjs} +1 -1
  51. package/dist/index.cjs +7 -8
  52. package/dist/index.d.cts +2 -0
  53. package/dist/index.d.ts +2 -0
  54. package/dist/index.js +865 -834
  55. package/dist/json-snapshot-D6ioHth9.js +1702 -0
  56. package/dist/json-snapshot-DknkjvxP.cjs +2 -0
  57. package/dist/{pdf-CvvrjPQg.cjs → pdf-ByVCb1i6.cjs} +48 -50
  58. package/dist/{pdf-BwNyeGpt.js → pdf-DJ5S6ukC.js} +2737 -2749
  59. package/dist/pdf.cjs +1 -1
  60. package/dist/pdf.d.cts +2 -0
  61. package/dist/pdf.d.ts +2 -0
  62. package/dist/pdf.js +2 -2
  63. package/dist/{plugin-Ca_XZG3l.js → plugin-C2j5_mhx.js} +1 -1
  64. package/dist/{plugin-DHO7X8z2.cjs → plugin-Dr39GBRG.cjs} +1 -1
  65. package/dist/prepared-DdrjLC7L.cjs +1 -0
  66. package/dist/prepared-DqtpvRTn.js +87 -0
  67. package/dist/progress-BXzlVbIp.js +29 -0
  68. package/dist/progress-DJBd9Rb9.cjs +1 -0
  69. package/dist/{progress-D-OTpEav.js → progress-Hc2vxoCs.js} +2 -2
  70. package/dist/protocol-BzwMP4Vw.cjs +1 -0
  71. package/dist/protocol-kt4Iy6-3.js +90 -0
  72. package/dist/{record-bindings-Do_b3h4V.js → record-bindings-CZWBJ1fU.js} +9 -10
  73. package/dist/record-bindings-DUX1VMlR.cjs +1 -0
  74. package/dist/{region-binding-workflow-BMhK_TjP.js → region-binding-workflow-CWNvIjkV.js} +1 -1
  75. package/dist/{region-binding-workflow-DIYJdCUr.cjs → region-binding-workflow-CqSMxQ4p.cjs} +1 -1
  76. package/dist/report-encoding-worker.cjs +1 -0
  77. package/dist/report-encoding-worker.d.ts +1 -0
  78. package/dist/report-encoding-worker.js +2 -0
  79. package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
  80. package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
  81. package/dist/runtime-BjKBI530.js +168 -0
  82. package/dist/runtime-CBFEPKEs.cjs +1 -0
  83. package/dist/sbom.cdx.json +2 -2
  84. package/dist/server/node.d.cts +86 -1
  85. package/dist/server/node.d.ts +86 -1
  86. package/dist/server-node.cjs +5 -1
  87. package/dist/server-node.js +4558 -473
  88. package/dist/server.cjs +1 -1
  89. package/dist/server.d.cts +8 -1
  90. package/dist/server.d.ts +8 -1
  91. package/dist/server.js +634 -792
  92. package/dist/sha256-BshdOkCC.cjs +1 -0
  93. package/dist/sha256-DTG-Gq8i.js +157 -0
  94. package/dist/style-67OqfNed.js +73 -0
  95. package/dist/style-C22Pbv3T.cjs +1 -0
  96. package/dist/style.css +1 -1
  97. package/dist/{template-catalog-j2B1MJlL.js → template-catalog-BtR2JmCL.js} +9 -9
  98. package/dist/{template-catalog-FJE_c9Qe.cjs → template-catalog-C2NLdrwB.cjs} +1 -1
  99. package/dist/{template-fragments-DcKeiylI.cjs → template-fragments-BVsbxs4a.cjs} +1 -1
  100. package/dist/{template-fragments-BGbQLGlV.js → template-fragments-By0aZC1D.js} +2 -2
  101. package/dist/template-registry-C62vpv4a.cjs +1 -0
  102. package/dist/{template-registry-BtaKPELV.js → template-registry-Cw3vRTX2.js} +389 -321
  103. package/dist/{textwrap-DE1kgcJB.js → textwrap-BEIg2w8y.js} +1 -1
  104. package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
  105. package/dist/vue/async.d.cts +66 -0
  106. package/dist/vue/async.d.ts +66 -0
  107. package/dist/vue/index.d.cts +89 -1
  108. package/dist/vue/index.d.ts +89 -1
  109. package/dist/vue-async.cjs +1 -1
  110. package/dist/vue-async.js +3 -3
  111. package/dist/vue.cjs +1 -1
  112. package/dist/vue.js +7 -7
  113. package/dist/{workbook-session-BvToI-Fd.js → workbook-session-BeSO8PFB.js} +153 -140
  114. package/dist/{workbook-session-Bjv1YCRK.cjs → workbook-session-Cbts-22R.cjs} +12 -12
  115. package/dist/worker.cjs +1 -1
  116. package/dist/worker.d.cts +84 -1
  117. package/dist/worker.d.ts +84 -1
  118. package/dist/worker.js +12 -157
  119. package/dist/xlsx-node.cjs +33 -33
  120. package/dist/xlsx-node.js +1282 -1289
  121. package/dist/xlsx.cjs +4 -3
  122. package/dist/xlsx.d.cts +2 -0
  123. package/dist/xlsx.d.ts +2 -0
  124. package/dist/xlsx.js +297 -279
  125. package/package.json +6 -3
  126. package/dist/ReportPreview-ChV19HBp.js +0 -4619
  127. package/dist/ReportPreview-DbLvvOUT.cjs +0 -6
  128. package/dist/assets-B9ImAi6_.cjs +0 -1
  129. package/dist/batch-BaP6pWDE.cjs +0 -1
  130. package/dist/batch-CGyt-b2W.js +0 -273
  131. package/dist/capabilities-CAh2Nrue.cjs +0 -1
  132. package/dist/capabilities-DskCHs3V.js +0 -69
  133. package/dist/config-D10us76d.cjs +0 -1
  134. package/dist/data-explanation-B8MZRYVS.js +0 -16
  135. package/dist/data-explanation-DE55G30w.cjs +0 -1
  136. package/dist/defaults-DXhiM1ZD.js +0 -10
  137. package/dist/defaults-xhmcLLrf.cjs +0 -1
  138. package/dist/designer-2bDlcNXQ.js +0 -5136
  139. package/dist/designer-BT7XCdbW.cjs +0 -2
  140. package/dist/drill-DYTxuL3A.cjs +0 -1
  141. package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
  142. package/dist/grid-strokes-DyyG1q_o.js +0 -53
  143. package/dist/json-snapshot-DFb2eWkf.js +0 -1416
  144. package/dist/json-snapshot-WWSGlaHG.cjs +0 -2
  145. package/dist/prepared-CFy9B75C.cjs +0 -1
  146. package/dist/prepared-ajM-H-9B.js +0 -69
  147. package/dist/record-bindings-By_UKZ2g.cjs +0 -1
  148. package/dist/render-plan-7xpGrCEl.cjs +0 -1
  149. package/dist/render-plan-Ck6koX9L.js +0 -13
  150. package/dist/sha256-ArEYjaTI.cjs +0 -1
  151. package/dist/sha256-DPEuJ3nh.js +0 -155
  152. package/dist/style-CQ1PK8ZB.js +0 -67
  153. package/dist/style-UgIJSA1F.cjs +0 -1
  154. package/dist/template-registry-Co1zPq5e.cjs +0 -1
  155. package/dist/textwrap-CWHyzkBH.cjs +0 -4
package/dist/worker.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("./json-snapshot-WWSGlaHG.cjs"),M=require("./prepared-CFy9B75C.cjs"),A=require("./data-explanation-DE55G30w.cjs"),L=require("./template-registry-Co1zPq5e.cjs"),u="mach-report-worker/1";class l extends Error{constructor(r){super(r.message),this.name=r.name,this.code=r.code,this.path=r.path,this.issues=r.issues,this.diagnostics=r.diagnostics}}function f(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function T(e){return f(e)?["rows","pages","cells"].every(r=>typeof e[r]=="number"&&Number.isSafeInteger(e[r])&&e[r]>=0)&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>=0:!1}function j(e){return Array.isArray(e)&&e.every(r=>f(r)&&typeof r.code=="string"&&typeof r.message=="string"&&["info","warning","error"].includes(r.severity)&&A.hasValidDataExplanation(r))}function S(e){return f(e)&&Object.values(e).every(r=>f(r)&&(r.revision===void 0||typeof r.revision=="string")&&(r.sourceToken===void 0||typeof r.sourceToken=="string"))}function O(e){return e===void 0?!0:f(e)&&["heuristic","provided","font-bytes"].includes(e.textMetrics)&&(e.fontFingerprint===void 0||typeof e.fontFingerprint=="string"&&/^[a-f0-9]{64}$/.test(e.fontFingerprint))}function F(e,r){if(!f(e)||!T(e.stats)||!j(e.diagnostics)||!S(e.revisions)||!O(e.layout)||!M.validPreparedSources(e.sources))return!1;if(r==="prepare")return L.validateRenderPlan(e.plan).ok;const t=e.format==="pdf"?"application/pdf":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";return e.bytes instanceof Uint8Array&&(e.format==="pdf"||e.format==="xlsx")&&e.contentType===t}function x(e){if(!e||typeof e!="object")return{message:String(e)};const r={};for(const t of["code","path","field","message"]){const o=e[t];typeof o=="string"&&(r[t]=o)}return r}function N(e){const r=x(e);if(!f(e))return r;for(const t of["format","severity","kind","nid"])typeof e[t]=="string"&&(r[t]=e[t]);for(const t of["pageIndex","componentIndex"])Number.isSafeInteger(e[t])&&e[t]>=0&&(r[t]=e[t]);return Array.isArray(e.componentPath)&&e.componentPath.every(t=>Number.isSafeInteger(t)&&t>=0)&&(r.componentPath=e.componentPath),r}function z(e){if(!(e instanceof Error))return{name:"Error",message:String(e)};const r=e;return{name:e.name,message:e.message,...typeof r.code=="string"?{code:r.code}:{},...typeof r.path=="string"?{path:r.path}:{},...Array.isArray(r.issues)?{issues:r.issues.map(x)}:{},...Array.isArray(r.diagnostics)?{diagnostics:r.diagnostics.map(N)}:{}}}function _(e){if(!e||typeof e!="object")return!1;const r=e;return r.protocol===u&&typeof r.id=="string"&&(r.operation==="prepare"||r.operation==="export"||r.operation==="exportPrepared")&&!!r.input&&typeof r.input=="object"}async function $(e,r,t){try{const o=r.operation==="prepare"?await e.prepare({...r.input,onEvent:t}):r.operation==="exportPrepared"?await e.exportPrepared({...r.input,onEvent:t}):await e.export({...r.input,onEvent:t});return{protocol:u,id:r.id,result:o}}catch(o){return{protocol:u,id:r.id,error:z(o)}}}function q(e){const r=e.result;return!r||!("bytes"in r)||!(r.bytes.buffer instanceof ArrayBuffer)?[]:[r.bytes.buffer]}function v(e,r){if(!f(e)||typeof e.taskId!="string"||!e.taskId||r.taskId!==void 0&&e.taskId!==r.taskId||e.correlationId!==r.correlationId||e.reportId!==void 0&&(typeof e.reportId!="string"||!("reportIds"in r&&r.reportIds.includes(e.reportId)))||!["query","validate","layout","assets","encode"].includes(e.stage)||!["started","completed","failed"].includes(e.status))return!1;for(const t of["completed","total"])if(e[t]!==void 0&&(typeof e[t]!="number"||!Number.isFinite(e[t])||e[t]<0))return!1;return e.completed===void 0||e.total===void 0||e.completed<=e.total}let B=0;function w(e){const r=new Error("报表 Worker 任务已取消");return r.name="AbortError",Object.defineProperty(r,"cause",{value:e}),r}function D(e,r){if(!e||typeof e!="object")return;const t=e;return t.protocol===u&&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 o=(s,a,n,d)=>n?.aborted?Promise.reject(w(n.reason)):new Promise((I,b)=>{let g;try{g=e()}catch(c){b(c);return}const R=`mach-report-${Date.now()}-${++B}`;let y=!1,E=()=>{},h;const p=(c,i)=>{y||(y=!0,h&&clearTimeout(h),E(),n?.removeEventListener("abort",k),Promise.resolve().then(()=>g.terminate()).then(()=>c===void 0?I(i):b(c),m=>b(c??m)))},k=()=>p(w(n?.reason)),P=c=>{const i=D(c,R);if(!(!i||y)){if("type"in i&&i.type==="event"){const m="event"in i?i.event:void 0;v(m,a)?W.notifyReportTaskEvent(d,m,n):p(new Error("报表 Worker 返回无效阶段事件"));return}i.error&&typeof i.error.name=="string"&&typeof i.error.message=="string"?p(new l(i.error)):F(i.result,s)&&(s==="prepare"||"format"in i.result&&"format"in a&&i.result.format===a.format)?p(void 0,i.result):p(new Error("报表 Worker 返回无效响应"))}};try{if(E=g.subscribe(P,c=>p(c??new Error("报表 Worker 执行失败"))),y){E();return}if(n?.addEventListener("abort",k,{once:!0}),h=setTimeout(()=>p(new l({name:"ReportRuntimeError",code:"timeout",message:`报表 Worker 执行超过 ${t}ms`})),t),n?.aborted)k();else{const{onEvent:c,signal:i,...m}=a;g.postMessage({protocol:u,id:R,operation:s,input:m})}}catch(c){p(c)}});return{exportPrepared:(s,a,n)=>o("exportPrepared",s,a,n),prepare:(s,a,n)=>o("prepare",s,a,n),export:(s,a,n)=>o("export",s,a,n)}}function K(e,r={}){return C(()=>{const t=e();return{postMessage:o=>t.postMessage(o),terminate:()=>t.terminate(),subscribe:(o,s)=>{const a=d=>o(d.data),n=d=>s(d instanceof ErrorEvent?new Error(d.message):new Error("报表 Worker 消息无法解码"));return t.addEventListener("message",a),t.addEventListener("error",n),t.addEventListener("messageerror",n),()=>{t.removeEventListener("message",a),t.removeEventListener("error",n),t.removeEventListener("messageerror",n)}}}},r)}function U(e,r=globalThis){const t=o=>{_(o.data)&&$(e,o.data,s=>r.postMessage({protocol:u,id:o.data.id,type:"event",event:s})).then(s=>r.postMessage(s,q(s)))};return r.addEventListener("message",t),()=>r.removeEventListener("message",t)}exports.ReportWorkerError=l;exports.createBrowserReportExecutor=K;exports.serveReportWorker=U;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./protocol-BzwMP4Vw.cjs"),s=require("./auto-uVBjX1j5.cjs"),R=require("./encoding-BYF9ZTl9.cjs");function p(n,e=globalThis){const a=t=>{r.isReportWorkerRequest(t.data)&&r.runReportWorkerRequest(n,t.data,o=>e.postMessage({protocol:r.REPORT_WORKER_PROTOCOL,id:t.data.id,type:"event",event:o})).then(o=>e.postMessage(o,r.reportWorkerTransferList(o)))};return e.addEventListener("message",a),()=>e.removeEventListener("message",a)}exports.ReportWorkerError=r.ReportWorkerError;exports.ReportWorkerStartError=s.ReportWorkerStartError;exports.createAutoReportExporter=s.createAutoReportExporter;exports.createBrowserReportExecutor=s.createBrowserReportExecutor;exports.serveReportEncodingWorker=R.serveReportEncodingWorker;exports.serveReportWorker=p;
package/dist/worker.d.cts CHANGED
@@ -77,10 +77,15 @@ declare interface ComponentStyle {
77
77
  rotateDeg?: number;
78
78
  }
79
79
 
80
+ /** Small exports stay local; large exports use the supplied bundler/CSP-compatible Worker factory. */
81
+ export declare function createAutoReportExporter(options?: ReportExportExecutionOptions): ReportAutoExporter;
82
+
80
83
  /** factory 每次返回全新 Worker,例如 () => new Worker(new URL('./worker.ts', import.meta.url), {type:'module'})。 */
81
84
  export declare function createBrowserReportExecutor(factory: () => BrowserReportWorker, options?: ReportWorkerOptions): ReportRuntimeExecutor;
82
85
 
83
86
  declare interface GridCell {
87
+ /** Styled cell content; text remains a plain-text fallback. Imported rich cells are read-only. */
88
+ richParagraphs?: RichParagraph[];
84
89
  text?: string;
85
90
  rawText?: string;
86
91
  /** 原始值,仅供 Excel raw 模式消费;不参与预览、分页与 PDF 绘制。 */
@@ -104,6 +109,19 @@ declare interface GridCell {
104
109
  style?: ComponentStyle;
105
110
  }
106
111
 
112
+ /** Bounded binary image inspection shared by PDF, Excel and template import. No decoder is loaded. */
113
+ declare interface ImageMediaOptions {
114
+ maxImageBytes?: number;
115
+ maxTotalImageBytes?: number;
116
+ maxImages?: number;
117
+ /** Decoded pixels per unique image, default 16 million. */
118
+ maxImagePixels?: number;
119
+ /** Total decoded pixels for unique media, default 64 million. */
120
+ maxTotalImagePixels?: number;
121
+ /** Maximum source dimension, default 16384 pixels. */
122
+ maxImageDimension?: number;
123
+ }
124
+
107
125
  declare interface PlanComponent {
108
126
  /** Optional QR/barcode encoding configuration; no encoder is loaded by the core. */
109
127
  code?: CodeOptions;
@@ -197,6 +215,16 @@ declare interface RenderPlan {
197
215
  pages: PlanPage[];
198
216
  }
199
217
 
218
+ export declare interface ReportAutoExporter {
219
+ exportPrepared(input: ReportRuntimePreparedExportInput, localOverride?: ReportLocalExport): Promise<ReportAutoExportResult>;
220
+ cancel(): void;
221
+ dispose(): void;
222
+ }
223
+
224
+ export declare interface ReportAutoExportResult extends ReportRuntimeExportResult {
225
+ execution: ReportExportDecision;
226
+ }
227
+
200
228
  /** 可持久化的业务身份与计划坐标独立;权限及并发校验仍由业务服务器执行。 */
201
229
  declare interface ReportCellSource {
202
230
  /** Source identity across report occurrences; sharing must be explicitly declared. */
@@ -241,6 +269,40 @@ declare interface ReportDiagnostic {
241
269
  target?: ReportDataTarget;
242
270
  }
243
271
 
272
+ export declare interface ReportExportDecision {
273
+ mode: "local" | "worker";
274
+ reason: ReportExportDecisionReason;
275
+ /** Lower bounds: traversal stops as soon as isolation is warranted. No font or image hashing. */
276
+ estimate: {
277
+ pages: number;
278
+ cells: number;
279
+ bytes: number;
280
+ };
281
+ hardCancellation: boolean;
282
+ }
283
+
284
+ export declare type ReportExportDecisionReason = "small-task" | "threshold" | "scan-limit" | "explicit-local" | "explicit-worker" | "worker-unavailable" | "worker-start-failed" | "nonserializable-options";
285
+
286
+ export declare interface ReportExportExecutionOptions {
287
+ mode?: "auto" | "worker" | "local";
288
+ /** A fresh bundler-managed module Worker for every call; never a shared worker. */
289
+ workerFactory?: () => BrowserReportWorker;
290
+ thresholds?: ReportExportThresholds;
291
+ /** Auto only. Startup unavailability may use local; encoding failures never retry. */
292
+ fallback?: "local" | "error";
293
+ timeoutMs?: number;
294
+ budget?: ReportRuntimeBudget;
295
+ onDecision?: (decision: ReportExportDecision) => void;
296
+ }
297
+
298
+ export declare interface ReportExportThresholds {
299
+ cells?: number;
300
+ pages?: number;
301
+ bytes?: number;
302
+ }
303
+
304
+ export declare type ReportLocalExport = (input: ReportRuntimePreparedExportInput) => Promise<ReportRuntimeExportResult>;
305
+
244
306
  /** 报表参数定义(声明式,模板自描述参数面:渲染组件据此生成查询面板) */
245
307
  declare interface ReportParamDef {
246
308
  /** 参数名(传入 params,与数据集 SQL #{field} 绑定对应) */
@@ -305,6 +367,16 @@ declare interface ReportRuntime {
305
367
  exportPrepared(input: ReportRuntimePreparedExportInput): Promise<ReportRuntimeExportResult>;
306
368
  }
307
369
 
370
+ declare interface ReportRuntimeBudget {
371
+ maxRows?: number;
372
+ maxPages?: number;
373
+ maxCells?: number;
374
+ maxOutputBytes?: number;
375
+ /** Bound the plain JSON snapshot accepted by exportPrepared (default 64 MB). */
376
+ maxPreparedBytes?: number;
377
+ maxDurationMs?: number;
378
+ }
379
+
308
380
  /** 可用 worker_threads/进程/RPC 实现;接收可序列化请求,signal 由桥接层映射为取消消息。 */
309
381
  declare interface ReportRuntimeExecutor {
310
382
  /** Old custom executors may omit this; the runtime explicitly rejects unsupported prepared output. */
@@ -317,10 +389,11 @@ declare interface ReportRuntimeExportInput extends ReportRuntimeInput {
317
389
  format: "pdf" | "xlsx";
318
390
  /** strict 在编码前拒绝已识别的输出降级;默认保留诊断并继续。 */
319
391
  fidelity?: "warn" | "strict";
320
- xlsx?: {
392
+ xlsx?: ImageMediaOptions & {
321
393
  sheetMode?: "auto" | "pages" | "continuous";
322
394
  valueMode?: "text" | "raw";
323
395
  paperSize?: "auto" | "a3" | "a4" | "a5";
396
+ sheetName?: (sheetIndex: number) => string;
324
397
  };
325
398
  }
326
399
 
@@ -341,6 +414,8 @@ declare interface ReportRuntimeInput extends ReportTaskMonitoring {
341
414
  /** Encode an existing plan without querying providers or repaginating. */
342
415
  declare interface ReportRuntimePreparedExportInput extends ReportTaskMonitoring {
343
416
  prepared: PreparedReport;
417
+ /** verify checks font metric identity; preserve explicitly keeps existing geometry, with a diagnostic. Encoding fidelity is unchanged. */
418
+ layoutPolicy?: "verify" | "preserve";
344
419
  format: ReportRuntimeExportInput["format"];
345
420
  fidelity?: ReportRuntimeExportInput["fidelity"];
346
421
  pdf?: ReportPdfFontOptions;
@@ -397,6 +472,7 @@ export declare class ReportWorkerError extends Error {
397
472
 
398
473
  export declare interface ReportWorkerOptions {
399
474
  timeoutMs?: number;
475
+ budget?: ReportRuntimeBudget;
400
476
  }
401
477
 
402
478
  export declare interface ReportWorkerScope {
@@ -405,6 +481,11 @@ export declare interface ReportWorkerScope {
405
481
  removeEventListener(type: "message", listener: (event: MessageEvent) => void): void;
406
482
  }
407
483
 
484
+ export declare class ReportWorkerStartError extends Error {
485
+ readonly cause: unknown;
486
+ constructor(cause: unknown);
487
+ }
488
+
408
489
  declare interface RichParagraph {
409
490
  segments: RichSegment[];
410
491
  align?: ComponentStyle["align"];
@@ -430,6 +511,8 @@ declare interface SerializedReportError {
430
511
  diagnostics?: unknown;
431
512
  }
432
513
 
514
+ export declare function serveReportEncodingWorker(scope?: ReportWorkerScope): () => void;
515
+
433
516
  /** 在 Worker 入口注册一次 runtime;返回函数可清理监听器,浏览器主线程无需引入 Node。 */
434
517
  export declare function serveReportWorker(runtime: ReportRuntime, scope?: ReportWorkerScope): () => void;
435
518
 
package/dist/worker.d.ts CHANGED
@@ -77,10 +77,15 @@ declare interface ComponentStyle {
77
77
  rotateDeg?: number;
78
78
  }
79
79
 
80
+ /** Small exports stay local; large exports use the supplied bundler/CSP-compatible Worker factory. */
81
+ export declare function createAutoReportExporter(options?: ReportExportExecutionOptions): ReportAutoExporter;
82
+
80
83
  /** factory 每次返回全新 Worker,例如 () => new Worker(new URL('./worker.ts', import.meta.url), {type:'module'})。 */
81
84
  export declare function createBrowserReportExecutor(factory: () => BrowserReportWorker, options?: ReportWorkerOptions): ReportRuntimeExecutor;
82
85
 
83
86
  declare interface GridCell {
87
+ /** Styled cell content; text remains a plain-text fallback. Imported rich cells are read-only. */
88
+ richParagraphs?: RichParagraph[];
84
89
  text?: string;
85
90
  rawText?: string;
86
91
  /** 原始值,仅供 Excel raw 模式消费;不参与预览、分页与 PDF 绘制。 */
@@ -104,6 +109,19 @@ declare interface GridCell {
104
109
  style?: ComponentStyle;
105
110
  }
106
111
 
112
+ /** Bounded binary image inspection shared by PDF, Excel and template import. No decoder is loaded. */
113
+ declare interface ImageMediaOptions {
114
+ maxImageBytes?: number;
115
+ maxTotalImageBytes?: number;
116
+ maxImages?: number;
117
+ /** Decoded pixels per unique image, default 16 million. */
118
+ maxImagePixels?: number;
119
+ /** Total decoded pixels for unique media, default 64 million. */
120
+ maxTotalImagePixels?: number;
121
+ /** Maximum source dimension, default 16384 pixels. */
122
+ maxImageDimension?: number;
123
+ }
124
+
107
125
  declare interface PlanComponent {
108
126
  /** Optional QR/barcode encoding configuration; no encoder is loaded by the core. */
109
127
  code?: CodeOptions;
@@ -197,6 +215,16 @@ declare interface RenderPlan {
197
215
  pages: PlanPage[];
198
216
  }
199
217
 
218
+ export declare interface ReportAutoExporter {
219
+ exportPrepared(input: ReportRuntimePreparedExportInput, localOverride?: ReportLocalExport): Promise<ReportAutoExportResult>;
220
+ cancel(): void;
221
+ dispose(): void;
222
+ }
223
+
224
+ export declare interface ReportAutoExportResult extends ReportRuntimeExportResult {
225
+ execution: ReportExportDecision;
226
+ }
227
+
200
228
  /** 可持久化的业务身份与计划坐标独立;权限及并发校验仍由业务服务器执行。 */
201
229
  declare interface ReportCellSource {
202
230
  /** Source identity across report occurrences; sharing must be explicitly declared. */
@@ -241,6 +269,40 @@ declare interface ReportDiagnostic {
241
269
  target?: ReportDataTarget;
242
270
  }
243
271
 
272
+ export declare interface ReportExportDecision {
273
+ mode: "local" | "worker";
274
+ reason: ReportExportDecisionReason;
275
+ /** Lower bounds: traversal stops as soon as isolation is warranted. No font or image hashing. */
276
+ estimate: {
277
+ pages: number;
278
+ cells: number;
279
+ bytes: number;
280
+ };
281
+ hardCancellation: boolean;
282
+ }
283
+
284
+ export declare type ReportExportDecisionReason = "small-task" | "threshold" | "scan-limit" | "explicit-local" | "explicit-worker" | "worker-unavailable" | "worker-start-failed" | "nonserializable-options";
285
+
286
+ export declare interface ReportExportExecutionOptions {
287
+ mode?: "auto" | "worker" | "local";
288
+ /** A fresh bundler-managed module Worker for every call; never a shared worker. */
289
+ workerFactory?: () => BrowserReportWorker;
290
+ thresholds?: ReportExportThresholds;
291
+ /** Auto only. Startup unavailability may use local; encoding failures never retry. */
292
+ fallback?: "local" | "error";
293
+ timeoutMs?: number;
294
+ budget?: ReportRuntimeBudget;
295
+ onDecision?: (decision: ReportExportDecision) => void;
296
+ }
297
+
298
+ export declare interface ReportExportThresholds {
299
+ cells?: number;
300
+ pages?: number;
301
+ bytes?: number;
302
+ }
303
+
304
+ export declare type ReportLocalExport = (input: ReportRuntimePreparedExportInput) => Promise<ReportRuntimeExportResult>;
305
+
244
306
  /** 报表参数定义(声明式,模板自描述参数面:渲染组件据此生成查询面板) */
245
307
  declare interface ReportParamDef {
246
308
  /** 参数名(传入 params,与数据集 SQL #{field} 绑定对应) */
@@ -305,6 +367,16 @@ declare interface ReportRuntime {
305
367
  exportPrepared(input: ReportRuntimePreparedExportInput): Promise<ReportRuntimeExportResult>;
306
368
  }
307
369
 
370
+ declare interface ReportRuntimeBudget {
371
+ maxRows?: number;
372
+ maxPages?: number;
373
+ maxCells?: number;
374
+ maxOutputBytes?: number;
375
+ /** Bound the plain JSON snapshot accepted by exportPrepared (default 64 MB). */
376
+ maxPreparedBytes?: number;
377
+ maxDurationMs?: number;
378
+ }
379
+
308
380
  /** 可用 worker_threads/进程/RPC 实现;接收可序列化请求,signal 由桥接层映射为取消消息。 */
309
381
  declare interface ReportRuntimeExecutor {
310
382
  /** Old custom executors may omit this; the runtime explicitly rejects unsupported prepared output. */
@@ -317,10 +389,11 @@ declare interface ReportRuntimeExportInput extends ReportRuntimeInput {
317
389
  format: "pdf" | "xlsx";
318
390
  /** strict 在编码前拒绝已识别的输出降级;默认保留诊断并继续。 */
319
391
  fidelity?: "warn" | "strict";
320
- xlsx?: {
392
+ xlsx?: ImageMediaOptions & {
321
393
  sheetMode?: "auto" | "pages" | "continuous";
322
394
  valueMode?: "text" | "raw";
323
395
  paperSize?: "auto" | "a3" | "a4" | "a5";
396
+ sheetName?: (sheetIndex: number) => string;
324
397
  };
325
398
  }
326
399
 
@@ -341,6 +414,8 @@ declare interface ReportRuntimeInput extends ReportTaskMonitoring {
341
414
  /** Encode an existing plan without querying providers or repaginating. */
342
415
  declare interface ReportRuntimePreparedExportInput extends ReportTaskMonitoring {
343
416
  prepared: PreparedReport;
417
+ /** verify checks font metric identity; preserve explicitly keeps existing geometry, with a diagnostic. Encoding fidelity is unchanged. */
418
+ layoutPolicy?: "verify" | "preserve";
344
419
  format: ReportRuntimeExportInput["format"];
345
420
  fidelity?: ReportRuntimeExportInput["fidelity"];
346
421
  pdf?: ReportPdfFontOptions;
@@ -397,6 +472,7 @@ export declare class ReportWorkerError extends Error {
397
472
 
398
473
  export declare interface ReportWorkerOptions {
399
474
  timeoutMs?: number;
475
+ budget?: ReportRuntimeBudget;
400
476
  }
401
477
 
402
478
  export declare interface ReportWorkerScope {
@@ -405,6 +481,11 @@ export declare interface ReportWorkerScope {
405
481
  removeEventListener(type: "message", listener: (event: MessageEvent) => void): void;
406
482
  }
407
483
 
484
+ export declare class ReportWorkerStartError extends Error {
485
+ readonly cause: unknown;
486
+ constructor(cause: unknown);
487
+ }
488
+
408
489
  declare interface RichParagraph {
409
490
  segments: RichSegment[];
410
491
  align?: ComponentStyle["align"];
@@ -430,6 +511,8 @@ declare interface SerializedReportError {
430
511
  diagnostics?: unknown;
431
512
  }
432
513
 
514
+ export declare function serveReportEncodingWorker(scope?: ReportWorkerScope): () => void;
515
+
433
516
  /** 在 Worker 入口注册一次 runtime;返回函数可清理监听器,浏览器主线程无需引入 Node。 */
434
517
  export declare function serveReportWorker(runtime: ReportRuntime, scope?: ReportWorkerScope): () => void;
435
518
 
package/dist/worker.js CHANGED
@@ -1,163 +1,18 @@
1
- import { o as M } from "./json-snapshot-DFb2eWkf.js";
2
- import { d as W } from "./prepared-ajM-H-9B.js";
3
- import { h as A } from "./data-explanation-B8MZRYVS.js";
4
- import { a as L } from "./template-registry-BtaKPELV.js";
5
- const u = "mach-report-worker/1";
6
- class R extends Error {
7
- constructor(r) {
8
- super(r.message), this.name = r.name, this.code = r.code, this.path = r.path, this.issues = r.issues, this.diagnostics = r.diagnostics;
9
- }
10
- }
11
- function p(e) {
12
- return !!e && typeof e == "object" && !Array.isArray(e);
13
- }
14
- function T(e) {
15
- return p(e) ? ["rows", "pages", "cells"].every((r) => typeof e[r] == "number" && Number.isSafeInteger(e[r]) && e[r] >= 0) && typeof e.durationMs == "number" && Number.isFinite(e.durationMs) && e.durationMs >= 0 : !1;
16
- }
17
- function j(e) {
18
- return Array.isArray(e) && e.every((r) => p(r) && typeof r.code == "string" && typeof r.message == "string" && ["info", "warning", "error"].includes(r.severity) && A(r));
19
- }
20
- function O(e) {
21
- return p(e) && Object.values(e).every((r) => p(r) && (r.revision === void 0 || typeof r.revision == "string") && (r.sourceToken === void 0 || typeof r.sourceToken == "string"));
22
- }
23
- function F(e) {
24
- return e === void 0 ? !0 : p(e) && ["heuristic", "provided", "font-bytes"].includes(e.textMetrics) && (e.fontFingerprint === void 0 || typeof e.fontFingerprint == "string" && /^[a-f0-9]{64}$/.test(e.fontFingerprint));
25
- }
26
- function N(e, r) {
27
- if (!p(e) || !T(e.stats) || !j(e.diagnostics) || !O(e.revisions) || !F(e.layout) || !W(e.sources)) return !1;
28
- if (r === "prepare") return L(e.plan).ok;
29
- const t = e.format === "pdf" ? "application/pdf" : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
30
- return e.bytes instanceof Uint8Array && (e.format === "pdf" || e.format === "xlsx") && e.contentType === t;
31
- }
32
- function x(e) {
33
- if (!e || typeof e != "object") return { message: String(e) };
34
- const r = {};
35
- for (const t of ["code", "path", "field", "message"]) {
36
- const o = e[t];
37
- typeof o == "string" && (r[t] = o);
38
- }
39
- return r;
40
- }
41
- function S(e) {
42
- const r = x(e);
43
- if (!p(e)) return r;
44
- for (const t of ["format", "severity", "kind", "nid"]) typeof e[t] == "string" && (r[t] = e[t]);
45
- for (const t of ["pageIndex", "componentIndex"]) Number.isSafeInteger(e[t]) && e[t] >= 0 && (r[t] = e[t]);
46
- return Array.isArray(e.componentPath) && e.componentPath.every((t) => Number.isSafeInteger(t) && t >= 0) && (r.componentPath = e.componentPath), r;
47
- }
48
- function z(e) {
49
- if (!(e instanceof Error)) return { name: "Error", message: String(e) };
50
- const r = e;
51
- return {
52
- name: e.name,
53
- message: e.message,
54
- ...typeof r.code == "string" ? { code: r.code } : {},
55
- ...typeof r.path == "string" ? { path: r.path } : {},
56
- ...Array.isArray(r.issues) ? { issues: r.issues.map(x) } : {},
57
- ...Array.isArray(r.diagnostics) ? { diagnostics: r.diagnostics.map(S) } : {}
58
- };
59
- }
60
- function _(e) {
61
- if (!e || typeof e != "object") return !1;
62
- const r = e;
63
- return r.protocol === u && typeof r.id == "string" && (r.operation === "prepare" || r.operation === "export" || r.operation === "exportPrepared") && !!r.input && typeof r.input == "object";
64
- }
65
- async function $(e, r, t) {
66
- try {
67
- const o = r.operation === "prepare" ? await e.prepare({ ...r.input, onEvent: t }) : r.operation === "exportPrepared" ? await e.exportPrepared({ ...r.input, onEvent: t }) : await e.export({ ...r.input, onEvent: t });
68
- return { protocol: u, id: r.id, result: o };
69
- } catch (o) {
70
- return { protocol: u, id: r.id, error: z(o) };
71
- }
72
- }
73
- function D(e) {
74
- const r = e.result;
75
- return !r || !("bytes" in r) || !(r.bytes.buffer instanceof ArrayBuffer) ? [] : [r.bytes.buffer];
76
- }
77
- function B(e, r) {
78
- if (!p(e) || typeof e.taskId != "string" || !e.taskId || r.taskId !== void 0 && e.taskId !== r.taskId || e.correlationId !== r.correlationId || e.reportId !== void 0 && (typeof e.reportId != "string" || !("reportIds" in r && r.reportIds.includes(e.reportId))) || !["query", "validate", "layout", "assets", "encode"].includes(e.stage) || !["started", "completed", "failed"].includes(e.status)) return !1;
79
- for (const t of ["completed", "total"]) if (e[t] !== void 0 && (typeof e[t] != "number" || !Number.isFinite(e[t]) || e[t] < 0)) return !1;
80
- return e.completed === void 0 || e.total === void 0 || e.completed <= e.total;
81
- }
82
- let v = 0;
83
- function w(e) {
84
- const r = new Error("报表 Worker 任务已取消");
85
- return r.name = "AbortError", Object.defineProperty(r, "cause", { value: e }), r;
86
- }
87
- function C(e, r) {
88
- if (!e || typeof e != "object") return;
89
- const t = e;
90
- return t.protocol === u && t.id === r ? t : void 0;
91
- }
92
- function K(e, r = {}) {
93
- const t = r.timeoutMs ?? 12e4;
94
- if (!Number.isFinite(t) || t <= 0 || t > 2147483647) throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");
95
- const o = (s, a, n, d) => n?.aborted ? Promise.reject(w(n.reason)) : new Promise((I, b) => {
96
- let g;
97
- try {
98
- g = e();
99
- } catch (c) {
100
- b(c);
101
- return;
102
- }
103
- const l = `mach-report-${Date.now()}-${++v}`;
104
- let y = !1, E = () => {
105
- }, h;
106
- const f = (c, i) => {
107
- y || (y = !0, h && clearTimeout(h), E(), n?.removeEventListener("abort", k), Promise.resolve().then(() => g.terminate()).then(
108
- () => c === void 0 ? I(i) : b(c),
109
- (m) => b(c ?? m)
110
- ));
111
- }, k = () => f(w(n?.reason)), P = (c) => {
112
- const i = C(c, l);
113
- if (!(!i || y)) {
114
- if ("type" in i && i.type === "event") {
115
- const m = "event" in i ? i.event : void 0;
116
- B(m, a) ? M(d, m, n) : f(new Error("报表 Worker 返回无效阶段事件"));
117
- return;
118
- }
119
- i.error && typeof i.error.name == "string" && typeof i.error.message == "string" ? f(new R(i.error)) : N(i.result, s) && (s === "prepare" || "format" in i.result && "format" in a && i.result.format === a.format) ? f(void 0, i.result) : f(new Error("报表 Worker 返回无效响应"));
120
- }
121
- };
122
- try {
123
- if (E = g.subscribe(P, (c) => f(c ?? new Error("报表 Worker 执行失败"))), y) {
124
- E();
125
- return;
126
- }
127
- if (n?.addEventListener("abort", k, { once: !0 }), h = setTimeout(() => f(new R({ name: "ReportRuntimeError", code: "timeout", message: `报表 Worker 执行超过 ${t}ms` })), t), n?.aborted) k();
128
- else {
129
- const { onEvent: c, signal: i, ...m } = a;
130
- g.postMessage({ protocol: u, id: l, operation: s, input: m });
131
- }
132
- } catch (c) {
133
- f(c);
134
- }
135
- });
136
- return { exportPrepared: (s, a, n) => o("exportPrepared", s, a, n), prepare: (s, a, n) => o("prepare", s, a, n), export: (s, a, n) => o("export", s, a, n) };
137
- }
138
- function J(e, r = {}) {
139
- return K(() => {
140
- const t = e();
141
- return {
142
- postMessage: (o) => t.postMessage(o),
143
- terminate: () => t.terminate(),
144
- subscribe: (o, s) => {
145
- const a = (d) => o(d.data), n = (d) => s(d instanceof ErrorEvent ? new Error(d.message) : new Error("报表 Worker 消息无法解码"));
146
- return t.addEventListener("message", a), t.addEventListener("error", n), t.addEventListener("messageerror", n), () => {
147
- t.removeEventListener("message", a), t.removeEventListener("error", n), t.removeEventListener("messageerror", n);
148
- };
149
- }
150
- };
151
- }, r);
152
- }
153
- function Q(e, r = globalThis) {
1
+ import { i as a, r as R, R as p, a as n } from "./protocol-kt4Iy6-3.js";
2
+ import { b as W } from "./protocol-kt4Iy6-3.js";
3
+ import { R as g, c as k, a as u } from "./auto-YR7a4BtF.js";
4
+ import { s as x } from "./encoding-BOGq4qYL.js";
5
+ function d(s, r = globalThis) {
154
6
  const t = (o) => {
155
- _(o.data) && $(e, o.data, (s) => r.postMessage({ protocol: u, id: o.data.id, type: "event", event: s })).then((s) => r.postMessage(s, D(s)));
7
+ a(o.data) && R(s, o.data, (e) => r.postMessage({ protocol: p, id: o.data.id, type: "event", event: e })).then((e) => r.postMessage(e, n(e)));
156
8
  };
157
9
  return r.addEventListener("message", t), () => r.removeEventListener("message", t);
158
10
  }
159
11
  export {
160
- R as ReportWorkerError,
161
- J as createBrowserReportExecutor,
162
- Q as serveReportWorker
12
+ W as ReportWorkerError,
13
+ g as ReportWorkerStartError,
14
+ k as createAutoReportExporter,
15
+ u as createBrowserReportExecutor,
16
+ x as serveReportEncodingWorker,
17
+ d as serveReportWorker
163
18
  };