@vite-hub/realtime 0.4.1 → 0.5.1
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/README.md +8 -4
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +1 -2
- package/dist/{bus-CKv8gQZf.js → bus-DJ3dOQAZ.js} +11 -22
- package/dist/{bus-protocol-wXkXW28q.d.ts → bus-protocol-juNrVJDF.d.ts} +0 -2
- package/dist/bus.d.ts +1 -3
- package/dist/bus.js +1 -2
- package/dist/client/browser.js +3 -3
- package/dist/client.d.ts +2 -4
- package/dist/client.js +15 -9
- package/dist/{conflict-DYC_qXzM.js → conflict-BqdKFrkE.js} +3 -5
- package/dist/{conflict-CmZizTYl.d.ts → conflict-C5KRv-J1.d.ts} +0 -2
- package/dist/{document-BfMW1zYU.d.ts → document-CbqgNO_0.d.ts} +2 -4
- package/dist/document-CfrQbB03.js +1736 -0
- package/dist/durability.d.ts +1 -3
- package/dist/durability.js +1 -6
- package/dist/{editor-BM5-vHqf.js → editor-DzhKM4Gt.js} +2 -5
- package/dist/{error-diagnostics-Cd-XWNf7.js → error-diagnostics-we8V1O-X.js} +1 -2
- package/dist/index.d.ts +3 -7
- package/dist/index.js +3 -3
- package/dist/internal/runtime/unavailable.d.ts +1 -3
- package/dist/internal/runtime/unavailable.js +1 -2
- package/dist/internal/server.d.ts +7 -0
- package/dist/internal/server.js +6 -0
- package/dist/{keepalive-B4ONG6AD.js → keepalive-BYkk6Ax8.js} +3 -5
- package/dist/{layout-DNaxppTZ.js → layout-BQwRLTH0.js} +1 -2
- package/dist/{layout-B7i6-FnH.d.ts → layout-BZtKNqiC.d.ts} +1 -3
- package/dist/log-NlQi6kow.js +157 -0
- package/dist/{object-BgPPDLDE.js → object-DfrneieE.js} +2 -4
- package/dist/{presence-B6rvkHqd.js → presence-DZ21pPKm.js} +3 -4
- package/dist/{request-C_bQc4NE.js → request-DM6xHTaU.js} +5 -10
- package/dist/{request-BwaohsJS.d.ts → request-PrMHOYFK.d.ts} +1 -3
- package/dist/server-CLdYV7Md.d.ts +126 -0
- package/dist/server-yQp02XNp.js +2599 -0
- package/dist/server.d.ts +4 -142
- package/dist/server.js +3 -2588
- package/dist/{types-Cvm0G3VJ.d.ts → types-oUyN-CJR.d.ts} +1 -27
- package/dist/vite.d.ts +4 -15
- package/dist/vite.js +64 -63
- package/dist/vue.d.ts +2 -7
- package/dist/vue.js +47 -40
- package/package.json +44 -39
- package/dist/document-U5rzg2vG.js +0 -2041
package/dist/durability.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Durability, DurabilityContext } from "@vite-hub/runtime/durability";
|
|
2
|
-
//#region src/durability.d.ts
|
|
3
2
|
/** What the build passes to `realtimeDurability()`: the Realtime driver that the build resolved. */
|
|
4
3
|
export interface RealtimeDurabilityInput {
|
|
5
4
|
/** `cloudflare`, `memory`, `postgres`, `redis`, or `auto` / `node` when the server picks it at boot. */
|
|
6
5
|
driver: string;
|
|
7
6
|
}
|
|
8
7
|
/** The durability of Realtime rooms, from the driver that the server uses at boot. */
|
|
9
|
-
export declare function realtimeDurability(input: RealtimeDurabilityInput, context: DurabilityContext): Durability[];
|
|
10
|
-
//#endregion
|
|
8
|
+
export declare function realtimeDurability(input: RealtimeDurabilityInput, context: DurabilityContext): Durability[];
|
package/dist/durability.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// src/durability.ts
|
|
2
2
|
const shared = {
|
|
3
3
|
cloudflare: "One Durable Object owns each room.",
|
|
4
4
|
postgres: "Postgres carries room updates between instances.",
|
|
5
5
|
redis: "Redis carries room updates between instances."
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
8
|
-
* The driver that the server uses. An `auto` or `node` driver picks it at boot: `REDIS_URL`, then
|
|
9
|
-
* `REALTIME_POSTGRES_URL`, then a Postgres Default Database, then memory.
|
|
10
|
-
*/
|
|
11
7
|
function resolveDriver(input, context) {
|
|
12
8
|
if (input.driver !== "auto" && input.driver !== "node") return { driver: input.driver };
|
|
13
9
|
if (context.env.REDIS_URL?.trim()) return {
|
|
@@ -42,5 +38,4 @@ function realtimeDurability(input, context) {
|
|
|
42
38
|
fix: "Set REDIS_URL, or use a Postgres Default Database, so instances share rooms. Or send every Realtime connection to one instance."
|
|
43
39
|
}];
|
|
44
40
|
}
|
|
45
|
-
//#endregion
|
|
46
41
|
export { realtimeDurability };
|
|
@@ -7,7 +7,7 @@ import { TableKit } from "@tiptap/extension-table";
|
|
|
7
7
|
import { Markdown } from "@tiptap/markdown";
|
|
8
8
|
import StarterKit from "@tiptap/starter-kit";
|
|
9
9
|
import { Marked } from "marked";
|
|
10
|
-
|
|
10
|
+
// src/frontmatter.ts
|
|
11
11
|
const frontmatterPattern = /^---\r?\n(?:---(?:\r?\n|$)|([\s\S]*?)\r?\n---(?:\r?\n|$))/;
|
|
12
12
|
const Frontmatter = Node.create({
|
|
13
13
|
name: "frontmatter",
|
|
@@ -58,8 +58,7 @@ const Frontmatter = Node.create({
|
|
|
58
58
|
return node.attrs?.value === null ? "---\n---" : `---\n${node.attrs?.value || ""}\n---`;
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
|
-
|
|
62
|
-
//#region src/editor.ts
|
|
61
|
+
// src/editor.ts
|
|
63
62
|
const RealtimeDocument = Document.extend({
|
|
64
63
|
content: "frontmatter? block+",
|
|
65
64
|
renderMarkdown(node, helpers, context) {
|
|
@@ -73,7 +72,6 @@ const RealtimeDocument = Document.extend({
|
|
|
73
72
|
});
|
|
74
73
|
const RealtimeCode = Code.extend({ excludes: "" });
|
|
75
74
|
const escapedAlertMarker = /^> \\\[!(note|tip|important|warning|caution)\\\](?=\n|$)/i;
|
|
76
|
-
/** A blockquote that writes a GitHub alert's first line (`> [!NOTE]`) as it read it, so the alert stays an alert. */
|
|
77
75
|
const RealtimeBlockquote = Blockquote.extend({ renderMarkdown(node, helpers, context) {
|
|
78
76
|
return (this.parent?.(node, helpers, context) ?? "").replace(escapedAlertMarker, "> [!$1]");
|
|
79
77
|
} });
|
|
@@ -143,5 +141,4 @@ const realtimeMarkdownEditor = defineRealtimeEditor({
|
|
|
143
141
|
}
|
|
144
142
|
}
|
|
145
143
|
});
|
|
146
|
-
//#endregion
|
|
147
144
|
export { defineRealtimeEditor as n, realtimeMarkdownEditor as r, createRealtimeEditorExtensions as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineErrors } from "@vite-hub/runtime";
|
|
2
|
-
|
|
2
|
+
// src/error-diagnostics.ts
|
|
3
3
|
const realtimeErrorDiagnostics = /*#__PURE__*/ defineErrors({
|
|
4
4
|
docs: "https://vitehub.dev/docs/realtime/diagnostics",
|
|
5
5
|
codes: {
|
|
@@ -154,5 +154,4 @@ const realtimeErrorDiagnostics = /*#__PURE__*/ defineErrors({
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
|
-
//#endregion
|
|
158
157
|
export { realtimeErrorDiagnostics as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { A as RealtimeResetReason, C as RealtimeReadOnlyReason, D as RealtimeRequestErrorCode, E as RealtimeRequestError, F as RealtimeUser, I as RealtimeVerifyResult, L as RealtimeWorkspaceChange, M as RealtimeSaveOptions, N as RealtimeSaveResult, O as RealtimeRequestEvent, P as RealtimeSaved, R as RealtimeWorkspaceDocumentOptions, S as RealtimePresenceDefinition, T as RealtimeRequestContext, _ as RealtimeLoadedDocument, a as RealtimeDefinition, b as RealtimePersistenceOptions, c as RealtimeDocumentContext, d as RealtimeDocumentStatus, f as RealtimeEditor, g as RealtimeIssue, h as RealtimeHoldOptions, i as RealtimeCheckpoint, j as RealtimeRoomRequestErrorCode, k as RealtimeRequestResult, l as RealtimeDocumentDefinition, m as RealtimeHistoryOptions, n as RealtimeAuthorizeContext, o as RealtimeDefinitionAccess, p as RealtimeFieldValue, s as RealtimeDocumentAdapter, u as RealtimeDocumentSnapshot, v as RealtimeOptions, x as RealtimePerson, y as RealtimeOriginContext, z as RealtimeRequestFailure } from "./types-
|
|
2
|
-
import { n as isRealtimeDocumentConflict, t as RealtimeDocumentConflict } from "./conflict-
|
|
3
|
-
import { n as realtimeDocumentLayout, t as readRealtimeStatus } from "./layout-
|
|
4
|
-
//#region src/definition.d.ts
|
|
1
|
+
import { A as RealtimeResetReason, C as RealtimeReadOnlyReason, D as RealtimeRequestErrorCode, E as RealtimeRequestError, F as RealtimeUser, I as RealtimeVerifyResult, L as RealtimeWorkspaceChange, M as RealtimeSaveOptions, N as RealtimeSaveResult, O as RealtimeRequestEvent, P as RealtimeSaved, R as RealtimeWorkspaceDocumentOptions, S as RealtimePresenceDefinition, T as RealtimeRequestContext, _ as RealtimeLoadedDocument, a as RealtimeDefinition, b as RealtimePersistenceOptions, c as RealtimeDocumentContext, d as RealtimeDocumentStatus, f as RealtimeEditor, g as RealtimeIssue, h as RealtimeHoldOptions, i as RealtimeCheckpoint, j as RealtimeRoomRequestErrorCode, k as RealtimeRequestResult, l as RealtimeDocumentDefinition, m as RealtimeHistoryOptions, n as RealtimeAuthorizeContext, o as RealtimeDefinitionAccess, p as RealtimeFieldValue, s as RealtimeDocumentAdapter, u as RealtimeDocumentSnapshot, v as RealtimeOptions, x as RealtimePerson, y as RealtimeOriginContext, z as RealtimeRequestFailure } from "./types-oUyN-CJR.js";
|
|
2
|
+
import { n as isRealtimeDocumentConflict, t as RealtimeDocumentConflict } from "./conflict-C5KRv-J1.js";
|
|
3
|
+
import { n as realtimeDocumentLayout, t as readRealtimeStatus } from "./layout-BZtKNqiC.js";
|
|
5
4
|
/**
|
|
6
5
|
* Checks a definition when the server loads it. A definition must say who can use its rooms: `authorize: true`,
|
|
7
6
|
* `authorize()`, or `access: "public"`. `history.checkpoint` needs a document that can record history: a Workspace
|
|
8
7
|
* document, or an adapter with `checkpoint()`.
|
|
9
8
|
*/
|
|
10
9
|
export declare function defineRealtime(definition: RealtimeDefinition): RealtimeDefinition;
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/editor.d.ts
|
|
13
10
|
export declare function createRealtimeEditorExtensions(options?: {
|
|
14
11
|
collaborative?: boolean;
|
|
15
12
|
}): (import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-blockquote").BlockquoteOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-code").CodeOptions, any> | import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-table").TableKitOptions, any> | import("@tiptap/core").Extension<import("@tiptap/markdown").MarkdownExtensionOptions, import("@tiptap/markdown").MarkdownExtensionStorage>)[];
|
|
@@ -20,5 +17,4 @@ export declare function defineRealtimeEditor(editor: RealtimeEditor): RealtimeEd
|
|
|
20
17
|
* atom node, parsed and printed by `@tiptap/markdown`. It runs headless on the server.
|
|
21
18
|
*/
|
|
22
19
|
export declare const realtimeMarkdownEditor: RealtimeEditor;
|
|
23
|
-
//#endregion
|
|
24
20
|
export { type RealtimeAuthorizeContext, type RealtimeCheckpoint, type RealtimeDefinition, type RealtimeDefinitionAccess, type RealtimeDocumentAdapter, RealtimeDocumentConflict, type RealtimeDocumentContext, type RealtimeDocumentDefinition, type RealtimeDocumentSnapshot, type RealtimeDocumentStatus, type RealtimeEditor, type RealtimeFieldValue, type RealtimeHistoryOptions, type RealtimeHoldOptions, type RealtimeIssue, type RealtimeLoadedDocument, type RealtimeOptions, type RealtimeOriginContext, type RealtimePersistenceOptions, type RealtimePerson, type RealtimePresenceDefinition, type RealtimeReadOnlyReason, type RealtimeRequestContext, type RealtimeRequestError, type RealtimeRequestErrorCode, type RealtimeRequestEvent, type RealtimeRequestFailure, type RealtimeRequestResult, type RealtimeResetReason, type RealtimeRoomRequestErrorCode, type RealtimeSaveOptions, type RealtimeSaveResult, type RealtimeSaved, type RealtimeUser, type RealtimeVerifyResult, type RealtimeWorkspaceChange, type RealtimeWorkspaceDocumentOptions, isRealtimeDocumentConflict, readRealtimeStatus, realtimeDocumentLayout };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
1
|
+
import { a as defineRealtime, n as isRealtimeDocumentConflict, t as RealtimeDocumentConflict } from "./conflict-BqdKFrkE.js";
|
|
2
|
+
import { n as defineRealtimeEditor, r as realtimeMarkdownEditor, t as createRealtimeEditorExtensions } from "./editor-DzhKM4Gt.js";
|
|
3
|
+
import { n as realtimeDocumentLayout, t as readRealtimeStatus } from "./layout-BQwRLTH0.js";
|
|
4
4
|
export { RealtimeDocumentConflict, createRealtimeEditorExtensions, defineRealtime, defineRealtimeEditor, isRealtimeDocumentConflict, readRealtimeStatus, realtimeDocumentLayout, realtimeMarkdownEditor };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { r as RealtimeAvailability } from "../../types-
|
|
2
|
-
//#region src/internal/runtime/unavailable.d.ts
|
|
1
|
+
import { r as RealtimeAvailability } from "../../types-oUyN-CJR.js";
|
|
3
2
|
declare const availability: RealtimeAvailability;
|
|
4
|
-
//#endregion
|
|
5
3
|
export { availability as default };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/runtime/unavailable.ts
|
|
2
2
|
const availability = {
|
|
3
3
|
available: false,
|
|
4
4
|
reason: "This build does not enable Realtime.",
|
|
5
5
|
fix: "Enable `realtime` in vitehub() with the Cloudflare or Node preset."
|
|
6
6
|
};
|
|
7
|
-
//#endregion
|
|
8
7
|
export { availability as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { i as RealtimeRoomRequestResult, n as RealtimeDurableObjectNamespace, o as requestRealtimeRoom, r as RealtimeRoomRequestOptions } from "../request-PrMHOYFK.js";
|
|
2
|
+
import { n as RealtimeBusMessage, r as RealtimeRoomRecord, t as RealtimeBus } from "../bus-protocol-juNrVJDF.js";
|
|
3
|
+
import { n as isRealtimeDocumentConflict, t as RealtimeDocumentConflict } from "../conflict-C5KRv-J1.js";
|
|
4
|
+
import { n as realtimeDocumentLayout, t as readRealtimeStatus } from "../layout-BZtKNqiC.js";
|
|
5
|
+
import { C as claimAwarenessClientIds, D as blobDocument, E as RealtimeBlobStore, O as isRealtimeAvailable, S as bindAwarenessIdentity, T as RealtimeBlobDocumentOptions, _ as isRealtimeWorkspaceDocument, a as applyRealtimeSyncMessage, b as readRealtimeRequestState, c as encodeAwarenessState, d as realtimePersistenceDefaults, f as realtimeRoomKey, g as RealtimeWorkspaceDocumentAdapter, h as restoreRealtimeDocument, i as RealtimeSyncOptions, l as encodeSyncStep1, m as resolveRealtimeDefinition, n as RealtimeHandlerOptions, o as assertRealtimeRoomStateQuota, p as refreshRealtimeDocument, r as RealtimeRefreshOptions, s as createRealtimeHandler, t as RealtimeHandler, u as encodeSyncUpdate, v as readRealtimeWorkspaceDocument, w as compactRealtimeAwareness, x as applyRealtimeAwarenessUpdate, y as workspaceDocument } from "../server-CLdYV7Md.js";
|
|
6
|
+
import { i as readRealtimeYDoc, n as createRealtimeYDoc, r as diffRealtimeYDoc, t as containsRealtimeState } from "../document-CbqgNO_0.js";
|
|
7
|
+
export { type RealtimeBlobDocumentOptions, type RealtimeBlobStore, type RealtimeBus, type RealtimeBusMessage, RealtimeDocumentConflict, type RealtimeDurableObjectNamespace, RealtimeHandler, RealtimeHandlerOptions, RealtimeRefreshOptions, type RealtimeRoomRecord, type RealtimeRoomRequestOptions, type RealtimeRoomRequestResult, RealtimeSyncOptions, type RealtimeWorkspaceDocumentAdapter, applyRealtimeAwarenessUpdate, applyRealtimeSyncMessage, assertRealtimeRoomStateQuota, bindAwarenessIdentity, blobDocument, claimAwarenessClientIds, compactRealtimeAwareness, containsRealtimeState, createRealtimeHandler, createRealtimeYDoc, diffRealtimeYDoc, encodeAwarenessState, encodeSyncStep1, encodeSyncUpdate, isRealtimeAvailable, isRealtimeDocumentConflict, isRealtimeWorkspaceDocument, readRealtimeRequestState, readRealtimeStatus, readRealtimeWorkspaceDocument, readRealtimeYDoc, realtimeDocumentLayout, realtimePersistenceDefaults, realtimeRoomKey, refreshRealtimeDocument, requestRealtimeRoom, resolveRealtimeDefinition, restoreRealtimeDocument, workspaceDocument };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { l as requestRealtimeRoom, m as isRealtimeAvailable } from "../request-DM6xHTaU.js";
|
|
2
|
+
import { n as realtimeDocumentLayout, t as readRealtimeStatus } from "../layout-BQwRLTH0.js";
|
|
3
|
+
import { n as isRealtimeDocumentConflict, t as RealtimeDocumentConflict } from "../conflict-BqdKFrkE.js";
|
|
4
|
+
import { _ as applyRealtimeAwarenessUpdate, a as encodeSyncStep1, b as compactRealtimeAwareness, c as realtimeRoomKey, d as restoreRealtimeDocument, f as blobDocument, g as readRealtimeRequestState, h as workspaceDocument, i as encodeAwarenessState, l as refreshRealtimeDocument, m as readRealtimeWorkspaceDocument, n as assertRealtimeRoomStateQuota, o as encodeSyncUpdate, p as isRealtimeWorkspaceDocument, r as createRealtimeHandler, s as realtimePersistenceDefaults, t as applyRealtimeSyncMessage, u as resolveRealtimeDefinition, v as bindAwarenessIdentity, y as claimAwarenessClientIds } from "../server-yQp02XNp.js";
|
|
5
|
+
import { i as diffRealtimeYDoc, n as containsRealtimeState, o as readRealtimeYDoc, r as createRealtimeYDoc } from "../document-CfrQbB03.js";
|
|
6
|
+
export { RealtimeDocumentConflict, applyRealtimeAwarenessUpdate, applyRealtimeSyncMessage, assertRealtimeRoomStateQuota, bindAwarenessIdentity, blobDocument, claimAwarenessClientIds, compactRealtimeAwareness, containsRealtimeState, createRealtimeHandler, createRealtimeYDoc, diffRealtimeYDoc, encodeAwarenessState, encodeSyncStep1, encodeSyncUpdate, isRealtimeAvailable, isRealtimeDocumentConflict, isRealtimeWorkspaceDocument, readRealtimeRequestState, readRealtimeStatus, readRealtimeWorkspaceDocument, readRealtimeYDoc, realtimeDocumentLayout, realtimePersistenceDefaults, realtimeRoomKey, refreshRealtimeDocument, requestRealtimeRoom, resolveRealtimeDefinition, restoreRealtimeDocument, workspaceDocument };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { h as realtimeKeepalivePing } from "./object-
|
|
1
|
+
import { h as realtimeKeepalivePing } from "./object-DfrneieE.js";
|
|
2
2
|
import * as time from "lib0/time";
|
|
3
|
-
|
|
3
|
+
// src/application-path.ts
|
|
4
4
|
function resolveRealtimeApplicationPath(path, baseURL = typeof __VITEHUB_APP_BASE_URL__ === "undefined" ? "/" : __VITEHUB_APP_BASE_URL__) {
|
|
5
5
|
return baseURL === "/" ? path : `${baseURL.replace(/\/+$/, "")}${path}`;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
//#region src/keepalive.ts
|
|
7
|
+
// src/keepalive.ts
|
|
9
8
|
const keepaliveIntervalMs = 15e3;
|
|
10
9
|
/**
|
|
11
10
|
* y-websocket closes a socket that received nothing for 30 seconds, then connects again. A room with nobody else in it,
|
|
@@ -29,5 +28,4 @@ function keepRealtimeSocketAlive(provider) {
|
|
|
29
28
|
}, keepaliveIntervalMs);
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
|
-
//#endregion
|
|
33
31
|
export { resolveRealtimeApplicationPath as n, keepRealtimeSocketAlive as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/layout.ts
|
|
2
2
|
/**
|
|
3
3
|
* Root types of every Realtime Y.Doc:
|
|
4
4
|
* - `body`: Y.XmlFragment bound to the editor through TipTap Collaboration.
|
|
@@ -30,5 +30,4 @@ function readRealtimeStatus(document) {
|
|
|
30
30
|
savedBy: status.savedBy
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
//#endregion
|
|
34
33
|
export { realtimeDocumentLayout as n, readRealtimeStatus as t };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { d as RealtimeDocumentStatus } from "./types-
|
|
1
|
+
import { d as RealtimeDocumentStatus } from "./types-oUyN-CJR.js";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
|
-
//#region src/layout.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Root types of every Realtime Y.Doc:
|
|
6
5
|
* - `body`: Y.XmlFragment bound to the editor through TipTap Collaboration.
|
|
@@ -14,5 +13,4 @@ declare const realtimeDocumentLayout: Readonly<{
|
|
|
14
13
|
readonly status: "status";
|
|
15
14
|
}>;
|
|
16
15
|
declare function readRealtimeStatus(document: Y.Doc): RealtimeDocumentStatus;
|
|
17
|
-
//#endregion
|
|
18
16
|
export { realtimeDocumentLayout as n, readRealtimeStatus as t };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// ../internal/src/runtime/request-log.ts
|
|
2
|
+
function isRequestLog(value) {
|
|
3
|
+
return value !== null && typeof value === "object" && typeof Reflect.get(value, "set") === "function" && typeof Reflect.get(value, "warn") === "function" && typeof Reflect.get(value, "error") === "function";
|
|
4
|
+
}
|
|
5
|
+
function contextLog(value) {
|
|
6
|
+
const context = value !== null && typeof value === "object" ? Reflect.get(value, "context") : void 0;
|
|
7
|
+
return context !== null && typeof context === "object" ? Reflect.get(context, "log") : void 0;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The evlog request logger of a request, or `undefined` when the app does not register evlog. Pass a Nitro v3 event
|
|
11
|
+
* (evlog sets `event.req.context.log`) or its `Request` (`request.context.log`).
|
|
12
|
+
*/
|
|
13
|
+
function requestLog(input) {
|
|
14
|
+
const log = contextLog(input !== null && typeof input === "object" ? Reflect.get(input, "req") : void 0) ?? contextLog(input);
|
|
15
|
+
return isRequestLog(log) ? log : void 0;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The `Symbol.for()` key of the bridge on `globalThis`. Every bundled copy of this module and the Nitro plugin that
|
|
19
|
+
* `vitehub()` generates use the same key.
|
|
20
|
+
*/
|
|
21
|
+
const evlogBridgeKey = "vitehub.evlog";
|
|
22
|
+
function isEvlogBridge(value) {
|
|
23
|
+
return value !== null && typeof value === "object" && typeof Reflect.get(value, "createLogger") === "function";
|
|
24
|
+
}
|
|
25
|
+
/** The evlog bridge of this process, or `undefined` when the app does not register evlog. */
|
|
26
|
+
function evlogBridge() {
|
|
27
|
+
const bridge = globalThis[Symbol.for(evlogBridgeKey)];
|
|
28
|
+
return isEvlogBridge(bridge) ? bridge : void 0;
|
|
29
|
+
}
|
|
30
|
+
function activeBridge() {
|
|
31
|
+
const bridge = evlogBridge();
|
|
32
|
+
try {
|
|
33
|
+
return bridge && bridge.isEnabled?.() !== false ? bridge : void 0;
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A short name for the cause of a failure, safe to put in a log field: the string `code` of the error, such as
|
|
40
|
+
* `ENOSPC` or a ViteHub diagnostic code, else its class name. Never the message, which can hold paths or values.
|
|
41
|
+
*/
|
|
42
|
+
function errorCode(error) {
|
|
43
|
+
if (error === null || typeof error !== "object") return void 0;
|
|
44
|
+
const code = Reflect.get(error, "code");
|
|
45
|
+
if (typeof code === "string" && code) return code;
|
|
46
|
+
const name = Reflect.get(error, "name");
|
|
47
|
+
return typeof name === "string" && name && name !== "Error" ? name : void 0;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Emits one evlog event of its own, outside a request's wide event. The event also reaches the app's `evlog:drain`
|
|
51
|
+
* hooks. Returns `false` when the app does not register evlog or turned it off, and never throws.
|
|
52
|
+
*/
|
|
53
|
+
function emitLogEvent(event) {
|
|
54
|
+
const bridge = activeBridge();
|
|
55
|
+
if (!bridge) return false;
|
|
56
|
+
try {
|
|
57
|
+
const log = bridge.createLogger({
|
|
58
|
+
action: event.field,
|
|
59
|
+
message: event.message,
|
|
60
|
+
[event.field]: event.fields
|
|
61
|
+
}, event.waitUntil ? { waitUntil: event.waitUntil } : void 0);
|
|
62
|
+
if (event.level === "error") log.error(event.withError && event.error instanceof Error ? event.error : event.message);
|
|
63
|
+
else log[event.level](event.message);
|
|
64
|
+
const emitted = log.emit();
|
|
65
|
+
if (emitted && bridge.drain) {
|
|
66
|
+
const drained = Promise.resolve().then(() => bridge.drain?.(emitted)).catch((error) => {
|
|
67
|
+
console.error("[evlog] drain failed:", error);
|
|
68
|
+
});
|
|
69
|
+
event.waitUntil?.(drained);
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
} catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Logs a failure that the caller survives, with a fixed message and the `code` of the error. With the evlog request
|
|
78
|
+
* logger of `request`, it replaces `[field]` on the request's wide event and adds a warning. Pass `request` only when the
|
|
79
|
+
* request has not answered yet: evlog drops fields after it emits the wide event. Otherwise it emits an event of its
|
|
80
|
+
* own. Without evlog, or with evlog off, it calls `fallback`, which prints to the server console as before. It never
|
|
81
|
+
* throws.
|
|
82
|
+
*/
|
|
83
|
+
function logFailure(failure, fallback) {
|
|
84
|
+
const code = errorCode(failure.error);
|
|
85
|
+
const fields = {
|
|
86
|
+
...failure.fields,
|
|
87
|
+
...code ? { code } : {}
|
|
88
|
+
};
|
|
89
|
+
const log = failure.request !== void 0 && activeBridge() ? requestLog(failure.request) : void 0;
|
|
90
|
+
if (log) try {
|
|
91
|
+
log.set({ [failure.field]: false });
|
|
92
|
+
log.warn(failure.message, { [failure.field]: fields });
|
|
93
|
+
return;
|
|
94
|
+
} catch {}
|
|
95
|
+
if (emitLogEvent({
|
|
96
|
+
...failure,
|
|
97
|
+
fields,
|
|
98
|
+
level: failure.level ?? "warn"
|
|
99
|
+
})) return;
|
|
100
|
+
try {
|
|
101
|
+
fallback();
|
|
102
|
+
} catch {}
|
|
103
|
+
}
|
|
104
|
+
// src/log.ts
|
|
105
|
+
/**
|
|
106
|
+
* The label of a room in logs. A `document: false` room id can be a random token that lets a person join, such as a
|
|
107
|
+
* page id, so the log gets a short hash of it. A cryptographic hash adds nothing here: a short or guessable id can be
|
|
108
|
+
* found from any hash by trying values.
|
|
109
|
+
*/
|
|
110
|
+
function realtimeRoomLabel(documentId, presence) {
|
|
111
|
+
if (!presence) return documentId;
|
|
112
|
+
let hash = 2166136261;
|
|
113
|
+
for (let index = 0; index < documentId.length; index++) {
|
|
114
|
+
hash ^= documentId.charCodeAt(index);
|
|
115
|
+
hash = Math.imul(hash, 16777619);
|
|
116
|
+
}
|
|
117
|
+
return `#${(hash >>> 0).toString(16).padStart(8, "0")}`;
|
|
118
|
+
}
|
|
119
|
+
/** The definition and room of a room key from `realtimeRoomKey()`. Workspace event rooms have no room id. */
|
|
120
|
+
function realtimeRoomFields(key, presence) {
|
|
121
|
+
let parts;
|
|
122
|
+
try {
|
|
123
|
+
parts = JSON.parse(key);
|
|
124
|
+
} catch {
|
|
125
|
+
return {};
|
|
126
|
+
}
|
|
127
|
+
if (!Array.isArray(parts)) return {};
|
|
128
|
+
const [definition, documentId] = parts;
|
|
129
|
+
return {
|
|
130
|
+
...typeof definition === "string" ? { definition } : {},
|
|
131
|
+
...typeof documentId === "string" ? { room: realtimeRoomLabel(documentId, presence) } : {}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Logs one Realtime failure as its own evlog event, `{ action: "realtime", message, realtime: fields }`, when the app
|
|
136
|
+
* registers evlog and has it on. The event has the fixed `message` and the error's `code`, never its message. Otherwise
|
|
137
|
+
* it prints to the console, with the error unless the room is private. It never throws: it also runs inside a Durable
|
|
138
|
+
* Object and in socket callbacks, which have no `waitUntil()`.
|
|
139
|
+
*/
|
|
140
|
+
function logRealtime(level, message, fields, error, options = {}) {
|
|
141
|
+
logFailure({
|
|
142
|
+
field: "realtime",
|
|
143
|
+
fields: { ...fields },
|
|
144
|
+
level,
|
|
145
|
+
message,
|
|
146
|
+
...error === void 0 ? {} : { error }
|
|
147
|
+
}, () => {
|
|
148
|
+
if (options.console === false) return;
|
|
149
|
+
const text = `[vitehub] ${message}`;
|
|
150
|
+
if (options.privateRoom) {
|
|
151
|
+
if (level === "error") console.error(text, fields);
|
|
152
|
+
else console.warn(text, fields);
|
|
153
|
+
} else if (level === "error") console.error(text, ...error === void 0 ? [] : [error]);
|
|
154
|
+
else console.warn(text, ...error === void 0 ? [] : [error instanceof Error ? error.message : String(error)]);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
export { requestLog as i, realtimeRoomFields as n, realtimeRoomLabel as r, logRealtime as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as realtimeErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as realtimeErrorDiagnostics } from "./error-diagnostics-we8V1O-X.js";
|
|
2
2
|
import * as decoding from "lib0/decoding";
|
|
3
3
|
import * as encoding from "lib0/encoding";
|
|
4
4
|
import { normalizeSafeWorkspacePath } from "@vite-hub/workspace/internal/path";
|
|
@@ -127,8 +127,7 @@ function decodeRealtimeRequestFramePayload(decoder) {
|
|
|
127
127
|
};
|
|
128
128
|
} catch {}
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
//#region ../internal/src/object.ts
|
|
130
|
+
// ../internal/src/object.ts
|
|
132
131
|
/** A non-null object that is not an array. Functions do not pass. */
|
|
133
132
|
function isRecord(value) {
|
|
134
133
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -141,5 +140,4 @@ function isRecordOrFunction(value) {
|
|
|
141
140
|
function cloneRecord(value) {
|
|
142
141
|
return value && typeof value === "object" && !Array.isArray(value) ? { ...value } : {};
|
|
143
142
|
}
|
|
144
|
-
//#endregion
|
|
145
143
|
export { realtimeReadOnlyCode as _, decodeRealtimeRequestFramePayload as a, realtimeSyncPendingCode as b, encodeRealtimeRequestFrame as c, maxAwarenessClients as d, readAwarenessClientIds as f, realtimeKeepalivePong as g, realtimeKeepalivePing as h, decodeRealtimeControlPayload as i, encodeWorkspaceChange as l, realtimeInvalidDocumentCode as m, isRecord as n, decodeWorkspaceChangePayload as o, realtimeForbiddenWriteCloseCode as p, isRecordOrFunction as r, encodeRealtimeControl as s, cloneRecord as t, isRetryableRealtimeRequestCode as u, realtimeResetCloseCode as v, workspaceRoomId as x, realtimeSourceChangedCode as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { n as isRecord } from "./object-DfrneieE.js";
|
|
2
|
+
import { t as realtimeErrorDiagnostics } from "./error-diagnostics-we8V1O-X.js";
|
|
3
|
+
// src/presence.ts
|
|
4
4
|
const personColors = [
|
|
5
5
|
"#E11D48",
|
|
6
6
|
"#D97706",
|
|
@@ -49,5 +49,4 @@ function getRealtimePeople(states) {
|
|
|
49
49
|
}
|
|
50
50
|
return people;
|
|
51
51
|
}
|
|
52
|
-
//#endregion
|
|
53
52
|
export { getRealtimePeople as n, createRealtimeIdentity as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as realtimeErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { t as realtimeErrorDiagnostics } from "./error-diagnostics-we8V1O-X.js";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
import availability from "#vitehub/realtime/availability";
|
|
4
|
-
|
|
4
|
+
// ../internal/src/runtime/cloudflare-env-lookup.ts
|
|
5
5
|
/** The key of the AsyncLocalStorage store on `globalThis`. Every bundled copy of this module shares the store. */
|
|
6
6
|
const activeEnvStorageKey = Symbol.for("vitehub.cloudflare.env-storage");
|
|
7
7
|
let activeEnv;
|
|
@@ -15,16 +15,14 @@ function getActiveCloudflareEnv() {
|
|
|
15
15
|
const host = globalThis;
|
|
16
16
|
return Object.hasOwn(host, "__env__") && host.__env__ !== void 0 ? host.__env__ : activeEnv;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
//#region ../internal/src/runtime/cloudflare-env.ts
|
|
18
|
+
// ../internal/src/runtime/cloudflare-env.ts
|
|
20
19
|
const runtimeGlobal = globalThis;
|
|
21
20
|
runtimeGlobal[activeEnvStorageKey] ||= new AsyncLocalStorage();
|
|
22
21
|
function getActiveCloudflareBinding(name) {
|
|
23
22
|
const env = getActiveCloudflareEnv();
|
|
24
23
|
return env && Object.hasOwn(env, name) ? env[name] : void 0;
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
//#region src/availability.ts
|
|
25
|
+
// src/availability.ts
|
|
28
26
|
/**
|
|
29
27
|
* Returns `true` when this build has a Realtime room driver: Durable Objects on Cloudflare, a Node server, or memory
|
|
30
28
|
* on the dev server. Without one, no room opens and `refreshRealtimeDocument()` resolves `false`.
|
|
@@ -32,8 +30,7 @@ function getActiveCloudflareBinding(name) {
|
|
|
32
30
|
function isRealtimeAvailable() {
|
|
33
31
|
return availability.available;
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
//#region src/request.ts
|
|
33
|
+
// src/request.ts
|
|
37
34
|
const routePrefix = "/_vitehub/realtime/";
|
|
38
35
|
/** Marks the request that `requestRealtimeRoom()` sends to a Durable Object. The Worker strips it from client requests. */
|
|
39
36
|
const internalRequestHeader = "x-vitehub-realtime-request";
|
|
@@ -80,7 +77,6 @@ function localRequesters() {
|
|
|
80
77
|
requestScope[localRequestKey] ??= /* @__PURE__ */ new Set();
|
|
81
78
|
return requestScope[localRequestKey];
|
|
82
79
|
}
|
|
83
|
-
/** The parameters each request error was made with, so a Durable Object can send the same error to the Worker. */
|
|
84
80
|
const roomRequestErrorParams = /* @__PURE__ */ new WeakMap();
|
|
85
81
|
function roomRequestError(code, params = {}) {
|
|
86
82
|
const result = createRoomRequestError(code, params);
|
|
@@ -188,5 +184,4 @@ const agentRealtime = {
|
|
|
188
184
|
available: isRealtimeAvailable,
|
|
189
185
|
request: requestRealtimeRoom
|
|
190
186
|
};
|
|
191
|
-
//#endregion
|
|
192
187
|
export { internalRequestHeader as a, localRequesters as c, routePrefix as d, toDurableRequestReply as f, durableRoomsInstance as i, requestRealtimeRoom as l, isRealtimeAvailable as m, defaultRequestTimeout as n, isDurableSockets as o, workerDurableObjects as p, defaultRequestWait as r, isRealtimeDurableObjectNamespace as s, agentRealtime as t, roomRequestError as u };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { j as RealtimeRoomRequestErrorCode } from "./types-
|
|
1
|
+
import { j as RealtimeRoomRequestErrorCode } from "./types-oUyN-CJR.js";
|
|
2
2
|
import { Result } from "@vite-hub/runtime";
|
|
3
|
-
//#region src/request.d.ts
|
|
4
3
|
/** The `$DurableObject` namespace binding that holds Realtime rooms on Cloudflare. */
|
|
5
4
|
interface RealtimeDurableObjectNamespace {
|
|
6
5
|
get(id: unknown): {
|
|
@@ -44,5 +43,4 @@ interface AgentRealtime {
|
|
|
44
43
|
request: typeof requestRealtimeRoom;
|
|
45
44
|
}
|
|
46
45
|
declare const agentRealtime: AgentRealtime;
|
|
47
|
-
//#endregion
|
|
48
46
|
export { agentRealtime as a, RealtimeRoomRequestResult as i, RealtimeDurableObjectNamespace as n, requestRealtimeRoom as o, RealtimeRoomRequestOptions as r, AgentRealtime as t };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { t as RealtimeBus } from "./bus-protocol-juNrVJDF.js";
|
|
2
|
+
import { R as RealtimeWorkspaceDocumentOptions, c as RealtimeDocumentContext, f as RealtimeEditor, l as RealtimeDocumentDefinition, s as RealtimeDocumentAdapter, w as RealtimeRegistry, x as RealtimePerson } from "./types-oUyN-CJR.js";
|
|
3
|
+
import { n as RealtimeDurableObjectNamespace } from "./request-PrMHOYFK.js";
|
|
4
|
+
import "./conflict-C5KRv-J1.js";
|
|
5
|
+
import "./document-CbqgNO_0.js";
|
|
6
|
+
import * as awarenessProtocol from "y-protocols/awareness";
|
|
7
|
+
import * as Y from "yjs";
|
|
8
|
+
import { Diagnostic } from "nostics";
|
|
9
|
+
import { ReadonlyWorkspaceFiles, WritableWorkspaceFiles } from "@vite-hub/workspace/files";
|
|
10
|
+
/**
|
|
11
|
+
* Returns `true` when this build has a Realtime room driver: Durable Objects on Cloudflare, a Node server, or memory
|
|
12
|
+
* on the dev server. Without one, no room opens and `refreshRealtimeDocument()` resolves `false`.
|
|
13
|
+
*/
|
|
14
|
+
declare function isRealtimeAvailable(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The part of a ViteHub Blob store that `blobDocument()` uses, such as `blob` from `vite-hub/blob`. `put()` writes only
|
|
17
|
+
* when its `ifMatch` or `overwrite: false` condition holds, and otherwise returns a `BLOB_CONFLICT` error.
|
|
18
|
+
*/
|
|
19
|
+
interface RealtimeBlobStore {
|
|
20
|
+
get(pathname: string): Promise<[error: unknown, value: Blob | null | undefined]>;
|
|
21
|
+
head(pathname: string): Promise<[error: unknown, value: {
|
|
22
|
+
httpEtag: string | undefined;
|
|
23
|
+
} | null | undefined]>;
|
|
24
|
+
put(pathname: string, body: string, options: {
|
|
25
|
+
contentType: string;
|
|
26
|
+
ifMatch: string;
|
|
27
|
+
} | {
|
|
28
|
+
contentType: string;
|
|
29
|
+
overwrite: false;
|
|
30
|
+
}): Promise<[error: unknown, value: unknown]>;
|
|
31
|
+
}
|
|
32
|
+
interface RealtimeBlobDocumentOptions {
|
|
33
|
+
/** Defaults to `text/markdown; charset=utf-8`. */
|
|
34
|
+
contentType?: string;
|
|
35
|
+
/** Prepended to the document id to make the Blob pathname. Defaults to none. */
|
|
36
|
+
prefix?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Stores each Realtime document as one Blob file at `prefix + documentId`. Its digest is the SHA-256 of the
|
|
40
|
+
* body. `save()` reads the stored file and throws `RealtimeDocumentConflict` when its digest is not `ifDigest`. It
|
|
41
|
+
* writes only if the file still has the ETag that it read, so a writer outside the room that writes between that read
|
|
42
|
+
* and the save's write also makes the save throw `RealtimeDocumentConflict`, and keeps its file.
|
|
43
|
+
*/
|
|
44
|
+
declare function blobDocument(store: RealtimeBlobStore, options?: RealtimeBlobDocumentOptions): RealtimeDocumentAdapter;
|
|
45
|
+
type RealtimeIdentity = Omit<RealtimePerson, "clientId">;
|
|
46
|
+
/**
|
|
47
|
+
* Records that `peer` owns `clients`. A client that another peer owns is a conflict, unless `transferable` accepts its
|
|
48
|
+
* owner, such as another server instance that the client left.
|
|
49
|
+
*/
|
|
50
|
+
declare function claimAwarenessClientIds<Peer extends object>(owners: Map<number, Peer>, peer: Peer, clients: number[], transferable?: (owner: Peer) => boolean): number[];
|
|
51
|
+
declare function bindAwarenessIdentity(update: Uint8Array, identity: RealtimeIdentity): Uint8Array;
|
|
52
|
+
declare function applyRealtimeAwarenessUpdate(awareness: awarenessProtocol.Awareness, update: Uint8Array, origin: unknown, maxStateBytes?: number): void;
|
|
53
|
+
declare function compactRealtimeAwareness(awareness: awarenessProtocol.Awareness): awarenessProtocol.Awareness;
|
|
54
|
+
declare function readRealtimeRequestState(request: Request, maxBytes?: number): Promise<Uint8Array>;
|
|
55
|
+
interface RealtimeWorkspaceDocumentAdapter extends RealtimeDocumentAdapter {
|
|
56
|
+
kind: "workspace";
|
|
57
|
+
workspace: string;
|
|
58
|
+
}
|
|
59
|
+
declare function readRealtimeWorkspaceDocument(readable: ReadonlyWorkspaceFiles, writable: WritableWorkspaceFiles, documentId: string): Promise<{
|
|
60
|
+
baselineDigest: string | undefined;
|
|
61
|
+
markdown: string;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Stores each Realtime document as the Markdown file at its path in a Workspace working tree.
|
|
65
|
+
* `history.checkpoint()` commits the working tree to Workspace history with the Store's author by default.
|
|
66
|
+
* `document: { workspace }` in a Realtime Definition uses this adapter.
|
|
67
|
+
*/
|
|
68
|
+
declare function workspaceDocument(workspaceName: string, checkpointAuthor?: RealtimeWorkspaceDocumentOptions["checkpointAuthor"]): RealtimeWorkspaceDocumentAdapter;
|
|
69
|
+
declare function isRealtimeWorkspaceDocument(adapter: RealtimeDocumentAdapter): adapter is RealtimeWorkspaceDocumentAdapter;
|
|
70
|
+
interface RealtimeHandler {
|
|
71
|
+
(event: unknown): Promise<unknown>;
|
|
72
|
+
fetch(input: Request | URL | string): Promise<Response>;
|
|
73
|
+
}
|
|
74
|
+
interface RealtimeHandlerOptions {
|
|
75
|
+
/**
|
|
76
|
+
* Shares the rooms of this server with other instances. ViteHub passes `useRealtimeBus()` from
|
|
77
|
+
* `@vite-hub/realtime/bus` in Node builds. It runs once, when the first room opens. `undefined` keeps the rooms in
|
|
78
|
+
* this process.
|
|
79
|
+
*/
|
|
80
|
+
bus?: () => Promise<RealtimeBus | undefined> | RealtimeBus | undefined;
|
|
81
|
+
}
|
|
82
|
+
declare const realtimePersistenceDefaults: Readonly<{
|
|
83
|
+
debounce: 2000;
|
|
84
|
+
maxWait: 10000;
|
|
85
|
+
}>;
|
|
86
|
+
declare function encodeSyncUpdate(update: Uint8Array): Uint8Array;
|
|
87
|
+
declare function encodeSyncStep1(document: Y.Doc): Uint8Array;
|
|
88
|
+
declare function encodeAwarenessState(awareness: awarenessProtocol.Awareness, clients: number[]): Uint8Array;
|
|
89
|
+
interface RealtimeSyncOptions {
|
|
90
|
+
maxStateBytes?: number;
|
|
91
|
+
/** Reject any update that changes the document. A string replaces the rejection message. */
|
|
92
|
+
readOnly?: boolean | string;
|
|
93
|
+
/** Reject updates that change the server-written `status` map. Default `true`. */
|
|
94
|
+
protectStatus?: boolean;
|
|
95
|
+
}
|
|
96
|
+
declare function applyRealtimeSyncMessage(data: Uint8Array, document: Y.Doc, origin: unknown, options?: RealtimeSyncOptions): Uint8Array | undefined;
|
|
97
|
+
declare function assertRealtimeRoomStateQuota(document: Y.Doc, maxStateBytes?: number): void;
|
|
98
|
+
declare function realtimeRoomKey(definitionName: string, documentId: string, scope?: string): string;
|
|
99
|
+
declare function restoreRealtimeDocument(markdown: string, baselineDigest: string | undefined, stored: Record<string, unknown> | undefined): Promise<Y.Doc>;
|
|
100
|
+
interface ResolvedRealtimeDefinition {
|
|
101
|
+
adapter: RealtimeDocumentAdapter;
|
|
102
|
+
definition: RealtimeDocumentDefinition;
|
|
103
|
+
editor: (context: RealtimeDocumentContext) => RealtimeEditor | Promise<RealtimeEditor>;
|
|
104
|
+
persistence: {
|
|
105
|
+
debounce: number;
|
|
106
|
+
maxWait: number;
|
|
107
|
+
} | false;
|
|
108
|
+
}
|
|
109
|
+
/** Resolves the document adapter, editor codec, and persistence timing of a definition. */
|
|
110
|
+
declare function resolveRealtimeDefinition(definition: RealtimeDocumentDefinition): ResolvedRealtimeDefinition;
|
|
111
|
+
interface RealtimeRefreshOptions {
|
|
112
|
+
/**
|
|
113
|
+
* On Cloudflare, the `$DurableObject` binding that holds the rooms. Defaults to the binding of the running Worker.
|
|
114
|
+
* Without one, the rooms of this process refresh.
|
|
115
|
+
*/
|
|
116
|
+
durableObjects?: RealtimeDurableObjectNamespace;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Tells the open room of a document that its stored copy changed outside the room, such as a save by an Agent or the
|
|
120
|
+
* CLI. A room without unsaved edits re-seeds at once and resets its clients. A room with unsaved edits finds the change
|
|
121
|
+
* at its next save, which also re-seeds it. A room that is not open loads the stored copy when it opens. Resolves
|
|
122
|
+
* whether a room re-seeded. It never throws: a failed refresh leaves the next save to find the change.
|
|
123
|
+
*/
|
|
124
|
+
declare function refreshRealtimeDocument(definition: string, documentId: string, options?: RealtimeRefreshOptions): Promise<boolean>;
|
|
125
|
+
declare function createRealtimeHandler(registry: RealtimeRegistry, options?: RealtimeHandlerOptions): RealtimeHandler;
|
|
126
|
+
export { claimAwarenessClientIds as C, blobDocument as D, RealtimeBlobStore as E, isRealtimeAvailable as O, bindAwarenessIdentity as S, RealtimeBlobDocumentOptions as T, isRealtimeWorkspaceDocument as _, applyRealtimeSyncMessage as a, readRealtimeRequestState as b, encodeAwarenessState as c, realtimePersistenceDefaults as d, realtimeRoomKey as f, RealtimeWorkspaceDocumentAdapter as g, restoreRealtimeDocument as h, RealtimeSyncOptions as i, encodeSyncStep1 as l, resolveRealtimeDefinition as m, RealtimeHandlerOptions as n, assertRealtimeRoomStateQuota as o, refreshRealtimeDocument as p, RealtimeRefreshOptions as r, createRealtimeHandler as s, RealtimeHandler as t, encodeSyncUpdate as u, readRealtimeWorkspaceDocument as v, compactRealtimeAwareness as w, applyRealtimeAwarenessUpdate as x, workspaceDocument as y };
|