@agile-team/mach-report 2.14.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.
- package/README.md +16 -11
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/dist/{ExcelBindingWizard-CvsWR8Ga.js → ExcelBindingWizard-BKH1nGNS.js} +3 -3
- package/dist/{ExcelBindingWizard-CLT2p7P3.cjs → ExcelBindingWizard-Bs43BGNp.cjs} +1 -1
- package/dist/ParamEditor-Da4akw6V.cjs +1 -0
- package/dist/ParamEditor-DoAhzJsm.js +594 -0
- package/dist/{ReportBatchPanel-LqVgiqp7.js → ReportBatchPanel-BMf6boMA.js} +39 -39
- package/dist/{ReportBatchPanel-DkxTzBkD.cjs → ReportBatchPanel-wP9m9Pj1.cjs} +1 -1
- package/dist/ReportPreview-ChV19HBp.js +4619 -0
- package/dist/ReportPreview-DbLvvOUT.cjs +6 -0
- package/dist/{ReportTemplateLibrary-MjWEtc7X.js → ReportTemplateLibrary-C9wutIiT.js} +1 -1
- package/dist/{ReportTemplateLibrary-cQ1sqNYo.cjs → ReportTemplateLibrary-Sxr3eD0J.cjs} +1 -1
- package/dist/{RuleEditor-ChuXMlei.js → RuleEditor-C_Clasvd.js} +5 -5
- package/dist/{RuleEditor-BaR6xUiI.cjs → RuleEditor-XhGHK8DE.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-Dci6aRn1.js → TemplateOutlinePanel-D6Bkny59.js} +2 -2
- package/dist/{TemplateOutlinePanel-BHKP89Xz.cjs → TemplateOutlinePanel-JTSR53vJ.cjs} +1 -1
- package/dist/{TemplateReusePanel-CY5eO2Sh.cjs → TemplateReusePanel-Kx35S0Ql.cjs} +1 -1
- package/dist/{TemplateReusePanel-B7Gmyc1z.js → TemplateReusePanel-rVuK1kTz.js} +2 -2
- package/dist/{TemplateReviewPanel-DjlX3xpt.js → TemplateReviewPanel-B0ar9_zf.js} +2 -2
- package/dist/{TemplateReviewPanel-JvZe9_4G.cjs → TemplateReviewPanel-Dn6X9UmY.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.d.cts +3 -1
- package/dist/analytics.d.ts +3 -1
- package/dist/analytics.js +154 -60
- package/dist/artifact-integrity.json +135 -0
- package/dist/assets-B9ImAi6_.cjs +1 -0
- package/dist/assets-DEaz4qsp.js +124 -0
- package/dist/batch-BaP6pWDE.cjs +1 -0
- package/dist/batch-BfZHN1do.js +220 -0
- package/dist/batch-CGyt-b2W.js +273 -0
- package/dist/batch-CLpELXBl.cjs +1 -0
- package/dist/capabilities-CAh2Nrue.cjs +1 -0
- package/dist/capabilities-DskCHs3V.js +69 -0
- package/dist/codes.d.cts +2 -0
- package/dist/codes.d.ts +2 -0
- package/dist/{computed-Bvk0W15F.js → computed-C-4C2S5h.js} +3 -3
- package/dist/config-BVsJXSqS.js +842 -0
- package/dist/config-D10us76d.cjs +1 -0
- package/dist/data-explanation-B8MZRYVS.js +16 -0
- package/dist/data-explanation-DE55G30w.cjs +1 -0
- package/dist/designer-2bDlcNXQ.js +5136 -0
- package/dist/designer-BT7XCdbW.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +144 -16
- package/dist/designer.d.ts +144 -16
- package/dist/designer.js +1 -1
- package/dist/drill-ByJviLXS.js +145 -0
- package/dist/drill-DYTxuL3A.cjs +1 -0
- package/dist/{font-loader-vhCT8znW.cjs → font-loader-B_UkxpzC.cjs} +1 -1
- package/dist/{font-loader-DHto6Lra.js → font-loader-Q3bQjmrI.js} +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +82 -4
- package/dist/index.d.ts +82 -4
- package/dist/index.js +785 -820
- package/dist/json-snapshot-DFb2eWkf.js +1416 -0
- package/dist/json-snapshot-WWSGlaHG.cjs +2 -0
- package/dist/licenses/_bwip-js_generic-4.11.4.txt +24 -0
- package/dist/licenses/_fast-csv_format-4.3.5.txt +22 -0
- package/dist/licenses/_fast-csv_parse-4.3.6.txt +22 -0
- package/dist/licenses/_pdf-lib_fontkit-1.1.1.txt +326 -0
- package/dist/licenses/_pdf-lib_standard-fonts-1.0.0.txt +22 -0
- package/dist/licenses/_pdf-lib_upng-1.0.1.txt +22 -0
- package/dist/licenses/_types_node-14.18.63.txt +22 -0
- package/dist/licenses/_types_pako-2.0.3.txt +22 -0
- package/dist/licenses/_types_pegjs-0.10.6.txt +22 -0
- package/dist/licenses/archiver-5.3.2.txt +23 -0
- package/dist/licenses/archiver-utils-2.1.0.txt +23 -0
- package/dist/licenses/archiver-utils-3.0.4.txt +23 -0
- package/dist/licenses/async-3.2.6.txt +20 -0
- package/dist/licenses/balanced-match-1.0.2.txt +22 -0
- package/dist/licenses/base64-js-1.5.1.txt +22 -0
- package/dist/licenses/big-integer-1.6.52.txt +25 -0
- package/dist/licenses/binary-0.3.0.txt +178 -0
- package/dist/licenses/bl-4.1.0.txt +14 -0
- package/dist/licenses/bluebird-3.4.7.txt +22 -0
- package/dist/licenses/brace-expansion-1.1.21.txt +22 -0
- package/dist/licenses/brace-expansion-2.1.7.txt +22 -0
- package/dist/licenses/buffer-5.7.1.txt +22 -0
- package/dist/licenses/buffer-crc32-0.2.13.txt +20 -0
- package/dist/licenses/buffer-indexof-polyfill-1.0.2.txt +23 -0
- package/dist/licenses/buffers-0.1.1.txt +140 -0
- package/dist/licenses/chainsaw-0.1.0.txt +184 -0
- package/dist/licenses/compress-commons-4.1.2.txt +23 -0
- package/dist/licenses/concat-map-0.0.1.txt +19 -0
- package/dist/licenses/core-util-is-1.0.3.txt +20 -0
- package/dist/licenses/crc-32-1.2.2.txt +202 -0
- package/dist/licenses/crc32-stream-4.0.3.txt +23 -0
- package/dist/licenses/dayjs-1.11.23.txt +22 -0
- package/dist/licenses/duplexer2-0.1.4.txt +27 -0
- package/dist/licenses/end-of-stream-1.4.5.txt +22 -0
- package/dist/licenses/exceljs-4.4.0.txt +23 -0
- package/dist/licenses/fast-csv-4.3.6.txt +22 -0
- package/dist/licenses/fast-png-6.4.0.txt +22 -0
- package/dist/licenses/fs-constants-1.0.0.txt +22 -0
- package/dist/licenses/fs.realpath-1.0.0.txt +44 -0
- package/dist/licenses/fstream-1.0.12.txt +16 -0
- package/dist/licenses/glob-7.2.3.txt +22 -0
- package/dist/licenses/graceful-fs-4.2.11.txt +16 -0
- package/dist/licenses/ieee754-1.2.1.txt +12 -0
- package/dist/licenses/immediate-3.0.6.txt +21 -0
- package/dist/licenses/inflight-1.0.6.txt +16 -0
- package/dist/licenses/inherits-2.0.4.txt +17 -0
- package/dist/licenses/iobuffer-5.4.0.txt +23 -0
- package/dist/licenses/isarray-1.0.0.txt +61 -0
- package/dist/licenses/jszip-3.10.2.txt +652 -0
- package/dist/licenses/lazystream-1.0.1.txt +24 -0
- package/dist/licenses/lie-3.3.0.txt +8 -0
- package/dist/licenses/listenercount-1.0.1.txt +6 -0
- package/dist/licenses/lodash.defaults-4.2.0.txt +48 -0
- package/dist/licenses/lodash.difference-4.5.0.txt +48 -0
- package/dist/licenses/lodash.escaperegexp-4.1.2.txt +48 -0
- package/dist/licenses/lodash.flatten-4.4.0.txt +48 -0
- package/dist/licenses/lodash.groupby-4.6.0.txt +48 -0
- package/dist/licenses/lodash.isboolean-3.0.3.txt +23 -0
- package/dist/licenses/lodash.isequal-4.5.0.txt +48 -0
- package/dist/licenses/lodash.isfunction-3.0.9.txt +48 -0
- package/dist/licenses/lodash.isnil-4.0.0.txt +23 -0
- package/dist/licenses/lodash.isplainobject-4.0.6.txt +48 -0
- package/dist/licenses/lodash.isundefined-3.0.1.txt +23 -0
- package/dist/licenses/lodash.union-4.6.0.txt +48 -0
- package/dist/licenses/lodash.uniq-4.5.0.txt +48 -0
- package/dist/licenses/minimatch-3.1.5.txt +16 -0
- package/dist/licenses/minimatch-5.1.9.txt +16 -0
- package/dist/licenses/minimist-1.2.8.txt +19 -0
- package/dist/licenses/mkdirp-0.5.6.txt +22 -0
- package/dist/licenses/node-sql-parser-5.4.0.txt +202 -0
- package/dist/licenses/normalize-path-3.0.0.txt +22 -0
- package/dist/licenses/once-1.4.0.txt +16 -0
- package/dist/licenses/pako-1.0.11.txt +22 -0
- package/dist/licenses/pako-2.2.0.txt +22 -0
- package/dist/licenses/path-is-absolute-1.0.1.txt +22 -0
- package/dist/licenses/pdf-lib-1.17.1.txt +22 -0
- package/dist/licenses/process-nextick-args-2.0.1.txt +20 -0
- package/dist/licenses/readable-stream-2.3.8.txt +48 -0
- package/dist/licenses/readable-stream-3.6.2.txt +48 -0
- package/dist/licenses/readdir-glob-1.1.3.txt +202 -0
- package/dist/licenses/rimraf-2.7.1.txt +16 -0
- package/dist/licenses/safe-buffer-5.1.2.txt +22 -0
- package/dist/licenses/safe-buffer-5.2.1.txt +22 -0
- package/dist/licenses/saxes-5.0.1.txt +397 -0
- package/dist/licenses/setimmediate-1.0.5.txt +21 -0
- package/dist/licenses/string_decoder-1.1.1.txt +49 -0
- package/dist/licenses/string_decoder-1.3.0.txt +49 -0
- package/dist/licenses/tar-stream-2.2.0.txt +22 -0
- package/dist/licenses/tmp-0.2.7.txt +22 -0
- package/dist/licenses/traverse-0.3.9.txt +25 -0
- package/dist/licenses/tslib-1.14.1.txt +13 -0
- package/dist/licenses/unzipper-0.10.14.txt +26 -0
- package/dist/licenses/util-deprecate-1.0.2.txt +25 -0
- package/dist/licenses/uuid-11.1.1.txt +10 -0
- package/dist/licenses/wrappy-1.0.2.txt +16 -0
- package/dist/licenses/xmlchars-2.2.0.txt +19 -0
- package/dist/licenses/zip-stream-4.1.1.txt +23 -0
- package/dist/matrix-CGRGkn5s.js +112 -0
- package/dist/matrix-gEO7ZM_u.cjs +1 -0
- package/dist/media-B7vnpD8k.cjs +1 -0
- package/dist/media-Y90dHK9z.js +70 -0
- package/dist/param-validation-C3HlcLLO.cjs +1 -0
- package/dist/param-validation-Do7Eg8Zv.js +181 -0
- package/dist/{pdf-8UPQebOE.js → pdf-BwNyeGpt.js} +4385 -4321
- package/dist/{pdf-AyJGb22z.cjs → pdf-CvvrjPQg.cjs} +51 -49
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +18 -3
- package/dist/pdf.d.ts +18 -3
- package/dist/pdf.js +2 -2
- package/dist/{plugin-BGKf-Tqg.js → plugin-Ca_XZG3l.js} +2 -2
- package/dist/{plugin-CktLH_Iy.cjs → plugin-DHO7X8z2.cjs} +1 -1
- package/dist/prepared-CFy9B75C.cjs +1 -0
- package/dist/prepared-ajM-H-9B.js +69 -0
- package/dist/progress-B0ctFpKf.cjs +1 -0
- package/dist/progress-D-OTpEav.js +52 -0
- package/dist/record-bindings-By_UKZ2g.cjs +1 -0
- package/dist/record-bindings-Do_b3h4V.js +196 -0
- package/dist/{region-binding-workflow-DEJbhpCv.js → region-binding-workflow-BMhK_TjP.js} +1 -1
- package/dist/{region-binding-workflow-BzfbxRiR.cjs → region-binding-workflow-DIYJdCUr.cjs} +1 -1
- package/dist/{report-params-B44imUd4.js → report-params-B1RzkhJj.js} +1 -1
- package/dist/{report-params-SJfhKgaX.cjs → report-params-WDGrA4oP.cjs} +1 -1
- package/dist/sbom.cdx.json +3982 -0
- package/dist/server/node.d.cts +20 -1
- package/dist/server/node.d.ts +20 -1
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +247 -237
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +772 -4
- package/dist/server.d.ts +772 -4
- package/dist/server.js +885 -645
- package/dist/sha256-ArEYjaTI.cjs +1 -0
- package/dist/sha256-DPEuJ3nh.js +155 -0
- package/dist/style.css +1 -1
- package/dist/template-bindings-C2SpvsMU.js +58 -0
- package/dist/template-bindings-CEtWyiLX.cjs +1 -0
- package/dist/template-catalog-FJE_c9Qe.cjs +1 -0
- package/dist/template-catalog-j2B1MJlL.js +414 -0
- package/dist/{template-fragments-CLkGo6To.js → template-fragments-BGbQLGlV.js} +21 -21
- package/dist/{template-fragments-DFUpq5QM.cjs → template-fragments-DcKeiylI.cjs} +1 -1
- package/dist/{template-outline-B3xVkzSv.cjs → template-outline-BwRV_eRo.cjs} +1 -1
- package/dist/{template-outline-CFenM1PV.js → template-outline-cnWfT_LK.js} +3 -3
- package/dist/{template-registry-COXDEJEM.js → template-registry-BtaKPELV.js} +364 -201
- package/dist/template-registry-Co1zPq5e.cjs +1 -0
- package/dist/textwrap-CWHyzkBH.cjs +4 -0
- package/dist/textwrap-DE1kgcJB.js +110 -0
- package/dist/{tree-CqcQ99NM.js → tree-CjVZLRw7.js} +1 -1
- package/dist/vue/async.d.cts +123 -14
- package/dist/vue/async.d.ts +123 -14
- package/dist/vue/index.d.cts +158 -22
- package/dist/vue/index.d.ts +158 -22
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +80 -78
- package/dist/{workbook-session-DNa2RHNG.cjs → workbook-session-Bjv1YCRK.cjs} +18 -18
- package/dist/{workbook-session-BfK1yHOO.js → workbook-session-BvToI-Fd.js} +5440 -5288
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +20 -1
- package/dist/worker.d.ts +20 -1
- package/dist/worker.js +33 -32
- package/dist/xlsx-node.cjs +34 -34
- package/dist/xlsx-node.js +878 -870
- package/dist/xlsx.cjs +3 -4
- package/dist/xlsx.d.cts +22 -10
- package/dist/xlsx.d.ts +22 -10
- package/dist/xlsx.js +261 -253
- package/package.json +2 -2
- package/dist/ParamEditor-CflQV3eQ.js +0 -526
- package/dist/ParamEditor-vIDzvpPV.cjs +0 -1
- package/dist/ReportPreview-CvbqLUzM.cjs +0 -6
- package/dist/ReportPreview-D_ywJ_-H.js +0 -4533
- package/dist/assets-C2U-e-Sz.cjs +0 -4
- package/dist/assets-Q0wUwNrV.js +0 -217
- package/dist/batch-DzaTNLWI.js +0 -371
- package/dist/batch-xMkqYiTr.cjs +0 -1
- package/dist/capabilities-CK_7hizc.js +0 -63
- package/dist/capabilities-CsZ-pNHR.cjs +0 -1
- package/dist/config-0UIohTS7.cjs +0 -1
- package/dist/config-Dt9NtCPl.js +0 -566
- package/dist/data-explanation-BktvER5B.cjs +0 -1
- package/dist/data-explanation-C_J6jYNi.js +0 -16
- package/dist/designer-Ci1LizA9.js +0 -5020
- package/dist/designer-rtmVIIdN.cjs +0 -2
- package/dist/json-snapshot-BeFT3Tso.js +0 -1952
- package/dist/json-snapshot-D1NTP2oI.cjs +0 -2
- package/dist/matrix-DVyWiYsd.cjs +0 -1
- package/dist/matrix-yZsGnldA.js +0 -227
- package/dist/page-window-index-CIuT4BAv.js +0 -43
- package/dist/page-window-index-DEjnM6IB.cjs +0 -1
- package/dist/param-validation-BlHHXs6u.js +0 -153
- package/dist/param-validation-DCK039V1.cjs +0 -1
- package/dist/progress-7OSZbFok.js +0 -39
- package/dist/progress-BnLiS5eH.cjs +0 -1
- package/dist/task-events-DQ276fn2.cjs +0 -1
- package/dist/task-events-Dpsvf_t2.js +0 -47
- package/dist/template-bindings-BJR4k7qZ.cjs +0 -1
- package/dist/template-bindings-Daui7hLF.js +0 -252
- package/dist/template-registry-D3SjENi6.cjs +0 -1
- package/dist/validate-BJ5HIWY8.cjs +0 -1
- package/dist/validate-CkQBWCeg.js +0 -163
package/dist/assets-C2U-e-Sz.cjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";const I=require("./defaults-xhmcLLrf.cjs"),b=require("./capabilities-CsZ-pNHR.cjs"),v=require("./progress-BnLiS5eH.cjs"),x=/[\u3000-\u9fff\uff00-\uffef]/,m=new Uint8Array(128);{for(const e of"iljtf.,:;'`|!()[]")m[e.charCodeAt(0)]=1;for(const e of"mwMW@")m[e.charCodeAt(0)]=2;for(let e=48;e<=57;e++)m[e]=3;for(let e=65;e<=90;e++)m[e]=4;m[32]=5}const E=[.54,.26,.95,.59,.67,.3];function M(e){const t=e.charCodeAt(0);return t<128?E[m[t]]:x.test(e)?1:/[A-Z]/.test(e)?.67:.54}const h={measureMm(e,t){const{fontSizePt:r,bold:s=!1,letterSpacingPt:a=0}=t,n=25.4/72;let i=0;for(const u of e)i+=M(u);return s&&(i*=1.04),(i*r+a*Math.max(0,Array.from(e).length-1))*n}};function T(){return h}function k(e,t){return h.measureMm(e,t)}function D(e){let t;return{measureMm(r,s){if(t===void 0&&(t=e()),!t)return h.measureMm(r,s);const a=s.fontSizePt*96/72;t.font=`${s.italic?"italic ":""}${s.bold?"bold ":""}${a}px ${s.fontFamily??I.DEFAULT_FONT_FAMILY}`,"letterSpacing"in t&&(t.letterSpacing="0px");const n=(s.letterSpacingPt??0)*Math.max(0,Array.from(r).length-1);return t.measureText(r).width*25.4/96+n*25.4/72}}}function O(e,t,r){const s=[];let a="";const n=()=>{a&&(s.push({text:a,widthMm:r.measureMm(a,t),cjk:!1}),a="")};for(const i of e){if(i===`
|
|
2
|
-
`){n(),s.push({text:`
|
|
3
|
-
`,widthMm:0,cjk:!1,br:!0});continue}if(i===" "){n(),s.push({text:i,widthMm:r.measureMm(i,t),cjk:!1,space:!0});continue}if(x.test(i)){n(),s.push({text:i,widthMm:r.measureMm(i,t),cjk:!0});continue}a+=i}return n(),s}function P(e,t,r,s=h){if(!e)return[""];e=e.replace(/\r\n?/g,`
|
|
4
|
-
`);const a=[];let n="",i=0;const u=(r.letterSpacingPt??0)*25.4/72,c=()=>{a.push(n),n="",i=0};for(const o of O(e,r,s)){if(o.br){c();continue}const f=n.length>0?u:0;if(i+f+o.widthMm<=t){n+=o.text,i+=f+o.widthMm;continue}if(o.space){c();continue}if(o.cjk){n.length>0&&c(),n=o.text,i=o.widthMm;continue}if(n.length>0&&c(),o.widthMm<=t){n=o.text,i=o.widthMm;continue}for(const d of o.text)s.measureMm(n+d,r)>t&&n.length>0&&c(),n+=d,i=s.measureMm(n,r)}return c(),a}class w extends Error{constructor(t,r){super(t.message),this.name="OutputAssetError",this.diagnostic=t,this.cause=r}}function p(e){if(e.aborted)throw e.reason??new DOMException("The operation was aborted.","AbortError")}function C(e){const t={maxAssets:1e3,maxImageBytes:33554432,maxTotalImageBytes:134217728,maxDurationMs:3e4,...e.assetBudget};for(const[r,s]of Object.entries(t))if(!Number.isSafeInteger(s)||s<=0||s>2147483647)throw new RangeError(`${r} must be a positive safe integer at most 2147483647.`);return t}function S(e){const t=/^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(e);if(!t)throw new TypeError("Asset renderers must return an image data URL.");return t[1]?Math.ceil(t[2].length*3/4):new TextEncoder().encode(decodeURIComponent(t[2])).byteLength}function l(e,t,r,s,a){const n={code:r,message:s,severity:"warning",format:e.options.format??"dom",pageIndex:t.pageIndex,componentIndex:t.componentIndex,componentPath:t.componentPath,kind:t.component.kind,nid:t.component.nid};if(e.diagnostics.push(n),b.notifyOutputDiagnostic(n,{...e.options,signal:e.signal}),e.options.assetFailure!=="placeholder")throw new w(n,a)}async function L(e,t,r){const s=e.options.assetRenderers?.[t.kind];if(t.imageData||!s)return t.imageData;if(++e.rendered>e.budget.maxAssets)return l(e,r,"asset-budget-exceeded","Output exceeded the asset count budget.");let a;try{if(e.active=r,a=await v.waitForOutput(s({...r,signal:e.signal}),e.signal),p(e.signal),a.length>e.budget.maxImageBytes*4+1024)return l(e,r,"asset-budget-exceeded","Output exceeded the image payload byte budget.");const n=S(a);if(n>e.budget.maxImageBytes||e.bytes+n>e.budget.maxTotalImageBytes)return l(e,r,"asset-budget-exceeded","Output exceeded the encoded image byte budget.");e.bytes+=n}catch(n){if(e.signal.aborted||n instanceof w)throw n;return l(e,r,"asset-render-failed",`Asset renderer failed for ${t.kind}; output was not silently omitted.`,n)}return a}function j(e,t){const r=e.active;if(!r){t.abort(new Error("Asset rendering exceeded maxDurationMs."));return}const s={code:"asset-budget-exceeded",message:"Asset rendering exceeded maxDurationMs.",severity:"warning",format:e.options.format??"dom",pageIndex:r.pageIndex,componentIndex:r.componentIndex,componentPath:r.componentPath,kind:r.component.kind,nid:r.component.nid};e.diagnostics.push(s);try{b.notifyOutputDiagnostic(s,{...e.options,signal:e.signal})}catch(a){t.abort(a);return}t.abort(new w(s))}async function B(e,t,r,s,a){if(!t?.children?.length)return t;const n=[];for(const[i,u]of t.children.entries())n.push(await y(e,u,{...r,component:u,componentPath:[...s,i]},a));return n.some((i,u)=>i!==t.children[u])?{...t,children:n}:t}async function y(e,t,r,s){if(p(e.signal),s.has(t))throw new TypeError("Cyclic grid children cannot be rendered.");let a=e.cache.get(t);a||(a=L(e,t,r),e.cache.set(t,a));const n=await a;p(e.signal);let i=t.grid;if(i){const u=new Set(s).add(t),c=[];for(const[o,f]of i.cells.entries()){const d=[];for(const[g,A]of f.entries())d.push(await B(e,A,r,[...r.componentPath,o,g],u));c.push(d)}c.some((o,f)=>o.some((d,g)=>d!==i.cells[f][g]))&&(i={...i,cells:c})}return n!==t.imageData||i!==t.grid?{...t,imageData:n,grid:i}:t}async function R(e,t={}){const r=C(t);if(t.signal?.aborted)throw t.signal.reason??new DOMException("The operation was aborted.","AbortError");const s=new AbortController,a=()=>s.abort(t.signal?.reason);if(t.signal?.addEventListener("abort",a,{once:!0}),!t.assetRenderers||!Object.keys(t.assetRenderers).length)return t.signal?.removeEventListener("abort",a),{plan:e,diagnostics:[]};const n={options:t,signal:s.signal,diagnostics:[],rendered:0,bytes:0,budget:r,cache:new WeakMap},i=setTimeout(()=>j(n,s),r.maxDurationMs);try{const u=[];for(const[c,o]of e.pages.entries()){if(c<(t.start??0)||c>(t.end??e.pages.length-1)){u.push(o);continue}const f=[];for(const[d,g]of o.components.entries())f.push(await y(n,g,{component:g,pageIndex:c,componentIndex:d,componentPath:[]},new Set));u.push(f.some((d,g)=>d!==o.components[g])?{...o,components:f}:o)}return p(n.signal),{plan:u.some((c,o)=>c!==e.pages[o])?{...e,pages:u}:e,diagnostics:n.diagnostics}}finally{clearTimeout(i),t.signal?.removeEventListener("abort",a)}}exports.OutputAssetError=w;exports.charWidthEm=M;exports.createCanvasMeasurer=D;exports.createHeuristicMeasurer=T;exports.heuristicMeasurer=h;exports.measureTextMm=k;exports.resolvePlanAssets=R;exports.wrapText=P;
|
package/dist/assets-Q0wUwNrV.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { D as A } from "./defaults-DXhiM1ZD.js";
|
|
2
|
-
import { n as b } from "./capabilities-CK_7hizc.js";
|
|
3
|
-
import { w as I } from "./progress-7OSZbFok.js";
|
|
4
|
-
const x = /[\u3000-\u9fff\uff00-\uffef]/, g = new Uint8Array(128);
|
|
5
|
-
{
|
|
6
|
-
for (const e of "iljtf.,:;'`|!()[]") g[e.charCodeAt(0)] = 1;
|
|
7
|
-
for (const e of "mwMW@") g[e.charCodeAt(0)] = 2;
|
|
8
|
-
for (let e = 48; e <= 57; e++) g[e] = 3;
|
|
9
|
-
for (let e = 65; e <= 90; e++) g[e] = 4;
|
|
10
|
-
g[32] = 5;
|
|
11
|
-
}
|
|
12
|
-
const v = [0.54, 0.26, 0.95, 0.59, 0.67, 0.3];
|
|
13
|
-
function E(e) {
|
|
14
|
-
const t = e.charCodeAt(0);
|
|
15
|
-
return t < 128 ? v[g[t]] : x.test(e) ? 1 : /[A-Z]/.test(e) ? 0.67 : 0.54;
|
|
16
|
-
}
|
|
17
|
-
const p = {
|
|
18
|
-
measureMm(e, t) {
|
|
19
|
-
const { fontSizePt: r, bold: s = !1, letterSpacingPt: a = 0 } = t, n = 25.4 / 72;
|
|
20
|
-
let i = 0;
|
|
21
|
-
for (const d of e)
|
|
22
|
-
i += E(d);
|
|
23
|
-
return s && (i *= 1.04), (i * r + a * Math.max(0, Array.from(e).length - 1)) * n;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
function B() {
|
|
27
|
-
return p;
|
|
28
|
-
}
|
|
29
|
-
function R(e, t) {
|
|
30
|
-
return p.measureMm(e, t);
|
|
31
|
-
}
|
|
32
|
-
function $(e) {
|
|
33
|
-
let t;
|
|
34
|
-
return {
|
|
35
|
-
measureMm(r, s) {
|
|
36
|
-
if (t === void 0 && (t = e()), !t) return p.measureMm(r, s);
|
|
37
|
-
const a = s.fontSizePt * 96 / 72;
|
|
38
|
-
t.font = `${s.italic ? "italic " : ""}${s.bold ? "bold " : ""}${a}px ${s.fontFamily ?? A}`, "letterSpacing" in t && (t.letterSpacing = "0px");
|
|
39
|
-
const n = (s.letterSpacingPt ?? 0) * Math.max(0, Array.from(r).length - 1);
|
|
40
|
-
return t.measureText(r).width * 25.4 / 96 + n * 25.4 / 72;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function T(e, t, r) {
|
|
45
|
-
const s = [];
|
|
46
|
-
let a = "";
|
|
47
|
-
const n = () => {
|
|
48
|
-
a && (s.push({ text: a, widthMm: r.measureMm(a, t), cjk: !1 }), a = "");
|
|
49
|
-
};
|
|
50
|
-
for (const i of e) {
|
|
51
|
-
if (i === `
|
|
52
|
-
`) {
|
|
53
|
-
n(), s.push({ text: `
|
|
54
|
-
`, widthMm: 0, cjk: !1, br: !0 });
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (i === " ") {
|
|
58
|
-
n(), s.push({ text: i, widthMm: r.measureMm(i, t), cjk: !1, space: !0 });
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
if (x.test(i)) {
|
|
62
|
-
n(), s.push({ text: i, widthMm: r.measureMm(i, t), cjk: !0 });
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
a += i;
|
|
66
|
-
}
|
|
67
|
-
return n(), s;
|
|
68
|
-
}
|
|
69
|
-
function F(e, t, r, s = p) {
|
|
70
|
-
if (!e) return [""];
|
|
71
|
-
e = e.replace(/\r\n?/g, `
|
|
72
|
-
`);
|
|
73
|
-
const a = [];
|
|
74
|
-
let n = "", i = 0;
|
|
75
|
-
const d = (r.letterSpacingPt ?? 0) * 25.4 / 72, c = () => {
|
|
76
|
-
a.push(n), n = "", i = 0;
|
|
77
|
-
};
|
|
78
|
-
for (const o of T(e, r, s)) {
|
|
79
|
-
if (o.br) {
|
|
80
|
-
c();
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
const f = n.length > 0 ? d : 0;
|
|
84
|
-
if (i + f + o.widthMm <= t) {
|
|
85
|
-
n += o.text, i += f + o.widthMm;
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (o.space) {
|
|
89
|
-
c();
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (o.cjk) {
|
|
93
|
-
n.length > 0 && c(), n = o.text, i = o.widthMm;
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (n.length > 0 && c(), o.widthMm <= t) {
|
|
97
|
-
n = o.text, i = o.widthMm;
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
for (const u of o.text)
|
|
101
|
-
s.measureMm(n + u, r) > t && n.length > 0 && c(), n += u, i = s.measureMm(n, r);
|
|
102
|
-
}
|
|
103
|
-
return c(), a;
|
|
104
|
-
}
|
|
105
|
-
class w extends Error {
|
|
106
|
-
constructor(t, r) {
|
|
107
|
-
super(t.message), this.name = "OutputAssetError", this.diagnostic = t, this.cause = r;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function l(e) {
|
|
111
|
-
if (e.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
112
|
-
}
|
|
113
|
-
function k(e) {
|
|
114
|
-
const t = { maxAssets: 1e3, maxImageBytes: 33554432, maxTotalImageBytes: 134217728, maxDurationMs: 3e4, ...e.assetBudget };
|
|
115
|
-
for (const [r, s] of Object.entries(t))
|
|
116
|
-
if (!Number.isSafeInteger(s) || s <= 0 || s > 2147483647) throw new RangeError(`${r} must be a positive safe integer at most 2147483647.`);
|
|
117
|
-
return t;
|
|
118
|
-
}
|
|
119
|
-
function D(e) {
|
|
120
|
-
const t = /^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(e);
|
|
121
|
-
if (!t) throw new TypeError("Asset renderers must return an image data URL.");
|
|
122
|
-
return t[1] ? Math.ceil(t[2].length * 3 / 4) : new TextEncoder().encode(decodeURIComponent(t[2])).byteLength;
|
|
123
|
-
}
|
|
124
|
-
function h(e, t, r, s, a) {
|
|
125
|
-
const n = { code: r, message: s, severity: "warning", format: e.options.format ?? "dom", pageIndex: t.pageIndex, componentIndex: t.componentIndex, componentPath: t.componentPath, kind: t.component.kind, nid: t.component.nid };
|
|
126
|
-
if (e.diagnostics.push(n), b(n, { ...e.options, signal: e.signal }), e.options.assetFailure !== "placeholder") throw new w(n, a);
|
|
127
|
-
}
|
|
128
|
-
async function O(e, t, r) {
|
|
129
|
-
const s = e.options.assetRenderers?.[t.kind];
|
|
130
|
-
if (t.imageData || !s) return t.imageData;
|
|
131
|
-
if (++e.rendered > e.budget.maxAssets) return h(e, r, "asset-budget-exceeded", "Output exceeded the asset count budget.");
|
|
132
|
-
let a;
|
|
133
|
-
try {
|
|
134
|
-
if (e.active = r, a = await I(s({ ...r, signal: e.signal }), e.signal), l(e.signal), a.length > e.budget.maxImageBytes * 4 + 1024) return h(e, r, "asset-budget-exceeded", "Output exceeded the image payload byte budget.");
|
|
135
|
-
const n = D(a);
|
|
136
|
-
if (n > e.budget.maxImageBytes || e.bytes + n > e.budget.maxTotalImageBytes) return h(e, r, "asset-budget-exceeded", "Output exceeded the encoded image byte budget.");
|
|
137
|
-
e.bytes += n;
|
|
138
|
-
} catch (n) {
|
|
139
|
-
if (e.signal.aborted || n instanceof w) throw n;
|
|
140
|
-
return h(e, r, "asset-render-failed", `Asset renderer failed for ${t.kind}; output was not silently omitted.`, n);
|
|
141
|
-
}
|
|
142
|
-
return a;
|
|
143
|
-
}
|
|
144
|
-
function P(e, t) {
|
|
145
|
-
const r = e.active;
|
|
146
|
-
if (!r) {
|
|
147
|
-
t.abort(new Error("Asset rendering exceeded maxDurationMs."));
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const s = { code: "asset-budget-exceeded", message: "Asset rendering exceeded maxDurationMs.", severity: "warning", format: e.options.format ?? "dom", pageIndex: r.pageIndex, componentIndex: r.componentIndex, componentPath: r.componentPath, kind: r.component.kind, nid: r.component.nid };
|
|
151
|
-
e.diagnostics.push(s);
|
|
152
|
-
try {
|
|
153
|
-
b(s, { ...e.options, signal: e.signal });
|
|
154
|
-
} catch (a) {
|
|
155
|
-
t.abort(a);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
t.abort(new w(s));
|
|
159
|
-
}
|
|
160
|
-
async function S(e, t, r, s, a) {
|
|
161
|
-
if (!t?.children?.length) return t;
|
|
162
|
-
const n = [];
|
|
163
|
-
for (const [i, d] of t.children.entries())
|
|
164
|
-
n.push(await y(e, d, { ...r, component: d, componentPath: [...s, i] }, a));
|
|
165
|
-
return n.some((i, d) => i !== t.children[d]) ? { ...t, children: n } : t;
|
|
166
|
-
}
|
|
167
|
-
async function y(e, t, r, s) {
|
|
168
|
-
if (l(e.signal), s.has(t)) throw new TypeError("Cyclic grid children cannot be rendered.");
|
|
169
|
-
let a = e.cache.get(t);
|
|
170
|
-
a || (a = O(e, t, r), e.cache.set(t, a));
|
|
171
|
-
const n = await a;
|
|
172
|
-
l(e.signal);
|
|
173
|
-
let i = t.grid;
|
|
174
|
-
if (i) {
|
|
175
|
-
const d = new Set(s).add(t), c = [];
|
|
176
|
-
for (const [o, f] of i.cells.entries()) {
|
|
177
|
-
const u = [];
|
|
178
|
-
for (const [m, M] of f.entries()) u.push(await S(e, M, r, [...r.componentPath, o, m], d));
|
|
179
|
-
c.push(u);
|
|
180
|
-
}
|
|
181
|
-
c.some((o, f) => o.some((u, m) => u !== i.cells[f][m])) && (i = { ...i, cells: c });
|
|
182
|
-
}
|
|
183
|
-
return n !== t.imageData || i !== t.grid ? { ...t, imageData: n, grid: i } : t;
|
|
184
|
-
}
|
|
185
|
-
async function W(e, t = {}) {
|
|
186
|
-
const r = k(t);
|
|
187
|
-
if (t.signal?.aborted) throw t.signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
188
|
-
const s = new AbortController(), a = () => s.abort(t.signal?.reason);
|
|
189
|
-
if (t.signal?.addEventListener("abort", a, { once: !0 }), !t.assetRenderers || !Object.keys(t.assetRenderers).length)
|
|
190
|
-
return t.signal?.removeEventListener("abort", a), { plan: e, diagnostics: [] };
|
|
191
|
-
const n = { options: t, signal: s.signal, diagnostics: [], rendered: 0, bytes: 0, budget: r, cache: /* @__PURE__ */ new WeakMap() }, i = setTimeout(() => P(n, s), r.maxDurationMs);
|
|
192
|
-
try {
|
|
193
|
-
const d = [];
|
|
194
|
-
for (const [c, o] of e.pages.entries()) {
|
|
195
|
-
if (c < (t.start ?? 0) || c > (t.end ?? e.pages.length - 1)) {
|
|
196
|
-
d.push(o);
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
const f = [];
|
|
200
|
-
for (const [u, m] of o.components.entries()) f.push(await y(n, m, { component: m, pageIndex: c, componentIndex: u, componentPath: [] }, /* @__PURE__ */ new Set()));
|
|
201
|
-
d.push(f.some((u, m) => u !== o.components[m]) ? { ...o, components: f } : o);
|
|
202
|
-
}
|
|
203
|
-
return l(n.signal), { plan: d.some((c, o) => c !== e.pages[o]) ? { ...e, pages: d } : e, diagnostics: n.diagnostics };
|
|
204
|
-
} finally {
|
|
205
|
-
clearTimeout(i), t.signal?.removeEventListener("abort", a);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
export {
|
|
209
|
-
w as O,
|
|
210
|
-
$ as a,
|
|
211
|
-
B as b,
|
|
212
|
-
E as c,
|
|
213
|
-
p as h,
|
|
214
|
-
R as m,
|
|
215
|
-
W as r,
|
|
216
|
-
F as w
|
|
217
|
-
};
|
package/dist/batch-DzaTNLWI.js
DELETED
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
class m extends Error {
|
|
2
|
-
constructor(t, n, r) {
|
|
3
|
-
super(n), this.code = t, this.path = r, this.name = "ReportRuntimeError";
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
function S(e) {
|
|
7
|
-
if (!e?.aborted) return;
|
|
8
|
-
if (e.reason instanceof m) throw e.reason;
|
|
9
|
-
const t = new Error("报表执行已取消");
|
|
10
|
-
throw t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
|
|
11
|
-
}
|
|
12
|
-
function Z(e, t, n) {
|
|
13
|
-
if (!Number.isFinite(n) || n < 0) throw new m("budget", `${t} 的执行统计无效`, `$.budget.${t}`);
|
|
14
|
-
const r = e[t];
|
|
15
|
-
if (r !== void 0 && n > r) throw new m("budget", `${t} 超出预算 ${r}(实际 ${n})`, `$.budget.${t}`);
|
|
16
|
-
}
|
|
17
|
-
function F(e) {
|
|
18
|
-
for (const [t, n] of Object.entries(e)) {
|
|
19
|
-
if (n !== void 0 && (!Number.isFinite(n) || n <= 0)) throw new m("budget", `${t} 应为正有限数字`, `$.budget.${t}`);
|
|
20
|
-
if (t !== "maxDurationMs" && n !== void 0 && !Number.isSafeInteger(n)) throw new m("budget", `${t} 应为正安全整数`, `$.budget.${t}`);
|
|
21
|
-
if (t === "maxDurationMs" && n !== void 0 && n > 2147483647) throw new m("budget", "maxDurationMs 不能超过 2147483647", `$.budget.${t}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async function V(e, t, n) {
|
|
25
|
-
const r = new AbortController(), s = () => r.abort(e?.reason);
|
|
26
|
-
e?.addEventListener("abort", s, { once: !0 }), e?.aborted && s();
|
|
27
|
-
const a = Date.now(), c = t === void 0 ? void 0 : setTimeout(() => r.abort(new m("timeout", `报表执行超过 ${t}ms`)), t);
|
|
28
|
-
let d;
|
|
29
|
-
try {
|
|
30
|
-
S(r.signal);
|
|
31
|
-
const g = new Promise((u, i) => {
|
|
32
|
-
d = () => {
|
|
33
|
-
try {
|
|
34
|
-
S(r.signal);
|
|
35
|
-
} catch (w) {
|
|
36
|
-
i(w);
|
|
37
|
-
}
|
|
38
|
-
}, r.signal.addEventListener("abort", d, { once: !0 });
|
|
39
|
-
}), o = await Promise.race([n(r.signal), g]);
|
|
40
|
-
if (S(r.signal), t !== void 0 && Date.now() - a > t) throw new m("timeout", `报表执行超过 ${t}ms`);
|
|
41
|
-
return o;
|
|
42
|
-
} finally {
|
|
43
|
-
c !== void 0 && clearTimeout(c), d && r.signal.removeEventListener("abort", d), e?.removeEventListener("abort", s);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const $ = new Uint32Array([
|
|
47
|
-
1116352408,
|
|
48
|
-
1899447441,
|
|
49
|
-
3049323471,
|
|
50
|
-
3921009573,
|
|
51
|
-
961987163,
|
|
52
|
-
1508970993,
|
|
53
|
-
2453635748,
|
|
54
|
-
2870763221,
|
|
55
|
-
3624381080,
|
|
56
|
-
310598401,
|
|
57
|
-
607225278,
|
|
58
|
-
1426881987,
|
|
59
|
-
1925078388,
|
|
60
|
-
2162078206,
|
|
61
|
-
2614888103,
|
|
62
|
-
3248222580,
|
|
63
|
-
3835390401,
|
|
64
|
-
4022224774,
|
|
65
|
-
264347078,
|
|
66
|
-
604807628,
|
|
67
|
-
770255983,
|
|
68
|
-
1249150122,
|
|
69
|
-
1555081692,
|
|
70
|
-
1996064986,
|
|
71
|
-
2554220882,
|
|
72
|
-
2821834349,
|
|
73
|
-
2952996808,
|
|
74
|
-
3210313671,
|
|
75
|
-
3336571891,
|
|
76
|
-
3584528711,
|
|
77
|
-
113926993,
|
|
78
|
-
338241895,
|
|
79
|
-
666307205,
|
|
80
|
-
773529912,
|
|
81
|
-
1294757372,
|
|
82
|
-
1396182291,
|
|
83
|
-
1695183700,
|
|
84
|
-
1986661051,
|
|
85
|
-
2177026350,
|
|
86
|
-
2456956037,
|
|
87
|
-
2730485921,
|
|
88
|
-
2820302411,
|
|
89
|
-
3259730800,
|
|
90
|
-
3345764771,
|
|
91
|
-
3516065817,
|
|
92
|
-
3600352804,
|
|
93
|
-
4094571909,
|
|
94
|
-
275423344,
|
|
95
|
-
430227734,
|
|
96
|
-
506948616,
|
|
97
|
-
659060556,
|
|
98
|
-
883997877,
|
|
99
|
-
958139571,
|
|
100
|
-
1322822218,
|
|
101
|
-
1537002063,
|
|
102
|
-
1747873779,
|
|
103
|
-
1955562222,
|
|
104
|
-
2024104815,
|
|
105
|
-
2227730452,
|
|
106
|
-
2361852424,
|
|
107
|
-
2428436474,
|
|
108
|
-
2756734187,
|
|
109
|
-
3204031479,
|
|
110
|
-
3329325298
|
|
111
|
-
]), y = (e, t) => e >>> t | e << 32 - t;
|
|
112
|
-
function R(e, t, n) {
|
|
113
|
-
const r = new DataView(e.buffer, e.byteOffset + t, 64);
|
|
114
|
-
for (let s = 0; s < 16; s++) n[s] = r.getUint32(s * 4);
|
|
115
|
-
for (let s = 16; s < 64; s++) {
|
|
116
|
-
const a = n[s - 15], c = n[s - 2], d = y(a, 7) ^ y(a, 18) ^ a >>> 3, g = y(c, 17) ^ y(c, 19) ^ c >>> 10;
|
|
117
|
-
n[s] = n[s - 16] + d + n[s - 7] + g;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function B(e, t) {
|
|
121
|
-
let n = e[0], r = e[1], s = e[2], a = e[3], c = e[4], d = e[5], g = e[6], o = e[7];
|
|
122
|
-
for (let u = 0; u < 64; u++) {
|
|
123
|
-
const i = y(c, 6) ^ y(c, 11) ^ y(c, 25), w = c & d ^ ~c & g, f = o + i + w + $[u] + t[u] >>> 0, b = y(n, 2) ^ y(n, 13) ^ y(n, 22), h = n & r ^ n & s ^ r & s, A = b + h >>> 0;
|
|
124
|
-
o = g, g = d, d = c, c = a + f >>> 0, a = s, s = r, r = n, n = f + A >>> 0;
|
|
125
|
-
}
|
|
126
|
-
e[0] = e[0] + n, e[1] = e[1] + r, e[2] = e[2] + s, e[3] = e[3] + a, e[4] = e[4] + c, e[5] = e[5] + d, e[6] = e[6] + g, e[7] = e[7] + o;
|
|
127
|
-
}
|
|
128
|
-
function E(e) {
|
|
129
|
-
const t = new Uint8Array(Math.ceil((e.byteLength + 9) / 64) * 64);
|
|
130
|
-
t.set(e), t[e.byteLength] = 128;
|
|
131
|
-
const n = new DataView(t.buffer);
|
|
132
|
-
return n.setUint32(t.length - 8, Math.floor(e.byteLength / 536870912)), n.setUint32(t.length - 4, e.byteLength * 8 >>> 0), t;
|
|
133
|
-
}
|
|
134
|
-
const O = () => new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]), j = (e) => Array.from(e, (t) => t.toString(16).padStart(8, "0")).join("");
|
|
135
|
-
function K(e) {
|
|
136
|
-
const t = E(e), n = O(), r = new Uint32Array(64);
|
|
137
|
-
for (let s = 0; s < t.length; s += 64)
|
|
138
|
-
R(t, s, r), B(n, r);
|
|
139
|
-
return j(n);
|
|
140
|
-
}
|
|
141
|
-
async function I(e) {
|
|
142
|
-
const t = E(e), n = O(), r = new Uint32Array(64);
|
|
143
|
-
for (let s = 0; s < t.length; s += 64)
|
|
144
|
-
s > 0 && s % 262144 === 0 && await new Promise((a) => setTimeout(a, 0)), R(t, s, r), B(n, r);
|
|
145
|
-
return j(n);
|
|
146
|
-
}
|
|
147
|
-
function q(e = {}) {
|
|
148
|
-
const t = {
|
|
149
|
-
maxRecords: e.maxRecords ?? 1e4,
|
|
150
|
-
maxBytes: e.maxBytes ?? 67108864,
|
|
151
|
-
maxResultBytes: e.maxResultBytes ?? 262144,
|
|
152
|
-
controlReserveBytes: e.controlReserveBytes ?? 4096,
|
|
153
|
-
maxTombstones: e.maxTombstones ?? 1e4,
|
|
154
|
-
maxTombstoneBytes: e.maxTombstoneBytes ?? 16777216
|
|
155
|
-
};
|
|
156
|
-
if (!Object.values(t).every((n) => Number.isSafeInteger(n) && n > 0) || t.controlReserveBytes < 4096) throw new l("input", "任务容量应为正整数,控制状态预留至少4096字节");
|
|
157
|
-
return t;
|
|
158
|
-
}
|
|
159
|
-
function v(e) {
|
|
160
|
-
return new TextEncoder().encode(p(e)).byteLength;
|
|
161
|
-
}
|
|
162
|
-
function N(e, t) {
|
|
163
|
-
const n = { scope: e.scope, id: e.id, revision: 1, request: e.request, status: "queued", createdAt: e.createdAt, updatedAt: e.createdAt, attempt: 0 }, r = { ...e };
|
|
164
|
-
delete r.result;
|
|
165
|
-
const s = e.result === void 0 ? 0 : v(e.result);
|
|
166
|
-
if (s > t.maxResultBytes) throw new l("capacity", "任务结果超过独立预算,请保存文件引用");
|
|
167
|
-
return Math.max(v(n) + t.controlReserveBytes, v(r)) + s;
|
|
168
|
-
}
|
|
169
|
-
function J(e) {
|
|
170
|
-
return e.status !== "queued" && e.status !== "running";
|
|
171
|
-
}
|
|
172
|
-
function T(e) {
|
|
173
|
-
const t = { ...e, tombstoneRetentionMs: e.tombstoneRetentionMs ?? 6048e5, limit: e.limit ?? 100 };
|
|
174
|
-
if (![t.now, t.terminalBefore].every((n) => Number.isSafeInteger(n) && n >= 0) || t.terminalBefore > t.now) throw new l("input", "终态清理时间应为不超过当前时间的非负整数");
|
|
175
|
-
if (![t.tombstoneRetentionMs, t.limit].every((n) => Number.isSafeInteger(n) && n > 0) || !Number.isSafeInteger(t.now + t.tombstoneRetentionMs)) throw new l("input", "幂等保留期与清理批量应为正整数");
|
|
176
|
-
return t;
|
|
177
|
-
}
|
|
178
|
-
async function D(e) {
|
|
179
|
-
const t = new TextEncoder().encode(p(e)), n = globalThis.crypto?.subtle;
|
|
180
|
-
if (!n) return I(t);
|
|
181
|
-
const r = await n.digest("SHA-256", t);
|
|
182
|
-
return Array.from(new Uint8Array(r), (s) => s.toString(16).padStart(2, "0")).join("");
|
|
183
|
-
}
|
|
184
|
-
async function L(e, t) {
|
|
185
|
-
if (!J(e)) throw new l("input", "只能归档终态任务");
|
|
186
|
-
return { scope: e.scope, id: e.id, revision: e.revision, status: e.status, createdAt: e.createdAt, updatedAt: e.updatedAt, attempt: e.attempt, requestHash: await D(e.request), expiresAt: t };
|
|
187
|
-
}
|
|
188
|
-
class l extends Error {
|
|
189
|
-
constructor(t, n) {
|
|
190
|
-
super(n), this.code = t, this.name = "ReportJobError";
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
function P(e, t) {
|
|
194
|
-
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 l("input", "任务范围应非空,ID应为1–128位安全标识");
|
|
195
|
-
}
|
|
196
|
-
function M(e) {
|
|
197
|
-
const t = Array.isArray(e), n = Object.getPrototypeOf(e), r = Object.keys(e);
|
|
198
|
-
if (n !== (t ? Array.prototype : Object.prototype) && !(n === null && !t)) throw new l("input", "任务对象应为普通 JSON 对象");
|
|
199
|
-
if (Object.getOwnPropertySymbols(e).length) throw new l("input", "任务不能包含Symbol");
|
|
200
|
-
if (Object.getOwnPropertyNames(e).filter((a) => !(t && a === "length")).length !== r.length) throw new l("input", "任务不能包含不可枚举属性");
|
|
201
|
-
if (t && (r.length !== e.length || r.some((a) => a !== String(Number(a)) || !Number.isSafeInteger(Number(a)) || Number(a) < 0 || Number(a) >= e.length))) throw new l("input", "任务数组不能稀疏或包含额外属性");
|
|
202
|
-
return r.sort();
|
|
203
|
-
}
|
|
204
|
-
function C(e, t) {
|
|
205
|
-
const n = Object.getOwnPropertyDescriptor(e, t);
|
|
206
|
-
if (["__proto__", "prototype", "constructor"].includes(t) || n.get || n.set) throw new l("input", "任务不能包含危险键或访问器");
|
|
207
|
-
return n.value;
|
|
208
|
-
}
|
|
209
|
-
function p(e, t = {}) {
|
|
210
|
-
const n = t.maxNodes ?? 2e4, r = t.maxCharacters ?? 1e6;
|
|
211
|
-
if (!Number.isSafeInteger(n) || n < 1 || n > 2e4 || !Number.isSafeInteger(r) || r < 1 || r > 1e6) throw new l("input", "任务JSON预算无效");
|
|
212
|
-
let s = 0, a = 0;
|
|
213
|
-
const c = /* @__PURE__ */ new Set();
|
|
214
|
-
function d(o, u) {
|
|
215
|
-
if (++s > n || u > 32) throw new l("input", "任务数据超过节点或深度预算");
|
|
216
|
-
if (typeof o == "string") {
|
|
217
|
-
if (a += o.length, a > r) throw new l("input", "任务文本超过预算");
|
|
218
|
-
return o;
|
|
219
|
-
}
|
|
220
|
-
if (o === null || typeof o == "boolean" || typeof o == "number" && Number.isFinite(o)) return o;
|
|
221
|
-
if (!o || typeof o != "object" || c.has(o)) throw new l("input", "任务只允许无循环的有限 JSON 值");
|
|
222
|
-
const i = Array.isArray(o), w = M(o);
|
|
223
|
-
c.add(o);
|
|
224
|
-
const f = /* @__PURE__ */ Object.create(null);
|
|
225
|
-
for (const b of w) {
|
|
226
|
-
if (a += b.length, a > r) throw new l("input", "任务文本超过预算");
|
|
227
|
-
f[b] = d(C(o, b), u + 1);
|
|
228
|
-
}
|
|
229
|
-
return c.delete(o), i ? Array.from({ length: o.length }, (b, h) => f[String(h)]) : f;
|
|
230
|
-
}
|
|
231
|
-
const g = JSON.stringify(d(e, 0));
|
|
232
|
-
if (g.length > r) throw new l("input", "任务序列化数据超过字符预算");
|
|
233
|
-
return g;
|
|
234
|
-
}
|
|
235
|
-
function x(e) {
|
|
236
|
-
return JSON.parse(JSON.stringify(e));
|
|
237
|
-
}
|
|
238
|
-
function U(e, t, n, r) {
|
|
239
|
-
if (P(t, n), e.scope !== t || e.id !== n || e.revision !== (r ?? 0) + 1 || !Number.isSafeInteger(e.revision)) throw new l("input", "任务身份或修订不匹配");
|
|
240
|
-
if (![e.createdAt, e.updatedAt, e.attempt].every((s) => Number.isSafeInteger(s) && s >= 0) || !["queued", "running", "completed", "failed", "cancelled"].includes(e.status)) throw new l("input", "任务状态无效");
|
|
241
|
-
if (e.lease && (!e.lease.owner || !Number.isSafeInteger(e.lease.expiresAt))) throw new l("input", "任务租约无效");
|
|
242
|
-
if (!e.request || typeof e.request.kind != "string" || !e.request.kind.trim() || e.request.kind.length > 128) throw new l("input", "任务类型无效");
|
|
243
|
-
p(e.request.payload, { maxNodes: 19e3, maxCharacters: 75e4 }), p(e);
|
|
244
|
-
}
|
|
245
|
-
function z(e, t) {
|
|
246
|
-
if (e && (e.createdAt !== t.createdAt || p(e.request) !== p(t.request))) throw new l("input", "任务创建时间与请求不可变更,请使用新任务ID");
|
|
247
|
-
}
|
|
248
|
-
function _(e, t) {
|
|
249
|
-
return e.status === "queued" || e.status === "running" && (e.lease?.expiresAt ?? 0) <= t;
|
|
250
|
-
}
|
|
251
|
-
function W(e = {}) {
|
|
252
|
-
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = q(e);
|
|
253
|
-
let s = 0, a = 0, c = Promise.resolve();
|
|
254
|
-
const d = (o, u) => JSON.stringify([o, u]), g = (o) => {
|
|
255
|
-
const u = c.then(o);
|
|
256
|
-
return c = u.then(() => {
|
|
257
|
-
}, () => {
|
|
258
|
-
}), u;
|
|
259
|
-
};
|
|
260
|
-
return {
|
|
261
|
-
read: async (o, u) => {
|
|
262
|
-
await c;
|
|
263
|
-
const i = t.get(d(o, u));
|
|
264
|
-
return i ? x(i) : void 0;
|
|
265
|
-
},
|
|
266
|
-
readTombstone: async (o, u) => {
|
|
267
|
-
await c;
|
|
268
|
-
const i = n.get(d(o, u));
|
|
269
|
-
return i ? x(i) : void 0;
|
|
270
|
-
},
|
|
271
|
-
candidates: async (o, u) => (await c, Array.from(t.values()).filter((i) => _(i, o)).sort((i, w) => i.createdAt - w.createdAt).slice(0, u).map(x)),
|
|
272
|
-
compareAndSwap: async (o, u, i, w) => {
|
|
273
|
-
U(w, o, u, i);
|
|
274
|
-
const f = x(w);
|
|
275
|
-
return g(async () => {
|
|
276
|
-
const b = d(o, u), h = t.get(b);
|
|
277
|
-
if ((h?.revision ?? null) !== i || n.has(b)) return !1;
|
|
278
|
-
z(h, f);
|
|
279
|
-
const A = s - (h ? N(h, r) : 0) + N(f, r);
|
|
280
|
-
if (A > r.maxBytes || !h && t.size >= r.maxRecords) throw new l("capacity", "任务容量已满,请清理终态任务或扩大显式预算");
|
|
281
|
-
return t.set(b, f), s = A, !0;
|
|
282
|
-
});
|
|
283
|
-
},
|
|
284
|
-
prune: async (o) => {
|
|
285
|
-
const u = T(o);
|
|
286
|
-
return g(async () => {
|
|
287
|
-
const i = { archived: 0, expired: 0 };
|
|
288
|
-
for (const [w, f] of n)
|
|
289
|
-
f.expiresAt > u.now || i.expired >= u.limit || (n.delete(w), a -= v(f), i.expired++);
|
|
290
|
-
for (const [w, f] of t) {
|
|
291
|
-
if (!J(f) || f.updatedAt > u.terminalBefore || i.archived + i.expired >= u.limit) continue;
|
|
292
|
-
const b = await L(f, u.now + u.tombstoneRetentionMs), h = v(b);
|
|
293
|
-
if (n.size >= r.maxTombstones || a + h > r.maxTombstoneBytes) break;
|
|
294
|
-
n.set(w, b), a += h, t.delete(w), s -= N(f, r), i.archived++;
|
|
295
|
-
}
|
|
296
|
-
return i;
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
function k(e, t = 100) {
|
|
302
|
-
if (!Number.isSafeInteger(t) || t < 1 || t > 1e3 || !Array.isArray(e) || e.length > t) throw new RangeError("批量参数应包含 1–maxCases 条,maxCases 最大为 1000");
|
|
303
|
-
const n = JSON.parse(p(e)), r = /* @__PURE__ */ new Set();
|
|
304
|
-
for (const s of n) {
|
|
305
|
-
if (!s || typeof s.id != "string" || s.id !== s.id.trim() || !/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(s.id) || r.has(s.id)) throw new TypeError("批量行 ID 应唯一且为安全标识");
|
|
306
|
-
if (!s.params || Array.isArray(s.params) || typeof s.params != "object" || Object.values(s.params).some((a) => typeof a != "string")) throw new TypeError("批量参数应为字符串字典");
|
|
307
|
-
r.add(s.id);
|
|
308
|
-
}
|
|
309
|
-
return n;
|
|
310
|
-
}
|
|
311
|
-
function H(e, t) {
|
|
312
|
-
if (!t) return;
|
|
313
|
-
const n = { completed: 0, total: e.length, failed: 0, cancelled: 0 };
|
|
314
|
-
for (const r of e)
|
|
315
|
-
r && (n.completed++, r.status === "failed" && n.failed++, r.status === "cancelled" && n.cancelled++);
|
|
316
|
-
try {
|
|
317
|
-
t(n);
|
|
318
|
-
} catch {
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
async function G(e, t, n = {}) {
|
|
322
|
-
const r = n.concurrency ?? 2;
|
|
323
|
-
if (!Number.isSafeInteger(r) || r < 1 || r > 16) throw new RangeError("批量并发应为 1–16");
|
|
324
|
-
if (n.failure !== void 0 && n.failure !== "continue" && n.failure !== "stop") throw new TypeError("批量失败策略无效");
|
|
325
|
-
const s = k(e, n.maxCases ?? 100);
|
|
326
|
-
if (!s.length) throw new RangeError("批量生成至少需要一组参数");
|
|
327
|
-
const a = Array.from({ length: s.length }), c = new AbortController(), d = () => c.abort(n.signal?.reason);
|
|
328
|
-
n.signal?.addEventListener("abort", d, { once: !0 }), n.signal?.aborted && d();
|
|
329
|
-
let g = 0, o = !1;
|
|
330
|
-
async function u() {
|
|
331
|
-
for (; g < s.length; ) {
|
|
332
|
-
const i = g++, w = s[i], f = { id: w.id, index: i };
|
|
333
|
-
if (o || c.signal.aborted) a[i] = { ...f, status: "cancelled" };
|
|
334
|
-
else
|
|
335
|
-
try {
|
|
336
|
-
S(c.signal);
|
|
337
|
-
const b = await t(w, { index: i, signal: c.signal });
|
|
338
|
-
a[i] = { ...f, status: "completed", value: b };
|
|
339
|
-
} catch (b) {
|
|
340
|
-
c.signal.aborted ? a[i] = { ...f, status: "cancelled" } : (a[i] = { ...f, status: "failed", error: { name: b instanceof Error ? b.name : "Error", message: b instanceof Error ? b.message : String(b) } }, n.failure === "stop" && (o = !0));
|
|
341
|
-
}
|
|
342
|
-
H(a, n.onProgress);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
try {
|
|
346
|
-
await Promise.all(Array.from({ length: Math.min(r, s.length) }, u));
|
|
347
|
-
} finally {
|
|
348
|
-
n.signal?.removeEventListener("abort", d);
|
|
349
|
-
}
|
|
350
|
-
return a;
|
|
351
|
-
}
|
|
352
|
-
export {
|
|
353
|
-
m as R,
|
|
354
|
-
Z as a,
|
|
355
|
-
l as b,
|
|
356
|
-
V as c,
|
|
357
|
-
P as d,
|
|
358
|
-
x as e,
|
|
359
|
-
D as f,
|
|
360
|
-
W as g,
|
|
361
|
-
_ as h,
|
|
362
|
-
k as i,
|
|
363
|
-
v as j,
|
|
364
|
-
U as k,
|
|
365
|
-
z as l,
|
|
366
|
-
K as p,
|
|
367
|
-
G as r,
|
|
368
|
-
p as s,
|
|
369
|
-
S as t,
|
|
370
|
-
F as v
|
|
371
|
-
};
|
package/dist/batch-xMkqYiTr.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";class m extends Error{constructor(t,n,r){super(n),this.code=t,this.path=r,this.name="ReportRuntimeError"}}function x(e){if(!e?.aborted)return;if(e.reason instanceof m)throw e.reason;const t=new Error("报表执行已取消");throw t.name="AbortError",Object.defineProperty(t,"cause",{value:e.reason}),t}function M(e,t,n){if(!Number.isFinite(n)||n<0)throw new m("budget",`${t} 的执行统计无效`,`$.budget.${t}`);const r=e[t];if(r!==void 0&&n>r)throw new m("budget",`${t} 超出预算 ${r}(实际 ${n})`,`$.budget.${t}`)}function P(e){for(const[t,n]of Object.entries(e)){if(n!==void 0&&(!Number.isFinite(n)||n<=0))throw new m("budget",`${t} 应为正有限数字`,`$.budget.${t}`);if(t!=="maxDurationMs"&&n!==void 0&&!Number.isSafeInteger(n))throw new m("budget",`${t} 应为正安全整数`,`$.budget.${t}`);if(t==="maxDurationMs"&&n!==void 0&&n>2147483647)throw new m("budget","maxDurationMs 不能超过 2147483647",`$.budget.${t}`)}}async function C(e,t,n){const r=new AbortController,o=()=>r.abort(e?.reason);e?.addEventListener("abort",o,{once:!0}),e?.aborted&&o();const a=Date.now(),c=t===void 0?void 0:setTimeout(()=>r.abort(new m("timeout",`报表执行超过 ${t}ms`)),t);let d;try{x(r.signal);const w=new Promise((u,i)=>{d=()=>{try{x(r.signal)}catch(h){i(h)}},r.signal.addEventListener("abort",d,{once:!0})}),s=await Promise.race([n(r.signal),w]);if(x(r.signal),t!==void 0&&Date.now()-a>t)throw new m("timeout",`报表执行超过 ${t}ms`);return s}finally{c!==void 0&&clearTimeout(c),d&&r.signal.removeEventListener("abort",d),e?.removeEventListener("abort",o)}}const U=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),y=(e,t)=>e>>>t|e<<32-t;function N(e,t,n){const r=new DataView(e.buffer,e.byteOffset+t,64);for(let o=0;o<16;o++)n[o]=r.getUint32(o*4);for(let o=16;o<64;o++){const a=n[o-15],c=n[o-2],d=y(a,7)^y(a,18)^a>>>3,w=y(c,17)^y(c,19)^c>>>10;n[o]=n[o-16]+d+n[o-7]+w}}function B(e,t){let n=e[0],r=e[1],o=e[2],a=e[3],c=e[4],d=e[5],w=e[6],s=e[7];for(let u=0;u<64;u++){const i=y(c,6)^y(c,11)^y(c,25),h=c&d^~c&w,f=s+i+h+U[u]+t[u]>>>0,b=y(n,2)^y(n,13)^y(n,22),g=n&r^n&o^r&o,S=b+g>>>0;s=w,w=d,d=c,c=a+f>>>0,a=o,o=r,r=n,n=f+S>>>0}e[0]=e[0]+n,e[1]=e[1]+r,e[2]=e[2]+o,e[3]=e[3]+a,e[4]=e[4]+c,e[5]=e[5]+d,e[6]=e[6]+w,e[7]=e[7]+s}function J(e){const t=new Uint8Array(Math.ceil((e.byteLength+9)/64)*64);t.set(e),t[e.byteLength]=128;const n=new DataView(t.buffer);return n.setUint32(t.length-8,Math.floor(e.byteLength/536870912)),n.setUint32(t.length-4,e.byteLength*8>>>0),t}const E=()=>new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),O=e=>Array.from(e,t=>t.toString(16).padStart(8,"0")).join("");function z(e){const t=J(e),n=E(),r=new Uint32Array(64);for(let o=0;o<t.length;o+=64)N(t,o,r),B(n,r);return O(n)}async function _(e){const t=J(e),n=E(),r=new Uint32Array(64);for(let o=0;o<t.length;o+=64)o>0&&o%262144===0&&await new Promise(a=>setTimeout(a,0)),N(t,o,r),B(n,r);return O(n)}function H(e={}){const t={maxRecords:e.maxRecords??1e4,maxBytes:e.maxBytes??67108864,maxResultBytes:e.maxResultBytes??262144,controlReserveBytes:e.controlReserveBytes??4096,maxTombstones:e.maxTombstones??1e4,maxTombstoneBytes:e.maxTombstoneBytes??16777216};if(!Object.values(t).every(n=>Number.isSafeInteger(n)&&n>0)||t.controlReserveBytes<4096)throw new l("input","任务容量应为正整数,控制状态预留至少4096字节");return t}function v(e){return new TextEncoder().encode(p(e)).byteLength}function R(e,t){const n={scope:e.scope,id:e.id,revision:1,request:e.request,status:"queued",createdAt:e.createdAt,updatedAt:e.createdAt,attempt:0},r={...e};delete r.result;const o=e.result===void 0?0:v(e.result);if(o>t.maxResultBytes)throw new l("capacity","任务结果超过独立预算,请保存文件引用");return Math.max(v(n)+t.controlReserveBytes,v(r))+o}function j(e){return e.status!=="queued"&&e.status!=="running"}function k(e){const t={...e,tombstoneRetentionMs:e.tombstoneRetentionMs??6048e5,limit:e.limit??100};if(![t.now,t.terminalBefore].every(n=>Number.isSafeInteger(n)&&n>=0)||t.terminalBefore>t.now)throw new l("input","终态清理时间应为不超过当前时间的非负整数");if(![t.tombstoneRetentionMs,t.limit].every(n=>Number.isSafeInteger(n)&&n>0)||!Number.isSafeInteger(t.now+t.tombstoneRetentionMs))throw new l("input","幂等保留期与清理批量应为正整数");return t}async function I(e){const t=new TextEncoder().encode(p(e)),n=globalThis.crypto?.subtle;if(!n)return _(t);const r=await n.digest("SHA-256",t);return Array.from(new Uint8Array(r),o=>o.toString(16).padStart(2,"0")).join("")}async function Z(e,t){if(!j(e))throw new l("input","只能归档终态任务");return{scope:e.scope,id:e.id,revision:e.revision,status:e.status,createdAt:e.createdAt,updatedAt:e.updatedAt,attempt:e.attempt,requestHash:await I(e.request),expiresAt:t}}class l extends Error{constructor(t,n){super(n),this.code=t,this.name="ReportJobError"}}function $(e,t){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 l("input","任务范围应非空,ID应为1–128位安全标识")}function F(e){const t=Array.isArray(e),n=Object.getPrototypeOf(e),r=Object.keys(e);if(n!==(t?Array.prototype:Object.prototype)&&!(n===null&&!t))throw new l("input","任务对象应为普通 JSON 对象");if(Object.getOwnPropertySymbols(e).length)throw new l("input","任务不能包含Symbol");if(Object.getOwnPropertyNames(e).filter(a=>!(t&&a==="length")).length!==r.length)throw new l("input","任务不能包含不可枚举属性");if(t&&(r.length!==e.length||r.some(a=>a!==String(Number(a))||!Number.isSafeInteger(Number(a))||Number(a)<0||Number(a)>=e.length)))throw new l("input","任务数组不能稀疏或包含额外属性");return r.sort()}function V(e,t){const n=Object.getOwnPropertyDescriptor(e,t);if(["__proto__","prototype","constructor"].includes(t)||n.get||n.set)throw new l("input","任务不能包含危险键或访问器");return n.value}function p(e,t={}){const n=t.maxNodes??2e4,r=t.maxCharacters??1e6;if(!Number.isSafeInteger(n)||n<1||n>2e4||!Number.isSafeInteger(r)||r<1||r>1e6)throw new l("input","任务JSON预算无效");let o=0,a=0;const c=new Set;function d(s,u){if(++o>n||u>32)throw new l("input","任务数据超过节点或深度预算");if(typeof s=="string"){if(a+=s.length,a>r)throw new l("input","任务文本超过预算");return s}if(s===null||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s))return s;if(!s||typeof s!="object"||c.has(s))throw new l("input","任务只允许无循环的有限 JSON 值");const i=Array.isArray(s),h=F(s);c.add(s);const f=Object.create(null);for(const b of h){if(a+=b.length,a>r)throw new l("input","任务文本超过预算");f[b]=d(V(s,b),u+1)}return c.delete(s),i?Array.from({length:s.length},(b,g)=>f[String(g)]):f}const w=JSON.stringify(d(e,0));if(w.length>r)throw new l("input","任务序列化数据超过字符预算");return w}function A(e){return JSON.parse(JSON.stringify(e))}function q(e,t,n,r){if($(t,n),e.scope!==t||e.id!==n||e.revision!==(r??0)+1||!Number.isSafeInteger(e.revision))throw new l("input","任务身份或修订不匹配");if(![e.createdAt,e.updatedAt,e.attempt].every(o=>Number.isSafeInteger(o)&&o>=0)||!["queued","running","completed","failed","cancelled"].includes(e.status))throw new l("input","任务状态无效");if(e.lease&&(!e.lease.owner||!Number.isSafeInteger(e.lease.expiresAt)))throw new l("input","任务租约无效");if(!e.request||typeof e.request.kind!="string"||!e.request.kind.trim()||e.request.kind.length>128)throw new l("input","任务类型无效");p(e.request.payload,{maxNodes:19e3,maxCharacters:75e4}),p(e)}function T(e,t){if(e&&(e.createdAt!==t.createdAt||p(e.request)!==p(t.request)))throw new l("input","任务创建时间与请求不可变更,请使用新任务ID")}function L(e,t){return e.status==="queued"||e.status==="running"&&(e.lease?.expiresAt??0)<=t}function K(e={}){const t=new Map,n=new Map,r=H(e);let o=0,a=0,c=Promise.resolve();const d=(s,u)=>JSON.stringify([s,u]),w=s=>{const u=c.then(s);return c=u.then(()=>{},()=>{}),u};return{read:async(s,u)=>{await c;const i=t.get(d(s,u));return i?A(i):void 0},readTombstone:async(s,u)=>{await c;const i=n.get(d(s,u));return i?A(i):void 0},candidates:async(s,u)=>(await c,Array.from(t.values()).filter(i=>L(i,s)).sort((i,h)=>i.createdAt-h.createdAt).slice(0,u).map(A)),compareAndSwap:async(s,u,i,h)=>{q(h,s,u,i);const f=A(h);return w(async()=>{const b=d(s,u),g=t.get(b);if((g?.revision??null)!==i||n.has(b))return!1;T(g,f);const S=o-(g?R(g,r):0)+R(f,r);if(S>r.maxBytes||!g&&t.size>=r.maxRecords)throw new l("capacity","任务容量已满,请清理终态任务或扩大显式预算");return t.set(b,f),o=S,!0})},prune:async s=>{const u=k(s);return w(async()=>{const i={archived:0,expired:0};for(const[h,f]of n)f.expiresAt>u.now||i.expired>=u.limit||(n.delete(h),a-=v(f),i.expired++);for(const[h,f]of t){if(!j(f)||f.updatedAt>u.terminalBefore||i.archived+i.expired>=u.limit)continue;const b=await Z(f,u.now+u.tombstoneRetentionMs),g=v(b);if(n.size>=r.maxTombstones||a+g>r.maxTombstoneBytes)break;n.set(h,b),a+=g,t.delete(h),o-=R(f,r),i.archived++}return i})}}}function D(e,t=100){if(!Number.isSafeInteger(t)||t<1||t>1e3||!Array.isArray(e)||e.length>t)throw new RangeError("批量参数应包含 1–maxCases 条,maxCases 最大为 1000");const n=JSON.parse(p(e)),r=new Set;for(const o of n){if(!o||typeof o.id!="string"||o.id!==o.id.trim()||!/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(o.id)||r.has(o.id))throw new TypeError("批量行 ID 应唯一且为安全标识");if(!o.params||Array.isArray(o.params)||typeof o.params!="object"||Object.values(o.params).some(a=>typeof a!="string"))throw new TypeError("批量参数应为字符串字典");r.add(o.id)}return n}function W(e,t){if(!t)return;const n={completed:0,total:e.length,failed:0,cancelled:0};for(const r of e)r&&(n.completed++,r.status==="failed"&&n.failed++,r.status==="cancelled"&&n.cancelled++);try{t(n)}catch{}}async function G(e,t,n={}){const r=n.concurrency??2;if(!Number.isSafeInteger(r)||r<1||r>16)throw new RangeError("批量并发应为 1–16");if(n.failure!==void 0&&n.failure!=="continue"&&n.failure!=="stop")throw new TypeError("批量失败策略无效");const o=D(e,n.maxCases??100);if(!o.length)throw new RangeError("批量生成至少需要一组参数");const a=Array.from({length:o.length}),c=new AbortController,d=()=>c.abort(n.signal?.reason);n.signal?.addEventListener("abort",d,{once:!0}),n.signal?.aborted&&d();let w=0,s=!1;async function u(){for(;w<o.length;){const i=w++,h=o[i],f={id:h.id,index:i};if(s||c.signal.aborted)a[i]={...f,status:"cancelled"};else try{x(c.signal);const b=await t(h,{index:i,signal:c.signal});a[i]={...f,status:"completed",value:b}}catch(b){c.signal.aborted?a[i]={...f,status:"cancelled"}:(a[i]={...f,status:"failed",error:{name:b instanceof Error?b.name:"Error",message:b instanceof Error?b.message:String(b)}},n.failure==="stop"&&(s=!0))}W(a,n.onProgress)}}try{await Promise.all(Array.from({length:Math.min(r,o.length)},u))}finally{n.signal?.removeEventListener("abort",d)}return a}exports.ReportJobError=l;exports.ReportRuntimeError=m;exports.assertBudget=M;exports.checkJobIdentity=$;exports.cloneJob=A;exports.controlled=C;exports.createMemoryReportJobStore=K;exports.jobByteLength=v;exports.jobRequestHash=I;exports.portableSha256Hex=z;exports.runReportBatch=G;exports.runnableJob=L;exports.serializeJobJson=p;exports.snapshotReportBatchCases=D;exports.throwIfAborted=x;exports.validateBudget=P;exports.validateJobRecord=q;exports.validateJobTransition=T;
|