@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.
Files changed (149) hide show
  1. package/README.md +102 -8
  2. package/dist/client.d.ts +75 -2
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +192 -32
  5. package/dist/client.js.map +1 -1
  6. package/dist/find/controller.d.ts +73 -0
  7. package/dist/find/controller.d.ts.map +1 -0
  8. package/dist/find/controller.js +227 -0
  9. package/dist/find/controller.js.map +1 -0
  10. package/dist/find/fold.d.ts +23 -0
  11. package/dist/find/fold.d.ts.map +1 -0
  12. package/dist/find/fold.js +99 -0
  13. package/dist/find/fold.js.map +1 -0
  14. package/dist/find/page.d.ts +44 -0
  15. package/dist/find/page.d.ts.map +1 -0
  16. package/dist/find/page.js +173 -0
  17. package/dist/find/page.js.map +1 -0
  18. package/dist/first-draw.d.ts +10 -0
  19. package/dist/first-draw.d.ts.map +1 -0
  20. package/dist/first-draw.js +33 -0
  21. package/dist/first-draw.js.map +1 -0
  22. package/dist/history/history.d.ts +65 -0
  23. package/dist/history/history.d.ts.map +1 -0
  24. package/dist/history/history.js +135 -0
  25. package/dist/history/history.js.map +1 -0
  26. package/dist/index.d.ts +13 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +4 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/layers/box.d.ts +10 -0
  31. package/dist/layers/box.d.ts.map +1 -0
  32. package/dist/layers/box.js +19 -0
  33. package/dist/layers/box.js.map +1 -0
  34. package/dist/layers/copy.d.ts +26 -0
  35. package/dist/layers/copy.d.ts.map +1 -0
  36. package/dist/layers/copy.js +150 -0
  37. package/dist/layers/copy.js.map +1 -0
  38. package/dist/layers/highlight-layer.d.ts +31 -0
  39. package/dist/layers/highlight-layer.d.ts.map +1 -0
  40. package/dist/layers/highlight-layer.js +95 -0
  41. package/dist/layers/highlight-layer.js.map +1 -0
  42. package/dist/layers/link-layer.d.ts +68 -0
  43. package/dist/layers/link-layer.d.ts.map +1 -0
  44. package/dist/layers/link-layer.js +279 -0
  45. package/dist/layers/link-layer.js.map +1 -0
  46. package/dist/layers/link-url.d.ts +19 -0
  47. package/dist/layers/link-url.d.ts.map +1 -0
  48. package/dist/layers/link-url.js +47 -0
  49. package/dist/layers/link-url.js.map +1 -0
  50. package/dist/layers/spans.d.ts +36 -0
  51. package/dist/layers/spans.d.ts.map +1 -0
  52. package/dist/layers/spans.js +103 -0
  53. package/dist/layers/spans.js.map +1 -0
  54. package/dist/layers/structure-layer.d.ts +15 -0
  55. package/dist/layers/structure-layer.d.ts.map +1 -0
  56. package/dist/layers/structure-layer.js +155 -0
  57. package/dist/layers/structure-layer.js.map +1 -0
  58. package/dist/layers/text-layer.d.ts +70 -0
  59. package/dist/layers/text-layer.d.ts.map +1 -0
  60. package/dist/layers/text-layer.js +576 -0
  61. package/dist/layers/text-layer.js.map +1 -0
  62. package/dist/layout/range.d.ts +3 -0
  63. package/dist/layout/range.d.ts.map +1 -0
  64. package/dist/layout/range.js +5 -0
  65. package/dist/layout/range.js.map +1 -0
  66. package/dist/network/watch.d.ts +30 -0
  67. package/dist/network/watch.d.ts.map +1 -0
  68. package/dist/network/watch.js +181 -0
  69. package/dist/network/watch.js.map +1 -0
  70. package/dist/protocol.d.ts +193 -6
  71. package/dist/protocol.d.ts.map +1 -1
  72. package/dist/protocol.js +16 -4
  73. package/dist/protocol.js.map +1 -1
  74. package/dist/render/tiles.d.ts +43 -3
  75. package/dist/render/tiles.d.ts.map +1 -1
  76. package/dist/render/tiles.js +62 -10
  77. package/dist/render/tiles.js.map +1 -1
  78. package/dist/source/http-range.d.ts +59 -0
  79. package/dist/source/http-range.d.ts.map +1 -0
  80. package/dist/source/http-range.js +284 -0
  81. package/dist/source/http-range.js.map +1 -0
  82. package/dist/source/opfs.d.ts +35 -0
  83. package/dist/source/opfs.d.ts.map +1 -0
  84. package/dist/source/opfs.js +178 -0
  85. package/dist/source/opfs.js.map +1 -0
  86. package/dist/thumbnails/strip.d.ts +37 -0
  87. package/dist/thumbnails/strip.d.ts.map +1 -0
  88. package/dist/thumbnails/strip.js +324 -0
  89. package/dist/thumbnails/strip.js.map +1 -0
  90. package/dist/view/budgets.d.ts +29 -0
  91. package/dist/view/budgets.d.ts.map +1 -0
  92. package/dist/view/budgets.js +63 -0
  93. package/dist/view/budgets.js.map +1 -0
  94. package/dist/view/touch.d.ts +71 -0
  95. package/dist/view/touch.d.ts.map +1 -0
  96. package/dist/view/touch.js +220 -0
  97. package/dist/view/touch.js.map +1 -0
  98. package/dist/view/user-select.d.ts +3 -0
  99. package/dist/view/user-select.d.ts.map +1 -0
  100. package/dist/view/user-select.js +10 -0
  101. package/dist/view/user-select.js.map +1 -0
  102. package/dist/view/viewer.d.ts +102 -1
  103. package/dist/view/viewer.d.ts.map +1 -1
  104. package/dist/view/viewer.js +660 -95
  105. package/dist/view/viewer.js.map +1 -1
  106. package/dist/worker/document.d.ts +53 -1
  107. package/dist/worker/document.d.ts.map +1 -1
  108. package/dist/worker/document.js +222 -24
  109. package/dist/worker/document.js.map +1 -1
  110. package/dist/worker/entry.d.ts +1 -1
  111. package/dist/worker/entry.d.ts.map +1 -1
  112. package/dist/worker/entry.js +2 -0
  113. package/dist/worker/entry.js.map +1 -1
  114. package/dist/worker/find.d.ts +7 -0
  115. package/dist/worker/find.d.ts.map +1 -0
  116. package/dist/worker/find.js +46 -0
  117. package/dist/worker/find.js.map +1 -0
  118. package/dist/worker/methods.d.ts.map +1 -1
  119. package/dist/worker/methods.js +49 -4
  120. package/dist/worker/methods.js.map +1 -1
  121. package/dist/worker/navigation.d.ts +10 -0
  122. package/dist/worker/navigation.d.ts.map +1 -0
  123. package/dist/worker/navigation.js +34 -0
  124. package/dist/worker/navigation.js.map +1 -0
  125. package/dist/worker/network.d.ts +4 -0
  126. package/dist/worker/network.d.ts.map +1 -0
  127. package/dist/worker/network.js +24 -0
  128. package/dist/worker/network.js.map +1 -0
  129. package/dist/worker/print.d.ts +14 -0
  130. package/dist/worker/print.d.ts.map +1 -0
  131. package/dist/worker/print.js +49 -0
  132. package/dist/worker/print.js.map +1 -0
  133. package/dist/worker/recent-pages.d.ts +14 -0
  134. package/dist/worker/recent-pages.d.ts.map +1 -0
  135. package/dist/worker/recent-pages.js +53 -0
  136. package/dist/worker/recent-pages.js.map +1 -0
  137. package/dist/worker/render.d.ts +5 -2
  138. package/dist/worker/render.d.ts.map +1 -1
  139. package/dist/worker/render.js +16 -6
  140. package/dist/worker/render.js.map +1 -1
  141. package/dist/worker/text.d.ts +25 -0
  142. package/dist/worker/text.d.ts.map +1 -0
  143. package/dist/worker/text.js +82 -0
  144. package/dist/worker/text.js.map +1 -0
  145. package/dist/zoom/destination.d.ts +18 -0
  146. package/dist/zoom/destination.d.ts.map +1 -0
  147. package/dist/zoom/destination.js +56 -0
  148. package/dist/zoom/destination.js.map +1 -0
  149. package/package.json +6 -5
@@ -0,0 +1,30 @@
1
+ import type { NetworkRecord, NetworkSource, PolicyViolation } from "../protocol.js";
2
+ /** What `watchNetwork` reports to. */
3
+ export interface NetworkSink {
4
+ /** A request was made: called when it starts, failed or not, or when its timing entry arrives. */
5
+ request(record: NetworkRecord): void;
6
+ /** The scope's Content Security Policy blocked a request, so nothing was sent. */
7
+ violation(violation: PolicyViolation): void;
8
+ }
9
+ /** The global scope parts the watcher wraps and reads (a Window or a WorkerGlobalScope). */
10
+ type Scope = typeof globalThis & {
11
+ XMLHttpRequest?: typeof XMLHttpRequest;
12
+ WebSocket?: typeof WebSocket;
13
+ PerformanceObserver?: typeof PerformanceObserver;
14
+ location?: {
15
+ href: string;
16
+ };
17
+ navigator?: Navigator & {
18
+ sendBeacon?: Navigator["sendBeacon"];
19
+ };
20
+ addEventListener?: (type: string, listener: (event: Event) => void) => void;
21
+ removeEventListener?: (type: string, listener: (event: Event) => void) => void;
22
+ };
23
+ /**
24
+ * Starts reporting every request `scope` makes to `sink`, as `source`. Returns the function that
25
+ * stops it: the scope's own `fetch`, `XMLHttpRequest`, `WebSocket` and `sendBeacon` put back, the
26
+ * observers disconnected and the violation listener removed.
27
+ */
28
+ export declare function watchNetwork(scope: Scope, sink: NetworkSink, source: NetworkSource): () => void;
29
+ export {};
30
+ //# sourceMappingURL=watch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/network/watch.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQpF,sCAAsC;AACtC,MAAM,WAAW,WAAW;IAC1B,kGAAkG;IAClG,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,kFAAkF;IAClF,SAAS,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;CAC7C;AAED,4FAA4F;AAC5F,KAAK,KAAK,GAAG,OAAO,UAAU,GAAG;IAC/B,cAAc,CAAC,EAAE,OAAO,cAAc,CAAC;IACvC,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,mBAAmB,CAAC;IACjD,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5B,SAAS,CAAC,EAAE,SAAS,GAAG;QAAE,UAAU,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,CAAA;KAAE,CAAC;IACjE,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;IAC5E,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;CAChF,CAAC;AAkBF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,IAAI,CAwC/F"}
@@ -0,0 +1,181 @@
1
+ // Every network request a JavaScript context makes, reported as it happens: the page's and the
2
+ // document worker's (ADR 0011's privacy guarantees, R13's network panel). A context can request
3
+ // in two ways that leave different traces, so the watcher uses both:
4
+ //
5
+ // - calls the page's or the worker's code makes (`fetch`, `XMLHttpRequest`, `WebSocket`,
6
+ // `navigator.sendBeacon`) are wrapped, so each is reported when it starts, failed or not, and a
7
+ // WebSocket, which leaves no timing entry, is counted too;
8
+ // - everything the browser loads by itself (scripts, module imports, styles, fonts, images, the
9
+ // page) is read from the Resource Timing entries, whose `initiatorType` tells them apart from
10
+ // the wrapped calls, so nothing is counted twice.
11
+ //
12
+ // Installed before any other code of the context runs, so no code path can capture an unwrapped
13
+ // `fetch` first. A request the context never makes (a browser extension's) is out of its sight.
14
+ /** The entries a wrapped call also leaves in Resource Timing, read from the call instead. */
15
+ const WRAPPED_INITIATORS = new Set(["fetch", "xmlhttprequest", "beacon"]);
16
+ /** The `blockedURI`s of violations that block no request (CSP3 §5.3's keywords for them). */
17
+ const NOT_REQUESTS = new Set(["", "inline", "eval", "wasm-eval", "trusted-types-policy", "trusted-types-sink"]);
18
+ /** `input`'s absolute URL, against the scope's address. */
19
+ function urlOf(input, base) {
20
+ const raw = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
21
+ try {
22
+ return new URL(raw, base).href;
23
+ }
24
+ catch {
25
+ return raw;
26
+ }
27
+ }
28
+ /** A `Content-Length` header's bytes, or 0 when there is none or it isn't a number. */
29
+ function lengthOf(header) {
30
+ const length = Number(header);
31
+ return Number.isFinite(length) && length > 0 ? length : 0;
32
+ }
33
+ /**
34
+ * Starts reporting every request `scope` makes to `sink`, as `source`. Returns the function that
35
+ * stops it: the scope's own `fetch`, `XMLHttpRequest`, `WebSocket` and `sendBeacon` put back, the
36
+ * observers disconnected and the violation listener removed.
37
+ */
38
+ export function watchNetwork(scope, sink, source) {
39
+ const base = scope.location?.href;
40
+ const report = (record, at = Date.now()) => sink.request({ ...record, source, at });
41
+ const restore = [];
42
+ const originalFetch = scope.fetch;
43
+ if (typeof originalFetch === "function") {
44
+ scope.fetch = async (input, init) => {
45
+ const url = urlOf(input, base);
46
+ const method = (init?.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
47
+ // Stamped when the call starts: a request belongs to the file that was opening then.
48
+ const at = Date.now();
49
+ try {
50
+ const response = await originalFetch.call(scope, input, init);
51
+ const bytes = lengthOf(response.headers.get("Content-Length"));
52
+ report({ url, method, initiator: "fetch", bytes, failed: false }, at);
53
+ return response;
54
+ }
55
+ catch (e) {
56
+ report({ url, method, initiator: "fetch", bytes: 0, failed: true }, at);
57
+ throw e;
58
+ }
59
+ };
60
+ restore.push(() => {
61
+ scope.fetch = originalFetch;
62
+ });
63
+ }
64
+ restore.push(...wrapXhr(scope, base, report), ...wrapWebSocket(scope, base, report));
65
+ restore.push(...wrapBeacon(scope, base, report), ...observeResources(scope, report));
66
+ const onViolation = (event) => {
67
+ const e = event;
68
+ // Inline code, eval and Trusted Types violations block no request: only a blocked URL is one.
69
+ if (NOT_REQUESTS.has(e.blockedURI))
70
+ return;
71
+ sink.violation({ directive: e.effectiveDirective, blockedUri: e.blockedURI, source, at: Date.now() });
72
+ };
73
+ scope.addEventListener?.("securitypolicyviolation", onViolation);
74
+ restore.push(() => scope.removeEventListener?.("securitypolicyviolation", onViolation));
75
+ return () => {
76
+ for (const undo of restore)
77
+ undo();
78
+ };
79
+ }
80
+ /** `XMLHttpRequest`: the method and URL from `open`, reported once the request ends. */
81
+ function wrapXhr(scope, base, report) {
82
+ const Xhr = scope.XMLHttpRequest;
83
+ if (Xhr === undefined)
84
+ return [];
85
+ const { open, send } = Xhr.prototype;
86
+ const seen = new WeakMap();
87
+ Xhr.prototype.open = function (method, url, ...rest) {
88
+ seen.set(this, { method: method.toUpperCase(), url: urlOf(url, base) });
89
+ return open.call(this, method, url, ...rest);
90
+ };
91
+ Xhr.prototype.send = function (body) {
92
+ const call = seen.get(this);
93
+ if (call !== undefined) {
94
+ const at = Date.now();
95
+ this.addEventListener("loadend", () => {
96
+ const bytes = lengthOf(this.getResponseHeader("Content-Length"));
97
+ report({ ...call, initiator: "xmlhttprequest", bytes, failed: this.status === 0 }, at);
98
+ });
99
+ }
100
+ return send.call(this, body);
101
+ };
102
+ return [
103
+ () => {
104
+ Xhr.prototype.open = open;
105
+ Xhr.prototype.send = send;
106
+ },
107
+ ];
108
+ }
109
+ /** `WebSocket`: each connection attempt, which Resource Timing never lists. */
110
+ function wrapWebSocket(scope, base, report) {
111
+ const Socket = scope.WebSocket;
112
+ if (Socket === undefined)
113
+ return [];
114
+ const Wrapped = new Proxy(Socket, {
115
+ construct(target, args) {
116
+ report({ url: urlOf(args[0], base), method: "GET", initiator: "websocket", bytes: 0, failed: false });
117
+ return Reflect.construct(target, args);
118
+ },
119
+ });
120
+ scope.WebSocket = Wrapped;
121
+ return [
122
+ () => {
123
+ scope.WebSocket = Socket;
124
+ },
125
+ ];
126
+ }
127
+ /** `navigator.sendBeacon` (the page only): each beacon, sent or refused. */
128
+ function wrapBeacon(scope, base, report) {
129
+ const nav = scope.navigator;
130
+ const beacon = nav?.sendBeacon;
131
+ if (nav === undefined || typeof beacon !== "function")
132
+ return [];
133
+ nav.sendBeacon = (url, data) => {
134
+ const sent = beacon.call(nav, url, data);
135
+ report({ url: urlOf(url, base), method: "POST", initiator: "beacon", bytes: 0, failed: !sent });
136
+ return sent;
137
+ };
138
+ return [
139
+ () => {
140
+ nav.sendBeacon = beacon;
141
+ },
142
+ ];
143
+ }
144
+ /** What the browser loaded by itself: Resource Timing entries (and the page's own load), buffered. */
145
+ function observeResources(scope, report) {
146
+ const Observer = scope.PerformanceObserver;
147
+ if (Observer === undefined)
148
+ return [];
149
+ const types = new Set(Observer.supportedEntryTypes ?? []);
150
+ // A document navigates once, but Chromium reports its navigation entry again when the load ends.
151
+ let navigated = false;
152
+ const take = (entry) => {
153
+ if (entry.entryType === "navigation") {
154
+ if (navigated)
155
+ return;
156
+ navigated = true;
157
+ }
158
+ const timing = entry;
159
+ if (WRAPPED_INITIATORS.has(timing.initiatorType))
160
+ return;
161
+ if (!/^https?:/.test(timing.name))
162
+ return;
163
+ const bytes = timing.transferSize || timing.encodedBodySize || 0;
164
+ // When the request started, not when the observer heard of it: a buffered entry comes late.
165
+ const at = Math.round((scope.performance?.timeOrigin ?? Date.now()) + entry.startTime);
166
+ report({ url: timing.name, method: "GET", initiator: timing.initiatorType || entry.entryType, bytes, failed: false }, at);
167
+ };
168
+ const observers = [];
169
+ for (const type of ["navigation", "resource"]) {
170
+ if (!types.has(type))
171
+ continue;
172
+ const observer = new Observer((list) => {
173
+ for (const entry of list.getEntries())
174
+ take(entry);
175
+ });
176
+ observer.observe({ type, buffered: true });
177
+ observers.push(observer);
178
+ }
179
+ return observers.map((observer) => () => observer.disconnect());
180
+ }
181
+ //# sourceMappingURL=watch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/network/watch.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,gGAAgG;AAChG,qEAAqE;AACrE,EAAE;AACF,yFAAyF;AACzF,kGAAkG;AAClG,6DAA6D;AAC7D,gGAAgG;AAChG,gGAAgG;AAChG,oDAAoD;AACpD,EAAE;AACF,gGAAgG;AAChG,gGAAgG;AAIhG,6FAA6F;AAC7F,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1E,6FAA6F;AAC7F,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,oBAAoB,CAAC,CAAC,CAAC;AAqBhH,2DAA2D;AAC3D,SAAS,KAAK,CAAC,KAAiC,EAAE,IAAwB;IACxE,MA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E,SAAS;QAC/B,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE;YACrC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,UAAU,EAAE;gBAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QACH,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3C,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;AAClE,CAAC"}
@@ -1,5 +1,7 @@
1
- import { type CloneableWasmSource, type RenderLimits, type RenderRequest } from "@laminapdf/render";
2
- import type { Limits, PageInfo } from "@laminapdf/sdk";
1
+ import { type CloneableWasmSource, type PageAppearance, type RenderLimits, type RenderRequest } from "@laminapdf/render";
2
+ import type { DocumentProperties, Limits, OutlineNode, PageInfo, PageLink, Reflow, StructureNode, Target } from "@laminapdf/sdk";
3
+ import type { FindOptions } from "./find/fold.js";
4
+ import type { FindSnippet } from "./find/page.js";
3
5
  /** Which engine draws the pages (ADR 0004: PDFium by default, hayro the CI oracle). */
4
6
  export type BackendName = "pdfium" | "hayro";
5
7
  /** What the worker loads a backend from. */
@@ -8,8 +10,15 @@ export interface BackendInit {
8
10
  /** The engine's `.wasm`: required for PDFium (its URL from your bundler); hayro finds its own. */
9
11
  readonly wasm?: CloneableWasmSource;
10
12
  }
13
+ /**
14
+ * A remote file the worker fetches itself, with HTTP Range requests (`HttpRangeByteSource`): its
15
+ * bytes never pass through the page.
16
+ */
17
+ export interface RemoteSource {
18
+ readonly url: string;
19
+ }
11
20
  /** What a document is opened from: sent to the worker, which reads it there. */
12
- export type SourceInit = Blob | ArrayBuffer | Uint8Array;
21
+ export type SourceInit = Blob | ArrayBuffer | Uint8Array | RemoteSource;
13
22
  /** `open`'s options. The password crosses to the worker once and is kept only there. */
14
23
  export interface ViewerOpenOptions {
15
24
  readonly password?: string;
@@ -17,6 +26,13 @@ export interface ViewerOpenOptions {
17
26
  readonly limits?: Partial<Limits>;
18
27
  /** The backend's render limits (ADR 0004). */
19
28
  readonly renderLimits?: Partial<RenderLimits>;
29
+ /**
30
+ * A local file larger than this many bytes is copied into the origin-private file system and
31
+ * read from there, not held in memory (default 200 MiB; tests lower it).
32
+ */
33
+ readonly copyAbove?: number;
34
+ /** Keep that copy once the document closes, for next time (default true); false removes it then. */
35
+ readonly keepCopy?: boolean;
20
36
  }
21
37
  /** An open document, as layout needs it up front. */
22
38
  export interface OpenedDocument {
@@ -31,6 +47,8 @@ export interface OpenedDocument {
31
47
  readonly name: BackendName;
32
48
  readonly version: string;
33
49
  };
50
+ /** The title in the file's metadata, for the window's title; absent when the file has none. */
51
+ readonly title?: string;
34
52
  }
35
53
  /** A rendered tile on the page: an ImageBitmap transferred from the worker. Close it when done. */
36
54
  export interface RenderedBitmap {
@@ -55,10 +73,19 @@ export interface Methods {
55
73
  version: string;
56
74
  };
57
75
  };
76
+ /** `ticket`: the page's number for this open, which `currentDocument` gives back. */
58
77
  openDocument: {
59
- params: [source: SourceInit, options: ViewerOpenOptions];
78
+ params: [source: SourceInit, options: ViewerOpenOptions, ticket?: number];
60
79
  result: OpenedDocument;
61
80
  };
81
+ /** The open document's answer and its open's ticket; asked after a cancelled open. */
82
+ currentDocument: {
83
+ params: [];
84
+ result: {
85
+ readonly document: OpenedDocument;
86
+ readonly ticket: number | undefined;
87
+ } | undefined;
88
+ };
62
89
  closeDocument: {
63
90
  params: [];
64
91
  result: undefined;
@@ -75,6 +102,160 @@ export interface Methods {
75
102
  params: [];
76
103
  result: WorkerMemory;
77
104
  };
105
+ pageText: {
106
+ params: [index: number];
107
+ result: PageTextData;
108
+ };
109
+ structure: {
110
+ params: [];
111
+ result: StructureData;
112
+ };
113
+ reflow: {
114
+ params: [];
115
+ result: Reflow;
116
+ };
117
+ networkLog: {
118
+ params: [];
119
+ result: WorkerNetworkLog;
120
+ };
121
+ outline: {
122
+ params: [];
123
+ result: OutlineNode[];
124
+ };
125
+ namedDestination: {
126
+ params: [name: string];
127
+ result: Target | undefined;
128
+ };
129
+ pageLinks: {
130
+ params: [index: number];
131
+ result: readonly PageLink[];
132
+ };
133
+ properties: {
134
+ params: [];
135
+ result: DocumentProperties;
136
+ };
137
+ printPage: {
138
+ params: [index: number, options: PrintOptions];
139
+ result: PrintedPage;
140
+ };
141
+ fileBytes: {
142
+ params: [];
143
+ result: Uint8Array;
144
+ };
145
+ find: {
146
+ params: [query: string, options: FindOptions, pages: readonly number[]];
147
+ result: FindPageResult[];
148
+ };
149
+ readingOrder: {
150
+ params: [index: number];
151
+ result: ReadingBlock[];
152
+ };
153
+ }
154
+ /**
155
+ * One block of a page's text in reading order, as Lamina PDF's extraction finds it (ADR 0030):
156
+ * where it is, in page space (points from the displayed page's top-left, y down), and what kind
157
+ * of block it is. Copy as paragraph joins the selected text block by block in this order.
158
+ */
159
+ export interface ReadingBlock {
160
+ /** Its box: `[x, y, width, height]`. */
161
+ readonly bbox: readonly [number, number, number, number];
162
+ /** `paragraph`, `heading`, `list-item`, `caption`, `footnote`, `table` or `other`. */
163
+ readonly type: string;
164
+ }
165
+ /** How a page is drawn for printing. */
166
+ export interface PrintOptions {
167
+ /** Dots per inch: 150 (standard) or 300 (high). Lowered for a page too large to hold. */
168
+ readonly dpi: number;
169
+ /** Draw annotations as their print flags say (comments, highlights, stamps); off leaves them out. */
170
+ readonly annotations: boolean;
171
+ }
172
+ /** One page drawn for printing. */
173
+ export interface PrintedPage {
174
+ /** The page as a PNG. */
175
+ readonly image: Blob;
176
+ /** Its displayed size in points (`/Rotate` applied), which the printed page takes. */
177
+ readonly width: number;
178
+ readonly height: number;
179
+ /** The resolution it was drawn at: below the one asked for when the page was too large. */
180
+ readonly dpi: number;
181
+ }
182
+ /** One page's find results: each match as its quads (8 numbers per run it touches), in page space. */
183
+ export interface FindPageResult {
184
+ readonly page: number;
185
+ readonly matches: readonly (readonly number[])[];
186
+ /** Each match in its line, in the same order. */
187
+ readonly snippets: readonly FindSnippet[];
188
+ /** The page has no text to search (a scan without an OCR layer). */
189
+ readonly noText?: true;
190
+ }
191
+ /** One text run of a page: glyphs of one font, size and direction on one baseline, in logical order. */
192
+ export interface TextRunData {
193
+ /** Its text in logical order (document text; an `/ActualText` replacement when `actualText`). */
194
+ readonly text: string;
195
+ /** Font size in points, the text matrix applied. */
196
+ readonly size: number;
197
+ /** Vertical writing. */
198
+ readonly vertical: boolean;
199
+ /** The text replaces its glyphs (`/ActualText`). */
200
+ readonly actualText: boolean;
201
+ /** Drawn invisibly (`Tr` 3 or 7: an OCR layer, hidden text); selectable all the same. */
202
+ readonly invisible: boolean;
203
+ /** Its glyphs: `[start, end)` into `quads` (8 numbers each), as the SDK's `PageTextRun.glyphRange`. */
204
+ readonly glyphRange: readonly [number, number];
205
+ /** The marked-content ID it is in, which links it to the structure tree. */
206
+ readonly mcid?: number;
207
+ }
208
+ /**
209
+ * A page's text: its runs, and every glyph's quad as 8 numbers (bottom-left, bottom-right,
210
+ * top-right, top-left, each `x, y`) in page space (ADR 0027: points from the displayed page's
211
+ * top-left, y down).
212
+ */
213
+ export interface PageTextData {
214
+ readonly runs: readonly TextRunData[];
215
+ readonly quads: Float32Array;
216
+ }
217
+ /** Whether the document says it is tagged, and its structure tree when it has one. */
218
+ export interface StructureData {
219
+ readonly tagged: boolean;
220
+ readonly tree?: readonly StructureNode[];
221
+ }
222
+ /** Which JavaScript context made a request: the page, or the document worker. */
223
+ export type NetworkSource = "page" | "worker";
224
+ /** One network request a context made, as `watchNetwork` reports it. */
225
+ export interface NetworkRecord {
226
+ readonly url: string;
227
+ readonly method: string;
228
+ /**
229
+ * What made it: `fetch`, `xmlhttprequest`, `websocket` and `beacon` for wrapped calls, else the
230
+ * Resource Timing `initiatorType` (`script`, `link`, `css`, `img`, `navigation` …).
231
+ */
232
+ readonly initiator: string;
233
+ /** Bytes received, when known (0 otherwise). */
234
+ readonly bytes: number;
235
+ /** The call failed or was refused (a CORS refusal, a network error, a beacon not queued). */
236
+ readonly failed: boolean;
237
+ readonly source: NetworkSource;
238
+ /** `Date.now()` when it was reported. */
239
+ readonly at: number;
240
+ }
241
+ /** A request the Content Security Policy blocked: nothing was sent. */
242
+ export interface PolicyViolation {
243
+ readonly directive: string;
244
+ readonly blockedUri: string;
245
+ readonly source: NetworkSource;
246
+ readonly at: number;
247
+ }
248
+ /** The document worker's network log: every request and blocked request since it started. */
249
+ export interface WorkerNetworkLog {
250
+ /** Different for each worker the client starts, so a restarted worker's records stay apart. */
251
+ readonly worker: string;
252
+ readonly requests: readonly NetworkRecord[];
253
+ readonly violations: readonly PolicyViolation[];
254
+ }
255
+ /** How much of a remote file the worker has read: the `progress` event. */
256
+ export interface LoadProgress {
257
+ readonly loaded: number;
258
+ readonly total: number;
78
259
  }
79
260
  /** A viewer method's name. */
80
261
  export type MethodName = keyof Methods;
@@ -100,8 +281,14 @@ export interface RenderKeyFields {
100
281
  export declare function renderKeyFields(key: string): RenderKeyFields;
101
282
  /**
102
283
  * The coalescing key of a render on document `id`: the document and the whole normalised
103
- * RenderRequest (page, scale, clip, rotation, flags and background), so two requests share a run
104
- * only when their pixels are the same (ADR 0009 §3.3).
284
+ * RenderRequest (page, scale, clip, rotation, flags, background and appearance), so two requests
285
+ * share a run only when their pixels are the same (ADR 0009 §3.3).
105
286
  */
106
287
  export declare function renderKey(request: RenderRequest, id: number): string;
288
+ /** The request field for `appearance`: none for the pages' own colours, as requests were before page appearances. */
289
+ export declare function appearanceField(appearance: PageAppearance): {
290
+ appearance?: PageAppearance;
291
+ };
292
+ /** A page appearance as a string: equal for the same appearance, whatever the object. */
293
+ export declare function appearanceKey(appearance: PageAppearance | undefined): string;
107
294
  //# sourceMappingURL=protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,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aAAa,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAYpE;AAED,qHAAqH;AACrH,wBAAgB,eAAe,CAAC,UAAU,EAAE,cAAc,GAAG;IAAE,UAAU,CAAC,EAAE,cAAc,CAAA;CAAE,CAE3F;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,UAAU,EAAE,cAAc,GAAG,SAAS,GAAG,MAAM,CAI5E"}
package/dist/protocol.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // added through `serve({ methods })` in the worker and `client.request` on the page. This module
4
4
  // holds what both sides agree on: the method map (params and results), the priorities and the
5
5
  // coalescing key.
6
- import { flagsOf } from "@laminapdf/render";
6
+ import { flagsOf, } from "@laminapdf/render";
7
7
  /** The worker queue's numbers for each priority (higher first). */
8
8
  export const PRIORITY = Object.freeze({
9
9
  document: 4,
@@ -18,11 +18,11 @@ export function renderKeyFields(key) {
18
18
  }
19
19
  /**
20
20
  * The coalescing key of a render on document `id`: the document and the whole normalised
21
- * RenderRequest (page, scale, clip, rotation, flags and background), so two requests share a run
22
- * only when their pixels are the same (ADR 0009 §3.3).
21
+ * RenderRequest (page, scale, clip, rotation, flags, background and appearance), so two requests
22
+ * share a run only when their pixels are the same (ADR 0009 §3.3).
23
23
  */
24
24
  export function renderKey(request, id) {
25
- const { page, scale, clip, rotation = 0, flags, background } = request;
25
+ const { page, scale, clip, rotation = 0, flags, background, appearance } = request;
26
26
  return JSON.stringify([
27
27
  id,
28
28
  page,
@@ -31,6 +31,18 @@ export function renderKey(request, id) {
31
31
  rotation,
32
32
  flagsOf(flags),
33
33
  background === undefined ? "white" : background,
34
+ appearanceKey(appearance),
34
35
  ]);
35
36
  }
37
+ /** The request field for `appearance`: none for the pages' own colours, as requests were before page appearances. */
38
+ export function appearanceField(appearance) {
39
+ return appearance === "original" ? {} : { appearance };
40
+ }
41
+ /** A page appearance as a string: equal for the same appearance, whatever the object. */
42
+ export function appearanceKey(appearance) {
43
+ if (appearance === undefined || typeof appearance === "string")
44
+ return appearance ?? "original";
45
+ const { ink: i, paper: p } = appearance;
46
+ return `high-contrast:${i.r},${i.g},${i.b},${i.a}:${p.r},${p.g},${p.b},${p.a}`;
47
+ }
36
48
  //# sourceMappingURL=protocol.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,wFAAwF;AACxF,iGAAiG;AACjG,8FAA8F;AAC9F,kBAAkB;AAElB,OAAO,EAA4B,OAAO,EAAyC,MAAM,mBAAmB,CAAC;AA4E7G,mEAAmE;AACnE,MAAM,CAAC,MAAM,QAAQ,GAAsD,MAAM,CAAC,MAAM,CAAC;IACvF,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,CAAC;CACd,CAAC,CAAC;AAQH,kEAAkE;AAClE,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAc,CAAC;IAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAW,EAAE,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,OAAsB,EAAE,EAAU;IAC1D,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACvE,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,EAAE;QACF,IAAI;QACJ,KAAK;QACL,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QACrE,QAAQ;QACR,OAAO,CA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,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU;QAC/C,aAAa,CAAC,UAAU,CAAC;KAC1B,CAAC,CAAC;AACL,CAAC;AAED,qHAAqH;AACrH,MAAM,UAAU,eAAe,CAAC,UAA0B;IACxD,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;AACzD,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,aAAa,CAAC,UAAsC;IAClE,IAAI,UAAU,KAAK,SAAS,IAAI,OAAO,UAAU,KAAK,QAAQ;QAAE,OAAO,UAAU,IAAI,UAAU,CAAC;IAChG,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,UAAU,CAAC;IACxC,OAAO,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AACjF,CAAC"}
@@ -1,17 +1,57 @@
1
1
  import type { PixelRect } from "@laminapdf/render";
2
+ /**
3
+ * The most device pixels a page's backdrop canvas holds: well below Safari's 16.7 MP per canvas,
4
+ * and small enough that the mounted pages share the pool. A page larger than this at the full
5
+ * pixel ratio keeps its backdrop at a lower one and gets a detail canvas over the part in view.
6
+ */
7
+ export declare const BACKDROP_MAX_PIXELS: number;
8
+ /**
9
+ * Device px per CSS px of the backdrop of a page `css` CSS px in size: `dpr`, or less so that the
10
+ * whole page fits `maxPixels` ({@link BACKDROP_MAX_PIXELS} by default; less on touch devices).
11
+ */
12
+ export declare function backdropRatio(dpr: number, css: {
13
+ readonly width: number;
14
+ readonly height: number;
15
+ }, maxPixels?: number): number;
16
+ /** The smallest rectangle covering every one of `rects`; undefined when there are none. */
17
+ export declare function bounds(rects: readonly PixelRect[]): PixelRect | undefined;
18
+ /** Whether `outer` contains all of `inner`. */
19
+ export declare function contains(outer: PixelRect, inner: PixelRect): boolean;
2
20
  /** The render scale (output px per pt) of the low-resolution pass for a page `widthPt` wide. */
3
21
  export declare function lowScale(sharpScale: number, widthPt: number): number;
22
+ /**
23
+ * The sharp scale (device px per pt) of a page `css` CSS px in size at layout scale `layoutScale`:
24
+ * `layoutScale × dpr`, unless the canvas pool could only `fit` fewer pixels than `wanted`, the page
25
+ * in whole pixels at that scale (`pagePixels`); then lowered to what fits. The canvas is then
26
+ * `pagePixels` at this scale, which never exceeds `fitted` on either side.
27
+ *
28
+ * `wanted` is in whole pixels, as the pool fits them: comparing `fitted` with the fractional CSS
29
+ * size instead takes the pool's rounding (79.33 px to 79) for a cap, which lowers the scale a
30
+ * hair below the full one and sends every page asking for a detail canvas it doesn't need.
31
+ */
32
+ export declare function sharpScale(layoutScale: number, dpr: number, css: {
33
+ readonly width: number;
34
+ readonly height: number;
35
+ }, fitted: {
36
+ readonly width: number;
37
+ readonly height: number;
38
+ }, wanted: {
39
+ readonly width: number;
40
+ readonly height: number;
41
+ }): number;
4
42
  /**
5
43
  * The tiles (device px, in the page's pixel space at the sharp scale) covering `visible`, the
6
- * part of the page in view in CSS px (x, y from the page's top-left), clamped to the page.
44
+ * part of the page in view in CSS px (x, y from the page's top-left), clamped to `page`: the
45
+ * whole page in device px, as the renderer sizes it (`pagePixels` of `@laminapdf/render`), so no
46
+ * tile reaches past it. `ratio` is device px per CSS px.
7
47
  */
8
48
  export declare function tilesFor(visible: {
9
49
  readonly x: number;
10
50
  readonly y: number;
11
51
  readonly width: number;
12
52
  readonly height: number;
13
- }, pageCss: {
53
+ }, page: {
14
54
  readonly width: number;
15
55
  readonly height: number;
16
- }, dpr: number): PixelRect[];
56
+ }, ratio: number): PixelRect[];
17
57
  //# sourceMappingURL=tiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tiles.d.ts","sourceR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