@instantdb/solidjs 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.tshy/build.json +8 -0
  2. package/.tshy/commonjs.json +16 -0
  3. package/.tshy/esm.json +15 -0
  4. package/.turbo/turbo-build.log +69 -0
  5. package/dist/commonjs/InstantSolidDatabase.d.ts +156 -0
  6. package/dist/commonjs/InstantSolidDatabase.d.ts.map +1 -0
  7. package/dist/commonjs/InstantSolidDatabase.js +265 -0
  8. package/dist/commonjs/InstantSolidDatabase.js.map +1 -0
  9. package/dist/commonjs/InstantSolidRoom.d.ts +97 -0
  10. package/dist/commonjs/InstantSolidRoom.d.ts.map +1 -0
  11. package/dist/commonjs/InstantSolidRoom.js +200 -0
  12. package/dist/commonjs/InstantSolidRoom.js.map +1 -0
  13. package/dist/commonjs/index.d.ts +6 -0
  14. package/dist/commonjs/index.d.ts.map +1 -0
  15. package/dist/commonjs/index.js +24 -0
  16. package/dist/commonjs/index.js.map +1 -0
  17. package/dist/commonjs/package.json +3 -0
  18. package/dist/commonjs/version.d.ts +3 -0
  19. package/dist/commonjs/version.d.ts.map +1 -0
  20. package/dist/commonjs/version.js +5 -0
  21. package/dist/commonjs/version.js.map +1 -0
  22. package/dist/esm/InstantSolidDatabase.d.ts +156 -0
  23. package/dist/esm/InstantSolidDatabase.d.ts.map +1 -0
  24. package/dist/esm/InstantSolidDatabase.js +257 -0
  25. package/dist/esm/InstantSolidDatabase.js.map +1 -0
  26. package/dist/esm/InstantSolidRoom.d.ts +97 -0
  27. package/dist/esm/InstantSolidRoom.d.ts.map +1 -0
  28. package/dist/esm/InstantSolidRoom.js +191 -0
  29. package/dist/esm/InstantSolidRoom.js.map +1 -0
  30. package/dist/esm/index.d.ts +6 -0
  31. package/dist/esm/index.d.ts.map +1 -0
  32. package/dist/esm/index.js +18 -0
  33. package/dist/esm/index.js.map +1 -0
  34. package/dist/esm/package.json +3 -0
  35. package/dist/esm/version.d.ts +3 -0
  36. package/dist/esm/version.d.ts.map +1 -0
  37. package/dist/esm/version.js +3 -0
  38. package/dist/esm/version.js.map +1 -0
  39. package/dist/standalone/index.js +7010 -0
  40. package/dist/standalone/index.umd.cjs +7 -0
  41. package/package.json +63 -0
  42. package/src/InstantSolidDatabase.ts +363 -0
  43. package/src/InstantSolidRoom.ts +319 -0
  44. package/src/index.ts +191 -0
  45. package/src/version.ts +2 -0
  46. package/tsconfig.dev.json +14 -0
  47. package/tsconfig.json +45 -0
  48. package/vite.config.ts +20 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InstantSolidRoom.d.ts","sourceRoot":"","sources":["../../src/InstantSolidRoom.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC,MAAM,MAAM,cAAc,CACxB,aAAa,EACb,IAAI,SAAS,MAAM,aAAa,IAC9B,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG;IAC1C,eAAe,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;CACzD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,aAAa,IAAI;IACjD,MAAM,EAAE,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAClC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE;QACV,SAAS,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,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 exports.InstantSolidRoom = exports.rooms = exports.defaultActivityStopTimeout = void 0;
4
+ exports.useTopicEffect = useTopicEffect;
5
+ exports.usePublishTopic = usePublishTopic;
6
+ exports.usePresence = usePresence;
7
+ exports.useSyncPresence = useSyncPresence;
8
+ exports.useTypingIndicator = useTypingIndicator;
9
+ const solid_js_1 = require("solid-js");
10
+ exports.defaultActivityStopTimeout = 1_000;
11
+ // ------
12
+ // Topics
13
+ /**
14
+ * Listen for broadcasted events given a room and topic.
15
+ *
16
+ * @see https://instantdb.com/docs/presence-and-topics
17
+ * @example
18
+ * function App({ roomId }) {
19
+ * const room = db.room('chats', roomId);
20
+ * db.rooms.useTopicEffect(room, 'emoji', (message, peer) => {
21
+ * console.log(peer.name, 'sent', message);
22
+ * });
23
+ * // ...
24
+ * }
25
+ */
26
+ function useTopicEffect(room, topic, onEvent) {
27
+ (0, solid_js_1.createEffect)(() => {
28
+ const unsub = room.core._reactor.subscribeTopic(room.type, room.id, topic, (event, peer) => {
29
+ onEvent(event, peer);
30
+ });
31
+ (0, solid_js_1.onCleanup)(unsub);
32
+ });
33
+ }
34
+ /**
35
+ * Broadcast an event to a room.
36
+ *
37
+ * @see https://instantdb.com/docs/presence-and-topics
38
+ * @example
39
+ * function App({ roomId }) {
40
+ * const room = db.room('chat', roomId);
41
+ * const publishTopic = db.rooms.usePublishTopic(room, "emoji");
42
+ *
43
+ * return (
44
+ * <button onClick={() => publishTopic({ emoji: "🔥" })}>Send emoji</button>
45
+ * );
46
+ * }
47
+ *
48
+ */
49
+ function usePublishTopic(room, topic) {
50
+ (0, solid_js_1.createEffect)(() => {
51
+ const unsub = room.core._reactor.joinRoom(room.type, room.id);
52
+ (0, solid_js_1.onCleanup)(unsub);
53
+ });
54
+ return (data) => {
55
+ room.core._reactor.publishTopic({
56
+ roomType: room.type,
57
+ roomId: room.id,
58
+ topic,
59
+ data,
60
+ });
61
+ };
62
+ }
63
+ // ---------
64
+ // Presence
65
+ /**
66
+ * Listen for peer's presence data in a room, and publish the current user's presence.
67
+ *
68
+ * @see https://instantdb.com/docs/presence-and-topics
69
+ * @example
70
+ * function App({ roomId }) {
71
+ * const presence = db.rooms.usePresence(room, { keys: ["name", "avatar"] });
72
+ * // presence().peers, presence().isLoading, presence().publishPresence
73
+ * }
74
+ */
75
+ function usePresence(room, opts = {}) {
76
+ const [state, setState] = (0, solid_js_1.createSignal)((room.core._reactor.getPresence(room.type, room.id, opts) ?? {
77
+ peers: {},
78
+ isLoading: true,
79
+ }));
80
+ (0, solid_js_1.createEffect)(() => {
81
+ const unsub = room.core._reactor.subscribePresence(room.type, room.id, opts, (data) => {
82
+ setState(data);
83
+ });
84
+ (0, solid_js_1.onCleanup)(unsub);
85
+ });
86
+ const publishPresence = (data) => {
87
+ room.core._reactor.publishPresence(room.type, room.id, data);
88
+ };
89
+ return (0, solid_js_1.createMemo)(() => ({
90
+ ...state(),
91
+ publishPresence,
92
+ }));
93
+ }
94
+ /**
95
+ * Publishes presence data to a room
96
+ *
97
+ * @see https://instantdb.com/docs/presence-and-topics
98
+ * @example
99
+ * function App({ roomId, nickname }) {
100
+ * const room = db.room('chat', roomId);
101
+ * db.rooms.useSyncPresence(room, { nickname });
102
+ * }
103
+ */
104
+ function useSyncPresence(room, data, deps) {
105
+ (0, solid_js_1.createEffect)(() => {
106
+ const unsub = room.core._reactor.joinRoom(room.type, room.id, data);
107
+ (0, solid_js_1.onCleanup)(unsub);
108
+ });
109
+ (0, solid_js_1.createEffect)(() => {
110
+ // Track deps if provided, otherwise track serialized data
111
+ if (deps) {
112
+ deps.forEach((d) => d);
113
+ }
114
+ else {
115
+ JSON.stringify(data);
116
+ }
117
+ room.core._reactor.publishPresence(room.type, room.id, data);
118
+ });
119
+ }
120
+ // -----------------
121
+ // Typing Indicator
122
+ /**
123
+ * Manage typing indicator state
124
+ *
125
+ * @see https://instantdb.com/docs/presence-and-topics
126
+ * @example
127
+ * function App({ roomId }) {
128
+ * const room = db.room('chat', roomId);
129
+ * const typing = db.rooms.useTypingIndicator(room, "chat-input");
130
+ * // typing.active(), typing.setActive(bool), typing.inputProps
131
+ * }
132
+ */
133
+ function useTypingIndicator(room, inputName, opts = {}) {
134
+ let timeoutId = null;
135
+ const presence = exports.rooms.usePresence(room, {
136
+ keys: [inputName],
137
+ });
138
+ const active = (0, solid_js_1.createMemo)(() => {
139
+ if (opts?.writeOnly)
140
+ return [];
141
+ // Access presence to track it
142
+ presence();
143
+ const presenceSnapshot = room.core._reactor.getPresence(room.type, room.id);
144
+ return Object.values(presenceSnapshot?.peers ?? {}).filter((p) => p[inputName] === true);
145
+ });
146
+ const setActive = (isActive) => {
147
+ room.core._reactor.publishPresence(room.type, room.id, {
148
+ [inputName]: isActive,
149
+ });
150
+ if (timeoutId) {
151
+ clearTimeout(timeoutId);
152
+ timeoutId = null;
153
+ }
154
+ if (!isActive)
155
+ return;
156
+ if (opts?.timeout === null || opts?.timeout === 0)
157
+ return;
158
+ timeoutId = setTimeout(() => {
159
+ room.core._reactor.publishPresence(room.type, room.id, {
160
+ [inputName]: null,
161
+ });
162
+ }, opts?.timeout ?? exports.defaultActivityStopTimeout);
163
+ };
164
+ const onKeyDown = (e) => {
165
+ const isEnter = opts?.stopOnEnter && e.key === 'Enter';
166
+ const isActive = !isEnter;
167
+ setActive(isActive);
168
+ };
169
+ const onBlur = () => {
170
+ setActive(false);
171
+ };
172
+ return {
173
+ active,
174
+ setActive,
175
+ inputProps: { onKeyDown, onBlur },
176
+ };
177
+ }
178
+ // --------------
179
+ // Hooks namespace
180
+ exports.rooms = {
181
+ useTopicEffect,
182
+ usePublishTopic,
183
+ usePresence,
184
+ useSyncPresence,
185
+ useTypingIndicator,
186
+ };
187
+ // ------------
188
+ // Class
189
+ class InstantSolidRoom {
190
+ core;
191
+ type;
192
+ id;
193
+ constructor(core, type, id) {
194
+ this.core = core;
195
+ this.type = type;
196
+ this.id = id;
197
+ }
198
+ }
199
+ exports.InstantSolidRoom = InstantSolidRoom;
200
+ //# sourceMappingURL=InstantSol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IACnB,cAAc;IACd,eAAe;IACf,WAAW;IACX,eAAe;IACf,kBAAkB;CACnB,CAAC;AAEF,eAAe;AACf,QAAQ;AAER,MAAa,gBAAgB;IAK3B,IAAI,CAAuC;IAC3C,IAAI,CAAW;IACf,EAAE,CAAS;IAEX,YACE,IAA0C,EAC1C,IAAc,EACd,EAAU;QAEV,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;CACF;AAlBD,4CAkBC","sourcesContent":["import {\n type PresenceOpts,\n type PresenceResponse,\n type RoomSchemaShape,\n InstantCoreDatabase,\n InstantSchemaDef,\n} from '@instantdb/core';\n\nimport { createSignal, createEffect, onCleanup, createMemo } from 'solid-js';\nimport type { Accessor } from 'solid-js';\n\n// ------\n// Types\n\nexport type PresenceHandle<\n PresenceShape,\n Keys extends keyof PresenceShape,\n> = PresenceResponse<PresenceShape, Keys> & {\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: Accessor<PresenceShape[]>;\n setActive(active: boolean): void;\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://instantdb.com/docs/presence-and-topics\n * @example\n * function App({ roomId }) {\n * const room = db.room('chats', roomId);\n * db.rooms.useTopicEffect(room, 'emoji', (message, peer) => {\n * console.log(peer.name, 'sent', message);\n * });\n * // ...\n * }\n */\nexport function useTopicEffect<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n TopicType extends keyof RoomSchema[RoomType]['topics'],\n>(\n room: InstantSolidRoom<any, RoomSchema, RoomType>,\n topic: TopicType,\n onEvent: (\n event: RoomSchema[RoomType]['topics'][TopicType],\n peer: RoomSchema[RoomType]['presence'],\n ) => any,\n): void {\n createEffect(() => {\n const unsub = room.core._reactor.subscribeTopic(\n room.type,\n room.id,\n topic,\n (event: any, peer: any) => {\n onEvent(event, peer);\n },\n );\n\n onCleanup(unsub);\n });\n}\n\n/**\n * Broadcast an event to a room.\n *\n * @see https://instantdb.com/docs/presence-and-topics\n * @example\n * function App({ roomId }) {\n * const room = db.room('chat', roomId);\n * const publishTopic = db.rooms.usePublishTopic(room, \"emoji\");\n *\n * return (\n * <button onClick={() => publishTopic({ emoji: \"🔥\" })}>Send emoji</button>\n * );\n * }\n *\n */\nexport function usePublishTopic<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n TopicType extends keyof RoomSchema[RoomType]['topics'],\n>(\n room: InstantSolidRoom<any, RoomSchema, RoomType>,\n topic: TopicType,\n): (data: RoomSchema[RoomType]['topics'][TopicType]) => void {\n createEffect(() => {\n const unsub = room.core._reactor.joinRoom(room.type as string, room.id);\n onCleanup(unsub);\n });\n\n return (data: RoomSchema[RoomType]['topics'][TopicType]) => {\n room.core._reactor.publishTopic({\n roomType: room.type,\n roomId: 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://instantdb.com/docs/presence-and-topics\n * @example\n * function App({ roomId }) {\n * const presence = db.rooms.usePresence(room, { keys: [\"name\", \"avatar\"] });\n * // presence().peers, presence().isLoading, presence().publishPresence\n * }\n */\nexport function usePresence<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n Keys extends keyof RoomSchema[RoomType]['presence'],\n>(\n room: InstantSolidRoom<any, RoomSchema, RoomType>,\n opts: PresenceOpts<RoomSchema[RoomType]['presence'], Keys> = {},\n): Accessor<PresenceHandle<RoomSchema[RoomType]['presence'], Keys>> {\n const [state, setState] = createSignal<\n PresenceResponse<RoomSchema[RoomType]['presence'], Keys>\n >(\n (room.core._reactor.getPresence(room.type, room.id, opts) ?? {\n peers: {},\n isLoading: true,\n }) as PresenceResponse<RoomSchema[RoomType]['presence'], Keys>,\n );\n\n createEffect(() => {\n const unsub = room.core._reactor.subscribePresence(\n room.type,\n room.id,\n opts,\n (data: any) => {\n setState(data);\n },\n );\n\n onCleanup(unsub);\n });\n\n const publishPresence = (data: Partial<RoomSchema[RoomType]['presence']>) => {\n room.core._reactor.publishPresence(room.type, room.id, data);\n };\n\n return createMemo(() => ({\n ...state(),\n publishPresence,\n }));\n}\n\n/**\n * Publishes presence data to a room\n *\n * @see https://instantdb.com/docs/presence-and-topics\n * @example\n * function App({ roomId, nickname }) {\n * const room = db.room('chat', roomId);\n * db.rooms.useSyncPresence(room, { nickname });\n * }\n */\nexport function useSyncPresence<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n>(\n room: InstantSolidRoom<any, RoomSchema, RoomType>,\n data: Partial<RoomSchema[RoomType]['presence']>,\n deps?: any[],\n): void {\n createEffect(() => {\n const unsub = room.core._reactor.joinRoom(\n room.type as string,\n room.id,\n data,\n );\n onCleanup(unsub);\n });\n\n createEffect(() => {\n // Track deps if provided, otherwise track serialized data\n if (deps) {\n deps.forEach((d) => d);\n } else {\n JSON.stringify(data);\n }\n room.core._reactor.publishPresence(room.type, room.id, data);\n });\n}\n\n// -----------------\n// Typing Indicator\n\n/**\n * Manage typing indicator state\n *\n * @see https://instantdb.com/docs/presence-and-topics\n * @example\n * function App({ roomId }) {\n * const room = db.room('chat', roomId);\n * const typing = db.rooms.useTypingIndicator(room, \"chat-input\");\n * // typing.active(), typing.setActive(bool), typing.inputProps\n * }\n */\nexport function useTypingIndicator<\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n>(\n room: InstantSolidRoom<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 = rooms.usePresence(room, {\n keys: [inputName] as (keyof RoomSchema[RoomType]['presence'])[],\n });\n\n const active = createMemo(() => {\n if (opts?.writeOnly) return [];\n // Access presence to track it\n presence();\n const presenceSnapshot = room.core._reactor.getPresence(room.type, room.id);\n return Object.values(presenceSnapshot?.peers ?? {}).filter(\n (p: any) => p[inputName] === true,\n );\n });\n\n const setActive = (isActive: boolean) => {\n room.core._reactor.publishPresence(room.type, room.id, {\n [inputName]: isActive,\n } as unknown as Partial<RoomSchema[RoomType]['presence']>);\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n timeoutId = null;\n }\n\n if (!isActive) return;\n\n if (opts?.timeout === null || opts?.timeout === 0) return;\n\n timeoutId = setTimeout(() => {\n room.core._reactor.publishPresence(room.type, room.id, {\n [inputName]: null,\n } as Partial<RoomSchema[RoomType]['presence']>);\n }, opts?.timeout ?? defaultActivityStopTimeout);\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 InstantSolidRoom<\n Schema extends InstantSchemaDef<any, any, any>,\n RoomSchema extends RoomSchemaShape,\n RoomType extends keyof RoomSchema,\n> {\n core: InstantCoreDatabase<Schema, boolean>;\n type: RoomType;\n id: string;\n\n constructor(\n core: InstantCoreDatabase<Schema, boolean>,\n type: RoomType,\n id: string,\n ) {\n this.core = core;\n this.type = type;\n this.id = id;\n }\n}\n"]}
@@ -0,0 +1,6 @@
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 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 StoreInterfaceStoreName } from '@instantdb/core';
2
+ import { InstantSolidDatabase } from './InstantSolidDatabase.js';
3
+ import { init, init_experimental } from './InstantSolidDatabase.js';
4
+ import { InstantSolidRoom } from './InstantSolidRoom.js';
5
+ export { id, tx, lookup, init, init_experimental, InstantSolidDatabase, InstantSolidRoom, 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 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, };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,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esModule", { value: true });
3
+ exports.createInstantRouteHandler = exports.StoreInterface = exports.SyncTableCallbackEventType = exports.InstantAPIError = exports.i = exports.InstantSolidRoom = exports.InstantSolidDatabase = exports.init_experimental = exports.init = exports.lookup = exports.tx = exports.id = void 0;
4
+ const core_1 = require("@instantdb/core");
5
+ Object.defineProperty(exports, "id", { enumerable: true, get: function () { return core_1.id; } });
6
+ Object.defineProperty(exports, "tx", { enumerable: true, get: function () { return core_1.tx; } });
7
+ Object.defineProperty(exports, "lookup", { enumerable: true, get: function () { return core_1.lookup; } });
8
+ Object.defineProperty(exports, "i", { enumerable: true, get: function () { return core_1.i; } });
9
+ Object.defineProperty(exports, "InstantAPIError", { enumerable: true, get: function () { return
10
+ // error
11
+ core_1.InstantAPIError; } });
12
+ Object.defineProperty(exports, "SyncTableCallbackEventType", { enumerable: true, get: function () { return
13
+ // sync table enums
14
+ core_1.SyncTableCallbackEventType; } });
15
+ Object.defineProperty(exports, "StoreInterface", { enumerable: true, get: function () { return core_1.StoreInterface; } });
16
+ Object.defineProperty(exports, "createInstantRouteHandler", { enumerable: true, get: function () { return core_1.createInstantRouteHandler; } });
17
+ const InstantSolidDatabase_js_1 = require("./InstantSolidDatabase.js");
18
+ Object.defineProperty(exports, "InstantSolidDatabase", { enumerable: true, get: function () { return InstantSolidDatabase_js_1.InstantSolidDatabase; } });
19
+ const InstantSolidDatabase_js_2 = require("./InstantSolidDatabase.js");
20
+ Object.defineProperty(exports, "init", { enumerable: true, get: function () { return InstantSolidDatabase_js_2.init; } });
21
+ Object.defineProperty(exports, "init_experimental", { enumerable: true, get: function () { return InstantSolidDatabase_js_2.init_experimental; } });
22
+ const InstantSolidRoom_js_1 = require("./InstantSolidRoom.js");
23
+ Object.defineProperty(exports, "InstantSolidRoom", { enumerable: true, get: function () { return InstantSolidRoom_js_1.InstantSolidRoom; } });
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,0CAwFyB;AAOvB,mFA9FA,SAAE,OA8FA;AACF,mFA9FA,SAAE,OA8FA;AACF,uFA9FA,aAAM,OA8FA;AAKN,kFAlGA,QAAC,OAkGA;AAGD;IAnGA,QAAQ;IACR,sBAAe,OAkGA;AAGf;IAnGA,mBAAmB;IACnB,iCAA0B,OAkGA;AAoE1B,+FA3FA,qBAAc,OA2FA;AAad,0GAvGA,gCAAyB,OAuGA;AAnG3B,uEAAiE;AAU/D,qGAVO,8CAAoB,OAUP;AATtB,uEAAoE;AAOlE,qFAPO,8BAAI,OAOP;AACJ,kGARa,2CAAiB,OAQb;AAPnB,+DAAyD;AASvD,iGATO,sCAAgB,OASP","sourcesContent":["import {\n id,\n tx,\n lookup,\n i,\n\n // error\n InstantAPIError,\n\n // sync table enums\n SyncTableCallbackEventType,\n\n // types\n type QueryResponse,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantObject,\n type InstantEntity,\n type InstantSchemaDatabase,\n type InstantUnknownSchemaDef,\n type IInstantDatabase,\n type User,\n type AuthState,\n type Query,\n type Config,\n type InstaQLParams,\n type ConnectionStatus,\n type ValidQuery,\n\n // presence types\n type PresencePeer,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type InstantConfig,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type ValueTypes,\n type InstaQLEntity,\n type InstaQLFields,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type RoomsOf,\n type RoomsDef,\n type PresenceOf,\n type TopicsOf,\n type TopicOf,\n type RoomHandle,\n type TransactionChunk,\n type InstantUnknownSchema,\n type InstantSchemaDef,\n type BackwardsCompatibleSchema,\n type InstantRules,\n type UpdateParams,\n type LinkParams,\n type CreateParams,\n type ExchangeCodeForTokenParams,\n type SendMagicCodeParams,\n type SendMagicCodeResponse,\n type SignInWithIdTokenParams,\n type VerifyMagicCodeParams,\n type VerifyResponse,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n\n // sync table types\n type SyncTableCallback,\n type SyncTableCallbackEvent,\n type SyncTableInitialSyncBatch,\n type SyncTableInitialSyncComplete,\n type SyncTableSyncTransaction,\n type SyncTableLoadFromStorage,\n type SyncTableSetupError,\n StoreInterface,\n createInstantRouteHandler,\n type StoreInterfaceStoreName,\n} from '@instantdb/core';\n\nimport { InstantSolidDatabase } from './InstantSolidDatabase.js';\nimport { init, init_experimental } from './InstantSolidDatabase.js';\nimport { InstantSolidRoom } from './InstantSolidRoom.js';\n\nexport {\n id,\n tx,\n lookup,\n init,\n init_experimental,\n InstantSolidDatabase,\n InstantSolidRoom,\n i,\n\n // error\n InstantAPIError,\n\n // sync table enums\n SyncTableCallbackEventType,\n\n // types\n type Config,\n type InstantConfig,\n type InstantUnknownSchemaDef,\n type Query,\n type QueryResponse,\n type InstantObject,\n type User,\n type AuthState,\n type ConnectionStatus,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantEntity,\n type InstantSchemaDatabase,\n type IInstantDatabase,\n type InstaQLParams,\n type ValidQuery,\n type InstaQLFields,\n\n // presence types\n type PresencePeer,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type ValueTypes,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type RoomsOf,\n type RoomsDef,\n type TransactionChunk,\n type PresenceOf,\n type TopicsOf,\n type TopicOf,\n type RoomHandle,\n type InstantUnknownSchema,\n type InstantSchemaDef,\n type BackwardsCompatibleSchema,\n type InstantRules,\n type UpdateParams,\n type LinkParams,\n type CreateParams,\n type ExchangeCodeForTokenParams,\n type SendMagicCodeParams,\n type SendMagicCodeResponse,\n type SignInWithIdTokenParams,\n type VerifyMagicCodeParams,\n type VerifyResponse,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n\n // custom store\n StoreInterface,\n type StoreInterfaceStoreName,\n\n // sync table types\n type SyncTableCallback,\n type SyncTableCallbackEvent,\n type SyncTableInitialSyncBatch,\n type SyncTableInitialSyncComplete,\n type SyncTableSyncTransaction,\n type SyncTableLoadFromStorage,\n type SyncTableSetupError,\n\n // Server helper\n createInstantRouteHandler,\n};\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,3 @@
1
+ import { version } from '@instantdb/version';
2
+ export default version;
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,eAAe,OAAO,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const version_1 = require("@instantdb/version");
4
+ exports.default = version_1.version;
5
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;AAAA,gDAA6C;AAC7C,kBAAe,iBAAO,CAAC","sourcesContent":["import { version } from '@instantdb/version';\nexport default version;\n"]}
@@ -0,0 +1,156 @@
1
+ import { type AuthState, type User, type ConnectionStatus, type TransactionChunk, type RoomSchemaShape, type InstaQLOptions, type InstantConfig, type PageInfoResponse, type InstaQLLifecycleState, type InstaQLResponse, type ValidQuery, Auth, Storage, InstantCoreDatabase, InstantSchemaDef, RoomsOf, IInstantDatabase } from '@instantdb/core';
2
+ import type { Accessor } from 'solid-js';
3
+ import { InstantSolidRoom } from './InstantSolidRoom.js';
4
+ export declare class InstantSolidDatabase<Schema extends InstantSchemaDef<any, any, any>, UseDates extends boolean = false, Rooms extends RoomSchemaShape = RoomsOf<Schema>> implements IInstantDatabase<Schema> {
5
+ tx: import("@instantdb/core").TxChunk<Schema>;
6
+ auth: Auth;
7
+ storage: Storage;
8
+ core: InstantCoreDatabase<Schema, UseDates>;
9
+ constructor(core: InstantCoreDatabase<Schema, UseDates>);
10
+ /**
11
+ * Returns a unique ID for a given `name`. It's stored in local storage,
12
+ * so you will get the same ID across sessions.
13
+ *
14
+ * @example
15
+ * const deviceId = await db.getLocalId('device');
16
+ */
17
+ getLocalId: (name: string) => Promise<string>;
18
+ /**
19
+ * Use this to write data! You can create, update, delete, and link objects
20
+ *
21
+ * @see https://instantdb.com/docs/instaml
22
+ *
23
+ * @example
24
+ * const goalId = id();
25
+ * db.transact(db.tx.goals[goalId].update({title: "Get fit"}))
26
+ */
27
+ transact: (chunks: TransactionChunk<any, any> | TransactionChunk<any, any>[]) => Promise<import("@instantdb/core").TransactionResult>;
28
+ /**
29
+ * One time query for the logged in state.
30
+ *
31
+ * @see https://instantdb.com/docs/auth
32
+ * @example
33
+ * const user = await db.getAuth();
34
+ * console.log('logged in as', user.email)
35
+ */
36
+ getAuth(): Promise<User | null>;
37
+ /**
38
+ * Use this for one-off queries.
39
+ * Returns local data if available, otherwise fetches from the server.
40
+ *
41
+ * @see https://instantdb.com/docs/instaql
42
+ *
43
+ * @example
44
+ * const resp = await db.queryOnce({ goals: {} });
45
+ * console.log(resp.data.goals)
46
+ */
47
+ queryOnce: <Q extends ValidQuery<Q, Schema>>(query: Q, opts?: InstaQLOptions) => Promise<{
48
+ data: InstaQLResponse<Schema, Q, UseDates>;
49
+ pageInfo: PageInfoResponse<Q>;
50
+ }>;
51
+ /**
52
+ * Use this to query your data!
53
+ *
54
+ * @see https://instantdb.com/docs/instaql
55
+ *
56
+ * @example
57
+ * const state = db.useQuery({ goals: {} });
58
+ * // state().isLoading, state().error, state().data
59
+ */
60
+ useQuery: <Q extends ValidQuery<Q, Schema>>(query: null | Q, opts?: InstaQLOptions) => Accessor<InstaQLLifecycleState<Schema, Q, UseDates>>;
61
+ /**
62
+ * Listen for the logged in state. This is useful
63
+ * for deciding when to show a login screen.
64
+ *
65
+ * @see https://instantdb.com/docs/auth
66
+ * @example
67
+ * function App() {
68
+ * const auth = db.useAuth();
69
+ * // auth().isLoading, auth().user, auth().error
70
+ * }
71
+ */
72
+ useAuth: () => Accessor<AuthState>;
73
+ /**
74
+ * Subscribe to the currently logged in user.
75
+ * If the user is not logged in, this will throw an Error.
76
+ *
77
+ * @see https://instantdb.com/docs/auth
78
+ * @example
79
+ * function UserDisplay() {
80
+ * const user = db.useUser();
81
+ * return <div>Logged in as: {user().email}</div>
82
+ * }
83
+ */
84
+ useUser: () => Accessor<User>;
85
+ /**
86
+ * Listen for connection status changes to Instant.
87
+ *
88
+ * @see https://www.instantdb.com/docs/patterns#connection-status
89
+ * @example
90
+ * function App() {
91
+ * const status = db.useConnectionStatus();
92
+ * return <div>Connection state: {status()}</div>
93
+ * }
94
+ */
95
+ useConnectionStatus: () => Accessor<ConnectionStatus>;
96
+ /**
97
+ * A hook that returns a unique ID for a given `name`. localIds are
98
+ * stored in local storage, so you will get the same ID across sessions.
99
+ *
100
+ * Initially returns `null`, and then loads the localId.
101
+ *
102
+ * @example
103
+ * const deviceId = db.useLocalId('device');
104
+ * // deviceId() is null initially, then the ID string
105
+ */
106
+ useLocalId: (name: string) => Accessor<string | null>;
107
+ /**
108
+ * Obtain a handle to a room, which allows you to listen to topics and presence data
109
+ *
110
+ * @see https://instantdb.com/docs/presence-and-topics
111
+ *
112
+ * @example
113
+ * const room = db.room('chat', roomId);
114
+ * const presence = db.rooms.usePresence(room);
115
+ */
116
+ room<RoomType extends keyof Rooms>(type?: RoomType, id?: string): InstantSolidRoom<Schema, Rooms, RoomType>;
117
+ /**
118
+ * Hooks for working with rooms
119
+ *
120
+ * @see https://instantdb.com/docs/presence-and-topics
121
+ *
122
+ * @example
123
+ * const room = db.room('chat', roomId);
124
+ * const presence = db.rooms.usePresence(room);
125
+ * const publish = db.rooms.usePublishTopic(room, 'emoji');
126
+ */
127
+ rooms: {
128
+ useTopicEffect: typeof import("./InstantSolidRoom.js").useTopicEffect;
129
+ usePublishTopic: typeof import("./InstantSolidRoom.js").usePublishTopic;
130
+ usePresence: typeof import("./InstantSolidRoom.js").usePresence;
131
+ useSyncPresence: typeof import("./InstantSolidRoom.js").useSyncPresence;
132
+ useTypingIndicator: typeof import("./InstantSolidRoom.js").useTypingIndicator;
133
+ };
134
+ }
135
+ /**
136
+ * The first step: init your application!
137
+ *
138
+ * Visit https://instantdb.com/dash to get your `appId` :)
139
+ *
140
+ * @example
141
+ * import { init } from "@instantdb/solidjs"
142
+ *
143
+ * const db = init({ appId: "my-app-id" })
144
+ *
145
+ * // You can also provide a schema for type safety and editor autocomplete!
146
+ *
147
+ * import { init } from "@instantdb/solidjs"
148
+ * import schema from "../instant.schema.ts";
149
+ *
150
+ * const db = init({ appId: "my-app-id", schema })
151
+ */
152
+ export declare function init<Schema extends InstantSchemaDef<any, any, any>, UseDates extends boolean = false>(config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
153
+ useDateObjects?: UseDates;
154
+ }): InstantSolidDatabase<Schema, UseDates>;
155
+ export declare const init_experimental: typeof init;
156
+ //# sourceMappingURL=InstantSolidDatabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InstantSolidDatabase.d.ts","sourceRoot":"","sources":["../../src/InstantSolidDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,UAAU,EAEf,IAAI,EACJ,OAAO,EAEP,mBAAmB,EAGnB,gBAAgB,EAChB,OAAO,EAEP,g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