@agile-team/mach-report 0.5.0 → 0.6.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/dist/ReportPreview-DWLjYi_p.js +527 -0
- package/dist/ReportPreview-rBtmbu3W.cjs +6 -0
- package/dist/_commonjsHelpers-DKOUU3wS.cjs +1 -0
- package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
- package/dist/builder/template-builder.d.ts +53 -0
- package/dist/compat/jh4j-template.d.ts +12 -0
- package/dist/defaults.d.ts +27 -0
- package/dist/index.cjs +6 -1663
- package/dist/index.d.cts +13 -344
- package/dist/index.d.ts +13 -344
- package/dist/index.js +727 -1419
- package/dist/layout/paginate.d.ts +51 -0
- package/dist/layout/textwrap.d.ts +36 -0
- package/dist/manager/api.d.ts +45 -0
- package/dist/manager/index.d.ts +2 -0
- package/dist/manager/types.d.ts +50 -0
- package/dist/manager.cjs +1 -122
- package/dist/manager.d.cts +5 -97
- package/dist/manager.d.ts +5 -97
- package/dist/manager.js +66 -81
- package/dist/pdf/font-loader.d.ts +5 -0
- package/dist/pdf/index.d.ts +2 -0
- package/dist/pdf/render-pdf.d.ts +25 -0
- package/dist/pdf.cjs +84 -52530
- package/dist/pdf.d.cts +4 -31
- package/dist/pdf.d.ts +4 -31
- package/dist/pdf.js +22843 -39218
- package/dist/plugin-BIJxGHZX.cjs +1 -0
- package/dist/plugin-DrV67_VW.js +89 -0
- package/dist/render/canvas.d.ts +61 -0
- package/dist/render/dom.d.ts +10 -0
- package/dist/render/grid-geometry.d.ts +41 -0
- package/dist/render/style.d.ts +33 -0
- package/dist/render/window.d.ts +23 -0
- package/dist/schema/render-plan.d.ts +96 -0
- package/dist/schema/validate.d.ts +15 -0
- package/dist/sql/ast-check.d.ts +14 -0
- package/dist/sql/compile.d.ts +31 -0
- package/dist/sql/expr.d.ts +21 -0
- package/dist/sql/index.d.ts +4 -0
- package/dist/sql/tokenizer.d.ts +25 -0
- package/dist/sql.cjs +68 -45207
- package/dist/sql.d.cts +3 -93
- package/dist/sql.d.ts +3 -93
- package/dist/sql.js +37213 -41613
- package/dist/style-B3vxGDZd.cjs +3 -0
- package/dist/style-B7Xfo5I-.js +255 -0
- package/dist/style.css +1 -0
- package/dist/units.d.ts +11 -0
- package/dist/vue/ReportPreview.d.ts +141 -0
- package/dist/vue/ReportToolbar.d.ts +25 -0
- package/dist/vue/adapters.d.ts +37 -0
- package/dist/vue/async.d.cts +146 -0
- package/dist/vue/async.d.ts +146 -0
- package/dist/vue/composables/usePageWindow.d.ts +28 -0
- package/dist/vue/composables/usePrintExport.d.ts +19 -0
- package/dist/vue/composables/useZoom.d.ts +15 -0
- package/dist/vue/config.d.ts +79 -0
- package/dist/vue/index.d.cts +11 -0
- package/dist/vue/index.d.ts +11 -0
- package/dist/vue/injection-keys.d.ts +12 -0
- package/dist/vue/local-adapter.d.ts +12 -0
- package/dist/vue/pdf-exporter.d.ts +13 -0
- package/dist/vue/plugin.d.ts +34 -0
- package/dist/vue-async.cjs +1 -0
- package/dist/vue-async.js +17 -0
- package/dist/vue.cjs +1 -0
- package/dist/vue.js +44 -0
- package/package.json +44 -6
- package/dist/textwrap-DWzM7pt1.d.cts +0 -135
- package/dist/textwrap-DWzM7pt1.d.ts +0 -135
package/dist/manager.js
CHANGED
|
@@ -1,85 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
super(message);
|
|
5
|
-
this.url = url;
|
|
6
|
-
this.name = "ReportAdminError";
|
|
1
|
+
class h extends Error {
|
|
2
|
+
constructor(a, r) {
|
|
3
|
+
super(a), this.url = r, this.name = "ReportAdminError";
|
|
7
4
|
}
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// src/manager/api.ts
|
|
11
|
-
var BASE = "/report/codePrintReport";
|
|
12
|
-
var LOCK_BASE = "/report/codePrintReportLock";
|
|
13
|
-
function unwrap(response, url) {
|
|
14
|
-
const body = response;
|
|
15
|
-
if (body && body.code != null && body.code !== 200) {
|
|
16
|
-
throw new ReportAdminError(String(body.message || "\u8BF7\u6C42\u5931\u8D25"), url);
|
|
17
|
-
}
|
|
18
|
-
return body?.data ?? body;
|
|
19
5
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
6
|
+
const o = "/report/codePrintReport", d = "/report/codePrintReportLock";
|
|
7
|
+
function n(s, a) {
|
|
8
|
+
const r = s;
|
|
9
|
+
if (r && r.code != null && r.code !== 200)
|
|
10
|
+
throw new h(String(r.message || "请求失败"), a);
|
|
11
|
+
return r?.data ?? r;
|
|
12
|
+
}
|
|
13
|
+
function $(s) {
|
|
14
|
+
const { request: a } = s, r = s.baseUrl ?? "";
|
|
23
15
|
return {
|
|
24
16
|
/** 模板列表(分页) */
|
|
25
|
-
async listReports(
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
await
|
|
29
|
-
|
|
17
|
+
async listReports(e = {}) {
|
|
18
|
+
const t = `${r}${o}/list`;
|
|
19
|
+
return n(
|
|
20
|
+
await a({ url: t, method: "get", params: { current: 1, size: 20, ...e } }),
|
|
21
|
+
t
|
|
30
22
|
);
|
|
31
23
|
},
|
|
32
24
|
/** 模板详情(content 为 jh4j 私有模板 JSON 字符串,可喂给 importJh4jTemplateContent) */
|
|
33
|
-
async getReport(
|
|
34
|
-
const
|
|
35
|
-
return
|
|
25
|
+
async getReport(e) {
|
|
26
|
+
const t = `${r}${o}/getById`;
|
|
27
|
+
return n(await a({ url: t, method: "get", params: { id: e } }), t);
|
|
36
28
|
},
|
|
37
29
|
/** 保存模板(jh4j:PUT,body {id, code, name, content}) */
|
|
38
|
-
async updateReport(
|
|
39
|
-
const
|
|
40
|
-
return
|
|
30
|
+
async updateReport(e) {
|
|
31
|
+
const t = `${r}${o}/update`;
|
|
32
|
+
return n(await a({ url: t, method: "put", data: e }), t);
|
|
41
33
|
},
|
|
42
34
|
/** 导出模板定义包(body = ID 数组,返回 ZIP blob) */
|
|
43
|
-
async exportDefinition(
|
|
44
|
-
const
|
|
45
|
-
return
|
|
35
|
+
async exportDefinition(e) {
|
|
36
|
+
const t = `${r}${o}/exportDefinition`;
|
|
37
|
+
return a({ url: t, method: "post", data: e });
|
|
46
38
|
},
|
|
47
39
|
/** 导入模板定义包(multipart: file + strategy) */
|
|
48
|
-
async importDefinition(
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
form.append("file", file);
|
|
52
|
-
form.append("strategy", strategy);
|
|
53
|
-
return request({ url, method: "post", data: form });
|
|
40
|
+
async importDefinition(e, t) {
|
|
41
|
+
const c = `${r}${o}/importDefinition`, i = new FormData();
|
|
42
|
+
return i.append("file", e), i.append("strategy", t), a({ url: c, method: "post", data: i });
|
|
54
43
|
},
|
|
55
44
|
/** 数据集列表 */
|
|
56
|
-
async listDatasets(
|
|
57
|
-
const
|
|
58
|
-
return
|
|
59
|
-
await
|
|
60
|
-
|
|
45
|
+
async listDatasets(e) {
|
|
46
|
+
const t = `${r}${o}Ds/list`;
|
|
47
|
+
return n(
|
|
48
|
+
await a({ url: t, method: "get", params: { reportId: e, current: 1, size: 999 } }),
|
|
49
|
+
t
|
|
61
50
|
);
|
|
62
51
|
},
|
|
63
52
|
/** 参数列表 */
|
|
64
|
-
async listParams(
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
-
await
|
|
68
|
-
|
|
53
|
+
async listParams(e) {
|
|
54
|
+
const t = `${r}${o}Param/list`;
|
|
55
|
+
return n(
|
|
56
|
+
await a({ url: t, method: "get", params: { reportId: e, current: 1, size: 999 } }),
|
|
57
|
+
t
|
|
69
58
|
);
|
|
70
59
|
},
|
|
71
60
|
/** 模板锁:进入设计器前获取(40s 心跳由 holdLock 驱动) */
|
|
72
|
-
async acquireLock(
|
|
73
|
-
const
|
|
74
|
-
return
|
|
61
|
+
async acquireLock(e) {
|
|
62
|
+
const t = `${r}${d}/acquire`;
|
|
63
|
+
return n(await a({ url: t, method: "post", data: { reportId: e } }), t);
|
|
75
64
|
},
|
|
76
|
-
async lockHeartbeat(
|
|
77
|
-
const
|
|
78
|
-
return
|
|
65
|
+
async lockHeartbeat(e) {
|
|
66
|
+
const t = `${r}${d}/heartbeat`;
|
|
67
|
+
return n(await a({ url: t, method: "post", data: { reportId: e } }), t);
|
|
79
68
|
},
|
|
80
|
-
async releaseLock(
|
|
81
|
-
const
|
|
82
|
-
return
|
|
69
|
+
async releaseLock(e) {
|
|
70
|
+
const t = `${r}${d}/release`;
|
|
71
|
+
return n(await a({ url: t, method: "post", data: { reportId: e } }), t);
|
|
83
72
|
},
|
|
84
73
|
/**
|
|
85
74
|
* 持锁执行:acquire → fn(期间自动心跳)→ release(finally)。
|
|
@@ -87,33 +76,29 @@ function createReportAdminClient(options) {
|
|
|
87
76
|
* 心跳连续失败(默认 2 次)视为锁丢失:触发 onLockLost 回调并停止心跳,
|
|
88
77
|
* fn 继续执行(避免中途丢弃用户编辑),由调用方决定是否提示/中止。
|
|
89
78
|
*/
|
|
90
|
-
async holdLock(
|
|
91
|
-
await this.acquireLock(
|
|
92
|
-
const
|
|
93
|
-
let
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
lockLost = true;
|
|
102
|
-
options2.onLockLost?.(
|
|
103
|
-
`\u6A21\u677F\u9501\u5FC3\u8DF3\u8FDE\u7EED ${consecutiveFailures} \u6B21\u5931\u8D25\uFF08${e instanceof Error ? e.message : String(e)}\uFF09\uFF0C\u9501\u53EF\u80FD\u5DF2\u88AB\u91CA\u653E`
|
|
104
|
-
);
|
|
105
|
-
clearInterval(timer);
|
|
106
|
-
}
|
|
79
|
+
async holdLock(e, t, c = {}) {
|
|
80
|
+
await this.acquireLock(e);
|
|
81
|
+
const i = Math.max(1, c.heartbeatFailLimit ?? 2);
|
|
82
|
+
let l = 0, m = !1;
|
|
83
|
+
const p = setInterval(() => {
|
|
84
|
+
this.lockHeartbeat(e).then(() => {
|
|
85
|
+
l = 0;
|
|
86
|
+
}).catch((u) => {
|
|
87
|
+
l++, !m && l >= i && (m = !0, c.onLockLost?.(
|
|
88
|
+
`模板锁心跳连续 ${l} 次失败(${u instanceof Error ? u.message : String(u)}),锁可能已被释放`
|
|
89
|
+
), clearInterval(p));
|
|
107
90
|
});
|
|
108
91
|
}, 4e4);
|
|
109
92
|
try {
|
|
110
|
-
return await
|
|
93
|
+
return await t();
|
|
111
94
|
} finally {
|
|
112
|
-
clearInterval(
|
|
113
|
-
|
|
95
|
+
clearInterval(p), await this.releaseLock(e).catch(() => {
|
|
96
|
+
});
|
|
114
97
|
}
|
|
115
98
|
}
|
|
116
99
|
};
|
|
117
100
|
}
|
|
118
|
-
|
|
119
|
-
|
|
101
|
+
export {
|
|
102
|
+
h as ReportAdminError,
|
|
103
|
+
$ as createReportAdminClient
|
|
104
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RenderPlan } from '../schema/render-plan';
|
|
2
|
+
import { TextMeasurer } from '../index';
|
|
3
|
+
export interface PdfRenderOptions {
|
|
4
|
+
/** 嵌入字体字节(TTF,如黑体);缺省用 Helvetica(不支持 CJK) */
|
|
5
|
+
customFontBytes?: Uint8Array | ArrayBuffer;
|
|
6
|
+
customFontName?: string;
|
|
7
|
+
/** 文本测量器(默认启发式;与分页/Canvas 注入同一实例可消除折行差异) */
|
|
8
|
+
measurer?: TextMeasurer;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* PDF 文档句柄(不透明最小面):结构化仅暴露 save(),
|
|
12
|
+
* 避免在公共类型面泄漏 pdf-lib 类型(引擎保持零运行时依赖声明)。
|
|
13
|
+
*/
|
|
14
|
+
export type PdfDocumentHandle = {
|
|
15
|
+
save(): Promise<Uint8Array>;
|
|
16
|
+
};
|
|
17
|
+
export interface PdfRenderResult {
|
|
18
|
+
pdfDoc: PdfDocumentHandle;
|
|
19
|
+
bytes: Uint8Array;
|
|
20
|
+
pageErrors: string[];
|
|
21
|
+
unsupportedTextCount: number;
|
|
22
|
+
/** 保真度降级清单(富文本转纯文本、图片格式不支持等),供上层提示 */
|
|
23
|
+
fidelityWarnings: string[];
|
|
24
|
+
}
|
|
25
|
+
export declare function renderPlanToPdf(plan: RenderPlan, options?: PdfRenderOptions): Promise<PdfRenderResult>;
|