@vite-hub/realtime 0.5.0 → 0.6.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 (43) hide show
  1. package/README.md +2 -2
  2. package/dist/agent.d.ts +1 -1
  3. package/dist/agent.js +1 -2
  4. package/dist/{bus-Bsdanf5O.js → bus-DJ3dOQAZ.js} +4 -6
  5. package/dist/{bus-protocol-wXkXW28q.d.ts → bus-protocol-juNrVJDF.d.ts} +0 -2
  6. package/dist/bus.d.ts +1 -3
  7. package/dist/bus.js +1 -2
  8. package/dist/client/browser.js +3 -3
  9. package/dist/client.d.ts +2 -4
  10. package/dist/client.js +5 -6
  11. package/dist/{conflict-DYC_qXzM.js → conflict-BqdKFrkE.js} +3 -5
  12. package/dist/{conflict-CmZizTYl.d.ts → conflict-C5KRv-J1.d.ts} +0 -2
  13. package/dist/{document-b1ShR2S1.d.ts → document-CbqgNO_0.d.ts} +2 -4
  14. package/dist/document-CfrQbB03.js +1736 -0
  15. package/dist/durability.d.ts +1 -3
  16. package/dist/durability.js +1 -2
  17. package/dist/{editor-IL2jHqn8.js → editor-DzhKM4Gt.js} +2 -4
  18. package/dist/{error-diagnostics-Cd-XWNf7.js → error-diagnostics-we8V1O-X.js} +1 -2
  19. package/dist/index.d.ts +3 -7
  20. package/dist/index.js +3 -3
  21. package/dist/internal/runtime/unavailable.d.ts +1 -3
  22. package/dist/internal/runtime/unavailable.js +1 -2
  23. package/dist/internal/server.d.ts +6 -6
  24. package/dist/internal/server.js +5 -5
  25. package/dist/{keepalive-B4ONG6AD.js → keepalive-BYkk6Ax8.js} +3 -5
  26. package/dist/{layout-DNaxppTZ.js → layout-BQwRLTH0.js} +1 -2
  27. package/dist/{layout-VHjYWa-M.d.ts → layout-BZtKNqiC.d.ts} +1 -3
  28. package/dist/{log-E-cH6xkd.js → log-NlQi6kow.js} +2 -4
  29. package/dist/{object-BgPPDLDE.js → object-DfrneieE.js} +2 -4
  30. package/dist/{presence-B6rvkHqd.js → presence-DZ21pPKm.js} +3 -4
  31. package/dist/{request-kM5epeSd.js → request-DM6xHTaU.js} +5 -9
  32. package/dist/{request-DAodIqZ8.d.ts → request-PrMHOYFK.d.ts} +1 -3
  33. package/dist/{server-Covbc24E.d.ts → server-CLdYV7Md.d.ts} +6 -20
  34. package/dist/{server-BSXJP45b.js → server-yQp02XNp.js} +17 -24
  35. package/dist/server.d.ts +3 -3
  36. package/dist/server.js +2 -2
  37. package/dist/{types-DdY7Vo1H.d.ts → types-oUyN-CJR.d.ts} +1 -5
  38. package/dist/vite.d.ts +2 -15
  39. package/dist/vite.js +20 -27
  40. package/dist/vue.d.ts +2 -6
  41. package/dist/vue.js +47 -26
  42. package/package.json +39 -39
  43. package/dist/document-U5rzg2vG.js +0 -2041
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
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";
1
+ import { g as realtimeKeepalivePong, h as realtimeKeepalivePing, r as isRecordOrFunction, t as cloneRecord } from "./object-DfrneieE.js";
2
+ import { o as realtimeNamespaceVariable, s as realtimePostgresUrlVariable } from "./bus-DJ3dOQAZ.js";
3
+ import { t as realtimeErrorDiagnostics } from "./error-diagnostics-we8V1O-X.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";
@@ -8,7 +8,7 @@ import { mkdir, writeFile } from "node:fs/promises";
8
8
  import { basename, dirname, parse, relative, resolve } from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import { tmpdir } from "node:os";
11
- //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
11
+ // ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
12
12
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
13
13
  function normalizeWindowsPath(input = "") {
14
14
  if (!input) return input;
@@ -99,8 +99,7 @@ const relative$1 = function(from, to) {
99
99
  }
100
100
  return [..._from.map(() => ".."), ..._to].join("/");
101
101
  };
102
- //#endregion
103
- //#region ../internal/src/error-diagnostics.ts
102
+ // ../internal/src/error-diagnostics.ts
104
103
  const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
105
104
  const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
106
105
  docsBase: "https://vitehub.dev/docs/development/diagnostics",
@@ -357,6 +356,10 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
357
356
  why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
358
357
  fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
359
358
  },
359
+ INTERNAL_SITE_TOKEN_TOO_LONG: {
360
+ why: ({ length, maximum }) => `The Site access token is ${length} characters, and an app accepts ${maximum}.`,
361
+ fix: "Open the app with a shorter path, or give the person and the project shorter names, so that the Site access token fits."
362
+ },
360
363
  INTERNAL_SQLITE_ARGUMENT_INVALID: {
361
364
  why: ({ value }) => value === "undefined" ? "undefined cannot be passed as argument to the database" : "Only finite numbers (not Infinity or NaN) can be passed as arguments",
362
365
  fix: "Pass query arguments as finite numbers, strings, booleans, bigints, dates, byte arrays, or null. Replace undefined with null, and check numbers with `Number.isFinite()` before the query."
@@ -371,8 +374,7 @@ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
371
374
  }
372
375
  }
373
376
  });
374
- //#endregion
375
- //#region ../internal/src/definition-catalog.ts
377
+ // ../internal/src/definition-catalog.ts
376
378
  const sourceFilePattern = /\.(?:c|m)?[jt]sx?$/i;
377
379
  const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
378
380
  const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
@@ -504,22 +506,19 @@ function createRuntimeRegistryContents(registryFile, definitions) {
504
506
  ""
505
507
  ].join("\n");
506
508
  }
507
- //#endregion
508
- //#region ../internal/src/durability.ts
509
+ // ../internal/src/durability.ts
509
510
  /** The `durability` module next to the Vite plugin module at `importMetaUrl`, in source and in `dist`. */
510
511
  function durabilityModuleFile(importMetaUrl) {
511
512
  return fileURLToPath(new URL(importMetaUrl.endsWith(".ts") ? "./durability.ts" : "./durability.js", importMetaUrl));
512
513
  }
513
- //#endregion
514
- //#region ../internal/src/inspect.ts
514
+ // ../internal/src/inspect.ts
515
515
  function relativeDefinitionFile(projectRoot, file) {
516
516
  return relative$1(projectRoot, file).replaceAll("\\", "/");
517
517
  }
518
518
  const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
519
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
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
522
- //#region ../internal/src/build/vite.ts
521
+ // ../internal/src/build/vite.ts
523
522
  const projectRootDirectoryMarkers = [
524
523
  ["server", "agents"],
525
524
  ["server", "channels"],
@@ -595,6 +594,7 @@ function isMissingProjectMarker(error) {
595
594
  const code = error.code;
596
595
  return code === "ENOENT" || code === "ENOTDIR";
597
596
  }
597
+ // ../internal/src/runtime/page-tools-shared.ts
598
598
  /**
599
599
  * The path of an app base, without the trailing slash: `/portal/` and `https://cdn.example/portal/` give `/portal`.
600
600
  * The root and relative bases (`""`, `"./"`) give `""`. The Console mounts its routes with the same rule.
@@ -646,8 +646,7 @@ function createNitroServerKit(value = {}) {
646
646
  }
647
647
  };
648
648
  }
649
- //#endregion
650
- //#region ../internal/src/build/page-tools.ts
649
+ // ../internal/src/build/page-tools.ts
651
650
  function readString(value, key) {
652
651
  const field = value !== null && typeof value === "object" ? Reflect.get(value, key) : void 0;
653
652
  return typeof field === "string" ? field : void 0;
@@ -683,8 +682,7 @@ function hostFromNitroPreset(value) {
683
682
  if (normalized === "node" || normalized.startsWith("node-")) return "node";
684
683
  if (normalized.startsWith("vercel")) return "vercel";
685
684
  }
686
- //#endregion
687
- //#region ../internal/src/hosting.ts
685
+ // ../internal/src/hosting.ts
688
686
  /**
689
687
  * Returns the Nitro preset name that this build targets, as the developer wrote it.
690
688
  * The order is `nitro.preset`, `hosting`, `NITRO_PRESET`, `SERVER_PRESET`, then `VITEHUB_HOST`.
@@ -710,8 +708,7 @@ function getHostingProvider(hosting) {
710
708
  const host = hostFromNitroPreset(hosting);
711
709
  if (host === "cloudflare" || host === "netlify" || host === "vercel") return host;
712
710
  }
713
- //#endregion
714
- //#region src/deployment-env.ts
711
+ // src/deployment-env.ts
715
712
  const owners = ["realtime"];
716
713
  function entry(names, required, secret, hasDefault = false) {
717
714
  return {
@@ -738,8 +735,7 @@ function realtimeDeploymentEnv(input, context) {
738
735
  namespace
739
736
  ];
740
737
  }
741
- //#endregion
742
- //#region src/discovery.ts
738
+ // src/discovery.ts
743
739
  function discoverRealtimeDefinitions(rootDir, serverDirs) {
744
740
  return discoverDefinitions("realtime", [createDirectoryDefinitionSource("server-realtime", serverDirs ?? [resolve(rootDir, "server")], "realtime", {
745
741
  createDefinition: ({ file, name }) => ({
@@ -750,8 +746,7 @@ function discoverRealtimeDefinitions(rootDir, serverDirs) {
750
746
  normalizeName: normalizePathDefinitionName
751
747
  })]);
752
748
  }
753
- //#endregion
754
- //#region src/inspect.ts
749
+ // src/inspect.ts
755
750
  const driverLabels = {
756
751
  auto: "auto: Cloudflare Durable Objects on Cloudflare, memory in development, shared rooms on a Node server, build error elsewhere",
757
752
  cloudflare: "cloudflare: one Durable Object per document, Yjs state in SQLite",
@@ -897,8 +892,7 @@ async function summarizeRealtimeDefinitions(projectRoot, definitions, driver) {
897
892
  };
898
893
  });
899
894
  }
900
- //#endregion
901
- //#region src/vite.ts
895
+ // src/vite.ts
902
896
  /**
903
897
  * Lists Realtime Definitions with their document adapter, editor codec, identity, authorization,
904
898
  * persistence, and driver, read statically from each definition file.
@@ -1170,5 +1164,4 @@ function hubRealtime(options = {}) {
1170
1164
  }
1171
1165
  };
1172
1166
  }
1173
- //#endregion
1174
1167
  export { discoverRealtimeDefinitions, hubRealtime, inspectRealtimeDefinitions };
package/dist/vue.d.ts CHANGED
@@ -1,12 +1,11 @@
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";
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-oUyN-CJR.js";
2
+ import { i as readRealtimeYDoc } from "./document-CbqgNO_0.js";
3
3
  import { Awareness } from "y-protocols/awareness";
4
4
  import { WebsocketProvider } from "y-websocket";
5
5
  import * as Y from "yjs";
6
6
  import { AnyExtension, Extension } from "@tiptap/core";
7
7
  import { MaybeRefOrGetter, Ref } from "vue";
8
8
  import { DecorationAttrs } from "@tiptap/pm/view";
9
- //#region src/caret.d.ts
10
9
  /** A remote person as the caret sees them: the presence identity from awareness. */
11
10
  interface RealtimeCaretUser {
12
11
  color: string;
@@ -26,8 +25,6 @@ interface RealtimeCaretOptions {
26
25
  * Realtime has its own copy, cannot find Realtime's sync plugin, and draws nothing. Presence identity stays Realtime's.
27
26
  */
28
27
  export declare const RealtimeCaret: Extension<RealtimeCaretOptions, any>;
29
- //#endregion
30
- //#region src/vue.d.ts
31
28
  export type RealtimeStatus = "connected" | "connecting" | "disconnected";
32
29
  export interface RealtimeResetEvent {
33
30
  /** Room seed the client reconnects to. */
@@ -82,5 +79,4 @@ export declare function useRealtimeTiptap(definition: string, documentId: MaybeR
82
79
  };
83
80
  destroy: () => void;
84
81
  };
85
- //#endregion
86
82
  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-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
- import { n as realtimeDocumentLayout, t as readRealtimeStatus } from "./layout-DNaxppTZ.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";
1
+ 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-CfrQbB03.js";
2
+ import { n as resolveRealtimeApplicationPath, t as keepRealtimeSocketAlive } from "./keepalive-BYkk6Ax8.js";
3
+ import { t as createRealtimeEditorExtensions } from "./editor-DzhKM4Gt.js";
4
+ import { n as realtimeDocumentLayout, t as readRealtimeStatus } from "./layout-BQwRLTH0.js";
5
+ 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-DfrneieE.js";
6
+ import { n as getRealtimePeople, t as createRealtimeIdentity } from "./presence-DZ21pPKm.js";
7
+ import { t as realtimeErrorDiagnostics } from "./error-diagnostics-we8V1O-X.js";
8
8
  import "lib0/decoding";
9
9
  import * as encoding from "lib0/encoding";
10
10
  import * as awarenessProtocol from "y-protocols/awareness";
@@ -14,7 +14,7 @@ import { Extension, MappablePosition, getUpdatedPosition } from "@tiptap/core";
14
14
  import { Plugin, PluginKey } from "@tiptap/pm/state";
15
15
  import { useUserSession } from "@vite-hub/auth/vue";
16
16
  import { computed, getCurrentInstance, markRaw, onMounted, onScopeDispose, ref, shallowRef, toValue, watch } from "vue";
17
- //#region ../../node_modules/.pnpm/@tiptap+extension-collaboration@3.31.4_@tiptap+core@3.31.4_@tiptap+pm@3.31.4__@tiptap+p_85015a5a825a0d4859fbb90094e145d9/node_modules/@tiptap/extension-collaboration/dist/index.js
17
+ // ../../node_modules/.pnpm/@tiptap+extension-collaboration@3.35.0_@tiptap+core@3.35.0_@tiptap+pm@3.35.0__@tiptap+p_d75d2d6e96a1dd569ff00a6acb5ce82e/node_modules/@tiptap/extension-collaboration/dist/index.js
18
18
  /**
19
19
  * Checks if a transaction was originated from a Yjs change.
20
20
  * @param {Transaction} transaction - The transaction to check.
@@ -30,16 +30,22 @@ function isChangeOrigin(transaction) {
30
30
  * Converts a Y.js relative position to a position in the Tiptap document.
31
31
  */
32
32
  function getYAbsolutePosition(state, relativePos) {
33
- const ystate = ySyncPluginKey.getState(state);
33
+ if (relativePos === null) return 0;
34
+ const ystate = getSyncState(state);
34
35
  return relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0;
35
36
  }
36
37
  /**
37
38
  * Converts a position in the Tiptap document to a Y.js relative position.
38
39
  */
39
40
  function getYRelativePosition(state, absolutePos) {
40
- const ystate = ySyncPluginKey.getState(state);
41
+ const ystate = getSyncState(state);
41
42
  return absolutePositionToRelativePosition(absolutePos, ystate.type, ystate.binding.mapping);
42
43
  }
44
+ function getSyncState(state) {
45
+ const syncState = ySyncPluginKey.getState(state);
46
+ if (!syncState) throw new Error("Collaboration requires the Yjs sync plugin");
47
+ return syncState;
48
+ }
43
49
  /**
44
50
  * A MappablePosition subclass that includes Y.js relative position information
45
51
  * to track positions in collaborative transactions.
@@ -76,7 +82,7 @@ function createMappablePosition(position, state) {
76
82
  * Returns the new position after applying a transaction. Handles both Y.js
77
83
  * transactions and regular transactions.
78
84
  */
79
- function getUpdatedPosition$1(position, transaction, state) {
85
+ function getUpdatedPosition$2(position, transaction, state) {
80
86
  const yRelativePosition = position instanceof CollaborationMappablePosition ? position.yRelativePosition : null;
81
87
  if (isChangeOrigin(transaction) && yRelativePosition) return {
82
88
  position: new CollaborationMappablePosition(getYAbsolutePosition(state, yRelativePosition), yRelativePosition),
@@ -89,6 +95,11 @@ function getUpdatedPosition$1(position, transaction, state) {
89
95
  mapResult: result.mapResult
90
96
  };
91
97
  }
98
+ function getUndoManager(state) {
99
+ const undoState = yUndoPluginKey.getState(state);
100
+ if (!undoState) throw new Error("Collaboration requires the Yjs undo plugin");
101
+ return undoState.undoManager;
102
+ }
92
103
  var src_default = Extension.create({
93
104
  name: "collaboration",
94
105
  priority: 1e3,
@@ -107,22 +118,24 @@ var src_default = Extension.create({
107
118
  if (this.editor.extensionManager.extensions.find((extension) => extension.name === "undoRedo")) console.warn("[tiptap warn]: \"@tiptap/extension-collaboration\" comes with its own history support and is not compatible with \"@tiptap/extension-undo-redo\".");
108
119
  },
109
120
  onBeforeCreate() {
110
- this.editor.utils.getUpdatedPosition = (position, transaction) => getUpdatedPosition$1(position, transaction, this.editor.state);
121
+ this.editor.utils.getUpdatedPosition = (position, transaction) => getUpdatedPosition$2(position, transaction, this.editor.state);
111
122
  this.editor.utils.createMappablePosition = (position) => createMappablePosition(position, this.editor.state);
112
123
  },
113
124
  addCommands() {
114
125
  return {
115
126
  undo: () => ({ tr, state, dispatch }) => {
127
+ var _undo;
116
128
  tr.setMeta("preventDispatch", true);
117
- if (yUndoPluginKey.getState(state).undoManager.undoStack.length === 0) return false;
129
+ if (getUndoManager(state).undoStack.length === 0) return false;
118
130
  if (!dispatch) return true;
119
- return undo(state);
131
+ return (_undo = undo(state)) !== null && _undo !== void 0 ? _undo : false;
120
132
  },
121
133
  redo: () => ({ tr, state, dispatch }) => {
134
+ var _redo;
122
135
  tr.setMeta("preventDispatch", true);
123
- if (yUndoPluginKey.getState(state).undoManager.redoStack.length === 0) return false;
136
+ if (getUndoManager(state).redoStack.length === 0) return false;
124
137
  if (!dispatch) return true;
125
- return redo(state);
138
+ return (_redo = redo(state)) !== null && _redo !== void 0 ? _redo : false;
126
139
  }
127
140
  };
128
141
  },
@@ -138,7 +151,7 @@ var src_default = Extension.create({
138
151
  const yUndoPluginInstance = yUndoPlugin(this.options.yUndoOptions);
139
152
  const originalUndoPluginView = yUndoPluginInstance.spec.view;
140
153
  yUndoPluginInstance.spec.view = (view) => {
141
- const { undoManager } = yUndoPluginKey.getState(view.state);
154
+ const undoManager = getUndoManager(view.state);
142
155
  if (undoManager.restore) {
143
156
  undoManager.restore();
144
157
  undoManager.restore = () => {};
@@ -159,11 +172,22 @@ var src_default = Extension.create({
159
172
  ...this.options.ySyncOptions,
160
173
  onFirstRender: this.options.onFirstRender
161
174
  };
175
+ if (this.editor.options.enableContentCheck) ySyncPluginOptions.onInvalidContent = (error) => {
176
+ this.editor.emit("contentError", {
177
+ error,
178
+ editor: this.editor,
179
+ disableCollaboration: () => {
180
+ var _fragment$doc;
181
+ this.storage.isDisabled = true;
182
+ (_fragment$doc = fragment.doc) === null || _fragment$doc === void 0 || _fragment$doc.destroy();
183
+ }
184
+ });
185
+ };
162
186
  return [
163
187
  ySyncPlugin(fragment, ySyncPluginOptions),
164
188
  yUndoPluginInstance,
165
189
  new Plugin({ filterTransaction: (transaction, state) => {
166
- if (transaction.getMeta("inputRule")) yUndoPluginKey.getState(state).undoManager.stopCapturing();
190
+ if (transaction.getMeta("inputRule")) getUndoManager(state).stopCapturing();
167
191
  return true;
168
192
  } }),
169
193
  this.editor.options.enableContentCheck && new Plugin({
@@ -181,19 +205,18 @@ var src_default = Extension.create({
181
205
  error,
182
206
  editor: this.editor,
183
207
  disableCollaboration: () => {
184
- var _fragment$doc;
185
- (_fragment$doc = fragment.doc) === null || _fragment$doc === void 0 || _fragment$doc.destroy();
208
+ var _fragment$doc2;
209
+ (_fragment$doc2 = fragment.doc) === null || _fragment$doc2 === void 0 || _fragment$doc2.destroy();
186
210
  }
187
211
  });
188
212
  return true;
189
213
  }
190
214
  }
191
215
  })
192
- ].filter(Boolean);
216
+ ].filter((plugin) => plugin !== false);
193
217
  }
194
218
  });
195
- //#endregion
196
- //#region src/caret.ts
219
+ // src/caret.ts
197
220
  const validColor = /^#[0-9a-f]{6}$/i;
198
221
  /**
199
222
  * Other people's carets and selections, drawn from the room's awareness. It renders what TipTap's CollaborationCaret
@@ -237,8 +260,7 @@ const RealtimeCaret = Extension.create({
237
260
  })];
238
261
  }
239
262
  });
240
- //#endregion
241
- //#region src/vue.ts
263
+ // src/vue.ts
242
264
  function serverRequestError(code, action) {
243
265
  switch (code) {
244
266
  case realtimeInvalidDocumentCode: return realtimeErrorDiagnostics.REALTIME_INVALID_DOCUMENT({ action });
@@ -609,5 +631,4 @@ function useRealtimeTiptap(definition, documentId, options = {}) {
609
631
  destroy
610
632
  };
611
633
  }
612
- //#endregion
613
634
  export { RealtimeCaret, readRealtimeYDoc, useRealtimeTiptap };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/realtime",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Realtime document primitives and Vite integration for ViteHub.",
5
5
  "keywords": [
6
6
  "collaboration",
@@ -94,66 +94,66 @@
94
94
  }
95
95
  },
96
96
  "dependencies": {
97
- "@tiptap/extension-collaboration": "^3.31.4",
98
- "@tiptap/y-tiptap": "^3.0.9",
99
- "@vite-hub/auth": "0.5.0",
100
- "@vite-hub/workspace": "0.5.0",
97
+ "@tiptap/extension-collaboration": "^3.35.0",
98
+ "@tiptap/y-tiptap": "^3.3.1",
99
+ "@vite-hub/auth": "0.6.0",
100
+ "@vite-hub/workspace": "0.6.0",
101
101
  "h3": "^2.0.8",
102
- "ioredis": "^5.11.1",
103
- "lib0": "^0.2.119",
102
+ "ioredis": "^6.1.0",
103
+ "lib0": "^0.2.120",
104
104
  "marked": "17.0.6",
105
105
  "nostics": "1.4.0",
106
106
  "postgres": "^3.4.9",
107
- "prosemirror-model": "^1.25.12",
107
+ "prosemirror-model": "^1.25.13",
108
108
  "prosemirror-state": "^1.4.4",
109
- "prosemirror-transform": "^1.12.2",
110
- "prosemirror-view": "^1.42.3",
109
+ "prosemirror-transform": "^1.12.7",
110
+ "prosemirror-view": "^1.43.0",
111
111
  "y-protocols": "^1.0.7",
112
112
  "y-websocket": "^3.1.0",
113
- "@vite-hub/runtime": "0.5.0"
113
+ "@vite-hub/runtime": "0.6.0"
114
114
  },
115
115
  "devDependencies": {
116
- "@tiptap/core": "^3.31.4",
117
- "@tiptap/extension-blockquote": "^3.31.4",
118
- "@tiptap/extension-code": "^3.31.4",
119
- "@tiptap/extension-document": "^3.31.4",
120
- "@tiptap/extension-image": "^3.31.4",
121
- "@tiptap/extension-table": "^3.31.4",
122
- "@tiptap/markdown": "^3.31.4",
123
- "@tiptap/pm": "^3.31.4",
124
- "@tiptap/starter-kit": "^3.31.4",
116
+ "@tiptap/core": "^3.35.0",
117
+ "@tiptap/extension-blockquote": "^3.35.0",
118
+ "@tiptap/extension-code": "^3.35.0",
119
+ "@tiptap/extension-document": "^3.35.0",
120
+ "@tiptap/extension-image": "^3.35.0",
121
+ "@tiptap/extension-table": "^3.35.0",
122
+ "@tiptap/markdown": "^3.35.0",
123
+ "@tiptap/pm": "^3.35.0",
124
+ "@tiptap/starter-kit": "^3.35.0",
125
125
  "@types/json-schema": "^7.0.15",
126
- "@types/node": "^24.19.1",
127
- "@vite-hub/database": "0.5.0",
126
+ "@types/node": "^24.19.2",
127
+ "@vite-hub/database": "0.6.0",
128
128
  "@vite-hub/internal": "0.0.1",
129
- "happy-dom": "21.0.3",
130
- "linkedom": "^0.18.13",
129
+ "happy-dom": "21.0.4",
130
+ "linkedom": "^0.18.15",
131
131
  "nitro": "^3.0.261103-rc",
132
132
  "publint": "^0.3.25",
133
133
  "typescript": "^6.0.3",
134
- "vite": "^8.2.2",
135
- "vite-plus": "^0.3.3",
136
- "vitest": "^4.1.11",
137
- "vue": "3.5.44",
134
+ "vite": "^8.3.8",
135
+ "vite-plus": "^1.7.0",
136
+ "vitest": "5.1.0",
137
+ "vue": "3.5.46",
138
138
  "miniflare": "4.20260730.0",
139
- "drizzle-orm": "1.0.0-rc.5",
139
+ "drizzle-orm": "1.0.0-rc.6",
140
140
  "yjs": "^13.6.33"
141
141
  },
142
142
  "peerDependencies": {
143
- "@tiptap/core": "^3.31.4",
144
- "@tiptap/extension-blockquote": "^3.31.4",
145
- "@tiptap/extension-code": "^3.31.4",
146
- "@tiptap/extension-document": "^3.31.4",
147
- "@tiptap/extension-image": "^3.31.4",
148
- "@tiptap/extension-table": "^3.31.4",
149
- "@tiptap/markdown": "^3.31.4",
150
- "@tiptap/pm": "^3.31.4",
151
- "@tiptap/starter-kit": "^3.31.4",
143
+ "@tiptap/core": "^3.35.0",
144
+ "@tiptap/extension-blockquote": "^3.35.0",
145
+ "@tiptap/extension-code": "^3.35.0",
146
+ "@tiptap/extension-document": "^3.35.0",
147
+ "@tiptap/extension-image": "^3.35.0",
148
+ "@tiptap/extension-table": "^3.35.0",
149
+ "@tiptap/markdown": "^3.35.0",
150
+ "@tiptap/pm": "^3.35.0",
151
+ "@tiptap/starter-kit": "^3.35.0",
152
152
  "@types/json-schema": "^7.0.15",
153
153
  "nitro": "3.0.261102-rc || ^3.0.261103-rc",
154
154
  "vite": ">=8.0.0",
155
155
  "vue": "^3.5.0",
156
- "drizzle-orm": "1.0.0-rc.5 || ^1.0.0",
156
+ "drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0",
157
157
  "yjs": "^13.6.33"
158
158
  },
159
159
  "peerDependenciesMeta": {