@agile-team/mach-report 2.0.0 → 2.1.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.
Files changed (77) hide show
  1. package/LICENSE +2 -4
  2. package/LICENSING.md +15 -0
  3. package/README.md +232 -76
  4. package/dist/ReportPreview-Dwdsyk9b.js +1558 -0
  5. package/dist/ReportPreview-VHAIfsz1.cjs +6 -0
  6. package/dist/index.cjs +5 -5
  7. package/dist/index.d.cts +738 -13
  8. package/dist/index.d.ts +738 -13
  9. package/dist/index.js +821 -631
  10. package/dist/pdf.cjs +47 -47
  11. package/dist/pdf.d.cts +155 -6
  12. package/dist/pdf.d.ts +155 -6
  13. package/dist/pdf.js +3542 -3466
  14. package/dist/plugin-Bl00j_CP.cjs +1 -0
  15. package/dist/plugin-DVScnZ4C.js +25 -0
  16. package/dist/report-params-BB85g7mg.js +10 -0
  17. package/dist/report-params-D1NeY-eR.cjs +1 -0
  18. package/dist/sql.cjs +65 -64
  19. package/dist/sql.d.cts +109 -5
  20. package/dist/sql.d.ts +109 -5
  21. package/dist/sql.js +7947 -7922
  22. package/dist/style.css +1 -1
  23. package/dist/vue/async.d.cts +769 -320
  24. package/dist/vue/async.d.ts +769 -320
  25. package/dist/vue/index.d.cts +1321 -14
  26. package/dist/vue/index.d.ts +1321 -14
  27. package/dist/vue-async.cjs +1 -1
  28. package/dist/vue-async.js +11 -12
  29. package/dist/vue.cjs +1 -1
  30. package/dist/vue.js +129 -49
  31. package/dist/xlsx.cjs +20 -20
  32. package/dist/xlsx.d.cts +2292 -5
  33. package/dist/xlsx.d.ts +2292 -5
  34. package/dist/xlsx.js +5452 -5443
  35. package/package.json +6 -2
  36. package/dist/ReportPreview-Cr0IH1Rz.cjs +0 -6
  37. package/dist/ReportPreview-DwknBgsJ.js +0 -1266
  38. package/dist/builder/template-builder.d.ts +0 -69
  39. package/dist/defaults.d.ts +0 -23
  40. package/dist/format.d.ts +0 -48
  41. package/dist/layout/paginate.d.ts +0 -97
  42. package/dist/layout/textwrap.d.ts +0 -36
  43. package/dist/pdf/font-loader.d.ts +0 -6
  44. package/dist/pdf/index.d.ts +0 -2
  45. package/dist/pdf/render-pdf.d.ts +0 -25
  46. package/dist/plugin-Cj3c2wJc.cjs +0 -1
  47. package/dist/plugin-DJf_6_fl.js +0 -18
  48. package/dist/render/canvas.d.ts +0 -76
  49. package/dist/render/dom.d.ts +0 -10
  50. package/dist/render/grid-geometry.d.ts +0 -41
  51. package/dist/render/style.d.ts +0 -33
  52. package/dist/render/window.d.ts +0 -23
  53. package/dist/schema/render-plan.d.ts +0 -88
  54. package/dist/schema/validate.d.ts +0 -15
  55. package/dist/sql/ast-check.d.ts +0 -14
  56. package/dist/sql/compile.d.ts +0 -31
  57. package/dist/sql/expr.d.ts +0 -21
  58. package/dist/sql/index.d.ts +0 -4
  59. package/dist/sql/tokenizer.d.ts +0 -25
  60. package/dist/units.d.ts +0 -11
  61. package/dist/vue/ReportParamPanel.d.ts +0 -19
  62. package/dist/vue/ReportPreview.d.ts +0 -200
  63. package/dist/vue/ReportToolbar.d.ts +0 -42
  64. package/dist/vue/adapters.d.ts +0 -34
  65. package/dist/vue/composables/useHighlight.d.ts +0 -8
  66. package/dist/vue/composables/usePageWindow.d.ts +0 -25
  67. package/dist/vue/composables/usePrintExport.d.ts +0 -40
  68. package/dist/vue/composables/useReportSearch.d.ts +0 -73
  69. package/dist/vue/composables/useZoom.d.ts +0 -15
  70. package/dist/vue/config.d.ts +0 -108
  71. package/dist/vue/controller.d.ts +0 -29
  72. package/dist/vue/errors.d.ts +0 -16
  73. package/dist/vue/injection-keys.d.ts +0 -14
  74. package/dist/vue/local-adapter.d.ts +0 -11
  75. package/dist/vue/pdf-exporter.d.ts +0 -13
  76. package/dist/vue/plugin.d.ts +0 -332
  77. package/dist/xlsx/render-xlsx.d.ts +0 -20
@@ -1,29 +0,0 @@
1
- /**
2
- * ReportPreview 的编程式控制器(与组件 ref 方法同面):
3
- * reload / print / exportAs / openPdfWindow / gotoPage / setParams。
4
- */
5
- export interface MachReportController {
6
- reload(): Promise<void>;
7
- print(): Promise<void>;
8
- /** 支持 html/pdf/xlsx/png/word(excel/image/doc 为兼容别名);未知格式报 export 错误。 */
9
- exportAs(format: string): void;
10
- openPdfWindow(): void;
11
- gotoPage(page: number): void;
12
- /** 编程式设置参数并查询(合并进面板值;opts.reload=false 仅设值不重载) */
13
- setParams(values: Record<string, string>, opts?: {
14
- reload?: boolean;
15
- }): void;
16
- }
17
- /**
18
- * 在 ReportPreview 的任意后代组件中获取控制器(免模板 ref):
19
- *
20
- * ```vue
21
- * <script setup>
22
- * import { useReportPreview } from "@agile-team/mach-report/vue";
23
- * const preview = useReportPreview();
24
- * </script>
25
- * <template><button @click="preview?.print()">打印本单</button></template>
26
- *
27
- * 不在预览组件内调用时返回 null(不抛错,便于条件渲染场景)。
28
- */
29
- export declare function useReportPreview(): MachReportController | null;
@@ -1,16 +0,0 @@
1
- /**
2
- * 结构化错误(code 分类,宿主可按码决定 UX:重试 / 提示 / 降级)。
3
- * error 事件契约保持 `(message: string)` 不变,新增第二参数 detail(可选)。
4
- */
5
- export type MachReportErrorCode = "param" | "fetch" | "validate" | "render" | "pdf" | "print" | "export" | "config";
6
- export declare class MachReportError extends Error {
7
- readonly code: MachReportErrorCode;
8
- readonly cause?: unknown;
9
- constructor(code: MachReportErrorCode, message: string, cause?: unknown);
10
- }
11
- /** error 事件第二参数的形状(向后兼容:仅监听 message 的旧用法不受影响) */
12
- export interface MachReportErrorDetail {
13
- code: MachReportErrorCode;
14
- cause?: unknown;
15
- }
16
- export declare function toErrorDetail(error: unknown): MachReportErrorDetail;
@@ -1,14 +0,0 @@
1
- import { ComputedRef, InjectionKey } from 'vue';
2
- import { PlanFetcher } from './adapters';
3
- import { PdfExporter } from './pdf-exporter';
4
- import { MachReportConfig } from './config';
5
- import { MachReportController } from './controller';
6
- /**
7
- * 注入 key 全部为字符串(而非裸 Symbol):跨模块联邦边界时宿主与远程
8
- * 各自打包会生成不同的 Symbol 实例导致 inject 失效;字符串恒等。
9
- * 保留 InjectionKey 类型以获得类型提示。
10
- */
11
- export declare const MACH_REPORT_FETCHER_KEY: InjectionKey<PlanFetcher>;
12
- export declare const MACH_REPORT_PDF_EXPORTER_KEY: InjectionKey<PdfExporter>;
13
- export declare const MACH_REPORT_CONFIG_KEY: InjectionKey<ComputedRef<MachReportConfig | null>>;
14
- export declare const MACH_REPORT_CONTROLLER_KEY: InjectionKey<MachReportController>;
@@ -1,11 +0,0 @@
1
- import { ReportTemplate } from '@agile-team/mach-report';
2
- import { PlanFetcher } from './adapters';
3
- export interface LocalTemplateEntry {
4
- template: ReportTemplate;
5
- datasets?: Record<string, Record<string, unknown>[]>;
6
- }
7
- /**
8
- * 本地渲染适配器:模板 + 数据 → core 分页引擎 → RenderPlan。
9
- * 用于本地预览、离线场景和单测。
10
- */
11
- export declare function createLocalFetcher(entries: Record<string, LocalTemplateEntry>): PlanFetcher;
@@ -1,13 +0,0 @@
1
- import { RenderPlan } from '@agile-team/mach-report';
2
- /** PDF 导出器:RenderPlan → PDF 字节;第二参数可上报非致命保真告警。 */
3
- export type PdfExporter = (plan: RenderPlan, onWarning?: (message: string) => void) => Promise<Uint8Array>;
4
- export interface DefaultPdfExporterOptions {
5
- /** 中文字体 URL(浏览器 fetch);空串跳过字体加载(西文报表) */
6
- fontUrl: string;
7
- }
8
- /**
9
- * 默认 PDF 导出器:
10
- * - 懒加载 @agile-team/mach-report/pdf(含 pdf-lib,只在首次导出时进 bundle)
11
- * - 字体走 IndexedDB 持久缓存(loadFontWithCache,二次导出零网络)
12
- */
13
- export declare function createDefaultPdfExporter(options?: DefaultPdfExporterOptions): PdfExporter;
@@ -1,332 +0,0 @@
1
- import { App } from 'vue';
2
- import { PlanFetcher } from './adapters';
3
- import { PdfExporter } from './pdf-exporter';
4
- import { MachReportConfig } from './config';
5
- /**
6
- * 全局组件(懒加载分片:首次渲染才拉取组件与引擎依赖,
7
- * 与局部 import 等价——首屏敏感页面零额外成本)
8
- */
9
- export declare const MachReportPreview: {
10
- new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('vue').ExtractPropTypes<{
11
- reportId: {
12
- type: import('vue').PropType<string | string[] | null>;
13
- default: null;
14
- };
15
- params: {
16
- type: import('vue').PropType<Record<string, string>>;
17
- default: () => {};
18
- };
19
- height: {
20
- type: StringConstructor;
21
- default: string;
22
- };
23
- autoLoad: {
24
- type: BooleanConstructor;
25
- default: boolean;
26
- };
27
- showExport: {
28
- type: BooleanConstructor;
29
- default: undefined;
30
- };
31
- showPrint: {
32
- type: BooleanConstructor;
33
- default: undefined;
34
- };
35
- showPdfWindow: {
36
- type: BooleanConstructor;
37
- default: undefined;
38
- };
39
- gapPx: {
40
- type: NumberConstructor;
41
- default: undefined;
42
- };
43
- messages: {
44
- type: import('vue').PropType<Partial<import('./config').MachReportMessages>>;
45
- default: undefined;
46
- };
47
- preset: {
48
- type: StringConstructor;
49
- default: undefined;
50
- };
51
- debug: {
52
- type: BooleanConstructor;
53
- default: boolean;
54
- };
55
- paramDefs: {
56
- type: import('vue').PropType<import('..').ReportParamDef[] | undefined>;
57
- default: undefined;
58
- };
59
- showParams: {
60
- type: BooleanConstructor;
61
- default: undefined;
62
- };
63
- fetcher: {
64
- type: import('vue').PropType<PlanFetcher | null>;
65
- default: null;
66
- };
67
- }>> & Readonly<{
68
- onError?: ((message: string, detail?: {
69
- code: string;
70
- cause?: unknown;
71
- } | undefined) => any) | undefined;
72
- onLoaded?: ((pageCount: number) => any) | undefined;
73
- onWarning?: ((message: string) => any) | undefined;
74
- }>, {
75
- reload: () => Promise<void>;
76
- print: () => Promise<void>;
77
- exportAs: (format: string) => void;
78
- openPdfWindow: () => void;
79
- gotoPage: (n: number) => void;
80
- setParams: (values: Record<string, string>, opts?: {
81
- reload?: boolean;
82
- }) => void;
83
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
84
- error: (message: string, detail?: {
85
- code: string;
86
- cause?: unknown;
87
- } | undefined) => any;
88
- loaded: (pageCount: number) => any;
89
- warning: (message: string) => any;
90
- }, import('vue').PublicProps, {
91
- height: string;
92
- gapPx: number;
93
- params: Record<string, string>;
94
- debug: boolean;
95
- showExport: boolean;
96
- showPrint: boolean;
97
- showPdfWindow: boolean;
98
- showParams: boolean;
99
- messages: Partial<import('./config').MachReportMessages>;
100
- reportId: string | string[] | null;
101
- autoLoad: boolean;
102
- preset: string;
103
- paramDefs: import('..').ReportParamDef[] | undefined;
104
- fetcher: PlanFetcher | null;
105
- }, true, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
106
- viewportRef: HTMLDivElement;
107
- containerRef: HTMLDivElement;
108
- thumbsRef: HTMLElement;
109
- }, HTMLDivElement, import('vue').ComponentProvideOptions, {
110
- P: {};
111
- B: {};
112
- D: {};
113
- C: {};
114
- M: {};
115
- Defaults: {};
116
- }, Readonly<import('vue').ExtractPropTypes<{
117
- reportId: {
118
- type: import('vue').PropType<string | string[] | null>;
119
- default: null;
120
- };
121
- params: {
122
- type: import('vue').PropType<Record<string, string>>;
123
- default: () => {};
124
- };
125
- height: {
126
- type: StringConstructor;
127
- default: string;
128
- };
129
- autoLoad: {
130
- type: BooleanConstructor;
131
- default: boolean;
132
- };
133
- showExport: {
134
- type: BooleanConstructor;
135
- default: undefined;
136
- };
137
- showPrint: {
138
- type: BooleanConstructor;
139
- default: undefined;
140
- };
141
- showPdfWindow: {
142
- type: BooleanConstructor;
143
- default: undefined;
144
- };
145
- gapPx: {
146
- type: NumberConstructor;
147
- default: undefined;
148
- };
149
- messages: {
150
- type: import('vue').PropType<Partial<import('./config').MachReportMessages>>;
151
- default: undefined;
152
- };
153
- preset: {
154
- type: StringConstructor;
155
- default: undefined;
156
- };
157
- debug: {
158
- type: BooleanConstructor;
159
- default: boolean;
160
- };
161
- paramDefs: {
162
- type: import('vue').PropType<import('..').ReportParamDef[] | undefined>;
163
- default: undefined;
164
- };
165
- showParams: {
166
- type: BooleanConstructor;
167
- default: undefined;
168
- };
169
- fetcher: {
170
- type: import('vue').PropType<PlanFetcher | null>;
171
- default: null;
172
- };
173
- }>> & Readonly<{
174
- onError?: ((message: string, detail?: {
175
- code: string;
176
- cause?: unknown;
177
- } | undefined) => any) | undefined;
178
- onLoaded?: ((pageCount: number) => any) | undefined;
179
- onWarning?: ((message: string) => any) | undefined;
180
- }>, {
181
- reload: () => Promise<void>;
182
- print: () => Promise<void>;
183
- exportAs: (format: string) => void;
184
- openPdfWindow: () => void;
185
- gotoPage: (n: number) => void;
186
- setParams: (values: Record<string, string>, opts?: {
187
- reload?: boolean;
188
- }) => void;
189
- }, {}, {}, {}, {
190
- height: string;
191
- gapPx: number;
192
- params: Record<string, string>;
193
- debug: boolean;
194
- showExport: boolean;
195
- showPrint: boolean;
196
- showPdfWindow: boolean;
197
- showParams: boolean;
198
- messages: Partial<import('./config').MachReportMessages>;
199
- reportId: string | string[] | null;
200
- autoLoad: boolean;
201
- preset: string;
202
- paramDefs: import('..').ReportParamDef[] | undefined;
203
- fetcher: PlanFetcher | null;
204
- }>;
205
- __isFragment?: never;
206
- __isTeleport?: never;
207
- __isSuspense?: never;
208
- } & import('vue').ComponentOptionsBase<Readonly<import('vue').ExtractPropTypes<{
209
- reportId: {
210
- type: import('vue').PropType<string | string[] | null>;
211
- default: null;
212
- };
213
- params: {
214
- type: import('vue').PropType<Record<string, string>>;
215
- default: () => {};
216
- };
217
- height: {
218
- type: StringConstructor;
219
- default: string;
220
- };
221
- autoLoad: {
222
- type: BooleanConstructor;
223
- default: boolean;
224
- };
225
- showExport: {
226
- type: BooleanConstructor;
227
- default: undefined;
228
- };
229
- showPrint: {
230
- type: BooleanConstructor;
231
- default: undefined;
232
- };
233
- showPdfWindow: {
234
- type: BooleanConstructor;
235
- default: undefined;
236
- };
237
- gapPx: {
238
- type: NumberConstructor;
239
- default: undefined;
240
- };
241
- messages: {
242
- type: import('vue').PropType<Partial<import('./config').MachReportMessages>>;
243
- default: undefined;
244
- };
245
- preset: {
246
- type: StringConstructor;
247
- default: undefined;
248
- };
249
- debug: {
250
- type: BooleanConstructor;
251
- default: boolean;
252
- };
253
- paramDefs: {
254
- type: import('vue').PropType<import('..').ReportParamDef[] | undefined>;
255
- default: undefined;
256
- };
257
- showParams: {
258
- type: BooleanConstructor;
259
- default: undefined;
260
- };
261
- fetcher: {
262
- type: import('vue').PropType<PlanFetcher | null>;
263
- default: null;
264
- };
265
- }>> & Readonly<{
266
- onError?: ((message: string, detail?: {
267
- code: string;
268
- cause?: unknown;
269
- } | undefined) => any) | undefined;
270
- onLoaded?: ((pageCount: number) => any) | undefined;
271
- onWarning?: ((message: string) => any) | undefined;
272
- }>, {
273
- reload: () => Promise<void>;
274
- print: () => Promise<void>;
275
- exportAs: (format: string) => void;
276
- openPdfWindow: () => void;
277
- gotoPage: (n: number) => void;
278
- setParams: (values: Record<string, string>, opts?: {
279
- reload?: boolean;
280
- }) => void;
281
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
282
- error: (message: string, detail?: {
283
- code: string;
284
- cause?: unknown;
285
- } | undefined) => any;
286
- loaded: (pageCount: number) => any;
287
- warning: (message: string) => any;
288
- }, string, {
289
- height: string;
290
- gapPx: number;
291
- params: Record<string, string>;
292
- debug: boolean;
293
- showExport: boolean;
294
- showPrint: boolean;
295
- showPdfWindow: boolean;
296
- showParams: boolean;
297
- messages: Partial<import('./config').MachReportMessages>;
298
- reportId: string | string[] | null;
299
- autoLoad: boolean;
300
- preset: string;
301
- paramDefs: import('..').ReportParamDef[] | undefined;
302
- fetcher: PlanFetcher | null;
303
- }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
304
- $slots: {
305
- default?(_: {}): any;
306
- };
307
- });
308
- export interface MachReportPluginOptions {
309
- /** 报表数据源;也可直接传给 ReportPreview 的 fetcher prop */
310
- fetcher?: PlanFetcher;
311
- /** 应用级配置中心(defaults/presets/文案/主题),见 defineMachReportConfig */
312
- config?: MachReportConfig;
313
- /** PDF 导出字体 URL(默认 /simhei.ttf;'' 跳过字体) */
314
- pdfFontUrl?: string;
315
- /** 自定义 PDF 导出器(缺省用懒加载引擎 /pdf 子路径的默认实现) */
316
- pdfExporter?: PdfExporter;
317
- /** 注册全局组件 <MachReportPreview>(默认 true;懒加载分片不影响首屏) */
318
- globalComponent?: boolean;
319
- }
320
- /**
321
- * Vue 插件:注册组件、配置和可选的数据源,不绑定任何后端接口。
322
- *
323
- * ```ts
324
- * app.use(machReportPlugin, { fetcher })
325
- * app.use(machReportPlugin, { config: defineMachReportConfig({...}) })
326
- * ```
327
- *
328
- * 之后业务模板直接写 `<MachReportPreview report-id="X" />`。
329
- */
330
- export declare const machReportPlugin: {
331
- install(app: App, options?: MachReportPluginOptions): void;
332
- };
@@ -1,20 +0,0 @@
1
- import { default as ExcelJS } from 'exceljs';
2
- import { RenderPlan } from '../schema/render-plan';
3
- /**
4
- * RenderPlan → xlsx 导出(B 端第二出口,对齐家族 @agile-team/mach-table-xlsx 路线):
5
- * - 网格组件 → 真表格:列宽(mm→Excel 宽度)、行高(mm→pt)、colSpan/rowSpan 合并、
6
- * 加粗/对齐/底色/字号直译(resolveGridLayout 复用单真相源几何)
7
- * - 文本组件 → 合并标题行(顺序流式输出,保字号/加粗/对齐;非像素级定位,
8
- * 目标是"财务能直接用的对账表"而非复刻版面)
9
- * - 图片/条码/图表跳过并计入 warnings(与 PDF 保真告警同口径)
10
- */
11
- export interface XlsxRenderOptions {
12
- /** 工作表命名(默认 "Sheet1" 起序) */
13
- sheetName?: (pageIndex: number) => string;
14
- }
15
- export interface XlsxRenderResult {
16
- workbook: ExcelJS.Workbook;
17
- buffer: ExcelJS.Buffer;
18
- warnings: string[];
19
- }
20
- export declare function renderPlanToXlsx(plan: RenderPlan, options?: XlsxRenderOptions): Promise<XlsxRenderResult>;