@agile-team/mach-report 2.26.1 → 2.26.2
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 +14 -5
- package/dist/ExcelBindingWizard-CnjjpYxD.cjs +1 -0
- package/dist/{ExcelBindingWizard-Bzndrp_z.js → ExcelBindingWizard-DAprCgn-.js} +4 -4
- package/dist/{ParamEditor-BrUrInJH.js → ParamEditor-CY9d8QZD.js} +3 -3
- package/dist/ParamEditor-CiVjpbc-.cjs +1 -0
- package/dist/ReportBatchPanel-0-Oymcdm.cjs +1 -0
- package/dist/{ReportBatchPanel-2mXS1uol.js → ReportBatchPanel-CDp7xRHp.js} +4 -4
- package/dist/ReportLabelStudio-CsyHqBco.cjs +1 -0
- package/dist/{ReportLabelStudio-BUKNmYUY.js → ReportLabelStudio-DtKxk9n0.js} +4 -4
- package/dist/ReportParamPanel-CoKcXzSy.cjs +1 -0
- package/dist/{ReportParamPanel-Czm3OPo_.js → ReportParamPanel-jKDJVar2.js} +2 -2
- package/dist/{ReportPreview-C9c0Rp7Y.js → ReportPreview-DJqt40zA.js} +2863 -2836
- package/dist/ReportPreview-s7c2nrfo.cjs +6 -0
- package/dist/ReportTemplateLibrary-CsUm6edm.cjs +1 -0
- package/dist/{ReportTemplateLibrary-ovj03u0F.js → ReportTemplateLibrary-qPQX0Dt_.js} +2 -2
- package/dist/RuleEditor-CJBibiLY.cjs +1 -0
- package/dist/{RuleEditor-4JTKq_N7.js → RuleEditor-Di-JZ2Lb.js} +6 -6
- package/dist/{TemplateOutlinePanel-DfFRc91I.js → TemplateOutlinePanel-D0mKfVWf.js} +3 -3
- package/dist/TemplateOutlinePanel-RiRgXnnH.cjs +1 -0
- package/dist/TemplateReusePanel-BdK91T7z.cjs +1 -0
- package/dist/{TemplateReusePanel-CmX1rq69.js → TemplateReusePanel-J6PvD2Sf.js} +3 -3
- package/dist/TemplateReviewPanel-B5yUgOgb.cjs +1 -0
- package/dist/{TemplateReviewPanel-BKMo7Qd7.js → TemplateReviewPanel-BlUbD2GY.js} +3 -3
- package/dist/analytics.cjs +1 -1
- package/dist/analytics.js +5 -5
- package/dist/artifact-integrity.json +112 -114
- package/dist/assets-CylgPA6P.cjs +1 -0
- package/dist/assets-Vt10jCtl.js +136 -0
- package/dist/auto-D3UNXBrM.cjs +1 -0
- package/dist/{auto-C7udkeAa.js → auto-Hq-xgrvS.js} +28 -25
- package/dist/{batch-DGCt44XM.js → batch-Be_NbW7U.js} +1 -1
- package/dist/{batch-DYcokH4v.cjs → batch-CI4ZpuoX.cjs} +1 -1
- package/dist/{charts-D-Vg-ak9.cjs → charts-Cy7muNWi.cjs} +1 -1
- package/dist/{charts-D48XCefN.js → charts-DLTz0OEG.js} +1 -1
- package/dist/{computed-BQgBrma-.cjs → computed-8nFyVnok.cjs} +1 -1
- package/dist/{computed-CH3NYPOW.js → computed-BR_O8uAv.js} +14 -20
- package/dist/{data-bar-DzceAVeR.cjs → data-bar--_aPWr-W.cjs} +1 -1
- package/dist/{data-bar-DjOgTLqu.js → data-bar-BVnzVbE9.js} +1 -1
- package/dist/designer-Bc5AXS38.cjs +2 -0
- package/dist/designer-CZqnLTyE.js +8350 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +108 -1
- package/dist/designer.d.ts +108 -1
- package/dist/designer.js +1 -1
- package/dist/{diagnostic-collector-C-JBA016.js → diagnostic-collector-CZ8DV6wA.js} +208 -186
- package/dist/diagnostic-collector-DwMJWEHo.cjs +1 -0
- package/dist/{dom-DgWc-DY1.js → dom-CbOWY7KE.js} +5 -5
- package/dist/dom-VuLh_fhL.cjs +1 -0
- package/dist/{encoding-tWc2Wn89.cjs → encoding-D0ITsCCp.cjs} +1 -1
- package/dist/{encoding-D480EM2r.js → encoding-TbA3oQLr.js} +2 -2
- package/dist/{execution-result-Ba65gieT.js → execution-result-BUPPNlaS.js} +3 -3
- package/dist/{execution-result-7sG_mdcD.cjs → execution-result-BgZtqlOT.cjs} +1 -1
- package/dist/{font-loader-CHmEwkHl.js → font-loader-BSRR-a0C.js} +1 -1
- package/dist/{font-loader-BIxme_9g.cjs → font-loader-BZ4CRPys.cjs} +1 -1
- package/dist/{grid-strokes-DsoICRjZ.js → grid-strokes-CovSH3A2.js} +1 -1
- package/dist/{grid-strokes-RFMR91jn.cjs → grid-strokes-G5omPT3s.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +23 -23
- package/dist/{json-snapshot-BZ0CIQln.js → json-snapshot-DRQmh_k5.js} +718 -683
- package/dist/json-snapshot-HR8bez8j.cjs +2 -0
- package/dist/{matrix-CB9TqTEy.js → matrix-6wjFVN0Z.js} +149 -142
- package/dist/matrix-DeA6__cd.cjs +1 -0
- package/dist/media-IV_r4Sp7.cjs +1 -0
- package/dist/media-jiLdCn3i.js +208 -0
- package/dist/{pdf-DTR7fAIr.js → pdf-BqnoP1L_.js} +14 -15
- package/dist/{pdf-d9oJ6V0P.cjs → pdf-Ddm0HCuT.cjs} +48 -48
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-B7Bi-1te.cjs → plugin-BFBLxfsq.cjs} +1 -1
- package/dist/{plugin-OKDFQFS4.js → plugin-BnRcXQzg.js} +1 -1
- package/dist/{prefill-C8fF91JB.js → prefill-BqbuktRt.js} +3 -3
- package/dist/{prefill-C_Bf_AMo.cjs → prefill-DPLV68I7.cjs} +1 -1
- package/dist/prepared-Cl7C69N7.cjs +1 -0
- package/dist/{prepared-DhgQ0d-h.js → prepared-V7tYf1qj.js} +68 -64
- package/dist/{protocol-CZ-BILne.cjs → protocol-BVhKnBmX.cjs} +1 -1
- package/dist/{protocol-DHO91-Jt.js → protocol-Bf33Gu9J.js} +3 -3
- package/dist/{record-bindings-KEs-DKCS.cjs → record-bindings-DVs_g_No.cjs} +1 -1
- package/dist/{record-bindings-DBrCu6zO.js → record-bindings-hxJqcLSK.js} +3 -3
- package/dist/{region-binding-workflow-ikpY1Kbw.cjs → region-binding-workflow-Bu31bqCr.cjs} +1 -1
- package/dist/{region-binding-workflow-FSyIZge8.js → region-binding-workflow-DRvX25XH.js} +2 -2
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/{rich-text-layout-BYbIc3eJ.cjs → rich-text-layout-6VphrIcj.cjs} +1 -1
- package/dist/{rich-text-layout-BtygMWZC.js → rich-text-layout-BCdxMT4m.js} +1 -1
- package/dist/{runtime-BsvAqz4a.js → runtime-ChdUbPvs.js} +9 -9
- package/dist/{runtime-B5HG8poy.cjs → runtime-D2noLfgC.cjs} +1 -1
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +5 -5
- package/dist/server-node.js +2099 -1959
- package/dist/server.cjs +1 -1
- package/dist/server.js +17 -13
- package/dist/sha256-C26wdjDi.cjs +1 -0
- package/dist/sha256-D-msitGX.js +166 -0
- package/dist/style.css +1 -1
- package/dist/{template-catalog-BbrN9dgu.js → template-catalog-CZfnMXKc.js} +4 -4
- package/dist/template-catalog-Dv4sOYaB.cjs +1 -0
- package/dist/{template-fragments-CUTE8-_I.js → template-fragments-BO6i19kt.js} +3 -3
- package/dist/{template-fragments-cyAQu7aw.cjs → template-fragments-CTfJeHoM.cjs} +1 -1
- package/dist/{template-registry-PSuLsnyq.js → template-registry-CIaC6qBW.js} +168 -171
- package/dist/template-registry-CKo-bogM.cjs +1 -0
- package/dist/template-serialization-Cb1ospyK.js +367 -0
- package/dist/template-serialization-D4Fofl9c.cjs +1 -0
- package/dist/{textwrap-LhJkHWb1.cjs → textwrap-BYSqmGGV.cjs} +1 -1
- package/dist/{textwrap-Bt_tnI6V.js → textwrap-CGjFy7gf.js} +1 -1
- package/dist/usePopoverBounds-C3hn7F1s.js +84 -0
- package/dist/usePopoverBounds-mJhJ-VqG.cjs +1 -0
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +13 -10
- package/dist/{workbook-session-BJfZVp4q.cjs → workbook-session-DL3uBAl8.cjs} +1 -1
- package/dist/{workbook-session-DRnMjIFK.js → workbook-session-nkvroJUE.js} +2 -2
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.js +28 -29
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-D1LZxm93.cjs +0 -1
- package/dist/ParamEditor-BTIx9UDt.cjs +0 -1
- package/dist/ReportBatchPanel-CU2BbpBg.cjs +0 -1
- package/dist/ReportLabelStudio-BXKE0GVs.cjs +0 -1
- package/dist/ReportParamPanel-Chxu4MTx.cjs +0 -1
- package/dist/ReportPreview-CIMR4ERo.cjs +0 -6
- package/dist/ReportTemplateLibrary-tv1sNa78.cjs +0 -1
- package/dist/RuleEditor-CvyjPyR6.cjs +0 -1
- package/dist/TemplateOutlinePanel-hb8cKkKR.cjs +0 -1
- package/dist/TemplateReusePanel-CR5jF00y.cjs +0 -1
- package/dist/TemplateReviewPanel-BU35FHwG.cjs +0 -1
- package/dist/_plugin-vue_export-helper-8SL1F89S.js +0 -53
- package/dist/_plugin-vue_export-helper-BLmdZLlg.cjs +0 -1
- package/dist/assets-BFTP-0WR.js +0 -137
- package/dist/assets-CZiZhTf2.cjs +0 -1
- package/dist/auto-CXd2E2aZ.cjs +0 -1
- package/dist/capabilities-D8UU2clQ.cjs +0 -1
- package/dist/capabilities-g0a2j9Yy.js +0 -125
- package/dist/designer-CEMTZomv.cjs +0 -2
- package/dist/designer-_IKm_n5N.js +0 -8002
- package/dist/diagnostic-collector-wASg6Fzs.cjs +0 -1
- package/dist/dom-Fk4NF-gN.cjs +0 -1
- package/dist/json-snapshot-DGFeI30h.cjs +0 -2
- package/dist/matrix-CcqYOuq_.cjs +0 -1
- package/dist/media-B7vnpD8k.cjs +0 -1
- package/dist/media-Y90dHK9z.js +0 -70
- package/dist/prepared-BLhV7vdE.cjs +0 -1
- package/dist/sha256-BDQ1Qk7A.js +0 -158
- package/dist/sha256-DgZAKXqI.cjs +0 -1
- package/dist/template-catalog-DDH-5J57.cjs +0 -1
- package/dist/template-registry-D24Z8aQf.cjs +0 -1
- package/dist/template-serialization-BOUidUlh.cjs +0 -1
- package/dist/template-serialization-BgGWYV_1.js +0 -307
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const v=require("./sha256-
|
|
1
|
+
"use strict";const v=require("./sha256-C26wdjDi.cjs");function j(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 c("input","任务容量应为正整数,控制状态预留至少4096字节");return t}function g(e){return new TextEncoder().encode(d(e)).byteLength}function A(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 a=e.result===void 0?0:g(e.result);if(a>t.maxResultBytes)throw new c("capacity","任务结果超过独立预算,请保存文件引用");return Math.max(g(n)+t.controlReserveBytes,g(r))+a}function x(e){return e.status!=="queued"&&e.status!=="running"}function I(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 c("input","终态清理时间应为不超过当前时间的非负整数");if(![t.tombstoneRetentionMs,t.limit].every(n=>Number.isSafeInteger(n)&&n>0)||!Number.isSafeInteger(t.now+t.tombstoneRetentionMs))throw new c("input","幂等保留期与清理批量应为正整数");return t}async function R(e){const t=new TextEncoder().encode(d(e)),n=globalThis.crypto?.subtle;if(!n)return v.portableSha256HexAsync(t);const r=await n.digest("SHA-256",t);return Array.from(new Uint8Array(r),a=>a.toString(16).padStart(2,"0")).join("")}async function E(e,t){if(!x(e))throw new c("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 R(e.request),expiresAt:t}}class c extends Error{constructor(t,n){super(n),this.code=t,this.name="ReportJobError"}}function J(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 c("input","任务范围应非空,ID应为1–128位安全标识")}function T(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 c("input","任务对象应为普通 JSON 对象");if(Object.getOwnPropertySymbols(e).length)throw new c("input","任务不能包含Symbol");if(Object.getOwnPropertyNames(e).filter(i=>!(t&&i==="length")).length!==r.length)throw new c("input","任务不能包含不可枚举属性");if(t&&(r.length!==e.length||r.some(i=>i!==String(Number(i))||!Number.isSafeInteger(Number(i))||Number(i)<0||Number(i)>=e.length)))throw new c("input","任务数组不能稀疏或包含额外属性");return r.sort()}function M(e,t){const n=Object.getOwnPropertyDescriptor(e,t);if(["__proto__","prototype","constructor"].includes(t)||n.get||n.set)throw new c("input","任务不能包含危险键或访问器");return n.value}function d(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 c("input","任务JSON预算无效");let a=0,i=0;const y=new Set;function b(s,u){if(++a>n||u>32)throw new c("input","任务数据超过节点或深度预算");if(typeof s=="string"){if(i+=s.length,i>r)throw new c("input","任务文本超过预算");return s}if(s===null||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s))return s;if(!s||typeof s!="object"||y.has(s))throw new c("input","任务只允许无循环的有限 JSON 值");const o=Array.isArray(s),h=T(s);y.add(s);const l=Object.create(null);for(const f of h){if(i+=f.length,i>r)throw new c("input","任务文本超过预算");l[f]=b(M(s,f),u+1)}return y.delete(s),o?Array.from({length:s.length},(f,p)=>l[String(p)]):l}const w=JSON.stringify(b(e,0));if(w.length>r)throw new c("input","任务序列化数据超过字符预算");return w}function m(e){return JSON.parse(JSON.stringify(e))}function N(e,t,n,r){if(J(t,n),e.scope!==t||e.id!==n||e.revision!==(r??0)+1||!Number.isSafeInteger(e.revision))throw new c("input","任务身份或修订不匹配");if(![e.createdAt,e.updatedAt,e.attempt].every(a=>Number.isSafeInteger(a)&&a>=0)||!["queued","running","completed","failed","cancelled"].includes(e.status))throw new c("input","任务状态无效");if(e.lease&&(!e.lease.owner||!Number.isSafeInteger(e.lease.expiresAt)))throw new c("input","任务租约无效");if(!e.request||typeof e.request.kind!="string"||!e.request.kind.trim()||e.request.kind.length>128)throw new c("input","任务类型无效");d(e.request.payload,{maxNodes:19e3,maxCharacters:75e4}),d(e)}function B(e,t){if(e&&(e.createdAt!==t.createdAt||d(e.request)!==d(t.request)))throw new c("input","任务创建时间与请求不可变更,请使用新任务ID")}function O(e,t){return e.status==="queued"||e.status==="running"&&(e.lease?.expiresAt??0)<=t}function C(e={}){const t=new Map,n=new Map,r=j(e);let a=0,i=0,y=Promise.resolve();const b=(s,u)=>JSON.stringify([s,u]),w=s=>{const u=y.then(s);return y=u.then(()=>{},()=>{}),u};return{read:async(s,u)=>{await y;const o=t.get(b(s,u));return o?m(o):void 0},readTombstone:async(s,u)=>{await y;const o=n.get(b(s,u));return o?m(o):void 0},candidates:async(s,u)=>(await y,Array.from(t.values()).filter(o=>O(o,s)).sort((o,h)=>o.createdAt-h.createdAt).slice(0,u).map(m)),compareAndSwap:async(s,u,o,h)=>{N(h,s,u,o);const l=m(h);return w(async()=>{const f=b(s,u),p=t.get(f);if((p?.revision??null)!==o||n.has(f))return!1;B(p,l);const S=a-(p?A(p,r):0)+A(l,r);if(S>r.maxBytes||!p&&t.size>=r.maxRecords)throw new c("capacity","任务容量已满,请清理终态任务或扩大显式预算");return t.set(f,l),a=S,!0})},prune:async s=>{const u=I(s);return w(async()=>{const o={archived:0,expired:0};for(const[h,l]of n)l.expiresAt>u.now||o.expired>=u.limit||(n.delete(h),i-=g(l),o.expired++);for(const[h,l]of t){if(!x(l)||l.updatedAt>u.terminalBefore||o.archived+o.expired>=u.limit)continue;const f=await E(l,u.now+u.tombstoneRetentionMs),p=g(f);if(n.size>=r.maxTombstones||i+p>r.maxTombstoneBytes)break;n.set(h,f),i+=p,t.delete(h),a-=A(l,r),o.archived++}return o})}}}function q(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(d(e)),r=new Set;for(const a of n){if(!a||typeof a.id!="string"||a.id!==a.id.trim()||!/^[a-zA-Z0-9][a-zA-Z0-9_.:-]{0,127}$/.test(a.id)||r.has(a.id))throw new TypeError("批量行 ID 应唯一且为安全标识");if(!a.params||Array.isArray(a.params)||typeof a.params!="object"||Object.values(a.params).some(i=>typeof i!="string"))throw new TypeError("批量参数应为字符串字典");r.add(a.id)}return n}function z(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 k(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 a=q(e,n.maxCases??100);if(!a.length)throw new RangeError("批量生成至少需要一组参数");const i=Array.from({length:a.length}),y=new AbortController,b=()=>y.abort(n.signal?.reason);n.signal?.addEventListener("abort",b,{once:!0}),n.signal?.aborted&&b();let w=0,s=!1;async function u(){for(;w<a.length;){const o=w++,h=a[o],l={id:h.id,index:o};if(s||y.signal.aborted)i[o]={...l,status:"cancelled"};else try{v.throwIfAborted(y.signal);const f=await t(h,{index:o,signal:y.signal});i[o]={...l,status:"completed",value:f}}catch(f){y.signal.aborted?i[o]={...l,status:"cancelled"}:(i[o]={...l,status:"failed",error:{name:f instanceof Error?f.name:"Error",message:f instanceof Error?f.message:String(f)}},n.failure==="stop"&&(s=!0))}z(i,n.onProgress)}}try{await Promise.all(Array.from({length:Math.min(r,a.length)},u))}finally{n.signal?.removeEventListener("abort",b)}return i}exports.ReportJobError=c;exports.checkJobIdentity=J;exports.cloneJob=m;exports.createMemoryReportJobStore=C;exports.jobByteLength=g;exports.jobRequestHash=R;exports.runReportBatch=k;exports.runnableJob=O;exports.serializeJobJson=d;exports.snapshotReportBatchCases=q;exports.validateJobRecord=N;exports.validateJobTransition=B;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const w=require("./computed-
|
|
1
|
+
"use strict";const w=require("./computed-8nFyVnok.cjs"),g=["#2563eb","#0d9488","#d97706","#7c3aed","#dc2626","#0284c7"];function E(e){if(!["bar","line","stackedBar","percentBar"].includes(e.type))throw new Error("未知图表类型");if(!Array.isArray(e.categories)||!Array.isArray(e.series)||!e.categories.length||e.categories.length>200||!e.series.length||e.series.length>12)throw new Error("图表支持 1–200 个分类、1–12 个系列;大数据应先聚合");const t=w.chartArray(e.categories,200,"图表分类"),r=w.chartArray(e.series,12,"图表系列").map(a=>({...a,values:w.chartArray(a?.values,200,"图表数值")}));for(const a of t)if(typeof a!="string")throw new Error("图表分类应为字符串");x(e);for(const a of r)A(a,t.length);return{...e,categories:t,series:r}}function x(e){for(const t of["leftMm","topMm","widthMm","heightMm"])if(!Number.isFinite(e[t])||e[t]<0)throw new Error(`${t} 应为有限非负数`);if(e.widthMm<45||e.heightMm<35)throw new Error("图表至少需要 45×35mm");if(!Number.isFinite(e.leftMm+e.widthMm)||!Number.isFinite(e.topMm+e.heightMm))throw new Error("图表几何范围溢出")}function A(e,t){if(!e||typeof e.name!="string"||!Array.isArray(e.values)||e.values.length!==t)throw new Error("图表系列应提供名称及逐分类的有限数字或 null");for(const r of e.values)if(r!==null&&!Number.isFinite(r))throw new Error("图表系列应提供名称及逐分类的有限数字或 null");if(e.color!==void 0&&!/^#[\da-f]{6}$/i.test(e.color))throw new Error("图表颜色应为 #RRGGBB")}function y(e,t,r,a,c,n=.8){return{kind:"line",leftMm:Math.min(e,r),topMm:Math.min(t,a),widthMm:Math.abs(r-e),heightMm:Math.abs(a-t),lineDirection:a<t?"up":"down",style:{lineColor:c,lineWidthPt:n}}}function o(e,t,r,a,c="center"){return{kind:"text",text:e,leftMm:t,topMm:r,widthMm:a,heightMm:5,style:{fontSize:8,color:"#475569",align:c,verticalAlign:"middle"}}}function M(e){return Number(e.toPrecision(5)).toString()}function N(e){let t=0,r=0;const a=B(e)?S(e):void 0;if(a)t=a.min,r=a.max;else for(const u of e.series)for(const f of u.values)f!==null&&(t=Math.min(t,f),r=Math.max(r,f));t===r&&(r=t+1);const c=e.leftMm+13,n=e.topMm+8,h=e.widthMm-17,i=e.heightMm-23,l=Math.max(Math.abs(t),Math.abs(r),1),m=t/l,s=r/l-m;return{left:c,top:n,width:h,height:i,min:t,max:r,y:u=>n+i*(1-(u/l-m)/s)}}function B(e){return e.type==="stackedBar"||e.type==="percentBar"}function S(e){let t=0,r=e.type==="percentBar"?100:0;for(let a=0;a<e.categories.length;a++){let c=0,n=0;for(const h of e.series){const i=h.values[a]??0;i<0?n+=i:c+=i}if(!Number.isFinite(c)||!Number.isFinite(n))throw new Error("图表堆叠合计溢出,请先明确缩放单位");t=Math.min(t,n),r=Math.max(r,c)}return{min:t,max:r}}function z(e){if(e.type!=="percentBar")return e;const t=e.categories.map((r,a)=>{let c=0;for(const n of e.series){const h=n.values[a];if(h!==null&&h<0)throw new Error("占比图需要非负度量,负数口径应由业务明确处理");c=Math.max(c,h??0)}return{scale:c,total:c?e.series.reduce((n,h)=>n+(h.values[a]??0)/c,0):0}});return{...e,series:e.series.map(r=>({...r,values:r.values.map((a,c)=>{if(a===null)return null;const{scale:n,total:h}=t[c];return n&&h?a/n/h*100:0})}))}}function F(e,t){const r=[],a=t.width/e.categories.length;return e.categories.forEach((c,n)=>{let h=0,i=0;e.series.forEach((l,m)=>{const s=l.values[n];if(s==null)return;const u=s<0?i:h,f=u+s;s<0?i=f:h=f;const b=Math.min(t.y(u),t.y(f)),d=Math.abs(t.y(f)-t.y(u)),C=l.color??g[m%g.length],v=t.left+a*(n+.15),k=a*.7;r.push({kind:"rect",leftMm:v,topMm:b,widthMm:k,heightMm:d,style:{backgroundColor:C,borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}}),e.showValues&&d>=5&&r.push({...o(e.type==="percentBar"?`${M(s)}%`:M(s),v,b+d/2-2.5,k),style:{fontSize:7,color:"#ffffff",align:"center"}})})}),r}function R(e,t){const r=[];e.title&&r.push({...o(e.title,e.leftMm,e.topMm,e.widthMm),style:{fontSize:10,bold:!0,align:"left"}});for(let n=0;n<=4;n++){const h=n/4,i=t.min*(1-h)+t.max*h,l=t.y(i);r.push(y(t.left,l,t.left+t.width,l,"#e2e8f0",.4),o(`${M(i)}${e.type==="percentBar"?"%":""}`,e.leftMm,l-2.5,11,"right"))}r.push(y(t.left,t.top,t.left,t.top+t.height,"#94a3b8"));const a=Math.max(1,Math.ceil(e.categories.length/Math.max(1,Math.floor(t.width/14))));e.categories.forEach((n,h)=>{h%a===0&&r.push(o(n,t.left+(h+.5)*t.width/e.categories.length-7,t.top+t.height+1,14))});const c=t.width/e.series.length;return e.series.forEach((n,h)=>{r.push({...o(n.name,t.left+h*c,e.topMm+e.heightMm-5,c),style:{fontSize:8,color:n.color??g[h%g.length],align:"center"}})}),r}function W(e,t,r,a){const c=[],n=r.color??g[a%g.length],h=t.width/e.categories.length,i=h*.75/e.series.length;let l;return r.values.forEach((m,s)=>{if(m===null){l=void 0;return}const u=t.left+(s+.5)*h,f=t.y(m);e.type==="bar"?c.push({kind:"rect",leftMm:t.left+s*h+h*.125+a*i,topMm:Math.min(f,t.y(0)),widthMm:i,heightMm:Math.abs(t.y(0)-f),style:{backgroundColor:n,borderTop:!1,borderRight:!1,borderBottom:!1,borderLeft:!1}}):(l&&c.push(y(l.x,l.y,u,f,n,1.2)),c.push({kind:"ellipse",leftMm:u-.7,topMm:f-.7,widthMm:1.4,heightMm:1.4,style:{backgroundColor:n,borderColor:n}}),l={x:u,y:f}),e.showValues&&c.push({...o(M(m),u-h/2,Math.max(t.top,f-5),h),style:{fontSize:7,color:n,align:"center"}})}),c}function $(e,t){let r=0,a=!1;for(const c of t.values){if(c===null){a=!1;continue}r+=1+ +!!e.showValues,e.type==="line"&&a&&r++,a=!0}return r}function L(e){const t=e.categories.length,r=Math.max(1,Math.ceil(t/Math.max(1,Math.floor((e.widthMm-17)/14)))),a=11+ +!!e.title+Math.ceil(t/r)+e.series.length;return e.series.reduce((c,n)=>c+$(e,n),a)}function G(e){e=z(E(e));const t=N(e);return[...R(e,t),...B(e)?F(e,t):e.series.flatMap((r,a)=>W(e,t,r,a))]}exports.chartComponentUpperBound=L;exports.createChartComponents=G;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w } from "./computed-
|
|
1
|
+
import { w } from "./computed-BR_O8uAv.js";
|
|
2
2
|
const g = ["#2563eb", "#0d9488", "#d97706", "#7c3aed", "#dc2626", "#0284c7"];
|
|
3
3
|
function x(e) {
|
|
4
4
|
if (!["bar", "line", "stackedBar", "percentBar"].includes(e.type)) throw new Error("未知图表类型");
|
|
@@ -1 +1 @@
|
|
|
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 D=1e3;function w(r){if(!Number.isSafeInteger(r)||r<0||r>D*2)throw new Error("十进制精度超出预算");return 10n**BigInt(r)}function j(r){if(r.coefficient.toString().length>D*2||r.scale>D*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>D)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*w(-c),scale:0}:{coefficient:i,scale:c})}function H(r,e){const t=Math.max(r.scale,e.scale);return[r.coefficient*w(t-r.scale),e.coefficient*w(t-e.scale),t]}function E(r,e){const[t,n]=H(r,e);return t<n?-1:t>n?1:0}function A(r,e){const[t,n,o]=H(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 Q(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 y(r){if(!Number.isInteger(r)||r<0||r>100)throw new Error("十进制小数位应为 0–100 的整数")}function N(r,e,t=20){if(y(t),e.coefficient===0n)throw new Error("不能除以零");const n=e.scale-r.scale+t,o=r.coefficient*w(Math.max(0,n)),c=e.coefficient*w(Math.max(0,-n));return j({coefficient:Q(o,c),scale:t})}function b(r,e){let t=r.coefficient,n=r.scale;e!==void 0&&(y(e),t=e>=n?t*w(e-n):Q(t,w(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 ir(r,e,t=!1,n=!1){let o=u(r);n&&(o=M(o,{coefficient:100n,scale:0}));const[c,i]=b(o,e).split(".");return`${t?c.replace(/\B(?=(\d{3})+(?!\d))/g,","):c}${i===void 0?"":`.${i}`}${n?"%":""}`}const cr=["sum","count","avg","min","max","weightedAvg"];function W(r){if(typeof r!="number"||!Number.isFinite(r))throw new Error("聚合度量必须是有限数字,不能隐式转换;小数文本请显式选择 decimal");return r}function S(r,e){return e&&Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}function ar(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=S(s,r.field);if(r.op==="count"){(!r.field||f!=null)&&e++;return}if(f==null)return;const l=W(f),d=r.op==="weightedAvg"?S(s,r.weightField):1;if(d==null)return;const g=W(d);if(r.op==="weightedAvg"&&g<0)throw new Error("加权平均的权重不能为负数");["sum","avg","weightedAvg"].includes(r.op)&&a(l*g),o+=g,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 sr(r){let e=0,t=u("0"),n=u("0"),o,c;return{add(i){const a=S(i,r.field);if(r.op==="count"){(!r.field||a!=null)&&e++;return}if(a==null)return;const s=r.op==="weightedAvg"?S(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=A(t,M(f,l))),r.op==="weightedAvg"&&(n=A(n,l)),(!o||E(f,o)<0)&&(o=f),(!c||E(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)),b(i,r.digits)}}}function R(r){if(r.digits!==void 0&&y(r.digits),r.numeric!==void 0&&r.numeric!=="number"&&r.numeric!=="decimal")throw new Error("未知聚合数值模式");if(!cr.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"?sr(r):ar(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 rr(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 z(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 J(r){return["string","boolean"].includes(typeof r)||typeof r=="number"&&Number.isFinite(r)}function K(r){return r==null||r===""}function fr(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 v(r,e,t){if(K(r)||K(e))return;const n=fr(t);try{if(n==="decimal")return E(u(r),u(e));if(n==="number")return!["number","string"].includes(typeof r)||!["number","string"].includes(typeof e)?void 0:E(u(r),u(e));if(n==="date"&&(r=T(r),e=T(e)),n==="boolean"&&(typeof r!="boolean"||typeof e!="boolean")||n==="text"&&(!J(r)||!J(e)))return;const o=String(r),c=String(e);return o<c?-1:o>c?1:0}catch{return}}function lr(r){if(z(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=v(r.values[0],r.values[1],r);if(e===void 0||e>0)throw new Error("范围边界无效或顺序颠倒")}else if(r.right!==void 0){if(rr(r.right),Object.keys(r.right).length!==1)throw new Error("条件 right 只能指定一个 field 或 value");if("field"in r.right?z(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 ur(r){lr(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(">=",v(n,r.values[0],r))&&C("<=",v(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,v(n,o,r))}}function h(r,e={nodes:0},t=0){if(++e.nodes>256||t>16)throw new Error("条件超出深度或节点预算");if(rr(r),["all","any","not","field"].filter(o=>Object.prototype.hasOwnProperty.call(r,o)).length!==1)throw new Error("条件只能指定一种组合或比较");if("not"in r){const o=h(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=>h(i,e,t+1));return"all"in r?i=>c.every(a=>a(i)):i=>c.some(a=>a(i))}return ur(r)}function mr(r,e){return h(e)(r)}function er(r){h(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 dr=[{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(dr.map(r=>Object.freeze(r)));function gr(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 pr(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 pr(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("小数位必须为数字");y(i)}const a=b(c,i),s=Number(a);if(t!=="decimal"&&!Number.isFinite(s))throw new Error("计算结果不是有限数字");return t==="decimal"?a:s}const wr=new Set(["__proto__","prototype","constructor"]);function m(r){if(typeof r!="string"||!r.trim()||wr.has(r))throw new Error("计算字段应为安全的非空字段名")}function _(r){return r===null||["string","boolean"].includes(typeof r)||typeof r=="number"&&Number.isFinite(r)}function hr(r){if(r.some(e=>typeof e!="number"||!Number.isFinite(e)))throw new Error("算术参数必须是有限数字;空值和小数文本不会隐式转换");return r}function yr(r,e){const t=hr(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 Er(r,e,t){const n=e.map(u);let o;return r==="add"?o=n.reduce(A):r==="multiply"?o=n.reduce(M):r==="subtract"?o=A(n[0],{...n[1],coefficient:-n[1].coefficient}):o=N(n[0],n[1],t),b(o,t)}function Ar(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"?Er(r,e,t.digits):yr(r,e)}function br(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 vr(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 br(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 Or(r,e,t,n)}function Or(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"?h(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=>vr(i,a):a=>Ar(r.op,i.map(s=>s(a)),e):a=>gr(r.op,i.map(s=>s(a)),e.numeric,e.digits,e.nulls)}function Dr(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&&er(n.condition).forEach(o=>e.add(o)))};return t(r),[...e]}function F(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 tr(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,"图表度量"))Nr(e);F(r.maxRows,1e5,1e5),F(r.maxCategories,200,200)}function Nr(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 Sr(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 Fr(r){if(r===null)return null;const e=Number(r);if(!Number.isFinite(e))throw new RangeError("聚合结果超出图表有限数值范围");return e}function xr(r,e,t){if(t?.aborted){const a=new Error("图表数据处理已取消");throw a.name="AbortError",a}tr(e);const n=Y(e.measures,12,"图表度量");if(!Array.isArray(r)||r.length>F(e.maxRows,1e5,1e5))throw new RangeError("图表数据超出行数预算");const o=new Map,c=F(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=Sr(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=>Fr(f.accumulators[s].value())),...a.color?{color:a.color}:{}}))}}const jr=16,B=1024*1024,X=5e5,x=new WeakMap,p=Symbol("uncacheable-computation-definition");function O(r,e,t=0){if(++e.nodes>1e4||t>32)throw p;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 p;return["string",r]}if(typeof r!="object")throw p;if(Array.isArray(r)){if(Object.getPrototypeOf(r)!==Array.prototype||Object.keys(r).length!==r.length)throw p;return["array",Array.from({length:r.length},(n,o)=>O(Z(r,String(o)),e,t+1))]}if(Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null)throw p;return["object",Object.keys(r).map(n=>[O(n,e,t+1),O(Z(r,n),e,t+1)])]}function Z(r,e){const t=Object.getOwnPropertyDescriptor(r,e);if(!t||t.get||t.set)throw p;return t.value}function Mr(r){try{return JSON.stringify(O(r,{nodes:0,units:0}))}catch(e){if(e!==p)throw e;return}}function Rr(r){x.set(r,{programs:new Map,units:0,slots:0})}function kr(r,e){const t=x.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})}x.set(e,n)}function Cr(r,e,t){const n=x.get(r);if(!n||e.some(f=>typeof f.expression=="string"))return;const o=Mr(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<=X};if(!s.cacheRows)return s;for(;n.programs.size>=jr||n.units+o.length>B||n.slots+a>X;){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 Pr(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 Tr(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 $r(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&&y(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 字段");Br(r)}function Br(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??[]:Dr(r.expression),...r.groupBy??[]])]}function nr(r){if(!Array.isArray(r)||r.length>2048)throw new Error("计算字段应为数组且最多2048项");const e=new Map;for(const i of r){if($r(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 Yr(r){try{const e=nr(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 _r(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 G(r){return nr(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 Ir(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 Ur(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=Ir(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 Vr(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 L(r){if(r?.aborted){const e=new Error("数据计算已取消");throw e.name="AbortError",e}}function Wr(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 zr(r,e,t,n,o,c,i,a){const s=Pr(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;Wr(t,n,o,c,i,a),Tr(r,e,t,n,a.length>f?a[a.length-1]:void 0)}function Jr(r,e){const t=or(r,e,!1);let n=t.next();for(;!n.done;)n=t.next();return n.value}function*or(r,e,t=!0){Vr(r,e),L(e.signal);const n=Cr(r,e.fields,()=>G(e)),o={program:n,writes:new WeakMap},c=n?.fields??G(e),i=[],a=[],s=r.length;for(let f=0;f<s;f++){const l=r[f];if(!l||typeof l!="object"||Array.isArray(l))throw new Error(`第 ${f+1} 行应为对象`);a.push({...l}),t&&(yield)}for(const f of c){const l=Ur(a,f.definition),d=a.length;for(let g=0;g<d;g++){const V=a[g];L(e.signal),zr(o,r[g],f,V,g,l(V),e,i),t&&(yield)}}return{rows:a,issues:i}}exports.addDecimal=A;exports.aggregateRows=P;exports.chartArray=Y;exports.compareDecimal=E;exports.compileReportPredicate=h;exports.computationFieldName=m;exports.computeDataset=Jr;exports.createAggregateAccumulator=R;exports.createReportChartData=xr;exports.decimalDigits=y;exports.divideDecimal=N;exports.evaluateReportPredicate=mr;exports.forkComputedDataset=kr;exports.formatDecimal=ir;exports.getComputationMetadata=_r;exports.iterateComputedDataset=or;exports.multiplyDecimal=M;exports.parseDecimal=u;exports.printDecimal=b;exports.registerComputedDataset=Rr;exports.reportPredicateFields=er;exports.validateComputedFields=Yr;exports.validateReportChartBinding=tr;
|
|
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 D=1e3;function w(r){if(!Number.isSafeInteger(r)||r<0||r>D*2)throw new Error("十进制精度超出预算");return 10n**BigInt(r)}function j(r){if(r.coefficient.toString().length>D*2||r.scale>D*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>D)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*w(-c),scale:0}:{coefficient:i,scale:c})}function H(r,e){const t=Math.max(r.scale,e.scale);return[r.coefficient*w(t-r.scale),e.coefficient*w(t-e.scale),t]}function E(r,e){const[t,n]=H(r,e);return t<n?-1:t>n?1:0}function A(r,e){const[t,n,o]=H(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 Q(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 y(r){if(!Number.isInteger(r)||r<0||r>100)throw new Error("十进制小数位应为 0–100 的整数")}function N(r,e,t=20){if(y(t),e.coefficient===0n)throw new Error("不能除以零");const n=e.scale-r.scale+t,o=r.coefficient*w(Math.max(0,n)),c=e.coefficient*w(Math.max(0,-n));return j({coefficient:Q(o,c),scale:t})}function b(r,e){let t=r.coefficient,n=r.scale;e!==void 0&&(y(e),t=e>=n?t*w(e-n):Q(t,w(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 ir(r,e,t=!1,n=!1){let o=u(r);n&&(o=M(o,{coefficient:100n,scale:0}));const[c,i]=b(o,e).split(".");return`${t?c.replace(/\B(?=(\d{3})+(?!\d))/g,","):c}${i===void 0?"":`.${i}`}${n?"%":""}`}const cr=["sum","count","avg","min","max","weightedAvg"];function z(r){if(typeof r!="number"||!Number.isFinite(r))throw new Error("聚合度量必须是有限数字,不能隐式转换;小数文本请显式选择 decimal");return r}function S(r,e){return e&&Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}function ar(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=S(s,r.field);if(r.op==="count"){(!r.field||f!=null)&&e++;return}if(f==null)return;const l=z(f),d=r.op==="weightedAvg"?S(s,r.weightField):1;if(d==null)return;const g=z(d);if(r.op==="weightedAvg"&&g<0)throw new Error("加权平均的权重不能为负数");["sum","avg","weightedAvg"].includes(r.op)&&a(l*g),o+=g,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 sr(r){let e=0,t=u("0"),n=u("0"),o,c;return{add(i){const a=S(i,r.field);if(r.op==="count"){(!r.field||a!=null)&&e++;return}if(a==null)return;const s=r.op==="weightedAvg"?S(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=A(t,M(f,l))),r.op==="weightedAvg"&&(n=A(n,l)),(!o||E(f,o)<0)&&(o=f),(!c||E(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)),b(i,r.digits)}}}function R(r){if(r.digits!==void 0&&y(r.digits),r.numeric!==void 0&&r.numeric!=="number"&&r.numeric!=="decimal")throw new Error("未知聚合数值模式");if(!cr.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"?sr(r):ar(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 rr(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 J(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 W(r){return["string","boolean"].includes(typeof r)||typeof r=="number"&&Number.isFinite(r)}function K(r){return r==null||r===""}function fr(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 v(r,e,t){if(K(r)||K(e))return;const n=fr(t);try{if(n==="decimal")return E(u(r),u(e));if(n==="number")return!["number","string"].includes(typeof r)||!["number","string"].includes(typeof e)?void 0:E(u(r),u(e));if(n==="date"&&(r=T(r),e=T(e)),n==="boolean"&&(typeof r!="boolean"||typeof e!="boolean")||n==="text"&&(!W(r)||!W(e)))return;const o=String(r),c=String(e);return o<c?-1:o>c?1:0}catch{return}}function lr(r){if(J(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=v(r.values[0],r.values[1],r);if(e===void 0||e>0)throw new Error("范围边界无效或顺序颠倒")}else if(r.right!==void 0){if(rr(r.right),Object.keys(r.right).length!==1)throw new Error("条件 right 只能指定一个 field 或 value");if("field"in r.right?J(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 ur(r){lr(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(">=",v(n,r.values[0],r))&&C("<=",v(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,v(n,o,r))}}function h(r,e={nodes:0},t=0){if(++e.nodes>256||t>16)throw new Error("条件超出深度或节点预算");if(rr(r),["all","any","not","field"].filter(o=>Object.prototype.hasOwnProperty.call(r,o)).length!==1)throw new Error("条件只能指定一种组合或比较");if("not"in r){const o=h(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=>h(i,e,t+1));return"all"in r?i=>c.every(a=>a(i)):i=>c.some(a=>a(i))}return ur(r)}function mr(r,e){return h(e)(r)}function er(r){h(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 dr=[{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(dr.map(r=>Object.freeze(r)));function gr(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 pr(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 pr(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("小数位必须为数字");y(i)}const a=b(c,i),s=Number(a);if(t!=="decimal"&&!Number.isFinite(s))throw new Error("计算结果不是有限数字");return t==="decimal"?a:s}const wr=new Set(["__proto__","prototype","constructor"]);function m(r){if(typeof r!="string"||!r.trim()||wr.has(r))throw new Error("计算字段应为安全的非空字段名")}function _(r){return r===null||["string","boolean"].includes(typeof r)||typeof r=="number"&&Number.isFinite(r)}function hr(r){if(r.some(e=>typeof e!="number"||!Number.isFinite(e)))throw new Error("算术参数必须是有限数字;空值和小数文本不会隐式转换");return r}function yr(r,e){const t=hr(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 Er(r,e,t){const n=e.map(u);let o;return r==="add"?o=n.reduce(A):r==="multiply"?o=n.reduce(M):r==="subtract"?o=A(n[0],{...n[1],coefficient:-n[1].coefficient}):o=N(n[0],n[1],t),b(o,t)}function Ar(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"?Er(r,e,t.digits):yr(r,e)}function br(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 vr(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 br(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 Or(r,e,t,n)}function Or(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"?h(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=>vr(i,a):a=>Ar(r.op,i.map(s=>s(a)),e):a=>gr(r.op,i.map(s=>s(a)),e.numeric,e.digits,e.nulls)}function Dr(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&&er(n.condition).forEach(o=>e.add(o)))};return t(r),[...e]}function F(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 tr(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,"图表度量"))Nr(e);F(r.maxRows,1e5,1e5),F(r.maxCategories,200,200)}function Nr(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 Sr(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 Fr(r){if(r===null)return null;const e=Number(r);if(!Number.isFinite(e))throw new RangeError("聚合结果超出图表有限数值范围");return e}function xr(r,e,t){if(t?.aborted){const a=new Error("图表数据处理已取消");throw a.name="AbortError",a}tr(e);const n=Y(e.measures,12,"图表度量");if(!Array.isArray(r)||r.length>F(e.maxRows,1e5,1e5))throw new RangeError("图表数据超出行数预算");const o=new Map,c=F(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=Sr(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=>Fr(f.accumulators[s].value())),...a.color?{color:a.color}:{}}))}}const jr=16,B=1024*1024,X=5e5,x=new WeakMap,p=Symbol("uncacheable-computation-definition");function O(r,e,t=0){if(++e.nodes>1e4||t>32)throw p;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 p;return["string",r]}if(typeof r!="object")throw p;if(Array.isArray(r)){if(Object.getPrototypeOf(r)!==Array.prototype||Object.keys(r).length!==r.length)throw p;return["array",Array.from({length:r.length},(n,o)=>O(Z(r,String(o)),e,t+1))]}if(Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null)throw p;return["object",Object.keys(r).map(n=>[O(n,e,t+1),O(Z(r,n),e,t+1)])]}function Z(r,e){const t=Object.getOwnPropertyDescriptor(r,e);if(!t||t.get||t.set)throw p;return t.value}function Mr(r){try{return JSON.stringify(O(r,{nodes:0,units:0}))}catch(e){if(e!==p)throw e;return}}function Rr(r){x.set(r,{programs:new Map,units:0,slots:0})}function kr(r,e){const t=x.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})}x.set(e,n)}function Cr(r,e,t){const n=x.get(r);if(!n||e.some(f=>typeof f.expression=="string"))return;const o=Mr(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<=X};if(!s.cacheRows)return s;for(;n.programs.size>=jr||n.units+o.length>B||n.slots+a>X;){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 Pr(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 Tr(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 $r(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&&y(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 字段");Br(r)}function Br(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??[]:Dr(r.expression),...r.groupBy??[]])]}function nr(r){if(!Array.isArray(r)||r.length>2048)throw new Error("计算字段应为数组且最多2048项");const e=new Map;for(const i of r){if($r(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 Yr(r){try{const e=nr(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 _r(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 G(r){return nr(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 Ir(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 Ur(r,e){if(e.scope==="dataset")return()=>r;if(e.scope!=="group")return o=>[o];const t=new Map,n=new WeakMap;for(const o of r){const c=Ir(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 Vr(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 L(r){if(r?.aborted){const e=new Error("数据计算已取消");throw e.name="AbortError",e}}function zr(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 Jr(r,e,t,n,o,c,i,a){const s=Pr(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;zr(t,n,o,c,i,a),Tr(r,e,t,n,a.length>f?a[a.length-1]:void 0)}function Wr(r,e){const t=or(r,e,!1);let n=t.next();for(;!n.done;)n=t.next();return n.value}function*or(r,e,t=!0){Vr(r,e),L(e.signal);const n=Cr(r,e.fields,()=>G(e)),o={program:n,writes:new WeakMap},c=n?.fields??G(e),i=[],a=[],s=r.length;for(let f=0;f<s;f++){const l=r[f];if(!l||typeof l!="object"||Array.isArray(l))throw new Error(`第 ${f+1} 行应为对象`);a.push({...l}),t&&(yield)}for(const f of c){const l=Ur(a,f.definition),d=a.length;for(let g=0;g<d;g++){const V=a[g];L(e.signal),Jr(o,r[g],f,V,g,l(V),e,i),t&&(yield)}}return{rows:a,issues:i}}exports.addDecimal=A;exports.aggregateRows=P;exports.chartArray=Y;exports.compareDecimal=E;exports.compileReportPredicate=h;exports.computationFieldName=m;exports.computeDataset=Wr;exports.createAggregateAccumulator=R;exports.createReportChartData=xr;exports.decimalDigits=y;exports.divideDecimal=N;exports.evaluateReportPredicate=mr;exports.forkComputedDataset=kr;exports.formatDecimal=ir;exports.getComputationMetadata=_r;exports.iterateComputedDataset=or;exports.multiplyDecimal=M;exports.parseDecimal=u;exports.printDecimal=b;exports.registerComputedDataset=Rr;exports.reportPredicateFields=er;exports.validateComputedFields=Yr;exports.validateReportChartBinding=tr;
|
|
@@ -182,7 +182,7 @@ function rr(r) {
|
|
|
182
182
|
if (!r || typeof r != "object" || Array.isArray(r) || ![Object.prototype, null].includes(Object.getPrototypeOf(r))) throw new Error("条件应为普通声明式对象");
|
|
183
183
|
for (const [e, t] of Object.entries(Object.getOwnPropertyDescriptors(r))) if (q.has(e) || !Object.prototype.hasOwnProperty.call(t, "value")) throw new Error("条件不允许访问器或不安全属性");
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function z(r) {
|
|
186
186
|
if (typeof r != "string" || !r.trim() || r.length > 512 || q.has(r)) throw new Error("条件字段应为安全的非空字段名");
|
|
187
187
|
}
|
|
188
188
|
function D(r) {
|
|
@@ -195,10 +195,10 @@ function R(r) {
|
|
|
195
195
|
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("无效日历日");
|
|
196
196
|
return r;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function J(r) {
|
|
199
199
|
return ["string", "boolean"].includes(typeof r) || typeof r == "number" && Number.isFinite(r);
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function W(r) {
|
|
202
202
|
return r == null || r === "";
|
|
203
203
|
}
|
|
204
204
|
function ir(r) {
|
|
@@ -206,13 +206,13 @@ function ir(r) {
|
|
|
206
206
|
return r.valueType ?? r.numeric ?? (typeof e == "number" ? "decimal" : typeof e == "boolean" ? "boolean" : "text");
|
|
207
207
|
}
|
|
208
208
|
function E(r, e, t) {
|
|
209
|
-
if (
|
|
209
|
+
if (W(r) || W(e)) return;
|
|
210
210
|
const n = ir(t);
|
|
211
211
|
try {
|
|
212
212
|
if (n === "decimal") return O(u(r), u(e));
|
|
213
213
|
if (n === "number")
|
|
214
214
|
return !["number", "string"].includes(typeof r) || !["number", "string"].includes(typeof e) ? void 0 : O(u(r), u(e));
|
|
215
|
-
if (n === "date" && (r = R(r), e = R(e)), n === "boolean" && (typeof r != "boolean" || typeof e != "boolean") || n === "text" && (!
|
|
215
|
+
if (n === "date" && (r = R(r), e = R(e)), n === "boolean" && (typeof r != "boolean" || typeof e != "boolean") || n === "text" && (!J(r) || !J(e))) return;
|
|
216
216
|
const o = String(r), c = String(e);
|
|
217
217
|
return o < c ? -1 : o > c ? 1 : 0;
|
|
218
218
|
} catch {
|
|
@@ -220,7 +220,7 @@ function E(r, e, t) {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
function cr(r) {
|
|
223
|
-
if (
|
|
223
|
+
if (z(r.field), ![">", ">=", "<", "<=", "==", "!=", "between", "contains", "isNull", "isNotNull"].includes(r.op)) throw new Error("未知条件运算符");
|
|
224
224
|
if (r.numeric !== void 0 && !["number", "decimal"].includes(r.numeric)) throw new Error("未知条件数值模式");
|
|
225
225
|
if (r.valueType !== void 0 && !["number", "decimal", "text", "date", "boolean"].includes(r.valueType)) throw new Error("未知条件值类型");
|
|
226
226
|
if (!(r.op === "isNull" || r.op === "isNotNull"))
|
|
@@ -231,7 +231,7 @@ function cr(r) {
|
|
|
231
231
|
if (e === void 0 || e > 0) throw new Error("范围边界无效或顺序颠倒");
|
|
232
232
|
} else if (r.right !== void 0) {
|
|
233
233
|
if (rr(r.right), Object.keys(r.right).length !== 1) throw new Error("条件 right 只能指定一个 field 或 value");
|
|
234
|
-
if ("field" in r.right ?
|
|
234
|
+
if ("field" in r.right ? z(r.right.field) : D(r.right.value), r.value !== void 0) throw new Error("条件不能同时指定 value 和 right");
|
|
235
235
|
} else D(r.value);
|
|
236
236
|
}
|
|
237
237
|
function M(r, e) {
|
|
@@ -650,7 +650,7 @@ function er(r) {
|
|
|
650
650
|
}
|
|
651
651
|
return r.forEach(c), o;
|
|
652
652
|
}
|
|
653
|
-
function
|
|
653
|
+
function zr(r) {
|
|
654
654
|
try {
|
|
655
655
|
const e = er(r);
|
|
656
656
|
return {
|
|
@@ -672,7 +672,7 @@ function Wr(r) {
|
|
|
672
672
|
};
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function Jr(r = []) {
|
|
676
676
|
return {
|
|
677
677
|
fields: r.map((e) => ({ ...e })),
|
|
678
678
|
functions: T,
|
|
@@ -722,13 +722,7 @@ function Rr(r, e) {
|
|
|
722
722
|
}
|
|
723
723
|
function Tr(r, e) {
|
|
724
724
|
if (e.scope === "dataset") return () => r;
|
|
725
|
-
if (e.scope !== "group")
|
|
726
|
-
const o = /* @__PURE__ */ new WeakMap();
|
|
727
|
-
return (c) => {
|
|
728
|
-
let i = o.get(c);
|
|
729
|
-
return i || (i = [c], o.set(c, i)), i;
|
|
730
|
-
};
|
|
731
|
-
}
|
|
725
|
+
if (e.scope !== "group") return (o) => [o];
|
|
732
726
|
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new WeakMap();
|
|
733
727
|
for (const o of r) {
|
|
734
728
|
const c = Rr(o, e.groupBy);
|
|
@@ -778,7 +772,7 @@ function Pr(r, e, t, n, o, c, i, a) {
|
|
|
778
772
|
const f = a.length;
|
|
779
773
|
$r(t, n, o, c, i, a), Dr(r, e, t, n, a.length > f ? a[a.length - 1] : void 0);
|
|
780
774
|
}
|
|
781
|
-
function
|
|
775
|
+
function Wr(r, e) {
|
|
782
776
|
const t = Yr(r, e, !1);
|
|
783
777
|
let n = t.next();
|
|
784
778
|
for (; !n.done; ) n = t.next();
|
|
@@ -807,12 +801,12 @@ export {
|
|
|
807
801
|
V as b,
|
|
808
802
|
P as c,
|
|
809
803
|
O as d,
|
|
810
|
-
|
|
804
|
+
Wr as e,
|
|
811
805
|
Ir as f,
|
|
812
806
|
y as g,
|
|
813
807
|
k as h,
|
|
814
808
|
Br as i,
|
|
815
|
-
|
|
809
|
+
Jr as j,
|
|
816
810
|
F as k,
|
|
817
811
|
Ar as l,
|
|
818
812
|
$ as m,
|
|
@@ -824,6 +818,6 @@ export {
|
|
|
824
818
|
m as s,
|
|
825
819
|
Vr as t,
|
|
826
820
|
Ur as u,
|
|
827
|
-
|
|
821
|
+
zr as v,
|
|
828
822
|
L as w
|
|
829
823
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const d=require("./diagnostic-collector-
|
|
1
|
+
"use strict";const d=require("./diagnostic-collector-DwMJWEHo.cjs");function i(t,r,c,o){if(!d.validDataBar(t)||t.start===t.end)return;const a=Math.max(0,r-2*o);return{x:o+a*t.start,y:o,width:a*(t.end-t.start),height:Math.max(0,c-2*o),color:t.color}}exports.dataBarBox=i;
|