@betteroffice/docx 0.3.0 → 0.4.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/README.md +64 -0
- package/dist/chunk-24Z6ZVFZ.mjs +1 -0
- package/dist/chunk-2QHGQA3V.mjs +1 -0
- package/dist/{chunk-ACGKK7IB.mjs → chunk-3CYO46ML.mjs} +1 -1
- package/dist/chunk-6CHGYCFU.mjs +1 -0
- package/dist/chunk-AOWJ4WDE.mjs +1 -0
- package/dist/chunk-DLXIZBB6.mjs +1 -0
- package/dist/chunk-F2VBW6RB.mjs +1 -0
- package/dist/chunk-HPZFJGGM.mjs +0 -0
- package/dist/chunk-L2ML3DDI.mjs +1 -0
- package/dist/chunk-LIGZ75FP.mjs +1 -0
- package/dist/chunk-LT2GCWZ3.mjs +0 -0
- package/dist/chunk-ND3FBCB3.mjs +16 -0
- package/dist/{chunk-NT2OYIJ4.mjs → chunk-NMDQHUQB.mjs} +1 -1
- package/dist/chunk-NVN26RHH.mjs +1 -0
- package/dist/{chunk-H5YYCN42.mjs → chunk-OK5UFGX3.mjs} +1 -1
- package/dist/{chunk-VQXNED2P.mjs → chunk-RZQ3OXZY.mjs} +1 -1
- package/dist/{chunk-QE4ZDRKV.mjs → chunk-YLFKV2NT.mjs} +1 -1
- package/dist/collaboration/index.d.mts +5 -4
- package/dist/compareDocx-IHFPGIGV.mjs +1 -0
- package/dist/computeLayout-4MNWHE2T.mjs +1 -0
- package/dist/core.d.mts +4 -4
- package/dist/core.mjs +1 -1
- package/dist/{displayListQueries-BYFrBkw5.d.mts → displayListQueries-H5YnU_hX.d.mts} +23 -5
- package/dist/docx/index.mjs +1 -1
- package/dist/editor/index.d.mts +15 -7
- package/dist/editor/index.mjs +1 -1
- package/dist/{fontLoader-CkXcPB1C.d.mts → fontLoader-BNSs0E8K.d.mts} +54 -1
- package/dist/{frameDelta-CVt5FAXT.d.mts → frameDelta-ByU7HBuB.d.mts} +21 -1
- package/dist/generated/edit/docx_edit_bg.wasm +0 -0
- package/dist/generated/layout/docx_layout_bg.wasm +0 -0
- package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
- package/dist/generated/parse/docx_parse_bg.wasm +0 -0
- package/dist/{index-BbZwdkPz.d.mts → index-CHy6_Yuo.d.mts} +470 -14
- package/dist/layout/index.d.mts +2 -2
- package/dist/layout/index.mjs +1 -1
- package/dist/layout/pagination/index.d.mts +2 -2
- package/dist/layout/render/index.d.mts +118 -31
- package/dist/layout/render/index.mjs +1 -1
- package/dist/loadWasmAsset-Cr95TImt.d.mts +25 -0
- package/dist/{pagedExport-D3E4jZ-B.d.mts → pagedExport---0Dlmzo.d.mts} +1 -1
- package/dist/parseWasm-NLAG22EU.mjs +1 -0
- package/dist/plugin-api/RenderedDomContext.d.mts +6 -4
- package/dist/plugin-api/RenderedDomContext.mjs +1 -1
- package/dist/{rustDisplayList-CwOoUn3t.d.mts → rustDisplayList-LcRZHCSL.d.mts} +12 -4
- package/dist/{rustMeasureSource-CyBMcy1x.d.mts → rustMeasureSource-BkCx1FDx.d.mts} +2 -0
- package/dist/types/document.d.mts +3 -0
- package/dist/{types-B4jD0rrc.d.mts → types-D6Pra38E.d.mts} +12 -3
- package/dist/utils/index.d.mts +14 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/wasm-GSI2XMOH.mjs +1 -0
- package/dist/{wasm-G62X4WRW.mjs → wasm-K6DRABAA.mjs} +1 -1
- package/dist/wasm-NF6B3AH7.mjs +1 -0
- package/dist/wasm-edit.d.mts +177 -18
- package/dist/wasm-edit.mjs +1 -1
- package/dist/wasm-layout.d.mts +1 -1
- package/dist/wasm-layout.mjs +1 -1
- package/dist/wasm-opc.d.mts +1 -1
- package/dist/wasm-opc.mjs +1 -1
- package/dist/wasm-parse.d.mts +1 -1
- package/dist/wasm-parse.mjs +1 -1
- package/dist/yrs/index.d.mts +4 -3
- package/dist/yrs/index.mjs +1 -1
- package/dist/yrs/residentEngineWorker.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-5B4VMUXM.mjs +0 -16
- package/dist/chunk-5F6DLQZP.mjs +0 -1
- package/dist/chunk-5JEQC76K.mjs +0 -1
- package/dist/chunk-7GJG6LLU.mjs +0 -1
- package/dist/chunk-FE6FWGBJ.mjs +0 -1
- package/dist/chunk-HLDJMU3R.mjs +0 -1
- package/dist/chunk-J7LNO6SM.mjs +0 -1
- package/dist/chunk-PGMXWI5X.mjs +0 -1
- package/dist/chunk-Z4HZIPBS.mjs +0 -1
- package/dist/compareDocx-XXTZV4CG.mjs +0 -1
- package/dist/computeLayout-LWLAJWYA.mjs +0 -1
- package/dist/loadWasmAsset-CMvnVkfA.d.mts +0 -3
- package/dist/wasm-US6R7SWN.mjs +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { C as ColorValue } from './formatting-gqLFeJ9X.mjs';
|
|
2
|
-
import { Document } from './types/document.mjs';
|
|
3
|
-
import { a0 as
|
|
4
|
-
import { R as RetainedFrame } from './frameDelta-
|
|
2
|
+
import { Document, CompatibilityFlags } from './types/document.mjs';
|
|
3
|
+
import { a0 as DocxEditSuggestion, a1 as DocxEditFailure, a2 as DocxEditFailureCode, a3 as DocxReadParagraphsRequest, a4 as DocxReadParagraphsResult, a5 as DocxFindTextRequest, a6 as DocxFindTextResult, a7 as DocxEditRequest, a8 as DocxValidationResult, a9 as DocxEditResult, aa as DocxTextTarget, ab as DocxEditRefusal, a as DocxExportOptions, H as DocxExportResult, c as DocxStructuredContent, b as DocxMarkdownContent, d as DocxPageExportOptions, f as DocxPagedStructuredContent, i as DocxLayoutMap, g as DocxSnapshotLayoutMap, D as DocxExportFailure, V as DocxParagraphHeading, m as DocxContentControlsOptions, w as DocxContentControlsResult, l as DocxContentControlQuery } from './pagedExport---0Dlmzo.mjs';
|
|
4
|
+
import { R as RetainedFrame } from './frameDelta-ByU7HBuB.mjs';
|
|
5
|
+
import { a as WasmModuleMemory } from './loadWasmAsset-Cr95TImt.mjs';
|
|
5
6
|
import { R as RepackOptions } from './rezip-Bxiq4Z_R.mjs';
|
|
6
7
|
|
|
7
8
|
type CollaborationUpdateOrigin = 'local' | 'remote';
|
|
@@ -241,6 +242,84 @@ type DocxParagraphAnchorResult = {
|
|
|
241
242
|
/** The paragraph IDs a session save applies, as the package writer's `paragraphIds`. @internal */
|
|
242
243
|
type DocxParagraphSavePlan = RustParagraphIds;
|
|
243
244
|
|
|
245
|
+
/**
|
|
246
|
+
* Host proposals: tracked changes a host proposes by paragraph anchor and search, grouped by the
|
|
247
|
+
* host's proposal ids. A round resolves against one version and applies as one atomic batch
|
|
248
|
+
* outside undo history. Decisions only change how the proposals' revisions render: the
|
|
249
|
+
* revisions stay in the document, and the document version and history are untouched until the
|
|
250
|
+
* host withdraws the proposals.
|
|
251
|
+
*/
|
|
252
|
+
|
|
253
|
+
type DocxProposalState = 'proposed' | 'accepted' | 'rejected';
|
|
254
|
+
/** Which non-overlapping matches of a search a proposal replaces; numbers count from 1. */
|
|
255
|
+
type DocxOccurrence = 'first' | 'all' | number;
|
|
256
|
+
/**
|
|
257
|
+
* One proposal. `replaceText` with `replaceWith: ''` deletes; with `search: ''` it fills a
|
|
258
|
+
* paragraph whose accepted text is empty (an inline atom counts as text), where the empty search
|
|
259
|
+
* matches once, at offset 0. `insertText` offsets are UTF-16 units of the paragraph's accepted
|
|
260
|
+
* text.
|
|
261
|
+
*/
|
|
262
|
+
type DocxProposalInput = {
|
|
263
|
+
id: string;
|
|
264
|
+
paragraph: DocxParagraphAnchor;
|
|
265
|
+
suggest: DocxEditSuggestion;
|
|
266
|
+
} & ({
|
|
267
|
+
op: 'replaceText';
|
|
268
|
+
search: string;
|
|
269
|
+
replaceWith: string;
|
|
270
|
+
occurrence?: DocxOccurrence;
|
|
271
|
+
} | {
|
|
272
|
+
op: 'insertText';
|
|
273
|
+
at: 'start' | 'end' | {
|
|
274
|
+
offset: number;
|
|
275
|
+
};
|
|
276
|
+
text: string;
|
|
277
|
+
});
|
|
278
|
+
interface DocxProposalRequest {
|
|
279
|
+
expectVersion: string;
|
|
280
|
+
proposals: readonly DocxProposalInput[];
|
|
281
|
+
}
|
|
282
|
+
interface DocxProposalRecord {
|
|
283
|
+
id: string;
|
|
284
|
+
state: DocxProposalState;
|
|
285
|
+
paragraph: DocxSessionParagraphAnchor;
|
|
286
|
+
revisionIds: readonly string[];
|
|
287
|
+
changed: boolean;
|
|
288
|
+
}
|
|
289
|
+
interface DocxProposalSnapshot {
|
|
290
|
+
version: string;
|
|
291
|
+
/** Increments whenever a decision changes. */
|
|
292
|
+
previewVersion: number;
|
|
293
|
+
proposals: readonly DocxProposalRecord[];
|
|
294
|
+
}
|
|
295
|
+
type DocxProposalFailure = Omit<DocxEditFailure, 'code'> & {
|
|
296
|
+
code: DocxEditFailureCode | 'stale-preview' | 'unknown-proposal' | 'proposal-id-conflict';
|
|
297
|
+
proposalId?: string;
|
|
298
|
+
};
|
|
299
|
+
type DocxProposalResult = {
|
|
300
|
+
ok: true;
|
|
301
|
+
snapshot: DocxProposalSnapshot;
|
|
302
|
+
} | {
|
|
303
|
+
ok: false;
|
|
304
|
+
version: string;
|
|
305
|
+
failure: DocxProposalFailure;
|
|
306
|
+
};
|
|
307
|
+
/** Ids that name no proposal are ignored, so a retried withdrawal changes nothing. */
|
|
308
|
+
interface DocxProposalWithdrawRequest {
|
|
309
|
+
expectVersion: string;
|
|
310
|
+
ids: readonly string[];
|
|
311
|
+
}
|
|
312
|
+
interface DocxProposalStateRequest {
|
|
313
|
+
expectVersion: string;
|
|
314
|
+
expectPreviewVersion: number;
|
|
315
|
+
changes: readonly {
|
|
316
|
+
id: string;
|
|
317
|
+
state: DocxProposalState;
|
|
318
|
+
}[];
|
|
319
|
+
}
|
|
320
|
+
/** The revision decisions a snapshot shows, for `YrsRenderEnv.revisionPreview`. */
|
|
321
|
+
declare function proposalRevisionPreview(snapshot: DocxProposalSnapshot): Readonly<Record<string, 'accepted' | 'rejected'>> | undefined;
|
|
322
|
+
|
|
244
323
|
/** One native paragraph in the yrs-backed display-position projection. */
|
|
245
324
|
interface YrsInputParagraphSpan {
|
|
246
325
|
paraId: string;
|
|
@@ -289,11 +368,49 @@ declare function residentCaretDeviceRect(rect: Pick<YrsResidentCaretRect, 'x' |
|
|
|
289
368
|
declare function residentCaretSnapshotForFrame(snapshot: YrsResidentCaretSnapshot, frame: RetainedFrame): YrsResidentCaretSnapshot | null;
|
|
290
369
|
|
|
291
370
|
type ResidentEngineWorkerRequest = {
|
|
371
|
+
id: number;
|
|
372
|
+
type: 'warm';
|
|
373
|
+
} | {
|
|
292
374
|
id: number;
|
|
293
375
|
type: 'bootstrap';
|
|
294
376
|
snapshot: YrsResidentWorkerSnapshot;
|
|
295
377
|
extras: string;
|
|
296
378
|
expectedFrameEpoch: number;
|
|
379
|
+
layoutExtras?: string;
|
|
380
|
+
/** Pages `[start, end)` a full build compiles; the rest stay unbuilt. */
|
|
381
|
+
displayWindow?: [number, number];
|
|
382
|
+
retainBuiltPages?: boolean;
|
|
383
|
+
/**
|
|
384
|
+
* Lay out only as much of the body as fills this many pages; a reply
|
|
385
|
+
* marked `layoutProvisional` is finished by `completeLayout`.
|
|
386
|
+
*/
|
|
387
|
+
provisionalPages?: number;
|
|
388
|
+
/**
|
|
389
|
+
* The document replaces the one this worker showed, which the host
|
|
390
|
+
* hands over from: keep the attached page surfaces for its pages.
|
|
391
|
+
*/
|
|
392
|
+
keepSurfaces?: boolean;
|
|
393
|
+
/** Lay out the document `open` seeded here, not the snapshot's state. */
|
|
394
|
+
opened?: boolean;
|
|
395
|
+
/** The most the worker's editing core may allocate at once. */
|
|
396
|
+
heapLimitBytes?: number;
|
|
397
|
+
} | {
|
|
398
|
+
id: number;
|
|
399
|
+
type: 'open';
|
|
400
|
+
/** The DOCX package, parsed and seeded in a fresh session here. */
|
|
401
|
+
bytes: ArrayBuffer;
|
|
402
|
+
/** The package's SHA-256, when the caller already took it. */
|
|
403
|
+
digest?: string;
|
|
404
|
+
generation?: string;
|
|
405
|
+
/** The most the worker's editing core may allocate at once. */
|
|
406
|
+
heapLimitBytes?: number;
|
|
407
|
+
} | {
|
|
408
|
+
id: number;
|
|
409
|
+
type: 'fontRequirements';
|
|
410
|
+
layoutInput: string;
|
|
411
|
+
} | {
|
|
412
|
+
id: number;
|
|
413
|
+
type: 'encodeState';
|
|
297
414
|
} | {
|
|
298
415
|
id: number;
|
|
299
416
|
type: 'sync';
|
|
@@ -301,12 +418,38 @@ type ResidentEngineWorkerRequest = {
|
|
|
301
418
|
extras: string;
|
|
302
419
|
expectedFrameEpoch: number;
|
|
303
420
|
paintCaret: boolean;
|
|
421
|
+
/**
|
|
422
|
+
* Display extras without the header/footer payload. When present, the
|
|
423
|
+
* snapshot's layout is authoritative: the worker completes the extras
|
|
424
|
+
* from the layout it runs and returns that layout as `layoutJson`.
|
|
425
|
+
*/
|
|
426
|
+
layoutExtras?: string;
|
|
427
|
+
displayWindow?: [number, number];
|
|
428
|
+
retainBuiltPages?: boolean;
|
|
429
|
+
} | {
|
|
430
|
+
id: number;
|
|
431
|
+
type: 'buildPages';
|
|
432
|
+
pages: number[];
|
|
433
|
+
expectedFrameEpoch: number;
|
|
434
|
+
paintCaret: boolean;
|
|
435
|
+
} | {
|
|
436
|
+
id: number;
|
|
437
|
+
type: 'completeLayout';
|
|
438
|
+
expectedFrameEpoch: number;
|
|
439
|
+
paintCaret: boolean;
|
|
440
|
+
/**
|
|
441
|
+
* Measure the rest this many body blocks a step to start with, letting
|
|
442
|
+
* requests that arrive meanwhile run between steps; absent, in one step.
|
|
443
|
+
*/
|
|
444
|
+
sliceBlocks?: number;
|
|
304
445
|
} | {
|
|
305
446
|
id: number;
|
|
306
447
|
type: 'buildFrame';
|
|
307
448
|
extras: string;
|
|
308
449
|
expectedFrameEpoch: number;
|
|
309
450
|
paintCaret: boolean;
|
|
451
|
+
displayWindow?: [number, number];
|
|
452
|
+
retainBuiltPages?: boolean;
|
|
310
453
|
} | {
|
|
311
454
|
id: number;
|
|
312
455
|
type: 'applyInput';
|
|
@@ -315,14 +458,19 @@ type ResidentEngineWorkerRequest = {
|
|
|
315
458
|
expectedFrameEpoch: number;
|
|
316
459
|
profile: boolean;
|
|
317
460
|
paintCaret: boolean;
|
|
461
|
+
displayWindow?: [number, number];
|
|
462
|
+
retainBuiltPages?: boolean;
|
|
318
463
|
} | {
|
|
319
464
|
id: number;
|
|
320
465
|
type: 'applyDelete';
|
|
321
466
|
direction: 'backward' | 'forward';
|
|
467
|
+
count: number;
|
|
322
468
|
selection: YrsSelection;
|
|
323
469
|
expectedFrameEpoch: number;
|
|
324
470
|
profile: boolean;
|
|
325
471
|
paintCaret: boolean;
|
|
472
|
+
displayWindow?: [number, number];
|
|
473
|
+
retainBuiltPages?: boolean;
|
|
326
474
|
} | {
|
|
327
475
|
id: number;
|
|
328
476
|
type: 'applyUpdate';
|
|
@@ -346,7 +494,7 @@ type ResidentEngineWorkerRequest = {
|
|
|
346
494
|
id: number;
|
|
347
495
|
type: 'destroy';
|
|
348
496
|
};
|
|
349
|
-
type ResidentEngineWorkerResponse = {
|
|
497
|
+
type ResidentEngineWorkerResponse = ({
|
|
350
498
|
id: number;
|
|
351
499
|
ok: true;
|
|
352
500
|
frame?: ArrayBuffer;
|
|
@@ -361,9 +509,21 @@ type ResidentEngineWorkerResponse = {
|
|
|
361
509
|
replayMs?: number;
|
|
362
510
|
replayedPages?: number;
|
|
363
511
|
layoutRevision?: number;
|
|
512
|
+
/** Characters an applyDelete removed. */
|
|
513
|
+
deletedUnits?: number;
|
|
364
514
|
/** The worker replica's yrs state vector after this operation, so the
|
|
365
515
|
* next sync can ship a diff instead of the whole document state. */
|
|
366
516
|
stateVector?: ArrayBuffer;
|
|
517
|
+
/** The region layout the worker ran, for a request carrying `layoutExtras`. */
|
|
518
|
+
layoutJson?: string;
|
|
519
|
+
/** `layoutJson` covers only the first pages of the body. */
|
|
520
|
+
layoutProvisional?: boolean;
|
|
521
|
+
/** An `open` reply: the opened package's host metadata JSON. */
|
|
522
|
+
hostJson?: string;
|
|
523
|
+
/** A `fontRequirements` reply. */
|
|
524
|
+
requirementsJson?: string;
|
|
525
|
+
/** An `encodeState` reply: the document state as one yrs v1 update. */
|
|
526
|
+
state?: ArrayBuffer;
|
|
367
527
|
} | {
|
|
368
528
|
id: number;
|
|
369
529
|
ok: false;
|
|
@@ -371,6 +531,11 @@ type ResidentEngineWorkerResponse = {
|
|
|
371
531
|
residentUnavailable?: boolean;
|
|
372
532
|
/** A wasm trap poisoned the worker; it refuses every later request. */
|
|
373
533
|
terminal?: boolean;
|
|
534
|
+
/** The trap followed an allocation the worker's memory could not satisfy. */
|
|
535
|
+
outOfMemory?: boolean;
|
|
536
|
+
}) & {
|
|
537
|
+
/** The worker's wasm memories as the reply left. */
|
|
538
|
+
memory?: WasmModuleMemory[];
|
|
374
539
|
};
|
|
375
540
|
|
|
376
541
|
interface ResidentEngineWorkerFrame {
|
|
@@ -386,6 +551,42 @@ interface ResidentEngineWorkerFrame {
|
|
|
386
551
|
replayMs: number;
|
|
387
552
|
replayedPages: number;
|
|
388
553
|
layoutRevision: number;
|
|
554
|
+
/** Characters an applyDelete removed. */
|
|
555
|
+
deletedUnits: number;
|
|
556
|
+
/** The region layout the worker ran, when the request handed it the layout. */
|
|
557
|
+
layoutJson?: string;
|
|
558
|
+
/** `layoutJson` covers only the first pages; `completeLayout` finishes it. */
|
|
559
|
+
layoutProvisional?: boolean;
|
|
560
|
+
}
|
|
561
|
+
/** A bootstrap/sync whose snapshot layout the worker runs as the only layout. */
|
|
562
|
+
interface ResidentEngineWorkerLayoutOptions {
|
|
563
|
+
/** Display extras minus the header/footer payload the worker's layout supplies. */
|
|
564
|
+
layoutExtras?: string;
|
|
565
|
+
/** The host state vector the snapshot brings the worker to. */
|
|
566
|
+
stateVector?: Uint8Array;
|
|
567
|
+
/** Bootstrap only: lay out just the body's first pages before replying. */
|
|
568
|
+
provisionalPages?: number;
|
|
569
|
+
/** Bootstrap only: lay out the document {@link ResidentEngineWorkerClient.open} opened. */
|
|
570
|
+
opened?: boolean;
|
|
571
|
+
/** Bootstrap only: the epoch of the frame the host shows; the worker's frames follow it. */
|
|
572
|
+
frameEpoch?: number;
|
|
573
|
+
/**
|
|
574
|
+
* Bootstrap only: the most the worker's editing core may allocate at once.
|
|
575
|
+
* An allocation past it stops the worker with {@link ResidentWorkerOutOfMemoryError}.
|
|
576
|
+
*/
|
|
577
|
+
heapLimitBytes?: number;
|
|
578
|
+
}
|
|
579
|
+
/** What an {@link ResidentEngineWorkerClient.open} seeded in the worker. */
|
|
580
|
+
interface ResidentEngineWorkerOpened {
|
|
581
|
+
/** The package's host metadata JSON, for `decodeDocxHostJson`. */
|
|
582
|
+
hostJson: string;
|
|
583
|
+
/** The worker replica's state vector once seeded. */
|
|
584
|
+
stateVector: Uint8Array;
|
|
585
|
+
}
|
|
586
|
+
/** How a bootstrap or sync builds its frame. */
|
|
587
|
+
interface ResidentEngineWorkerSnapshotOptions {
|
|
588
|
+
/** Pages `[start, end)` the frame builds; the rest stay unbuilt. */
|
|
589
|
+
displayWindow?: [number, number];
|
|
389
590
|
}
|
|
390
591
|
interface ResidentEngineOffscreenPage {
|
|
391
592
|
pageId: string;
|
|
@@ -405,26 +606,78 @@ interface ResidentEngineWorkerPort {
|
|
|
405
606
|
declare class ResidentEngineWorkerClient {
|
|
406
607
|
private readonly worker;
|
|
407
608
|
private readonly pending;
|
|
609
|
+
private watchdog;
|
|
408
610
|
private nextId;
|
|
409
611
|
private terminalError;
|
|
410
612
|
private ready;
|
|
411
613
|
private revision;
|
|
412
614
|
private remoteVector;
|
|
413
615
|
private appliedFontsRevision;
|
|
616
|
+
private bootstrapped;
|
|
617
|
+
/** Set once `open` is sent, with the heap limit it opened under. */
|
|
618
|
+
private openedHeapLimit;
|
|
619
|
+
private bootstraps;
|
|
620
|
+
/** Id of the last snapshot request sent; replies to earlier requests must
|
|
621
|
+
* not replace the state it recorded. */
|
|
622
|
+
private lastSnapshotId;
|
|
623
|
+
private keepSurfaces;
|
|
624
|
+
private lastMemory;
|
|
625
|
+
private answeredFrameEpoch;
|
|
626
|
+
private retainBuiltPages;
|
|
414
627
|
constructor(worker?: ResidentEngineWorkerPort);
|
|
415
628
|
isReady(): boolean;
|
|
629
|
+
/** @internal */
|
|
630
|
+
hasFailed(): boolean;
|
|
631
|
+
/** The worker's wasm memories as of its latest reply; null before one. */
|
|
632
|
+
memory(): WasmModuleMemory[] | null;
|
|
416
633
|
layoutRevision(): number;
|
|
634
|
+
/** @internal The newest frame epoch a reply carried; 0 before any frame. */
|
|
635
|
+
answeredFrame(): number;
|
|
636
|
+
/** @internal */
|
|
637
|
+
setRetainBuiltPages(retain: boolean): void;
|
|
638
|
+
/** @internal Whether a frame request other than `buildPages` awaits its reply. */
|
|
639
|
+
frameRequestPending(): boolean;
|
|
417
640
|
/** The worker replica's last reported yrs state vector (null before any). */
|
|
418
641
|
remoteStateVector(): Uint8Array | null;
|
|
419
642
|
/** The fonts revision this worker last applied (null before bootstrap). */
|
|
420
643
|
syncedFontsRevision(): number | null;
|
|
421
|
-
bootstrap
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
644
|
+
/** A bootstrap was sent; later snapshots go as syncs queued behind it. */
|
|
645
|
+
bootstrapSent(): boolean;
|
|
646
|
+
/**
|
|
647
|
+
* Starts over with another document in the same worker: the next request
|
|
648
|
+
* is a bootstrap, which keeps the page surfaces already attached so the
|
|
649
|
+
* new document's pages paint where the old ones were.
|
|
650
|
+
*/
|
|
651
|
+
rebootstrap(): void;
|
|
652
|
+
/**
|
|
653
|
+
* Parses and seeds a DOCX in the worker, which then holds the document:
|
|
654
|
+
* its first layout is a bootstrap with `opened`, and the main replica loads
|
|
655
|
+
* {@link encodeState}. A copy of `bytes` is transferred.
|
|
656
|
+
*/
|
|
657
|
+
open(bytes: Uint8Array, options?: {
|
|
658
|
+
digest?: string;
|
|
659
|
+
generation?: string;
|
|
660
|
+
heapLimitBytes?: number;
|
|
661
|
+
}): Promise<ResidentEngineWorkerOpened>;
|
|
662
|
+
/** The font requirements of a region layout request, read from the opened document. */
|
|
663
|
+
fontRequirements(layoutInput: string): Promise<string>;
|
|
664
|
+
/** The worker's whole document state as one yrs v1 update. */
|
|
665
|
+
encodeState(): Promise<Uint8Array>;
|
|
666
|
+
warm(): Promise<void>;
|
|
667
|
+
bootstrap(snapshot: YrsResidentWorkerSnapshot, extras: string, options?: ResidentEngineWorkerLayoutOptions & ResidentEngineWorkerSnapshotOptions): Promise<ResidentEngineWorkerFrame>;
|
|
668
|
+
sync(snapshot: YrsResidentWorkerSnapshot, extras: string, expectedFrameEpoch: number, paintCaret?: boolean, options?: ResidentEngineWorkerLayoutOptions & ResidentEngineWorkerSnapshotOptions): Promise<ResidentEngineWorkerFrame>;
|
|
669
|
+
/**
|
|
670
|
+
* Lay out the rest of a provisional bootstrap layout: its frame and full
|
|
671
|
+
* layout, or null when a later snapshot already replaced it.
|
|
672
|
+
*/
|
|
673
|
+
completeLayout(expectedFrameEpoch: number, paintCaret?: boolean, sliceBlocks?: number): Promise<ResidentEngineWorkerFrame | null>;
|
|
674
|
+
buildFrame(extras: string, expectedFrameEpoch: number, paintCaret?: boolean, displayWindow?: [number, number]): Promise<ResidentEngineWorkerFrame>;
|
|
675
|
+
/** Build unbuilt display pages; the reply frame carries them. */
|
|
676
|
+
buildPages(pages: number[], expectedFrameEpoch: number, paintCaret?: boolean): Promise<ResidentEngineWorkerFrame>;
|
|
677
|
+
applyInput(text: string, selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean, paintCaret?: boolean, displayWindow?: [number, number]): Promise<ResidentEngineWorkerApplyResult | {
|
|
425
678
|
applied: false;
|
|
426
679
|
}>;
|
|
427
|
-
applyDelete(direction: 'backward' | 'forward', selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean, paintCaret?: boolean): Promise<ResidentEngineWorkerApplyResult | {
|
|
680
|
+
applyDelete(direction: 'backward' | 'forward', selection: YrsSelection, expectedFrameEpoch: number, profile?: boolean, paintCaret?: boolean, count?: number, displayWindow?: [number, number]): Promise<ResidentEngineWorkerApplyResult | {
|
|
428
681
|
applied: false;
|
|
429
682
|
}>;
|
|
430
683
|
/** Drop the worker-painted caret line by re-presenting the caret page's
|
|
@@ -434,15 +687,46 @@ declare class ResidentEngineWorkerClient {
|
|
|
434
687
|
attachCanvases(pages: ResidentEngineOffscreenPage[], activePageIds: string[], devicePixelRatio: number, zoom: number, caretStyle: ResidentCaretPaintStyle): Promise<void>;
|
|
435
688
|
destroy(): void;
|
|
436
689
|
private request;
|
|
690
|
+
/**
|
|
691
|
+
* Requests run in order, so once a snapshot is sent every later request
|
|
692
|
+
* finds its state and fonts in the worker: the next sync can diff against
|
|
693
|
+
* them before this one answers.
|
|
694
|
+
*/
|
|
695
|
+
private recordSent;
|
|
696
|
+
/** Restarted by every message, so a queue of slow but answered requests never trips it. */
|
|
697
|
+
private armWatchdog;
|
|
698
|
+
private disarmWatchdog;
|
|
437
699
|
/** Record a successfully applied bootstrap/sync payload's fonts revision.
|
|
438
700
|
* The state vector is tracked centrally in `onmessage`. */
|
|
439
701
|
private recordSync;
|
|
440
702
|
private fail;
|
|
441
703
|
}
|
|
704
|
+
declare class ResidentWorkerUnavailableError extends Error {
|
|
705
|
+
}
|
|
442
706
|
/** The worker itself failed (crash, timeout, torn-down, corrupt reply). */
|
|
443
707
|
declare class ResidentWorkerFailureError extends Error {
|
|
444
708
|
}
|
|
709
|
+
/** The worker trapped because its wasm memory could not grow any further. */
|
|
710
|
+
declare class ResidentWorkerOutOfMemoryError extends ResidentWorkerUnavailableError {
|
|
711
|
+
/** The worker's wasm memories when it trapped. */
|
|
712
|
+
readonly memory: WasmModuleMemory[];
|
|
713
|
+
constructor(message: string,
|
|
714
|
+
/** The worker's wasm memories when it trapped. */
|
|
715
|
+
memory: WasmModuleMemory[]);
|
|
716
|
+
}
|
|
445
717
|
declare function canUseResidentEngineWorker(): boolean;
|
|
718
|
+
/** @internal */
|
|
719
|
+
declare function preloadResidentEngineWorker(): Promise<void>;
|
|
720
|
+
/** @internal */
|
|
721
|
+
declare function retainPreloadedResidentEngineWorker(): () => void;
|
|
722
|
+
/** @internal */
|
|
723
|
+
declare function takePreloadedResidentEngineWorker(): ResidentEngineWorkerClient | null;
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Preload the editing engine and one spare resident worker. Opt-in.
|
|
727
|
+
* @experimental
|
|
728
|
+
*/
|
|
729
|
+
declare function preloadDocxEngine(): Promise<void>;
|
|
446
730
|
|
|
447
731
|
/** Direct Document-to-yrs load projection. */
|
|
448
732
|
|
|
@@ -534,6 +818,13 @@ declare function saveYrsDocx(session: YrsSession, options?: RepackOptions): Prom
|
|
|
534
818
|
interface YrsDocxHost {
|
|
535
819
|
document: Document;
|
|
536
820
|
referencedFonts: string[];
|
|
821
|
+
/**
|
|
822
|
+
* The `referencedFonts` a document seeded from its package names only for
|
|
823
|
+
* East Asian or complex-script text it does not contain, so no text is
|
|
824
|
+
* measured or drawn with them. Empty when its stories were not seeded; a
|
|
825
|
+
* preview's cover only its own first pages.
|
|
826
|
+
*/
|
|
827
|
+
unusedScriptFonts?: string[];
|
|
537
828
|
embeddedFonts: Map<string, ArrayBuffer>;
|
|
538
829
|
fontTableRelationshipsXml?: string;
|
|
539
830
|
}
|
|
@@ -651,7 +942,23 @@ interface YrsOpeningOptions {
|
|
|
651
942
|
* as one session. Each opening mints a fresh one by default.
|
|
652
943
|
*/
|
|
653
944
|
generation?: string;
|
|
945
|
+
/**
|
|
946
|
+
* Seeds images as `media:{n}` tokens naming their part of the package,
|
|
947
|
+
* instead of `data:` URLs, keeping them out of the document state. Only a
|
|
948
|
+
* replica opened from the same package on a version that reads tokens
|
|
949
|
+
* shows them, so every client of a shared room must be one. Off by default.
|
|
950
|
+
*/
|
|
951
|
+
mediaTokens?: boolean;
|
|
654
952
|
}
|
|
953
|
+
/**
|
|
954
|
+
* A copy of `bytes` whose SHA-256 the platform takes off the calling thread,
|
|
955
|
+
* where it has Web Crypto. Opening that copy unchanged skips hashing the
|
|
956
|
+
* package on the calling thread; any other bytes open as before.
|
|
957
|
+
* @internal
|
|
958
|
+
*/
|
|
959
|
+
declare function prepareDocxBytes(bytes: Uint8Array): Promise<Uint8Array>;
|
|
960
|
+
/** The SHA-256 {@link prepareDocxBytes} took of `bytes`, if it took one. @internal */
|
|
961
|
+
declare function preparedDocxDigest(bytes: Uint8Array): string | undefined;
|
|
655
962
|
/** Snapshot of one paragraph from {@link YrsSession.paragraphs}. */
|
|
656
963
|
interface YrsParagraph {
|
|
657
964
|
/** Session key; not the paragraph's Word `w14:paraId`. */
|
|
@@ -821,6 +1128,10 @@ interface YrsParagraphReceipt {
|
|
|
821
1128
|
interface YrsRevisionReceipt {
|
|
822
1129
|
revisionId: string | null;
|
|
823
1130
|
}
|
|
1131
|
+
/** Where the replacement text landed; after the struck-out text when suggesting. */
|
|
1132
|
+
interface YrsReplaceReceipt extends YrsRevisionReceipt {
|
|
1133
|
+
range?: YrsStoryRange;
|
|
1134
|
+
}
|
|
824
1135
|
/**
|
|
825
1136
|
* Receipt of {@link YrsSession.splitParagraph}. The first half keeps the
|
|
826
1137
|
* original paraId and the second half is re-minted; suggesting
|
|
@@ -876,6 +1187,7 @@ type YrsRawOp = {
|
|
|
876
1187
|
};
|
|
877
1188
|
/** Host context for {@link YrsSession.yrsBlocksForStory} (theme + list numbering). */
|
|
878
1189
|
interface YrsRenderEnv {
|
|
1190
|
+
compatibilityFlags?: Partial<CompatibilityFlags>;
|
|
879
1191
|
tocStyleIds?: string[];
|
|
880
1192
|
paragraphSpacingLinePx?: number;
|
|
881
1193
|
/** Section document-grid snap pitch in px (w:docGrid). The engine derives this from sections; hosts may omit it. */
|
|
@@ -891,6 +1203,13 @@ interface YrsRenderEnv {
|
|
|
891
1203
|
numericIds?: Record<string, number>;
|
|
892
1204
|
/** Include hidden text in visible layout without changing the document. */
|
|
893
1205
|
showHiddenText?: boolean;
|
|
1206
|
+
/** Revision id → decision shown in layout; unlisted revisions render as tracked changes. */
|
|
1207
|
+
revisionPreview?: Readonly<Record<string, 'accepted' | 'rejected'>>;
|
|
1208
|
+
/**
|
|
1209
|
+
* Lay the opened package's images out as `media:{n}` tokens, which a
|
|
1210
|
+
* resolver given the session's `mediaSource` reads. @internal
|
|
1211
|
+
*/
|
|
1212
|
+
mediaTokens?: boolean;
|
|
894
1213
|
}
|
|
895
1214
|
/** Receipt of {@link YrsSession.addComment}. */
|
|
896
1215
|
interface YrsCommentReceipt {
|
|
@@ -939,6 +1258,13 @@ interface YrsResidentCaretSnapshot {
|
|
|
939
1258
|
selection?: YrsSelection | null;
|
|
940
1259
|
}
|
|
941
1260
|
declare function sameYrsSelection(left: YrsSelection | null, right: YrsSelection | null): boolean;
|
|
1261
|
+
/** How far a region layout begun with {@link YrsSession.beginRegionLayout} has come. */
|
|
1262
|
+
interface YrsRegionLayoutProgress {
|
|
1263
|
+
measuredBlocks: number;
|
|
1264
|
+
bodyBlocks: number;
|
|
1265
|
+
/** The retained region layout reply, once the pass is complete. */
|
|
1266
|
+
layoutJson?: string;
|
|
1267
|
+
}
|
|
942
1268
|
/** Opt-in internal stage timings for one resident engine input. @internal */
|
|
943
1269
|
interface YrsEngineApplyProfile {
|
|
944
1270
|
selectionMs: number;
|
|
@@ -990,6 +1316,10 @@ interface YrsResidentWorkerSnapshot {
|
|
|
990
1316
|
layoutInput: string;
|
|
991
1317
|
layoutWithRegions: boolean;
|
|
992
1318
|
layoutRevision: number;
|
|
1319
|
+
/** The document is a preview's cut of a package: its layouts render NUMPAGES empty. */
|
|
1320
|
+
partialDocument?: boolean;
|
|
1321
|
+
/** Which seeded `data:` image sources lay out as `media:{n}` tokens. @internal */
|
|
1322
|
+
mediaSources?: string;
|
|
993
1323
|
}
|
|
994
1324
|
/**
|
|
995
1325
|
* What the sync target already holds, so a snapshot can ship deltas instead
|
|
@@ -1165,6 +1495,11 @@ interface YrsSelectionText {
|
|
|
1165
1495
|
* One live replica of the yrs editing model. Thin typed wrapper over the
|
|
1166
1496
|
* wasm `EditSession` — no editing logic on this side of the boundary.
|
|
1167
1497
|
*/
|
|
1498
|
+
/** An embedded image's bytes, as its `media:{n}` source displays them. */
|
|
1499
|
+
interface YrsMediaSource {
|
|
1500
|
+
bytes: Uint8Array;
|
|
1501
|
+
mimeType: string;
|
|
1502
|
+
}
|
|
1168
1503
|
interface YrsSession extends CollaborationReplica {
|
|
1169
1504
|
/** The yrs client id this replica writes with. */
|
|
1170
1505
|
readonly clientId: number;
|
|
@@ -1189,25 +1524,59 @@ interface YrsSession extends CollaborationReplica {
|
|
|
1189
1524
|
/** Same pass, but the reply omits the measured arena (fetch it on demand
|
|
1190
1525
|
* through {@link YrsSession.retainedKernelInputsJson}). */
|
|
1191
1526
|
layoutDocumentWithRegionsRetainedJson(input: string): string;
|
|
1527
|
+
/**
|
|
1528
|
+
* {@link YrsSession.layoutDocumentWithRegionsRetainedJson} a step at a time:
|
|
1529
|
+
* this lowers the body, and each {@link YrsSession.resumeRegionLayout}
|
|
1530
|
+
* measures up to `blocks` more body blocks. `layoutJson` arrives with the
|
|
1531
|
+
* step that completes the pass, equal to the one-call reply. A document
|
|
1532
|
+
* change, a font registration or another layout in between abandons the
|
|
1533
|
+
* pass, and resuming it then throws.
|
|
1534
|
+
*/
|
|
1535
|
+
beginRegionLayout(input: string): YrsRegionLayoutProgress;
|
|
1536
|
+
resumeRegionLayout(blocks: number): YrsRegionLayoutProgress;
|
|
1192
1537
|
/** Retained `{ measured, options }` for the main-thread display fallback. */
|
|
1193
1538
|
retainedKernelInputsJson(expectedLayoutRevision: number): string;
|
|
1539
|
+
/**
|
|
1540
|
+
* Record region layout `input` as the resident layout without running it
|
|
1541
|
+
* here: a resident worker replica runs it, and snapshots carry it there.
|
|
1542
|
+
* Returns the new layout revision. @internal
|
|
1543
|
+
*/
|
|
1544
|
+
adoptResidentWorkerLayout?(input: string): number;
|
|
1545
|
+
/** The current resident layout ran only in a worker replica. @internal */
|
|
1546
|
+
residentLayoutInWorker?(): boolean;
|
|
1194
1547
|
/** Build display primitives against the session's resident font store. */
|
|
1195
1548
|
buildDisplayListJson(input: string): string;
|
|
1196
1549
|
/** Build a binary FrameDelta v1 against the last host-applied frame. */
|
|
1197
1550
|
buildDisplayListFrame(input: string, expectedFrameEpoch: number): Uint8Array;
|
|
1551
|
+
/**
|
|
1552
|
+
* Limit full display builds to pages `start..end` plus the pages already
|
|
1553
|
+
* built; the rest stay unbuilt placeholders carrying their geometry. @internal
|
|
1554
|
+
*/
|
|
1555
|
+
setDisplayWindow(start: number, end: number): void;
|
|
1556
|
+
/** Keep every previously built page while windowed builds are on. @internal */
|
|
1557
|
+
setDisplayRetainBuiltPages(retain: boolean): void;
|
|
1558
|
+
/** Build the listed unbuilt pages into a FrameDelta v1. @internal */
|
|
1559
|
+
buildDisplayPagesFrame(pages: readonly number[], expectedFrameEpoch: number): Uint8Array;
|
|
1560
|
+
/** Make the next frame a full one, for a host taking over from another engine; no-op once destroyed. */
|
|
1561
|
+
resetFrameBase(): void;
|
|
1198
1562
|
/** Caret geometry from the current resident display frame. */
|
|
1199
1563
|
residentCaretSnapshot(): YrsResidentCaretSnapshot;
|
|
1200
1564
|
/** Apply a collapsed plain-text insertion and return its resident FrameDelta. */
|
|
1201
1565
|
applyInput(text: string, expectedFrameEpoch: number): Uint8Array;
|
|
1202
|
-
/**
|
|
1203
|
-
|
|
1566
|
+
/**
|
|
1567
|
+
* Apply up to `count` (default 1) collapsed character deletions/paragraph
|
|
1568
|
+
* merges, lay out once, and return the resident FrameDelta.
|
|
1569
|
+
*/
|
|
1570
|
+
applyDelete(direction: 'backward' | 'forward', expectedFrameEpoch: number, count?: number): Uint8Array;
|
|
1571
|
+
/** Characters the last resident deletion removed; fewer than asked at a document boundary. */
|
|
1572
|
+
residentDeletedUnits(): number;
|
|
1204
1573
|
/** Instrumented apply used only by opt-in browser performance traces. */
|
|
1205
1574
|
applyInputProfiled(text: string, expectedFrameEpoch: number): {
|
|
1206
1575
|
frame: Uint8Array;
|
|
1207
1576
|
profile: YrsEngineApplyProfile;
|
|
1208
1577
|
};
|
|
1209
1578
|
/** Instrumented deletion used only by opt-in browser performance traces. */
|
|
1210
|
-
applyDeleteProfiled(direction: 'backward' | 'forward', expectedFrameEpoch: number): {
|
|
1579
|
+
applyDeleteProfiled(direction: 'backward' | 'forward', expectedFrameEpoch: number, count?: number): {
|
|
1211
1580
|
frame: Uint8Array;
|
|
1212
1581
|
profile: YrsEngineApplyProfile;
|
|
1213
1582
|
};
|
|
@@ -1239,14 +1608,51 @@ interface YrsSession extends CollaborationReplica {
|
|
|
1239
1608
|
* one seeded alike by the same client; see {@link beginOpening}.
|
|
1240
1609
|
*/
|
|
1241
1610
|
openDocx(bytes: Uint8Array, seedStories: boolean, options?: YrsOpeningOptions): YrsDocxHost;
|
|
1611
|
+
/**
|
|
1612
|
+
* Opens a DOCX for display only, from the body's first `blocks` blocks:
|
|
1613
|
+
* enough to lay out its first pages with a prefix pass before the whole
|
|
1614
|
+
* document is opened. The session cannot save. `null`, opening nothing,
|
|
1615
|
+
* for a document with a float placed from outside the text or a section
|
|
1616
|
+
* with columns, which no cut of the body lays out like the whole: open it
|
|
1617
|
+
* with {@link openDocx}. @internal
|
|
1618
|
+
*/
|
|
1619
|
+
openDocxPreview(bytes: Uint8Array, blocks: number): YrsDocxHost | null;
|
|
1620
|
+
/** Opened by {@link openDocxPreview}: its document refuses every change. @internal */
|
|
1621
|
+
isDisplayOnly(): boolean;
|
|
1622
|
+
/**
|
|
1623
|
+
* Marks whether the document is a preview's, as a replica of one is: its
|
|
1624
|
+
* layouts render NUMPAGES empty. @internal
|
|
1625
|
+
*/
|
|
1626
|
+
setPartialDocument(partial: boolean): void;
|
|
1627
|
+
/**
|
|
1628
|
+
* The region layout of only as much of the body as fills `pages` pages;
|
|
1629
|
+
* a reply marked `provisional` covers a prefix. @internal
|
|
1630
|
+
*/
|
|
1631
|
+
layoutDocumentWithRegionsPrefixRetainedJson(input: string, pages: number): string;
|
|
1242
1632
|
/**
|
|
1243
1633
|
* Starts a new opening of the document: its generation, replicated to
|
|
1244
1634
|
* every replica, becomes part of every session anchor. Every seeding entry
|
|
1245
1635
|
* point calls it; call it after building a document another way.
|
|
1246
1636
|
*/
|
|
1247
1637
|
beginOpening(generation?: string): void;
|
|
1638
|
+
/** Unions seeded opaque sequence names into document state. @internal */
|
|
1639
|
+
seedOpaqueSequences(names: readonly string[]): void;
|
|
1248
1640
|
/** Materializes the retained canonical package for compatibility APIs. */
|
|
1249
1641
|
materializeDocx(): Document | null;
|
|
1642
|
+
/**
|
|
1643
|
+
* The displayed bytes and media type of the package part a `media:{n}`
|
|
1644
|
+
* image source names, or `null` for any other source or a destroyed session.
|
|
1645
|
+
*/
|
|
1646
|
+
mediaSource(token: string): YrsMediaSource | null;
|
|
1647
|
+
/** Changes on package opening and session destruction. */
|
|
1648
|
+
mediaScope(): number;
|
|
1649
|
+
/** The `data:` URL a token stands for, or `null` when unavailable or destroyed. */
|
|
1650
|
+
mediaDataUrl(token: string): string | null;
|
|
1651
|
+
/**
|
|
1652
|
+
* Lays this replica's `data:` image sources out as the `media:{n}` tokens a
|
|
1653
|
+
* snapshot's `mediaSources` names. @internal
|
|
1654
|
+
*/
|
|
1655
|
+
loadMediaSources(json: string): void;
|
|
1250
1656
|
/**
|
|
1251
1657
|
* Seeds stories and returns paragraph IDs in document order. Seeding a
|
|
1252
1658
|
* document that has no opening yet starts one; see {@link beginOpening}.
|
|
@@ -1342,7 +1748,7 @@ interface YrsSession extends CollaborationReplica {
|
|
|
1342
1748
|
*/
|
|
1343
1749
|
deleteRange(range: YrsStoryRange, suggesting?: YrsAuthor): YrsRevisionReceipt;
|
|
1344
1750
|
/** Replaces a range with text in one transaction (one shared revision when suggesting). */
|
|
1345
|
-
replaceRange(range: YrsStoryRange, text: string, suggesting?: YrsAuthor):
|
|
1751
|
+
replaceRange(range: YrsStoryRange, text: string, suggesting?: YrsAuthor): YrsReplaceReceipt;
|
|
1346
1752
|
/**
|
|
1347
1753
|
* Splits a paragraph by inserting one pilcrow. The FIRST half keeps the
|
|
1348
1754
|
* original paraId; the SECOND half is re-minted (`secondParaId`).
|
|
@@ -1428,6 +1834,8 @@ interface YrsSession extends CollaborationReplica {
|
|
|
1428
1834
|
listComments(): YrsCommentInfo[];
|
|
1429
1835
|
/** Story ids in the document, sorted. */
|
|
1430
1836
|
storyIds(): string[];
|
|
1837
|
+
/** Whether the document has a story with this id, without listing them all. */
|
|
1838
|
+
hasStory(story: string): boolean;
|
|
1431
1839
|
/** Story length in UTF-16 units (every embed, pilcrows included, counts 1). */
|
|
1432
1840
|
storyLength(story: string): number;
|
|
1433
1841
|
/** Returns the story's canonical-stream checksum. */
|
|
@@ -1442,6 +1850,27 @@ interface YrsSession extends CollaborationReplica {
|
|
|
1442
1850
|
paragraphSpans(story: string): YrsParagraphLength[];
|
|
1443
1851
|
/** The raw formatted-segment view (the render bridge's input). */
|
|
1444
1852
|
storySegments(story: string): YrsStorySegment[];
|
|
1853
|
+
/**
|
|
1854
|
+
* The current story revision and the sorted ids of the stories created,
|
|
1855
|
+
* edited, or deleted after revision `since` (0 lists every story).
|
|
1856
|
+
*/
|
|
1857
|
+
storiesChangedSince(since: number): {
|
|
1858
|
+
revision: number;
|
|
1859
|
+
stories: string[];
|
|
1860
|
+
};
|
|
1861
|
+
/**
|
|
1862
|
+
* One digest per unit of {@link YrsSession.storySegments}, split after each
|
|
1863
|
+
* pilcrow. Equal digests mean equal segments.
|
|
1864
|
+
*/
|
|
1865
|
+
storySegmentUnitDigests(story: string): string[];
|
|
1866
|
+
/** The segments of the listed units, each as {@link YrsSession.storySegments} gives them. */
|
|
1867
|
+
storySegmentUnits(story: string, units: readonly number[]): YrsStorySegment[][];
|
|
1868
|
+
/**
|
|
1869
|
+
* The payload of the story's `tableIndex`-th table embed, as
|
|
1870
|
+
* {@link YrsSession.storySegments} gives it, or null when there is no such
|
|
1871
|
+
* table. Reads the one table rather than the whole story.
|
|
1872
|
+
*/
|
|
1873
|
+
tablePayload(story: string, tableIndex: number): Record<string, unknown> | null;
|
|
1445
1874
|
/** A paragraph's story span (start unit, pilcrow index). */
|
|
1446
1875
|
locateParagraph(story: string, paraId: string): YrsParagraphSpan;
|
|
1447
1876
|
/**
|
|
@@ -1501,6 +1930,28 @@ interface YrsSession extends CollaborationReplica {
|
|
|
1501
1930
|
}): YrsTargetEditResult;
|
|
1502
1931
|
/** Accepted-view texts around a paragraph-keyed selection. @internal */
|
|
1503
1932
|
selectionText(range: YrsStoryRange): YrsSelectionText;
|
|
1933
|
+
/**
|
|
1934
|
+
* Proposes a round of tracked changes: every new proposal resolves against `expectVersion` and
|
|
1935
|
+
* the round applies as one batch outside undo history, or nothing changes. A retried id with
|
|
1936
|
+
* the same edit is a no-op; the same id with another edit refuses. Opening another document
|
|
1937
|
+
* forgets every proposal.
|
|
1938
|
+
*/
|
|
1939
|
+
proposeChanges(request: DocxProposalRequest): DocxProposalResult;
|
|
1940
|
+
/**
|
|
1941
|
+
* Sets how proposals render. Decisions change neither the document, its version nor undo
|
|
1942
|
+
* history; each call that changes one increments `previewVersion`.
|
|
1943
|
+
*/
|
|
1944
|
+
setProposalStates(request: DocxProposalStateRequest): DocxProposalResult;
|
|
1945
|
+
/**
|
|
1946
|
+
* Withdraws proposals, settling each as its decision previews it: accepted ones apply for good,
|
|
1947
|
+
* rejected and undecided ones are removed. The settlement is one change against `expectVersion`
|
|
1948
|
+
* outside undo history, so a later round resolves against the text the preview showed.
|
|
1949
|
+
*/
|
|
1950
|
+
withdrawProposals(request: DocxProposalWithdrawRequest): DocxProposalResult;
|
|
1951
|
+
/** The proposals in the order they were made. */
|
|
1952
|
+
getProposals(): DocxProposalSnapshot;
|
|
1953
|
+
/** Listens for new proposals, decisions and a forgotten registry. Returns the unsubscribe. */
|
|
1954
|
+
onProposalChange(listener: (snapshot: DocxProposalSnapshot) => void): () => void;
|
|
1504
1955
|
/**
|
|
1505
1956
|
* Exports the committed document as read-only structured content with the version it was read
|
|
1506
1957
|
* at; anchors resolve against that version. Nothing is committed, flushed or published.
|
|
@@ -1560,6 +2011,11 @@ interface CreateYrsSessionOptions {
|
|
|
1560
2011
|
*/
|
|
1561
2012
|
clientId?: number;
|
|
1562
2013
|
}
|
|
2014
|
+
/**
|
|
2015
|
+
* Decodes the host metadata a resident worker's `open` replied with, for the
|
|
2016
|
+
* package `source` it opened. @internal
|
|
2017
|
+
*/
|
|
2018
|
+
declare function decodeDocxHostJson(json: string, source: Uint8Array): YrsDocxHost;
|
|
1563
2019
|
/**
|
|
1564
2020
|
* Creates a yrs editing replica. The first call dynamically imports and
|
|
1565
2021
|
* initializes the embedded docx-edit wasm (~440KB base64) — callers must
|
|
@@ -1567,4 +2023,4 @@ interface CreateYrsSessionOptions {
|
|
|
1567
2023
|
*/
|
|
1568
2024
|
declare function createYrsSession(options?: CreateYrsSessionOptions): Promise<YrsSession>;
|
|
1569
2025
|
|
|
1570
|
-
export { type
|
|
2026
|
+
export { type DocxSourceStory as $, type DocxParagraphIdDiagnostic as A, type DocxParagraphIdOrigin as B, type CollaborationReplica as C, type DocxOccurrence as D, type DocxParagraphIdRefusal as E, type DocxParagraphIdentity as F, type DocxParagraphIdentityReceipt as G, type DocxParagraphIdentitySnapshot as H, type DocxParagraphOrigin as I, type DocxParagraphRef as J, type DocxParagraphSavePlan as K, type DocxPersistedParagraphAnchor as L, type DocxProposalFailure as M, type DocxProposalInput as N, type DocxProposalRecord as O, type DocxProposalRequest as P, type DocxProposalResult as Q, type DocxProposalSnapshot as R, type DocxProposalState as S, type DocxProposalStateRequest as T, type DocxProposalWithdrawRequest as U, type DocxSavedDocument as V, type DocxSavedParagraph as W, type DocxSessionParagraphAnchor as X, type YrsSession as Y, type DocxSessionSave as Z, type DocxSourceParagraphAnchor as _, type YrsRenderEnv as a, type YrsWatermark as a$, type ResidentCaretPaintStyle as a0, type ResidentEngineOffscreenPage as a1, type ResidentEngineWorkerApplyResult as a2, ResidentEngineWorkerClient as a3, type ResidentEngineWorkerFrame as a4, type ResidentEngineWorkerOpened as a5, ResidentWorkerFailureError as a6, ResidentWorkerOutOfMemoryError as a7, type YrsAuthor as a8, type YrsCellBorder as a9, type YrsRegionLayoutProgress as aA, type YrsReplaceReceipt as aB, type YrsResidentCaretRect as aC, type YrsResidentCaretSnapshot as aD, type YrsResidentFontRegistration as aE, type YrsResidentWorkerSnapshot as aF, type YrsResidentWorkerSyncOptions as aG, type YrsResolveReceipt as aH, type YrsResolvedCommentAnchor as aI, type YrsRevisionReceipt as aJ, type YrsRunMark as aK, type YrsSelectionContext as aL, type YrsSelectionText as aM, type YrsSplitReceipt as aN, type YrsStickyPosition as aO, type YrsStoryRange as aP, type YrsStorySeed as aQ, type YrsStorySegment as aR, type YrsTableLoc as aS, type YrsTableRange as aT, type YrsTableReceipt as aU, type YrsTargetEditResult as aV, type YrsTextColor as aW, type YrsTextMatch as aX, type YrsTextSearchOptions as aY, type YrsTriState as aZ, type YrsUndoCaptureMode as a_, type YrsCellBorders as aa, type YrsCellLoc as ab, type YrsChangeTarget as ac, type YrsCommentInfo as ad, type YrsCommentReceipt as ae, type YrsContentControlValue as af, type YrsDocxHost as ag, type YrsEngineApplyProfile as ah, type YrsHyperlinkAttrs as ai, type YrsImageGeometry as aj, type YrsInlineFormatDelta as ak, type YrsInputParagraphSeed as al, type YrsInputParagraphSpan as am, type YrsInputPositionMap as an, type YrsMediaSource as ao, type YrsNumberingProperties as ap, type YrsOpeningOptions as aq, type YrsParaOffset as ar, type YrsParagraph as as, type YrsParagraphAttrs as at, type YrsParagraphLength as au, type YrsParagraphReceipt as av, type YrsParagraphSeed as aw, type YrsParagraphSpan as ax, type YrsParagraphTabStop as ay, type YrsRawOp as az, type CollaborationTransport as b, canUseResidentEngineWorker as b0, captureSessionSave as b1, compareYrsLocs as b2, createYrsInputPositionMap as b3, createYrsSession as b4, decodeDocxHostJson as b5, displayPositionToYrsLoc as b6, documentToYrs as b7, preloadDocxEngine as b8, preloadResidentEngineWorker as b9, prepareDocxBytes as ba, preparedDocxDigest as bb, proposalRevisionPreview as bc, residentCaretDeviceRect as bd, residentCaretSnapshotForFrame as be, retainPreloadedResidentEngineWorker as bf, sameYrsSelection as bg, saveYrsDocx as bh, takePreloadedResidentEngineWorker as bi, writeSessionSave as bj, yrsLocToDisplayPosition as bk, yrsToDocument as bl, type CollaborationProviderOptions as c, type CollaborationStatus as d, type CollaborationPeer as e, type CollaborationCursor as f, type CollaborationPeerListener as g, type CollaborationStatusListener as h, type CollaborationErrorListener as i, type YrsSelection as j, type CollaborationAwarenessState as k, CollaborationError as l, type CollaborationErrorCode as m, type CollaborationPresence as n, type CollaborationResolvedUser as o, type CollaborationStatusChange as p, type CollaborationTextInsertion as q, type CollaborationTransportEvent as r, type CollaborationUpdateOrigin as s, type CollaborationUser as t, type YrsLoc as u, type YrsRevisionInfo as v, type CreateYrsSessionOptions as w, type DocxParagraphAnchor as x, type DocxParagraphAnchorResult as y, type DocxParagraphIdAssignment as z };
|