@papyrus-sdk/types 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.d.mts +147 -0
- package/dist/index.d.ts +147 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +15 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +23 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Papyrus Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
type ViewMode = 'single' | 'double' | 'continuous';
|
|
2
|
+
type UITheme = 'light' | 'dark';
|
|
3
|
+
type PageTheme = 'normal' | 'sepia' | 'dark' | 'high-contrast';
|
|
4
|
+
type Locale = 'en' | 'pt-BR';
|
|
5
|
+
interface FileLike {
|
|
6
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
7
|
+
}
|
|
8
|
+
type DocumentSource = ArrayBuffer | Uint8Array | string | {
|
|
9
|
+
uri: string;
|
|
10
|
+
} | {
|
|
11
|
+
data: ArrayBuffer | Uint8Array;
|
|
12
|
+
} | FileLike;
|
|
13
|
+
interface TextItem {
|
|
14
|
+
str: string;
|
|
15
|
+
dir: string;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
transform: number[];
|
|
19
|
+
fontName: string;
|
|
20
|
+
}
|
|
21
|
+
interface SearchResult {
|
|
22
|
+
pageIndex: number;
|
|
23
|
+
text: string;
|
|
24
|
+
matchIndex: number;
|
|
25
|
+
rects?: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}[];
|
|
31
|
+
}
|
|
32
|
+
interface TextSelection {
|
|
33
|
+
text: string;
|
|
34
|
+
rects: {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
41
|
+
interface Annotation {
|
|
42
|
+
id: string;
|
|
43
|
+
type: 'highlight' | 'text' | 'strikeout' | 'comment';
|
|
44
|
+
pageIndex: number;
|
|
45
|
+
content?: string;
|
|
46
|
+
rect: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
color: string;
|
|
53
|
+
createdAt: number;
|
|
54
|
+
}
|
|
55
|
+
interface OutlineItem {
|
|
56
|
+
title: string;
|
|
57
|
+
pageIndex: number;
|
|
58
|
+
children?: OutlineItem[];
|
|
59
|
+
}
|
|
60
|
+
interface PapyrusConfig {
|
|
61
|
+
initialPage?: number;
|
|
62
|
+
initialZoom?: number;
|
|
63
|
+
initialRotation?: number;
|
|
64
|
+
initialViewMode?: ViewMode;
|
|
65
|
+
initialUITheme?: UITheme;
|
|
66
|
+
initialPageTheme?: PageTheme;
|
|
67
|
+
initialAccentColor?: string;
|
|
68
|
+
initialLocale?: Locale;
|
|
69
|
+
initialAnnotations?: Annotation[];
|
|
70
|
+
sidebarLeftOpen?: boolean;
|
|
71
|
+
sidebarRightOpen?: boolean;
|
|
72
|
+
}
|
|
73
|
+
declare enum PapyrusEventType {
|
|
74
|
+
DOCUMENT_LOADED = "DOCUMENT_LOADED",
|
|
75
|
+
PAGE_CHANGED = "PAGE_CHANGED",
|
|
76
|
+
ZOOM_CHANGED = "ZOOM_CHANGED",
|
|
77
|
+
ANNOTATION_CREATED = "ANNOTATION_CREATED",
|
|
78
|
+
ANNOTATION_DELETED = "ANNOTATION_DELETED",
|
|
79
|
+
SEARCH_TRIGGERED = "SEARCH_TRIGGERED",
|
|
80
|
+
TEXT_SELECTED = "TEXT_SELECTED"
|
|
81
|
+
}
|
|
82
|
+
interface EventPayloads {
|
|
83
|
+
[PapyrusEventType.DOCUMENT_LOADED]: {
|
|
84
|
+
pageCount: number;
|
|
85
|
+
};
|
|
86
|
+
[PapyrusEventType.PAGE_CHANGED]: {
|
|
87
|
+
pageNumber: number;
|
|
88
|
+
};
|
|
89
|
+
[PapyrusEventType.ZOOM_CHANGED]: {
|
|
90
|
+
zoom: number;
|
|
91
|
+
};
|
|
92
|
+
[PapyrusEventType.ANNOTATION_CREATED]: {
|
|
93
|
+
annotation: Annotation;
|
|
94
|
+
};
|
|
95
|
+
[PapyrusEventType.ANNOTATION_DELETED]: {
|
|
96
|
+
annotationId: string;
|
|
97
|
+
};
|
|
98
|
+
[PapyrusEventType.SEARCH_TRIGGERED]: {
|
|
99
|
+
query: string;
|
|
100
|
+
};
|
|
101
|
+
[PapyrusEventType.TEXT_SELECTED]: {
|
|
102
|
+
text: string;
|
|
103
|
+
pageIndex: number;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
type PapyrusEventListener<T extends PapyrusEventType> = (payload: EventPayloads[T]) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Interface agnóstica do Motor.
|
|
109
|
+
* A UI interage apenas com estes métodos.
|
|
110
|
+
*/
|
|
111
|
+
interface DocumentEngine {
|
|
112
|
+
load(source: DocumentSource): Promise<void>;
|
|
113
|
+
getPageCount(): number;
|
|
114
|
+
getCurrentPage(): number;
|
|
115
|
+
goToPage(page: number): void;
|
|
116
|
+
setZoom(zoom: number): void;
|
|
117
|
+
getZoom(): number;
|
|
118
|
+
rotate(direction: 'clockwise' | 'counterclockwise'): void;
|
|
119
|
+
getRotation(): number;
|
|
120
|
+
/**
|
|
121
|
+
* Renderiza o conteúdo visual da página.
|
|
122
|
+
* target: HTMLCanvasElement no Web ou NativeHandle no RN.
|
|
123
|
+
*/
|
|
124
|
+
renderPage(pageIndex: number, target: any, scale: number): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Renderiza a camada de texto para seleção.
|
|
127
|
+
* container: HTMLElement no Web ou GhostView no RN.
|
|
128
|
+
*/
|
|
129
|
+
renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void>;
|
|
130
|
+
getTextContent(pageIndex: number): Promise<TextItem[]>;
|
|
131
|
+
getPageDimensions(pageIndex: number): Promise<{
|
|
132
|
+
width: number;
|
|
133
|
+
height: number;
|
|
134
|
+
}>;
|
|
135
|
+
searchText?(query: string): Promise<SearchResult[]>;
|
|
136
|
+
selectText?(pageIndex: number, rect: {
|
|
137
|
+
x: number;
|
|
138
|
+
y: number;
|
|
139
|
+
width: number;
|
|
140
|
+
height: number;
|
|
141
|
+
}): Promise<TextSelection | null>;
|
|
142
|
+
getOutline(): Promise<OutlineItem[]>;
|
|
143
|
+
getPageIndex(dest: any): Promise<number | null>;
|
|
144
|
+
destroy(): void;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { type Annotation, type DocumentEngine, type DocumentSource, type EventPayloads, type FileLike, type Locale, type OutlineItem, type PageTheme, type PapyrusConfig, type PapyrusEventListener, PapyrusEventType, type SearchResult, type TextItem, type TextSelection, type UITheme, type ViewMode };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
type ViewMode = 'single' | 'double' | 'continuous';
|
|
2
|
+
type UITheme = 'light' | 'dark';
|
|
3
|
+
type PageTheme = 'normal' | 'sepia' | 'dark' | 'high-contrast';
|
|
4
|
+
type Locale = 'en' | 'pt-BR';
|
|
5
|
+
interface FileLike {
|
|
6
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
7
|
+
}
|
|
8
|
+
type DocumentSource = ArrayBuffer | Uint8Array | string | {
|
|
9
|
+
uri: string;
|
|
10
|
+
} | {
|
|
11
|
+
data: ArrayBuffer | Uint8Array;
|
|
12
|
+
} | FileLike;
|
|
13
|
+
interface TextItem {
|
|
14
|
+
str: string;
|
|
15
|
+
dir: string;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
transform: number[];
|
|
19
|
+
fontName: string;
|
|
20
|
+
}
|
|
21
|
+
interface SearchResult {
|
|
22
|
+
pageIndex: number;
|
|
23
|
+
text: string;
|
|
24
|
+
matchIndex: number;
|
|
25
|
+
rects?: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}[];
|
|
31
|
+
}
|
|
32
|
+
interface TextSelection {
|
|
33
|
+
text: string;
|
|
34
|
+
rects: {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
}[];
|
|
40
|
+
}
|
|
41
|
+
interface Annotation {
|
|
42
|
+
id: string;
|
|
43
|
+
type: 'highlight' | 'text' | 'strikeout' | 'comment';
|
|
44
|
+
pageIndex: number;
|
|
45
|
+
content?: string;
|
|
46
|
+
rect: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
};
|
|
52
|
+
color: string;
|
|
53
|
+
createdAt: number;
|
|
54
|
+
}
|
|
55
|
+
interface OutlineItem {
|
|
56
|
+
title: string;
|
|
57
|
+
pageIndex: number;
|
|
58
|
+
children?: OutlineItem[];
|
|
59
|
+
}
|
|
60
|
+
interface PapyrusConfig {
|
|
61
|
+
initialPage?: number;
|
|
62
|
+
initialZoom?: number;
|
|
63
|
+
initialRotation?: number;
|
|
64
|
+
initialViewMode?: ViewMode;
|
|
65
|
+
initialUITheme?: UITheme;
|
|
66
|
+
initialPageTheme?: PageTheme;
|
|
67
|
+
initialAccentColor?: string;
|
|
68
|
+
initialLocale?: Locale;
|
|
69
|
+
initialAnnotations?: Annotation[];
|
|
70
|
+
sidebarLeftOpen?: boolean;
|
|
71
|
+
sidebarRightOpen?: boolean;
|
|
72
|
+
}
|
|
73
|
+
declare enum PapyrusEventType {
|
|
74
|
+
DOCUMENT_LOADED = "DOCUMENT_LOADED",
|
|
75
|
+
PAGE_CHANGED = "PAGE_CHANGED",
|
|
76
|
+
ZOOM_CHANGED = "ZOOM_CHANGED",
|
|
77
|
+
ANNOTATION_CREATED = "ANNOTATION_CREATED",
|
|
78
|
+
ANNOTATION_DELETED = "ANNOTATION_DELETED",
|
|
79
|
+
SEARCH_TRIGGERED = "SEARCH_TRIGGERED",
|
|
80
|
+
TEXT_SELECTED = "TEXT_SELECTED"
|
|
81
|
+
}
|
|
82
|
+
interface EventPayloads {
|
|
83
|
+
[PapyrusEventType.DOCUMENT_LOADED]: {
|
|
84
|
+
pageCount: number;
|
|
85
|
+
};
|
|
86
|
+
[PapyrusEventType.PAGE_CHANGED]: {
|
|
87
|
+
pageNumber: number;
|
|
88
|
+
};
|
|
89
|
+
[PapyrusEventType.ZOOM_CHANGED]: {
|
|
90
|
+
zoom: number;
|
|
91
|
+
};
|
|
92
|
+
[PapyrusEventType.ANNOTATION_CREATED]: {
|
|
93
|
+
annotation: Annotation;
|
|
94
|
+
};
|
|
95
|
+
[PapyrusEventType.ANNOTATION_DELETED]: {
|
|
96
|
+
annotationId: string;
|
|
97
|
+
};
|
|
98
|
+
[PapyrusEventType.SEARCH_TRIGGERED]: {
|
|
99
|
+
query: string;
|
|
100
|
+
};
|
|
101
|
+
[PapyrusEventType.TEXT_SELECTED]: {
|
|
102
|
+
text: string;
|
|
103
|
+
pageIndex: number;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
type PapyrusEventListener<T extends PapyrusEventType> = (payload: EventPayloads[T]) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Interface agnóstica do Motor.
|
|
109
|
+
* A UI interage apenas com estes métodos.
|
|
110
|
+
*/
|
|
111
|
+
interface DocumentEngine {
|
|
112
|
+
load(source: DocumentSource): Promise<void>;
|
|
113
|
+
getPageCount(): number;
|
|
114
|
+
getCurrentPage(): number;
|
|
115
|
+
goToPage(page: number): void;
|
|
116
|
+
setZoom(zoom: number): void;
|
|
117
|
+
getZoom(): number;
|
|
118
|
+
rotate(direction: 'clockwise' | 'counterclockwise'): void;
|
|
119
|
+
getRotation(): number;
|
|
120
|
+
/**
|
|
121
|
+
* Renderiza o conteúdo visual da página.
|
|
122
|
+
* target: HTMLCanvasElement no Web ou NativeHandle no RN.
|
|
123
|
+
*/
|
|
124
|
+
renderPage(pageIndex: number, target: any, scale: number): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Renderiza a camada de texto para seleção.
|
|
127
|
+
* container: HTMLElement no Web ou GhostView no RN.
|
|
128
|
+
*/
|
|
129
|
+
renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void>;
|
|
130
|
+
getTextContent(pageIndex: number): Promise<TextItem[]>;
|
|
131
|
+
getPageDimensions(pageIndex: number): Promise<{
|
|
132
|
+
width: number;
|
|
133
|
+
height: number;
|
|
134
|
+
}>;
|
|
135
|
+
searchText?(query: string): Promise<SearchResult[]>;
|
|
136
|
+
selectText?(pageIndex: number, rect: {
|
|
137
|
+
x: number;
|
|
138
|
+
y: number;
|
|
139
|
+
width: number;
|
|
140
|
+
height: number;
|
|
141
|
+
}): Promise<TextSelection | null>;
|
|
142
|
+
getOutline(): Promise<OutlineItem[]>;
|
|
143
|
+
getPageIndex(dest: any): Promise<number | null>;
|
|
144
|
+
destroy(): void;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { type Annotation, type DocumentEngine, type DocumentSource, type EventPayloads, type FileLike, type Locale, type OutlineItem, type PageTheme, type PapyrusConfig, type PapyrusEventListener, PapyrusEventType, type SearchResult, type TextItem, type TextSelection, type UITheme, type ViewMode };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// index.ts
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
|
+
PapyrusEventType: () => PapyrusEventType
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(index_exports);
|
|
25
|
+
var PapyrusEventType = /* @__PURE__ */ ((PapyrusEventType2) => {
|
|
26
|
+
PapyrusEventType2["DOCUMENT_LOADED"] = "DOCUMENT_LOADED";
|
|
27
|
+
PapyrusEventType2["PAGE_CHANGED"] = "PAGE_CHANGED";
|
|
28
|
+
PapyrusEventType2["ZOOM_CHANGED"] = "ZOOM_CHANGED";
|
|
29
|
+
PapyrusEventType2["ANNOTATION_CREATED"] = "ANNOTATION_CREATED";
|
|
30
|
+
PapyrusEventType2["ANNOTATION_DELETED"] = "ANNOTATION_DELETED";
|
|
31
|
+
PapyrusEventType2["SEARCH_TRIGGERED"] = "SEARCH_TRIGGERED";
|
|
32
|
+
PapyrusEventType2["TEXT_SELECTED"] = "TEXT_SELECTED";
|
|
33
|
+
return PapyrusEventType2;
|
|
34
|
+
})(PapyrusEventType || {});
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
PapyrusEventType
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["\nexport type ViewMode = 'single' | 'double' | 'continuous';\nexport type UITheme = 'light' | 'dark';\nexport type PageTheme = 'normal' | 'sepia' | 'dark' | 'high-contrast';\nexport type Locale = 'en' | 'pt-BR';\n\nexport interface FileLike {\n arrayBuffer(): Promise<ArrayBuffer>;\n}\n\nexport type DocumentSource =\n | ArrayBuffer\n | Uint8Array\n | string\n | { uri: string }\n | { data: ArrayBuffer | Uint8Array }\n | FileLike;\n\nexport interface TextItem {\n str: string;\n dir: string;\n width: number;\n height: number;\n transform: number[];\n fontName: string;\n}\n\nexport interface SearchResult {\n pageIndex: number;\n text: string;\n matchIndex: number;\n rects?: { x: number; y: number; width: number; height: number }[];\n}\n\nexport interface TextSelection {\n text: string;\n rects: { x: number; y: number; width: number; height: number }[];\n}\n\nexport interface Annotation {\n id: string;\n type: 'highlight' | 'text' | 'strikeout' | 'comment';\n pageIndex: number;\n content?: string;\n rect: { x: number; y: number; width: number; height: number };\n color: string;\n createdAt: number;\n}\n\nexport interface OutlineItem {\n title: string;\n pageIndex: number;\n children?: OutlineItem[];\n}\n\nexport interface PapyrusConfig {\n initialPage?: number;\n initialZoom?: number;\n initialRotation?: number;\n initialViewMode?: ViewMode;\n initialUITheme?: UITheme;\n initialPageTheme?: PageTheme;\n initialAccentColor?: string;\n initialLocale?: Locale;\n initialAnnotations?: Annotation[];\n sidebarLeftOpen?: boolean;\n sidebarRightOpen?: boolean;\n}\n\nexport enum PapyrusEventType {\n DOCUMENT_LOADED = 'DOCUMENT_LOADED',\n PAGE_CHANGED = 'PAGE_CHANGED',\n ZOOM_CHANGED = 'ZOOM_CHANGED',\n ANNOTATION_CREATED = 'ANNOTATION_CREATED',\n ANNOTATION_DELETED = 'ANNOTATION_DELETED',\n SEARCH_TRIGGERED = 'SEARCH_TRIGGERED',\n TEXT_SELECTED = 'TEXT_SELECTED',\n}\n\nexport interface EventPayloads {\n [PapyrusEventType.DOCUMENT_LOADED]: { pageCount: number };\n [PapyrusEventType.PAGE_CHANGED]: { pageNumber: number };\n [PapyrusEventType.ZOOM_CHANGED]: { zoom: number };\n [PapyrusEventType.ANNOTATION_CREATED]: { annotation: Annotation };\n [PapyrusEventType.ANNOTATION_DELETED]: { annotationId: string };\n [PapyrusEventType.SEARCH_TRIGGERED]: { query: string };\n [PapyrusEventType.TEXT_SELECTED]: { text: string, pageIndex: number };\n}\n\nexport type PapyrusEventListener<T extends PapyrusEventType> = (payload: EventPayloads[T]) => void;\n\n/**\n * Interface agnóstica do Motor.\n * A UI interage apenas com estes métodos.\n */\nexport interface DocumentEngine {\n load(source: DocumentSource): Promise<void>;\n getPageCount(): number;\n getCurrentPage(): number;\n goToPage(page: number): void;\n setZoom(zoom: number): void;\n getZoom(): number;\n rotate(direction: 'clockwise' | 'counterclockwise'): void;\n getRotation(): number;\n \n /** \n * Renderiza o conteúdo visual da página.\n * target: HTMLCanvasElement no Web ou NativeHandle no RN.\n */\n renderPage(pageIndex: number, target: any, scale: number): Promise<void>;\n \n /** \n * Renderiza a camada de texto para seleção.\n * container: HTMLElement no Web ou GhostView no RN.\n */\n renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void>;\n \n getTextContent(pageIndex: number): Promise<TextItem[]>;\n getPageDimensions(pageIndex: number): Promise<{ width: number, height: number }>;\n searchText?(query: string): Promise<SearchResult[]>;\n selectText?(pageIndex: number, rect: { x: number; y: number; width: number; height: number }): Promise<TextSelection | null>;\n getOutline(): Promise<OutlineItem[]>;\n getPageIndex(dest: any): Promise<number | null>;\n destroy(): void;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqEO,IAAK,mBAAL,kBAAKA,sBAAL;AACL,EAAAA,kBAAA,qBAAkB;AAClB,EAAAA,kBAAA,kBAAe;AACf,EAAAA,kBAAA,kBAAe;AACf,EAAAA,kBAAA,wBAAqB;AACrB,EAAAA,kBAAA,wBAAqB;AACrB,EAAAA,kBAAA,sBAAmB;AACnB,EAAAA,kBAAA,mBAAgB;AAPN,SAAAA;AAAA,GAAA;","names":["PapyrusEventType"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// index.ts
|
|
2
|
+
var PapyrusEventType = /* @__PURE__ */ ((PapyrusEventType2) => {
|
|
3
|
+
PapyrusEventType2["DOCUMENT_LOADED"] = "DOCUMENT_LOADED";
|
|
4
|
+
PapyrusEventType2["PAGE_CHANGED"] = "PAGE_CHANGED";
|
|
5
|
+
PapyrusEventType2["ZOOM_CHANGED"] = "ZOOM_CHANGED";
|
|
6
|
+
PapyrusEventType2["ANNOTATION_CREATED"] = "ANNOTATION_CREATED";
|
|
7
|
+
PapyrusEventType2["ANNOTATION_DELETED"] = "ANNOTATION_DELETED";
|
|
8
|
+
PapyrusEventType2["SEARCH_TRIGGERED"] = "SEARCH_TRIGGERED";
|
|
9
|
+
PapyrusEventType2["TEXT_SELECTED"] = "TEXT_SELECTED";
|
|
10
|
+
return PapyrusEventType2;
|
|
11
|
+
})(PapyrusEventType || {});
|
|
12
|
+
export {
|
|
13
|
+
PapyrusEventType
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../index.ts"],"sourcesContent":["\nexport type ViewMode = 'single' | 'double' | 'continuous';\nexport type UITheme = 'light' | 'dark';\nexport type PageTheme = 'normal' | 'sepia' | 'dark' | 'high-contrast';\nexport type Locale = 'en' | 'pt-BR';\n\nexport interface FileLike {\n arrayBuffer(): Promise<ArrayBuffer>;\n}\n\nexport type DocumentSource =\n | ArrayBuffer\n | Uint8Array\n | string\n | { uri: string }\n | { data: ArrayBuffer | Uint8Array }\n | FileLike;\n\nexport interface TextItem {\n str: string;\n dir: string;\n width: number;\n height: number;\n transform: number[];\n fontName: string;\n}\n\nexport interface SearchResult {\n pageIndex: number;\n text: string;\n matchIndex: number;\n rects?: { x: number; y: number; width: number; height: number }[];\n}\n\nexport interface TextSelection {\n text: string;\n rects: { x: number; y: number; width: number; height: number }[];\n}\n\nexport interface Annotation {\n id: string;\n type: 'highlight' | 'text' | 'strikeout' | 'comment';\n pageIndex: number;\n content?: string;\n rect: { x: number; y: number; width: number; height: number };\n color: string;\n createdAt: number;\n}\n\nexport interface OutlineItem {\n title: string;\n pageIndex: number;\n children?: OutlineItem[];\n}\n\nexport interface PapyrusConfig {\n initialPage?: number;\n initialZoom?: number;\n initialRotation?: number;\n initialViewMode?: ViewMode;\n initialUITheme?: UITheme;\n initialPageTheme?: PageTheme;\n initialAccentColor?: string;\n initialLocale?: Locale;\n initialAnnotations?: Annotation[];\n sidebarLeftOpen?: boolean;\n sidebarRightOpen?: boolean;\n}\n\nexport enum PapyrusEventType {\n DOCUMENT_LOADED = 'DOCUMENT_LOADED',\n PAGE_CHANGED = 'PAGE_CHANGED',\n ZOOM_CHANGED = 'ZOOM_CHANGED',\n ANNOTATION_CREATED = 'ANNOTATION_CREATED',\n ANNOTATION_DELETED = 'ANNOTATION_DELETED',\n SEARCH_TRIGGERED = 'SEARCH_TRIGGERED',\n TEXT_SELECTED = 'TEXT_SELECTED',\n}\n\nexport interface EventPayloads {\n [PapyrusEventType.DOCUMENT_LOADED]: { pageCount: number };\n [PapyrusEventType.PAGE_CHANGED]: { pageNumber: number };\n [PapyrusEventType.ZOOM_CHANGED]: { zoom: number };\n [PapyrusEventType.ANNOTATION_CREATED]: { annotation: Annotation };\n [PapyrusEventType.ANNOTATION_DELETED]: { annotationId: string };\n [PapyrusEventType.SEARCH_TRIGGERED]: { query: string };\n [PapyrusEventType.TEXT_SELECTED]: { text: string, pageIndex: number };\n}\n\nexport type PapyrusEventListener<T extends PapyrusEventType> = (payload: EventPayloads[T]) => void;\n\n/**\n * Interface agnóstica do Motor.\n * A UI interage apenas com estes métodos.\n */\nexport interface DocumentEngine {\n load(source: DocumentSource): Promise<void>;\n getPageCount(): number;\n getCurrentPage(): number;\n goToPage(page: number): void;\n setZoom(zoom: number): void;\n getZoom(): number;\n rotate(direction: 'clockwise' | 'counterclockwise'): void;\n getRotation(): number;\n \n /** \n * Renderiza o conteúdo visual da página.\n * target: HTMLCanvasElement no Web ou NativeHandle no RN.\n */\n renderPage(pageIndex: number, target: any, scale: number): Promise<void>;\n \n /** \n * Renderiza a camada de texto para seleção.\n * container: HTMLElement no Web ou GhostView no RN.\n */\n renderTextLayer(pageIndex: number, container: any, scale: number): Promise<void>;\n \n getTextContent(pageIndex: number): Promise<TextItem[]>;\n getPageDimensions(pageIndex: number): Promise<{ width: number, height: number }>;\n searchText?(query: string): Promise<SearchResult[]>;\n selectText?(pageIndex: number, rect: { x: number; y: number; width: number; height: number }): Promise<TextSelection | null>;\n getOutline(): Promise<OutlineItem[]>;\n getPageIndex(dest: any): Promise<number | null>;\n destroy(): void;\n}\n"],"mappings":";AAqEO,IAAK,mBAAL,kBAAKA,sBAAL;AACL,EAAAA,kBAAA,qBAAkB;AAClB,EAAAA,kBAAA,kBAAe;AACf,EAAAA,kBAAA,kBAAe;AACf,EAAAA,kBAAA,wBAAqB;AACrB,EAAAA,kBAAA,wBAAqB;AACrB,EAAAA,kBAAA,sBAAmB;AACnB,EAAAA,kBAAA,mBAAgB;AAPN,SAAAA;AAAA,GAAA;","names":["PapyrusEventType"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@papyrus-sdk/types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "dist/index.cjs",
|
|
5
|
+
"module": "dist/index.mjs",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup index.ts --dts --format cjs,esm --out-dir dist --clean --sourcemap"
|
|
22
|
+
}
|
|
23
|
+
}
|