@rhc-office/sdk 6.6.268 → 6.6.363
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 +1 -5
- package/dist/api/annotation-tool.d.ts +187 -102
- package/dist/api/annotation-tool.d.ts.map +1 -1
- package/dist/api/callbacks.d.ts +32 -6
- package/dist/api/callbacks.d.ts.map +1 -1
- package/dist/api/document-sdk.d.ts +6 -5
- package/dist/api/document-sdk.d.ts.map +1 -1
- package/dist/api/document-tool.d.ts +19 -11
- package/dist/api/document-tool.d.ts.map +1 -1
- package/dist/api/menu-visibility.d.ts +6 -1
- package/dist/api/menu-visibility.d.ts.map +1 -1
- package/dist/api/page-arrange-tool.d.ts +28 -0
- package/dist/api/page-arrange-tool.d.ts.map +1 -0
- package/dist/api/security-tool.d.ts +21 -0
- package/dist/api/security-tool.d.ts.map +1 -0
- package/dist/api/ui-tool.d.ts +19 -0
- package/dist/api/ui-tool.d.ts.map +1 -1
- package/dist/browser/document-viewer.js +1 -1
- package/dist/browser/document-viewer.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +469 -359
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/dist/tools/AnnotationToolImpl.d.ts +8 -27
- package/dist/tools/AnnotationToolImpl.d.ts.map +1 -1
- package/dist/tools/DigitalSignToolImpl.d.ts.map +1 -1
- package/dist/tools/DocumentToolImpl.d.ts.map +1 -1
- package/dist/tools/PageArrangeToolImpl.d.ts +21 -0
- package/dist/tools/PageArrangeToolImpl.d.ts.map +1 -0
- package/dist/tools/SecurityToolImpl.d.ts +12 -0
- package/dist/tools/SecurityToolImpl.d.ts.map +1 -0
- package/dist/tools/UIToolImpl.d.ts +13 -0
- package/dist/tools/UIToolImpl.d.ts.map +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/viewer/AdapterProtocol.d.ts +3 -1
- package/dist/viewer/AdapterProtocol.d.ts.map +1 -1
- package/dist/viewer/BridgeToolAdapter.d.ts +1 -0
- package/dist/viewer/BridgeToolAdapter.d.ts.map +1 -1
- package/dist/viewer/DocumentSDK.d.ts +10 -4
- package/dist/viewer/DocumentSDK.d.ts.map +1 -1
- package/dist/viewer/ReaderBridgeClient.d.ts +3 -0
- package/dist/viewer/ReaderBridgeClient.d.ts.map +1 -1
- package/dist/viewer/ReaderConfiguration.d.ts +0 -1
- package/dist/viewer/ReaderConfiguration.d.ts.map +1 -1
- package/dist/viewer/ReaderStateStore.d.ts +2 -0
- package/dist/viewer/ReaderStateStore.d.ts.map +1 -1
- package/dist/viewer/SdkCallbackRegistry.d.ts +2 -2
- package/dist/viewer/SdkCallbackRegistry.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api/annotation-tool.ts +257 -140
- package/src/api/callbacks.ts +48 -7
- package/src/api/document-sdk.ts +9 -5
- package/src/api/document-tool.ts +28 -13
- package/src/api/menu-visibility.ts +10 -1
- package/src/api/page-arrange-tool.ts +67 -0
- package/src/api/security-tool.ts +32 -0
- package/src/api/ui-tool.ts +33 -0
- package/src/index.ts +2 -0
- package/src/tools/AnnotationToolImpl.ts +84 -163
- package/src/tools/DigitalSignToolImpl.ts +13 -2
- package/src/tools/DocumentToolImpl.ts +8 -4
- package/src/tools/PageArrangeToolImpl.ts +99 -0
- package/src/tools/SecurityToolImpl.ts +48 -0
- package/src/tools/UIToolImpl.ts +98 -12
- package/src/tools/index.ts +2 -1
- package/src/viewer/AdapterProtocol.ts +4 -0
- package/src/viewer/BridgeToolAdapter.ts +11 -2
- package/src/viewer/DocumentSDK.ts +120 -30
- package/src/viewer/ReaderBridgeClient.ts +9 -0
- package/src/viewer/ReaderConfiguration.ts +0 -2
- package/src/viewer/ReaderStateStore.ts +13 -1
- package/src/viewer/SdkCallbackRegistry.ts +75 -6
- package/dist/tools/Phase1ToolPlaceholder.d.ts +0 -5
- package/dist/tools/Phase1ToolPlaceholder.d.ts.map +0 -1
- package/src/tools/Phase1ToolPlaceholder.ts +0 -35
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AnnotationEventCallback,
|
|
3
|
+
AnnotationEventPayload,
|
|
3
4
|
DigitalSignatureRetrieveCallback,
|
|
4
5
|
DocumentClosedCallback,
|
|
6
|
+
DocumentCloseResult,
|
|
7
|
+
DocumentOpenedCallback,
|
|
8
|
+
DocumentOpenResult,
|
|
9
|
+
DocumentReaderStatus,
|
|
10
|
+
DocumentSaveResult,
|
|
5
11
|
DocumentSavedCallback,
|
|
6
12
|
PageChangeCallback,
|
|
7
13
|
PageModeChangeCallback,
|
|
@@ -9,6 +15,62 @@ import type {
|
|
|
9
15
|
import type { IDigitalAnnotationInfo } from '../api/annotation-tool';
|
|
10
16
|
import type { ISignServerAuthorization, SignServerAuthCallback } from '../api/sign-server';
|
|
11
17
|
|
|
18
|
+
const normalizeAnnotationEventPayload = (payload: unknown): AnnotationEventPayload | undefined => {
|
|
19
|
+
return typeof payload === 'object' && payload !== null && !Array.isArray(payload)
|
|
20
|
+
? (payload as AnnotationEventPayload)
|
|
21
|
+
: undefined;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const isRecord = (value: unknown): value is Record<string, unknown> => {
|
|
25
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const normalizeDocumentReaderStatus = (value: unknown): DocumentReaderStatus | undefined => {
|
|
29
|
+
if (!isRecord(value)) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const state: DocumentReaderStatus = {};
|
|
34
|
+
if (typeof value.currentPage === 'number') {
|
|
35
|
+
state.currentPage = value.currentPage;
|
|
36
|
+
}
|
|
37
|
+
if (typeof value.documentType === 'string') {
|
|
38
|
+
state.documentType = value.documentType;
|
|
39
|
+
}
|
|
40
|
+
if (typeof value.totalPages === 'number') {
|
|
41
|
+
state.totalPages = value.totalPages;
|
|
42
|
+
} else if (typeof value.pageCount === 'number') {
|
|
43
|
+
state.totalPages = value.pageCount;
|
|
44
|
+
}
|
|
45
|
+
if (typeof value.zoomLevel === 'number') {
|
|
46
|
+
state.zoomLevel = value.zoomLevel;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return Object.keys(state).length > 0 ? state : undefined;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const normalizeDocumentOpenResult = (payload: unknown): DocumentOpenResult => {
|
|
53
|
+
if (!isRecord(payload)) {
|
|
54
|
+
return {
|
|
55
|
+
success: true,
|
|
56
|
+
status: 'ok',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const nestedState = normalizeDocumentReaderStatus(payload.state);
|
|
61
|
+
const payloadState = normalizeDocumentReaderStatus(payload);
|
|
62
|
+
const error = typeof payload.error === 'string' ? payload.error : undefined;
|
|
63
|
+
const success = typeof payload.success === 'boolean' ? payload.success : !error;
|
|
64
|
+
const status = typeof payload.status === 'string' ? payload.status : success ? 'ok' : 'error';
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
success,
|
|
68
|
+
status,
|
|
69
|
+
error,
|
|
70
|
+
state: nestedState ?? payloadState,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
12
74
|
export class SdkCallbackRegistry {
|
|
13
75
|
readonly annotationEvents: AnnotationEventCallback[] = [];
|
|
14
76
|
readonly annotationPersist: Array<(event: unknown) => void> = [];
|
|
@@ -18,7 +80,7 @@ export class SdkCallbackRegistry {
|
|
|
18
80
|
readonly digitalSignatureParse: DigitalSignatureRetrieveCallback[] = [];
|
|
19
81
|
readonly digitalSignatureRetrieve: DigitalSignatureRetrieveCallback[] = [];
|
|
20
82
|
readonly documentClosed: DocumentClosedCallback[] = [];
|
|
21
|
-
readonly documentOpened:
|
|
83
|
+
readonly documentOpened: DocumentOpenedCallback[] = [];
|
|
22
84
|
readonly documentSaved: DocumentSavedCallback[] = [];
|
|
23
85
|
readonly pageChange: PageChangeCallback[] = [];
|
|
24
86
|
readonly pageModeChange: PageModeChangeCallback[] = [];
|
|
@@ -27,14 +89,18 @@ export class SdkCallbackRegistry {
|
|
|
27
89
|
emit(event: string, payload: unknown): void {
|
|
28
90
|
switch (event) {
|
|
29
91
|
case 'documentOpened':
|
|
30
|
-
case 'documentLoaded':
|
|
31
|
-
|
|
92
|
+
case 'documentLoaded': {
|
|
93
|
+
const result = normalizeDocumentOpenResult(payload);
|
|
94
|
+
this.documentOpened.forEach((callback) =>
|
|
95
|
+
callback(result.status ?? 'ok', result.error ?? '', result),
|
|
96
|
+
);
|
|
32
97
|
return;
|
|
98
|
+
}
|
|
33
99
|
case 'documentSaved':
|
|
34
|
-
this.documentSaved.forEach((callback) => callback(payload));
|
|
100
|
+
this.documentSaved.forEach((callback) => callback(payload as DocumentSaveResult));
|
|
35
101
|
return;
|
|
36
102
|
case 'documentClosed':
|
|
37
|
-
this.documentClosed.forEach((callback) => callback(payload));
|
|
103
|
+
this.documentClosed.forEach((callback) => callback(payload as DocumentCloseResult));
|
|
38
104
|
return;
|
|
39
105
|
case 'pageChange': {
|
|
40
106
|
const pagePayload = payload as { pageIndex?: number; pageCount?: number };
|
|
@@ -51,7 +117,10 @@ export class SdkCallbackRegistry {
|
|
|
51
117
|
case 'annotationEvent': {
|
|
52
118
|
const annotationPayload = payload as { event?: string; payload?: unknown };
|
|
53
119
|
this.annotationEvents.forEach((callback) =>
|
|
54
|
-
callback(
|
|
120
|
+
callback(
|
|
121
|
+
annotationPayload.event ?? 'annotationEvent',
|
|
122
|
+
normalizeAnnotationEventPayload(annotationPayload.payload),
|
|
123
|
+
),
|
|
55
124
|
);
|
|
56
125
|
return;
|
|
57
126
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Phase1ToolPlaceholder.d.ts","sourceRoot":"","sources":["../../src/tools/Phase1ToolPlaceholder.ts"],"names":[],"mappings":"AAAA,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAIjD;AAQD,eAAO,MAAM,2BAA2B,GAAI,CAAC,SAAS,MAAM,EAAE,UAAU,MAAM,KAAG,CAqBhF,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export class SDKPhase1NotImplementedError extends Error {
|
|
2
|
-
constructor(toolName: string, methodName: string) {
|
|
3
|
-
super(`[Phase 1] ${toolName}.${methodName} is not implemented yet.`);
|
|
4
|
-
this.name = 'SDKPhase1NotImplementedError';
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const createThrowingMethod = (toolName: string, methodName: string) => {
|
|
9
|
-
return (): never => {
|
|
10
|
-
throw new SDKPhase1NotImplementedError(toolName, methodName);
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const createPhase1ToolPlaceholder = <T extends object>(toolName: string): T => {
|
|
15
|
-
return new Proxy(
|
|
16
|
-
{},
|
|
17
|
-
{
|
|
18
|
-
get: (_target, property): unknown => {
|
|
19
|
-
if (property === 'then') {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (typeof property === 'symbol') {
|
|
24
|
-
if (property === Symbol.toStringTag) {
|
|
25
|
-
return toolName;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return createThrowingMethod(toolName, property);
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
) as T;
|
|
35
|
-
};
|