@brass-build/client 0.2.0 → 0.4.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.
- package/AGENTS.md +26 -5
- package/CHANGELOG.md +61 -2
- package/README.md +247 -87
- package/dist/acting-organization.d.ts +131 -0
- package/dist/acting-organization.d.ts.map +1 -0
- package/dist/acting-organization.js +278 -0
- package/dist/acting-organization.js.map +1 -0
- package/dist/api-headers.js +7 -7
- package/dist/api-headers.js.map +1 -1
- package/dist/call-service.d.ts +74 -0
- package/dist/call-service.d.ts.map +1 -0
- package/dist/call-service.js +253 -0
- package/dist/call-service.js.map +1 -0
- package/dist/client.d.ts +29 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +583 -12
- package/dist/client.js.map +1 -1
- package/dist/document-checkpoints.d.ts +1 -0
- package/dist/document-checkpoints.d.ts.map +1 -1
- package/dist/document-checkpoints.js +27 -0
- package/dist/document-checkpoints.js.map +1 -1
- package/dist/document-contents.d.ts +15 -0
- package/dist/document-contents.d.ts.map +1 -0
- package/dist/document-contents.js +88 -0
- package/dist/document-contents.js.map +1 -0
- package/dist/document-signals.d.ts +31 -1
- package/dist/document-signals.d.ts.map +1 -1
- package/dist/document-signals.js +59 -0
- package/dist/document-signals.js.map +1 -1
- package/dist/document-streams.d.ts +4 -2
- package/dist/document-streams.d.ts.map +1 -1
- package/dist/document-streams.js +6 -0
- package/dist/document-streams.js.map +1 -1
- package/dist/document-thumbnail-capture.d.ts +20 -0
- package/dist/document-thumbnail-capture.d.ts.map +1 -1
- package/dist/document-thumbnail-capture.js +247 -9
- package/dist/document-thumbnail-capture.js.map +1 -1
- package/dist/documents-namespace.d.ts.map +1 -1
- package/dist/documents-namespace.js +3 -0
- package/dist/documents-namespace.js.map +1 -1
- package/dist/documents.d.ts +51 -3
- package/dist/documents.d.ts.map +1 -1
- package/dist/documents.js +415 -36
- package/dist/documents.js.map +1 -1
- package/dist/export-guest.d.ts.map +1 -1
- package/dist/export-guest.js +5 -0
- package/dist/export-guest.js.map +1 -1
- package/dist/handle-types.d.ts +23 -0
- package/dist/handle-types.d.ts.map +1 -1
- package/dist/handles.d.ts +1 -1
- package/dist/handles.d.ts.map +1 -1
- package/dist/handles.js +3 -3
- package/dist/handles.js.map +1 -1
- package/dist/hosted-ui.d.ts +10 -0
- package/dist/hosted-ui.d.ts.map +1 -1
- package/dist/hosted-ui.js +115 -30
- package/dist/hosted-ui.js.map +1 -1
- package/dist/importer.d.ts.map +1 -1
- package/dist/importer.js +28 -66
- package/dist/importer.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -0
- package/dist/internal.js.map +1 -1
- package/dist/mutate-batching.js +2 -2
- package/dist/mutate-batching.js.map +1 -1
- package/dist/open-document.d.ts +16 -1
- package/dist/open-document.d.ts.map +1 -1
- package/dist/open-document.js +123 -35
- package/dist/open-document.js.map +1 -1
- package/dist/presence.d.ts +10 -0
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js.map +1 -1
- package/dist/record-paging.d.ts +13 -14
- package/dist/record-paging.d.ts.map +1 -1
- package/dist/record-paging.js +13 -14
- package/dist/record-paging.js.map +1 -1
- package/dist/serializer.d.ts +3 -3
- package/dist/session-toolbar.d.ts +9 -0
- package/dist/session-toolbar.d.ts.map +1 -1
- package/dist/session-toolbar.js +191 -21
- package/dist/session-toolbar.js.map +1 -1
- package/dist/tail-ops.js +2 -2
- package/dist/tail-ops.js.map +1 -1
- package/dist/types.d.ts +0 -42
- package/dist/types.d.ts.map +1 -1
- package/dist/undo.d.ts +1 -1
- package/dist/undo.d.ts.map +1 -1
- package/dist/undo.js +1 -1
- package/dist/undo.js.map +1 -1
- package/dist/version-bar.d.ts.map +1 -1
- package/dist/version-bar.js +75 -4
- package/dist/version-bar.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/dist/wasm-ready-gate.d.ts +13 -0
- package/dist/wasm-ready-gate.d.ts.map +1 -0
- package/dist/wasm-ready-gate.js +28 -0
- package/dist/wasm-ready-gate.js.map +1 -0
- package/dist/wasm-runtime.browser.d.ts +11 -0
- package/dist/wasm-runtime.browser.d.ts.map +1 -0
- package/dist/wasm-runtime.browser.js +44 -0
- package/dist/wasm-runtime.browser.js.map +1 -0
- package/dist/wasm-runtime.d.ts +6 -0
- package/dist/wasm-runtime.d.ts.map +1 -0
- package/dist/wasm-runtime.js +20 -0
- package/dist/wasm-runtime.js.map +1 -0
- package/dist/when-saved.d.ts +2 -0
- package/dist/when-saved.d.ts.map +1 -0
- package/dist/when-saved.js +70 -0
- package/dist/when-saved.js.map +1 -0
- package/dist/ws-client.d.ts +4 -0
- package/dist/ws-client.d.ts.map +1 -1
- package/dist/ws-client.js +70 -1
- package/dist/ws-client.js.map +1 -1
- package/dist/ws-frame-limit.d.ts.map +1 -1
- package/dist/ws-frame-limit.js +9 -10
- package/dist/ws-frame-limit.js.map +1 -1
- package/docs/app-manifest.md +335 -5
- package/docs/custom-chrome.md +7 -2
- package/docs/presence.md +12 -0
- package/docs/services.md +265 -0
- package/docs/text-fields.md +191 -0
- package/package.json +4 -5
- package/src/acting-organization.ts +396 -0
- package/src/api-headers.ts +7 -7
- package/src/call-service.ts +354 -0
- package/src/client.ts +655 -15
- package/src/document-checkpoints.ts +30 -0
- package/src/document-contents.ts +104 -0
- package/src/document-signals.ts +113 -1
- package/src/document-streams.ts +15 -1
- package/src/document-thumbnail-capture.ts +253 -9
- package/src/documents-namespace.ts +20 -10
- package/src/documents.ts +460 -33
- package/src/export-guest.ts +5 -0
- package/src/handle-types.ts +35 -0
- package/src/handles.ts +7 -6
- package/src/hosted-ui.ts +155 -29
- package/src/importer.ts +28 -62
- package/src/index.ts +43 -4
- package/src/internal.ts +10 -0
- package/src/mutate-batching.ts +2 -2
- package/src/open-document.ts +179 -39
- package/src/presence.ts +6 -0
- package/src/record-paging.ts +13 -14
- package/src/serializer.ts +3 -3
- package/src/session-toolbar.ts +219 -22
- package/src/tail-ops.ts +2 -2
- package/src/types.ts +6 -4
- package/src/undo.ts +1 -1
- package/src/version-bar.ts +77 -7
- package/src/version.ts +1 -1
- package/src/wasm-ready-gate.ts +30 -0
- package/src/wasm-runtime.browser.ts +48 -0
- package/src/wasm-runtime.ts +21 -0
- package/src/when-saved.ts +66 -0
- package/src/ws-client.ts +70 -1
- package/src/ws-frame-limit.ts +9 -10
- package/dist/vite.d.ts +0 -31
- package/dist/vite.d.ts.map +0 -1
- package/dist/vite.js +0 -161
- package/dist/vite.js.map +0 -1
- package/src/vite.ts +0 -214
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,yEAAyE;AACzE,4EAA4E;AAC5E,2EAA2E;AAC3E,2DAA2D;AAC3D,uDAAuD;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,yEAAyE;AACzE,4EAA4E;AAC5E,2EAA2E;AAC3E,2DAA2D;AAC3D,uDAAuD;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA6B1C,OAAO,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AAM9D,OAAO,EAGN,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAaN,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAQN,MAAM,cAAc,CAAC;AAatB,OAAO,EACL,QAAQ,GAqBT,MAAM,gBAAgB,CAAC;AAyBxB,OAAO,EAAE,cAAc,EAAE,MAAM,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Client } from './client.js';
|
|
|
2
2
|
export { BrassWsClient } from './ws-client.js';
|
|
3
3
|
export { buildSignInUrl, refreshTokens, type RefreshCredential, type RefreshOutcome, type RefreshResult, type TokenSet, } from './auth-flow.js';
|
|
4
4
|
export { decodeIdToken } from './jwt.js';
|
|
5
|
+
export { readDocumentContents, type DocumentContents, } from './document-contents.js';
|
|
6
|
+
export { fetchWithRetry, RETRY_READ, type RetryOptions, type RetryPolicy, } from './fetch-retry.js';
|
|
5
7
|
export { BRASS_INIT_ARG_KEYS, type BrassInitArgKey } from './init-keys.js';
|
|
6
8
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,cAAc,EACd,UAAU,EACV,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/internal.js
CHANGED
|
@@ -13,5 +13,7 @@ export { BrassClient } from './client.js';
|
|
|
13
13
|
export { BrassWsClient } from './ws-client.js';
|
|
14
14
|
export { buildSignInUrl, refreshTokens, } from './auth-flow.js';
|
|
15
15
|
export { decodeIdToken } from './jwt.js';
|
|
16
|
+
export { readDocumentContents, } from './document-contents.js';
|
|
17
|
+
export { fetchWithRetry, RETRY_READ, } from './fetch-retry.js';
|
|
16
18
|
export { BRASS_INIT_ARG_KEYS } from './init-keys.js';
|
|
17
19
|
//# sourceMappingURL=internal.js.map
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,oCAAoC;AACpC,EAAE;AACF,wEAAwE;AACxE,oEAAoE;AACpE,sEAAsE;AACtE,uEAAuE;AACvE,sEAAsE;AACtE,qEAAqE;AACrE,uEAAuE;AACvE,sBAAsB;AAEtB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,aAAa,GAKd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAwB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,oCAAoC;AACpC,EAAE;AACF,wEAAwE;AACxE,oEAAoE;AACpE,sEAAsE;AACtE,uEAAuE;AACvE,sEAAsE;AACtE,qEAAqE;AACrE,uEAAuE;AACvE,sBAAsB;AAEtB,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,aAAa,GAKd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,oBAAoB,GAErB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,cAAc,EACd,UAAU,GAGX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAwB,MAAM,gBAAgB,CAAC"}
|
package/dist/mutate-batching.js
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
//
|
|
17
17
|
// The budget answers to STORAGE, not to the socket: an op past the frame cap
|
|
18
18
|
// takes the HTTP write, which carries about 190x a frame. What storage meters
|
|
19
|
-
// is op COUNT
|
|
20
|
-
//
|
|
19
|
+
// is op COUNT: each op costs the same bookkeeping whatever its size, and
|
|
20
|
+
// takes a place in the join's tail budget. Measured on a
|
|
21
21
|
// 500,000-element write, 48 KB produces 526 ops and 512 KB produces 158, past
|
|
22
22
|
// which the budget stops binding for that shape, while encode time stays flat
|
|
23
23
|
// throughout: a smaller budget spends op count and buys nothing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutate-batching.js","sourceRoot":"","sources":["../src/mutate-batching.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,qEAAqE;AACrE,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,yEAAyE;AACzE,sEAAsE;AACtE,yBAAyB;AACzB,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,8CAA8C;AAE9C,sEAAsE;AACtE,uEAAuE;AACvE,+CAA+C;AAC/C,EA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EAAwE;IACxE,yEAAyE;IACzE,qBAAqB;IACb,OAAO,GAAwB,IAAI,CAAC;IAE5C,YAA6B,MAAyC;QAAzC,WAAM,GAAN,MAAM,CAAmC;IAAG,CAAC;IAE1E;kEAC8D;IAC9D,OAAO,CAAC,MAAkB;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED;2EACuE;IACvE,QAAQ,CAAC,IAAsB;QAC7B,KAAK,MAAM,GAAG,IAAI,IAAI;YAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED,6DAA6D;IAC7D,MAAM,CAAC,KAAc;QACnB,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;oBAQgB;IAChB,WAAW,CAAC,KAAa;QACvB,uEAAuE;QACvE,sEAAsE;QACtE,oBAAoB;QACpB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,KAAK,GAAG,8BAA8B,EAAE,CAAC;YAC5E,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;YACxB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAClB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC;IACvB,CAAC;IAED;;;;cAIU;IACV,YAAY,CAAC,GAAW;QACtB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;CACF"}
|
package/dist/open-document.d.ts
CHANGED
|
@@ -51,6 +51,20 @@ export interface DocumentSnapshotResponse {
|
|
|
51
51
|
can_edit?: boolean;
|
|
52
52
|
status?: DocumentWorkStatus;
|
|
53
53
|
drive?: DocumentDriveSummaryWire;
|
|
54
|
+
calling_app_exports?: boolean;
|
|
55
|
+
thumbnail?: {
|
|
56
|
+
version?: number;
|
|
57
|
+
} | null;
|
|
58
|
+
drive_publish_target?: DrivePublishTargetWire;
|
|
59
|
+
}
|
|
60
|
+
export interface DrivePublishTargetWire {
|
|
61
|
+
drive_type?: unknown;
|
|
62
|
+
drive_name?: unknown;
|
|
63
|
+
container_name?: unknown;
|
|
64
|
+
detail?: unknown;
|
|
65
|
+
source_unreadable?: unknown;
|
|
66
|
+
publishing?: unknown;
|
|
67
|
+
publish_failed?: unknown;
|
|
54
68
|
}
|
|
55
69
|
export interface DocumentDriveSummaryWire {
|
|
56
70
|
drive_type: string;
|
|
@@ -66,6 +80,7 @@ export interface DocumentDriveSummaryWire {
|
|
|
66
80
|
push_replaces_remote: boolean;
|
|
67
81
|
mirror_direction: DriveMirrorDirection;
|
|
68
82
|
publishing?: boolean;
|
|
83
|
+
source_unreadable?: string;
|
|
69
84
|
}
|
|
70
85
|
export interface DocumentAtVersionResponse {
|
|
71
86
|
effective_version: number;
|
|
@@ -115,7 +130,7 @@ export interface OpenDocumentFactoryOptions {
|
|
|
115
130
|
create: (docId: string, branchId: string, name: string) => Promise<import('./documents-namespace.js').DocumentStreamInfo>;
|
|
116
131
|
};
|
|
117
132
|
hostedUiProvider?: HostedUiProvider;
|
|
118
|
-
|
|
133
|
+
preferredOrganizationId?: () => string | null;
|
|
119
134
|
identity?: () => string | null;
|
|
120
135
|
reportError?: (err: Error) => void;
|
|
121
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-document.d.ts","sourceRoot":"","sources":["../src/open-document.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,QAAQ,EACR,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"open-document.d.ts","sourceRoot":"","sources":["../src/open-document.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,QAAQ,E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AC;CACpC;AAQD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG;IACtC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB,CAAC;AAqEF,MAAM,MAAM,kBAAkB,GAAG,CAC/B,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,uBAAuB,KAC9B,OAAO,CAAC,cAAc,CAAC,CAAC;AAO7B,MAAM,MAAM,oBAAoB,GAAG,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,uBAAuB,KAC9B,OAAO,CAAC,cAAc,CAAC,CAAC;AAE7B,MAAM,MAAM,gBAAgB,GAAG,CAC7B,OAAO,CAAC,EAAE,qBAAqB,KAC5B,OAAO,CAAC,cAAc,CAAC,CAAC;AAE7B,MAAM,WAAW,eAAe;IAE9B,IAAI,EAAE,kBAAkB,CAAC;IAKzB,MAAM,EAAE,gBAAgB,CAAC;IAKzB,gBAAgB,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAE9E,UAAU,EAAE,oBAAoB,CAAC;CAClC;AA6oBD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,0BAA0B,GAC/B,eAAe,CAmyDjB;AAoOD,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAmBD,eAAO,MAAM,6BAA6B,QAAa,CAAC;AAOxD,eAAO,MAAM,yBAAyB,OAAQ,CAAC;AAO/C,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAC1C,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAqB1C,eAAO,MAAM,uBAAuB,QAAS,CAAC"}
|
package/dist/open-document.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// raw Loro import at 50k entities, so the materialisation path adds no
|
|
5
5
|
// full-snapshot logging or deep cloning of decoded bytes.
|
|
6
6
|
import { DEFAULT_STREAM_NAME, Document, } from './documents.js';
|
|
7
|
+
import { ensureWasmReady } from './wasm-runtime.js';
|
|
7
8
|
import { createPresenceController } from './presence.js';
|
|
8
9
|
import { applyAppAssertionHeader, applyClientVersionHeader } from './api-headers.js';
|
|
9
10
|
import { brassErrorFromBody } from './api-fetch.js';
|
|
@@ -111,7 +112,9 @@ function toDriveStatus(wire) {
|
|
|
111
112
|
// update) must not be treated as unbroken and offered a push the server
|
|
112
113
|
// would reject. Require an explicit `false` to enable, and an explicit
|
|
113
114
|
// `true` to flag broken. Behaviour is unchanged for today's frames, which
|
|
114
|
-
// always carry the boolean.
|
|
115
|
+
// always carry the boolean. Whether the file is written server-side or
|
|
116
|
+
// from the app's own serializer is a REQUEST SHAPE the push path resolves
|
|
117
|
+
// for itself, so it says nothing about whether this document can publish.
|
|
115
118
|
canPush: wire.broken === false &&
|
|
116
119
|
mirrorDirection === 'two_way' &&
|
|
117
120
|
(state === 'ahead' || state === 'diverged'),
|
|
@@ -125,6 +128,29 @@ function toDriveStatus(wire) {
|
|
|
125
128
|
itemName: wire.item_name,
|
|
126
129
|
itemUrl: wire.item_url,
|
|
127
130
|
publishing: wire.publishing === true,
|
|
131
|
+
// Spread rather than assigned, because `exactOptionalPropertyTypes`
|
|
132
|
+
// separates an absent optional field from one holding `undefined`.
|
|
133
|
+
...(wire.source_unreadable !== undefined
|
|
134
|
+
? { sourceUnreadable: wire.source_unreadable }
|
|
135
|
+
: {}),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
// Map the wire target to the public shape, dropping one that does not carry
|
|
139
|
+
// what a publish needs. A malformed target is skipped rather than failing
|
|
140
|
+
// the open: the document is readable whatever its publish offer says.
|
|
141
|
+
function toPublishTarget(wire) {
|
|
142
|
+
if (typeof wire !== 'object' || wire === null)
|
|
143
|
+
return null;
|
|
144
|
+
const driveName = wire.drive_name;
|
|
145
|
+
if (typeof driveName !== 'string' || driveName === '')
|
|
146
|
+
return null;
|
|
147
|
+
return {
|
|
148
|
+
driveName,
|
|
149
|
+
driveType: typeof wire.drive_type === 'string' ? wire.drive_type : '',
|
|
150
|
+
containerName: typeof wire.container_name === 'string' ? wire.container_name : '',
|
|
151
|
+
detail: typeof wire.detail === 'string' ? wire.detail : '',
|
|
152
|
+
publishing: wire.publishing === true,
|
|
153
|
+
publishFailed: wire.publish_failed === true,
|
|
128
154
|
};
|
|
129
155
|
}
|
|
130
156
|
function isDocOpFrame(frame) {
|
|
@@ -373,6 +399,15 @@ function isDocMetaFrame(frame) {
|
|
|
373
399
|
typeof f.topic === 'string' &&
|
|
374
400
|
typeof f.name === 'string');
|
|
375
401
|
}
|
|
402
|
+
function isDocDrivePublishFrame(frame) {
|
|
403
|
+
if (typeof frame !== 'object' || frame === null)
|
|
404
|
+
return false;
|
|
405
|
+
const f = frame;
|
|
406
|
+
if (f.type !== 'doc_drive_publish' || typeof f.topic !== 'string') {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
return typeof f.publish === 'object' && f.publish !== null;
|
|
410
|
+
}
|
|
376
411
|
function isDocDriveStatusFrame(frame) {
|
|
377
412
|
if (typeof frame !== 'object' || frame === null)
|
|
378
413
|
return false;
|
|
@@ -499,16 +534,16 @@ export function createOpenDocument(opts) {
|
|
|
499
534
|
// open on something that clears on its own.
|
|
500
535
|
//
|
|
501
536
|
// Longer than the default handful of attempts because of what a 503 means
|
|
502
|
-
// on this route: the document is intact and its storage is busy.
|
|
503
|
-
//
|
|
504
|
-
// answer 503 is one that was just written hard, which is exactly the
|
|
537
|
+
// on this route: the document is intact and its storage is busy. A
|
|
538
|
+
// document's own writes contend with each other, so the one most likely
|
|
539
|
+
// to answer 503 is one that was just written hard, which is exactly the
|
|
505
540
|
// moment a person reloads to see their work. That pressure clears over
|
|
506
541
|
// tens of seconds, not the one second the default budget spans, and the
|
|
507
542
|
// cost of giving up early is telling someone their document will not open
|
|
508
543
|
// when waiting would have opened it.
|
|
509
544
|
//
|
|
510
545
|
// A thrown request gets a short budget of its own: it never reached the
|
|
511
|
-
// API, so
|
|
546
|
+
// API, so busy storage is not what is wrong, and a blocked origin
|
|
512
547
|
// or a host that does not resolve answers the seventh attempt as it
|
|
513
548
|
// answered the first, with the reader watching a loading surface
|
|
514
549
|
// throughout.
|
|
@@ -631,7 +666,7 @@ export function createOpenDocument(opts) {
|
|
|
631
666
|
// piped through `open` to materialise the editable Document.
|
|
632
667
|
// What the app hears when an op the socket could not carry also failed
|
|
633
668
|
// over HTTP. The server's message is preferred where it has one, since it
|
|
634
|
-
// names the actual refusal (too large
|
|
669
|
+
// names the actual refusal (too large to store inline, a revoked
|
|
635
670
|
// role); the status-shaped fallbacks cover a response that carries none.
|
|
636
671
|
function opWriteFailureMessage(status, parsed) {
|
|
637
672
|
const serverMessage = parsed?.error;
|
|
@@ -644,12 +679,12 @@ export function createOpenDocument(opts) {
|
|
|
644
679
|
return 'This document is no longer available.';
|
|
645
680
|
return `This change could not be saved (${status}).`;
|
|
646
681
|
}
|
|
647
|
-
// Write one op over HTTP. The socket carries an op only up to
|
|
648
|
-
//
|
|
649
|
-
//
|
|
682
|
+
// Write one op over HTTP. The socket carries an op only up to its own
|
|
683
|
+
// message cap; past it the message is not delivered and the connection is
|
|
684
|
+
// closed, so `wireDocTransport` sends the large ones here.
|
|
650
685
|
// Not retried on a transient failure: the caller holds the op in its
|
|
651
686
|
// outstanding tracker and re-asserts it, and a blind replay would write a
|
|
652
|
-
// second
|
|
687
|
+
// second stored copy of the same edit.
|
|
653
688
|
// Mint a presigned PUT and upload the blob to it, returning the staging
|
|
654
689
|
// key the op write names. The PUT carries no Brass headers: the URL is
|
|
655
690
|
// signed, and an extra header falls outside that signature.
|
|
@@ -701,9 +736,9 @@ export function createOpenDocument(opts) {
|
|
|
701
736
|
};
|
|
702
737
|
applyClientVersionHeader(headers);
|
|
703
738
|
await applyAppAssertionHeader(headers, opts.getAppAssertion);
|
|
704
|
-
// Past
|
|
705
|
-
//
|
|
706
|
-
//
|
|
739
|
+
// Past the size an op can carry inline, the blob is uploaded first and
|
|
740
|
+
// the write names what was staged, so a multi-megabyte op never travels
|
|
741
|
+
// through a request body.
|
|
707
742
|
let stagedKey;
|
|
708
743
|
if (opBlobNeedsStaging(opBlobB64)) {
|
|
709
744
|
stagedKey = await stageOpBlob(docId, opBlobB64, token);
|
|
@@ -787,31 +822,35 @@ export function createOpenDocument(opts) {
|
|
|
787
822
|
// a needed destination / organization before showing a loading state; any
|
|
788
823
|
// other non-2xx throws.
|
|
789
824
|
//
|
|
790
|
-
// A create that names no placement of its own
|
|
791
|
-
//
|
|
792
|
-
//
|
|
793
|
-
//
|
|
794
|
-
//
|
|
825
|
+
// A create that names no placement of its own lands in the organization the
|
|
826
|
+
// app is already acting in: the one a launch named, the one a document the
|
|
827
|
+
// reader just closed lives in, or the one they chose in the account menu's
|
|
828
|
+
// switch. Without it a member of several organizations is asked to name a
|
|
829
|
+
// destination they have already answered, once per create. An explicit
|
|
830
|
+
// `siblingOf` / `destination` outranks it: placing a document beside the
|
|
831
|
+
// open one is the more specific answer.
|
|
795
832
|
const createDocumentId = async (args) => {
|
|
796
|
-
const
|
|
797
|
-
? (opts.
|
|
833
|
+
const preferred = args.siblingOf === undefined && args.destination === undefined
|
|
834
|
+
? (opts.preferredOrganizationId?.() ?? null)
|
|
798
835
|
: null;
|
|
799
|
-
if (
|
|
836
|
+
if (preferred === null)
|
|
800
837
|
return postAndClassify(args);
|
|
801
838
|
try {
|
|
802
839
|
return await postAndClassify({
|
|
803
840
|
...args,
|
|
804
|
-
destination: { organization_id:
|
|
841
|
+
destination: { organization_id: preferred },
|
|
805
842
|
});
|
|
806
843
|
}
|
|
807
844
|
catch (err) {
|
|
808
|
-
//
|
|
809
|
-
//
|
|
810
|
-
//
|
|
811
|
-
//
|
|
812
|
-
//
|
|
813
|
-
//
|
|
814
|
-
//
|
|
845
|
+
// Every source of this value is a preference rather than an answer: a
|
|
846
|
+
// URL parameter, a document open in an organization reached through a
|
|
847
|
+
// shared project, a choice made before the person left. Each can name
|
|
848
|
+
// an organization the caller no longer has, which the server answers
|
|
849
|
+
// with a plain 404. Drop it and let the server resolve the destination
|
|
850
|
+
// on its own, which routes a multi-organization caller to the picker. A
|
|
851
|
+
// coded rejection (`app_not_installed`) belongs to the caller's own
|
|
852
|
+
// consent flow and passes through untouched, as does the 404 for an
|
|
853
|
+
// organization that exists but denies the app.
|
|
815
854
|
if (err instanceof BrassError && err.status === 404 && !err.code) {
|
|
816
855
|
return postAndClassify(args);
|
|
817
856
|
}
|
|
@@ -1018,6 +1057,7 @@ export function createOpenDocument(opts) {
|
|
|
1018
1057
|
resyncFromSnapshot,
|
|
1019
1058
|
skipPresence: true,
|
|
1020
1059
|
parkable: false,
|
|
1060
|
+
capacityReloadsDocument: false,
|
|
1021
1061
|
});
|
|
1022
1062
|
}
|
|
1023
1063
|
return doc;
|
|
@@ -1036,11 +1076,21 @@ export function createOpenDocument(opts) {
|
|
|
1036
1076
|
// status).
|
|
1037
1077
|
if (parsed.status !== undefined)
|
|
1038
1078
|
doc._emitStatus(parsed.status);
|
|
1079
|
+
// Whether this app is the one to serialize the document, which is what
|
|
1080
|
+
// decides whether a push carries bytes. Answered by the server for the
|
|
1081
|
+
// caller's own app and only on the join, since the fanout frame is one
|
|
1082
|
+
// payload for every subscriber and has no caller to answer for.
|
|
1083
|
+
doc._setExportRunsHere(parsed.calling_app_exports === true);
|
|
1039
1084
|
// Seed `doc.driveStatus` from the join before the first
|
|
1040
1085
|
// `doc_drive_status` frame.
|
|
1041
1086
|
if (parsed.drive !== undefined) {
|
|
1042
1087
|
doc._emitDriveStatus(toDriveStatus(parsed.drive));
|
|
1043
1088
|
}
|
|
1089
|
+
else {
|
|
1090
|
+
// Only for a document that mirrors nothing: a mirror publishes through
|
|
1091
|
+
// its link, and `_emitDriveStatus` clears any targets anyway.
|
|
1092
|
+
doc._setPublishTarget(toPublishTarget(parsed.drive_publish_target));
|
|
1093
|
+
}
|
|
1044
1094
|
// Highest seq seen; later `doc_op` / `op_ack` frames advance it. Kept in
|
|
1045
1095
|
// a closure, not on the Document: it is a transport concern, not CRDT
|
|
1046
1096
|
// state.
|
|
@@ -1430,6 +1480,7 @@ export function createOpenDocument(opts) {
|
|
|
1430
1480
|
await uploader(doc, image, width, height);
|
|
1431
1481
|
});
|
|
1432
1482
|
}
|
|
1483
|
+
doc._setThumbnailVersion(parsed.thumbnail?.version ?? null);
|
|
1433
1484
|
if (opts.checkpointCreator) {
|
|
1434
1485
|
const creator = opts.checkpointCreator;
|
|
1435
1486
|
doc.setCheckpointCreator(() => creator(doc));
|
|
@@ -1488,6 +1539,12 @@ export function createOpenDocument(opts) {
|
|
|
1488
1539
|
}
|
|
1489
1540
|
if (opts.reportError)
|
|
1490
1541
|
doc.setErrorReporter(opts.reportError);
|
|
1542
|
+
// No socket on a document the caller can write to: the write path reaches
|
|
1543
|
+
// no server, so the document reports the first attempt rather than
|
|
1544
|
+
// discarding it. Outside tests this is `wsBaseUrl` left unset, which
|
|
1545
|
+
// naming any other base URL does.
|
|
1546
|
+
if (!opts.wsClient && !doc.readOnly)
|
|
1547
|
+
doc.markTransportUnavailable();
|
|
1491
1548
|
return doc;
|
|
1492
1549
|
}
|
|
1493
1550
|
// Open at a historical version: read-only, no transport. The at-version
|
|
@@ -1704,8 +1761,13 @@ export function createOpenDocument(opts) {
|
|
|
1704
1761
|
// guest).
|
|
1705
1762
|
function wireGuestTransport(doc, token, docId, lineId, canEdit) {
|
|
1706
1763
|
const wsClient = opts.wsClient;
|
|
1707
|
-
if (!wsClient)
|
|
1764
|
+
if (!wsClient) {
|
|
1765
|
+
// No socket: a write would change local state and reach no server, so
|
|
1766
|
+
// the document reports the first one instead of discarding it quietly.
|
|
1767
|
+
if (canEdit)
|
|
1768
|
+
doc.markTransportUnavailable();
|
|
1708
1769
|
return;
|
|
1770
|
+
}
|
|
1709
1771
|
const topic = `doc:${docId}:${lineId}`;
|
|
1710
1772
|
// Ops on the socket awaiting an answer, keyed by `client_op_id`. An
|
|
1711
1773
|
// `unavailable` shed names no op, so re-asserting one needs the frames
|
|
@@ -2015,11 +2077,12 @@ export function createOpenDocument(opts) {
|
|
|
2015
2077
|
// create + obtain the doc_id, then `open(docId)`); they aren't fused
|
|
2016
2078
|
// because the create response is metadata-only and the open path already
|
|
2017
2079
|
// handles the empty-snapshot case via `Document.create()`. This is the
|
|
2018
|
-
// low-level path (`Brass.createDocument`): the
|
|
2019
|
-
// the
|
|
2020
|
-
//
|
|
2021
|
-
//
|
|
2022
|
-
//
|
|
2080
|
+
// low-level path (`Brass.createDocument`): the doc lands in the
|
|
2081
|
+
// organization the app is acting in, and otherwise in the caller's single
|
|
2082
|
+
// organization; a caller with none is routed to the hosted
|
|
2083
|
+
// acquire-organization surface and the create retries; a multi-org caller
|
|
2084
|
+
// whose app is acting nowhere rejects with a 409 (no hosted picker here,
|
|
2085
|
+
// that is the session's `create()`).
|
|
2023
2086
|
const create = async (options) => {
|
|
2024
2087
|
const args = { name: options?.name ?? 'Untitled' };
|
|
2025
2088
|
if (options?.app_metadata !== undefined)
|
|
@@ -2712,6 +2775,18 @@ function wireDocTransport(args) {
|
|
|
2712
2775
|
clearTimeout(gapTimer);
|
|
2713
2776
|
gapTimer = null;
|
|
2714
2777
|
}
|
|
2778
|
+
// A stream line reaches this only at capacity, and it has no owner to
|
|
2779
|
+
// reopen it: the session reopens the top-level id, but a stream is one
|
|
2780
|
+
// part of a document nothing reloads on its behalf. So it stops the
|
|
2781
|
+
// divergence (above) and marks itself read-only at capacity, which
|
|
2782
|
+
// `stream.readOnly` / `stream.atCapacity` already surface to the app,
|
|
2783
|
+
// rather than alerting the reader and reloading a document it is part
|
|
2784
|
+
// of. The diverged edit stays visible until the app reopens the stream;
|
|
2785
|
+
// it reached no other reader, so nothing is lost by leaving it.
|
|
2786
|
+
if (args.capacityReloadsDocument === false) {
|
|
2787
|
+
args.doc._markReadOnly('capacity');
|
|
2788
|
+
return;
|
|
2789
|
+
}
|
|
2715
2790
|
args.doc._markReadOnly('unsaved');
|
|
2716
2791
|
// The user is told by the SDK, not by each app, because an app that
|
|
2717
2792
|
// renders nothing is exactly the case this has to cover: a document that
|
|
@@ -3280,6 +3355,14 @@ function wireDocTransport(args) {
|
|
|
3280
3355
|
args.doc._emitDriveStatus(toDriveStatus(frame.drive));
|
|
3281
3356
|
return;
|
|
3282
3357
|
}
|
|
3358
|
+
if (isDocDrivePublishFrame(frame)) {
|
|
3359
|
+
args.doc._emitPublishState({
|
|
3360
|
+
publishing: frame.publish.publishing === true,
|
|
3361
|
+
failed: frame.publish.failed === true,
|
|
3362
|
+
detail: typeof frame.publish.detail === 'string' ? frame.publish.detail : null,
|
|
3363
|
+
});
|
|
3364
|
+
return;
|
|
3365
|
+
}
|
|
3283
3366
|
if (isDocOpsDroppedFrame(frame)) {
|
|
3284
3367
|
// Prompt durability re-check: the discard sealed a new snapshot, so
|
|
3285
3368
|
// re-fetch the moved frontier and run the handshake now instead of at
|
|
@@ -3603,6 +3686,11 @@ function snapshotKindTooNewError() {
|
|
|
3603
3686
|
return new BrassError('This document needs a newer version of this app. Update to the latest @brass-build/client to open it.', { status: 426 });
|
|
3604
3687
|
}
|
|
3605
3688
|
async function materialise(body, documentOptions, onSnapshotProgress) {
|
|
3689
|
+
// Constructing the document is the first thing in this package that runs the
|
|
3690
|
+
// WASM, and `Brass.init` only starts the fetch, so this is where it is
|
|
3691
|
+
// waited on. Usually it resolved during the auth round-trip and this costs
|
|
3692
|
+
// nothing.
|
|
3693
|
+
await ensureWasmReady();
|
|
3606
3694
|
// Stamp the server-minted doc_id onto the Document (via DocumentOptions, so
|
|
3607
3695
|
// it threads through the LoroDoc constructor without changing the static
|
|
3608
3696
|
// factory signatures) so callers can read `doc.id` to correlate.
|