@open-docex/shared 0.0.0-stage → 0.1.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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +101 -2
  3. package/dist/errors/catalogue.d.ts +30 -0
  4. package/dist/errors/catalogue.d.ts.map +1 -0
  5. package/dist/errors/catalogue.js +52 -0
  6. package/dist/errors/catalogue.js.map +1 -0
  7. package/dist/errors/index.d.ts +9 -0
  8. package/dist/errors/index.d.ts.map +1 -0
  9. package/dist/errors/index.js +9 -0
  10. package/dist/errors/index.js.map +1 -0
  11. package/dist/errors/open-docex-error.d.ts +81 -0
  12. package/dist/errors/open-docex-error.d.ts.map +1 -0
  13. package/dist/errors/open-docex-error.js +127 -0
  14. package/dist/errors/open-docex-error.js.map +1 -0
  15. package/dist/ids/index.d.ts +41 -0
  16. package/dist/ids/index.d.ts.map +1 -0
  17. package/dist/ids/index.js +70 -0
  18. package/dist/ids/index.js.map +1 -0
  19. package/dist/index.d.ts +16 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +16 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/ot/index.d.ts +4 -0
  24. package/dist/ot/index.d.ts.map +1 -0
  25. package/dist/ot/index.js +3 -0
  26. package/dist/ot/index.js.map +1 -0
  27. package/dist/ot/types.d.ts +55 -0
  28. package/dist/ot/types.d.ts.map +1 -0
  29. package/dist/ot/types.js +11 -0
  30. package/dist/ot/types.js.map +1 -0
  31. package/dist/protocol/close-codes.d.ts +39 -0
  32. package/dist/protocol/close-codes.d.ts.map +1 -0
  33. package/dist/protocol/close-codes.js +47 -0
  34. package/dist/protocol/close-codes.js.map +1 -0
  35. package/dist/protocol/codec.d.ts +32 -0
  36. package/dist/protocol/codec.d.ts.map +1 -0
  37. package/dist/protocol/codec.js +270 -0
  38. package/dist/protocol/codec.js.map +1 -0
  39. package/dist/protocol/frames.d.ts +45 -0
  40. package/dist/protocol/frames.d.ts.map +1 -0
  41. package/dist/protocol/frames.js +125 -0
  42. package/dist/protocol/frames.js.map +1 -0
  43. package/dist/protocol/index.d.ts +12 -0
  44. package/dist/protocol/index.d.ts.map +1 -0
  45. package/dist/protocol/index.js +12 -0
  46. package/dist/protocol/index.js.map +1 -0
  47. package/dist/protocol/messages.d.ts +250 -0
  48. package/dist/protocol/messages.d.ts.map +1 -0
  49. package/dist/protocol/messages.js +7 -0
  50. package/dist/protocol/messages.js.map +1 -0
  51. package/dist/protocol/validate.d.ts +61 -0
  52. package/dist/protocol/validate.d.ts.map +1 -0
  53. package/dist/protocol/validate.js +139 -0
  54. package/dist/protocol/validate.js.map +1 -0
  55. package/dist/text/apply.d.ts +27 -0
  56. package/dist/text/apply.d.ts.map +1 -0
  57. package/dist/text/apply.js +151 -0
  58. package/dist/text/apply.js.map +1 -0
  59. package/dist/text/chunk.d.ts +33 -0
  60. package/dist/text/chunk.d.ts.map +1 -0
  61. package/dist/text/chunk.js +152 -0
  62. package/dist/text/chunk.js.map +1 -0
  63. package/dist/text/equal.d.ts +4 -0
  64. package/dist/text/equal.d.ts.map +1 -0
  65. package/dist/text/equal.js +16 -0
  66. package/dist/text/equal.js.map +1 -0
  67. package/dist/text/href.d.ts +13 -0
  68. package/dist/text/href.d.ts.map +1 -0
  69. package/dist/text/href.js +31 -0
  70. package/dist/text/href.js.map +1 -0
  71. package/dist/text/index.d.ts +18 -0
  72. package/dist/text/index.d.ts.map +1 -0
  73. package/dist/text/index.js +14 -0
  74. package/dist/text/index.js.map +1 -0
  75. package/dist/text/ot.d.ts +7 -0
  76. package/dist/text/ot.d.ts.map +1 -0
  77. package/dist/text/ot.js +136 -0
  78. package/dist/text/ot.js.map +1 -0
  79. package/dist/text/page.d.ts +35 -0
  80. package/dist/text/page.d.ts.map +1 -0
  81. package/dist/text/page.js +31 -0
  82. package/dist/text/page.js.map +1 -0
  83. package/dist/text/rebase.d.ts +50 -0
  84. package/dist/text/rebase.d.ts.map +1 -0
  85. package/dist/text/rebase.js +59 -0
  86. package/dist/text/rebase.js.map +1 -0
  87. package/dist/text/schema.d.ts +43 -0
  88. package/dist/text/schema.d.ts.map +1 -0
  89. package/dist/text/schema.js +482 -0
  90. package/dist/text/schema.js.map +1 -0
  91. package/dist/text/steps.d.ts +17 -0
  92. package/dist/text/steps.d.ts.map +1 -0
  93. package/dist/text/steps.js +14 -0
  94. package/dist/text/steps.js.map +1 -0
  95. package/dist/util/canonical-json.d.ts +16 -0
  96. package/dist/util/canonical-json.d.ts.map +1 -0
  97. package/dist/util/canonical-json.js +28 -0
  98. package/dist/util/canonical-json.js.map +1 -0
  99. package/dist/util/index.d.ts +10 -0
  100. package/dist/util/index.d.ts.map +1 -0
  101. package/dist/util/index.js +10 -0
  102. package/dist/util/index.js.map +1 -0
  103. package/dist/util/random.d.ts +17 -0
  104. package/dist/util/random.d.ts.map +1 -0
  105. package/dist/util/random.js +40 -0
  106. package/dist/util/random.js.map +1 -0
  107. package/dist/util/utf8.d.ts +13 -0
  108. package/dist/util/utf8.d.ts.map +1 -0
  109. package/dist/util/utf8.js +38 -0
  110. package/dist/util/utf8.js.map +1 -0
  111. package/package.json +57 -4
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Binary frame layout (LLD Part 1 §5.1):
3
+ *
4
+ * | Offset | Size | Field |
5
+ * |---|---|---|
6
+ * | 0 | 1 | Magic `0xD0` |
7
+ * | 1 | 1 | Layout version `1` |
8
+ * | 2 | 4 | Header length H, uint32 big-endian, 1 ≤ H ≤ 65 536 |
9
+ * | 6 | H | Header: UTF-8 JSON of the message without `bytes` |
10
+ * | 6+H | rest | Payload, which becomes the `bytes` field |
11
+ *
12
+ * @module
13
+ */
14
+ /** First byte of every binary frame. */
15
+ export const FRAME_MAGIC = 0xd0;
16
+ /** Binary frame layout version. */
17
+ export const FRAME_VERSION = 1;
18
+ /** Bytes before the header: magic, version and the header length. */
19
+ export const FRAME_PREFIX_BYTES = 6;
20
+ /** Largest allowed header, in bytes. */
21
+ export const MAX_FRAME_HEADER_BYTES = 65_536;
22
+ /**
23
+ * Builds a binary frame from a UTF-8 header and a payload. Returns `undefined` when the header
24
+ * length is outside 1…65 536 bytes.
25
+ */
26
+ export function writeBinaryFrame(header, payload) {
27
+ const h = header.byteLength;
28
+ if (h < 1 || h > MAX_FRAME_HEADER_BYTES)
29
+ return undefined;
30
+ const out = new Uint8Array(FRAME_PREFIX_BYTES + h + payload.byteLength);
31
+ out[0] = FRAME_MAGIC;
32
+ out[1] = FRAME_VERSION;
33
+ out[2] = (h >>> 24) & 0xff;
34
+ out[3] = (h >>> 16) & 0xff;
35
+ out[4] = (h >>> 8) & 0xff;
36
+ out[5] = h & 0xff;
37
+ out.set(header, FRAME_PREFIX_BYTES);
38
+ out.set(payload, FRAME_PREFIX_BYTES + h);
39
+ return out;
40
+ }
41
+ /**
42
+ * Splits a binary frame. Returns `undefined` when the frame is shorter than 6 bytes, the magic
43
+ * or version is wrong, or the header length is outside 1…65 536 or past the end of the frame.
44
+ */
45
+ export function readBinaryFrame(data) {
46
+ if (data.byteLength < FRAME_PREFIX_BYTES || data[0] !== FRAME_MAGIC || data[1] !== FRAME_VERSION) {
47
+ return undefined;
48
+ }
49
+ const h = ((data[2] << 24) >>> 0) + (data[3] << 16) + (data[4] << 8) + data[5];
50
+ if (h < 1 || h > MAX_FRAME_HEADER_BYTES || FRAME_PREFIX_BYTES + h > data.byteLength)
51
+ return undefined;
52
+ return {
53
+ header: data.subarray(FRAME_PREFIX_BYTES, FRAME_PREFIX_BYTES + h),
54
+ payload: data.subarray(FRAME_PREFIX_BYTES + h),
55
+ };
56
+ }
57
+ /**
58
+ * Strict UTF-8 decoding of a frame header. Returns `undefined` for malformed UTF-8 (overlong
59
+ * forms, surrogates, code points above U+10FFFF, truncated sequences).
60
+ *
61
+ * Written by hand because shared may use only the globals in `env.d.ts`, which has no
62
+ * `TextDecoder` (LLD Part 1 §1.4).
63
+ */
64
+ export function decodeUtf8(b) {
65
+ const units = [];
66
+ let out = '';
67
+ let i = 0;
68
+ while (i < b.length) {
69
+ const c = b[i];
70
+ let cp;
71
+ if (c < 0x80) {
72
+ cp = c;
73
+ i += 1;
74
+ }
75
+ else if (c >= 0xc2 && c <= 0xdf) {
76
+ const c1 = cont(b, i + 1);
77
+ if (c1 < 0)
78
+ return undefined;
79
+ cp = ((c & 0x1f) << 6) | c1;
80
+ i += 2;
81
+ }
82
+ else if (c >= 0xe0 && c <= 0xef) {
83
+ const c1 = cont(b, i + 1);
84
+ const c2 = cont(b, i + 2);
85
+ if (c1 < 0 || c2 < 0)
86
+ return undefined;
87
+ cp = ((c & 0x0f) << 12) | (c1 << 6) | c2;
88
+ if (cp < 0x800 || (cp >= 0xd800 && cp <= 0xdfff))
89
+ return undefined;
90
+ i += 3;
91
+ }
92
+ else if (c >= 0xf0 && c <= 0xf4) {
93
+ const c1 = cont(b, i + 1);
94
+ const c2 = cont(b, i + 2);
95
+ const c3 = cont(b, i + 3);
96
+ if (c1 < 0 || c2 < 0 || c3 < 0)
97
+ return undefined;
98
+ cp = ((c & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3;
99
+ if (cp < 0x10000 || cp > 0x10ffff)
100
+ return undefined;
101
+ i += 4;
102
+ }
103
+ else {
104
+ return undefined;
105
+ }
106
+ if (cp >= 0x10000) {
107
+ cp -= 0x10000;
108
+ units.push(0xd800 + (cp >> 10), 0xdc00 + (cp & 0x3ff));
109
+ }
110
+ else {
111
+ units.push(cp);
112
+ }
113
+ if (units.length >= 4096) {
114
+ out += String.fromCharCode(...units);
115
+ units.length = 0;
116
+ }
117
+ }
118
+ return out + String.fromCharCode(...units);
119
+ }
120
+ /** The 6 payload bits of a continuation byte at `i`, or -1. */
121
+ function cont(b, i) {
122
+ const x = b[i];
123
+ return x !== undefined && (x & 0xc0) === 0x80 ? x & 0x3f : -1;
124
+ }
125
+ //# sourceMappingURL=frames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frames.js","sourceRoot":"","sources":["../../src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message, binary framing, validation,
3
+ * encode/decode and close codes (HLD §9, LLD Part 1 §5, §6).
4
+ *
5
+ * Transport and session logic belong to the server and the client.
6
+ *
7
+ * @module
8
+ */
9
+ export * from './messages.js';
10
+ export { encodeMessage, decodeClientMessage, decodeServerMessage, isBinaryType, type DecodeResult } from './codec.js';
11
+ export { CloseCode, closeCodeFor } from './close-codes.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACtH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `@open-docex/shared/protocol`: every WebSocket message, binary framing, validation,
3
+ * encode/decode and close codes (HLD §9, LLD Part 1 §5, §6).
4
+ *
5
+ * Transport and session logic belong to the server and the client.
6
+ *
7
+ * @module
8
+ */
9
+ export * from './messages.js';
10
+ export { encodeMessage, decodeClientMessage, decodeServerMessage, isBinaryType } from './codec.js';
11
+ export { CloseCode, closeCodeFor } from './close-codes.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,YAAY,EAAqB,MAAM,YAAY,CAAC;AACtH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,250 @@
1
+ /**
2
+ * Every WebSocket message of the open_docex protocol, with exact fields (HLD §9,
3
+ * LLD Part 1 §5.2, §0 R-3, R-4, R-5, R-10, R-12, R-13).
4
+ *
5
+ * The upload family is V4 and the annotation family is V5; both are defined here so the
6
+ * contract is complete from V1.
7
+ *
8
+ * @module
9
+ */
10
+ import type { ClientErrorPayload } from '../errors/index.js';
11
+ import type { ClientId, DocumentId, Epoch } from '../ids/index.js';
12
+ /** The protocol version a client sends in `hello.protocol`. */
13
+ export declare const PROTOCOL_VERSION: 1;
14
+ /** The `Sec-WebSocket-Protocol` the client offers first and the Gateway selects (LLD §0 R-12). */
15
+ export declare const WS_SUBPROTOCOL: "open-docex.v1";
16
+ /** The connect-URL query parameter that carries the document ID (HLD §10.1, LLD §0 R-12). */
17
+ export declare const DOC_QUERY_PARAM: "doc";
18
+ /** The two document kinds. */
19
+ export type DocKind = 'text' | 'sheet';
20
+ /** A session's access level. */
21
+ export type Access = 'edit' | 'view';
22
+ /** The image types an asset may have (PO-24). */
23
+ export type AssetMime = 'image/png' | 'image/jpeg' | 'image/gif';
24
+ /** The office file formats open_docex reads and writes. */
25
+ export type FileFormat = 'docx' | 'odt' | 'xlsx' | 'ods';
26
+ /** The submission envelope (HLD §8.3, LLD Part 1 §6). `ops` are validated deeply by the Core. */
27
+ export interface SubmitEnvelope<O = unknown> {
28
+ clientId: ClientId;
29
+ /** ≥ 1; see LLD Part 1 §6 R9. */
30
+ clientSeq: number;
31
+ epoch: Epoch;
32
+ /** ≥ 0; see LLD Part 1 §6 R4. */
33
+ baseRev: number;
34
+ ops: O[];
35
+ }
36
+ /** A document feature open_docex cannot edit; its presence opens the file read-only (PO-13). */
37
+ export type UnsupportedFeature = 'tracked-changes' | 'comments' | 'footnotes' | 'fields' | 'text-boxes' | 'equations' | 'charts' | 'multiple-page-styles' | 'first-page-header' | 'odd-even-header' | 'conditional-formatting' | 'data-validation' | 'pivot-tables' | 'sheet-images' | 'cell-comments' | 'other';
38
+ /** One kind of unsupported content found on import (LLD §0 R-15). */
39
+ export interface UnsupportedFinding {
40
+ feature: UnsupportedFeature;
41
+ count: number;
42
+ /** At most 20 human-readable locations. */
43
+ where?: string[];
44
+ detail?: string;
45
+ }
46
+ /** Content converted on import, for example EMF images saved as PNG (PO-22, LLD §0 R-3). */
47
+ export interface ConversionNotice {
48
+ feature: 'image-to-png';
49
+ count: number;
50
+ where?: string[];
51
+ }
52
+ /** The first client frame. The server binds `clientId` to the session. */
53
+ export interface HelloMsg {
54
+ type: 'hello';
55
+ protocol: number;
56
+ clientId: ClientId;
57
+ resume?: {
58
+ epoch: Epoch;
59
+ rev: number;
60
+ };
61
+ }
62
+ /** A batch of ops (LLD Part 1 §6). */
63
+ export interface SubmitMsg<O = unknown> extends SubmitEnvelope<O> {
64
+ type: 'submit';
65
+ }
66
+ /** Uploads an image asset. Binary frame only. Answered by an {@link AssetMsg} without `bytes`. */
67
+ export interface AssetPutMsg {
68
+ type: 'asset-put';
69
+ reqId: number;
70
+ mime: AssetMime;
71
+ bytes: Uint8Array;
72
+ }
73
+ /** Requests an asset. Answered by a binary-frame {@link AssetMsg} with `bytes`. */
74
+ export interface AssetGetMsg {
75
+ type: 'asset-get';
76
+ reqId: number;
77
+ assetId: string;
78
+ }
79
+ /** Client heartbeat (HLD §13). The server echoes `n` in a {@link PongMsg} (LLD §0 R-5). */
80
+ export interface PingMsg {
81
+ type: 'ping';
82
+ n: number;
83
+ }
84
+ /** Starts a file upload [V4]. `name` is at most 255 characters. */
85
+ export interface UploadStartMsg {
86
+ type: 'upload-start';
87
+ reqId: number;
88
+ name: string;
89
+ format: FileFormat;
90
+ size: number;
91
+ }
92
+ /** One upload chunk of at most 256 KiB, `seq` from 0 [V4]. Binary frame only. */
93
+ export interface UploadChunkMsg {
94
+ type: 'upload-chunk';
95
+ reqId: number;
96
+ seq: number;
97
+ bytes: Uint8Array;
98
+ }
99
+ /** Ends a file upload [V4]. */
100
+ export interface UploadEndMsg {
101
+ type: 'upload-end';
102
+ reqId: number;
103
+ }
104
+ /** Lists the document's annotations [V5]. */
105
+ export interface AnnotationListMsg {
106
+ type: 'annotation-list';
107
+ reqId: number;
108
+ }
109
+ /** Creates or updates an annotation [V5]. */
110
+ export interface AnnotationPutMsg {
111
+ type: 'annotation-put';
112
+ reqId: number;
113
+ annotation: AnnotationInput;
114
+ }
115
+ /** Deletes an annotation [V5]. */
116
+ export interface AnnotationDeleteMsg {
117
+ type: 'annotation-delete';
118
+ reqId: number;
119
+ id: string;
120
+ }
121
+ /** Every message a client sends. */
122
+ export type ClientMessage = HelloMsg | SubmitMsg | AssetPutMsg | AssetGetMsg | PingMsg | UploadStartMsg | UploadChunkMsg | UploadEndMsg | AnnotationListMsg | AnnotationPutMsg | AnnotationDeleteMsg;
123
+ /** Starts a full load (LLD Part 1 §6 R12, §0 R-2, R-3). */
124
+ export interface LoadStartMsg {
125
+ type: 'load-start';
126
+ epoch: Epoch;
127
+ rev: number;
128
+ kind: DocKind;
129
+ access: Access;
130
+ readOnly: boolean;
131
+ unsupported?: UnsupportedFinding[];
132
+ /** The highest `clientSeq` of `hello.clientId` that the snapshot already contains. */
133
+ ackedClientSeq?: number;
134
+ totalChunks?: number;
135
+ limits?: {
136
+ maxAssetBytes?: number;
137
+ };
138
+ conversions?: ConversionNotice[];
139
+ }
140
+ /**
141
+ * One load chunk `{ seq, data }` (LLD Part 1 §7). `data` is a `TextChunkData` or
142
+ * `SheetChunkData` object; the protocol checks only that it is a plain object, and
143
+ * `OtType.assemble` validates it deeply.
144
+ */
145
+ export interface LoadChunkMsg {
146
+ type: 'load-chunk';
147
+ seq: number;
148
+ data: unknown;
149
+ }
150
+ /** Ends a full load. */
151
+ export interface LoadDoneMsg {
152
+ type: 'load-done';
153
+ rev: number;
154
+ }
155
+ /** Confirms a submit (LLD Part 1 §6 R5, R6, R10). */
156
+ export interface AckMsg<O = unknown> {
157
+ type: 'ack';
158
+ clientSeq: number;
159
+ rev: number;
160
+ committed?: O[];
161
+ }
162
+ /** Another client's committed ops (LLD Part 1 §6 R7). */
163
+ export interface RemoteMsg<O = unknown> {
164
+ type: 'remote';
165
+ fromRev: number;
166
+ ops: O[];
167
+ clientId: ClientId;
168
+ }
169
+ /** A sanitized error (HLD §11.1). */
170
+ export interface ErrorMsg extends ClientErrorPayload {
171
+ type: 'error';
172
+ }
173
+ /** The client must reload; a full load follows on the same socket (LLD §0 R-9). */
174
+ export interface ResyncMsg {
175
+ type: 'resync';
176
+ reason: 'epoch-changed' | 'history-unavailable' | 'inconsistent';
177
+ }
178
+ /** A state change the client shows (LLD Part 1 §5.2, §0 R-4). */
179
+ export type NoticeMsg = {
180
+ type: 'notice';
181
+ notice: 'storage';
182
+ state: 'normal' | 'local' | 'pending';
183
+ } | {
184
+ type: 'notice';
185
+ notice: 'read-only';
186
+ readOnly: boolean;
187
+ reason: 'unsupported-content';
188
+ } | {
189
+ type: 'notice';
190
+ notice: 'engine-restarting';
191
+ };
192
+ /**
193
+ * An asset. With `bytes` it is a binary frame (answer to `asset-get`); without `bytes` it is a
194
+ * text frame confirming an `asset-put` (LLD §0 R-10).
195
+ */
196
+ export interface AssetMsg {
197
+ type: 'asset';
198
+ reqId: number;
199
+ assetId: string;
200
+ mime: AssetMime;
201
+ size: number;
202
+ bytes?: Uint8Array;
203
+ }
204
+ /** Heartbeat answer, echoing `ping.n`. */
205
+ export interface PongMsg {
206
+ type: 'pong';
207
+ n: number;
208
+ }
209
+ /** Sent after the server persists an upload chunk [V4]. */
210
+ export interface UploadAckMsg {
211
+ type: 'upload-ack';
212
+ reqId: number;
213
+ receivedBytes: number;
214
+ }
215
+ /** The upload's result from the `onUploaded` hook [V4]. */
216
+ export interface UploadDoneMsg {
217
+ type: 'upload-done';
218
+ reqId: number;
219
+ documentId: DocumentId;
220
+ }
221
+ /** A bookmark or note on a text document [V5, PO-27]. Timestamps are ISO 8601 UTC. */
222
+ export interface Annotation {
223
+ id: string;
224
+ kind: 'bookmark' | 'note';
225
+ body: string;
226
+ authorId: string;
227
+ createdAt: string;
228
+ updatedAt: string;
229
+ resolved: boolean;
230
+ replyTo?: string;
231
+ }
232
+ /** The client-supplied part of an {@link Annotation} [V5]. */
233
+ export type AnnotationInput = Pick<Annotation, 'id' | 'kind' | 'body' | 'resolved'> & {
234
+ replyTo?: string;
235
+ };
236
+ /** A list of annotations, for example the answer to `annotation-list` [V5]. */
237
+ export interface AnnotationResultMsg {
238
+ type: 'annotation-result';
239
+ reqId: number;
240
+ annotations: Annotation[];
241
+ }
242
+ /** Broadcast to the document's other sessions when an annotation changes [V5]. Carries exactly one of `annotation` or `deletedId`. */
243
+ export interface AnnotationChangedMsg {
244
+ type: 'annotation-changed';
245
+ annotation?: Annotation;
246
+ deletedId?: string;
247
+ }
248
+ /** Every message a server sends. */
249
+ export type ServerMessage = LoadStartMsg | LoadChunkMsg | LoadDoneMsg | AckMsg | RemoteMsg | ErrorMsg | ResyncMsg | NoticeMsg | AssetMsg | PongMsg | UploadAckMsg | UploadDoneMsg | AnnotationResultMsg | AnnotationChangedMsg;
250
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/protocol/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAEnE,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAC3C,kGAAkG;AAClG,eAAO,MAAM,cAAc,EAAG,eAAwB,CAAC;AACvD,6FAA6F;AAC7F,eAAO,MAAM,eAAe,EAAG,KAAc,CAAC;AAE9C,8BAA8B;AAC9B,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AACvC,gCAAgC;AAChC,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AACrC,iDAAiD;AACjD,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,YA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-Protocol` the client offers first and the Gateway selects (LLD §0 R-12). */
4
+ export const WS_SUBPROTOCOL = 'open-docex.v1';
5
+ /** The connect-URL query parameter that carries the document ID (HLD §10.1, LLD §0 R-12). */
6
+ export const DOC_QUERY_PARAM = 'doc';
7
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/protocol/messages.ts"],"names":[],"mappings":"AAYA,+DAA+D;AAC/D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAC3C,kGAAkG;AAClG,MAAM,CAAC,MAAM,cAAc,GAAG,eAAwB,CAAC;AACvD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,eAAe,GAAG,KAAc,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Hand-written runtime validation combinators (LLD Part 1 §5.3). Internal to the protocol
3
+ * module: no dependencies, no `eval` or `new Function`, so it is CSP-safe.
4
+ *
5
+ * Every check takes an untrusted value and a path such as `$.resume.epoch`, and returns a
6
+ * fresh value or throws {@link ValidationError}. Inputs are never mutated.
7
+ *
8
+ * @module
9
+ * @internal
10
+ */
11
+ /** A validation failure at `path`. The decoder turns it into `PROTOCOL_INVALID_MESSAGE`. */
12
+ export declare class ValidationError extends Error {
13
+ readonly path: string;
14
+ readonly reason: string;
15
+ readonly name: "ValidationError";
16
+ constructor(path: string, reason: string);
17
+ }
18
+ /** A check: returns the validated value or throws {@link ValidationError}. */
19
+ export type Check<T> = (x: unknown, path: string) => T;
20
+ /** True for a plain data object (`{}` or a null-prototype object), as `JSON.parse` makes. */
21
+ export declare function isPlainObject(x: unknown): x is Record<string, unknown>;
22
+ /** Result type of an object check: required keys plus optional keys that may be absent. */
23
+ type ObjOf<R extends Record<string, Check<unknown>>, O extends Record<string, Check<unknown>>> = {
24
+ [K in keyof R]: ReturnType<R[K]>;
25
+ } & {
26
+ [K in keyof O]?: ReturnType<O[K]>;
27
+ };
28
+ declare function int(min: number, max: number): Check<number>;
29
+ declare function str(maxLen: number, re?: RegExp): Check<string>;
30
+ declare function bool(): Check<boolean>;
31
+ declare function lit<T extends string>(...values: T[]): Check<T>;
32
+ declare function arr<T>(item: Check<T>, o: {
33
+ min?: number;
34
+ max: number;
35
+ }): Check<T[]>;
36
+ /**
37
+ * Requires a plain object and copies only the declared keys into a fresh object, so unknown
38
+ * fields are dropped. `__proto__`, `constructor` and `prototype` are never read or copied, and
39
+ * a schema may not declare them. A missing required field fails. An absent optional field is
40
+ * left absent, never set to `undefined` (`exactOptionalPropertyTypes`).
41
+ */
42
+ declare function obj<R extends Record<string, Check<unknown>>, O extends Record<string, Check<unknown>> = Record<never, never>>(req: R, opt?: O): Check<ObjOf<R, O>>;
43
+ declare function bytes(maxLen: number): Check<Uint8Array>;
44
+ /** Accepts a plain object and returns it as is. Deep validation is the caller's job. */
45
+ declare function plain(): Check<Record<string, unknown>>;
46
+ /** Accepts `x` when `pred(x)` is true. */
47
+ declare function is<T>(pred: (x: unknown) => x is T, reason: string): Check<T>;
48
+ /** The validation combinators (LLD Part 1 §5.3), plus `bool`, `plain` and `is`. */
49
+ export declare const v: {
50
+ int: typeof int;
51
+ str: typeof str;
52
+ bool: typeof bool;
53
+ lit: typeof lit;
54
+ arr: typeof arr;
55
+ obj: typeof obj;
56
+ bytes: typeof bytes;
57
+ plain: typeof plain;
58
+ is: typeof is;
59
+ };
60
+ export {};
61
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/protocol/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,4FAA4F;AAC5F,qBAAa,eAAgB,SAAQ,KAAK;IAGtC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM;IAHzB,SAAkB,IAAI,EAAG,iBAAiB,CAAU;gBAEzC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAI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;AACH,iBAAS,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EACpH,GAAG,EAAE,CAAC,EACN,GAAG,CAAC,EAAE,CAAC,GACN,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAkBpB;AAED,iBAAS,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,CAMhD;AAED,wFAAwF;AACxF,iBAAS,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAK/C;AAED,0CAA0C;AAC1C,iBAAS,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAKrE;AAED,mFAAmF;AACnF,eAAO,MAAM,CAAC;;;;;;;;;;CAAsD,CAAC"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Hand-written runtime validation combinators (LLD Part 1 §5.3). Internal to the protocol
3
+ * module: no dependencies, no `eval` or `new Function`, so it is CSP-safe.
4
+ *
5
+ * Every check takes an untrusted value and a path such as `$.resume.epoch`, and returns a
6
+ * fresh value or throws {@link ValidationError}. Inputs are never mutated.
7
+ *
8
+ * @module
9
+ * @internal
10
+ */
11
+ /** A validation failure at `path`. The decoder turns it into `PROTOCOL_INVALID_MESSAGE`. */
12
+ export class ValidationError extends Error {
13
+ path;
14
+ reason;
15
+ name = 'ValidationError';
16
+ constructor(path, reason) {
17
+ super(`${path}: ${reason}`);
18
+ this.path = path;
19
+ this.reason = reason;
20
+ }
21
+ }
22
+ /** Keys that are never read from or copied out of untrusted objects. */
23
+ const FORBIDDEN_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
24
+ /** True for a plain data object (`{}` or a null-prototype object), as `JSON.parse` makes. */
25
+ export function isPlainObject(x) {
26
+ if (typeof x !== 'object' || x === null || Array.isArray(x))
27
+ return false;
28
+ const proto = Object.getPrototypeOf(x);
29
+ return proto === Object.prototype || proto === null;
30
+ }
31
+ function own(o, key) {
32
+ return Object.prototype.hasOwnProperty.call(o, key);
33
+ }
34
+ function int(min, max) {
35
+ return (x, path) => {
36
+ if (typeof x !== 'number' || !Number.isSafeInteger(x))
37
+ throw new ValidationError(path, 'expected a safe integer');
38
+ if (x < min || x > max)
39
+ throw new ValidationError(path, `expected an integer in [${min}, ${max}]`);
40
+ return x;
41
+ };
42
+ }
43
+ function str(maxLen, re) {
44
+ return (x, path) => {
45
+ if (typeof x !== 'string')
46
+ throw new ValidationError(path, 'expected a string');
47
+ if (x.length > maxLen)
48
+ throw new ValidationError(path, `expected at most ${maxLen} characters`);
49
+ if (re !== undefined && !re.test(x))
50
+ throw new ValidationError(path, 'string has the wrong format');
51
+ return x;
52
+ };
53
+ }
54
+ function bool() {
55
+ return (x, path) => {
56
+ if (typeof x !== 'boolean')
57
+ throw new ValidationError(path, 'expected a boolean');
58
+ return x;
59
+ };
60
+ }
61
+ function lit(...values) {
62
+ const allowed = new Set(values);
63
+ return (x, path) => {
64
+ if (typeof x !== 'string' || !allowed.has(x))
65
+ throw new ValidationError(path, 'unexpected value');
66
+ return x;
67
+ };
68
+ }
69
+ function arr(item, o) {
70
+ const min = o.min ?? 0;
71
+ return (x, path) => {
72
+ if (!Array.isArray(x))
73
+ throw new ValidationError(path, 'expected an array');
74
+ if (x.length < min || x.length > o.max) {
75
+ throw new ValidationError(path, `expected ${min} to ${o.max} items`);
76
+ }
77
+ const out = [];
78
+ for (let i = 0; i < x.length; i++)
79
+ out.push(item(x[i], `${path}[${i}]`));
80
+ return out;
81
+ };
82
+ }
83
+ /**
84
+ * Requires a plain object and copies only the declared keys into a fresh object, so unknown
85
+ * fields are dropped. `__proto__`, `constructor` and `prototype` are never read or copied, and
86
+ * a schema may not declare them. A missing required field fails. An absent optional field is
87
+ * left absent, never set to `undefined` (`exactOptionalPropertyTypes`).
88
+ */
89
+ function obj(req, opt) {
90
+ const reqKeys = Object.keys(req);
91
+ const optKeys = opt === undefined ? [] : Object.keys(opt);
92
+ for (const k of [...reqKeys, ...optKeys]) {
93
+ if (FORBIDDEN_KEYS.has(k))
94
+ throw new Error(`protocol schema may not declare the key "${k}"`);
95
+ }
96
+ return (x, path) => {
97
+ if (!isPlainObject(x))
98
+ throw new ValidationError(path, 'expected an object');
99
+ const out = {};
100
+ for (const k of reqKeys) {
101
+ if (!own(x, k))
102
+ throw new ValidationError(`${path}.${k}`, 'missing required field');
103
+ out[k] = req[k](x[k], `${path}.${k}`);
104
+ }
105
+ for (const k of optKeys) {
106
+ if (own(x, k) && x[k] !== undefined)
107
+ out[k] = opt[k](x[k], `${path}.${k}`);
108
+ }
109
+ return out;
110
+ };
111
+ }
112
+ function bytes(maxLen) {
113
+ return (x, path) => {
114
+ if (!(x instanceof Uint8Array))
115
+ throw new ValidationError(path, 'expected bytes');
116
+ if (x.byteLength > maxLen)
117
+ throw new ValidationError(path, `expected at most ${maxLen} bytes`);
118
+ return x;
119
+ };
120
+ }
121
+ /** Accepts a plain object and returns it as is. Deep validation is the caller's job. */
122
+ function plain() {
123
+ return (x, path) => {
124
+ if (!isPlainObject(x))
125
+ throw new ValidationError(path, 'expected an object');
126
+ return x;
127
+ };
128
+ }
129
+ /** Accepts `x` when `pred(x)` is true. */
130
+ function is(pred, reason) {
131
+ return (x, path) => {
132
+ if (!pred(x))
133
+ throw new ValidationError(path, reason);
134
+ return x;
135
+ };
136
+ }
137
+ /** The validation combinators (LLD Part 1 §5.3), plus `bool`, `plain` and `is`. */
138
+ export const v = { int, str, bool, lit, arr, obj, bytes, plain, is };
139
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate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