@tabula-md/tabula 0.2.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 (122) hide show
  1. package/README.md +106 -0
  2. package/dist/activeDocumentRuntime.d.ts +50 -0
  3. package/dist/activeDocumentRuntime.d.ts.map +1 -0
  4. package/dist/collabCollaborators.d.ts +16 -0
  5. package/dist/collabCollaborators.d.ts.map +1 -0
  6. package/dist/collabConnectionModel.d.ts +11 -0
  7. package/dist/collabConnectionModel.d.ts.map +1 -0
  8. package/dist/collabSessionState.d.ts +24 -0
  9. package/dist/collabSessionState.d.ts.map +1 -0
  10. package/dist/collaboration.d.ts +8 -0
  11. package/dist/collaboration.d.ts.map +1 -0
  12. package/dist/collaboration.js +78 -0
  13. package/dist/collaboration.js.map +1 -0
  14. package/dist/collaborationPresence.d.ts +7 -0
  15. package/dist/collaborationPresence.d.ts.map +1 -0
  16. package/dist/collaborationTypes.d.ts +27 -0
  17. package/dist/collaborationTypes.d.ts.map +1 -0
  18. package/dist/commentRuntimeModel.d.ts +53 -0
  19. package/dist/commentRuntimeModel.d.ts.map +1 -0
  20. package/dist/data/base64Url.d.ts +3 -0
  21. package/dist/data/base64Url.d.ts.map +1 -0
  22. package/dist/data/encode.d.ts +20 -0
  23. package/dist/data/encode.d.ts.map +1 -0
  24. package/dist/data/encode.js +61 -0
  25. package/dist/data/encode.js.map +1 -0
  26. package/dist/data/encryption.d.ts +20 -0
  27. package/dist/data/encryption.d.ts.map +1 -0
  28. package/dist/data/encryption.js +13 -0
  29. package/dist/data/encryption.js.map +1 -0
  30. package/dist/data/json.d.ts +18 -0
  31. package/dist/data/json.d.ts.map +1 -0
  32. package/dist/data/json.js +18 -0
  33. package/dist/data/json.js.map +1 -0
  34. package/dist/data/restore.d.ts +3 -0
  35. package/dist/data/restore.d.ts.map +1 -0
  36. package/dist/data/restore.js +6 -0
  37. package/dist/data/restore.js.map +1 -0
  38. package/dist/documentBuffer.d.ts +68 -0
  39. package/dist/documentBuffer.d.ts.map +1 -0
  40. package/dist/documentControlsModel.d.ts +58 -0
  41. package/dist/documentControlsModel.d.ts.map +1 -0
  42. package/dist/documentMetrics.d.ts +2 -0
  43. package/dist/documentMetrics.d.ts.map +1 -0
  44. package/dist/documentPrimitives.d.ts +9 -0
  45. package/dist/documentPrimitives.d.ts.map +1 -0
  46. package/dist/documentSurfaceModel.d.ts +44 -0
  47. package/dist/documentSurfaceModel.d.ts.map +1 -0
  48. package/dist/encryption-B0xRVvlF.js +82 -0
  49. package/dist/encryption-B0xRVvlF.js.map +1 -0
  50. package/dist/index.d.ts +85 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +2474 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/jsonShareLinkModel.d.ts +36 -0
  55. package/dist/jsonShareLinkModel.d.ts.map +1 -0
  56. package/dist/lineSurfaceModel.d.ts +73 -0
  57. package/dist/lineSurfaceModel.d.ts.map +1 -0
  58. package/dist/markdown/editing.d.ts +12 -0
  59. package/dist/markdown/editing.d.ts.map +1 -0
  60. package/dist/markdown/links.d.ts +23 -0
  61. package/dist/markdown/links.d.ts.map +1 -0
  62. package/dist/markdown/tasks.d.ts +22 -0
  63. package/dist/markdown/tasks.d.ts.map +1 -0
  64. package/dist/markdown.d.ts +25 -0
  65. package/dist/markdown.d.ts.map +1 -0
  66. package/dist/markdownEditing.d.ts +2 -0
  67. package/dist/markdownEditing.d.ts.map +1 -0
  68. package/dist/markdownFormatting.d.ts +11 -0
  69. package/dist/markdownFormatting.d.ts.map +1 -0
  70. package/dist/previewBlockModel.d.ts +66 -0
  71. package/dist/previewBlockModel.d.ts.map +1 -0
  72. package/dist/productPerformancePolicy.d.ts +14 -0
  73. package/dist/productPerformancePolicy.d.ts.map +1 -0
  74. package/dist/rightPanelCommentViewModel.d.ts +39 -0
  75. package/dist/rightPanelCommentViewModel.d.ts.map +1 -0
  76. package/dist/room/envelope.d.ts +27 -0
  77. package/dist/room/envelope.d.ts.map +1 -0
  78. package/dist/room/envelope.js +38 -0
  79. package/dist/room/envelope.js.map +1 -0
  80. package/dist/roomBinaryProtocol.d.ts +43 -0
  81. package/dist/roomBinaryProtocol.d.ts.map +1 -0
  82. package/dist/roomCollaboration.d.ts +39 -0
  83. package/dist/roomCollaboration.d.ts.map +1 -0
  84. package/dist/roomProtocol.d.ts +11 -0
  85. package/dist/roomProtocol.d.ts.map +1 -0
  86. package/dist/roomShareLinkModel.d.ts +20 -0
  87. package/dist/roomShareLinkModel.d.ts.map +1 -0
  88. package/dist/shareLinkViewModel.d.ts +8 -0
  89. package/dist/shareLinkViewModel.d.ts.map +1 -0
  90. package/dist/shareSnapshotPayload-CsTw9sRq.js +209 -0
  91. package/dist/shareSnapshotPayload-CsTw9sRq.js.map +1 -0
  92. package/dist/shareSnapshotPayload.d.ts +75 -0
  93. package/dist/shareSnapshotPayload.d.ts.map +1 -0
  94. package/dist/shareViewModel.d.ts +33 -0
  95. package/dist/shareViewModel.d.ts.map +1 -0
  96. package/dist/sourceScrollTransfer.d.ts +54 -0
  97. package/dist/sourceScrollTransfer.d.ts.map +1 -0
  98. package/dist/statusBarViewModel.d.ts +13 -0
  99. package/dist/statusBarViewModel.d.ts.map +1 -0
  100. package/dist/textPatches.d.ts +16 -0
  101. package/dist/textPatches.d.ts.map +1 -0
  102. package/dist/workspaceFileRuntimeModel.d.ts +11 -0
  103. package/dist/workspaceFileRuntimeModel.d.ts.map +1 -0
  104. package/dist/workspaceIoModel.d.ts +37 -0
  105. package/dist/workspaceIoModel.d.ts.map +1 -0
  106. package/dist/workspaceModel.d.ts +112 -0
  107. package/dist/workspaceModel.d.ts.map +1 -0
  108. package/dist/workspaceRoomCheckpoint.d.ts +46 -0
  109. package/dist/workspaceRoomCheckpoint.d.ts.map +1 -0
  110. package/dist/workspaceRoomCrdt.d.ts +55 -0
  111. package/dist/workspaceRoomCrdt.d.ts.map +1 -0
  112. package/dist/workspaceRoomModel-CO-5ZOpS.js +78 -0
  113. package/dist/workspaceRoomModel-CO-5ZOpS.js.map +1 -0
  114. package/dist/workspaceRoomModel.d.ts +69 -0
  115. package/dist/workspaceRoomModel.d.ts.map +1 -0
  116. package/dist/workspaceRoomSync-B3niC7cn.js +758 -0
  117. package/dist/workspaceRoomSync-B3niC7cn.js.map +1 -0
  118. package/dist/workspaceRoomSync.d.ts +98 -0
  119. package/dist/workspaceRoomSync.d.ts.map +1 -0
  120. package/dist/workspaceViewModel.d.ts +13 -0
  121. package/dist/workspaceViewModel.d.ts.map +1 -0
  122. package/package.json +82 -0
package/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # @tabula-md/tabula
2
+
3
+ Core product contracts for Tabula.md.
4
+
5
+ This package is intentionally small and browser-service agnostic. It contains
6
+ pure models for Markdown editing, workspace files, document controls, comments,
7
+ status labels, live room links, encrypted Export links, the workspace Yjs
8
+ schema, binary room packets, transport-neutral Yjs sync controller, Awareness
9
+ flow, and encrypted checkpoint format. It also owns product data, actor, and
10
+ room envelope contracts used by Export links and live recovery. The Tabula
11
+ app in `tabula-app` wires these contracts to React, CodeMirror, local storage,
12
+ collaboration transports, hosted recovery, and network services.
13
+
14
+ ## Boundary
15
+
16
+ Keep in this package:
17
+
18
+ - Markdown text transforms and formatting commands.
19
+ - Workspace file and tab state transitions.
20
+ - Share link parsing and URL contracts.
21
+ - AES-GCM primitives through `globalThis.crypto`.
22
+ - Versioned encrypted data encoding for Export links and recovery blobs.
23
+ - Comment/status/document control view models.
24
+ - Workspace CRDT, binary room protocol, actor, envelope, sync, Awareness, and
25
+ checkpoint code that does not require React or a concrete transport.
26
+ - Pure helpers that can be tested without the DOM, React, storage, or network.
27
+
28
+ Public imports must go through the package root:
29
+
30
+ ```ts
31
+ import { parseRoomShareUrl } from "@tabula-md/tabula";
32
+ ```
33
+
34
+ Do not rely on deep source paths. The root `src/index.ts` file is the public
35
+ API list and new modules are private until they are explicitly exported there.
36
+ Both `tabula-app` and `tabula-mcp` must consume this package rather than copying
37
+ or redefining live-room contracts.
38
+
39
+ Agent clients should use the collaboration-only entrypoint so they do not load
40
+ editor and preview models:
41
+
42
+ ```ts
43
+ import {
44
+ createWorkspaceRoomCrdt,
45
+ createWorkspaceRoomSyncController,
46
+ } from "@tabula-md/tabula/collaboration";
47
+ ```
48
+
49
+ Keep outside this package:
50
+
51
+ - React components and hooks.
52
+ - CodeMirror extensions and editor refs.
53
+ - Browser storage, file picker, clipboard, and download behavior.
54
+ - Socket.IO, fetch, hosted recovery SDKs, or browser app wiring.
55
+ - `tabula-room`, `tabula-json`, recovery provider settings, or managed
56
+ deployment settings.
57
+ - Product surfaces that depend on a service account, billing, auth, or runtime
58
+ environment.
59
+
60
+ ## Link Contracts
61
+
62
+ Tabula has two first-class share links:
63
+
64
+ - Live collaboration: `https://tabula.md/#room=<roomId>,<roomKey>`
65
+ - Export link import: `https://tabula.md/#json=<snapshotId>,<snapshotKey>`
66
+
67
+ The key stays in the URL hash so it is client-only. Servers receive the object
68
+ identifier, not the decryption key.
69
+
70
+ ## Example
71
+
72
+ ```ts
73
+ import {
74
+ applyMarkdownFormat,
75
+ encodeEncryptedData,
76
+ generateEncryptionKey,
77
+ createJsonShareUrl,
78
+ parseRoomShareUrl,
79
+ } from "@tabula-md/tabula";
80
+
81
+ const room = parseRoomShareUrl("https://tabula.md/#room=abc,secret");
82
+ const snapshotUrl = createJsonShareUrl("https://tabula.md", "abc", "secret");
83
+
84
+ const nextText = applyMarkdownFormat(
85
+ "hello",
86
+ { from: 0, to: 5 },
87
+ "bold",
88
+ ).text;
89
+
90
+ const key = await generateEncryptionKey();
91
+ const encrypted = await encodeEncryptedData(new TextEncoder().encode("# Draft"), key);
92
+ ```
93
+
94
+ Subpath exports are available for lower-level integrations:
95
+
96
+ ```ts
97
+ import { encryptData } from "@tabula-md/tabula/data/encryption";
98
+ import { createRoomEnvelope } from "@tabula-md/tabula/room";
99
+ ```
100
+
101
+ ## Service App Relationship
102
+
103
+ `tabula-app` is the tabula.md service app. It can choose to enable or hide
104
+ service features such as live collaboration, hosted recovery, encrypted
105
+ Export-link upload, or future Tabula+ boundaries without changing the
106
+ pure contracts here.
@@ -0,0 +1,50 @@
1
+ import { type FileViewMode, type ReadingWidth } from "./documentPrimitives";
2
+ import { type MarkdownHeading, type ParsedFrontmatter, type PreviewBody } from "./markdown";
3
+ export type DocumentBookmark = {
4
+ id: string;
5
+ position: number;
6
+ createdAt: string;
7
+ };
8
+ export type ActiveDocumentFile = {
9
+ title: string;
10
+ text: string;
11
+ viewMode: FileViewMode;
12
+ readingWidth: ReadingWidth;
13
+ splitRatio?: number;
14
+ lineWrapping: boolean;
15
+ lineNumbers: boolean;
16
+ bookmarks?: DocumentBookmark[];
17
+ };
18
+ export type ActiveDocumentRuntime = {
19
+ bookmarks: DocumentBookmark[];
20
+ canCopy: boolean;
21
+ canFormat: boolean;
22
+ hasFile: boolean;
23
+ lineNumbers: boolean;
24
+ lineWrapping: boolean;
25
+ outlineHeadings: MarkdownHeading[];
26
+ parsedMarkdown: ParsedFrontmatter;
27
+ previewBodyStartOffset: number;
28
+ readingWidth: ReadingWidth;
29
+ renderedPreview: PreviewBody;
30
+ largeDocumentMode: boolean;
31
+ splitRatio: number;
32
+ text: string;
33
+ title: string;
34
+ viewMode: FileViewMode;
35
+ wordCount: number;
36
+ };
37
+ export type ActiveDocumentEditorRuntime = Omit<ActiveDocumentRuntime, "outlineHeadings" | "parsedMarkdown" | "previewBodyStartOffset" | "renderedPreview">;
38
+ export type ActiveDocumentPreviewRuntime = Pick<ActiveDocumentRuntime, "outlineHeadings" | "parsedMarkdown" | "previewBodyStartOffset" | "renderedPreview">;
39
+ export type ActiveDocumentPreviewBodyRuntime = Pick<ActiveDocumentRuntime, "previewBodyStartOffset" | "renderedPreview">;
40
+ export type ActiveDocumentPreviewMetadataRuntime = Pick<ActiveDocumentRuntime, "outlineHeadings" | "parsedMarkdown">;
41
+ export type ActiveDocumentRuntimeOptions = {
42
+ text?: string;
43
+ wordCount?: number;
44
+ };
45
+ export declare const createActiveDocumentEditorRuntime: (activeFile?: ActiveDocumentFile, options?: ActiveDocumentRuntimeOptions) => ActiveDocumentEditorRuntime;
46
+ export declare const createActiveDocumentPreviewRuntime: (activeFile?: Pick<ActiveDocumentFile, "text">, options?: Pick<ActiveDocumentRuntimeOptions, "text">) => ActiveDocumentPreviewRuntime;
47
+ export declare const createActiveDocumentPreviewBodyRuntime: (activeFile?: Pick<ActiveDocumentFile, "text">, options?: Pick<ActiveDocumentRuntimeOptions, "text">) => ActiveDocumentPreviewBodyRuntime;
48
+ export declare const createActiveDocumentPreviewMetadataRuntime: (activeFile?: Pick<ActiveDocumentFile, "text">, options?: Pick<ActiveDocumentRuntimeOptions, "text">) => ActiveDocumentPreviewMetadataRuntime;
49
+ export declare const createActiveDocumentRuntime: (activeFile?: ActiveDocumentFile, options?: ActiveDocumentRuntimeOptions) => ActiveDocumentRuntime;
50
+ //# sourceMappingURL=activeDocumentRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activeDocumentRuntime.d.ts","sourceRoot":"","sources":["../src/activeDocumentRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAIpB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,E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iC,GAC5C,aAAa,kBAAkB,EAC/B,UAAS,4BAAiC,KACzC,2BA4BF,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAC7C,aAAa,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAC7C,UAAS,IAAI,CAAC,4BAA4B,EAAE,MAAM,CAAM,KACvD,4BAuBF,CAAC;AAEF,eAAO,MAAM,sCAAsC,GACjD,aAAa,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAC7C,UAAS,IAAI,CAAC,4BAA4B,EAAE,MAAM,CAAM,KACvD,gCAiBF,CAAC;AAEF,eAAO,MAAM,0CAA0C,GACrD,aAAa,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAC7C,UAAS,IAAI,CAAC,4BAA4B,EAAE,MAAM,CAAM,KACvD,oCAaF,CAAC;AAEF,eAAO,MAAM,2BAA2B,GACtC,aAAa,kBAAkB,EAC/B,UAAS,4BAAiC,KACzC,qBAGD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { CollaborationCollaborator } from "./collaborationTypes";
2
+ import { type TextPatch } from "./textPatches";
3
+ export type CollaboratorRegistry = {
4
+ upsert(collaborator: CollaborationCollaborator, selfId: string): boolean;
5
+ prune(peerIds: Iterable<string>): boolean;
6
+ remapSelections(patches: readonly TextPatch[], docLength: number): boolean;
7
+ clear(): boolean;
8
+ list(): CollaborationCollaborator[];
9
+ };
10
+ export declare const mapCollaborationPositionThroughTextPatches: (position: number, patches: readonly TextPatch[], docLength: number, assoc?: -1 | 1) => number;
11
+ export declare const mapCollaborationSelectionThroughTextPatches: (selection: NonNullable<CollaborationCollaborator["selection"]>, patches: readonly TextPatch[], docLength: number) => {
12
+ from: number;
13
+ to: number;
14
+ };
15
+ export declare const createCollaboratorRegistry: () => CollaboratorRegistry;
16
+ //# sourceMappingURL=collabCollaborators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collabCollaborators.d.ts","sourceRoot":"","sources":["../src/collabCollaborators.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,CAAC,YAAY,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzE,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;IAC1C,eAAe,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3E,KAAK,IAAI,OAAO,CAAC;IACjB,IAAI,IAAI,yBAAyB,EAAE,CAAC;CACrC,CAAC;AAyCF,eAAO,MAAM,0CAA0C,GACrD,UAAU,MAAM,EAChB,SAAS,SAAS,SAAS,EAAE,EAC7B,WAAW,MAAM,EACjB,QAAO,CAAC,CAAC,GAAG,CAAM,WAwBnB,CAAC;AAEF,eAAO,MAAM,2CAA2C,GACtD,WAAW,WAAW,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC,EAC9D,SAAS,SAAS,SAAS,EAAE,EAC7B,WAAW,MAAM;;;CAWlB,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAAO,oBAiE7C,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { CollaborationCollaborator } from "./collaborationTypes";
2
+ import type { EncryptedEnvelope } from "./roomProtocol";
3
+ export type RoomServerMetadata = {
4
+ roomId: string;
5
+ activeConnections: number;
6
+ updatedAt?: string | null;
7
+ };
8
+ export declare const createRoomApiUrl: (baseUrl: string, roomId: string, suffix?: string) => string;
9
+ export declare const isEncryptedEnvelope: (value: unknown) => value is EncryptedEnvelope;
10
+ export declare const sortCollaborators: (collaborators: Iterable<CollaborationCollaborator>) => CollaborationCollaborator[];
11
+ //# sourceMappingURL=collabConnectionModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collabConnectionModel.d.ts","sourceRoot":"","sources":["../src/collabConnectionModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,SAAS,MAAM,EAAE,QAAQ,MAAM,EAAE,eAAW,WACf,CAAC;AAE/D,eAAO,MAAM,mBAAmB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,iBAe7D,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,eAAe,QAAQ,CAAC,yBAAyB,CAAC,gCACD,CAAC"}
@@ -0,0 +1,24 @@
1
+ export type CollabOfflineReason = "disconnect" | "connect-error";
2
+ export type CollabOfflineStatus = "reconnecting" | "disconnected" | "failed";
3
+ export type CollabJoinResult = {
4
+ reconnected: true;
5
+ message: string;
6
+ } | {
7
+ reconnected: false;
8
+ };
9
+ export type CollabOfflineResult = {
10
+ status: CollabOfflineStatus;
11
+ notify: true;
12
+ message: string;
13
+ } | {
14
+ status: CollabOfflineStatus;
15
+ notify: false;
16
+ };
17
+ export type CollabSessionState = {
18
+ markJoinBlocked(): void;
19
+ markJoined(): CollabJoinResult;
20
+ markOffline(reason: CollabOfflineReason): CollabOfflineResult;
21
+ isBlocked(): boolean;
22
+ };
23
+ export declare const createCollabSessionState: () => CollabSessionState;
24
+ //# sourceMappingURL=collabSessionState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collabSessionState.d.ts","sourceRoot":"","sources":["../src/collabSessionState.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,eAAe,CAAC;AACjE,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,cAAc,GAAG,QAAQ,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GACxB;IACE,WAAW,EAAE,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,GACD;IACE,WAAW,EAAE,KAAK,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,mBAAmB,GAC3B;IACE,MAAM,EAAE,mBAAmB,CAAC;IAC5B,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,GACD;IACE,MAAM,EAAE,mBAAmB,CAAC;IAC5B,MAAM,EAAE,KAAK,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,kBAAkB,GAAG;IAC/B,eAAe,IAAI,IAAI,CAAC;IACxB,UAAU,IAAI,gBAAgB,CAAC;IAC/B,WAAW,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAAC;IAC9D,SAAS,IAAI,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAAO,kBA2D3C,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from "./room/envelope.js";
2
+ export * from "./roomBinaryProtocol.js";
3
+ export * from "./roomCollaboration.js";
4
+ export * from "./workspaceRoomCheckpoint.js";
5
+ export * from "./workspaceRoomCrdt.js";
6
+ export * from "./workspaceRoomModel.js";
7
+ export * from "./workspaceRoomSync.js";
8
+ //# sourceMappingURL=collaboration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collaboration.d.ts","sourceRoot":"","sources":["../src/collaboration.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,78 @@
1
+ import { createRoomAad as e, createRoomEnvelope as R, decryptRoomEnvelope as s, isEnvelopeKind as _, validateRoomPayload as O } from "./room/envelope.js";
2
+ import { A as t, D as r, a as m, b as A, c, H as C, R as M, d as T, e as W, f as p, g as S, h as i, i as N, j as I, k, l as n, m as d, n as l, o as L, p as P, q as D, r as K, s as X, t as H, u as U, v as u, w as v, x as y, y as B, z as F, B as G, C as g, E as Y, F as h, G as b, I as f, J as x, K as V, L as z, M as J, N as j, O as q, P as w, Q, S as Z, T as $, U as oo, V as ao, W as eo, X as Ro, Y as so, Z as _o, _ as Oo, $ as Eo, a0 as to, a1 as ro } from "./workspaceRoomSync-B3niC7cn.js";
3
+ import { W as Ao, a as co, b as Co, c as Mo, d as To, e as Wo, f as po, g as So, h as io, v as No, i as Io } from "./workspaceRoomModel-CO-5ZOpS.js";
4
+ export {
5
+ t as AGENT_ROOM_CAPABILITIES,
6
+ r as DEFAULT_ACTOR_COLOR,
7
+ m as DEFAULT_ACTOR_NAME,
8
+ A as DEFAULT_AGENT_ACTOR_CLIENT,
9
+ c as DEFAULT_HUMAN_ACTOR_CLIENT,
10
+ C as HUMAN_ROOM_CAPABILITIES,
11
+ M as REMOTE_AWARENESS_ORIGIN,
12
+ T as REMOTE_SYNC_ORIGIN,
13
+ W as ROOM_ACTOR_ADJECTIVES,
14
+ p as ROOM_ACTOR_COLORS,
15
+ S as ROOM_ACTOR_MAX_ID_LENGTH,
16
+ i as ROOM_ACTOR_MAX_NAME_LENGTH,
17
+ N as ROOM_CHECKPOINT_RETENTION_MS,
18
+ I as ROOM_WIRE_CHUNK_BYTES,
19
+ k as ROOM_WIRE_CHUNK_PAYLOAD_BYTES,
20
+ n as ROOM_WIRE_CHUNK_TTL_MS,
21
+ d as ROOM_WIRE_MAX_BUFFERED_BYTES,
22
+ l as ROOM_WIRE_MAX_CHUNKS,
23
+ L as ROOM_WIRE_MAX_CRDT_STATE_BYTES,
24
+ P as ROOM_WIRE_MAX_INFLIGHT_PER_ACTOR,
25
+ D as ROOM_WIRE_MAX_MESSAGE_BYTES,
26
+ K as ROOM_WIRE_PROTOCOL_VERSION,
27
+ Ao as WORKSPACE_ROOM_MAX_COMMENTS,
28
+ co as WORKSPACE_ROOM_MAX_COMMENT_LENGTH,
29
+ Co as WORKSPACE_ROOM_MAX_CONTENT_BYTES,
30
+ Mo as WORKSPACE_ROOM_MAX_DOCUMENTS,
31
+ To as WORKSPACE_ROOM_MAX_FOLDERS,
32
+ Wo as WORKSPACE_ROOM_MAX_REPLIES,
33
+ po as WORKSPACE_ROOM_MAX_TREE_DEPTH,
34
+ So as WORKSPACE_ROOM_ROOT_ID,
35
+ io as WORKSPACE_ROOM_SCHEMA_VERSION,
36
+ X as addWorkspaceRoomCommentReply,
37
+ e as createRoomAad,
38
+ H as createRoomActor,
39
+ U as createRoomActorColor,
40
+ u as createRoomActorName,
41
+ v as createRoomChunkAssembler,
42
+ R as createRoomEnvelope,
43
+ y as createWorkspaceRoomCrdt,
44
+ B as createWorkspaceRoomDocument,
45
+ F as createWorkspaceRoomFolder,
46
+ G as createWorkspaceRoomSyncController,
47
+ g as decodeRoomWirePacket,
48
+ s as decryptRoomEnvelope,
49
+ Y as decryptWorkspaceRoomCheckpoint,
50
+ h as deleteWorkspaceRoomComment,
51
+ b as deleteWorkspaceRoomNode,
52
+ f as encodeRoomWirePacket,
53
+ x as encodeRoomWirePackets,
54
+ V as encryptWorkspaceRoomCheckpoint,
55
+ z as getDefaultRoomCapabilities,
56
+ J as getWorkspaceRoomComments,
57
+ j as getWorkspaceRoomDocument,
58
+ q as getWorkspaceRoomDocumentComments,
59
+ w as getWorkspaceRoomSnapshot,
60
+ Q as getWorkspaceRoomStructureSnapshot,
61
+ Z as hasRoomCapability,
62
+ $ as initializeWorkspaceRoomCrdt,
63
+ _ as isEnvelopeKind,
64
+ oo as isRemoteSyncOrigin,
65
+ ao as isRoomCapability,
66
+ eo as moveWorkspaceRoomNode,
67
+ Ro as normalizeRoomCapabilities,
68
+ so as parseRoomActor,
69
+ _o as renameWorkspaceRoomNode,
70
+ Oo as setWorkspaceRoomComment,
71
+ Eo as setWorkspaceRoomCommentResolved,
72
+ to as setWorkspaceRoomNodeOrder,
73
+ O as validateRoomPayload,
74
+ No as validateWorkspaceRoomLimits,
75
+ ro as validateWorkspaceRoomStructure,
76
+ Io as validateWorkspaceRoomStructureLimits
77
+ };
78
+ //# sourceMappingURL=collaboration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collaboration.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -0,0 +1,7 @@
1
+ import type { CollaborationCollaborator, CollaborationLiveSelection } from "./collaborationTypes";
2
+ export declare const getLineNumberForPresenceOffset: (text: string, offset: number) => number;
3
+ export declare const getLineNumberForPresenceSelection: (text: string, selection?: CollaborationLiveSelection) => number | null;
4
+ export declare const isCollaboratorInFile: (collaborator: CollaborationCollaborator, currentFileTitle?: string, currentRoomId?: string, currentDocumentId?: string) => boolean;
5
+ export declare const getCollaboratorPresenceDetail: (collaborator: CollaborationCollaborator, text: string, currentFileTitle?: string, currentRoomId?: string, currentDocumentId?: string) => string;
6
+ export declare const getCollaboratorPresenceLabel: (collaborator: CollaborationCollaborator, text?: string) => string;
7
+ //# sourceMappingURL=collaborationPresence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collaborationPresence.d.ts","sourceRoot":"","sources":["../src/collaborationPresence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAI9B,eAAO,MAAM,8BAA8B,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,WAW1E,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAAI,MAAM,MAAM,EAAE,YAAY,0BAA0B,kBAWrG,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,cAAc,yBAAyB,EACvC,mBAAmB,MAAM,EACzB,gBAAgB,MAAM,EACtB,oBAAoB,MAAM,YAY3B,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,cAAc,yBAAyB,EACvC,MAAM,MAAM,EACZ,mBAAmB,MAAM,EACzB,gBAAgB,MAAM,EACtB,oBAAoB,MAAM,WAe3B,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,cAAc,yBAAyB,EAAE,aAAS,WAiB9F,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { RoomActorClient, RoomActorKind, RoomCapability } from "./roomCollaboration";
2
+ export type CollaborationConnectionStatus = "idle" | "connecting" | "connected" | "reconnecting" | "disconnected" | "failed";
3
+ export type CollaborationLiveSelection = {
4
+ documentId?: string;
5
+ from: number;
6
+ to: number;
7
+ columnNumber?: number;
8
+ fromLineNumber?: number;
9
+ lineNumber?: number;
10
+ selectionEndsWithLineBreak?: boolean;
11
+ toLineNumber?: number;
12
+ };
13
+ export type CollaborationCollaborator = {
14
+ id: string;
15
+ name: string;
16
+ color: string;
17
+ lastSeen: number;
18
+ activeDocumentId?: string;
19
+ kind?: RoomActorKind;
20
+ client?: RoomActorClient;
21
+ capabilities?: RoomCapability[];
22
+ joinedAt?: string;
23
+ roomId?: string;
24
+ fileTitle?: string;
25
+ selection?: CollaborationLiveSelection;
26
+ };
27
+ //# sourceMappingURL=collaborationTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collaborationTypes.d.ts","sourceRoot":"","sources":["../src/collaborationTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,cAAc,EACf,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,6BAA6B,GACrC,MAAM,GACN,YAAY,GACZ,WAAW,GACX,cAAc,GACd,cAAc,GACd,QAAQ,CAAC;AAEb,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,0BAA0B,CAAC;CACxC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { type LineSurfaceSourceRange } from "./lineSurfaceModel";
2
+ export type CommentRuntimeAnchor = {
3
+ id: string;
4
+ start: number;
5
+ end: number;
6
+ };
7
+ export type CommentRuntimeBookmark = {
8
+ id: string;
9
+ position: number;
10
+ createdAt: string;
11
+ };
12
+ export type PreviewCommentAnchor = {
13
+ id: string;
14
+ start: number;
15
+ end: number;
16
+ };
17
+ export type PreviewLineAnnotation = {
18
+ lineNumber: number;
19
+ start: number;
20
+ end: number;
21
+ hasBookmark: boolean;
22
+ hasComment: boolean;
23
+ hasActiveComment: boolean;
24
+ };
25
+ export declare const isPositionInLineRange: (position: number, lineStart: number, lineEnd: number) => boolean;
26
+ export declare const toggleLineBookmarkInList: <TBookmark extends CommentRuntimeBookmark = CommentRuntimeBookmark>({ bookmarks, createId, lineStart, lineEnd, nowIso, }: {
27
+ bookmarks: TBookmark[];
28
+ createId: () => string;
29
+ lineStart: number;
30
+ lineEnd: number;
31
+ nowIso: string;
32
+ }) => CommentRuntimeBookmark[];
33
+ export declare const getPreviewCommentAnchors: <TAnchor extends CommentRuntimeAnchor = CommentRuntimeAnchor>({ commentAnchors, previewBody, previewBodyStartOffset, }: {
34
+ commentAnchors: TAnchor[];
35
+ previewBody: string;
36
+ previewBodyStartOffset: number;
37
+ }) => PreviewCommentAnchor[];
38
+ export declare const getPreviewLineAnnotations: <TBookmark extends Pick<CommentRuntimeBookmark, "position"> = CommentRuntimeBookmark, TAnchor extends CommentRuntimeAnchor = CommentRuntimeAnchor>({ body, bodyStartOffset, bookmarks, commentAnchors, activeCommentId, includeEmptyLines, }: {
39
+ body: string;
40
+ bodyStartOffset: number;
41
+ bookmarks: TBookmark[];
42
+ commentAnchors: TAnchor[];
43
+ activeCommentId?: string | null;
44
+ includeEmptyLines?: boolean;
45
+ }) => PreviewLineAnnotation[];
46
+ export declare const getItemsInSourceLineRange: <TItem>({ items, lineStart, lineEnd, resolveRange, }: {
47
+ items: TItem[];
48
+ lineStart: number;
49
+ lineEnd: number;
50
+ resolveRange: (item: TItem) => LineSurfaceSourceRange | null | undefined;
51
+ }) => TItem[];
52
+ export declare const formatCommentDate: (isoDate: string, now?: number) => string;
53
+ //# sourceMappingURL=commentRuntimeModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commentRuntimeModel.d.ts","sourceRoot":"","sources":["../src/commentRuntimeModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC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AI,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,KAAG,qBAAqB,EA+BxB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,KAAK,EAAE,8CAK9C;IACD,KAAK,EAAE,KAAK,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,sBAAsB,GAAG,IAAI,GAAG,SAAS,CAAC;CAC1E,YAUG,CAAC;AAEL,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,EAAE,YAAgB,WA8BlE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const encodeBase64Url: (bytes: Uint8Array) => string;
2
+ export declare const decodeBase64Url: (value: string) => Uint8Array<ArrayBuffer>;
3
+ //# sourceMappingURL=base64Url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64Url.d.ts","sourceRoot":"","sources":["../../src/data/base64Url.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,eAAe,GAAI,OAAO,UAAU,WAsBhD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,4BA6B5C,CAAC"}
@@ -0,0 +1,20 @@
1
+ export type EncryptedDataEncodingInfo = {
2
+ version: 1;
3
+ encryption: "AES-GCM";
4
+ compression: "none";
5
+ };
6
+ export type EncodeEncryptedDataOptions<TMetadata extends Record<string, unknown> | null = null> = {
7
+ encryptionKey: string | CryptoKey;
8
+ metadata?: TMetadata;
9
+ additionalData?: Uint8Array;
10
+ };
11
+ export type DecodeEncryptedDataOptions = {
12
+ decryptionKey: string | CryptoKey;
13
+ additionalData?: Uint8Array;
14
+ };
15
+ export declare const encodeEncryptedData: <TMetadata extends Record<string, unknown> | null = null>(data: Uint8Array, options: EncodeEncryptedDataOptions<TMetadata>) => Promise<Uint8Array<ArrayBuffer>>;
16
+ export declare const decodeEncryptedData: <TMetadata extends Record<string, unknown> | null = null>(encoded: Uint8Array, options: DecodeEncryptedDataOptions) => Promise<{
17
+ metadata: TMetadata;
18
+ data: Uint8Array;
19
+ }>;
20
+ //# sourceMappingURL=encode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/data/encode.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,SAAS,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,IAAI,IAAI;IAChG,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,cAAc,CAAC,EAAE,UAAU,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,cAAc,CAAC,EAAE,UAAU,CAAC;CAC7B,CAAC;AAQF,eAAO,MAAM,mBAAmB,GAAU,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,IAAI,EAC/F,MAAM,UAAU,EAChB,SAAS,0BAA0B,CAAC,SAAS,CAAC,qCAqB/C,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,IAAI,EAC/F,SAAS,UAAU,EACnB,SAAS,0BAA0B,KAClC,OAAO,CAAC;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAsCnD,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { d as L, e as D } from "../encryption-B0xRVvlF.js";
2
+ const o = new Uint8Array([84, 66, 69, 49]), c = 4, g = 12, h = new TextEncoder(), E = new TextDecoder(), A = async (e, t) => {
3
+ const n = {
4
+ version: 1,
5
+ encryption: "AES-GCM",
6
+ compression: "none"
7
+ }, r = h.encode(JSON.stringify(n)), a = h.encode(JSON.stringify(t.metadata ?? null)), d = l(m(a.byteLength), a, e), { encryptedBuffer: s, iv: i } = await D(t.encryptionKey, d, {
8
+ additionalData: t.additionalData
9
+ });
10
+ return l(
11
+ o,
12
+ m(r.byteLength),
13
+ r,
14
+ i,
15
+ new Uint8Array(s)
16
+ );
17
+ }, v = async (e, t) => {
18
+ const n = new Uint8Array(e);
19
+ if (n.byteLength < o.byteLength + c + g)
20
+ throw new Error("Encrypted data is too short");
21
+ U(n);
22
+ const r = u(n, o.byteLength), a = o.byteLength + c, d = a + r, s = d, i = s + g;
23
+ if (n.byteLength <= i)
24
+ throw new Error("Encrypted data is incomplete");
25
+ const w = JSON.parse(E.decode(n.slice(a, d)));
26
+ if (w.version !== 1 || w.encryption !== "AES-GCM")
27
+ throw new Error("Unsupported encrypted data format");
28
+ const y = new Uint8Array(
29
+ await L(n.slice(s, i), n.slice(i), t.decryptionKey, {
30
+ additionalData: t.additionalData
31
+ })
32
+ ), b = u(y, 0), p = c, f = p + b;
33
+ if (y.byteLength < f)
34
+ throw new Error("Encrypted data metadata is incomplete");
35
+ return {
36
+ metadata: JSON.parse(E.decode(y.slice(p, f))),
37
+ data: y.slice(f)
38
+ };
39
+ }, l = (...e) => {
40
+ const t = new Uint8Array(e.reduce((r, a) => r + a.byteLength, 0));
41
+ let n = 0;
42
+ for (const r of e)
43
+ t.set(r, n), n += r.byteLength;
44
+ return t;
45
+ }, m = (e) => {
46
+ const t = new Uint8Array(c);
47
+ return new DataView(t.buffer).setUint32(0, e, !1), t;
48
+ }, u = (e, t) => {
49
+ if (e.byteLength < t + c)
50
+ throw new Error("Encrypted data is incomplete");
51
+ return new DataView(e.buffer, e.byteOffset + t, c).getUint32(0, !1);
52
+ }, U = (e) => {
53
+ for (let t = 0; t < o.byteLength; t += 1)
54
+ if (e[t] !== o[t])
55
+ throw new Error("Unsupported encrypted data format");
56
+ };
57
+ export {
58
+ v as decodeEncryptedData,
59
+ A as encodeEncryptedData
60
+ };
61
+ //# sourceMappingURL=encode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode.js","sources":["../../src/data/encode.ts"],"sourcesContent":["import { decryptData, encryptData } from \"./encryption\";\n\nexport type EncryptedDataEncodingInfo = {\n version: 1;\n encryption: \"AES-GCM\";\n compression: \"none\";\n};\n\nexport type EncodeEncryptedDataOptions<TMetadata extends Record<string, unknown> | null = null> = {\n encryptionKey: string | CryptoKey;\n metadata?: TMetadata;\n additionalData?: Uint8Array;\n};\n\nexport type DecodeEncryptedDataOptions = {\n decryptionKey: string | CryptoKey;\n additionalData?: Uint8Array;\n};\n\nconst magic = new Uint8Array([0x54, 0x42, 0x45, 0x31]);\nconst uint32Bytes = 4;\nconst ivBytes = 12;\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\n\nexport const encodeEncryptedData = async <TMetadata extends Record<string, unknown> | null = null>(\n data: Uint8Array,\n options: EncodeEncryptedDataOptions<TMetadata>,\n) => {\n const encodingInfo: EncryptedDataEncodingInfo = {\n version: 1,\n encryption: \"AES-GCM\",\n compression: \"none\",\n };\n const encodingInfoBytes = textEncoder.encode(JSON.stringify(encodingInfo));\n const metadataBytes = textEncoder.encode(JSON.stringify(options.metadata ?? null));\n const encryptedContents = concatBuffers(writeUint32(metadataBytes.byteLength), metadataBytes, data);\n const { encryptedBuffer, iv } = await encryptData(options.encryptionKey, encryptedContents, {\n additionalData: options.additionalData,\n });\n\n return concatBuffers(\n magic,\n writeUint32(encodingInfoBytes.byteLength),\n encodingInfoBytes,\n iv,\n new Uint8Array(encryptedBuffer),\n );\n};\n\nexport const decodeEncryptedData = async <TMetadata extends Record<string, unknown> | null = null>(\n encoded: Uint8Array,\n options: DecodeEncryptedDataOptions,\n): Promise<{ metadata: TMetadata; data: Uint8Array }> => {\n const view = new Uint8Array(encoded);\n if (view.byteLength < magic.byteLength + uint32Bytes + ivBytes) {\n throw new Error(\"Encrypted data is too short\");\n }\n\n assertMagic(view);\n const encodingInfoLength = readUint32(view, magic.byteLength);\n const encodingInfoStart = magic.byteLength + uint32Bytes;\n const encodingInfoEnd = encodingInfoStart + encodingInfoLength;\n const ivStart = encodingInfoEnd;\n const ivEnd = ivStart + ivBytes;\n\n if (view.byteLength <= ivEnd) {\n throw new Error(\"Encrypted data is incomplete\");\n }\n\n const encodingInfo = JSON.parse(textDecoder.decode(view.slice(encodingInfoStart, encodingInfoEnd))) as Partial<EncryptedDataEncodingInfo>;\n if (encodingInfo.version !== 1 || encodingInfo.encryption !== \"AES-GCM\") {\n throw new Error(\"Unsupported encrypted data format\");\n }\n\n const decrypted = new Uint8Array(\n await decryptData(view.slice(ivStart, ivEnd), view.slice(ivEnd), options.decryptionKey, {\n additionalData: options.additionalData,\n }),\n );\n const metadataLength = readUint32(decrypted, 0);\n const metadataStart = uint32Bytes;\n const metadataEnd = metadataStart + metadataLength;\n if (decrypted.byteLength < metadataEnd) {\n throw new Error(\"Encrypted data metadata is incomplete\");\n }\n\n return {\n metadata: JSON.parse(textDecoder.decode(decrypted.slice(metadataStart, metadataEnd))) as TMetadata,\n data: decrypted.slice(metadataEnd),\n };\n};\n\nconst concatBuffers = (...buffers: Uint8Array[]) => {\n const output = new Uint8Array(buffers.reduce((total, buffer) => total + buffer.byteLength, 0));\n let offset = 0;\n for (const buffer of buffers) {\n output.set(buffer, offset);\n offset += buffer.byteLength;\n }\n return output;\n};\n\nconst writeUint32 = (value: number) => {\n const bytes = new Uint8Array(uint32Bytes);\n new DataView(bytes.buffer).setUint32(0, value, false);\n return bytes;\n};\n\nconst readUint32 = (bytes: Uint8Array, offset: number) => {\n if (bytes.byteLength < offset + uint32Bytes) {\n throw new Error(\"Encrypted data is incomplete\");\n }\n return new DataView(bytes.buffer, bytes.byteOffset + offset, uint32Bytes).getUint32(0, false);\n};\n\nconst assertMagic = (bytes: Uint8Array) => {\n for (let index = 0; index < magic.byteLength; index += 1) {\n if (bytes[index] !== magic[index]) {\n throw new Error(\"Unsupported encrypted data format\");\n }\n }\n};\n"],"names":["magic","uint32Bytes","ivBytes","textEncoder","textDecoder","encodeEncryptedData","data","options","encodingInfo","encodingInfoBytes","metadataBytes","encryptedContents","concatBuffers","writeUint32","encryptedBuffer","iv","encryptData","decodeEncryptedData","encoded","view","assertMagic","encodingInfoLength","readUint32","encodingInfoStart","encodingInfoEnd","ivStart","ivEnd","decrypted","decryptData","metadataLength","metadataStart","metadataEnd","buffers","output","total","buffer","offset","value","bytes","index"],"mappings":";AAmBA,MAAMA,IAAQ,IAAI,WAAW,CAAC,IAAM,IAAM,IAAM,EAAI,CAAC,GAC/CC,IAAc,GACdC,IAAU,IACVC,IAAc,IAAI,YAAA,GAClBC,IAAc,IAAI,YAAA,GAEXC,IAAsB,OACjCC,GACAC,MACG;AACH,QAAMC,IAA0C;AAAA,IAC9C,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,aAAa;AAAA,EAAA,GAETC,IAAoBN,EAAY,OAAO,KAAK,UAAUK,CAAY,CAAC,GACnEE,IAAgBP,EAAY,OAAO,KAAK,UAAUI,EAAQ,YAAY,IAAI,CAAC,GAC3EI,IAAoBC,EAAcC,EAAYH,EAAc,UAAU,GAAGA,GAAeJ,CAAI,GAC5F,EAAE,iBAAAQ,GAAiB,IAAAC,EAAA,IAAO,MAAMC,EAAYT,EAAQ,eAAeI,GAAmB;AAAA,IAC1F,gBAAgBJ,EAAQ;AAAA,EAAA,CACzB;AAED,SAAOK;AAAA,IACLZ;AAAA,IACAa,EAAYJ,EAAkB,UAAU;AAAA,IACxCA;AAAA,IACAM;AAAA,IACA,IAAI,WAAWD,CAAe;AAAA,EAAA;AAElC,GAEaG,IAAsB,OACjCC,GACAX,MACuD;AACvD,QAAMY,IAAO,IAAI,WAAWD,CAAO;AACnC,MAAIC,EAAK,aAAanB,EAAM,aAAaC,IAA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xC,aAAI,SAASqC,EAAM,MAAM,EAAE,UAAU,GAAGD,GAAO,EAAK,GAC7CC;AACT,GAEMhB,IAAa,CAACgB,GAAmBF,MAAmB;AACxD,MAAIE,EAAM,aAAaF,IAASnC;AAC9B,UAAM,IAAI,MAAM,8BAA8B;AAEhD,SAAO,IAAI,SAASqC,EAAM,QAAQA,EAAM,aAAaF,GAAQnC,CAAW,EAAE,UAAU,GAAG,EAAK;AAC9F,GAEMmB,IAAc,CAACkB,MAAsB;AACzC,WAASC,IAAQ,GAAGA,IAAQvC,EAAM,YAAYuC,KAAS;AACrD,QAAID,EAAMC,CAAK,MAAMvC,EAAMuC,CAAK;AAC9B,YAAM,IAAI,MAAM,mCAAmC;AAGzD;"}
@@ -0,0 +1,20 @@
1
+ export declare const AES_GCM_IV_BYTES = 12;
2
+ export declare const DEFAULT_ENCRYPTION_KEY_BYTES = 32;
3
+ export type EncryptedData = {
4
+ encryptedBuffer: ArrayBuffer;
5
+ iv: Uint8Array;
6
+ };
7
+ export type EncryptDataOptions = {
8
+ additionalData?: Uint8Array;
9
+ };
10
+ export type DecryptDataOptions = {
11
+ additionalData?: Uint8Array;
12
+ };
13
+ export declare const getCrypto: () => Crypto;
14
+ export declare const createIV: () => Uint8Array<ArrayBuffer>;
15
+ export declare const generateEncryptionKey: (byteLength?: number) => string;
16
+ export declare const importEncryptionKey: (encodedKey: string, usages?: KeyUsage[], expectedByteLength?: number) => Promise<CryptoKey>;
17
+ export declare const encryptData: (key: string | CryptoKey, data: Uint8Array, options?: EncryptDataOptions) => Promise<EncryptedData>;
18
+ export declare const decryptData: (iv: Uint8Array, encrypted: Uint8Array | ArrayBuffer, key: string | CryptoKey, options?: DecryptDataOptions) => Promise<ArrayBuffer>;
19
+ export declare const toArrayBuffer: (bytes: Uint8Array) => ArrayBuffer;
20
+ //# sourceMappingURL=encryption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/data/encryption.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE,WAAW,CAAC;IAC7B,EAAE,EAAE,UAAU,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,UAAU,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,CAAC,EAAE,UAAU,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,SAAS,QAAO,MAM5B,CAAC;AAEF,eAAO,MAAM,QAAQ,+BAIpB,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,mBAAyC,WAI9E,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,YAAY,MAAM,EAClB,SAAQ,QAAQ,EAA2B,EAC3C,2BAAiD,uBAQlD,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,KAAK,MAAM,GAAG,SAAS,EACvB,MAAM,UAAU,EAChB,UAAS,kBAAuB,KAC/B,OAAO,CAAC,aAAa,CAiBvB,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,IAAI,UAAU,EACd,WAAW,UAAU,GAAG,WAAW,EACnC,KAAK,MAAM,GAAG,SAAS,EACvB,UAAS,kBAAuB,yBAYjC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,UAAU,KAAG,WACwC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { A as e, D as r, c as s, d as y, e as E, g as o, f as p, i as c, t as n } from "../encryption-B0xRVvlF.js";
2
+ export {
3
+ e as AES_GCM_IV_BYTES,
4
+ r as DEFAULT_ENCRYPTION_KEY_BYTES,
5
+ s as createIV,
6
+ y as decryptData,
7
+ E as encryptData,
8
+ o as generateEncryptionKey,
9
+ p as getCrypto,
10
+ c as importEncryptionKey,
11
+ n as toArrayBuffer
12
+ };
13
+ //# sourceMappingURL=encryption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encryption.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,18 @@
1
+ import { createShareSnapshotPayload, type ShareSnapshot, type ShareSnapshotPayload, type ShareSnapshotSourceFile, type ShareSnapshotSourceFolder, type ShareSnapshotComment } from "../shareSnapshotPayload";
2
+ export type SerializeShareSnapshotInput = {
3
+ files: ShareSnapshotSourceFile[];
4
+ folders: ShareSnapshotSourceFolder[];
5
+ rootFolderId: string;
6
+ activeFileId: string;
7
+ commentsByFileId: Record<string, ShareSnapshotComment[]>;
8
+ };
9
+ export declare const serializeShareSnapshot: (payload: ShareSnapshotPayload) => Uint8Array<ArrayBuffer>;
10
+ export declare const parseShareSnapshot: (bytes: Uint8Array) => ShareSnapshotPayload;
11
+ export declare const restoreShareSnapshot: ({ id, url, payload, }: {
12
+ id: string;
13
+ url: string;
14
+ payload: ShareSnapshotPayload;
15
+ }) => ShareSnapshot;
16
+ export { createShareSnapshotPayload };
17
+ export type { ShareSnapshot, ShareSnapshotPayload };
18
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/data/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,0BAA0B,EAE1B,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EAC1B,MAAM,yBAAyB,CAAC;AAKjC,MAAM,MAAM,2BAA2B,GAAG;IACxC,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACjC,OAAO,EAAE,yBAAyB,EAAE,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;CAC1D,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,SAAS,oBAAoB,4BACO,CAAC;AAE5E,eAAO,MAAM,kBAAkB,GAAI,OAAO,UAAU,KAAG,oBACyB,CAAC;AAEjF,eAAO,MAAM,oBAAoB,GAAI,uBAIlC;IACD,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,oBAAoB,CAAC;CAC/B,KAAG,aAKA,CAAC;AAEL,OAAO,EAAE,0BAA0B,EAAE,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { v as a, c as r } from "../shareSnapshotPayload-CsTw9sRq.js";
2
+ import { a as x } from "../shareSnapshotPayload-CsTw9sRq.js";
3
+ const s = new TextEncoder(), n = new TextDecoder(), S = (e) => s.encode(JSON.stringify(a(e))), h = (e) => a(JSON.parse(n.decode(e))), p = ({
4
+ id: e,
5
+ url: o,
6
+ payload: t
7
+ }) => r({
8
+ id: e,
9
+ url: o,
10
+ payload: a(t)
11
+ });
12
+ export {
13
+ x as createShareSnapshotPayload,
14
+ h as parseShareSnapshot,
15
+ p as restoreShareSnapshot,
16
+ S as serializeShareSnapshot
17
+ };
18
+ //# sourceMappingURL=json.js.map