@vite-hub/realtime 0.3.1 → 0.5.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 (36) hide show
  1. package/README.md +20 -14
  2. package/dist/agent.d.ts +1 -1
  3. package/dist/agent.js +1 -1
  4. package/dist/{bus-Bi-Ec414.js → bus-Bsdanf5O.js} +9 -18
  5. package/dist/bus.js +1 -1
  6. package/dist/client/browser.js +1 -1
  7. package/dist/client.d.ts +2 -2
  8. package/dist/client.js +14 -7
  9. package/dist/{conflict-Bg8vCisd.js → conflict-DYC_qXzM.js} +7 -7
  10. package/dist/{document-DjBrcgpY.js → document-U5rzg2vG.js} +1 -1
  11. package/dist/{document-DPaywuCO.d.ts → document-b1ShR2S1.d.ts} +2 -2
  12. package/dist/durability.js +0 -4
  13. package/dist/{editor-BM5-vHqf.js → editor-IL2jHqn8.js} +0 -1
  14. package/dist/{error-diagnostics-B_66irmt.js → error-diagnostics-Cd-XWNf7.js} +21 -4
  15. package/dist/index.d.ts +4 -4
  16. package/dist/index.js +2 -2
  17. package/dist/internal/runtime/unavailable.d.ts +1 -1
  18. package/dist/internal/server.d.ts +7 -0
  19. package/dist/internal/server.js +6 -0
  20. package/dist/{keepalive-BCs-uXp4.js → keepalive-B4ONG6AD.js} +1 -1
  21. package/dist/{layout-fyQnhwCg.d.ts → layout-VHjYWa-M.d.ts} +1 -1
  22. package/dist/log-E-cH6xkd.js +159 -0
  23. package/dist/{object-CzKyK0hX.js → object-BgPPDLDE.js} +1 -1
  24. package/dist/{presence-Tuy1y_l9.js → presence-B6rvkHqd.js} +2 -2
  25. package/dist/{request-BUwa359H.d.ts → request-DAodIqZ8.d.ts} +1 -1
  26. package/dist/{request-CWaHqW3R.js → request-kM5epeSd.js} +2 -3
  27. package/dist/server-BSXJP45b.js +2606 -0
  28. package/dist/server-Covbc24E.d.ts +140 -0
  29. package/dist/server.d.ts +3 -141
  30. package/dist/server.js +3 -2581
  31. package/dist/{types-1DVVG5ro.d.ts → types-DdY7Vo1H.d.ts} +30 -41
  32. package/dist/vite.d.ts +3 -1
  33. package/dist/vite.js +67 -54
  34. package/dist/vue.d.ts +7 -9
  35. package/dist/vue.js +35 -38
  36. package/package.json +11 -6
@@ -1,7 +1,14 @@
1
- import { ViteHubContext } from "@vite-hub/runtime";
1
+ import { ResultError, ViteHubContext } from "@vite-hub/runtime";
2
2
  import { AnyExtension, JSONContent } from "@tiptap/core";
3
- import { WorkspaceSnapshot } from "@vite-hub/workspace";
3
+ import { WorkspaceAuthor, WorkspaceSnapshot } from "@vite-hub/workspace";
4
4
  import { H3Event } from "h3";
5
+ //#region src/error-diagnostics.d.ts
6
+ /** The `data` of a `REALTIME_REQUEST_FAILED` error. */
7
+ type RealtimeRequestFailure = {
8
+ /** HTTP status of the server answer, such as `409` when the stored document changed. `undefined` for a network error. */
9
+ status: number | undefined;
10
+ };
11
+ //#endregion
5
12
  //#region src/types.d.ts
6
13
  /** JSON value stored in one field of a structured Realtime document. */
7
14
  type RealtimeFieldValue = null | boolean | number | string | RealtimeFieldValue[] | {
@@ -63,6 +70,7 @@ interface RealtimeHistoryOptions {
63
70
  /** Digest of the save that the history entry must contain. */
64
71
  digest: string;
65
72
  message?: string;
73
+ /** The checkpoint requester, when identified. */
66
74
  user?: RealtimeUser;
67
75
  }
68
76
  /**
@@ -96,6 +104,8 @@ interface RealtimeHoldOptions {
96
104
  interface RealtimeWorkspaceDocumentOptions {
97
105
  /** Workspace whose working tree stores the Markdown file at the document path. */
98
106
  workspace: string;
107
+ /** Resolve an author's name and email approved for Git history. Return undefined to keep the Store's author. */
108
+ checkpointAuthor?: (user: RealtimeUser) => WorkspaceAuthor | undefined | Promise<WorkspaceAuthor | undefined>;
99
109
  }
100
110
  /**
101
111
  * Editor schema and Markdown codec shared by the server and the browser. The server never
@@ -165,52 +175,35 @@ interface RealtimePersistenceOptions {
165
175
  maxWait?: number;
166
176
  }
167
177
  interface RealtimeDefinitionIdentity {
168
- /** Resolve the user for a request, replacing the ViteHub Auth session. Return `null` for anonymous. */
169
178
  identify?: (context: RealtimeRequestContext) => RealtimeUser | null | undefined | Promise<RealtimeUser | null | undefined>;
170
- /**
171
- * Let a page on another origin connect, such as a script that sites load from the app. Return `true` to accept
172
- * `origin`. Without it, only the app's own origin connects. The browser sends cookies with a cross-site handshake
173
- * too, so `identify` and `authorize` must then trust only what the page sends on purpose, such as a ticket in
174
- * `params`, never the session cookie. `auth: true` without `identify` rejects it: the Auth session is a cookie.
175
- */
176
179
  origins?: (context: RealtimeOriginContext) => boolean | Promise<boolean>;
177
180
  }
178
181
  type RealtimeAuthorize = (context: RealtimeAuthorizeContext) => boolean | Promise<boolean>;
179
182
  /**
180
- * Who can use the rooms. Set one: `auth: true` requires an identified user, `authorize()` decides each request, and
181
- * `access: "public"` lets anyone read and write.
183
+ * Who can use the rooms. Set one: `authorize: true` requires an identified user, `authorize()` decides each request,
184
+ * and `access: "public"` lets anyone read and write.
182
185
  */
183
186
  type RealtimeDefinitionAccess = RealtimeDefinitionIdentity & ({
184
187
  access?: never;
185
- /** Require an identified user. Without `identify`, the identity is the ViteHub Auth session. */
186
- auth: true;
187
- /** Allow or deny one access mode. Only `true` allows. Write denial makes a connection read-only. */
188
- authorize?: RealtimeAuthorize;
189
- } | {
190
- access?: never;
191
- /** Require an identified user. Without `identify`, the identity is the ViteHub Auth session. */
192
- auth?: boolean;
193
- /** Allow or deny one access mode. Only `true` allows. Write denial makes a connection read-only. */
194
- authorize: RealtimeAuthorize;
188
+ /**
189
+ * `true` requires an identified user: `identify()`, or the ViteHub Auth session without it. A callback decides each
190
+ * request and access mode. It gets the identified user, or `null` when the caller is signed out. Only `true` allows.
191
+ * Write denial makes a connection read-only.
192
+ */
193
+ authorize: true | RealtimeAuthorize;
195
194
  } | {
196
195
  /** Let anyone who can reach the app read and write every room of this definition. */
197
196
  access: "public";
198
- auth?: never;
199
197
  authorize?: never;
200
198
  });
201
199
  interface RealtimeDocumentFields {
202
200
  document: RealtimeWorkspaceDocumentOptions | RealtimeDocumentAdapter;
203
- /**
204
- * Editor schema and Markdown codec. Defaults to the built-in Markdown kit. A function picks the codec of each
205
- * document, such as one per Content collection; browsers that open the document must use the same schema.
206
- */
207
201
  editor?: RealtimeEditor | ((context: RealtimeDocumentContext) => RealtimeEditor);
208
202
  history?: {
209
203
  checkpoint: true | {
210
204
  message?: string;
211
205
  };
212
206
  };
213
- /** Idle saves. `false` saves only when a client calls `save()` or `history.checkpoint()`. */
214
207
  persistence?: RealtimePersistenceOptions | false;
215
208
  }
216
209
  /** A definition whose rooms edit one stored document each. */
@@ -220,17 +213,7 @@ interface RealtimePresenceFields {
220
213
  editor?: never;
221
214
  history?: never;
222
215
  persistence?: never;
223
- /**
224
- * Lets server code ask the one browser in a room with `requestRealtimeRoom()` from `@vite-hub/realtime/server`. The
225
- * browser answers with `room.onRequest()`. Default `false`: rooms without it refuse request frames.
226
- */
227
216
  requests?: boolean;
228
- /**
229
- * `"user"`: each person gets their own rooms. A room is keyed by the identity of whoever joins it, so the same room id
230
- * for two people is two rooms, and `requestRealtimeRoom()` must name the person with `{ user }`. The identity is the
231
- * ViteHub Auth session when the app has Auth, read without requiring one; everyone without a session shares one
232
- * `anonymous` scope. With `identify` or `auth: true`, those decide the identity.
233
- */
234
217
  scope?: "user";
235
218
  }
236
219
  /**
@@ -297,12 +280,18 @@ type RealtimeResetReason = "source-changed" | "stale";
297
280
  type RealtimeRegistry = Record<string, () => Promise<{
298
281
  default: RealtimeDefinition;
299
282
  }>>;
283
+ /** The codes that `requestRealtimeRoom()` returns in `[error, undefined]`. */
284
+ type RealtimeRoomRequestErrorCode = "REALTIME_ROOM_ABORTED" | "REALTIME_ROOM_CROWDED" | "REALTIME_ROOM_ELSEWHERE" | "REALTIME_ROOM_EMPTY" | "REALTIME_ROOM_REFUSED" | "REALTIME_ROOM_REQUESTS_OFF" | "REALTIME_ROOM_TIMEOUT";
300
285
  /**
301
286
  * Codes that `save()`, `history.checkpoint()`, and `refresh()` of `useRealtimeTiptap()` return in the `[error, data]` tuple.
287
+ * When the server names why it refused the request, the code is that name, such as `REALTIME_SOURCE_CHANGED`. Other
288
+ * server and network errors are `REALTIME_REQUEST_FAILED`.
302
289
  */
303
- /** The codes that `requestRealtimeRoom()` returns in `[error, undefined]`. */
304
- type RealtimeRoomRequestErrorCode = "REALTIME_ROOM_ABORTED" | "REALTIME_ROOM_CROWDED" | "REALTIME_ROOM_ELSEWHERE" | "REALTIME_ROOM_EMPTY" | "REALTIME_ROOM_REFUSED" | "REALTIME_ROOM_REQUESTS_OFF" | "REALTIME_ROOM_TIMEOUT";
305
- type RealtimeRequestErrorCode = "REALTIME_DISABLED" | "REALTIME_DISCONNECTED" | "REALTIME_INVALID_RESPONSE" | "REALTIME_MISSING_DOCUMENT" | "REALTIME_REQUEST_FAILED";
290
+ type RealtimeRequestErrorCode = "REALTIME_DISABLED" | "REALTIME_DISCONNECTED" | "REALTIME_INVALID_DOCUMENT" | "REALTIME_INVALID_RESPONSE" | "REALTIME_MISSING_DOCUMENT" | "REALTIME_READ_ONLY" | "REALTIME_REQUEST_FAILED" | "REALTIME_SOURCE_CHANGED" | "REALTIME_SYNC_PENDING";
291
+ /** The error of `save()`, `history.checkpoint()`, and `refresh()`. Check `code` to read the typed `data`. */
292
+ type RealtimeRequestError = ResultError<Exclude<RealtimeRequestErrorCode, "REALTIME_REQUEST_FAILED">, undefined> | ResultError<"REALTIME_REQUEST_FAILED", RealtimeRequestFailure>;
293
+ /** The `[error, data]` tuple of `save()`, `history.checkpoint()`, and `refresh()`. */
294
+ type RealtimeRequestResult<TData> = [error: RealtimeRequestError, data: undefined] | [error: undefined, data: TData];
306
295
  /**
307
296
  * Whether this build has a Realtime room driver. ViteHub generates it for each build; an unavailable build says why
308
297
  * and how to enable Realtime.
@@ -316,4 +305,4 @@ type RealtimeAvailability = {
316
305
  fix: string;
317
306
  };
318
307
  //#endregion
319
- export { RealtimeSaveOptions as A, RealtimeReadOnlyReason as C, RealtimeRequestEvent as D, RealtimeRequestErrorCode as E, RealtimeWorkspaceChange as F, RealtimeWorkspaceDocumentOptions as I, RealtimeSaved as M, RealtimeUser as N, RealtimeResetReason as O, RealtimeVerifyResult as P, RealtimePresenceDefinition as S, RealtimeRequestContext as T, RealtimeLoadedDocument as _, RealtimeDefinition as a, RealtimePersistenceOptions as b, RealtimeDocumentContext as c, RealtimeDocumentStatus as d, RealtimeEditor as f, RealtimeIssue as g, RealtimeHoldOptions as h, RealtimeCheckpoint as i, RealtimeSaveResult as j, RealtimeRoomRequestErrorCode as k, RealtimeDocumentDefinition as l, RealtimeHistoryOptions as m, RealtimeAuthorizeContext as n, RealtimeDefinitionAccess as o, RealtimeFieldValue as p, RealtimeAvailability as r, RealtimeDocumentAdapter as s, DiscoveredRealtimeDefinition as t, RealtimeDocumentSnapshot as u, RealtimeOptions as v, RealtimeRegistry as w, RealtimePerson as x, RealtimeOriginContext as y };
308
+ export { RealtimeResetReason as A, RealtimeReadOnlyReason as C, RealtimeRequestErrorCode as D, RealtimeRequestError as E, RealtimeUser as F, RealtimeVerifyResult as I, RealtimeWorkspaceChange as L, RealtimeSaveOptions as M, RealtimeSaveResult as N, RealtimeRequestEvent as O, RealtimeSaved as P, RealtimeWorkspaceDocumentOptions as R, RealtimePresenceDefinition as S, RealtimeRequestContext as T, RealtimeLoadedDocument as _, RealtimeDefinition as a, RealtimePersistenceOptions as b, RealtimeDocumentContext as c, RealtimeDocumentStatus as d, RealtimeEditor as f, RealtimeIssue as g, RealtimeHoldOptions as h, RealtimeCheckpoint as i, RealtimeRoomRequestErrorCode as j, RealtimeRequestResult as k, RealtimeDocumentDefinition as l, RealtimeHistoryOptions as m, RealtimeAuthorizeContext as n, RealtimeDefinitionAccess as o, RealtimeFieldValue as p, RealtimeAvailability as r, RealtimeDocumentAdapter as s, DiscoveredRealtimeDefinition as t, RealtimeDocumentSnapshot as u, RealtimeOptions as v, RealtimeRegistry as w, RealtimePerson as x, RealtimeOriginContext as y, RealtimeRequestFailure as z };
package/dist/vite.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as DiscoveredRealtimeDefinition, v as RealtimeOptions } from "./types-1DVVG5ro.js";
1
+ import { t as DiscoveredRealtimeDefinition, v as RealtimeOptions } from "./types-DdY7Vo1H.js";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/discovery.d.ts
4
4
  export declare function discoverRealtimeDefinitions(rootDir: string, serverDirs?: string[]): DiscoveredRealtimeDefinition[];
@@ -57,6 +57,8 @@ interface ViteHubResourceSummary {
57
57
  owner: string;
58
58
  /** Absent when no id is known yet. */
59
59
  source?: ViteHubResourceIdSource;
60
+ /** The resource is in the Wrangler config of a standalone Provider Output Worker, not in Nitro's. */
61
+ standalone?: boolean;
60
62
  }
61
63
  interface ViteHubInspectionContributor {
62
64
  definitions?: readonly ViteHubDefinitionInspector[];
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
- import { t as realtimeErrorDiagnostics } from "./error-diagnostics-B_66irmt.js";
2
- import { o as realtimeNamespaceVariable, s as realtimePostgresUrlVariable } from "./bus-Bi-Ec414.js";
3
- import { g as realtimeKeepalivePong, h as realtimeKeepalivePing, r as isRecordOrFunction, t as cloneRecord } from "./object-CzKyK0hX.js";
1
+ import { t as realtimeErrorDiagnostics } from "./error-diagnostics-Cd-XWNf7.js";
2
+ import { o as realtimeNamespaceVariable, s as realtimePostgresUrlVariable } from "./bus-Bsdanf5O.js";
3
+ import { g as realtimeKeepalivePong, h as realtimeKeepalivePing, r as isRecordOrFunction, t as cloneRecord } from "./object-BgPPDLDE.js";
4
4
  import availability from "./internal/runtime/unavailable.js";
5
5
  import { defineDiagnostics } from "nostics";
6
6
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
@@ -126,7 +126,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
126
126
  why: ({ message }) => message === void 0 ? "" : String(message)
127
127
  },
128
128
  INTERNAL_R0022: {
129
- fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields.",
129
+ fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields, and the list_operations tool of the ViteHub MCP gives the input schema of each operation.",
130
130
  why: ({ message }) => message === void 0 ? "" : String(message)
131
131
  },
132
132
  INTERNAL_R0024: {
@@ -271,7 +271,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
271
271
  },
272
272
  INTERNAL_R0004: {
273
273
  ...dynamicError,
274
- fix: "Set a larger `maxResponseBytes` on the HTTP request, such as the `fetch()` Source options, or ask the server for a smaller response."
274
+ fix: "Set a larger `maxResponseBytes` on the HTTP request, such as the `url()` Source options, or ask the server for a smaller response."
275
275
  },
276
276
  INTERNAL_R0005: {
277
277
  ...dynamicError,
@@ -317,6 +317,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
317
317
  why: ({ variable }) => `[vitehub] ${variable} must be the 43-character private key that \`vitehub secret console-key\` prints, and its name 1 to 64 of A-Z, 0-9, and _.`,
318
318
  fix: "Set the variable that the message names to the private key that `vitehub secret console-key` prints, and name it `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` with A-Z, 0-9, and _ in `<NAME>`."
319
319
  },
320
+ INTERNAL_DEV_SERVER_NOT_FOUND: {
321
+ why: ({ command }) => `[vitehub] No dev server of this project is running, and --url is not set, so \`vitehub ${command}\` has no app to call.`,
322
+ fix: "Start the dev server of this project, such as with `pnpm dev`, or pass --url with the app URL, such as --url http://localhost:3000."
323
+ },
320
324
  INTERNAL_FORGE_NOT_INSTALLED: {
321
325
  why: ({ feature }) => `${feature} needs @vite-hub/forge, and the app did not install it.`,
322
326
  fix: "Install Forge in your app with `pnpm add @vite-hub/forge`, then build again."
@@ -341,6 +345,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
341
345
  why: ({ owner }) => `[vitehub] ${owner} extends tuple requires [preset, options] with an options object.`,
342
346
  fix: "Set `extends` to a preset, or to a two-item tuple `[preset, { ...options }]` whose second item is a plain object."
343
347
  },
348
+ INTERNAL_RUNTIME_PACKAGE_VERSION_CONFLICT: {
349
+ why: ({ first, name, second }) => `[vitehub] One server function needs ${name} from two installations: ${first} and ${second}.`,
350
+ fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`, then build again."
351
+ },
344
352
  INTERNAL_SECRET_PURPOSE_MISSING: {
345
353
  why: "[vitehub] A derived secret requires a purpose.",
346
354
  fix: "Pass a non-empty purpose to `deriveSecret()`, such as `deriveSecret(\"my-module:session\")`."
@@ -503,6 +511,14 @@ function durabilityModuleFile(importMetaUrl) {
503
511
  return fileURLToPath(new URL(importMetaUrl.endsWith(".ts") ? "./durability.ts" : "./durability.js", importMetaUrl));
504
512
  }
505
513
  //#endregion
514
+ //#region ../internal/src/inspect.ts
515
+ function relativeDefinitionFile(projectRoot, file) {
516
+ return relative$1(projectRoot, file).replaceAll("\\", "/");
517
+ }
518
+ const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
519
+ new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
520
+ new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
521
+ //#endregion
506
522
  //#region ../internal/src/build/vite.ts
507
523
  const projectRootDirectoryMarkers = [
508
524
  ["server", "agents"],
@@ -556,7 +572,7 @@ function hasProjectRootDirectoryMarker(root) {
556
572
  for (const marker of projectRootDirectoryMarkers) try {
557
573
  if (statSync(resolve(root, ...marker)).isDirectory()) return true;
558
574
  } catch (error) {
559
- if (error.code !== "ENOENT") throw error;
575
+ if (!isMissingProjectMarker(error)) throw error;
560
576
  }
561
577
  return false;
562
578
  }
@@ -570,11 +586,15 @@ function hasProjectRootFileMarker(root, markers) {
570
586
  try {
571
587
  if (statSync(resolve(root, ...path)).isFile()) return true;
572
588
  } catch (error) {
573
- if (error.code !== "ENOENT") throw error;
589
+ if (!isMissingProjectMarker(error)) throw error;
574
590
  }
575
591
  }
576
592
  return false;
577
593
  }
594
+ function isMissingProjectMarker(error) {
595
+ const code = error.code;
596
+ return code === "ENOENT" || code === "ENOTDIR";
597
+ }
578
598
  /**
579
599
  * The path of an app base, without the trailing slash: `/portal/` and `https://cdn.example/portal/` give `/portal`.
580
600
  * The root and relative bases (`""`, `"./"`) give `""`. The Console mounts its routes with the same rule.
@@ -590,35 +610,15 @@ function viteHubBasePath(base) {
590
610
  if (!pathname.startsWith("/") || pathname.startsWith("//")) return "";
591
611
  return pathname.replace(/\/+$/, "");
592
612
  }
593
- //#endregion
594
- //#region ../internal/src/build/page-tools.ts
595
- function readString(value, key) {
596
- const field = value !== null && typeof value === "object" ? Reflect.get(value, key) : void 0;
597
- return typeof field === "string" ? field : void 0;
598
- }
613
+ Object.freeze({ vitehubAuthAccess: "handler" });
599
614
  /**
600
- * The app base of a Vite configuration. ViteHub's application-base config field or `__VITEHUB_APP_BASE_URL__` constant
601
- * takes precedence over the Vite `base`; the Nuxt module sets both from `app.baseURL`. Only a root-relative Vite `base`
602
- * supplies an application path; absolute and protocol-relative URLs are asset CDN bases. The Nitro base is
603
- * `nitro.baseURL`, else `NITRO_APP_BASE_URL`.
615
+ * The route meta of a generated handler that checks access on every request, even when the app adds no rule: a required
616
+ * `authorize` policy, an explicit `access` rule, a required access token, or a signature. Auth access routes still apply
617
+ * to it, so an app rule stays in force. `checksOwnAccess(event)` of `vite-hub/auth` reads it, so app middleware can skip
618
+ * the route. A route that can run without a check, such as a browser error sink, an optional `authorize`, or a webhook
619
+ * with `secret: false`, must not use it.
604
620
  */
605
- function viteHubPageToolsBase(config, env = process.env) {
606
- const defined = readString(config !== null && typeof config === "object" ? Reflect.get(config, "define") : void 0, "__VITEHUB_APP_BASE_URL__");
607
- const viteBase = readString(config, "base");
608
- let appBase = viteBase?.startsWith("/") && !viteBase.startsWith("//") ? viteBase : void 0;
609
- if (defined) try {
610
- const value = JSON.parse(defined);
611
- if (typeof value === "string") appBase = value;
612
- } catch {}
613
- const base = viteHubBasePath(readString(config, "__vitehubAppBaseURL") ?? appBase);
614
- const nitroBase = viteHubBasePath(readString(config !== null && typeof config === "object" ? Reflect.get(config, "nitro") : void 0, "baseURL") ?? env.NITRO_APP_BASE_URL);
615
- return {
616
- base,
617
- mount: nitroBase && (base === nitroBase || base.startsWith(`${nitroBase}/`)) ? base.slice(nitroBase.length) : base
618
- };
619
- }
620
- //#endregion
621
- //#region ../internal/src/nitro-kit.ts
621
+ const ownAccessRouteMeta = Object.freeze({ vitehubOwnAccess: true });
622
622
  function cloneArray(value) {
623
623
  return Array.isArray(value) ? [...value] : [];
624
624
  }
@@ -646,6 +646,33 @@ function createNitroServerKit(value = {}) {
646
646
  }
647
647
  };
648
648
  }
649
+ //#endregion
650
+ //#region ../internal/src/build/page-tools.ts
651
+ function readString(value, key) {
652
+ const field = value !== null && typeof value === "object" ? Reflect.get(value, key) : void 0;
653
+ return typeof field === "string" ? field : void 0;
654
+ }
655
+ /**
656
+ * The app base of a Vite configuration. ViteHub's application-base config field or `__VITEHUB_APP_BASE_URL__` constant
657
+ * takes precedence over the Vite `base`; the Nuxt module sets both from `app.baseURL`. Only a root-relative Vite `base`
658
+ * supplies an application path; absolute and protocol-relative URLs are asset CDN bases. The Nitro base is
659
+ * `nitro.baseURL`, else `NITRO_APP_BASE_URL`.
660
+ */
661
+ function viteHubPageToolsBase(config, env = process.env) {
662
+ const defined = readString(config !== null && typeof config === "object" ? Reflect.get(config, "define") : void 0, "__VITEHUB_APP_BASE_URL__");
663
+ const viteBase = readString(config, "base");
664
+ let appBase = viteBase?.startsWith("/") && !viteBase.startsWith("//") ? viteBase : void 0;
665
+ if (defined) try {
666
+ const value = JSON.parse(defined);
667
+ if (typeof value === "string") appBase = value;
668
+ } catch {}
669
+ const base = viteHubBasePath(readString(config, "__vitehubAppBaseURL") ?? appBase);
670
+ const nitroBase = viteHubBasePath(readString(config !== null && typeof config === "object" ? Reflect.get(config, "nitro") : void 0, "baseURL") ?? env.NITRO_APP_BASE_URL);
671
+ return {
672
+ base,
673
+ mount: nitroBase && (base === nitroBase || base.startsWith(`${nitroBase}/`)) ? base.slice(nitroBase.length) : base
674
+ };
675
+ }
649
676
  /** Maps a host name or a Nitro preset name, such as `cloudflare-module` or `node-server`, to its ViteHub host. */
650
677
  function hostFromNitroPreset(value) {
651
678
  const normalized = value?.trim().toLowerCase().replaceAll("_", "-");
@@ -724,14 +751,6 @@ function discoverRealtimeDefinitions(rootDir, serverDirs) {
724
751
  })]);
725
752
  }
726
753
  //#endregion
727
- //#region ../internal/src/inspect.ts
728
- function relativeDefinitionFile(projectRoot, file) {
729
- return relative$1(projectRoot, file).replaceAll("\\", "/");
730
- }
731
- const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
732
- new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
733
- new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
734
- //#endregion
735
754
  //#region src/inspect.ts
736
755
  const driverLabels = {
737
756
  auto: "auto: Cloudflare Durable Objects on Cloudflare, memory in development, shared rooms on a Node server, build error elsewhere",
@@ -801,7 +820,6 @@ function describePersistence(node) {
801
820
  } else if (node) return "dynamic";
802
821
  return `idle save after ${debounce} ms (at most ${maxWait} ms) and when the last client leaves`;
803
822
  }
804
- /** Reads the static shape of one Realtime Definition file without executing it. */
805
823
  function describeRealtimeDefinitionSource(parse, file, source) {
806
824
  let object;
807
825
  let builder;
@@ -817,13 +835,14 @@ function describeRealtimeDefinitionSource(parse, file, source) {
817
835
  }];
818
836
  const values = properties(object);
819
837
  const editor = values.get("editor");
820
- const auth = literal(values.get("auth")) === true;
838
+ const signedIn = literal(values.get("authorize")) === true;
839
+ const callback = values.has("authorize") && !signedIn;
821
840
  const publicAccess = literal(values.get("access")) === "public";
822
- const authorization = (rule) => values.has("authorize") ? rule : publicAccess ? "public: anyone may read and write" : auth ? "every identified user" : "missing: the server rejects this definition";
841
+ const authorization = (rule) => callback ? rule : publicAccess ? "public: anyone may read and write" : signedIn ? "every identified user" : "missing: the server rejects this definition";
823
842
  const perDocument = editor?.type === "ArrowFunctionExpression" || editor?.type === "FunctionExpression";
824
843
  const identity = {
825
844
  label: "Identity",
826
- value: values.has("identify") ? `identify()${auth ? ", required" : ""}` : auth ? "ViteHub Auth session, required" : "anonymous; presence names are client-asserted"
845
+ value: values.has("identify") ? `identify()${signedIn ? ", required" : ""}` : signedIn ? "ViteHub Auth session, required" : callback ? "ViteHub Auth session when signed in" : "anonymous; presence names are client-asserted"
827
846
  };
828
847
  if (literal(values.get("document")) === false) return [
829
848
  {
@@ -906,7 +925,6 @@ function configureCloudflareRealtime(nitro) {
906
925
  cloudflare.wrangler = wrangler;
907
926
  nitro.cloudflare = cloudflare;
908
927
  }
909
- /** Packages that share the Yjs runtime on the server. They must load as one module graph. */
910
928
  const realtimeServerYjsPackages = [
911
929
  "yjs",
912
930
  "y-protocols",
@@ -929,14 +947,9 @@ function findDatabasePlugin(plugins) {
929
947
  if (found) return found;
930
948
  } else if (plugin && typeof plugin === "object" && "name" in plugin && plugin.name === databaseVitePluginName) return plugin;
931
949
  }
932
- /** Whether the Database integration resolved the Default Database on Postgres. The Postgres bus then uses its client. */
933
950
  function hasPostgresDefaultDatabase(plugin) {
934
951
  return plugin?.api?.getConfig?.()?.databases.default?.dialect === "postgresql";
935
952
  }
936
- /**
937
- * The handler and the Nitro plugin of a Node build. `database` is the module that exports the app's `databases`, when
938
- * the Default Database is on Postgres: the bus then borrows the postgres.js client of that Database.
939
- */
940
953
  function renderNodeFiles(input) {
941
954
  const { busPlugin, database, handlerFile, importBase, namespace, nodeDriver, registryFile } = input;
942
955
  const busOptions = `, { ${database ? `databases: () => import(${JSON.stringify(database)}).then(module => module.databases), ` : ""}namespace: ${JSON.stringify(namespace)} }`;
@@ -965,7 +978,6 @@ function renderNodeFiles(input) {
965
978
  ""
966
979
  ].join("\n")]];
967
980
  }
968
- /** The app name: the `name` in the root `package.json`, else the root folder name. */
969
981
  function defaultNamespace(root) {
970
982
  try {
971
983
  const name = JSON.parse(readFileSync(resolve(root, "package.json"), "utf8")).name;
@@ -1122,7 +1134,8 @@ function hubRealtime(options = {}) {
1122
1134
  kit.addHandler({
1123
1135
  handler: handlerFile,
1124
1136
  lazy: true,
1125
- route: `${mount}/api/_vitehub/realtime/**`
1137
+ meta: { ...ownAccessRouteMeta },
1138
+ route: `${mount}/_vitehub/realtime/**`
1126
1139
  });
1127
1140
  if (durablePlugin) kit.addPlugin(durablePlugin);
1128
1141
  if (busPlugin) kit.addPlugin(busPlugin);
package/dist/vue.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { C as RealtimeReadOnlyReason, E as RealtimeRequestErrorCode, F as RealtimeWorkspaceChange, M as RealtimeSaved, N as RealtimeUser, O as RealtimeResetReason, d as RealtimeDocumentStatus, f as RealtimeEditor, i as RealtimeCheckpoint, x as RealtimePerson } from "./types-1DVVG5ro.js";
2
- import { i as readRealtimeYDoc } from "./document-DPaywuCO.js";
3
- import { Result } from "@vite-hub/runtime";
1
+ import { A as RealtimeResetReason, C as RealtimeReadOnlyReason, D as RealtimeRequestErrorCode, E as RealtimeRequestError, F as RealtimeUser, L as RealtimeWorkspaceChange, P as RealtimeSaved, d as RealtimeDocumentStatus, f as RealtimeEditor, i as RealtimeCheckpoint, k as RealtimeRequestResult, x as RealtimePerson, z as RealtimeRequestFailure } from "./types-DdY7Vo1H.js";
2
+ import { i as readRealtimeYDoc } from "./document-b1ShR2S1.js";
4
3
  import { Awareness } from "y-protocols/awareness";
5
4
  import { WebsocketProvider } from "y-websocket";
6
5
  import * as Y from "yjs";
@@ -61,21 +60,20 @@ export declare function useRealtimeTiptap(definition: string, documentId: MaybeR
61
60
  fields: import("vue").ComputedRef<Y.Map<unknown> | undefined>;
62
61
  people: import("vue").ShallowRef<RealtimePerson[], RealtimePerson[]>;
63
62
  provider: import("vue").ShallowRef<WebsocketProvider | undefined, WebsocketProvider | undefined>;
64
- /** The server rejects edits from this connection. `readOnlyReason` tells why; `saveStatus` holds the details. */
65
63
  readOnly: import("vue").ComputedRef<boolean>;
66
64
  readOnlyReason: Ref<RealtimeReadOnlyReason | null, RealtimeReadOnlyReason | null>;
67
- refresh: () => Promise<Result<{
65
+ refresh: () => Promise<RealtimeRequestResult<{
68
66
  digest: string | null;
69
67
  reseeded: boolean;
70
- }, RealtimeRequestErrorCode>>;
68
+ }>>;
71
69
  onReset: (listener: (event: RealtimeResetEvent) => void) => () => void;
72
- save: () => Promise<Result<RealtimeSaved, RealtimeRequestErrorCode>>;
70
+ save: () => Promise<RealtimeRequestResult<RealtimeSaved>>;
73
71
  saveStatus: import("vue").ShallowRef<RealtimeDocumentStatus | undefined, RealtimeDocumentStatus | undefined>;
74
72
  saving: import("vue").ComputedRef<boolean>;
75
73
  status: Ref<RealtimeStatus, RealtimeStatus>;
76
74
  synced: Ref<boolean, boolean>;
77
75
  history: {
78
- checkpoint: () => Promise<Result<RealtimeCheckpoint, RealtimeRequestErrorCode>>;
76
+ checkpoint: () => Promise<RealtimeRequestResult<RealtimeCheckpoint>>;
79
77
  pending: import("vue").ComputedRef<boolean>;
80
78
  };
81
79
  workspace: {
@@ -85,4 +83,4 @@ export declare function useRealtimeTiptap(definition: string, documentId: MaybeR
85
83
  destroy: () => void;
86
84
  };
87
85
  //#endregion
88
- export { type RealtimeCaretOptions, type RealtimeCaretUser, type RealtimeRequestErrorCode, readRealtimeYDoc };
86
+ export { type RealtimeCaretOptions, type RealtimeCaretUser, type RealtimeRequestError, type RealtimeRequestErrorCode, type RealtimeRequestFailure, type RealtimeRequestResult, readRealtimeYDoc };
package/dist/vue.js CHANGED
@@ -1,10 +1,10 @@
1
- import { t as realtimeErrorDiagnostics } from "./error-diagnostics-B_66irmt.js";
2
- import { n as resolveRealtimeApplicationPath, t as keepRealtimeSocketAlive } from "./keepalive-BCs-uXp4.js";
3
- import { i as decodeRealtimeControlPayload, l as encodeWorkspaceChange, n as isRecord, o as decodeWorkspaceChangePayload, u as isRetryableRealtimeRequestCode, x as workspaceRoomId } from "./object-CzKyK0hX.js";
1
+ import { t as realtimeErrorDiagnostics } from "./error-diagnostics-Cd-XWNf7.js";
2
+ import { n as resolveRealtimeApplicationPath, t as keepRealtimeSocketAlive } from "./keepalive-B4ONG6AD.js";
3
+ import { _ as realtimeReadOnlyCode, b as realtimeSyncPendingCode, i as decodeRealtimeControlPayload, l as encodeWorkspaceChange, m as realtimeInvalidDocumentCode, n as isRecord, o as decodeWorkspaceChangePayload, u as isRetryableRealtimeRequestCode, x as workspaceRoomId, y as realtimeSourceChangedCode } from "./object-BgPPDLDE.js";
4
4
  import { n as realtimeDocumentLayout, t as readRealtimeStatus } from "./layout-DNaxppTZ.js";
5
- import { n as getRealtimePeople, t as createRealtimeIdentity } from "./presence-Tuy1y_l9.js";
6
- import { t as createRealtimeEditorExtensions } from "./editor-BM5-vHqf.js";
7
- import { _ as yCursorPlugin, b as yUndoPlugin, f as absolutePositionToRelativePosition, g as undo, h as relativePositionToAbsolutePosition, m as redo, o as readRealtimeYDoc, p as defaultSelectionBuilder, v as ySyncPlugin, x as yUndoPluginKey, y as ySyncPluginKey } from "./document-DjBrcgpY.js";
5
+ import { n as getRealtimePeople, t as createRealtimeIdentity } from "./presence-B6rvkHqd.js";
6
+ import { t as createRealtimeEditorExtensions } from "./editor-IL2jHqn8.js";
7
+ import { _ as yCursorPlugin, b as yUndoPlugin, f as absolutePositionToRelativePosition, g as undo, h as relativePositionToAbsolutePosition, m as redo, o as readRealtimeYDoc, p as defaultSelectionBuilder, v as ySyncPlugin, x as yUndoPluginKey, y as ySyncPluginKey } from "./document-U5rzg2vG.js";
8
8
  import "lib0/decoding";
9
9
  import * as encoding from "lib0/encoding";
10
10
  import * as awarenessProtocol from "y-protocols/awareness";
@@ -239,6 +239,14 @@ const RealtimeCaret = Extension.create({
239
239
  });
240
240
  //#endregion
241
241
  //#region src/vue.ts
242
+ function serverRequestError(code, action) {
243
+ switch (code) {
244
+ case realtimeInvalidDocumentCode: return realtimeErrorDiagnostics.REALTIME_INVALID_DOCUMENT({ action });
245
+ case realtimeReadOnlyCode: return realtimeErrorDiagnostics.REALTIME_READ_ONLY({ action });
246
+ case realtimeSourceChangedCode: return realtimeErrorDiagnostics.REALTIME_SOURCE_CHANGED({ action });
247
+ case realtimeSyncPendingCode: return realtimeErrorDiagnostics.REALTIME_SYNC_PENDING({ action });
248
+ }
249
+ }
242
250
  const workspaceChangeFlushIntervalMs = 11;
243
251
  function isString(value) {
244
252
  return typeof value === "string";
@@ -304,17 +312,16 @@ function useRealtimeTiptap(definition, documentId, options = {}) {
304
312
  let workspaceChangeTimer;
305
313
  const enabled = () => options.enabled === void 0 || toValue(options.enabled);
306
314
  let canConnect = !getCurrentInstance();
307
- function destroyDocument(keepDocument = false, preserveRefresh = false) {
308
- for (const controller of requestControllers) if (!preserveRefresh || !refreshControllers.has(controller)) controller.abort();
309
- if (preserveRefresh) {
310
- for (const controller of requestControllers) if (!refreshControllers.has(controller)) requestControllers.delete(controller);
311
- } else {
312
- requestControllers.clear();
313
- refreshControllers.clear();
315
+ function destroyDocument(resetReason) {
316
+ for (const controller of requestControllers) {
317
+ if (resetReason === "source-changed" || resetReason && refreshControllers.has(controller)) continue;
318
+ controller.abort();
319
+ requestControllers.delete(controller);
320
+ refreshControllers.delete(controller);
314
321
  }
315
322
  connectedDocumentId = void 0;
316
323
  provider.value?.destroy();
317
- if (!keepDocument) document.value?.destroy();
324
+ if (!resetReason) document.value?.destroy();
318
325
  provider.value = void 0;
319
326
  document.value = void 0;
320
327
  people.value = [];
@@ -363,7 +370,7 @@ function useRealtimeTiptap(definition, documentId, options = {}) {
363
370
  pendingWorkspaceChanges.length = 0;
364
371
  }
365
372
  function serverURL() {
366
- return `${window.location.protocol === "https:" ? "wss:" : "ws:"}//${window.location.host}${resolveRealtimeApplicationPath(`/api/_vitehub/realtime/${encodeURIComponent(definition)}`)}`;
373
+ return `${window.location.protocol === "https:" ? "wss:" : "ws:"}//${window.location.host}${resolveRealtimeApplicationPath(`/_vitehub/realtime/${encodeURIComponent(definition)}`)}`;
367
374
  }
368
375
  if (typeof window !== "undefined") {
369
376
  const workspaceDocument = markRaw(new Y.Doc());
@@ -444,7 +451,7 @@ function useRealtimeTiptap(definition, documentId, options = {}) {
444
451
  }
445
452
  function reset(id, reason, epoch) {
446
453
  const previous = document.value;
447
- destroyDocument(true, true);
454
+ destroyDocument(reason);
448
455
  if (previous) try {
449
456
  for (const listener of resetListeners) listener({
450
457
  epoch,
@@ -471,18 +478,19 @@ function useRealtimeTiptap(definition, documentId, options = {}) {
471
478
  const room = id.split("/").map(encodeURIComponent).join("/");
472
479
  const current = document.value;
473
480
  const query = action === "checkpoint" ? "history=checkpoint" : `document=${action}`;
474
- const stillCurrent = () => !controller.signal.aborted && !!current && connectedDocumentId === id && document.value === current && toValue(documentId) === id && enabled();
481
+ const stillInScope = () => !controller.signal.aborted && toValue(documentId) === id && enabled();
482
+ const stillCurrent = () => !!current && connectedDocumentId === id && document.value === current;
475
483
  for (let attempt = 0;; attempt++) {
476
- if (action !== "refresh" && !stillCurrent()) return disconnected();
484
+ if (!stillInScope() || action !== "refresh" && !stillCurrent()) return disconnected();
477
485
  let response;
478
486
  try {
479
- response = await fetch(resolveRealtimeApplicationPath(`/api/_vitehub/realtime/${encodeURIComponent(definition)}/${room}?${query}`), {
487
+ response = await fetch(resolveRealtimeApplicationPath(`/_vitehub/realtime/${encodeURIComponent(definition)}/${room}?${query}`), {
480
488
  body: action === "refresh" ? void 0 : Uint8Array.from(Y.encodeStateAsUpdate(current)).buffer,
481
489
  method: "POST",
482
490
  signal: controller.signal
483
491
  });
484
492
  } catch (cause) {
485
- if (controller.signal.aborted) return disconnected();
493
+ if (!stillInScope() || action !== "refresh" && !stillCurrent()) return disconnected();
486
494
  return [realtimeErrorDiagnostics.REALTIME_REQUEST_FAILED({
487
495
  action,
488
496
  cause
@@ -492,18 +500,20 @@ function useRealtimeTiptap(definition, documentId, options = {}) {
492
500
  try {
493
501
  data = await response.json();
494
502
  } catch {
495
- if (controller.signal.aborted) return disconnected();
503
+ data = void 0;
496
504
  }
497
- if (action !== "refresh" && !stillCurrent()) return disconnected();
498
- if (response.ok) return [void 0, data];
505
+ if (!stillInScope()) return disconnected();
499
506
  const errorData = isRecord(data) ? data : void 0;
500
507
  const nestedData = isRecord(errorData?.data) ? errorData.data : void 0;
508
+ const serverCode = isString(nestedData?.code) ? nestedData.code : void 0;
509
+ if (action !== "refresh" && !stillCurrent() && (response.ok || serverCode !== "REALTIME_SOURCE_CHANGED")) return disconnected();
510
+ if (response.ok) return [void 0, data];
501
511
  const message = isString(errorData?.statusMessage) && errorData.statusMessage ? errorData.statusMessage : isString(errorData?.message) ? errorData.message : void 0;
502
- if (response.status === 409 && isRetryableRealtimeRequestCode(isString(nestedData?.code) ? nestedData.code : void 0) && attempt < 20) {
512
+ if (response.status === 409 && isRetryableRealtimeRequestCode(serverCode) && attempt < 20) {
503
513
  await new Promise((resolve) => setTimeout(resolve, 50));
504
514
  continue;
505
515
  }
506
- return [realtimeErrorDiagnostics.REALTIME_REQUEST_FAILED({
516
+ return [serverRequestError(serverCode, action) ?? realtimeErrorDiagnostics.REALTIME_REQUEST_FAILED({
507
517
  action,
508
518
  message,
509
519
  status: response.status
@@ -520,10 +530,6 @@ function useRealtimeTiptap(definition, documentId, options = {}) {
520
530
  if (error) return [error, void 0];
521
531
  return accepts(data) ? [void 0, data] : [realtimeErrorDiagnostics.REALTIME_INVALID_RESPONSE({ action }), void 0];
522
532
  }
523
- /**
524
- * Saves the room through its document adapter now, including every edit this client has sent.
525
- * Returns `[error, saved]`; `error.code` is a `RealtimeRequestErrorCode`.
526
- */
527
533
  async function save() {
528
534
  if (!enabled()) return [realtimeErrorDiagnostics.REALTIME_DISABLED({ action: "save" }), void 0];
529
535
  saveRequests.value++;
@@ -533,10 +539,6 @@ function useRealtimeTiptap(definition, documentId, options = {}) {
533
539
  saveRequests.value--;
534
540
  }
535
541
  }
536
- /**
537
- * Saves the room and records a durable history entry through the document adapter.
538
- * Returns `[error, checkpoint]`; `error.code` is a `RealtimeRequestErrorCode`.
539
- */
540
542
  async function checkpoint() {
541
543
  if (!enabled()) return [realtimeErrorDiagnostics.REALTIME_DISABLED({ action: "checkpoint" }), void 0];
542
544
  checkpointRequests.value++;
@@ -546,10 +548,6 @@ function useRealtimeTiptap(definition, documentId, options = {}) {
546
548
  checkpointRequests.value--;
547
549
  }
548
550
  }
549
- /**
550
- * Asks the room to compare its seed with the stored document. A changed source resets every client.
551
- * Returns `[error, result]`; `error.code` is a `RealtimeRequestErrorCode`.
552
- */
553
551
  async function refresh() {
554
552
  return await requestResult("refresh", isRefreshResult);
555
553
  }
@@ -591,7 +589,6 @@ function useRealtimeTiptap(definition, documentId, options = {}) {
591
589
  fields: computed(() => document.value?.getMap(realtimeDocumentLayout.fields)),
592
590
  people,
593
591
  provider,
594
- /** The server rejects edits from this connection. `readOnlyReason` tells why; `saveStatus` holds the details. */
595
592
  readOnly: computed(() => readOnlyReason.value !== null),
596
593
  readOnlyReason,
597
594
  refresh,