@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
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { s as S, d as j, c as U, a as H } from "./prepared-
|
|
2
|
-
import { H as I } from "./json-snapshot-
|
|
3
|
-
import { b as W, R as
|
|
4
|
-
import {
|
|
5
|
-
import { c as K, e as X
|
|
6
|
-
import { D as
|
|
1
|
+
import { s as S, d as j, c as U, a as H } from "./prepared-DhgQ0d-h.js";
|
|
2
|
+
import { H as I } from "./json-snapshot-BZ0CIQln.js";
|
|
3
|
+
import { b as W, R as C, v as $, c as N } from "./protocol-DHO91-Jt.js";
|
|
4
|
+
import { A as G } from "./diagnostic-collector-C-JBA016.js";
|
|
5
|
+
import { c as K, e as X } from "./runtime-BsvAqz4a.js";
|
|
6
|
+
import { D as z, R as O, t as R, v as J, c as D, b as M } from "./sha256-BDQ1Qk7A.js";
|
|
7
|
+
import { a as Q } from "./execution-result-Ba65gieT.js";
|
|
7
8
|
class T extends Error {
|
|
8
9
|
constructor(r) {
|
|
9
10
|
super("报表 Worker 无法启动"), this.cause = r, this.name = "ReportWorkerStartError";
|
|
@@ -17,7 +18,7 @@ function F(e) {
|
|
|
17
18
|
function Y(e, r) {
|
|
18
19
|
if (!e || typeof e != "object") return;
|
|
19
20
|
const t = e;
|
|
20
|
-
return t.protocol ===
|
|
21
|
+
return t.protocol === C && t.id === r ? t : void 0;
|
|
21
22
|
}
|
|
22
23
|
function Z(e, r = {}) {
|
|
23
24
|
const t = r.timeoutMs ?? 12e4;
|
|
@@ -65,7 +66,7 @@ function Z(e, r = {}) {
|
|
|
65
66
|
if (n?.addEventListener("abort", y, { once: !0 }), k = setTimeout(() => l(new W({ name: "ReportRuntimeError", code: "timeout", message: `报表 Worker 执行超过 ${t}ms` })), t), n?.aborted) y();
|
|
66
67
|
else {
|
|
67
68
|
const { onEvent: f, signal: c, ...g } = s, x = ee(g);
|
|
68
|
-
p.postMessage({ protocol:
|
|
69
|
+
p.postMessage({ protocol: C, id: E, operation: o, input: g, ...r.budget ? { budget: r.budget } : {} }, x);
|
|
69
70
|
}
|
|
70
71
|
} catch (f) {
|
|
71
72
|
l(f);
|
|
@@ -171,24 +172,24 @@ function ae(e, r) {
|
|
|
171
172
|
function ne(e) {
|
|
172
173
|
if (e.mode !== void 0 && !["auto", "local", "worker"].includes(e.mode)) throw new TypeError("无效的导出执行模式");
|
|
173
174
|
if (e.fallback !== void 0 && !["local", "error"].includes(e.fallback)) throw new TypeError("无效的导出回退策略");
|
|
174
|
-
|
|
175
|
+
J({ ...e.budget, maxDurationMs: e.timeoutMs ?? e.budget?.maxDurationMs ?? 12e4 });
|
|
175
176
|
}
|
|
176
|
-
function
|
|
177
|
+
function A(e, r) {
|
|
177
178
|
G(() => e.onDecision?.({ ...r, estimate: { ...r.estimate } }));
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
+
function _(e, r) {
|
|
180
181
|
return { ...e, mode: "local", reason: r, hardCancellation: !1 };
|
|
181
182
|
}
|
|
182
183
|
function B(e, r, t) {
|
|
183
184
|
M(t, "maxRows", e.stats.rows), M(t, "maxPages", e.stats.pages), M(t, "maxCells", e.stats.cells), M(t, "maxOutputBytes", e.bytes.byteLength), j({ ...r, prepared: { ...r.prepared, stats: e.stats } }, t);
|
|
184
185
|
}
|
|
185
186
|
function ie(e, r) {
|
|
186
|
-
const t = { ...
|
|
187
|
+
const t = { ...z, ...r.budget }, a = U(e.prepared, t.maxPreparedBytes, e.signal), o = { ...e, prepared: a.prepared, pdf: S(e.pdf), xlsx: H(e.xlsx) };
|
|
187
188
|
return { request: o, forward: () => ({ ...o, prepared: a.forward() }) };
|
|
188
189
|
}
|
|
189
190
|
function ce(e, r) {
|
|
190
191
|
ne(e);
|
|
191
|
-
const t = { ...e, thresholds: { ...e.thresholds }, budget: { ...
|
|
192
|
+
const t = { ...e, thresholds: { ...e.thresholds }, budget: { ...z, ...e.budget } }, a = t.timeoutMs ?? t.budget.maxDurationMs ?? 12e4, o = K({ reports: {}, budget: { ...t.budget, maxDurationMs: a } }), s = /* @__PURE__ */ new Set();
|
|
192
193
|
let n = !1;
|
|
193
194
|
const u = t.mode !== "worker" && t.fallback !== "error";
|
|
194
195
|
async function v(i, p) {
|
|
@@ -201,10 +202,10 @@ function ce(e, r) {
|
|
|
201
202
|
if (d.reason === "nonserializable-options" && t.mode === "worker") throw new TypeError("Worker 模式不接受函数选项;请使用本地模式或可序列化配置");
|
|
202
203
|
if (d.mode === "worker" && !r) {
|
|
203
204
|
if (!u) throw new T(new Error("未配置 workerFactory"));
|
|
204
|
-
d =
|
|
205
|
+
d = _(d, "worker-unavailable");
|
|
205
206
|
}
|
|
206
207
|
const k = ie(i, t), l = k.request;
|
|
207
|
-
if (
|
|
208
|
+
if (A(t, d), R(i.signal), d.mode === "worker")
|
|
208
209
|
try {
|
|
209
210
|
const m = r(b());
|
|
210
211
|
if (!m.exportPrepared) throw new TypeError("隔离执行器缺少 exportPrepared");
|
|
@@ -212,11 +213,11 @@ function ce(e, r) {
|
|
|
212
213
|
return R(f), B(x, l, t.budget), { ...x, execution: d };
|
|
213
214
|
} catch (m) {
|
|
214
215
|
if (!(m instanceof T) || !u) throw m;
|
|
215
|
-
R(i.signal), d =
|
|
216
|
+
R(i.signal), d = _(d, "worker-start-failed"), A(t, d);
|
|
216
217
|
}
|
|
217
218
|
p && (l.prepared = X(l.prepared, t.budget), j(l, t.budget));
|
|
218
219
|
const y = p ? await D(i.signal, b(), (m) => p({ ...l, signal: m })) : await D(i.signal, b(), (m) => o.exportPrepared({ ...k.forward(), signal: m }));
|
|
219
|
-
return R(i.signal), p &&
|
|
220
|
+
return R(i.signal), p && Q(y, l.format), B(y, l, t.budget), { ...y, execution: d };
|
|
220
221
|
}
|
|
221
222
|
return {
|
|
222
223
|
async exportPrepared(i, p) {
|
|
@@ -245,13 +246,13 @@ function le(e = {}) {
|
|
|
245
246
|
const r = e.workerFactory, t = { timeoutMs: e.timeoutMs ?? e.budget?.maxDurationMs, budget: { ...e.budget } };
|
|
246
247
|
return ce(e, r ? (a) => re(r, { ...t, timeoutMs: a }) : void 0);
|
|
247
248
|
}
|
|
248
|
-
const
|
|
249
|
+
const we = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
249
250
|
__proto__: null,
|
|
250
251
|
createAutoReportExporter: le
|
|
251
252
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
252
253
|
export {
|
|
253
254
|
T as R,
|
|
254
255
|
re as a,
|
|
255
|
-
|
|
256
|
+
we as b,
|
|
256
257
|
le as c
|
|
257
258
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const O=require("./prepared-BLhV7vdE.cjs"),C=require("./json-snapshot-DGFeI30h.cjs"),P=require("./protocol-CZ-BILne.cjs"),I=require("./diagnostic-collector-wASg6Fzs.cjs"),W=require("./runtime-B5HG8poy.cjs"),u=require("./sha256-DgZAKXqI.cjs"),j=require("./execution-result-7sG_mdcD.cjs");class M extends Error{constructor(r){super("报表 Worker 无法启动"),this.cause=r,this.name="ReportWorkerStartError"}}let U=0;function F(e){const r=new Error("报表 Worker 任务已取消");return r.name="AbortError",Object.defineProperty(r,"cause",{value:e}),r}function z(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 N(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()}-${++U}`;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=z(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=$(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 $(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 N(()=>{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 H={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 q(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;q(s,r,t+1)}}}}}}function G(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 K(e){const r={...H,...e.thresholds};for(const t of Object.values(r))if(!Number.isSafeInteger(t)||t<=0)throw new RangeError("导出隔离阈值应为正安全整数");return r}function X(e,r){const t=K(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;q(y,o,0)}}G(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 J(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 Q(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 V(e,r){J(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=X(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=Q(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&&j.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 S(e={}){const r=e.workerFactory,t={timeoutMs:e.timeoutMs??e.budget?.maxDurationMs,budget:{...e.budget}};return V(e,r?n=>_(r,{...t,timeoutMs:n}):void 0)}const Y=Object.freeze(Object.defineProperty({__proto__:null,createAutoReportExporter:S},Symbol.toStringTag,{value:"Module"}));exports.ReportWorkerStartError=M;exports.auto=Y;exports.createAutoReportExporter=S;exports.createBrowserReportExecutor=_;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const c=require("./diagnostic-collector-wASg6Fzs.cjs");function b(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 g(e,t,i,s,n){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{...n,severity:"warning",format:t,pageIndex:i,componentIndex:s,kind:e.kind,nid:e.nid,...d?{extension:d}:{}}}function L(e,t){const i=[];return e.rotateDeg&&(t||!Number.isFinite(e.rotateDeg))&&i.push("rotateDeg"),e.opacity!==void 0&&e.opacity!==1&&(t||!Number.isFinite(e.opacity)||e.opacity<0||e.opacity>1)&&i.push("opacity"),i}function h(e,t,i=!1){if(!e||t==="dom")return;const s=t==="pdf"?L(e,i):[];return t!=="pdf"&&(e.rotateDeg&&s.push("rotateDeg"),e.opacity!==void 0&&e.opacity!==1&&s.push("opacity"),t!=="xlsx"&&e.align==="justify"&&s.push("justify")),t==="xlsx"&&e.letterSpacing&&s.push("letterSpacing"),s.length?`${t} does not preserve these styles: ${s.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 X(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,s,n,o){const a=u=>{n.push({...g(e,t,i,s,{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,!0)??(t==="xlsx"?S(d.style):void 0);l&&a(l)}}}function w(e,t,i,s,n,o,a){if(a.has(e))return;const u=new Set(a).add(e),r=$(e,t);r&&o.push({...g(e,t,i,s,r),componentPath:n});const d=h(e.style,t);d&&o.push({...g(e,t,i,s,{code:"unsupported-style",message:d}),componentPath:n}),m(e,t,i,s,o,n),A(e,t,i,s,n,o,u)}function j(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 s=X(e);if(s)return s;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 B(e){let t;return(i,s,n,o)=>{t??=new Map(c.resolveGridLayout(e.grid,e.widthMm,e.heightMm).cells.map(r=>[`${r.ri}:${r.ci}`,r]));const a=t.get(`${s}:${n}`),u=2*(e.grid?.paddingMm??.5);return j(i,(a?.widthMm??0)-u-(o?.indentMm??0),(a?.heightMm??0)-u)}}function A(e,t,i,s,n,o,a){const u=B(e);for(const[r,d]of(e.grid?.cells??[]).entries())for(const[l,p]of d.entries()){p?.dataBar!==void 0&&!c.validDataBar(p.dataBar)&&o.push({...g(e,t,i,s,{code:"unsupported-style",message:"Invalid resolved data-bar geometry or color; visual data bars require ordered 0–1 ratios and #RRGGBB colors."}),componentPath:[...n,r,l]});const v=h(p?.style,t);v&&o.push({...g(e,t,i,s,{code:"unsupported-style",message:v}),componentPath:[...n,r,l]}),p?.richParagraphs?.length&&m({...e,richParagraphs:p.richParagraphs},t,i,s,o,[...n,r,l]);for(const[E,f]of(p?.children??[]).entries()){const O=[...n,r,l,E];if(t==="xlsx"){const D=u(f,r,l,p);if(D&&o.push({...g(f,t,i,s,D),componentPath:O}),f.grid)continue}w(f,t,i,s,O,o,a)}}}function y(e,t,i){c.assertBoundedRenderTree(e),e.pages.forEach((s,n)=>s.components.forEach((o,a)=>w(o,t,n,a,[],i,new Set)))}function G(e,t){const i=[];return y(e,t,i),i}function P(e,t,i=c.DEFAULT_DIAGNOSTIC_LIMIT){const s=c.createDiagnosticCollector(i);return y(e,t,s),s.snapshot()}function x(e,t,i,s){c.assertOutputActive(i.signal);const n=c.createDiagnosticCollector(i.diagnosticLimit);s?.diagnosticSummary?n.merge(s.diagnosticSummary):s?.diagnostics.forEach(r=>n.push(r));const o=n.entries.length,a=i.diagnosticLimit===void 0?void 0:new Set(n.entries);if(y(e,t,{push:r=>{c.assertOutputActive(i.signal),n.push(r)}}),(a?n.entries.filter(r=>!a.has(r)):n.entries.slice(o)).forEach(r=>b(r,i)),i.fidelity==="strict"&&n.total)throw new M(n.entries,i.diagnosticLimit===void 0?void 0:n.snapshot());return n}function N(e,t,i){return x(e,t,i).entries}exports.OutputFidelityError=M;exports.collectOutputDiagnostics=x;exports.inspectOutputCapabilities=G;exports.inspectOutputCapabilitiesSummary=P;exports.notifyOutputDiagnostic=b;exports.reportOutputDiagnostics=N;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z as f, A as E, G as k, x, N as $, i as M, E as L, r as C } from "./diagnostic-collector-C-JBA016.js";
|
|
2
2
|
function X(e, t) {
|
|
3
3
|
f(t.signal), E(() => t.onDiagnostic?.(e)), f(t.signal);
|
|
4
4
|
}
|
|
@@ -7,108 +7,112 @@ class j extends Error {
|
|
|
7
7
|
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";
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
function
|
|
10
|
+
const G = /* @__PURE__ */ new Set(["text", "rect", "line", "ellipse"]), B = /* @__PURE__ */ new Set(["image", "chart", "barcode", "qrcode"]);
|
|
11
|
+
function N(e, t) {
|
|
12
12
|
if (!e.grid) {
|
|
13
|
-
if (
|
|
13
|
+
if (M(e))
|
|
14
14
|
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;
|
|
15
|
-
if (
|
|
16
|
-
if (!
|
|
15
|
+
if (B.has(e.kind)) return { code: "missing-image", message: `${e.kind} requires imageData or a renderer adapter before output.` };
|
|
16
|
+
if (!G.has(e.kind)) return { code: "unsupported-component", message: `Unsupported component kind: ${e.kind}.` };
|
|
17
17
|
if (t === "xlsx" && e.kind !== "text") return { code: "unsupported-component", message: `XLSX data export omits ${e.kind} geometry.` };
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
function g(e, t, i,
|
|
20
|
+
function g(e, t, i, s, n) {
|
|
21
21
|
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;
|
|
22
|
-
return { ...
|
|
22
|
+
return { ...n, severity: "warning", format: t, pageIndex: i, componentIndex: s, kind: e.kind, nid: e.nid, ...d ? { extension: d } : {} };
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
if (!e || t === "dom") return;
|
|
24
|
+
function P(e, t) {
|
|
26
25
|
const i = [];
|
|
27
|
-
return e.rotateDeg && i.push("rotateDeg"), e.opacity !== void 0 && e.opacity !== 1 &&
|
|
26
|
+
return e.rotateDeg && (t || !Number.isFinite(e.rotateDeg)) && i.push("rotateDeg"), e.opacity !== void 0 && e.opacity !== 1 && (t || !Number.isFinite(e.opacity) || e.opacity < 0 || e.opacity > 1) && i.push("opacity"), i;
|
|
27
|
+
}
|
|
28
|
+
function h(e, t, i = !1) {
|
|
29
|
+
if (!e || t === "dom") return;
|
|
30
|
+
const s = t === "pdf" ? P(e, i) : [];
|
|
31
|
+
return t !== "pdf" && (e.rotateDeg && s.push("rotateDeg"), e.opacity !== void 0 && e.opacity !== 1 && s.push("opacity"), t !== "xlsx" && e.align === "justify" && s.push("justify")), t === "xlsx" && e.letterSpacing && s.push("letterSpacing"), s.length ? `${t} does not preserve these styles: ${s.join(", ")}.` : void 0;
|
|
28
32
|
}
|
|
29
|
-
function
|
|
33
|
+
function O(e) {
|
|
30
34
|
if (!e) return;
|
|
31
35
|
const t = ["backgroundColor", "align", "verticalAlign", "lineHeight", "borderTop", "borderRight", "borderBottom", "borderLeft", "borderColor", "lineColor", "lineWidthPt"].filter((i) => e[i] !== void 0);
|
|
32
36
|
return t.length ? `XLSX rich text does not retain independent run styles: ${t.join(", ")}.` : void 0;
|
|
33
37
|
}
|
|
34
38
|
function A(e) {
|
|
35
39
|
if (e.kind !== "text") return;
|
|
36
|
-
const t =
|
|
40
|
+
const t = O(e.style);
|
|
37
41
|
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}` : ""}` };
|
|
38
42
|
}
|
|
39
|
-
function
|
|
43
|
+
function S(e, t, i, s, n, o) {
|
|
40
44
|
const a = (u) => {
|
|
41
|
-
|
|
45
|
+
n.push({ ...g(e, t, i, s, { code: "unsupported-style", message: u }), componentPath: o });
|
|
42
46
|
};
|
|
43
47
|
for (const u of e.richParagraphs ?? []) {
|
|
44
48
|
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.");
|
|
45
49
|
const r = h({ align: u.align }, t);
|
|
46
50
|
r && a(r);
|
|
47
51
|
for (const d of u.segments) {
|
|
48
|
-
const c = h(d.style, t) ?? (t === "xlsx" ?
|
|
52
|
+
const c = h(d.style, t, !0) ?? (t === "xlsx" ? O(d.style) : void 0);
|
|
49
53
|
c && a(c);
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
|
-
function
|
|
57
|
+
function w(e, t, i, s, n, o, a) {
|
|
54
58
|
if (a.has(e)) return;
|
|
55
|
-
const u = new Set(a).add(e), r =
|
|
56
|
-
r && o.push({ ...g(e, t, i,
|
|
59
|
+
const u = new Set(a).add(e), r = N(e, t);
|
|
60
|
+
r && o.push({ ...g(e, t, i, s, r), componentPath: n });
|
|
57
61
|
const d = h(e.style, t);
|
|
58
|
-
d && o.push({ ...g(e, t, i,
|
|
62
|
+
d && o.push({ ...g(e, t, i, s, { code: "unsupported-style", message: d }), componentPath: n }), S(e, t, i, s, o, n), F(e, t, i, s, n, o, u);
|
|
59
63
|
}
|
|
60
|
-
function
|
|
64
|
+
function T(e, t, i) {
|
|
61
65
|
if (e.grid) return { code: "nested-components-omitted", message: "XLSX cannot place a nested grid inside a single cell; the nested grid is omitted." };
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
if (
|
|
66
|
+
const s = A(e);
|
|
67
|
+
if (s) return s;
|
|
68
|
+
if (M(e) && (e.leftMm < 0 || e.topMm < 0 || e.leftMm + e.widthMm > t + 1e-3 || e.topMm + e.heightMm > i + 1e-3)) return { code: "unsupported-style", message: "XLSX cannot clip a child image to a cell; it retains the original image dimensions." };
|
|
65
69
|
}
|
|
66
70
|
function R(e) {
|
|
67
71
|
let t;
|
|
68
|
-
return (i,
|
|
72
|
+
return (i, s, n, o) => {
|
|
69
73
|
t ??= new Map(C(e.grid, e.widthMm, e.heightMm).cells.map((r) => [`${r.ri}:${r.ci}`, r]));
|
|
70
|
-
const a = t.get(`${
|
|
71
|
-
return
|
|
74
|
+
const a = t.get(`${s}:${n}`), u = 2 * (e.grid?.paddingMm ?? 0.5);
|
|
75
|
+
return T(i, (a?.widthMm ?? 0) - u - (o?.indentMm ?? 0), (a?.heightMm ?? 0) - u);
|
|
72
76
|
};
|
|
73
77
|
}
|
|
74
|
-
function
|
|
78
|
+
function F(e, t, i, s, n, o, a) {
|
|
75
79
|
const u = R(e);
|
|
76
80
|
for (const [r, d] of (e.grid?.cells ?? []).entries()) for (const [c, l] of d.entries()) {
|
|
77
|
-
l?.dataBar !== void 0 && !L(l.dataBar) && o.push({ ...g(e, t, i,
|
|
81
|
+
l?.dataBar !== void 0 && !L(l.dataBar) && o.push({ ...g(e, t, i, s, { code: "unsupported-style", message: "Invalid resolved data-bar geometry or color; visual data bars require ordered 0–1 ratios and #RRGGBB colors." }), componentPath: [...n, r, c] });
|
|
78
82
|
const v = h(l?.style, t);
|
|
79
|
-
v && o.push({ ...g(e, t, i,
|
|
83
|
+
v && o.push({ ...g(e, t, i, s, { code: "unsupported-style", message: v }), componentPath: [...n, r, c] }), l?.richParagraphs?.length && S({ ...e, richParagraphs: l.richParagraphs }, t, i, s, o, [...n, r, c]);
|
|
80
84
|
for (const [m, p] of (l?.children ?? []).entries()) {
|
|
81
|
-
const b = [...
|
|
85
|
+
const b = [...n, r, c, m];
|
|
82
86
|
if (t === "xlsx") {
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
87
|
+
const D = u(p, r, c, l);
|
|
88
|
+
if (D && o.push({ ...g(p, t, i, s, D), componentPath: b }), p.grid) continue;
|
|
85
89
|
}
|
|
86
|
-
|
|
90
|
+
w(p, t, i, s, b, o, a);
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
function y(e, t, i) {
|
|
91
|
-
$(e), e.pages.forEach((
|
|
95
|
+
$(e), e.pages.forEach((s, n) => s.components.forEach((o, a) => w(o, t, n, a, [], i, /* @__PURE__ */ new Set())));
|
|
92
96
|
}
|
|
93
97
|
function _(e, t) {
|
|
94
98
|
const i = [];
|
|
95
99
|
return y(e, t, i), i;
|
|
96
100
|
}
|
|
97
101
|
function q(e, t, i = k) {
|
|
98
|
-
const
|
|
99
|
-
return y(e, t,
|
|
102
|
+
const s = x(i);
|
|
103
|
+
return y(e, t, s), s.snapshot();
|
|
100
104
|
}
|
|
101
|
-
function I(e, t, i,
|
|
105
|
+
function I(e, t, i, s) {
|
|
102
106
|
f(i.signal);
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
const o =
|
|
107
|
+
const n = x(i.diagnosticLimit);
|
|
108
|
+
s?.diagnosticSummary ? n.merge(s.diagnosticSummary) : s?.diagnostics.forEach((r) => n.push(r));
|
|
109
|
+
const o = n.entries.length, a = i.diagnosticLimit === void 0 ? void 0 : new Set(n.entries);
|
|
106
110
|
if (y(e, t, { push: (r) => {
|
|
107
|
-
f(i.signal),
|
|
108
|
-
} }), (a ?
|
|
109
|
-
return
|
|
111
|
+
f(i.signal), n.push(r);
|
|
112
|
+
} }), (a ? n.entries.filter((r) => !a.has(r)) : n.entries.slice(o)).forEach((r) => X(r, i)), i.fidelity === "strict" && n.total) throw new j(n.entries, i.diagnosticLimit === void 0 ? void 0 : n.snapshot());
|
|
113
|
+
return n;
|
|
110
114
|
}
|
|
111
|
-
function
|
|
115
|
+
function H(e, t, i) {
|
|
112
116
|
return I(e, t, i).entries;
|
|
113
117
|
}
|
|
114
118
|
export {
|
|
@@ -117,5 +121,5 @@ export {
|
|
|
117
121
|
I as c,
|
|
118
122
|
_ as i,
|
|
119
123
|
X as n,
|
|
120
|
-
|
|
124
|
+
H as r
|
|
121
125
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const w=require("./computed-
|
|
1
|
+
"use strict";const w=require("./computed-BQgBrma-.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 {
|
|
1
|
+
import { w } from "./computed-CH3NYPOW.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("未知图表类型");
|
|
@@ -0,0 +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;
|