@llamaindex/liteparse-grpc 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/LICENSE +21 -0
- package/README.md +154 -0
- package/dist/client.js +1674 -0
- package/dist/protogen/parser.js +1542 -0
- package/dist/server.js +6224 -0
- package/dist/types/client.d.ts +3 -0
- package/dist/types/protogen/parser.d.ts +267 -0
- package/dist/types/server.d.ts +3 -0
- package/package.json +84 -0
- package/proto/parser.proto +213 -0
|
@@ -0,0 +1,1542 @@
|
|
|
1
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
+
import {
|
|
3
|
+
Client,
|
|
4
|
+
makeGenericClientConstructor
|
|
5
|
+
} from "@grpc/grpc-js";
|
|
6
|
+
const protobufPackage = "parser";
|
|
7
|
+
var ImageMode = /* @__PURE__ */ ((ImageMode2) => {
|
|
8
|
+
ImageMode2[ImageMode2["IMAGE_MODE_UNSPECIFIED"] = 0] = "IMAGE_MODE_UNSPECIFIED";
|
|
9
|
+
ImageMode2[ImageMode2["IMAGE_MODE_OFF"] = 1] = "IMAGE_MODE_OFF";
|
|
10
|
+
ImageMode2[ImageMode2["IMAGE_MODE_PLACEHOLDER"] = 2] = "IMAGE_MODE_PLACEHOLDER";
|
|
11
|
+
ImageMode2[ImageMode2["IMAGE_MODE_EMBED"] = 3] = "IMAGE_MODE_EMBED";
|
|
12
|
+
ImageMode2[ImageMode2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
13
|
+
return ImageMode2;
|
|
14
|
+
})(ImageMode || {});
|
|
15
|
+
function imageModeFromJSON(object) {
|
|
16
|
+
switch (object) {
|
|
17
|
+
case 0:
|
|
18
|
+
case "IMAGE_MODE_UNSPECIFIED":
|
|
19
|
+
return 0 /* IMAGE_MODE_UNSPECIFIED */;
|
|
20
|
+
case 1:
|
|
21
|
+
case "IMAGE_MODE_OFF":
|
|
22
|
+
return 1 /* IMAGE_MODE_OFF */;
|
|
23
|
+
case 2:
|
|
24
|
+
case "IMAGE_MODE_PLACEHOLDER":
|
|
25
|
+
return 2 /* IMAGE_MODE_PLACEHOLDER */;
|
|
26
|
+
case 3:
|
|
27
|
+
case "IMAGE_MODE_EMBED":
|
|
28
|
+
return 3 /* IMAGE_MODE_EMBED */;
|
|
29
|
+
case -1:
|
|
30
|
+
case "UNRECOGNIZED":
|
|
31
|
+
default:
|
|
32
|
+
return -1 /* UNRECOGNIZED */;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function imageModeToJSON(object) {
|
|
36
|
+
switch (object) {
|
|
37
|
+
case 0 /* IMAGE_MODE_UNSPECIFIED */:
|
|
38
|
+
return "IMAGE_MODE_UNSPECIFIED";
|
|
39
|
+
case 1 /* IMAGE_MODE_OFF */:
|
|
40
|
+
return "IMAGE_MODE_OFF";
|
|
41
|
+
case 2 /* IMAGE_MODE_PLACEHOLDER */:
|
|
42
|
+
return "IMAGE_MODE_PLACEHOLDER";
|
|
43
|
+
case 3 /* IMAGE_MODE_EMBED */:
|
|
44
|
+
return "IMAGE_MODE_EMBED";
|
|
45
|
+
case -1 /* UNRECOGNIZED */:
|
|
46
|
+
default:
|
|
47
|
+
return "UNRECOGNIZED";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var OutputFormat = /* @__PURE__ */ ((OutputFormat2) => {
|
|
51
|
+
OutputFormat2[OutputFormat2["OUTPUT_FORMAT_UNSPECIFIED"] = 0] = "OUTPUT_FORMAT_UNSPECIFIED";
|
|
52
|
+
OutputFormat2[OutputFormat2["OUTPUT_FORMAT_JSON"] = 1] = "OUTPUT_FORMAT_JSON";
|
|
53
|
+
OutputFormat2[OutputFormat2["OUTPUT_FORMAT_TEXT"] = 2] = "OUTPUT_FORMAT_TEXT";
|
|
54
|
+
OutputFormat2[OutputFormat2["OUTPUT_FORMAT_MARKDOWN"] = 3] = "OUTPUT_FORMAT_MARKDOWN";
|
|
55
|
+
OutputFormat2[OutputFormat2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
56
|
+
return OutputFormat2;
|
|
57
|
+
})(OutputFormat || {});
|
|
58
|
+
function outputFormatFromJSON(object) {
|
|
59
|
+
switch (object) {
|
|
60
|
+
case 0:
|
|
61
|
+
case "OUTPUT_FORMAT_UNSPECIFIED":
|
|
62
|
+
return 0 /* OUTPUT_FORMAT_UNSPECIFIED */;
|
|
63
|
+
case 1:
|
|
64
|
+
case "OUTPUT_FORMAT_JSON":
|
|
65
|
+
return 1 /* OUTPUT_FORMAT_JSON */;
|
|
66
|
+
case 2:
|
|
67
|
+
case "OUTPUT_FORMAT_TEXT":
|
|
68
|
+
return 2 /* OUTPUT_FORMAT_TEXT */;
|
|
69
|
+
case 3:
|
|
70
|
+
case "OUTPUT_FORMAT_MARKDOWN":
|
|
71
|
+
return 3 /* OUTPUT_FORMAT_MARKDOWN */;
|
|
72
|
+
case -1:
|
|
73
|
+
case "UNRECOGNIZED":
|
|
74
|
+
default:
|
|
75
|
+
return -1 /* UNRECOGNIZED */;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function outputFormatToJSON(object) {
|
|
79
|
+
switch (object) {
|
|
80
|
+
case 0 /* OUTPUT_FORMAT_UNSPECIFIED */:
|
|
81
|
+
return "OUTPUT_FORMAT_UNSPECIFIED";
|
|
82
|
+
case 1 /* OUTPUT_FORMAT_JSON */:
|
|
83
|
+
return "OUTPUT_FORMAT_JSON";
|
|
84
|
+
case 2 /* OUTPUT_FORMAT_TEXT */:
|
|
85
|
+
return "OUTPUT_FORMAT_TEXT";
|
|
86
|
+
case 3 /* OUTPUT_FORMAT_MARKDOWN */:
|
|
87
|
+
return "OUTPUT_FORMAT_MARKDOWN";
|
|
88
|
+
case -1 /* UNRECOGNIZED */:
|
|
89
|
+
default:
|
|
90
|
+
return "UNRECOGNIZED";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function createBaseLiteParseConfig() {
|
|
94
|
+
return {
|
|
95
|
+
ocrLanguage: "",
|
|
96
|
+
ocrEnabled: false,
|
|
97
|
+
ocrServerUrl: void 0,
|
|
98
|
+
ocrServerHeaders: [],
|
|
99
|
+
tessdataPath: void 0,
|
|
100
|
+
maxPages: 0,
|
|
101
|
+
targetPages: void 0,
|
|
102
|
+
dpi: 0,
|
|
103
|
+
outputFormat: 0,
|
|
104
|
+
preserveVerySmallText: false,
|
|
105
|
+
password: void 0,
|
|
106
|
+
quiet: false,
|
|
107
|
+
numWorkers: 0,
|
|
108
|
+
imageMode: 0,
|
|
109
|
+
extractLinks: false,
|
|
110
|
+
ocrFailureFatal: false,
|
|
111
|
+
ocrHedgeDelaysMs: [],
|
|
112
|
+
emitWordBoxes: false
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const LiteParseConfig = {
|
|
116
|
+
encode(message, writer = new BinaryWriter()) {
|
|
117
|
+
if (message.ocrLanguage !== "") {
|
|
118
|
+
writer.uint32(10).string(message.ocrLanguage);
|
|
119
|
+
}
|
|
120
|
+
if (message.ocrEnabled !== false) {
|
|
121
|
+
writer.uint32(16).bool(message.ocrEnabled);
|
|
122
|
+
}
|
|
123
|
+
if (message.ocrServerUrl !== void 0) {
|
|
124
|
+
writer.uint32(26).string(message.ocrServerUrl);
|
|
125
|
+
}
|
|
126
|
+
for (const v of message.ocrServerHeaders) {
|
|
127
|
+
HttpHeader.encode(v, writer.uint32(34).fork()).join();
|
|
128
|
+
}
|
|
129
|
+
if (message.tessdataPath !== void 0) {
|
|
130
|
+
writer.uint32(42).string(message.tessdataPath);
|
|
131
|
+
}
|
|
132
|
+
if (message.maxPages !== 0) {
|
|
133
|
+
writer.uint32(48).uint64(message.maxPages);
|
|
134
|
+
}
|
|
135
|
+
if (message.targetPages !== void 0) {
|
|
136
|
+
writer.uint32(58).string(message.targetPages);
|
|
137
|
+
}
|
|
138
|
+
if (message.dpi !== 0) {
|
|
139
|
+
writer.uint32(69).float(message.dpi);
|
|
140
|
+
}
|
|
141
|
+
if (message.outputFormat !== 0) {
|
|
142
|
+
writer.uint32(72).int32(message.outputFormat);
|
|
143
|
+
}
|
|
144
|
+
if (message.preserveVerySmallText !== false) {
|
|
145
|
+
writer.uint32(80).bool(message.preserveVerySmallText);
|
|
146
|
+
}
|
|
147
|
+
if (message.password !== void 0) {
|
|
148
|
+
writer.uint32(90).string(message.password);
|
|
149
|
+
}
|
|
150
|
+
if (message.quiet !== false) {
|
|
151
|
+
writer.uint32(96).bool(message.quiet);
|
|
152
|
+
}
|
|
153
|
+
if (message.numWorkers !== 0) {
|
|
154
|
+
writer.uint32(104).uint64(message.numWorkers);
|
|
155
|
+
}
|
|
156
|
+
if (message.imageMode !== 0) {
|
|
157
|
+
writer.uint32(112).int32(message.imageMode);
|
|
158
|
+
}
|
|
159
|
+
if (message.extractLinks !== false) {
|
|
160
|
+
writer.uint32(120).bool(message.extractLinks);
|
|
161
|
+
}
|
|
162
|
+
if (message.ocrFailureFatal !== false) {
|
|
163
|
+
writer.uint32(128).bool(message.ocrFailureFatal);
|
|
164
|
+
}
|
|
165
|
+
writer.uint32(138).fork();
|
|
166
|
+
for (const v of message.ocrHedgeDelaysMs) {
|
|
167
|
+
writer.uint64(v);
|
|
168
|
+
}
|
|
169
|
+
writer.join();
|
|
170
|
+
if (message.emitWordBoxes !== false) {
|
|
171
|
+
writer.uint32(144).bool(message.emitWordBoxes);
|
|
172
|
+
}
|
|
173
|
+
return writer;
|
|
174
|
+
},
|
|
175
|
+
decode(input, length) {
|
|
176
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
177
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
178
|
+
const message = createBaseLiteParseConfig();
|
|
179
|
+
while (reader.pos < end) {
|
|
180
|
+
const tag = reader.uint32();
|
|
181
|
+
switch (tag >>> 3) {
|
|
182
|
+
case 1: {
|
|
183
|
+
if (tag !== 10) {
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
message.ocrLanguage = reader.string();
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
case 2: {
|
|
190
|
+
if (tag !== 16) {
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
message.ocrEnabled = reader.bool();
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
case 3: {
|
|
197
|
+
if (tag !== 26) {
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
message.ocrServerUrl = reader.string();
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
case 4: {
|
|
204
|
+
if (tag !== 34) {
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
message.ocrServerHeaders.push(
|
|
208
|
+
HttpHeader.decode(reader, reader.uint32())
|
|
209
|
+
);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
case 5: {
|
|
213
|
+
if (tag !== 42) {
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
message.tessdataPath = reader.string();
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
case 6: {
|
|
220
|
+
if (tag !== 48) {
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
message.maxPages = longToNumber(reader.uint64());
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
case 7: {
|
|
227
|
+
if (tag !== 58) {
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
message.targetPages = reader.string();
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
case 8: {
|
|
234
|
+
if (tag !== 69) {
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
message.dpi = reader.float();
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
case 9: {
|
|
241
|
+
if (tag !== 72) {
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
message.outputFormat = reader.int32();
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
case 10: {
|
|
248
|
+
if (tag !== 80) {
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
message.preserveVerySmallText = reader.bool();
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
case 11: {
|
|
255
|
+
if (tag !== 90) {
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
message.password = reader.string();
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
case 12: {
|
|
262
|
+
if (tag !== 96) {
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
message.quiet = reader.bool();
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
case 13: {
|
|
269
|
+
if (tag !== 104) {
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
message.numWorkers = longToNumber(reader.uint64());
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
case 14: {
|
|
276
|
+
if (tag !== 112) {
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
message.imageMode = reader.int32();
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
case 15: {
|
|
283
|
+
if (tag !== 120) {
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
message.extractLinks = reader.bool();
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
case 16: {
|
|
290
|
+
if (tag !== 128) {
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
message.ocrFailureFatal = reader.bool();
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
case 17: {
|
|
297
|
+
if (tag === 136) {
|
|
298
|
+
message.ocrHedgeDelaysMs.push(longToNumber(reader.uint64()));
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (tag === 138) {
|
|
302
|
+
const end2 = reader.uint32() + reader.pos;
|
|
303
|
+
while (reader.pos < end2) {
|
|
304
|
+
message.ocrHedgeDelaysMs.push(longToNumber(reader.uint64()));
|
|
305
|
+
}
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
case 18: {
|
|
311
|
+
if (tag !== 144) {
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
message.emitWordBoxes = reader.bool();
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
reader.skip(tag & 7);
|
|
322
|
+
}
|
|
323
|
+
return message;
|
|
324
|
+
},
|
|
325
|
+
fromJSON(object) {
|
|
326
|
+
return {
|
|
327
|
+
ocrLanguage: isSet(object.ocrLanguage) ? globalThis.String(object.ocrLanguage) : isSet(object.ocr_language) ? globalThis.String(object.ocr_language) : "",
|
|
328
|
+
ocrEnabled: isSet(object.ocrEnabled) ? globalThis.Boolean(object.ocrEnabled) : isSet(object.ocr_enabled) ? globalThis.Boolean(object.ocr_enabled) : false,
|
|
329
|
+
ocrServerUrl: isSet(object.ocrServerUrl) ? globalThis.String(object.ocrServerUrl) : isSet(object.ocr_server_url) ? globalThis.String(object.ocr_server_url) : void 0,
|
|
330
|
+
ocrServerHeaders: globalThis.Array.isArray(object?.ocrServerHeaders) ? object.ocrServerHeaders.map((e) => HttpHeader.fromJSON(e)) : globalThis.Array.isArray(object?.ocr_server_headers) ? object.ocr_server_headers.map((e) => HttpHeader.fromJSON(e)) : [],
|
|
331
|
+
tessdataPath: isSet(object.tessdataPath) ? globalThis.String(object.tessdataPath) : isSet(object.tessdata_path) ? globalThis.String(object.tessdata_path) : void 0,
|
|
332
|
+
maxPages: isSet(object.maxPages) ? globalThis.Number(object.maxPages) : isSet(object.max_pages) ? globalThis.Number(object.max_pages) : 0,
|
|
333
|
+
targetPages: isSet(object.targetPages) ? globalThis.String(object.targetPages) : isSet(object.target_pages) ? globalThis.String(object.target_pages) : void 0,
|
|
334
|
+
dpi: isSet(object.dpi) ? globalThis.Number(object.dpi) : 0,
|
|
335
|
+
outputFormat: isSet(object.outputFormat) ? outputFormatFromJSON(object.outputFormat) : isSet(object.output_format) ? outputFormatFromJSON(object.output_format) : 0,
|
|
336
|
+
preserveVerySmallText: isSet(object.preserveVerySmallText) ? globalThis.Boolean(object.preserveVerySmallText) : isSet(object.preserve_very_small_text) ? globalThis.Boolean(object.preserve_very_small_text) : false,
|
|
337
|
+
password: isSet(object.password) ? globalThis.String(object.password) : void 0,
|
|
338
|
+
quiet: isSet(object.quiet) ? globalThis.Boolean(object.quiet) : false,
|
|
339
|
+
numWorkers: isSet(object.numWorkers) ? globalThis.Number(object.numWorkers) : isSet(object.num_workers) ? globalThis.Number(object.num_workers) : 0,
|
|
340
|
+
imageMode: isSet(object.imageMode) ? imageModeFromJSON(object.imageMode) : isSet(object.image_mode) ? imageModeFromJSON(object.image_mode) : 0,
|
|
341
|
+
extractLinks: isSet(object.extractLinks) ? globalThis.Boolean(object.extractLinks) : isSet(object.extract_links) ? globalThis.Boolean(object.extract_links) : false,
|
|
342
|
+
ocrFailureFatal: isSet(object.ocrFailureFatal) ? globalThis.Boolean(object.ocrFailureFatal) : isSet(object.ocr_failure_fatal) ? globalThis.Boolean(object.ocr_failure_fatal) : false,
|
|
343
|
+
ocrHedgeDelaysMs: globalThis.Array.isArray(object?.ocrHedgeDelaysMs) ? object.ocrHedgeDelaysMs.map((e) => globalThis.Number(e)) : globalThis.Array.isArray(object?.ocr_hedge_delays_ms) ? object.ocr_hedge_delays_ms.map((e) => globalThis.Number(e)) : [],
|
|
344
|
+
emitWordBoxes: isSet(object.emitWordBoxes) ? globalThis.Boolean(object.emitWordBoxes) : isSet(object.emit_word_boxes) ? globalThis.Boolean(object.emit_word_boxes) : false
|
|
345
|
+
};
|
|
346
|
+
},
|
|
347
|
+
toJSON(message) {
|
|
348
|
+
const obj = {};
|
|
349
|
+
if (message.ocrLanguage !== "") {
|
|
350
|
+
obj.ocrLanguage = message.ocrLanguage;
|
|
351
|
+
}
|
|
352
|
+
if (message.ocrEnabled !== false) {
|
|
353
|
+
obj.ocrEnabled = message.ocrEnabled;
|
|
354
|
+
}
|
|
355
|
+
if (message.ocrServerUrl !== void 0) {
|
|
356
|
+
obj.ocrServerUrl = message.ocrServerUrl;
|
|
357
|
+
}
|
|
358
|
+
if (message.ocrServerHeaders?.length) {
|
|
359
|
+
obj.ocrServerHeaders = message.ocrServerHeaders.map(
|
|
360
|
+
(e) => HttpHeader.toJSON(e)
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
if (message.tessdataPath !== void 0) {
|
|
364
|
+
obj.tessdataPath = message.tessdataPath;
|
|
365
|
+
}
|
|
366
|
+
if (message.maxPages !== 0) {
|
|
367
|
+
obj.maxPages = Math.round(message.maxPages);
|
|
368
|
+
}
|
|
369
|
+
if (message.targetPages !== void 0) {
|
|
370
|
+
obj.targetPages = message.targetPages;
|
|
371
|
+
}
|
|
372
|
+
if (message.dpi !== 0) {
|
|
373
|
+
obj.dpi = message.dpi;
|
|
374
|
+
}
|
|
375
|
+
if (message.outputFormat !== 0) {
|
|
376
|
+
obj.outputFormat = outputFormatToJSON(message.outputFormat);
|
|
377
|
+
}
|
|
378
|
+
if (message.preserveVerySmallText !== false) {
|
|
379
|
+
obj.preserveVerySmallText = message.preserveVerySmallText;
|
|
380
|
+
}
|
|
381
|
+
if (message.password !== void 0) {
|
|
382
|
+
obj.password = message.password;
|
|
383
|
+
}
|
|
384
|
+
if (message.quiet !== false) {
|
|
385
|
+
obj.quiet = message.quiet;
|
|
386
|
+
}
|
|
387
|
+
if (message.numWorkers !== 0) {
|
|
388
|
+
obj.numWorkers = Math.round(message.numWorkers);
|
|
389
|
+
}
|
|
390
|
+
if (message.imageMode !== 0) {
|
|
391
|
+
obj.imageMode = imageModeToJSON(message.imageMode);
|
|
392
|
+
}
|
|
393
|
+
if (message.extractLinks !== false) {
|
|
394
|
+
obj.extractLinks = message.extractLinks;
|
|
395
|
+
}
|
|
396
|
+
if (message.ocrFailureFatal !== false) {
|
|
397
|
+
obj.ocrFailureFatal = message.ocrFailureFatal;
|
|
398
|
+
}
|
|
399
|
+
if (message.ocrHedgeDelaysMs?.length) {
|
|
400
|
+
obj.ocrHedgeDelaysMs = message.ocrHedgeDelaysMs.map((e) => Math.round(e));
|
|
401
|
+
}
|
|
402
|
+
if (message.emitWordBoxes !== false) {
|
|
403
|
+
obj.emitWordBoxes = message.emitWordBoxes;
|
|
404
|
+
}
|
|
405
|
+
return obj;
|
|
406
|
+
},
|
|
407
|
+
create(base) {
|
|
408
|
+
return LiteParseConfig.fromPartial(base ?? {});
|
|
409
|
+
},
|
|
410
|
+
fromPartial(object) {
|
|
411
|
+
const message = createBaseLiteParseConfig();
|
|
412
|
+
message.ocrLanguage = object.ocrLanguage ?? "";
|
|
413
|
+
message.ocrEnabled = object.ocrEnabled ?? false;
|
|
414
|
+
message.ocrServerUrl = object.ocrServerUrl ?? void 0;
|
|
415
|
+
message.ocrServerHeaders = object.ocrServerHeaders?.map((e) => HttpHeader.fromPartial(e)) || [];
|
|
416
|
+
message.tessdataPath = object.tessdataPath ?? void 0;
|
|
417
|
+
message.maxPages = object.maxPages ?? 0;
|
|
418
|
+
message.targetPages = object.targetPages ?? void 0;
|
|
419
|
+
message.dpi = object.dpi ?? 0;
|
|
420
|
+
message.outputFormat = object.outputFormat ?? 0;
|
|
421
|
+
message.preserveVerySmallText = object.preserveVerySmallText ?? false;
|
|
422
|
+
message.password = object.password ?? void 0;
|
|
423
|
+
message.quiet = object.quiet ?? false;
|
|
424
|
+
message.numWorkers = object.numWorkers ?? 0;
|
|
425
|
+
message.imageMode = object.imageMode ?? 0;
|
|
426
|
+
message.extractLinks = object.extractLinks ?? false;
|
|
427
|
+
message.ocrFailureFatal = object.ocrFailureFatal ?? false;
|
|
428
|
+
message.ocrHedgeDelaysMs = object.ocrHedgeDelaysMs?.map((e) => e) || [];
|
|
429
|
+
message.emitWordBoxes = object.emitWordBoxes ?? false;
|
|
430
|
+
return message;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
function createBaseHttpHeader() {
|
|
434
|
+
return { name: "", value: "" };
|
|
435
|
+
}
|
|
436
|
+
const HttpHeader = {
|
|
437
|
+
encode(message, writer = new BinaryWriter()) {
|
|
438
|
+
if (message.name !== "") {
|
|
439
|
+
writer.uint32(10).string(message.name);
|
|
440
|
+
}
|
|
441
|
+
if (message.value !== "") {
|
|
442
|
+
writer.uint32(18).string(message.value);
|
|
443
|
+
}
|
|
444
|
+
return writer;
|
|
445
|
+
},
|
|
446
|
+
decode(input, length) {
|
|
447
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
448
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
449
|
+
const message = createBaseHttpHeader();
|
|
450
|
+
while (reader.pos < end) {
|
|
451
|
+
const tag = reader.uint32();
|
|
452
|
+
switch (tag >>> 3) {
|
|
453
|
+
case 1: {
|
|
454
|
+
if (tag !== 10) {
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
message.name = reader.string();
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
case 2: {
|
|
461
|
+
if (tag !== 18) {
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
message.value = reader.string();
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
reader.skip(tag & 7);
|
|
472
|
+
}
|
|
473
|
+
return message;
|
|
474
|
+
},
|
|
475
|
+
fromJSON(object) {
|
|
476
|
+
return {
|
|
477
|
+
name: isSet(object.name) ? globalThis.String(object.name) : "",
|
|
478
|
+
value: isSet(object.value) ? globalThis.String(object.value) : ""
|
|
479
|
+
};
|
|
480
|
+
},
|
|
481
|
+
toJSON(message) {
|
|
482
|
+
const obj = {};
|
|
483
|
+
if (message.name !== "") {
|
|
484
|
+
obj.name = message.name;
|
|
485
|
+
}
|
|
486
|
+
if (message.value !== "") {
|
|
487
|
+
obj.value = message.value;
|
|
488
|
+
}
|
|
489
|
+
return obj;
|
|
490
|
+
},
|
|
491
|
+
create(base) {
|
|
492
|
+
return HttpHeader.fromPartial(base ?? {});
|
|
493
|
+
},
|
|
494
|
+
fromPartial(object) {
|
|
495
|
+
const message = createBaseHttpHeader();
|
|
496
|
+
message.name = object.name ?? "";
|
|
497
|
+
message.value = object.value ?? "";
|
|
498
|
+
return message;
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
function createBaseParseRequest() {
|
|
502
|
+
return { file: Buffer.alloc(0), config: void 0 };
|
|
503
|
+
}
|
|
504
|
+
const ParseRequest = {
|
|
505
|
+
encode(message, writer = new BinaryWriter()) {
|
|
506
|
+
if (message.file.length !== 0) {
|
|
507
|
+
writer.uint32(10).bytes(message.file);
|
|
508
|
+
}
|
|
509
|
+
if (message.config !== void 0) {
|
|
510
|
+
LiteParseConfig.encode(message.config, writer.uint32(18).fork()).join();
|
|
511
|
+
}
|
|
512
|
+
return writer;
|
|
513
|
+
},
|
|
514
|
+
decode(input, length) {
|
|
515
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
516
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
517
|
+
const message = createBaseParseRequest();
|
|
518
|
+
while (reader.pos < end) {
|
|
519
|
+
const tag = reader.uint32();
|
|
520
|
+
switch (tag >>> 3) {
|
|
521
|
+
case 1: {
|
|
522
|
+
if (tag !== 10) {
|
|
523
|
+
break;
|
|
524
|
+
}
|
|
525
|
+
message.file = Buffer.from(reader.bytes());
|
|
526
|
+
continue;
|
|
527
|
+
}
|
|
528
|
+
case 2: {
|
|
529
|
+
if (tag !== 18) {
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
message.config = LiteParseConfig.decode(reader, reader.uint32());
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
reader.skip(tag & 7);
|
|
540
|
+
}
|
|
541
|
+
return message;
|
|
542
|
+
},
|
|
543
|
+
fromJSON(object) {
|
|
544
|
+
return {
|
|
545
|
+
file: isSet(object.file) ? Buffer.from(bytesFromBase64(object.file)) : Buffer.alloc(0),
|
|
546
|
+
config: isSet(object.config) ? LiteParseConfig.fromJSON(object.config) : void 0
|
|
547
|
+
};
|
|
548
|
+
},
|
|
549
|
+
toJSON(message) {
|
|
550
|
+
const obj = {};
|
|
551
|
+
if (message.file.length !== 0) {
|
|
552
|
+
obj.file = base64FromBytes(message.file);
|
|
553
|
+
}
|
|
554
|
+
if (message.config !== void 0) {
|
|
555
|
+
obj.config = LiteParseConfig.toJSON(message.config);
|
|
556
|
+
}
|
|
557
|
+
return obj;
|
|
558
|
+
},
|
|
559
|
+
create(base) {
|
|
560
|
+
return ParseRequest.fromPartial(base ?? {});
|
|
561
|
+
},
|
|
562
|
+
fromPartial(object) {
|
|
563
|
+
const message = createBaseParseRequest();
|
|
564
|
+
message.file = object.file ?? Buffer.alloc(0);
|
|
565
|
+
message.config = object.config !== void 0 && object.config !== null ? LiteParseConfig.fromPartial(object.config) : void 0;
|
|
566
|
+
return message;
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
function createBaseScreenshotRequest() {
|
|
570
|
+
return { file: Buffer.alloc(0), config: void 0 };
|
|
571
|
+
}
|
|
572
|
+
const ScreenshotRequest = {
|
|
573
|
+
encode(message, writer = new BinaryWriter()) {
|
|
574
|
+
if (message.file.length !== 0) {
|
|
575
|
+
writer.uint32(10).bytes(message.file);
|
|
576
|
+
}
|
|
577
|
+
if (message.config !== void 0) {
|
|
578
|
+
LiteParseConfig.encode(message.config, writer.uint32(18).fork()).join();
|
|
579
|
+
}
|
|
580
|
+
return writer;
|
|
581
|
+
},
|
|
582
|
+
decode(input, length) {
|
|
583
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
584
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
585
|
+
const message = createBaseScreenshotRequest();
|
|
586
|
+
while (reader.pos < end) {
|
|
587
|
+
const tag = reader.uint32();
|
|
588
|
+
switch (tag >>> 3) {
|
|
589
|
+
case 1: {
|
|
590
|
+
if (tag !== 10) {
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
message.file = Buffer.from(reader.bytes());
|
|
594
|
+
continue;
|
|
595
|
+
}
|
|
596
|
+
case 2: {
|
|
597
|
+
if (tag !== 18) {
|
|
598
|
+
break;
|
|
599
|
+
}
|
|
600
|
+
message.config = LiteParseConfig.decode(reader, reader.uint32());
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
605
|
+
break;
|
|
606
|
+
}
|
|
607
|
+
reader.skip(tag & 7);
|
|
608
|
+
}
|
|
609
|
+
return message;
|
|
610
|
+
},
|
|
611
|
+
fromJSON(object) {
|
|
612
|
+
return {
|
|
613
|
+
file: isSet(object.file) ? Buffer.from(bytesFromBase64(object.file)) : Buffer.alloc(0),
|
|
614
|
+
config: isSet(object.config) ? LiteParseConfig.fromJSON(object.config) : void 0
|
|
615
|
+
};
|
|
616
|
+
},
|
|
617
|
+
toJSON(message) {
|
|
618
|
+
const obj = {};
|
|
619
|
+
if (message.file.length !== 0) {
|
|
620
|
+
obj.file = base64FromBytes(message.file);
|
|
621
|
+
}
|
|
622
|
+
if (message.config !== void 0) {
|
|
623
|
+
obj.config = LiteParseConfig.toJSON(message.config);
|
|
624
|
+
}
|
|
625
|
+
return obj;
|
|
626
|
+
},
|
|
627
|
+
create(base) {
|
|
628
|
+
return ScreenshotRequest.fromPartial(base ?? {});
|
|
629
|
+
},
|
|
630
|
+
fromPartial(object) {
|
|
631
|
+
const message = createBaseScreenshotRequest();
|
|
632
|
+
message.file = object.file ?? Buffer.alloc(0);
|
|
633
|
+
message.config = object.config !== void 0 && object.config !== null ? LiteParseConfig.fromPartial(object.config) : void 0;
|
|
634
|
+
return message;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
function createBaseTextItem() {
|
|
638
|
+
return { text: "", x: 0, y: 0, width: 0, height: 0 };
|
|
639
|
+
}
|
|
640
|
+
const TextItem = {
|
|
641
|
+
encode(message, writer = new BinaryWriter()) {
|
|
642
|
+
if (message.text !== "") {
|
|
643
|
+
writer.uint32(10).string(message.text);
|
|
644
|
+
}
|
|
645
|
+
if (message.x !== 0) {
|
|
646
|
+
writer.uint32(21).float(message.x);
|
|
647
|
+
}
|
|
648
|
+
if (message.y !== 0) {
|
|
649
|
+
writer.uint32(29).float(message.y);
|
|
650
|
+
}
|
|
651
|
+
if (message.width !== 0) {
|
|
652
|
+
writer.uint32(37).float(message.width);
|
|
653
|
+
}
|
|
654
|
+
if (message.height !== 0) {
|
|
655
|
+
writer.uint32(45).float(message.height);
|
|
656
|
+
}
|
|
657
|
+
return writer;
|
|
658
|
+
},
|
|
659
|
+
decode(input, length) {
|
|
660
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
661
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
662
|
+
const message = createBaseTextItem();
|
|
663
|
+
while (reader.pos < end) {
|
|
664
|
+
const tag = reader.uint32();
|
|
665
|
+
switch (tag >>> 3) {
|
|
666
|
+
case 1: {
|
|
667
|
+
if (tag !== 10) {
|
|
668
|
+
break;
|
|
669
|
+
}
|
|
670
|
+
message.text = reader.string();
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
case 2: {
|
|
674
|
+
if (tag !== 21) {
|
|
675
|
+
break;
|
|
676
|
+
}
|
|
677
|
+
message.x = reader.float();
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
case 3: {
|
|
681
|
+
if (tag !== 29) {
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
message.y = reader.float();
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
case 4: {
|
|
688
|
+
if (tag !== 37) {
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
message.width = reader.float();
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
case 5: {
|
|
695
|
+
if (tag !== 45) {
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
message.height = reader.float();
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
703
|
+
break;
|
|
704
|
+
}
|
|
705
|
+
reader.skip(tag & 7);
|
|
706
|
+
}
|
|
707
|
+
return message;
|
|
708
|
+
},
|
|
709
|
+
fromJSON(object) {
|
|
710
|
+
return {
|
|
711
|
+
text: isSet(object.text) ? globalThis.String(object.text) : "",
|
|
712
|
+
x: isSet(object.x) ? globalThis.Number(object.x) : 0,
|
|
713
|
+
y: isSet(object.y) ? globalThis.Number(object.y) : 0,
|
|
714
|
+
width: isSet(object.width) ? globalThis.Number(object.width) : 0,
|
|
715
|
+
height: isSet(object.height) ? globalThis.Number(object.height) : 0
|
|
716
|
+
};
|
|
717
|
+
},
|
|
718
|
+
toJSON(message) {
|
|
719
|
+
const obj = {};
|
|
720
|
+
if (message.text !== "") {
|
|
721
|
+
obj.text = message.text;
|
|
722
|
+
}
|
|
723
|
+
if (message.x !== 0) {
|
|
724
|
+
obj.x = message.x;
|
|
725
|
+
}
|
|
726
|
+
if (message.y !== 0) {
|
|
727
|
+
obj.y = message.y;
|
|
728
|
+
}
|
|
729
|
+
if (message.width !== 0) {
|
|
730
|
+
obj.width = message.width;
|
|
731
|
+
}
|
|
732
|
+
if (message.height !== 0) {
|
|
733
|
+
obj.height = message.height;
|
|
734
|
+
}
|
|
735
|
+
return obj;
|
|
736
|
+
},
|
|
737
|
+
create(base) {
|
|
738
|
+
return TextItem.fromPartial(base ?? {});
|
|
739
|
+
},
|
|
740
|
+
fromPartial(object) {
|
|
741
|
+
const message = createBaseTextItem();
|
|
742
|
+
message.text = object.text ?? "";
|
|
743
|
+
message.x = object.x ?? 0;
|
|
744
|
+
message.y = object.y ?? 0;
|
|
745
|
+
message.width = object.width ?? 0;
|
|
746
|
+
message.height = object.height ?? 0;
|
|
747
|
+
return message;
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
function createBaseParsedPage() {
|
|
751
|
+
return { pageNumber: 0, pageWidth: 0, pageHeight: 0, textItems: [] };
|
|
752
|
+
}
|
|
753
|
+
const ParsedPage = {
|
|
754
|
+
encode(message, writer = new BinaryWriter()) {
|
|
755
|
+
if (message.pageNumber !== 0) {
|
|
756
|
+
writer.uint32(8).uint32(message.pageNumber);
|
|
757
|
+
}
|
|
758
|
+
if (message.pageWidth !== 0) {
|
|
759
|
+
writer.uint32(21).float(message.pageWidth);
|
|
760
|
+
}
|
|
761
|
+
if (message.pageHeight !== 0) {
|
|
762
|
+
writer.uint32(29).float(message.pageHeight);
|
|
763
|
+
}
|
|
764
|
+
for (const v of message.textItems) {
|
|
765
|
+
TextItem.encode(v, writer.uint32(34).fork()).join();
|
|
766
|
+
}
|
|
767
|
+
return writer;
|
|
768
|
+
},
|
|
769
|
+
decode(input, length) {
|
|
770
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
771
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
772
|
+
const message = createBaseParsedPage();
|
|
773
|
+
while (reader.pos < end) {
|
|
774
|
+
const tag = reader.uint32();
|
|
775
|
+
switch (tag >>> 3) {
|
|
776
|
+
case 1: {
|
|
777
|
+
if (tag !== 8) {
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
message.pageNumber = reader.uint32();
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
case 2: {
|
|
784
|
+
if (tag !== 21) {
|
|
785
|
+
break;
|
|
786
|
+
}
|
|
787
|
+
message.pageWidth = reader.float();
|
|
788
|
+
continue;
|
|
789
|
+
}
|
|
790
|
+
case 3: {
|
|
791
|
+
if (tag !== 29) {
|
|
792
|
+
break;
|
|
793
|
+
}
|
|
794
|
+
message.pageHeight = reader.float();
|
|
795
|
+
continue;
|
|
796
|
+
}
|
|
797
|
+
case 4: {
|
|
798
|
+
if (tag !== 34) {
|
|
799
|
+
break;
|
|
800
|
+
}
|
|
801
|
+
message.textItems.push(TextItem.decode(reader, reader.uint32()));
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
808
|
+
reader.skip(tag & 7);
|
|
809
|
+
}
|
|
810
|
+
return message;
|
|
811
|
+
},
|
|
812
|
+
fromJSON(object) {
|
|
813
|
+
return {
|
|
814
|
+
pageNumber: isSet(object.pageNumber) ? globalThis.Number(object.pageNumber) : isSet(object.page_number) ? globalThis.Number(object.page_number) : 0,
|
|
815
|
+
pageWidth: isSet(object.pageWidth) ? globalThis.Number(object.pageWidth) : isSet(object.page_width) ? globalThis.Number(object.page_width) : 0,
|
|
816
|
+
pageHeight: isSet(object.pageHeight) ? globalThis.Number(object.pageHeight) : isSet(object.page_height) ? globalThis.Number(object.page_height) : 0,
|
|
817
|
+
textItems: globalThis.Array.isArray(object?.textItems) ? object.textItems.map((e) => TextItem.fromJSON(e)) : globalThis.Array.isArray(object?.text_items) ? object.text_items.map((e) => TextItem.fromJSON(e)) : []
|
|
818
|
+
};
|
|
819
|
+
},
|
|
820
|
+
toJSON(message) {
|
|
821
|
+
const obj = {};
|
|
822
|
+
if (message.pageNumber !== 0) {
|
|
823
|
+
obj.pageNumber = Math.round(message.pageNumber);
|
|
824
|
+
}
|
|
825
|
+
if (message.pageWidth !== 0) {
|
|
826
|
+
obj.pageWidth = message.pageWidth;
|
|
827
|
+
}
|
|
828
|
+
if (message.pageHeight !== 0) {
|
|
829
|
+
obj.pageHeight = message.pageHeight;
|
|
830
|
+
}
|
|
831
|
+
if (message.textItems?.length) {
|
|
832
|
+
obj.textItems = message.textItems.map((e) => TextItem.toJSON(e));
|
|
833
|
+
}
|
|
834
|
+
return obj;
|
|
835
|
+
},
|
|
836
|
+
create(base) {
|
|
837
|
+
return ParsedPage.fromPartial(base ?? {});
|
|
838
|
+
},
|
|
839
|
+
fromPartial(object) {
|
|
840
|
+
const message = createBaseParsedPage();
|
|
841
|
+
message.pageNumber = object.pageNumber ?? 0;
|
|
842
|
+
message.pageWidth = object.pageWidth ?? 0;
|
|
843
|
+
message.pageHeight = object.pageHeight ?? 0;
|
|
844
|
+
message.textItems = object.textItems?.map((e) => TextItem.fromPartial(e)) || [];
|
|
845
|
+
return message;
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
function createBaseParseResponse() {
|
|
849
|
+
return { text: "", pages: [] };
|
|
850
|
+
}
|
|
851
|
+
const ParseResponse = {
|
|
852
|
+
encode(message, writer = new BinaryWriter()) {
|
|
853
|
+
if (message.text !== "") {
|
|
854
|
+
writer.uint32(10).string(message.text);
|
|
855
|
+
}
|
|
856
|
+
for (const v of message.pages) {
|
|
857
|
+
ParsedPage.encode(v, writer.uint32(18).fork()).join();
|
|
858
|
+
}
|
|
859
|
+
return writer;
|
|
860
|
+
},
|
|
861
|
+
decode(input, length) {
|
|
862
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
863
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
864
|
+
const message = createBaseParseResponse();
|
|
865
|
+
while (reader.pos < end) {
|
|
866
|
+
const tag = reader.uint32();
|
|
867
|
+
switch (tag >>> 3) {
|
|
868
|
+
case 1: {
|
|
869
|
+
if (tag !== 10) {
|
|
870
|
+
break;
|
|
871
|
+
}
|
|
872
|
+
message.text = reader.string();
|
|
873
|
+
continue;
|
|
874
|
+
}
|
|
875
|
+
case 2: {
|
|
876
|
+
if (tag !== 18) {
|
|
877
|
+
break;
|
|
878
|
+
}
|
|
879
|
+
message.pages.push(ParsedPage.decode(reader, reader.uint32()));
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
886
|
+
reader.skip(tag & 7);
|
|
887
|
+
}
|
|
888
|
+
return message;
|
|
889
|
+
},
|
|
890
|
+
fromJSON(object) {
|
|
891
|
+
return {
|
|
892
|
+
text: isSet(object.text) ? globalThis.String(object.text) : "",
|
|
893
|
+
pages: globalThis.Array.isArray(object?.pages) ? object.pages.map((e) => ParsedPage.fromJSON(e)) : []
|
|
894
|
+
};
|
|
895
|
+
},
|
|
896
|
+
toJSON(message) {
|
|
897
|
+
const obj = {};
|
|
898
|
+
if (message.text !== "") {
|
|
899
|
+
obj.text = message.text;
|
|
900
|
+
}
|
|
901
|
+
if (message.pages?.length) {
|
|
902
|
+
obj.pages = message.pages.map((e) => ParsedPage.toJSON(e));
|
|
903
|
+
}
|
|
904
|
+
return obj;
|
|
905
|
+
},
|
|
906
|
+
create(base) {
|
|
907
|
+
return ParseResponse.fromPartial(base ?? {});
|
|
908
|
+
},
|
|
909
|
+
fromPartial(object) {
|
|
910
|
+
const message = createBaseParseResponse();
|
|
911
|
+
message.text = object.text ?? "";
|
|
912
|
+
message.pages = object.pages?.map((e) => ParsedPage.fromPartial(e)) || [];
|
|
913
|
+
return message;
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
function createBaseScreenshotPage() {
|
|
917
|
+
return {
|
|
918
|
+
imageBytes: Buffer.alloc(0),
|
|
919
|
+
pageNumber: 0,
|
|
920
|
+
height: 0,
|
|
921
|
+
width: 0,
|
|
922
|
+
mimeType: ""
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
const ScreenshotPage = {
|
|
926
|
+
encode(message, writer = new BinaryWriter()) {
|
|
927
|
+
if (message.imageBytes.length !== 0) {
|
|
928
|
+
writer.uint32(10).bytes(message.imageBytes);
|
|
929
|
+
}
|
|
930
|
+
if (message.pageNumber !== 0) {
|
|
931
|
+
writer.uint32(16).uint32(message.pageNumber);
|
|
932
|
+
}
|
|
933
|
+
if (message.height !== 0) {
|
|
934
|
+
writer.uint32(24).uint32(message.height);
|
|
935
|
+
}
|
|
936
|
+
if (message.width !== 0) {
|
|
937
|
+
writer.uint32(32).uint32(message.width);
|
|
938
|
+
}
|
|
939
|
+
if (message.mimeType !== "") {
|
|
940
|
+
writer.uint32(42).string(message.mimeType);
|
|
941
|
+
}
|
|
942
|
+
return writer;
|
|
943
|
+
},
|
|
944
|
+
decode(input, length) {
|
|
945
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
946
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
947
|
+
const message = createBaseScreenshotPage();
|
|
948
|
+
while (reader.pos < end) {
|
|
949
|
+
const tag = reader.uint32();
|
|
950
|
+
switch (tag >>> 3) {
|
|
951
|
+
case 1: {
|
|
952
|
+
if (tag !== 10) {
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
955
|
+
message.imageBytes = Buffer.from(reader.bytes());
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
case 2: {
|
|
959
|
+
if (tag !== 16) {
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
message.pageNumber = reader.uint32();
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
case 3: {
|
|
966
|
+
if (tag !== 24) {
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
message.height = reader.uint32();
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
case 4: {
|
|
973
|
+
if (tag !== 32) {
|
|
974
|
+
break;
|
|
975
|
+
}
|
|
976
|
+
message.width = reader.uint32();
|
|
977
|
+
continue;
|
|
978
|
+
}
|
|
979
|
+
case 5: {
|
|
980
|
+
if (tag !== 42) {
|
|
981
|
+
break;
|
|
982
|
+
}
|
|
983
|
+
message.mimeType = reader.string();
|
|
984
|
+
continue;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
reader.skip(tag & 7);
|
|
991
|
+
}
|
|
992
|
+
return message;
|
|
993
|
+
},
|
|
994
|
+
fromJSON(object) {
|
|
995
|
+
return {
|
|
996
|
+
imageBytes: isSet(object.imageBytes) ? Buffer.from(bytesFromBase64(object.imageBytes)) : isSet(object.image_bytes) ? Buffer.from(bytesFromBase64(object.image_bytes)) : Buffer.alloc(0),
|
|
997
|
+
pageNumber: isSet(object.pageNumber) ? globalThis.Number(object.pageNumber) : isSet(object.page_number) ? globalThis.Number(object.page_number) : 0,
|
|
998
|
+
height: isSet(object.height) ? globalThis.Number(object.height) : 0,
|
|
999
|
+
width: isSet(object.width) ? globalThis.Number(object.width) : 0,
|
|
1000
|
+
mimeType: isSet(object.mimeType) ? globalThis.String(object.mimeType) : isSet(object.mime_type) ? globalThis.String(object.mime_type) : ""
|
|
1001
|
+
};
|
|
1002
|
+
},
|
|
1003
|
+
toJSON(message) {
|
|
1004
|
+
const obj = {};
|
|
1005
|
+
if (message.imageBytes.length !== 0) {
|
|
1006
|
+
obj.imageBytes = base64FromBytes(message.imageBytes);
|
|
1007
|
+
}
|
|
1008
|
+
if (message.pageNumber !== 0) {
|
|
1009
|
+
obj.pageNumber = Math.round(message.pageNumber);
|
|
1010
|
+
}
|
|
1011
|
+
if (message.height !== 0) {
|
|
1012
|
+
obj.height = Math.round(message.height);
|
|
1013
|
+
}
|
|
1014
|
+
if (message.width !== 0) {
|
|
1015
|
+
obj.width = Math.round(message.width);
|
|
1016
|
+
}
|
|
1017
|
+
if (message.mimeType !== "") {
|
|
1018
|
+
obj.mimeType = message.mimeType;
|
|
1019
|
+
}
|
|
1020
|
+
return obj;
|
|
1021
|
+
},
|
|
1022
|
+
create(base) {
|
|
1023
|
+
return ScreenshotPage.fromPartial(base ?? {});
|
|
1024
|
+
},
|
|
1025
|
+
fromPartial(object) {
|
|
1026
|
+
const message = createBaseScreenshotPage();
|
|
1027
|
+
message.imageBytes = object.imageBytes ?? Buffer.alloc(0);
|
|
1028
|
+
message.pageNumber = object.pageNumber ?? 0;
|
|
1029
|
+
message.height = object.height ?? 0;
|
|
1030
|
+
message.width = object.width ?? 0;
|
|
1031
|
+
message.mimeType = object.mimeType ?? "";
|
|
1032
|
+
return message;
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
function createBaseScreenshotResponse() {
|
|
1036
|
+
return { screenshots: [] };
|
|
1037
|
+
}
|
|
1038
|
+
const ScreenshotResponse = {
|
|
1039
|
+
encode(message, writer = new BinaryWriter()) {
|
|
1040
|
+
for (const v of message.screenshots) {
|
|
1041
|
+
ScreenshotPage.encode(v, writer.uint32(10).fork()).join();
|
|
1042
|
+
}
|
|
1043
|
+
return writer;
|
|
1044
|
+
},
|
|
1045
|
+
decode(input, length) {
|
|
1046
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
1047
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
1048
|
+
const message = createBaseScreenshotResponse();
|
|
1049
|
+
while (reader.pos < end) {
|
|
1050
|
+
const tag = reader.uint32();
|
|
1051
|
+
switch (tag >>> 3) {
|
|
1052
|
+
case 1: {
|
|
1053
|
+
if (tag !== 10) {
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1056
|
+
message.screenshots.push(
|
|
1057
|
+
ScreenshotPage.decode(reader, reader.uint32())
|
|
1058
|
+
);
|
|
1059
|
+
continue;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1065
|
+
reader.skip(tag & 7);
|
|
1066
|
+
}
|
|
1067
|
+
return message;
|
|
1068
|
+
},
|
|
1069
|
+
fromJSON(object) {
|
|
1070
|
+
return {
|
|
1071
|
+
screenshots: globalThis.Array.isArray(object?.screenshots) ? object.screenshots.map((e) => ScreenshotPage.fromJSON(e)) : []
|
|
1072
|
+
};
|
|
1073
|
+
},
|
|
1074
|
+
toJSON(message) {
|
|
1075
|
+
const obj = {};
|
|
1076
|
+
if (message.screenshots?.length) {
|
|
1077
|
+
obj.screenshots = message.screenshots.map(
|
|
1078
|
+
(e) => ScreenshotPage.toJSON(e)
|
|
1079
|
+
);
|
|
1080
|
+
}
|
|
1081
|
+
return obj;
|
|
1082
|
+
},
|
|
1083
|
+
create(base) {
|
|
1084
|
+
return ScreenshotResponse.fromPartial(base ?? {});
|
|
1085
|
+
},
|
|
1086
|
+
fromPartial(object) {
|
|
1087
|
+
const message = createBaseScreenshotResponse();
|
|
1088
|
+
message.screenshots = object.screenshots?.map((e) => ScreenshotPage.fromPartial(e)) || [];
|
|
1089
|
+
return message;
|
|
1090
|
+
}
|
|
1091
|
+
};
|
|
1092
|
+
function createBaseIsComplexRequest() {
|
|
1093
|
+
return { file: Buffer.alloc(0), config: void 0 };
|
|
1094
|
+
}
|
|
1095
|
+
const IsComplexRequest = {
|
|
1096
|
+
encode(message, writer = new BinaryWriter()) {
|
|
1097
|
+
if (message.file.length !== 0) {
|
|
1098
|
+
writer.uint32(10).bytes(message.file);
|
|
1099
|
+
}
|
|
1100
|
+
if (message.config !== void 0) {
|
|
1101
|
+
LiteParseConfig.encode(message.config, writer.uint32(18).fork()).join();
|
|
1102
|
+
}
|
|
1103
|
+
return writer;
|
|
1104
|
+
},
|
|
1105
|
+
decode(input, length) {
|
|
1106
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
1107
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
1108
|
+
const message = createBaseIsComplexRequest();
|
|
1109
|
+
while (reader.pos < end) {
|
|
1110
|
+
const tag = reader.uint32();
|
|
1111
|
+
switch (tag >>> 3) {
|
|
1112
|
+
case 1: {
|
|
1113
|
+
if (tag !== 10) {
|
|
1114
|
+
break;
|
|
1115
|
+
}
|
|
1116
|
+
message.file = Buffer.from(reader.bytes());
|
|
1117
|
+
continue;
|
|
1118
|
+
}
|
|
1119
|
+
case 2: {
|
|
1120
|
+
if (tag !== 18) {
|
|
1121
|
+
break;
|
|
1122
|
+
}
|
|
1123
|
+
message.config = LiteParseConfig.decode(reader, reader.uint32());
|
|
1124
|
+
continue;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
reader.skip(tag & 7);
|
|
1131
|
+
}
|
|
1132
|
+
return message;
|
|
1133
|
+
},
|
|
1134
|
+
fromJSON(object) {
|
|
1135
|
+
return {
|
|
1136
|
+
file: isSet(object.file) ? Buffer.from(bytesFromBase64(object.file)) : Buffer.alloc(0),
|
|
1137
|
+
config: isSet(object.config) ? LiteParseConfig.fromJSON(object.config) : void 0
|
|
1138
|
+
};
|
|
1139
|
+
},
|
|
1140
|
+
toJSON(message) {
|
|
1141
|
+
const obj = {};
|
|
1142
|
+
if (message.file.length !== 0) {
|
|
1143
|
+
obj.file = base64FromBytes(message.file);
|
|
1144
|
+
}
|
|
1145
|
+
if (message.config !== void 0) {
|
|
1146
|
+
obj.config = LiteParseConfig.toJSON(message.config);
|
|
1147
|
+
}
|
|
1148
|
+
return obj;
|
|
1149
|
+
},
|
|
1150
|
+
create(base) {
|
|
1151
|
+
return IsComplexRequest.fromPartial(base ?? {});
|
|
1152
|
+
},
|
|
1153
|
+
fromPartial(object) {
|
|
1154
|
+
const message = createBaseIsComplexRequest();
|
|
1155
|
+
message.file = object.file ?? Buffer.alloc(0);
|
|
1156
|
+
message.config = object.config !== void 0 && object.config !== null ? LiteParseConfig.fromPartial(object.config) : void 0;
|
|
1157
|
+
return message;
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
1160
|
+
function createBasePageComplexityStats() {
|
|
1161
|
+
return {
|
|
1162
|
+
pageNumber: 0,
|
|
1163
|
+
textLength: 0,
|
|
1164
|
+
textCoverage: 0,
|
|
1165
|
+
hasSubstantialImages: false,
|
|
1166
|
+
imageBlockCount: 0,
|
|
1167
|
+
imageCoverage: 0,
|
|
1168
|
+
largestImageCoverage: 0,
|
|
1169
|
+
fullPageImage: false,
|
|
1170
|
+
uncovertedVectorArea: void 0,
|
|
1171
|
+
isGarbled: false,
|
|
1172
|
+
pageArea: 0,
|
|
1173
|
+
needsOcr: false,
|
|
1174
|
+
reasons: []
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
const PageComplexityStats = {
|
|
1178
|
+
encode(message, writer = new BinaryWriter()) {
|
|
1179
|
+
if (message.pageNumber !== 0) {
|
|
1180
|
+
writer.uint32(8).uint32(message.pageNumber);
|
|
1181
|
+
}
|
|
1182
|
+
if (message.textLength !== 0) {
|
|
1183
|
+
writer.uint32(16).uint64(message.textLength);
|
|
1184
|
+
}
|
|
1185
|
+
if (message.textCoverage !== 0) {
|
|
1186
|
+
writer.uint32(29).float(message.textCoverage);
|
|
1187
|
+
}
|
|
1188
|
+
if (message.hasSubstantialImages !== false) {
|
|
1189
|
+
writer.uint32(32).bool(message.hasSubstantialImages);
|
|
1190
|
+
}
|
|
1191
|
+
if (message.imageBlockCount !== 0) {
|
|
1192
|
+
writer.uint32(40).uint32(message.imageBlockCount);
|
|
1193
|
+
}
|
|
1194
|
+
if (message.imageCoverage !== 0) {
|
|
1195
|
+
writer.uint32(53).float(message.imageCoverage);
|
|
1196
|
+
}
|
|
1197
|
+
if (message.largestImageCoverage !== 0) {
|
|
1198
|
+
writer.uint32(61).float(message.largestImageCoverage);
|
|
1199
|
+
}
|
|
1200
|
+
if (message.fullPageImage !== false) {
|
|
1201
|
+
writer.uint32(64).bool(message.fullPageImage);
|
|
1202
|
+
}
|
|
1203
|
+
if (message.uncovertedVectorArea !== void 0) {
|
|
1204
|
+
writer.uint32(77).float(message.uncovertedVectorArea);
|
|
1205
|
+
}
|
|
1206
|
+
if (message.isGarbled !== false) {
|
|
1207
|
+
writer.uint32(80).bool(message.isGarbled);
|
|
1208
|
+
}
|
|
1209
|
+
if (message.pageArea !== 0) {
|
|
1210
|
+
writer.uint32(93).float(message.pageArea);
|
|
1211
|
+
}
|
|
1212
|
+
if (message.needsOcr !== false) {
|
|
1213
|
+
writer.uint32(96).bool(message.needsOcr);
|
|
1214
|
+
}
|
|
1215
|
+
for (const v of message.reasons) {
|
|
1216
|
+
writer.uint32(106).string(v);
|
|
1217
|
+
}
|
|
1218
|
+
return writer;
|
|
1219
|
+
},
|
|
1220
|
+
decode(input, length) {
|
|
1221
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
1222
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
1223
|
+
const message = createBasePageComplexityStats();
|
|
1224
|
+
while (reader.pos < end) {
|
|
1225
|
+
const tag = reader.uint32();
|
|
1226
|
+
switch (tag >>> 3) {
|
|
1227
|
+
case 1: {
|
|
1228
|
+
if (tag !== 8) {
|
|
1229
|
+
break;
|
|
1230
|
+
}
|
|
1231
|
+
message.pageNumber = reader.uint32();
|
|
1232
|
+
continue;
|
|
1233
|
+
}
|
|
1234
|
+
case 2: {
|
|
1235
|
+
if (tag !== 16) {
|
|
1236
|
+
break;
|
|
1237
|
+
}
|
|
1238
|
+
message.textLength = longToNumber(reader.uint64());
|
|
1239
|
+
continue;
|
|
1240
|
+
}
|
|
1241
|
+
case 3: {
|
|
1242
|
+
if (tag !== 29) {
|
|
1243
|
+
break;
|
|
1244
|
+
}
|
|
1245
|
+
message.textCoverage = reader.float();
|
|
1246
|
+
continue;
|
|
1247
|
+
}
|
|
1248
|
+
case 4: {
|
|
1249
|
+
if (tag !== 32) {
|
|
1250
|
+
break;
|
|
1251
|
+
}
|
|
1252
|
+
message.hasSubstantialImages = reader.bool();
|
|
1253
|
+
continue;
|
|
1254
|
+
}
|
|
1255
|
+
case 5: {
|
|
1256
|
+
if (tag !== 40) {
|
|
1257
|
+
break;
|
|
1258
|
+
}
|
|
1259
|
+
message.imageBlockCount = reader.uint32();
|
|
1260
|
+
continue;
|
|
1261
|
+
}
|
|
1262
|
+
case 6: {
|
|
1263
|
+
if (tag !== 53) {
|
|
1264
|
+
break;
|
|
1265
|
+
}
|
|
1266
|
+
message.imageCoverage = reader.float();
|
|
1267
|
+
continue;
|
|
1268
|
+
}
|
|
1269
|
+
case 7: {
|
|
1270
|
+
if (tag !== 61) {
|
|
1271
|
+
break;
|
|
1272
|
+
}
|
|
1273
|
+
message.largestImageCoverage = reader.float();
|
|
1274
|
+
continue;
|
|
1275
|
+
}
|
|
1276
|
+
case 8: {
|
|
1277
|
+
if (tag !== 64) {
|
|
1278
|
+
break;
|
|
1279
|
+
}
|
|
1280
|
+
message.fullPageImage = reader.bool();
|
|
1281
|
+
continue;
|
|
1282
|
+
}
|
|
1283
|
+
case 9: {
|
|
1284
|
+
if (tag !== 77) {
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
message.uncovertedVectorArea = reader.float();
|
|
1288
|
+
continue;
|
|
1289
|
+
}
|
|
1290
|
+
case 10: {
|
|
1291
|
+
if (tag !== 80) {
|
|
1292
|
+
break;
|
|
1293
|
+
}
|
|
1294
|
+
message.isGarbled = reader.bool();
|
|
1295
|
+
continue;
|
|
1296
|
+
}
|
|
1297
|
+
case 11: {
|
|
1298
|
+
if (tag !== 93) {
|
|
1299
|
+
break;
|
|
1300
|
+
}
|
|
1301
|
+
message.pageArea = reader.float();
|
|
1302
|
+
continue;
|
|
1303
|
+
}
|
|
1304
|
+
case 12: {
|
|
1305
|
+
if (tag !== 96) {
|
|
1306
|
+
break;
|
|
1307
|
+
}
|
|
1308
|
+
message.needsOcr = reader.bool();
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1311
|
+
case 13: {
|
|
1312
|
+
if (tag !== 106) {
|
|
1313
|
+
break;
|
|
1314
|
+
}
|
|
1315
|
+
message.reasons.push(reader.string());
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1320
|
+
break;
|
|
1321
|
+
}
|
|
1322
|
+
reader.skip(tag & 7);
|
|
1323
|
+
}
|
|
1324
|
+
return message;
|
|
1325
|
+
},
|
|
1326
|
+
fromJSON(object) {
|
|
1327
|
+
return {
|
|
1328
|
+
pageNumber: isSet(object.pageNumber) ? globalThis.Number(object.pageNumber) : isSet(object.page_number) ? globalThis.Number(object.page_number) : 0,
|
|
1329
|
+
textLength: isSet(object.textLength) ? globalThis.Number(object.textLength) : isSet(object.text_length) ? globalThis.Number(object.text_length) : 0,
|
|
1330
|
+
textCoverage: isSet(object.textCoverage) ? globalThis.Number(object.textCoverage) : isSet(object.text_coverage) ? globalThis.Number(object.text_coverage) : 0,
|
|
1331
|
+
hasSubstantialImages: isSet(object.hasSubstantialImages) ? globalThis.Boolean(object.hasSubstantialImages) : isSet(object.has_substantial_images) ? globalThis.Boolean(object.has_substantial_images) : false,
|
|
1332
|
+
imageBlockCount: isSet(object.imageBlockCount) ? globalThis.Number(object.imageBlockCount) : isSet(object.image_block_count) ? globalThis.Number(object.image_block_count) : 0,
|
|
1333
|
+
imageCoverage: isSet(object.imageCoverage) ? globalThis.Number(object.imageCoverage) : isSet(object.image_coverage) ? globalThis.Number(object.image_coverage) : 0,
|
|
1334
|
+
largestImageCoverage: isSet(object.largestImageCoverage) ? globalThis.Number(object.largestImageCoverage) : isSet(object.largest_image_coverage) ? globalThis.Number(object.largest_image_coverage) : 0,
|
|
1335
|
+
fullPageImage: isSet(object.fullPageImage) ? globalThis.Boolean(object.fullPageImage) : isSet(object.full_page_image) ? globalThis.Boolean(object.full_page_image) : false,
|
|
1336
|
+
uncovertedVectorArea: isSet(object.uncovertedVectorArea) ? globalThis.Number(object.uncovertedVectorArea) : isSet(object.uncoverted_vector_area) ? globalThis.Number(object.uncoverted_vector_area) : void 0,
|
|
1337
|
+
isGarbled: isSet(object.isGarbled) ? globalThis.Boolean(object.isGarbled) : isSet(object.is_garbled) ? globalThis.Boolean(object.is_garbled) : false,
|
|
1338
|
+
pageArea: isSet(object.pageArea) ? globalThis.Number(object.pageArea) : isSet(object.page_area) ? globalThis.Number(object.page_area) : 0,
|
|
1339
|
+
needsOcr: isSet(object.needsOcr) ? globalThis.Boolean(object.needsOcr) : isSet(object.needs_ocr) ? globalThis.Boolean(object.needs_ocr) : false,
|
|
1340
|
+
reasons: globalThis.Array.isArray(object?.reasons) ? object.reasons.map((e) => globalThis.String(e)) : []
|
|
1341
|
+
};
|
|
1342
|
+
},
|
|
1343
|
+
toJSON(message) {
|
|
1344
|
+
const obj = {};
|
|
1345
|
+
if (message.pageNumber !== 0) {
|
|
1346
|
+
obj.pageNumber = Math.round(message.pageNumber);
|
|
1347
|
+
}
|
|
1348
|
+
if (message.textLength !== 0) {
|
|
1349
|
+
obj.textLength = Math.round(message.textLength);
|
|
1350
|
+
}
|
|
1351
|
+
if (message.textCoverage !== 0) {
|
|
1352
|
+
obj.textCoverage = message.textCoverage;
|
|
1353
|
+
}
|
|
1354
|
+
if (message.hasSubstantialImages !== false) {
|
|
1355
|
+
obj.hasSubstantialImages = message.hasSubstantialImages;
|
|
1356
|
+
}
|
|
1357
|
+
if (message.imageBlockCount !== 0) {
|
|
1358
|
+
obj.imageBlockCount = Math.round(message.imageBlockCount);
|
|
1359
|
+
}
|
|
1360
|
+
if (message.imageCoverage !== 0) {
|
|
1361
|
+
obj.imageCoverage = message.imageCoverage;
|
|
1362
|
+
}
|
|
1363
|
+
if (message.largestImageCoverage !== 0) {
|
|
1364
|
+
obj.largestImageCoverage = message.largestImageCoverage;
|
|
1365
|
+
}
|
|
1366
|
+
if (message.fullPageImage !== false) {
|
|
1367
|
+
obj.fullPageImage = message.fullPageImage;
|
|
1368
|
+
}
|
|
1369
|
+
if (message.uncovertedVectorArea !== void 0) {
|
|
1370
|
+
obj.uncovertedVectorArea = message.uncovertedVectorArea;
|
|
1371
|
+
}
|
|
1372
|
+
if (message.isGarbled !== false) {
|
|
1373
|
+
obj.isGarbled = message.isGarbled;
|
|
1374
|
+
}
|
|
1375
|
+
if (message.pageArea !== 0) {
|
|
1376
|
+
obj.pageArea = message.pageArea;
|
|
1377
|
+
}
|
|
1378
|
+
if (message.needsOcr !== false) {
|
|
1379
|
+
obj.needsOcr = message.needsOcr;
|
|
1380
|
+
}
|
|
1381
|
+
if (message.reasons?.length) {
|
|
1382
|
+
obj.reasons = message.reasons;
|
|
1383
|
+
}
|
|
1384
|
+
return obj;
|
|
1385
|
+
},
|
|
1386
|
+
create(base) {
|
|
1387
|
+
return PageComplexityStats.fromPartial(base ?? {});
|
|
1388
|
+
},
|
|
1389
|
+
fromPartial(object) {
|
|
1390
|
+
const message = createBasePageComplexityStats();
|
|
1391
|
+
message.pageNumber = object.pageNumber ?? 0;
|
|
1392
|
+
message.textLength = object.textLength ?? 0;
|
|
1393
|
+
message.textCoverage = object.textCoverage ?? 0;
|
|
1394
|
+
message.hasSubstantialImages = object.hasSubstantialImages ?? false;
|
|
1395
|
+
message.imageBlockCount = object.imageBlockCount ?? 0;
|
|
1396
|
+
message.imageCoverage = object.imageCoverage ?? 0;
|
|
1397
|
+
message.largestImageCoverage = object.largestImageCoverage ?? 0;
|
|
1398
|
+
message.fullPageImage = object.fullPageImage ?? false;
|
|
1399
|
+
message.uncovertedVectorArea = object.uncovertedVectorArea ?? void 0;
|
|
1400
|
+
message.isGarbled = object.isGarbled ?? false;
|
|
1401
|
+
message.pageArea = object.pageArea ?? 0;
|
|
1402
|
+
message.needsOcr = object.needsOcr ?? false;
|
|
1403
|
+
message.reasons = object.reasons?.map((e) => e) || [];
|
|
1404
|
+
return message;
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
function createBaseIsComplexResponse() {
|
|
1408
|
+
return { complexity: [] };
|
|
1409
|
+
}
|
|
1410
|
+
const IsComplexResponse = {
|
|
1411
|
+
encode(message, writer = new BinaryWriter()) {
|
|
1412
|
+
for (const v of message.complexity) {
|
|
1413
|
+
PageComplexityStats.encode(v, writer.uint32(10).fork()).join();
|
|
1414
|
+
}
|
|
1415
|
+
return writer;
|
|
1416
|
+
},
|
|
1417
|
+
decode(input, length) {
|
|
1418
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
1419
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
1420
|
+
const message = createBaseIsComplexResponse();
|
|
1421
|
+
while (reader.pos < end) {
|
|
1422
|
+
const tag = reader.uint32();
|
|
1423
|
+
switch (tag >>> 3) {
|
|
1424
|
+
case 1: {
|
|
1425
|
+
if (tag !== 10) {
|
|
1426
|
+
break;
|
|
1427
|
+
}
|
|
1428
|
+
message.complexity.push(
|
|
1429
|
+
PageComplexityStats.decode(reader, reader.uint32())
|
|
1430
|
+
);
|
|
1431
|
+
continue;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1435
|
+
break;
|
|
1436
|
+
}
|
|
1437
|
+
reader.skip(tag & 7);
|
|
1438
|
+
}
|
|
1439
|
+
return message;
|
|
1440
|
+
},
|
|
1441
|
+
fromJSON(object) {
|
|
1442
|
+
return {
|
|
1443
|
+
complexity: globalThis.Array.isArray(object?.complexity) ? object.complexity.map((e) => PageComplexityStats.fromJSON(e)) : []
|
|
1444
|
+
};
|
|
1445
|
+
},
|
|
1446
|
+
toJSON(message) {
|
|
1447
|
+
const obj = {};
|
|
1448
|
+
if (message.complexity?.length) {
|
|
1449
|
+
obj.complexity = message.complexity.map(
|
|
1450
|
+
(e) => PageComplexityStats.toJSON(e)
|
|
1451
|
+
);
|
|
1452
|
+
}
|
|
1453
|
+
return obj;
|
|
1454
|
+
},
|
|
1455
|
+
create(base) {
|
|
1456
|
+
return IsComplexResponse.fromPartial(base ?? {});
|
|
1457
|
+
},
|
|
1458
|
+
fromPartial(object) {
|
|
1459
|
+
const message = createBaseIsComplexResponse();
|
|
1460
|
+
message.complexity = object.complexity?.map((e) => PageComplexityStats.fromPartial(e)) || [];
|
|
1461
|
+
return message;
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
const ParserServiceService = {
|
|
1465
|
+
/** Parse a file */
|
|
1466
|
+
parse: {
|
|
1467
|
+
path: "/parser.ParserService/Parse",
|
|
1468
|
+
requestStream: false,
|
|
1469
|
+
responseStream: false,
|
|
1470
|
+
requestSerialize: (value) => Buffer.from(ParseRequest.encode(value).finish()),
|
|
1471
|
+
requestDeserialize: (value) => ParseRequest.decode(value),
|
|
1472
|
+
responseSerialize: (value) => Buffer.from(ParseResponse.encode(value).finish()),
|
|
1473
|
+
responseDeserialize: (value) => ParseResponse.decode(value)
|
|
1474
|
+
},
|
|
1475
|
+
/** Screenshot the pages of a PDF file */
|
|
1476
|
+
screenshot: {
|
|
1477
|
+
path: "/parser.ParserService/Screenshot",
|
|
1478
|
+
requestStream: false,
|
|
1479
|
+
responseStream: false,
|
|
1480
|
+
requestSerialize: (value) => Buffer.from(ScreenshotRequest.encode(value).finish()),
|
|
1481
|
+
requestDeserialize: (value) => ScreenshotRequest.decode(value),
|
|
1482
|
+
responseSerialize: (value) => Buffer.from(ScreenshotResponse.encode(value).finish()),
|
|
1483
|
+
responseDeserialize: (value) => ScreenshotResponse.decode(value)
|
|
1484
|
+
},
|
|
1485
|
+
/** Estimate the complexity of a file and the need for OCR */
|
|
1486
|
+
isComplex: {
|
|
1487
|
+
path: "/parser.ParserService/IsComplex",
|
|
1488
|
+
requestStream: false,
|
|
1489
|
+
responseStream: false,
|
|
1490
|
+
requestSerialize: (value) => Buffer.from(IsComplexRequest.encode(value).finish()),
|
|
1491
|
+
requestDeserialize: (value) => IsComplexRequest.decode(value),
|
|
1492
|
+
responseSerialize: (value) => Buffer.from(IsComplexResponse.encode(value).finish()),
|
|
1493
|
+
responseDeserialize: (value) => IsComplexResponse.decode(value)
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1496
|
+
const ParserServiceClient = makeGenericClientConstructor(
|
|
1497
|
+
ParserServiceService,
|
|
1498
|
+
"parser.ParserService"
|
|
1499
|
+
);
|
|
1500
|
+
function bytesFromBase64(b64) {
|
|
1501
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
1502
|
+
}
|
|
1503
|
+
function base64FromBytes(arr) {
|
|
1504
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
1505
|
+
}
|
|
1506
|
+
function longToNumber(int64) {
|
|
1507
|
+
const num = globalThis.Number(int64.toString());
|
|
1508
|
+
if (num > globalThis.Number.MAX_SAFE_INTEGER) {
|
|
1509
|
+
throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
|
1510
|
+
}
|
|
1511
|
+
if (num < globalThis.Number.MIN_SAFE_INTEGER) {
|
|
1512
|
+
throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");
|
|
1513
|
+
}
|
|
1514
|
+
return num;
|
|
1515
|
+
}
|
|
1516
|
+
function isSet(value) {
|
|
1517
|
+
return value !== null && value !== void 0;
|
|
1518
|
+
}
|
|
1519
|
+
export {
|
|
1520
|
+
HttpHeader,
|
|
1521
|
+
ImageMode,
|
|
1522
|
+
IsComplexRequest,
|
|
1523
|
+
IsComplexResponse,
|
|
1524
|
+
LiteParseConfig,
|
|
1525
|
+
OutputFormat,
|
|
1526
|
+
PageComplexityStats,
|
|
1527
|
+
ParseRequest,
|
|
1528
|
+
ParseResponse,
|
|
1529
|
+
ParsedPage,
|
|
1530
|
+
ParserServiceClient,
|
|
1531
|
+
ParserServiceService,
|
|
1532
|
+
ScreenshotPage,
|
|
1533
|
+
ScreenshotRequest,
|
|
1534
|
+
ScreenshotResponse,
|
|
1535
|
+
TextItem,
|
|
1536
|
+
imageModeFromJSON,
|
|
1537
|
+
imageModeToJSON,
|
|
1538
|
+
outputFormatFromJSON,
|
|
1539
|
+
outputFormatToJSON,
|
|
1540
|
+
protobufPackage
|
|
1541
|
+
};
|
|
1542
|
+
//# sourceMappingURL=parser.js.map
|