@superdoc/sdk 2.19.0-next.2 → 2.19.0-next.20
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 +56 -0
- package/dist/generated/client.d.ts +59 -0
- package/dist/generated/contract.cjs +1 -1
- package/dist/generated/contract.js +1 -1
- package/dist/runtime/host.cjs +61 -19
- package/dist/runtime/host.d.ts +3 -0
- package/dist/runtime/host.js +61 -19
- package/dist/runtime/sdk-version.generated.cjs +1 -1
- package/dist/runtime/sdk-version.generated.d.ts +1 -1
- package/dist/runtime/sdk-version.generated.js +1 -1
- package/dist/runtime/state-directory.cjs +132 -0
- package/dist/runtime/state-directory.d.ts +14 -0
- package/dist/runtime/state-directory.js +127 -0
- package/dist/runtime/transport-common.d.ts +2 -0
- package/package.json +8 -8
- package/tools/tools-policy.json +1 -1
package/README.md
CHANGED
|
@@ -37,6 +37,42 @@ room sync on every call. To cut round trips further, batch related edits with
|
|
|
37
37
|
`document.mutations.apply()` or arbitrary operations with
|
|
38
38
|
`document.plan.execute()`.
|
|
39
39
|
|
|
40
|
+
For read-only hosts and containers, configure a writable state directory:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
const client = new SuperDocClient({ stateDir: '/tmp/superdoc-state' });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`stateDir` takes precedence over `SUPERDOC_CLI_STATE_DIR` in the client's child
|
|
47
|
+
environment. Configured directories remain after disposal. Without either
|
|
48
|
+
setting, the SDK keeps the usual home directory state when it is usable;
|
|
49
|
+
otherwise it allocates a private directory in the child environment's temporary
|
|
50
|
+
location. `connect()` (including lazy connection on `open()`) checks that state
|
|
51
|
+
can be written and throws `SuperDocCliError` with code
|
|
52
|
+
`STATE_DIRECTORY_UNWRITABLE` and path details if it cannot. An invalid explicit
|
|
53
|
+
setting never silently falls back.
|
|
54
|
+
|
|
55
|
+
The home default is `~/.superdoc-cli/state/v1`. Each open document uses
|
|
56
|
+
`<state root>/contexts/<context ID>/`, where the root is the default,
|
|
57
|
+
configured `stateDir`, environment override, or SDK-owned temporary directory.
|
|
58
|
+
The context contains `metadata.json`, an `original.docx` input copy, a
|
|
59
|
+
`working.docx` checkpoint copy, and the host's `owner` file; operations can also
|
|
60
|
+
create a temporary `lock` file. Budget writable storage for both DOCX copies.
|
|
61
|
+
State does not need to live in the working directory, which can be read-only.
|
|
62
|
+
Temporary fallback uses the child's `TMPDIR` (or `TMP`/`TEMP`) on Unix; that
|
|
63
|
+
location must be writable. A configured state directory needs writable storage
|
|
64
|
+
even when the temporary directory is read-only. Save destinations must also be
|
|
65
|
+
writable; choose an explicit output path outside a read-only working directory.
|
|
66
|
+
|
|
67
|
+
`close()` removes that document's context. `dispose()` removes only an
|
|
68
|
+
SDK-allocated temporary root, after active operations finish and the host has
|
|
69
|
+
stopped. State remains when disposal fails. If the host exits unsuccessfully, disposal
|
|
70
|
+
throws `HOST_SHUTDOWN_FAILED` with the retained path in `details`; that client
|
|
71
|
+
remains failed, and the retained files are available for recovery. Killing
|
|
72
|
+
the SDK parent can leave temporary state behind; the operating system or host
|
|
73
|
+
operator must reclaim it. A new client gets a separate private root and does
|
|
74
|
+
not sweep another client's state.
|
|
75
|
+
|
|
40
76
|
For token-authenticated Hocuspocus or y-websocket rooms, pass the credential as
|
|
41
77
|
an option on that document's open request:
|
|
42
78
|
|
|
@@ -96,6 +132,26 @@ if (matches.total === 1) {
|
|
|
96
132
|
}
|
|
97
133
|
```
|
|
98
134
|
|
|
135
|
+
## Tracked comparison with direct style definitions
|
|
136
|
+
|
|
137
|
+
For standalone V2 comparisons, `styleChangeMode: 'direct'` lets you explicitly
|
|
138
|
+
carry the target style definitions while applying body edits as tracked changes:
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
const diff = await older.diff.compare({ targetSnapshot, styleChangeMode: 'direct' });
|
|
142
|
+
const result = await older.diff.apply({ diff, changeMode: 'tracked', styleChangeMode: 'direct' });
|
|
143
|
+
console.log(result.styleChanges); // { changeMode: 'direct', partUris: [...] }, when styles changed
|
|
144
|
+
await older.save({ out: 'comparison.docx' });
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Set the policy on both calls: compare reports eligibility for that policy;
|
|
148
|
+
apply requires its own explicit consent. Style definitions are applied directly
|
|
149
|
+
and remain if the body revisions are rejected in Word. A style-only comparison
|
|
150
|
+
creates no body revisions. Without this option, changed style definitions still
|
|
151
|
+
block tracked apply. Unsupported numbering, settings, and other package changes
|
|
152
|
+
retain their existing restrictions. Suggest-only versioned review sessions
|
|
153
|
+
refuse this direct-style option.
|
|
154
|
+
|
|
99
155
|
## Tracked comparison with exact-file review
|
|
100
156
|
|
|
101
157
|
The SDK's `diff.capture` and `diff.compare` describe a snapshot comparison. A
|
|
@@ -26693,6 +26693,7 @@ export interface DocContentControlsDeleteParams {
|
|
|
26693
26693
|
textboxId: string;
|
|
26694
26694
|
});
|
|
26695
26695
|
};
|
|
26696
|
+
overrideDeletionLock?: boolean;
|
|
26696
26697
|
}
|
|
26697
26698
|
export interface DocContentControlsCopyParams {
|
|
26698
26699
|
doc?: string;
|
|
@@ -30733,6 +30734,7 @@ export interface DocDiffCompareParams {
|
|
|
30733
30734
|
};
|
|
30734
30735
|
payload: Record<string, unknown>;
|
|
30735
30736
|
};
|
|
30737
|
+
styleChangeMode?: string;
|
|
30736
30738
|
}
|
|
30737
30739
|
export interface DocDiffApplyParams {
|
|
30738
30740
|
doc?: string;
|
|
@@ -30801,6 +30803,7 @@ export interface DocDiffApplyParams {
|
|
|
30801
30803
|
}>;
|
|
30802
30804
|
payload: Record<string, unknown>;
|
|
30803
30805
|
};
|
|
30806
|
+
styleChangeMode?: string;
|
|
30804
30807
|
}
|
|
30805
30808
|
export interface DocExportToDocxParams {
|
|
30806
30809
|
doc?: string;
|
|
@@ -103374,6 +103377,55 @@ export type DocSelectionCurrentResult = {
|
|
|
103374
103377
|
});
|
|
103375
103378
|
coordinateSpace?: "visible" | "tracked";
|
|
103376
103379
|
}) | null;
|
|
103380
|
+
tableSelection?: ({
|
|
103381
|
+
kind: "tableCells";
|
|
103382
|
+
type: "table" | "cell" | "cells";
|
|
103383
|
+
tableId: string;
|
|
103384
|
+
story?: ({
|
|
103385
|
+
kind: "story";
|
|
103386
|
+
storyType: "body";
|
|
103387
|
+
}) | ({
|
|
103388
|
+
kind: "story";
|
|
103389
|
+
storyType: "headerFooterSlot";
|
|
103390
|
+
section: {
|
|
103391
|
+
kind: "section";
|
|
103392
|
+
sectionId: string;
|
|
103393
|
+
};
|
|
103394
|
+
headerFooterKind: "header" | "footer";
|
|
103395
|
+
variant: "default" | "first" | "even";
|
|
103396
|
+
resolution?: "effective" | "explicit";
|
|
103397
|
+
onWrite?: "materializeIfInherited" | "editResolvedPart" | "error";
|
|
103398
|
+
}) | ({
|
|
103399
|
+
kind: "story";
|
|
103400
|
+
storyType: "headerFooterPart";
|
|
103401
|
+
refId: string;
|
|
103402
|
+
}) | ({
|
|
103403
|
+
kind: "story";
|
|
103404
|
+
storyType: "footnote";
|
|
103405
|
+
noteId: string;
|
|
103406
|
+
}) | ({
|
|
103407
|
+
kind: "story";
|
|
103408
|
+
storyType: "endnote";
|
|
103409
|
+
noteId: string;
|
|
103410
|
+
}) | ({
|
|
103411
|
+
kind: "story";
|
|
103412
|
+
storyType: "textbox";
|
|
103413
|
+
textboxId: string;
|
|
103414
|
+
});
|
|
103415
|
+
start: {
|
|
103416
|
+
rowIndex: number;
|
|
103417
|
+
columnIndex: number;
|
|
103418
|
+
};
|
|
103419
|
+
end: {
|
|
103420
|
+
rowIndex: number;
|
|
103421
|
+
columnIndex: number;
|
|
103422
|
+
};
|
|
103423
|
+
cells: Array<{
|
|
103424
|
+
nodeId: string;
|
|
103425
|
+
rowIndex: number;
|
|
103426
|
+
columnIndex: number;
|
|
103427
|
+
}>;
|
|
103428
|
+
}) | null;
|
|
103377
103429
|
activeMarks: Array<string>;
|
|
103378
103430
|
activeCommentIds: Array<string>;
|
|
103379
103431
|
activeChangeIds: Array<string>;
|
|
@@ -122818,6 +122870,10 @@ export type DocDiffCompareResult = {
|
|
|
122818
122870
|
};
|
|
122819
122871
|
export type DocDiffApplyResult = {
|
|
122820
122872
|
appliedOperations: number;
|
|
122873
|
+
styleChanges?: {
|
|
122874
|
+
changeMode: "direct";
|
|
122875
|
+
partUris: Array<string>;
|
|
122876
|
+
};
|
|
122821
122877
|
operationReceipts: Array<({
|
|
122822
122878
|
operationId: string;
|
|
122823
122879
|
disposition: "review-created";
|
|
@@ -149090,6 +149146,7 @@ export interface DocContentControlsDeleteBoundParams {
|
|
|
149090
149146
|
textboxId: string;
|
|
149091
149147
|
});
|
|
149092
149148
|
};
|
|
149149
|
+
overrideDeletionLock?: boolean;
|
|
149093
149150
|
}
|
|
149094
149151
|
export interface DocContentControlsCopyBoundParams {
|
|
149095
149152
|
out?: string;
|
|
@@ -152904,6 +152961,7 @@ export interface DocDiffCompareBoundParams {
|
|
|
152904
152961
|
};
|
|
152905
152962
|
payload: Record<string, unknown>;
|
|
152906
152963
|
};
|
|
152964
|
+
styleChangeMode?: string;
|
|
152907
152965
|
}
|
|
152908
152966
|
export interface DocDiffApplyBoundParams {
|
|
152909
152967
|
out?: string;
|
|
@@ -152970,6 +153028,7 @@ export interface DocDiffApplyBoundParams {
|
|
|
152970
153028
|
}>;
|
|
152971
153029
|
payload: Record<string, unknown>;
|
|
152972
153030
|
};
|
|
153031
|
+
styleChangeMode?: string;
|
|
152973
153032
|
}
|
|
152974
153033
|
export interface DocExportToDocxBoundParams {
|
|
152975
153034
|
mode?: string;
|