@embedpdf/engines 1.0.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/pdfium.js ADDED
@@ -0,0 +1,22 @@
1
+ import {
2
+ BitmapFormat,
3
+ PdfiumEngine,
4
+ PdfiumEngineRunner,
5
+ PdfiumErrorCode,
6
+ RenderFlag,
7
+ browserImageDataToBlobConverter,
8
+ readArrayBuffer,
9
+ readString
10
+ } from "./chunk-NDTYBBMQ.js";
11
+ import "./chunk-YZLT3A2D.js";
12
+ export {
13
+ BitmapFormat,
14
+ PdfiumEngine,
15
+ PdfiumEngineRunner,
16
+ PdfiumErrorCode,
17
+ RenderFlag,
18
+ browserImageDataToBlobConverter,
19
+ readArrayBuffer,
20
+ readString
21
+ };
22
+ //# sourceMappingURL=pdfium.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,131 @@
1
+ import { Logger, PdfEngine, PdfEngineMethodName, PdfEngineMethodArgs, TaskReturn, PdfEngineMethodReturnType } from '@embedpdf/models';
2
+
3
+ /**
4
+ * Request body that represent method calls of PdfEngine, it contains the
5
+ * method name and arguments
6
+ */
7
+ type PdfEngineMethodRequestBody = {
8
+ [P in PdfEngineMethodName]: {
9
+ name: P;
10
+ args: PdfEngineMethodArgs<P>;
11
+ };
12
+ }[PdfEngineMethodName];
13
+ /**
14
+ * Response body that represent return value of PdfEngine
15
+ */
16
+ type PdfEngineMethodResponseBody = {
17
+ [P in PdfEngineMethodName]: TaskReturn<PdfEngineMethodReturnType<P>>;
18
+ }[PdfEngineMethodName];
19
+ /**
20
+ * Request that abort the specified task
21
+ */
22
+ interface AbortRequest {
23
+ /**
24
+ * message id
25
+ */
26
+ id: string;
27
+ /**
28
+ * request type
29
+ */
30
+ type: 'AbortRequest';
31
+ }
32
+ /**
33
+ * Request that execute pdf engine method
34
+ */
35
+ interface ExecuteRequest {
36
+ /**
37
+ * message id
38
+ */
39
+ id: string;
40
+ /**
41
+ * request type
42
+ */
43
+ type: 'ExecuteRequest';
44
+ /**
45
+ * request body
46
+ */
47
+ data: PdfEngineMethodRequestBody;
48
+ }
49
+ /**
50
+ * Response that execute pdf engine method
51
+ */
52
+ interface ExecuteResponse {
53
+ /**
54
+ * message id
55
+ */
56
+ id: string;
57
+ /**
58
+ * response type
59
+ */
60
+ type: 'ExecuteResponse';
61
+ /**
62
+ * response body
63
+ */
64
+ data: PdfEngineMethodResponseBody;
65
+ }
66
+ /**
67
+ * Response that indicate engine is ready
68
+ */
69
+ interface ReadyResponse {
70
+ /**
71
+ * message id
72
+ */
73
+ id: string;
74
+ /**
75
+ * response type
76
+ */
77
+ type: 'ReadyResponse';
78
+ }
79
+ /**
80
+ * Request type
81
+ */
82
+ type Request = ExecuteRequest | AbortRequest;
83
+ /**
84
+ * Response type
85
+ */
86
+ type Response = ExecuteResponse | ReadyResponse;
87
+ /**
88
+ * Pdf engine runner, it will execute pdf engine based on the request it received and
89
+ * send back the response with post message
90
+ */
91
+ declare class EngineRunner {
92
+ logger: Logger;
93
+ engine: PdfEngine | undefined;
94
+ /**
95
+ * Create instance of EngineRunnder
96
+ * @param logger - logger instance
97
+ */
98
+ constructor(logger?: Logger);
99
+ /**
100
+ * Listening on post message
101
+ */
102
+ listen(): void;
103
+ /**
104
+ * Handle post message
105
+ */
106
+ handle(evt: MessageEvent<Request>): void;
107
+ /**
108
+ * Send the ready response when pdf engine is ready
109
+ * @returns
110
+ *
111
+ * @protected
112
+ */
113
+ ready(): void;
114
+ /**
115
+ * Execute the request
116
+ * @param request - request that represent the pdf engine call
117
+ * @returns
118
+ *
119
+ * @protected
120
+ */
121
+ execute: (request: ExecuteRequest) => void;
122
+ /**
123
+ * Send back the response
124
+ * @param response - response that needs sent back
125
+ *
126
+ * @protected
127
+ */
128
+ respond(response: Response): void;
129
+ }
130
+
131
+ export { type AbortRequest as A, type ExecuteRequest as E, type PdfEngineMethodRequestBody as P, type ReadyResponse as R, type PdfEngineMethodResponseBody as a, type ExecuteResponse as b, type Request as c, type Response as d, EngineRunner as e };
@@ -0,0 +1,131 @@
1
+ import { Logger, PdfEngine, PdfEngineMethodName, PdfEngineMethodArgs, TaskReturn, PdfEngineMethodReturnType } from '@embedpdf/models';
2
+
3
+ /**
4
+ * Request body that represent method calls of PdfEngine, it contains the
5
+ * method name and arguments
6
+ */
7
+ type PdfEngineMethodRequestBody = {
8
+ [P in PdfEngineMethodName]: {
9
+ name: P;
10
+ args: PdfEngineMethodArgs<P>;
11
+ };
12
+ }[PdfEngineMethodName];
13
+ /**
14
+ * Response body that represent return value of PdfEngine
15
+ */
16
+ type PdfEngineMethodResponseBody = {
17
+ [P in PdfEngineMethodName]: TaskReturn<PdfEngineMethodReturnType<P>>;
18
+ }[PdfEngineMethodName];
19
+ /**
20
+ * Request that abort the specified task
21
+ */
22
+ interface AbortRequest {
23
+ /**
24
+ * message id
25
+ */
26
+ id: string;
27
+ /**
28
+ * request type
29
+ */
30
+ type: 'AbortRequest';
31
+ }
32
+ /**
33
+ * Request that execute pdf engine method
34
+ */
35
+ interface ExecuteRequest {
36
+ /**
37
+ * message id
38
+ */
39
+ id: string;
40
+ /**
41
+ * request type
42
+ */
43
+ type: 'ExecuteRequest';
44
+ /**
45
+ * request body
46
+ */
47
+ data: PdfEngineMethodRequestBody;
48
+ }
49
+ /**
50
+ * Response that execute pdf engine method
51
+ */
52
+ interface ExecuteResponse {
53
+ /**
54
+ * message id
55
+ */
56
+ id: string;
57
+ /**
58
+ * response type
59
+ */
60
+ type: 'ExecuteResponse';
61
+ /**
62
+ * response body
63
+ */
64
+ data: PdfEngineMethodResponseBody;
65
+ }
66
+ /**
67
+ * Response that indicate engine is ready
68
+ */
69
+ interface ReadyResponse {
70
+ /**
71
+ * message id
72
+ */
73
+ id: string;
74
+ /**
75
+ * response type
76
+ */
77
+ type: 'ReadyResponse';
78
+ }
79
+ /**
80
+ * Request type
81
+ */
82
+ type Request = ExecuteRequest | AbortRequest;
83
+ /**
84
+ * Response type
85
+ */
86
+ type Response = ExecuteResponse | ReadyResponse;
87
+ /**
88
+ * Pdf engine runner, it will execute pdf engine based on the request it received and
89
+ * send back the response with post message
90
+ */
91
+ declare class EngineRunner {
92
+ logger: Logger;
93
+ engine: PdfEngine | undefined;
94
+ /**
95
+ * Create instance of EngineRunnder
96
+ * @param logger - logger instance
97
+ */
98
+ constructor(logger?: Logger);
99
+ /**
100
+ * Listening on post message
101
+ */
102
+ listen(): void;
103
+ /**
104
+ * Handle post message
105
+ */
106
+ handle(evt: MessageEvent<Request>): void;
107
+ /**
108
+ * Send the ready response when pdf engine is ready
109
+ * @returns
110
+ *
111
+ * @protected
112
+ */
113
+ ready(): void;
114
+ /**
115
+ * Execute the request
116
+ * @param request - request that represent the pdf engine call
117
+ * @returns
118
+ *
119
+ * @protected
120
+ */
121
+ execute: (request: ExecuteRequest) => void;
122
+ /**
123
+ * Send back the response
124
+ * @param response - response that needs sent back
125
+ *
126
+ * @protected
127
+ */
128
+ respond(response: Response): void;
129
+ }
130
+
131
+ export { type AbortRequest as A, type ExecuteRequest as E, type PdfEngineMethodRequestBody as P, type ReadyResponse as R, type PdfEngineMethodResponseBody as a, type ExecuteResponse as b, type Request as c, type Response as d, EngineRunner as e };