@laminapdf/viewer 0.2.0-alpha.3 → 0.2.0-alpha.5
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/README.md +102 -8
- package/dist/client.d.ts +75 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +192 -32
- package/dist/client.js.map +1 -1
- package/dist/find/controller.d.ts +73 -0
- package/dist/find/controller.d.ts.map +1 -0
- package/dist/find/controller.js +227 -0
- package/dist/find/controller.js.map +1 -0
- package/dist/find/fold.d.ts +23 -0
- package/dist/find/fold.d.ts.map +1 -0
- package/dist/find/fold.js +99 -0
- package/dist/find/fold.js.map +1 -0
- package/dist/find/page.d.ts +44 -0
- package/dist/find/page.d.ts.map +1 -0
- package/dist/find/page.js +173 -0
- package/dist/find/page.js.map +1 -0
- package/dist/first-draw.d.ts +10 -0
- package/dist/first-draw.d.ts.map +1 -0
- package/dist/first-draw.js +33 -0
- package/dist/first-draw.js.map +1 -0
- package/dist/history/history.d.ts +65 -0
- package/dist/history/history.d.ts.map +1 -0
- package/dist/history/history.js +135 -0
- package/dist/history/history.js.map +1 -0
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/layers/box.d.ts +10 -0
- package/dist/layers/box.d.ts.map +1 -0
- package/dist/layers/box.js +19 -0
- package/dist/layers/box.js.map +1 -0
- package/dist/layers/copy.d.ts +26 -0
- package/dist/layers/copy.d.ts.map +1 -0
- package/dist/layers/copy.js +150 -0
- package/dist/layers/copy.js.map +1 -0
- package/dist/layers/highlight-layer.d.ts +31 -0
- package/dist/layers/highlight-layer.d.ts.map +1 -0
- package/dist/layers/highlight-layer.js +95 -0
- package/dist/layers/highlight-layer.js.map +1 -0
- package/dist/layers/link-layer.d.ts +68 -0
- package/dist/layers/link-layer.d.ts.map +1 -0
- package/dist/layers/link-layer.js +279 -0
- package/dist/layers/link-layer.js.map +1 -0
- package/dist/layers/link-url.d.ts +19 -0
- package/dist/layers/link-url.d.ts.map +1 -0
- package/dist/layers/link-url.js +47 -0
- package/dist/layers/link-url.js.map +1 -0
- package/dist/layers/spans.d.ts +36 -0
- package/dist/layers/spans.d.ts.map +1 -0
- package/dist/layers/spans.js +103 -0
- package/dist/layers/spans.js.map +1 -0
- package/dist/layers/structure-layer.d.ts +15 -0
- package/dist/layers/structure-layer.d.ts.map +1 -0
- package/dist/layers/structure-layer.js +155 -0
- package/dist/layers/structure-layer.js.map +1 -0
- package/dist/layers/text-layer.d.ts +70 -0
- package/dist/layers/text-layer.d.ts.map +1 -0
- package/dist/layers/text-layer.js +576 -0
- package/dist/layers/text-layer.js.map +1 -0
- package/dist/layout/range.d.ts +3 -0
- package/dist/layout/range.d.ts.map +1 -0
- package/dist/layout/range.js +5 -0
- package/dist/layout/range.js.map +1 -0
- package/dist/network/watch.d.ts +30 -0
- package/dist/network/watch.d.ts.map +1 -0
- package/dist/network/watch.js +181 -0
- package/dist/network/watch.js.map +1 -0
- package/dist/protocol.d.ts +193 -6
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +16 -4
- package/dist/protocol.js.map +1 -1
- package/dist/render/tiles.d.ts +43 -3
- package/dist/render/tiles.d.ts.map +1 -1
- package/dist/render/tiles.js +62 -10
- package/dist/render/tiles.js.map +1 -1
- package/dist/source/http-range.d.ts +59 -0
- package/dist/source/http-range.d.ts.map +1 -0
- package/dist/source/http-range.js +284 -0
- package/dist/source/http-range.js.map +1 -0
- package/dist/source/opfs.d.ts +35 -0
- package/dist/source/opfs.d.ts.map +1 -0
- package/dist/source/opfs.js +178 -0
- package/dist/source/opfs.js.map +1 -0
- package/dist/thumbnails/strip.d.ts +37 -0
- package/dist/thumbnails/strip.d.ts.map +1 -0
- package/dist/thumbnails/strip.js +324 -0
- package/dist/thumbnails/strip.js.map +1 -0
- package/dist/view/budgets.d.ts +29 -0
- package/dist/view/budgets.d.ts.map +1 -0
- package/dist/view/budgets.js +63 -0
- package/dist/view/budgets.js.map +1 -0
- package/dist/view/touch.d.ts +71 -0
- package/dist/view/touch.d.ts.map +1 -0
- package/dist/view/touch.js +220 -0
- package/dist/view/touch.js.map +1 -0
- package/dist/view/user-select.d.ts +3 -0
- package/dist/view/user-select.d.ts.map +1 -0
- package/dist/view/user-select.js +10 -0
- package/dist/view/user-select.js.map +1 -0
- package/dist/view/viewer.d.ts +102 -1
- package/dist/view/viewer.d.ts.map +1 -1
- package/dist/view/viewer.js +660 -95
- package/dist/view/viewer.js.map +1 -1
- package/dist/worker/document.d.ts +53 -1
- package/dist/worker/document.d.ts.map +1 -1
- package/dist/worker/document.js +222 -24
- package/dist/worker/document.js.map +1 -1
- package/dist/worker/entry.d.ts +1 -1
- package/dist/worker/entry.d.ts.map +1 -1
- package/dist/worker/entry.js +2 -0
- package/dist/worker/entry.js.map +1 -1
- package/dist/worker/find.d.ts +7 -0
- package/dist/worker/find.d.ts.map +1 -0
- package/dist/worker/find.js +46 -0
- package/dist/worker/find.js.map +1 -0
- package/dist/worker/methods.d.ts.map +1 -1
- package/dist/worker/methods.js +49 -4
- package/dist/worker/methods.js.map +1 -1
- package/dist/worker/navigation.d.ts +10 -0
- package/dist/worker/navigation.d.ts.map +1 -0
- package/dist/worker/navigation.js +34 -0
- package/dist/worker/navigation.js.map +1 -0
- package/dist/worker/network.d.ts +4 -0
- package/dist/worker/network.d.ts.map +1 -0
- package/dist/worker/network.js +24 -0
- package/dist/worker/network.js.map +1 -0
- package/dist/worker/print.d.ts +14 -0
- package/dist/worker/print.d.ts.map +1 -0
- package/dist/worker/print.js +49 -0
- package/dist/worker/print.js.map +1 -0
- package/dist/worker/recent-pages.d.ts +14 -0
- package/dist/worker/recent-pages.d.ts.map +1 -0
- package/dist/worker/recent-pages.js +53 -0
- package/dist/worker/recent-pages.js.map +1 -0
- package/dist/worker/render.d.ts +5 -2
- package/dist/worker/render.d.ts.map +1 -1
- package/dist/worker/render.js +16 -6
- package/dist/worker/render.js.map +1 -1
- package/dist/worker/text.d.ts +25 -0
- package/dist/worker/text.d.ts.map +1 -0
- package/dist/worker/text.js +82 -0
- package/dist/worker/text.js.map +1 -0
- package/dist/zoom/destination.d.ts +18 -0
- package/dist/zoom/destination.d.ts.map +1 -0
- package/dist/zoom/destination.js +56 -0
- package/dist/zoom/destination.js.map +1 -0
- package/package.json +6 -5
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// The text calls' gate for one open document. The document worker runs one call at a time, so a
|
|
2
|
+
// text or link call that waits for the extract module to download would hold the first page's
|
|
3
|
+
// render behind it: those calls wait here until the document's first page is drawn.
|
|
4
|
+
/** How long text calls wait for the open document's first render before going ahead anyway, in ms. */
|
|
5
|
+
const FIRST_DRAW_WAIT = 2000;
|
|
6
|
+
/** Open once document `id`'s first render answers, or after `wait` ms, whichever comes first. */
|
|
7
|
+
export class FirstDraw {
|
|
8
|
+
#id;
|
|
9
|
+
#opened;
|
|
10
|
+
#open = () => undefined;
|
|
11
|
+
#timer;
|
|
12
|
+
constructor(id, wait = FIRST_DRAW_WAIT) {
|
|
13
|
+
this.#id = id;
|
|
14
|
+
this.#opened = new Promise((resolve) => {
|
|
15
|
+
this.#open = resolve;
|
|
16
|
+
});
|
|
17
|
+
// One timer per open: a caller that never renders waits once, not on every call.
|
|
18
|
+
this.#timer = setTimeout(() => this.#open(), wait);
|
|
19
|
+
}
|
|
20
|
+
/** A render of document `id` answered: a render of an earlier document doesn't count. */
|
|
21
|
+
drawn(id) {
|
|
22
|
+
if (id !== this.#id)
|
|
23
|
+
return;
|
|
24
|
+
clearTimeout(this.#timer);
|
|
25
|
+
this.#open();
|
|
26
|
+
}
|
|
27
|
+
/** Resolves once the gate is open; rejects with `signal`'s reason if it was aborted meanwhile. */
|
|
28
|
+
async wait(signal) {
|
|
29
|
+
await this.#opened;
|
|
30
|
+
signal?.throwIfAborted();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=first-draw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"first-draw.js","sourceRoot":"","sources":["../src/first-draw.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,8FAA8F;AAC9F,oFAAoF;AAEpF,sGAAsG;AACtG,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,iGAAiG;AACjG,MAAM,OAAO,SAAS;IACX,GAAG,CAAS;IACZ,OAAO,CAAgB;IAChC,KAAK,GAAe,GAAG,EAAE,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAgC;IAE/C,YAAY,EAAU,EAAE,IAAI,GAAG,eAAe;QAC5C,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAC3C,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,iFAAiF;QACjF,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,yFAAyF;IACzF,KAAK,CAAC,EAAU;QACd,IAAI,EAAE,KAAK,IAAI,CAAC,GAAG;YAAE,OAAO;QAC5B,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,kGAAkG;IAClG,KAAK,CAAC,IAAI,CAAC,MAAoB;QAC7B,MAAM,IAAI,CAAC,OAAO,CAAC;QACnB,MAAM,EAAE,cAAc,EAAE,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { DocumentPoint, Zoom } from "../zoom/zoom.js";
|
|
2
|
+
/** A place in the document: the point at the viewport's top-left, and the zoom. */
|
|
3
|
+
export interface HistoryPlace {
|
|
4
|
+
readonly point: DocumentPoint;
|
|
5
|
+
readonly zoom: Zoom;
|
|
6
|
+
}
|
|
7
|
+
/** One entry: a place and the id it keeps while it is in the history. */
|
|
8
|
+
export interface HistoryEntry extends HistoryPlace {
|
|
9
|
+
readonly id: number;
|
|
10
|
+
}
|
|
11
|
+
/** What the history shows: whether Back and Forward go anywhere, and the pages they go to. */
|
|
12
|
+
export interface HistoryState {
|
|
13
|
+
/** The entry the view is at. */
|
|
14
|
+
readonly current: HistoryEntry | undefined;
|
|
15
|
+
/** Where Back goes, when it goes anywhere. */
|
|
16
|
+
readonly back: HistoryEntry | undefined;
|
|
17
|
+
/** Where Forward goes, when it goes anywhere. */
|
|
18
|
+
readonly forward: HistoryEntry | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** What the history reads and moves of its viewer. */
|
|
21
|
+
export interface HistoryHost {
|
|
22
|
+
/** Where the view is now; `undefined` without a document. */
|
|
23
|
+
place(): HistoryPlace | undefined;
|
|
24
|
+
/** Puts the view at `place`. */
|
|
25
|
+
show(place: HistoryPlace): void;
|
|
26
|
+
}
|
|
27
|
+
/** The history's options. */
|
|
28
|
+
export interface NavigationHistoryOptions {
|
|
29
|
+
/** The most entries kept; the oldest go first (default 100). */
|
|
30
|
+
readonly max?: number;
|
|
31
|
+
}
|
|
32
|
+
/** One viewer's back and forward history. */
|
|
33
|
+
export declare class NavigationHistory {
|
|
34
|
+
#private;
|
|
35
|
+
constructor(host: HistoryHost, options?: NavigationHistoryOptions);
|
|
36
|
+
/** What Back and Forward do now (a new object after each change). */
|
|
37
|
+
getState(): HistoryState;
|
|
38
|
+
/** Calls `listener` after every change (for `useSyncExternalStore`). */
|
|
39
|
+
subscribe(listener: () => void): () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Calls `listener` when an entry is added: by a jump (`replaced` false), or as the first entry
|
|
42
|
+
* of a document (`replaced` true, as `history.replaceState` would). Back, Forward and `goTo`
|
|
43
|
+
* add nothing, so they never call it.
|
|
44
|
+
*/
|
|
45
|
+
onEntry(listener: (entry: HistoryEntry, replaced: boolean) => void): () => void;
|
|
46
|
+
/** Forgets every entry: a new document starts a history of its own. */
|
|
47
|
+
reset(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Runs `go` (which moves the view) as a jump: where the view was is kept for Back, and where it
|
|
50
|
+
* lands is the new current entry, with nothing left for Forward. Landing where it was adds
|
|
51
|
+
* nothing.
|
|
52
|
+
*/
|
|
53
|
+
jump(go: () => void): void;
|
|
54
|
+
/** Goes back one entry; `false` when there is none. */
|
|
55
|
+
back(): boolean;
|
|
56
|
+
/** Goes forward one entry; `false` when there is none. */
|
|
57
|
+
forward(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Goes to the entry `id` (Back or Forward, by the browser's history or the app's own): the
|
|
60
|
+
* view moves there and the entries stay. `false` when that entry is gone (pushed out, or from
|
|
61
|
+
* another document).
|
|
62
|
+
*/
|
|
63
|
+
goTo(id: number): boolean;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/history/history.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE3D,mFAAmF;AACnF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AAED,yEAAyE;AACzE,MAAM,WAAW,YAAa,SAAQ,YAAY;IAChD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,8FAA8F;AAC9F,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,CAAC;IAC3C,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,CAAC;CAC5C;AAED,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,6DAA6D;IAC7D,KAAK,IAAI,YAAY,GAAG,SAAS,CAAC;IAClC,gCAAgC;IAChC,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;CACjC;AAED,6BAA6B;AAC7B,MAAM,WAAW,wBAAwB;IACvC,gEAAgE;IAChE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAQD,6CAA6C;AAC7C,qBAAa,iBAAiB;;IAU5B,YAAY,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,wBAA6B,EAGpE;IAED,qEAAqE;IACrE,QAAQ,IAAI,YAAY,CAEvB;IAED,wEAAwE;IACxE,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAG1C;IAED;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAG9E;IAED,uEAAuE;IACvE,KAAK,IAAI,IAAI,CAIZ;IAED;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAYzB;IAED,uDAAuD;IACvD,IAAI,IAAI,OAAO,CAGd;IAED,0DAA0D;IAC1D,OAAO,IAAI,OAAO,CAGjB;IAED;;;;OAIG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAWxB;CAiCF"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Back and forward through the places a reader jumped from and to (web-app §6 C6, R07): links,
|
|
2
|
+
// the outline, thumbnails, go to page and find each record a jump; scrolling alone never does.
|
|
3
|
+
// A jump first notes where the view is now (so Back returns to where the reader had scrolled,
|
|
4
|
+
// not only to where they last landed), then adds the place it lands on, cutting off whatever
|
|
5
|
+
// Forward held. A jump that lands where the view already is adds nothing. Each entry has an id
|
|
6
|
+
// that outlives the oldest entries' removal, so an app can tie its own history (the browser's,
|
|
7
|
+
// through the address fragment) to these entries and come back to one by id.
|
|
8
|
+
/** Whether `a` and `b` show the same view: one page, a point within a thousandth of the page, one zoom. */
|
|
9
|
+
function samePlace(a, b) {
|
|
10
|
+
const near = (x, y) => Math.abs(x - y) < 1e-3;
|
|
11
|
+
return a.point.page === b.point.page && near(a.point.x, b.point.x) && near(a.point.y, b.point.y) && a.zoom === b.zoom;
|
|
12
|
+
}
|
|
13
|
+
/** One viewer's back and forward history. */
|
|
14
|
+
export class NavigationHistory {
|
|
15
|
+
#host;
|
|
16
|
+
#max;
|
|
17
|
+
#entries = [];
|
|
18
|
+
#index = -1;
|
|
19
|
+
#nextId = 1;
|
|
20
|
+
#state = { current: undefined, back: undefined, forward: undefined };
|
|
21
|
+
#listeners = new Set();
|
|
22
|
+
#pushes = new Set();
|
|
23
|
+
constructor(host, options = {}) {
|
|
24
|
+
this.#host = host;
|
|
25
|
+
this.#max = Math.max(2, Math.trunc(options.max ?? 100));
|
|
26
|
+
}
|
|
27
|
+
/** What Back and Forward do now (a new object after each change). */
|
|
28
|
+
getState() {
|
|
29
|
+
return this.#state;
|
|
30
|
+
}
|
|
31
|
+
/** Calls `listener` after every change (for `useSyncExternalStore`). */
|
|
32
|
+
subscribe(listener) {
|
|
33
|
+
this.#listeners.add(listener);
|
|
34
|
+
return () => this.#listeners.delete(listener);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Calls `listener` when an entry is added: by a jump (`replaced` false), or as the first entry
|
|
38
|
+
* of a document (`replaced` true, as `history.replaceState` would). Back, Forward and `goTo`
|
|
39
|
+
* add nothing, so they never call it.
|
|
40
|
+
*/
|
|
41
|
+
onEntry(listener) {
|
|
42
|
+
this.#pushes.add(listener);
|
|
43
|
+
return () => this.#pushes.delete(listener);
|
|
44
|
+
}
|
|
45
|
+
/** Forgets every entry: a new document starts a history of its own. */
|
|
46
|
+
reset() {
|
|
47
|
+
this.#entries = [];
|
|
48
|
+
this.#index = -1;
|
|
49
|
+
this.#changed();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Runs `go` (which moves the view) as a jump: where the view was is kept for Back, and where it
|
|
53
|
+
* lands is the new current entry, with nothing left for Forward. Landing where it was adds
|
|
54
|
+
* nothing.
|
|
55
|
+
*/
|
|
56
|
+
jump(go) {
|
|
57
|
+
const before = this.#host.place();
|
|
58
|
+
if (before !== undefined)
|
|
59
|
+
this.#note(before);
|
|
60
|
+
go();
|
|
61
|
+
const after = this.#host.place();
|
|
62
|
+
if (after === undefined)
|
|
63
|
+
return;
|
|
64
|
+
const current = this.#entries[this.#index];
|
|
65
|
+
if (current !== undefined && samePlace(current, after))
|
|
66
|
+
return;
|
|
67
|
+
this.#entries.splice(this.#index + 1);
|
|
68
|
+
const entry = this.#add(after);
|
|
69
|
+
for (const listener of this.#pushes)
|
|
70
|
+
listener(entry, false);
|
|
71
|
+
this.#changed();
|
|
72
|
+
}
|
|
73
|
+
/** Goes back one entry; `false` when there is none. */
|
|
74
|
+
back() {
|
|
75
|
+
const entry = this.#entries[this.#index - 1];
|
|
76
|
+
return entry === undefined ? false : this.goTo(entry.id);
|
|
77
|
+
}
|
|
78
|
+
/** Goes forward one entry; `false` when there is none. */
|
|
79
|
+
forward() {
|
|
80
|
+
const entry = this.#entries[this.#index + 1];
|
|
81
|
+
return entry === undefined ? false : this.goTo(entry.id);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Goes to the entry `id` (Back or Forward, by the browser's history or the app's own): the
|
|
85
|
+
* view moves there and the entries stay. `false` when that entry is gone (pushed out, or from
|
|
86
|
+
* another document).
|
|
87
|
+
*/
|
|
88
|
+
goTo(id) {
|
|
89
|
+
const index = this.#entries.findIndex((e) => e.id === id);
|
|
90
|
+
const entry = this.#entries[index];
|
|
91
|
+
if (entry === undefined)
|
|
92
|
+
return false;
|
|
93
|
+
const here = this.#host.place();
|
|
94
|
+
// Where the reader scrolled to since landing is where coming back returns.
|
|
95
|
+
if (here !== undefined)
|
|
96
|
+
this.#update(here);
|
|
97
|
+
this.#index = index;
|
|
98
|
+
this.#host.show(entry);
|
|
99
|
+
this.#changed();
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
/** The current entry takes `place`, or the first entry is made from it. */
|
|
103
|
+
#note(place) {
|
|
104
|
+
if (this.#index < 0) {
|
|
105
|
+
const entry = this.#add(place);
|
|
106
|
+
for (const listener of this.#pushes)
|
|
107
|
+
listener(entry, true);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.#update(place);
|
|
111
|
+
}
|
|
112
|
+
#update(place) {
|
|
113
|
+
const current = this.#entries[this.#index];
|
|
114
|
+
if (current !== undefined)
|
|
115
|
+
this.#entries[this.#index] = { ...place, id: current.id };
|
|
116
|
+
}
|
|
117
|
+
#add(place) {
|
|
118
|
+
const entry = { ...place, id: this.#nextId++ };
|
|
119
|
+
this.#entries.push(entry);
|
|
120
|
+
if (this.#entries.length > this.#max)
|
|
121
|
+
this.#entries.splice(0, this.#entries.length - this.#max);
|
|
122
|
+
this.#index = this.#entries.length - 1;
|
|
123
|
+
return entry;
|
|
124
|
+
}
|
|
125
|
+
#changed() {
|
|
126
|
+
this.#state = {
|
|
127
|
+
current: this.#entries[this.#index],
|
|
128
|
+
back: this.#entries[this.#index - 1],
|
|
129
|
+
forward: this.#entries[this.#index + 1],
|
|
130
|
+
};
|
|
131
|
+
for (const listener of this.#listeners)
|
|
132
|
+
listener();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/history/history.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,+FAA+F;AAC/F,8FAA8F;AAC9F,6FAA6F;AAC7F,+FAA+F;AAC/F,+FAA+F;AAC/F,6EAA6E;AAuC7E,2GAA2G;AAC3G,SAAS,SAAS,CAAC,CAA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,CAAC;YACpC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACxC,CAAC;QACF,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU;YAAE,QAAQ,EAAE,CAAC;IACrD,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
export type { CanvasPoolOptions } from "./canvas/pool.js";
|
|
2
2
|
export type { RestartReason, ViewerCallOptions, ViewerEvent, ViewerEvents, ViewerOptions } from "./client.js";
|
|
3
3
|
export { ViewerClient } from "./client.js";
|
|
4
|
+
export type { FindController, FindResult, FindState } from "./find/controller.js";
|
|
5
|
+
export type { FindOptions } from "./find/fold.js";
|
|
6
|
+
export type { FindSnippet } from "./find/page.js";
|
|
7
|
+
export type { HistoryEntry, HistoryPlace, HistoryState, NavigationHistory, NavigationHistoryOptions, } from "./history/history.js";
|
|
8
|
+
export type { CopyMode } from "./layers/copy.js";
|
|
9
|
+
export type { LinkLayerOptions, LinkWords } from "./layers/link-layer.js";
|
|
10
|
+
export { type ExternalLink, externalLink, type OpenableLink } from "./layers/link-url.js";
|
|
11
|
+
export type { TextLayerOptions, TextSelection } from "./layers/text-layer.js";
|
|
4
12
|
export type { Rotation } from "./layout/page-layout.js";
|
|
5
|
-
export
|
|
6
|
-
export type {
|
|
13
|
+
export { type NetworkSink, watchNetwork } from "./network/watch.js";
|
|
14
|
+
export type { BackendInit, BackendName, FindPageResult, LoadProgress, MethodName, Methods, NetworkRecord, NetworkSource, OpenedDocument, PageTextData, Params, PolicyViolation, PrintedPage, PrintOptions, Priority, ReadingBlock, RemoteSource, RenderedBitmap, Result, SourceInit, StructureData, TextRunData, ViewerOpenOptions, WorkerMemory, WorkerNetworkLog, } from "./protocol.js";
|
|
15
|
+
export { CACHE_FOLDER } from "./source/opfs.js";
|
|
16
|
+
export { ThumbnailStrip, type ThumbnailStripOptions } from "./thumbnails/strip.js";
|
|
17
|
+
export type { CreateViewerOptions, PageLayer, PageRegionOptions, PageRenderState, RenderStats, ViewerEventMap, ViewState, } from "./view/viewer.js";
|
|
7
18
|
export { createViewer, Viewer } from "./view/viewer.js";
|
|
8
19
|
export type { DocumentPoint, Point, Zoom, ZoomMode } from "./zoom/zoom.js";
|
|
9
20
|
export { MAX_ZOOM, MIN_ZOOM } from "./zoom/zoom.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,YAAY,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,OAAO,EACP,cAAc,EACd,MAAM,EACN,QAAQ,EACR,cAAc,EACd,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClF,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,YAAY,EAC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Q,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
// canvas pool, the bitmap cache, the tile and zoom maths) are not exported: the README describes
|
|
4
4
|
// them, and their unit tests import them by path within the package.
|
|
5
5
|
export { ViewerClient } from "./client.js";
|
|
6
|
+
export { externalLink } from "./layers/link-url.js";
|
|
7
|
+
export { watchNetwork } from "./network/watch.js";
|
|
8
|
+
export { CACHE_FOLDER } from "./source/opfs.js";
|
|
9
|
+
export { ThumbnailStrip } from "./thumbnails/strip.js";
|
|
6
10
|
export { createViewer, Viewer } from "./view/viewer.js";
|
|
7
11
|
export { MAX_ZOOM, MIN_ZOOM } from "./zoom/zoom.js";
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,iGAAiG;AACjG,iGAAiG;AACjG,qEAAqE;AAIrE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,iGAAiG;AACjG,iGAAiG;AACjG,qEAAqE;AAIrE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAa3C,OAAO,EAAqB,YAAY,EAAqB,MAAM,sBAAsB,CAAC;AAG1F,OAAO,EAAoB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA4BpE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAA8B,MAAM,uBAAuB,CAAC;AAUnF,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Rotation } from "../layout/page-layout.js";
|
|
2
|
+
/** Sizes `box` in points and places it over a page `size` CSS px at `rotation`. */
|
|
3
|
+
export declare function placeBox(box: HTMLElement, points: {
|
|
4
|
+
readonly width: number;
|
|
5
|
+
readonly height: number;
|
|
6
|
+
}, size: {
|
|
7
|
+
readonly width: number;
|
|
8
|
+
readonly height: number;
|
|
9
|
+
}, rotation: Rotation): void;
|
|
10
|
+
//# sourceMappingURL=box.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/layers/box.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAczD,mFAAmF;AACnF,wBAAgB,QAAQ,CACtB,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC3D,IAAI,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACzD,QAAQ,EAAE,QAAQ,GACjB,IAAI,CAMN"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// A page layer's box: a div sized in page points, scaled and turned by one CSS transform to the
|
|
2
|
+
// page's current size, so what a layer places in points stays over the rendered page at every
|
|
3
|
+
// zoom and rotation. The text and highlight layers share it.
|
|
4
|
+
/** The page's box: its size in points, scaled and turned to `size` (CSS px) at `rotation`. */
|
|
5
|
+
function boxTransform(points, size, rotation) {
|
|
6
|
+
const turned = rotation === 90 || rotation === 270;
|
|
7
|
+
const scale = size.width / (turned ? points.height : points.width);
|
|
8
|
+
const [x, y] = { 0: [0, 0], 90: [size.width, 0], 180: [size.width, size.height], 270: [0, size.height] }[rotation];
|
|
9
|
+
return `translate(${x}px, ${y}px) rotate(${rotation}deg) scale(${scale})`;
|
|
10
|
+
}
|
|
11
|
+
/** Sizes `box` in points and places it over a page `size` CSS px at `rotation`. */
|
|
12
|
+
export function placeBox(box, points, size, rotation) {
|
|
13
|
+
Object.assign(box.style, {
|
|
14
|
+
width: `${points.width}px`,
|
|
15
|
+
height: `${points.height}px`,
|
|
16
|
+
transform: boxTransform(points, size, rotation),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box.js","sourceRoot":"","sources":["../../src/layers/box.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,8FAA8F;AAC9F,6DAA6D;AAI7D,8FAA8F;AAC9F,SAAS,YAAY,CACnB,MAA2D,EAC3D,IAAyD,EACzD,QAAkB;IAElB,MAAM,MAAM,GAAG,QAAQ,KAAK,EAAE,IAAI,QAAQ,KAAK,GAAG,CAAC;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;IACnH,OAAO,aAAa,CAAC,OAAO,CAAC,cAAc,QAAQ,cAAc,KAAK,GAAG,CAAC;AAC5E,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,QAAQ,CACtB,GAAgB,EAChB,MAA2D,EAC3D,IAAyD,EACzD,QAAkB;IAElB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE;QACvB,KAAK,EAAE,GAAG,MAAM,CAAC,KAAK,IAAI;QAC1B,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI;QAC5B,SAAS,EAAE,YAAY,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC;KAChD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReadingBlock } from "../protocol.js";
|
|
2
|
+
import { type Piece } from "./spans.js";
|
|
3
|
+
/** How copy joins a selection: by paragraph (reading order) or as laid out. */
|
|
4
|
+
export type CopyMode = "paragraph" | "exact";
|
|
5
|
+
/** What copy writes to the clipboard. */
|
|
6
|
+
export interface Copied {
|
|
7
|
+
readonly text: string;
|
|
8
|
+
readonly html: string;
|
|
9
|
+
}
|
|
10
|
+
/** `text` with each ligature written as its letters, so the copied words can be searched. */
|
|
11
|
+
export declare function expandLigatures(text: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* The copy of `pieces` (the selection's, in page and run order). `blocks` gives a page's
|
|
14
|
+
* reading-order blocks, or `undefined` when they aren't known (yet): that page's pieces then form
|
|
15
|
+
* one block in run order.
|
|
16
|
+
*/
|
|
17
|
+
export declare function copySelection(pieces: readonly Piece[], mode: CopyMode, blocks: (page: number) => readonly ReadingBlock[] | undefined): Copied;
|
|
18
|
+
/**
|
|
19
|
+
* `lines` as one, by the extraction's own rule (`join_lines` in laminapdf-extract's
|
|
20
|
+
* `text_fix.rs`), so a paragraph copies as `extract()` gives it: joined by a space, except after
|
|
21
|
+
* a soft hyphen or a word-final hyphen. There a lowercase continuation joins the word again (the
|
|
22
|
+
* hyphen dropped), and anything else follows the hyphen with no space ("Jean-" "Paul" gives
|
|
23
|
+
* "Jean-Paul"; a soft hyphen becomes a hyphen). A spaced dash ("a -") is followed by a space.
|
|
24
|
+
*/
|
|
25
|
+
export declare function joinLines(lines: readonly string[]): string;
|
|
26
|
+
//# sourceMappingURL=copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../src/layers/copy.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,KAAK,KAAK,EAAa,MAAM,YAAY,CAAC;AAEnD,+EAA+E;AAC/E,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAC;AAE7C,yCAAyC;AACzC,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAgBD,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAQD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,KAAK,EAAE,EACxB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,YAAY,EAAE,GAAG,SAAS,GAC5D,MAAM,CAWR;AAiFD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAQ1D"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// What copy writes (UI/UX plan §5.3): the selected pieces of the text layer's spans, joined in one
|
|
2
|
+
// of two modes. Copy as paragraph, the default, follows the reading order of Lamina PDF's
|
|
3
|
+
// extraction: the pieces go block by block, a block's lines join into one line (a word broken by
|
|
4
|
+
// a hyphen at a line's end joined again), and blocks are separated by a blank line, so a paragraph
|
|
5
|
+
// pasted from a two-column page reads as one paragraph, column after column. Copy exact keeps the
|
|
6
|
+
// layout's line breaks. Both write the same text as HTML too, a paragraph per block. A table's
|
|
7
|
+
// lines keep their breaks in both modes, since joining them would merge its cells.
|
|
8
|
+
import { separator } from "./spans.js";
|
|
9
|
+
/** U+00AD, which marks where a word may break: written as a code, since it is invisible. */
|
|
10
|
+
const SOFT_HYPHEN = String.fromCharCode(0xad);
|
|
11
|
+
/** The Latin ligatures of Unicode's Alphabetic Presentation Forms, as the letters they join. */
|
|
12
|
+
const LIGATURES = {
|
|
13
|
+
ff: "ff",
|
|
14
|
+
fi: "fi",
|
|
15
|
+
fl: "fl",
|
|
16
|
+
ffi: "ffi",
|
|
17
|
+
ffl: "ffl",
|
|
18
|
+
ſt: "st",
|
|
19
|
+
st: "st",
|
|
20
|
+
};
|
|
21
|
+
/** `text` with each ligature written as its letters, so the copied words can be searched. */
|
|
22
|
+
export function expandLigatures(text) {
|
|
23
|
+
return text.replace(/[ff-st]/g, (c) => LIGATURES[c] ?? c);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The copy of `pieces` (the selection's, in page and run order). `blocks` gives a page's
|
|
27
|
+
* reading-order blocks, or `undefined` when they aren't known (yet): that page's pieces then form
|
|
28
|
+
* one block in run order.
|
|
29
|
+
*/
|
|
30
|
+
export function copySelection(pieces, mode, blocks) {
|
|
31
|
+
const groups = mode === "paragraph" ? byBlock(pieces, blocks) : byPage(pieces);
|
|
32
|
+
const paragraphs = groups
|
|
33
|
+
.map((group) => {
|
|
34
|
+
const lines = linesOf(group.pieces);
|
|
35
|
+
return mode === "exact" || group.table ? lines.map((l) => l.replaceAll(SOFT_HYPHEN, "")) : [joinLines(lines)];
|
|
36
|
+
})
|
|
37
|
+
.filter((lines) => lines.some((l) => l !== ""));
|
|
38
|
+
const text = paragraphs.map((lines) => lines.join("\n")).join(mode === "paragraph" ? "\n\n" : "\n");
|
|
39
|
+
const html = paragraphs.map((lines) => `<p>${lines.map(escapeHtml).join("<br>")}</p>`).join("");
|
|
40
|
+
return { text, html };
|
|
41
|
+
}
|
|
42
|
+
/** The pieces page by page, in run order (copy exact). */
|
|
43
|
+
function byPage(pieces) {
|
|
44
|
+
const groups = [];
|
|
45
|
+
for (const piece of pieces) {
|
|
46
|
+
const last = groups.at(-1);
|
|
47
|
+
if (last !== undefined && last.pieces[0]?.page === piece.page)
|
|
48
|
+
last.pieces.push(piece);
|
|
49
|
+
else
|
|
50
|
+
groups.push({ pieces: [piece], table: false });
|
|
51
|
+
}
|
|
52
|
+
return groups;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The pieces block by block, in the page's reading order: each piece goes to the block its span's
|
|
56
|
+
* centre is in, or the nearest one; within a block they keep their run order.
|
|
57
|
+
*/
|
|
58
|
+
function byBlock(pieces, blocks) {
|
|
59
|
+
const keyed = new Map();
|
|
60
|
+
pieces.forEach((piece, k) => {
|
|
61
|
+
const found = blocks(piece.page);
|
|
62
|
+
const index = found === undefined || found.length === 0 ? -1 : nearest(found, centreOf(piece));
|
|
63
|
+
const key = `${piece.page}:${index}`;
|
|
64
|
+
let entry = keyed.get(key);
|
|
65
|
+
if (entry === undefined) {
|
|
66
|
+
// A page without blocks keeps its place by its first piece; a block, by its reading order.
|
|
67
|
+
const order = index === -1 ? k : index;
|
|
68
|
+
entry = { page: piece.page, order, group: { pieces: [], table: found?.[index]?.type === "table" } };
|
|
69
|
+
keyed.set(key, entry);
|
|
70
|
+
}
|
|
71
|
+
entry.group.pieces.push(piece);
|
|
72
|
+
});
|
|
73
|
+
return [...keyed.values()].sort((a, b) => a.page - b.page || a.order - b.order).map((e) => e.group);
|
|
74
|
+
}
|
|
75
|
+
/** The centre of `piece`'s span, in page space. */
|
|
76
|
+
function centreOf(piece) {
|
|
77
|
+
const { left, top, width, height, angle } = piece.span;
|
|
78
|
+
const along = { x: Math.cos(angle), y: Math.sin(angle) };
|
|
79
|
+
const down = { x: -along.y, y: along.x };
|
|
80
|
+
return {
|
|
81
|
+
x: left + (along.x * width) / 2 + (down.x * height) / 2,
|
|
82
|
+
y: top + (along.y * width) / 2 + (down.y * height) / 2,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** The index of the block whose box holds `p`, or else the one nearest it. */
|
|
86
|
+
function nearest(blocks, p) {
|
|
87
|
+
let best = 0;
|
|
88
|
+
let bestDistance = Infinity;
|
|
89
|
+
blocks.forEach((block, k) => {
|
|
90
|
+
const [x, y, w, h] = block.bbox;
|
|
91
|
+
const dx = Math.max(x - p.x, 0, p.x - (x + w));
|
|
92
|
+
const dy = Math.max(y - p.y, 0, p.y - (y + h));
|
|
93
|
+
const distance = Math.hypot(dx, dy);
|
|
94
|
+
if (distance < bestDistance) {
|
|
95
|
+
best = k;
|
|
96
|
+
bestDistance = distance;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return best;
|
|
100
|
+
}
|
|
101
|
+
/** `pieces` as the lines they are laid out on (the text layer's rule: `separator`). */
|
|
102
|
+
function linesOf(pieces) {
|
|
103
|
+
const lines = [];
|
|
104
|
+
let line = "";
|
|
105
|
+
let before;
|
|
106
|
+
for (const piece of pieces) {
|
|
107
|
+
const gap = before === undefined ? "" : separator(before, piece);
|
|
108
|
+
if (gap === "\n") {
|
|
109
|
+
lines.push(line);
|
|
110
|
+
line = "";
|
|
111
|
+
}
|
|
112
|
+
else
|
|
113
|
+
line += gap;
|
|
114
|
+
line += piece.text;
|
|
115
|
+
before = piece;
|
|
116
|
+
}
|
|
117
|
+
lines.push(line);
|
|
118
|
+
return lines.map((l) => expandLigatures(l).trimEnd());
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* `lines` as one, by the extraction's own rule (`join_lines` in laminapdf-extract's
|
|
122
|
+
* `text_fix.rs`), so a paragraph copies as `extract()` gives it: joined by a space, except after
|
|
123
|
+
* a soft hyphen or a word-final hyphen. There a lowercase continuation joins the word again (the
|
|
124
|
+
* hyphen dropped), and anything else follows the hyphen with no space ("Jean-" "Paul" gives
|
|
125
|
+
* "Jean-Paul"; a soft hyphen becomes a hyphen). A spaced dash ("a -") is followed by a space.
|
|
126
|
+
*/
|
|
127
|
+
export function joinLines(lines) {
|
|
128
|
+
let out = "";
|
|
129
|
+
for (const raw of lines) {
|
|
130
|
+
const line = raw.trim();
|
|
131
|
+
if (line === "")
|
|
132
|
+
continue;
|
|
133
|
+
out = out === "" ? line : joinTwo(out, line);
|
|
134
|
+
}
|
|
135
|
+
return out.replaceAll(SOFT_HYPHEN, "");
|
|
136
|
+
}
|
|
137
|
+
/** `out` followed by the next `line`, by `joinLines`' rule. */
|
|
138
|
+
function joinTwo(out, line) {
|
|
139
|
+
const lowerNext = /^\p{Ll}/u.test(line);
|
|
140
|
+
if (out.endsWith(SOFT_HYPHEN))
|
|
141
|
+
return out.slice(0, -1) + (lowerNext ? "" : "-") + line;
|
|
142
|
+
if (out.endsWith("-") && !out.endsWith(" -"))
|
|
143
|
+
return (lowerNext ? out.slice(0, -1) : out) + line;
|
|
144
|
+
return `${out} ${line}`;
|
|
145
|
+
}
|
|
146
|
+
/** `text` safe in HTML. */
|
|
147
|
+
function escapeHtml(text) {
|
|
148
|
+
return text.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c] ?? c);
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.js","sourceRoot":"","sources":["../../src/layers/copy.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,0FAA0F;AAC1F,iGAAiG;AACjG,mGAAmG;AACnG,kGAAkG;AAClG,+FAA+F;AAC/F,mFAAmF;AAGnF,OAAO,EAAc,SAAS,EAAE,MAAM,YAAY,CAAC;AAWnD,4FAA4F;AAC5F,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAE9C,gGAAgG;AAChG,MAAM,SAAS,GAAqC;IAClD,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI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,CAAC;AAED,+DAA+D;AAC/D,SAAS,OAAO,CAAC,GAAW,EAAE,IAAY;IACxC,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACvF,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACjG,OAAO,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;AAC1B,CAAC;AAED,2BAA2B;AAC3B,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7G,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Rotation } from "../layout/page-layout.js";
|
|
2
|
+
import type { PageLayer } from "../view/viewer.js";
|
|
3
|
+
/** What the highlight layer reads of the find controller and the viewer. */
|
|
4
|
+
export interface HighlightHost {
|
|
5
|
+
/** Page `page`'s matches (quads, 8 numbers per run) and which one is current, if any. */
|
|
6
|
+
matchesOn(page: number): {
|
|
7
|
+
readonly matches: readonly (readonly number[])[];
|
|
8
|
+
readonly current: number | undefined;
|
|
9
|
+
};
|
|
10
|
+
/** Page `page`'s displayed size in points. */
|
|
11
|
+
points(page: number): {
|
|
12
|
+
readonly width: number;
|
|
13
|
+
readonly height: number;
|
|
14
|
+
} | undefined;
|
|
15
|
+
rotation(): Rotation;
|
|
16
|
+
}
|
|
17
|
+
/** The find highlights of one viewer. */
|
|
18
|
+
export declare class HighlightLayer implements PageLayer {
|
|
19
|
+
#private;
|
|
20
|
+
readonly name = "highlight";
|
|
21
|
+
constructor(host: HighlightHost);
|
|
22
|
+
onMount(page: number, slot: HTMLElement): void;
|
|
23
|
+
onUnmount(page: number): void;
|
|
24
|
+
onZoom(page: number, _slot: HTMLElement, size: {
|
|
25
|
+
readonly width: number;
|
|
26
|
+
readonly height: number;
|
|
27
|
+
}): void;
|
|
28
|
+
/** Draws the pages again: matches arrived or went, the current one moved, or the view turned. */
|
|
29
|
+
refresh(pages?: Iterable<number>): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=highlight-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight-layer.d.ts","sourceRoot":"","sources":["../../src/layers/highlight-layer.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,yFAAyF;IACzF,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IACpH,8CAA8C;IAC9C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAA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