@agile-team/mach-report 0.4.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 +3 -3
- package/dist/compat/jh4j-template.d.ts +1 -1
- package/dist/index.cjs +6 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.js +919 -14
- package/dist/layout/paginate.d.ts +2 -2
- package/dist/manager/api.d.ts +1 -1
- package/dist/manager/index.d.ts +2 -2
- package/dist/manager.cjs +1 -0
- package/dist/manager.d.cts +5 -0
- package/dist/manager.d.ts +1 -1
- package/dist/manager.js +104 -6
- package/dist/pdf/index.d.ts +2 -2
- package/dist/pdf/render-pdf.d.ts +10 -4
- package/dist/pdf.cjs +84 -0
- package/dist/pdf.d.cts +6 -0
- package/dist/pdf.d.ts +1 -1
- package/dist/pdf.js +36152 -7
- package/dist/plugin-BIJxGHZX.cjs +1 -0
- package/dist/plugin-DrV67_VW.js +89 -0
- package/dist/render/canvas.d.ts +2 -2
- package/dist/render/dom.d.ts +1 -1
- package/dist/render/grid-geometry.d.ts +1 -1
- package/dist/render/style.d.ts +1 -8
- package/dist/schema/validate.d.ts +1 -1
- package/dist/sql/compile.d.ts +1 -1
- package/dist/sql/index.d.ts +4 -4
- package/dist/sql.cjs +68 -0
- package/dist/sql.d.cts +5 -0
- package/dist/sql.d.ts +1 -1
- package/dist/sql.js +40794 -6
- package/dist/style-B3vxGDZd.cjs +3 -0
- package/dist/style-B7Xfo5I-.js +255 -0
- package/dist/style.css +1 -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 +84 -17
- package/dist/builder/template-builder.js +0 -153
- package/dist/builder/template-builder.js.map +0 -1
- package/dist/compat/jh4j-template.js +0 -196
- package/dist/compat/jh4j-template.js.map +0 -1
- package/dist/defaults.js +0 -28
- package/dist/defaults.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/layout/paginate.js +0 -197
- package/dist/layout/paginate.js.map +0 -1
- package/dist/layout/textwrap.js +0 -173
- package/dist/layout/textwrap.js.map +0 -1
- package/dist/manager/api.js +0 -101
- package/dist/manager/api.js.map +0 -1
- package/dist/manager/index.js +0 -3
- package/dist/manager/index.js.map +0 -1
- package/dist/manager/types.js +0 -8
- package/dist/manager/types.js.map +0 -1
- package/dist/manager.js.map +0 -1
- package/dist/pdf/font-loader.js +0 -84
- package/dist/pdf/font-loader.js.map +0 -1
- package/dist/pdf/index.js +0 -3
- package/dist/pdf/index.js.map +0 -1
- package/dist/pdf/render-pdf.js +0 -284
- package/dist/pdf/render-pdf.js.map +0 -1
- package/dist/pdf.js.map +0 -1
- package/dist/render/canvas.js +0 -402
- package/dist/render/canvas.js.map +0 -1
- package/dist/render/dom.js +0 -311
- package/dist/render/dom.js.map +0 -1
- package/dist/render/grid-geometry.js +0 -131
- package/dist/render/grid-geometry.js.map +0 -1
- package/dist/render/style.js +0 -39
- package/dist/render/style.js.map +0 -1
- package/dist/render/window.js +0 -58
- package/dist/render/window.js.map +0 -1
- package/dist/schema/render-plan.js +0 -25
- package/dist/schema/render-plan.js.map +0 -1
- package/dist/schema/validate.js +0 -129
- package/dist/schema/validate.js.map +0 -1
- package/dist/sql/ast-check.js +0 -44
- package/dist/sql/ast-check.js.map +0 -1
- package/dist/sql/compile.js +0 -145
- package/dist/sql/compile.js.map +0 -1
- package/dist/sql/expr.js +0 -123
- package/dist/sql/expr.js.map +0 -1
- package/dist/sql/index.js +0 -5
- package/dist/sql/index.js.map +0 -1
- package/dist/sql/tokenizer.js +0 -124
- package/dist/sql/tokenizer.js.map +0 -1
- package/dist/sql.js.map +0 -1
- package/dist/units.js +0 -26
- package/dist/units.js.map +0 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Plugin } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* 异步插件入口(@agile-team/mach-report-vue/async):
|
|
4
|
+
*
|
|
5
|
+
* 首屏敏感页面用异步全局组件代替静态 import——组件与其引擎依赖
|
|
6
|
+
* 拆为独立 chunk,路由级按需加载:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import AsyncMachReportPlugin, { preloadMachReport } from "@agile-team/mach-report-vue/async";
|
|
10
|
+
* app.use(AsyncMachReportPlugin, { baseUrl: "/sub/mach-report" });
|
|
11
|
+
* void preloadMachReport(); // 可选:路由 hover 时预取
|
|
12
|
+
* // 模板:<MachReportPreview temp-id="X" />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
/** 全局异步组件(懒加载 ReportPreview 及其引擎分片) */
|
|
16
|
+
export declare const MachReportPreview: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
17
|
+
tempId: {
|
|
18
|
+
type: import('vue').PropType<string | string[] | null>;
|
|
19
|
+
default: null;
|
|
20
|
+
};
|
|
21
|
+
furnitureTempId: {
|
|
22
|
+
type: StringConstructor;
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
params: {
|
|
26
|
+
type: import('vue').PropType<Record<string, string>>;
|
|
27
|
+
default: () => {};
|
|
28
|
+
};
|
|
29
|
+
height: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
default: string;
|
|
32
|
+
};
|
|
33
|
+
autoLoad: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
showExport: {
|
|
38
|
+
type: BooleanConstructor;
|
|
39
|
+
default: undefined;
|
|
40
|
+
};
|
|
41
|
+
showPrint: {
|
|
42
|
+
type: BooleanConstructor;
|
|
43
|
+
default: undefined;
|
|
44
|
+
};
|
|
45
|
+
showPdfWindow: {
|
|
46
|
+
type: BooleanConstructor;
|
|
47
|
+
default: undefined;
|
|
48
|
+
};
|
|
49
|
+
gapPx: {
|
|
50
|
+
type: NumberConstructor;
|
|
51
|
+
default: undefined;
|
|
52
|
+
};
|
|
53
|
+
messages: {
|
|
54
|
+
type: import('vue').PropType<Partial<import('./config').MachReportMessages>>;
|
|
55
|
+
default: undefined;
|
|
56
|
+
};
|
|
57
|
+
preset: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
default: undefined;
|
|
60
|
+
};
|
|
61
|
+
fetcher: {
|
|
62
|
+
type: import('vue').PropType<import('./adapters').PlanFetcher | null>;
|
|
63
|
+
default: null;
|
|
64
|
+
};
|
|
65
|
+
}>, {
|
|
66
|
+
reload: () => Promise<void>;
|
|
67
|
+
print: () => Promise<void>;
|
|
68
|
+
exportAs: (format: string) => void;
|
|
69
|
+
openPdfWindow: () => void;
|
|
70
|
+
gotoPage: (n: number) => void;
|
|
71
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
72
|
+
error: (message: string) => any;
|
|
73
|
+
loaded: (pageCount: number) => any;
|
|
74
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
75
|
+
tempId: {
|
|
76
|
+
type: import('vue').PropType<string | string[] | null>;
|
|
77
|
+
default: null;
|
|
78
|
+
};
|
|
79
|
+
furnitureTempId: {
|
|
80
|
+
type: StringConstructor;
|
|
81
|
+
default: string;
|
|
82
|
+
};
|
|
83
|
+
params: {
|
|
84
|
+
type: import('vue').PropType<Record<string, string>>;
|
|
85
|
+
default: () => {};
|
|
86
|
+
};
|
|
87
|
+
height: {
|
|
88
|
+
type: StringConstructor;
|
|
89
|
+
default: string;
|
|
90
|
+
};
|
|
91
|
+
autoLoad: {
|
|
92
|
+
type: BooleanConstructor;
|
|
93
|
+
default: boolean;
|
|
94
|
+
};
|
|
95
|
+
showExport: {
|
|
96
|
+
type: BooleanConstructor;
|
|
97
|
+
default: undefined;
|
|
98
|
+
};
|
|
99
|
+
showPrint: {
|
|
100
|
+
type: BooleanConstructor;
|
|
101
|
+
default: undefined;
|
|
102
|
+
};
|
|
103
|
+
showPdfWindow: {
|
|
104
|
+
type: BooleanConstructor;
|
|
105
|
+
default: undefined;
|
|
106
|
+
};
|
|
107
|
+
gapPx: {
|
|
108
|
+
type: NumberConstructor;
|
|
109
|
+
default: undefined;
|
|
110
|
+
};
|
|
111
|
+
messages: {
|
|
112
|
+
type: import('vue').PropType<Partial<import('./config').MachReportMessages>>;
|
|
113
|
+
default: undefined;
|
|
114
|
+
};
|
|
115
|
+
preset: {
|
|
116
|
+
type: StringConstructor;
|
|
117
|
+
default: undefined;
|
|
118
|
+
};
|
|
119
|
+
fetcher: {
|
|
120
|
+
type: import('vue').PropType<import('./adapters').PlanFetcher | null>;
|
|
121
|
+
default: null;
|
|
122
|
+
};
|
|
123
|
+
}>> & Readonly<{
|
|
124
|
+
onError?: ((message: string) => any) | undefined;
|
|
125
|
+
onLoaded?: ((pageCount: number) => any) | undefined;
|
|
126
|
+
}>, {
|
|
127
|
+
height: string;
|
|
128
|
+
gapPx: number;
|
|
129
|
+
params: Record<string, string>;
|
|
130
|
+
furnitureTempId: string;
|
|
131
|
+
tempId: string | string[] | null;
|
|
132
|
+
showExport: boolean;
|
|
133
|
+
showPrint: boolean;
|
|
134
|
+
showPdfWindow: boolean;
|
|
135
|
+
messages: Partial<import('./config').MachReportMessages>;
|
|
136
|
+
autoLoad: boolean;
|
|
137
|
+
preset: string;
|
|
138
|
+
fetcher: import('./adapters').PlanFetcher | null;
|
|
139
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
140
|
+
viewportRef: HTMLDivElement;
|
|
141
|
+
containerRef: HTMLDivElement;
|
|
142
|
+
}, HTMLDivElement>;
|
|
143
|
+
/** 预取组件分片(路由 hover / 空闲时调用,正式渲染零等待) */
|
|
144
|
+
export declare function preloadMachReport(): Promise<unknown>;
|
|
145
|
+
export declare const machReportAsyncPlugin: Plugin;
|
|
146
|
+
export default machReportAsyncPlugin;
|
|
@@ -0,0 +1,28 @@
|
|
|
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;
|
|
13
|
+
}): {
|
|
14
|
+
pageHeightsPx: import('vue').ComputedRef<number[]>;
|
|
15
|
+
contentSize: import('vue').ComputedRef<{
|
|
16
|
+
w: number;
|
|
17
|
+
h: number;
|
|
18
|
+
}>;
|
|
19
|
+
windowRange: import('vue').ComputedRef<import('@agile-team/mach-report').PageWindow>;
|
|
20
|
+
visiblePages: import('vue').ComputedRef<{
|
|
21
|
+
page: PlanPage;
|
|
22
|
+
index: number;
|
|
23
|
+
}[]>;
|
|
24
|
+
scrollTop: Ref<number, number>;
|
|
25
|
+
viewportHeight: Ref<number, number>;
|
|
26
|
+
makeScrollHandler: (currentPage: Ref<number>, pageCount: Ref<number>) => (vp: HTMLElement) => void;
|
|
27
|
+
refreshViewport(vp: HTMLElement | null): void;
|
|
28
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
/** 构建打印文档:head(含按尺寸分组的 @page 规则)+ 每页一段 HTML(供流式写入) */
|
|
9
|
+
export declare function buildPrintDocument(p: RenderPlan): PrintHtmlResult;
|
|
10
|
+
export declare function usePrintExport(plan: Ref<RenderPlan | null>, hooks: {
|
|
11
|
+
getPdfExporter: () => PdfExporter;
|
|
12
|
+
onError: (message: string) => void;
|
|
13
|
+
}): {
|
|
14
|
+
print: () => Promise<void>;
|
|
15
|
+
exportAs: (format: string) => void;
|
|
16
|
+
openPdfWindow: () => void;
|
|
17
|
+
releasePrintFrame: () => void;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
print: string;
|
|
19
|
+
pdfWindow: string;
|
|
20
|
+
loading: string;
|
|
21
|
+
empty: string;
|
|
22
|
+
errorPrefix: string;
|
|
23
|
+
retry: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_MESSAGES: MachReportMessages;
|
|
26
|
+
/** 主题变量(组件外壳注入的 --mrp-* CSS 自定义属性) */
|
|
27
|
+
export interface MachReportTheme {
|
|
28
|
+
shellBg: string;
|
|
29
|
+
shellFg: string;
|
|
30
|
+
toolbarBg: string;
|
|
31
|
+
toolbarBorder: string;
|
|
32
|
+
toolbarFg: string;
|
|
33
|
+
btnFg: string;
|
|
34
|
+
btnBorder: string;
|
|
35
|
+
btnHoverBg: string;
|
|
36
|
+
btnHoverFg: string;
|
|
37
|
+
btnActiveBg: string;
|
|
38
|
+
}
|
|
39
|
+
export declare const DEFAULT_THEME: MachReportTheme;
|
|
40
|
+
/** defaults 层可配置项(全部可选,均有内置缺省) */
|
|
41
|
+
export interface MachReportDefaults {
|
|
42
|
+
showExport?: boolean;
|
|
43
|
+
showPrint?: boolean;
|
|
44
|
+
showPdfWindow?: boolean;
|
|
45
|
+
/** 页间距 px */
|
|
46
|
+
gapPx?: number;
|
|
47
|
+
/** PDF 导出中文字体 URL */
|
|
48
|
+
pdfFontUrl?: string;
|
|
49
|
+
theme?: Partial<MachReportTheme>;
|
|
50
|
+
messages?: Partial<MachReportMessages>;
|
|
51
|
+
}
|
|
52
|
+
export type MachReportPreset = MachReportDefaults;
|
|
53
|
+
export interface MachReportConfig {
|
|
54
|
+
defaults: MachReportDefaults;
|
|
55
|
+
presets: Record<string, MachReportPreset>;
|
|
56
|
+
/** 默认启用的 preset 名 */
|
|
57
|
+
defaultPreset?: string;
|
|
58
|
+
}
|
|
59
|
+
/** 类型化配置声明(纯类型助手,便于独立 config 文件) */
|
|
60
|
+
export declare function defineMachReportConfig(config: MachReportConfig): MachReportConfig;
|
|
61
|
+
/** 类型化 preset 声明 */
|
|
62
|
+
export declare function defineMachReportPreset(preset: MachReportPreset): MachReportPreset;
|
|
63
|
+
export type ResolvedConfig = Required<Pick<MachReportDefaults, "showExport" | "showPrint" | "showPdfWindow" | "gapPx">> & {
|
|
64
|
+
pdfFontUrl: string;
|
|
65
|
+
theme: MachReportTheme;
|
|
66
|
+
messages: MachReportMessages;
|
|
67
|
+
};
|
|
68
|
+
export declare function resolveConfig(config: MachReportConfig | null | undefined, presetName?: string): ResolvedConfig;
|
|
69
|
+
/** theme 对象 → CSS 自定义属性 style 对象(注入组件外壳) */
|
|
70
|
+
export declare function themeToCssVars(theme: Partial<MachReportTheme>): CSSProperties;
|
|
71
|
+
type ConfigRef = ComputedRef<MachReportConfig | null>;
|
|
72
|
+
/**
|
|
73
|
+
* 路由/布局级响应式叠加:就近提供配置层(如某路由关闭导出按钮)。
|
|
74
|
+
* 与应用级 config 合并(本层 defaults/presets 优先)。
|
|
75
|
+
*/
|
|
76
|
+
export declare function provideMachReportConfig(overlay: MachReportConfig | MachReportDefaults): void;
|
|
77
|
+
/** 组件内部读取当前生效配置层(未提供时返回 null → 走内置缺省) */
|
|
78
|
+
export declare function useMachReportConfig(): ConfigRef;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as ReportPreview } from './ReportPreview';
|
|
2
|
+
export { default as ReportToolbar } from './ReportToolbar';
|
|
3
|
+
export * from './adapters';
|
|
4
|
+
export * from './local-adapter';
|
|
5
|
+
export * from './injection-keys';
|
|
6
|
+
export * from './plugin';
|
|
7
|
+
export * from './config';
|
|
8
|
+
export * from './pdf-exporter';
|
|
9
|
+
export * from './composables/usePageWindow';
|
|
10
|
+
export * from './composables/useZoom';
|
|
11
|
+
export * from './composables/usePrintExport';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as ReportPreview } from './ReportPreview';
|
|
2
|
+
export { default as ReportToolbar } from './ReportToolbar';
|
|
3
|
+
export * from './adapters';
|
|
4
|
+
export * from './local-adapter';
|
|
5
|
+
export * from './injection-keys';
|
|
6
|
+
export * from './plugin';
|
|
7
|
+
export * from './config';
|
|
8
|
+
export * from './pdf-exporter';
|
|
9
|
+
export * from './composables/usePageWindow';
|
|
10
|
+
export * from './composables/useZoom';
|
|
11
|
+
export * from './composables/usePrintExport';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
+
import { PlanFetcher } from './adapters';
|
|
3
|
+
import { PdfExporter } from './pdf-exporter';
|
|
4
|
+
import { MachReportConfig } from './config';
|
|
5
|
+
/**
|
|
6
|
+
* 注入 key 全部为字符串(而非裸 Symbol):跨模块联邦边界时宿主与远程
|
|
7
|
+
* 各自打包会生成不同的 Symbol 实例导致 inject 失效;字符串恒等。
|
|
8
|
+
* 保留 InjectionKey 类型以获得类型提示。
|
|
9
|
+
*/
|
|
10
|
+
export declare const MACH_REPORT_FETCHER_KEY: InjectionKey<PlanFetcher>;
|
|
11
|
+
export declare const MACH_REPORT_PDF_EXPORTER_KEY: InjectionKey<PdfExporter>;
|
|
12
|
+
export declare const MACH_REPORT_CONFIG_KEY: InjectionKey<ComputedRef<MachReportConfig | null>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReportTemplate } from '@agile-team/mach-report';
|
|
2
|
+
import { PlanFetcher } from './adapters';
|
|
3
|
+
export interface LocalTemplateEntry {
|
|
4
|
+
tempId: string;
|
|
5
|
+
template: ReportTemplate;
|
|
6
|
+
datasets?: Record<string, Record<string, unknown>[]>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 本地渲染适配器:模板 + 数据 → core 分页引擎 → RenderPlan。
|
|
10
|
+
* 用于离线预览、单测与 jh4j 后端不可用场景(单真相源验证)。
|
|
11
|
+
*/
|
|
12
|
+
export declare function createLocalFetcher(entries: Record<string, LocalTemplateEntry>): PlanFetcher;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RenderPlan } from '@agile-team/mach-report';
|
|
2
|
+
/** PDF 导出器:RenderPlan → PDF 字节。宿主可注入自定义实现(自研后端/Worker 化等)。 */
|
|
3
|
+
export type PdfExporter = (plan: RenderPlan) => 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;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { PlanFetcher, HostRequest } from './adapters';
|
|
3
|
+
import { PdfExporter } from './pdf-exporter';
|
|
4
|
+
import { MachReportConfig } from './config';
|
|
5
|
+
export interface MachReportPluginOptions {
|
|
6
|
+
/**
|
|
7
|
+
* 数据面(全部可选——零配置时用全局 fetch 同源直连):
|
|
8
|
+
* - request:宿主 http 客户端(axios 风格签名)
|
|
9
|
+
* - fetcher:完整 PlanFetcher(自定义数据面/本地模板,优先级最高)
|
|
10
|
+
*/
|
|
11
|
+
request?: HostRequest;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
fetcher?: PlanFetcher;
|
|
14
|
+
/** 应用级配置中心(defaults/presets/文案/主题),见 defineMachReportConfig */
|
|
15
|
+
config?: MachReportConfig;
|
|
16
|
+
/** PDF 导出字体 URL(默认 /simhei.ttf;'' 跳过字体) */
|
|
17
|
+
pdfFontUrl?: string;
|
|
18
|
+
/** 自定义 PDF 导出器(缺省用懒加载引擎 /pdf 子路径的默认实现) */
|
|
19
|
+
pdfExporter?: PdfExporter;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Vue 插件(零配置可用):
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* app.use(machReportPlugin) // 同源 jh4j 部署,零胶水
|
|
26
|
+
* app.use(machReportPlugin, { baseUrl: "/sub/mach-report" })
|
|
27
|
+
* app.use(machReportPlugin, { request: axios, config: defineMachReportConfig({...}) })
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* 之后业务页面一行使用:`<ReportPreview temp-id="X" />`
|
|
31
|
+
*/
|
|
32
|
+
export declare const machReportPlugin: {
|
|
33
|
+
install(app: App, options?: MachReportPluginOptions): void;
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),i=require("./plugin-BIJxGHZX.cjs"),r=n.defineAsyncComponent(()=>Promise.resolve().then(()=>require("./ReportPreview-rBtmbu3W.cjs")).then(e=>e.ReportPreview$1));function c(){return Promise.resolve().then(()=>require("./ReportPreview-rBtmbu3W.cjs")).then(e=>e.ReportPreview$1)}const t={install(e,o={}){i.machReportPlugin.install(e,o),e.component("MachReportPreview",r)}};exports.MachReportPreview=r;exports.default=t;exports.machReportAsyncPlugin=t;exports.preloadMachReport=c;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineAsyncComponent as e } from "vue";
|
|
2
|
+
import { m as n } from "./plugin-DrV67_VW.js";
|
|
3
|
+
const r = e(() => import("./ReportPreview-DWLjYi_p.js").then((t) => t.i));
|
|
4
|
+
function m() {
|
|
5
|
+
return import("./ReportPreview-DWLjYi_p.js").then((t) => t.i);
|
|
6
|
+
}
|
|
7
|
+
const p = {
|
|
8
|
+
install(t, o = {}) {
|
|
9
|
+
n.install(t, o), t.component("MachReportPreview", r);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
r as MachReportPreview,
|
|
14
|
+
p as default,
|
|
15
|
+
p as machReportAsyncPlugin,
|
|
16
|
+
m as preloadMachReport
|
|
17
|
+
};
|
package/dist/vue.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ReportPreview-rBtmbu3W.cjs"),r=require("./plugin-BIJxGHZX.cjs"),E=require("@agile-team/mach-report");function R(c){return async({tempIds:t})=>{if(t.length===0)throw new r.PlanLoadError("缺少报表模板 ID");const a=[];for(const n of t){const o=c[n];if(!o)throw new r.PlanLoadError(`本地模板 ${n} 不存在`);const{plan:s,warnings:i}=E.paginateTemplate(o.template,o.datasets??{});i.length>0&&console.warn("[mach-report] 分页告警:",i),a.push(...s.pages)}return{schemaVersion:"mach-local",pages:a}}}exports.DEFAULT_MESSAGES=e.DEFAULT_MESSAGES;exports.DEFAULT_THEME=e.DEFAULT_THEME;exports.ReportPreview=e.ReportPreview;exports.ReportToolbar=e.ReportToolbar;exports.buildPrintDocument=e.buildPrintDocument;exports.defineMachReportConfig=e.defineMachReportConfig;exports.defineMachReportPreset=e.defineMachReportPreset;exports.provideMachReportConfig=e.provideMachReportConfig;exports.resolveConfig=e.resolveConfig;exports.themeToCssVars=e.themeToCssVars;exports.useMachReportConfig=e.useMachReportConfig;exports.usePageWindow=e.usePageWindow;exports.usePrintExport=e.usePrintExport;exports.useZoom=e.useZoom;exports.MACH_REPORT_CONFIG_KEY=r.MACH_REPORT_CONFIG_KEY;exports.MACH_REPORT_FETCHER_KEY=r.MACH_REPORT_FETCHER_KEY;exports.MACH_REPORT_PDF_EXPORTER_KEY=r.MACH_REPORT_PDF_EXPORTER_KEY;exports.PlanLoadError=r.PlanLoadError;exports.createDefaultPdfExporter=r.createDefaultPdfExporter;exports.createFetchRequest=r.createFetchRequest;exports.createJh4jGridPlanFetcher=r.createJh4jGridPlanFetcher;exports.joinTempIds=r.joinTempIds;exports.machReportPlugin=r.machReportPlugin;exports.normalizeTempIds=r.normalizeTempIds;exports.createLocalFetcher=R;
|
package/dist/vue.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { D as m, a as R, R as P, b as g, c as u, d, e as T, p as _, r as C, t as M, u as w, f as F, g as D, h as A } from "./ReportPreview-DWLjYi_p.js";
|
|
2
|
+
import { P as t } from "./plugin-DrV67_VW.js";
|
|
3
|
+
import { M as H, a as O, b, c as L, d as j, e as v, j as G, m as I, n as K } from "./plugin-DrV67_VW.js";
|
|
4
|
+
import { paginateTemplate as i } from "@agile-team/mach-report";
|
|
5
|
+
function h(n) {
|
|
6
|
+
return async ({ tempIds: a }) => {
|
|
7
|
+
if (a.length === 0) throw new t("缺少报表模板 ID");
|
|
8
|
+
const r = [];
|
|
9
|
+
for (const o of a) {
|
|
10
|
+
const e = n[o];
|
|
11
|
+
if (!e) throw new t(`本地模板 ${o} 不存在`);
|
|
12
|
+
const { plan: c, warnings: s } = i(e.template, e.datasets ?? {});
|
|
13
|
+
s.length > 0 && console.warn("[mach-report] 分页告警:", s), r.push(...c.pages);
|
|
14
|
+
}
|
|
15
|
+
return { schemaVersion: "mach-local", pages: r };
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
m as DEFAULT_MESSAGES,
|
|
20
|
+
R as DEFAULT_THEME,
|
|
21
|
+
H as MACH_REPORT_CONFIG_KEY,
|
|
22
|
+
O as MACH_REPORT_FETCHER_KEY,
|
|
23
|
+
b as MACH_REPORT_PDF_EXPORTER_KEY,
|
|
24
|
+
t as PlanLoadError,
|
|
25
|
+
P as ReportPreview,
|
|
26
|
+
g as ReportToolbar,
|
|
27
|
+
u as buildPrintDocument,
|
|
28
|
+
L as createDefaultPdfExporter,
|
|
29
|
+
j as createFetchRequest,
|
|
30
|
+
v as createJh4jGridPlanFetcher,
|
|
31
|
+
h as createLocalFetcher,
|
|
32
|
+
d as defineMachReportConfig,
|
|
33
|
+
T as defineMachReportPreset,
|
|
34
|
+
G as joinTempIds,
|
|
35
|
+
I as machReportPlugin,
|
|
36
|
+
K as normalizeTempIds,
|
|
37
|
+
_ as provideMachReportConfig,
|
|
38
|
+
C as resolveConfig,
|
|
39
|
+
M as themeToCssVars,
|
|
40
|
+
w as useMachReportConfig,
|
|
41
|
+
F as usePageWindow,
|
|
42
|
+
D as usePrintExport,
|
|
43
|
+
A as useZoom
|
|
44
|
+
};
|
package/package.json
CHANGED
|
@@ -1,42 +1,109 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agile-team/mach-report",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "MachReport 报表引擎单包:RenderPlan 模型 + 分页 + DOM/Canvas/PDF 渲染 + 动态 SQL + 管理端 API
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "MachReport 报表引擎单包:RenderPlan 模型 + 分页 + DOM/Canvas/PDF 渲染 + 动态 SQL + 管理端 API + Vue 3 契约组件(零运行时依赖;./vue 为框架子路径,vue 为可选 peer)",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"sideEffects":
|
|
7
|
-
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"**/*.css",
|
|
8
|
+
"**/*.vue"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/index.cjs",
|
|
8
11
|
"types": "./dist/index.d.ts",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
|
-
"
|
|
12
|
-
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
13
22
|
},
|
|
14
23
|
"./pdf": {
|
|
15
|
-
"
|
|
16
|
-
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/pdf.d.ts",
|
|
26
|
+
"default": "./dist/pdf.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/pdf.d.cts",
|
|
30
|
+
"default": "./dist/pdf.cjs"
|
|
31
|
+
}
|
|
17
32
|
},
|
|
18
33
|
"./sql": {
|
|
19
|
-
"
|
|
20
|
-
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/sql.d.ts",
|
|
36
|
+
"default": "./dist/sql.js"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/sql.d.cts",
|
|
40
|
+
"default": "./dist/sql.cjs"
|
|
41
|
+
}
|
|
21
42
|
},
|
|
22
43
|
"./manager": {
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
44
|
+
"import": {
|
|
45
|
+
"types": "./dist/manager.d.ts",
|
|
46
|
+
"default": "./dist/manager.js"
|
|
47
|
+
},
|
|
48
|
+
"require": {
|
|
49
|
+
"types": "./dist/manager.d.cts",
|
|
50
|
+
"default": "./dist/manager.cjs"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"./vue": {
|
|
54
|
+
"import": {
|
|
55
|
+
"types": "./dist/vue/index.d.ts",
|
|
56
|
+
"default": "./dist/vue.js"
|
|
57
|
+
},
|
|
58
|
+
"require": {
|
|
59
|
+
"types": "./dist/vue/index.d.cts",
|
|
60
|
+
"default": "./dist/vue.cjs"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"./vue/async": {
|
|
64
|
+
"import": {
|
|
65
|
+
"types": "./dist/vue/async.d.ts",
|
|
66
|
+
"default": "./dist/vue-async.js"
|
|
67
|
+
},
|
|
68
|
+
"require": {
|
|
69
|
+
"types": "./dist/vue/async.d.cts",
|
|
70
|
+
"default": "./dist/vue-async.cjs"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"./vue/style.css": "./dist/style.css"
|
|
26
74
|
},
|
|
27
75
|
"publishConfig": {
|
|
28
76
|
"access": "public"
|
|
29
77
|
},
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=18.0.0"
|
|
80
|
+
},
|
|
30
81
|
"files": [
|
|
31
82
|
"dist"
|
|
32
83
|
],
|
|
33
|
-
"
|
|
84
|
+
"peerDependencies": {
|
|
85
|
+
"vue": "^3.2.0"
|
|
86
|
+
},
|
|
87
|
+
"peerDependenciesMeta": {
|
|
88
|
+
"vue": {
|
|
89
|
+
"optional": true
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"devDependencies": {
|
|
34
93
|
"@pdf-lib/fontkit": "^1.1.1",
|
|
94
|
+
"@vitejs/plugin-vue": "^6.0.9",
|
|
95
|
+
"@vue/test-utils": "^2.4.0",
|
|
35
96
|
"node-sql-parser": "^5.4.0",
|
|
36
|
-
"pdf-lib": "^1.17.1"
|
|
97
|
+
"pdf-lib": "^1.17.1",
|
|
98
|
+
"typescript": "^5.9.0",
|
|
99
|
+
"vite": "^7.3.6",
|
|
100
|
+
"vite-plugin-dts": "^4.5.0",
|
|
101
|
+
"vue": "^3.5.0",
|
|
102
|
+
"vue-tsc": "^3.0.0"
|
|
37
103
|
},
|
|
38
104
|
"scripts": {
|
|
39
|
-
"build": "
|
|
105
|
+
"build": "vite build && node scripts/copy-dcts.mjs",
|
|
40
106
|
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\""
|
|
41
|
-
}
|
|
107
|
+
},
|
|
108
|
+
"module": "./dist/index.js"
|
|
42
109
|
}
|