postext-folio 0.52.6 → 0.52.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/postext/book.d.ts +35 -0
- package/dist/postext/book.d.ts.map +1 -0
- package/dist/postext/book.js +96 -0
- package/dist/postext/book.js.map +1 -0
- package/dist/postext/constants.d.ts +36 -0
- package/dist/postext/constants.d.ts.map +1 -0
- package/dist/postext/constants.js +13 -0
- package/dist/postext/constants.js.map +1 -0
- package/dist/postext/pageVideos.d.ts +26 -0
- package/dist/postext/pageVideos.d.ts.map +1 -0
- package/dist/postext/pageVideos.js +276 -0
- package/dist/postext/pageVideos.js.map +1 -0
- package/dist/postext/painting.d.ts +30 -0
- package/dist/postext/painting.d.ts.map +1 -0
- package/dist/postext/painting.js +167 -0
- package/dist/postext/painting.js.map +1 -0
- package/dist/postext/sharp.d.ts +19 -0
- package/dist/postext/sharp.d.ts.map +1 -0
- package/dist/postext/sharp.js +121 -0
- package/dist/postext/sharp.js.map +1 -0
- package/dist/postext/state.d.ts +29 -0
- package/dist/postext/state.d.ts.map +1 -0
- package/dist/postext/state.js +2 -0
- package/dist/postext/state.js.map +1 -0
- package/dist/postext/sweep.d.ts +24 -0
- package/dist/postext/sweep.d.ts.map +1 -0
- package/dist/postext/sweep.js +37 -0
- package/dist/postext/sweep.js.map +1 -0
- package/dist/postext/types.d.ts +77 -0
- package/dist/postext/types.d.ts.map +1 -0
- package/dist/postext/types.js +2 -0
- package/dist/postext/types.js.map +1 -0
- package/dist/postext.d.ts +6 -124
- package/dist/postext.d.ts.map +1 -1
- package/dist/postext.js +87 -732
- package/dist/postext.js.map +1 -1
- package/dist/viewer/constants.d.ts +30 -0
- package/dist/viewer/constants.d.ts.map +1 -0
- package/dist/viewer/constants.js +49 -0
- package/dist/viewer/constants.js.map +1 -0
- package/dist/viewer/input.d.ts +15 -0
- package/dist/viewer/input.d.ts.map +1 -0
- package/dist/viewer/input.js +142 -0
- package/dist/viewer/input.js.map +1 -0
- package/dist/viewer/layout.d.ts +24 -0
- package/dist/viewer/layout.d.ts.map +1 -0
- package/dist/viewer/layout.js +183 -0
- package/dist/viewer/layout.js.map +1 -0
- package/dist/viewer/lens.d.ts +42 -0
- package/dist/viewer/lens.d.ts.map +1 -0
- package/dist/viewer/lens.js +166 -0
- package/dist/viewer/lens.js.map +1 -0
- package/dist/viewer/pointer.d.ts +37 -0
- package/dist/viewer/pointer.d.ts.map +1 -0
- package/dist/viewer/pointer.js +250 -0
- package/dist/viewer/pointer.js.map +1 -0
- package/dist/viewer/state.d.ts +70 -0
- package/dist/viewer/state.d.ts.map +1 -0
- package/dist/viewer/state.js +2 -0
- package/dist/viewer/state.js.map +1 -0
- package/dist/viewer/turning.d.ts +34 -0
- package/dist/viewer/turning.d.ts.map +1 -0
- package/dist/viewer/turning.js +156 -0
- package/dist/viewer/turning.js.map +1 -0
- package/dist/viewer/types.d.ts +241 -0
- package/dist/viewer/types.d.ts.map +1 -0
- package/dist/viewer/types.js +2 -0
- package/dist/viewer/types.js.map +1 -0
- package/dist/viewer.d.ts +3 -242
- package/dist/viewer.d.ts.map +1 -1
- package/dist/viewer.js +104 -976
- package/dist/viewer.js.map +1 -1
- package/package.json +3 -3
package/dist/viewer.d.ts
CHANGED
|
@@ -1,245 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* and the paper it is printed on when that is not the book's (a plate
|
|
5
|
-
* section on gloss in a matte book). */
|
|
6
|
-
export type FolioPage = PageSource | {
|
|
7
|
-
src: PageSource;
|
|
8
|
-
alt?: string;
|
|
9
|
-
paper?: FolioPaperConfig;
|
|
10
|
-
};
|
|
11
|
-
/** How the 3D book is presented. */
|
|
12
|
-
export interface FolioAppearance {
|
|
13
|
-
/** View, paper, binding, desk and light (postext's `folio` config). */
|
|
14
|
-
folio?: FolioConfig;
|
|
15
|
-
/** The trim width of a page in mm (the paper's caliper and the cover's
|
|
16
|
-
* board are scaled against it). Default 150. */
|
|
17
|
-
pageWidthMm?: number;
|
|
18
|
-
/** Pages of the book before the first page given and after the last
|
|
19
|
-
* (the other chapters of a book shown a chapter at a time): they are
|
|
20
|
-
* never drawn, only counted for the thickness of the page block.
|
|
21
|
-
* `createFolioFromDocument` places the covers by them too: with pages
|
|
22
|
-
* before, the first page given is not the book's front cover, nor with
|
|
23
|
-
* pages after the last its back cover (a chapter from the middle of a
|
|
24
|
-
* book with its own covers turns paper leaves). */
|
|
25
|
-
extraPages?: {
|
|
26
|
-
before: number;
|
|
27
|
-
after: number;
|
|
28
|
-
};
|
|
29
|
-
/** Where the scanned desk textures are served (see
|
|
30
|
-
* `FlipAppearance.textureBaseUrl`). */
|
|
31
|
-
textureBaseUrl?: string;
|
|
32
|
-
/** The first page given is the book's front cover, the last its back
|
|
33
|
-
* cover (when it falls on a verso): they turn as boards and no case
|
|
34
|
-
* is drawn round the pages. */
|
|
35
|
-
covers?: {
|
|
36
|
-
front: boolean;
|
|
37
|
-
back: boolean;
|
|
38
|
-
};
|
|
39
|
-
/** The picture printed on the spine: the image the `folio.binding.
|
|
40
|
-
* spineImage` resource names, as a URL (or a drawn canvas or image).
|
|
41
|
-
* See `FlipAppearance.spineImage`. */
|
|
42
|
-
spineImage?: PageSource;
|
|
43
|
-
}
|
|
44
|
-
/** What the left button (or one finger) does on the book: `hand` takes
|
|
45
|
-
* and turns the pages, `orbit` turns the view round the book (what the
|
|
46
|
-
* right button always does), `select` leaves the pointer to the host (to
|
|
47
|
-
* select text: `pageAt` says where on which page it is), `magnify` holds
|
|
48
|
-
* a magnifying glass over the book where the pointer is (#527; a finger
|
|
49
|
-
* holds it above itself while it touches the screen): the wheel, + and −
|
|
50
|
-
* change how much it magnifies, Esc puts it away. The pointer is left to
|
|
51
|
-
* the host under the glass too, a text cursor over the pages (#543):
|
|
52
|
-
* `pageAt` then says what lies under the glass's centre. */
|
|
53
|
-
export type FolioInteraction = "hand" | "orbit" | "select" | "magnify";
|
|
54
|
-
/** The magnifying glass (`interaction: 'magnify'`). */
|
|
55
|
-
export interface FolioMagnifier {
|
|
56
|
-
/** How many times it magnifies the book at its centre (1.5 … 10).
|
|
57
|
-
* Default: enough to show the page at about 5.5 CSS px a millimetre
|
|
58
|
-
* (small print readable), between 2 and 8. */
|
|
59
|
-
zoom?: number;
|
|
60
|
-
/** The glass's diameter with its rim, in CSS px. Default 42 % of the
|
|
61
|
-
* viewer's shorter side, between 180 and 520. */
|
|
62
|
-
diameter?: number;
|
|
63
|
-
}
|
|
64
|
-
/** Sharper paintings of the pages for the magnifying glass: without them
|
|
65
|
-
* it magnifies the pages as given (an image at its natural size, a
|
|
66
|
-
* canvas at its own). */
|
|
67
|
-
export interface FolioPageDetail {
|
|
68
|
-
/** Page `index` painted `deviceWidth` px wide (or as near as the host
|
|
69
|
-
* can): the glass shows it in place of the page's own source. */
|
|
70
|
-
paint(index: number, deviceWidth: number): PageSource | Promise<PageSource>;
|
|
71
|
-
/** The glass was put away (another interaction): the paintings can be
|
|
72
|
-
* let go. */
|
|
73
|
-
release?(): void;
|
|
74
|
-
}
|
|
75
|
-
/** A point on a page as printed: the page index and where on it, as
|
|
76
|
-
* fractions of its width and height from its top left corner. */
|
|
77
|
-
export interface FolioPagePoint {
|
|
78
|
-
page: number;
|
|
79
|
-
x: number;
|
|
80
|
-
y: number;
|
|
81
|
-
}
|
|
82
|
-
/** A video drawn on a page of the book (#477): the element playing it and
|
|
83
|
-
* where its picture lies on the page (see `PageVideoFrame`). */
|
|
84
|
-
export interface FolioPageVideo extends PageVideoFrame {
|
|
85
|
-
page: number;
|
|
86
|
-
element: HTMLVideoElement;
|
|
87
|
-
}
|
|
88
|
-
export interface FolioLabels {
|
|
89
|
-
/** The viewer's accessible name. */
|
|
90
|
-
region: string;
|
|
91
|
-
prev: string;
|
|
92
|
-
next: string;
|
|
93
|
-
/** The pages on show, for the live count under the book: page indexes
|
|
94
|
-
* (0-based) and the page count. */
|
|
95
|
-
count: (pages: number[], total: number) => string;
|
|
96
|
-
}
|
|
97
|
-
export interface FolioOptions {
|
|
98
|
-
pages: FolioPage[];
|
|
99
|
-
/** Whether the first page is a recto (it opens alone, on the right of a
|
|
100
|
-
* left-bound book). Default true. */
|
|
101
|
-
firstPageRecto?: boolean;
|
|
102
|
-
/** The edge the book is bound on. A right-bound book lies mirrored: page
|
|
103
|
-
* 1 alone on the left, pairs [3 | 2], and its pages turn leftward. */
|
|
104
|
-
binding?: "left" | "right";
|
|
105
|
-
/** The page to open on (0-based). Default 0. */
|
|
106
|
-
at?: number;
|
|
107
|
-
/** `double` shows spreads and turns leaves in 3D; `single` one page at a
|
|
108
|
-
* time; `auto` (default) is single in a box narrower than 560 px. */
|
|
109
|
-
mode?: "auto" | "single" | "double";
|
|
110
|
-
/** A page's width / height, when the pages cannot tell it yet (blank
|
|
111
|
-
* until painted). Default: the first sized page's, else 1 : √2. */
|
|
112
|
-
aspect?: number;
|
|
113
|
-
/** The colour of blank pages (any CSS colour). Default white. */
|
|
114
|
-
paper?: string;
|
|
115
|
-
/** Turns leaves in 3D when WebGL2 is there and the reader has not asked
|
|
116
|
-
* for reduced motion. Default true. */
|
|
117
|
-
animate?: boolean;
|
|
118
|
-
/** Draws the ‹ › buttons and the page count. Default true. */
|
|
119
|
-
controls?: boolean;
|
|
120
|
-
/** Shows the page count under the book. Default true. When false it is
|
|
121
|
-
* still announced to screen readers (a visually hidden live region). */
|
|
122
|
-
showCount?: boolean;
|
|
123
|
-
labels?: Partial<FolioLabels>;
|
|
124
|
-
/** How the 3D book is presented (see {@link FolioAppearance}). */
|
|
125
|
-
appearance?: FolioAppearance;
|
|
126
|
-
/** What the left button does (see {@link FolioInteraction}). Default
|
|
127
|
-
* `hand`. */
|
|
128
|
-
interaction?: FolioInteraction;
|
|
129
|
-
/** The magnifying glass (see {@link FolioMagnifier}). */
|
|
130
|
-
magnifier?: FolioMagnifier;
|
|
131
|
-
/** Sharper paintings for the magnifying glass (see
|
|
132
|
-
* {@link FolioPageDetail}). */
|
|
133
|
-
detail?: FolioPageDetail;
|
|
134
|
-
/** Told of every spread that settles: its index and the pages on show. */
|
|
135
|
-
onChange?: (state: FolioState) => void;
|
|
136
|
-
/** Told as soon as the book is sent to another spread (a button, a key,
|
|
137
|
-
* a page let go past halfway), before its leaves have landed. */
|
|
138
|
-
onTarget?: (state: FolioState) => void;
|
|
139
|
-
/** A click on a page, before it turns the page (hand mode) or reaches
|
|
140
|
-
* the host (select mode): return true when the click did something else,
|
|
141
|
-
* such as playing a video printed there. In orbit and select modes it is
|
|
142
|
-
* asked only where `isPageAction` says a click acts. */
|
|
143
|
-
onPageClick?: (point: FolioPagePoint) => boolean;
|
|
144
|
-
/** Whether a click at this point of a page acts on it (`onPageClick`):
|
|
145
|
-
* the pointer shows a hand there. */
|
|
146
|
-
isPageAction?: (point: FolioPagePoint) => boolean;
|
|
147
|
-
/** Told when the page slots change size: a host painting pages for the
|
|
148
|
-
* viewer paints them at `deviceWidth` × `deviceHeight` pixels, so they
|
|
149
|
-
* are shown 1:1 both at rest and on a turning leaf. */
|
|
150
|
-
onLayout?: (size: FolioPageSize) => void;
|
|
151
|
-
}
|
|
152
|
-
/** One page slot of the spread: its CSS size, and the device pixels it
|
|
153
|
-
* covers (the size a page bitmap is shown 1:1 at). */
|
|
154
|
-
export interface FolioPageSize {
|
|
155
|
-
width: number;
|
|
156
|
-
height: number;
|
|
157
|
-
deviceWidth: number;
|
|
158
|
-
deviceHeight: number;
|
|
159
|
-
}
|
|
160
|
-
export interface FolioState {
|
|
161
|
-
spread: number;
|
|
162
|
-
/** The page indexes on show (one or two). */
|
|
163
|
-
pages: number[];
|
|
164
|
-
}
|
|
165
|
-
export interface FolioViewer {
|
|
166
|
-
/** The viewer's root element. */
|
|
167
|
-
readonly element: HTMLElement;
|
|
168
|
-
/** Turns to the spread that shows page `index`; `instant` opens it
|
|
169
|
-
* there without turning the leaves (a link, a restored position). */
|
|
170
|
-
goToPage(index: number, options?: {
|
|
171
|
-
instant?: boolean;
|
|
172
|
-
}): void;
|
|
173
|
-
/** Turns to spread `index` (`instant`: opens it there). */
|
|
174
|
-
goToSpread(index: number, options?: {
|
|
175
|
-
instant?: boolean;
|
|
176
|
-
}): void;
|
|
177
|
-
next(): void;
|
|
178
|
-
prev(): void;
|
|
179
|
-
/** Replaces the pages (a relayout, or more pages painted), staying on
|
|
180
|
-
* the page on show unless `at` says otherwise. */
|
|
181
|
-
setPages(pages: FolioPage[], options?: Pick<FolioOptions, "firstPageRecto" | "binding" | "at" | "paper" | "mode">): void;
|
|
182
|
-
/** The page slot's size, as last laid out. */
|
|
183
|
-
readonly pageSize: FolioPageSize;
|
|
184
|
-
/** Swaps the labels (a host that changes language). */
|
|
185
|
-
setLabels(labels: Partial<FolioLabels>): void;
|
|
186
|
-
/** Changes how the 3D book is presented. */
|
|
187
|
-
setAppearance(appearance: FolioAppearance): void;
|
|
188
|
-
/** Eases the view back to the one the settings give (after the reader
|
|
189
|
-
* orbited it with a right-drag). */
|
|
190
|
-
resetView(): void;
|
|
191
|
-
/** The view as it is seen now, in degrees: `tilt` from straight above,
|
|
192
|
-
* `yaw` round the book (−180 … 180), ready to store as `folio.tilt` and
|
|
193
|
-
* `folio.yaw`; null without the 3D book. */
|
|
194
|
-
getView(): {
|
|
195
|
-
tilt: number;
|
|
196
|
-
yaw: number;
|
|
197
|
-
} | null;
|
|
198
|
-
/** Changes what the left button does. */
|
|
199
|
-
setInteraction(mode: FolioInteraction): void;
|
|
200
|
-
/** How many times the magnifying glass magnifies at its centre; null
|
|
201
|
-
* goes back to the default (see {@link FolioMagnifier.zoom}). */
|
|
202
|
-
setMagnification(zoom: number | null): void;
|
|
203
|
-
/** The magnifying glass as it is: how many times it magnifies at its
|
|
204
|
-
* centre, and whether it is held over the book now. */
|
|
205
|
-
getMagnifier(): {
|
|
206
|
-
zoom: number;
|
|
207
|
-
held: boolean;
|
|
208
|
-
};
|
|
209
|
-
/** Holds the glass over the middle of the open spread, as the + and −
|
|
210
|
-
* keys do (in the magnify interaction, on the 3D book), or puts it
|
|
211
|
-
* away, as Escape does. */
|
|
212
|
-
holdMagnifier(held: boolean): void;
|
|
213
|
-
/** A page's canvas was drawn again in place: shows it again. */
|
|
214
|
-
refreshPage(src: PageSource): void;
|
|
215
|
-
/** Plays a video on a page (#477): drawn over the page's painting, on
|
|
216
|
-
* the leaf that carries it as it lies or turns; `null` takes it off.
|
|
217
|
-
* The same as `setPageVideos` with one video or none. */
|
|
218
|
-
setPageVideo(video: FolioPageVideo | null): void;
|
|
219
|
-
/** Plays these videos on their pages together (#507), in place of the
|
|
220
|
-
* ones shown before; an empty list takes them all off. The WebGL book
|
|
221
|
-
* draws up to eight at once (any more show their posters); the DOM
|
|
222
|
-
* spread lays each element over its page. */
|
|
223
|
-
setPageVideos(videos: readonly FolioPageVideo[]): void;
|
|
224
|
-
/** The page under a pointer and where on it, as the book is seen (the
|
|
225
|
-
* tilted, orbited 3D book included); null off the open pages. In
|
|
226
|
-
* magnify mode, the point under the glass's centre (#543), which a
|
|
227
|
-
* finger holds above itself. */
|
|
228
|
-
pageAt(event: {
|
|
229
|
-
clientX: number;
|
|
230
|
-
clientY: number;
|
|
231
|
-
}): FolioPagePoint | null;
|
|
232
|
-
/** Where a point of a page lies on screen (client px), when the page
|
|
233
|
-
* lies open; null otherwise. */
|
|
234
|
-
pointOnScreen(point: FolioPagePoint): {
|
|
235
|
-
x: number;
|
|
236
|
-
y: number;
|
|
237
|
-
} | null;
|
|
238
|
-
readonly state: FolioState;
|
|
239
|
-
dispose(): void;
|
|
240
|
-
}
|
|
241
|
-
/** Below this width (px) `mode: 'auto'` shows one page at a time. */
|
|
242
|
-
export declare const SINGLE_BELOW = 560;
|
|
1
|
+
import type { FolioOptions, FolioViewer } from './viewer/types.js';
|
|
2
|
+
export type { FolioPage, FolioAppearance, FolioInteraction, FolioMagnifier, FolioPageDetail, FolioPagePoint, FolioPageVideo, FolioLabels, FolioOptions, FolioPageSize, FolioState, FolioViewer } from './viewer/types.js';
|
|
3
|
+
export { SINGLE_BELOW } from './viewer/constants.js';
|
|
243
4
|
/**
|
|
244
5
|
* A book on the page: the pages in spreads by the recto rule, turned with
|
|
245
6
|
* the ‹ › buttons, ←/→, a swipe, a click on a page, or taken by hand and
|
package/dist/viewer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../src/viewer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../src/viewer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQnE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC1N,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,GAAG,WAAW,CAuOtF"}
|