@xiongtao.xt/tau-plugins 0.47.0 → 0.49.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/client/{chunk-M3YEVDN4.js → chunk-CQ3UMKDY.js} +2 -3
  3. package/client/{chunk-X6MBLKAL.js → chunk-MNFXOBPW.js} +3 -8
  4. package/docs/README.md +26 -31
  5. package/docs/ai.md +12 -8
  6. package/docs/backend.md +15 -6
  7. package/docs/editor-collaboration.md +96 -130
  8. package/docs/editor.md +95 -29
  9. package/docs/excerpts.md +28 -9
  10. package/docs/flashcards.md +23 -6
  11. package/docs/getting-started.md +58 -26
  12. package/docs/mcp.md +18 -6
  13. package/docs/plugin-basics.md +51 -47
  14. package/docs/portability.md +92 -73
  15. package/docs/providers/README.md +22 -17
  16. package/docs/providers/asr.md +111 -20
  17. package/docs/providers/embeddings.md +77 -0
  18. package/docs/providers/images.md +17 -5
  19. package/docs/providers/publish.md +20 -7
  20. package/docs/providers/sync.md +26 -11
  21. package/docs/providers/tts.md +22 -8
  22. package/docs/providers/upload.md +30 -15
  23. package/docs/providers/video.md +19 -7
  24. package/docs/release.md +9 -9
  25. package/docs/services.md +19 -9
  26. package/docs/site-data.md +4 -4
  27. package/docs/skills.md +2 -1
  28. package/docs/storage-and-network.md +32 -7
  29. package/docs/ui.md +171 -92
  30. package/docs/user-data.md +95 -38
  31. package/docs/whiteboard.md +105 -53
  32. package/package.js +1 -1
  33. package/package.json +3 -2
  34. package/portable.js +2 -4
  35. package/publish-artifacts.js +15 -17
  36. package/types/packages/collaboration/src/document-adapter.d.ts +7 -0
  37. package/types/packages/collaboration/src/document-installation.d.ts +15 -0
  38. package/types/packages/collaboration/src/document-operations.d.ts +37 -0
  39. package/types/packages/collaboration/src/document-protocol.d.ts +41 -0
  40. package/types/packages/collaboration/src/document-sync.d.ts +62 -0
  41. package/types/packages/collaboration/src/document-version.d.ts +13 -0
  42. package/types/packages/collaboration/src/document-write-queue.d.ts +10 -0
  43. package/types/packages/collaboration/src/encoding.d.ts +2 -0
  44. package/types/packages/collaboration/src/index.d.ts +26 -0
  45. package/types/packages/collaboration/src/model-limits.d.ts +22 -0
  46. package/types/packages/collaboration/src/node-document.d.ts +21 -0
  47. package/types/packages/collaboration/src/node-tree-history.d.ts +34 -0
  48. package/types/packages/collaboration/src/node-tree.d.ts +107 -0
  49. package/types/packages/collaboration/src/palette.d.ts +4 -0
  50. package/types/packages/collaboration/src/presence-budget.d.ts +2 -0
  51. package/types/packages/collaboration/src/protocol.d.ts +0 -5
  52. package/types/packages/collaboration/src/resource-policy.d.ts +1 -0
  53. package/types/packages/collaboration/src/shared-values.d.ts +4 -0
  54. package/types/packages/collaboration/src/text-segments.d.ts +52 -0
  55. package/types/packages/collaboration/src/whiteboard-baseline.d.ts +7 -0
  56. package/types/packages/collaboration/src/whiteboard-document.d.ts +7 -0
  57. package/types/packages/collaboration/src/whiteboard-model.d.ts +85 -0
  58. package/types/packages/collaboration/src/whiteboard-presence.d.ts +28 -0
  59. package/types/packages/collaboration/src/whiteboard-presentation.d.ts +21 -0
  60. package/types/packages/collaboration/src/whiteboard-relations.d.ts +11 -0
  61. package/types/packages/collaboration/src/whiteboard-transfer.d.ts +27 -0
  62. package/types/packages/db-schema/data-versions.d.ts +0 -5
  63. package/types/packages/editor/contracts.d.ts +1 -1
  64. package/types/packages/editor/src/core/CoreEditor.d.ts +2 -2
  65. package/types/packages/editor/src/core/api/extension.d.ts +14 -4
  66. package/types/packages/editor/src/core/api/index.d.ts +0 -1
  67. package/types/packages/editor/src/core/index.d.ts +1 -1
  68. package/types/packages/editor/src/core/kit/EditorKit.d.ts +3 -4
  69. package/types/packages/editor/src/core/kit/ExtensionAssembly.d.ts +1 -2
  70. package/types/packages/editor/src/core/kit/context.d.ts +2 -2
  71. package/types/packages/editor/src/extensions/diagram/src/types/index.d.ts +1 -2
  72. package/types/packages/editor/src/extensions/media/src/types/element/image.d.ts +1 -8
  73. package/types/packages/editor/src/extensions/tabs/src/types.d.ts +0 -11
  74. package/types/packages/editor/src/presets/default.d.ts +2 -2
  75. package/types/packages/plugins/src/contract.d.ts +3 -0
  76. package/types/packages/plugins/src/embeddings.d.ts +16 -0
  77. package/types/packages/plugins/src/index.d.ts +2 -1
  78. package/types/packages/plugins/src/package.d.ts +2 -2
  79. package/types/packages/plugins/src/portable.d.ts +4 -10
  80. package/types/packages/plugins/src/provider-form.d.ts +35 -1
  81. package/types/packages/plugins/src/render-artifact.d.ts +2 -2
  82. package/types/packages/plugins/src/rendering.d.ts +4 -4
  83. package/types/packages/plugins/src/settings.d.ts +8 -5
  84. package/types/packages/ui/src/primitives/ResizableAndHideableSidebar.d.ts +0 -4
  85. package/types/packages/whiteboard/src/Board.d.ts +3 -1
  86. package/types/packages/whiteboard/src/WhiteBoard.d.ts +2 -0
  87. package/types/packages/whiteboard/src/collaboration/presence.d.ts +23 -0
  88. package/types/packages/whiteboard/src/constants/text-style.d.ts +5 -7
  89. package/types/packages/whiteboard/src/context.d.ts +23 -0
  90. package/types/packages/whiteboard/src/document.d.ts +8 -1
  91. package/types/packages/whiteboard/src/extensions/api.d.ts +4 -7
  92. package/types/packages/whiteboard/src/extensions/authorTypes.d.ts +2 -4
  93. package/types/packages/whiteboard/src/extensions/runtime.d.ts +1 -1
  94. package/types/packages/whiteboard/src/plugins/RichTextPlugin.d.ts +0 -4
  95. package/types/packages/whiteboard/src/transforms/ViewPortTransforms.d.ts +1 -0
  96. package/types/packages/whiteboard/src/utils/index.d.ts +0 -1
  97. package/docs/api-support.md +0 -95
  98. package/docs/content-metrics.md +0 -45
  99. package/docs/websocket.md +0 -39
  100. package/docs/whiteboard-collaboration.md +0 -67
  101. package/types/packages/editor/src/core/api/legacy.d.ts +0 -10
  102. package/types/packages/editor/src/extensions/diagram/src/types/typst.d.ts +0 -9
  103. package/types/packages/whiteboard/src/utils/Constraints.d.ts +0 -6
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  PORTABLE_SHARED_MODULES,
3
- readPortablePluginManifest
4
- } from "./client/chunk-X6MBLKAL.js";
3
+ validatePortablePluginManifest
4
+ } from "./client/chunk-MNFXOBPW.js";
5
5
  import {
6
6
  PLUGIN_SHARED_MODULES,
7
7
  validatePluginManifest
8
- } from "./client/chunk-M3YEVDN4.js";
8
+ } from "./client/chunk-CQ3UMKDY.js";
9
9
  import {
10
10
  __commonJS,
11
11
  __toESM
@@ -1823,7 +1823,7 @@ var WhiteboardAPIProvider = WhiteboardAPIContext.Provider;
1823
1823
  // packages/db-schema/data-versions.ts
1824
1824
  function assertDataVersions(spec, validate) {
1825
1825
  if (spec.dataVersion === void 0) {
1826
- if (spec.collaboration || spec.previousVersions || spec.migrations)
1826
+ if (spec.collaboration || spec.previousVersions)
1827
1827
  throw new Error("\u534F\u4F5C\u58F0\u660E\u4E0E\u7248\u672C\u517C\u5BB9\u5FC5\u987B\u6307\u5B9A dataVersion");
1828
1828
  return;
1829
1829
  }
@@ -1836,12 +1836,6 @@ function assertDataVersions(spec, validate) {
1836
1836
  if (versions.has(previous.element.dataVersion)) throw new Error("\u8282\u70B9\u6570\u636E\u7248\u672C\u91CD\u590D");
1837
1837
  versions.add(previous.element.dataVersion);
1838
1838
  }
1839
- const migrations = /* @__PURE__ */ new Set();
1840
- for (const migration of spec.migrations ?? []) {
1841
- if (!migration || typeof migration.migrate !== "function" || migration.from === spec.dataVersion || !versions.has(migration.from) || migrations.has(migration.from))
1842
- throw new Error("\u8282\u70B9\u8F6C\u6362\u6765\u6E90\u5FC5\u987B\u662F\u663E\u5F0F\u58F0\u660E\u7684\u5386\u53F2\u7248\u672C\u4E14\u4E0D\u80FD\u91CD\u590D");
1843
- migrations.add(migration.from);
1844
- }
1845
1839
  }
1846
1840
 
1847
1841
  // packages/db-schema/content-resources.ts
@@ -1987,11 +1981,10 @@ function normalizeWhiteboardContract(owner, definition) {
1987
1981
 
1988
1982
  // packages/whiteboard/src/extensions/versions.ts
1989
1983
  function assertWhiteboardElementVersions(element) {
1990
- if (element.dataVersion !== void 0 && (element.schemaVersion !== void 0 || element.migrate !== void 0))
1991
- throw new Error("\u65B0\u5951\u7EA6\u4E0D\u80FD\u6DF7\u7528 schemaVersion/migrate");
1984
+ if (element.dataVersion !== void 0 && element.schemaVersion !== void 0)
1985
+ throw new Error("\u65B0\u5951\u7EA6\u4E0D\u80FD\u6DF7\u7528 schemaVersion");
1992
1986
  assertDataVersions(element, (value) => {
1993
- if (value.schemaVersion !== void 0 || value.migrate !== void 0)
1994
- throw new Error("\u5386\u53F2\u5B9A\u4E49\u4E0D\u80FD\u6DF7\u7528\u65E7\u7248\u672C\u5B57\u6BB5");
1987
+ if (value.schemaVersion !== void 0) throw new Error("\u5386\u53F2\u5B9A\u4E49\u4E0D\u80FD\u6DF7\u7528\u65E7\u7248\u672C\u5B57\u6BB5");
1995
1988
  return normalizeWhiteboardContract("validation", {
1996
1989
  type: value.type,
1997
1990
  dataVersion: value.dataVersion,
@@ -9363,7 +9356,7 @@ function normalizePluginEditorExtension(extension) {
9363
9356
  // packages/plugins/src/rendering.ts
9364
9357
  var PLUGIN_RENDER_VERSION = 1;
9365
9358
  function readPublishedPluginManifest(value) {
9366
- return value?.formatVersion === 3 ? readPortablePluginManifest(value) : validatePluginManifest(value);
9359
+ return value?.formatVersion === 3 ? validatePortablePluginManifest(value) : validatePluginManifest(value);
9367
9360
  }
9368
9361
  function evaluatePublishedPluginPackage(artifact, modules) {
9369
9362
  const manifest = readPublishedPluginManifest(artifact.manifest);
@@ -9374,8 +9367,13 @@ function evaluatePublishedPluginPackage(artifact, modules) {
9374
9367
  return definition;
9375
9368
  }
9376
9369
  function evaluatePluginPackage(artifact, modules) {
9377
- const manifest = validatePluginManifest(artifact.manifest);
9378
- return evaluateModule(manifest, artifact.code, modules, PLUGIN_SHARED_MODULES);
9370
+ const manifest = readPublishedPluginManifest(artifact.manifest);
9371
+ return evaluateModule(
9372
+ manifest,
9373
+ artifact.code,
9374
+ modules,
9375
+ manifest.formatVersion === 3 ? PORTABLE_SHARED_MODULES : PLUGIN_SHARED_MODULES
9376
+ );
9379
9377
  }
9380
9378
  function evaluateModule(manifest, code, modules, allowed) {
9381
9379
  const module = { exports: {} };
@@ -0,0 +1,7 @@
1
+ import * as Y from "yjs";
2
+ import { type NodeDocumentIdentity } from "./node-document";
3
+ export declare const isStructuredDocumentVersion: (version: unknown) => boolean;
4
+ export declare function validateStructuredDocument(doc: Y.Doc, identity?: NodeDocumentIdentity, previous?: Y.Doc): Promise<void>;
5
+ export declare function readDocumentProjection(doc: Y.Doc): import("./protocol").SharedContent | import("./whiteboard-types").WhiteboardSnapshot;
6
+ export declare function collectDocumentResources(doc: Y.Doc): unknown;
7
+ export declare function applyStructuredDocumentUpdate(current: Y.Doc, update: Uint8Array, identity: NodeDocumentIdentity): Promise<Y.Doc>;
@@ -0,0 +1,15 @@
1
+ /** 当前跨存储安装的候选身份;不提供历史格式转换。 */
2
+ export interface DocumentInstallFingerprint {
3
+ expectedRevision: string;
4
+ candidateHash: string;
5
+ targetVersion: number;
6
+ baselineId: string;
7
+ }
8
+ export interface DocumentInstallReceipt {
9
+ operationId: string;
10
+ documentId: string;
11
+ epoch: number;
12
+ revision: string;
13
+ version: number;
14
+ baselineId: string;
15
+ }
@@ -0,0 +1,37 @@
1
+ import type { DocumentSql, DocumentProtocol } from "./document-protocol";
2
+ export interface DocumentOperationRequest {
3
+ operationId: string;
4
+ epoch: number;
5
+ baselineId: string;
6
+ version: number;
7
+ updateHash: string;
8
+ expiresAt: number;
9
+ expectedRevision?: string;
10
+ expectedSequence?: number;
11
+ }
12
+ export interface DocumentOperation extends DocumentOperationRequest {
13
+ documentId: string;
14
+ actorId: string;
15
+ state: "PENDING" | "COMMITTED" | "ABORTED" | "EXPIRED";
16
+ reason?: string;
17
+ receipt?: {
18
+ documentId: string;
19
+ epoch: number;
20
+ baselineId: string;
21
+ revision: string;
22
+ sequence: number;
23
+ };
24
+ }
25
+ /** 普通条件提交保留 epoch,回执与更新必须同事务提交。 */
26
+ export declare class DocumentOperationLedger {
27
+ private readonly sql;
28
+ private readonly now;
29
+ constructor(sql: DocumentSql, now?: () => number);
30
+ sequence(documentId: string): number;
31
+ advance(documentId: string): number;
32
+ private save;
33
+ get(documentId: string, operationId: string, actorId: string): DocumentOperation | null;
34
+ begin(documentId: string, actorId: string, request: DocumentOperationRequest): DocumentOperation;
35
+ abort(operation: DocumentOperation, reason: string): DocumentOperation;
36
+ commit(operation: DocumentOperation, read: () => DocumentProtocol, revision: string, install: () => void): DocumentOperation;
37
+ }
@@ -0,0 +1,41 @@
1
+ export interface DocumentProtocol {
2
+ id: string;
3
+ ownerId: string;
4
+ epoch: number;
5
+ revision: string;
6
+ version: number;
7
+ baselineId: string;
8
+ publication?: {
9
+ candidateHash: string;
10
+ baselineId: string;
11
+ version: number;
12
+ };
13
+ }
14
+ type Parameter = string | number | null;
15
+ export interface DocumentSql {
16
+ exec(sql: string, ...parameters: Parameter[]): void;
17
+ get<T>(sql: string, ...parameters: Parameter[]): T | undefined;
18
+ transaction<T>(action: () => T): T;
19
+ }
20
+ /** 旧迁移未完成的文档只拒绝读取,不自动解冻或覆盖。 */
21
+ export declare function readDocumentProtocol(value: string): DocumentProtocol;
22
+ /** 当前协议、首次发布与修订缓存;调用方负责与正文共用 SQLite 事务。 */
23
+ export declare class DocumentProtocolStore {
24
+ private readonly sql;
25
+ private readonly readCurrent;
26
+ private readonly verified;
27
+ constructor(sql: DocumentSql, readCurrent: (id: string) => DocumentProtocol);
28
+ publication(documentId: string): {
29
+ candidateHash: string;
30
+ baselineId: string;
31
+ version: number;
32
+ } | null;
33
+ publish(document: DocumentProtocol, install: () => void): void;
34
+ private document;
35
+ /** 与正文增量同事务更新,普通轮询只读已核验的协议记录。 */
36
+ updateRevision(documentId: string, revision: string): void;
37
+ invalidate(documentId?: string): void;
38
+ state(documentId: string): DocumentProtocol;
39
+ assertWritable(documentId: string, expected?: Pick<DocumentProtocol, "epoch" | "version" | "baselineId">): DocumentProtocol;
40
+ }
41
+ export {};
@@ -0,0 +1,62 @@
1
+ import type { DocumentProtocol } from "./document-protocol";
2
+ import type { DocumentOperation, DocumentOperationRequest } from "./document-operations";
3
+ export interface ConfirmedDocument {
4
+ state: Uint8Array;
5
+ protocol: DocumentProtocol & {
6
+ sequence: number;
7
+ };
8
+ }
9
+ export interface PendingDocumentOperation {
10
+ request: DocumentOperationRequest;
11
+ update: Uint8Array;
12
+ }
13
+ export interface DocumentSyncState {
14
+ confirmed: ConfirmedDocument;
15
+ pending: PendingDocumentOperation[];
16
+ rejected: {
17
+ reason: string;
18
+ baseline: ConfirmedDocument;
19
+ operations: PendingDocumentOperation[];
20
+ state: Uint8Array;
21
+ }[];
22
+ blocked: boolean;
23
+ }
24
+ export interface DocumentSyncJournal {
25
+ load(): Promise<DocumentSyncState | null>;
26
+ save(state: DocumentSyncState, receipt?: DocumentOperation): Promise<void>;
27
+ receipt(operationId: string): Promise<DocumentOperation | null>;
28
+ }
29
+ export interface DocumentSyncTransport {
30
+ /** 最近一次服务端响应的时间;HTTP 宿主消费标准 Date,不推断客户端墙钟偏移。 */
31
+ now?(): number;
32
+ read(): Promise<ConfirmedDocument>;
33
+ /** 只读确认摘要与序号;提供时,远端未变化的刷新不下载完整状态。 */
34
+ peek?(): Promise<ConfirmedDocument["protocol"]>;
35
+ submit(request: DocumentOperationRequest, update: Uint8Array): Promise<DocumentOperation>;
36
+ receipt(operationId: string): Promise<DocumentOperation | null>;
37
+ cancel(request: DocumentOperationRequest): Promise<DocumentOperation>;
38
+ }
39
+ /** 不把未确认分支并入新基线;恢复材料落盘成功以前不清队列、不安装另一代次。 */
40
+ export declare class DocumentSyncSession {
41
+ readonly documentId: string;
42
+ private readonly journal;
43
+ private readonly transport;
44
+ private state;
45
+ private readonly queue;
46
+ private constructor();
47
+ static open(documentId: string, journal: DocumentSyncJournal, transport: DocumentSyncTransport): Promise<DocumentSyncSession>;
48
+ snapshot(): DocumentSyncState;
49
+ private check;
50
+ private persist;
51
+ stage(update: Uint8Array, condition?: {
52
+ revision: string;
53
+ sequence: number;
54
+ }, operationId?: string): Promise<string>;
55
+ private isolate;
56
+ private refresh;
57
+ synchronize(): Promise<void>;
58
+ /** 调用方必须丢弃旧可写副本并使用返回的确认快照;原分支仍保留在日志中。 */
59
+ restartFromConfirmed(): Promise<ConfirmedDocument>;
60
+ flush(): Promise<void>;
61
+ cancel(operationId: string): Promise<void>;
62
+ }
@@ -0,0 +1,13 @@
1
+ import type * as Y from "yjs";
2
+ export declare const NODE_DOCUMENT_VERSION = 2;
3
+ export declare const WHITEBOARD_DOCUMENT_VERSION = 3;
4
+ export declare const SUPPORTED_DOCUMENT_VERSIONS: readonly [2, 3];
5
+ export type DocumentVersion = (typeof SUPPORTED_DOCUMENT_VERSIONS)[number];
6
+ export declare function assertCurrentDocumentVersion(version: unknown): asserts version is DocumentVersion;
7
+ /** 读取信封不创建 Yjs 根,也不为缺失身份生成替代值。 */
8
+ export declare function readDocumentIdentity(doc: Y.Doc): {
9
+ version: 2 | 3;
10
+ documentId: string;
11
+ baselineId: string;
12
+ epoch: number;
13
+ };
@@ -0,0 +1,10 @@
1
+ /** 同文档按到达顺序校验与持久化;不同文档共享有界的排队预算。 */
2
+ export declare class DocumentWriteQueue {
3
+ private readonly maxBytes;
4
+ private readonly maxRequests;
5
+ private tails;
6
+ private bytes;
7
+ private requests;
8
+ constructor(maxBytes: number, maxRequests?: number);
9
+ run<T>(id: string, bytes: number, action: () => Promise<T>): Promise<T>;
10
+ }
@@ -0,0 +1,2 @@
1
+ export declare function bytesToBase64(bytes: Uint8Array): string;
2
+ export declare function base64ToBytes(value: string): Uint8Array;
@@ -0,0 +1,26 @@
1
+ export * from "./protocol";
2
+ export { replaceText } from "./shared-values";
3
+ export { assertCurrentDocumentVersion, readDocumentIdentity, SUPPORTED_DOCUMENT_VERSIONS, } from "./document-version";
4
+ export * from "./palette";
5
+ export * from "./encoding";
6
+ export * from "./node-tree";
7
+ export { NodeTreeHistory, type NodeTreeHistoryOptions } from "./node-tree-history";
8
+ export * from "./model-limits";
9
+ export * from "./whiteboard-contract";
10
+ export * from "./node-document";
11
+ export * from "./document-protocol";
12
+ export * from "./document-installation";
13
+ export * from "./document-write-queue";
14
+ export * from "./whiteboard-types";
15
+ export * from "./whiteboard-model";
16
+ export * from "./whiteboard-relations";
17
+ export * from "./whiteboard-document";
18
+ export * from "./document-adapter";
19
+ export * from "./document-operations";
20
+ export * from "./document-sync";
21
+ export { exportWhiteboardTransfer, prepareWhiteboardTransfer, whiteboardTransferResources, } from "./whiteboard-transfer";
22
+ export type { WhiteboardTransfer } from "./whiteboard-types";
23
+ export { isSafeResource } from "./resource-policy";
24
+ export * from "./whiteboard-baseline";
25
+ export { assertPresenceBudget } from "./presence-budget";
26
+ export * from "./whiteboard-presence";
@@ -0,0 +1,22 @@
1
+ /** 候选文档模型的准入预算;各根共享节点额度,包含仍可恢复的记录。 */
2
+ export declare const NODE_TREE_LIMITS: Readonly<{
3
+ roots: 1024;
4
+ rootIdLength: 128;
5
+ nodes: 150000;
6
+ depth: 64;
7
+ }>;
8
+ /** 白板首期的存储准入预算,不代表已测得的渲染或网络容量。 */
9
+ export declare const WHITEBOARD_LIMITS: Readonly<{
10
+ documentBytes: number;
11
+ pages: 64;
12
+ elements: 5000;
13
+ richTextRoots: 1024;
14
+ richTextNodes: 150000;
15
+ commandsPerBatch: 256;
16
+ batchBytes: number;
17
+ payloadDepth: 64;
18
+ patchBytes: number;
19
+ presenceBytes: 16384;
20
+ presencePerMinute: 600;
21
+ }>;
22
+ export declare function assertWhiteboardBudget(usage: Partial<Record<keyof typeof WHITEBOARD_LIMITS, number>>): void;
@@ -0,0 +1,21 @@
1
+ import * as Y from "yjs";
2
+ import { type ContentContractDictionary } from "../../db-schema/content-contracts";
3
+ import { type SharedContent } from "./protocol";
4
+ export { NODE_DOCUMENT_VERSION } from "./document-version";
5
+ export declare const NODE_DOCUMENT_MAX_BYTES: number;
6
+ export interface NodeDocumentIdentity {
7
+ documentId: string;
8
+ baselineId: string;
9
+ epoch: number;
10
+ }
11
+ /** 也检查冲突中未成为可见值的身份写入,避免旧全量状态借新票据重放。 */
12
+ export declare function assertStableDocumentIdentity(doc: Y.Doc, previous: Y.Doc): void;
13
+ export declare function createNodeDocument(identity: NodeDocumentIdentity, content: SharedContent, contracts: ContentContractDictionary): Promise<Y.Doc>;
14
+ /** 检查完整候选;调用方仍须在持久化事务内核对修订并安装。 */
15
+ export declare function validateNodeDocument(doc: Y.Doc, identity?: NodeDocumentIdentity, previous?: Y.Doc): Promise<void>;
16
+ /** 正文与白板富文本根共用候选校验,不依赖任何渲染或插件代码。 */
17
+ export declare function validateNodeTree(doc: Y.Doc, rootId?: string, previous?: Y.Doc): Promise<void>;
18
+ export declare function applyNodeDocumentUpdate(current: Y.Doc, update: Uint8Array, identity: NodeDocumentIdentity): Promise<Y.Doc>;
19
+ export declare function readNodeDocument(doc: Y.Doc): SharedContent;
20
+ /** 保留记录也可能被撤销重新显示;只读取各自契约声明的资源位置。 */
21
+ export declare function collectNodeDocumentResources(doc: Y.Doc): string[];
@@ -0,0 +1,34 @@
1
+ import * as Y from "yjs";
2
+ interface InitializationRange {
3
+ client: number;
4
+ clock: number;
5
+ len: number;
6
+ }
7
+ /** 初始化结构不参与撤销,创建可见性仍由同一事务中的独立记录控制。 */
8
+ export declare function preserveNodeInitialization(transaction: Y.Transaction, range: InitializationRange): void;
9
+ /** 宿主在隔离候选组装大批导入时,随正式增量转交初始化保护范围。 */
10
+ export declare function nodeInitializationRanges(transaction: Y.Transaction): readonly InitializationRange[];
11
+ export interface NodeTreeHistoryOptions {
12
+ trackedOrigins: Set<unknown>;
13
+ captureTimeout?: number;
14
+ beforeChange?: (history: NodeTreeHistory, direction: "undo" | "redo") => void;
15
+ }
16
+ export declare class NodeTreeHistory extends Y.UndoManager {
17
+ readonly identity: `${string}-${string}-${string}-${string}-${string}`;
18
+ private closed;
19
+ private origins;
20
+ private activeStackItem?;
21
+ private beforeChange?;
22
+ constructor(scope: ConstructorParameters<typeof Y.UndoManager>[0], options: NodeTreeHistoryOptions);
23
+ get isDisposed(): boolean;
24
+ assertActive(doc?: Y.Doc): void;
25
+ attach(scope: ConstructorParameters<typeof Y.UndoManager>[0]): void;
26
+ retainOrigin(origin: unknown): () => void;
27
+ undo(): ReturnType<Y.UndoManager["undo"]>;
28
+ redo(): ReturnType<Y.UndoManager["redo"]>;
29
+ private canDeleteDuringHistory;
30
+ destroy(): void;
31
+ private inScope;
32
+ }
33
+ export declare function createNodeTreeHistory(scope: ConstructorParameters<typeof Y.UndoManager>[0], options: NodeTreeHistoryOptions): NodeTreeHistory;
34
+ export {};
@@ -0,0 +1,107 @@
1
+ import * as Y from "yjs";
2
+ import type { ContentNode } from "./protocol";
3
+ import { type ContentContract, type DataContract, type ContentContractDictionary } from "../../db-schema/content-contracts";
4
+ import { NodeTreeHistory, type NodeTreeHistoryOptions } from "./node-tree-history";
5
+ import { TextSegments } from "./text-segments";
6
+ export interface NodePlacement {
7
+ parent: string | null;
8
+ token: string;
9
+ split?: {
10
+ after: string;
11
+ node: string;
12
+ source: string;
13
+ segment: string;
14
+ };
15
+ order?: {
16
+ after: string;
17
+ before?: string;
18
+ };
19
+ }
20
+ export interface TreeSpan {
21
+ value: string | {
22
+ node: string;
23
+ };
24
+ attributes?: Record<string, unknown>;
25
+ offset: number;
26
+ length: number;
27
+ source: string | null;
28
+ segment?: string;
29
+ }
30
+ export interface NodeTreeOptions {
31
+ rootId?: string;
32
+ }
33
+ /** 内容保留在节点池;移动只改位置引用,不能删除并复制共享文本。 */
34
+ export declare class NodeTree {
35
+ readonly doc: Y.Doc;
36
+ readonly rootId: string;
37
+ private disposed;
38
+ private cleanups;
39
+ readonly nodes: Y.Map<Y.Map<unknown>>;
40
+ readonly root: Y.XmlText;
41
+ readonly contracts: Y.Map<DataContract>;
42
+ readonly creations: Y.Map<boolean>;
43
+ readonly segments: TextSegments;
44
+ private cachedRouting?;
45
+ private snapshots;
46
+ private rootSnapshot?;
47
+ private changes;
48
+ constructor(doc: Y.Doc, options?: NodeTreeOptions);
49
+ get isDisposed(): boolean;
50
+ private assertActive;
51
+ readonly dispose: () => void;
52
+ createUndoManager(options: NodeTreeHistoryOptions): NodeTreeHistory;
53
+ attachUndoManager(history: NodeTreeHistory): void;
54
+ isDeleted(id: string): boolean;
55
+ private mergeTarget;
56
+ private mergedOwner;
57
+ installContracts(dictionary: ContentContractDictionary, origin: unknown): Promise<void>;
58
+ contract(id: string): ContentContract | undefined;
59
+ private nodeContract;
60
+ fields(id: string): Y.Map<unknown>;
61
+ textField(id: string, field: string): Y.Text;
62
+ private changeSet;
63
+ transactionChanges(transaction: Y.Transaction): {
64
+ structural: boolean;
65
+ nodes: Set<string>;
66
+ } | undefined;
67
+ private invalidate;
68
+ record(id: string): Y.Map<unknown>;
69
+ content(parent: string | null): Y.XmlText;
70
+ properties(id: string): Y.Map<unknown>;
71
+ placement(id: string): NodePlacement;
72
+ private routing;
73
+ private assertDepth;
74
+ spans(parent: string | null): TreeSpan[];
75
+ private readSpans;
76
+ snapshot(): readonly ContentNode[];
77
+ nodeSnapshot(id: string): ContentNode;
78
+ read(): ContentNode[];
79
+ physicalOffset(parent: string | null, index: number): number;
80
+ textLocation(parent: string | null, index: number): {
81
+ source: string | null;
82
+ offset: number;
83
+ segment?: string;
84
+ };
85
+ visibleOffset(parent: string | null, index: number): number;
86
+ capturePosition(parent: string, index: number): Y.RelativePosition;
87
+ resolvePosition(position: Y.RelativePosition): {
88
+ parent: string;
89
+ offset: number;
90
+ } | null;
91
+ private assertStructuralFields;
92
+ splitNode(id: string, index: number, next: ContentNode, origin: unknown): void;
93
+ mergeNodes(source: string, target: string, origin: unknown): void;
94
+ insertNode(node: ContentNode, parent: string | null, index: number, origin: unknown, preserveIds?: boolean): string;
95
+ private positionOrder;
96
+ /** index 是移除原位置之后目标父节点中的可见偏移。 */
97
+ moveNode(id: string, parent: string | null, index: number, origin: unknown): void;
98
+ removeNode(id: string, origin: unknown): void;
99
+ /** 只删除调用方观察到的集合,不在接收端重新扩展子树。 */
100
+ removeNodes(ids: readonly string[], origin: unknown): void;
101
+ setProperties(id: string, changes: Record<string, unknown>, origin: unknown): void;
102
+ convertNode(id: string, targetId: string, changes: Record<string, unknown>, origin: unknown): void;
103
+ insertText(id: string, index: number, text: string, origin: unknown, marks?: Record<string, unknown>): void;
104
+ deleteText(id: string, index: number, length: number, origin: unknown): void;
105
+ formatText(id: string, index: number, length: number, marks: Record<string, unknown>, origin: unknown): void;
106
+ private textRanges;
107
+ }
@@ -0,0 +1,4 @@
1
+ /** 成员色底上的文字与描边色:色板亮度按白色可读设计,明暗主题通用。 */
2
+ export declare const MEMBER_INK = "white";
3
+ /** 由设备 ID 稳定派生成员色:同一成员在头像、光标、名牌、选区上颜色一致。 */
4
+ export declare function memberColor(id: string): string;
@@ -0,0 +1,2 @@
1
+ /** 状态 JSON 按 UTF-8 编码计量,避免中文与 emoji 绕过字节限制。 */
2
+ export declare function assertPresenceBudget(states: ReadonlyMap<number, unknown>): void;
@@ -1,4 +1,3 @@
1
- export declare const COLLABORATION_VERSION = 1;
2
1
  export declare const DEFAULT_COLLABORATION_URL = "https://collab.taunote.app";
3
2
  export declare const ASSET_PREFIX = "tau-collab-asset:";
4
3
  /**
@@ -61,10 +60,6 @@ export type JoinRequestResult = {
61
60
  status: "approved";
62
61
  documentId: string;
63
62
  };
64
- export interface ContentVersionUpgrade {
65
- expectedRevision: string;
66
- content: ContentNode[];
67
- }
68
63
  export interface SourceBinding {
69
64
  databaseName: string;
70
65
  contentId: number;
@@ -0,0 +1 @@
1
+ export declare function isSafeResource(value: string, field?: string): boolean;
@@ -0,0 +1,4 @@
1
+ import * as Y from "yjs";
2
+ export declare function sharedValueEquals(a: unknown, b: unknown): boolean;
3
+ export declare function replaceText(text: Y.Text, value: string): void;
4
+ export declare function setSharedValue(map: Y.Map<unknown>, key: string, value: unknown): void;
@@ -0,0 +1,52 @@
1
+ import * as Y from "yjs";
2
+ export interface SegmentReference {
3
+ segment: string;
4
+ token: string;
5
+ }
6
+ type FlowReference = SegmentReference | {
7
+ merge: string;
8
+ token: string;
9
+ };
10
+ interface SegmentPlacement {
11
+ parent: string;
12
+ token: string;
13
+ }
14
+ export interface TextSegment {
15
+ id: string;
16
+ source: string;
17
+ start: number;
18
+ end: number;
19
+ reference: SegmentReference;
20
+ }
21
+ /** 分界标记保留原文字身份;归属变化与初始化分开进入历史。 */
22
+ export declare class TextSegments {
23
+ readonly records: Y.Map<Y.Map<unknown>>;
24
+ private readonly node;
25
+ private readonly content;
26
+ private readonly owner;
27
+ private readonly mergeTarget;
28
+ private index?;
29
+ private rangeCache;
30
+ private readonly invalidateIndex;
31
+ constructor(records: Y.Map<Y.Map<unknown>>, node: (id: string) => Y.Map<unknown>, content: (id: string) => Y.XmlText, owner: (id: string) => string, mergeTarget: (id: string) => string | undefined);
32
+ dispose(): void;
33
+ clearRanges(): void;
34
+ private getIndex;
35
+ owners(source: string, changes?: readonly {
36
+ start: number;
37
+ end: number;
38
+ }[]): Set<string>;
39
+ flow(id: string): Y.Array<FlowReference>;
40
+ initialize(id: string): void;
41
+ placement(id: string): SegmentPlacement;
42
+ source(id: string): string;
43
+ ranges(source: string): Map<string, {
44
+ start: number;
45
+ end: number;
46
+ }>;
47
+ list(parent: string, includeInactive?: boolean): TextSegment[];
48
+ cut(segment: TextSegment, at: number, transaction: Y.Transaction): string;
49
+ move(ids: readonly string[], parent: string): void;
50
+ merge(source: string, target: string): void;
51
+ }
52
+ export {};
@@ -0,0 +1,7 @@
1
+ import * as Y from "yjs";
2
+ import { WhiteboardModel } from "./whiteboard-model";
3
+ import type { NodeDocumentIdentity } from "./node-document";
4
+ import type { WhiteboardTransfer } from "./whiteboard-types";
5
+ /** 只从确认投影建立新共享根;逻辑身份保留,旧删除历史不进入候选。 */
6
+ export declare function createWhiteboardBaseline(bundle: WhiteboardTransfer, identity?: NodeDocumentIdentity): Promise<Y.Doc>;
7
+ export declare function whiteboardPublicationScope(model: WhiteboardModel, documentId: string, pageIds: readonly string[]): WhiteboardTransfer;
@@ -0,0 +1,7 @@
1
+ import * as Y from "yjs";
2
+ import { type NodeDocumentIdentity } from "./node-document";
3
+ export { WHITEBOARD_DOCUMENT_VERSION } from "./document-version";
4
+ export declare function createWhiteboardDocument(identity: NodeDocumentIdentity, state: Uint8Array): Promise<Y.Doc>;
5
+ export declare function validateWhiteboardDocument(doc: Y.Doc, identity?: NodeDocumentIdentity, previous?: Y.Doc): Promise<void>;
6
+ /** 删除与恢复池同样扫描;曾经被替换的资产由服务端历史账另行持有。 */
7
+ export declare function collectWhiteboardDocumentResources(doc: Y.Doc): string[];