web-doc 0.6.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +33 -1
- package/dist/adapters/docx-images.d.ts +13 -4
- package/dist/adapters/docx-images.js +3 -0
- package/dist/adapters/docx-paragraphs.d.ts +65 -0
- package/dist/adapters/docx-paragraphs.js +165 -0
- package/dist/adapters/docx-prepass.d.ts +17 -0
- package/dist/adapters/docx-prepass.js +230 -0
- package/dist/adapters/office.d.ts +31 -5
- package/dist/adapters/office.js +60 -29
- package/dist/adapters/pdf.d.ts +9 -0
- package/dist/adapters/pdf.js +10 -0
- package/dist/assets/pdfium/pdfium.wasm +0 -0
- package/dist/contracts.d.ts +53 -2
- package/dist/edit/ai/outline.d.ts +47 -0
- package/dist/edit/ai/outline.js +338 -0
- package/dist/edit/ai/targets.d.ts +16 -0
- package/dist/edit/ai/targets.js +309 -0
- package/dist/edit/ai/tools.d.ts +28 -0
- package/dist/edit/ai/tools.js +605 -0
- package/dist/edit/ai/types.d.ts +175 -0
- package/dist/edit/ai/types.js +1 -0
- package/dist/edit/assets.d.ts +23 -0
- package/dist/edit/assets.js +75 -0
- package/dist/edit/docx/elements.d.ts +6 -0
- package/dist/edit/docx/elements.js +90 -0
- package/dist/edit/docx/engine.d.ts +57 -0
- package/dist/edit/docx/engine.js +547 -0
- package/dist/edit/docx/handlers.d.ts +3 -0
- package/dist/edit/docx/handlers.js +15 -0
- package/dist/edit/docx/ids.d.ts +45 -0
- package/dist/edit/docx/ids.js +101 -0
- package/dist/edit/docx/model.d.ts +94 -0
- package/dist/edit/docx/model.js +350 -0
- package/dist/edit/docx/operations.d.ts +47 -0
- package/dist/edit/docx/operations.js +3 -0
- package/dist/edit/docx/provider.d.ts +16 -0
- package/dist/edit/docx/provider.js +37 -0
- package/dist/edit/docx/schemas.d.ts +6 -0
- package/dist/edit/docx/schemas.js +192 -0
- package/dist/edit/docx/session.d.ts +48 -0
- package/dist/edit/docx/session.js +467 -0
- package/dist/edit/docx/structure-ops.d.ts +6 -0
- package/dist/edit/docx/structure-ops.js +529 -0
- package/dist/edit/docx/style.d.ts +45 -0
- package/dist/edit/docx/style.js +375 -0
- package/dist/edit/docx/table-ops.d.ts +4 -0
- package/dist/edit/docx/table-ops.js +241 -0
- package/dist/edit/docx/text-ops.d.ts +40 -0
- package/dist/edit/docx/text-ops.js +491 -0
- package/dist/edit/docx/text.d.ts +34 -0
- package/dist/edit/docx/text.js +284 -0
- package/dist/edit/docx/tracked.d.ts +52 -0
- package/dist/edit/docx/tracked.js +347 -0
- package/dist/edit/docx/types.d.ts +206 -0
- package/dist/edit/docx/types.js +1 -0
- package/dist/edit/docx/write.d.ts +64 -0
- package/dist/edit/docx/write.js +375 -0
- package/dist/edit/engine.d.ts +128 -0
- package/dist/edit/engine.js +1 -0
- package/dist/edit/history.d.ts +77 -0
- package/dist/edit/history.js +123 -0
- package/dist/edit/ooxml/names.d.ts +20 -0
- package/dist/edit/ooxml/names.js +61 -0
- package/dist/edit/ooxml/opc.d.ts +50 -0
- package/dist/edit/ooxml/opc.js +150 -0
- package/dist/edit/ooxml/package.d.ts +82 -0
- package/dist/edit/ooxml/package.js +233 -0
- package/dist/edit/ooxml/patch.d.ts +51 -0
- package/dist/edit/ooxml/patch.js +250 -0
- package/dist/edit/ooxml/transaction.d.ts +39 -0
- package/dist/edit/ooxml/transaction.js +316 -0
- package/dist/edit/ooxml/worker.d.ts +8 -0
- package/dist/edit/ooxml/worker.js +12 -0
- package/dist/edit/ooxml/writer.d.ts +21 -0
- package/dist/edit/ooxml/writer.js +187 -0
- package/dist/edit/ooxml/xml.d.ts +74 -0
- package/dist/edit/ooxml/xml.js +451 -0
- package/dist/edit/ooxml/zip.d.ts +54 -0
- package/dist/edit/ooxml/zip.js +280 -0
- package/dist/edit/operations.d.ts +19 -0
- package/dist/edit/operations.js +137 -0
- package/dist/edit/pdf/engine/compact.d.ts +6 -0
- package/dist/edit/pdf/engine/compact.js +442 -0
- package/dist/edit/pdf/engine/document.d.ts +95 -0
- package/dist/edit/pdf/engine/document.js +868 -0
- package/dist/edit/pdf/engine/elements.d.ts +45 -0
- package/dist/edit/pdf/engine/elements.js +313 -0
- package/dist/edit/pdf/engine/existing-text.d.ts +4 -0
- package/dist/edit/pdf/engine/existing-text.js +424 -0
- package/dist/edit/pdf/engine/fonts.d.ts +78 -0
- package/dist/edit/pdf/engine/fonts.js +466 -0
- package/dist/edit/pdf/engine/geometry.d.ts +36 -0
- package/dist/edit/pdf/engine/geometry.js +97 -0
- package/dist/edit/pdf/engine/handler.d.ts +21 -0
- package/dist/edit/pdf/engine/handler.js +108 -0
- package/dist/edit/pdf/engine/images.d.ts +33 -0
- package/dist/edit/pdf/engine/images.js +188 -0
- package/dist/edit/pdf/engine/layout.d.ts +23 -0
- package/dist/edit/pdf/engine/layout.js +177 -0
- package/dist/edit/pdf/engine/operations.d.ts +67 -0
- package/dist/edit/pdf/engine/operations.js +3 -0
- package/dist/edit/pdf/engine/pages.d.ts +6 -0
- package/dist/edit/pdf/engine/pages.js +98 -0
- package/dist/edit/pdf/engine/pdfium.d.ts +195 -0
- package/dist/edit/pdf/engine/pdfium.js +249 -0
- package/dist/edit/pdf/engine/shapes.d.ts +4 -0
- package/dist/edit/pdf/engine/shapes.js +183 -0
- package/dist/edit/pdf/engine/tables.d.ts +44 -0
- package/dist/edit/pdf/engine/tables.js +315 -0
- package/dist/edit/pdf/engine/text-box.d.ts +71 -0
- package/dist/edit/pdf/engine/text-box.js +317 -0
- package/dist/edit/pdf/engine/text-layout.d.ts +28 -0
- package/dist/edit/pdf/engine/text-layout.js +67 -0
- package/dist/edit/pdf/engine/transform.d.ts +5 -0
- package/dist/edit/pdf/engine/transform.js +137 -0
- package/dist/edit/pdf/provider.d.ts +35 -0
- package/dist/edit/pdf/provider.js +92 -0
- package/dist/edit/pdf/range-map.d.ts +16 -0
- package/dist/edit/pdf/range-map.js +107 -0
- package/dist/edit/pdf/schemas.d.ts +11 -0
- package/dist/edit/pdf/schemas.js +291 -0
- package/dist/edit/pdf/selection.d.ts +5 -0
- package/dist/edit/pdf/selection.js +152 -0
- package/dist/edit/pdf/session.d.ts +63 -0
- package/dist/edit/pdf/session.js +312 -0
- package/dist/edit/pdf/types.d.ts +336 -0
- package/dist/edit/pdf/types.js +1 -0
- package/dist/edit/pptx/elements.d.ts +74 -0
- package/dist/edit/pptx/elements.js +301 -0
- package/dist/edit/pptx/engine.d.ts +37 -0
- package/dist/edit/pptx/engine.js +466 -0
- package/dist/edit/pptx/geometry.d.ts +72 -0
- package/dist/edit/pptx/geometry.js +193 -0
- package/dist/edit/pptx/handler.d.ts +7 -0
- package/dist/edit/pptx/handler.js +99 -0
- package/dist/edit/pptx/handlers.d.ts +3 -0
- package/dist/edit/pptx/handlers.js +21 -0
- package/dist/edit/pptx/image-table-ops.d.ts +5 -0
- package/dist/edit/pptx/image-table-ops.js +233 -0
- package/dist/edit/pptx/model.d.ts +69 -0
- package/dist/edit/pptx/model.js +170 -0
- package/dist/edit/pptx/operations.d.ts +50 -0
- package/dist/edit/pptx/operations.js +11 -0
- package/dist/edit/pptx/provider.d.ts +17 -0
- package/dist/edit/pptx/provider.js +40 -0
- package/dist/edit/pptx/schemas.d.ts +6 -0
- package/dist/edit/pptx/schemas.js +220 -0
- package/dist/edit/pptx/session.d.ts +54 -0
- package/dist/edit/pptx/session.js +145 -0
- package/dist/edit/pptx/shape-ops.d.ts +10 -0
- package/dist/edit/pptx/shape-ops.js +486 -0
- package/dist/edit/pptx/slide-ops.d.ts +6 -0
- package/dist/edit/pptx/slide-ops.js +353 -0
- package/dist/edit/pptx/style.d.ts +31 -0
- package/dist/edit/pptx/style.js +181 -0
- package/dist/edit/pptx/text-ops.d.ts +13 -0
- package/dist/edit/pptx/text-ops.js +267 -0
- package/dist/edit/pptx/text-write.d.ts +67 -0
- package/dist/edit/pptx/text-write.js +293 -0
- package/dist/edit/pptx/text.d.ts +41 -0
- package/dist/edit/pptx/text.js +99 -0
- package/dist/edit/pptx/types.d.ts +232 -0
- package/dist/edit/pptx/types.js +1 -0
- package/dist/edit/schema.d.ts +11 -0
- package/dist/edit/schema.js +275 -0
- package/dist/edit/session.d.ts +77 -0
- package/dist/edit/session.js +943 -0
- package/dist/edit/sessions.d.ts +8 -0
- package/dist/edit/sessions.js +1 -0
- package/dist/edit/types.d.ts +290 -0
- package/dist/edit/types.js +1 -0
- package/dist/edit/worker-engine.d.ts +31 -0
- package/dist/edit/worker-engine.js +91 -0
- package/dist/fonts/THIRD_PARTY_NOTICES.md +3 -0
- package/dist/fonts/manifest.json +6 -1
- package/dist/fonts/noto-sans-latin-cyrillic.ttf +0 -0
- package/dist/fonts.d.ts +2 -0
- package/dist/fonts.js +4 -0
- package/dist/fuzzy-alignment.d.ts +11 -4
- package/dist/fuzzy-alignment.js +3 -9
- package/dist/headless.d.ts +5 -1
- package/dist/headless.js +8 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.js +16 -2
- package/dist/limits.js +6 -0
- package/dist/ooxml-edit-worker.d.ts +1 -0
- package/dist/ooxml-edit-worker.js +8 -0
- package/dist/pdf-edit-worker.d.ts +1 -0
- package/dist/pdf-edit-worker.js +35 -0
- package/dist/spreadsheet-viewport.d.ts +5 -0
- package/dist/spreadsheet-viewport.js +11 -0
- package/dist/ui.js +7 -0
- package/dist/viewer.d.ts +6 -0
- package/dist/viewer.js +293 -19
- package/dist/viewport.d.ts +13 -0
- package/dist/viewport.js +126 -1
- package/dist/worker-protocol.d.ts +39 -2
- package/dist/workers/fuzzy-search-worker.js +1 -1
- package/dist/workers/ooxml-edit-worker.js +9212 -0
- package/dist/workers/pdf-edit-worker.js +10847 -0
- package/package.json +3 -3
package/dist/viewport.js
CHANGED
|
@@ -30,6 +30,19 @@ export class AdaptiveViewport {
|
|
|
30
30
|
}
|
|
31
31
|
this.#strategy.setDocument(info);
|
|
32
32
|
}
|
|
33
|
+
replaceDocument(info, changedPages, revision) {
|
|
34
|
+
const nextKind = info.unit === "sheet" ? "sheet" : "page";
|
|
35
|
+
if (nextKind !== this.#kind)
|
|
36
|
+
this.setDocument(info);
|
|
37
|
+
else
|
|
38
|
+
this.#strategy.replaceDocument(info, changedPages, revision);
|
|
39
|
+
}
|
|
40
|
+
pageToClient(pageIndex, rect) {
|
|
41
|
+
return this.#strategy.pageToClient(pageIndex, rect);
|
|
42
|
+
}
|
|
43
|
+
clientToPage(clientX, clientY) {
|
|
44
|
+
return this.#strategy.clientToPage(clientX, clientY);
|
|
45
|
+
}
|
|
33
46
|
update() {
|
|
34
47
|
this.#strategy.update();
|
|
35
48
|
}
|
|
@@ -70,6 +83,13 @@ export class ViewerViewport {
|
|
|
70
83
|
#onSelectionChange = () => this.#handleSelectionChange();
|
|
71
84
|
#pointers = new Map();
|
|
72
85
|
#info;
|
|
86
|
+
/** Per page: grows when that page's content changed, so only it re-renders. */
|
|
87
|
+
#pageRevisions = [];
|
|
88
|
+
/** The session revision the shown content belongs to; 0 before any edit. */
|
|
89
|
+
#contentRevision = 0;
|
|
90
|
+
/** Pages painted since the last `onPainted`, keyed by content revision. */
|
|
91
|
+
#painted = new Map();
|
|
92
|
+
#paintedFlush = 0;
|
|
73
93
|
#frame = 0;
|
|
74
94
|
#resizeObserver;
|
|
75
95
|
#destroyed = false;
|
|
@@ -126,11 +146,90 @@ export class ViewerViewport {
|
|
|
126
146
|
}
|
|
127
147
|
setDocument(info) {
|
|
128
148
|
this.#info = info;
|
|
149
|
+
this.#pageRevisions = [];
|
|
150
|
+
this.#contentRevision = 0;
|
|
151
|
+
this.#painted.clear();
|
|
129
152
|
this.#appliedZoom = this.#host.state.zoom;
|
|
130
153
|
this.#root.scrollTo({ left: 0, top: 0 });
|
|
131
154
|
this.#clearSlots();
|
|
132
155
|
this.schedule();
|
|
133
156
|
}
|
|
157
|
+
replaceDocument(info, changedPages, revision) {
|
|
158
|
+
const previous = this.#info;
|
|
159
|
+
this.#info = info;
|
|
160
|
+
this.#contentRevision = revision ?? this.#contentRevision + 1;
|
|
161
|
+
// Only pages whose content or size changed get a new render key; the
|
|
162
|
+
// others keep their bitmaps. A changed page count shifts everything
|
|
163
|
+
// from the first changed page on.
|
|
164
|
+
const countChanged = previous?.pageCount !== info.pageCount;
|
|
165
|
+
const from = changedPages === undefined
|
|
166
|
+
? 0
|
|
167
|
+
: countChanged
|
|
168
|
+
? Math.min(...changedPages, info.pageCount)
|
|
169
|
+
: Number.POSITIVE_INFINITY;
|
|
170
|
+
const changed = new Set(changedPages ?? []);
|
|
171
|
+
for (let pageIndex = 0; pageIndex < info.pageCount; pageIndex += 1) {
|
|
172
|
+
const size = info.pageSizes?.[pageIndex];
|
|
173
|
+
const before = previous?.pageSizes?.[pageIndex];
|
|
174
|
+
const resized = size?.width !== before?.width || size?.height !== before?.height;
|
|
175
|
+
if (pageIndex >= from || changed.has(pageIndex) || resized)
|
|
176
|
+
this.#pageRevisions[pageIndex] =
|
|
177
|
+
(this.#pageRevisions[pageIndex] ?? 0) + 1;
|
|
178
|
+
}
|
|
179
|
+
// Slots stay mounted and repaint in place; the browser clamps the scroll
|
|
180
|
+
// position itself once the spacer takes the new document's height.
|
|
181
|
+
this.schedule();
|
|
182
|
+
}
|
|
183
|
+
pageToClient(pageIndex, rect) {
|
|
184
|
+
const page = this.#mountedPage(pageIndex);
|
|
185
|
+
if (!page)
|
|
186
|
+
return undefined;
|
|
187
|
+
return {
|
|
188
|
+
left: page.left + rect.x * page.scale,
|
|
189
|
+
top: page.top + rect.y * page.scale,
|
|
190
|
+
width: rect.width * page.scale,
|
|
191
|
+
height: rect.height * page.scale,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
clientToPage(clientX, clientY) {
|
|
195
|
+
for (const pageIndex of this.#slots.keys()) {
|
|
196
|
+
const page = this.#mountedPage(pageIndex);
|
|
197
|
+
if (!page ||
|
|
198
|
+
clientX < page.left ||
|
|
199
|
+
clientX >= page.left + page.width ||
|
|
200
|
+
clientY < page.top ||
|
|
201
|
+
clientY >= page.top + page.height)
|
|
202
|
+
continue;
|
|
203
|
+
return {
|
|
204
|
+
pageIndex,
|
|
205
|
+
point: {
|
|
206
|
+
x: (clientX - page.left) / page.scale,
|
|
207
|
+
y: (clientY - page.top) / page.scale,
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Client-space box of a mounted page and its page-space scale, read from
|
|
215
|
+
* the DOM so it matches what is painted rather than what is scheduled.
|
|
216
|
+
*/
|
|
217
|
+
#mountedPage(pageIndex) {
|
|
218
|
+
const slot = this.#slots.get(pageIndex);
|
|
219
|
+
if (!slot || !this.#info)
|
|
220
|
+
return undefined;
|
|
221
|
+
const box = slot.root.getBoundingClientRect();
|
|
222
|
+
const natural = naturalPageSize(this.#info, pageIndex);
|
|
223
|
+
if (box.width <= 0 || box.height <= 0)
|
|
224
|
+
return undefined;
|
|
225
|
+
return {
|
|
226
|
+
left: box.left,
|
|
227
|
+
top: box.top,
|
|
228
|
+
width: box.width,
|
|
229
|
+
height: box.height,
|
|
230
|
+
scale: box.width / natural.width,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
134
233
|
update() {
|
|
135
234
|
const zoom = this.#host.state.zoom;
|
|
136
235
|
if (this.#info &&
|
|
@@ -198,6 +297,28 @@ export class ViewerViewport {
|
|
|
198
297
|
const size = naturalPageSize(this.#info, this.#host.state.pageIndex);
|
|
199
298
|
return Math.max(0.1, Math.min(8, (this.#root.clientWidth - 24) / size.width, (this.#root.clientHeight - 24) / size.height));
|
|
200
299
|
}
|
|
300
|
+
/** Collects finished paints and reports them once per frame, newest content only. */
|
|
301
|
+
#markPainted(pageIndex, contentRevision) {
|
|
302
|
+
if (contentRevision !== this.#contentRevision)
|
|
303
|
+
return;
|
|
304
|
+
let pages = this.#painted.get(contentRevision);
|
|
305
|
+
if (!pages) {
|
|
306
|
+
pages = new Set();
|
|
307
|
+
this.#painted.clear();
|
|
308
|
+
this.#painted.set(contentRevision, pages);
|
|
309
|
+
}
|
|
310
|
+
pages.add(pageIndex);
|
|
311
|
+
if (this.#paintedFlush)
|
|
312
|
+
return;
|
|
313
|
+
this.#paintedFlush = requestAnimationFrame(() => {
|
|
314
|
+
this.#paintedFlush = 0;
|
|
315
|
+
const current = this.#painted.get(this.#contentRevision);
|
|
316
|
+
this.#painted.clear();
|
|
317
|
+
if (!current || current.size === 0 || this.#destroyed)
|
|
318
|
+
return;
|
|
319
|
+
this.#host.onPainted([...current].sort((a, b) => a - b), this.#contentRevision);
|
|
320
|
+
});
|
|
321
|
+
}
|
|
201
322
|
schedule() {
|
|
202
323
|
if (this.#destroyed || this.#frame)
|
|
203
324
|
return;
|
|
@@ -212,6 +333,8 @@ export class ViewerViewport {
|
|
|
212
333
|
this.#destroyed = true;
|
|
213
334
|
if (this.#frame)
|
|
214
335
|
cancelAnimationFrame(this.#frame);
|
|
336
|
+
if (this.#paintedFlush)
|
|
337
|
+
cancelAnimationFrame(this.#paintedFlush);
|
|
215
338
|
if (this.#zoomSettleTimer)
|
|
216
339
|
clearTimeout(this.#zoomSettleTimer);
|
|
217
340
|
this.#resizeObserver?.disconnect();
|
|
@@ -266,7 +389,7 @@ export class ViewerViewport {
|
|
|
266
389
|
.getSearchMatches(pageIndex)
|
|
267
390
|
.map((match) => `${match.start}:${match.end}`)
|
|
268
391
|
.join(",");
|
|
269
|
-
const renderKey = `${state.zoom}:${window.devicePixelRatio || 1}:${highlights}`;
|
|
392
|
+
const renderKey = `${this.#pageRevisions[pageIndex] ?? 0}:${state.zoom}:${window.devicePixelRatio || 1}:${highlights}`;
|
|
270
393
|
if (slot.renderKey === undefined ||
|
|
271
394
|
(!this.#zoomGestureActive && slot.renderKey !== renderKey)) {
|
|
272
395
|
slot.renderKey = renderKey;
|
|
@@ -320,6 +443,7 @@ export class ViewerViewport {
|
|
|
320
443
|
slot.controller = controller;
|
|
321
444
|
const generation = ++slot.generation;
|
|
322
445
|
const zoom = this.#host.state.zoom;
|
|
446
|
+
const contentRevision = this.#contentRevision;
|
|
323
447
|
try {
|
|
324
448
|
let renderError;
|
|
325
449
|
const rendering = this.#host
|
|
@@ -347,6 +471,7 @@ export class ViewerViewport {
|
|
|
347
471
|
const cssHeight = slot.canvas.height / (window.devicePixelRatio || 1);
|
|
348
472
|
slot.root.style.width = `${cssWidth}px`;
|
|
349
473
|
slot.root.style.height = `${cssHeight}px`;
|
|
474
|
+
this.#markPainted(pageIndex, contentRevision);
|
|
350
475
|
}
|
|
351
476
|
catch (error) {
|
|
352
477
|
if (!controller.signal.aborted) {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { DocumentFormat, DocumentInfo, ResourceLimits, TextRun, ViewerErrorData, ViewerProgress, ViewerWarning } from "./contracts.js";
|
|
2
|
-
|
|
2
|
+
import type { EditableFormat } from "./edit/types.js";
|
|
3
|
+
export type DocumentWorkerOperation = "init" | "open" | "get-info" | "render" | "get-text-map" | "close" | "destroy";
|
|
4
|
+
/** Operations of an edit engine worker; payloads mirror the engine interface. */
|
|
5
|
+
export type EditWorkerOperation = "edit-init" | "edit-open" | "edit-validate" | "edit-apply" | "edit-materialize" | "edit-restore" | "edit-put-asset" | "edit-elements" | "edit-element" | "edit-elements-at" | "edit-find-text" | "edit-text-layout" | "edit-position-at" | "edit-range-rects" | "edit-render-without" | "edit-page-layout" | "edit-pptx-slides" | "edit-pptx-layouts" | "edit-docx-revisions" | "edit-dispose";
|
|
6
|
+
export type WorkerOperation = DocumentWorkerOperation | EditWorkerOperation;
|
|
3
7
|
export interface WorkerRequest {
|
|
4
8
|
readonly kind: "request";
|
|
5
9
|
readonly id: number;
|
|
@@ -44,5 +48,38 @@ export interface WorkerRenderPayload {
|
|
|
44
48
|
readonly zoom: number;
|
|
45
49
|
readonly devicePixelRatio: number;
|
|
46
50
|
}
|
|
47
|
-
export
|
|
51
|
+
export interface EditWorkerInitPayload {
|
|
52
|
+
/** Where the worker fetches the engine's WebAssembly from. */
|
|
53
|
+
readonly wasmUrl: string;
|
|
54
|
+
/** TrueType font for text the standard PDF fonts cannot encode. */
|
|
55
|
+
readonly fallbackFontUrl?: string;
|
|
56
|
+
}
|
|
57
|
+
/** A host-registered font as the edit worker receives it. */
|
|
58
|
+
export interface EditWorkerFont {
|
|
59
|
+
readonly family: string;
|
|
60
|
+
readonly weight: number;
|
|
61
|
+
readonly style: "normal" | "italic" | "oblique";
|
|
62
|
+
/** Font bytes, or an absolute URL the worker fetches on first use. */
|
|
63
|
+
readonly source: ArrayBuffer | string;
|
|
64
|
+
}
|
|
65
|
+
export interface EditWorkerOpenPayload {
|
|
66
|
+
readonly data: ArrayBuffer;
|
|
67
|
+
readonly limits: ResourceLimits;
|
|
68
|
+
/** The session format; a worker that serves several formats picks its engine by it. */
|
|
69
|
+
readonly format?: EditableFormat;
|
|
70
|
+
readonly fileName?: string;
|
|
71
|
+
readonly fonts?: readonly EditWorkerFont[];
|
|
72
|
+
}
|
|
73
|
+
/** A rendered page as the worker returns it; `data` is transferred, not copied. */
|
|
74
|
+
export interface EditWorkerBitmap {
|
|
75
|
+
readonly pageIndex: number;
|
|
76
|
+
readonly scale: number;
|
|
77
|
+
readonly width: number;
|
|
78
|
+
readonly height: number;
|
|
79
|
+
readonly data: ArrayBuffer;
|
|
80
|
+
}
|
|
81
|
+
export interface EditWorkerOpenResult {
|
|
82
|
+
readonly pageCount: number;
|
|
83
|
+
}
|
|
84
|
+
export type WorkerOperationResult = DocumentInfo | readonly TextRun[] | ImageBitmap | ArrayBuffer | EditWorkerOpenResult | undefined;
|
|
48
85
|
export declare function transferablesFor(value: unknown): Transferable[];
|
|
@@ -1634,7 +1634,7 @@ function alignFuzzyPassage(text, query, caseSensitive, maxScore) {
|
|
|
1634
1634
|
if (bestEnd <= bestStart || bestCost / length > maxScore) return void 0;
|
|
1635
1635
|
const start = source.starts[bestStart];
|
|
1636
1636
|
const end = source.ends[bestEnd - 1];
|
|
1637
|
-
return start === void 0 || end === void 0 ? void 0 : { start, end };
|
|
1637
|
+
return start === void 0 || end === void 0 ? void 0 : { start, end, cost: bestCost, length };
|
|
1638
1638
|
}
|
|
1639
1639
|
|
|
1640
1640
|
// src/fuzzy-search.ts
|