@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,31 +0,0 @@
1
- export { SqlSyntaxError } from './tokenizer';
2
- export interface RenderedSql {
3
- sql: string;
4
- binds: unknown[];
5
- warnings: string[];
6
- }
7
- export interface CompiledSql {
8
- original: string;
9
- /** 参数名集合(bind 与 subst 并集) */
10
- paramNames: string[];
11
- render(params: Record<string, unknown>): RenderedSql;
12
- }
13
- export declare class SqlValidationError extends Error {
14
- readonly sql: string;
15
- constructor(message: string, sql: string);
16
- }
17
- export declare function compileDynamicSql(source: string): CompiledSql;
18
- /**
19
- * 去注释:-- 行注释、# 行注释(仅行首/空白后,且排除 #{ 绑定占位)、/* 块注释。
20
- * 注意:此函数用于校验口径,输出会折叠空白。
21
- */
22
- export declare function stripSqlComments(sql: string): string;
23
- /**
24
- * 单 SELECT 结构校验(词法层;AST 级校验见 ast-check.ts 双保险):
25
- * - 去注释后必须以 select 或 with 开头
26
- * - 语句内除末尾外不允许出现分号
27
- * - 顶层禁止 DML/DDL/调用关键字(字符串字面量内容不参与匹配)
28
- */
29
- export declare function assertSingleSelect(sql: string): void;
30
- /** 便捷入口:编译 + 渲染 + 校验一体 */
31
- export declare function renderDynamicSql(source: string, params: Record<string, unknown>): RenderedSql;
@@ -1,21 +0,0 @@
1
- export interface ExprContext {
2
- params: Record<string, unknown>;
3
- }
4
- export declare class ExprError extends Error {
5
- constructor(message: string);
6
- }
7
- /**
8
- * 求值动态 SQL 条件表达式(用于 {if(cond, a, b)} 的 cond 与操作数):
9
- * - #param 引用(渲染时被替换为参数值;此实现按值求值)
10
- * - "..." 字符串字面量(仅双引号)
11
- * - isEmpty(x)、isNotEmpty(x)
12
- * - == / != 比较
13
- * - + 拼接
14
- */
15
- export declare function evalExpr(input: string, ctx: ExprContext): unknown;
16
- /** {if(cond, whenTrue, whenFalse)} 的参数拆分(2 或 3 段) */
17
- export declare function parseIfArgs(inner: string): {
18
- cond: string;
19
- whenTrue: string;
20
- whenFalse: string;
21
- };
@@ -1,4 +0,0 @@
1
- export * from './tokenizer';
2
- export * from './expr';
3
- export * from './compile';
4
- export * from './ast-check';
@@ -1,25 +0,0 @@
1
- export type TokenType = "literal" | "bind" | "subst" | "if" | "escape";
2
- export interface Token {
3
- type: TokenType;
4
- text: string;
5
- /** bind/subst 参数名;if 表达式源码 */
6
- value?: string;
7
- start: number;
8
- end: number;
9
- }
10
- export declare class SqlSyntaxError extends Error {
11
- readonly position: number;
12
- readonly source: string;
13
- constructor(message: string, position: number, source: string);
14
- }
15
- /**
16
- * 扫描动态 SQL,产出 token 流:
17
- * - literal: 纯 SQL 文本(已反转义 \{ \})
18
- * - bind: #{name}
19
- * - subst: ${name}
20
- * - if: {if(expr, a, b)} —— value 为去壳后的参数串
21
- * - escape: \{ 或 \}
22
- */
23
- export declare function tokenize(sql: string): Token[];
24
- /** 按顶层逗号拆分(忽略双引号内与括号/花括号内) */
25
- export declare function splitTopLevel(input: string): string[];
package/dist/units.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export declare const MM_PER_INCH = 25.4;
2
- export declare const CSS_DPI = 96;
3
- export declare function mmToPxFactor(dpi?: number): number;
4
- export declare function mmToPx(value: number, dpi?: number): number;
5
- export declare function pxToMm(value: number, dpi?: number): number;
6
- export declare function ptToPx(pt: number, dpi?: number): number;
7
- export declare function round(value: number, digits: number): number;
8
- export declare const PAPER_SIZES: Record<string, {
9
- widthMm: number;
10
- heightMm: number;
11
- }>;
@@ -1,19 +0,0 @@
1
- import { ReportParamDef } from '@agile-team/mach-report';
2
- import { MachReportMessages } from './config';
3
- type __VLS_Props = {
4
- defs: ReportParamDef[];
5
- modelValue: Record<string, string>;
6
- messages: MachReportMessages;
7
- /** 触发过查询后才开始必填提示(避免首屏一片红) */
8
- attempted: boolean;
9
- };
10
- declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
11
- reset: () => any;
12
- query: () => any;
13
- "update:modelValue": (value: Record<string, string>) => any;
14
- }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
15
- onReset?: (() => any) | undefined;
16
- onQuery?: (() => any) | undefined;
17
- "onUpdate:modelValue"?: ((value: Record<string, string>) => any) | undefined;
18
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
19
- export default _default;
@@ -1,200 +0,0 @@
1
- import { PropType } from 'vue';
2
- import { PlanFetcher } from './adapters';
3
- import { ReportParamDef } from '@agile-team/mach-report';
4
- import { MachReportMessages } from './config';
5
- declare function reload(): Promise<void>;
6
- declare function gotoPage(n: number): void;
7
- /** 控制器注入:后代组件 useReportPreview() 免模板 ref 编程式访问(与 expose 同面) */
8
- /** 编程式设参查询:合并进面板值(面板本地字典经 v-model 同步),可选立即重载 */
9
- declare function setParams(values: Record<string, string>, opts?: {
10
- reload?: boolean;
11
- }): void;
12
- declare function __VLS_template(): {
13
- attrs: Partial<{}>;
14
- slots: {
15
- default?(_: {}): any;
16
- };
17
- refs: {
18
- viewportRef: HTMLDivElement;
19
- containerRef: HTMLDivElement;
20
- thumbsRef: HTMLElement;
21
- };
22
- rootEl: HTMLDivElement;
23
- };
24
- type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
25
- declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
26
- reportId: {
27
- type: PropType<string | string[] | null>;
28
- default: null;
29
- };
30
- params: {
31
- type: PropType<Record<string, string>>;
32
- default: () => {};
33
- };
34
- height: {
35
- type: StringConstructor;
36
- default: string;
37
- };
38
- autoLoad: {
39
- type: BooleanConstructor;
40
- default: boolean;
41
- };
42
- /** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
43
- showExport: {
44
- type: BooleanConstructor;
45
- default: undefined;
46
- };
47
- showPrint: {
48
- type: BooleanConstructor;
49
- default: undefined;
50
- };
51
- showPdfWindow: {
52
- type: BooleanConstructor;
53
- default: undefined;
54
- };
55
- /** 页间距(px);不传走配置中心 */
56
- gapPx: {
57
- type: NumberConstructor;
58
- default: undefined;
59
- };
60
- /** 工具栏/状态文案覆写(不传走配置中心 messages) */
61
- messages: {
62
- type: PropType<Partial<MachReportMessages>>;
63
- default: undefined;
64
- };
65
- /** 启用的 preset 名(不传用配置中心 defaultPreset) */
66
- preset: {
67
- type: StringConstructor;
68
- default: undefined;
69
- };
70
- /** 调试面板(也可用 URL ?mrp-debug=1 开启) */
71
- debug: {
72
- type: BooleanConstructor;
73
- default: boolean;
74
- };
75
- /** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
76
- paramDefs: {
77
- type: PropType<ReportParamDef[] | undefined>;
78
- default: undefined;
79
- };
80
- /** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
81
- showParams: {
82
- type: BooleanConstructor;
83
- default: undefined;
84
- };
85
- fetcher: {
86
- type: PropType<PlanFetcher | null>;
87
- default: null;
88
- };
89
- }>, {
90
- reload: typeof reload;
91
- print: () => Promise<void>;
92
- exportAs: (format: string) => void;
93
- openPdfWindow: () => void;
94
- gotoPage: typeof gotoPage;
95
- setParams: typeof setParams;
96
- }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
97
- error: (message: string, detail?: {
98
- code: string;
99
- cause?: unknown;
100
- } | undefined) => any;
101
- loaded: (pageCount: number) => any;
102
- warning: (message: string) => any;
103
- }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
104
- reportId: {
105
- type: PropType<string | string[] | null>;
106
- default: null;
107
- };
108
- params: {
109
- type: PropType<Record<string, string>>;
110
- default: () => {};
111
- };
112
- height: {
113
- type: StringConstructor;
114
- default: string;
115
- };
116
- autoLoad: {
117
- type: BooleanConstructor;
118
- default: boolean;
119
- };
120
- /** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
121
- showExport: {
122
- type: BooleanConstructor;
123
- default: undefined;
124
- };
125
- showPrint: {
126
- type: BooleanConstructor;
127
- default: undefined;
128
- };
129
- showPdfWindow: {
130
- type: BooleanConstructor;
131
- default: undefined;
132
- };
133
- /** 页间距(px);不传走配置中心 */
134
- gapPx: {
135
- type: NumberConstructor;
136
- default: undefined;
137
- };
138
- /** 工具栏/状态文案覆写(不传走配置中心 messages) */
139
- messages: {
140
- type: PropType<Partial<MachReportMessages>>;
141
- default: undefined;
142
- };
143
- /** 启用的 preset 名(不传用配置中心 defaultPreset) */
144
- preset: {
145
- type: StringConstructor;
146
- default: undefined;
147
- };
148
- /** 调试面板(也可用 URL ?mrp-debug=1 开启) */
149
- debug: {
150
- type: BooleanConstructor;
151
- default: boolean;
152
- };
153
- /** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
154
- paramDefs: {
155
- type: PropType<ReportParamDef[] | undefined>;
156
- default: undefined;
157
- };
158
- /** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
159
- showParams: {
160
- type: BooleanConstructor;
161
- default: undefined;
162
- };
163
- fetcher: {
164
- type: PropType<PlanFetcher | null>;
165
- default: null;
166
- };
167
- }>> & Readonly<{
168
- onError?: ((message: string, detail?: {
169
- code: string;
170
- cause?: unknown;
171
- } | undefined) => any) | undefined;
172
- onLoaded?: ((pageCount: number) => any) | undefined;
173
- onWarning?: ((message: string) => any) | undefined;
174
- }>, {
175
- height: string;
176
- gapPx: number;
177
- params: Record<string, string>;
178
- debug: boolean;
179
- showExport: boolean;
180
- showPrint: boolean;
181
- showPdfWindow: boolean;
182
- showParams: boolean;
183
- messages: Partial<MachReportMessages>;
184
- reportId: string | string[] | null;
185
- autoLoad: boolean;
186
- preset: string;
187
- paramDefs: ReportParamDef[] | undefined;
188
- fetcher: PlanFetcher | null;
189
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
190
- viewportRef: HTMLDivElement;
191
- containerRef: HTMLDivElement;
192
- thumbsRef: HTMLElement;
193
- }, HTMLDivElement>;
194
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
195
- export default _default;
196
- type __VLS_WithTemplateSlots<T, S> = T & {
197
- new (): {
198
- $slots: S;
199
- };
200
- };
@@ -1,42 +0,0 @@
1
- import { MachReportMessages } from './config';
2
- type __VLS_Props = {
3
- pageCount: number;
4
- currentPage: number;
5
- zoomMode: "fit" | "raw";
6
- zoom: number;
7
- showExport: boolean;
8
- showPrint: boolean;
9
- showPdfWindow: boolean;
10
- messages: MachReportMessages;
11
- search: {
12
- visible: boolean;
13
- query: string;
14
- matchIndex: number;
15
- matchCount: number;
16
- };
17
- thumbsVisible: boolean;
18
- };
19
- declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
20
- export: (format: "html" | "png" | "pdf" | "xlsx" | "word") => any;
21
- zoom: (mode: number | "fit") => any;
22
- print: () => any;
23
- goto: (page: number) => any;
24
- "pdf-window": () => any;
25
- "search-input": (query: string) => any;
26
- "search-nav": (dir: 1 | -1) => any;
27
- "search-toggle": () => any;
28
- "thumbs-toggle": () => any;
29
- }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
30
- onExport?: ((format: "html" | "png" | "pdf" | "xlsx" | "word") => any) | undefined;
31
- onZoom?: ((mode: number | "fit") => any) | undefined;
32
- onPrint?: (() => any) | undefined;
33
- onGoto?: ((page: number) => any) | undefined;
34
- "onPdf-window"?: (() => any) | undefined;
35
- "onSearch-input"?: ((query: string) => any) | undefined;
36
- "onSearch-nav"?: ((dir: 1 | -1) => any) | undefined;
37
- "onSearch-toggle"?: (() => any) | undefined;
38
- "onThumbs-toggle"?: (() => any) | undefined;
39
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
40
- searchInputRef: HTMLInputElement;
41
- }, HTMLDivElement>;
42
- export default _default;
@@ -1,34 +0,0 @@
1
- import { RenderPlan } from '@agile-team/mach-report';
2
- export type ReportIdInput = string | string[] | null | undefined;
3
- export interface PlanFetcher {
4
- (input: {
5
- reportIds: string[];
6
- params: Record<string, string>;
7
- }): Promise<RenderPlan>;
8
- }
9
- export declare function normalizeReportIds(reportId: ReportIdInput): string[];
10
- export declare function joinReportIds(reportId: ReportIdInput): string;
11
- export declare class PlanLoadError extends Error {
12
- constructor(message: string);
13
- }
14
- /** 通用请求函数签名(可适配 Axios 风格客户端) */
15
- export type HostRequest = (config: {
16
- url: string;
17
- method: string;
18
- params?: Record<string, string>;
19
- }) => Promise<unknown>;
20
- export interface FetchRequestOptions {
21
- /** 网关前缀(默认空 = 同源) */
22
- baseUrl?: string;
23
- /** 附加请求头(如鉴权 token) */
24
- headers?: Record<string, string>;
25
- credentials?: RequestCredentials;
26
- /** 超时毫秒(默认 30000;超时抛 PlanLoadError) */
27
- timeoutMs?: number;
28
- }
29
- /**
30
- * 零依赖请求适配器:用全局 fetch 实现 HostRequest 签名,
31
- * 供自定义 PlanFetcher 按需调用,不预设任何报表接口路径或响应包装。
32
- * 内置超时(AbortController)与网络/HTTP 错误语义。
33
- */
34
- export declare function createFetchRequest(options?: FetchRequestOptions): HostRequest;
@@ -1,8 +0,0 @@
1
- /**
2
- * 预览内文本高亮(搜索命中标记):
3
- * - highlightTextNodes:TreeWalker 找文本节点,命中片段包 <mark class="mrp-hit">
4
- * - clearHighlights:拆包还原(避免重复高亮叠加)
5
- * 纯 DOM 操作,虚拟化窗口外的页不处理(随窗口重建自然清理)。
6
- */
7
- export declare function clearHighlights(root: HTMLElement): void;
8
- export declare function highlightTextNodes(root: HTMLElement, query: string): number;
@@ -1,25 +0,0 @@
1
- import { Ref } from 'vue';
2
- import { PlanPage, RenderPlan } from '@agile-team/mach-report';
3
- /**
4
- * 页级视口虚拟化(DOM 后端)。
5
- *
6
- * 坐标口径(与 transform: scale 缩放配合):
7
- * - 页高/间距/占位均在"自然坐标系"(未缩放 px)维护
8
- * - 视口滚动量与视口高换算回自然系(除以 zoom)后再进 computePageWindow
9
- */
10
- export declare function usePageWindow(plan: Ref<RenderPlan | null>, zoom: Ref<number>, options?: {
11
- pxPerMm?: number;
12
- gapPx?: number | Ref<number>;
13
- }): {
14
- contentSize: import('vue').ComputedRef<{
15
- w: number;
16
- h: number;
17
- }>;
18
- windowRange: import('vue').ComputedRef<import('@agile-team/mach-report').PageWindow>;
19
- visiblePages: import('vue').ComputedRef<{
20
- page: PlanPage;
21
- index: number;
22
- }[]>;
23
- makeScrollHandler: (currentPage: Ref<number>, pageCount: Ref<number>) => (vp: HTMLElement) => void;
24
- refreshViewport(vp: HTMLElement | null): void;
25
- };
@@ -1,40 +0,0 @@
1
- import { Ref } from 'vue';
2
- import { RenderPlan } from '@agile-team/mach-report';
3
- import { PdfExporter } from '../pdf-exporter';
4
- interface PrintHtmlResult {
5
- head: string;
6
- pageChunks: string[];
7
- }
8
- /** 供 HTML/Word 导出的完整文档;打印路径逐页渲染,避免预先生成所有页。 */
9
- export declare function buildPrintDocument(p: RenderPlan): PrintHtmlResult;
10
- /**
11
- * 批量打印(多单连打):把多份计划合并为一个打印文档——
12
- * named pages 保证混合纸张正确分页,浏览器只弹一次打印对话框。
13
- */
14
- export declare function printPlans(plans: RenderPlan[], options?: {
15
- onProgress?: (done: number, total: number) => void;
16
- onError?: (message: string) => void;
17
- }): Promise<void>;
18
- /**
19
- * Word 导出(Word 兼容 HTML,.doc MIME):
20
- * 复用打印文档构建(同一样式与 named pages 分页规则),套 Word 命名空间头。
21
- * Word 2003+ 可直接打开编辑——覆盖"导出可编辑单据"场景,零后端。
22
- */
23
- export declare function buildWordHtml(p: RenderPlan): {
24
- html: string;
25
- filename: string;
26
- };
27
- export declare function usePrintExport(plan: Ref<RenderPlan | null>, hooks: {
28
- getPdfExporter: () => PdfExporter;
29
- onError: (message: string, code?: string) => void;
30
- onWarning?: (message: string) => void;
31
- onBusy?: (format: string | null) => void;
32
- }): {
33
- print: () => Promise<void>;
34
- exportAs: (format: string) => void;
35
- exportImages: () => Promise<void>;
36
- exportWord: () => void;
37
- openPdfWindow: () => void;
38
- releasePrintFrame: () => void;
39
- };
40
- export {};
@@ -1,73 +0,0 @@
1
- import { Ref } from 'vue';
2
- import { RenderPlan } from '@agile-team/mach-report';
3
- /**
4
- * 预览交互 composables 集合(本文件包含四件):
5
- *
6
- * - useReportSearch:搜索(防抖索引 → 跳页导航 → 命中页高亮)
7
- * - useDebugPanel:调试面板(?mrp-debug=1;planKB 按 plan 引用缓存)
8
- * - useThumbs:缩略图侧栏(IntersectionObserver 懒渲染小画布)
9
- * - useLoadTiming:加载耗时计时(performance 不可用时降级为 0)
10
- */
11
- export interface ReportSearchState {
12
- visible: Ref<boolean>;
13
- query: Ref<string>;
14
- matchIndex: Ref<number>;
15
- matchCount: Ref<number>;
16
- toggle(): void;
17
- onInput(query: string): void;
18
- onNav(dir: 1 | -1): void;
19
- /** 页面元素高亮(查询为空时为 no-op) */
20
- apply(pageEl: HTMLElement): void;
21
- clear(pageEl: HTMLElement): void;
22
- /** 换单据/清空时的整体复位 */
23
- reset(): void;
24
- }
25
- export interface ReportSearchOptions {
26
- plan: Ref<RenderPlan | null>;
27
- gotoPage(page: number): void;
28
- debounceMs?: number;
29
- highlight: (pageEl: HTMLElement, query: string) => number;
30
- clearHighlights: (pageEl: HTMLElement) => void;
31
- }
32
- export declare function useReportSearch(options: ReportSearchOptions): ReportSearchState;
33
- /**
34
- * 调试面板状态:?mrp-debug=1 或 debug prop。
35
- * planKB 按 plan 引用缓存(滚动/缩放不触发全量 JSON 序列化)。
36
- */
37
- export declare function useDebugPanel(debug: Ref<boolean>, stats: {
38
- plan: Ref<RenderPlan | null>;
39
- pageCount: Ref<number>;
40
- windowRange: Ref<{
41
- start: number;
42
- end: number;
43
- }>;
44
- zoom: Ref<number>;
45
- loadMs: Ref<number>;
46
- }): {
47
- enabled: import('vue').ComputedRef<boolean>;
48
- debugStats: import('vue').ComputedRef<{
49
- pages: number;
50
- window: string;
51
- zoom: string;
52
- loadMs: string;
53
- planKB: number;
54
- } | null>;
55
- };
56
- /**
57
- * 缩略图侧栏:懒渲染小画布(IntersectionObserver + 低 dpr)。
58
- * 无 2D 环境(SSR/测试)保留占位框,不抛错。
59
- */
60
- export declare function useThumbs(plan: Ref<RenderPlan | null>, opts: {
61
- thumbsRoot: Ref<HTMLElement | null>;
62
- visible: Ref<boolean>;
63
- renderThumbCanvas: (pageIndex: number) => HTMLCanvasElement | null;
64
- }): {
65
- schedule: () => void;
66
- destroy: () => void;
67
- };
68
- /** 加载耗时计时(performance 不可用时为 0) */
69
- export declare function useLoadTiming(): {
70
- loadMs: Ref<number>;
71
- start(): number;
72
- end(t0: number): void;
73
- };
@@ -1,15 +0,0 @@
1
- /**
2
- * 缩放状态(transform: scale 方案):
3
- * - fit 模式:按视口宽自适应(clamp 0.3~1)
4
- * - raw 模式:固定百分比
5
- * transform 而非 CSS zoom:标准属性、跨浏览器、零重排。
6
- */
7
- export declare function useZoom(getFitInputs: () => {
8
- viewport: HTMLElement | null;
9
- pageWidthPx: number;
10
- } | null): {
11
- zoom: import('vue').Ref<number, number>;
12
- zoomMode: import('vue').Ref<"fit" | "raw", "fit" | "raw">;
13
- applyFitZoom: () => void;
14
- setZoom: (mode: "fit" | number) => void;
15
- };
@@ -1,108 +0,0 @@
1
- import { ComputedRef, CSSProperties } from 'vue';
2
- /**
3
- * 配置中心(对齐 mach-table 的 defineMachTableConfig 体验):
4
- * - 应用级:app.use(machReportPlugin, { config: defineMachReportConfig({...}) })
5
- * - 路由级叠加:provideMachReportConfig(overlay)(响应式,就近覆盖)
6
- * - 优先级:组件 props > 路由级叠加 > preset > defaults(props 永远最高)
7
- */
8
- /** 工具栏与状态文案(默认简体中文;出海场景覆写) */
9
- export interface MachReportMessages {
10
- title: string;
11
- prevPage: string;
12
- nextPage: string;
13
- /** 页码显示模板,{cur}/{total} 占位 */
14
- pageInfo: string;
15
- fitWidth: string;
16
- exportHtml: string;
17
- exportPdf: string;
18
- exportExcel: string;
19
- exportImage: string;
20
- exportWord: string;
21
- /** 导出进行中提示,{format} 占位 */
22
- exporting: string;
23
- print: string;
24
- pdfWindow: string;
25
- loading: string;
26
- empty: string;
27
- /** @deprecated 未被组件消费,将在下个大版本移除(保留仅为类型兼容) */
28
- errorPrefix: string;
29
- retry: string;
30
- /** 搜索框占位文案 */
31
- searchPlaceholder: string;
32
- /** 搜索命中计数,{cur}/{total} 占位 */
33
- matchInfo: string;
34
- /** 上/下一个命中 */
35
- prevMatch: string;
36
- nextMatch: string;
37
- /** 缩略图侧栏开关 */
38
- thumbnails: string;
39
- /** 参数面板 */
40
- paramsTitle: string;
41
- query: string;
42
- reset: string;
43
- /** 必填缺失提示({label} 占位) */
44
- paramRequired: string;
45
- }
46
- export declare const DEFAULT_MESSAGES: MachReportMessages;
47
- /** 主题变量(组件外壳注入的 --mrp-* CSS 自定义属性) */
48
- export interface MachReportTheme {
49
- shellBg: string;
50
- shellFg: string;
51
- toolbarBg: string;
52
- toolbarBorder: string;
53
- toolbarFg: string;
54
- btnFg: string;
55
- btnBorder: string;
56
- btnHoverBg: string;
57
- btnHoverFg: string;
58
- btnActiveBg: string;
59
- }
60
- export declare const DEFAULT_THEME: MachReportTheme;
61
- /** 日志通道(默认 console;可注入 noop 静默或上报 collector) */
62
- export type MachReportLogger = Pick<Console, "warn" | "info">;
63
- /** defaults 层可配置项(全部可选,均有内置缺省) */
64
- export interface MachReportDefaults {
65
- showExport?: boolean;
66
- showPrint?: boolean;
67
- showPdfWindow?: boolean;
68
- /** 参数面板显隐(有参数定义且未显式关闭时显示;缺省 true) */
69
- showParams?: boolean;
70
- /** 页间距 px */
71
- gapPx?: number;
72
- /** PDF 导出中文字体 URL */
73
- pdfFontUrl?: string;
74
- theme?: Partial<MachReportTheme>;
75
- messages?: Partial<MachReportMessages>;
76
- /** 校验告警等内部日志通道(默认 console;静默传 { warn: () => {}, info: () => {} }) */
77
- logger?: MachReportLogger;
78
- }
79
- export type MachReportPreset = MachReportDefaults;
80
- export interface MachReportConfig {
81
- defaults: MachReportDefaults;
82
- presets: Record<string, MachReportPreset>;
83
- /** 默认启用的 preset 名 */
84
- defaultPreset?: string;
85
- }
86
- /** 类型化配置声明(纯类型助手,便于独立 config 文件) */
87
- export declare function defineMachReportConfig(config: MachReportConfig): MachReportConfig;
88
- /** 类型化 preset 声明 */
89
- export declare function defineMachReportPreset(preset: MachReportPreset): MachReportPreset;
90
- export type ResolvedConfig = Required<Pick<MachReportDefaults, "showExport" | "showPrint" | "showPdfWindow" | "showParams" | "gapPx">> & {
91
- pdfFontUrl: string;
92
- theme: MachReportTheme;
93
- messages: MachReportMessages;
94
- logger: MachReportLogger;
95
- };
96
- declare const SILENT_LOGGER: MachReportLogger;
97
- export { SILENT_LOGGER };
98
- export declare function resolveConfig(config: MachReportConfig | null | undefined, presetName?: string): ResolvedConfig;
99
- /** theme 对象 → CSS 自定义属性 style 对象(注入组件外壳) */
100
- export declare function themeToCssVars(theme: Partial<MachReportTheme>): CSSProperties;
101
- type ConfigRef = ComputedRef<MachReportConfig | null>;
102
- /**
103
- * 路由/布局级响应式叠加:就近提供配置层(如某路由关闭导出按钮)。
104
- * 与应用级 config 合并(本层 defaults/presets 优先)。
105
- */
106
- export declare function provideMachReportConfig(overlay: MachReportConfig | MachReportDefaults): void;
107
- /** 组件内部读取当前生效配置层(未提供时返回 null → 走内置缺省) */
108
- export declare function useMachReportConfig(): ConfigRef;