@sidekickdb/vue 2.0.1 → 3.0.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 (32) hide show
  1. package/README.md +3 -3
  2. package/dist/{InstantVueDatabase.d.ts → SidekickVueDatabase.d.ts} +26 -26
  3. package/dist/SidekickVueDatabase.d.ts.map +1 -0
  4. package/dist/{InstantVueDatabase.js → SidekickVueDatabase.js} +14 -14
  5. package/dist/SidekickVueDatabase.js.map +1 -0
  6. package/dist/{InstantVueRoom.d.ts → SidekickVueRoom.d.ts} +10 -10
  7. package/dist/SidekickVueRoom.d.ts.map +1 -0
  8. package/dist/{InstantVueRoom.js → SidekickVueRoom.js} +3 -3
  9. package/dist/SidekickVueRoom.js.map +1 -0
  10. package/dist/chunks/{Cursors.vue_vue_type_script_setup_true_lang-C6eE1KRI.js → Cursors.vue_vue_type_script_setup_true_lang-BIVjDXb4.js} +2 -2
  11. package/dist/chunks/Cursors.vue_vue_type_script_setup_true_lang-BIVjDXb4.js.map +1 -0
  12. package/dist/chunks/SignedIn.vue_vue_type_script_setup_true_lang-MJrQPE2B.js.map +1 -1
  13. package/dist/chunks/SignedOut.vue_vue_type_script_setup_true_lang-CcoDHmXu.js.map +1 -1
  14. package/dist/components/Cursors.js +1 -1
  15. package/dist/components/Cursors.vue.d.ts +2 -2
  16. package/dist/components/Cursors.vue.d.ts.map +1 -1
  17. package/dist/components/SignedIn.vue.d.ts +3 -3
  18. package/dist/components/SignedIn.vue.d.ts.map +1 -1
  19. package/dist/components/SignedOut.vue.d.ts +3 -3
  20. package/dist/components/SignedOut.vue.d.ts.map +1 -1
  21. package/dist/index.d.ts +4 -4
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +8 -8
  24. package/dist/useInfiniteQuery.d.ts +4 -4
  25. package/dist/useInfiniteQuery.d.ts.map +1 -1
  26. package/dist/useInfiniteQuery.js.map +1 -1
  27. package/package.json +3 -3
  28. package/dist/InstantVueDatabase.d.ts.map +0 -1
  29. package/dist/InstantVueDatabase.js.map +0 -1
  30. package/dist/InstantVueRoom.d.ts.map +0 -1
  31. package/dist/InstantVueRoom.js.map +0 -1
  32. package/dist/chunks/Cursors.vue_vue_type_script_setup_true_lang-C6eE1KRI.js.map +0 -1
package/README.md CHANGED
@@ -9,7 +9,7 @@ Welcome to SidekickDB's Vue SDK.
9
9
  ```vue
10
10
  <!-- ༼ つ ◕_◕ ༽つ Real-time Chat -->
11
11
  <!-- ---------------------------------- -->
12
- <!-- * Updates instantly -->
12
+ <!-- * Updates in real time -->
13
13
  <!-- * Multiplayer -->
14
14
  <!-- * Works offline -->
15
15
 
@@ -17,8 +17,8 @@ Welcome to SidekickDB's Vue SDK.
17
17
  import { init, id } from '@sidekickdb/vue';
18
18
 
19
19
  const db = init({
20
- appId: import.meta.env.VITE_INSTANT_APP_ID,
21
- apiURI: import.meta.env.VITE_INSTANT_API_URI,
20
+ appId: import.meta.env.VITE_SIDEKICK_APP_ID,
21
+ apiURI: import.meta.env.VITE_SIDEKICK_API_URI,
22
22
  });
23
23
 
24
24
  // 1. Read
@@ -1,10 +1,10 @@
1
- import { type User, type ConnectionStatus, type TransactionChunk, type RoomSchemaShape, type InstaQLOptions, type InstantConfig, type PageInfoResponse, type InstaQLResponse, type ValidQuery, Auth, Storage, Streams, InstantCoreDatabase, InstantSchemaDef, RoomsOf, IInstantDatabase } from '@sidekickdb/core';
1
+ import { type User, type ConnectionStatus, type TransactionChunk, type RoomSchemaShape, type SideQLOptions, type SidekickConfig, type PageInfoResponse, type SideQLResponse, type ValidQuery, Auth, Storage, Streams, SidekickCoreDatabase, SidekickSchemaDef, RoomsOf, ISidekickDatabase } from '@sidekickdb/core';
2
2
  import type { Ref, ShallowRef, ComputedRef, MaybeRefOrGetter } from 'vue';
3
- import { InstantVueRoom } from './InstantVueRoom.js';
3
+ import { SidekickVueRoom } from './SidekickVueRoom.js';
4
4
  import type { InfiniteQueryResult } from './useInfiniteQuery.js';
5
- export type UseQueryReturn<Schema extends InstantSchemaDef<any, any, any>, Q extends ValidQuery<Q, Schema>, UseDates extends boolean> = {
5
+ export type UseQueryReturn<Schema extends SidekickSchemaDef<any, any, any>, Q extends ValidQuery<Q, Schema>, UseDates extends boolean> = {
6
6
  isLoading: Ref<boolean>;
7
- data: ShallowRef<InstaQLResponse<Schema, Q, UseDates> | undefined>;
7
+ data: ShallowRef<SideQLResponse<Schema, Q, UseDates> | undefined>;
8
8
  pageInfo: ShallowRef<PageInfoResponse<Q> | undefined>;
9
9
  error: ShallowRef<{
10
10
  message: string;
@@ -17,13 +17,13 @@ export type UseAuthReturn = {
17
17
  message: string;
18
18
  } | undefined>;
19
19
  };
20
- export declare class InstantVueDatabase<Schema extends InstantSchemaDef<any, any, any>, UseDates extends boolean = false, Rooms extends RoomSchemaShape = RoomsOf<Schema>> implements IInstantDatabase<Schema> {
20
+ export declare class SidekickVueDatabase<Schema extends SidekickSchemaDef<any, any, any>, UseDates extends boolean = false, Rooms extends RoomSchemaShape = RoomsOf<Schema>> implements ISidekickDatabase<Schema> {
21
21
  tx: import("@sidekickdb/core").TxChunk<Schema>;
22
22
  auth: Auth;
23
23
  storage: Storage;
24
24
  streams: Streams;
25
- core: InstantCoreDatabase<Schema, UseDates>;
26
- constructor(core: InstantCoreDatabase<Schema, UseDates>);
25
+ core: SidekickCoreDatabase<Schema, UseDates>;
26
+ constructor(core: SidekickCoreDatabase<Schema, UseDates>);
27
27
  /**
28
28
  * Returns a unique ID for a given `name`. It's stored in local storage,
29
29
  * so you will get the same ID across sessions.
@@ -35,7 +35,7 @@ export declare class InstantVueDatabase<Schema extends InstantSchemaDef<any, any
35
35
  /**
36
36
  * Use this to write data! You can create, update, delete, and link objects
37
37
  *
38
- * @see https://sidekickdb.co/docs/instaml
38
+ * @see https://sidekickdb.co/docs/sideml
39
39
  *
40
40
  * @example
41
41
  * const goalId = id();
@@ -55,20 +55,20 @@ export declare class InstantVueDatabase<Schema extends InstantSchemaDef<any, any
55
55
  * Use this for one-off queries.
56
56
  * Returns local data if available, otherwise fetches from the server.
57
57
  *
58
- * @see https://sidekickdb.co/docs/instaql
58
+ * @see https://sidekickdb.co/docs/sideql
59
59
  *
60
60
  * @example
61
61
  * const resp = await db.queryOnce({ goals: {} });
62
62
  * console.log(resp.data.goals)
63
63
  */
64
- queryOnce: <Q extends ValidQuery<Q, Schema>>(query: Q, opts?: InstaQLOptions) => Promise<{
65
- data: InstaQLResponse<Schema, Q, UseDates>;
64
+ queryOnce: <Q extends ValidQuery<Q, Schema>>(query: Q, opts?: SideQLOptions) => Promise<{
65
+ data: SideQLResponse<Schema, Q, UseDates>;
66
66
  pageInfo: PageInfoResponse<Q>;
67
67
  }>;
68
68
  /**
69
69
  * Use this to query your data!
70
70
  *
71
- * @see https://sidekickdb.co/docs/instaql
71
+ * @see https://sidekickdb.co/docs/sideql
72
72
  *
73
73
  * @example
74
74
  * // basic query — refs auto-unwrap in templates
@@ -86,7 +86,7 @@ export declare class InstantVueDatabase<Schema extends InstantSchemaDef<any, any
86
86
  * const query = ref<{ todos: {} } | null>({ todos: {} });
87
87
  * const { data } = db.useQuery(query);
88
88
  */
89
- useQuery: <Q extends ValidQuery<Q, Schema>>(query: MaybeRefOrGetter<Q | null>, opts?: MaybeRefOrGetter<InstaQLOptions | null | undefined>) => UseQueryReturn<Schema, Q, UseDates>;
89
+ useQuery: <Q extends ValidQuery<Q, Schema>>(query: MaybeRefOrGetter<Q | null>, opts?: MaybeRefOrGetter<SideQLOptions | null | undefined>) => UseQueryReturn<Schema, Q, UseDates>;
90
90
  /**
91
91
  * Subscribe to a query and incrementally load more items.
92
92
  *
@@ -98,7 +98,7 @@ export declare class InstantVueDatabase<Schema extends InstantSchemaDef<any, any
98
98
  * posts: { $: { limit: 20, order: { createdAt: 'desc' } } },
99
99
  * });
100
100
  */
101
- useInfiniteQuery: <Q extends ValidQuery<Q, Schema>>(query: MaybeRefOrGetter<Q | null>, opts?: MaybeRefOrGetter<InstaQLOptions | undefined>) => InfiniteQueryResult<Schema, Q, UseDates>;
101
+ useInfiniteQuery: <Q extends ValidQuery<Q, Schema>>(query: MaybeRefOrGetter<Q | null>, opts?: MaybeRefOrGetter<SideQLOptions | undefined>) => InfiniteQueryResult<Schema, Q, UseDates>;
102
102
  /**
103
103
  * Listen for the logged in state. This is useful
104
104
  * for deciding when to show a login screen.
@@ -120,9 +120,9 @@ export declare class InstantVueDatabase<Schema extends InstantSchemaDef<any, any
120
120
  */
121
121
  useUser: () => ComputedRef<User>;
122
122
  /**
123
- * Listen for connection status changes to Instant.
123
+ * Listen for connection status changes to SidekickDB.
124
124
  *
125
- * @see https://sidekickdb.co/docs/patterns#connection-status
125
+ * @see https://sidekickdb.co/docs/patterns#listen-to-sidekick-db-connection-status
126
126
  * @example
127
127
  * const status = db.useConnectionStatus();
128
128
  * // status.value
@@ -148,7 +148,7 @@ export declare class InstantVueDatabase<Schema extends InstantSchemaDef<any, any
148
148
  * const room = db.room('chat', roomId);
149
149
  * const { peers } = db.rooms.usePresence(room);
150
150
  */
151
- room<RoomType extends string & keyof Rooms>(type?: MaybeRefOrGetter<RoomType | undefined>, id?: MaybeRefOrGetter<string | undefined>): InstantVueRoom<Schema, Rooms, RoomType>;
151
+ room<RoomType extends string & keyof Rooms>(type?: MaybeRefOrGetter<RoomType | undefined>, id?: MaybeRefOrGetter<string | undefined>): SidekickVueRoom<Schema, Rooms, RoomType>;
152
152
  /**
153
153
  * Hooks for working with rooms
154
154
  *
@@ -160,11 +160,11 @@ export declare class InstantVueDatabase<Schema extends InstantSchemaDef<any, any
160
160
  * const publish = db.rooms.usePublishTopic(room, 'emoji');
161
161
  */
162
162
  rooms: {
163
- useTopicEffect: typeof import("./InstantVueRoom.js").useTopicEffect;
164
- usePublishTopic: typeof import("./InstantVueRoom.js").usePublishTopic;
165
- usePresence: typeof import("./InstantVueRoom.js").usePresence;
166
- useSyncPresence: typeof import("./InstantVueRoom.js").useSyncPresence;
167
- useTypingIndicator: typeof import("./InstantVueRoom.js").useTypingIndicator;
163
+ useTopicEffect: typeof import("./SidekickVueRoom.js").useTopicEffect;
164
+ usePublishTopic: typeof import("./SidekickVueRoom.js").usePublishTopic;
165
+ usePresence: typeof import("./SidekickVueRoom.js").usePresence;
166
+ useSyncPresence: typeof import("./SidekickVueRoom.js").useSyncPresence;
167
+ useTypingIndicator: typeof import("./SidekickVueRoom.js").useTypingIndicator;
168
168
  };
169
169
  }
170
170
  /**
@@ -180,11 +180,11 @@ export declare class InstantVueDatabase<Schema extends InstantSchemaDef<any, any
180
180
  * // You can also provide a schema for type safety and editor autocomplete!
181
181
  *
182
182
  * import { init } from "@sidekickdb/vue"
183
- * import schema from "../instant.schema.ts";
183
+ * import schema from "../sidekick.schema.ts";
184
184
  *
185
185
  * const db = init({ appId: "my-app-id", apiURI: "https://sidekick.example.com", schema })
186
186
  */
187
- export declare function init<Schema extends InstantSchemaDef<any, any, any>, UseDates extends boolean = false>(config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
187
+ export declare function init<Schema extends SidekickSchemaDef<any, any, any>, UseDates extends boolean = false>(config: Omit<SidekickConfig<Schema, UseDates>, 'useDateObjects'> & {
188
188
  useDateObjects?: UseDates;
189
- }): InstantVueDatabase<Schema, UseDates>;
190
- //# sourceMappingURL=InstantVueDatabase.d.ts.map
189
+ }): SidekickVueDatabase<Schema, UseDates>;
190
+ //# sourceMappingURL=SidekickVueDatabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidekickVueDatabase.d.ts","sourceRoot":"","sources":["../src/SidekickVueDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,UAAU,EAEf,IAAI,EACJ,OAAO,EACP,OAAO,EAEP,oBAAoB,EAIpB,iBA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gB,CAAC,CAAC,GAAG,IAAI,CAAC,EACjC,OAAO,gBAAgB,CAAC,aAAa,GAAG,SAAS,CAAC,KACjD,mBAAmB,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,CAEzC;IAEF;;;;;;;OAOG;IACH,OAAO,QAAO,aAAa,CAkBzB;IAEF;;;;;;;;;OASG;IACH,OAAO,QAAO,WAAW,CAAC,IAAI,CAAC,CAU7B;IAEF;;;;;;;OAOG;IACH,mBAAmB,QAAO,GAAG,CAAC,gBAAgB,CAAC,CAY7C;IAEF;;;;;;;;;OASG;IACH,UAAU,GAAI,MAAM,gBAAgB,CAAC,MAAM,CAAC,KAAG,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAkB/D;IAEF;;;;;;;;OAQG;IACH,IAAI,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,KAAK,EACxC,IAAI,CAAC,EAAE,gBAAgB,CAAC,QAAQ,GAAG,SAAS,CAAC,EAC7C,EAAE,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC;IAS3C;;;;;;;;;OASG;IACH,KAAK;;;;;;MAAS;CACf;AAKD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAClB,MAAM,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC/C,QAAQ,SAAS,OAAO,GAAG,KAAK,EAEhC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,GAAG;IACjE,cAAc,CAAC,EAAE,QAAQ,CAAC;CAC3B,GACA,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAKvC"}
@@ -1,13 +1,13 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { init as init$1, txInit, coerceQuery, weakHash, InstantError } from "@sidekickdb/core";
4
+ import { init as init$1, txInit, coerceQuery, weakHash, SidekickError } from "@sidekickdb/core";
5
5
  import { ref, shallowRef, computed, toValue, watch } from "vue";
6
- import { InstantVueRoom, rooms } from "./InstantVueRoom.js";
6
+ import { SidekickVueRoom, rooms } from "./SidekickVueRoom.js";
7
7
  import { tryOnScopeDispose } from "./utils.js";
8
8
  import { useInfiniteQuery } from "./useInfiniteQuery.js";
9
9
  import { version } from "@sidekickdb/version";
10
- class InstantVueDatabase {
10
+ class SidekickVueDatabase {
11
11
  constructor(core) {
12
12
  __publicField(this, "tx", txInit());
13
13
  __publicField(this, "auth");
@@ -27,7 +27,7 @@ class InstantVueDatabase {
27
27
  /**
28
28
  * Use this to write data! You can create, update, delete, and link objects
29
29
  *
30
- * @see https://sidekickdb.co/docs/instaml
30
+ * @see https://sidekickdb.co/docs/sideml
31
31
  *
32
32
  * @example
33
33
  * const goalId = id();
@@ -40,7 +40,7 @@ class InstantVueDatabase {
40
40
  * Use this for one-off queries.
41
41
  * Returns local data if available, otherwise fetches from the server.
42
42
  *
43
- * @see https://sidekickdb.co/docs/instaql
43
+ * @see https://sidekickdb.co/docs/sideql
44
44
  *
45
45
  * @example
46
46
  * const resp = await db.queryOnce({ goals: {} });
@@ -54,7 +54,7 @@ class InstantVueDatabase {
54
54
  /**
55
55
  * Use this to query your data!
56
56
  *
57
- * @see https://sidekickdb.co/docs/instaql
57
+ * @see https://sidekickdb.co/docs/sideql
58
58
  *
59
59
  * @example
60
60
  * // basic query — refs auto-unwrap in templates
@@ -159,7 +159,7 @@ class InstantVueDatabase {
159
159
  const { user } = this.useAuth();
160
160
  return computed(() => {
161
161
  if (!user.value) {
162
- throw new InstantError(
162
+ throw new SidekickError(
163
163
  "useUser must be used within an auth-protected route"
164
164
  );
165
165
  }
@@ -167,9 +167,9 @@ class InstantVueDatabase {
167
167
  });
168
168
  });
169
169
  /**
170
- * Listen for connection status changes to Instant.
170
+ * Listen for connection status changes to SidekickDB.
171
171
  *
172
- * @see https://sidekickdb.co/docs/patterns#connection-status
172
+ * @see https://sidekickdb.co/docs/patterns#listen-to-sidekick-db-connection-status
173
173
  * @example
174
174
  * const status = db.useConnectionStatus();
175
175
  * // status.value
@@ -251,17 +251,17 @@ class InstantVueDatabase {
251
251
  () => toValue(type) ?? "_defaultRoomType"
252
252
  );
253
253
  const _id = computed(() => toValue(id) ?? "_defaultRoomId");
254
- return new InstantVueRoom(this.core, _type, _id);
254
+ return new SidekickVueRoom(this.core, _type, _id);
255
255
  }
256
256
  }
257
257
  function init(config) {
258
258
  const coreDb = init$1(config, void 0, void 0, {
259
- "@instantdb/vue": version
259
+ "@sidekickdb/vue": version
260
260
  });
261
- return new InstantVueDatabase(coreDb);
261
+ return new SidekickVueDatabase(coreDb);
262
262
  }
263
263
  export {
264
- InstantVueDatabase,
264
+ SidekickVueDatabase,
265
265
  init
266
266
  };
267
- //# sourceMappingURL=InstantVueDatabase.js.map
267
+ //# sourceMappingURL=SidekickVueDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidekickVueDatabase.js","sources":["../src/SidekickVueDatabase.ts"],"sourcesContent":["import {\n // types\n type AuthState,\n type User,\n type ConnectionStatus,\n type TransactionChunk,\n type RoomSchemaShape,\n type SideQLOptions,\n type SidekickConfig,\n type PageInfoResponse,\n type SideQLResponse,\n type ValidQuery,\n // classes\n Auth,\n Storage,\n Streams,\n txInit,\n SidekickCoreDatabase,\n init as core_init,\n coerceQuery,\n weakHash,\n SidekickSchemaDef,\n RoomsOf,\n SidekickError,\n ISidekickDatabase,\n} from '@sidekickdb/core';\n\nimport { ref, shallowRef, computed, watch, toValue } from 'vue';\nimport type { Ref, ShallowRef, ComputedRef, MaybeRefOrGetter } from 'vue';\n\nimport { SidekickVueRoom, rooms } from './SidekickVueRoom.js';\nimport { tryOnScopeDispose } from './utils.js';\nimport { useInfiniteQuery } from './useInfiniteQuery.js';\nimport type { InfiniteQueryResult } from './useInfiniteQuery.js';\nimport version from './version.js';\n\n// ------\n// Types\n\nexport type UseQueryReturn<\n Schema extends SidekickSchemaDef<any, any, any>,\n Q extends ValidQuery<Q, Schema>,\n UseDates extends boolean,\n> = {\n isLoading: Ref<boolean>;\n data: ShallowRef<SideQLResponse<Schema, Q, UseDates> | undefined>;\n pageInfo: ShallowRef<PageInfoResponse<Q> | undefined>;\n error: ShallowRef<{ message: string } | undefined>;\n};\n\nexport type UseAuthReturn = {\n isLoading: Ref<boolean>;\n user: ShallowRef<User | null | undefined>;\n error: ShallowRef<{ message: string } | undefined>;\n};\n\nexport class SidekickVueDatabase<\n Schema extends SidekickSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n Rooms extends RoomSchemaShape = RoomsOf<Schema>,\n> implements ISidekickDatabase<Schema>\n{\n public tx = txInit<Schema>();\n\n public auth: Auth;\n public storage: Storage;\n public streams: Streams;\n public core: SidekickCoreDatabase<Schema, UseDates>;\n\n constructor(core: SidekickCoreDatabase<Schema, UseDates>) {\n this.core = core;\n this.auth = this.core.auth;\n this.storage = this.core.storage;\n this.streams = this.core.streams;\n }\n\n /**\n * Returns a unique ID for a given `name`. It's stored in local storage,\n * so you will get the same ID across sessions.\n *\n * @example\n * const deviceId = await db.getLocalId('device');\n */\n getLocalId = (name: string): Promise<string> => {\n return this.core.getLocalId(name);\n };\n\n /**\n * Use this to write data! You can create, update, delete, and link objects\n *\n * @see https://sidekickdb.co/docs/sideml\n *\n * @example\n * const goalId = id();\n * db.transact(db.tx.goals[goalId].update({title: \"Get fit\"}))\n */\n transact = (\n chunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n ) => {\n return this.core.transact(chunks);\n };\n\n /**\n * One time query for the logged in state.\n *\n * @see https://sidekickdb.co/docs/auth\n * @example\n * const user = await db.getAuth();\n * console.log('logged in as', user.email)\n */\n getAuth(): Promise<User | null> {\n return this.core.getAuth();\n }\n\n /**\n * Use this for one-off queries.\n * Returns local data if available, otherwise fetches from the server.\n *\n * @see https://sidekickdb.co/docs/sideql\n *\n * @example\n * const resp = await db.queryOnce({ goals: {} });\n * console.log(resp.data.goals)\n */\n queryOnce = <Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts?: SideQLOptions,\n ): Promise<{\n data: SideQLResponse<Schema, Q, UseDates>;\n pageInfo: PageInfoResponse<Q>;\n }> => {\n return this.core.queryOnce(query, opts);\n };\n\n // -----------\n // Vue reactive hooks\n\n /**\n * Use this to query your data!\n *\n * @see https://sidekickdb.co/docs/sideql\n *\n * @example\n * // basic query — refs auto-unwrap in templates\n * const { isLoading, error, data } = db.useQuery({ goals: {} });\n *\n * @example\n * // reactive query — pass a getter that returns null to skip\n * const { user } = db.useAuth();\n * const { data } = db.useQuery(() =>\n * user.value ? { todos: { $: { where: { 'owner.id': user.value.id } } } } : null,\n * );\n *\n * @example\n * // pass a ref directly\n * const query = ref<{ todos: {} } | null>({ todos: {} });\n * const { data } = db.useQuery(query);\n */\n useQuery = <Q extends ValidQuery<Q, Schema>>(\n query: MaybeRefOrGetter<Q | null>,\n opts?: MaybeRefOrGetter<SideQLOptions | null | undefined>,\n ): UseQueryReturn<Schema, Q, UseDates> => {\n const isLoading = ref(true);\n const data = shallowRef<SideQLResponse<Schema, Q, UseDates> | undefined>(\n undefined,\n );\n const pageInfo = shallowRef<PageInfoResponse<Q> | undefined>(undefined);\n const error = shallowRef<{ message: string } | undefined>(undefined);\n\n const resolvedQuery = computed(() => {\n const q = toValue(query);\n if (!q) return null;\n const o = toValue(opts);\n const withParams =\n o && 'ruleParams' in o\n ? ({ $$ruleParams: (o as any).ruleParams, ...q } as Q)\n : q;\n return coerceQuery(withParams);\n });\n\n const queryHash = computed(() => weakHash(resolvedQuery.value));\n\n const stop = watch(\n queryHash,\n (_, __, onCleanup) => {\n const q = resolvedQuery.value;\n const cached: any = q ? this.core._reactor.getPreviousResult(q) : null;\n isLoading.value = !cached;\n data.value = cached?.data;\n pageInfo.value = cached?.pageInfo;\n error.value = cached?.error;\n\n if (!q) return;\n\n const unsub = this.core.subscribeQuery<Q, UseDates>(q, (r: any) => {\n isLoading.value = false;\n data.value = r.data;\n pageInfo.value = r.pageInfo;\n error.value = r.error;\n });\n onCleanup(unsub);\n },\n { immediate: true },\n );\n\n tryOnScopeDispose(stop);\n\n return { isLoading, data, pageInfo, error } as UseQueryReturn<\n Schema,\n Q,\n UseDates\n >;\n };\n\n /**\n * Subscribe to a query and incrementally load more items.\n *\n * Only one top-level namespace in the query is allowed.\n *\n * @example\n * const { data, isLoading, error, loadNextPage, canLoadNextPage } =\n * db.useInfiniteQuery({\n * posts: { $: { limit: 20, order: { createdAt: 'desc' } } },\n * });\n */\n useInfiniteQuery = <Q extends ValidQuery<Q, Schema>>(\n query: MaybeRefOrGetter<Q | null>,\n opts?: MaybeRefOrGetter<SideQLOptions | undefined>,\n ): InfiniteQueryResult<Schema, Q, UseDates> => {\n return useInfiniteQuery<Schema, Q, UseDates>(this.core, query, opts);\n };\n\n /**\n * Listen for the logged in state. This is useful\n * for deciding when to show a login screen.\n *\n * @see https://sidekickdb.co/docs/auth\n * @example\n * const { isLoading, user, error } = db.useAuth();\n */\n useAuth = (): UseAuthReturn => {\n const cached = this.core._reactor._currentUserCached as\n | AuthState\n | undefined;\n\n const isLoading = ref(cached?.isLoading ?? true);\n const user = shallowRef<User | null | undefined>(cached?.user);\n const error = shallowRef<{ message: string } | undefined>(cached?.error);\n\n const unsub = this.core.subscribeAuth((auth: any) => {\n isLoading.value = false;\n user.value = auth.user ?? null;\n error.value = auth.error;\n });\n\n tryOnScopeDispose(unsub);\n\n return { isLoading, user, error };\n };\n\n /**\n * Subscribe to the currently logged in user. Throws if the user isn't\n * signed in when `.value` is accessed — wrap callers with `<SignedIn>` or\n * a `useAuth` check.\n *\n * @see https://sidekickdb.co/docs/auth\n * @example\n * const user = db.useUser();\n * // user.value.email\n */\n useUser = (): ComputedRef<User> => {\n const { user } = this.useAuth();\n return computed(() => {\n if (!user.value) {\n throw new SidekickError(\n 'useUser must be used within an auth-protected route',\n );\n }\n return user.value;\n });\n };\n\n /**\n * Listen for connection status changes to SidekickDB.\n *\n * @see https://sidekickdb.co/docs/patterns#listen-to-sidekick-db-connection-status\n * @example\n * const status = db.useConnectionStatus();\n * // status.value\n */\n useConnectionStatus = (): Ref<ConnectionStatus> => {\n const status = ref<ConnectionStatus>(\n this.core._reactor.status as ConnectionStatus,\n );\n\n const unsub = this.core.subscribeConnectionStatus((newStatus) => {\n status.value = newStatus;\n });\n\n tryOnScopeDispose(unsub);\n\n return status;\n };\n\n /**\n * A hook that returns a unique ID for a given `name`. localIds are stored in\n * local storage, so you get the same ID across sessions.\n *\n * Returns `null` initially, then the loaded ID.\n *\n * @example\n * const deviceId = db.useLocalId('device');\n * // deviceId.value is null initially, then the ID string\n */\n useLocalId = (name: MaybeRefOrGetter<string>): Ref<string | null> => {\n const localId = ref<string | null>(null);\n\n const stop = watch(\n () => toValue(name),\n (currentName) => {\n this.getLocalId(currentName).then((id) => {\n // Drop a late resolve if `name` has since changed.\n if (toValue(name) === currentName) {\n localId.value = id;\n }\n });\n },\n { immediate: true },\n );\n\n tryOnScopeDispose(stop);\n return localId;\n };\n\n /**\n * Obtain a handle to a room, which allows you to listen to topics and presence data\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n *\n * @example\n * const room = db.room('chat', roomId);\n * const { peers } = db.rooms.usePresence(room);\n */\n room<RoomType extends string & keyof Rooms>(\n type?: MaybeRefOrGetter<RoomType | undefined>,\n id?: MaybeRefOrGetter<string | undefined>,\n ) {\n const _type = computed(\n () => (toValue(type) ?? '_defaultRoomType') as RoomType,\n );\n const _id = computed(() => toValue(id) ?? '_defaultRoomId');\n return new SidekickVueRoom<Schema, Rooms, RoomType>(this.core, _type, _id);\n }\n\n /**\n * Hooks for working with rooms\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n *\n * @example\n * const room = db.room('chat', roomId);\n * const { peers } = db.rooms.usePresence(room);\n * const publish = db.rooms.usePublishTopic(room, 'emoji');\n */\n rooms = rooms;\n}\n\n// -----------\n// init\n\n/**\n * The first step: init your application!\n *\n * Find your `appId` in your SidekickDB dashboard.\n *\n * @example\n * import { init } from \"@sidekickdb/vue\"\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\" })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@sidekickdb/vue\"\n * import schema from \"../sidekick.schema.ts\";\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\", schema })\n */\nexport function init<\n Schema extends SidekickSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n>(\n config: Omit<SidekickConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): SidekickVueDatabase<Schema, UseDates> {\n const coreDb = core_init<Schema, UseDates>(config, undefined, undefined, {\n '@sidekickdb/vue': version,\n });\n return new SidekickVueDatabase<Schema, UseDates>(coreDb);\n}\n"],"names":["core_init"],"mappings":";;;;;;;;;AAwDO,MAAM,oBAKb;AAAA,EAQE,YAAY,MAA8C;AAPnD,8BAAK,OAAe;AAEpB;AACA;AACA;AACA;AAgBP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAa,CAAC,SAAkC;AACvC,aAAA,KAAK,KAAK,WAAW,IAAI;AAAA,IAClC;AAWA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAW,CACT,WACG;AACI,aAAA,KAAK,KAAK,SAAS,MAAM;AAAA,IAClC;AAwBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qCAAY,CACV,OACA,SAII;AACJ,aAAO,KAAK,KAAK,UAAU,OAAO,IAAI;AAAA,IACxC;AA0BA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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,WAAW,EAAE,KAAK,CAAC,OAAO;AAEpC,gBAAA,QAAQ,IAAI,MAAM,aAAa;AACjC,sBAAQ,QAAQ;AAAA,YAAA;AAAA,UAClB,CACD;AAAA,QACH;AAAA,QACA,EAAE,WAAW,KAAK;AAAA,MACpB;AAEA,wBAAkB,IAAI;AACf,aAAA;AAAA,IACT;AAgCA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAQ;AAtSN,SAAK,OAAO;AACP,SAAA,OAAO,KAAK,KAAK;AACjB,SAAA,UAAU,KAAK,KAAK;AACpB,SAAA,UAAU,KAAK,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqC3B,UAAgC;AACvB,WAAA,KAAK,KAAK,QAAQ;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwO3B,KACE,MACA,IACA;AACA,UAAM,QAAQ;AAAA,MACZ,MAAO,QAAQ,IAAI,KAAK;AAAA,IAC1B;AACA,UAAM,MAAM,SAAS,MAAM,QAAQ,EAAE,KAAK,gBAAgB;AAC1D,WAAO,IAAI,gBAAyC,KAAK,MAAM,OAAO,GAAG;AAAA,EAAA;AAc7E;AAsBO,SAAS,KAId,QAGuC;AACvC,QAAM,SAASA,OAA4B,QAAQ,QAAW,QAAW;AAAA,IACvE,mBAAmB;AAAA,EAAA,CACpB;AACM,SAAA,IAAI,oBAAsC,MAAM;AACzD;"}
@@ -1,4 +1,4 @@
1
- import { type PresenceOpts, type PresenceResponse, type RoomSchemaShape, InstantCoreDatabase, InstantSchemaDef } from '@sidekickdb/core';
1
+ import { type PresenceOpts, type PresenceResponse, type RoomSchemaShape, SidekickCoreDatabase, SidekickSchemaDef } from '@sidekickdb/core';
2
2
  import type { Ref, ShallowRef, MaybeRefOrGetter, ComputedRef } from 'vue';
3
3
  export type PresenceHandle<PresenceShape, Keys extends keyof PresenceShape> = {
4
4
  [K in keyof PresenceResponse<PresenceShape, Keys>]: ShallowRef<PresenceResponse<PresenceShape, Keys>[K]>;
@@ -35,7 +35,7 @@ export declare const defaultActivityStopTimeout = 1000;
35
35
  * console.log(peer.name, 'sent', message);
36
36
  * });
37
37
  */
38
- export declare function useTopicEffect<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema, TopicType extends keyof RoomSchema[RoomType]['topics']>(room: InstantVueRoom<any, RoomSchema, RoomType>, topic: TopicType, onEvent: (event: RoomSchema[RoomType]['topics'][TopicType], peer: RoomSchema[RoomType]['presence']) => any): void;
38
+ export declare function useTopicEffect<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema, TopicType extends keyof RoomSchema[RoomType]['topics']>(room: SidekickVueRoom<any, RoomSchema, RoomType>, topic: TopicType, onEvent: (event: RoomSchema[RoomType]['topics'][TopicType], peer: RoomSchema[RoomType]['presence']) => any): void;
39
39
  /**
40
40
  * Broadcast an event to a room.
41
41
  *
@@ -45,7 +45,7 @@ export declare function useTopicEffect<RoomSchema extends RoomSchemaShape, RoomT
45
45
  * const publishTopic = db.rooms.usePublishTopic(room, 'emoji');
46
46
  * publishTopic({ emoji: "🔥" });
47
47
  */
48
- export declare function usePublishTopic<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema, TopicType extends keyof RoomSchema[RoomType]['topics']>(room: InstantVueRoom<any, RoomSchema, RoomType>, topic: TopicType): (data: RoomSchema[RoomType]['topics'][TopicType]) => void;
48
+ export declare function usePublishTopic<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema, TopicType extends keyof RoomSchema[RoomType]['topics']>(room: SidekickVueRoom<any, RoomSchema, RoomType>, topic: TopicType): (data: RoomSchema[RoomType]['topics'][TopicType]) => void;
49
49
  /**
50
50
  * Listen for peer's presence data in a room, and publish the current user's presence.
51
51
  *
@@ -54,7 +54,7 @@ export declare function usePublishTopic<RoomSchema extends RoomSchemaShape, Room
54
54
  * const room = db.room('chat', roomId);
55
55
  * const { peers, isLoading, publishPresence } = db.rooms.usePresence(room, { keys: ["name", "avatar"] });
56
56
  */
57
- export declare function usePresence<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema, Keys extends keyof RoomSchema[RoomType]['presence']>(room: InstantVueRoom<any, RoomSchema, RoomType>, opts?: PresenceOpts<RoomSchema[RoomType]['presence'], Keys>): PresenceHandle<RoomSchema[RoomType]['presence'], Keys>;
57
+ export declare function usePresence<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema, Keys extends keyof RoomSchema[RoomType]['presence']>(room: SidekickVueRoom<any, RoomSchema, RoomType>, opts?: PresenceOpts<RoomSchema[RoomType]['presence'], Keys>): PresenceHandle<RoomSchema[RoomType]['presence'], Keys>;
58
58
  /**
59
59
  * Publishes presence data to a room
60
60
  *
@@ -63,7 +63,7 @@ export declare function usePresence<RoomSchema extends RoomSchemaShape, RoomType
63
63
  * const room = db.room('chat', roomId);
64
64
  * db.rooms.useSyncPresence(room, { nickname });
65
65
  */
66
- export declare function useSyncPresence<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema>(room: InstantVueRoom<any, RoomSchema, RoomType>, data: MaybeRefOrGetter<Partial<RoomSchema[RoomType]['presence']>>): void;
66
+ export declare function useSyncPresence<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema>(room: SidekickVueRoom<any, RoomSchema, RoomType>, data: MaybeRefOrGetter<Partial<RoomSchema[RoomType]['presence']>>): void;
67
67
  /**
68
68
  * Manage typing indicator state
69
69
  *
@@ -73,7 +73,7 @@ export declare function useSyncPresence<RoomSchema extends RoomSchemaShape, Room
73
73
  * const typing = db.rooms.useTypingIndicator(room, 'chat-input');
74
74
  * // typing.active.value, typing.setActive(bool), typing.inputProps
75
75
  */
76
- export declare function useTypingIndicator<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema>(room: InstantVueRoom<any, RoomSchema, RoomType>, inputName: string, opts?: TypingIndicatorOpts): TypingIndicatorHandle<RoomSchema[RoomType]['presence']>;
76
+ export declare function useTypingIndicator<RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema>(room: SidekickVueRoom<any, RoomSchema, RoomType>, inputName: string, opts?: TypingIndicatorOpts): TypingIndicatorHandle<RoomSchema[RoomType]['presence']>;
77
77
  export declare const rooms: {
78
78
  useTopicEffect: typeof useTopicEffect;
79
79
  usePublishTopic: typeof usePublishTopic;
@@ -81,10 +81,10 @@ export declare const rooms: {
81
81
  useSyncPresence: typeof useSyncPresence;
82
82
  useTypingIndicator: typeof useTypingIndicator;
83
83
  };
84
- export declare class InstantVueRoom<Schema extends InstantSchemaDef<any, any, any>, RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema> {
85
- core: InstantCoreDatabase<Schema, boolean>;
84
+ export declare class SidekickVueRoom<Schema extends SidekickSchemaDef<any, any, any>, RoomSchema extends RoomSchemaShape, RoomType extends keyof RoomSchema> {
85
+ core: SidekickCoreDatabase<Schema, boolean>;
86
86
  type: ComputedRef<RoomType> | RoomType;
87
87
  id: ComputedRef<string> | string;
88
- constructor(core: InstantCoreDatabase<Schema, boolean>, type: ComputedRef<RoomType> | RoomType, id: ComputedRef<string> | string);
88
+ constructor(core: SidekickCoreDatabase<Schema, boolean>, type: ComputedRef<RoomType> | RoomType, id: ComputedRef<string> | string);
89
89
  }
90
- //# sourceMappingURL=InstantVueRoom.d.ts.map
90
+ //# sourceMappingURL=SidekickVueRoom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidekickVueRoom.d.ts","sourceRoot":"","sources":["../src/SidekickVueRoom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAO1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,UAAU,EAAE,QAAQ,CAAC,EAChD,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,mBAAwB,GAC7B,qBAAqB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,CAqEzD;AAKD,eAAO,MAAM,KAAK;;;;;;CAMjB,CAAC;AAKF,qBAAa,eAAe,CAC1B,MAAM,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC/C,UAAU,SAAS,eAAe,EAClC,QAAQ,SAAS,MAAM,UAAU;IAEjC,IAAI,EAAE,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACvC,EAAE,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;gBAG/B,IAAI,EAAE,oBAAoB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3C,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,QAAQ,EACtC,EAAE,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM;CAMnC"}
@@ -157,7 +157,7 @@ const rooms = {
157
157
  useSyncPresence,
158
158
  useTypingIndicator
159
159
  };
160
- class InstantVueRoom {
160
+ class SidekickVueRoom {
161
161
  constructor(core, type, id) {
162
162
  __publicField(this, "core");
163
163
  __publicField(this, "type");
@@ -168,7 +168,7 @@ class InstantVueRoom {
168
168
  }
169
169
  }
170
170
  export {
171
- InstantVueRoom,
171
+ SidekickVueRoom,
172
172
  defaultActivityStopTimeout,
173
173
  rooms,
174
174
  usePresence,
@@ -177,4 +177,4 @@ export {
177
177
  useTopicEffect,
178
178
  useTypingIndicator
179
179
  };
180
- //# sourceMappingURL=InstantVueRoom.js.map
180
+ //# sourceMappingURL=SidekickVueRoom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidekickVueRoom.js","sources":["../src/SidekickVueRoom.ts"],"sourcesContent":["import {\n type PresenceOpts,\n type PresenceResponse,\n type RoomSchemaShape,\n SidekickCoreDatabase,\n SidekickSchemaDef,\n} from '@sidekickdb/core';\n\nimport { shallowRef, watchEffect, toValue } from 'vue';\nimport type { Ref, ShallowRef, MaybeRefOrGetter, ComputedRef } from 'vue';\n\nimport { tryOnScopeDispose } from './utils.js';\n\n// ------\n// Types\n\nexport type PresenceHandle<PresenceShape, Keys extends keyof PresenceShape> = {\n [K in keyof PresenceResponse<PresenceShape, Keys>]: ShallowRef<\n PresenceResponse<PresenceShape, Keys>[K]\n >;\n} & {\n publishPresence: (data: Partial<PresenceShape>) => void;\n};\n\nexport type TypingIndicatorOpts = {\n timeout?: number | null;\n stopOnEnter?: boolean;\n // Perf opt - `active` will always be an empty array\n writeOnly?: boolean;\n};\n\nexport type TypingIndicatorHandle<PresenceShape> = {\n active: Ref<PresenceShape[]>;\n setActive(active: boolean): void;\n /**\n * Listener keys are lowercased (`onKeydown`, not `onKeyDown`) so that\n * Vue's `v-bind` spread hyphenates them correctly to native DOM events\n * (`keydown`). With camelCase Vue would emit a non-existent `key-down`\n * listener and the indicator would never fire.\n */\n inputProps: {\n onKeydown: (e: KeyboardEvent) => void;\n onBlur: () => void;\n };\n};\n\nexport const defaultActivityStopTimeout = 1_000;\n\n// ------\n// Topics\n\n/**\n * Listen for broadcasted events given a room and topic.\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n * @example\n * const room = db.room('chats', roomId);\n * db.rooms.useTopicEffect(room, 'emoji', (message, peer) => {\n * console.log(peer.name, 'sent', message);\n * });\n */\nexport function useTopicEffect<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n TopicType extends keyof RoomSchema[RoomType]['topics'],\n>(\n room: SidekickVueRoom<any, RoomSchema, RoomType>,\n topic: TopicType,\n onEvent: (\n event: RoomSchema[RoomType]['topics'][TopicType],\n peer: RoomSchema[RoomType]['presence'],\n ) => any,\n): void {\n watchEffect((onCleanup) => {\n const type = toValue(room.type);\n const id = toValue(room.id);\n const unsub = room.core._reactor.subscribeTopic(\n type,\n id,\n topic,\n (event: any, peer: any) => {\n onEvent(event, peer);\n },\n );\n onCleanup(unsub);\n });\n}\n\n/**\n * Broadcast an event to a room.\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n * @example\n * const room = db.room('chat', roomId);\n * const publishTopic = db.rooms.usePublishTopic(room, 'emoji');\n * publishTopic({ emoji: \"🔥\" });\n */\nexport function usePublishTopic<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n TopicType extends keyof RoomSchema[RoomType]['topics'],\n>(\n room: SidekickVueRoom<any, RoomSchema, RoomType>,\n topic: TopicType,\n): (data: RoomSchema[RoomType]['topics'][TopicType]) => void {\n watchEffect((onCleanup) => {\n const type = toValue(room.type) as string;\n const id = toValue(room.id);\n const unsub = room.core._reactor.joinRoom(type, id);\n onCleanup(unsub);\n });\n\n return (data: RoomSchema[RoomType]['topics'][TopicType]) => {\n room.core._reactor.publishTopic({\n roomType: toValue(room.type),\n roomId: toValue(room.id),\n topic,\n data,\n });\n };\n}\n\n// ---------\n// Presence\n\n/**\n * Listen for peer's presence data in a room, and publish the current user's presence.\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n * @example\n * const room = db.room('chat', roomId);\n * const { peers, isLoading, publishPresence } = db.rooms.usePresence(room, { keys: [\"name\", \"avatar\"] });\n */\nexport function usePresence<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n Keys extends keyof RoomSchema[RoomType]['presence'],\n>(\n room: SidekickVueRoom<any, RoomSchema, RoomType>,\n opts: PresenceOpts<RoomSchema[RoomType]['presence'], Keys> = {},\n): PresenceHandle<RoomSchema[RoomType]['presence'], Keys> {\n const initial = (room.core._reactor.getPresence(\n toValue(room.type),\n toValue(room.id),\n opts,\n ) ?? {\n peers: {},\n isLoading: true,\n }) as PresenceResponse<RoomSchema[RoomType]['presence'], Keys>;\n\n const peers = shallowRef(initial.peers);\n const isLoading = shallowRef(initial.isLoading);\n const user = shallowRef<any>((initial as any).user);\n const error = shallowRef<any>((initial as any).error);\n\n watchEffect((onCleanup) => {\n const type = toValue(room.type);\n const id = toValue(room.id);\n const unsub = room.core._reactor.subscribePresence(\n type,\n id,\n opts,\n (data: any) => {\n peers.value = data.peers;\n isLoading.value = data.isLoading;\n if ('user' in data) user.value = data.user;\n if ('error' in data) error.value = data.error;\n },\n );\n onCleanup(unsub);\n });\n\n return {\n peers,\n isLoading,\n user,\n error,\n publishPresence: (data: Partial<RoomSchema[RoomType]['presence']>) => {\n room.core._reactor.publishPresence(\n toValue(room.type),\n toValue(room.id),\n data,\n );\n },\n } as PresenceHandle<RoomSchema[RoomType]['presence'], Keys>;\n}\n\n/**\n * Publishes presence data to a room\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n * @example\n * const room = db.room('chat', roomId);\n * db.rooms.useSyncPresence(room, { nickname });\n */\nexport function useSyncPresence<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n>(\n room: SidekickVueRoom<any, RoomSchema, RoomType>,\n data: MaybeRefOrGetter<Partial<RoomSchema[RoomType]['presence']>>,\n): void {\n watchEffect((onCleanup) => {\n const type = toValue(room.type) as string;\n const id = toValue(room.id);\n const unsub = room.core._reactor.joinRoom(type, id, toValue(data));\n onCleanup(unsub);\n });\n\n watchEffect(() => {\n room.core._reactor.publishPresence(\n toValue(room.type),\n toValue(room.id),\n toValue(data),\n );\n });\n}\n\n// -----------------\n// Typing Indicator\n\n/**\n * Manage typing indicator state\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n * @example\n * const room = db.room('chat', roomId);\n * const typing = db.rooms.useTypingIndicator(room, 'chat-input');\n * // typing.active.value, typing.setActive(bool), typing.inputProps\n */\nexport function useTypingIndicator<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n>(\n room: SidekickVueRoom<any, RoomSchema, RoomType>,\n inputName: string,\n opts: TypingIndicatorOpts = {},\n): TypingIndicatorHandle<RoomSchema[RoomType]['presence']> {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const presence = usePresence(room, {\n keys: [inputName] as (keyof RoomSchema[RoomType]['presence'])[],\n });\n\n const active = shallowRef<RoomSchema[RoomType]['presence'][]>([]);\n\n watchEffect(() => {\n if (opts?.writeOnly) {\n active.value = [];\n return;\n }\n // Track peers so we re-run when presence updates\n presence.peers.value;\n const snapshot = room.core._reactor.getPresence(\n toValue(room.type),\n toValue(room.id),\n );\n active.value = Object.values(snapshot?.peers ?? {}).filter(\n (p: any) => p[inputName] === true,\n );\n });\n\n const setActive = (isActive: boolean) => {\n room.core._reactor.publishPresence(toValue(room.type), toValue(room.id), {\n [inputName]: isActive ? true : null,\n } as Partial<RoomSchema[RoomType]['presence']>);\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n\n if (!isActive) return;\n if (opts?.timeout === null || opts?.timeout === 0) return;\n\n timeoutId = setTimeout(() => {\n room.core._reactor.publishPresence(toValue(room.type), toValue(room.id), {\n [inputName]: null,\n } as Partial<RoomSchema[RoomType]['presence']>);\n }, opts?.timeout ?? defaultActivityStopTimeout);\n };\n\n tryOnScopeDispose(() => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n // Clear sticky typing state on unmount, even when timeout is disabled.\n setActive(false);\n });\n\n const onKeydown = (e: KeyboardEvent) => {\n const isEnter = opts?.stopOnEnter && e.key === 'Enter';\n const isActive = !isEnter;\n setActive(isActive);\n };\n\n const onBlur = () => {\n setActive(false);\n };\n\n return {\n active,\n setActive,\n inputProps: { onKeydown, onBlur },\n };\n}\n\n// --------------\n// Hooks namespace\n\nexport const rooms = {\n useTopicEffect,\n usePublishTopic,\n usePresence,\n useSyncPresence,\n useTypingIndicator,\n};\n\n// ------------\n// Class\n\nexport class SidekickVueRoom<\n Schema extends SidekickSchemaDef<any, any, any>,\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n> {\n core: SidekickCoreDatabase<Schema, boolean>;\n type: ComputedRef<RoomType> | RoomType;\n id: ComputedRef<string> | string;\n\n constructor(\n core: SidekickCoreDatabase<Schema, boolean>,\n type: ComputedRef<RoomType> | RoomType,\n id: ComputedRef<string> | string,\n ) {\n this.core = core;\n this.type = type;\n this.id = id;\n }\n}\n"],"names":[],"mappings":";;;;;AA8CO,MAAM,6BAA6B;AAe1B,SAAA,eAKd,MACA,OACA,SAIM;AACN,cAAY,CAAC,cAAc;AACnB,UAAA,OAAO,QAAQ,KAAK,IAAI;AACxB,UAAA,KAAK,QAAQ,KAAK,EAAE;AACpB,UAAA,QAAQ,KAAK,KAAK,SAAS;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA,CAAC,OAAY,SAAc;AACzB,gBAAQ,OAAO,IAAI;AAAA,MAAA;AAAA,IAEvB;AACA,cAAU,KAAK;AAAA,EAAA,CAChB;AACH;AAWgB,SAAA,gBAKd,MACA,OAC2D;AAC3D,cAAY,CAAC,cAAc;AACnB,UAAA,OAAO,QAAQ,KAAK,IAAI;AACxB,UAAA,KAAK,QAAQ,KAAK,EAAE;AAC1B,UAAM,QAAQ,KAAK,KAAK,SAAS,SAAS,MAAM,EAAE;AAClD,cAAU,KAAK;AAAA,EAAA,CAChB;AAED,SAAO,CAAC,SAAoD;AACrD,SAAA,KAAK,SAAS,aAAa;AAAA,MAC9B,UAAU,QAAQ,KAAK,IAAI;AAAA,MAC3B,QAAQ,QAAQ,KAAK,EAAE;AAAA,MACvB;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EACH;AACF;AAaO,SAAS,YAKd,MACA,OAA6D,IACL;AAClD,QAAA,UAAW,KAAK,KAAK,SAAS;AAAA,IAClC,QAAQ,KAAK,IAAI;AAAA,IACjB,QAAQ,KAAK,EAAE;AAAA,IACf;AAAA,EAAA,KACG;AAAA,IACH,OAAO,CAAC;AAAA,IACR,WAAW;AAAA,EACb;AAEM,QAAA,QAAQ,WAAW,QAAQ,KA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cAAU,KAAK;AAAA,EACjB;AAEO,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA,YAAY,EAAE,WAAW,OAAO;AAAA,EAClC;AACF;AAKO,MAAM,QAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,MAAM,gBAIX;AAAA,EAKA,YACE,MACA,MACA,IACA;AARF;AACA;AACA;AAOE,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,KAAK;AAAA,EAAA;AAEd;"}
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, computed, toValue, createBlock, openBlock, resolveDynamicComponent, withCtx, renderSlot, createElementVNode, normalizeStyle, createElementBlock, Fragment, renderList, createVNode } from "vue";
2
- import { usePresence } from "../InstantVueRoom.js";
2
+ import { usePresence } from "../SidekickVueRoom.js";
3
3
  import { _ as _sfc_main$1 } from "./Cursor.vue_vue_type_script_setup_true_lang-DeM0moKd.js";
4
4
  const _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  __name: "Cursors",
@@ -125,4 +125,4 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
125
125
  export {
126
126
  _sfc_main as _
127
127
  };
128
- //# sourceMappingURL=Cursors.vue_vue_type_script_setup_true_lang-C6eE1KRI.js.map
128
+ //# sourceMappingURL=Cursors.vue_vue_type_script_setup_true_lang-BIVjDXb4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Cursors.vue_vue_type_script_setup_true_lang-BIVjDXb4.js","sources":["../../src/components/Cursors.vue"],"sourcesContent":["<script\n setup\n lang=\"ts\"\n generic=\"RoomSchema extends RoomSchemaShape, RoomType extends string & keyof RoomSchema\"\n>\nimport { computed, toValue } from 'vue';\nimport type { RoomSchemaShape } from '@sidekickdb/core';\nimport { usePresence } from '../SidekickVueRoom.js';\nimport type { SidekickVueRoom } from '../SidekickVueRoom.js';\nimport Cursor from './Cursor.vue';\n\ntype CursorPresence = {\n x: number;\n y: number;\n xPercent: number;\n yPercent: number;\n color?: string;\n};\n\nconst props = withDefaults(\n defineProps<{\n room: SidekickVueRoom<any, RoomSchema, RoomType>;\n spaceId?: string;\n as?: string;\n userCursorColor?: string;\n propagate?: boolean;\n zIndex?: number;\n }>(),\n {\n as: 'div',\n propagate: false,\n zIndex: 99999,\n },\n);\n\nconst spaceId = computed(\n () =>\n props.spaceId ||\n `cursors-space-default--${String(toValue(props.room.type))}-${toValue(props.room.id)}`,\n);\n\nconst { peers, publishPresence } = usePresence(props.room, {\n keys: [spaceId.value] as (keyof RoomSchema[RoomType]['presence'])[],\n});\n\nconst fullPresence = computed(() => {\n // Track peers so the snapshot refreshes when presence changes.\n peers.value;\n return props.room.core._reactor.getPresence(\n toValue(props.room.type),\n toValue(props.room.id),\n );\n});\n\nconst cursorPeers = computed(() => {\n const sid = spaceId.value;\n return Object.entries(peers.value || {}).flatMap(([peerId, p]) => {\n const cursor = (p as any)?.[sid] as CursorPresence | undefined;\n return cursor ? [{ peerId, cursor }] : [];\n });\n});\n\nfunction publishCursor(\n rect: DOMRect,\n touch: { clientX: number; clientY: number },\n) {\n const x = touch.clientX;\n const y = touch.clientY;\n const xPercent = ((x - rect.left) / rect.width) * 100;\n const yPercent = ((y - rect.top) / rect.height) * 100;\n publishPresence({\n [spaceId.value]: {\n x,\n y,\n xPercent,\n yPercent,\n color: props.userCursorColor,\n },\n } as RoomSchema[RoomType]['presence']);\n}\n\nfunction onMouseMove(e: MouseEvent) {\n if (!props.propagate) e.stopPropagation();\n const rect = (e.currentTarget as Element).getBoundingClientRect();\n publishCursor(rect, e);\n}\n\nfunction clearCursor() {\n publishPresence({\n [spaceId.value]: undefined,\n } as RoomSchema[RoomType]['presence']);\n}\n\nfunction onTouchMove(e: TouchEvent) {\n if (e.touches.length !== 1) return;\n const touch = e.touches[0];\n if (!touch || !(touch.target instanceof Element)) return;\n if (!props.propagate) e.stopPropagation();\n const rect = touch.target.getBoundingClientRect();\n publishCursor(rect, touch);\n}\n</script>\n\n<template>\n <component\n :is=\"as\"\n :style=\"{ position: 'relative' }\"\n @mousemove=\"onMouseMove\"\n @mouseout=\"clearCursor\"\n @blur=\"clearCursor\"\n @touchmove=\"onTouchMove\"\n @touchend=\"clearCursor\"\n >\n <slot />\n <div\n :style=\"{\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n right: 0,\n overflow: 'hidden',\n pointerEvents: 'none',\n userSelect: 'none',\n zIndex,\n }\"\n >\n <div\n v-for=\"{ peerId, cursor } in cursorPeers\"\n :key=\"peerId\"\n :style=\"{\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n right: 0,\n transform: `translate(${cursor.xPercent}%, ${cursor.yPercent}%)`,\n transformOrigin: '0 0',\n transition: 'transform 100ms',\n }\"\n >\n <slot\n name=\"cursor\"\n :color=\"cursor.color\"\n :presence=\"fullPresence?.peers[peerId]\"\n >\n <Cursor :color=\"cursor.color ?? ''\" />\n </slot>\n </div>\n </div>\n </component>\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAmBA,UAAM,QAAQ;AAgBd,UAAM,UAAU;AAAA,MACd,MACE,MAAM,WACN,0BAA0B,OAAO,QAAQ,MAAM,KAAK,IAAI,CAAC,CAAC,IAAI,QAAQ,MAAM,KAAK,EAAE,CAAC;AAAA,IACxF;AAEA,UAAM,EAAE,OAAO,gBAAA,IAAoB,YAAY,MAAM,MAAM;AAAA,MACzD,MAAM,CAAC,QAAQ,KAAK;AAAA,IAAA,CACrB;AAEK,UAAA,eAAe,SAAS,MAAM;AAE5B,YAAA;AACC,aAAA,MAAM,KAAK,KAAK,SAAS;AAAA,QAC9B,QAAQ,MAAM,KAAK,IAAI;AAAA,QACvB,QAAQ,MAAM,KAAK,EAAE;AAAA,MACvB;AAAA,IAAA,CACD;AAEK,UAAA,cAAc,SAAS,MAAM;AACjC,YAAM,MAAM,QAAQ;AACpB,aAAO,OAAO,QAAQ,MAAM,SAAS,CAAA,CAAE,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM;AAC1D,cAAA,SAAU,uBAAY;AAC5B,eAAO,SAAS,CAAC,EAAE,QAAQ,OAAO,CAAC,IAAI,CAAC;AAAA,MAAA,CACzC;AAAA,IAAA,CACF;AAEQ,aAAA,cACP,MACA,OACA;AACA,YAAM,IAAI,MAAM;AAChB,YAAM,IAAI,MAAM;AAChB,YAAM,YAAa,IAAI,KAAK,QAAQ,KAAK,QAAS;AAClD,YAAM,YAAa,IAAI,KAAK,OAAO,KAAK,SAAU;AAClC,sBAAA;AAAA,QACd,CAAC,QAAQ,KAAK,GAAG;AAAA,UACf;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,OAAO,MAAM;AAAA,QAAA;AAAA,MACf,CACmC;AAAA,IAAA;AAGvC,aAAS,YAAY,GAAe;AAClC,UAAI,CAAC,MAAM,UAAW,GAAE,gBAAgB;AAClC,YAAA,OAAQ,EAAE,cAA0B,sBAAsB;AAChE,oBAAc,MAAM,CAAC;AAAA,IAAA;AAGvB,aAAS,cAAc;AACL,sBAAA;AAAA,QACd,CAAC,QAAQ,KAAK,GAAG;AAAA,MAAA,CACkB;AAAA,IAAA;AAGvC,aAAS,YAAY,GAAe;AAC9B,UAAA,EAAE,QAAQ,WAAW,EAAG;AACtB,YAAA,QAAQ,EAAE,QAAQ,CAAC;AACzB,UAAI,CAAC,SAAS,EAAE,MAAM,kBAAkB,SAAU;AAClD,UAAI,CAAC,MAAM,UAAW,GAAE,gBAAgB;AAClC,YAAA,OAAO,MAAM,OAAO,sBAAsB;AAChD,oBAAc,MAAM,KAAK;AAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SignedIn.vue_vue_type_script_setup_true_lang-MJrQPE2B.js","sources":["../../src/components/SignedIn.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { InstantSchemaDef } from '@sidekickdb/core';\nimport type { InstantVueDatabase } from '../InstantVueDatabase.js';\n\nconst props = defineProps<{\n db: InstantVueDatabase<InstantSchemaDef<any, any, any>, boolean>;\n}>();\n\nconst { isLoading, error, user } = props.db.useAuth();\n</script>\n\n<template>\n <slot v-if=\"!isLoading && !error && user\" />\n</template>\n"],"names":[],"mappings":";;;;;;;AAIA,UAAM,QAAQ;AAId,UAAM,EAAE,WAAW,OAAO,KAAS,IAAA,MAAM,GAAG,QAAQ;;;;;;"}
1
+ {"version":3,"file":"SignedIn.vue_vue_type_script_setup_true_lang-MJrQPE2B.js","sources":["../../src/components/SignedIn.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { SidekickSchemaDef } from '@sidekickdb/core';\nimport type { SidekickVueDatabase } from '../SidekickVueDatabase.js';\n\nconst props = defineProps<{\n db: SidekickVueDatabase<SidekickSchemaDef<any, any, any>, boolean>;\n}>();\n\nconst { isLoading, error, user } = props.db.useAuth();\n</script>\n\n<template>\n <slot v-if=\"!isLoading && !error && user\" />\n</template>\n"],"names":[],"mappings":";;;;;;;AAIA,UAAM,QAAQ;AAId,UAAM,EAAE,WAAW,OAAO,KAAS,IAAA,MAAM,GAAG,QAAQ;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SignedOut.vue_vue_type_script_setup_true_lang-CcoDHmXu.js","sources":["../../src/components/SignedOut.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { InstantSchemaDef } from '@sidekickdb/core';\nimport type { InstantVueDatabase } from '../InstantVueDatabase.js';\n\nconst props = defineProps<{\n db: InstantVueDatabase<InstantSchemaDef<any, any, any>, boolean>;\n}>();\n\nconst { isLoading, error, user } = props.db.useAuth();\n</script>\n\n<template>\n <slot v-if=\"!isLoading && !error && !user\" />\n</template>\n"],"names":[],"mappings":";;;;;;;AAIA,UAAM,QAAQ;AAId,UAAM,EAAE,WAAW,OAAO,KAAS,IAAA,MAAM,GAAG,QAAQ;;;;;;"}
1
+ {"version":3,"file":"SignedOut.vue_vue_type_script_setup_true_lang-CcoDHmXu.js","sources":["../../src/components/SignedOut.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { SidekickSchemaDef } from '@sidekickdb/core';\nimport type { SidekickVueDatabase } from '../SidekickVueDatabase.js';\n\nconst props = defineProps<{\n db: SidekickVueDatabase<SidekickSchemaDef<any, any, any>, boolean>;\n}>();\n\nconst { isLoading, error, user } = props.db.useAuth();\n</script>\n\n<template>\n <slot v-if=\"!isLoading && !error && !user\" />\n</template>\n"],"names":[],"mappings":";;;;;;;AAIA,UAAM,QAAQ;AAId,UAAM,EAAE,WAAW,OAAO,KAAS,IAAA,MAAM,GAAG,QAAQ;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/Cursors.vue_vue_type_script_setup_true_lang-C6eE1KRI.js";
1
+ import { _ as _sfc_main } from "../chunks/Cursors.vue_vue_type_script_setup_true_lang-BIVjDXb4.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -1,8 +1,8 @@
1
1
  import type { RoomSchemaShape } from '@sidekickdb/core';
2
- import type { InstantVueRoom } from '../InstantVueRoom.js';
2
+ import type { SidekickVueRoom } from '../SidekickVueRoom.js';
3
3
  declare const _default: <RoomSchema extends RoomSchemaShape, RoomType extends string & keyof RoomSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
4
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & {
5
- room: InstantVueRoom<any, RoomSchema, RoomType>;
5
+ room: SidekickVueRoom<any, RoomSchema, RoomType>;
6
6
  spaceId?: string;
7
7
  as?: string;
8
8
  userCursorColor?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Cursors.vue.d.ts","sourceRoot":"","sources":["../../src/components/Cursors.vue"],"names":[],"mappings":"AA2JA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;yBAG1C,UAAU,SAAS,eAAe,EAAE,QAAQ,SAAS,MAAM,GAAG,MAAM,UAAU,EAC9F,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,eAAe,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EACjE;WAyNO,mBAAmB,CAAC;cA/MlB,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC;kBACrC,MAAM;aACX,MAAM;0BACO,MAAM;oBACZ,OAAO;iBACV,MAAM;QA0M8C,OAAO,IAAsB,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;kBA9BG,CAAC,KAAK,IAAiB,KAAK,GAAG;;iBAChC,CAAC,KAAK;;;;;SAAiB,KAAK,GAAG;;UA+BrC,EAAE;EAEL,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AApOzE,wBAoO4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"Cursors.vue.d.ts","sourceRoot":"","sources":["../../src/components/Cursors.vue"],"names":[],"mappings":"AA2JA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;yBAG5C,UAAU,SAAS,eAAe,EAAE,QAAQ,SAAS,MAAM,GAAG,MAAM,UAAU,EAC9F,aAAa,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,EAC9D,YAAY,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,EAC3G,eAAe,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EACjE;WAyNO,mBAAmB,CAAC;cA/MlB,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC;kBACtC,MAAM;aACX,MAAM;0BACO,MAAM;oBACZ,OAAO;iBACV,MAAM;QA0M8C,OAAO,IAAsB,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;kBA9BG,CAAC,KAAK,IAAiB,KAAK,GAAG;;iBAChC,CAAC,KAAK;;;;;SAAiB,KAAK,GAAG;;UA+BrC,EAAE;EAEL,KACQ,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AApOzE,wBAoO4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -1,7 +1,7 @@
1
- import type { InstantSchemaDef } from '@sidekickdb/core';
2
- import type { InstantVueDatabase } from '../InstantVueDatabase.js';
1
+ import type { SidekickSchemaDef } from '@sidekickdb/core';
2
+ import type { SidekickVueDatabase } from '../SidekickVueDatabase.js';
3
3
  type __VLS_Props = {
4
- db: InstantVueDatabase<InstantSchemaDef<any, any, any>, boolean>;
4
+ db: SidekickVueDatabase<SidekickSchemaDef<any, any, any>, boolean>;
5
5
  };
6
6
  declare var __VLS_1: {};
7
7
  type __VLS_Slots = {} & {
@@ -1 +1 @@
1
- {"version":3,"file":"SignedIn.vue.d.ts","sourceRoot":"","sources":["../../src/components/SignedIn.vue"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;CAClE,CAAC;AAkBF,QAAA,IAAI,OAAO,IAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAqB/C,QAAA,MAAM,eAAe,kSAMnB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"SignedIn.vue.d.ts","sourceRoot":"","sources":["../../src/components/SignedIn.vue"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;CACpE,CAAC;AAkBF,QAAA,IAAI,OAAO,IAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAqB/C,QAAA,MAAM,eAAe,kSAMnB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
@@ -1,7 +1,7 @@
1
- import type { InstantSchemaDef } from '@sidekickdb/core';
2
- import type { InstantVueDatabase } from '../InstantVueDatabase.js';
1
+ import type { SidekickSchemaDef } from '@sidekickdb/core';
2
+ import type { SidekickVueDatabase } from '../SidekickVueDatabase.js';
3
3
  type __VLS_Props = {
4
- db: InstantVueDatabase<InstantSchemaDef<any, any, any>, boolean>;
4
+ db: SidekickVueDatabase<SidekickSchemaDef<any, any, any>, boolean>;
5
5
  };
6
6
  declare var __VLS_1: {};
7
7
  type __VLS_Slots = {} & {
@@ -1 +1 @@
1
- {"version":3,"file":"SignedOut.vue.d.ts","sourceRoot":"","sources":["../../src/components/SignedOut.vue"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;CAClE,CAAC;AAkBF,QAAA,IAAI,OAAO,IAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAqB/C,QAAA,MAAM,eAAe,kSAMnB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"SignedOut.vue.d.ts","sourceRoot":"","sources":["../../src/components/SignedOut.vue"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;CACpE,CAAC;AAkBF,QAAA,IAAI,OAAO,IAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAqB/C,QAAA,MAAM,eAAe,kSAMnB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAQ1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { id, tx, lookup, i, InstantAPIError, SyncTableCallbackEventType, type QueryResponse, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantObject, type InstantEntity, type InstantSchemaDatabase, type InstantUnknownSchemaDef, type IInstantDatabase, type User, type AuthState, type Query, type Config, type InstaQLParams, type ConnectionStatus, type ValidQuery, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type InstantConfig, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type ValueTypes, type InstaQLEntity, type InstaQLFields, type InstaQLResult, type InstaQLEntitySubquery, type RoomsOf, type RoomsDef, type PresenceOf, type TopicsOf, type TopicOf, type RoomHandle, type TransactionChunk, type InstantUnknownSchema, type InstantSchemaDef, type BackwardsCompatibleSchema, type InstantRules, type UpdateParams, type LinkParams, type CreateParams, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, StoreInterface, createInstantRouteHandler, type InstantRouteHandlerPayloadByType, type InstantRouteHandlerType, type InstantRouteHandlerBody, type StoreInterfaceStoreName, type Logger } from '@sidekickdb/core';
2
- import { InstantVueDatabase, init } from './InstantVueDatabase.js';
3
- import { InstantVueRoom } from './InstantVueRoom.js';
1
+ import { id, tx, lookup, i, SidekickAPIError, SyncTableCallbackEventType, type QueryResponse, type SidekickQuery, type SidekickQueryResult, type SidekickSchema, type SidekickObject, type SidekickEntity, type SidekickSchemaDatabase, type SidekickUnknownSchemaDef, type ISidekickDatabase, type User, type AuthState, type Query, type Config, type SideQLParams, type ConnectionStatus, type ValidQuery, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type SidekickGraph, type SidekickConfig, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type ValueTypes, type SideQLEntity, type SideQLFields, type SideQLResult, type SideQLEntitySubquery, type RoomsOf, type RoomsDef, type PresenceOf, type TopicsOf, type TopicOf, type RoomHandle, type TransactionChunk, type SidekickUnknownSchema, type SidekickSchemaDef, type BackwardsCompatibleSchema, type SidekickRules, type UpdateParams, type LinkParams, type CreateParams, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, StoreInterface, createSidekickRouteHandler, type SidekickRouteHandlerPayloadByType, type SidekickRouteHandlerType, type SidekickRouteHandlerBody, type StoreInterfaceStoreName, type Logger } from '@sidekickdb/core';
2
+ import { SidekickVueDatabase, init } from './SidekickVueDatabase.js';
3
+ import { SidekickVueRoom } from './SidekickVueRoom.js';
4
4
  import SignedIn from './components/SignedIn.vue';
5
5
  import SignedOut from './components/SignedOut.vue';
6
6
  import Cursors from './components/Cursors.vue';
7
- export { id, tx, lookup, init, InstantVueDatabase, InstantVueRoom, SignedIn, SignedOut, Cursors, i, InstantAPIError, SyncTableCallbackEventType, type Config, type InstantConfig, type InstantUnknownSchemaDef, type Query, type QueryResponse, type InstantObject, type User, type AuthState, type ConnectionStatus, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantEntity, type InstantSchemaDatabase, type IInstantDatabase, type InstaQLParams, type ValidQuery, type InstaQLFields, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type ValueTypes, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type RoomsOf, type RoomsDef, type TransactionChunk, type PresenceOf, type TopicsOf, type TopicOf, type RoomHandle, type InstantUnknownSchema, type InstantSchemaDef, type BackwardsCompatibleSchema, type InstantRules, type UpdateParams, type LinkParams, type CreateParams, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, StoreInterface, type StoreInterfaceStoreName, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, createInstantRouteHandler, type InstantRouteHandlerPayloadByType, type InstantRouteHandlerType, type InstantRouteHandlerBody, type Logger, };
7
+ export { id, tx, lookup, init, SidekickVueDatabase, SidekickVueRoom, SignedIn, SignedOut, Cursors, i, SidekickAPIError, SyncTableCallbackEventType, type Config, type SidekickConfig, type SidekickUnknownSchemaDef, type Query, type QueryResponse, type SidekickObject, type User, type AuthState, type ConnectionStatus, type SidekickQuery, type SidekickQueryResult, type SidekickSchema, type SidekickEntity, type SidekickSchemaDatabase, type ISidekickDatabase, type SideQLParams, type ValidQuery, type SideQLFields, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type SidekickGraph, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type ValueTypes, type SideQLEntity, type SideQLResult, type SideQLEntitySubquery, type RoomsOf, type RoomsDef, type TransactionChunk, type PresenceOf, type TopicsOf, type TopicOf, type RoomHandle, type SidekickUnknownSchema, type SidekickSchemaDef, type BackwardsCompatibleSchema, type SidekickRules, type UpdateParams, type LinkParams, type CreateParams, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, StoreInterface, type StoreInterfaceStoreName, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, createSidekickRouteHandler, type SidekickRouteHandlerPayloadByType, type SidekickRouteHandlerType, type SidekickRouteHandlerBody, type Logger, };
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EACF,EAAE,EACF,MAAM,EACN,CAAC,EAGD,eAAe,EAGf,0BAA0B,EAG1B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAGf,KAAK,YAAY,EAGjB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAC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YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EAGnB,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAGvB,cAAc,EACd,KAAK,uBAAuB,EAG5B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EAGxB,0BAA0B,EAC1B,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAG7B,KAAK,MAAM,GACZ,CAAC"}
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import { InstantAPIError, StoreInterface, SyncTableCallbackEventType, createInstantRouteHandler, i, id, lookup, tx } from "@sidekickdb/core";
2
- import { InstantVueDatabase, init } from "./InstantVueDatabase.js";
3
- import { InstantVueRoom } from "./InstantVueRoom.js";
1
+ import { SidekickAPIError, StoreInterface, SyncTableCallbackEventType, createSidekickRouteHandler, i, id, lookup, tx } from "@sidekickdb/core";
2
+ import { SidekickVueDatabase, init } from "./SidekickVueDatabase.js";
3
+ import { SidekickVueRoom } from "./SidekickVueRoom.js";
4
4
  import { _ } from "./chunks/SignedIn.vue_vue_type_script_setup_true_lang-MJrQPE2B.js";
5
5
  import { _ as _2 } from "./chunks/SignedOut.vue_vue_type_script_setup_true_lang-CcoDHmXu.js";
6
- import { _ as _3 } from "./chunks/Cursors.vue_vue_type_script_setup_true_lang-C6eE1KRI.js";
6
+ import { _ as _3 } from "./chunks/Cursors.vue_vue_type_script_setup_true_lang-BIVjDXb4.js";
7
7
  export {
8
8
  _3 as Cursors,
9
- InstantAPIError,
10
- InstantVueDatabase,
11
- InstantVueRoom,
9
+ SidekickAPIError,
10
+ SidekickVueDatabase,
11
+ SidekickVueRoom,
12
12
  _ as SignedIn,
13
13
  _2 as SignedOut,
14
14
  StoreInterface,
15
15
  SyncTableCallbackEventType,
16
- createInstantRouteHandler,
16
+ createSidekickRouteHandler,
17
17
  i,
18
18
  id,
19
19
  init,
@@ -1,8 +1,8 @@
1
- import type { InstaQLResponse, ValidQuery, InstantCoreDatabase, InstantSchemaDef, InstaQLOptions } from '@sidekickdb/core';
1
+ import type { SideQLResponse, ValidQuery, SidekickCoreDatabase, SidekickSchemaDef, SideQLOptions } from '@sidekickdb/core';
2
2
  import type { ShallowRef, Ref, MaybeRefOrGetter } from 'vue';
3
- export type InfiniteQueryResult<Schema extends InstantSchemaDef<any, any, any>, Q extends ValidQuery<Q, Schema>, UseDates extends boolean> = {
3
+ export type InfiniteQueryResult<Schema extends SidekickSchemaDef<any, any, any>, Q extends ValidQuery<Q, Schema>, UseDates extends boolean> = {
4
4
  isLoading: Ref<boolean>;
5
- data: ShallowRef<InstaQLResponse<Schema, Q, UseDates> | undefined>;
5
+ data: ShallowRef<SideQLResponse<Schema, Q, UseDates> | undefined>;
6
6
  error: ShallowRef<{
7
7
  message: string;
8
8
  } | undefined>;
@@ -21,5 +21,5 @@ export type InfiniteQueryResult<Schema extends InstantSchemaDef<any, any, any>,
21
21
  * posts: { $: { limit: 20, order: { createdAt: 'desc' } } },
22
22
  * });
23
23
  */
24
- export declare function useInfiniteQuery<Schema extends InstantSchemaDef<any, any, any>, Q extends ValidQuery<Q, Schema>, UseDates extends boolean>(core: InstantCoreDatabase<Schema, UseDates>, query: MaybeRefOrGetter<Q | null>, opts?: MaybeRefOrGetter<InstaQLOptions | undefined>): InfiniteQueryResult<Schema, Q, UseDates>;
24
+ export declare function useInfiniteQuery<Schema extends SidekickSchemaDef<any, any, any>, Q extends ValidQuery<Q, Schema>, UseDates extends boolean>(core: SidekickCoreDatabase<Schema, UseDates>, query: MaybeRefOrGetter<Q | null>, opts?: MaybeRefOrGetter<SideQLOptions | undefined>): InfiniteQueryResult<Schema, Q, UseDates>;
25
25
  //# sourceMappingURL=useInfiniteQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInfiniteQuery.d.ts","sourceRoot":"","sources":["../src/useInfiniteQuery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EAEV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAI7D,MAAM,MAAM,mBAAmB,CAC7B,MAAM,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC9C,CAAC,SAAS,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,EAC/B,QAAQ,SAAS,OAAO,IACtB;IACF,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,CAAC;IACnE,KAAK,EAAE,UAAU,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAAC;IACnD,eAAe,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9B,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;A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CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC/C,CAAC,SAAS,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,EAC/B,QAAQ,SAAS,OAAO,EAExB,IAAI,EAAE,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,EAC5C,KAAK,EAAE,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAC,EACjC,IAAI,CAAC,EAAE,gBAAgB,CAAC,aAAa,GAAG,SAAS,CAAC,GACjD,mBAAmB,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,CA6D1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useInfiniteQuery.js","sources":["../src/useInfiniteQuery.ts"],"sourcesContent":["import { weakHash, getInfiniteQueryInitialSnapshot } from '@sidekickdb/core';\nimport type {\n InstaQLResponse,\n ValidQuery,\n InfiniteQuerySubscription,\n InstantCoreDatabase,\n InstantSchemaDef,\n InstaQLOptions,\n} from '@sidekickdb/core';\nimport { shallowRef, ref, watch, toValue } from 'vue';\nimport type { ShallowRef, Ref, MaybeRefOrGetter } from 'vue';\n\nimport { tryOnScopeDispose } from './utils.js';\n\nexport type InfiniteQueryResult<\n Schema extends InstantSchemaDef<any, any, any>,\n Q extends ValidQuery<Q, Schema>,\n UseDates extends boolean,\n> = {\n isLoading: Ref<boolean>;\n data: ShallowRef<InstaQLResponse<Schema, Q, UseDates> | undefined>;\n error: ShallowRef<{ message: string } | undefined>;\n canLoadNextPage: Ref<boolean>;\n loadNextPage: () => void;\n};\n\n/**\n * Subscribe to a query and incrementally load more items.\n *\n * Only one top-level namespace in the query is allowed. Changing the query or\n * options while the subscription is active resets and starts over.\n *\n * @example\n * const { data, isLoading, error, loadNextPage, canLoadNextPage } =\n * db.useInfiniteQuery({\n * posts: { $: { limit: 20, order: { createdAt: 'desc' } } },\n * });\n */\nexport function useInfiniteQuery<\n Schema extends InstantSchemaDef<any, any, any>,\n Q extends ValidQuery<Q, Schema>,\n UseDates extends boolean,\n>(\n core: InstantCoreDatabase<Schema, UseDates>,\n query: MaybeRefOrGetter<Q | null>,\n opts?: MaybeRefOrGetter<InstaQLOptions | undefined>,\n): InfiniteQueryResult<Schema, Q, UseDates> {\n const initialQuery = toValue(query);\n const snapshot = initialQuery\n ? getInfiniteQueryInitialSnapshot(core, initialQuery, toValue(opts))\n : { data: undefined, error: undefined, canLoadNextPage: false };\n\n const isLoading = ref(!snapshot.data && !snapshot.error);\n const data = shallowRef<InstaQLResponse<Schema, Q, UseDates> | undefined>(\n snapshot.data as any,\n );\n const error = shallowRef<{ message: string } | undefined>(snapshot.error);\n const canLoadNextPage = ref(snapshot.canLoadNextPage);\n\n let subRef: InfiniteQuerySubscription | null = null;\n\n const stop = watch(\n [() => weakHash(toValue(query)), () => weakHash(toValue(opts))],\n (_, __, onCleanup) => {\n subRef = null;\n error.value = undefined;\n data.value = undefined;\n isLoading.value = true;\n canLoadNextPage.value = false;\n\n const q = toValue(query);\n if (!q) return;\n\n const sub = core.subscribeInfiniteQuery(\n q,\n (resp: any) => {\n error.value = resp.error;\n data.value = resp.data;\n isLoading.value = false;\n canLoadNextPage.value = resp.canLoadNextPage;\n },\n toValue(opts),\n );\n\n subRef = sub;\n\n onCleanup(() => {\n sub.unsubscribe();\n if (subRef === sub) subRef = null;\n });\n },\n { immediate: true },\n );\n\n const loadNextPage = () => {\n subRef?.loadNextPage();\n };\n\n tryOnScopeDispose(stop);\n\n return {\n isLoading,\n data,\n error,\n canLoadNextPage,\n loadNextPage,\n } as InfiniteQueryResult<Schema, Q, UseDates>;\n}\n"],"names":[],"mappings":";;;AAsCgB,SAAA,iBAKd,MACA,OACA,MAC0C;AACpC,QAAA,eAAe,QAAQ,KAAK;AAClC,QAAM,WAAW,eACb,gCAAgC,MAAM,cAAc,QAAQ,IAAI,CAAC,IACjE,EAAE,MAAM,QAAW,OAAO,QAAW,iBAAiB,MAAM;AAEhE,QAAM,YAAY,IAAI,CAAC,SAAS,QAAQ,CAAC,SAAS,KAAK;AACvD,QAAM,OAAO;AAAA,IACX,SAAS;AAAA,EACX;AACM,QAAA,QAAQ,WAA4C,SAAS,KAAK;AAClE,QAAA,kBAAkB,IAAI,SAAS,eAAe;AAEpD,MAAI,SAA2C;AAE/C,QAAM,OAAO;AAAA,IACX,CAAC,MAAM,SAAS,QAAQ,KAAK,CAAC,GAAG,MAAM,SAAS,QAAQ,IAAI,CAAC,CAAC;AAAA,IAC9D,CAAC,GAAG,IAAI,cAAc;AACX,eAAA;AACT,YAAM,QAAQ;AACd,WAAK,QAAQ;AACb,gBAAU,QAAQ;AAClB,sBAAgB,QAAQ;AAElB,YAAA,IAAI,QAAQ,KAAK;AACvB,UAAI,CAAC,EAAG;AAER,YAAM,MAAM,KAAK;AAAA,QACf;AAAA,QACA,CAAC,SAAc;AACb,gBAAM,QAAQ,KAAK;AACnB,eAAK,QAAQ,KAAK;AAClB,oBAAU,QAAQ;AAClB,0BAAgB,QAAQ,KAAK;AAAA,QAC/B;AAAA,QACA,QAAQ,IAAI;AAAA,MACd;AAES,eAAA;AAET,gBAAU,MAAM;AACd,YAAI,YAAY;AACZ,YAAA,WAAW,IAAc,UAAA;AAAA,MAAA,CAC9B;AAAA,IACH;AAAA,IACA,EAAE,WAAW,KAAK;AAAA,EACpB;AAEA,QAAM,eAAe,MAAM;AACzB,qCAAQ;AAAA,EACV;AAEA,oBAAkB,IAAI;AAEf,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useInfiniteQuery.js","sources":["../src/useInfiniteQuery.ts"],"sourcesContent":["import { weakHash, getInfiniteQueryInitialSnapshot } from '@sidekickdb/core';\nimport type {\n SideQLResponse,\n ValidQuery,\n InfiniteQuerySubscription,\n SidekickCoreDatabase,\n SidekickSchemaDef,\n SideQLOptions,\n} from '@sidekickdb/core';\nimport { shallowRef, ref, watch, toValue } from 'vue';\nimport type { ShallowRef, Ref, MaybeRefOrGetter } from 'vue';\n\nimport { tryOnScopeDispose } from './utils.js';\n\nexport type InfiniteQueryResult<\n Schema extends SidekickSchemaDef<any, any, any>,\n Q extends ValidQuery<Q, Schema>,\n UseDates extends boolean,\n> = {\n isLoading: Ref<boolean>;\n data: ShallowRef<SideQLResponse<Schema, Q, UseDates> | undefined>;\n error: ShallowRef<{ message: string } | undefined>;\n canLoadNextPage: Ref<boolean>;\n loadNextPage: () => void;\n};\n\n/**\n * Subscribe to a query and incrementally load more items.\n *\n * Only one top-level namespace in the query is allowed. Changing the query or\n * options while the subscription is active resets and starts over.\n *\n * @example\n * const { data, isLoading, error, loadNextPage, canLoadNextPage } =\n * db.useInfiniteQuery({\n * posts: { $: { limit: 20, order: { createdAt: 'desc' } } },\n * });\n */\nexport function useInfiniteQuery<\n Schema extends SidekickSchemaDef<any, any, any>,\n Q extends ValidQuery<Q, Schema>,\n UseDates extends boolean,\n>(\n core: SidekickCoreDatabase<Schema, UseDates>,\n query: MaybeRefOrGetter<Q | null>,\n opts?: MaybeRefOrGetter<SideQLOptions | undefined>,\n): InfiniteQueryResult<Schema, Q, UseDates> {\n const initialQuery = toValue(query);\n const snapshot = initialQuery\n ? getInfiniteQueryInitialSnapshot(core, initialQuery, toValue(opts))\n : { data: undefined, error: undefined, canLoadNextPage: false };\n\n const isLoading = ref(!snapshot.data && !snapshot.error);\n const data = shallowRef<SideQLResponse<Schema, Q, UseDates> | undefined>(\n snapshot.data as any,\n );\n const error = shallowRef<{ message: string } | undefined>(snapshot.error);\n const canLoadNextPage = ref(snapshot.canLoadNextPage);\n\n let subRef: InfiniteQuerySubscription | null = null;\n\n const stop = watch(\n [() => weakHash(toValue(query)), () => weakHash(toValue(opts))],\n (_, __, onCleanup) => {\n subRef = null;\n error.value = undefined;\n data.value = undefined;\n isLoading.value = true;\n canLoadNextPage.value = false;\n\n const q = toValue(query);\n if (!q) return;\n\n const sub = core.subscribeInfiniteQuery(\n q,\n (resp: any) => {\n error.value = resp.error;\n data.value = resp.data;\n isLoading.value = false;\n canLoadNextPage.value = resp.canLoadNextPage;\n },\n toValue(opts),\n );\n\n subRef = sub;\n\n onCleanup(() => {\n sub.unsubscribe();\n if (subRef === sub) subRef = null;\n });\n },\n { immediate: true },\n );\n\n const loadNextPage = () => {\n subRef?.loadNextPage();\n };\n\n tryOnScopeDispose(stop);\n\n return {\n isLoading,\n data,\n error,\n canLoadNextPage,\n loadNextPage,\n } as InfiniteQueryResult<Schema, Q, UseDates>;\n}\n"],"names":[],"mappings":";;;AAsCgB,SAAA,iBAKd,MACA,OACA,MAC0C;AACpC,QAAA,eAAe,QAAQ,KAAK;AAClC,QAAM,WAAW,eACb,gCAAgC,MAAM,cAAc,QAAQ,IAAI,CAAC,IACjE,EAAE,MAAM,QAAW,OAAO,QAAW,iBAAiB,MAAM;AAEhE,QAAM,YAAY,IAAI,CAAC,SAAS,QAAQ,CAAC,SAAS,KAAK;AACvD,QAAM,OAAO;AAAA,IACX,SAAS;AAAA,EACX;AACM,QAAA,QAAQ,WAA4C,SAAS,KAAK;AAClE,QAAA,kBAAkB,IAAI,SAAS,eAAe;AAEpD,MAAI,SAA2C;AAE/C,QAAM,OAAO;AAAA,IACX,CAAC,MAAM,SAAS,QAAQ,KAAK,CAAC,GAAG,MAAM,SAAS,QAAQ,IAAI,CAAC,CAAC;AAAA,IAC9D,CAAC,GAAG,IAAI,cAAc;AACX,eAAA;AACT,YAAM,QAAQ;AACd,WAAK,QAAQ;AACb,gBAAU,QAAQ;AAClB,sBAAgB,QAAQ;AAElB,YAAA,IAAI,QAAQ,KAAK;AACvB,UAAI,CAAC,EAAG;AAER,YAAM,MAAM,KAAK;AAAA,QACf;AAAA,QACA,CAAC,SAAc;AACb,gBAAM,QAAQ,KAAK;AACnB,eAAK,QAAQ,KAAK;AAClB,oBAAU,QAAQ;AAClB,0BAAgB,QAAQ,KAAK;AAAA,QAC/B;AAAA,QACA,QAAQ,IAAI;AAAA,MACd;AAES,eAAA;AAET,gBAAU,MAAM;AACd,YAAI,YAAY;AACZ,YAAA,WAAW,IAAc,UAAA;AAAA,MAAA,CAC9B;AAAA,IACH;AAAA,IACA,EAAE,WAAW,KAAK;AAAA,EACpB;AAEA,QAAM,eAAe,MAAM;AACzB,qCAAQ;AAAA,EACV;AAEA,oBAAkB,IAAI;AAEf,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sidekickdb/vue",
3
3
  "type": "module",
4
- "version": "2.0.1",
4
+ "version": "3.0.0",
5
5
  "description": "Vue client for SidekickDB",
6
6
  "license": "Apache-2.0",
7
7
  "homepage": "https://sidekickdb.co/docs/start-vue",
@@ -39,8 +39,8 @@
39
39
  "vue": "^3.4.0"
40
40
  },
41
41
  "dependencies": {
42
- "@sidekickdb/core": "2.0.1",
43
- "@sidekickdb/version": "2.0.1"
42
+ "@sidekickdb/version": "3.0.0",
43
+ "@sidekickdb/core": "3.0.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@vitejs/plugin-vue": "^5.2.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"InstantVueDatabase.d.ts","sourceRoot":"","sources":["../src/InstantVueDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,UAAU,EAEf,IAAI,EACJ,OAAO,EACP,OAAO,EAEP,mBAAmB,EAInB,gBAAgB,EAChB,OAAO,EAEP,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,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AAC,EAAE,QAAQ,CAAC,CAEzC;IAEF;;;;;;;OAOG;IACH,OAAO,QAAO,aAAa,CAkBzB;IAEF;;;;;;;;;OASG;IACH,OAAO,QAAO,WAAW,CAAC,IAAI,CAAC,CAU7B;IAEF;;;;;;;OAOG;IACH,mBAAmB,QAAO,GAAG,CAAC,gBAAgB,CAAC,CAY7C;IAEF;;;;;;;;;OASG;IACH,UAAU,GAAI,MAAM,gBAAgB,CAAC,MAAM,CAAC,KAAG,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAkB/D;IAEF;;;;;;;;OAQG;IACH,IAAI,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,KAAK,EACxC,IAAI,CAAC,EAAE,gBAAgB,CAAC,QAAQ,GAAG,SAAS,CAAC,EAC7C,EAAE,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC;IAS3C;;;;;;;;;OASG;IACH,KAAK;;;;;;MAAS;CACf;AAKD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAClB,MAAM,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC9C,QAAQ,SAAS,OAAO,GAAG,KAAK,EAEhC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,GAAG;IAChE,cAAc,CAAC,EAAE,QAAQ,CAAC;CAC3B,GACA,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAKtC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"InstantVueDatabase.js","sources":["../src/InstantVueDatabase.ts"],"sourcesContent":["import {\n // types\n type AuthState,\n type User,\n type ConnectionStatus,\n type TransactionChunk,\n type RoomSchemaShape,\n type InstaQLOptions,\n type InstantConfig,\n type PageInfoResponse,\n type InstaQLResponse,\n type ValidQuery,\n // classes\n Auth,\n Storage,\n Streams,\n txInit,\n InstantCoreDatabase,\n init as core_init,\n coerceQuery,\n weakHash,\n InstantSchemaDef,\n RoomsOf,\n InstantError,\n IInstantDatabase,\n} from '@sidekickdb/core';\n\nimport { ref, shallowRef, computed, watch, toValue } from 'vue';\nimport type { Ref, ShallowRef, ComputedRef, MaybeRefOrGetter } from 'vue';\n\nimport { InstantVueRoom, rooms } from './InstantVueRoom.js';\nimport { tryOnScopeDispose } from './utils.js';\nimport { useInfiniteQuery } from './useInfiniteQuery.js';\nimport type { InfiniteQueryResult } from './useInfiniteQuery.js';\nimport version from './version.js';\n\n// ------\n// Types\n\nexport type UseQueryReturn<\n Schema extends InstantSchemaDef<any, any, any>,\n Q extends ValidQuery<Q, Schema>,\n UseDates extends boolean,\n> = {\n isLoading: Ref<boolean>;\n data: ShallowRef<InstaQLResponse<Schema, Q, UseDates> | undefined>;\n pageInfo: ShallowRef<PageInfoResponse<Q> | undefined>;\n error: ShallowRef<{ message: string } | undefined>;\n};\n\nexport type UseAuthReturn = {\n isLoading: Ref<boolean>;\n user: ShallowRef<User | null | undefined>;\n error: ShallowRef<{ message: string } | undefined>;\n};\n\nexport class InstantVueDatabase<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n Rooms extends RoomSchemaShape = RoomsOf<Schema>,\n> implements IInstantDatabase<Schema>\n{\n public tx = txInit<Schema>();\n\n public auth: Auth;\n public storage: Storage;\n public streams: Streams;\n public core: InstantCoreDatabase<Schema, UseDates>;\n\n constructor(core: InstantCoreDatabase<Schema, UseDates>) {\n this.core = core;\n this.auth = this.core.auth;\n this.storage = this.core.storage;\n this.streams = this.core.streams;\n }\n\n /**\n * Returns a unique ID for a given `name`. It's stored in local storage,\n * so you will get the same ID across sessions.\n *\n * @example\n * const deviceId = await db.getLocalId('device');\n */\n getLocalId = (name: string): Promise<string> => {\n return this.core.getLocalId(name);\n };\n\n /**\n * Use this to write data! You can create, update, delete, and link objects\n *\n * @see https://sidekickdb.co/docs/instaml\n *\n * @example\n * const goalId = id();\n * db.transact(db.tx.goals[goalId].update({title: \"Get fit\"}))\n */\n transact = (\n chunks: TransactionChunk<any, any> | TransactionChunk<any, any>[],\n ) => {\n return this.core.transact(chunks);\n };\n\n /**\n * One time query for the logged in state.\n *\n * @see https://sidekickdb.co/docs/auth\n * @example\n * const user = await db.getAuth();\n * console.log('logged in as', user.email)\n */\n getAuth(): Promise<User | null> {\n return this.core.getAuth();\n }\n\n /**\n * Use this for one-off queries.\n * Returns local data if available, otherwise fetches from the server.\n *\n * @see https://sidekickdb.co/docs/instaql\n *\n * @example\n * const resp = await db.queryOnce({ goals: {} });\n * console.log(resp.data.goals)\n */\n queryOnce = <Q extends ValidQuery<Q, Schema>>(\n query: Q,\n opts?: InstaQLOptions,\n ): Promise<{\n data: InstaQLResponse<Schema, Q, UseDates>;\n pageInfo: PageInfoResponse<Q>;\n }> => {\n return this.core.queryOnce(query, opts);\n };\n\n // -----------\n // Vue reactive hooks\n\n /**\n * Use this to query your data!\n *\n * @see https://sidekickdb.co/docs/instaql\n *\n * @example\n * // basic query — refs auto-unwrap in templates\n * const { isLoading, error, data } = db.useQuery({ goals: {} });\n *\n * @example\n * // reactive query — pass a getter that returns null to skip\n * const { user } = db.useAuth();\n * const { data } = db.useQuery(() =>\n * user.value ? { todos: { $: { where: { 'owner.id': user.value.id } } } } : null,\n * );\n *\n * @example\n * // pass a ref directly\n * const query = ref<{ todos: {} } | null>({ todos: {} });\n * const { data } = db.useQuery(query);\n */\n useQuery = <Q extends ValidQuery<Q, Schema>>(\n query: MaybeRefOrGetter<Q | null>,\n opts?: MaybeRefOrGetter<InstaQLOptions | null | undefined>,\n ): UseQueryReturn<Schema, Q, UseDates> => {\n const isLoading = ref(true);\n const data = shallowRef<InstaQLResponse<Schema, Q, UseDates> | undefined>(\n undefined,\n );\n const pageInfo = shallowRef<PageInfoResponse<Q> | undefined>(undefined);\n const error = shallowRef<{ message: string } | undefined>(undefined);\n\n const resolvedQuery = computed(() => {\n const q = toValue(query);\n if (!q) return null;\n const o = toValue(opts);\n const withParams =\n o && 'ruleParams' in o\n ? ({ $$ruleParams: (o as any).ruleParams, ...q } as Q)\n : q;\n return coerceQuery(withParams);\n });\n\n const queryHash = computed(() => weakHash(resolvedQuery.value));\n\n const stop = watch(\n queryHash,\n (_, __, onCleanup) => {\n const q = resolvedQuery.value;\n const cached: any = q ? this.core._reactor.getPreviousResult(q) : null;\n isLoading.value = !cached;\n data.value = cached?.data;\n pageInfo.value = cached?.pageInfo;\n error.value = cached?.error;\n\n if (!q) return;\n\n const unsub = this.core.subscribeQuery<Q, UseDates>(q, (r: any) => {\n isLoading.value = false;\n data.value = r.data;\n pageInfo.value = r.pageInfo;\n error.value = r.error;\n });\n onCleanup(unsub);\n },\n { immediate: true },\n );\n\n tryOnScopeDispose(stop);\n\n return { isLoading, data, pageInfo, error } as UseQueryReturn<\n Schema,\n Q,\n UseDates\n >;\n };\n\n /**\n * Subscribe to a query and incrementally load more items.\n *\n * Only one top-level namespace in the query is allowed.\n *\n * @example\n * const { data, isLoading, error, loadNextPage, canLoadNextPage } =\n * db.useInfiniteQuery({\n * posts: { $: { limit: 20, order: { createdAt: 'desc' } } },\n * });\n */\n useInfiniteQuery = <Q extends ValidQuery<Q, Schema>>(\n query: MaybeRefOrGetter<Q | null>,\n opts?: MaybeRefOrGetter<InstaQLOptions | undefined>,\n ): InfiniteQueryResult<Schema, Q, UseDates> => {\n return useInfiniteQuery<Schema, Q, UseDates>(this.core, query, opts);\n };\n\n /**\n * Listen for the logged in state. This is useful\n * for deciding when to show a login screen.\n *\n * @see https://sidekickdb.co/docs/auth\n * @example\n * const { isLoading, user, error } = db.useAuth();\n */\n useAuth = (): UseAuthReturn => {\n const cached = this.core._reactor._currentUserCached as\n | AuthState\n | undefined;\n\n const isLoading = ref(cached?.isLoading ?? true);\n const user = shallowRef<User | null | undefined>(cached?.user);\n const error = shallowRef<{ message: string } | undefined>(cached?.error);\n\n const unsub = this.core.subscribeAuth((auth: any) => {\n isLoading.value = false;\n user.value = auth.user ?? null;\n error.value = auth.error;\n });\n\n tryOnScopeDispose(unsub);\n\n return { isLoading, user, error };\n };\n\n /**\n * Subscribe to the currently logged in user. Throws if the user isn't\n * signed in when `.value` is accessed — wrap callers with `<SignedIn>` or\n * a `useAuth` check.\n *\n * @see https://sidekickdb.co/docs/auth\n * @example\n * const user = db.useUser();\n * // user.value.email\n */\n useUser = (): ComputedRef<User> => {\n const { user } = this.useAuth();\n return computed(() => {\n if (!user.value) {\n throw new InstantError(\n 'useUser must be used within an auth-protected route',\n );\n }\n return user.value;\n });\n };\n\n /**\n * Listen for connection status changes to Instant.\n *\n * @see https://sidekickdb.co/docs/patterns#connection-status\n * @example\n * const status = db.useConnectionStatus();\n * // status.value\n */\n useConnectionStatus = (): Ref<ConnectionStatus> => {\n const status = ref<ConnectionStatus>(\n this.core._reactor.status as ConnectionStatus,\n );\n\n const unsub = this.core.subscribeConnectionStatus((newStatus) => {\n status.value = newStatus;\n });\n\n tryOnScopeDispose(unsub);\n\n return status;\n };\n\n /**\n * A hook that returns a unique ID for a given `name`. localIds are stored in\n * local storage, so you get the same ID across sessions.\n *\n * Returns `null` initially, then the loaded ID.\n *\n * @example\n * const deviceId = db.useLocalId('device');\n * // deviceId.value is null initially, then the ID string\n */\n useLocalId = (name: MaybeRefOrGetter<string>): Ref<string | null> => {\n const localId = ref<string | null>(null);\n\n const stop = watch(\n () => toValue(name),\n (currentName) => {\n this.getLocalId(currentName).then((id) => {\n // Drop a late resolve if `name` has since changed.\n if (toValue(name) === currentName) {\n localId.value = id;\n }\n });\n },\n { immediate: true },\n );\n\n tryOnScopeDispose(stop);\n return localId;\n };\n\n /**\n * Obtain a handle to a room, which allows you to listen to topics and presence data\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n *\n * @example\n * const room = db.room('chat', roomId);\n * const { peers } = db.rooms.usePresence(room);\n */\n room<RoomType extends string & keyof Rooms>(\n type?: MaybeRefOrGetter<RoomType | undefined>,\n id?: MaybeRefOrGetter<string | undefined>,\n ) {\n const _type = computed(\n () => (toValue(type) ?? '_defaultRoomType') as RoomType,\n );\n const _id = computed(() => toValue(id) ?? '_defaultRoomId');\n return new InstantVueRoom<Schema, Rooms, RoomType>(this.core, _type, _id);\n }\n\n /**\n * Hooks for working with rooms\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n *\n * @example\n * const room = db.room('chat', roomId);\n * const { peers } = db.rooms.usePresence(room);\n * const publish = db.rooms.usePublishTopic(room, 'emoji');\n */\n rooms = rooms;\n}\n\n// -----------\n// init\n\n/**\n * The first step: init your application!\n *\n * Find your `appId` in your SidekickDB dashboard.\n *\n * @example\n * import { init } from \"@sidekickdb/vue\"\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\" })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@sidekickdb/vue\"\n * import schema from \"../instant.schema.ts\";\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\", schema })\n */\nexport function init<\n Schema extends InstantSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n>(\n config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): InstantVueDatabase<Schema, UseDates> {\n const coreDb = core_init<Schema, UseDates>(config, undefined, undefined, {\n '@instantdb/vue': version,\n });\n return new InstantVueDatabase<Schema, UseDates>(coreDb);\n}\n"],"names":["core_init"],"mappings":";;;;;;;;;AAwDO,MAAM,mBAKb;AAAA,EAQE,YAAY,MAA6C;AAPlD,8BAAK,OAAe;AAEpB;AACA;AACA;AACA;AAgBP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAa,CAAC,SAAkC;AACvC,aAAA,KAAK,KAAK,WAAW,IAAI;AAAA,IAClC;AAWA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAW,CACT,WACG;AACI,aAAA,KAAK,KAAK,SAAS,MAAM;AAAA,IAClC;AAwBA;AAAA;AAAA;AAAA;AAA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AAC,EAC/C,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAChE,IAAI,CAeN;AAKD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,SAAS,eAAe,EAClC,QAAQ,SAAS,MAAM,UAAU,EAEjC,IAAI,EAAE,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,EAC/C,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,mBAAwB,GAC7B,qBAAqB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,CAqEzD;AAKD,eAAO,MAAM,KAAK;;;;;;CAMjB,CAAC;AAKF,qBAAa,cAAc,CACzB,MAAM,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC9C,UAAU,SAAS,eAAe,EAClC,QAAQ,SAAS,MAAM,UAAU;IAEjC,IAAI,EAAE,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACvC,EAAE,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;gBAG/B,IAAI,EAAE,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,QAAQ,EACtC,EAAE,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM;CAMnC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"InstantVueRoom.js","sources":["../src/InstantVueRoom.ts"],"sourcesContent":["import {\n type PresenceOpts,\n type PresenceResponse,\n type RoomSchemaShape,\n InstantCoreDatabase,\n InstantSchemaDef,\n} from '@sidekickdb/core';\n\nimport { shallowRef, watchEffect, toValue } from 'vue';\nimport type { Ref, ShallowRef, MaybeRefOrGetter, ComputedRef } from 'vue';\n\nimport { tryOnScopeDispose } from './utils.js';\n\n// ------\n// Types\n\nexport type PresenceHandle<PresenceShape, Keys extends keyof PresenceShape> = {\n [K in keyof PresenceResponse<PresenceShape, Keys>]: ShallowRef<\n PresenceResponse<PresenceShape, Keys>[K]\n >;\n} & {\n publishPresence: (data: Partial<PresenceShape>) => void;\n};\n\nexport type TypingIndicatorOpts = {\n timeout?: number | null;\n stopOnEnter?: boolean;\n // Perf opt - `active` will always be an empty array\n writeOnly?: boolean;\n};\n\nexport type TypingIndicatorHandle<PresenceShape> = {\n active: Ref<PresenceShape[]>;\n setActive(active: boolean): void;\n /**\n * Listener keys are lowercased (`onKeydown`, not `onKeyDown`) so that\n * Vue's `v-bind` spread hyphenates them correctly to native DOM events\n * (`keydown`). With camelCase Vue would emit a non-existent `key-down`\n * listener and the indicator would never fire.\n */\n inputProps: {\n onKeydown: (e: KeyboardEvent) => void;\n onBlur: () => void;\n };\n};\n\nexport const defaultActivityStopTimeout = 1_000;\n\n// ------\n// Topics\n\n/**\n * Listen for broadcasted events given a room and topic.\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n * @example\n * const room = db.room('chats', roomId);\n * db.rooms.useTopicEffect(room, 'emoji', (message, peer) => {\n * console.log(peer.name, 'sent', message);\n * });\n */\nexport function useTopicEffect<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n TopicType extends keyof RoomSchema[RoomType]['topics'],\n>(\n room: InstantVueRoom<any, RoomSchema, RoomType>,\n topic: TopicType,\n onEvent: (\n event: RoomSchema[RoomType]['topics'][TopicType],\n peer: RoomSchema[RoomType]['presence'],\n ) => any,\n): void {\n watchEffect((onCleanup) => {\n const type = toValue(room.type);\n const id = toValue(room.id);\n const unsub = room.core._reactor.subscribeTopic(\n type,\n id,\n topic,\n (event: any, peer: any) => {\n onEvent(event, peer);\n },\n );\n onCleanup(unsub);\n });\n}\n\n/**\n * Broadcast an event to a room.\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n * @example\n * const room = db.room('chat', roomId);\n * const publishTopic = db.rooms.usePublishTopic(room, 'emoji');\n * publishTopic({ emoji: \"🔥\" });\n */\nexport function usePublishTopic<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n TopicType extends keyof RoomSchema[RoomType]['topics'],\n>(\n room: InstantVueRoom<any, RoomSchema, RoomType>,\n topic: TopicType,\n): (data: RoomSchema[RoomType]['topics'][TopicType]) => void {\n watchEffect((onCleanup) => {\n const type = toValue(room.type) as string;\n const id = toValue(room.id);\n const unsub = room.core._reactor.joinRoom(type, id);\n onCleanup(unsub);\n });\n\n return (data: RoomSchema[RoomType]['topics'][TopicType]) => {\n room.core._reactor.publishTopic({\n roomType: toValue(room.type),\n roomId: toValue(room.id),\n topic,\n data,\n });\n };\n}\n\n// ---------\n// Presence\n\n/**\n * Listen for peer's presence data in a room, and publish the current user's presence.\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n * @example\n * const room = db.room('chat', roomId);\n * const { peers, isLoading, publishPresence } = db.rooms.usePresence(room, { keys: [\"name\", \"avatar\"] });\n */\nexport function usePresence<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n Keys extends keyof RoomSchema[RoomType]['presence'],\n>(\n room: InstantVueRoom<any, RoomSchema, RoomType>,\n opts: PresenceOpts<RoomSchema[RoomType]['presence'], Keys> = {},\n): PresenceHandle<RoomSchema[RoomType]['presence'], Keys> {\n const initial = (room.core._reactor.getPresence(\n toValue(room.type),\n toValue(room.id),\n opts,\n ) ?? {\n peers: {},\n isLoading: true,\n }) as PresenceResponse<RoomSchema[RoomType]['presence'], Keys>;\n\n const peers = shallowRef(initial.peers);\n const isLoading = shallowRef(initial.isLoading);\n const user = shallowRef<any>((initial as any).user);\n const error = shallowRef<any>((initial as any).error);\n\n watchEffect((onCleanup) => {\n const type = toValue(room.type);\n const id = toValue(room.id);\n const unsub = room.core._reactor.subscribePresence(\n type,\n id,\n opts,\n (data: any) => {\n peers.value = data.peers;\n isLoading.value = data.isLoading;\n if ('user' in data) user.value = data.user;\n if ('error' in data) error.value = data.error;\n },\n );\n onCleanup(unsub);\n });\n\n return {\n peers,\n isLoading,\n user,\n error,\n publishPresence: (data: Partial<RoomSchema[RoomType]['presence']>) => {\n room.core._reactor.publishPresence(\n toValue(room.type),\n toValue(room.id),\n data,\n );\n },\n } as PresenceHandle<RoomSchema[RoomType]['presence'], Keys>;\n}\n\n/**\n * Publishes presence data to a room\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n * @example\n * const room = db.room('chat', roomId);\n * db.rooms.useSyncPresence(room, { nickname });\n */\nexport function useSyncPresence<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n>(\n room: InstantVueRoom<any, RoomSchema, RoomType>,\n data: MaybeRefOrGetter<Partial<RoomSchema[RoomType]['presence']>>,\n): void {\n watchEffect((onCleanup) => {\n const type = toValue(room.type) as string;\n const id = toValue(room.id);\n const unsub = room.core._reactor.joinRoom(type, id, toValue(data));\n onCleanup(unsub);\n });\n\n watchEffect(() => {\n room.core._reactor.publishPresence(\n toValue(room.type),\n toValue(room.id),\n toValue(data),\n );\n });\n}\n\n// -----------------\n// Typing Indicator\n\n/**\n * Manage typing indicator state\n *\n * @see https://sidekickdb.co/docs/presence-and-topics\n * @example\n * const room = db.room('chat', roomId);\n * const typing = db.rooms.useTypingIndicator(room, 'chat-input');\n * // typing.active.value, typing.setActive(bool), typing.inputProps\n */\nexport function useTypingIndicator<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n>(\n room: InstantVueRoom<any, RoomSchema, RoomType>,\n inputName: string,\n opts: TypingIndicatorOpts = {},\n): TypingIndicatorHandle<RoomSchema[RoomType]['presence']> {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n const presence = usePresence(room, {\n keys: [inputName] as (keyof RoomSchema[RoomType]['presence'])[],\n });\n\n const active = shallowRef<RoomSchema[RoomType]['presence'][]>([]);\n\n watchEffect(() => {\n if (opts?.writeOnly) {\n active.value = [];\n return;\n }\n // Track peers so we re-run when presence updates\n presence.peers.value;\n const snapshot = room.core._reactor.getPresence(\n toValue(room.type),\n toValue(room.id),\n );\n active.value = Object.values(snapshot?.peers ?? {}).filter(\n (p: any) => p[inputName] === true,\n );\n });\n\n const setActive = (isActive: boolean) => {\n room.core._reactor.publishPresence(toValue(room.type), toValue(room.id), {\n [inputName]: isActive ? true : null,\n } as Partial<RoomSchema[RoomType]['presence']>);\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n\n if (!isActive) return;\n if (opts?.timeout === null || opts?.timeout === 0) return;\n\n timeoutId = setTimeout(() => {\n room.core._reactor.publishPresence(toValue(room.type), toValue(room.id), {\n [inputName]: null,\n } as Partial<RoomSchema[RoomType]['presence']>);\n }, opts?.timeout ?? defaultActivityStopTimeout);\n };\n\n tryOnScopeDispose(() => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n // Clear sticky typing state on unmount, even when timeout is disabled.\n setActive(false);\n });\n\n const onKeydown = (e: KeyboardEvent) => {\n const isEnter = opts?.stopOnEnter && e.key === 'Enter';\n const isActive = !isEnter;\n setActive(isActive);\n };\n\n const onBlur = () => {\n setActive(false);\n };\n\n return {\n active,\n setActive,\n inputProps: { onKeydown, onBlur },\n };\n}\n\n// --------------\n// Hooks namespace\n\nexport const rooms = {\n useTopicEffect,\n usePublishTopic,\n usePresence,\n useSyncPresence,\n useTypingIndicator,\n};\n\n// ------------\n// Class\n\nexport class InstantVueRoom<\n Schema extends InstantSchemaDef<any, any, any>,\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n> {\n core: InstantCoreDatabase<Schema, boolean>;\n type: ComputedRef<RoomType> | RoomType;\n id: ComputedRef<string> | string;\n\n constructor(\n core: InstantCoreDatabase<Schema, boolean>,\n type: ComputedRef<RoomType> | RoomType,\n id: ComputedRef<string> | string,\n ) {\n this.core = core;\n this.type = type;\n this.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KO,MAAM,eAIX;AAAA,EAKA,YACE,MACA,MACA,IACA;AARF;AACA;AACA;AAOE,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,KAAK;AAAA,EAAA;AAEd;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Cursors.vue_vue_type_script_setup_true_lang-C6eE1KRI.js","sources":["../../src/components/Cursors.vue"],"sourcesContent":["<script\n setup\n lang=\"ts\"\n generic=\"RoomSchema extends RoomSchemaShape, RoomType extends string & keyof RoomSchema\"\n>\nimport { computed, toValue } from 'vue';\nimport type { RoomSchemaShape } from '@sidekickdb/core';\nimport { usePresence } from '../InstantVueRoom.js';\nimport type { InstantVueRoom } from '../InstantVueRoom.js';\nimport Cursor from './Cursor.vue';\n\ntype CursorPresence = {\n x: number;\n y: number;\n xPercent: number;\n yPercent: number;\n color?: string;\n};\n\nconst props = withDefaults(\n defineProps<{\n room: InstantVueRoom<any, RoomSchema, RoomType>;\n spaceId?: string;\n as?: string;\n userCursorColor?: string;\n propagate?: boolean;\n zIndex?: number;\n }>(),\n {\n as: 'div',\n propagate: false,\n zIndex: 99999,\n },\n);\n\nconst spaceId = computed(\n () =>\n props.spaceId ||\n `cursors-space-default--${String(toValue(props.room.type))}-${toValue(props.room.id)}`,\n);\n\nconst { peers, publishPresence } = usePresence(props.room, {\n keys: [spaceId.value] as (keyof RoomSchema[RoomType]['presence'])[],\n});\n\nconst fullPresence = computed(() => {\n // Track peers so the snapshot refreshes when presence changes.\n peers.value;\n return props.room.core._reactor.getPresence(\n toValue(props.room.type),\n toValue(props.room.id),\n );\n});\n\nconst cursorPeers = computed(() => {\n const sid = spaceId.value;\n return Object.entries(peers.value || {}).flatMap(([peerId, p]) => {\n const cursor = (p as any)?.[sid] as CursorPresence | undefined;\n return cursor ? [{ peerId, cursor }] : [];\n });\n});\n\nfunction publishCursor(\n rect: DOMRect,\n touch: { clientX: number; clientY: number },\n) {\n const x = touch.clientX;\n const y = touch.clientY;\n const xPercent = ((x - rect.left) / rect.width) * 100;\n const yPercent = ((y - rect.top) / rect.height) * 100;\n publishPresence({\n [spaceId.value]: {\n x,\n y,\n xPercent,\n yPercent,\n color: props.userCursorColor,\n },\n } as RoomSchema[RoomType]['presence']);\n}\n\nfunction onMouseMove(e: MouseEvent) {\n if (!props.propagate) e.stopPropagation();\n const rect = (e.currentTarget as Element).getBoundingClientRect();\n publishCursor(rect, e);\n}\n\nfunction clearCursor() {\n publishPresence({\n [spaceId.value]: undefined,\n } as RoomSchema[RoomType]['presence']);\n}\n\nfunction onTouchMove(e: TouchEvent) {\n if (e.touches.length !== 1) return;\n const touch = e.touches[0];\n if (!touch || !(touch.target instanceof Element)) return;\n if (!props.propagate) e.stopPropagation();\n const rect = touch.target.getBoundingClientRect();\n publishCursor(rect, touch);\n}\n</script>\n\n<template>\n <component\n :is=\"as\"\n :style=\"{ position: 'relative' }\"\n @mousemove=\"onMouseMove\"\n @mouseout=\"clearCursor\"\n @blur=\"clearCursor\"\n @touchmove=\"onTouchMove\"\n @touchend=\"clearCursor\"\n >\n <slot />\n <div\n :style=\"{\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n right: 0,\n overflow: 'hidden',\n pointerEvents: 'none',\n userSelect: 'none',\n zIndex,\n }\"\n >\n <div\n v-for=\"{ peerId, cursor } in cursorPeers\"\n :key=\"peerId\"\n :style=\"{\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n right: 0,\n transform: `translate(${cursor.xPercent}%, ${cursor.yPercent}%)`,\n transformOrigin: '0 0',\n transition: 'transform 100ms',\n }\"\n >\n <slot\n name=\"cursor\"\n :color=\"cursor.color\"\n :presence=\"fullPresence?.peers[peerId]\"\n >\n <Cursor :color=\"cursor.color ?? ''\" />\n </slot>\n </div>\n </div>\n </component>\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAmBA,UAAM,QAAQ;AAgBd,UAAM,UAAU;AAAA,MACd,MACE,MAAM,WACN,0BAA0B,OAAO,QAAQ,MAAM,K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