hprint-designer 0.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.
- package/README.md +45 -0
- package/dist/adapters/http.d.ts +7 -0
- package/dist/adapters/mock.d.ts +33 -0
- package/dist/adapters/rest.d.ts +29 -0
- package/dist/client/detection.d.ts +4 -0
- package/dist/client/platform.d.ts +2 -0
- package/dist/client/version.d.ts +2 -0
- package/dist/contract/adapter.d.ts +23 -0
- package/dist/contract/types.d.ts +63 -0
- package/dist/core/facade.d.ts +15 -0
- package/dist/core/plugin.d.ts +11 -0
- package/dist/core/print-lock-inject.d.ts +2 -0
- package/dist/designer/provider.d.ts +10 -0
- package/dist/fields/formatters.d.ts +6 -0
- package/dist/fields/sample-data.d.ts +3 -0
- package/dist/fonts/font-face.d.ts +8 -0
- package/dist/fonts/font-manager.d.ts +7 -0
- package/dist/hprint-designer.es.js +71788 -0
- package/dist/hprint-designer.umd.js +3743 -0
- package/dist/index.d.ts +9 -0
- package/dist/style.css +1 -0
- package/dist/version.d.ts +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# hprint-designer
|
|
2
|
+
|
|
3
|
+
A Vue 2 print-template designer wrapping [vue-plugin-hiprint](https://github.com/CcSimple/vue-plugin-hiprint) — for designing paper scenic-ticket & invitation print templates, with custom fonts, field-schema third-party binding, and Electron silent-print client detection.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install hprint-designer
|
|
9
|
+
# or taobao mirror:
|
|
10
|
+
cnpm install hprint-designer
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Peer dependencies: `vue@^2.6.0`, `ant-design-vue@^1.7.2`.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import Vue from 'vue'
|
|
19
|
+
import HPrintDesigner from 'hprint-designer'
|
|
20
|
+
import 'hprint-designer/dist/style.css'
|
|
21
|
+
|
|
22
|
+
Vue.use(HPrintDesigner, { baseURL: 'https://your-server/api' })
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<print-designer
|
|
27
|
+
:template-id="id"
|
|
28
|
+
host="http://localhost:17521"
|
|
29
|
+
@save="onSave"
|
|
30
|
+
@print="onPrint" />
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Backend contract
|
|
34
|
+
|
|
35
|
+
Implement a REST backend matching `BackendAdapter`. See `src/contract/adapter.ts`:
|
|
36
|
+
|
|
37
|
+
- `GET/POST/PUT/DELETE /templates` (PUT uses `If-Match` header for optimistic lock)
|
|
38
|
+
- `GET/POST/DELETE /fonts`, `PUT /fonts/:id`
|
|
39
|
+
- `GET /client-release` — returns `{ officialUrl, selfHostedUrl?, minCompatibleVersion, ... }` for the Electron client download guide.
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT. This library depends on `vue-plugin-hiprint` (hiprint 2.5.4, LGPL). The library
|
|
44
|
+
references hiprint as a class library without modifying its source, per the LGPL
|
|
45
|
+
class-library exemption. See hiprint's LICENSE for its terms.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BackendAdapter } from '../contract/adapter';
|
|
2
|
+
import { PrintTemplate, NewPrintTemplate, PrintFont, ClientRelease } from '../contract/types';
|
|
3
|
+
|
|
4
|
+
export declare class MockAdapter implements BackendAdapter {
|
|
5
|
+
private templates;
|
|
6
|
+
private fonts;
|
|
7
|
+
listTemplates(filter?: {
|
|
8
|
+
keyword?: string;
|
|
9
|
+
[k: string]: any;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
items: PrintTemplate[];
|
|
12
|
+
total: number;
|
|
13
|
+
}>;
|
|
14
|
+
getTemplate(id: string): Promise<PrintTemplate>;
|
|
15
|
+
createTemplate(input: NewPrintTemplate): Promise<PrintTemplate>;
|
|
16
|
+
updateTemplate(id: string, patch: Partial<PrintTemplate>, ifVersion?: number): Promise<PrintTemplate>;
|
|
17
|
+
deleteTemplate(id: string): Promise<void>;
|
|
18
|
+
listFonts(): Promise<PrintFont[]>;
|
|
19
|
+
uploadFont(file: File | File[], meta: {
|
|
20
|
+
name: string;
|
|
21
|
+
family: string;
|
|
22
|
+
}): Promise<PrintFont>;
|
|
23
|
+
updateFont(id: string, patch: Partial<Pick<PrintFont, 'name' | 'family'>>): Promise<{
|
|
24
|
+
name: string;
|
|
25
|
+
family: string;
|
|
26
|
+
id: string;
|
|
27
|
+
files: import('../contract/types').FontFile[];
|
|
28
|
+
uploader?: string | undefined;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
}>;
|
|
31
|
+
deleteFont(id: string): Promise<void>;
|
|
32
|
+
getClientRelease(): Promise<ClientRelease>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BackendAdapter } from '../contract/adapter';
|
|
2
|
+
import { PrintTemplate, NewPrintTemplate, PrintFont, ClientRelease } from '../contract/types';
|
|
3
|
+
|
|
4
|
+
export interface RestAdapterOptions {
|
|
5
|
+
baseURL: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class RestAdapter implements BackendAdapter {
|
|
8
|
+
private opts;
|
|
9
|
+
constructor(opts: RestAdapterOptions);
|
|
10
|
+
listTemplates(filter?: {
|
|
11
|
+
keyword?: string;
|
|
12
|
+
[k: string]: any;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
items: PrintTemplate[];
|
|
15
|
+
total: number;
|
|
16
|
+
}>;
|
|
17
|
+
getTemplate(id: string): Promise<PrintTemplate>;
|
|
18
|
+
createTemplate(input: NewPrintTemplate): Promise<PrintTemplate>;
|
|
19
|
+
updateTemplate(id: string, patch: Partial<PrintTemplate>, ifVersion?: number): Promise<PrintTemplate>;
|
|
20
|
+
deleteTemplate(id: string): Promise<void>;
|
|
21
|
+
listFonts(): Promise<PrintFont[]>;
|
|
22
|
+
uploadFont(file: File | File[], meta: {
|
|
23
|
+
name: string;
|
|
24
|
+
family: string;
|
|
25
|
+
}): Promise<PrintFont>;
|
|
26
|
+
updateFont(id: string, patch: Partial<Pick<PrintFont, 'name' | 'family'>>): Promise<PrintFont>;
|
|
27
|
+
deleteFont(id: string): Promise<void>;
|
|
28
|
+
getClientRelease(): Promise<ClientRelease>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PrintTemplate, NewPrintTemplate, PrintFont, ClientRelease } from './types';
|
|
2
|
+
|
|
3
|
+
export interface BackendAdapter {
|
|
4
|
+
listTemplates(filter?: {
|
|
5
|
+
keyword?: string;
|
|
6
|
+
[k: string]: any;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
items: PrintTemplate[];
|
|
9
|
+
total: number;
|
|
10
|
+
}>;
|
|
11
|
+
getTemplate(id: string): Promise<PrintTemplate>;
|
|
12
|
+
createTemplate(input: NewPrintTemplate): Promise<PrintTemplate>;
|
|
13
|
+
updateTemplate(id: string, patch: Partial<PrintTemplate>, ifVersion?: number): Promise<PrintTemplate>;
|
|
14
|
+
deleteTemplate(id: string): Promise<void>;
|
|
15
|
+
listFonts(): Promise<PrintFont[]>;
|
|
16
|
+
uploadFont(file: File | File[], meta: {
|
|
17
|
+
name: string;
|
|
18
|
+
family: string;
|
|
19
|
+
}): Promise<PrintFont>;
|
|
20
|
+
updateFont(id: string, patch: Partial<Pick<PrintFont, 'name' | 'family'>>): Promise<PrintFont>;
|
|
21
|
+
deleteFont(id: string): Promise<void>;
|
|
22
|
+
getClientRelease(): Promise<ClientRelease>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type FieldType = 'string' | 'number' | 'date' | 'datetime' | 'image' | 'qrcode' | 'barcode' | 'longtext';
|
|
2
|
+
export interface FieldSchema {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
type: FieldType;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
group?: string;
|
|
8
|
+
sample: any;
|
|
9
|
+
formatter?: string;
|
|
10
|
+
enum?: {
|
|
11
|
+
label: string;
|
|
12
|
+
value: any;
|
|
13
|
+
}[];
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PrintTemplate {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
paper?: {
|
|
20
|
+
widthMm: number;
|
|
21
|
+
heightMm: number;
|
|
22
|
+
orientation?: 'portrait' | 'landscape';
|
|
23
|
+
};
|
|
24
|
+
panels: any[];
|
|
25
|
+
fields: FieldSchema[];
|
|
26
|
+
status: 'draft' | 'published';
|
|
27
|
+
version: number;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
updatedBy?: string;
|
|
30
|
+
}
|
|
31
|
+
export type NewPrintTemplate = Omit<PrintTemplate, 'id' | 'version' | 'updatedAt'>;
|
|
32
|
+
export interface FontFile {
|
|
33
|
+
format: 'woff2' | 'woff' | 'ttf';
|
|
34
|
+
url: string;
|
|
35
|
+
size?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface PrintFont {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
family: string;
|
|
41
|
+
files: FontFile[];
|
|
42
|
+
uploader?: string;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
}
|
|
45
|
+
export interface PrintClientInfo {
|
|
46
|
+
opened: boolean;
|
|
47
|
+
hostname?: string;
|
|
48
|
+
version?: string;
|
|
49
|
+
platform?: string;
|
|
50
|
+
mac?: string;
|
|
51
|
+
ip?: string;
|
|
52
|
+
clientUrl?: string;
|
|
53
|
+
nickName?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface ClientRelease {
|
|
56
|
+
version: string;
|
|
57
|
+
officialUrl: string;
|
|
58
|
+
selfHostedUrl?: string;
|
|
59
|
+
minCompatibleVersion: string;
|
|
60
|
+
releaseNotes?: string;
|
|
61
|
+
os?: string[];
|
|
62
|
+
publishedAt: string;
|
|
63
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BackendAdapter } from '../contract/adapter';
|
|
2
|
+
|
|
3
|
+
export interface HPrintDesignerOptions {
|
|
4
|
+
adapter?: BackendAdapter;
|
|
5
|
+
host?: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
lang?: 'cn' | 'en' | 'de' | 'es' | 'fr' | 'it' | 'ja' | 'ru' | 'cn_tw';
|
|
8
|
+
}
|
|
9
|
+
export declare class HPrintDesigner {
|
|
10
|
+
private _hiprint;
|
|
11
|
+
private opts;
|
|
12
|
+
constructor(opts?: HPrintDesignerOptions);
|
|
13
|
+
load(): Promise<any>;
|
|
14
|
+
get raw(): any;
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HPrintDesignerOptions } from './facade';
|
|
2
|
+
import { BackendAdapter } from '../contract/adapter';
|
|
3
|
+
|
|
4
|
+
export interface PluginOptions extends HPrintDesignerOptions {
|
|
5
|
+
componentName?: string;
|
|
6
|
+
baseURL?: string;
|
|
7
|
+
adapter?: BackendAdapter;
|
|
8
|
+
}
|
|
9
|
+
export declare const HprintPlugin: {
|
|
10
|
+
install(Vue: any, options?: PluginOptions): void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PrintFont } from '../contract/types';
|
|
2
|
+
|
|
3
|
+
export declare function buildFontFaceCss(fonts: PrintFont[]): string;
|
|
4
|
+
export declare function buildStyleHandlerCss(fonts: PrintFont[]): string;
|
|
5
|
+
export declare function toHiprintFontList(fonts: PrintFont[]): {
|
|
6
|
+
title: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}[];
|