@agile-team/mach-report 2.25.2 → 2.26.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 +12 -8
- package/dist/ExcelBindingWizard-B418l44t.js +1578 -0
- package/dist/ExcelBindingWizard-C4FGVsY_.cjs +1 -0
- package/dist/{ParamEditor-CGfaweYX.cjs → ParamEditor-BemJE8n8.cjs} +1 -1
- package/dist/{ParamEditor-B7YVD28E.js → ParamEditor-XvMtf_XQ.js} +2 -2
- package/dist/{ReportBatchPanel-BRJt0TXp.cjs → ReportBatchPanel-CbY4fvXD.cjs} +1 -1
- package/dist/{ReportBatchPanel-BTKHtLTW.js → ReportBatchPanel-Ds0R_uXn.js} +37 -37
- package/dist/{ReportLabelStudio-BvK_WBke.cjs → ReportLabelStudio-DuTwN5er.cjs} +1 -1
- package/dist/{ReportLabelStudio-CZwqyO3t.js → ReportLabelStudio-ZFy79eRv.js} +26 -26
- package/dist/ReportParamPanel-Chxu4MTx.cjs +1 -0
- package/dist/{ReportParamPanel-DGXzBzl2.js → ReportParamPanel-Czm3OPo_.js} +216 -205
- package/dist/{ReportPreview-D1ZC5kzz.js → ReportPreview-C9c0Rp7Y.js} +2938 -2875
- package/dist/ReportPreview-CIMR4ERo.cjs +6 -0
- package/dist/{ReportTemplateLibrary-ClwxhnC0.cjs → ReportTemplateLibrary-C6lByc69.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-C7sB0Jay.js → ReportTemplateLibrary-XJVoTDIz.js} +1 -1
- package/dist/{RuleEditor-CsDGFaWz.js → RuleEditor-CeNFPeOc.js} +5 -5
- package/dist/{RuleEditor-D-OdaGdR.cjs → RuleEditor-gggUkEwB.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-DAqR9zQi.cjs → TemplateOutlinePanel-B0e-umq2.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-CXOT7d1r.js → TemplateOutlinePanel-BWN4Y9iz.js} +2 -2
- package/dist/{TemplateReusePanel-Dcfx3Hba.js → TemplateReusePanel-CR-4OHoU.js} +2 -2
- package/dist/{TemplateReusePanel-ygIi-Ajz.cjs → TemplateReusePanel-Cthig1S1.cjs} +1 -1
- package/dist/{TemplateReviewPanel-COU8FqPq.js → TemplateReviewPanel-BkWzyNL4.js} +2 -2
- package/dist/{TemplateReviewPanel-DyGULVxr.cjs → TemplateReviewPanel-D8o2gDaK.cjs} +1 -1
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.js +5 -5
- package/dist/artifact-integrity.json +106 -102
- package/dist/{assets-C4MIvzQ4.js → assets-BFTP-0WR.js} +2 -2
- package/dist/{assets-BYdpkTIt.cjs → assets-CZiZhTf2.cjs} +1 -1
- package/dist/{auto-j7mr8Kvc.js → auto-C7udkeAa.js} +20 -19
- package/dist/auto-CXd2E2aZ.cjs +1 -0
- package/dist/capabilities-D8UU2clQ.cjs +1 -0
- package/dist/{capabilities-CN_kSVjO.js → capabilities-g0a2j9Yy.js} +50 -46
- package/dist/{charts-Cjw5AYkg.cjs → charts-D-Vg-ak9.cjs} +1 -1
- package/dist/{charts-CxJZ0XaY.js → charts-D48XCefN.js} +1 -1
- package/dist/computed-BQgBrma-.cjs +1 -0
- package/dist/{computed-f3pOqWLX.js → computed-CH3NYPOW.js} +198 -188
- package/dist/{data-bar-Bfh54sT4.js → data-bar-DjOgTLqu.js} +1 -1
- package/dist/{dataset-DL83majE.js → dataset-B8oTsC6o.js} +69 -66
- package/dist/dataset-D3OsyzG1.cjs +1 -0
- package/dist/designer-COuSUxZ1.cjs +2 -0
- package/dist/designer-CT4mlrr0.js +7997 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +83 -4
- package/dist/designer.d.ts +83 -4
- package/dist/designer.js +4 -4
- package/dist/{diagnostic-collector-gB07PHy2.js → diagnostic-collector-C-JBA016.js} +2 -2
- package/dist/dom-DgWc-DY1.js +452 -0
- package/dist/dom-Fk4NF-gN.cjs +1 -0
- package/dist/{encoding-BWEMdzFG.js → encoding-D480EM2r.js} +2 -2
- package/dist/{encoding-DVea2qIR.cjs → encoding-tWc2Wn89.cjs} +1 -1
- package/dist/execution-result-7sG_mdcD.cjs +1 -0
- package/dist/execution-result-Ba65gieT.js +39 -0
- package/dist/{font-loader-p_SyTvqt.cjs → font-loader-BIxme_9g.cjs} +1 -1
- package/dist/{font-loader-D4NLIKJL.js → font-loader-CHmEwkHl.js} +1 -1
- package/dist/{grid-strokes-DkZEZvcI.js → grid-strokes-DsoICRjZ.js} +1 -1
- package/dist/import-range-BwT86Z3j.cjs +1 -0
- package/dist/import-range-D9p_blcb.js +98 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +25 -25
- package/dist/{json-snapshot-DdzALe8q.js → json-snapshot-BZ0CIQln.js} +1041 -887
- package/dist/json-snapshot-DGFeI30h.cjs +2 -0
- package/dist/{matrix-b6T291xo.js → matrix-CB9TqTEy.js} +1 -1
- package/dist/{matrix-DUYPRL7t.cjs → matrix-CcqYOuq_.cjs} +1 -1
- package/dist/{pdf-DU8HelKd.js → pdf-DTR7fAIr.js} +3596 -3517
- package/dist/{pdf-C060D5UY.cjs → pdf-d9oJ6V0P.cjs} +49 -49
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-D5BRHlne.cjs → plugin-B7Bi-1te.cjs} +1 -1
- package/dist/{plugin-FWhTnjr0.js → plugin-OKDFQFS4.js} +1 -1
- package/dist/{prefill-m01IM1hl.js → prefill-C8fF91JB.js} +3 -3
- package/dist/{prefill-DZymomY6.cjs → prefill-C_Bf_AMo.cjs} +1 -1
- package/dist/{prepared-BHu8bIdj.cjs → prepared-BLhV7vdE.cjs} +1 -1
- package/dist/{prepared-DO5pe6Ed.js → prepared-DhgQ0d-h.js} +7 -7
- package/dist/protocol-CZ-BILne.cjs +1 -0
- package/dist/{protocol-CZddmu2n.js → protocol-DHO91-Jt.js} +3 -3
- package/dist/{record-bindings-Cv7lFiof.js → record-bindings-DBrCu6zO.js} +3 -3
- package/dist/{record-bindings-B7djSjNs.cjs → record-bindings-KEs-DKCS.cjs} +1 -1
- package/dist/region-binding-workflow-FSyIZge8.js +882 -0
- package/dist/region-binding-workflow-ikpY1Kbw.cjs +3 -0
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/rich-text-layout-BYbIc3eJ.cjs +3 -0
- package/dist/rich-text-layout-BtygMWZC.js +96 -0
- package/dist/runtime-B5HG8poy.cjs +1 -0
- package/dist/runtime-BsvAqz4a.js +204 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +2049 -1889
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +35 -0
- package/dist/server.d.ts +35 -0
- package/dist/server.js +340 -328
- package/dist/style.css +1 -1
- package/dist/{template-catalog-DLu814zA.js → template-catalog-BbrN9dgu.js} +5 -5
- package/dist/{template-catalog-Lil5Ryt-.cjs → template-catalog-DDH-5J57.cjs} +1 -1
- package/dist/{template-fragments-BDxdCuMD.js → template-fragments-CUTE8-_I.js} +3 -3
- package/dist/{template-fragments-DbKdxI1z.cjs → template-fragments-cyAQu7aw.cjs} +1 -1
- package/dist/{template-registry-B-AK1oam.cjs → template-registry-D24Z8aQf.cjs} +1 -1
- package/dist/{template-registry-DeVgwEZj.js → template-registry-PSuLsnyq.js} +4 -4
- package/dist/{template-serialization-CqQY4zDg.cjs → template-serialization-BOUidUlh.cjs} +1 -1
- package/dist/{template-serialization-CWmHq7lX.js → template-serialization-BgGWYV_1.js} +1 -1
- package/dist/{textwrap-BywMBMXM.js → textwrap-Bt_tnI6V.js} +1 -1
- package/dist/vue/async.d.cts +46 -3
- package/dist/vue/async.d.ts +46 -3
- package/dist/vue/index.d.cts +215 -24
- package/dist/vue/index.d.ts +215 -24
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +433 -202
- package/dist/workbook-session-BJfZVp4q.cjs +29 -0
- package/dist/{workbook-session-B6hRjTyX.js → workbook-session-DRnMjIFK.js} +2377 -2350
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +1 -1
- package/dist/xlsx.d.cts +27 -2
- package/dist/xlsx.d.ts +27 -2
- package/dist/xlsx.js +15 -15
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-bs3F4dD8.js +0 -1486
- package/dist/ExcelBindingWizard-jSdjBtWw.cjs +0 -1
- package/dist/ReportParamPanel-B27IGJjk.cjs +0 -1
- package/dist/ReportPreview-DAU-V3Ov.cjs +0 -6
- package/dist/auto-DjmvmcX-.cjs +0 -1
- package/dist/capabilities-D4nfhcvB.cjs +0 -1
- package/dist/computed-DK6BruFz.cjs +0 -1
- package/dist/dataset-IrlXbUvh.cjs +0 -1
- package/dist/designer-B597ZdC0.js +0 -7595
- package/dist/designer-DFIdv_n7.cjs +0 -2
- package/dist/dom-CXWMmwh-.cjs +0 -1
- package/dist/dom-DxdCMLzs.js +0 -452
- package/dist/json-snapshot-L_gJ7KRS.cjs +0 -2
- package/dist/protocol-CymmHWmL.cjs +0 -1
- package/dist/region-binding-workflow-EYxvUYJ-.js +0 -977
- package/dist/region-binding-workflow-NdkMSFCh.cjs +0 -3
- package/dist/rich-text-layout-Ch_N0Ubu.js +0 -52
- package/dist/rich-text-layout-yJGuThtC.cjs +0 -3
- package/dist/runtime-D8AlfJ6S.js +0 -234
- package/dist/runtime-ywf3oLBR.cjs +0 -1
- package/dist/workbook-session-BclW7KKH.cjs +0 -29
package/dist/auto-DjmvmcX-.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const O=require("./prepared-BHu8bIdj.cjs"),C=require("./json-snapshot-L_gJ7KRS.cjs"),P=require("./protocol-CymmHWmL.cjs"),I=require("./diagnostic-collector-wASg6Fzs.cjs"),W=require("./runtime-ywf3oLBR.cjs"),u=require("./sha256-DgZAKXqI.cjs");class M extends Error{constructor(r){super("报表 Worker 无法启动"),this.cause=r,this.name="ReportWorkerStartError"}}let j=0;function F(e){const r=new Error("报表 Worker 任务已取消");return r.name="AbortError",Object.defineProperty(r,"cause",{value:e}),r}function U(e,r){if(!e||typeof e!="object")return;const t=e;return t.protocol===P.REPORT_WORKER_PROTOCOL&&t.id===r?t:void 0}function z(e,r={}){const t=r.timeoutMs??12e4;if(!Number.isFinite(t)||t<=0||t>2147483647)throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");const n=(o,s,a,d)=>a?.aborted?Promise.reject(F(a.reason)):new Promise((y,i)=>{let b;try{b=e()}catch(f){i(new M(f));return}const h=`mach-report-${Date.now()}-${++j}`;let g=!1,p=()=>{},k;const l=(f,c)=>{if(g)return;g=!0,k&&clearTimeout(k);let w;try{p()}catch(R){w=R}a?.removeEventListener("abort",v),f??=w,Promise.resolve().then(()=>b.terminate()).then(()=>f===void 0?y(c):i(f),R=>i(f??R))},v=()=>l(F(a?.reason)),m=f=>{const c=U(f,h);if(!(!c||g)){if("type"in c&&c.type==="event"){const w="event"in c?c.event:void 0;P.validReportWorkerEvent(w,s)?C.notifyReportTaskEvent(d,w,a):l(new Error("报表 Worker 返回无效阶段事件"));return}c.error&&typeof c.error.name=="string"&&typeof c.error.message=="string"?l(new P.ReportWorkerError(c.error)):P.validReportWorkerResult(c.result,o)&&(o==="prepare"||"format"in c.result&&"format"in s&&c.result.format===s.format)?l(void 0,c.result):l(new Error("报表 Worker 返回无效响应"))}};try{if(p=b.subscribe(m,f=>l(f??new Error("报表 Worker 执行失败"))),g){p();return}if(a?.addEventListener("abort",v,{once:!0}),k=setTimeout(()=>l(new P.ReportWorkerError({name:"ReportRuntimeError",code:"timeout",message:`报表 Worker 执行超过 ${t}ms`})),t),a?.aborted)v();else{const{onEvent:f,signal:c,...w}=s,R=N(w);b.postMessage({protocol:P.REPORT_WORKER_PROTOCOL,id:h,operation:o,input:w,...r.budget?{budget:r.budget}:{}},R)}}catch(f){l(f)}});return{exportPrepared:(o,s,a)=>n("exportPrepared",o,s,a),prepare:(o,s,a)=>n("prepare",o,s,a),export:(o,s,a)=>n("export",o,s,a)}}function N(e){return e.pdf?(e.pdf=O.snapshotPdfFonts(e.pdf),(e.pdf?.customFontFaces?Object.values(e.pdf.customFontFaces):[e.pdf?.customFontBytes]).filter(t=>t instanceof Uint8Array).map(t=>t.buffer)):[]}function _(e,r={}){return z(()=>{const t=e();return{postMessage:(n,o)=>t.postMessage(n,o),terminate:()=>t.terminate(),subscribe:(n,o)=>{const s=d=>n(d.data),a=d=>o(d instanceof ErrorEvent?new Error(d.message):new Error("报表 Worker 消息无法解码"));return t.addEventListener("message",s),t.addEventListener("error",a),t.addEventListener("messageerror",a),()=>{t.removeEventListener("message",s),t.removeEventListener("error",a),t.removeEventListener("messageerror",a)}}}},r)}const $={cells:2e4,pages:20,bytes:2e6};function T(e){return e.cells>=e.limits.cells||e.pages>=e.limits.pages||e.bytes>=e.limits.bytes||e.capped}function x(e){return++e.visits>=1e5&&(e.capped=!0),!T(e)}function E(e){return typeof e=="string"?e.length*2:0}function L(e,r){for(const t of e??[]){if(!x(r))return;for(const n of t.segments){if(!x(r))return;r.bytes+=E(n.text)}}}function S(e,r,t){if(t>32){r.capped=!0;return}if(x(r)){r.bytes+=E(e.text)+E(e.rawText)+E(e.imageData),L(e.richParagraphs,r);for(const n of e.lines??[]){if(!x(r))return;r.bytes+=E(n)}for(const n of e.grid?.cells??[]){if(!x(r))return;for(const o of n){if(!x(r))return;if(o){r.cells++,r.bytes+=E(o.text)+E(o.rawText)+E(o.value),L(o.richParagraphs,r);for(const s of o.children??[]){if(T(r))return;S(s,r,t+1)}}}}}}function H(e,r){if(e.format==="xlsx")for(const t of e.xlsx?.additionalSheets??[]){if(!x(r))return;r.bytes+=E(t?.name);for(const n of t?.rows??[]){if(!x(r))return;for(const o of n??[]){if(!x(r))return;r.cells++,r.bytes+=E(o)}}}}function G(e){const r={...$,...e.thresholds};for(const t of Object.values(r))if(!Number.isSafeInteger(t)||t<=0)throw new RangeError("导出隔离阈值应为正安全整数");return r}function K(e,r){const t=G(r),n=e.pdf?.customFontFaces?Object.values(e.pdf.customFontFaces):[e.pdf?.customFontBytes],o={pages:e.prepared.plan.pages.length,cells:0,bytes:n.reduce((d,y)=>d+(y?.byteLength??0),0),visits:0,capped:!1,limits:t};for(const d of e.prepared.plan.pages){if(T(o))break;for(const y of d.components){if(T(o))break;S(y,o,0)}}H(e,o);let s=T(o)?"worker":"local",a=o.capped?"scan-limit":s==="worker"?"threshold":"small-task";return r.mode==="local"&&(s="local",a="explicit-local"),r.mode==="worker"&&(s="worker",a="explicit-worker"),Object.values(e.xlsx??{}).some(d=>typeof d=="function")&&(s="local",a="nonserializable-options"),{mode:s,reason:a,estimate:{pages:o.pages,cells:o.cells,bytes:o.bytes},hardCancellation:s==="worker"}}function X(e){if(e.mode!==void 0&&!["auto","local","worker"].includes(e.mode))throw new TypeError("无效的导出执行模式");if(e.fallback!==void 0&&!["local","error"].includes(e.fallback))throw new TypeError("无效的导出回退策略");u.validateBudget({...e.budget,maxDurationMs:e.timeoutMs??e.budget?.maxDurationMs??12e4})}function A(e,r){I.observeOutput(()=>e.onDecision?.({...r,estimate:{...r.estimate}}))}function B(e,r){return{...e,mode:"local",reason:r,hardCancellation:!1}}function D(e,r,t){u.assertBudget(t,"maxRows",e.stats.rows),u.assertBudget(t,"maxPages",e.stats.pages),u.assertBudget(t,"maxCells",e.stats.cells),u.assertBudget(t,"maxOutputBytes",e.bytes.byteLength),O.assertPreparedOutputBudget({...r,prepared:{...r.prepared,stats:e.stats}},t)}function J(e,r){const t={...u.DEFAULT_REPORT_RUNTIME_BUDGET,...r.budget},n=O.capturePreparedHandoff(e.prepared,t.maxPreparedBytes,e.signal),o={...e,prepared:n.prepared,pdf:O.snapshotPdfFonts(e.pdf),xlsx:O.snapshotXlsxOptions(e.xlsx)};return{request:o,forward:()=>({...o,prepared:n.forward()})}}function Q(e,r){X(e);const t={...e,thresholds:{...e.thresholds},budget:{...u.DEFAULT_REPORT_RUNTIME_BUDGET,...e.budget}},n=t.timeoutMs??t.budget.maxDurationMs??12e4,o=W.createReportRuntime({reports:{},budget:{...t.budget,maxDurationMs:n}}),s=new Set;let a=!1;const d=t.mode!=="worker"&&t.fallback!=="error";async function y(i,b){const h=Date.now(),g=()=>{const m=n-(Date.now()-h);if(m<=0)throw new u.ReportRuntimeError("timeout",`报表执行超过 ${n}ms`);return m};let p=K(i,t);if(p.reason==="nonserializable-options"&&t.mode==="worker")throw new TypeError("Worker 模式不接受函数选项;请使用本地模式或可序列化配置");if(p.mode==="worker"&&!r){if(!d)throw new M(new Error("未配置 workerFactory"));p=B(p,"worker-unavailable")}const k=J(i,t),l=k.request;if(A(t,p),u.throwIfAborted(i.signal),p.mode==="worker")try{const m=r(g());if(!m.exportPrepared)throw new TypeError("隔离执行器缺少 exportPrepared");const{signal:f,onEvent:c,...w}=l,R=await m.exportPrepared(w,f,c);return u.throwIfAborted(f),D(R,l,t.budget),{...R,execution:p}}catch(m){if(!(m instanceof M)||!d)throw m;u.throwIfAborted(i.signal),p=B(p,"worker-start-failed"),A(t,p)}b&&(l.prepared=W.enforcePrepared(l.prepared,t.budget),O.assertPreparedOutputBudget(l,t.budget));const v=b?await u.controlled(i.signal,g(),m=>b({...l,signal:m})):await u.controlled(i.signal,g(),m=>o.exportPrepared({...k.forward(),signal:m}));return u.throwIfAborted(i.signal),b&&W.assertReportExportResult(v,l.format),D(v,l,t.budget),{...v,execution:p}}return{async exportPrepared(i,b){if(a)throw new u.ReportRuntimeError("closed","导出执行器已释放");if(u.throwIfAborted(i.signal),s.size>=2)throw new u.ReportRuntimeError("queue-full","同时导出的任务已达 2 个,请等待完成后重试");const h=new AbortController;s.add(h);const g=()=>h.abort(i.signal?.reason);i.signal?.addEventListener("abort",g,{once:!0});try{return await y({...i,signal:h.signal},b)}finally{i.signal?.removeEventListener("abort",g),s.delete(h)}},cancel(){for(const i of s)i.abort()},dispose(){a=!0;for(const i of s)i.abort()}}}function q(e={}){const r=e.workerFactory,t={timeoutMs:e.timeoutMs??e.budget?.maxDurationMs,budget:{...e.budget}};return Q(e,r?n=>_(r,{...t,timeoutMs:n}):void 0)}const V=Object.freeze(Object.defineProperty({__proto__:null,createAutoReportExporter:q},Symbol.toStringTag,{value:"Module"}));exports.ReportWorkerStartError=M;exports.auto=V;exports.createAutoReportExporter=q;exports.createBrowserReportExecutor=_;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const c=require("./diagnostic-collector-wASg6Fzs.cjs");function D(e,t){c.assertOutputActive(t.signal),c.observeOutput(()=>t.onDiagnostic?.(e)),c.assertOutputActive(t.signal)}class M extends Error{constructor(t,i){super(`Output contains ${i?.total??t.length} known fidelity issue(s): ${t[0]?.code??Object.keys(i?.counts??{})[0]??"unknown"}`),this.diagnostics=t,this.diagnosticSummary=i,this.code="output-fidelity",this.name="OutputFidelityError"}}const C=new Set(["text","rect","line","ellipse"]),k=new Set(["image","chart","barcode","qrcode"]);function $(e,t){if(!e.grid){if(c.isImageBackedComponent(e))return(t==="pdf"||t==="xlsx")&&!/^data:image\/(png|jpe?g);base64,/i.test(e.imageData)?{code:"unsupported-image-format",message:`${t.toUpperCase()} accepts PNG or JPEG data URLs; convert this image before exporting.`}:void 0;if(k.has(e.kind))return{code:"missing-image",message:`${e.kind} requires imageData or a renderer adapter before output.`};if(!C.has(e.kind))return{code:"unsupported-component",message:`Unsupported component kind: ${e.kind}.`};if(t==="xlsx"&&e.kind!=="text")return{code:"unsupported-component",message:`XLSX data export omits ${e.kind} geometry.`}}}function p(e,t,i,n,s){const o=Object.getOwnPropertyDescriptor(e,"meta")?.value,a=o&&Object.getOwnPropertyDescriptor(o,"componentExtension")?.value,u=a&&Object.getOwnPropertyDescriptor(a,"id")?.value,r=a&&Object.getOwnPropertyDescriptor(a,"version")?.value,d=typeof u=="string"&&u.length<=128&&typeof r=="string"&&r.length<=64?{id:u,version:r}:void 0;return{...s,severity:"warning",format:t,pageIndex:i,componentIndex:n,kind:e.kind,nid:e.nid,...d?{extension:d}:{}}}function h(e,t){if(!e||t==="dom")return;const i=[];return e.rotateDeg&&i.push("rotateDeg"),e.opacity!==void 0&&e.opacity!==1&&i.push("opacity"),t!=="xlsx"&&e.align==="justify"&&i.push("justify"),t==="xlsx"&&e.letterSpacing&&i.push("letterSpacing"),i.length?`${t} does not preserve these styles: ${i.join(", ")}.`:void 0}function S(e){if(!e)return;const t=["backgroundColor","align","verticalAlign","lineHeight","borderTop","borderRight","borderBottom","borderLeft","borderColor","lineColor","lineWidthPt"].filter(i=>e[i]!==void 0);return t.length?`XLSX rich text does not retain independent run styles: ${t.join(", ")}.`:void 0}function L(e){if(e.kind!=="text")return;const t=S(e.style);if(e.leftMm||e.topMm||t)return{code:"unsupported-style",message:`Nested XLSX text is retained as rich text in component order; absolute child offsets and independent paragraph styles are not retained.${t?` ${t}`:""}`}}function m(e,t,i,n,s,o){const a=u=>{s.push({...p(e,t,i,n,{code:"unsupported-style",message:u}),componentPath:o})};for(const u of e.richParagraphs??[]){t==="xlsx"&&(u.spaceBeforeMm||u.spaceAfterMm||u.indentMm||u.align||u.lineHeight)&&a("XLSX rich text preserves fonts and paragraph newlines; paragraph spacing, indentation and alignment are not retained.");const r=h({align:u.align},t);r&&a(r);for(const d of u.segments){const l=h(d.style,t)??(t==="xlsx"?S(d.style):void 0);l&&a(l)}}}function w(e,t,i,n,s,o,a){if(a.has(e))return;const u=new Set(a).add(e),r=$(e,t);r&&o.push({...p(e,t,i,n,r),componentPath:s});const d=h(e.style,t);d&&o.push({...p(e,t,i,n,{code:"unsupported-style",message:d}),componentPath:s}),m(e,t,i,n,o,s),B(e,t,i,n,s,o,u)}function X(e,t,i){if(e.grid)return{code:"nested-components-omitted",message:"XLSX cannot place a nested grid inside a single cell; the nested grid is omitted."};const n=L(e);if(n)return n;if(c.isImageBackedComponent(e)&&(e.leftMm<0||e.topMm<0||e.leftMm+e.widthMm>t+.001||e.topMm+e.heightMm>i+.001))return{code:"unsupported-style",message:"XLSX cannot clip a child image to a cell; it retains the original image dimensions."}}function j(e){let t;return(i,n,s,o)=>{t??=new Map(c.resolveGridLayout(e.grid,e.widthMm,e.heightMm).cells.map(r=>[`${r.ri}:${r.ci}`,r]));const a=t.get(`${n}:${s}`),u=2*(e.grid?.paddingMm??.5);return X(i,(a?.widthMm??0)-u-(o?.indentMm??0),(a?.heightMm??0)-u)}}function B(e,t,i,n,s,o,a){const u=j(e);for(const[r,d]of(e.grid?.cells??[]).entries())for(const[l,g]of d.entries()){g?.dataBar!==void 0&&!c.validDataBar(g.dataBar)&&o.push({...p(e,t,i,n,{code:"unsupported-style",message:"Invalid resolved data-bar geometry or color; visual data bars require ordered 0–1 ratios and #RRGGBB colors."}),componentPath:[...s,r,l]});const v=h(g?.style,t);v&&o.push({...p(e,t,i,n,{code:"unsupported-style",message:v}),componentPath:[...s,r,l]}),g?.richParagraphs?.length&&m({...e,richParagraphs:g.richParagraphs},t,i,n,o,[...s,r,l]);for(const[E,f]of(g?.children??[]).entries()){const O=[...s,r,l,E];if(t==="xlsx"){const b=u(f,r,l,g);if(b&&o.push({...p(f,t,i,n,b),componentPath:O}),f.grid)continue}w(f,t,i,n,O,o,a)}}}function y(e,t,i){c.assertBoundedRenderTree(e),e.pages.forEach((n,s)=>n.components.forEach((o,a)=>w(o,t,s,a,[],i,new Set)))}function A(e,t){const i=[];return y(e,t,i),i}function G(e,t,i=c.DEFAULT_DIAGNOSTIC_LIMIT){const n=c.createDiagnosticCollector(i);return y(e,t,n),n.snapshot()}function x(e,t,i,n){c.assertOutputActive(i.signal);const s=c.createDiagnosticCollector(i.diagnosticLimit);n?.diagnosticSummary?s.merge(n.diagnosticSummary):n?.diagnostics.forEach(r=>s.push(r));const o=s.entries.length,a=i.diagnosticLimit===void 0?void 0:new Set(s.entries);if(y(e,t,{push:r=>{c.assertOutputActive(i.signal),s.push(r)}}),(a?s.entries.filter(r=>!a.has(r)):s.entries.slice(o)).forEach(r=>D(r,i)),i.fidelity==="strict"&&s.total)throw new M(s.entries,i.diagnosticLimit===void 0?void 0:s.snapshot());return s}function P(e,t,i){return x(e,t,i).entries}exports.OutputFidelityError=M;exports.collectOutputDiagnostics=x;exports.inspectOutputCapabilities=A;exports.inspectOutputCapabilitiesSummary=G;exports.notifyOutputDiagnostic=D;exports.reportOutputDiagnostics=P;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function Y(r,e,t){if(!Array.isArray(r)||Object.getPrototypeOf(r)!==Array.prototype||r.length>e)throw new TypeError(`${t}应为有界普通数组`);if(Reflect.ownKeys(r).length!==r.length+1)throw new TypeError(`${t}不支持自定义数组方法或迭代器`);const n=[];for(let o=0;o<r.length;o++){const c=Object.getOwnPropertyDescriptor(r,String(o));if(!c||!Object.prototype.hasOwnProperty.call(c,"value"))throw new TypeError(`${t}不支持空洞或访问器`);n.push(c.value)}return n}const O=1e3;function p(r){if(!Number.isSafeInteger(r)||r<0||r>O*2)throw new Error("十进制精度超出预算");return 10n**BigInt(r)}function j(r){if(r.coefficient.toString().length>O*2||r.scale>O*2)throw new Error("十进制结果超出精度预算");return r}function u(r){if(typeof r!="string"&&!(typeof r=="number"&&Number.isFinite(r)))throw new Error("十进制参数必须是有限数字或十进制文本");const e=String(r);if(e.length>O)throw new Error("十进制文本超出精度预算");const t=/^([+-]?)(\d+)(?:\.(\d*))?(?:[eE]([+-]?\d{1,4}))?$/.exec(e);if(!t)throw new Error("无效十进制文本");const n=t[3]??"",o=Number(t[4]??0),c=n.length-o,i=BigInt(`${t[1]==="-"?"-":""}${t[2]}${n}`);return j(c<0?{coefficient:i*p(-c),scale:0}:{coefficient:i,scale:c})}function L(r,e){const t=Math.max(r.scale,e.scale);return[r.coefficient*p(t-r.scale),e.coefficient*p(t-e.scale),t]}function y(r,e){const[t,n]=L(r,e);return t<n?-1:t>n?1:0}function E(r,e){const[t,n,o]=L(r,e);return j({coefficient:t+n,scale:o})}function M(r,e){return j({coefficient:r.coefficient*e.coefficient,scale:r.scale+e.scale})}function H(r,e){const t=r/e,n=r%e,o=c=>c<0n?-c:c;return o(n)*2n<o(e)?t:t+(r<0n==e<0n?1n:-1n)}function h(r){if(!Number.isInteger(r)||r<0||r>100)throw new Error("十进制小数位应为 0–100 的整数")}function N(r,e,t=20){if(h(t),e.coefficient===0n)throw new Error("不能除以零");const n=e.scale-r.scale+t,o=r.coefficient*p(Math.max(0,n)),c=e.coefficient*p(Math.max(0,-n));return j({coefficient:H(o,c),scale:t})}function A(r,e){let t=r.coefficient,n=r.scale;e!==void 0&&(h(e),t=e>=n?t*p(e-n):H(t,p(n-e)),n=e);const o=t<0n,c=(o?-t:t).toString().padStart(n+1,"0");let i=n?c.slice(-n):"";return e===void 0&&(i=i.replace(/0+$/,"")),`${o?"-":""}${n?c.slice(0,-n):c}${i?`.${i}`:""}`}function nr(r,e,t=!1,n=!1){let o=u(r);n&&(o=M(o,{coefficient:100n,scale:0}));const[c,i]=A(o,e).split(".");return`${t?c.replace(/\B(?=(\d{3})+(?!\d))/g,","):c}${i===void 0?"":`.${i}`}${n?"%":""}`}const or=["sum","count","avg","min","max","weightedAvg"];function V(r){if(typeof r!="number"||!Number.isFinite(r))throw new Error("聚合度量必须是有限数字,不能隐式转换;小数文本请显式选择 decimal");return r}function D(r,e){return e&&Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}function ir(r){let e=0,t=0,n=0,o=0,c=1/0,i=-1/0;const a=s=>{const f=s-n,l=t+f;n=l-t-f,t=l};return{add(s){const f=D(s,r.field);if(r.op==="count"){(!r.field||f!=null)&&e++;return}if(f==null)return;const l=V(f),d=r.op==="weightedAvg"?D(s,r.weightField):1;if(d==null)return;const x=V(d);if(r.op==="weightedAvg"&&x<0)throw new Error("加权平均的权重不能为负数");["sum","avg","weightedAvg"].includes(r.op)&&a(l*x),o+=x,c=Math.min(c,l),i=Math.max(i,l),e++},value(){if(r.op==="count")return e;if(!e)return null;const s=r.op==="min"?c:r.op==="max"?i:r.op==="avg"?t/e:r.op==="weightedAvg"?o===0?null:t/o:t;if(s!==null&&!Number.isFinite(s))throw new Error("聚合计算溢出");return s}}}function cr(r){let e=0,t=u("0"),n=u("0"),o,c;return{add(i){const a=D(i,r.field);if(r.op==="count"){(!r.field||a!=null)&&e++;return}if(a==null)return;const s=r.op==="weightedAvg"?D(i,r.weightField):"1";if(s==null)return;const f=u(a),l=u(s);if(r.op==="weightedAvg"&&l.coefficient<0n)throw new Error("加权平均的权重不能为负数");["sum","avg","weightedAvg"].includes(r.op)&&(t=E(t,M(f,l))),r.op==="weightedAvg"&&(n=E(n,l)),(!o||y(f,o)<0)&&(o=f),(!c||y(f,c)>0)&&(c=f),e++},value(){if(r.op==="count")return e;if(!e||r.op==="weightedAvg"&&n.coefficient===0n)return null;let i=r.op==="min"?o:r.op==="max"?c:t;return r.op==="avg"&&(i=N(t,u(e),r.digits)),r.op==="weightedAvg"&&(i=N(t,n,r.digits)),A(i,r.digits)}}}function R(r){if(r.digits!==void 0&&h(r.digits),r.numeric!==void 0&&r.numeric!=="number"&&r.numeric!=="decimal")throw new Error("未知聚合数值模式");if(!or.includes(r.op))throw new Error("未知聚合操作");if(r.op!=="count"&&!r.field)throw new Error("聚合需要度量字段");if(r.op==="weightedAvg"&&!r.weightField)throw new Error("加权平均需要权重字段");return r.numeric==="decimal"?cr(r):ir(r)}function P(r,e){const t=R(e);for(const n of r)t.add(n);return t.value()}const Q=new Set(["__proto__","prototype","constructor"]);function q(r){if(!r||typeof r!="object"||Array.isArray(r)||![Object.prototype,null].includes(Object.getPrototypeOf(r)))throw new Error("条件应为普通声明式对象");for(const[e,t]of Object.entries(Object.getOwnPropertyDescriptors(r)))if(Q.has(e)||!Object.prototype.hasOwnProperty.call(t,"value"))throw new Error("条件不允许访问器或不安全属性")}function W(r){if(typeof r!="string"||!r.trim()||r.length>512||Q.has(r))throw new Error("条件字段应为安全的非空字段名")}function k(r){if(r!==null&&typeof r!="boolean"&&typeof r!="string"&&!(typeof r=="number"&&Number.isFinite(r)))throw new Error("条件常量应为有限 JSON 标量");if(typeof r=="string"&&r.length>16384)throw new Error("条件文本超出预算")}function T(r){if(typeof r!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(r))throw new Error("日期条件使用 YYYY-MM-DD 日历日");const[e,t,n]=r.split("-").map(Number),o=new Date(0);if(o.setUTCFullYear(e,t-1,n),o.setUTCHours(0,0,0,0),o.getUTCFullYear()!==e||o.getUTCMonth()!==t-1||o.getUTCDate()!==n)throw new Error("无效日历日");return r}function z(r){return["string","boolean"].includes(typeof r)||typeof r=="number"&&Number.isFinite(r)}function J(r){return r==null||r===""}function ar(r){const e=r.values?.[0]??(r.right&&"value"in r.right?r.right.value:r.value);return r.valueType??r.numeric??(typeof e=="number"?"decimal":typeof e=="boolean"?"boolean":"text")}function b(r,e,t){if(J(r)||J(e))return;const n=ar(t);try{if(n==="decimal")return y(u(r),u(e));if(n==="number")return!["number","string"].includes(typeof r)||!["number","string"].includes(typeof e)?void 0:y(u(r),u(e));if(n==="date"&&(r=T(r),e=T(e)),n==="boolean"&&(typeof r!="boolean"||typeof e!="boolean")||n==="text"&&(!z(r)||!z(e)))return;const o=String(r),c=String(e);return o<c?-1:o>c?1:0}catch{return}}function sr(r){if(W(r.field),![">",">=","<","<=","==","!=","between","contains","isNull","isNotNull"].includes(r.op))throw new Error("未知条件运算符");if(r.numeric!==void 0&&!["number","decimal"].includes(r.numeric))throw new Error("未知条件数值模式");if(r.valueType!==void 0&&!["number","decimal","text","date","boolean"].includes(r.valueType))throw new Error("未知条件值类型");if(!(r.op==="isNull"||r.op==="isNotNull"))if(r.op==="between"){if(!Array.isArray(r.values)||r.values.length!==2||Object.keys(r.values).length!==2)throw new Error("范围条件需要两个明确边界");r.values.forEach(k);const e=b(r.values[0],r.values[1],r);if(e===void 0||e>0)throw new Error("范围边界无效或顺序颠倒")}else if(r.right!==void 0){if(q(r.right),Object.keys(r.right).length!==1)throw new Error("条件 right 只能指定一个 field 或 value");if("field"in r.right?W(r.right.field):k(r.right.value),r.value!==void 0)throw new Error("条件不能同时指定 value 和 right")}else k(r.value)}function C(r,e){if(e===void 0)return!1;switch(r){case">":return e>0;case">=":return e>=0;case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;default:return!1}}function fr(r){sr(r),r={...r,right:r.right?{...r.right}:void 0,values:r.values?[r.values[0],r.values[1]]:void 0};const e=(t,n)=>Object.prototype.hasOwnProperty.call(t,n)?t[n]:void 0;return t=>{const n=e(t,r.field);if(r.op==="isNull")return n==null;if(r.op==="isNotNull")return n!=null;if(r.op==="between")return C(">=",b(n,r.values[0],r))&&C("<=",b(n,r.values[1],r));const o=r.right?"field"in r.right?e(t,r.right.field):r.right.value:r.value;return r.op==="contains"?typeof n=="string"&&typeof o=="string"&&n.includes(o):C(r.op,b(n,o,r))}}function w(r,e={nodes:0},t=0){if(++e.nodes>256||t>16)throw new Error("条件超出深度或节点预算");if(q(r),["all","any","not","field"].filter(o=>Object.prototype.hasOwnProperty.call(r,o)).length!==1)throw new Error("条件只能指定一种组合或比较");if("not"in r){const o=w(r.not,e,t+1);return c=>!o(c)}if("all"in r||"any"in r){const o="all"in r?r.all:r.any;if(!Array.isArray(o)||o.length<1||o.length>256||Object.keys(o).length!==o.length)throw new Error("组合条件需要有界、无空位的非空数组");const c=o.map(i=>w(i,e,t+1));return"all"in r?i=>c.every(a=>a(i)):i=>c.some(a=>a(i))}return fr(r)}function lr(r,e){return w(e)(r)}function rr(r){w(r);const e=new Set;function t(n){"all"in n?n.all.forEach(t):"any"in n?n.any.forEach(t):"not"in n?t(n.not):(e.add(n.field),n.right&&"field"in n.right&&e.add(n.right.field))}return t(r),[...e]}const ur=[{name:"add",minArgs:2,maxArgs:256,input:"numeric",output:"numeric",example:"add(quantity, adjustment)"},{name:"subtract",minArgs:2,maxArgs:2,input:"numeric",output:"numeric",example:"subtract(input, output)"},{name:"multiply",minArgs:2,maxArgs:256,input:"numeric",output:"numeric",example:"multiply(quantity, price)"},{name:"divide",minArgs:2,maxArgs:2,input:"numeric",output:"numeric",example:"divide(amount, quantity)"},{name:"coalesce",minArgs:2,maxArgs:256,input:"scalar",output:"scalar",example:"coalesce(actual, planned)"},{name:"if",minArgs:2,maxArgs:2,input:"condition + branches",output:"scalar",example:"if(quantity > 0, divide(amount, quantity), null)"},{name:"round",minArgs:1,maxArgs:2,input:"numeric, digits?",output:"numeric",example:"round(amount, 2)"},{name:"abs",minArgs:1,maxArgs:1,input:"numeric",output:"numeric",example:"abs(difference)"},{name:"concat",minArgs:2,maxArgs:256,input:"text",output:"text",example:"concat(plant, '-' , heat)"},{name:"trim",minArgs:1,maxArgs:1,input:"text",output:"text",example:"trim(heat)"},{name:"upper",minArgs:1,maxArgs:1,input:"text",output:"text",example:"upper(grade)"},{name:"lower",minArgs:1,maxArgs:1,input:"text",output:"text",example:"lower(code)"},{name:"dateYear",minArgs:1,maxArgs:1,input:"YYYY-MM-DD",output:"number",example:"dateYear(reportDate)"},{name:"dateMonth",minArgs:1,maxArgs:1,input:"YYYY-MM-DD",output:"number",example:"dateMonth(reportDate)"},{name:"dateDay",minArgs:1,maxArgs:1,input:"YYYY-MM-DD",output:"number",example:"dateDay(reportDate)"}],$=Object.freeze(ur.map(r=>Object.freeze(r)));function mr(r,e,t,n,o){if(e.some(a=>a==null)){if(o==="error")throw new Error("函数参数包含空值");return null}if(r==="round"||r==="abs")return dr(r,e,t,n);if(r.startsWith("date")){const a=T(e[0]);return Number(a.slice(r==="dateYear"?0:r==="dateMonth"?5:8,r==="dateYear"?4:r==="dateMonth"?7:10))}if(e.some(a=>typeof a!="string"))throw new Error("文本函数只接受文本,不隐式转换数字或空值");if(e.reduce((a,s)=>a+s.length,0)>1e6)throw new Error("计算文本超出长度预算");const c=e[0],i=r==="concat"?e.join(""):r==="trim"?c.trim():r==="upper"?c.toUpperCase():c.toLowerCase();if(i.length>1e6)throw new Error("计算文本超出长度预算");return i}function dr(r,e,t,n){const o=e[0];if(t!=="decimal"&&(typeof o!="number"||!Number.isFinite(o)))throw new Error("普通数值函数需要有限数字");const c=u(o);r==="abs"&&(c.coefficient=c.coefficient<0n?-c.coefficient:c.coefficient);const i=r==="round"?e.length===2?e[1]:n??0:n;if(i!==void 0){if(typeof i!="number")throw new Error("小数位必须为数字");h(i)}const a=A(c,i),s=Number(a);if(t!=="decimal"&&!Number.isFinite(s))throw new Error("计算结果不是有限数字");return t==="decimal"?a:s}const gr=new Set(["__proto__","prototype","constructor"]);function m(r){if(typeof r!="string"||!r.trim()||gr.has(r))throw new Error("计算字段应为安全的非空字段名")}function _(r){return r===null||["string","boolean"].includes(typeof r)||typeof r=="number"&&Number.isFinite(r)}function pr(r){if(r.some(e=>typeof e!="number"||!Number.isFinite(e)))throw new Error("算术参数必须是有限数字;空值和小数文本不会隐式转换");return r}function wr(r,e){const t=pr(e);let n;if(r==="add")n=t.reduce((o,c)=>o+c,0);else if(r==="multiply")n=t.reduce((o,c)=>o*c,1);else if(r==="subtract")n=t[0]-t[1];else{if(t[1]===0)throw new Error("不能除以零");n=t[0]/t[1]}if(!Number.isFinite(n))throw new Error("计算结果不是有限数字");return n}function hr(r,e,t){const n=e.map(u);let o;return r==="add"?o=n.reduce(E):r==="multiply"?o=n.reduce(M):r==="subtract"?o=E(n[0],{...n[1],coefficient:-n[1].coefficient}):o=N(n[0],n[1],t),A(o,t)}function yr(r,e,t){return t.nulls!=="error"&&e.some(n=>n==null)||r==="divide"&&t.divisionByZero==="null"&&(t.numeric==="decimal"?u(e[1]).coefficient===0n:e[1]===0)?null:t.numeric==="decimal"?hr(r,e,t.digits):wr(r,e)}function Er(r,e){r.field!==void 0&&m(r.field),r.weightField!==void 0&&m(r.weightField);const t={op:r.aggregate,field:r.field,weightField:r.weightField,numeric:e.numeric,digits:e.digits};P([],t);const n=new WeakMap;return o=>{let c=n.get(o.rows);if(!c){try{c={value:P(o.rows,t)}}catch(i){c={error:i instanceof Error?i:new Error(String(i))}}n.set(o.rows,c)}if(c.error)throw c.error;return c.value}}function Ar(r,e){for(const t of r){const n=t(e);if(n!=null)return n}return null}function I(r,e={},t={nodes:0},n=0){if(++t.nodes>256||n>16)throw new Error("计算表达式超出深度或节点预算");if(!r||typeof r!="object"||Array.isArray(r))throw new Error("计算表达式应为声明式对象");if("aggregate"in r)return Er(r,e);if("field"in r){m(r.field);const o=r.field;return({row:c})=>Object.prototype.hasOwnProperty.call(c,o)?c[o]:void 0}if("value"in r){if(!_(r.value))throw new Error("常量应为有限 JSON 标量");return()=>r.value}return br(r,e,t,n)}function br(r,e,t,n){const o=$.find(a=>a.name===r.op);if(!o||!Array.isArray(r.args))throw new Error("未知计算操作");if(r.args.length>256||Object.keys(r.args).length!==r.args.length)throw new Error("计算参数超出预算或包含空位");if(r.args.length<o.minArgs||r.args.length>o.maxArgs)throw new Error("运算参数数量不正确");const c=r.op==="if"?w(r.condition,t,n+1):void 0;if(r.op!=="if"&&r.condition!==void 0)throw new Error("仅 IF 运算接受 condition");const i=r.args.map(a=>I(a,e,t,n+1));return c?a=>i[c(a.row)?0:1](a):["add","subtract","multiply","divide","coalesce"].includes(r.op)?r.op==="coalesce"?a=>Ar(i,a):a=>yr(r.op,i.map(s=>s(a)),e):a=>mr(r.op,i.map(s=>s(a)),e.numeric,e.digits,e.nulls)}function vr(r){I(r);const e=new Set,t=n=>{"field"in n&&n.field&&e.add(n.field),"aggregate"in n&&n.weightField&&e.add(n.weightField),"args"in n&&(n.args.forEach(t),n.condition&&rr(n.condition).forEach(o=>e.add(o)))};return t(r),[...e]}function S(r,e,t){if(r===void 0)return e;if(!Number.isSafeInteger(r)||Number(r)<1||Number(r)>t)throw new RangeError("图表预算超出允许范围");return Number(r)}function er(r){if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError("图表绑定应为对象");if(m(r.dataset),m(r.categoryField),!["bar","line","stackedBar","percentBar"].includes(r.type))throw new TypeError("图表类型无效");if(r.sort!==void 0&&!["asc","desc"].includes(r.sort))throw new TypeError("图表排序无效");if(r.title!==void 0&&(typeof r.title!="string"||r.title.length>512))throw new TypeError("图表标题过长");if(r.showValues!==void 0&&typeof r.showValues!="boolean")throw new TypeError("图表数值标签应为布尔值");if(!Array.isArray(r.measures)||!r.measures.length||r.measures.length>12)throw new RangeError("图表支持 1–12 个度量");for(const e of Y(r.measures,12,"图表度量"))Or(e);S(r.maxRows,1e5,1e5),S(r.maxCategories,200,200)}function Or(r){if(!r||typeof r!="object"||Array.isArray(r))throw new TypeError("图表度量应为对象");if(r.field!==void 0&&m(r.field),r.weightField!==void 0&&m(r.weightField),r.label!==void 0&&(typeof r.label!="string"||r.label.length>256))throw new TypeError("图表系列名称过长");if(r.color!==void 0&&!/^#[\da-f]{6}$/i.test(r.color))throw new TypeError("图表颜色应为 #RRGGBB");R(r)}function Nr(r){if(r==null)return{key:"null",label:"—"};if(typeof r!="string"&&typeof r!="boolean"&&!(typeof r=="number"&&Number.isFinite(r)))throw new TypeError("图表分类应为文本、布尔或有限数字");const e=String(r);if(e.length>512)throw new RangeError("图表分类名称过长");return{key:JSON.stringify([typeof r,r]),label:e}}function Dr(r){if(r===null)return null;const e=Number(r);if(!Number.isFinite(e))throw new RangeError("聚合结果超出图表有限数值范围");return e}function Sr(r,e,t){if(t?.aborted){const a=new Error("图表数据处理已取消");throw a.name="AbortError",a}er(e);const n=Y(e.measures,12,"图表度量");if(!Array.isArray(r)||r.length>S(e.maxRows,1e5,1e5))throw new RangeError("图表数据超出行数预算");const o=new Map,c=S(e.maxCategories,200,200);for(let a=0;a<r.length;a++){if(t?.aborted){const d=new Error("图表数据处理已取消");throw d.name="AbortError",d}const s=r[a];if(!s||typeof s!="object"||Array.isArray(s))throw new TypeError("图表数据行应为对象");const f=Nr(Object.prototype.hasOwnProperty.call(s,e.categoryField)?s[e.categoryField]:null);let l=o.get(f.key);if(!l){if(o.size>=c)throw new RangeError("图表分类超出预算,请明确筛选或聚合数据");l={label:f.label,accumulators:n.map(R)},o.set(f.key,l)}l.accumulators.forEach(d=>d.add(s))}const i=[...o.values()];return e.sort&&i.sort((a,s)=>(e.sort==="desc"?-1:1)*(a.label<s.label?-1:a.label>s.label?1:0)),{categories:i.map(a=>a.label),series:n.map((a,s)=>({name:a.label??`${a.field??"记录"} · ${a.op}`,values:i.map(f=>Dr(f.accumulators[s].value())),...a.color?{color:a.color}:{}}))}}const Fr=16,B=1024*1024,K=5e5,F=new WeakMap,g=Symbol("uncacheable-computation-definition");function v(r,e,t=0){if(++e.nodes>1e4||t>32)throw g;if(r==null)return[String(r)];if(typeof r=="number")return["number",Object.is(r,-0)?"-0":String(r)];if(typeof r=="boolean")return["boolean",r];if(typeof r=="string"){if(e.units+=r.length,e.units>B)throw g;return["string",r]}if(typeof r!="object")throw g;if(Array.isArray(r)){if(Object.getPrototypeOf(r)!==Array.prototype||Object.keys(r).length!==r.length)throw g;return["array",Array.from({length:r.length},(n,o)=>v(X(r,String(o)),e,t+1))]}if(Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null)throw g;return["object",Object.keys(r).map(n=>[v(n,e,t+1),v(X(r,n),e,t+1)])]}function X(r,e){const t=Object.getOwnPropertyDescriptor(r,e);if(!t||t.get||t.set)throw g;return t.value}function jr(r){try{return JSON.stringify(v(r,{nodes:0,units:0}))}catch(e){if(e!==g)throw e;return}}function Mr(r){F.set(r,{programs:new Map,units:0,slots:0})}function Rr(r,e){const t=F.get(r);if(!t)return;const n={programs:new Map,units:t.units,slots:t.slots};for(const[o,c]of t.programs){const i=new WeakMap;e.forEach((a,s)=>{const f=c.rows.get(r[s]);f&&i.set(a,f)}),n.programs.set(o,{...c,rows:i})}F.set(e,n)}function xr(r,e,t){const n=F.get(r);if(!n||e.some(f=>typeof f.expression=="string"))return;const o=jr(e);if(o===void 0||o.length>B)return;const c=n.programs.get(o);if(c)return c;const i=t(),a=r.length*i.reduce((f,l)=>f+l.dependencies.length+1,0),s={fields:i,rows:new WeakMap,slots:a,cacheRows:a<=K};if(!s.cacheRows)return s;for(;n.programs.size>=Fr||n.units+o.length>B||n.slots+a>K;){const f=n.programs.keys().next().value;n.slots-=n.programs.get(f).slots,n.units-=f.length,n.programs.delete(f)}return n.programs.set(o,s),n.units+=o.length,n.slots+=a,s}function kr(r,e,t,n){if((t.definition.scope??"row")!=="row")return;const o=r.program?.rows.get(e)?.get(t.definition.field);return o?.dependencies.every((c,i)=>Object.is(n[t.dependencies[i]],c))?o:void 0}function Cr(r,e,t,n,o){const c=r.program;if(!c?.cacheRows||(t.definition.scope??"row")!=="row")return;let i=r.writes.get(e);i||(i=new Map(c.rows.get(e)),r.writes.set(e,i),c.rows.set(e,i)),i.set(t.definition.field,{dependencies:t.dependencies.map(a=>n[a]),value:n[t.definition.field],...o?{issue:{field:o.field,message:o.message}}:{}})}function Pr(r){if(m(r.field),r.scope!==void 0&&!["row","group","dataset"].includes(r.scope))throw new Error("未知计算范围");if(r.numeric!==void 0&&r.numeric!=="number"&&r.numeric!=="decimal")throw new Error("未知数值模式");if(r.digits!==void 0&&h(r.digits),r.nulls!==void 0&&r.nulls!=="propagate"&&r.nulls!=="error")throw new Error("未知空值规则");if(r.divisionByZero!==void 0&&r.divisionByZero!=="null"&&r.divisionByZero!=="error")throw new Error("未知除零规则");if(r.scope==="group"&&(!Array.isArray(r.groupBy)||!r.groupBy.length))throw new Error("分组计算需要 groupBy 字段");Tr(r)}function Tr(r){if(r.groupBy!==void 0){if(!Array.isArray(r.groupBy)||r.groupBy.length>16)throw new Error("计算分组最多 16 级");r.groupBy.forEach(m)}if(r.dependsOn!==void 0){if(!Array.isArray(r.dependsOn)||r.dependsOn.length>2048)throw new Error("计算依赖超出预算");r.dependsOn.forEach(m)}}function U(r){return[...new Set([...typeof r.expression=="string"?r.dependsOn??[]:vr(r.expression),...r.groupBy??[]])]}function tr(r){if(!Array.isArray(r)||r.length>2048)throw new Error("计算字段应为数组且最多2048项");const e=new Map;for(const i of r){if(Pr(i),e.has(i.field))throw new Error(`计算字段重复:${i.field}`);e.set(i.field,i)}const t=new Set,n=new Set,o=[];function c(i){if(!n.has(i.field)){if(t.has(i.field))throw new Error(`计算字段存在循环依赖:${[...t,i.field].join(" → ")}`);t.add(i.field);for(const a of U(i)){const s=e.get(a);s&&c(s)}t.delete(i.field),n.add(i.field),o.push(i)}}return r.forEach(c),o}function $r(r){try{const e=tr(r);return{valid:!0,errors:[],order:e.map(t=>t.field),fields:r.map(t=>({field:t.field,dependencies:U(t),scope:t.scope??"row"}))}}catch(e){return{valid:!1,errors:[e instanceof Error?e.message:String(e)],fields:[],order:[]}}}function Br(r=[]){return{fields:r.map(e=>({...e})),functions:$,operations:$.map(e=>e.name),aggregates:["sum","count","avg","min","max","weightedAvg"],scopes:["row","group","dataset"],numericModes:["number","decimal"],rules:{nulls:"propagate",aggregateNulls:"skip",emptyAggregate:null,countEmpty:0,divisionByZero:"error",decimalOutput:"string",rounding:"half-away-from-zero"}}}function Z(r){return tr(r.fields).map(e=>{const t=U(e);if(typeof e.expression!="string")return{definition:e,dependencies:t,read:I(e.expression,e)};if(!r.formula)throw new Error("字符串公式需要显式配置 formula adapter");const n=e.expression;return{definition:e,dependencies:t,read:o=>r.formula.evaluate(n,o)}})}function Yr(r,e){return JSON.stringify(e.map(t=>{const n=Object.prototype.hasOwnProperty.call(r,t)?r[t]:null;if(n!=null&&!_(n))throw new Error("分组字段应为有限 JSON 标量");return[typeof n,n??null]}))}function _r(r,e){if(e.scope==="dataset")return()=>r;if(e.scope!=="group"){const o=new WeakMap;return c=>{let i=o.get(c);return i||(i=[c],o.set(c,i)),i}}const t=new Map,n=new WeakMap;for(const o of r){const c=Yr(o,e.groupBy);n.set(o,c);const i=t.get(c);i?i.push(o):t.set(c,[o])}return o=>t.get(n.get(o))}function Ir(r,e){const t=e.maxRows??1e5,n=e.maxCells??2e6;if(!Array.isArray(r)||!Number.isSafeInteger(t)||t<1||r.length>t)throw new Error("计算数据行数超出预算或输入不是数组");if(!Array.isArray(e.fields)||e.fields.length>2048)throw new Error("计算字段应为数组且最多2048项");if(!Number.isSafeInteger(n)||n<1||r.length*e.fields.length>n)throw new Error("计算单元格超出 maxCells 预算")}function G(r){if(r?.aborted){const e=new Error("数据计算已取消");throw e.name="AbortError",e}}function Ur(r,e,t,n,o,c){try{const i=r.read({row:e,rowIndex:t,rows:n});if(i!==void 0&&!_(i))throw new Error("计算结果应为有限 JSON 标量,异步公式请先在数据源中求值");e[r.definition.field]=i??null}catch(i){const a=i instanceof Error?i.message:String(i);if(o.onError!=="null")throw Object.assign(new Error(`第 ${t+1} 行 ${r.definition.field}:${a}`),{cause:i});e[r.definition.field]=null,c.push({rowIndex:t,field:r.definition.field,message:a})}}function Vr(r,e,t,n,o,c,i,a){const s=kr(r,e,t,n);if(s&&(!s.issue||i.onError==="null")){n[t.definition.field]=s.value,s.issue&&a.push({...s.issue,rowIndex:o});return}const f=a.length;Ur(t,n,o,c,i,a),Cr(r,e,t,n,a.length>f?a[a.length-1]:void 0)}function Wr(r,e){Ir(r,e),G(e.signal);const t=xr(r,e.fields,()=>Z(e)),n={program:t,writes:new WeakMap},o=t?.fields??Z(e),c=[],i=r.map((a,s)=>{if(!a||typeof a!="object"||Array.isArray(a))throw new Error(`第 ${s+1} 行应为对象`);return{...a}});for(const a of o){const s=_r(i,a.definition);i.forEach((f,l)=>{G(e.signal),Vr(n,r[l],a,f,l,s(f),e,c)})}return{rows:i,issues:c}}exports.addDecimal=E;exports.aggregateRows=P;exports.chartArray=Y;exports.compareDecimal=y;exports.compileReportPredicate=w;exports.computationFieldName=m;exports.computeDataset=Wr;exports.createAggregateAccumulator=R;exports.createReportChartData=Sr;exports.decimalDigits=h;exports.divideDecimal=N;exports.evaluateReportPredicate=lr;exports.forkComputedDataset=Rr;exports.formatDecimal=nr;exports.getComputationMetadata=Br;exports.multiplyDecimal=M;exports.parseDecimal=u;exports.printDecimal=A;exports.registerComputedDataset=Mr;exports.reportPredicateFields=rr;exports.validateComputedFields=$r;exports.validateReportChartBinding=er;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function u(e){throw new Error(`数据契约无效:${e}`)}function d(e){return typeof e=="string"&&e.trim().length>0&&e.length<=4096}function y(e){for(const n of["description","missingMeaning"])e[n]!==void 0&&!d(e[n])&&u(`${n} 应为 1–4096 位非空字符串`);e.aggregation!==void 0&&!["sum","avg","min","max","count","none"].includes(e.aggregation)&&u("未知字段聚合语义"),e.aggregation&&!["count","none"].includes(e.aggregation)&&!["number","decimal"].includes(e.type)&&u("数值聚合仅适用于 number/decimal"),e.format!==void 0&&l(e),e.calculation!==void 0&&(!e.calculation||!d(e.calculation.description)||!Array.isArray(e.calculation.dependsOn)||!e.calculation.dependsOn.length||e.calculation.dependsOn.length>256||e.calculation.dependsOn.some(n=>typeof n!="string"||!n.trim())||new Set(e.calculation.dependsOn).size!==e.calculation.dependsOn.length)&&u("计算说明需包含说明及 1–256 个唯一依赖字段")}function l(e){const n=e.format;if((!n||!["number","percent","date"].includes(n.kind))&&u("未知字段显示格式"),n.kind==="date"){(e.type!=="date"||n.pattern!==void 0&&(!d(n.pattern)||n.pattern.length>128))&&u("日期格式仅适用于日期,pattern 最多 128 位");return}["number","decimal"].includes(e.type)||u("数值显示格式仅适用于 number/decimal"),n.digits!==void 0&&(!Number.isSafeInteger(n.digits)||n.digits<0||n.digits>100)&&u("显示小数位应为 0–100 的整数"),n.kind==="number"&&n.thousands!==void 0&&typeof n.thousands!="boolean"&&u("thousands 应为布尔值")}function b(e){const n=new Map(e.map(i=>[i.field,i])),t=new Set;for(const i of e){const o=[{field:i.field,exit:!1}],m=new Set;for(;o.length;){const s=o.pop();if(s.exit){m.delete(s.field),t.add(s.field);continue}if(m.has(s.field)&&u("字段计算依赖存在循环"),t.has(s.field))continue;const r=n.get(s.field);r||u(`计算依赖字段未声明:${s.field}`),m.add(s.field),o.push({field:s.field,exit:!0});for(const c of r.calculation?.dependsOn??[])o.push({field:c,exit:!1})}}}const x=["text","number","boolean","date","decimal"],w=new Set(["__proto__","prototype","constructor"]);function a(e){throw new Error(`数据契约无效:${e}`)}function h(e){(!e||!Array.isArray(e.fields)||!e.fields.length||e.fields.length>2048)&&a("fields 应包含 1–2048 个字段");const n=new Set;for(const t of e.fields)(!t||typeof t.field!="string"||!t.field.trim()||w.has(t.field)||n.has(t.field))&&a("字段名应安全、非空且唯一"),n.add(t.field),x.includes(t.type)||a(`未知字段类型 ${t.type}`),k(t),$(t),y(t),v(t);L(e,n),b(e.fields)}function v(e){e.enum!==void 0&&(!Array.isArray(e.enum)||!e.enum.length||e.enum.some(n=>!f(n,e.type)))&&a("enum 应为匹配字段类型的非空标量数组")}function L(e,n){e.rowKey!==void 0&&((typeof e.rowKey!="string"||!e.rowKey.trim()||!n.has(e.rowKey))&&a("rowKey 应为引用已声明字段的非空字符串"),e.fields.find(t=>t.field===e.rowKey)?.type==="boolean"&&a("布尔字段不能作为业务主键"))}function $(e){for(const n of["label","unit"])e[n]!==void 0&&typeof e[n]!="string"&&a(`${n} 应为字符串`);for(const n of["required","nullable"])e[n]!==void 0&&typeof e[n]!="boolean"&&a(`${n} 应为布尔值`);e.semanticRole!==void 0&&!["identifier","dimension","measure","date","text"].includes(e.semanticRole)&&a("未知字段语义")}function k(e){for(const n of["min","max","minLength","maxLength"]){const t=e[n];t!==void 0&&(!Number.isFinite(t)||n.includes("Length")&&(!Number.isInteger(t)||t<0))&&a(`${n} 无效`)}e.min!==void 0&&e.max!==void 0&&e.min>e.max&&a("min 不能超过 max"),e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&a("minLength 不能超过 maxLength"),e.type!=="number"&&(e.min!==void 0||e.max!==void 0)&&a("min/max 仅适用于 number,精确小数文本需业务校验"),["number","boolean"].includes(e.type)&&(e.minLength!==void 0||e.maxLength!==void 0)&&a("长度约束仅适用于文本类型")}function S(e){const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!n)return!1;const t=Number(n[1]),i=Number(n[2]),o=Number(n[3]),m=t%4===0&&(t%100!==0||t%400===0);return t>0&&i>=1&&i<=12&&o>=1&&o<=[31,m?29:28,31,30,31,30,31,31,30,31,30,31][i-1]}function f(e,n){return n==="number"?typeof e=="number"&&Number.isFinite(e):n==="boolean"?typeof e=="boolean":typeof e!="string"?!1:n==="date"?S(e):n==="decimal"?e.length<=1e4&&/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/.test(e):!0}function O(e,n){if(e==null)return n.required||e===null&&n.nullable===!1?{code:"required",message:"缺少必需字段值"}:void 0;if(!f(e,n.type))return{code:"type",message:`值应为 ${n.type},不会自动转换原始值`};if(n.enum&&!n.enum.includes(e))return{code:"enum",message:"值不在允许的枚举中"};if(typeof e=="number"&&(n.min!==void 0&&e<n.min||n.max!==void 0&&e>n.max))return{code:"range",message:"数值超出范围"};if(typeof e=="string"&&!K(e,n))return{code:"range",message:"文本长度超出范围"}}function K(e,n){if(n.minLength===void 0&&n.maxLength===void 0)return!0;let t=0;for(const i of e)t++;return(n.minLength===void 0||t>=n.minLength)&&(n.maxLength===void 0||t<=n.maxLength)}function g(e,n){const t=e??n;if(!Number.isInteger(t)||t<1)throw new Error("数据校验预算应为正整数");return t}function A(e,n,t){const i=Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0;if((typeof i!="string"||!i.trim())&&!(typeof i=="number"&&Number.isFinite(i)))return"业务主键应为非空字符串或有限数字";const o=JSON.stringify([typeof i,i]);if(t.has(o))return"业务主键重复";t.add(o)}function N(e,n,t={}){h(n);const i=t.path??"$.rows",o=[],m=g(t.maxIssues,100);if(!Array.isArray(e))return{ok:!1,issues:[{code:"row",path:i,message:"数据集应为对象数组"}]};if(e.length>g(t.maxRows,1e5)||e.length*n.fields.length>g(t.maxCells,2e6))return{ok:!1,issues:[{code:"budget",path:i,message:"数据校验超出行数或单元格预算"}]};const s=new Set;for(let r=0;r<e.length&&o.length<m;r++){const c=e[r];if(!c||typeof c!="object"||Array.isArray(c)){o.push({code:"row",path:`${i}[${r}]`,rowIndex:r,message:"行应为对象"});continue}R(c,n,r,i,s,o,m)}return{ok:o.length===0,issues:o}}function R(e,n,t,i,o,m,s){for(const r of n.fields){if(m.length>=s)return;const c=O(Object.prototype.hasOwnProperty.call(e,r.field)?e[r.field]:void 0,r);c&&m.push({...c,rowIndex:t,field:r.field,path:`${i}[${t}].${r.field}`})}if(n.rowKey&&m.length<s){const r=A(e,n.rowKey,o);r&&m.push({code:"row-key",path:`${i}[${t}].${n.rowKey}`,message:r,rowIndex:t,field:n.rowKey})}}function E(e){return h(e),{$schema:"https://json-schema.org/draft/2020-12/schema",type:"array",items:{type:"object",properties:Object.fromEntries(e.fields.map(t=>[t.field,M(t,t.field===e.rowKey)])),required:e.fields.filter(t=>t.required||t.field===e.rowKey).map(t=>t.field),additionalProperties:!0},...e.rowKey?{"x-report-rowKey":e.rowKey}:{}}}function M(e,n){const t=!n&&e.nullable!==!1&&!e.required;return{type:t?[p(e.type),"null"]:p(e.type),...e.label?{title:e.label}:{},...e.description?{description:e.description}:{},...e.type==="date"?{format:"date"}:{},...e.type==="decimal"?{pattern:"^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$"}:{},...e.enum?{enum:t?[...e.enum,null]:[...e.enum]}:{},...e.min===void 0?{}:{minimum:e.min},...e.max===void 0?{}:{maximum:e.max},...j(e,n),...n&&e.type==="text"?{pattern:"\\S"}:{},...e.unit?{"x-report-unit":e.unit}:{},...e.semanticRole?{"x-report-semanticRole":e.semanticRole}:{},...e.aggregation?{"x-report-aggregation":e.aggregation}:{},...e.format?{"x-report-format":{...e.format}}:{},...e.missingMeaning?{"x-report-missingMeaning":e.missingMeaning}:{},...e.calculation?{"x-report-calculation":{description:e.calculation.description,dependsOn:[...e.calculation.dependsOn]}}:{}}}function j(e,n){const t={};return(e.minLength!==void 0||n&&e.type!=="number")&&(t.minLength=Math.max(e.minLength??0,n?1:0)),e.type==="decimal"?t.maxLength=Math.min(e.maxLength??1e4,1e4):e.maxLength!==void 0&&(t.maxLength=e.maxLength),t}function p(e){return e==="text"||e==="date"||e==="decimal"?"string":e}exports.datasetJsonSchema=E;exports.validateDatasetRows=N;
|