@agile-team/mach-report 2.11.2 → 2.12.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 +14 -5
- package/THIRD_PARTY_NOTICES.md +270 -0
- package/dist/{ExcelBindingWizard-LWX6G1A2.js → ExcelBindingWizard-CeAf4QSE.js} +2 -2
- package/dist/{ExcelBindingWizard-a4kslPHF.cjs → ExcelBindingWizard-y0mT-AHR.cjs} +1 -1
- package/dist/{RuleEditor-C2QsOHOs.cjs → RuleEditor-ChRzNQuF.cjs} +1 -1
- package/dist/{RuleEditor-D9wQHrkf.js → RuleEditor-DzAmW5YH.js} +1 -1
- package/dist/analytics.d.cts +28 -0
- package/dist/analytics.d.ts +28 -0
- package/dist/assets-C2U-e-Sz.cjs +4 -0
- package/dist/assets-Q0wUwNrV.js +217 -0
- package/dist/code-options-BKXXY7NI.js +18 -0
- package/dist/code-options-BUTChiZZ.cjs +1 -0
- package/dist/codes.cjs +9 -0
- package/dist/codes.d.cts +223 -0
- package/dist/codes.d.ts +223 -0
- package/dist/codes.js +26917 -0
- package/dist/designer.cjs +2 -2
- package/dist/designer.d.cts +267 -0
- package/dist/designer.d.ts +267 -0
- package/dist/designer.js +2737 -1941
- package/dist/grid-strokes-Cr7DwUux.cjs +1 -0
- package/dist/grid-strokes-DyyG1q_o.js +53 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +80 -1
- package/dist/index.d.ts +80 -1
- package/dist/index.js +404 -374
- package/dist/pdf.cjs +76 -59
- package/dist/pdf.d.cts +51 -0
- package/dist/pdf.d.ts +51 -0
- package/dist/pdf.js +32128 -32048
- package/dist/record-bindings-By_UKZ2g.cjs +1 -0
- package/dist/{list-cell-ClFra1zS.js → record-bindings-D-5jQlTj.js} +67 -44
- package/dist/{region-binding-workflow-DhQvu1co.cjs → region-binding-workflow-BzfbxRiR.cjs} +1 -1
- package/dist/{region-binding-workflow-CXDmt9Bs.js → region-binding-workflow-CcUq8W2Q.js} +1 -1
- package/dist/server/node.d.cts +52 -1
- package/dist/server/node.d.ts +52 -1
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +239 -210
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +95 -3
- package/dist/server.d.ts +95 -3
- package/dist/server.js +456 -433
- package/dist/style.css +1 -1
- package/dist/{template-registry-WNXdkiET.js → template-registry-BjE1VS6g.js} +221 -157
- package/dist/template-registry-D3SjENi6.cjs +1 -0
- package/dist/template-review-BfCC8Ng9.cjs +2 -0
- package/dist/{template-review-BdcXSYbx.js → template-review-BzpcI-tR.js} +772 -666
- package/dist/validate-BJ5HIWY8.cjs +1 -0
- package/dist/validate-DbgEM1Hh.js +163 -0
- package/dist/vue/async.d.cts +121 -2
- package/dist/vue/async.d.ts +121 -2
- package/dist/vue/index.d.cts +114 -6
- package/dist/vue/index.d.ts +114 -6
- package/dist/{workbook-session-BKOTwcoq.js → workbook-session-BPb3TMnT.js} +1 -1
- package/dist/{workbook-session-CLYLhZWu.cjs → workbook-session-DNa2RHNG.cjs} +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +52 -1
- package/dist/worker.d.ts +52 -1
- package/dist/worker.js +2 -2
- package/dist/xlsx.cjs +1 -1
- package/dist/xlsx.d.cts +40 -0
- package/dist/xlsx.d.ts +40 -0
- package/dist/xlsx.js +3 -3
- package/package.json +16 -3
- package/dist/assets-Bu6UohJx.cjs +0 -1
- package/dist/assets-DegqDNqY.js +0 -160
- package/dist/list-cell-BuYn4tGF.cjs +0 -1
- package/dist/template-registry-ukBGlm8N.cjs +0 -1
- package/dist/template-review-BXp2oyqg.cjs +0 -1
- package/dist/textwrap-CWHyzkBH.cjs +0 -4
- package/dist/textwrap-DE1kgcJB.js +0 -110
- package/dist/validate-7s0yn6ii.js +0 -148
- package/dist/validate-DsRiNw8h.cjs +0 -1
package/dist/worker.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./task-events-DQ276fn2.cjs"),A=require("./validate-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./task-events-DQ276fn2.cjs"),A=require("./validate-BJ5HIWY8.cjs"),u="mach-report-worker/1";class l extends Error{constructor(r){super(r.message),this.name=r.name,this.code=r.code,this.path=r.path,this.issues=r.issues,this.diagnostics=r.diagnostics}}function p(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function L(e){return p(e)?["rows","pages","cells"].every(r=>typeof e[r]=="number"&&Number.isSafeInteger(e[r])&&e[r]>=0)&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>=0:!1}function P(e){return Array.isArray(e)&&e.every(r=>p(r)&&typeof r.code=="string"&&typeof r.message=="string"&&["info","warning","error"].includes(r.severity))}function T(e){return p(e)&&Object.values(e).every(r=>p(r)&&(r.revision===void 0||typeof r.revision=="string")&&(r.sourceToken===void 0||typeof r.sourceToken=="string"))}function v(e,r){if(!p(e)||!L(e.stats)||!P(e.diagnostics)||!T(e.revisions))return!1;if(r==="prepare")return A.validateRenderPlan(e.plan).ok;const t=e.format==="pdf"?"application/pdf":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";return e.bytes instanceof Uint8Array&&(e.format==="pdf"||e.format==="xlsx")&&e.contentType===t}function W(e){if(!e||typeof e!="object")return{message:String(e)};const r={};for(const t of["code","path","field","message"]){const o=e[t];typeof o=="string"&&(r[t]=o)}return r}function j(e){const r=W(e);if(!p(e))return r;for(const t of["format","severity","kind","nid"])typeof e[t]=="string"&&(r[t]=e[t]);for(const t of["pageIndex","componentIndex"])Number.isSafeInteger(e[t])&&e[t]>=0&&(r[t]=e[t]);return Array.isArray(e.componentPath)&&e.componentPath.every(t=>Number.isSafeInteger(t)&&t>=0)&&(r.componentPath=e.componentPath),r}function O(e){if(!(e instanceof Error))return{name:"Error",message:String(e)};const r=e;return{name:e.name,message:e.message,...typeof r.code=="string"?{code:r.code}:{},...typeof r.path=="string"?{path:r.path}:{},...Array.isArray(r.issues)?{issues:r.issues.map(W)}:{},...Array.isArray(r.diagnostics)?{diagnostics:r.diagnostics.map(j)}:{}}}function S(e){if(!e||typeof e!="object")return!1;const r=e;return r.protocol===u&&typeof r.id=="string"&&(r.operation==="prepare"||r.operation==="export")&&!!r.input&&typeof r.input=="object"}async function N(e,r,t){try{const o=r.operation==="prepare"?await e.prepare({...r.input,onEvent:t}):await e.export({...r.input,onEvent:t});return{protocol:u,id:r.id,result:o}}catch(o){return{protocol:u,id:r.id,error:O(o)}}}function z(e){const r=e.result;return!r||!("bytes"in r)||!(r.bytes.buffer instanceof ArrayBuffer)?[]:[r.bytes.buffer]}function _(e,r){if(!p(e)||typeof e.taskId!="string"||!e.taskId||r.taskId!==void 0&&e.taskId!==r.taskId||e.correlationId!==r.correlationId||e.reportId!==void 0&&(typeof e.reportId!="string"||!r.reportIds.includes(e.reportId))||!["query","validate","layout","assets","encode"].includes(e.stage)||!["started","completed","failed"].includes(e.status))return!1;for(const t of["completed","total"])if(e[t]!==void 0&&(typeof e[t]!="number"||!Number.isFinite(e[t])||e[t]<0))return!1;return e.completed===void 0||e.total===void 0||e.completed<=e.total}let q=0;function w(e){const r=new Error("报表 Worker 任务已取消");return r.name="AbortError",Object.defineProperty(r,"cause",{value:e}),r}function B(e,r){if(!e||typeof e!="object")return;const t=e;return t.protocol===u&&t.id===r?t:void 0}function F(e,r={}){const t=r.timeoutMs??12e4;if(!Number.isFinite(t)||t<=0||t>2147483647)throw new RangeError("Worker timeoutMs 应为正有限数字,且不能超过 2147483647");const o=(i,c,n,d)=>n?.aborted?Promise.reject(w(n.reason)):new Promise((I,b)=>{let g;try{g=e()}catch(a){b(a);return}const R=`mach-report-${Date.now()}-${++q}`;let y=!1,E=()=>{},k;const f=(a,s)=>{y||(y=!0,k&&clearTimeout(k),E(),n?.removeEventListener("abort",h),Promise.resolve().then(()=>g.terminate()).then(()=>a===void 0?I(s):b(a),m=>b(a??m)))},h=()=>f(w(n?.reason)),M=a=>{const s=B(a,R);if(!(!s||y)){if("type"in s&&s.type==="event"){const m="event"in s?s.event:void 0;_(m,c)?x.notifyReportTaskEvent(d,m,n):f(new Error("报表 Worker 返回无效阶段事件"));return}s.error&&typeof s.error.name=="string"&&typeof s.error.message=="string"?f(new l(s.error)):v(s.result,i)&&(i!=="export"||"format"in s.result&&"format"in c&&s.result.format===c.format)?f(void 0,s.result):f(new Error("报表 Worker 返回无效响应"))}};try{if(E=g.subscribe(M,a=>f(a??new Error("报表 Worker 执行失败"))),y){E();return}if(n?.addEventListener("abort",h,{once:!0}),k=setTimeout(()=>f(new l({name:"ReportRuntimeError",code:"timeout",message:`报表 Worker 执行超过 ${t}ms`})),t),n?.aborted)h();else{const{onEvent:a,signal:s,...m}=c;g.postMessage({protocol:u,id:R,operation:i,input:m})}}catch(a){f(a)}});return{prepare:(i,c,n)=>o("prepare",i,c,n),export:(i,c,n)=>o("export",i,c,n)}}function $(e,r={}){return F(()=>{const t=e();return{postMessage:o=>t.postMessage(o),terminate:()=>t.terminate(),subscribe:(o,i)=>{const c=d=>o(d.data),n=d=>i(d instanceof ErrorEvent?new Error(d.message):new Error("报表 Worker 消息无法解码"));return t.addEventListener("message",c),t.addEventListener("error",n),t.addEventListener("messageerror",n),()=>{t.removeEventListener("message",c),t.removeEventListener("error",n),t.removeEventListener("messageerror",n)}}}},r)}function D(e,r=globalThis){const t=o=>{S(o.data)&&N(e,o.data,i=>r.postMessage({protocol:u,id:o.data.id,type:"event",event:i})).then(i=>r.postMessage(i,z(i)))};return r.addEventListener("message",t),()=>r.removeEventListener("message",t)}exports.ReportWorkerError=l;exports.createBrowserReportExecutor=$;exports.serveReportWorker=D;
|
package/dist/worker.d.cts
CHANGED
|
@@ -7,6 +7,50 @@ export declare interface BrowserReportWorker {
|
|
|
7
7
|
removeEventListener(type: "error" | "messageerror", listener: (event: Event) => void): void;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/** Serializable symbol settings. Encoders remain in the optional /codes entry. */
|
|
11
|
+
declare interface CodeOptions {
|
|
12
|
+
/** Explicit content, including an empty value, takes precedence over legacy fallbackText. */
|
|
13
|
+
value?: string;
|
|
14
|
+
symbology?: "code128" | "code39" | "ean13" | "ean8";
|
|
15
|
+
errorCorrection?: "L" | "M" | "Q" | "H";
|
|
16
|
+
/** White modules around a symbol: QR >=4, linear >=10, EAN >=11. */
|
|
17
|
+
quietZoneModules?: number;
|
|
18
|
+
/** Human-readable content below a linear barcode. */
|
|
19
|
+
showText?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 列值格式化(声明式、JSON 可序列化)。
|
|
24
|
+
* 在 paginate 的 cellText 出口统一消费:格式化发生在进 RenderPlan 之前,
|
|
25
|
+
* 三后端(DOM/Canvas/PDF)零改动。
|
|
26
|
+
*
|
|
27
|
+
* 语义约定(v0.9 固化):
|
|
28
|
+
* - number.digits 显式给出 → 精确保留(12.5 + digits:2 → "12.50")
|
|
29
|
+
* - number.thousands 默认 false(千分位显式开启)
|
|
30
|
+
* - date 字符串按"本地时区的日历日"解析(YYYY-MM-DD / YYYY/MM/DD 直取年月日,
|
|
31
|
+
* 不经 Date 字符串构造——后者按 UTC 零点,负时区环境会少一天)
|
|
32
|
+
*/
|
|
33
|
+
declare type ColumnFormat = {
|
|
34
|
+
kind: "number";
|
|
35
|
+
thousands?: boolean;
|
|
36
|
+
digits?: number;
|
|
37
|
+
} | {
|
|
38
|
+
kind: "percent";
|
|
39
|
+
digits?: number;
|
|
40
|
+
} | {
|
|
41
|
+
kind: "date";
|
|
42
|
+
pattern?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** A literal own field of the current label record; expressions and paths are not evaluated. */
|
|
46
|
+
declare interface ComponentBinding {
|
|
47
|
+
field: string;
|
|
48
|
+
format?: ValueFormat;
|
|
49
|
+
prefix?: string;
|
|
50
|
+
suffix?: string;
|
|
51
|
+
emptyText?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
10
54
|
declare type ComponentKind = "text" | "image" | "barcode" | "qrcode" | "chart" | "line" | "rect" | "ellipse";
|
|
11
55
|
|
|
12
56
|
declare interface ComponentStyle {
|
|
@@ -61,6 +105,10 @@ declare interface GridCell {
|
|
|
61
105
|
}
|
|
62
106
|
|
|
63
107
|
declare interface PlanComponent {
|
|
108
|
+
/** Optional QR/barcode encoding configuration; no encoder is loaded by the core. */
|
|
109
|
+
code?: CodeOptions;
|
|
110
|
+
/** Template-only binding; resolved and removed before constructing the output plan. */
|
|
111
|
+
binding?: ComponentBinding;
|
|
64
112
|
/** Template page furniture repeats per page and reserves its vertical band. */
|
|
65
113
|
pageAnchor?: "header" | "footer";
|
|
66
114
|
kind: ComponentKind;
|
|
@@ -270,7 +318,7 @@ declare interface ReportRuntimeStats {
|
|
|
270
318
|
declare interface ReportTaskEvent {
|
|
271
319
|
taskId: string;
|
|
272
320
|
correlationId?: string;
|
|
273
|
-
stage: "query" | "validate" | "layout" | "encode";
|
|
321
|
+
stage: "query" | "validate" | "layout" | "assets" | "encode";
|
|
274
322
|
status: "started" | "completed" | "failed";
|
|
275
323
|
reportId?: string;
|
|
276
324
|
completed?: number;
|
|
@@ -331,4 +379,7 @@ declare interface SerializedReportError {
|
|
|
331
379
|
/** 在 Worker 入口注册一次 runtime;返回函数可清理监听器,浏览器主线程无需引入 Node。 */
|
|
332
380
|
export declare function serveReportWorker(runtime: ReportRuntime, scope?: ReportWorkerScope): () => void;
|
|
333
381
|
|
|
382
|
+
/** The same declarative formatting used by list columns, before any output backend. */
|
|
383
|
+
declare type ValueFormat = ColumnFormat;
|
|
384
|
+
|
|
334
385
|
export { }
|
package/dist/worker.d.ts
CHANGED
|
@@ -7,6 +7,50 @@ export declare interface BrowserReportWorker {
|
|
|
7
7
|
removeEventListener(type: "error" | "messageerror", listener: (event: Event) => void): void;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/** Serializable symbol settings. Encoders remain in the optional /codes entry. */
|
|
11
|
+
declare interface CodeOptions {
|
|
12
|
+
/** Explicit content, including an empty value, takes precedence over legacy fallbackText. */
|
|
13
|
+
value?: string;
|
|
14
|
+
symbology?: "code128" | "code39" | "ean13" | "ean8";
|
|
15
|
+
errorCorrection?: "L" | "M" | "Q" | "H";
|
|
16
|
+
/** White modules around a symbol: QR >=4, linear >=10, EAN >=11. */
|
|
17
|
+
quietZoneModules?: number;
|
|
18
|
+
/** Human-readable content below a linear barcode. */
|
|
19
|
+
showText?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 列值格式化(声明式、JSON 可序列化)。
|
|
24
|
+
* 在 paginate 的 cellText 出口统一消费:格式化发生在进 RenderPlan 之前,
|
|
25
|
+
* 三后端(DOM/Canvas/PDF)零改动。
|
|
26
|
+
*
|
|
27
|
+
* 语义约定(v0.9 固化):
|
|
28
|
+
* - number.digits 显式给出 → 精确保留(12.5 + digits:2 → "12.50")
|
|
29
|
+
* - number.thousands 默认 false(千分位显式开启)
|
|
30
|
+
* - date 字符串按"本地时区的日历日"解析(YYYY-MM-DD / YYYY/MM/DD 直取年月日,
|
|
31
|
+
* 不经 Date 字符串构造——后者按 UTC 零点,负时区环境会少一天)
|
|
32
|
+
*/
|
|
33
|
+
declare type ColumnFormat = {
|
|
34
|
+
kind: "number";
|
|
35
|
+
thousands?: boolean;
|
|
36
|
+
digits?: number;
|
|
37
|
+
} | {
|
|
38
|
+
kind: "percent";
|
|
39
|
+
digits?: number;
|
|
40
|
+
} | {
|
|
41
|
+
kind: "date";
|
|
42
|
+
pattern?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** A literal own field of the current label record; expressions and paths are not evaluated. */
|
|
46
|
+
declare interface ComponentBinding {
|
|
47
|
+
field: string;
|
|
48
|
+
format?: ValueFormat;
|
|
49
|
+
prefix?: string;
|
|
50
|
+
suffix?: string;
|
|
51
|
+
emptyText?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
10
54
|
declare type ComponentKind = "text" | "image" | "barcode" | "qrcode" | "chart" | "line" | "rect" | "ellipse";
|
|
11
55
|
|
|
12
56
|
declare interface ComponentStyle {
|
|
@@ -61,6 +105,10 @@ declare interface GridCell {
|
|
|
61
105
|
}
|
|
62
106
|
|
|
63
107
|
declare interface PlanComponent {
|
|
108
|
+
/** Optional QR/barcode encoding configuration; no encoder is loaded by the core. */
|
|
109
|
+
code?: CodeOptions;
|
|
110
|
+
/** Template-only binding; resolved and removed before constructing the output plan. */
|
|
111
|
+
binding?: ComponentBinding;
|
|
64
112
|
/** Template page furniture repeats per page and reserves its vertical band. */
|
|
65
113
|
pageAnchor?: "header" | "footer";
|
|
66
114
|
kind: ComponentKind;
|
|
@@ -270,7 +318,7 @@ declare interface ReportRuntimeStats {
|
|
|
270
318
|
declare interface ReportTaskEvent {
|
|
271
319
|
taskId: string;
|
|
272
320
|
correlationId?: string;
|
|
273
|
-
stage: "query" | "validate" | "layout" | "encode";
|
|
321
|
+
stage: "query" | "validate" | "layout" | "assets" | "encode";
|
|
274
322
|
status: "started" | "completed" | "failed";
|
|
275
323
|
reportId?: string;
|
|
276
324
|
completed?: number;
|
|
@@ -331,4 +379,7 @@ declare interface SerializedReportError {
|
|
|
331
379
|
/** 在 Worker 入口注册一次 runtime;返回函数可清理监听器,浏览器主线程无需引入 Node。 */
|
|
332
380
|
export declare function serveReportWorker(runtime: ReportRuntime, scope?: ReportWorkerScope): () => void;
|
|
333
381
|
|
|
382
|
+
/** The same declarative formatting used by list columns, before any output backend. */
|
|
383
|
+
declare type ValueFormat = ColumnFormat;
|
|
384
|
+
|
|
334
385
|
export { }
|
package/dist/worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as A } from "./task-events-Dpsvf_t2.js";
|
|
2
|
-
import { c as M } from "./validate-
|
|
2
|
+
import { c as M } from "./validate-DbgEM1Hh.js";
|
|
3
3
|
const u = "mach-report-worker/1";
|
|
4
4
|
class R extends Error {
|
|
5
5
|
constructor(r) {
|
|
@@ -70,7 +70,7 @@ function z(e) {
|
|
|
70
70
|
return !r || !("bytes" in r) || !(r.bytes.buffer instanceof ArrayBuffer) ? [] : [r.bytes.buffer];
|
|
71
71
|
}
|
|
72
72
|
function _(e, r) {
|
|
73
|
-
if (!p(e) || typeof e.taskId != "string" || !e.taskId || r.taskId !== void 0 && e.taskId !== r.taskId || e.correlationId !== r.correlationId || e.reportId !== void 0 && (typeof e.reportId != "string" || !r.reportIds.includes(e.reportId)) || !["query", "validate", "layout", "encode"].includes(e.stage) || !["started", "completed", "failed"].includes(e.status)) return !1;
|
|
73
|
+
if (!p(e) || typeof e.taskId != "string" || !e.taskId || r.taskId !== void 0 && e.taskId !== r.taskId || e.correlationId !== r.correlationId || e.reportId !== void 0 && (typeof e.reportId != "string" || !r.reportIds.includes(e.reportId)) || !["query", "validate", "layout", "assets", "encode"].includes(e.stage) || !["started", "completed", "failed"].includes(e.status)) return !1;
|
|
74
74
|
for (const t of ["completed", "total"]) if (e[t] !== void 0 && (typeof e[t] != "number" || !Number.isFinite(e[t]) || e[t] < 0)) return !1;
|
|
75
75
|
return e.completed === void 0 || e.total === void 0 || e.completed <= e.total;
|
|
76
76
|
}
|
package/dist/xlsx.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./progress-BnLiS5eH.cjs"),w=require("./workbook-session-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./progress-BnLiS5eH.cjs"),w=require("./workbook-session-DNa2RHNG.cjs"),W=require("./render-plan-7xpGrCEl.cjs"),R=require("./grid-geometry-CZ_cYB6O.cjs"),C=require("./style-UgIJSA1F.cjs"),P=require("./capabilities-CsZ-pNHR.cjs"),m=require("./region-binding-workflow-BzfbxRiR.cjs");function v(e,t){const i=e??t;if(!Number.isSafeInteger(i)||i<=0)throw new Error("Excel 图片字节预算应为正安全整数");return i}function z(e,t){const i=e.imageData;if(!i||!/^data:image\/(png|jpe?g);base64,/i.test(i))return;if(i.length>Math.ceil(t/3)*4+64)throw new Error("Excel 单张图片超过字节预算");const n=i.indexOf(","),r=i.slice(n+1);if(!/^[A-Za-z0-9+/]+={0,2}$/.test(r)||r.length%4!==0)throw new Error("Excel 图片不是有效的 base64 数据");const o=r.length/4*3-(r.endsWith("==")?2:r.endsWith("=")?1:0);if(o>t)throw new Error("Excel 单张图片超过字节预算");const l=/^data:image\/png;/i.test(i)?"png":"jpeg",s=atob(r.slice(0,12));if(l==="png"?!s.startsWith(`PNG\r
|
|
2
2
|
|
|
3
3
|
`):!s.startsWith("ÿØÿ"))throw new Error("Excel 图片内容与 PNG/JPEG 类型不一致");return{base64:`data:image/${l};base64,${r}`,key:`${l}:${r}`,extension:l,bytes:o}}function O(e,t,i){let n=i*72/25.4;if(!Number.isFinite(n)||t+Math.ceil(n/409)-1>1048576)throw new Error("Excel 图片占位超过工作表行数上限");for(;n>0;){if(t>1048576)throw new Error("Excel 图片占位超过工作表行数上限");const r=Math.min(409,n);e.getRow(t++).height=r,n-=r}return t}function G(e,t,i){let n=Math.round(t*36e3),r=0;if(!Number.isSafeInteger(n))throw new Error("Excel 图片锚点超出安全坐标范围");for(e.properties.defaultColWidth??=8.43;r<16384;){const o=e.getColumn(r+1).width??e.properties.defaultColWidth,l=Math.round(w.excelColumnWidthToMm(o)*36e3);if(!Number.isSafeInteger(l)||l<=0)throw new Error("Excel 图片锚点所在列宽无效");if(n<l)return{col:r+n/l,row:i-1,nativeCol:r,nativeColOff:n,nativeRow:i-1,nativeRowOff:0};n-=l,r++}throw new Error("Excel 图片锚点超过16384列上限")}function N(e,t,i){const n=v(t.maxImageBytes,16777216),r=v(t.maxTotalImageBytes,32*1024*1024),o=v(t.maxImages,1e3),l=new Map,s=new Map;let a=0;return{write(d,c,h){if(![c.widthMm,c.heightMm,c.leftMm].every(Number.isFinite)||c.widthMm<0||c.heightMm<0||c.leftMm<0)throw new Error("Excel 图片尺寸无效");if(!c.widthMm||!c.heightMm)return h;const g=s.get(c.imageData)??z(c,n);if(g&&s.set(c.imageData,g),!g)return i.push(`${c.nid??c.kind}: Excel 图片仅支持 PNG/JPEG data URI,已跳过`),h;let f=l.get(g.key);if(f===void 0){if(l.size>=o)throw new Error("Excel 唯一图片数量超过预算");if(a+g.bytes>r)throw new Error("Excel 图片总字节数超过预算");f=e.addImage({base64:g.base64,extension:g.extension}),l.set(g.key,f),a+=g.bytes}const u=O(d,h,c.heightMm);return d.addImage(f,{tl:G(d,c.leftMm,h),ext:{width:c.widthMm*96/25.4,height:c.heightMm*96/25.4},editAs:"oneCell"}),u}}}function B(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function A(e,t){const i=e.meta?.xlsxFlow;if(i===void 0)return;if(!B(i)||i.version!=="1.0"||!Number.isSafeInteger(i.columnStart)||Number(i.columnStart)<0)throw new Error("Excel 多区域几何标记无效,不能按列序猜测输出");if(!e.grid)throw new Error("Excel 多区域输出只接受显式网格组件");const n=i,r=e.grid.colWidthsMm;if(!r?.length||n.columnStart+r.length>t.length||r.some((o,l)=>Math.abs(o-t[n.columnStart+l])>.001))throw new Error("Excel 多区域列位置与网格列宽不一致");return n}function I(e){const t=e.meta?.xlsxFlow;if(t===void 0){if(e.components.some(n=>n.meta?.xlsxFlow!==void 0))throw new Error("Excel 多区域页面缺少完整列几何标记");return}const i=L(t,e.meta?.reportScope);for(const n of e.components){const r=A(n,i.widths);if(!r)throw new Error("Excel 多区域页面混入没有区域几何的组件,请使用独立页面模板");const o=i.widths.slice(0,r.columnStart).reduce((s,a)=>s+a,e.marginLeftMm??0),l=n.grid.colWidthsMm.reduce((s,a)=>s+a,0);if(Math.abs(o-n.leftMm)>.01||Math.abs(l-n.widthMm)>.01)throw new Error("Excel 多区域标记与真实横向位置不一致")}return i}function L(e,t){if(!B(e)||e.version!=="1.0"||typeof e.sheet!="string"||!e.sheet.trim()||typeof e.templateId!="string"||!e.templateId.trim())throw new Error("Excel 多区域工作表标识无效");if(!Array.isArray(e.fullWidthsMm)||!e.fullWidthsMm.length||e.fullWidthsMm.length>16384||e.fullWidthsMm.some(i=>typeof i!="number"||!Number.isFinite(i)||i<=0||i>2e3))throw new Error("Excel 多区域完整列宽无效");if(t!==void 0&&(typeof t!="string"||!t.trim()))throw new Error("Excel 多区域报表命名空间无效");return{key:JSON.stringify([t??e.templateId,e.sheet]),sheet:e.sheet,widths:e.fullWidthsMm}}function S(e){return Math.round(e*1e6)/1e6}function D(e,t,i,n,r){return e.components.filter(o=>n?o.pageAnchor==="header"?t===0:o.pageAnchor==="footer"?t===i-1:o.table?.role!=="header"?!0:r.has(o.table.id)?!1:(r.add(o.table.id),!0):!0)}function j(e,t,i,n){const r=e.components.filter(l=>!t.includes(l)&&l.table?.role==="header"),o=t.filter(l=>!l.pageAnchor).reduce((l,s)=>Math.max(l,s.topMm+s.heightMm),e.marginTopMm??0);return t.map(l=>{let s=l.topMm;return i&&l.pageAnchor==="footer"&&(s=o),s-=r.filter(a=>a.topMm+a.heightMm<=s+.001).reduce((a,d)=>a+d.heightMm,0),{component:l,layout:R.resolveGridLayout(l.grid,l.widthMm,l.heightMm),top:s,column:A(l,n).columnStart}})}function _(e,t,i){const n=t.length-1;if(n*i.length>1e6)throw new Error("Excel 多区域单页超过 100 万几何单元格,请减小预览分页高度或列数");const r=new Map(t.map((s,a)=>[s,a])),o=new Map,l=new Map;for(const s of e)for(const a of s.layout.cells){if(!Object.keys(a.cell).length)continue;const d=r.get(S(s.top+a.yMm)),c=r.get(S(s.top+a.yMm+a.heightMm)),h=s.column+a.ci,g=h+(a.cell.colSpan??1),f=`${d}:${h}`;for(let u=d;u<c;u++)for(let x=h;x<g;x++){const M=`${u}:${x}`;if(l.has(M))throw new Error("Excel 多区域实际单元格互相覆盖,已终止输出,未覆盖已有内容");l.set(M,f)}o.set(f,{...a.cell,style:C.mergeComponentStyles(s.component.style,a.cell.style),rowSpan:c-d,colSpan:g-h})}return Array.from({length:n},(s,a)=>{const d=[];for(let c=0;c<i.length;c++){const h=`${a}:${c}`,g=o.get(h);g?(d.push(g),c+=(g.colSpan??1)-1):l.has(h)||d.push(null)}return d})}function H(e,t){const i=new Set,n=[];let r;for(const[o,{page:l}]of e.entries()){const s=I(l);if(r&&(s.key!==r.key||s.widths.length!==r.widths.length||s.widths.some((f,u)=>Math.abs(f-r.widths[u])>.001)))throw new Error("Excel 多区域分页的工作表或列结构不一致");r??=s;const a=D(l,o,e.length,t,i),d=j(l,a,t,s.widths);if(!d.length)continue;const c=[...new Set(d.flatMap(f=>[...f.layout.rows.map(u=>S(f.top+u.pos)),S(f.top+f.component.heightMm)]))].sort((f,u)=>f-u),h=_(d,c,s.widths),g=c.slice(1).map((f,u)=>f-c[u]);n.push({kind:"rect",leftMm:0,topMm:0,widthMm:s.widths.reduce((f,u)=>f+u,0),heightMm:g.reduce((f,u)=>f+u,0),grid:{cells:h,colWidthsMm:s.widths,rowHeightsMm:g}})}return n}const T=72/25.4,q=32767,X=253;function b(e,t){if(typeof e!="string")return;if(e.length>q)throw new Error(`Excel 单元格 ${t} 最多支持 32767 个字符,无法无损导出;内容未裁剪`);let i=0;for(let n=0;n<e.length;n++)if(e.charCodeAt(n)===10&&++i>X)throw new Error(`Excel 单元格 ${t} 最多支持 253 个换行,无法无损导出;内容未改写`)}function E(e){if(!e)return;const t=e.replace("#","");return/^[0-9a-fA-F]{6}$/.test(t)?`FF${t.toUpperCase()}`:void 0}function F(e,t={}){e.font={name:t.fontFamily,bold:t.bold===!0,italic:t.italic===!0,underline:t.underline===!0,size:C.resolveFontSize(t).fontSizePt,color:E(t.color)?{argb:E(t.color)}:void 0}}const y={a3:{width:297,height:420,code:8},a4:{width:210,height:297,code:9},a5:{width:148,height:210,code:11}};function K(e,t,i,n){if(t&&t!=="auto")return y[t].code;const r=Math.min(e.pageWidthMm,e.pageHeightMm),o=Math.max(e.pageWidthMm,e.pageHeightMm),l=Object.values(y).find(s=>Math.abs(r-s.width)<=1&&Math.abs(o-s.height)<=1);return l?l.code:(n.push(`page ${i+1}: 自定义纸张 ${e.pageWidthMm}×${e.pageHeightMm}mm 无对应 Excel 纸型,打印设置回退 A4;可显式配置 paperSize`),y.a4.code)}function J(e,t,i,n){const r=typeof t.text=="string"?t.text:"";if(i!=="raw"||!Object.prototype.hasOwnProperty.call(t,"value")){b(r,e.address),e.value=r;return}const o=t.value;if(o===null||typeof o=="string"||typeof o=="boolean"||typeof o=="number"&&Number.isFinite(o)){b(o,e.address),e.value=o,t.numberFormat&&(e.numFmt=t.numberFormat);return}b(r,e.address),e.value=r,n.push(`原始单元格值无效,已保留显示文本:${e.address}`)}function U(e){const t=I(e);return t?{id:`xlsx-flow:${t.key}`,title:t.sheet,wide:!0,flow:!0}:V(e)}function V(e){const i=e.components.filter(n=>n.table!==void 0)[0]?.table;if(!(!i||typeof i.id!="string"||!i.id.trim()||!Array.isArray(i.columnKeys)||!i.columnKeys.length)){for(const n of e.components){if(n.table){if(!n.grid||n.table.id!==i.id)return;continue}if(n.grid||n.kind!=="text"&&!W.isImageBackedComponent(n)||n.richParagraphs?.length&&!n.text&&!n.lines?.length)return}return{id:i.id,title:i.title,wide:i.layout==="wide"||e.layout==="wide"}}}function Z(e,t){const i=new Set;for(const[n,r]of e.pages.entries())if(!t[n])for(const o of r.components)typeof o.table?.id=="string"&&i.add(o.table.id);return i}function k(e){return e.layout==="wide"||e.components.some(t=>t.table?.layout==="wide")}function Q(e,t,i){const n=[],r=e.pages.map(U),o=Z(e,r);for(const[l,s]of e.pages.entries()){const a=r[l],d=a&&!o.has(a.id),c=t==="pages"||!d?void 0:a;if(t==="continuous"&&!c)throw new Error(`page ${l+1}: continuous Excel 需要完整、单一的逻辑表来源;自由布局请使用 sheetMode: 'pages'`);const h=c!==void 0&&(t==="continuous"||c.wide);!h&&t!=="pages"&&k(s)&&i.push(`page ${l+1}: 混合或缺少逻辑表来源,已保留独立 Sheet,未猜测合并内容`);const g=n[n.length-1];h&&g?.continuous&&g.tableId===c.id?g.pages.push({page:s,index:l}):n.push({pages:[{page:s,index:l}],continuous:h,...h?{tableId:c.id,title:c.title}:{},...a?.flow?{flow:!0,title:a.title}:{}})}return n}function $(e,t,i){return!e||e.length===t.length&&e.every((n,r)=>i(n,t[r]))}function Y(e,t,i,n){const r=e.table,o=t.columns.map(a=>a.size),l=$(n.keys,r.columnKeys,(a,d)=>a===d),s=$(n.widths,o,(a,d)=>Math.abs(a-d)<=.001);if(r.columnKeys.length!==o.length||!l||!s)throw new Error(`page ${i+1}: 连续 Excel 逻辑表 ${r.id} 的列结构或列宽不一致`);if(n.keys??=r.columnKeys,n.widths??=o,r.role==="header"){if(r.rowIndex!==-1)throw new Error(`page ${i+1}: 连续 Excel 表头 rowIndex 必须为 -1`);n.headerSeen=!0}else{if(!["body","group-header","subtotal","grand-total"].includes(r.role)||r.rowIndex!==n.expectedRow)throw new Error(`page ${i+1}: 连续 Excel 逻辑行来源不连续或重复(期望 ${n.expectedRow})`);n.expectedRow+=t.rows.length}if(t.cells.some(a=>a.cell.children?.length))throw new Error(`page ${i+1}: 连续 Excel 暂不支持嵌套组件;请使用独立 Sheet 导出并检查告警`)}function ee(e,t){const i={expectedRow:0,headerSeen:!1};for(const{page:n,index:r}of e.pages)for(const o of n.components){const l=t.get(o);o.table&&l&&Y(o,l,r,i)}if(!i.headerSeen)throw new Error("连续 Excel 逻辑表缺少明确表头来源")}function te(e,t,i){let n=(e?.replace(/[\\/*?:[\]]/g," ").replace(/\s+/g," ").trim()||`Sheet${t+1}`).slice(0,31).replace(/^'+|'+$/g,"").trim()||`Sheet${t+1}`;n.toLowerCase()==="history"&&(n+=" 报表");let r=n,o=1;for(;i.has(r.toLowerCase());){const l=` (${++o})`;r=n.slice(0,31-l.length)+l}return i.add(r.toLowerCase()),r}function ne(e){const t=new Set;function i(n,r,o,l){return n<=r?n:(t.has(o)||(e.push(l),t.add(o)),r)}return{column:n=>i(n,255,"column","Excel 单列宽度上限为 255 字符,超宽列已收敛至 255;单元格值完整保留,显示范围可能受限"),row:n=>i(n,409,"row","Excel 行高上限为 409pt,超高行已收敛至 409pt;单元格值完整保留,显示范围可能受限")}}function ie(e){const t=e.flow?H(e.pages,e.continuous).map(o=>({comp:o,pageIndex:e.pages[0].index})):e.pages.flatMap(({page:o,index:l},s)=>o.components.filter(a=>!e.continuous||(a.pageAnchor!=="header"||s===0)&&(a.pageAnchor!=="footer"||s===e.pages.length-1)).map(a=>({comp:a,pageIndex:l}))),i=new Map;let n=1,r=0;for(const{comp:o}of t)if(o.grid){const l=R.resolveGridLayout(o.grid,o.widthMm,o.heightMm);i.set(o,l),n=Math.max(n,l.columns.length)}else o.kind==="text"&&(r=Math.max(r,o.widthMm));if(n>16384)throw new Error("Excel 最多支持 16384 列,无法无损导出此报表");return{components:t,grids:i,columnCount:n,textWidthMm:r}}function re(e,t,i){const{page:n,index:r}=e.pages[0],o=t!==void 0&&t!=="auto";return(e.continuous||k(n))&&!o?{}:{pageSetup:{paperSize:K(n,t,r,i),orientation:n.pageWidthMm>n.pageHeightMm?"landscape":"portrait",fitToPage:!0,...e.continuous?{fitToWidth:1,fitToHeight:0}:{}}}}function oe(e){const t=E(e.borderColor??e.lineColor),i={style:"thin",...t?{color:{argb:t}}:{}};return{...e.borderTop!==!1?{top:i}:{},...e.borderLeft!==!1?{left:i}:{},...e.borderBottom!==!1?{bottom:i}:{},...e.borderRight!==!1?{right:i}:{}}}function le(e,t){e.alignment={horizontal:t.align??"left",vertical:t.verticalAlign??"middle",wrapText:!0};const i=E(t.backgroundColor);i&&(e.fill={type:"pattern",pattern:"solid",fgColor:{argb:i}}),e.border=oe(t),F(e,t)}function se(e,t){for(const[i,n]of t.columns.entries()){const r=e.sheet.getColumn(i+1),o=e.limits.column(w.mmToExcelColumnWidth(n.size));(r.width==null||r.width<o)&&(r.width=o)}}function ae(e,t,i){for(const[n,r]of t.rows.entries()){const o=e.sheet.getRow(i+n),l=e.limits.row(r.size*T);(o.height==null||o.height<l)&&(o.height=l)}}function ce(e,t,i,n){const r=Math.max(1,Math.min(t.cell.colSpan??1,i.columns.length-t.ci)),o=Math.max(1,Math.min(t.cell.rowSpan??1,i.rows.length-t.ri));(r>1||o>1)&&e.mergeCells(n+t.ri,t.ci+1,n+t.ri+o-1,t.ci+r)}function de(e,t,i,n,r){if(n+i.rows.length-1>1048576)throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");ae(e,i,n);for(const o of i.cells){const l=e.sheet.getCell(n+o.ri,o.ci+1);J(l,o.cell,e.valueMode,e.warnings),o.cell.children?.length&&e.warnings.push(`page ${r+1} ${t.nid??t.kind} cell ${o.ri+1}:${o.ci+1}: 嵌套组件内容暂不支持 xlsx 导出,已跳过`),le(l,C.mergeComponentStyles(t.style,o.cell.style)),o.cell.indentMm&&(l.alignment={...l.alignment,indent:Math.min(250,Math.max(1,Math.round(o.cell.indentMm/2.5)))}),ce(e.sheet,o,i,n)}return n+i.rows.length}function he(e,t,i,n,r){const o=Array.isArray(t.lines)&&t.lines.length>0?t.lines.join(`
|
|
4
4
|
`):t.text??"";if(t.richParagraphs?.length){const d=o.length===0?"富文本内容暂不支持 xlsx 导出,已跳过":"富文本按已有文本回退导出,内联样式未保留";e.warnings.push(`page ${r+1} ${t.nid??t.kind}: ${d}`)}const l=e.sheet.getRow(i),s=l.getCell(1);b(o,s.address),s.value=o,s.alignment={horizontal:t.style?.align??"left",vertical:t.style?.verticalAlign??"middle",wrapText:!0};const a=E(t.style?.backgroundColor);return a&&(s.fill={type:"pattern",pattern:"solid",fgColor:{argb:a}}),F(s,t.style),n>1&&e.sheet.mergeCells(i,1,i,n),l.height=e.limits.row(t.heightMm*T),i+1}function ge(e,t,i){const n=t+i-1;e.views=[{state:"frozen",ySplit:n,xSplit:0}],e.pageSetup.printTitlesRow=`1:${n}`}function fe(e,t,i,n){!t.grids.size&&t.textWidthMm>0&&(e.sheet.getColumn(1).width=e.limits.column(w.mmToExcelColumnWidth(t.textWidthMm)));for(const l of t.grids.values())se(e,l);let r=1,o=!1;for(const{comp:l,pageIndex:s}of t.components){const a=i&&l.table?.role==="header";if(a&&o)continue;if(r>1048576)throw new Error("Excel 最多支持 1048576 行,无法无损导出此报表");const d=t.grids.get(l);d?(a&&(ge(e.sheet,r,d.rows.length),o=!0),r=de(e,l,d,r,s)):l.kind==="text"?r=he(e,l,r,t.columnCount,s):W.isImageBackedComponent(l)?r=n.write(e.sheet,l,r):e.warnings.push(`page ${s+1} ${l.nid??l.kind}: 组件类型 ${l.kind} 暂不支持 xlsx 导出,已跳过`)}}function ue(e){if(e.valueMode!==void 0&&e.valueMode!=="text"&&e.valueMode!=="raw")throw new Error("xlsx valueMode 必须是 text 或 raw");if(e.paperSize!==void 0&&e.paperSize!=="auto"&&!Object.prototype.hasOwnProperty.call(y,e.paperSize))throw new Error("xlsx paperSize 必须是 auto、a3、a4 或 a5");if(e.sheetMode!==void 0&&!["auto","pages","continuous"].includes(e.sheetMode))throw new Error("xlsx sheetMode 必须是 auto、pages 或 continuous")}async function me(e,t={}){ue(t),p.assertOutputActive(t.signal);const i=P.reportOutputDiagnostics(e,"xlsx",t),n=new w.ExcelJSRuntime.Workbook,r=[],o=N(n,t,r),l=ne(r),s=Q(e,t.sheetMode,r),a=new Set;for(const[c,h]of s.entries()){const g=ie(h);h.continuous&&!h.flow&&ee(h,g.grids);const f=h.pages[0].page,u=t.sheetName?.(c)??te(h.title,c,a);a.add(u.toLowerCase());const x=n.addWorksheet(u,re(h,t.paperSize,r)),M=t.valueMode??(k(f)||h.continuous||h.flow?"raw":"text");p.assertOutputActive(t.signal),fe({sheet:x,warnings:r,limits:l,valueMode:M},g,h.continuous,o),await p.outputCheckpoint(t,c+1,s.length)}p.assertOutputActive(t.signal);const d=await n.xlsx.writeBuffer();return p.assertOutputActive(t.signal),{workbook:n,buffer:d,warnings:r,diagnostics:i}}exports.importExcelTemplate=w.importExcelTemplate;exports.inspectExcelWorkbook=w.inspectExcelWorkbook;exports.openExcelWorkbook=w.openExcelWorkbook;exports.bindExcelTemplate=m.bindExcelTemplate;exports.createExcelBindingDocument=m.createExcelBindingDocument;exports.createExcelBindingSession=m.createExcelBindingSession;exports.createExcelRegionBindingDocument=m.createExcelRegionBindingDocument;exports.createExcelRegionBindingSession=m.createExcelRegionBindingSession;exports.excelBindingCellRange=m.excelBindingCellRange;exports.excelBindingRowRange=m.excelBindingRowRange;exports.getExcelSheetWindow=m.getExcelSheetWindow;exports.parseExcelBindingSession=m.parseExcelBindingSession;exports.parseExcelRegionBindingSession=m.parseExcelRegionBindingSession;exports.validateExcelBindingFields=m.validateExcelBindingFields;exports.validateExcelBindingRecipe=m.validateExcelBindingRecipe;exports.validateExcelBindingRegions=m.validateExcelBindingRegions;exports.validateExcelRegionBindings=m.validateExcelRegionBindings;exports.validateExcelRegionFields=m.validateExcelRegionFields;exports.validateExcelRegionGeometry=m.validateExcelRegionGeometry;exports.renderPlanToXlsx=me;
|
package/dist/xlsx.d.cts
CHANGED
|
@@ -264,6 +264,18 @@ declare type CellValue =
|
|
|
264
264
|
|
|
265
265
|
declare type CfvoTypes = 'percentile' | 'percent' | 'num' | 'min' | 'max' | 'formula' | 'autoMin' | 'autoMax';
|
|
266
266
|
|
|
267
|
+
/** Serializable symbol settings. Encoders remain in the optional /codes entry. */
|
|
268
|
+
declare interface CodeOptions {
|
|
269
|
+
/** Explicit content, including an empty value, takes precedence over legacy fallbackText. */
|
|
270
|
+
value?: string;
|
|
271
|
+
symbology?: "code128" | "code39" | "ean13" | "ean8";
|
|
272
|
+
errorCorrection?: "L" | "M" | "Q" | "H";
|
|
273
|
+
/** White modules around a symbol: QR >=4, linear >=10, EAN >=11. */
|
|
274
|
+
quietZoneModules?: number;
|
|
275
|
+
/** Human-readable content below a linear barcode. */
|
|
276
|
+
showText?: boolean;
|
|
277
|
+
}
|
|
278
|
+
|
|
267
279
|
declare interface Color {
|
|
268
280
|
/**
|
|
269
281
|
* Hex string for alpha-red-green-blue e.g. FF00FF00
|
|
@@ -402,6 +414,15 @@ declare interface CommentProtection {
|
|
|
402
414
|
lockText: 'True' | 'False';
|
|
403
415
|
}
|
|
404
416
|
|
|
417
|
+
/** A literal own field of the current label record; expressions and paths are not evaluated. */
|
|
418
|
+
declare interface ComponentBinding {
|
|
419
|
+
field: string;
|
|
420
|
+
format?: ValueFormat;
|
|
421
|
+
prefix?: string;
|
|
422
|
+
suffix?: string;
|
|
423
|
+
emptyText?: string;
|
|
424
|
+
}
|
|
425
|
+
|
|
405
426
|
declare type ComponentKind = "text" | "image" | "barcode" | "qrcode" | "chart" | "line" | "rect" | "ellipse";
|
|
406
427
|
|
|
407
428
|
declare interface ComponentStyle {
|
|
@@ -1622,6 +1643,10 @@ export declare function parseExcelBindingSession(input: unknown): ExcelBindingSe
|
|
|
1622
1643
|
export declare function parseExcelRegionBindingSession(input: unknown): ExcelRegionBindingSession;
|
|
1623
1644
|
|
|
1624
1645
|
declare interface PlanComponent {
|
|
1646
|
+
/** Optional QR/barcode encoding configuration; no encoder is loaded by the core. */
|
|
1647
|
+
code?: CodeOptions;
|
|
1648
|
+
/** Template-only binding; resolved and removed before constructing the output plan. */
|
|
1649
|
+
binding?: ComponentBinding;
|
|
1625
1650
|
/** Template page furniture repeats per page and reserves its vertical band. */
|
|
1626
1651
|
pageAnchor?: "header" | "footer";
|
|
1627
1652
|
kind: ComponentKind;
|
|
@@ -1844,6 +1869,8 @@ declare interface ReportTemplate {
|
|
|
1844
1869
|
schemaVersion?: string;
|
|
1845
1870
|
/** 参数定义(可选;宿主也可经 ReportPreview 的 paramDefs prop 提供,prop 优先) */
|
|
1846
1871
|
params?: ReportParamDef[];
|
|
1872
|
+
/** Fixed label pages repeat in record → copy → template-page order. */
|
|
1873
|
+
repeat?: ReportTemplateRepeat;
|
|
1847
1874
|
pages: TemplatePage[];
|
|
1848
1875
|
}
|
|
1849
1876
|
|
|
@@ -1858,6 +1885,16 @@ declare interface ReportTemplateDocument {
|
|
|
1858
1885
|
template: ReportTemplate;
|
|
1859
1886
|
}
|
|
1860
1887
|
|
|
1888
|
+
/** Every record emits its copies, each containing all template pages in their original order. */
|
|
1889
|
+
declare interface ReportTemplateRepeat {
|
|
1890
|
+
dataset: string;
|
|
1891
|
+
rowKey?: string;
|
|
1892
|
+
/** Whole copies per record, 1..1000. The field value must be a number, never a numeric string. */
|
|
1893
|
+
copies?: number | {
|
|
1894
|
+
field: string;
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1861
1898
|
declare interface RichParagraph {
|
|
1862
1899
|
segments: RichSegment[];
|
|
1863
1900
|
align?: ComponentStyle["align"];
|
|
@@ -2336,6 +2373,9 @@ export declare function validateExcelRegionFields(recipe: ExcelRegionBindingReci
|
|
|
2336
2373
|
/** Geometry-only scan is separate so field-selection UI need not repeatedly traverse the source grid. */
|
|
2337
2374
|
export declare function validateExcelRegionGeometry(imported: ExcelImportResult, recipe: ExcelRegionBindingRecipe): ExcelBindingIssue[];
|
|
2338
2375
|
|
|
2376
|
+
/** The same declarative formatting used by list columns, before any output backend. */
|
|
2377
|
+
declare type ValueFormat = ColumnFormat;
|
|
2378
|
+
|
|
2339
2379
|
declare enum ValueType {
|
|
2340
2380
|
Null = 0,
|
|
2341
2381
|
Merge = 1,
|
package/dist/xlsx.d.ts
CHANGED
|
@@ -264,6 +264,18 @@ declare type CellValue =
|
|
|
264
264
|
|
|
265
265
|
declare type CfvoTypes = 'percentile' | 'percent' | 'num' | 'min' | 'max' | 'formula' | 'autoMin' | 'autoMax';
|
|
266
266
|
|
|
267
|
+
/** Serializable symbol settings. Encoders remain in the optional /codes entry. */
|
|
268
|
+
declare interface CodeOptions {
|
|
269
|
+
/** Explicit content, including an empty value, takes precedence over legacy fallbackText. */
|
|
270
|
+
value?: string;
|
|
271
|
+
symbology?: "code128" | "code39" | "ean13" | "ean8";
|
|
272
|
+
errorCorrection?: "L" | "M" | "Q" | "H";
|
|
273
|
+
/** White modules around a symbol: QR >=4, linear >=10, EAN >=11. */
|
|
274
|
+
quietZoneModules?: number;
|
|
275
|
+
/** Human-readable content below a linear barcode. */
|
|
276
|
+
showText?: boolean;
|
|
277
|
+
}
|
|
278
|
+
|
|
267
279
|
declare interface Color {
|
|
268
280
|
/**
|
|
269
281
|
* Hex string for alpha-red-green-blue e.g. FF00FF00
|
|
@@ -402,6 +414,15 @@ declare interface CommentProtection {
|
|
|
402
414
|
lockText: 'True' | 'False';
|
|
403
415
|
}
|
|
404
416
|
|
|
417
|
+
/** A literal own field of the current label record; expressions and paths are not evaluated. */
|
|
418
|
+
declare interface ComponentBinding {
|
|
419
|
+
field: string;
|
|
420
|
+
format?: ValueFormat;
|
|
421
|
+
prefix?: string;
|
|
422
|
+
suffix?: string;
|
|
423
|
+
emptyText?: string;
|
|
424
|
+
}
|
|
425
|
+
|
|
405
426
|
declare type ComponentKind = "text" | "image" | "barcode" | "qrcode" | "chart" | "line" | "rect" | "ellipse";
|
|
406
427
|
|
|
407
428
|
declare interface ComponentStyle {
|
|
@@ -1622,6 +1643,10 @@ export declare function parseExcelBindingSession(input: unknown): ExcelBindingSe
|
|
|
1622
1643
|
export declare function parseExcelRegionBindingSession(input: unknown): ExcelRegionBindingSession;
|
|
1623
1644
|
|
|
1624
1645
|
declare interface PlanComponent {
|
|
1646
|
+
/** Optional QR/barcode encoding configuration; no encoder is loaded by the core. */
|
|
1647
|
+
code?: CodeOptions;
|
|
1648
|
+
/** Template-only binding; resolved and removed before constructing the output plan. */
|
|
1649
|
+
binding?: ComponentBinding;
|
|
1625
1650
|
/** Template page furniture repeats per page and reserves its vertical band. */
|
|
1626
1651
|
pageAnchor?: "header" | "footer";
|
|
1627
1652
|
kind: ComponentKind;
|
|
@@ -1844,6 +1869,8 @@ declare interface ReportTemplate {
|
|
|
1844
1869
|
schemaVersion?: string;
|
|
1845
1870
|
/** 参数定义(可选;宿主也可经 ReportPreview 的 paramDefs prop 提供,prop 优先) */
|
|
1846
1871
|
params?: ReportParamDef[];
|
|
1872
|
+
/** Fixed label pages repeat in record → copy → template-page order. */
|
|
1873
|
+
repeat?: ReportTemplateRepeat;
|
|
1847
1874
|
pages: TemplatePage[];
|
|
1848
1875
|
}
|
|
1849
1876
|
|
|
@@ -1858,6 +1885,16 @@ declare interface ReportTemplateDocument {
|
|
|
1858
1885
|
template: ReportTemplate;
|
|
1859
1886
|
}
|
|
1860
1887
|
|
|
1888
|
+
/** Every record emits its copies, each containing all template pages in their original order. */
|
|
1889
|
+
declare interface ReportTemplateRepeat {
|
|
1890
|
+
dataset: string;
|
|
1891
|
+
rowKey?: string;
|
|
1892
|
+
/** Whole copies per record, 1..1000. The field value must be a number, never a numeric string. */
|
|
1893
|
+
copies?: number | {
|
|
1894
|
+
field: string;
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1861
1898
|
declare interface RichParagraph {
|
|
1862
1899
|
segments: RichSegment[];
|
|
1863
1900
|
align?: ComponentStyle["align"];
|
|
@@ -2336,6 +2373,9 @@ export declare function validateExcelRegionFields(recipe: ExcelRegionBindingReci
|
|
|
2336
2373
|
/** Geometry-only scan is separate so field-selection UI need not repeatedly traverse the source grid. */
|
|
2337
2374
|
export declare function validateExcelRegionGeometry(imported: ExcelImportResult, recipe: ExcelRegionBindingRecipe): ExcelBindingIssue[];
|
|
2338
2375
|
|
|
2376
|
+
/** The same declarative formatting used by list columns, before any output backend. */
|
|
2377
|
+
declare type ValueFormat = ColumnFormat;
|
|
2378
|
+
|
|
2339
2379
|
declare enum ValueType {
|
|
2340
2380
|
Null = 0,
|
|
2341
2381
|
Merge = 1,
|
package/dist/xlsx.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { a as x, o as z } from "./progress-7OSZbFok.js";
|
|
2
|
-
import { e as P, E as B, m as C } from "./workbook-session-
|
|
3
|
-
import { i as ke, a as We, o as Ae } from "./workbook-session-
|
|
2
|
+
import { e as P, E as B, m as C } from "./workbook-session-BPb3TMnT.js";
|
|
3
|
+
import { i as ke, a as We, o as Ae } from "./workbook-session-BPb3TMnT.js";
|
|
4
4
|
import { i as $ } from "./render-plan-Ck6koX9L.js";
|
|
5
5
|
import { r as k } from "./grid-geometry-BNptEcMm.js";
|
|
6
6
|
import { e as W, r as N } from "./style-CQ1PK8ZB.js";
|
|
7
7
|
import { r as G } from "./capabilities-CK_7hizc.js";
|
|
8
|
-
import { b as Fe, c as Re, a as Te, d as ze, e as Pe, f as Be, g as Ne, h as Ge, p as Le, i as Oe, v as je, j as De, k as _e, l as He, m as Ke, n as Xe } from "./region-binding-workflow-
|
|
8
|
+
import { b as Fe, c as Re, a as Te, d as ze, e as Pe, f as Be, g as Ne, h as Ge, p as Le, i as Oe, v as je, j as De, k as _e, l as He, m as Ke, n as Xe } from "./region-binding-workflow-CcUq8W2Q.js";
|
|
9
9
|
function y(e, t) {
|
|
10
10
|
const r = e ?? t;
|
|
11
11
|
if (!Number.isSafeInteger(r) || r <= 0) throw new Error("Excel 图片字节预算应为正安全整数");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agile-team/mach-report",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "独立的 TypeScript 报表引擎:模板分页、DOM/Canvas/PDF/Excel 输出与 Vue 3 预览组件",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -130,6 +130,16 @@
|
|
|
130
130
|
"types": "./dist/server/node.d.cts",
|
|
131
131
|
"default": "./dist/server-node.cjs"
|
|
132
132
|
}
|
|
133
|
+
},
|
|
134
|
+
"./codes": {
|
|
135
|
+
"import": {
|
|
136
|
+
"types": "./dist/codes.d.ts",
|
|
137
|
+
"default": "./dist/codes.js"
|
|
138
|
+
},
|
|
139
|
+
"require": {
|
|
140
|
+
"types": "./dist/codes.d.cts",
|
|
141
|
+
"default": "./dist/codes.cjs"
|
|
142
|
+
}
|
|
133
143
|
}
|
|
134
144
|
},
|
|
135
145
|
"publishConfig": {
|
|
@@ -141,7 +151,8 @@
|
|
|
141
151
|
},
|
|
142
152
|
"files": [
|
|
143
153
|
"dist",
|
|
144
|
-
"LICENSING.md"
|
|
154
|
+
"LICENSING.md",
|
|
155
|
+
"THIRD_PARTY_NOTICES.md"
|
|
145
156
|
],
|
|
146
157
|
"peerDependencies": {
|
|
147
158
|
"vue": "^3.2.47"
|
|
@@ -165,7 +176,9 @@
|
|
|
165
176
|
"vite": "^7.3.6",
|
|
166
177
|
"vite-plugin-dts": "^4.5.0",
|
|
167
178
|
"vue": "^3.5.0",
|
|
168
|
-
"vue-tsc": "^3.0.0"
|
|
179
|
+
"vue-tsc": "^3.0.0",
|
|
180
|
+
"@bwip-js/generic": "4.11.4",
|
|
181
|
+
"fast-png": "6.4.0"
|
|
169
182
|
},
|
|
170
183
|
"license": "SEE LICENSE IN LICENSE",
|
|
171
184
|
"author": "ChenyCHENYU (Agile Team)",
|
package/dist/assets-Bu6UohJx.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const m=require("./style-UgIJSA1F.cjs"),k=require("./capabilities-CsZ-pNHR.cjs"),E=require("./progress-BnLiS5eH.cjs"),S=["borderTop","borderRight","borderBottom","borderLeft","borderColor","lineColor","lineWidthPt"];function y(n,e){const t=m.resolveBoxBorders(e.style),r=t.inner?[...n.edges]:[];t.top&&r.push({kind:"h",pos:0,from:0,to:e.widthMm}),t.bottom&&r.push({kind:"h",pos:e.heightMm,from:0,to:e.widthMm}),t.left&&r.push({kind:"v",pos:0,from:0,to:e.heightMm}),t.right&&r.push({kind:"v",pos:e.widthMm,from:0,to:e.heightMm});const o=m.resolveStroke(e.style);return r.map(s=>({...s,...o}))}function x(n,e,t){const r=n.get(e);(!r||t.widthPt>r.widthPt)&&n.set(e,t)}function w(n,e,t,r,o,s){const i=t<e.rows.length?e.rows[t].pos:e.rows[e.rows.length-1].pos+e.rows[e.rows.length-1].size;for(let c=r;c<o;c++){const d=e.columns[c];x(n,`h:${t}:${c}`,{kind:"h",pos:i,from:d.pos,to:d.pos+d.size,...s})}}function b(n,e,t,r,o,s){const i=t<e.columns.length?e.columns[t].pos:e.columns[e.columns.length-1].pos+e.columns[e.columns.length-1].size;for(let c=r;c<o;c++){const d=e.rows[c];x(n,`v:${t}:${c}`,{kind:"v",pos:i,from:d.pos,to:d.pos+d.size,...s})}}function v(n,e,t,r){const o=Math.min(e.columns.length,t.ci+(t.cell.colSpan??1)),s=Math.min(e.rows.length,t.ri+(t.cell.rowSpan??1)),i=m.mergeComponentStyles(r,t.cell.style),c=m.resolveBoxBorders(i),d=m.resolveStroke(i);c.top&&w(n,e,t.ri,t.ci,o,d),c.bottom&&w(n,e,s,t.ci,o,d),c.left&&b(n,e,t.ci,t.ri,s,d),c.right&&b(n,e,o,t.ri,s,d)}function A(n){const e=[...n.values()].sort((r,o)=>r.kind.localeCompare(o.kind)||r.pos-o.pos||r.from-o.from),t=[];for(const r of e){const o=t[t.length-1];o&&o.kind===r.kind&&o.pos===r.pos&&Math.abs(o.to-r.from)<1e-6&&o.color===r.color&&o.widthPt===r.widthPt?o.to=r.to:t.push({...r})}return t}function B(n,e){if(!n.cells.some(({cell:s})=>S.some(i=>s.style?.[i]!==void 0)))return y(n,e);const t=new Map,r=new Set,o=n.columns.length;for(const s of n.cells){v(t,n,s,e.style);const i=Math.min(n.rows.length,s.ri+(s.cell.rowSpan??1)),c=Math.min(o,s.ci+(s.cell.colSpan??1));for(let d=s.ri;d<i;d++)for(let a=s.ci;a<c;a++)r.add(d*o+a)}for(let s=0;s<n.rows.length;s++)for(let i=0;i<o;i++)r.has(s*o+i)||v(t,n,{ri:s,ci:i,cell:{}},e.style);return A(t)}class p extends Error{constructor(e,t){super(e.message),this.name="OutputAssetError",this.diagnostic=e,this.cause=t}}function f(n){if(n.aborted)throw n.reason??new DOMException("The operation was aborted.","AbortError")}function O(n){const e={maxAssets:1e3,maxImageBytes:33554432,maxTotalImageBytes:134217728,maxDurationMs:3e4,...n.assetBudget};for(const[t,r]of Object.entries(e))if(!Number.isSafeInteger(r)||r<=0||r>2147483647)throw new RangeError(`${t} must be a positive safe integer at most 2147483647.`);return e}function P(n){const e=/^data:image\/[a-z0-9.+-]+(;base64)?,(.*)$/is.exec(n);if(!e)throw new TypeError("Asset renderers must return an image data URL.");return e[1]?Math.ceil(e[2].length*3/4):new TextEncoder().encode(decodeURIComponent(e[2])).byteLength}function h(n,e,t,r,o){const s={code:t,message:r,severity:"warning",format:n.options.format??"dom",pageIndex:e.pageIndex,componentIndex:e.componentIndex,componentPath:e.componentPath,kind:e.component.kind,nid:e.component.nid};if(n.diagnostics.push(s),k.notifyOutputDiagnostic(s,{...n.options,signal:n.signal}),n.options.assetFailure!=="placeholder")throw new p(s,o)}async function D(n,e,t){const r=n.options.assetRenderers?.[e.kind];if(e.imageData||!r)return e.imageData;if(++n.rendered>n.budget.maxAssets)return h(n,t,"asset-budget-exceeded","Output exceeded the asset count budget.");let o;try{if(n.active=t,o=await E.waitForOutput(r({...t,signal:n.signal}),n.signal),f(n.signal),o.length>n.budget.maxImageBytes*4+1024)return h(n,t,"asset-budget-exceeded","Output exceeded the image payload byte budget.");const s=P(o);if(s>n.budget.maxImageBytes||n.bytes+s>n.budget.maxTotalImageBytes)return h(n,t,"asset-budget-exceeded","Output exceeded the encoded image byte budget.");n.bytes+=s}catch(s){if(n.signal.aborted||s instanceof p)throw s;return h(n,t,"asset-render-failed",`Asset renderer failed for ${e.kind}; output was not silently omitted.`,s)}return o}function T(n,e){const t=n.active;if(!t){e.abort(new Error("Asset rendering exceeded maxDurationMs."));return}const r={code:"asset-budget-exceeded",message:"Asset rendering exceeded maxDurationMs.",severity:"warning",format:n.options.format??"dom",pageIndex:t.pageIndex,componentIndex:t.componentIndex,componentPath:t.componentPath,kind:t.component.kind,nid:t.component.nid};n.diagnostics.push(r);try{k.notifyOutputDiagnostic(r,{...n.options,signal:n.signal})}catch(o){e.abort(o);return}e.abort(new p(r))}async function C(n,e,t,r,o){if(!e?.children?.length)return e;const s=[];for(const[i,c]of e.children.entries())s.push(await I(n,c,{...t,component:c,componentPath:[...r,i]},o));return s.some((i,c)=>i!==e.children[c])?{...e,children:s}:e}async function I(n,e,t,r){if(f(n.signal),r.has(e))throw new TypeError("Cyclic grid children cannot be rendered.");let o=n.cache.get(e);o||(o=D(n,e,t),n.cache.set(e,o));const s=await o;f(n.signal);let i=e.grid;if(i){const c=new Set(r).add(e),d=[];for(const[a,u]of i.cells.entries()){const g=[];for(const[l,M]of u.entries())g.push(await C(n,M,t,[...t.componentPath,a,l],c));d.push(g)}d.some((a,u)=>a.some((g,l)=>g!==i.cells[u][l]))&&(i={...i,cells:d})}return s!==e.imageData||i!==e.grid?{...e,imageData:s,grid:i}:e}async function R(n,e={}){const t=O(e);if(e.signal?.aborted)throw e.signal.reason??new DOMException("The operation was aborted.","AbortError");const r=new AbortController,o=()=>r.abort(e.signal?.reason);if(e.signal?.addEventListener("abort",o,{once:!0}),!e.assetRenderers||!Object.keys(e.assetRenderers).length)return e.signal?.removeEventListener("abort",o),{plan:n,diagnostics:[]};const s={options:e,signal:r.signal,diagnostics:[],rendered:0,bytes:0,budget:t,cache:new WeakMap},i=setTimeout(()=>T(s,r),t.maxDurationMs);try{const c=[];for(const[d,a]of n.pages.entries()){if(d<(e.start??0)||d>(e.end??n.pages.length-1)){c.push(a);continue}const u=[];for(const[g,l]of a.components.entries())u.push(await I(s,l,{component:l,pageIndex:d,componentIndex:g,componentPath:[]},new Set));c.push(u.some((g,l)=>g!==a.components[l])?{...a,components:u}:a)}return f(s.signal),{plan:c.some((d,a)=>d!==n.pages[a])?{...n,pages:c}:n,diagnostics:s.diagnostics}}finally{clearTimeout(i),e.signal?.removeEventListener("abort",o)}}exports.OutputAssetError=p;exports.resolveGridStrokes=B;exports.resolvePlanAssets=R;
|