superdoc 2.23.0-next.10 → 2.23.0-next.12

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.
@@ -19,7 +19,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
19
19
  var PRIVATE_ENGINE_INFO = (0, _superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
20
20
  var ENGINE_INFO = Object.freeze({
21
21
  ...PRIVATE_ENGINE_INFO,
22
- superdocVersion: "2.23.0-next.10",
22
+ superdocVersion: "2.23.0-next.12",
23
23
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
24
24
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
25
25
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -18,7 +18,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
18
18
  var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
19
19
  var ENGINE_INFO = Object.freeze({
20
20
  ...PRIVATE_ENGINE_INFO,
21
- superdocVersion: "2.23.0-next.10",
21
+ superdocVersion: "2.23.0-next.12",
22
22
  roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
23
23
  supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
24
24
  supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
@@ -1,4 +1,9 @@
1
1
  import { DocumentApiSurface } from '../index.js';
2
+ import { PlainTextInsertInput } from '../insert/insert.js';
3
+ import { TextReplaceInput } from '../replace/replace.js';
4
+ import { BodyStoryLocator } from '../types/story.types.js';
5
+ import { OperationCancellation } from '../write/operation-cancellation.js';
6
+ import { TrackedTextMutationOptions } from '../write/write.js';
2
7
  import { OPERATION_DEFINITIONS } from './operation-definitions.js';
3
8
  import { OperationId } from './types.js';
4
9
  type ResolveMemberPath<T, Path extends string> = Path extends `${infer Head}.${infer Tail}` ? Head extends keyof T ? ResolveMemberPath<T[Head], Tail> : never : Path extends keyof T ? T[Path] : never;
@@ -18,8 +23,7 @@ export type OperationRegistry = {
18
23
  output: Id extends 'mutations.preview' | 'mutations.apply' | 'plan.execute' ? Awaited<MethodReturn<Method>> : MethodReturn<Method>;
19
24
  } : never;
20
25
  };
21
- /** Typed invoke request narrowed by `operationId`. */
22
- export type InvokeRequest<T extends OperationId> = OperationRegistry[T]['options'] extends never ? {
26
+ type MethodInvokeRequest<T extends OperationId> = OperationRegistry[T]['options'] extends never ? {
23
27
  operationId: T;
24
28
  input: OperationRegistry[T]['input'];
25
29
  options?: never;
@@ -28,6 +32,19 @@ export type InvokeRequest<T extends OperationId> = OperationRegistry[T]['options
28
32
  input: OperationRegistry[T]['input'];
29
33
  options?: OperationRegistry[T]['options'];
30
34
  };
35
+ type AttributedTextInvokeRequest<T extends OperationId> = T extends 'insert' ? {
36
+ operationId: T;
37
+ input: PlainTextInsertInput;
38
+ options: TrackedTextMutationOptions & OperationCancellation;
39
+ } : T extends 'replace' ? {
40
+ operationId: T;
41
+ input: Exclude<TextReplaceInput, {
42
+ target: BodyStoryLocator;
43
+ }>;
44
+ options: TrackedTextMutationOptions;
45
+ } : never;
46
+ /** Typed invoke request narrowed by `operationId` and supported content shape. */
47
+ export type InvokeRequest<T extends OperationId> = MethodInvokeRequest<T> | AttributedTextInvokeRequest<T>;
31
48
  /** Typed invoke result narrowed by `operationId`. */
32
49
  export type InvokeResult<T extends OperationId> = T extends 'mutations.preview' | 'mutations.apply' ? Promise<OperationRegistry[T]['output']> : T extends 'plan.execute' ? OperationRegistry[T]['output'] | Promise<OperationRegistry[T]['output']> : OperationRegistry[T]['output'];
33
50
  /** Loose request for callers that resolve operation identity at runtime. */
@@ -1,6 +1,6 @@
1
1
  import { SelectionTarget, DeleteBehavior, TargetLocator } from '../types/address.js';
2
2
  import { TextMutationReceipt } from '../types/receipt.js';
3
- import { MutationOptions } from '../types/mutation-plan.types.js';
3
+ import { TextMutationOptions } from '../write/write.js';
4
4
  import { StoryLocator } from '../types/story.types.js';
5
5
  import { SelectionMutationAdapter } from '../selection-mutation.js';
6
6
  export type DeleteInput = TargetLocator & {
@@ -17,4 +17,4 @@ export type DeleteInput = TargetLocator & {
17
17
  /** Target a specific document story (body, header, footer, footnote, endnote). */
18
18
  in?: StoryLocator;
19
19
  };
20
- export declare function executeDelete(adapter: SelectionMutationAdapter, input: DeleteInput, options?: MutationOptions): TextMutationReceipt;
20
+ export declare function executeDelete(adapter: SelectionMutationAdapter, input: DeleteInput, options?: TextMutationOptions): TextMutationReceipt;
@@ -30,7 +30,7 @@ import { CreateAdapter, CreateApi } from './create/create.js';
30
30
  import { BlocksAdapter, BlocksApi } from './blocks/blocks.js';
31
31
  import { TableLocator, TableMutationResult, TablesConvertFromTextInput, TablesMoveInput, TablesSplitInput, TablesConvertToTextInput, TablesSetLayoutInput, TablesInsertRowInput, TablesDeleteRowInput, TablesMoveRowInput, TablesSetRowHeightInput, TablesDistributeRowsInput, TablesSetRowOptionsInput, TablesInsertColumnInput, TablesDeleteColumnInput, TablesMoveColumnInput, TablesSetColumnWidthInput, TablesDistributeColumnsInput, TablesInsertCellInput, TablesDeleteCellInput, TablesMergeCellsInput, TablesUnmergeCellsInput, TablesSplitCellInput, TablesSetCellPropertiesInput, TablesSetCellTextInput, TablesSortInput, TablesSetAltTextInput, TablesSetStyleInput, TablesClearStyleInput, TablesSetStyleOptionInput, TablesSetBorderInput, TablesClearBorderInput, TablesApplyBorderPresetInput, TablesSetShadingInput, TablesClearShadingInput, TablesSetTablePaddingInput, TablesSetCellPaddingInput, TablesSetCellSpacingInput, TablesClearCellSpacingInput, TablesApplyStyleInput, TablesSetBordersInput, TablesSetTableOptionsInput, TablesApplyPresetInput, TablesGetInput, TablesGetOutput, TablesGetCellsInput, TablesGetCellsOutput, TablesGetPropertiesInput, TablesGetPropertiesOutput, TablesGetStylesInput, TablesGetStylesOutput, TablesSetDefaultStyleInput, TablesClearDefaultStyleInput } from './types/table-operations.types.js';
32
32
  import { TrackChangesAdapter, TrackChangesApi } from './track-changes/track-changes.js';
33
- import { MutationOptions, RichContentMutationOptions, WriteAdapter } from './write/write.js';
33
+ import { MutationOptions, RichContentMutationOptions, TrackedTextMutationOptions, TextMutationOptions, WriteAdapter } from './write/write.js';
34
34
  import { OperationCancellation } from './write/operation-cancellation.js';
35
35
  import { SelectionMutationAdapter } from './selection-mutation.js';
36
36
  import { CapabilitiesAdapter, DocumentApiCapabilities, OperationCapabilityResolveInput, OperationCapabilityResolveResult } from './capabilities/capabilities.js';
@@ -105,7 +105,7 @@ export type { GetMarkdownAdapter, GetMarkdownInput } from './get-markdown/get-ma
105
105
  export type { GetHtmlAdapter, GetHtmlInput } from './get-html/get-html.js';
106
106
  export type { InfoAdapter, InfoInput } from './info/info.js';
107
107
  export type { ExtractAdapter, ExtractInput } from './extract/extract.js';
108
- export type { WriteAdapter, WriteRequest, RichContentMutationOptions } from './write/write.js';
108
+ export type { WriteAdapter, WriteRequest, RichContentMutationOptions, TrackedTextMutationOptions, TextMutationOptions, } from './write/write.js';
109
109
  export type { OperationCancellation, OperationCancellationCode } from './write/operation-cancellation.js';
110
110
  export { OperationCancellationError, assertOperationCanStart, indeterminateOperation, splitOperationCancellation, } from './write/operation-cancellation.js';
111
111
  export type { FormatInlineAliasApi, FormatInlineAliasInput, FormatBoldInput, FormatItalicInput, FormatRangeInput, FormatUnderlineInput, FormatStrikethroughInput, StyleApplyInput, StyleApplyOptions, } from './format/format.js';
@@ -175,7 +175,7 @@ export { DocumentApiValidationError } from './errors.js';
175
175
  export { textReceiptToSDReceipt, buildStructuralReceipt } from './receipt-bridge.js';
176
176
  export type { MutationReceiptBridgeContext, StructuralReceiptParams } from './receipt-bridge.js';
177
177
  export { isBlockNodeAddress } from './validation-primitives.js';
178
- export type { InsertInput, InsertContentType, TextInsertInput, RichContentInsertInput, LegacyInsertInput, } from './insert/insert.js';
178
+ export type { InsertInput, InsertContentType, TextInsertInput, PlainTextInsertInput, RichContentInsertInput, LegacyInsertInput, } from './insert/insert.js';
179
179
  export { isStructuralInsertInput } from './insert/insert.js';
180
180
  export type { ReplaceInput, TextReplaceInput, RichContentReplaceInput } from './replace/replace.js';
181
181
  export { executeReplace, isStructuralReplaceInput, isRichContentReplaceInput } from './replace/replace.js';
@@ -345,15 +345,19 @@ export interface DocumentApiSurface {
345
345
  * Insert content at a target location.
346
346
  * If target is omitted, inserts at the end of the document.
347
347
  */
348
+ insert(input: import('./insert/insert.js').PlainTextInsertInput, options: TrackedTextMutationOptions & OperationCancellation): SDMutationReceipt;
348
349
  insert(input: InsertInput, options?: RichContentMutationOptions & OperationCancellation): SDMutationReceipt;
349
350
  /**
350
351
  * Replace text at a target range.
351
352
  */
353
+ replace(input: Exclude<import('./replace/replace.js').TextReplaceInput, {
354
+ target: import('./types/story.types.js').BodyStoryLocator;
355
+ }>, options: TrackedTextMutationOptions): SDMutationReceipt;
352
356
  replace(input: ReplaceInput, options?: RichContentMutationOptions): SDMutationReceipt;
353
357
  /**
354
358
  * Delete text at a target range.
355
359
  */
356
- delete(input: DeleteInput, options?: MutationOptions): TextMutationReceipt;
360
+ delete(input: DeleteInput, options?: TextMutationOptions): TextMutationReceipt;
357
361
  /**
358
362
  * Formatting operations (inline and paragraph direct formatting).
359
363
  */
@@ -1,4 +1,4 @@
1
- import { RichContentMutationOptions, WriteAdapter } from '../write/write.js';
1
+ import { RichContentMutationOptions, TextMutationOptions, WriteAdapter } from '../write/write.js';
2
2
  import { SelectionTarget, TargetLocator, SDMutationReceipt } from '../types/index.js';
3
3
  import { SDInsertInput } from '../types/structural-input.js';
4
4
  import { StoryLocator } from '../types/story.types.js';
@@ -46,6 +46,9 @@ export type LegacyInsertInput = TextInsertInput;
46
46
  * These are mutually exclusive: providing both is an error.
47
47
  */
48
48
  export type InsertInput = TextInsertInput | RichContentInsertInput | SDInsertInput;
49
+ export type PlainTextInsertInput = TextInsertInput & {
50
+ type?: 'text';
51
+ };
49
52
  export declare function isRichContentInsertInput(input: InsertInput): input is RichContentInsertInput;
50
53
  /** Returns true when the input uses the structural SDFragment shape. */
51
54
  export declare function isStructuralInsertInput(input: InsertInput): input is SDInsertInput;
@@ -71,5 +74,5 @@ export declare function validateInsertInput(input: unknown): asserts input is In
71
74
  * @param options - Optional mutation options (changeMode, dryRun, expectedRevision).
72
75
  * @returns Receipt indicating success/failure and mutation metadata.
73
76
  */
74
- export declare function executeInsert(selectionAdapter: SelectionMutationAdapter, writeAdapter: WriteAdapter, input: InsertInput, options?: RichContentMutationOptions & OperationCancellation): SDMutationReceipt;
77
+ export declare function executeInsert(selectionAdapter: SelectionMutationAdapter, writeAdapter: WriteAdapter, input: InsertInput, options?: (RichContentMutationOptions | TextMutationOptions) & OperationCancellation): SDMutationReceipt;
75
78
  export {};
@@ -1,4 +1,4 @@
1
- import { RichContentMutationOptions, WriteAdapter } from '../write/write.js';
1
+ import { RichContentMutationOptions, TextMutationOptions, WriteAdapter } from '../write/write.js';
2
2
  import { SelectionTarget } from '../types/address.js';
3
3
  import { SDMutationReceipt } from '../types/sd-contract.js';
4
4
  import { SDReplaceInput } from '../types/structural-input.js';
@@ -54,4 +54,4 @@ export type ReplaceInput = TextReplaceInput | RichContentReplaceInput | SDReplac
54
54
  export declare function isStructuralReplaceInput(input: ReplaceInput): input is SDReplaceInput;
55
55
  export declare function isRichContentReplaceInput(input: ReplaceInput): input is RichContentReplaceInput;
56
56
  export declare function validateReplaceInput(input: unknown): asserts input is ReplaceInput;
57
- export declare function executeReplace(selectionAdapter: SelectionMutationAdapter, writeAdapter: WriteAdapter, input: ReplaceInput, options?: RichContentMutationOptions): SDMutationReceipt;
57
+ export declare function executeReplace(selectionAdapter: SelectionMutationAdapter, writeAdapter: WriteAdapter, input: ReplaceInput, options?: RichContentMutationOptions | TextMutationOptions): SDMutationReceipt;
@@ -1,6 +1,6 @@
1
1
  import { SelectionTarget, DeleteBehavior, TargetLocator } from './types/address.js';
2
2
  import { TextMutationReceipt } from './types/receipt.js';
3
- import { MutationOptions } from './types/mutation-plan.types.js';
3
+ import { TextMutationOptions } from './write/write.js';
4
4
  import { InlineRunPatch } from './format/inline-run-patch.js';
5
5
  import { StoryLocator } from './types/story.types.js';
6
6
  export type SelectionDeleteRequest = TargetLocator & {
@@ -44,5 +44,5 @@ export type SelectionMutationRequest = SelectionDeleteRequest | SelectionReplace
44
44
  * single interface.
45
45
  */
46
46
  export interface SelectionMutationAdapter {
47
- execute(request: SelectionMutationRequest, options?: MutationOptions): TextMutationReceipt;
47
+ execute(request: SelectionMutationRequest, options?: TextMutationOptions): TextMutationReceipt;
48
48
  }
@@ -2,7 +2,7 @@ import { BlockNodeAddress } from './base.js';
2
2
  import { SelectionTarget, TextAddress } from './address.js';
3
3
  import { ReceiptEffects, ReceiptSuccess, TextMutationRange } from './receipt.js';
4
4
  import { BodyStoryLocator } from './story.types.js';
5
- export type SDErrorCode = 'INVALID_PAYLOAD' | 'INVALID_TARGET' | 'TARGET_NOT_FOUND' | 'ADDRESS_STALE' | 'PERMISSION_DENIED' | 'PRECONDITION_FAILED' | 'REVISION_MISMATCH' | 'CHECK_MISMATCH' | 'INVALID_CONTEXT' | 'INVALID_NESTING' | 'INVALID_PLACEMENT' | 'DUPLICATE_ID' | 'CAPABILITY_UNSUPPORTED' | 'RAW_MODE_REQUIRED' | 'PRESERVE_ONLY_VIOLATION' | 'NO_OP' | 'UNSUPPORTED_ENVIRONMENT' | 'INTERNAL_ERROR';
5
+ export type SDErrorCode = 'INVALID_INPUT' | 'INVALID_PAYLOAD' | 'INVALID_TARGET' | 'TARGET_NOT_FOUND' | 'ADDRESS_STALE' | 'PERMISSION_DENIED' | 'PRECONDITION_FAILED' | 'REVISION_MISMATCH' | 'CHECK_MISMATCH' | 'INVALID_CONTEXT' | 'INVALID_NESTING' | 'INVALID_PLACEMENT' | 'DUPLICATE_ID' | 'CAPABILITY_UNSUPPORTED' | 'RAW_MODE_REQUIRED' | 'PRESERVE_ONLY_VIOLATION' | 'NO_OP' | 'UNSUPPORTED_ENVIRONMENT' | 'INTERNAL_ERROR';
6
6
  export declare const SD_HTML_MARKDOWN_OUTCOMES: readonly ["preserved", "preserved-with-warnings", "simplified", "rejected", "no-op", "invalid-target", "outdated"];
7
7
  export type SDHtmlMarkdownOutcome = (typeof SD_HTML_MARKDOWN_OUTCOMES)[number];
8
8
  export interface SDError {
@@ -41,9 +41,19 @@ export interface MutationOptions extends RevisionGuardOptions {
41
41
  dryRun?: boolean;
42
42
  }
43
43
  export interface RichContentMutationOptions extends MutationOptions {
44
+ author?: never;
44
45
  /** Guard returned by `doc.capabilities.check` for an exact rich write. */
45
46
  supportCheck?: SDHtmlMarkdownCheckGuard;
46
47
  }
48
+ /** Display-only attribution for one tracked plain-text mutation. */
49
+ export interface TrackedTextMutationOptions extends MutationOptions {
50
+ changeMode: 'tracked';
51
+ author: {
52
+ name: string;
53
+ };
54
+ }
55
+ export type TextMutationOptions = MutationOptions | TrackedTextMutationOptions;
56
+ export declare function normalizeTextMutationOptions(options?: RichContentMutationOptions | TextMutationOptions): RichContentMutationOptions | TrackedTextMutationOptions;
47
57
  /**
48
58
  * Text insertion request: target-less insert at document end.
49
59
  *
@@ -67,11 +77,11 @@ export type WriteRequest = InsertWriteRequest;
67
77
  * `SelectionMutationAdapter` instead.
68
78
  */
69
79
  export interface WriteAdapter {
70
- write(request: InsertWriteRequest, options?: MutationOptions): TextMutationReceipt;
80
+ write(request: InsertWriteRequest, options?: TextMutationOptions): TextMutationReceipt;
71
81
  /** Structured insert for SDFragment or markdown/html content. Returns SDMutationReceipt. */
72
82
  insertStructured(input: InsertInput, options?: RichContentMutationOptions): SDMutationReceipt;
73
83
  /** Structured replace for SDFragment or markdown/html content. Returns SDMutationReceipt. */
74
84
  replaceStructured(input: ReplaceInput, options?: RichContentMutationOptions): SDMutationReceipt;
75
85
  }
76
86
  export declare function normalizeMutationOptions(options?: MutationOptions | RichContentMutationOptions, supportCheckOperation?: 'insert' | 'replace'): RichContentMutationOptions;
77
- export declare function executeWrite(adapter: WriteAdapter, request: InsertWriteRequest, options?: MutationOptions): TextMutationReceipt;
87
+ export declare function executeWrite(adapter: WriteAdapter, request: InsertWriteRequest, options?: TextMutationOptions): TextMutationReceipt;
@@ -1,4 +1,4 @@
1
- import { DocumentApi } from '../../../document-api/src/index.js';
1
+ import { DocumentApi, DynamicInvokeRequest, InvokeRequest, InvokeResult, OperationId, OperationCancellation, PlainTextInsertInput, TextReplaceInput, TrackedTextMutationOptions } from '../../../document-api/src/index.js';
2
2
  type MaybePromise<T> = T | Promise<T>;
3
3
  type BrowserDocumentApiObject<T> = {
4
4
  [K in keyof T]: BrowserDocumentApiValue<T[K]>;
@@ -11,7 +11,17 @@ type BrowserDocumentApiValue<T> = T extends (...args: infer Args) => infer Retur
11
11
  * worker-backed runtime. SDK/headless callers should continue using the
12
12
  * synchronous `@superdoc/document-api` surface directly.
13
13
  */
14
- export type BrowserDocumentApi = BrowserDocumentApiObject<DocumentApi>;
14
+ export type BrowserDocumentApi = Omit<BrowserDocumentApiObject<DocumentApi>, 'invoke'> & {
15
+ invoke<T extends OperationId>(request: InvokeRequest<T>): MaybePromise<Awaited<InvokeResult<T>>>;
16
+ invoke(request: DynamicInvokeRequest): unknown;
17
+ insert(input: PlainTextInsertInput, options: TrackedTextMutationOptions & OperationCancellation): MaybePromise<Awaited<ReturnType<DocumentApi['insert']>>>;
18
+ replace(input: Exclude<TextReplaceInput, {
19
+ target: {
20
+ kind: 'story';
21
+ storyType: 'body';
22
+ };
23
+ }>, options: TrackedTextMutationOptions): MaybePromise<Awaited<ReturnType<DocumentApi['replace']>>>;
24
+ };
15
25
  /**
16
26
  * Every operation optional, at any depth.
17
27
  *
package/dist/superdoc.cjs CHANGED
@@ -304,7 +304,7 @@ var awarenessStatesToArray = (context, states) => {
304
304
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
305
305
  function getSuperdocVersion() {
306
306
  try {
307
- return "2.23.0-next.10";
307
+ return "2.23.0-next.12";
308
308
  } catch {
309
309
  return "unknown";
310
310
  }
@@ -46433,7 +46433,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
46433
46433
  }
46434
46434
  this.userColorMap = /* @__PURE__ */ new Map();
46435
46435
  this.colorIndex = 0;
46436
- this.version = "2.23.0-next.10";
46436
+ this.version = "2.23.0-next.12";
46437
46437
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
46438
46438
  this.superdocId = config.superdocId || require_uuid.v4();
46439
46439
  this.colors = this.config.colors ?? [];
@@ -302,7 +302,7 @@ var awarenessStatesToArray = (context, states) => {
302
302
  var DEFAULT_ENDPOINT = "https://ingest.superdoc.dev/v1/collect";
303
303
  function getSuperdocVersion() {
304
304
  try {
305
- return "2.23.0-next.10";
305
+ return "2.23.0-next.12";
306
306
  } catch {
307
307
  return "unknown";
308
308
  }
@@ -46362,7 +46362,7 @@ var SuperDoc = class extends import_eventemitter3.default {
46362
46362
  }
46363
46363
  this.userColorMap = /* @__PURE__ */ new Map();
46364
46364
  this.colorIndex = 0;
46365
- this.version = "2.23.0-next.10";
46365
+ this.version = "2.23.0-next.12";
46366
46366
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
46367
46367
  this.superdocId = config.superdocId || v4();
46368
46368
  this.colors = this.config.colors ?? [];