kviewer 0.1.0 → 0.1.2
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 +12 -0
- package/dist/module.d.mts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +20 -2
- package/dist/runtime/components/Viewer.d.vue.ts +16 -0
- package/dist/runtime/components/Viewer.vue +43 -2
- package/dist/runtime/components/Viewer.vue.d.ts +16 -0
- package/dist/runtime/components/ViewerBar.d.vue.ts +7 -1
- package/dist/runtime/components/ViewerBar.vue +36 -0
- package/dist/runtime/components/ViewerBar.vue.d.ts +7 -1
- package/dist/runtime/components/ViewerTabs.d.vue.ts +14 -0
- package/dist/runtime/components/ViewerTabs.vue +5 -1
- package/dist/runtime/components/ViewerTabs.vue.d.ts +14 -0
- package/dist/runtime/components/form-fields/FormFieldWrapper.vue +1 -0
- package/dist/runtime/composables/useFormFields.d.ts +18 -0
- package/dist/runtime/composables/useFormFields.js +22 -0
- package/dist/runtime/composables/usePageProxyCache.d.ts +4 -0
- package/dist/runtime/composables/usePageProxyCache.js +4 -1
- package/dist/runtime/composables/useScriptingBridge.d.ts +29 -0
- package/dist/runtime/composables/useScriptingBridge.js +74 -0
- package/dist/runtime/composables/useScriptingManager.d.ts +65 -0
- package/dist/runtime/composables/useScriptingManager.js +123 -0
- package/dist/runtime/embed/bridge-client.d.ts +58 -0
- package/dist/runtime/embed/bridge-client.js +143 -0
- package/dist/runtime/embed/bridge-host.d.ts +59 -0
- package/dist/runtime/embed/bridge-host.js +136 -0
- package/dist/runtime/embed/protocol.d.ts +105 -0
- package/dist/runtime/embed/protocol.js +13 -0
- package/dist/runtime/menu-items.d.ts +34 -0
- package/dist/runtime/menu-items.js +0 -0
- package/dist/runtime/public-types.d.ts +7 -0
- package/dist/runtime/public-types.js +3 -0
- package/dist/runtime/style.css +1 -0
- package/dist/types.d.mts +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { ExportPdfOptions } from '../annotation/pdf-export/export.js';
|
|
2
|
+
import type { AddFormFieldPayload, FormFieldDefinition, FormFieldValue, IAnnotationStore } from '../annotation/engine/types.js';
|
|
3
|
+
export declare const KVIEWER_EMBED_PROTOCOL_VERSION = 1;
|
|
4
|
+
export declare const REQUEST_KIND: "kviewer:request";
|
|
5
|
+
export declare const RESPONSE_KIND: "kviewer:response";
|
|
6
|
+
export declare const EVENT_KIND: "kviewer:event";
|
|
7
|
+
export type ImportAnnotationsMode = 'replace' | 'merge';
|
|
8
|
+
export interface MethodSignatures {
|
|
9
|
+
getAnnotations: {
|
|
10
|
+
args: [];
|
|
11
|
+
result: IAnnotationStore[];
|
|
12
|
+
};
|
|
13
|
+
importAnnotations: {
|
|
14
|
+
args: [annotations: IAnnotationStore[], options?: {
|
|
15
|
+
mode?: ImportAnnotationsMode;
|
|
16
|
+
}];
|
|
17
|
+
result: {
|
|
18
|
+
loaded: number;
|
|
19
|
+
skipped: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exportPdf: {
|
|
23
|
+
args: [options?: ExportPdfOptions];
|
|
24
|
+
result: Uint8Array;
|
|
25
|
+
};
|
|
26
|
+
getFormFieldValues: {
|
|
27
|
+
args: [];
|
|
28
|
+
result: FormFieldValue[];
|
|
29
|
+
};
|
|
30
|
+
setFormFieldValue: {
|
|
31
|
+
args: [fieldName: string, value: string | boolean | string[]];
|
|
32
|
+
result: undefined;
|
|
33
|
+
};
|
|
34
|
+
addFormField: {
|
|
35
|
+
args: [payload: AddFormFieldPayload];
|
|
36
|
+
result: FormFieldDefinition;
|
|
37
|
+
};
|
|
38
|
+
updateFormField: {
|
|
39
|
+
args: [id: string, patch: Partial<FormFieldDefinition>];
|
|
40
|
+
result: undefined;
|
|
41
|
+
};
|
|
42
|
+
removeFormField: {
|
|
43
|
+
args: [id: string];
|
|
44
|
+
result: undefined;
|
|
45
|
+
};
|
|
46
|
+
getFormFields: {
|
|
47
|
+
args: [];
|
|
48
|
+
result: FormFieldDefinition[];
|
|
49
|
+
};
|
|
50
|
+
getFormEditMode: {
|
|
51
|
+
args: [];
|
|
52
|
+
result: boolean;
|
|
53
|
+
};
|
|
54
|
+
setFormEditMode: {
|
|
55
|
+
args: [enabled: boolean];
|
|
56
|
+
result: undefined;
|
|
57
|
+
};
|
|
58
|
+
toggleFormEditMode: {
|
|
59
|
+
args: [];
|
|
60
|
+
result: boolean;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export type MethodName = keyof MethodSignatures;
|
|
64
|
+
export interface RequestMessage<M extends MethodName = MethodName> {
|
|
65
|
+
kind: typeof REQUEST_KIND;
|
|
66
|
+
v: typeof KVIEWER_EMBED_PROTOCOL_VERSION;
|
|
67
|
+
id: string;
|
|
68
|
+
method: M;
|
|
69
|
+
args: MethodSignatures[M]['args'];
|
|
70
|
+
}
|
|
71
|
+
export type ResponseMessage<M extends MethodName = MethodName> = {
|
|
72
|
+
kind: typeof RESPONSE_KIND;
|
|
73
|
+
v: typeof KVIEWER_EMBED_PROTOCOL_VERSION;
|
|
74
|
+
id: string;
|
|
75
|
+
ok: true;
|
|
76
|
+
result: MethodSignatures[M]['result'];
|
|
77
|
+
} | {
|
|
78
|
+
kind: typeof RESPONSE_KIND;
|
|
79
|
+
v: typeof KVIEWER_EMBED_PROTOCOL_VERSION;
|
|
80
|
+
id: string;
|
|
81
|
+
ok: false;
|
|
82
|
+
error: {
|
|
83
|
+
message: string;
|
|
84
|
+
name?: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
export interface EventPayloads {
|
|
88
|
+
ready: {
|
|
89
|
+
protocolVersion: number;
|
|
90
|
+
};
|
|
91
|
+
'formEditMode-changed': {
|
|
92
|
+
enabled: boolean;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export type EventName = keyof EventPayloads;
|
|
96
|
+
export interface EventMessage<E extends EventName = EventName> {
|
|
97
|
+
kind: typeof EVENT_KIND;
|
|
98
|
+
v: typeof KVIEWER_EMBED_PROTOCOL_VERSION;
|
|
99
|
+
name: E;
|
|
100
|
+
payload: EventPayloads[E];
|
|
101
|
+
}
|
|
102
|
+
export type AnyMessage = RequestMessage | ResponseMessage | EventMessage;
|
|
103
|
+
export declare function isRequest(msg: unknown): msg is RequestMessage;
|
|
104
|
+
export declare function isResponse(msg: unknown): msg is ResponseMessage;
|
|
105
|
+
export declare function isEvent(msg: unknown): msg is EventMessage;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const KVIEWER_EMBED_PROTOCOL_VERSION = 1;
|
|
2
|
+
export const REQUEST_KIND = "kviewer:request";
|
|
3
|
+
export const RESPONSE_KIND = "kviewer:response";
|
|
4
|
+
export const EVENT_KIND = "kviewer:event";
|
|
5
|
+
export function isRequest(msg) {
|
|
6
|
+
return !!msg && typeof msg === "object" && msg.kind === REQUEST_KIND && msg.v === KVIEWER_EMBED_PROTOCOL_VERSION;
|
|
7
|
+
}
|
|
8
|
+
export function isResponse(msg) {
|
|
9
|
+
return !!msg && typeof msg === "object" && msg.kind === RESPONSE_KIND && msg.v === KVIEWER_EMBED_PROTOCOL_VERSION;
|
|
10
|
+
}
|
|
11
|
+
export function isEvent(msg) {
|
|
12
|
+
return !!msg && typeof msg === "object" && msg.kind === EVENT_KIND && msg.v === KVIEWER_EMBED_PROTOCOL_VERSION;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** A custom item appended to the viewer's burger menu. Pass an array of
|
|
2
|
+
* these to `<KViewer :menu-items="...">` (or `<KViewerTabs>`) to extend
|
|
3
|
+
* the menu without replacing the built-in entries.
|
|
4
|
+
*
|
|
5
|
+
* Inspired by Nuxt UI's `UNavigationMenu` items pattern, but scoped to
|
|
6
|
+
* the small set of controls a viewer menu needs in practice. */
|
|
7
|
+
export type ViewerMenuItem = ViewerMenuButtonItem | ViewerMenuCheckboxItem | ViewerMenuSeparatorItem;
|
|
8
|
+
export interface ViewerMenuButtonItem {
|
|
9
|
+
type: 'button';
|
|
10
|
+
/** Stable key for Vue list rendering. Keep unique within the array. */
|
|
11
|
+
key: string;
|
|
12
|
+
label: string;
|
|
13
|
+
/** Lucide-style icon name passed through to the underlying UButton. */
|
|
14
|
+
icon?: string;
|
|
15
|
+
/** Fired on click. */
|
|
16
|
+
onSelect: () => void;
|
|
17
|
+
/** Disables the item without removing it. */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ViewerMenuCheckboxItem {
|
|
21
|
+
type: 'checkbox';
|
|
22
|
+
key: string;
|
|
23
|
+
label: string;
|
|
24
|
+
icon?: string;
|
|
25
|
+
/** Current checked state — keep this reactive (Vue will re-render). */
|
|
26
|
+
checked: boolean;
|
|
27
|
+
/** Fired with the new state when the user toggles the item. */
|
|
28
|
+
onUpdate: (checked: boolean) => void;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ViewerMenuSeparatorItem {
|
|
32
|
+
type: 'separator';
|
|
33
|
+
key: string;
|
|
34
|
+
}
|
|
File without changes
|
|
@@ -2,3 +2,10 @@ export type { ExportPdfOptions } from './annotation/pdf-export/export.js';
|
|
|
2
2
|
export type { ViewerTabItem, AddTabOptions } from './components/ViewerTabs.vue.js';
|
|
3
3
|
export type { AddFormFieldPayload, CheckboxStyle, FormFieldDefinition, FormFieldOrigin, FormFieldType, FormFieldValue, SignatureData, SignatureHandlers, } from './annotation/engine/types.js';
|
|
4
4
|
export type { ViewMode } from './composables/viewMode.js';
|
|
5
|
+
export type { KViewerApi, KViewerEmbedBridgeOptions, } from './embed/bridge-host.js';
|
|
6
|
+
export { useKViewerEmbedBridge } from './embed/bridge-host.js';
|
|
7
|
+
export type { KViewerEmbedClientOptions } from './embed/bridge-client.js';
|
|
8
|
+
export { KViewerEmbedClient } from './embed/bridge-client.js';
|
|
9
|
+
export type { EventName as KViewerEmbedEventName, EventPayloads as KViewerEmbedEventPayloads, MethodName as KViewerEmbedMethodName, } from './embed/protocol.js';
|
|
10
|
+
export { KVIEWER_EMBED_PROTOCOL_VERSION } from './embed/protocol.js';
|
|
11
|
+
export type { ViewerMenuItem, ViewerMenuButtonItem, ViewerMenuCheckboxItem, ViewerMenuSeparatorItem, } from './menu-items.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@source "./components/**/*.vue";
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type AddFormFieldPayload, type CheckboxStyle, type ExportPdfOptions, type FormFieldDefinition, type FormFieldOrigin, type FormFieldType, type FormFieldValue, type SignatureData, type SignatureHandlers, type ViewMode } from '../dist/runtime/public-types.js'
|
|
1
|
+
export { type AddFormFieldPayload, type CheckboxStyle, type ExportPdfOptions, type FormFieldDefinition, type FormFieldOrigin, type FormFieldType, type FormFieldValue, type KVIEWER_EMBED_PROTOCOL_VERSION, type KViewerApi, type KViewerEmbedBridgeOptions, type KViewerEmbedClient, type KViewerEmbedClientOptions, type KViewerEmbedEventName, type KViewerEmbedEventPayloads, type KViewerEmbedMethodName, type SignatureData, type SignatureHandlers, type ViewMode, type ViewerMenuButtonItem, type ViewerMenuCheckboxItem, type ViewerMenuItem, type ViewerMenuSeparatorItem, type useKViewerEmbedBridge } from '../dist/runtime/public-types.js'
|
|
2
2
|
|
|
3
3
|
export { default } from './module.mjs'
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kviewer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Kabema PDF Editor",
|
|
5
5
|
"repository": "kabema/kviewer",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/types.d.mts",
|
|
11
|
+
"style": "./dist/runtime/style.css",
|
|
11
12
|
"import": "./dist/module.mjs"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
"main": "./dist/module.mjs",
|
|
16
|
+
"style": "./dist/runtime/style.css",
|
|
15
17
|
"typesVersions": {
|
|
16
18
|
"*": {
|
|
17
19
|
".": [
|
|
@@ -40,21 +42,21 @@
|
|
|
40
42
|
"test:e2e:ui": "playwright test --ui"
|
|
41
43
|
},
|
|
42
44
|
"dependencies": {
|
|
45
|
+
"@iconify-json/lucide": "^1.2.101",
|
|
43
46
|
"@nuxt/kit": "^4.4.2",
|
|
47
|
+
"@nuxt/ui": "^4.6.0",
|
|
44
48
|
"konva": "^10.2.3",
|
|
45
49
|
"pdf-lib": "^1.17.1",
|
|
46
50
|
"pdfjs-dist": "^5.6.205",
|
|
47
51
|
"tailwindcss": "^4.2.2"
|
|
48
52
|
},
|
|
49
53
|
"devDependencies": {
|
|
50
|
-
"@iconify-json/lucide": "^1.2.101",
|
|
51
54
|
"@nuxt/devtools": "^3.2.4",
|
|
52
55
|
"@nuxt/eslint": "1.15.2",
|
|
53
56
|
"@nuxt/eslint-config": "^1.15.2",
|
|
54
57
|
"@nuxt/module-builder": "^1.0.2",
|
|
55
58
|
"@nuxt/schema": "^4.4.2",
|
|
56
59
|
"@nuxt/test-utils": "^4.0.0",
|
|
57
|
-
"@nuxt/ui": "4.6.0",
|
|
58
60
|
"@playwright/test": "^1.59.1",
|
|
59
61
|
"@types/node": "latest",
|
|
60
62
|
"canvas": "^3.2.3",
|