@papyrus-sdk/engine-native 0.2.7 → 0.2.9
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/android/build.gradle +4 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/cpp/CMakeLists.txt +1 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +79 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/android/build.gradle
CHANGED
|
@@ -5,12 +5,13 @@ def safeExtGet(prop, fallback) {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
android {
|
|
8
|
-
compileSdkVersion safeExtGet('compileSdkVersion',
|
|
8
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 35)
|
|
9
|
+
ndkVersion safeExtGet('ndkVersion', '26.1.10909125')
|
|
9
10
|
namespace 'com.papyrus.engine'
|
|
10
11
|
|
|
11
12
|
defaultConfig {
|
|
12
13
|
minSdkVersion safeExtGet('minSdkVersion', 21)
|
|
13
|
-
targetSdkVersion safeExtGet('targetSdkVersion',
|
|
14
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 35)
|
|
14
15
|
consumerProguardFiles 'consumer-rules.pro'
|
|
15
16
|
externalNativeBuild {
|
|
16
17
|
cmake {
|
|
@@ -34,7 +35,7 @@ android {
|
|
|
34
35
|
|
|
35
36
|
dependencies {
|
|
36
37
|
implementation 'com.facebook.react:react-android'
|
|
37
|
-
implementation('
|
|
38
|
+
implementation('io.github.oothp:pdfium-android:1.9.5-beta01') {
|
|
38
39
|
exclude group: 'com.android.support'
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -7,6 +7,7 @@ add_library(papyrus_text SHARED
|
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
target_compile_options(papyrus_text PRIVATE -Wall -Werror)
|
|
10
|
+
target_link_options(papyrus_text PRIVATE "-Wl,-z,max-page-size=16384")
|
|
10
11
|
set_target_properties(papyrus_text PROPERTIES
|
|
11
12
|
CXX_STANDARD 17
|
|
12
13
|
CXX_STANDARD_REQUIRED YES
|
package/dist/index.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ declare class NativeDocumentEngine extends BaseDocumentEngine {
|
|
|
22
22
|
goToPage(page: number): void;
|
|
23
23
|
setZoom(zoom: number): void;
|
|
24
24
|
getZoom(): number;
|
|
25
|
-
rotate(direction:
|
|
25
|
+
rotate(direction: "clockwise" | "counterclockwise"): void;
|
|
26
26
|
getRotation(): number;
|
|
27
27
|
renderPage(pageIndex: number, target: any, scale: number): Promise<void>;
|
|
28
28
|
renderTextLayer(pageIndex: number, target: any, scale: number): Promise<void>;
|
|
@@ -63,7 +63,7 @@ declare class WebViewDocumentEngine extends BaseDocumentEngine {
|
|
|
63
63
|
private zoom;
|
|
64
64
|
private rotation;
|
|
65
65
|
private outline;
|
|
66
|
-
getRenderTargetType():
|
|
66
|
+
getRenderTargetType(): "webview";
|
|
67
67
|
attachBridge(bridge: WebViewBridge): void;
|
|
68
68
|
handleMessage(raw: string): void;
|
|
69
69
|
load(input: DocumentLoadInput): Promise<void>;
|
|
@@ -72,7 +72,7 @@ declare class WebViewDocumentEngine extends BaseDocumentEngine {
|
|
|
72
72
|
goToPage(page: number): void;
|
|
73
73
|
setZoom(zoom: number): void;
|
|
74
74
|
getZoom(): number;
|
|
75
|
-
rotate(direction:
|
|
75
|
+
rotate(direction: "clockwise" | "counterclockwise"): void;
|
|
76
76
|
getRotation(): number;
|
|
77
77
|
renderPage(pageIndex: number, target: any, scale: number): Promise<void>;
|
|
78
78
|
renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void>;
|
|
@@ -115,7 +115,7 @@ declare class MobileDocumentEngine extends BaseDocumentEngine {
|
|
|
115
115
|
goToPage(page: number): void;
|
|
116
116
|
setZoom(zoom: number): void;
|
|
117
117
|
getZoom(): number;
|
|
118
|
-
rotate(direction:
|
|
118
|
+
rotate(direction: "clockwise" | "counterclockwise"): void;
|
|
119
119
|
getRotation(): number;
|
|
120
120
|
renderPage(pageIndex: number, target: any, scale: number): Promise<void>;
|
|
121
121
|
renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare class NativeDocumentEngine extends BaseDocumentEngine {
|
|
|
22
22
|
goToPage(page: number): void;
|
|
23
23
|
setZoom(zoom: number): void;
|
|
24
24
|
getZoom(): number;
|
|
25
|
-
rotate(direction:
|
|
25
|
+
rotate(direction: "clockwise" | "counterclockwise"): void;
|
|
26
26
|
getRotation(): number;
|
|
27
27
|
renderPage(pageIndex: number, target: any, scale: number): Promise<void>;
|
|
28
28
|
renderTextLayer(pageIndex: number, target: any, scale: number): Promise<void>;
|
|
@@ -63,7 +63,7 @@ declare class WebViewDocumentEngine extends BaseDocumentEngine {
|
|
|
63
63
|
private zoom;
|
|
64
64
|
private rotation;
|
|
65
65
|
private outline;
|
|
66
|
-
getRenderTargetType():
|
|
66
|
+
getRenderTargetType(): "webview";
|
|
67
67
|
attachBridge(bridge: WebViewBridge): void;
|
|
68
68
|
handleMessage(raw: string): void;
|
|
69
69
|
load(input: DocumentLoadInput): Promise<void>;
|
|
@@ -72,7 +72,7 @@ declare class WebViewDocumentEngine extends BaseDocumentEngine {
|
|
|
72
72
|
goToPage(page: number): void;
|
|
73
73
|
setZoom(zoom: number): void;
|
|
74
74
|
getZoom(): number;
|
|
75
|
-
rotate(direction:
|
|
75
|
+
rotate(direction: "clockwise" | "counterclockwise"): void;
|
|
76
76
|
getRotation(): number;
|
|
77
77
|
renderPage(pageIndex: number, target: any, scale: number): Promise<void>;
|
|
78
78
|
renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void>;
|
|
@@ -115,7 +115,7 @@ declare class MobileDocumentEngine extends BaseDocumentEngine {
|
|
|
115
115
|
goToPage(page: number): void;
|
|
116
116
|
setZoom(zoom: number): void;
|
|
117
117
|
getZoom(): number;
|
|
118
|
-
rotate(direction:
|
|
118
|
+
rotate(direction: "clockwise" | "counterclockwise"): void;
|
|
119
119
|
getRotation(): number;
|
|
120
120
|
renderPage(pageIndex: number, target: any, scale: number): Promise<void>;
|
|
121
121
|
renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -289,10 +289,14 @@ var resolveNativeModule = () => {
|
|
|
289
289
|
};
|
|
290
290
|
var resolvePapyrusPageView = () => {
|
|
291
291
|
try {
|
|
292
|
-
return requireNativeViewManager(
|
|
292
|
+
return requireNativeViewManager(
|
|
293
|
+
"PapyrusPageView"
|
|
294
|
+
);
|
|
293
295
|
} catch {
|
|
294
296
|
try {
|
|
295
|
-
return (0, import_react_native3.requireNativeComponent)(
|
|
297
|
+
return (0, import_react_native3.requireNativeComponent)(
|
|
298
|
+
"PapyrusPageView"
|
|
299
|
+
);
|
|
296
300
|
} catch {
|
|
297
301
|
return import_react_native3.View;
|
|
298
302
|
}
|
|
@@ -314,7 +318,9 @@ var NativeDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
314
318
|
async load(input) {
|
|
315
319
|
const { source, type } = normalizeLoadInput(input);
|
|
316
320
|
if (type && type !== "pdf") {
|
|
317
|
-
throw new Error(
|
|
321
|
+
throw new Error(
|
|
322
|
+
`[NativeDocumentEngine] Tipo de documento n\xE3o suportado: ${type}`
|
|
323
|
+
);
|
|
318
324
|
}
|
|
319
325
|
const native = this.assertNativeModule();
|
|
320
326
|
const normalized = await this.normalizeSource(source);
|
|
@@ -361,14 +367,28 @@ var NativeDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
361
367
|
if (!native.renderPage) return;
|
|
362
368
|
const viewTag = this.toNativeViewTag(target);
|
|
363
369
|
if (viewTag === null) return;
|
|
364
|
-
native.renderPage(
|
|
370
|
+
native.renderPage(
|
|
371
|
+
this.engineId,
|
|
372
|
+
pageIndex,
|
|
373
|
+
viewTag,
|
|
374
|
+
scale,
|
|
375
|
+
this.zoom,
|
|
376
|
+
this.rotation
|
|
377
|
+
);
|
|
365
378
|
}
|
|
366
379
|
async renderTextLayer(pageIndex, target, scale) {
|
|
367
380
|
const native = this.assertNativeModule();
|
|
368
381
|
if (!native.renderTextLayer) return;
|
|
369
382
|
const viewTag = this.toNativeViewTag(target);
|
|
370
383
|
if (viewTag === null) return;
|
|
371
|
-
native.renderTextLayer(
|
|
384
|
+
native.renderTextLayer(
|
|
385
|
+
this.engineId,
|
|
386
|
+
pageIndex,
|
|
387
|
+
viewTag,
|
|
388
|
+
scale,
|
|
389
|
+
this.zoom,
|
|
390
|
+
this.rotation
|
|
391
|
+
);
|
|
372
392
|
}
|
|
373
393
|
async getTextContent(pageIndex) {
|
|
374
394
|
const native = this.assertNativeModule();
|
|
@@ -383,7 +403,14 @@ var NativeDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
383
403
|
async selectText(pageIndex, rect) {
|
|
384
404
|
const native = this.assertNativeModule();
|
|
385
405
|
if (!native.selectText) return null;
|
|
386
|
-
return native.selectText(
|
|
406
|
+
return native.selectText(
|
|
407
|
+
this.engineId,
|
|
408
|
+
pageIndex,
|
|
409
|
+
rect.x,
|
|
410
|
+
rect.y,
|
|
411
|
+
rect.width,
|
|
412
|
+
rect.height
|
|
413
|
+
);
|
|
387
414
|
}
|
|
388
415
|
async getOutline() {
|
|
389
416
|
const native = this.assertNativeModule();
|
|
@@ -455,7 +482,8 @@ var NativeDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
455
482
|
}
|
|
456
483
|
toNativeViewTag(target) {
|
|
457
484
|
if (typeof target === "number") return target;
|
|
458
|
-
if (target?.nativeTag && typeof target.nativeTag === "number")
|
|
485
|
+
if (target?.nativeTag && typeof target.nativeTag === "number")
|
|
486
|
+
return target.nativeTag;
|
|
459
487
|
return null;
|
|
460
488
|
}
|
|
461
489
|
};
|
|
@@ -503,15 +531,21 @@ var WebViewDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
503
531
|
if (message.ok) {
|
|
504
532
|
pending.resolve(message.data);
|
|
505
533
|
} else {
|
|
506
|
-
pending.reject(
|
|
534
|
+
pending.reject(
|
|
535
|
+
new Error(message.error ?? "[Papyrus] WebView runtime error")
|
|
536
|
+
);
|
|
507
537
|
}
|
|
508
538
|
return;
|
|
509
539
|
}
|
|
510
540
|
if (message.type === "state") {
|
|
511
|
-
if (typeof message.payload.pageCount === "number")
|
|
512
|
-
|
|
513
|
-
if (typeof message.payload.
|
|
514
|
-
|
|
541
|
+
if (typeof message.payload.pageCount === "number")
|
|
542
|
+
this.pageCount = message.payload.pageCount;
|
|
543
|
+
if (typeof message.payload.currentPage === "number")
|
|
544
|
+
this.currentPage = message.payload.currentPage;
|
|
545
|
+
if (typeof message.payload.zoom === "number")
|
|
546
|
+
this.zoom = message.payload.zoom;
|
|
547
|
+
if (Array.isArray(message.payload.outline))
|
|
548
|
+
this.outline = message.payload.outline;
|
|
515
549
|
return;
|
|
516
550
|
}
|
|
517
551
|
if (message.type === "event") {
|
|
@@ -553,14 +587,20 @@ var WebViewDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
553
587
|
const { source, type } = normalizeLoadInput(input);
|
|
554
588
|
const resolvedType = type ?? inferDocumentType(source);
|
|
555
589
|
if (resolvedType === "pdf") {
|
|
556
|
-
throw new Error(
|
|
590
|
+
throw new Error(
|
|
591
|
+
"[WebViewDocumentEngine] Use o NativeDocumentEngine para PDFs no mobile."
|
|
592
|
+
);
|
|
557
593
|
}
|
|
558
|
-
const payloadSource = await this.normalizeRuntimeSource(
|
|
594
|
+
const payloadSource = await this.normalizeRuntimeSource(
|
|
595
|
+
resolvedType,
|
|
596
|
+
source
|
|
597
|
+
);
|
|
559
598
|
const response = await this.request("load", {
|
|
560
599
|
type: resolvedType,
|
|
561
600
|
source: payloadSource
|
|
562
601
|
});
|
|
563
|
-
if (typeof response?.pageCount === "number")
|
|
602
|
+
if (typeof response?.pageCount === "number")
|
|
603
|
+
this.pageCount = response.pageCount;
|
|
564
604
|
if (Array.isArray(response?.outline)) this.outline = response.outline;
|
|
565
605
|
this.currentPage = 1;
|
|
566
606
|
}
|
|
@@ -602,13 +642,19 @@ var WebViewDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
602
642
|
return await this.request("get-text-content", { pageIndex });
|
|
603
643
|
}
|
|
604
644
|
async getPageDimensions(pageIndex) {
|
|
605
|
-
return await this.request(
|
|
645
|
+
return await this.request(
|
|
646
|
+
"get-page-dimensions",
|
|
647
|
+
{ pageIndex }
|
|
648
|
+
);
|
|
606
649
|
}
|
|
607
650
|
async searchText(query) {
|
|
608
651
|
return await this.request("search-text", { query });
|
|
609
652
|
}
|
|
610
653
|
async selectText(pageIndex, rect) {
|
|
611
|
-
return await this.request("select-text", {
|
|
654
|
+
return await this.request("select-text", {
|
|
655
|
+
pageIndex,
|
|
656
|
+
rect
|
|
657
|
+
});
|
|
612
658
|
}
|
|
613
659
|
async getOutline() {
|
|
614
660
|
if (this.outline.length > 0) return this.outline;
|
|
@@ -620,14 +666,18 @@ var WebViewDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
620
666
|
if (dest.kind === "pageIndex") return dest.value;
|
|
621
667
|
if (dest.kind === "pageNumber") return Math.max(0, dest.value - 1);
|
|
622
668
|
if (dest.kind === "href") {
|
|
623
|
-
return await this.request("get-page-index", {
|
|
669
|
+
return await this.request("get-page-index", {
|
|
670
|
+
dest: dest.value
|
|
671
|
+
});
|
|
624
672
|
}
|
|
625
673
|
return null;
|
|
626
674
|
}
|
|
627
675
|
return await this.request("get-page-index", { dest });
|
|
628
676
|
}
|
|
629
677
|
destroy() {
|
|
630
|
-
this.pending.forEach(
|
|
678
|
+
this.pending.forEach(
|
|
679
|
+
({ reject }) => reject(new Error("[Papyrus] WebView engine destroyed"))
|
|
680
|
+
);
|
|
631
681
|
this.pending.clear();
|
|
632
682
|
this.bridge = null;
|
|
633
683
|
this.ready = false;
|
|
@@ -649,7 +699,7 @@ var WebViewDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
649
699
|
await this.ensureReady();
|
|
650
700
|
const id = `${Date.now()}-${this.requestId++}`;
|
|
651
701
|
return new Promise((resolve, reject) => {
|
|
652
|
-
const timeoutMs = kind === "load" ?
|
|
702
|
+
const timeoutMs = kind === "load" ? 18e4 : 8e3;
|
|
653
703
|
const timeoutId = setTimeout(() => {
|
|
654
704
|
this.pending.delete(id);
|
|
655
705
|
reject(new Error(`[Papyrus] WebView response timeout: ${kind}`));
|
|
@@ -672,7 +722,11 @@ var WebViewDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
672
722
|
const dataUri = parseDataUri(source);
|
|
673
723
|
if (dataUri) {
|
|
674
724
|
if (dataUri.isBase64) {
|
|
675
|
-
return {
|
|
725
|
+
return {
|
|
726
|
+
kind: "base64",
|
|
727
|
+
data: dataUri.data,
|
|
728
|
+
mime: dataUri.mime || void 0
|
|
729
|
+
};
|
|
676
730
|
}
|
|
677
731
|
const text = decodeURIComponent(dataUri.data);
|
|
678
732
|
return { kind: "text", text };
|
|
@@ -712,7 +766,10 @@ var WebViewDocumentEngine = class extends import_core.BaseDocumentEngine {
|
|
|
712
766
|
const bytes = source instanceof Uint8Array ? source : new Uint8Array(source);
|
|
713
767
|
return { kind: "base64", data: encodeBase64(bytes) };
|
|
714
768
|
}
|
|
715
|
-
return {
|
|
769
|
+
return {
|
|
770
|
+
kind: "base64",
|
|
771
|
+
data: encodeBase64(new Uint8Array(source))
|
|
772
|
+
};
|
|
716
773
|
}
|
|
717
774
|
async fetchRemoteSource(type, uri) {
|
|
718
775
|
try {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts","../../../node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts","../../../node_modules/expo-modules-core/src/web/index.ts","../../../node_modules/expo-modules-core/src/NativeModulesProxy.ts","../../../node_modules/expo-modules-core/src/errors/CodedError.ts","../../../node_modules/expo-modules-core/src/Platform.ts","../../../node_modules/expo-modules-core/src/environment/browser.ts","../../../node_modules/expo-modules-core/src/errors/UnavailabilityError.ts","../../../node_modules/expo-modules-core/src/NativeViewManagerAdapter.tsx","../../../node_modules/expo-modules-core/src/sweet/NativeErrorManager.ts","../../../node_modules/expo-modules-core/src/sweet/setUpErrorManager.fx.ts","../../../node_modules/expo-modules-core/src/requireNativeModule.ts"],"sourcesContent":["import type { ComponentType, RefAttributes } from 'react';\nimport { NativeModules, requireNativeComponent, View, type ViewProps } from 'react-native';\nimport { requireNativeViewManager, requireOptionalNativeModule } from 'expo-modules-core';\nimport { BaseDocumentEngine, papyrusEvents } from '@papyrus-sdk/core';\r\nimport {\r\n DocumentLoadInput,\r\n DocumentLoadRequest,\r\n DocumentEngine,\r\n DocumentSource,\r\n DocumentType,\r\n PageDestination,\r\n PapyrusEventType,\r\n RenderTargetType,\r\n TextItem,\r\n OutlineItem,\r\n FileLike,\r\n SearchResult,\r\n TextSelection,\r\n} from '@papyrus-sdk/types';\r\n\r\nconst MODULE_NAME = 'PapyrusNativeEngine';\r\n\r\nconst BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\r\nconst BASE64_LOOKUP = (() => {\r\n const table = new Uint8Array(256);\r\n table.fill(255);\r\n for (let i = 0; i < BASE64_CHARS.length; i += 1) {\r\n table[BASE64_CHARS.charCodeAt(i)] = i;\r\n }\r\n return table;\r\n})();\r\n\r\nconst parseDataUri = (value: string): { mime: string; isBase64: boolean; data: string } | null => {\r\n const match = /^data:([^;,]+)?(;base64)?,(.*)$/.exec(value);\r\n if (!match) return null;\r\n return {\r\n mime: match[1] ?? '',\r\n isBase64: Boolean(match[2]),\r\n data: match[3] ?? '',\r\n };\r\n};\r\n\r\nconst looksLikeUri = (value: string): boolean =>\r\n value.startsWith('http://') ||\r\n value.startsWith('https://') ||\r\n value.startsWith('/') ||\r\n value.startsWith('./') ||\r\n value.startsWith('../') ||\r\n value.startsWith('file://');\r\n\r\nconst isLikelyBase64 = (value: string): boolean => {\r\n if (looksLikeUri(value)) return false;\r\n if (value.includes('.')) return false;\r\n if (value.length < 16) return false;\r\n return /^[A-Za-z0-9+/=]+$/.test(value);\r\n};\r\n\r\nconst isHttpUri = (value: string): boolean =>\r\n value.startsWith('http://') || value.startsWith('https://');\r\n\r\nconst decodeBase64 = (value: string): Uint8Array => {\r\n const clean = value.replace(/[^A-Za-z0-9+/=]/g, '');\r\n const padding = clean.endsWith('==') ? 2 : clean.endsWith('=') ? 1 : 0;\r\n const outputLength = Math.max(0, (clean.length * 3) / 4 - padding);\r\n const output = new Uint8Array(outputLength);\r\n\r\n let buffer = 0;\r\n let bits = 0;\r\n let index = 0;\r\n\r\n for (let i = 0; i < clean.length; i += 1) {\r\n const charCode = clean.charCodeAt(i);\r\n if (charCode === 61) break;\r\n const valueIndex = BASE64_LOOKUP[charCode];\r\n if (valueIndex === 255) continue;\r\n buffer = (buffer << 6) | valueIndex;\r\n bits += 6;\r\n if (bits >= 8) {\r\n bits -= 8;\r\n output[index++] = (buffer >> bits) & 0xff;\r\n }\r\n }\r\n return output;\r\n};\r\n\r\nconst encodeBase64 = (bytes: Uint8Array): string => {\r\n let output = '';\r\n let buffer = 0;\r\n let bits = 0;\r\n\r\n for (let i = 0; i < bytes.length; i += 1) {\r\n buffer = (buffer << 8) | bytes[i];\r\n bits += 8;\r\n while (bits >= 6) {\r\n bits -= 6;\r\n output += BASE64_CHARS[(buffer >> bits) & 0x3f];\r\n }\r\n }\r\n\r\n if (bits > 0) {\r\n output += BASE64_CHARS[(buffer << (6 - bits)) & 0x3f];\r\n }\r\n\r\n const remainder = bytes.length % 3;\r\n if (remainder === 1) return `${output}==`;\r\n if (remainder === 2) return `${output}=`;\r\n return output;\r\n};\r\n\r\nconst isLoadRequest = (input: DocumentLoadInput): input is DocumentLoadRequest =>\r\n typeof input === 'object' && input !== null && 'source' in input && 'type' in input;\r\n\r\nconst normalizeLoadInput = (input: DocumentLoadInput): { source: DocumentSource; type?: DocumentType } =>\r\n isLoadRequest(input) ? { source: input.source, type: input.type } : { source: input };\r\n\r\nconst inferDocumentType = (source: DocumentSource): DocumentType => {\r\n if (typeof source === 'string') {\r\n const dataUri = parseDataUri(source);\r\n if (dataUri?.mime) {\r\n const mime = dataUri.mime.toLowerCase();\r\n if (mime.includes('epub')) return 'epub';\r\n if (mime.includes('text')) return 'text';\r\n if (mime.includes('pdf')) return 'pdf';\r\n }\r\n\r\n const clean = source.split('?')[0].split('#')[0];\r\n const ext = clean.includes('.') ? clean.split('.').pop()?.toLowerCase() : undefined;\r\n if (ext === 'epub') return 'epub';\r\n if (ext === 'txt') return 'text';\r\n if (ext === 'pdf') return 'pdf';\r\n return 'pdf';\r\n }\r\n\r\n if (typeof source === 'object' && source !== null && 'uri' in source) {\r\n const uri = source.uri;\r\n const clean = uri.split('?')[0].split('#')[0];\r\n const ext = clean.includes('.') ? clean.split('.').pop()?.toLowerCase() : undefined;\r\n if (ext === 'epub') return 'epub';\r\n if (ext === 'txt') return 'text';\r\n if (ext === 'pdf') return 'pdf';\r\n }\r\n\r\n return 'pdf';\r\n};\r\n\r\ntype NativeDocumentSource = {\r\n uri?: string;\r\n data?: Uint8Array;\r\n};\r\n\r\ntype NativePageDestination = {\r\n kind: 'pageIndex' | 'pageNumber' | 'named';\r\n value: number | string;\r\n};\r\n\r\nconst normalizeNativeDestination = (dest: PageDestination): NativePageDestination | null => {\r\n if (!dest) return null;\r\n if (typeof dest === 'string') {\r\n return { kind: 'named', value: dest };\r\n }\r\n\r\n if (dest.kind === 'pageIndex' || dest.kind === 'pageNumber' || dest.kind === 'named') {\r\n return { kind: dest.kind, value: dest.value };\r\n }\r\n\r\n return null;\r\n};\r\n\r\ntype NativeEngineModule = {\r\n createEngine?: () => string;\r\n destroyEngine?: (engineId: string) => void;\r\n load?: (engineId: string, source: NativeDocumentSource) => Promise<{ pageCount?: number } | void>;\r\n getPageCount?: (engineId: string) => number;\r\n renderPage?: (engineId: string, pageIndex: number, target: number, scale: number, zoom: number, rotation: number) => void;\r\n renderTextLayer?: (engineId: string, pageIndex: number, target: number, scale: number, zoom: number, rotation: number) => void;\r\n getTextContent?: (engineId: string, pageIndex: number) => Promise<TextItem[]>;\r\n getPageDimensions?: (engineId: string, pageIndex: number) => Promise<{ width: number; height: number }>;\r\n searchText?: (engineId: string, query: string) => Promise<SearchResult[]>;\r\n selectText?: (engineId: string, pageIndex: number, x: number, y: number, width: number, height: number) => Promise<TextSelection | null>;\r\n getOutline?: (engineId: string) => Promise<OutlineItem[]>;\r\n getPageIndex?: (engineId: string, dest: NativePageDestination) => Promise<number | null>;\r\n};\r\n\r\nexport type PapyrusPageViewProps = ViewProps & {\n engineId?: string;\n};\n\ntype PapyrusPageViewComponent = ComponentType<PapyrusPageViewProps & RefAttributes<View>>;\n\nconst resolveNativeModule = (): NativeEngineModule | null => {\n const expoModule = requireOptionalNativeModule<NativeEngineModule>(MODULE_NAME);\n if (expoModule) return expoModule;\n const rnModule = (NativeModules as Record<string, NativeEngineModule | undefined>)[MODULE_NAME];\n return rnModule ?? null;\n};\n\nconst resolvePapyrusPageView = (): PapyrusPageViewComponent => {\n try {\n return requireNativeViewManager<PapyrusPageViewProps>('PapyrusPageView') as PapyrusPageViewComponent;\n } catch {\n try {\n return requireNativeComponent<PapyrusPageViewProps>('PapyrusPageView') as PapyrusPageViewComponent;\n } catch {\n return View as PapyrusPageViewComponent;\n }\n }\n};\n\r\nexport const PapyrusPageView = resolvePapyrusPageView();\r\n\r\nexport class NativeDocumentEngine extends BaseDocumentEngine {\r\n private nativeModule: NativeEngineModule | null = null;\r\n private engineId: string = 'default';\r\n private pageCount: number = 0;\r\n private currentPage: number = 1;\r\n private zoom: number = 1.0;\r\n private rotation: number = 0;\r\n\r\n constructor() {\n super();\n this.nativeModule = resolveNativeModule();\n this.engineId = this.nativeModule?.createEngine ? this.nativeModule.createEngine() : 'default';\n }\n\r\n async load(input: DocumentLoadInput): Promise<void> {\r\n const { source, type } = normalizeLoadInput(input);\r\n if (type && type !== 'pdf') {\r\n throw new Error(`[NativeDocumentEngine] Tipo de documento não suportado: ${type}`);\r\n }\r\n\r\n const native = this.assertNativeModule();\r\n const normalized = await this.normalizeSource(source);\r\n const result = native.load ? await native.load(this.engineId, normalized) : undefined;\r\n\r\n if (result && typeof result.pageCount === 'number') {\r\n this.pageCount = result.pageCount;\r\n } else if (native.getPageCount) {\r\n this.pageCount = native.getPageCount(this.engineId);\r\n } else {\r\n this.pageCount = 0;\r\n }\r\n\r\n this.currentPage = 1;\r\n }\r\n\r\n getPageCount(): number {\r\n return this.pageCount;\r\n }\r\n\r\n getCurrentPage(): number {\r\n return this.currentPage;\r\n }\r\n\r\n goToPage(page: number): void {\r\n if (page >= 1 && page <= this.pageCount) {\r\n this.currentPage = page;\r\n }\r\n }\r\n\r\n setZoom(zoom: number): void {\r\n this.zoom = Math.max(0.1, Math.min(5.0, zoom));\r\n }\r\n\r\n getZoom(): number {\r\n return this.zoom;\r\n }\r\n\r\n rotate(direction: 'clockwise' | 'counterclockwise'): void {\r\n if (direction === 'clockwise') {\r\n this.rotation = (this.rotation + 90) % 360;\r\n } else {\r\n this.rotation = (this.rotation - 90) % 360;\r\n if (this.rotation < 0) this.rotation += 360;\r\n }\r\n }\r\n\r\n getRotation(): number {\r\n return this.rotation;\r\n }\r\n\r\n async renderPage(pageIndex: number, target: any, scale: number): Promise<void> {\r\n const native = this.assertNativeModule();\r\n if (!native.renderPage) return;\r\n const viewTag = this.toNativeViewTag(target);\r\n if (viewTag === null) return;\r\n native.renderPage(this.engineId, pageIndex, viewTag, scale, this.zoom, this.rotation);\r\n }\r\n\r\n async renderTextLayer(pageIndex: number, target: any, scale: number): Promise<void> {\r\n const native = this.assertNativeModule();\r\n if (!native.renderTextLayer) return;\r\n const viewTag = this.toNativeViewTag(target);\r\n if (viewTag === null) return;\r\n native.renderTextLayer(this.engineId, pageIndex, viewTag, scale, this.zoom, this.rotation);\r\n }\r\n\r\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\r\n const native = this.assertNativeModule();\r\n if (!native.getTextContent) return [];\r\n return native.getTextContent(this.engineId, pageIndex);\r\n }\r\n\r\n async getPageDimensions(pageIndex: number): Promise<{ width: number; height: number }> {\r\n const native = this.assertNativeModule();\r\n if (!native.getPageDimensions) return { width: 0, height: 0 };\r\n return native.getPageDimensions(this.engineId, pageIndex);\r\n }\r\n\r\n async selectText(\r\n pageIndex: number,\r\n rect: { x: number; y: number; width: number; height: number }\r\n ): Promise<TextSelection | null> {\r\n const native = this.assertNativeModule();\r\n if (!native.selectText) return null;\r\n return native.selectText(this.engineId, pageIndex, rect.x, rect.y, rect.width, rect.height);\r\n }\r\n\r\n async getOutline(): Promise<OutlineItem[]> {\r\n const native = this.assertNativeModule();\r\n if (!native.getOutline) return [];\r\n return native.getOutline(this.engineId);\r\n }\r\n\r\n async searchText(query: string): Promise<SearchResult[]> {\r\n const native = this.assertNativeModule();\r\n if (!native.searchText) return [];\r\n return native.searchText(this.engineId, query);\r\n }\r\n\r\n async getPageIndex(dest: PageDestination): Promise<number | null> {\r\n if (!dest) return null;\r\n if (typeof dest !== 'string') {\r\n if (dest.kind === 'pageIndex') return dest.value;\r\n if (dest.kind === 'pageNumber') return Math.max(0, dest.value - 1);\r\n }\r\n\r\n const native = this.assertNativeModule();\r\n if (!native.getPageIndex) return null;\r\n const normalized = normalizeNativeDestination(dest);\r\n if (!normalized || normalized.kind !== 'named') return null;\r\n return native.getPageIndex(this.engineId, normalized);\r\n }\r\n\r\n destroy(): void {\r\n this.nativeModule?.destroyEngine?.(this.engineId);\r\n }\r\n\r\n private assertNativeModule(): NativeEngineModule {\n if (!this.nativeModule) {\n this.nativeModule = resolveNativeModule();\n }\n if (!this.nativeModule) {\n throw new Error(\n `[Papyrus] Native module \"${MODULE_NAME}\" not found. Use a dev client or a native build (Expo Go is not supported).`\n );\n }\n return this.nativeModule;\r\n }\r\n\r\n private async normalizeSource(source: DocumentSource): Promise<NativeDocumentSource> {\r\n if (typeof source === 'string') {\r\n const dataUri = parseDataUri(source);\r\n if (dataUri?.isBase64) {\r\n return { data: decodeBase64(dataUri.data) };\r\n }\r\n if (looksLikeUri(source)) return { uri: source };\r\n if (isLikelyBase64(source)) return { data: decodeBase64(source) };\r\n return { uri: source };\r\n }\r\n if (this.isUriSource(source)) return { uri: source.uri };\r\n if (this.isDataSource(source)) {\r\n const data = source.data instanceof Uint8Array ? source.data : new Uint8Array(source.data);\r\n return { data };\r\n }\r\n if (this.isFileLike(source)) {\r\n const buffer = await source.arrayBuffer();\r\n return { data: new Uint8Array(buffer) };\r\n }\r\n if (source instanceof ArrayBuffer) return { data: new Uint8Array(source) };\r\n if (source instanceof Uint8Array) return { data: source };\r\n return { data: new Uint8Array(source as ArrayBuffer) };\r\n }\r\n\r\n private isUriSource(source: DocumentSource): source is { uri: string } {\r\n return typeof source === 'object' && source !== null && 'uri' in source;\r\n }\r\n\r\n private isDataSource(source: DocumentSource): source is { data: ArrayBuffer | Uint8Array } {\r\n return typeof source === 'object' && source !== null && 'data' in source;\r\n }\r\n\r\n private isFileLike(source: DocumentSource): source is FileLike {\r\n return typeof source === 'object' && source !== null && typeof (source as FileLike).arrayBuffer === 'function';\r\n }\r\n\r\n private toNativeViewTag(target: any): number | null {\r\n if (typeof target === 'number') return target;\r\n if (target?.nativeTag && typeof target.nativeTag === 'number') return target.nativeTag;\r\n return null;\r\n }\r\n}\r\n\r\ntype WebViewBridge = {\r\n postMessage: (message: string) => void;\r\n};\r\n\r\ntype WebViewResponseMessage = {\r\n type: 'response';\r\n id: string;\r\n ok: boolean;\r\n data?: any;\r\n error?: string;\r\n};\r\n\r\ntype WebViewEventMessage = {\r\n type: 'event';\r\n name: string;\r\n payload?: any;\r\n};\r\n\r\ntype WebViewStateMessage = {\r\n type: 'state';\r\n payload: {\r\n pageCount?: number;\r\n currentPage?: number;\r\n zoom?: number;\r\n outline?: OutlineItem[];\r\n };\r\n};\r\n\r\ntype WebViewReadyMessage = {\r\n type: 'ready';\r\n};\r\n\r\ntype WebViewRuntimeMessage =\r\n | WebViewResponseMessage\r\n | WebViewEventMessage\r\n | WebViewStateMessage\r\n | WebViewReadyMessage;\r\n\r\ntype WebViewSourcePayload =\r\n | { kind: 'uri'; uri: string }\r\n | { kind: 'base64'; data: string; mime?: string }\r\n | { kind: 'text'; text: string };\r\n\r\nexport class WebViewDocumentEngine extends BaseDocumentEngine {\r\n private bridge: WebViewBridge | null = null;\r\n private ready = false;\r\n private requestId = 0;\r\n private pending = new Map<string, { resolve: (data: any) => void; reject: (error: Error) => void }>();\r\n private bridgeResolvers: Array<(bridge: WebViewBridge) => void> = [];\r\n private readyResolvers: Array<() => void> = [];\r\n private pageCount = 0;\r\n private currentPage = 1;\r\n private zoom = 1.0;\r\n private rotation = 0;\r\n private outline: OutlineItem[] = [];\r\n\r\n getRenderTargetType(): 'webview' {\r\n return 'webview';\r\n }\r\n\r\n attachBridge(bridge: WebViewBridge): void {\r\n this.bridge = bridge;\r\n this.bridgeResolvers.forEach((resolve) => resolve(bridge));\r\n this.bridgeResolvers = [];\r\n }\r\n\r\n handleMessage(raw: string): void {\r\n let message: WebViewRuntimeMessage | null = null;\r\n try {\r\n message = JSON.parse(raw) as WebViewRuntimeMessage;\r\n } catch {\r\n return;\r\n }\r\n\r\n if (!message) return;\r\n\r\n if (message.type === 'ready') {\r\n this.ready = true;\r\n this.readyResolvers.forEach((resolve) => resolve());\r\n this.readyResolvers = [];\r\n return;\r\n }\r\n\r\n if (message.type === 'response') {\r\n const pending = this.pending.get(message.id);\r\n if (!pending) return;\r\n this.pending.delete(message.id);\r\n if (message.ok) {\r\n pending.resolve(message.data);\r\n } else {\r\n pending.reject(new Error(message.error ?? '[Papyrus] WebView runtime error'));\r\n }\r\n return;\r\n }\r\n\r\n if (message.type === 'state') {\r\n if (typeof message.payload.pageCount === 'number') this.pageCount = message.payload.pageCount;\r\n if (typeof message.payload.currentPage === 'number') this.currentPage = message.payload.currentPage;\r\n if (typeof message.payload.zoom === 'number') this.zoom = message.payload.zoom;\r\n if (Array.isArray(message.payload.outline)) this.outline = message.payload.outline;\r\n return;\r\n }\r\n\r\n if (message.type === 'event') {\r\n const payload = message.payload ?? {};\r\n if (message.name === 'RUNTIME_LOG') {\r\n if (__DEV__) {\r\n const text = typeof payload?.message === 'string' ? payload.message : JSON.stringify(payload);\r\n console.log('[Papyrus WebView runtime]', text);\r\n }\r\n return;\r\n }\r\n if (message.name === 'RUNTIME_ERROR') {\n const errorMessage = typeof payload?.message === 'string' ? payload.message : '';\n if (errorMessage.includes('ResizeObserver loop')) {\n return;\n }\n if (__DEV__) {\n console.warn('[Papyrus WebView runtime]', payload);\n }\n return;\n }\n if (message.name === PapyrusEventType.TEXT_SELECTED) {\r\n papyrusEvents.emit(PapyrusEventType.TEXT_SELECTED, payload);\r\n } else if (message.name === PapyrusEventType.SEARCH_TRIGGERED) {\r\n papyrusEvents.emit(PapyrusEventType.SEARCH_TRIGGERED, payload);\r\n } else if (message.name === PapyrusEventType.DOCUMENT_LOADED) {\r\n if (typeof payload.pageCount === 'number') {\r\n this.pageCount = payload.pageCount;\r\n }\r\n papyrusEvents.emit(PapyrusEventType.DOCUMENT_LOADED, payload);\r\n }\r\n return;\r\n }\r\n\r\n if (__DEV__) {\r\n console.warn('[Papyrus WebView] Unknown message', message);\r\n }\r\n }\r\n\r\n async load(input: DocumentLoadInput): Promise<void> {\r\n const { source, type } = normalizeLoadInput(input);\r\n const resolvedType = type ?? inferDocumentType(source);\r\n if (resolvedType === 'pdf') {\r\n throw new Error('[WebViewDocumentEngine] Use o NativeDocumentEngine para PDFs no mobile.');\r\n }\r\n\r\n const payloadSource = await this.normalizeRuntimeSource(resolvedType, source);\r\n const response = await this.request<{ pageCount?: number; outline?: OutlineItem[] }>('load', {\r\n type: resolvedType,\r\n source: payloadSource,\r\n });\r\n\r\n if (typeof response?.pageCount === 'number') this.pageCount = response.pageCount;\r\n if (Array.isArray(response?.outline)) this.outline = response.outline;\r\n this.currentPage = 1;\r\n }\r\n\r\n getPageCount(): number {\r\n return this.pageCount;\r\n }\r\n\r\n getCurrentPage(): number {\r\n return this.currentPage;\r\n }\r\n\r\n goToPage(page: number): void {\r\n if (page < 1) return;\r\n this.currentPage = page;\r\n void this.request('go-to-page', { page });\r\n }\r\n\r\n setZoom(zoom: number): void {\r\n this.zoom = Math.max(0.5, Math.min(4.0, zoom));\r\n void this.request('set-zoom', { zoom: this.zoom });\r\n }\r\n\r\n getZoom(): number {\r\n return this.zoom;\r\n }\r\n\r\n rotate(direction: 'clockwise' | 'counterclockwise'): void {\r\n if (direction === 'clockwise') {\r\n this.rotation = (this.rotation + 90) % 360;\r\n } else {\r\n this.rotation = (this.rotation - 90) % 360;\r\n if (this.rotation < 0) this.rotation += 360;\r\n }\r\n void this.request('set-rotation', { rotation: this.rotation });\r\n }\r\n\r\n getRotation(): number {\r\n return this.rotation;\r\n }\r\n\r\n async renderPage(pageIndex: number, target: any, scale: number): Promise<void> {\r\n void pageIndex;\r\n void target;\r\n void scale;\r\n }\r\n\r\n async renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void> {\r\n void pageIndex;\r\n void container;\r\n void scale;\r\n }\r\n\r\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\r\n return await this.request<TextItem[]>('get-text-content', { pageIndex });\r\n }\r\n\r\n async getPageDimensions(pageIndex: number): Promise<{ width: number; height: number }> {\r\n return await this.request<{ width: number; height: number }>('get-page-dimensions', { pageIndex });\r\n }\r\n\r\n async searchText(query: string): Promise<SearchResult[]> {\r\n return await this.request<SearchResult[]>('search-text', { query });\r\n }\r\n\r\n async selectText(\r\n pageIndex: number,\r\n rect: { x: number; y: number; width: number; height: number }\r\n ): Promise<TextSelection | null> {\r\n return await this.request<TextSelection | null>('select-text', { pageIndex, rect });\r\n }\r\n\r\n async getOutline(): Promise<OutlineItem[]> {\r\n if (this.outline.length > 0) return this.outline;\r\n return await this.request<OutlineItem[]>('get-outline');\r\n }\r\n\r\n async getPageIndex(dest: PageDestination): Promise<number | null> {\r\n if (!dest) return null;\r\n if (typeof dest !== 'string') {\r\n if (dest.kind === 'pageIndex') return dest.value;\r\n if (dest.kind === 'pageNumber') return Math.max(0, dest.value - 1);\r\n if (dest.kind === 'href') {\r\n return await this.request<number | null>('get-page-index', { dest: dest.value });\r\n }\r\n return null;\r\n }\r\n return await this.request<number | null>('get-page-index', { dest });\r\n }\r\n\r\n destroy(): void {\r\n this.pending.forEach(({ reject }) => reject(new Error('[Papyrus] WebView engine destroyed')));\r\n this.pending.clear();\r\n this.bridge = null;\r\n this.ready = false;\r\n }\r\n\r\n private async ensureBridge(): Promise<WebViewBridge> {\r\n if (this.bridge) return this.bridge;\r\n return new Promise((resolve) => {\r\n this.bridgeResolvers.push(resolve);\r\n });\r\n }\r\n\r\n private async ensureReady(): Promise<void> {\r\n if (this.ready) return;\r\n return new Promise((resolve) => {\r\n this.readyResolvers.push(resolve);\r\n });\r\n }\r\n\r\n private async request<T = any>(kind: string, payload?: any): Promise<T> {\r\n const bridge = await this.ensureBridge();\r\n await this.ensureReady();\r\n const id = `${Date.now()}-${this.requestId++}`;\r\n return new Promise<T>((resolve, reject) => {\r\n const timeoutMs = kind === 'load' ? 30000 : 8000;\r\n const timeoutId = setTimeout(() => {\r\n this.pending.delete(id);\r\n reject(new Error(`[Papyrus] WebView response timeout: ${kind}`));\r\n }, timeoutMs);\r\n this.pending.set(id, {\r\n resolve: (data) => {\r\n clearTimeout(timeoutId);\r\n resolve(data);\r\n },\r\n reject: (error) => {\r\n clearTimeout(timeoutId);\r\n reject(error);\r\n },\r\n });\r\n bridge.postMessage(JSON.stringify({ id, kind, payload }));\r\n });\r\n }\r\n\r\n private async normalizeRuntimeSource(type: DocumentType, source: DocumentSource): Promise<WebViewSourcePayload> {\r\n if (typeof source === 'string') {\r\n const dataUri = parseDataUri(source);\r\n if (dataUri) {\r\n if (dataUri.isBase64) {\r\n return { kind: 'base64', data: dataUri.data, mime: dataUri.mime || undefined };\r\n }\r\n const text = decodeURIComponent(dataUri.data);\r\n return { kind: 'text', text };\r\n }\r\n\r\n if (looksLikeUri(source)) {\r\n if (isHttpUri(source)) {\r\n const fetched = await this.fetchRemoteSource(type, source);\r\n if (fetched) return fetched;\r\n }\r\n return { kind: 'uri', uri: source };\r\n }\r\n\r\n if (isLikelyBase64(source)) {\r\n return { kind: 'base64', data: source };\r\n }\r\n\r\n if (type === 'text') {\r\n return { kind: 'text', text: source };\r\n }\r\n\r\n return { kind: 'uri', uri: source };\r\n }\r\n\r\n if (this.isUriSource(source)) {\r\n const uri = source.uri;\r\n if (isHttpUri(uri)) {\r\n const fetched = await this.fetchRemoteSource(type, uri);\r\n if (fetched) return fetched;\r\n }\r\n return { kind: 'uri', uri };\r\n }\r\n if (this.isDataSource(source)) {\r\n const bytes = source.data instanceof Uint8Array ? source.data : new Uint8Array(source.data);\r\n return { kind: 'base64', data: encodeBase64(bytes) };\r\n }\r\n if (this.isFileLike(source)) {\r\n const buffer = await source.arrayBuffer();\r\n return { kind: 'base64', data: encodeBase64(new Uint8Array(buffer)) };\r\n }\r\n if (source instanceof ArrayBuffer || source instanceof Uint8Array) {\r\n const bytes = source instanceof Uint8Array ? source : new Uint8Array(source);\r\n return { kind: 'base64', data: encodeBase64(bytes) };\r\n }\r\n\r\n return { kind: 'base64', data: encodeBase64(new Uint8Array(source as ArrayBuffer)) };\r\n }\r\n\r\n private async fetchRemoteSource(type: DocumentType, uri: string): Promise<WebViewSourcePayload | null> {\r\n try {\r\n const response = await fetch(uri);\r\n if (!response.ok) return null;\r\n if (type === 'text') {\r\n const text = await response.text();\r\n return { kind: 'text', text };\r\n }\r\n if (type === 'epub') {\r\n const buffer = await this.readResponseBuffer(response);\r\n return { kind: 'base64', data: encodeBase64(new Uint8Array(buffer)) };\r\n }\r\n return null;\r\n } catch {\r\n return null;\r\n }\r\n }\r\n\r\n private async readResponseBuffer(response: Response): Promise<ArrayBuffer> {\r\n try {\r\n return await response.arrayBuffer();\r\n } catch {\r\n const blob = await response.blob();\r\n return await new Promise<ArrayBuffer>((resolve, reject) => {\r\n const reader = new FileReader();\r\n reader.onerror = () => reject(new Error('[Papyrus] Failed to read response blob'));\r\n reader.onload = () => resolve(reader.result as ArrayBuffer);\r\n reader.readAsArrayBuffer(blob);\r\n });\r\n }\r\n }\r\n\r\n private isUriSource(source: DocumentSource): source is { uri: string } {\r\n return typeof source === 'object' && source !== null && 'uri' in source;\r\n }\r\n\r\n private isDataSource(source: DocumentSource): source is { data: ArrayBuffer | Uint8Array } {\r\n return typeof source === 'object' && source !== null && 'data' in source;\r\n }\r\n\r\n private isFileLike(source: DocumentSource): source is FileLike {\r\n return typeof source === 'object' && source !== null && typeof (source as FileLike).arrayBuffer === 'function';\r\n }\r\n}\r\n\r\nexport class MobileDocumentEngine extends BaseDocumentEngine {\r\n private pdfEngine: NativeDocumentEngine;\r\n private webEngine: WebViewDocumentEngine;\r\n private activeEngine: DocumentEngine;\r\n\r\n constructor() {\r\n super();\r\n this.pdfEngine = new NativeDocumentEngine();\r\n this.webEngine = new WebViewDocumentEngine();\r\n this.activeEngine = this.pdfEngine;\r\n }\r\n\r\n getRenderTargetType(): RenderTargetType {\r\n return this.activeEngine.getRenderTargetType?.() ?? 'canvas';\r\n }\r\n\r\n attachWebView(bridge: WebViewBridge): void {\r\n this.webEngine.attachBridge(bridge);\r\n }\r\n\r\n handleWebViewMessage(data: string): void {\r\n this.webEngine.handleMessage(data);\r\n }\r\n\r\n async load(input: DocumentLoadInput): Promise<void> {\r\n const { source, type } = normalizeLoadInput(input);\r\n const resolvedType = type ?? inferDocumentType(source);\r\n this.activeEngine = resolvedType === 'pdf' ? this.pdfEngine : this.webEngine;\r\n await this.activeEngine.load({ type: resolvedType, source });\r\n }\r\n\r\n getPageCount(): number {\r\n return this.activeEngine.getPageCount();\r\n }\r\n\r\n getCurrentPage(): number {\r\n return this.activeEngine.getCurrentPage();\r\n }\r\n\r\n goToPage(page: number): void {\r\n this.activeEngine.goToPage(page);\r\n }\r\n\r\n setZoom(zoom: number): void {\r\n this.activeEngine.setZoom(zoom);\r\n }\r\n\r\n getZoom(): number {\r\n return this.activeEngine.getZoom();\r\n }\r\n\r\n rotate(direction: 'clockwise' | 'counterclockwise'): void {\r\n this.activeEngine.rotate(direction);\r\n }\r\n\r\n getRotation(): number {\r\n return this.activeEngine.getRotation();\r\n }\r\n\r\n async renderPage(pageIndex: number, target: any, scale: number): Promise<void> {\r\n await this.activeEngine.renderPage(pageIndex, target, scale);\r\n }\r\n\r\n async renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void> {\r\n await this.activeEngine.renderTextLayer(pageIndex, container, scale);\r\n }\r\n\r\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\r\n return await this.activeEngine.getTextContent(pageIndex);\r\n }\r\n\r\n async getPageDimensions(pageIndex: number): Promise<{ width: number; height: number }> {\r\n return await this.activeEngine.getPageDimensions(pageIndex);\r\n }\r\n\r\n async searchText(query: string): Promise<SearchResult[]> {\r\n if (typeof this.activeEngine.searchText === 'function') {\r\n return await this.activeEngine.searchText(query);\r\n }\r\n return [];\r\n }\r\n\r\n async selectText(\r\n pageIndex: number,\r\n rect: { x: number; y: number; width: number; height: number }\r\n ): Promise<TextSelection | null> {\r\n if (typeof this.activeEngine.selectText === 'function') {\r\n return await this.activeEngine.selectText(pageIndex, rect);\r\n }\r\n return null;\r\n }\r\n\r\n async getOutline(): Promise<OutlineItem[]> {\r\n return await this.activeEngine.getOutline();\r\n }\r\n\r\n async getPageIndex(dest: PageDestination): Promise<number | null> {\r\n return await this.activeEngine.getPageIndex(dest);\r\n }\r\n\r\n destroy(): void {\r\n this.pdfEngine.destroy();\r\n this.webEngine.destroy();\r\n }\r\n}\r\n","import { NativeModules, Platform } from 'react-native';\n\nimport { registerWebGlobals } from './web/index';\n\n/**\n * Ensures that the native modules are installed in the current runtime.\n * Otherwise, it synchronously calls a native function that installs them.\n */\nexport function ensureNativeModulesAreInstalled(): void {\n if (globalThis.expo) {\n return;\n }\n try {\n if (Platform.OS === 'web') {\n // Requiring web folder sets up the `globalThis.expo` object.\n registerWebGlobals();\n } else {\n // TODO: ExpoModulesCore shouldn't be optional here,\n // but to keep backwards compatibility let's just ignore it in SDK 50.\n // In most cases the modules were already installed from the native side.\n NativeModules.ExpoModulesCore?.installModules();\n }\n } catch (error) {\n console.error(`Unable to install Expo modules: ${error}`);\n }\n}\n","export function registerWebGlobals() {}\n","import type { ProxyNativeModule } from './NativeModulesProxy.types';\n\n// We default to an empty object shim wherever we don't have an environment-specific implementation\n\n/**\n * @deprecated `NativeModulesProxy` is deprecated and might be removed in the future releases.\n * Use `requireNativeModule` or `requireOptionalNativeModule` instead.\n */\nexport default {} as { [moduleName: string]: ProxyNativeModule };\n","/**\n * A general error class that should be used for all errors in Expo modules.\n * Guarantees a `code` field that can be used to differentiate between different\n * types of errors without further subclassing Error.\n */\nexport class CodedError extends Error {\n code: string;\n info?: any;\n\n constructor(code: string, message: string) {\n super(message);\n this.code = code;\n }\n}\n","import { PlatformOSType, Platform as ReactNativePlatform } from 'react-native';\n\nimport {\n isDOMAvailable,\n canUseEventListeners,\n canUseViewport,\n isAsyncDebugging,\n} from './environment/browser';\n\nexport type PlatformSelectOSType = PlatformOSType | 'native' | 'electron' | 'default';\n\nexport type PlatformSelect = <T>(specifics: { [platform in PlatformSelectOSType]?: T }) => T;\n\nif (__DEV__ && typeof process.env.EXPO_OS === 'undefined') {\n console.warn(\n `The global process.env.EXPO_OS is not defined. This should be inlined by babel-preset-expo during transformation.`\n );\n}\n\nconst nativeSelect =\n typeof window !== 'undefined'\n ? ReactNativePlatform.select\n : // process.env.EXPO_OS is injected by `babel-preset-expo` and available in both client and `react-server` environments.\n // Opt to use the env var when possible, and fallback to the React Native Platform module when it's not (arbitrary bundlers and transformers).\n function select<T>(specifics: { [platform in PlatformSelectOSType]?: T }): T | undefined {\n if (!process.env.EXPO_OS) return undefined;\n if (specifics.hasOwnProperty(process.env.EXPO_OS)) {\n return specifics[process.env.EXPO_OS]!;\n } else if (process.env.EXPO_OS !== 'web' && specifics.hasOwnProperty('native')) {\n return specifics.native!;\n } else if (specifics.hasOwnProperty('default')) {\n return specifics.default!;\n }\n // do nothing...\n return undefined;\n };\n\nconst Platform = {\n /**\n * Denotes the currently running platform.\n * Can be one of ios, android, web.\n */\n OS: process.env.EXPO_OS || ReactNativePlatform.OS,\n /**\n * Returns the value with the matching platform.\n * Object keys can be any of ios, android, native, web, default.\n *\n * @ios ios, native, default\n * @android android, native, default\n * @web web, default\n */\n select: nativeSelect as PlatformSelect,\n /**\n * Denotes if the DOM API is available in the current environment.\n * The DOM is not available in native React runtimes and Node.js.\n */\n isDOMAvailable,\n /**\n * Denotes if the current environment can attach event listeners\n * to the window. This will return false in native React\n * runtimes and Node.js.\n */\n canUseEventListeners,\n /**\n * Denotes if the current environment can inspect properties of the\n * screen on which the current window is being rendered. This will\n * return false in native React runtimes and Node.js.\n */\n canUseViewport,\n /**\n * If the JavaScript is being executed in a remote JavaScript environment.\n * When `true`, synchronous native invocations cannot be executed.\n */\n isAsyncDebugging,\n};\n\nexport default Platform;\n","declare const global: any;\n\n// In standard node environments there is no DOM API\nexport const isDOMAvailable = false;\nexport const canUseEventListeners = false;\nexport const canUseViewport = false;\n\nexport let isAsyncDebugging: boolean = false;\n\nif (__DEV__) {\n // These native globals are injected by native React runtimes and not standard browsers\n // we can use them to determine if the JS is being executed in Chrome.\n isAsyncDebugging =\n !global.nativeExtensions && !global.nativeCallSyncHook && !global.RN$Bridgeless;\n}\n","import { CodedError } from './CodedError';\nimport Platform from '../Platform';\n\n/**\n * A class for errors to be thrown when a property is accessed which is\n * unavailable, unsupported, or not currently implemented on the running\n * platform.\n */\nexport class UnavailabilityError extends CodedError {\n constructor(moduleName: string, propertyName: string) {\n super(\n 'ERR_UNAVAILABLE',\n `The method or property ${moduleName}.${propertyName} is not available on ${Platform.OS}, are you sure you've linked all the native dependencies properly?`\n );\n }\n}\n","import React from 'react';\n\nimport { UnavailabilityError } from './errors/UnavailabilityError';\n\n/**\n * A drop-in replacement for `requireNativeComponent`.\n */\nexport function requireNativeViewManager<P = any>(viewName: string): React.ComponentType<P> {\n throw new UnavailabilityError('expo-modules-core', 'requireNativeViewManager');\n}\n","import NativeModulesProxy from '../NativeModulesProxy';\nexport default NativeModulesProxy.ExpoModulesCoreErrorManager;\n","import NativeErrorManager from './NativeErrorManager';\nimport Platform from '../Platform';\nimport { CodedError } from '../errors/CodedError';\n\nif (__DEV__ && Platform.OS === 'android' && NativeErrorManager) {\n const onNewException = 'ExpoModulesCoreErrorManager.onNewException';\n const onNewWarning = 'ExpoModulesCoreErrorManager.onNewWarning';\n\n NativeErrorManager.addListener(onNewException, ({ message }: { message: string }) => {\n console.error(message);\n });\n\n NativeErrorManager.addListener(onNewWarning, ({ message }: { message: string }) => {\n console.warn(message);\n });\n}\n\n// We have to export `CodedError` via global object to use in later in the C++ code.\nglobalThis.ExpoModulesCore_CodedError = CodedError;\n","import NativeModulesProxy from './NativeModulesProxy';\nimport { ensureNativeModulesAreInstalled } from './ensureNativeModulesAreInstalled';\n\n/**\n * Imports the native module registered with given name. In the first place it tries to load\n * the module installed through the JSI host object and then falls back to the bridge proxy module.\n * Notice that the modules loaded from the proxy may not support some features like synchronous functions.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module.\n * @throws Error when there is no native module with given name.\n */\nexport function requireNativeModule<ModuleType = any>(moduleName: string): ModuleType {\n const nativeModule = requireOptionalNativeModule<ModuleType>(moduleName);\n\n if (!nativeModule) {\n throw new Error(`Cannot find native module '${moduleName}'`);\n }\n return nativeModule;\n}\n\n/**\n * Imports the native module registered with the given name. The same as `requireNativeModule`,\n * but returns `null` when the module cannot be found instead of throwing an error.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module or `null` when it cannot be found.\n */\nexport function requireOptionalNativeModule<ModuleType = any>(\n moduleName: string\n): ModuleType | null {\n ensureNativeModulesAreInstalled();\n\n return globalThis.expo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8B;AACrF,UAAM,KAAK,aAAa,gBAAgB,WAAW,WAAW,KAAK;AAAA,EACrE;AAAA,EAEA,MAAM,eAAe,WAAwC;AAC3D,WAAO,MAAM,KAAK,aAAa,eAAe,SAAS;AAAA,EACzD;AAAA,EAEA,MAAM,kBAAkB,WAA+D;AACrF,WAAO,MAAM,KAAK,aAAa,kBAAkB,SAAS;AAAA,EAC5D;AAAA,EAEA,MAAM,WAAW,OAAwC;AACvD,QAAI,OAAO,KAAK,aAAa,eAAe,YAAY;AACtD,aAAO,MAAM,KAAK,aAAa,WAAW,KAAK;AAAA,IACjD;AACA,WAAO,CAAC;AAAA,EACV;AAAA,EAEA,MAAM,WACJ,WACA,MAC+B;AAC/B,QAAI,OAAO,KAAK,aAAa,eAAe,YAAY;AACtD,aAAO,MAAM,KAAK,aAAa,WAAW,WAAW,IAAI;AAAA,IAC3D;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,aAAqC;AACzC,WAAO,MAAM,KAAK,aAAa,WAAW;AAAA,EAC5C;AAAA,EAEA,MAAM,aAAa,MAA+C;AAChE,WAAO,MAAM,KAAK,aAAa,aAAa,IAAI;AAAA,EAClD;AAAA,EAEA,UAAgB;AACd,SAAK,UAAU,QAAQ;AACvB,SAAK,UAAU,QAAQ;AAAA,EACzB;AACF;","names":["import_react_native","import_react_native","ReactNativePlatform","Platform"]}
|
|
1
|
+
{"version":3,"sources":["../index.ts","../../../node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts","../../../node_modules/expo-modules-core/src/web/index.ts","../../../node_modules/expo-modules-core/src/NativeModulesProxy.ts","../../../node_modules/expo-modules-core/src/errors/CodedError.ts","../../../node_modules/expo-modules-core/src/Platform.ts","../../../node_modules/expo-modules-core/src/environment/browser.ts","../../../node_modules/expo-modules-core/src/errors/UnavailabilityError.ts","../../../node_modules/expo-modules-core/src/NativeViewManagerAdapter.tsx","../../../node_modules/expo-modules-core/src/sweet/NativeErrorManager.ts","../../../node_modules/expo-modules-core/src/sweet/setUpErrorManager.fx.ts","../../../node_modules/expo-modules-core/src/requireNativeModule.ts"],"sourcesContent":["import type { ComponentType, RefAttributes } from \"react\";\nimport {\n NativeModules,\n requireNativeComponent,\n View,\n type ViewProps,\n} from \"react-native\";\nimport {\n requireNativeViewManager,\n requireOptionalNativeModule,\n} from \"expo-modules-core\";\nimport { BaseDocumentEngine, papyrusEvents } from \"@papyrus-sdk/core\";\nimport {\n DocumentLoadInput,\n DocumentLoadRequest,\n DocumentEngine,\n DocumentSource,\n DocumentType,\n PageDestination,\n PapyrusEventType,\n RenderTargetType,\n TextItem,\n OutlineItem,\n FileLike,\n SearchResult,\n TextSelection,\n} from \"@papyrus-sdk/types\";\n\nconst MODULE_NAME = \"PapyrusNativeEngine\";\n\nconst BASE64_CHARS =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nconst BASE64_LOOKUP = (() => {\n const table = new Uint8Array(256);\n table.fill(255);\n for (let i = 0; i < BASE64_CHARS.length; i += 1) {\n table[BASE64_CHARS.charCodeAt(i)] = i;\n }\n return table;\n})();\n\nconst parseDataUri = (\n value: string\n): { mime: string; isBase64: boolean; data: string } | null => {\n const match = /^data:([^;,]+)?(;base64)?,(.*)$/.exec(value);\n if (!match) return null;\n return {\n mime: match[1] ?? \"\",\n isBase64: Boolean(match[2]),\n data: match[3] ?? \"\",\n };\n};\n\nconst looksLikeUri = (value: string): boolean =>\n value.startsWith(\"http://\") ||\n value.startsWith(\"https://\") ||\n value.startsWith(\"/\") ||\n value.startsWith(\"./\") ||\n value.startsWith(\"../\") ||\n value.startsWith(\"file://\");\n\nconst isLikelyBase64 = (value: string): boolean => {\n if (looksLikeUri(value)) return false;\n if (value.includes(\".\")) return false;\n if (value.length < 16) return false;\n return /^[A-Za-z0-9+/=]+$/.test(value);\n};\n\nconst isHttpUri = (value: string): boolean =>\n value.startsWith(\"http://\") || value.startsWith(\"https://\");\n\nconst decodeBase64 = (value: string): Uint8Array => {\n const clean = value.replace(/[^A-Za-z0-9+/=]/g, \"\");\n const padding = clean.endsWith(\"==\") ? 2 : clean.endsWith(\"=\") ? 1 : 0;\n const outputLength = Math.max(0, (clean.length * 3) / 4 - padding);\n const output = new Uint8Array(outputLength);\n\n let buffer = 0;\n let bits = 0;\n let index = 0;\n\n for (let i = 0; i < clean.length; i += 1) {\n const charCode = clean.charCodeAt(i);\n if (charCode === 61) break;\n const valueIndex = BASE64_LOOKUP[charCode];\n if (valueIndex === 255) continue;\n buffer = (buffer << 6) | valueIndex;\n bits += 6;\n if (bits >= 8) {\n bits -= 8;\n output[index++] = (buffer >> bits) & 0xff;\n }\n }\n return output;\n};\n\nconst encodeBase64 = (bytes: Uint8Array): string => {\n let output = \"\";\n let buffer = 0;\n let bits = 0;\n\n for (let i = 0; i < bytes.length; i += 1) {\n buffer = (buffer << 8) | bytes[i];\n bits += 8;\n while (bits >= 6) {\n bits -= 6;\n output += BASE64_CHARS[(buffer >> bits) & 0x3f];\n }\n }\n\n if (bits > 0) {\n output += BASE64_CHARS[(buffer << (6 - bits)) & 0x3f];\n }\n\n const remainder = bytes.length % 3;\n if (remainder === 1) return `${output}==`;\n if (remainder === 2) return `${output}=`;\n return output;\n};\n\nconst isLoadRequest = (\n input: DocumentLoadInput\n): input is DocumentLoadRequest =>\n typeof input === \"object\" &&\n input !== null &&\n \"source\" in input &&\n \"type\" in input;\n\nconst normalizeLoadInput = (\n input: DocumentLoadInput\n): { source: DocumentSource; type?: DocumentType } =>\n isLoadRequest(input)\n ? { source: input.source, type: input.type }\n : { source: input };\n\nconst inferDocumentType = (source: DocumentSource): DocumentType => {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri?.mime) {\n const mime = dataUri.mime.toLowerCase();\n if (mime.includes(\"epub\")) return \"epub\";\n if (mime.includes(\"text\")) return \"text\";\n if (mime.includes(\"pdf\")) return \"pdf\";\n }\n\n const clean = source.split(\"?\")[0].split(\"#\")[0];\n const ext = clean.includes(\".\")\n ? clean.split(\".\").pop()?.toLowerCase()\n : undefined;\n if (ext === \"epub\") return \"epub\";\n if (ext === \"txt\") return \"text\";\n if (ext === \"pdf\") return \"pdf\";\n return \"pdf\";\n }\n\n if (typeof source === \"object\" && source !== null && \"uri\" in source) {\n const uri = source.uri;\n const clean = uri.split(\"?\")[0].split(\"#\")[0];\n const ext = clean.includes(\".\")\n ? clean.split(\".\").pop()?.toLowerCase()\n : undefined;\n if (ext === \"epub\") return \"epub\";\n if (ext === \"txt\") return \"text\";\n if (ext === \"pdf\") return \"pdf\";\n }\n\n return \"pdf\";\n};\n\ntype NativeDocumentSource = {\n uri?: string;\n data?: Uint8Array;\n};\n\ntype NativePageDestination = {\n kind: \"pageIndex\" | \"pageNumber\" | \"named\";\n value: number | string;\n};\n\nconst normalizeNativeDestination = (\n dest: PageDestination\n): NativePageDestination | null => {\n if (!dest) return null;\n if (typeof dest === \"string\") {\n return { kind: \"named\", value: dest };\n }\n\n if (\n dest.kind === \"pageIndex\" ||\n dest.kind === \"pageNumber\" ||\n dest.kind === \"named\"\n ) {\n return { kind: dest.kind, value: dest.value };\n }\n\n return null;\n};\n\ntype NativeEngineModule = {\n createEngine?: () => string;\n destroyEngine?: (engineId: string) => void;\n load?: (\n engineId: string,\n source: NativeDocumentSource\n ) => Promise<{ pageCount?: number } | void>;\n getPageCount?: (engineId: string) => number;\n renderPage?: (\n engineId: string,\n pageIndex: number,\n target: number,\n scale: number,\n zoom: number,\n rotation: number\n ) => void;\n renderTextLayer?: (\n engineId: string,\n pageIndex: number,\n target: number,\n scale: number,\n zoom: number,\n rotation: number\n ) => void;\n getTextContent?: (engineId: string, pageIndex: number) => Promise<TextItem[]>;\n getPageDimensions?: (\n engineId: string,\n pageIndex: number\n ) => Promise<{ width: number; height: number }>;\n searchText?: (engineId: string, query: string) => Promise<SearchResult[]>;\n selectText?: (\n engineId: string,\n pageIndex: number,\n x: number,\n y: number,\n width: number,\n height: number\n ) => Promise<TextSelection | null>;\n getOutline?: (engineId: string) => Promise<OutlineItem[]>;\n getPageIndex?: (\n engineId: string,\n dest: NativePageDestination\n ) => Promise<number | null>;\n};\n\nexport type PapyrusPageViewProps = ViewProps & {\n engineId?: string;\n};\n\ntype PapyrusPageViewComponent = ComponentType<\n PapyrusPageViewProps & RefAttributes<View>\n>;\n\nconst resolveNativeModule = (): NativeEngineModule | null => {\n const expoModule =\n requireOptionalNativeModule<NativeEngineModule>(MODULE_NAME);\n if (expoModule) return expoModule;\n const rnModule = (\n NativeModules as Record<string, NativeEngineModule | undefined>\n )[MODULE_NAME];\n return rnModule ?? null;\n};\n\nconst resolvePapyrusPageView = (): PapyrusPageViewComponent => {\n try {\n return requireNativeViewManager<PapyrusPageViewProps>(\n \"PapyrusPageView\"\n ) as PapyrusPageViewComponent;\n } catch {\n try {\n return requireNativeComponent<PapyrusPageViewProps>(\n \"PapyrusPageView\"\n ) as PapyrusPageViewComponent;\n } catch {\n return View as PapyrusPageViewComponent;\n }\n }\n};\n\nexport const PapyrusPageView = resolvePapyrusPageView();\n\nexport class NativeDocumentEngine extends BaseDocumentEngine {\n private nativeModule: NativeEngineModule | null = null;\n private engineId: string = \"default\";\n private pageCount: number = 0;\n private currentPage: number = 1;\n private zoom: number = 1.0;\n private rotation: number = 0;\n\n constructor() {\n super();\n this.nativeModule = resolveNativeModule();\n this.engineId = this.nativeModule?.createEngine\n ? this.nativeModule.createEngine()\n : \"default\";\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type } = normalizeLoadInput(input);\n if (type && type !== \"pdf\") {\n throw new Error(\n `[NativeDocumentEngine] Tipo de documento não suportado: ${type}`\n );\n }\n\n const native = this.assertNativeModule();\n const normalized = await this.normalizeSource(source);\n const result = native.load\n ? await native.load(this.engineId, normalized)\n : undefined;\n\n if (result && typeof result.pageCount === \"number\") {\n this.pageCount = result.pageCount;\n } else if (native.getPageCount) {\n this.pageCount = native.getPageCount(this.engineId);\n } else {\n this.pageCount = 0;\n }\n\n this.currentPage = 1;\n }\n\n getPageCount(): number {\n return this.pageCount;\n }\n\n getCurrentPage(): number {\n return this.currentPage;\n }\n\n goToPage(page: number): void {\n if (page >= 1 && page <= this.pageCount) {\n this.currentPage = page;\n }\n }\n\n setZoom(zoom: number): void {\n this.zoom = Math.max(0.1, Math.min(5.0, zoom));\n }\n\n getZoom(): number {\n return this.zoom;\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n if (direction === \"clockwise\") {\n this.rotation = (this.rotation + 90) % 360;\n } else {\n this.rotation = (this.rotation - 90) % 360;\n if (this.rotation < 0) this.rotation += 360;\n }\n }\n\n getRotation(): number {\n return this.rotation;\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number\n ): Promise<void> {\n const native = this.assertNativeModule();\n if (!native.renderPage) return;\n const viewTag = this.toNativeViewTag(target);\n if (viewTag === null) return;\n native.renderPage(\n this.engineId,\n pageIndex,\n viewTag,\n scale,\n this.zoom,\n this.rotation\n );\n }\n\n async renderTextLayer(\n pageIndex: number,\n target: any,\n scale: number\n ): Promise<void> {\n const native = this.assertNativeModule();\n if (!native.renderTextLayer) return;\n const viewTag = this.toNativeViewTag(target);\n if (viewTag === null) return;\n native.renderTextLayer(\n this.engineId,\n pageIndex,\n viewTag,\n scale,\n this.zoom,\n this.rotation\n );\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n const native = this.assertNativeModule();\n if (!native.getTextContent) return [];\n return native.getTextContent(this.engineId, pageIndex);\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n const native = this.assertNativeModule();\n if (!native.getPageDimensions) return { width: 0, height: 0 };\n return native.getPageDimensions(this.engineId, pageIndex);\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number }\n ): Promise<TextSelection | null> {\n const native = this.assertNativeModule();\n if (!native.selectText) return null;\n return native.selectText(\n this.engineId,\n pageIndex,\n rect.x,\n rect.y,\n rect.width,\n rect.height\n );\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n const native = this.assertNativeModule();\n if (!native.getOutline) return [];\n return native.getOutline(this.engineId);\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n const native = this.assertNativeModule();\n if (!native.searchText) return [];\n return native.searchText(this.engineId, query);\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n if (!dest) return null;\n if (typeof dest !== \"string\") {\n if (dest.kind === \"pageIndex\") return dest.value;\n if (dest.kind === \"pageNumber\") return Math.max(0, dest.value - 1);\n }\n\n const native = this.assertNativeModule();\n if (!native.getPageIndex) return null;\n const normalized = normalizeNativeDestination(dest);\n if (!normalized || normalized.kind !== \"named\") return null;\n return native.getPageIndex(this.engineId, normalized);\n }\n\n destroy(): void {\n this.nativeModule?.destroyEngine?.(this.engineId);\n }\n\n private assertNativeModule(): NativeEngineModule {\n if (!this.nativeModule) {\n this.nativeModule = resolveNativeModule();\n }\n if (!this.nativeModule) {\n throw new Error(\n `[Papyrus] Native module \"${MODULE_NAME}\" not found. Use a dev client or a native build (Expo Go is not supported).`\n );\n }\n return this.nativeModule;\n }\n\n private async normalizeSource(\n source: DocumentSource\n ): Promise<NativeDocumentSource> {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri?.isBase64) {\n return { data: decodeBase64(dataUri.data) };\n }\n if (looksLikeUri(source)) return { uri: source };\n if (isLikelyBase64(source)) return { data: decodeBase64(source) };\n return { uri: source };\n }\n if (this.isUriSource(source)) return { uri: source.uri };\n if (this.isDataSource(source)) {\n const data =\n source.data instanceof Uint8Array\n ? source.data\n : new Uint8Array(source.data);\n return { data };\n }\n if (this.isFileLike(source)) {\n const buffer = await source.arrayBuffer();\n return { data: new Uint8Array(buffer) };\n }\n if (source instanceof ArrayBuffer) return { data: new Uint8Array(source) };\n if (source instanceof Uint8Array) return { data: source };\n return { data: new Uint8Array(source as ArrayBuffer) };\n }\n\n private isUriSource(source: DocumentSource): source is { uri: string } {\n return typeof source === \"object\" && source !== null && \"uri\" in source;\n }\n\n private isDataSource(\n source: DocumentSource\n ): source is { data: ArrayBuffer | Uint8Array } {\n return typeof source === \"object\" && source !== null && \"data\" in source;\n }\n\n private isFileLike(source: DocumentSource): source is FileLike {\n return (\n typeof source === \"object\" &&\n source !== null &&\n typeof (source as FileLike).arrayBuffer === \"function\"\n );\n }\n\n private toNativeViewTag(target: any): number | null {\n if (typeof target === \"number\") return target;\n if (target?.nativeTag && typeof target.nativeTag === \"number\")\n return target.nativeTag;\n return null;\n }\n}\n\ntype WebViewBridge = {\n postMessage: (message: string) => void;\n};\n\ntype WebViewResponseMessage = {\n type: \"response\";\n id: string;\n ok: boolean;\n data?: any;\n error?: string;\n};\n\ntype WebViewEventMessage = {\n type: \"event\";\n name: string;\n payload?: any;\n};\n\ntype WebViewStateMessage = {\n type: \"state\";\n payload: {\n pageCount?: number;\n currentPage?: number;\n zoom?: number;\n outline?: OutlineItem[];\n };\n};\n\ntype WebViewReadyMessage = {\n type: \"ready\";\n};\n\ntype WebViewRuntimeMessage =\n | WebViewResponseMessage\n | WebViewEventMessage\n | WebViewStateMessage\n | WebViewReadyMessage;\n\ntype WebViewSourcePayload =\n | { kind: \"uri\"; uri: string }\n | { kind: \"base64\"; data: string; mime?: string }\n | { kind: \"text\"; text: string };\n\nexport class WebViewDocumentEngine extends BaseDocumentEngine {\n private bridge: WebViewBridge | null = null;\n private ready = false;\n private requestId = 0;\n private pending = new Map<\n string,\n { resolve: (data: any) => void; reject: (error: Error) => void }\n >();\n private bridgeResolvers: Array<(bridge: WebViewBridge) => void> = [];\n private readyResolvers: Array<() => void> = [];\n private pageCount = 0;\n private currentPage = 1;\n private zoom = 1.0;\n private rotation = 0;\n private outline: OutlineItem[] = [];\n\n getRenderTargetType(): \"webview\" {\n return \"webview\";\n }\n\n attachBridge(bridge: WebViewBridge): void {\n this.bridge = bridge;\n this.bridgeResolvers.forEach((resolve) => resolve(bridge));\n this.bridgeResolvers = [];\n }\n\n handleMessage(raw: string): void {\n let message: WebViewRuntimeMessage | null = null;\n try {\n message = JSON.parse(raw) as WebViewRuntimeMessage;\n } catch {\n return;\n }\n\n if (!message) return;\n\n if (message.type === \"ready\") {\n this.ready = true;\n this.readyResolvers.forEach((resolve) => resolve());\n this.readyResolvers = [];\n return;\n }\n\n if (message.type === \"response\") {\n const pending = this.pending.get(message.id);\n if (!pending) return;\n this.pending.delete(message.id);\n if (message.ok) {\n pending.resolve(message.data);\n } else {\n pending.reject(\n new Error(message.error ?? \"[Papyrus] WebView runtime error\")\n );\n }\n return;\n }\n\n if (message.type === \"state\") {\n if (typeof message.payload.pageCount === \"number\")\n this.pageCount = message.payload.pageCount;\n if (typeof message.payload.currentPage === \"number\")\n this.currentPage = message.payload.currentPage;\n if (typeof message.payload.zoom === \"number\")\n this.zoom = message.payload.zoom;\n if (Array.isArray(message.payload.outline))\n this.outline = message.payload.outline;\n return;\n }\n\n if (message.type === \"event\") {\n const payload = message.payload ?? {};\n if (message.name === \"RUNTIME_LOG\") {\n if (__DEV__) {\n const text =\n typeof payload?.message === \"string\"\n ? payload.message\n : JSON.stringify(payload);\n console.log(\"[Papyrus WebView runtime]\", text);\n }\n return;\n }\n if (message.name === \"RUNTIME_ERROR\") {\n const errorMessage =\n typeof payload?.message === \"string\" ? payload.message : \"\";\n if (errorMessage.includes(\"ResizeObserver loop\")) {\n return;\n }\n if (__DEV__) {\n console.warn(\"[Papyrus WebView runtime]\", payload);\n }\n return;\n }\n if (message.name === PapyrusEventType.TEXT_SELECTED) {\n papyrusEvents.emit(PapyrusEventType.TEXT_SELECTED, payload);\n } else if (message.name === PapyrusEventType.SEARCH_TRIGGERED) {\n papyrusEvents.emit(PapyrusEventType.SEARCH_TRIGGERED, payload);\n } else if (message.name === PapyrusEventType.DOCUMENT_LOADED) {\n if (typeof payload.pageCount === \"number\") {\n this.pageCount = payload.pageCount;\n }\n papyrusEvents.emit(PapyrusEventType.DOCUMENT_LOADED, payload);\n }\n return;\n }\n\n if (__DEV__) {\n console.warn(\"[Papyrus WebView] Unknown message\", message);\n }\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type } = normalizeLoadInput(input);\n const resolvedType = type ?? inferDocumentType(source);\n if (resolvedType === \"pdf\") {\n throw new Error(\n \"[WebViewDocumentEngine] Use o NativeDocumentEngine para PDFs no mobile.\"\n );\n }\n\n const payloadSource = await this.normalizeRuntimeSource(\n resolvedType,\n source\n );\n const response = await this.request<{\n pageCount?: number;\n outline?: OutlineItem[];\n }>(\"load\", {\n type: resolvedType,\n source: payloadSource,\n });\n\n if (typeof response?.pageCount === \"number\")\n this.pageCount = response.pageCount;\n if (Array.isArray(response?.outline)) this.outline = response.outline;\n this.currentPage = 1;\n }\n\n getPageCount(): number {\n return this.pageCount;\n }\n\n getCurrentPage(): number {\n return this.currentPage;\n }\n\n goToPage(page: number): void {\n if (page < 1) return;\n this.currentPage = page;\n void this.request(\"go-to-page\", { page });\n }\n\n setZoom(zoom: number): void {\n this.zoom = Math.max(0.5, Math.min(4.0, zoom));\n void this.request(\"set-zoom\", { zoom: this.zoom });\n }\n\n getZoom(): number {\n return this.zoom;\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n if (direction === \"clockwise\") {\n this.rotation = (this.rotation + 90) % 360;\n } else {\n this.rotation = (this.rotation - 90) % 360;\n if (this.rotation < 0) this.rotation += 360;\n }\n void this.request(\"set-rotation\", { rotation: this.rotation });\n }\n\n getRotation(): number {\n return this.rotation;\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number\n ): Promise<void> {\n void pageIndex;\n void target;\n void scale;\n }\n\n async renderTextLayer(\n pageIndex: number,\n container: any,\n scale: number\n ): Promise<void> {\n void pageIndex;\n void container;\n void scale;\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n return await this.request<TextItem[]>(\"get-text-content\", { pageIndex });\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n return await this.request<{ width: number; height: number }>(\n \"get-page-dimensions\",\n { pageIndex }\n );\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n return await this.request<SearchResult[]>(\"search-text\", { query });\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number }\n ): Promise<TextSelection | null> {\n return await this.request<TextSelection | null>(\"select-text\", {\n pageIndex,\n rect,\n });\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n if (this.outline.length > 0) return this.outline;\n return await this.request<OutlineItem[]>(\"get-outline\");\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n if (!dest) return null;\n if (typeof dest !== \"string\") {\n if (dest.kind === \"pageIndex\") return dest.value;\n if (dest.kind === \"pageNumber\") return Math.max(0, dest.value - 1);\n if (dest.kind === \"href\") {\n return await this.request<number | null>(\"get-page-index\", {\n dest: dest.value,\n });\n }\n return null;\n }\n return await this.request<number | null>(\"get-page-index\", { dest });\n }\n\n destroy(): void {\n this.pending.forEach(({ reject }) =>\n reject(new Error(\"[Papyrus] WebView engine destroyed\"))\n );\n this.pending.clear();\n this.bridge = null;\n this.ready = false;\n }\n\n private async ensureBridge(): Promise<WebViewBridge> {\n if (this.bridge) return this.bridge;\n return new Promise((resolve) => {\n this.bridgeResolvers.push(resolve);\n });\n }\n\n private async ensureReady(): Promise<void> {\n if (this.ready) return;\n return new Promise((resolve) => {\n this.readyResolvers.push(resolve);\n });\n }\n\n private async request<T = any>(kind: string, payload?: any): Promise<T> {\n const bridge = await this.ensureBridge();\n await this.ensureReady();\n const id = `${Date.now()}-${this.requestId++}`;\n return new Promise<T>((resolve, reject) => {\n const timeoutMs = kind === \"load\" ? 180000 : 8000;\n const timeoutId = setTimeout(() => {\n this.pending.delete(id);\n reject(new Error(`[Papyrus] WebView response timeout: ${kind}`));\n }, timeoutMs);\n this.pending.set(id, {\n resolve: (data) => {\n clearTimeout(timeoutId);\n resolve(data);\n },\n reject: (error) => {\n clearTimeout(timeoutId);\n reject(error);\n },\n });\n bridge.postMessage(JSON.stringify({ id, kind, payload }));\n });\n }\n\n private async normalizeRuntimeSource(\n type: DocumentType,\n source: DocumentSource\n ): Promise<WebViewSourcePayload> {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri) {\n if (dataUri.isBase64) {\n return {\n kind: \"base64\",\n data: dataUri.data,\n mime: dataUri.mime || undefined,\n };\n }\n const text = decodeURIComponent(dataUri.data);\n return { kind: \"text\", text };\n }\n\n if (looksLikeUri(source)) {\n if (isHttpUri(source)) {\n const fetched = await this.fetchRemoteSource(type, source);\n if (fetched) return fetched;\n }\n return { kind: \"uri\", uri: source };\n }\n\n if (isLikelyBase64(source)) {\n return { kind: \"base64\", data: source };\n }\n\n if (type === \"text\") {\n return { kind: \"text\", text: source };\n }\n\n return { kind: \"uri\", uri: source };\n }\n\n if (this.isUriSource(source)) {\n const uri = source.uri;\n if (isHttpUri(uri)) {\n const fetched = await this.fetchRemoteSource(type, uri);\n if (fetched) return fetched;\n }\n return { kind: \"uri\", uri };\n }\n if (this.isDataSource(source)) {\n const bytes =\n source.data instanceof Uint8Array\n ? source.data\n : new Uint8Array(source.data);\n return { kind: \"base64\", data: encodeBase64(bytes) };\n }\n if (this.isFileLike(source)) {\n const buffer = await source.arrayBuffer();\n return { kind: \"base64\", data: encodeBase64(new Uint8Array(buffer)) };\n }\n if (source instanceof ArrayBuffer || source instanceof Uint8Array) {\n const bytes =\n source instanceof Uint8Array ? source : new Uint8Array(source);\n return { kind: \"base64\", data: encodeBase64(bytes) };\n }\n\n return {\n kind: \"base64\",\n data: encodeBase64(new Uint8Array(source as ArrayBuffer)),\n };\n }\n\n private async fetchRemoteSource(\n type: DocumentType,\n uri: string\n ): Promise<WebViewSourcePayload | null> {\n try {\n const response = await fetch(uri);\n if (!response.ok) return null;\n if (type === \"text\") {\n const text = await response.text();\n return { kind: \"text\", text };\n }\n if (type === \"epub\") {\n const buffer = await this.readResponseBuffer(response);\n return { kind: \"base64\", data: encodeBase64(new Uint8Array(buffer)) };\n }\n return null;\n } catch {\n return null;\n }\n }\n\n private async readResponseBuffer(response: Response): Promise<ArrayBuffer> {\n try {\n return await response.arrayBuffer();\n } catch {\n const blob = await response.blob();\n return await new Promise<ArrayBuffer>((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = () =>\n reject(new Error(\"[Papyrus] Failed to read response blob\"));\n reader.onload = () => resolve(reader.result as ArrayBuffer);\n reader.readAsArrayBuffer(blob);\n });\n }\n }\n\n private isUriSource(source: DocumentSource): source is { uri: string } {\n return typeof source === \"object\" && source !== null && \"uri\" in source;\n }\n\n private isDataSource(\n source: DocumentSource\n ): source is { data: ArrayBuffer | Uint8Array } {\n return typeof source === \"object\" && source !== null && \"data\" in source;\n }\n\n private isFileLike(source: DocumentSource): source is FileLike {\n return (\n typeof source === \"object\" &&\n source !== null &&\n typeof (source as FileLike).arrayBuffer === \"function\"\n );\n }\n}\n\nexport class MobileDocumentEngine extends BaseDocumentEngine {\n private pdfEngine: NativeDocumentEngine;\n private webEngine: WebViewDocumentEngine;\n private activeEngine: DocumentEngine;\n\n constructor() {\n super();\n this.pdfEngine = new NativeDocumentEngine();\n this.webEngine = new WebViewDocumentEngine();\n this.activeEngine = this.pdfEngine;\n }\n\n getRenderTargetType(): RenderTargetType {\n return this.activeEngine.getRenderTargetType?.() ?? \"canvas\";\n }\n\n attachWebView(bridge: WebViewBridge): void {\n this.webEngine.attachBridge(bridge);\n }\n\n handleWebViewMessage(data: string): void {\n this.webEngine.handleMessage(data);\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type } = normalizeLoadInput(input);\n const resolvedType = type ?? inferDocumentType(source);\n this.activeEngine =\n resolvedType === \"pdf\" ? this.pdfEngine : this.webEngine;\n await this.activeEngine.load({ type: resolvedType, source });\n }\n\n getPageCount(): number {\n return this.activeEngine.getPageCount();\n }\n\n getCurrentPage(): number {\n return this.activeEngine.getCurrentPage();\n }\n\n goToPage(page: number): void {\n this.activeEngine.goToPage(page);\n }\n\n setZoom(zoom: number): void {\n this.activeEngine.setZoom(zoom);\n }\n\n getZoom(): number {\n return this.activeEngine.getZoom();\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n this.activeEngine.rotate(direction);\n }\n\n getRotation(): number {\n return this.activeEngine.getRotation();\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number\n ): Promise<void> {\n await this.activeEngine.renderPage(pageIndex, target, scale);\n }\n\n async renderTextLayer(\n pageIndex: number,\n container: any,\n scale: number\n ): Promise<void> {\n await this.activeEngine.renderTextLayer(pageIndex, container, scale);\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n return await this.activeEngine.getTextContent(pageIndex);\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n return await this.activeEngine.getPageDimensions(pageIndex);\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n if (typeof this.activeEngine.searchText === \"function\") {\n return await this.activeEngine.searchText(query);\n }\n return [];\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number }\n ): Promise<TextSelection | null> {\n if (typeof this.activeEngine.selectText === \"function\") {\n return await this.activeEngine.selectText(pageIndex, rect);\n }\n return null;\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n return await this.activeEngine.getOutline();\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n return await this.activeEngine.getPageIndex(dest);\n }\n\n destroy(): void {\n this.pdfEngine.destroy();\n this.webEngine.destroy();\n }\n}\n","import { NativeModules, Platform } from 'react-native';\n\nimport { registerWebGlobals } from './web/index';\n\n/**\n * Ensures that the native modules are installed in the current runtime.\n * Otherwise, it synchronously calls a native function that installs them.\n */\nexport function ensureNativeModulesAreInstalled(): void {\n if (globalThis.expo) {\n return;\n }\n try {\n if (Platform.OS === 'web') {\n // Requiring web folder sets up the `globalThis.expo` object.\n registerWebGlobals();\n } else {\n // TODO: ExpoModulesCore shouldn't be optional here,\n // but to keep backwards compatibility let's just ignore it in SDK 50.\n // In most cases the modules were already installed from the native side.\n NativeModules.ExpoModulesCore?.installModules();\n }\n } catch (error) {\n console.error(`Unable to install Expo modules: ${error}`);\n }\n}\n","export function registerWebGlobals() {}\n","import type { ProxyNativeModule } from './NativeModulesProxy.types';\n\n// We default to an empty object shim wherever we don't have an environment-specific implementation\n\n/**\n * @deprecated `NativeModulesProxy` is deprecated and might be removed in the future releases.\n * Use `requireNativeModule` or `requireOptionalNativeModule` instead.\n */\nexport default {} as { [moduleName: string]: ProxyNativeModule };\n","/**\n * A general error class that should be used for all errors in Expo modules.\n * Guarantees a `code` field that can be used to differentiate between different\n * types of errors without further subclassing Error.\n */\nexport class CodedError extends Error {\n code: string;\n info?: any;\n\n constructor(code: string, message: string) {\n super(message);\n this.code = code;\n }\n}\n","import { PlatformOSType, Platform as ReactNativePlatform } from 'react-native';\n\nimport {\n isDOMAvailable,\n canUseEventListeners,\n canUseViewport,\n isAsyncDebugging,\n} from './environment/browser';\n\nexport type PlatformSelectOSType = PlatformOSType | 'native' | 'electron' | 'default';\n\nexport type PlatformSelect = <T>(specifics: { [platform in PlatformSelectOSType]?: T }) => T;\n\nif (__DEV__ && typeof process.env.EXPO_OS === 'undefined') {\n console.warn(\n `The global process.env.EXPO_OS is not defined. This should be inlined by babel-preset-expo during transformation.`\n );\n}\n\nconst nativeSelect =\n typeof window !== 'undefined'\n ? ReactNativePlatform.select\n : // process.env.EXPO_OS is injected by `babel-preset-expo` and available in both client and `react-server` environments.\n // Opt to use the env var when possible, and fallback to the React Native Platform module when it's not (arbitrary bundlers and transformers).\n function select<T>(specifics: { [platform in PlatformSelectOSType]?: T }): T | undefined {\n if (!process.env.EXPO_OS) return undefined;\n if (specifics.hasOwnProperty(process.env.EXPO_OS)) {\n return specifics[process.env.EXPO_OS]!;\n } else if (process.env.EXPO_OS !== 'web' && specifics.hasOwnProperty('native')) {\n return specifics.native!;\n } else if (specifics.hasOwnProperty('default')) {\n return specifics.default!;\n }\n // do nothing...\n return undefined;\n };\n\nconst Platform = {\n /**\n * Denotes the currently running platform.\n * Can be one of ios, android, web.\n */\n OS: process.env.EXPO_OS || ReactNativePlatform.OS,\n /**\n * Returns the value with the matching platform.\n * Object keys can be any of ios, android, native, web, default.\n *\n * @ios ios, native, default\n * @android android, native, default\n * @web web, default\n */\n select: nativeSelect as PlatformSelect,\n /**\n * Denotes if the DOM API is available in the current environment.\n * The DOM is not available in native React runtimes and Node.js.\n */\n isDOMAvailable,\n /**\n * Denotes if the current environment can attach event listeners\n * to the window. This will return false in native React\n * runtimes and Node.js.\n */\n canUseEventListeners,\n /**\n * Denotes if the current environment can inspect properties of the\n * screen on which the current window is being rendered. This will\n * return false in native React runtimes and Node.js.\n */\n canUseViewport,\n /**\n * If the JavaScript is being executed in a remote JavaScript environment.\n * When `true`, synchronous native invocations cannot be executed.\n */\n isAsyncDebugging,\n};\n\nexport default Platform;\n","declare const global: any;\n\n// In standard node environments there is no DOM API\nexport const isDOMAvailable = false;\nexport const canUseEventListeners = false;\nexport const canUseViewport = false;\n\nexport let isAsyncDebugging: boolean = false;\n\nif (__DEV__) {\n // These native globals are injected by native React runtimes and not standard browsers\n // we can use them to determine if the JS is being executed in Chrome.\n isAsyncDebugging =\n !global.nativeExtensions && !global.nativeCallSyncHook && !global.RN$Bridgeless;\n}\n","import { CodedError } from './CodedError';\nimport Platform from '../Platform';\n\n/**\n * A class for errors to be thrown when a property is accessed which is\n * unavailable, unsupported, or not currently implemented on the running\n * platform.\n */\nexport class UnavailabilityError extends CodedError {\n constructor(moduleName: string, propertyName: string) {\n super(\n 'ERR_UNAVAILABLE',\n `The method or property ${moduleName}.${propertyName} is not available on ${Platform.OS}, are you sure you've linked all the native dependencies properly?`\n );\n }\n}\n","import React from 'react';\n\nimport { UnavailabilityError } from './errors/UnavailabilityError';\n\n/**\n * A drop-in replacement for `requireNativeComponent`.\n */\nexport function requireNativeViewManager<P = any>(viewName: string): React.ComponentType<P> {\n throw new UnavailabilityError('expo-modules-core', 'requireNativeViewManager');\n}\n","import NativeModulesProxy from '../NativeModulesProxy';\nexport default NativeModulesProxy.ExpoModulesCoreErrorManager;\n","import NativeErrorManager from './NativeErrorManager';\nimport Platform from '../Platform';\nimport { CodedError } from '../errors/CodedError';\n\nif (__DEV__ && Platform.OS === 'android' && NativeErrorManager) {\n const onNewException = 'ExpoModulesCoreErrorManager.onNewException';\n const onNewWarning = 'ExpoModulesCoreErrorManager.onNewWarning';\n\n NativeErrorManager.addListener(onNewException, ({ message }: { message: string }) => {\n console.error(message);\n });\n\n NativeErrorManager.addListener(onNewWarning, ({ message }: { message: string }) => {\n console.warn(message);\n });\n}\n\n// We have to export `CodedError` via global object to use in later in the C++ code.\nglobalThis.ExpoModulesCore_CodedError = CodedError;\n","import NativeModulesProxy from './NativeModulesProxy';\nimport { ensureNativeModulesAreInstalled } from './ensureNativeModulesAreInstalled';\n\n/**\n * Imports the native module registered with given name. In the first place it tries to load\n * the module installed through the JSI host object and then falls back to the bridge proxy module.\n * Notice that the modules loaded from the proxy may not support some features like synchronous functions.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module.\n * @throws Error when there is no native module with given name.\n */\nexport function requireNativeModule<ModuleType = any>(moduleName: string): ModuleType {\n const nativeModule = requireOptionalNativeModule<ModuleType>(moduleName);\n\n if (!nativeModule) {\n throw new Error(`Cannot find native module '${moduleName}'`);\n }\n return nativeModule;\n}\n\n/**\n * Imports the native module registered with the given name. The same as `requireNativeModule`,\n * but returns `null` when the module cannot be found instead of throwing an error.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module or `null` when it cannot be found.\n */\nexport function requireOptionalNativeModule<ModuleType = any>(\n moduleName: string\n): ModuleType | null {\n ensureNativeModulesAreInstalled();\n\n return globalThis.expo?.modules?.[moduleName] ?? NativeModulesProxy[moduleName] ?? null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,uBAKO;;;ACNP,0BAAwC;;;ACAj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K;AAAA,EACrE;AAAA,EAEA,MAAM,eAAe,WAAwC;AAC3D,WAAO,MAAM,KAAK,aAAa,eAAe,SAAS;AAAA,EACzD;AAAA,EAEA,MAAM,kBACJ,WAC4C;AAC5C,WAAO,MAAM,KAAK,aAAa,kBAAkB,SAAS;AAAA,EAC5D;AAAA,EAEA,MAAM,WAAW,OAAwC;AACvD,QAAI,OAAO,KAAK,aAAa,eAAe,YAAY;AACtD,aAAO,MAAM,KAAK,aAAa,WAAW,KAAK;AAAA,IACjD;AACA,WAAO,CAAC;AAAA,EACV;AAAA,EAEA,MAAM,WACJ,WACA,MAC+B;AAC/B,QAAI,OAAO,KAAK,aAAa,eAAe,YAAY;AACtD,aAAO,MAAM,KAAK,aAAa,WAAW,WAAW,IAAI;AAAA,IAC3D;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,aAAqC;AACzC,WAAO,MAAM,KAAK,aAAa,WAAW;AAAA,EAC5C;AAAA,EAEA,MAAM,aAAa,MAA+C;AAChE,WAAO,MAAM,KAAK,aAAa,aAAa,IAAI;AAAA,EAClD;AAAA,EAEA,UAAgB;AACd,SAAK,UAAU,QAAQ;AACvB,SAAK,UAAU,QAAQ;AAAA,EACzB;AACF;","names":["import_react_native","import_react_native","ReactNativePlatform","Platform"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// index.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
NativeModules as NativeModules2,
|
|
4
|
+
requireNativeComponent,
|
|
5
|
+
View
|
|
6
|
+
} from "react-native";
|
|
3
7
|
|
|
4
8
|
// ../../node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts
|
|
5
9
|
import { NativeModules, Platform } from "react-native";
|
|
@@ -265,10 +269,14 @@ var resolveNativeModule = () => {
|
|
|
265
269
|
};
|
|
266
270
|
var resolvePapyrusPageView = () => {
|
|
267
271
|
try {
|
|
268
|
-
return requireNativeViewManager(
|
|
272
|
+
return requireNativeViewManager(
|
|
273
|
+
"PapyrusPageView"
|
|
274
|
+
);
|
|
269
275
|
} catch {
|
|
270
276
|
try {
|
|
271
|
-
return requireNativeComponent(
|
|
277
|
+
return requireNativeComponent(
|
|
278
|
+
"PapyrusPageView"
|
|
279
|
+
);
|
|
272
280
|
} catch {
|
|
273
281
|
return View;
|
|
274
282
|
}
|
|
@@ -290,7 +298,9 @@ var NativeDocumentEngine = class extends BaseDocumentEngine {
|
|
|
290
298
|
async load(input) {
|
|
291
299
|
const { source, type } = normalizeLoadInput(input);
|
|
292
300
|
if (type && type !== "pdf") {
|
|
293
|
-
throw new Error(
|
|
301
|
+
throw new Error(
|
|
302
|
+
`[NativeDocumentEngine] Tipo de documento n\xE3o suportado: ${type}`
|
|
303
|
+
);
|
|
294
304
|
}
|
|
295
305
|
const native = this.assertNativeModule();
|
|
296
306
|
const normalized = await this.normalizeSource(source);
|
|
@@ -337,14 +347,28 @@ var NativeDocumentEngine = class extends BaseDocumentEngine {
|
|
|
337
347
|
if (!native.renderPage) return;
|
|
338
348
|
const viewTag = this.toNativeViewTag(target);
|
|
339
349
|
if (viewTag === null) return;
|
|
340
|
-
native.renderPage(
|
|
350
|
+
native.renderPage(
|
|
351
|
+
this.engineId,
|
|
352
|
+
pageIndex,
|
|
353
|
+
viewTag,
|
|
354
|
+
scale,
|
|
355
|
+
this.zoom,
|
|
356
|
+
this.rotation
|
|
357
|
+
);
|
|
341
358
|
}
|
|
342
359
|
async renderTextLayer(pageIndex, target, scale) {
|
|
343
360
|
const native = this.assertNativeModule();
|
|
344
361
|
if (!native.renderTextLayer) return;
|
|
345
362
|
const viewTag = this.toNativeViewTag(target);
|
|
346
363
|
if (viewTag === null) return;
|
|
347
|
-
native.renderTextLayer(
|
|
364
|
+
native.renderTextLayer(
|
|
365
|
+
this.engineId,
|
|
366
|
+
pageIndex,
|
|
367
|
+
viewTag,
|
|
368
|
+
scale,
|
|
369
|
+
this.zoom,
|
|
370
|
+
this.rotation
|
|
371
|
+
);
|
|
348
372
|
}
|
|
349
373
|
async getTextContent(pageIndex) {
|
|
350
374
|
const native = this.assertNativeModule();
|
|
@@ -359,7 +383,14 @@ var NativeDocumentEngine = class extends BaseDocumentEngine {
|
|
|
359
383
|
async selectText(pageIndex, rect) {
|
|
360
384
|
const native = this.assertNativeModule();
|
|
361
385
|
if (!native.selectText) return null;
|
|
362
|
-
return native.selectText(
|
|
386
|
+
return native.selectText(
|
|
387
|
+
this.engineId,
|
|
388
|
+
pageIndex,
|
|
389
|
+
rect.x,
|
|
390
|
+
rect.y,
|
|
391
|
+
rect.width,
|
|
392
|
+
rect.height
|
|
393
|
+
);
|
|
363
394
|
}
|
|
364
395
|
async getOutline() {
|
|
365
396
|
const native = this.assertNativeModule();
|
|
@@ -431,7 +462,8 @@ var NativeDocumentEngine = class extends BaseDocumentEngine {
|
|
|
431
462
|
}
|
|
432
463
|
toNativeViewTag(target) {
|
|
433
464
|
if (typeof target === "number") return target;
|
|
434
|
-
if (target?.nativeTag && typeof target.nativeTag === "number")
|
|
465
|
+
if (target?.nativeTag && typeof target.nativeTag === "number")
|
|
466
|
+
return target.nativeTag;
|
|
435
467
|
return null;
|
|
436
468
|
}
|
|
437
469
|
};
|
|
@@ -479,15 +511,21 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
479
511
|
if (message.ok) {
|
|
480
512
|
pending.resolve(message.data);
|
|
481
513
|
} else {
|
|
482
|
-
pending.reject(
|
|
514
|
+
pending.reject(
|
|
515
|
+
new Error(message.error ?? "[Papyrus] WebView runtime error")
|
|
516
|
+
);
|
|
483
517
|
}
|
|
484
518
|
return;
|
|
485
519
|
}
|
|
486
520
|
if (message.type === "state") {
|
|
487
|
-
if (typeof message.payload.pageCount === "number")
|
|
488
|
-
|
|
489
|
-
if (typeof message.payload.
|
|
490
|
-
|
|
521
|
+
if (typeof message.payload.pageCount === "number")
|
|
522
|
+
this.pageCount = message.payload.pageCount;
|
|
523
|
+
if (typeof message.payload.currentPage === "number")
|
|
524
|
+
this.currentPage = message.payload.currentPage;
|
|
525
|
+
if (typeof message.payload.zoom === "number")
|
|
526
|
+
this.zoom = message.payload.zoom;
|
|
527
|
+
if (Array.isArray(message.payload.outline))
|
|
528
|
+
this.outline = message.payload.outline;
|
|
491
529
|
return;
|
|
492
530
|
}
|
|
493
531
|
if (message.type === "event") {
|
|
@@ -529,14 +567,20 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
529
567
|
const { source, type } = normalizeLoadInput(input);
|
|
530
568
|
const resolvedType = type ?? inferDocumentType(source);
|
|
531
569
|
if (resolvedType === "pdf") {
|
|
532
|
-
throw new Error(
|
|
570
|
+
throw new Error(
|
|
571
|
+
"[WebViewDocumentEngine] Use o NativeDocumentEngine para PDFs no mobile."
|
|
572
|
+
);
|
|
533
573
|
}
|
|
534
|
-
const payloadSource = await this.normalizeRuntimeSource(
|
|
574
|
+
const payloadSource = await this.normalizeRuntimeSource(
|
|
575
|
+
resolvedType,
|
|
576
|
+
source
|
|
577
|
+
);
|
|
535
578
|
const response = await this.request("load", {
|
|
536
579
|
type: resolvedType,
|
|
537
580
|
source: payloadSource
|
|
538
581
|
});
|
|
539
|
-
if (typeof response?.pageCount === "number")
|
|
582
|
+
if (typeof response?.pageCount === "number")
|
|
583
|
+
this.pageCount = response.pageCount;
|
|
540
584
|
if (Array.isArray(response?.outline)) this.outline = response.outline;
|
|
541
585
|
this.currentPage = 1;
|
|
542
586
|
}
|
|
@@ -578,13 +622,19 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
578
622
|
return await this.request("get-text-content", { pageIndex });
|
|
579
623
|
}
|
|
580
624
|
async getPageDimensions(pageIndex) {
|
|
581
|
-
return await this.request(
|
|
625
|
+
return await this.request(
|
|
626
|
+
"get-page-dimensions",
|
|
627
|
+
{ pageIndex }
|
|
628
|
+
);
|
|
582
629
|
}
|
|
583
630
|
async searchText(query) {
|
|
584
631
|
return await this.request("search-text", { query });
|
|
585
632
|
}
|
|
586
633
|
async selectText(pageIndex, rect) {
|
|
587
|
-
return await this.request("select-text", {
|
|
634
|
+
return await this.request("select-text", {
|
|
635
|
+
pageIndex,
|
|
636
|
+
rect
|
|
637
|
+
});
|
|
588
638
|
}
|
|
589
639
|
async getOutline() {
|
|
590
640
|
if (this.outline.length > 0) return this.outline;
|
|
@@ -596,14 +646,18 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
596
646
|
if (dest.kind === "pageIndex") return dest.value;
|
|
597
647
|
if (dest.kind === "pageNumber") return Math.max(0, dest.value - 1);
|
|
598
648
|
if (dest.kind === "href") {
|
|
599
|
-
return await this.request("get-page-index", {
|
|
649
|
+
return await this.request("get-page-index", {
|
|
650
|
+
dest: dest.value
|
|
651
|
+
});
|
|
600
652
|
}
|
|
601
653
|
return null;
|
|
602
654
|
}
|
|
603
655
|
return await this.request("get-page-index", { dest });
|
|
604
656
|
}
|
|
605
657
|
destroy() {
|
|
606
|
-
this.pending.forEach(
|
|
658
|
+
this.pending.forEach(
|
|
659
|
+
({ reject }) => reject(new Error("[Papyrus] WebView engine destroyed"))
|
|
660
|
+
);
|
|
607
661
|
this.pending.clear();
|
|
608
662
|
this.bridge = null;
|
|
609
663
|
this.ready = false;
|
|
@@ -625,7 +679,7 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
625
679
|
await this.ensureReady();
|
|
626
680
|
const id = `${Date.now()}-${this.requestId++}`;
|
|
627
681
|
return new Promise((resolve, reject) => {
|
|
628
|
-
const timeoutMs = kind === "load" ?
|
|
682
|
+
const timeoutMs = kind === "load" ? 18e4 : 8e3;
|
|
629
683
|
const timeoutId = setTimeout(() => {
|
|
630
684
|
this.pending.delete(id);
|
|
631
685
|
reject(new Error(`[Papyrus] WebView response timeout: ${kind}`));
|
|
@@ -648,7 +702,11 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
648
702
|
const dataUri = parseDataUri(source);
|
|
649
703
|
if (dataUri) {
|
|
650
704
|
if (dataUri.isBase64) {
|
|
651
|
-
return {
|
|
705
|
+
return {
|
|
706
|
+
kind: "base64",
|
|
707
|
+
data: dataUri.data,
|
|
708
|
+
mime: dataUri.mime || void 0
|
|
709
|
+
};
|
|
652
710
|
}
|
|
653
711
|
const text = decodeURIComponent(dataUri.data);
|
|
654
712
|
return { kind: "text", text };
|
|
@@ -688,7 +746,10 @@ var WebViewDocumentEngine = class extends BaseDocumentEngine {
|
|
|
688
746
|
const bytes = source instanceof Uint8Array ? source : new Uint8Array(source);
|
|
689
747
|
return { kind: "base64", data: encodeBase64(bytes) };
|
|
690
748
|
}
|
|
691
|
-
return {
|
|
749
|
+
return {
|
|
750
|
+
kind: "base64",
|
|
751
|
+
data: encodeBase64(new Uint8Array(source))
|
|
752
|
+
};
|
|
692
753
|
}
|
|
693
754
|
async fetchRemoteSource(type, uri) {
|
|
694
755
|
try {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts","../../../node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts","../../../node_modules/expo-modules-core/src/web/index.ts","../../../node_modules/expo-modules-core/src/NativeModulesProxy.ts","../../../node_modules/expo-modules-core/src/errors/CodedError.ts","../../../node_modules/expo-modules-core/src/Platform.ts","../../../node_modules/expo-modules-core/src/environment/browser.ts","../../../node_modules/expo-modules-core/src/errors/UnavailabilityError.ts","../../../node_modules/expo-modules-core/src/NativeViewManagerAdapter.tsx","../../../node_modules/expo-modules-core/src/sweet/NativeErrorManager.ts","../../../node_modules/expo-modules-core/src/sweet/setUpErrorManager.fx.ts","../../../node_modules/expo-modules-core/src/requireNativeModule.ts"],"sourcesContent":["import type { ComponentType, RefAttributes } from 'react';\nimport { NativeModules, requireNativeComponent, View, type ViewProps } from 'react-native';\nimport { requireNativeViewManager, requireOptionalNativeModule } from 'expo-modules-core';\nimport { BaseDocumentEngine, papyrusEvents } from '@papyrus-sdk/core';\r\nimport {\r\n DocumentLoadInput,\r\n DocumentLoadRequest,\r\n DocumentEngine,\r\n DocumentSource,\r\n DocumentType,\r\n PageDestination,\r\n PapyrusEventType,\r\n RenderTargetType,\r\n TextItem,\r\n OutlineItem,\r\n FileLike,\r\n SearchResult,\r\n TextSelection,\r\n} from '@papyrus-sdk/types';\r\n\r\nconst MODULE_NAME = 'PapyrusNativeEngine';\r\n\r\nconst BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\r\nconst BASE64_LOOKUP = (() => {\r\n const table = new Uint8Array(256);\r\n table.fill(255);\r\n for (let i = 0; i < BASE64_CHARS.length; i += 1) {\r\n table[BASE64_CHARS.charCodeAt(i)] = i;\r\n }\r\n return table;\r\n})();\r\n\r\nconst parseDataUri = (value: string): { mime: string; isBase64: boolean; data: string } | null => {\r\n const match = /^data:([^;,]+)?(;base64)?,(.*)$/.exec(value);\r\n if (!match) return null;\r\n return {\r\n mime: match[1] ?? '',\r\n isBase64: Boolean(match[2]),\r\n data: match[3] ?? '',\r\n };\r\n};\r\n\r\nconst looksLikeUri = (value: string): boolean =>\r\n value.startsWith('http://') ||\r\n value.startsWith('https://') ||\r\n value.startsWith('/') ||\r\n value.startsWith('./') ||\r\n value.startsWith('../') ||\r\n value.startsWith('file://');\r\n\r\nconst isLikelyBase64 = (value: string): boolean => {\r\n if (looksLikeUri(value)) return false;\r\n if (value.includes('.')) return false;\r\n if (value.length < 16) return false;\r\n return /^[A-Za-z0-9+/=]+$/.test(value);\r\n};\r\n\r\nconst isHttpUri = (value: string): boolean =>\r\n value.startsWith('http://') || value.startsWith('https://');\r\n\r\nconst decodeBase64 = (value: string): Uint8Array => {\r\n const clean = value.replace(/[^A-Za-z0-9+/=]/g, '');\r\n const padding = clean.endsWith('==') ? 2 : clean.endsWith('=') ? 1 : 0;\r\n const outputLength = Math.max(0, (clean.length * 3) / 4 - padding);\r\n const output = new Uint8Array(outputLength);\r\n\r\n let buffer = 0;\r\n let bits = 0;\r\n let index = 0;\r\n\r\n for (let i = 0; i < clean.length; i += 1) {\r\n const charCode = clean.charCodeAt(i);\r\n if (charCode === 61) break;\r\n const valueIndex = BASE64_LOOKUP[charCode];\r\n if (valueIndex === 255) continue;\r\n buffer = (buffer << 6) | valueIndex;\r\n bits += 6;\r\n if (bits >= 8) {\r\n bits -= 8;\r\n output[index++] = (buffer >> bits) & 0xff;\r\n }\r\n }\r\n return output;\r\n};\r\n\r\nconst encodeBase64 = (bytes: Uint8Array): string => {\r\n let output = '';\r\n let buffer = 0;\r\n let bits = 0;\r\n\r\n for (let i = 0; i < bytes.length; i += 1) {\r\n buffer = (buffer << 8) | bytes[i];\r\n bits += 8;\r\n while (bits >= 6) {\r\n bits -= 6;\r\n output += BASE64_CHARS[(buffer >> bits) & 0x3f];\r\n }\r\n }\r\n\r\n if (bits > 0) {\r\n output += BASE64_CHARS[(buffer << (6 - bits)) & 0x3f];\r\n }\r\n\r\n const remainder = bytes.length % 3;\r\n if (remainder === 1) return `${output}==`;\r\n if (remainder === 2) return `${output}=`;\r\n return output;\r\n};\r\n\r\nconst isLoadRequest = (input: DocumentLoadInput): input is DocumentLoadRequest =>\r\n typeof input === 'object' && input !== null && 'source' in input && 'type' in input;\r\n\r\nconst normalizeLoadInput = (input: DocumentLoadInput): { source: DocumentSource; type?: DocumentType } =>\r\n isLoadRequest(input) ? { source: input.source, type: input.type } : { source: input };\r\n\r\nconst inferDocumentType = (source: DocumentSource): DocumentType => {\r\n if (typeof source === 'string') {\r\n const dataUri = parseDataUri(source);\r\n if (dataUri?.mime) {\r\n const mime = dataUri.mime.toLowerCase();\r\n if (mime.includes('epub')) return 'epub';\r\n if (mime.includes('text')) return 'text';\r\n if (mime.includes('pdf')) return 'pdf';\r\n }\r\n\r\n const clean = source.split('?')[0].split('#')[0];\r\n const ext = clean.includes('.') ? clean.split('.').pop()?.toLowerCase() : undefined;\r\n if (ext === 'epub') return 'epub';\r\n if (ext === 'txt') return 'text';\r\n if (ext === 'pdf') return 'pdf';\r\n return 'pdf';\r\n }\r\n\r\n if (typeof source === 'object' && source !== null && 'uri' in source) {\r\n const uri = source.uri;\r\n const clean = uri.split('?')[0].split('#')[0];\r\n const ext = clean.includes('.') ? clean.split('.').pop()?.toLowerCase() : undefined;\r\n if (ext === 'epub') return 'epub';\r\n if (ext === 'txt') return 'text';\r\n if (ext === 'pdf') return 'pdf';\r\n }\r\n\r\n return 'pdf';\r\n};\r\n\r\ntype NativeDocumentSource = {\r\n uri?: string;\r\n data?: Uint8Array;\r\n};\r\n\r\ntype NativePageDestination = {\r\n kind: 'pageIndex' | 'pageNumber' | 'named';\r\n value: number | string;\r\n};\r\n\r\nconst normalizeNativeDestination = (dest: PageDestination): NativePageDestination | null => {\r\n if (!dest) return null;\r\n if (typeof dest === 'string') {\r\n return { kind: 'named', value: dest };\r\n }\r\n\r\n if (dest.kind === 'pageIndex' || dest.kind === 'pageNumber' || dest.kind === 'named') {\r\n return { kind: dest.kind, value: dest.value };\r\n }\r\n\r\n return null;\r\n};\r\n\r\ntype NativeEngineModule = {\r\n createEngine?: () => string;\r\n destroyEngine?: (engineId: string) => void;\r\n load?: (engineId: string, source: NativeDocumentSource) => Promise<{ pageCount?: number } | void>;\r\n getPageCount?: (engineId: string) => number;\r\n renderPage?: (engineId: string, pageIndex: number, target: number, scale: number, zoom: number, rotation: number) => void;\r\n renderTextLayer?: (engineId: string, pageIndex: number, target: number, scale: number, zoom: number, rotation: number) => void;\r\n getTextContent?: (engineId: string, pageIndex: number) => Promise<TextItem[]>;\r\n getPageDimensions?: (engineId: string, pageIndex: number) => Promise<{ width: number; height: number }>;\r\n searchText?: (engineId: string, query: string) => Promise<SearchResult[]>;\r\n selectText?: (engineId: string, pageIndex: number, x: number, y: number, width: number, height: number) => Promise<TextSelection | null>;\r\n getOutline?: (engineId: string) => Promise<OutlineItem[]>;\r\n getPageIndex?: (engineId: string, dest: NativePageDestination) => Promise<number | null>;\r\n};\r\n\r\nexport type PapyrusPageViewProps = ViewProps & {\n engineId?: string;\n};\n\ntype PapyrusPageViewComponent = ComponentType<PapyrusPageViewProps & RefAttributes<View>>;\n\nconst resolveNativeModule = (): NativeEngineModule | null => {\n const expoModule = requireOptionalNativeModule<NativeEngineModule>(MODULE_NAME);\n if (expoModule) return expoModule;\n const rnModule = (NativeModules as Record<string, NativeEngineModule | undefined>)[MODULE_NAME];\n return rnModule ?? null;\n};\n\nconst resolvePapyrusPageView = (): PapyrusPageViewComponent => {\n try {\n return requireNativeViewManager<PapyrusPageViewProps>('PapyrusPageView') as PapyrusPageViewComponent;\n } catch {\n try {\n return requireNativeComponent<PapyrusPageViewProps>('PapyrusPageView') as PapyrusPageViewComponent;\n } catch {\n return View as PapyrusPageViewComponent;\n }\n }\n};\n\r\nexport const PapyrusPageView = resolvePapyrusPageView();\r\n\r\nexport class NativeDocumentEngine extends BaseDocumentEngine {\r\n private nativeModule: NativeEngineModule | null = null;\r\n private engineId: string = 'default';\r\n private pageCount: number = 0;\r\n private currentPage: number = 1;\r\n private zoom: number = 1.0;\r\n private rotation: number = 0;\r\n\r\n constructor() {\n super();\n this.nativeModule = resolveNativeModule();\n this.engineId = this.nativeModule?.createEngine ? this.nativeModule.createEngine() : 'default';\n }\n\r\n async load(input: DocumentLoadInput): Promise<void> {\r\n const { source, type } = normalizeLoadInput(input);\r\n if (type && type !== 'pdf') {\r\n throw new Error(`[NativeDocumentEngine] Tipo de documento não suportado: ${type}`);\r\n }\r\n\r\n const native = this.assertNativeModule();\r\n const normalized = await this.normalizeSource(source);\r\n const result = native.load ? await native.load(this.engineId, normalized) : undefined;\r\n\r\n if (result && typeof result.pageCount === 'number') {\r\n this.pageCount = result.pageCount;\r\n } else if (native.getPageCount) {\r\n this.pageCount = native.getPageCount(this.engineId);\r\n } else {\r\n this.pageCount = 0;\r\n }\r\n\r\n this.currentPage = 1;\r\n }\r\n\r\n getPageCount(): number {\r\n return this.pageCount;\r\n }\r\n\r\n getCurrentPage(): number {\r\n return this.currentPage;\r\n }\r\n\r\n goToPage(page: number): void {\r\n if (page >= 1 && page <= this.pageCount) {\r\n this.currentPage = page;\r\n }\r\n }\r\n\r\n setZoom(zoom: number): void {\r\n this.zoom = Math.max(0.1, Math.min(5.0, zoom));\r\n }\r\n\r\n getZoom(): number {\r\n return this.zoom;\r\n }\r\n\r\n rotate(direction: 'clockwise' | 'counterclockwise'): void {\r\n if (direction === 'clockwise') {\r\n this.rotation = (this.rotation + 90) % 360;\r\n } else {\r\n this.rotation = (this.rotation - 90) % 360;\r\n if (this.rotation < 0) this.rotation += 360;\r\n }\r\n }\r\n\r\n getRotation(): number {\r\n return this.rotation;\r\n }\r\n\r\n async renderPage(pageIndex: number, target: any, scale: number): Promise<void> {\r\n const native = this.assertNativeModule();\r\n if (!native.renderPage) return;\r\n const viewTag = this.toNativeViewTag(target);\r\n if (viewTag === null) return;\r\n native.renderPage(this.engineId, pageIndex, viewTag, scale, this.zoom, this.rotation);\r\n }\r\n\r\n async renderTextLayer(pageIndex: number, target: any, scale: number): Promise<void> {\r\n const native = this.assertNativeModule();\r\n if (!native.renderTextLayer) return;\r\n const viewTag = this.toNativeViewTag(target);\r\n if (viewTag === null) return;\r\n native.renderTextLayer(this.engineId, pageIndex, viewTag, scale, this.zoom, this.rotation);\r\n }\r\n\r\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\r\n const native = this.assertNativeModule();\r\n if (!native.getTextContent) return [];\r\n return native.getTextContent(this.engineId, pageIndex);\r\n }\r\n\r\n async getPageDimensions(pageIndex: number): Promise<{ width: number; height: number }> {\r\n const native = this.assertNativeModule();\r\n if (!native.getPageDimensions) return { width: 0, height: 0 };\r\n return native.getPageDimensions(this.engineId, pageIndex);\r\n }\r\n\r\n async selectText(\r\n pageIndex: number,\r\n rect: { x: number; y: number; width: number; height: number }\r\n ): Promise<TextSelection | null> {\r\n const native = this.assertNativeModule();\r\n if (!native.selectText) return null;\r\n return native.selectText(this.engineId, pageIndex, rect.x, rect.y, rect.width, rect.height);\r\n }\r\n\r\n async getOutline(): Promise<OutlineItem[]> {\r\n const native = this.assertNativeModule();\r\n if (!native.getOutline) return [];\r\n return native.getOutline(this.engineId);\r\n }\r\n\r\n async searchText(query: string): Promise<SearchResult[]> {\r\n const native = this.assertNativeModule();\r\n if (!native.searchText) return [];\r\n return native.searchText(this.engineId, query);\r\n }\r\n\r\n async getPageIndex(dest: PageDestination): Promise<number | null> {\r\n if (!dest) return null;\r\n if (typeof dest !== 'string') {\r\n if (dest.kind === 'pageIndex') return dest.value;\r\n if (dest.kind === 'pageNumber') return Math.max(0, dest.value - 1);\r\n }\r\n\r\n const native = this.assertNativeModule();\r\n if (!native.getPageIndex) return null;\r\n const normalized = normalizeNativeDestination(dest);\r\n if (!normalized || normalized.kind !== 'named') return null;\r\n return native.getPageIndex(this.engineId, normalized);\r\n }\r\n\r\n destroy(): void {\r\n this.nativeModule?.destroyEngine?.(this.engineId);\r\n }\r\n\r\n private assertNativeModule(): NativeEngineModule {\n if (!this.nativeModule) {\n this.nativeModule = resolveNativeModule();\n }\n if (!this.nativeModule) {\n throw new Error(\n `[Papyrus] Native module \"${MODULE_NAME}\" not found. Use a dev client or a native build (Expo Go is not supported).`\n );\n }\n return this.nativeModule;\r\n }\r\n\r\n private async normalizeSource(source: DocumentSource): Promise<NativeDocumentSource> {\r\n if (typeof source === 'string') {\r\n const dataUri = parseDataUri(source);\r\n if (dataUri?.isBase64) {\r\n return { data: decodeBase64(dataUri.data) };\r\n }\r\n if (looksLikeUri(source)) return { uri: source };\r\n if (isLikelyBase64(source)) return { data: decodeBase64(source) };\r\n return { uri: source };\r\n }\r\n if (this.isUriSource(source)) return { uri: source.uri };\r\n if (this.isDataSource(source)) {\r\n const data = source.data instanceof Uint8Array ? source.data : new Uint8Array(source.data);\r\n return { data };\r\n }\r\n if (this.isFileLike(source)) {\r\n const buffer = await source.arrayBuffer();\r\n return { data: new Uint8Array(buffer) };\r\n }\r\n if (source instanceof ArrayBuffer) return { data: new Uint8Array(source) };\r\n if (source instanceof Uint8Array) return { data: source };\r\n return { data: new Uint8Array(source as ArrayBuffer) };\r\n }\r\n\r\n private isUriSource(source: DocumentSource): source is { uri: string } {\r\n return typeof source === 'object' && source !== null && 'uri' in source;\r\n }\r\n\r\n private isDataSource(source: DocumentSource): source is { data: ArrayBuffer | Uint8Array } {\r\n return typeof source === 'object' && source !== null && 'data' in source;\r\n }\r\n\r\n private isFileLike(source: DocumentSource): source is FileLike {\r\n return typeof source === 'object' && source !== null && typeof (source as FileLike).arrayBuffer === 'function';\r\n }\r\n\r\n private toNativeViewTag(target: any): number | null {\r\n if (typeof target === 'number') return target;\r\n if (target?.nativeTag && typeof target.nativeTag === 'number') return target.nativeTag;\r\n return null;\r\n }\r\n}\r\n\r\ntype WebViewBridge = {\r\n postMessage: (message: string) => void;\r\n};\r\n\r\ntype WebViewResponseMessage = {\r\n type: 'response';\r\n id: string;\r\n ok: boolean;\r\n data?: any;\r\n error?: string;\r\n};\r\n\r\ntype WebViewEventMessage = {\r\n type: 'event';\r\n name: string;\r\n payload?: any;\r\n};\r\n\r\ntype WebViewStateMessage = {\r\n type: 'state';\r\n payload: {\r\n pageCount?: number;\r\n currentPage?: number;\r\n zoom?: number;\r\n outline?: OutlineItem[];\r\n };\r\n};\r\n\r\ntype WebViewReadyMessage = {\r\n type: 'ready';\r\n};\r\n\r\ntype WebViewRuntimeMessage =\r\n | WebViewResponseMessage\r\n | WebViewEventMessage\r\n | WebViewStateMessage\r\n | WebViewReadyMessage;\r\n\r\ntype WebViewSourcePayload =\r\n | { kind: 'uri'; uri: string }\r\n | { kind: 'base64'; data: string; mime?: string }\r\n | { kind: 'text'; text: string };\r\n\r\nexport class WebViewDocumentEngine extends BaseDocumentEngine {\r\n private bridge: WebViewBridge | null = null;\r\n private ready = false;\r\n private requestId = 0;\r\n private pending = new Map<string, { resolve: (data: any) => void; reject: (error: Error) => void }>();\r\n private bridgeResolvers: Array<(bridge: WebViewBridge) => void> = [];\r\n private readyResolvers: Array<() => void> = [];\r\n private pageCount = 0;\r\n private currentPage = 1;\r\n private zoom = 1.0;\r\n private rotation = 0;\r\n private outline: OutlineItem[] = [];\r\n\r\n getRenderTargetType(): 'webview' {\r\n return 'webview';\r\n }\r\n\r\n attachBridge(bridge: WebViewBridge): void {\r\n this.bridge = bridge;\r\n this.bridgeResolvers.forEach((resolve) => resolve(bridge));\r\n this.bridgeResolvers = [];\r\n }\r\n\r\n handleMessage(raw: string): void {\r\n let message: WebViewRuntimeMessage | null = null;\r\n try {\r\n message = JSON.parse(raw) as WebViewRuntimeMessage;\r\n } catch {\r\n return;\r\n }\r\n\r\n if (!message) return;\r\n\r\n if (message.type === 'ready') {\r\n this.ready = true;\r\n this.readyResolvers.forEach((resolve) => resolve());\r\n this.readyResolvers = [];\r\n return;\r\n }\r\n\r\n if (message.type === 'response') {\r\n const pending = this.pending.get(message.id);\r\n if (!pending) return;\r\n this.pending.delete(message.id);\r\n if (message.ok) {\r\n pending.resolve(message.data);\r\n } else {\r\n pending.reject(new Error(message.error ?? '[Papyrus] WebView runtime error'));\r\n }\r\n return;\r\n }\r\n\r\n if (message.type === 'state') {\r\n if (typeof message.payload.pageCount === 'number') this.pageCount = message.payload.pageCount;\r\n if (typeof message.payload.currentPage === 'number') this.currentPage = message.payload.currentPage;\r\n if (typeof message.payload.zoom === 'number') this.zoom = message.payload.zoom;\r\n if (Array.isArray(message.payload.outline)) this.outline = message.payload.outline;\r\n return;\r\n }\r\n\r\n if (message.type === 'event') {\r\n const payload = message.payload ?? {};\r\n if (message.name === 'RUNTIME_LOG') {\r\n if (__DEV__) {\r\n const text = typeof payload?.message === 'string' ? payload.message : JSON.stringify(payload);\r\n console.log('[Papyrus WebView runtime]', text);\r\n }\r\n return;\r\n }\r\n if (message.name === 'RUNTIME_ERROR') {\n const errorMessage = typeof payload?.message === 'string' ? payload.message : '';\n if (errorMessage.includes('ResizeObserver loop')) {\n return;\n }\n if (__DEV__) {\n console.warn('[Papyrus WebView runtime]', payload);\n }\n return;\n }\n if (message.name === PapyrusEventType.TEXT_SELECTED) {\r\n papyrusEvents.emit(PapyrusEventType.TEXT_SELECTED, payload);\r\n } else if (message.name === PapyrusEventType.SEARCH_TRIGGERED) {\r\n papyrusEvents.emit(PapyrusEventType.SEARCH_TRIGGERED, payload);\r\n } else if (message.name === PapyrusEventType.DOCUMENT_LOADED) {\r\n if (typeof payload.pageCount === 'number') {\r\n this.pageCount = payload.pageCount;\r\n }\r\n papyrusEvents.emit(PapyrusEventType.DOCUMENT_LOADED, payload);\r\n }\r\n return;\r\n }\r\n\r\n if (__DEV__) {\r\n console.warn('[Papyrus WebView] Unknown message', message);\r\n }\r\n }\r\n\r\n async load(input: DocumentLoadInput): Promise<void> {\r\n const { source, type } = normalizeLoadInput(input);\r\n const resolvedType = type ?? inferDocumentType(source);\r\n if (resolvedType === 'pdf') {\r\n throw new Error('[WebViewDocumentEngine] Use o NativeDocumentEngine para PDFs no mobile.');\r\n }\r\n\r\n const payloadSource = await this.normalizeRuntimeSource(resolvedType, source);\r\n const response = await this.request<{ pageCount?: number; outline?: OutlineItem[] }>('load', {\r\n type: resolvedType,\r\n source: payloadSource,\r\n });\r\n\r\n if (typeof response?.pageCount === 'number') this.pageCount = response.pageCount;\r\n if (Array.isArray(response?.outline)) this.outline = response.outline;\r\n this.currentPage = 1;\r\n }\r\n\r\n getPageCount(): number {\r\n return this.pageCount;\r\n }\r\n\r\n getCurrentPage(): number {\r\n return this.currentPage;\r\n }\r\n\r\n goToPage(page: number): void {\r\n if (page < 1) return;\r\n this.currentPage = page;\r\n void this.request('go-to-page', { page });\r\n }\r\n\r\n setZoom(zoom: number): void {\r\n this.zoom = Math.max(0.5, Math.min(4.0, zoom));\r\n void this.request('set-zoom', { zoom: this.zoom });\r\n }\r\n\r\n getZoom(): number {\r\n return this.zoom;\r\n }\r\n\r\n rotate(direction: 'clockwise' | 'counterclockwise'): void {\r\n if (direction === 'clockwise') {\r\n this.rotation = (this.rotation + 90) % 360;\r\n } else {\r\n this.rotation = (this.rotation - 90) % 360;\r\n if (this.rotation < 0) this.rotation += 360;\r\n }\r\n void this.request('set-rotation', { rotation: this.rotation });\r\n }\r\n\r\n getRotation(): number {\r\n return this.rotation;\r\n }\r\n\r\n async renderPage(pageIndex: number, target: any, scale: number): Promise<void> {\r\n void pageIndex;\r\n void target;\r\n void scale;\r\n }\r\n\r\n async renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void> {\r\n void pageIndex;\r\n void container;\r\n void scale;\r\n }\r\n\r\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\r\n return await this.request<TextItem[]>('get-text-content', { pageIndex });\r\n }\r\n\r\n async getPageDimensions(pageIndex: number): Promise<{ width: number; height: number }> {\r\n return await this.request<{ width: number; height: number }>('get-page-dimensions', { pageIndex });\r\n }\r\n\r\n async searchText(query: string): Promise<SearchResult[]> {\r\n return await this.request<SearchResult[]>('search-text', { query });\r\n }\r\n\r\n async selectText(\r\n pageIndex: number,\r\n rect: { x: number; y: number; width: number; height: number }\r\n ): Promise<TextSelection | null> {\r\n return await this.request<TextSelection | null>('select-text', { pageIndex, rect });\r\n }\r\n\r\n async getOutline(): Promise<OutlineItem[]> {\r\n if (this.outline.length > 0) return this.outline;\r\n return await this.request<OutlineItem[]>('get-outline');\r\n }\r\n\r\n async getPageIndex(dest: PageDestination): Promise<number | null> {\r\n if (!dest) return null;\r\n if (typeof dest !== 'string') {\r\n if (dest.kind === 'pageIndex') return dest.value;\r\n if (dest.kind === 'pageNumber') return Math.max(0, dest.value - 1);\r\n if (dest.kind === 'href') {\r\n return await this.request<number | null>('get-page-index', { dest: dest.value });\r\n }\r\n return null;\r\n }\r\n return await this.request<number | null>('get-page-index', { dest });\r\n }\r\n\r\n destroy(): void {\r\n this.pending.forEach(({ reject }) => reject(new Error('[Papyrus] WebView engine destroyed')));\r\n this.pending.clear();\r\n this.bridge = null;\r\n this.ready = false;\r\n }\r\n\r\n private async ensureBridge(): Promise<WebViewBridge> {\r\n if (this.bridge) return this.bridge;\r\n return new Promise((resolve) => {\r\n this.bridgeResolvers.push(resolve);\r\n });\r\n }\r\n\r\n private async ensureReady(): Promise<void> {\r\n if (this.ready) return;\r\n return new Promise((resolve) => {\r\n this.readyResolvers.push(resolve);\r\n });\r\n }\r\n\r\n private async request<T = any>(kind: string, payload?: any): Promise<T> {\r\n const bridge = await this.ensureBridge();\r\n await this.ensureReady();\r\n const id = `${Date.now()}-${this.requestId++}`;\r\n return new Promise<T>((resolve, reject) => {\r\n const timeoutMs = kind === 'load' ? 30000 : 8000;\r\n const timeoutId = setTimeout(() => {\r\n this.pending.delete(id);\r\n reject(new Error(`[Papyrus] WebView response timeout: ${kind}`));\r\n }, timeoutMs);\r\n this.pending.set(id, {\r\n resolve: (data) => {\r\n clearTimeout(timeoutId);\r\n resolve(data);\r\n },\r\n reject: (error) => {\r\n clearTimeout(timeoutId);\r\n reject(error);\r\n },\r\n });\r\n bridge.postMessage(JSON.stringify({ id, kind, payload }));\r\n });\r\n }\r\n\r\n private async normalizeRuntimeSource(type: DocumentType, source: DocumentSource): Promise<WebViewSourcePayload> {\r\n if (typeof source === 'string') {\r\n const dataUri = parseDataUri(source);\r\n if (dataUri) {\r\n if (dataUri.isBase64) {\r\n return { kind: 'base64', data: dataUri.data, mime: dataUri.mime || undefined };\r\n }\r\n const text = decodeURIComponent(dataUri.data);\r\n return { kind: 'text', text };\r\n }\r\n\r\n if (looksLikeUri(source)) {\r\n if (isHttpUri(source)) {\r\n const fetched = await this.fetchRemoteSource(type, source);\r\n if (fetched) return fetched;\r\n }\r\n return { kind: 'uri', uri: source };\r\n }\r\n\r\n if (isLikelyBase64(source)) {\r\n return { kind: 'base64', data: source };\r\n }\r\n\r\n if (type === 'text') {\r\n return { kind: 'text', text: source };\r\n }\r\n\r\n return { kind: 'uri', uri: source };\r\n }\r\n\r\n if (this.isUriSource(source)) {\r\n const uri = source.uri;\r\n if (isHttpUri(uri)) {\r\n const fetched = await this.fetchRemoteSource(type, uri);\r\n if (fetched) return fetched;\r\n }\r\n return { kind: 'uri', uri };\r\n }\r\n if (this.isDataSource(source)) {\r\n const bytes = source.data instanceof Uint8Array ? source.data : new Uint8Array(source.data);\r\n return { kind: 'base64', data: encodeBase64(bytes) };\r\n }\r\n if (this.isFileLike(source)) {\r\n const buffer = await source.arrayBuffer();\r\n return { kind: 'base64', data: encodeBase64(new Uint8Array(buffer)) };\r\n }\r\n if (source instanceof ArrayBuffer || source instanceof Uint8Array) {\r\n const bytes = source instanceof Uint8Array ? source : new Uint8Array(source);\r\n return { kind: 'base64', data: encodeBase64(bytes) };\r\n }\r\n\r\n return { kind: 'base64', data: encodeBase64(new Uint8Array(source as ArrayBuffer)) };\r\n }\r\n\r\n private async fetchRemoteSource(type: DocumentType, uri: string): Promise<WebViewSourcePayload | null> {\r\n try {\r\n const response = await fetch(uri);\r\n if (!response.ok) return null;\r\n if (type === 'text') {\r\n const text = await response.text();\r\n return { kind: 'text', text };\r\n }\r\n if (type === 'epub') {\r\n const buffer = await this.readResponseBuffer(response);\r\n return { kind: 'base64', data: encodeBase64(new Uint8Array(buffer)) };\r\n }\r\n return null;\r\n } catch {\r\n return null;\r\n }\r\n }\r\n\r\n private async readResponseBuffer(response: Response): Promise<ArrayBuffer> {\r\n try {\r\n return await response.arrayBuffer();\r\n } catch {\r\n const blob = await response.blob();\r\n return await new Promise<ArrayBuffer>((resolve, reject) => {\r\n const reader = new FileReader();\r\n reader.onerror = () => reject(new Error('[Papyrus] Failed to read response blob'));\r\n reader.onload = () => resolve(reader.result as ArrayBuffer);\r\n reader.readAsArrayBuffer(blob);\r\n });\r\n }\r\n }\r\n\r\n private isUriSource(source: DocumentSource): source is { uri: string } {\r\n return typeof source === 'object' && source !== null && 'uri' in source;\r\n }\r\n\r\n private isDataSource(source: DocumentSource): source is { data: ArrayBuffer | Uint8Array } {\r\n return typeof source === 'object' && source !== null && 'data' in source;\r\n }\r\n\r\n private isFileLike(source: DocumentSource): source is FileLike {\r\n return typeof source === 'object' && source !== null && typeof (source as FileLike).arrayBuffer === 'function';\r\n }\r\n}\r\n\r\nexport class MobileDocumentEngine extends BaseDocumentEngine {\r\n private pdfEngine: NativeDocumentEngine;\r\n private webEngine: WebViewDocumentEngine;\r\n private activeEngine: DocumentEngine;\r\n\r\n constructor() {\r\n super();\r\n this.pdfEngine = new NativeDocumentEngine();\r\n this.webEngine = new WebViewDocumentEngine();\r\n this.activeEngine = this.pdfEngine;\r\n }\r\n\r\n getRenderTargetType(): RenderTargetType {\r\n return this.activeEngine.getRenderTargetType?.() ?? 'canvas';\r\n }\r\n\r\n attachWebView(bridge: WebViewBridge): void {\r\n this.webEngine.attachBridge(bridge);\r\n }\r\n\r\n handleWebViewMessage(data: string): void {\r\n this.webEngine.handleMessage(data);\r\n }\r\n\r\n async load(input: DocumentLoadInput): Promise<void> {\r\n const { source, type } = normalizeLoadInput(input);\r\n const resolvedType = type ?? inferDocumentType(source);\r\n this.activeEngine = resolvedType === 'pdf' ? this.pdfEngine : this.webEngine;\r\n await this.activeEngine.load({ type: resolvedType, source });\r\n }\r\n\r\n getPageCount(): number {\r\n return this.activeEngine.getPageCount();\r\n }\r\n\r\n getCurrentPage(): number {\r\n return this.activeEngine.getCurrentPage();\r\n }\r\n\r\n goToPage(page: number): void {\r\n this.activeEngine.goToPage(page);\r\n }\r\n\r\n setZoom(zoom: number): void {\r\n this.activeEngine.setZoom(zoom);\r\n }\r\n\r\n getZoom(): number {\r\n return this.activeEngine.getZoom();\r\n }\r\n\r\n rotate(direction: 'clockwise' | 'counterclockwise'): void {\r\n this.activeEngine.rotate(direction);\r\n }\r\n\r\n getRotation(): number {\r\n return this.activeEngine.getRotation();\r\n }\r\n\r\n async renderPage(pageIndex: number, target: any, scale: number): Promise<void> {\r\n await this.activeEngine.renderPage(pageIndex, target, scale);\r\n }\r\n\r\n async renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void> {\r\n await this.activeEngine.renderTextLayer(pageIndex, container, scale);\r\n }\r\n\r\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\r\n return await this.activeEngine.getTextContent(pageIndex);\r\n }\r\n\r\n async getPageDimensions(pageIndex: number): Promise<{ width: number; height: number }> {\r\n return await this.activeEngine.getPageDimensions(pageIndex);\r\n }\r\n\r\n async searchText(query: string): Promise<SearchResult[]> {\r\n if (typeof this.activeEngine.searchText === 'function') {\r\n return await this.activeEngine.searchText(query);\r\n }\r\n return [];\r\n }\r\n\r\n async selectText(\r\n pageIndex: number,\r\n rect: { x: number; y: number; width: number; height: number }\r\n ): Promise<TextSelection | null> {\r\n if (typeof this.activeEngine.selectText === 'function') {\r\n return await this.activeEngine.selectText(pageIndex, rect);\r\n }\r\n return null;\r\n }\r\n\r\n async getOutline(): Promise<OutlineItem[]> {\r\n return await this.activeEngine.getOutline();\r\n }\r\n\r\n async getPageIndex(dest: PageDestination): Promise<number | null> {\r\n return await this.activeEngine.getPageIndex(dest);\r\n }\r\n\r\n destroy(): void {\r\n this.pdfEngine.destroy();\r\n this.webEngine.destroy();\r\n }\r\n}\r\n","import { NativeModules, Platform } from 'react-native';\n\nimport { registerWebGlobals } from './web/index';\n\n/**\n * Ensures that the native modules are installed in the current runtime.\n * Otherwise, it synchronously calls a native function that installs them.\n */\nexport function ensureNativeModulesAreInstalled(): void {\n if (globalThis.expo) {\n return;\n }\n try {\n if (Platform.OS === 'web') {\n // Requiring web folder sets up the `globalThis.expo` object.\n registerWebGlobals();\n } else {\n // TODO: ExpoModulesCore shouldn't be optional here,\n // but to keep backwards compatibility let's just ignore it in SDK 50.\n // In most cases the modules were already installed from the native side.\n NativeModules.ExpoModulesCore?.installModules();\n }\n } catch (error) {\n console.error(`Unable to install Expo modules: ${error}`);\n }\n}\n","export function registerWebGlobals() {}\n","import type { ProxyNativeModule } from './NativeModulesProxy.types';\n\n// We default to an empty object shim wherever we don't have an environment-specific implementation\n\n/**\n * @deprecated `NativeModulesProxy` is deprecated and might be removed in the future releases.\n * Use `requireNativeModule` or `requireOptionalNativeModule` instead.\n */\nexport default {} as { [moduleName: string]: ProxyNativeModule };\n","/**\n * A general error class that should be used for all errors in Expo modules.\n * Guarantees a `code` field that can be used to differentiate between different\n * types of errors without further subclassing Error.\n */\nexport class CodedError extends Error {\n code: string;\n info?: any;\n\n constructor(code: string, message: string) {\n super(message);\n this.code = code;\n }\n}\n","import { PlatformOSType, Platform as ReactNativePlatform } from 'react-native';\n\nimport {\n isDOMAvailable,\n canUseEventListeners,\n canUseViewport,\n isAsyncDebugging,\n} from './environment/browser';\n\nexport type PlatformSelectOSType = PlatformOSType | 'native' | 'electron' | 'default';\n\nexport type PlatformSelect = <T>(specifics: { [platform in PlatformSelectOSType]?: T }) => T;\n\nif (__DEV__ && typeof process.env.EXPO_OS === 'undefined') {\n console.warn(\n `The global process.env.EXPO_OS is not defined. This should be inlined by babel-preset-expo during transformation.`\n );\n}\n\nconst nativeSelect =\n typeof window !== 'undefined'\n ? ReactNativePlatform.select\n : // process.env.EXPO_OS is injected by `babel-preset-expo` and available in both client and `react-server` environments.\n // Opt to use the env var when possible, and fallback to the React Native Platform module when it's not (arbitrary bundlers and transformers).\n function select<T>(specifics: { [platform in PlatformSelectOSType]?: T }): T | undefined {\n if (!process.env.EXPO_OS) return undefined;\n if (specifics.hasOwnProperty(process.env.EXPO_OS)) {\n return specifics[process.env.EXPO_OS]!;\n } else if (process.env.EXPO_OS !== 'web' && specifics.hasOwnProperty('native')) {\n return specifics.native!;\n } else if (specifics.hasOwnProperty('default')) {\n return specifics.default!;\n }\n // do nothing...\n return undefined;\n };\n\nconst Platform = {\n /**\n * Denotes the currently running platform.\n * Can be one of ios, android, web.\n */\n OS: process.env.EXPO_OS || ReactNativePlatform.OS,\n /**\n * Returns the value with the matching platform.\n * Object keys can be any of ios, android, native, web, default.\n *\n * @ios ios, native, default\n * @android android, native, default\n * @web web, default\n */\n select: nativeSelect as PlatformSelect,\n /**\n * Denotes if the DOM API is available in the current environment.\n * The DOM is not available in native React runtimes and Node.js.\n */\n isDOMAvailable,\n /**\n * Denotes if the current environment can attach event listeners\n * to the window. This will return false in native React\n * runtimes and Node.js.\n */\n canUseEventListeners,\n /**\n * Denotes if the current environment can inspect properties of the\n * screen on which the current window is being rendered. This will\n * return false in native React runtimes and Node.js.\n */\n canUseViewport,\n /**\n * If the JavaScript is being executed in a remote JavaScript environment.\n * When `true`, synchronous native invocations cannot be executed.\n */\n isAsyncDebugging,\n};\n\nexport default Platform;\n","declare const global: any;\n\n// In standard node environments there is no DOM API\nexport const isDOMAvailable = false;\nexport const canUseEventListeners = false;\nexport const canUseViewport = false;\n\nexport let isAsyncDebugging: boolean = false;\n\nif (__DEV__) {\n // These native globals are injected by native React runtimes and not standard browsers\n // we can use them to determine if the JS is being executed in Chrome.\n isAsyncDebugging =\n !global.nativeExtensions && !global.nativeCallSyncHook && !global.RN$Bridgeless;\n}\n","import { CodedError } from './CodedError';\nimport Platform from '../Platform';\n\n/**\n * A class for errors to be thrown when a property is accessed which is\n * unavailable, unsupported, or not currently implemented on the running\n * platform.\n */\nexport class UnavailabilityError extends CodedError {\n constructor(moduleName: string, propertyName: string) {\n super(\n 'ERR_UNAVAILABLE',\n `The method or property ${moduleName}.${propertyName} is not available on ${Platform.OS}, are you sure you've linked all the native dependencies properly?`\n );\n }\n}\n","import React from 'react';\n\nimport { UnavailabilityError } from './errors/UnavailabilityError';\n\n/**\n * A drop-in replacement for `requireNativeComponent`.\n */\nexport function requireNativeViewManager<P = any>(viewName: string): React.ComponentType<P> {\n throw new UnavailabilityError('expo-modules-core', 'requireNativeViewManager');\n}\n","import NativeModulesProxy from '../NativeModulesProxy';\nexport default NativeModulesProxy.ExpoModulesCoreErrorManager;\n","import NativeErrorManager from './NativeErrorManager';\nimport Platform from '../Platform';\nimport { CodedError } from '../errors/CodedError';\n\nif (__DEV__ && Platform.OS === 'android' && NativeErrorManager) {\n const onNewException = 'ExpoModulesCoreErrorManager.onNewException';\n const onNewWarning = 'ExpoModulesCoreErrorManager.onNewWarning';\n\n NativeErrorManager.addListener(onNewException, ({ message }: { message: string }) => {\n console.error(message);\n });\n\n NativeErrorManager.addListener(onNewWarning, ({ message }: { message: string }) => {\n console.warn(message);\n });\n}\n\n// We have to export `CodedError` via global object to use in later in the C++ code.\nglobalThis.ExpoModulesCore_CodedError = CodedError;\n","import NativeModulesProxy from './NativeModulesProxy';\nimport { ensureNativeModulesAreInstalled } from './ensureNativeModulesAreInstalled';\n\n/**\n * Imports the native module registered with given name. In the first place it tries to load\n * the module installed through the JSI host object and then falls back to the bridge proxy module.\n * Notice that the modules loaded from the proxy may not support some features like synchronous functions.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module.\n * @throws Error when there is no native module with given name.\n */\nexport function requireNativeModule<ModuleType = any>(moduleName: string): ModuleType {\n const nativeModule = requireOptionalNativeModule<ModuleType>(moduleName);\n\n if (!nativeModule) {\n throw new Error(`Cannot find native module '${moduleName}'`);\n }\n return nativeModule;\n}\n\n/**\n * Imports the native module registered with the given name. The same as `requireNativeModule`,\n * but returns `null` when the module cannot be found instead of throwing an error.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module or `null` when it cannot be found.\n */\nexport function requireOptionalNativeModule<ModuleType = any>(\n moduleName: string\n): ModuleType | null {\n ensureNativeModulesAreInstalled();\n\n return globalThis.expo?.modules?.[moduleName] ?? NativeModulesProxy[moduleName] ?? null;\n}\n"],"mappings":";AACA,SAAS,iBAAAA,gBAAe,wBAAwB,YAA4B;;;ACD5E,SAAS,eAAe,gBAAgB;;;ACAjC,SAAS,qBAAqB;AAAC;;;ADQ/B,SAAS,kCAAwC;AACtD,MAAI,WAAW,MAAM;AACnB;AAAA,EACF;AACA,MAAI;AACF,QAAI,SAAS,OAAO,OAAO;AAEzB,yBAAmB;AAAA,IACrB,OAAO;AAIL,oBAAc,iBAAiB,eAAe;AAAA,IAChD;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,mCAAmC,KAAK,EAAE;AAAA,EAC1D;AACF;;;AEjBA,IAAO,6BAAQ,CAAC;;;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eAAe,YAAY;AACtD,aAAO,MAAM,KAAK,aAAa,WAAW,WAAW,IAAI;AAAA,IAC3D;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,aAAqC;AACzC,WAAO,MAAM,KAAK,aAAa,WAAW;AAAA,EAC5C;AAAA,EAEA,MAAM,aAAa,MAA+C;AAChE,WAAO,MAAM,KAAK,aAAa,aAAa,IAAI;AAAA,EAClD;AAAA,EAEA,UAAgB;AACd,SAAK,UAAU,QAAQ;AACvB,SAAK,UAAU,QAAQ;AAAA,EACzB;AACF;","names":["NativeModules","Platform","NativeModules"]}
|
|
1
|
+
{"version":3,"sources":["../index.ts","../../../node_modules/expo-modules-core/src/ensureNativeModulesAreInstalled.ts","../../../node_modules/expo-modules-core/src/web/index.ts","../../../node_modules/expo-modules-core/src/NativeModulesProxy.ts","../../../node_modules/expo-modules-core/src/errors/CodedError.ts","../../../node_modules/expo-modules-core/src/Platform.ts","../../../node_modules/expo-modules-core/src/environment/browser.ts","../../../node_modules/expo-modules-core/src/errors/UnavailabilityError.ts","../../../node_modules/expo-modules-core/src/NativeViewManagerAdapter.tsx","../../../node_modules/expo-modules-core/src/sweet/NativeErrorManager.ts","../../../node_modules/expo-modules-core/src/sweet/setUpErrorManager.fx.ts","../../../node_modules/expo-modules-core/src/requireNativeModule.ts"],"sourcesContent":["import type { ComponentType, RefAttributes } from \"react\";\nimport {\n NativeModules,\n requireNativeComponent,\n View,\n type ViewProps,\n} from \"react-native\";\nimport {\n requireNativeViewManager,\n requireOptionalNativeModule,\n} from \"expo-modules-core\";\nimport { BaseDocumentEngine, papyrusEvents } from \"@papyrus-sdk/core\";\nimport {\n DocumentLoadInput,\n DocumentLoadRequest,\n DocumentEngine,\n DocumentSource,\n DocumentType,\n PageDestination,\n PapyrusEventType,\n RenderTargetType,\n TextItem,\n OutlineItem,\n FileLike,\n SearchResult,\n TextSelection,\n} from \"@papyrus-sdk/types\";\n\nconst MODULE_NAME = \"PapyrusNativeEngine\";\n\nconst BASE64_CHARS =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nconst BASE64_LOOKUP = (() => {\n const table = new Uint8Array(256);\n table.fill(255);\n for (let i = 0; i < BASE64_CHARS.length; i += 1) {\n table[BASE64_CHARS.charCodeAt(i)] = i;\n }\n return table;\n})();\n\nconst parseDataUri = (\n value: string\n): { mime: string; isBase64: boolean; data: string } | null => {\n const match = /^data:([^;,]+)?(;base64)?,(.*)$/.exec(value);\n if (!match) return null;\n return {\n mime: match[1] ?? \"\",\n isBase64: Boolean(match[2]),\n data: match[3] ?? \"\",\n };\n};\n\nconst looksLikeUri = (value: string): boolean =>\n value.startsWith(\"http://\") ||\n value.startsWith(\"https://\") ||\n value.startsWith(\"/\") ||\n value.startsWith(\"./\") ||\n value.startsWith(\"../\") ||\n value.startsWith(\"file://\");\n\nconst isLikelyBase64 = (value: string): boolean => {\n if (looksLikeUri(value)) return false;\n if (value.includes(\".\")) return false;\n if (value.length < 16) return false;\n return /^[A-Za-z0-9+/=]+$/.test(value);\n};\n\nconst isHttpUri = (value: string): boolean =>\n value.startsWith(\"http://\") || value.startsWith(\"https://\");\n\nconst decodeBase64 = (value: string): Uint8Array => {\n const clean = value.replace(/[^A-Za-z0-9+/=]/g, \"\");\n const padding = clean.endsWith(\"==\") ? 2 : clean.endsWith(\"=\") ? 1 : 0;\n const outputLength = Math.max(0, (clean.length * 3) / 4 - padding);\n const output = new Uint8Array(outputLength);\n\n let buffer = 0;\n let bits = 0;\n let index = 0;\n\n for (let i = 0; i < clean.length; i += 1) {\n const charCode = clean.charCodeAt(i);\n if (charCode === 61) break;\n const valueIndex = BASE64_LOOKUP[charCode];\n if (valueIndex === 255) continue;\n buffer = (buffer << 6) | valueIndex;\n bits += 6;\n if (bits >= 8) {\n bits -= 8;\n output[index++] = (buffer >> bits) & 0xff;\n }\n }\n return output;\n};\n\nconst encodeBase64 = (bytes: Uint8Array): string => {\n let output = \"\";\n let buffer = 0;\n let bits = 0;\n\n for (let i = 0; i < bytes.length; i += 1) {\n buffer = (buffer << 8) | bytes[i];\n bits += 8;\n while (bits >= 6) {\n bits -= 6;\n output += BASE64_CHARS[(buffer >> bits) & 0x3f];\n }\n }\n\n if (bits > 0) {\n output += BASE64_CHARS[(buffer << (6 - bits)) & 0x3f];\n }\n\n const remainder = bytes.length % 3;\n if (remainder === 1) return `${output}==`;\n if (remainder === 2) return `${output}=`;\n return output;\n};\n\nconst isLoadRequest = (\n input: DocumentLoadInput\n): input is DocumentLoadRequest =>\n typeof input === \"object\" &&\n input !== null &&\n \"source\" in input &&\n \"type\" in input;\n\nconst normalizeLoadInput = (\n input: DocumentLoadInput\n): { source: DocumentSource; type?: DocumentType } =>\n isLoadRequest(input)\n ? { source: input.source, type: input.type }\n : { source: input };\n\nconst inferDocumentType = (source: DocumentSource): DocumentType => {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri?.mime) {\n const mime = dataUri.mime.toLowerCase();\n if (mime.includes(\"epub\")) return \"epub\";\n if (mime.includes(\"text\")) return \"text\";\n if (mime.includes(\"pdf\")) return \"pdf\";\n }\n\n const clean = source.split(\"?\")[0].split(\"#\")[0];\n const ext = clean.includes(\".\")\n ? clean.split(\".\").pop()?.toLowerCase()\n : undefined;\n if (ext === \"epub\") return \"epub\";\n if (ext === \"txt\") return \"text\";\n if (ext === \"pdf\") return \"pdf\";\n return \"pdf\";\n }\n\n if (typeof source === \"object\" && source !== null && \"uri\" in source) {\n const uri = source.uri;\n const clean = uri.split(\"?\")[0].split(\"#\")[0];\n const ext = clean.includes(\".\")\n ? clean.split(\".\").pop()?.toLowerCase()\n : undefined;\n if (ext === \"epub\") return \"epub\";\n if (ext === \"txt\") return \"text\";\n if (ext === \"pdf\") return \"pdf\";\n }\n\n return \"pdf\";\n};\n\ntype NativeDocumentSource = {\n uri?: string;\n data?: Uint8Array;\n};\n\ntype NativePageDestination = {\n kind: \"pageIndex\" | \"pageNumber\" | \"named\";\n value: number | string;\n};\n\nconst normalizeNativeDestination = (\n dest: PageDestination\n): NativePageDestination | null => {\n if (!dest) return null;\n if (typeof dest === \"string\") {\n return { kind: \"named\", value: dest };\n }\n\n if (\n dest.kind === \"pageIndex\" ||\n dest.kind === \"pageNumber\" ||\n dest.kind === \"named\"\n ) {\n return { kind: dest.kind, value: dest.value };\n }\n\n return null;\n};\n\ntype NativeEngineModule = {\n createEngine?: () => string;\n destroyEngine?: (engineId: string) => void;\n load?: (\n engineId: string,\n source: NativeDocumentSource\n ) => Promise<{ pageCount?: number } | void>;\n getPageCount?: (engineId: string) => number;\n renderPage?: (\n engineId: string,\n pageIndex: number,\n target: number,\n scale: number,\n zoom: number,\n rotation: number\n ) => void;\n renderTextLayer?: (\n engineId: string,\n pageIndex: number,\n target: number,\n scale: number,\n zoom: number,\n rotation: number\n ) => void;\n getTextContent?: (engineId: string, pageIndex: number) => Promise<TextItem[]>;\n getPageDimensions?: (\n engineId: string,\n pageIndex: number\n ) => Promise<{ width: number; height: number }>;\n searchText?: (engineId: string, query: string) => Promise<SearchResult[]>;\n selectText?: (\n engineId: string,\n pageIndex: number,\n x: number,\n y: number,\n width: number,\n height: number\n ) => Promise<TextSelection | null>;\n getOutline?: (engineId: string) => Promise<OutlineItem[]>;\n getPageIndex?: (\n engineId: string,\n dest: NativePageDestination\n ) => Promise<number | null>;\n};\n\nexport type PapyrusPageViewProps = ViewProps & {\n engineId?: string;\n};\n\ntype PapyrusPageViewComponent = ComponentType<\n PapyrusPageViewProps & RefAttributes<View>\n>;\n\nconst resolveNativeModule = (): NativeEngineModule | null => {\n const expoModule =\n requireOptionalNativeModule<NativeEngineModule>(MODULE_NAME);\n if (expoModule) return expoModule;\n const rnModule = (\n NativeModules as Record<string, NativeEngineModule | undefined>\n )[MODULE_NAME];\n return rnModule ?? null;\n};\n\nconst resolvePapyrusPageView = (): PapyrusPageViewComponent => {\n try {\n return requireNativeViewManager<PapyrusPageViewProps>(\n \"PapyrusPageView\"\n ) as PapyrusPageViewComponent;\n } catch {\n try {\n return requireNativeComponent<PapyrusPageViewProps>(\n \"PapyrusPageView\"\n ) as PapyrusPageViewComponent;\n } catch {\n return View as PapyrusPageViewComponent;\n }\n }\n};\n\nexport const PapyrusPageView = resolvePapyrusPageView();\n\nexport class NativeDocumentEngine extends BaseDocumentEngine {\n private nativeModule: NativeEngineModule | null = null;\n private engineId: string = \"default\";\n private pageCount: number = 0;\n private currentPage: number = 1;\n private zoom: number = 1.0;\n private rotation: number = 0;\n\n constructor() {\n super();\n this.nativeModule = resolveNativeModule();\n this.engineId = this.nativeModule?.createEngine\n ? this.nativeModule.createEngine()\n : \"default\";\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type } = normalizeLoadInput(input);\n if (type && type !== \"pdf\") {\n throw new Error(\n `[NativeDocumentEngine] Tipo de documento não suportado: ${type}`\n );\n }\n\n const native = this.assertNativeModule();\n const normalized = await this.normalizeSource(source);\n const result = native.load\n ? await native.load(this.engineId, normalized)\n : undefined;\n\n if (result && typeof result.pageCount === \"number\") {\n this.pageCount = result.pageCount;\n } else if (native.getPageCount) {\n this.pageCount = native.getPageCount(this.engineId);\n } else {\n this.pageCount = 0;\n }\n\n this.currentPage = 1;\n }\n\n getPageCount(): number {\n return this.pageCount;\n }\n\n getCurrentPage(): number {\n return this.currentPage;\n }\n\n goToPage(page: number): void {\n if (page >= 1 && page <= this.pageCount) {\n this.currentPage = page;\n }\n }\n\n setZoom(zoom: number): void {\n this.zoom = Math.max(0.1, Math.min(5.0, zoom));\n }\n\n getZoom(): number {\n return this.zoom;\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n if (direction === \"clockwise\") {\n this.rotation = (this.rotation + 90) % 360;\n } else {\n this.rotation = (this.rotation - 90) % 360;\n if (this.rotation < 0) this.rotation += 360;\n }\n }\n\n getRotation(): number {\n return this.rotation;\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number\n ): Promise<void> {\n const native = this.assertNativeModule();\n if (!native.renderPage) return;\n const viewTag = this.toNativeViewTag(target);\n if (viewTag === null) return;\n native.renderPage(\n this.engineId,\n pageIndex,\n viewTag,\n scale,\n this.zoom,\n this.rotation\n );\n }\n\n async renderTextLayer(\n pageIndex: number,\n target: any,\n scale: number\n ): Promise<void> {\n const native = this.assertNativeModule();\n if (!native.renderTextLayer) return;\n const viewTag = this.toNativeViewTag(target);\n if (viewTag === null) return;\n native.renderTextLayer(\n this.engineId,\n pageIndex,\n viewTag,\n scale,\n this.zoom,\n this.rotation\n );\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n const native = this.assertNativeModule();\n if (!native.getTextContent) return [];\n return native.getTextContent(this.engineId, pageIndex);\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n const native = this.assertNativeModule();\n if (!native.getPageDimensions) return { width: 0, height: 0 };\n return native.getPageDimensions(this.engineId, pageIndex);\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number }\n ): Promise<TextSelection | null> {\n const native = this.assertNativeModule();\n if (!native.selectText) return null;\n return native.selectText(\n this.engineId,\n pageIndex,\n rect.x,\n rect.y,\n rect.width,\n rect.height\n );\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n const native = this.assertNativeModule();\n if (!native.getOutline) return [];\n return native.getOutline(this.engineId);\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n const native = this.assertNativeModule();\n if (!native.searchText) return [];\n return native.searchText(this.engineId, query);\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n if (!dest) return null;\n if (typeof dest !== \"string\") {\n if (dest.kind === \"pageIndex\") return dest.value;\n if (dest.kind === \"pageNumber\") return Math.max(0, dest.value - 1);\n }\n\n const native = this.assertNativeModule();\n if (!native.getPageIndex) return null;\n const normalized = normalizeNativeDestination(dest);\n if (!normalized || normalized.kind !== \"named\") return null;\n return native.getPageIndex(this.engineId, normalized);\n }\n\n destroy(): void {\n this.nativeModule?.destroyEngine?.(this.engineId);\n }\n\n private assertNativeModule(): NativeEngineModule {\n if (!this.nativeModule) {\n this.nativeModule = resolveNativeModule();\n }\n if (!this.nativeModule) {\n throw new Error(\n `[Papyrus] Native module \"${MODULE_NAME}\" not found. Use a dev client or a native build (Expo Go is not supported).`\n );\n }\n return this.nativeModule;\n }\n\n private async normalizeSource(\n source: DocumentSource\n ): Promise<NativeDocumentSource> {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri?.isBase64) {\n return { data: decodeBase64(dataUri.data) };\n }\n if (looksLikeUri(source)) return { uri: source };\n if (isLikelyBase64(source)) return { data: decodeBase64(source) };\n return { uri: source };\n }\n if (this.isUriSource(source)) return { uri: source.uri };\n if (this.isDataSource(source)) {\n const data =\n source.data instanceof Uint8Array\n ? source.data\n : new Uint8Array(source.data);\n return { data };\n }\n if (this.isFileLike(source)) {\n const buffer = await source.arrayBuffer();\n return { data: new Uint8Array(buffer) };\n }\n if (source instanceof ArrayBuffer) return { data: new Uint8Array(source) };\n if (source instanceof Uint8Array) return { data: source };\n return { data: new Uint8Array(source as ArrayBuffer) };\n }\n\n private isUriSource(source: DocumentSource): source is { uri: string } {\n return typeof source === \"object\" && source !== null && \"uri\" in source;\n }\n\n private isDataSource(\n source: DocumentSource\n ): source is { data: ArrayBuffer | Uint8Array } {\n return typeof source === \"object\" && source !== null && \"data\" in source;\n }\n\n private isFileLike(source: DocumentSource): source is FileLike {\n return (\n typeof source === \"object\" &&\n source !== null &&\n typeof (source as FileLike).arrayBuffer === \"function\"\n );\n }\n\n private toNativeViewTag(target: any): number | null {\n if (typeof target === \"number\") return target;\n if (target?.nativeTag && typeof target.nativeTag === \"number\")\n return target.nativeTag;\n return null;\n }\n}\n\ntype WebViewBridge = {\n postMessage: (message: string) => void;\n};\n\ntype WebViewResponseMessage = {\n type: \"response\";\n id: string;\n ok: boolean;\n data?: any;\n error?: string;\n};\n\ntype WebViewEventMessage = {\n type: \"event\";\n name: string;\n payload?: any;\n};\n\ntype WebViewStateMessage = {\n type: \"state\";\n payload: {\n pageCount?: number;\n currentPage?: number;\n zoom?: number;\n outline?: OutlineItem[];\n };\n};\n\ntype WebViewReadyMessage = {\n type: \"ready\";\n};\n\ntype WebViewRuntimeMessage =\n | WebViewResponseMessage\n | WebViewEventMessage\n | WebViewStateMessage\n | WebViewReadyMessage;\n\ntype WebViewSourcePayload =\n | { kind: \"uri\"; uri: string }\n | { kind: \"base64\"; data: string; mime?: string }\n | { kind: \"text\"; text: string };\n\nexport class WebViewDocumentEngine extends BaseDocumentEngine {\n private bridge: WebViewBridge | null = null;\n private ready = false;\n private requestId = 0;\n private pending = new Map<\n string,\n { resolve: (data: any) => void; reject: (error: Error) => void }\n >();\n private bridgeResolvers: Array<(bridge: WebViewBridge) => void> = [];\n private readyResolvers: Array<() => void> = [];\n private pageCount = 0;\n private currentPage = 1;\n private zoom = 1.0;\n private rotation = 0;\n private outline: OutlineItem[] = [];\n\n getRenderTargetType(): \"webview\" {\n return \"webview\";\n }\n\n attachBridge(bridge: WebViewBridge): void {\n this.bridge = bridge;\n this.bridgeResolvers.forEach((resolve) => resolve(bridge));\n this.bridgeResolvers = [];\n }\n\n handleMessage(raw: string): void {\n let message: WebViewRuntimeMessage | null = null;\n try {\n message = JSON.parse(raw) as WebViewRuntimeMessage;\n } catch {\n return;\n }\n\n if (!message) return;\n\n if (message.type === \"ready\") {\n this.ready = true;\n this.readyResolvers.forEach((resolve) => resolve());\n this.readyResolvers = [];\n return;\n }\n\n if (message.type === \"response\") {\n const pending = this.pending.get(message.id);\n if (!pending) return;\n this.pending.delete(message.id);\n if (message.ok) {\n pending.resolve(message.data);\n } else {\n pending.reject(\n new Error(message.error ?? \"[Papyrus] WebView runtime error\")\n );\n }\n return;\n }\n\n if (message.type === \"state\") {\n if (typeof message.payload.pageCount === \"number\")\n this.pageCount = message.payload.pageCount;\n if (typeof message.payload.currentPage === \"number\")\n this.currentPage = message.payload.currentPage;\n if (typeof message.payload.zoom === \"number\")\n this.zoom = message.payload.zoom;\n if (Array.isArray(message.payload.outline))\n this.outline = message.payload.outline;\n return;\n }\n\n if (message.type === \"event\") {\n const payload = message.payload ?? {};\n if (message.name === \"RUNTIME_LOG\") {\n if (__DEV__) {\n const text =\n typeof payload?.message === \"string\"\n ? payload.message\n : JSON.stringify(payload);\n console.log(\"[Papyrus WebView runtime]\", text);\n }\n return;\n }\n if (message.name === \"RUNTIME_ERROR\") {\n const errorMessage =\n typeof payload?.message === \"string\" ? payload.message : \"\";\n if (errorMessage.includes(\"ResizeObserver loop\")) {\n return;\n }\n if (__DEV__) {\n console.warn(\"[Papyrus WebView runtime]\", payload);\n }\n return;\n }\n if (message.name === PapyrusEventType.TEXT_SELECTED) {\n papyrusEvents.emit(PapyrusEventType.TEXT_SELECTED, payload);\n } else if (message.name === PapyrusEventType.SEARCH_TRIGGERED) {\n papyrusEvents.emit(PapyrusEventType.SEARCH_TRIGGERED, payload);\n } else if (message.name === PapyrusEventType.DOCUMENT_LOADED) {\n if (typeof payload.pageCount === \"number\") {\n this.pageCount = payload.pageCount;\n }\n papyrusEvents.emit(PapyrusEventType.DOCUMENT_LOADED, payload);\n }\n return;\n }\n\n if (__DEV__) {\n console.warn(\"[Papyrus WebView] Unknown message\", message);\n }\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type } = normalizeLoadInput(input);\n const resolvedType = type ?? inferDocumentType(source);\n if (resolvedType === \"pdf\") {\n throw new Error(\n \"[WebViewDocumentEngine] Use o NativeDocumentEngine para PDFs no mobile.\"\n );\n }\n\n const payloadSource = await this.normalizeRuntimeSource(\n resolvedType,\n source\n );\n const response = await this.request<{\n pageCount?: number;\n outline?: OutlineItem[];\n }>(\"load\", {\n type: resolvedType,\n source: payloadSource,\n });\n\n if (typeof response?.pageCount === \"number\")\n this.pageCount = response.pageCount;\n if (Array.isArray(response?.outline)) this.outline = response.outline;\n this.currentPage = 1;\n }\n\n getPageCount(): number {\n return this.pageCount;\n }\n\n getCurrentPage(): number {\n return this.currentPage;\n }\n\n goToPage(page: number): void {\n if (page < 1) return;\n this.currentPage = page;\n void this.request(\"go-to-page\", { page });\n }\n\n setZoom(zoom: number): void {\n this.zoom = Math.max(0.5, Math.min(4.0, zoom));\n void this.request(\"set-zoom\", { zoom: this.zoom });\n }\n\n getZoom(): number {\n return this.zoom;\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n if (direction === \"clockwise\") {\n this.rotation = (this.rotation + 90) % 360;\n } else {\n this.rotation = (this.rotation - 90) % 360;\n if (this.rotation < 0) this.rotation += 360;\n }\n void this.request(\"set-rotation\", { rotation: this.rotation });\n }\n\n getRotation(): number {\n return this.rotation;\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number\n ): Promise<void> {\n void pageIndex;\n void target;\n void scale;\n }\n\n async renderTextLayer(\n pageIndex: number,\n container: any,\n scale: number\n ): Promise<void> {\n void pageIndex;\n void container;\n void scale;\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n return await this.request<TextItem[]>(\"get-text-content\", { pageIndex });\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n return await this.request<{ width: number; height: number }>(\n \"get-page-dimensions\",\n { pageIndex }\n );\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n return await this.request<SearchResult[]>(\"search-text\", { query });\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number }\n ): Promise<TextSelection | null> {\n return await this.request<TextSelection | null>(\"select-text\", {\n pageIndex,\n rect,\n });\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n if (this.outline.length > 0) return this.outline;\n return await this.request<OutlineItem[]>(\"get-outline\");\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n if (!dest) return null;\n if (typeof dest !== \"string\") {\n if (dest.kind === \"pageIndex\") return dest.value;\n if (dest.kind === \"pageNumber\") return Math.max(0, dest.value - 1);\n if (dest.kind === \"href\") {\n return await this.request<number | null>(\"get-page-index\", {\n dest: dest.value,\n });\n }\n return null;\n }\n return await this.request<number | null>(\"get-page-index\", { dest });\n }\n\n destroy(): void {\n this.pending.forEach(({ reject }) =>\n reject(new Error(\"[Papyrus] WebView engine destroyed\"))\n );\n this.pending.clear();\n this.bridge = null;\n this.ready = false;\n }\n\n private async ensureBridge(): Promise<WebViewBridge> {\n if (this.bridge) return this.bridge;\n return new Promise((resolve) => {\n this.bridgeResolvers.push(resolve);\n });\n }\n\n private async ensureReady(): Promise<void> {\n if (this.ready) return;\n return new Promise((resolve) => {\n this.readyResolvers.push(resolve);\n });\n }\n\n private async request<T = any>(kind: string, payload?: any): Promise<T> {\n const bridge = await this.ensureBridge();\n await this.ensureReady();\n const id = `${Date.now()}-${this.requestId++}`;\n return new Promise<T>((resolve, reject) => {\n const timeoutMs = kind === \"load\" ? 180000 : 8000;\n const timeoutId = setTimeout(() => {\n this.pending.delete(id);\n reject(new Error(`[Papyrus] WebView response timeout: ${kind}`));\n }, timeoutMs);\n this.pending.set(id, {\n resolve: (data) => {\n clearTimeout(timeoutId);\n resolve(data);\n },\n reject: (error) => {\n clearTimeout(timeoutId);\n reject(error);\n },\n });\n bridge.postMessage(JSON.stringify({ id, kind, payload }));\n });\n }\n\n private async normalizeRuntimeSource(\n type: DocumentType,\n source: DocumentSource\n ): Promise<WebViewSourcePayload> {\n if (typeof source === \"string\") {\n const dataUri = parseDataUri(source);\n if (dataUri) {\n if (dataUri.isBase64) {\n return {\n kind: \"base64\",\n data: dataUri.data,\n mime: dataUri.mime || undefined,\n };\n }\n const text = decodeURIComponent(dataUri.data);\n return { kind: \"text\", text };\n }\n\n if (looksLikeUri(source)) {\n if (isHttpUri(source)) {\n const fetched = await this.fetchRemoteSource(type, source);\n if (fetched) return fetched;\n }\n return { kind: \"uri\", uri: source };\n }\n\n if (isLikelyBase64(source)) {\n return { kind: \"base64\", data: source };\n }\n\n if (type === \"text\") {\n return { kind: \"text\", text: source };\n }\n\n return { kind: \"uri\", uri: source };\n }\n\n if (this.isUriSource(source)) {\n const uri = source.uri;\n if (isHttpUri(uri)) {\n const fetched = await this.fetchRemoteSource(type, uri);\n if (fetched) return fetched;\n }\n return { kind: \"uri\", uri };\n }\n if (this.isDataSource(source)) {\n const bytes =\n source.data instanceof Uint8Array\n ? source.data\n : new Uint8Array(source.data);\n return { kind: \"base64\", data: encodeBase64(bytes) };\n }\n if (this.isFileLike(source)) {\n const buffer = await source.arrayBuffer();\n return { kind: \"base64\", data: encodeBase64(new Uint8Array(buffer)) };\n }\n if (source instanceof ArrayBuffer || source instanceof Uint8Array) {\n const bytes =\n source instanceof Uint8Array ? source : new Uint8Array(source);\n return { kind: \"base64\", data: encodeBase64(bytes) };\n }\n\n return {\n kind: \"base64\",\n data: encodeBase64(new Uint8Array(source as ArrayBuffer)),\n };\n }\n\n private async fetchRemoteSource(\n type: DocumentType,\n uri: string\n ): Promise<WebViewSourcePayload | null> {\n try {\n const response = await fetch(uri);\n if (!response.ok) return null;\n if (type === \"text\") {\n const text = await response.text();\n return { kind: \"text\", text };\n }\n if (type === \"epub\") {\n const buffer = await this.readResponseBuffer(response);\n return { kind: \"base64\", data: encodeBase64(new Uint8Array(buffer)) };\n }\n return null;\n } catch {\n return null;\n }\n }\n\n private async readResponseBuffer(response: Response): Promise<ArrayBuffer> {\n try {\n return await response.arrayBuffer();\n } catch {\n const blob = await response.blob();\n return await new Promise<ArrayBuffer>((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = () =>\n reject(new Error(\"[Papyrus] Failed to read response blob\"));\n reader.onload = () => resolve(reader.result as ArrayBuffer);\n reader.readAsArrayBuffer(blob);\n });\n }\n }\n\n private isUriSource(source: DocumentSource): source is { uri: string } {\n return typeof source === \"object\" && source !== null && \"uri\" in source;\n }\n\n private isDataSource(\n source: DocumentSource\n ): source is { data: ArrayBuffer | Uint8Array } {\n return typeof source === \"object\" && source !== null && \"data\" in source;\n }\n\n private isFileLike(source: DocumentSource): source is FileLike {\n return (\n typeof source === \"object\" &&\n source !== null &&\n typeof (source as FileLike).arrayBuffer === \"function\"\n );\n }\n}\n\nexport class MobileDocumentEngine extends BaseDocumentEngine {\n private pdfEngine: NativeDocumentEngine;\n private webEngine: WebViewDocumentEngine;\n private activeEngine: DocumentEngine;\n\n constructor() {\n super();\n this.pdfEngine = new NativeDocumentEngine();\n this.webEngine = new WebViewDocumentEngine();\n this.activeEngine = this.pdfEngine;\n }\n\n getRenderTargetType(): RenderTargetType {\n return this.activeEngine.getRenderTargetType?.() ?? \"canvas\";\n }\n\n attachWebView(bridge: WebViewBridge): void {\n this.webEngine.attachBridge(bridge);\n }\n\n handleWebViewMessage(data: string): void {\n this.webEngine.handleMessage(data);\n }\n\n async load(input: DocumentLoadInput): Promise<void> {\n const { source, type } = normalizeLoadInput(input);\n const resolvedType = type ?? inferDocumentType(source);\n this.activeEngine =\n resolvedType === \"pdf\" ? this.pdfEngine : this.webEngine;\n await this.activeEngine.load({ type: resolvedType, source });\n }\n\n getPageCount(): number {\n return this.activeEngine.getPageCount();\n }\n\n getCurrentPage(): number {\n return this.activeEngine.getCurrentPage();\n }\n\n goToPage(page: number): void {\n this.activeEngine.goToPage(page);\n }\n\n setZoom(zoom: number): void {\n this.activeEngine.setZoom(zoom);\n }\n\n getZoom(): number {\n return this.activeEngine.getZoom();\n }\n\n rotate(direction: \"clockwise\" | \"counterclockwise\"): void {\n this.activeEngine.rotate(direction);\n }\n\n getRotation(): number {\n return this.activeEngine.getRotation();\n }\n\n async renderPage(\n pageIndex: number,\n target: any,\n scale: number\n ): Promise<void> {\n await this.activeEngine.renderPage(pageIndex, target, scale);\n }\n\n async renderTextLayer(\n pageIndex: number,\n container: any,\n scale: number\n ): Promise<void> {\n await this.activeEngine.renderTextLayer(pageIndex, container, scale);\n }\n\n async getTextContent(pageIndex: number): Promise<TextItem[]> {\n return await this.activeEngine.getTextContent(pageIndex);\n }\n\n async getPageDimensions(\n pageIndex: number\n ): Promise<{ width: number; height: number }> {\n return await this.activeEngine.getPageDimensions(pageIndex);\n }\n\n async searchText(query: string): Promise<SearchResult[]> {\n if (typeof this.activeEngine.searchText === \"function\") {\n return await this.activeEngine.searchText(query);\n }\n return [];\n }\n\n async selectText(\n pageIndex: number,\n rect: { x: number; y: number; width: number; height: number }\n ): Promise<TextSelection | null> {\n if (typeof this.activeEngine.selectText === \"function\") {\n return await this.activeEngine.selectText(pageIndex, rect);\n }\n return null;\n }\n\n async getOutline(): Promise<OutlineItem[]> {\n return await this.activeEngine.getOutline();\n }\n\n async getPageIndex(dest: PageDestination): Promise<number | null> {\n return await this.activeEngine.getPageIndex(dest);\n }\n\n destroy(): void {\n this.pdfEngine.destroy();\n this.webEngine.destroy();\n }\n}\n","import { NativeModules, Platform } from 'react-native';\n\nimport { registerWebGlobals } from './web/index';\n\n/**\n * Ensures that the native modules are installed in the current runtime.\n * Otherwise, it synchronously calls a native function that installs them.\n */\nexport function ensureNativeModulesAreInstalled(): void {\n if (globalThis.expo) {\n return;\n }\n try {\n if (Platform.OS === 'web') {\n // Requiring web folder sets up the `globalThis.expo` object.\n registerWebGlobals();\n } else {\n // TODO: ExpoModulesCore shouldn't be optional here,\n // but to keep backwards compatibility let's just ignore it in SDK 50.\n // In most cases the modules were already installed from the native side.\n NativeModules.ExpoModulesCore?.installModules();\n }\n } catch (error) {\n console.error(`Unable to install Expo modules: ${error}`);\n }\n}\n","export function registerWebGlobals() {}\n","import type { ProxyNativeModule } from './NativeModulesProxy.types';\n\n// We default to an empty object shim wherever we don't have an environment-specific implementation\n\n/**\n * @deprecated `NativeModulesProxy` is deprecated and might be removed in the future releases.\n * Use `requireNativeModule` or `requireOptionalNativeModule` instead.\n */\nexport default {} as { [moduleName: string]: ProxyNativeModule };\n","/**\n * A general error class that should be used for all errors in Expo modules.\n * Guarantees a `code` field that can be used to differentiate between different\n * types of errors without further subclassing Error.\n */\nexport class CodedError extends Error {\n code: string;\n info?: any;\n\n constructor(code: string, message: string) {\n super(message);\n this.code = code;\n }\n}\n","import { PlatformOSType, Platform as ReactNativePlatform } from 'react-native';\n\nimport {\n isDOMAvailable,\n canUseEventListeners,\n canUseViewport,\n isAsyncDebugging,\n} from './environment/browser';\n\nexport type PlatformSelectOSType = PlatformOSType | 'native' | 'electron' | 'default';\n\nexport type PlatformSelect = <T>(specifics: { [platform in PlatformSelectOSType]?: T }) => T;\n\nif (__DEV__ && typeof process.env.EXPO_OS === 'undefined') {\n console.warn(\n `The global process.env.EXPO_OS is not defined. This should be inlined by babel-preset-expo during transformation.`\n );\n}\n\nconst nativeSelect =\n typeof window !== 'undefined'\n ? ReactNativePlatform.select\n : // process.env.EXPO_OS is injected by `babel-preset-expo` and available in both client and `react-server` environments.\n // Opt to use the env var when possible, and fallback to the React Native Platform module when it's not (arbitrary bundlers and transformers).\n function select<T>(specifics: { [platform in PlatformSelectOSType]?: T }): T | undefined {\n if (!process.env.EXPO_OS) return undefined;\n if (specifics.hasOwnProperty(process.env.EXPO_OS)) {\n return specifics[process.env.EXPO_OS]!;\n } else if (process.env.EXPO_OS !== 'web' && specifics.hasOwnProperty('native')) {\n return specifics.native!;\n } else if (specifics.hasOwnProperty('default')) {\n return specifics.default!;\n }\n // do nothing...\n return undefined;\n };\n\nconst Platform = {\n /**\n * Denotes the currently running platform.\n * Can be one of ios, android, web.\n */\n OS: process.env.EXPO_OS || ReactNativePlatform.OS,\n /**\n * Returns the value with the matching platform.\n * Object keys can be any of ios, android, native, web, default.\n *\n * @ios ios, native, default\n * @android android, native, default\n * @web web, default\n */\n select: nativeSelect as PlatformSelect,\n /**\n * Denotes if the DOM API is available in the current environment.\n * The DOM is not available in native React runtimes and Node.js.\n */\n isDOMAvailable,\n /**\n * Denotes if the current environment can attach event listeners\n * to the window. This will return false in native React\n * runtimes and Node.js.\n */\n canUseEventListeners,\n /**\n * Denotes if the current environment can inspect properties of the\n * screen on which the current window is being rendered. This will\n * return false in native React runtimes and Node.js.\n */\n canUseViewport,\n /**\n * If the JavaScript is being executed in a remote JavaScript environment.\n * When `true`, synchronous native invocations cannot be executed.\n */\n isAsyncDebugging,\n};\n\nexport default Platform;\n","declare const global: any;\n\n// In standard node environments there is no DOM API\nexport const isDOMAvailable = false;\nexport const canUseEventListeners = false;\nexport const canUseViewport = false;\n\nexport let isAsyncDebugging: boolean = false;\n\nif (__DEV__) {\n // These native globals are injected by native React runtimes and not standard browsers\n // we can use them to determine if the JS is being executed in Chrome.\n isAsyncDebugging =\n !global.nativeExtensions && !global.nativeCallSyncHook && !global.RN$Bridgeless;\n}\n","import { CodedError } from './CodedError';\nimport Platform from '../Platform';\n\n/**\n * A class for errors to be thrown when a property is accessed which is\n * unavailable, unsupported, or not currently implemented on the running\n * platform.\n */\nexport class UnavailabilityError extends CodedError {\n constructor(moduleName: string, propertyName: string) {\n super(\n 'ERR_UNAVAILABLE',\n `The method or property ${moduleName}.${propertyName} is not available on ${Platform.OS}, are you sure you've linked all the native dependencies properly?`\n );\n }\n}\n","import React from 'react';\n\nimport { UnavailabilityError } from './errors/UnavailabilityError';\n\n/**\n * A drop-in replacement for `requireNativeComponent`.\n */\nexport function requireNativeViewManager<P = any>(viewName: string): React.ComponentType<P> {\n throw new UnavailabilityError('expo-modules-core', 'requireNativeViewManager');\n}\n","import NativeModulesProxy from '../NativeModulesProxy';\nexport default NativeModulesProxy.ExpoModulesCoreErrorManager;\n","import NativeErrorManager from './NativeErrorManager';\nimport Platform from '../Platform';\nimport { CodedError } from '../errors/CodedError';\n\nif (__DEV__ && Platform.OS === 'android' && NativeErrorManager) {\n const onNewException = 'ExpoModulesCoreErrorManager.onNewException';\n const onNewWarning = 'ExpoModulesCoreErrorManager.onNewWarning';\n\n NativeErrorManager.addListener(onNewException, ({ message }: { message: string }) => {\n console.error(message);\n });\n\n NativeErrorManager.addListener(onNewWarning, ({ message }: { message: string }) => {\n console.warn(message);\n });\n}\n\n// We have to export `CodedError` via global object to use in later in the C++ code.\nglobalThis.ExpoModulesCore_CodedError = CodedError;\n","import NativeModulesProxy from './NativeModulesProxy';\nimport { ensureNativeModulesAreInstalled } from './ensureNativeModulesAreInstalled';\n\n/**\n * Imports the native module registered with given name. In the first place it tries to load\n * the module installed through the JSI host object and then falls back to the bridge proxy module.\n * Notice that the modules loaded from the proxy may not support some features like synchronous functions.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module.\n * @throws Error when there is no native module with given name.\n */\nexport function requireNativeModule<ModuleType = any>(moduleName: string): ModuleType {\n const nativeModule = requireOptionalNativeModule<ModuleType>(moduleName);\n\n if (!nativeModule) {\n throw new Error(`Cannot find native module '${moduleName}'`);\n }\n return nativeModule;\n}\n\n/**\n * Imports the native module registered with the given name. The same as `requireNativeModule`,\n * but returns `null` when the module cannot be found instead of throwing an error.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module or `null` when it cannot be found.\n */\nexport function requireOptionalNativeModule<ModuleType = any>(\n moduleName: string\n): ModuleType | null {\n ensureNativeModulesAreInstalled();\n\n return globalThis.expo?.modules?.[moduleName] ?? NativeModulesProxy[moduleName] ?? null;\n}\n"],"mappings":";AACA;AAAA,EACE,iBAAAA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACNP,SAAS,eAAe,gBAAgB;;;ACAjC,SAAS,qBAAqB;AAAC;;;ADQ/B,SAAS,kCAAwC;AACtD,MAAI,WAAW,MAAM;AACnB;AAAA,EACF;AACA,MAAI;AACF,QAAI,SAAS,OAAO,OAAO;AAEzB,yBAAmB;AAAA,IACrB,OAAO;AAIL,oBAAc,iBAAiB,eAAe;AAAA,IAChD;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,mCAAmC,KAAK,EAAE;AAAA,EAC1D;AACF;;;AEjBA,IAAO,6BAAQ,CAAC;;;ACHT,IAAM,aAAN,cAAyB,MAAM;AAAA,EAIpC,YAAY,MAAc,SAAiB;AACzC,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;;;ACbA,SAAyB,YAAY,2BAA2B;;;ACGzD,IAAM,iBAAiB;AACvB,IAAM,uBA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A,IAC3D;AACA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,aAAqC;AACzC,WAAO,MAAM,KAAK,aAAa,WAAW;AAAA,EAC5C;AAAA,EAEA,MAAM,aAAa,MAA+C;AAChE,WAAO,MAAM,KAAK,aAAa,aAAa,IAAI;AAAA,EAClD;AAAA,EAEA,UAAgB;AACd,SAAK,UAAU,QAAQ;AACvB,SAAK,UAAU,QAAQ;AAAA,EACzB;AACF;","names":["NativeModules","Platform","NativeModules"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@papyrus-sdk/engine-native",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"papyrus",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@papyrus-sdk/core": ">=0.2.1",
|
|
52
52
|
"@papyrus-sdk/types": ">=0.2.1",
|
|
53
|
-
"react-native": ">=0.
|
|
53
|
+
"react-native": ">=0.81.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@papyrus-sdk/core": "0.2.1",
|
|
57
57
|
"@papyrus-sdk/types": "0.2.1",
|
|
58
|
-
"react-native": "^0.
|
|
58
|
+
"react-native": "^0.81.0"
|
|
59
59
|
}
|
|
60
60
|
}
|