-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
628 lines (548 loc) · 24.7 KB
/
util.js
File metadata and controls
628 lines (548 loc) · 24.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
class MyViewer {
// purely virtual function
getDocument() {
throw new Error('getDocument() must be implemented by subclass');
}
async loadSource(base64Image) {
const doc = this.getDocument();
await doc.loadSource(MyViewerApp.base64toBlob(base64Image));
}
async loadDocument(url) {
const doc = this.getDocument();
const response = await fetch(url, {
method: "GET"
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const image = await response.arrayBuffer();
await doc?.loadSource(new Blob([image], { type: response.headers.get("content-type") }));
}
async saveToPng(index, settings) {
const doc = this.getDocument();
const file = await doc?.saveToPng(index, settings);
return await MyViewerApp.fileToBase64(file);
}
async saveToJpeg(index, settings) {
const doc = this.getDocument();
const file = await doc?.saveToJpeg(index, settings);
return await MyViewerApp.fileToBase64(file);
}
async saveAsTiff(indicies, settings) {
const doc = this.getDocument();
indicies = indicies ?? [...Array(doc?.pages.length).keys()];
if (indicies.length === 0) {
return "";
}
if (settings) {
const file = await doc?.saveToTiff(indicies, settings);
return await MyViewerApp.fileToBase64(file);
}
else {
const file = await doc?.saveToTiff(indicies);
return await MyViewerApp.fileToBase64(file);
}
}
async saveAllAsTiff(settings) {
return await this.saveAsTiff(null, settings);
}
async saveAsPdf(indicies, settings) {
console.log(settings);
const doc = this.getDocument();
indicies = indicies ?? [...Array(doc?.pages.length).keys()];
if (indicies.length === 0) {
return "";
}
if (settings) {
const file = await doc?.saveToPdf(indicies, settings);
return await MyViewerApp.fileToBase64(file);
}
else {
const file = await doc?.saveToPdf(indicies);
return await MyViewerApp.fileToBase64(file);
}
}
async saveAllAsPdf(settings) {
return await this.saveAsPdf(null, settings);
}
async setBarcodeResult(results){
//results = "[{"BarcodeFormat":2,"BarcodeFormatString":"CODE_128","LocalizationResult":{"ResultPoints":["723, 275","1021, 275","1021, 375","723, 375"],"accompanyingTextBytes":[],"angle":0,"barcodeFormat":3147775,"barcodeFormatString":"OneD","barcodeFormatString_2":"No Barcode Format in group 2","barcodeFormat_2":0,"confidence":100,"documentName":"{E55BE964-BA6D-4B9D-95DE-CA5C4994ADBC}","moduleSize":2,"pageNumber":1,"regionName":"","resultCoordinateType":1,"terminatePhase":32,"x1":723,"x2":1021,"x3":1021,"x4":723,"y1":275,"y2":275,"y3":375,"y4":375},"barcodeBytes":[67,79,68,69,49,50,56],"barcodeFormat":2,"barcodeFormatString":"CODE_128","barcodeFormatString_2":"No Barcode Format in group 2","barcodeFormat_2":0,"barcodeText":"CODE128","detailedResult":{"checkDigitBytes":[],"moduleSize":2,"startCharsBytes":[],"stopCharsBytes":[]},"localizationResult":{"ResultPoints":["723, 275","1021, 275","1021, 375","723, 375"],"accompanyingTextBytes":[],"angle":0,"barcodeFormat":3147775,"barcodeFormatString":"OneD","barcodeFormatString_2":"No Barcode Format in group 2","barcodeFormat_2":0,"confidence":100,"documentName":"{E55BE964-BA6D-4B9D-95DE-CA5C4994ADBC}","moduleSize":2,"pageNumber":1,"regionName":"","resultCoordinateType":1,"terminatePhase":32,"x1":723,"x2":1021,"x3":1021,"x4":723,"y1":275,"y2":275,"y3":375,"y4":375},"results":[{"accompanyingTextBytes":[],"barcodeFormat":2,"barcodeFormatString":"CODE_128","barcodeFormatString_2":"No Barcode Format in group 2","barcodeFormat_2":0,"bytes":[67,79,68,69,49,50,56],"clarity":-1,"confidence":100,"deformation":0,"resultType":0}]},{"BarcodeFormat":1024,"BarcodeFormatString":"CODE_39_EXTENDED","LocalizationResult":{"ResultPoints":["183, 272","564, 273","564, 373","183, 372"],"accompanyingTextBytes":[],"angle":0,"barcodeFormat":3147775,"barcodeFormatString":"OneD","barcodeFormatString_2":"No Barcode Format in group 2","barcodeFormat_2":0,"confidence":57,"documentName":"{E55BE964-BA6D-4B9D-95DE-CA5C4994ADBC}","moduleSize":3,"pageNumber":1,"regionName":"","resultCoordinateType":1,"terminatePhase":32,"x1":183,"x2":564,"x3":564,"x4":183,"y1":272,"y2":273,"y3":373,"y4":372},"barcodeBytes":[67,79,68,69,51,57],"barcodeFormat":1024,"barcodeFormatString":"CODE_39_EXTENDED","barcodeFormatString_2":"No Barcode Format in group 2","barcodeFormat_2":0,"barcodeText":"CODE39","detailedResult":{"checkDigitBytes":[],"moduleSize":3,"startCharsBytes":[42],"stopCharsBytes":[42]},"localizationResult":{"ResultPoints":["183, 272","564, 273","564, 373","183, 372"],"accompanyingTextBytes":[],"angle":0,"barcodeFormat":3147775,"barcodeFormatString":"OneD","barcodeFormatString_2":"No Barcode Format in group 2","barcodeFormat_2":0,"confidence":57,"documentName":"{E55BE964-BA6D-4B9D-95DE-CA5C4994ADBC}","moduleSize":3,"pageNumber":1,"regionName":"","resultCoordinateType":1,"terminatePhase":32,"x1":183,"x2":564,"x3":564,"x4":183,"y1":272,"y2":273,"y3":373,"y4":372},"results":[{"accompanyingTextBytes":[],"barcodeFormat":1024,"barcodeFormatString":"CODE_39_EXTENDED","barcodeFormatString_2":"No Barcode Format in group 2","barcodeFormat_2":0,"bytes":[67,79,68,69,51,57],"clarity":-1,"confidence":57,"deformation":0,"resultType":0}]}]";
console.log(results);
const doc = this.getDocument();
for (var i = 0; i < results.length; i++) {
var item = results[i];
let text = item.barcodeText;
let loc = item.localizationResult;//.points;
let currentPageId = doc.pages[this.editViewer.getCurrentPageIndex()];
let pageData = await doc.getPageData(currentPageId);
// https://www.dynamsoft.com/document-viewer/docs/api/interface/annotationinterface/texttypewriterannotationoptions.html
let textX = Math.min(loc.x1, loc.x2, loc.x3, loc.x4) / pageData.display.width * pageData.mediaBox.width;
let textY = Math.min(loc.y1, loc.y2, loc.y3, loc.y4) / pageData.display.height * pageData.mediaBox.height;
const textTypewriterOptions = {
x: textX < 0 ? 0 : textX,
y: textY - 15 < 0 ? 0 : textY - 15,
textContents: [{ content: text, color: "rgb(255,0,0)" }],
flags: {
print: false,
noView: false,
readOnly: true,
}
}
// https://www.dynamsoft.com/document-viewer/docs/api/class/annotationmanager.html#createAnnotation
let textTypewriter = await Dynamsoft.DDV.annotationManager.createAnnotation(currentPageId, "textTypewriter", textTypewriterOptions)
textTypewriter['name'] = 'overlay';
// https://www.dynamsoft.com/document-viewer/docs/api/interface/annotationinterface/polygonannotationoptions.html
const polygonOptions = {
points: loc.ResultPoints.map(p => {
const numbers = p.split(", ").map(Number);
return {
x: numbers[0] / pageData.display.width * pageData.mediaBox.width,
y: numbers[1] / pageData.display.height * pageData.mediaBox.height
}
}),
borderColor: "rgb(255,0,0)",
flags: {
print: false,
noView: false,
readOnly: true,
}
}
let polygon = Dynamsoft.DDV.annotationManager.createAnnotation(currentPageId, "polygon", polygonOptions);
polygon['name'] = 'overlay';
}
}
async clearAnnotations() {
const doc = this.getDocument();
if (!doc) {
alert("Please load a document first.");
return;
}
let currentPageId = doc.pages[this.editViewer.getCurrentPageIndex()];
let annotations = Dynamsoft.DDV.annotationManager.getAnnotationsByPage(currentPageId);
if (annotations.length > 0) {
for (let i = 0; i < annotations.length; i++) {
// https://www.dynamsoft.com/document-viewer/docs/api/class/annotationmanager.html#deleteannotations
if (!annotations[i].flattened && annotations[i].name !== 'barcode') {
await Dynamsoft.DDV.annotationManager.deleteAnnotations([annotations[i].uid]);
}
}
}
}
}
class MyDesktopViewer extends MyViewer {
editViewer = null;
fullFeatureEditViewer = null;
constructor(options) {
super();
let newUiConfig = Dynamsoft.DDV.getDefaultUiConfig("editViewer", { includeAnnotationSet: true });
if (options.uiConfig === 'desktop-default') {
newUiConfig = {
type: Dynamsoft.DDV.Elements.Layout,
flexDirection: "column",
className: "ddv-edit-viewer-desktop",
children: [
Dynamsoft.DDV.Elements.MainView,
{
type: Dynamsoft.DDV.Elements.Pagination,
className: "custom-pagination",
}
],
};
}
let groupUid = "uniqueID";
let fullFeatureConfig = {
type: Dynamsoft.DDV.Elements.Layout,
flexDirection: "column",
className: "ddv-edit-viewer-mobile",
children: [
{
type: Dynamsoft.DDV.Elements.Layout,
className: "ddv-edit-viewer-header-mobile",
children: [
{
// Add a "Back" buttom to header and bind click event to go back to the perspective viewer
// The event will be registered later.
type: Dynamsoft.DDV.Elements.Button,
className: "ddv-button-back",
events:{
click: "back"
}
},
Dynamsoft.DDV.Elements.Pagination,
Dynamsoft.DDV.Elements.Blank
],
},
Dynamsoft.DDV.Elements.MainView,
{
type: Dynamsoft.DDV.Elements.Layout,
className: "ddv-edit-viewer-footer-mobile",
children: [
Dynamsoft.DDV.Elements.DisplayMode,
Dynamsoft.DDV.Elements.RotateLeft,
Dynamsoft.DDV.Elements.Crop,
Dynamsoft.DDV.Elements.Filter,
Dynamsoft.DDV.Elements.Undo,
Dynamsoft.DDV.Elements.Delete
],
},
],
};
this.fullFeatureEditViewer = new Dynamsoft.DDV.EditViewer({
container: "container",
uiConfig: fullFeatureConfig,
groupUid: groupUid,
viewerConfig: {
scrollToLatest: true,
},
thumbnailConfig: {
scrollToLatest: true,
}
});
this.fullFeatureEditViewer.hide();
this.fullFeatureEditViewer.on("back",() => {
this.fullFeatureEditViewer.hide();
this.editViewer.show();
});
this.editViewer = new Dynamsoft.DDV.EditViewer({
container: "container",
uiConfig: newUiConfig,
groupUid: groupUid,
viewerConfig: {
canvasStyle: {
background: "rgb(255,255,255)"
},
scrollToLatest: true,
},
thumbnailConfig: {
visibility: "visible",
checkboxStyle: {
visibility: "hidden",
},
pageNumberStyle: {
visibility: "hidden",
},
canvasStyle: {
background: "rgb(244,244,244)"
},
selectedPageStyle: {
border: "2px solid rgb(153,209,255)",
background: "rgb(204,232,255)"
},
currentPageStyle: {
border: "0px solid blue"
},
hoveredPageStyle: {
border: "0px solid blue",
background: "rgb(229,243,255)"
},
scrollToLatest: true,
},
annotationConfig: {
enableContinuousDrawing: true
}
});
this.editViewer.displayMode = "single";
let internalIndexChanged = false;
let ifDragAndDrop = false;
this.editViewer.on("currentIndexChanged", (evt) => {
if(ifDragAndDrop)
return;
let selectedIndices = this.editViewer.thumbnail?.getSelectedPageIndices();
if (!internalIndexChanged) {
selectedIndices = [];
}
if (evt.newIndex != -1 && !selectedIndices.includes(evt.newIndex)) {
selectedIndices.push(evt.newIndex);
this.editViewer.thumbnail?.selectPages(selectedIndices);
}
});
this.editViewer.thumbnail?.on("selectedPagesChanged", (evt) => {
if(ifDragAndDrop)
return;
const currentPageIndex = this.editViewer.getCurrentPageIndex();
if (!evt.newIndices.includes(currentPageIndex) && evt.newIndices.length > 0) {
internalIndexChanged = true;
this.editViewer.goToPage(evt.newIndices[evt.newIndices.length - 1]);
internalIndexChanged = false;
}
});
this.editViewer.thumbnail?.on("pagesDragged", (evt) => {
ifDragAndDrop = true;
});
this.editViewer.thumbnail?.on("pagesDropped", (evt) => {
ifDragAndDrop = false;
});
}
// override
getDocument() {
let doc = this.editViewer.currentDocument;
if (!doc) {
doc = Dynamsoft.DDV.documentManager.createDocument();
this.editViewer.openDocument(doc.uid);
}
return doc;
}
showFullFeatureEditor(){
this.editViewer.hide();
this.fullFeatureEditViewer.show();
}
setToolMode(mode) {
this.editViewer.toolMode = mode;
return (this.editViewer.toolMode === mode);
}
rotateCurrentPage(angle) {
return this.editViewer.rotate(angle, [this.editViewer.getCurrentPageIndex()]);
}
rotateSelectedPages(angle) {
return this.editViewer.rotate(angle, this.editViewer.thumbnail?.getSelectedPageIndices());
}
cropCurrentPage() {
return this.editViewer.crop(this.editViewer.getCropRect(), [this.editViewer.getCurrentPageIndex()]);
}
cropSelectedPages() {
return this.editViewer.crop(this.editViewer.getCropRect(), this.editViewer.thumbnail?.getSelectedPageIndices());
}
undo() {
return this.editViewer.undo();
}
redo() {
return this.editViewer.redo();
}
setFitMode(mode) {
this.editViewer.fitMode = mode;
return (this.editViewer.fitMode === mode);
}
setAnnotationMode(mode) {
this.editViewer.toolMode = 'annotation';
this.editViewer.annotationMode = mode;
return (this.editViewer.annotationMode === mode);
}
deleteCurrentPage() {
return this.editViewer.currentDocument?.deletePages([this.editViewer.getCurrentPageIndex()]);
}
deleteSelectedPages() {
return this.editViewer.currentDocument?.deletePages(this.editViewer.thumbnail?.getSelectedPageIndices());
}
deleteAllPages() {
return this.editViewer.currentDocument?.deleteAllPages();
}
getSelectedPagesCount() {
return this.editViewer.thumbnail?.getSelectedPageIndices().length;
}
getPageCount() {
return this.editViewer.getPageCount();
}
async saveCurrentToPng(settings) {
if (this.editViewer.getPageCount() <= 0) {
return "";
}
return await this.saveToPng(this.editViewer.getCurrentPageIndex(), settings);
}
async saveCurrentToJpeg(settings) {
if (this.editViewer.getPageCount() <= 0) {
return "";
}
return await this.saveToJpeg(this.editViewer.getCurrentPageIndex(), settings);
}
async saveCurrentAsTiff(settings) {
return await this.saveAsTiff([this.editViewer.getCurrentPageIndex()], settings);
}
async saveSelectedAsTiff(settings) {
return await this.saveAsTiff(this.editViewer.thumbnail?.getSelectedPageIndices(), settings);
}
async saveCurrentAsPdf(settings) {
return await this.saveAsPdf([this.editViewer.getCurrentPageIndex()], settings);
}
async saveSelectedAsPdf(settings) {
return await this.saveAsPdf(this.editViewer.thumbnail?.getSelectedPageIndices(), settings);
}
}
class MyViewerApp {
static productkey = "";
static messageType = "";
static myViewer = null;
// Unified function to send messages to .NET
static sendMessageToDotNet(message) {
try {
message = (this.messageType === '') ? message : `${this.messageType}|${message}`;
if (window.chrome && window.chrome.webview) {
// For WinForms and WPF (WebView2)
window.chrome.webview.postMessage(message);
}
else if (window.DotNet) {
// For Blazor, not sure if this is the right way
DotNet.invokeMethodAsync(blazorAppName, blazorCallbackName, message);
}
else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.webwindowinterop) {
// iOS and MacCatalyst WKWebView
window.webkit.messageHandlers.webwindowinterop.postMessage(message);
}
else if (hybridWebViewHost) {
// Android WebView
hybridWebViewHost.sendMessage(message);
}
else {
console.error("Unsupported platform or WebView environment.");
}
}
catch (error) {
console.error("Error sending message to .NET:", error);
}
}
static invokeDotNet(context, result, error) {
try {
this.sendMessageToDotNet(JSON.stringify([context ?? '', result ?? '', error ?? '']));
} catch (e) {
console.error(`Error sending back: ${context}:`, e);
}
}
static async initView(options) {
return await MyViewerApp.createView(options);
}
static findFunction(ins, name) {
if (!ins) {
if (name === 'initView') {
return this.initView;
}
return null;
}
let proto = Object.getPrototypeOf(ins);
while (proto) {
if (proto.hasOwnProperty(name)) {
//console.log(`${name} defined on:`, proto.constructor.name);
return proto[name];
}
proto = Object.getPrototypeOf(proto);
}
//console.log(`${name} not found in prototype chain.`);
return null;
}
static async invokeJavaScript(name, params, context) {
let error = '';
try {
context = context ?? '';
const func = this.findFunction(this.myViewer, name);
// Check if the function exists and is callable
if (func) {
// Decode the base64 string into a JSON array
const decodedParams = JSON.parse(params);
// Dynamically call the function with the provided parameters
const result = await func.bind(this.myViewer)(...decodedParams);
// If a callback is provided, call it with the result
if (context) {
this.invokeDotNet(context, result ?? "", error);
}
return;
} else {
error = `Function ${name} is not defined or not callable.`;
console.error(error);
this.invokeDotNet(context, '', error);
}
} catch (e) {
console.error(`Error invoking function ${name}:`, e);
error = e.cause ?? JSON.stringify(e, Object.getOwnPropertyNames(e));
this.invokeDotNet(context, '', error);
}
}
static base64toBlob(base64Data, contentType = '', sliceSize = 512) {
const byteCharacters = atob(base64Data);
const byteArrays = [];
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
const slice = byteCharacters.slice(offset, offset + sliceSize);
const byteNumbers = new Array(slice.length);
for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
const blob = new Blob(byteArrays, { type: contentType });
return blob;
}
static async fileToBase64(file) {
if (!file) {
return Promise.resolve("");
}
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result.split(',')[1]); // Extract Base64 part
reader.onerror = (error) => reject(error);
reader.readAsDataURL(file);
});
};
static acquireImageFromCamera(mainViewer) {
const pcCaptureUiConfig = {
type: Dynamsoft.DDV.Elements.Layout,
flexDirection: "column",
className: "ddv-capture-viewer-desktop",
children: [
{
type: Dynamsoft.DDV.Elements.Layout,
className: "ddv-capture-viewer-header-desktop",
children: [
{
type: Dynamsoft.DDV.Elements.CameraResolution,
className: "ddv-capture-viewer-resolution-desktop",
},
Dynamsoft.DDV.Elements.AutoDetect,
{
type: Dynamsoft.DDV.Elements.Capture,
className: "ddv-capture-viewer-capture-desktop",
},
Dynamsoft.DDV.Elements.AutoCapture,
{
type: Dynamsoft.DDV.Elements.Button,
className: "ddv-button-close position-button-close", // Set the button's icon
tooltip: "close viewer", // Set tooltip for the button
events: {
click: "close", // Set the click event
},
},
],
},
Dynamsoft.DDV.Elements.MainView,
{
type: Dynamsoft.DDV.Elements.ImagePreview,
className: "ddv-capture-viewer-image-preview-desktop",
},
],
};
mainViewer?.hide();
const captureViewer = new Dynamsoft.DDV.CaptureViewer({
container: "container",
uiConfig: pcCaptureUiConfig
});
captureViewer.openDocument(mainViewer?.currentDocument.uid); // Open a document which has pages
captureViewer.play();
captureViewer.on("close", () => {
captureViewer.destroy();
mainViewer?.show();
});
}
static async createView(options) {
this.productkey = options.productKey;
this.messageType = options.messageType;
// Public trial license which is valid for 24 hours
// You can request a 30-day trial key from https://www.dynamsoft.com/customer/license/trialLicense/?product=mwc
Dynamsoft.DDV.Core.license = this.productkey;
// Preload DDV Resource
Dynamsoft.DDV.Core.loadWasm();
await Dynamsoft.DDV.Core.init();
Dynamsoft.DDV.setProcessingHandler("imageFilter", new Dynamsoft.DDV.ImageFilter());
if (options.uiConfig === 'desktop-default') {
this.myViewer = new MyDesktopViewer(options);
}else if (options.uiConfig === 'mobile-default') {
this.myViewer = new MyMobileViewer(options);
}
window["myViewer"] = this.myViewer;
return location.origin;
}
}
window.addEventListener("load", function () {
MyViewerApp.messageType = '__RawMessage'; // hybridwebview require this
MyViewerApp.invokeDotNet('load', 'true', '');
MyViewerApp.messageType = ''; // reset this, after initView, we will set it as real type
});
async function invokeJavaScript(name, params, context) {
return MyViewerApp.invokeJavaScript(name, params, context);
}