syncorejs 0.2.2 → 0.2.4

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 (142) hide show
  1. package/dist/_vendor/cli/app.d.mts.map +1 -1
  2. package/dist/_vendor/cli/app.mjs +8 -5
  3. package/dist/_vendor/cli/app.mjs.map +1 -1
  4. package/dist/_vendor/cli/context.mjs.map +1 -1
  5. package/dist/_vendor/cli/dev-session.mjs.map +1 -1
  6. package/dist/_vendor/cli/doctor.mjs.map +1 -1
  7. package/dist/_vendor/cli/errors.mjs.map +1 -1
  8. package/dist/_vendor/cli/help.mjs.map +1 -1
  9. package/dist/_vendor/cli/index.mjs +9 -2
  10. package/dist/_vendor/cli/index.mjs.map +1 -1
  11. package/dist/_vendor/cli/messages.mjs.map +1 -1
  12. package/dist/_vendor/cli/preflight.mjs.map +1 -1
  13. package/dist/_vendor/cli/project.mjs +20 -20
  14. package/dist/_vendor/cli/project.mjs.map +1 -1
  15. package/dist/_vendor/cli/render.mjs.map +1 -1
  16. package/dist/_vendor/cli/targets.mjs.map +1 -1
  17. package/dist/_vendor/core/cli.d.mts +8 -2
  18. package/dist/_vendor/core/cli.d.mts.map +1 -1
  19. package/dist/_vendor/core/cli.mjs +510 -71
  20. package/dist/_vendor/core/cli.mjs.map +1 -1
  21. package/dist/_vendor/core/devtools-auth.mjs.map +1 -1
  22. package/dist/_vendor/core/index.d.mts +3 -3
  23. package/dist/_vendor/core/runtime/components.d.mts.map +1 -1
  24. package/dist/_vendor/core/runtime/components.mjs.map +1 -1
  25. package/dist/_vendor/core/runtime/devtools.d.mts.map +1 -1
  26. package/dist/_vendor/core/runtime/devtools.mjs +261 -23
  27. package/dist/_vendor/core/runtime/devtools.mjs.map +1 -1
  28. package/dist/_vendor/core/runtime/functions.d.mts +388 -6
  29. package/dist/_vendor/core/runtime/functions.d.mts.map +1 -1
  30. package/dist/_vendor/core/runtime/functions.mjs +72 -1
  31. package/dist/_vendor/core/runtime/functions.mjs.map +1 -1
  32. package/dist/_vendor/core/runtime/id.d.mts.map +1 -1
  33. package/dist/_vendor/core/runtime/id.mjs.map +1 -1
  34. package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs +12 -6
  35. package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs.map +1 -1
  36. package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs +123 -20
  37. package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs.map +1 -1
  38. package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs +56 -8
  39. package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs.map +1 -1
  40. package/dist/_vendor/core/runtime/internal/engines/schedulerEngine.mjs +49 -14
  41. package/dist/_vendor/core/runtime/internal/engines/schedulerEngine.mjs.map +1 -1
  42. package/dist/_vendor/core/runtime/internal/engines/schemaEngine.mjs +4 -7
  43. package/dist/_vendor/core/runtime/internal/engines/schemaEngine.mjs.map +1 -1
  44. package/dist/_vendor/core/runtime/internal/engines/shared.mjs +81 -2
  45. package/dist/_vendor/core/runtime/internal/engines/shared.mjs.map +1 -1
  46. package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs +100 -13
  47. package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs.map +1 -1
  48. package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs +42 -7
  49. package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs.map +1 -1
  50. package/dist/_vendor/core/runtime/internal/runtimeStatus.mjs.map +1 -1
  51. package/dist/_vendor/core/runtime/internal/systemMeta.mjs.map +1 -1
  52. package/dist/_vendor/core/runtime/internal/transactionCoordinator.mjs +4 -0
  53. package/dist/_vendor/core/runtime/internal/transactionCoordinator.mjs.map +1 -1
  54. package/dist/_vendor/core/runtime/runtime.d.mts +1100 -12
  55. package/dist/_vendor/core/runtime/runtime.d.mts.map +1 -1
  56. package/dist/_vendor/core/runtime/runtime.mjs +63 -0
  57. package/dist/_vendor/core/runtime/runtime.mjs.map +1 -1
  58. package/dist/_vendor/core/transport.d.mts +2 -0
  59. package/dist/_vendor/core/transport.d.mts.map +1 -1
  60. package/dist/_vendor/core/transport.mjs +61 -27
  61. package/dist/_vendor/core/transport.mjs.map +1 -1
  62. package/dist/_vendor/devtools-protocol/index.d.ts +223 -4
  63. package/dist/_vendor/devtools-protocol/index.d.ts.map +1 -1
  64. package/dist/_vendor/devtools-protocol/index.js.map +1 -1
  65. package/dist/_vendor/next/config.d.ts +3 -4
  66. package/dist/_vendor/next/config.d.ts.map +1 -1
  67. package/dist/_vendor/next/config.js +37 -19
  68. package/dist/_vendor/next/config.js.map +1 -1
  69. package/dist/_vendor/next/index.d.ts +109 -29
  70. package/dist/_vendor/next/index.d.ts.map +1 -1
  71. package/dist/_vendor/next/index.js +86 -18
  72. package/dist/_vendor/next/index.js.map +1 -1
  73. package/dist/_vendor/platform-expo/index.d.ts +146 -27
  74. package/dist/_vendor/platform-expo/index.d.ts.map +1 -1
  75. package/dist/_vendor/platform-expo/index.js +81 -10
  76. package/dist/_vendor/platform-expo/index.js.map +1 -1
  77. package/dist/_vendor/platform-expo/react.js.map +1 -1
  78. package/dist/_vendor/platform-expo/web-sqljs-wasm.js +16 -0
  79. package/dist/_vendor/platform-expo/web-sqljs-wasm.js.map +1 -0
  80. package/dist/_vendor/platform-node/index.d.mts +174 -9
  81. package/dist/_vendor/platform-node/index.d.mts.map +1 -1
  82. package/dist/_vendor/platform-node/index.mjs +251 -95
  83. package/dist/_vendor/platform-node/index.mjs.map +1 -1
  84. package/dist/_vendor/platform-node/ipc-react.mjs +4 -0
  85. package/dist/_vendor/platform-node/ipc-react.mjs.map +1 -1
  86. package/dist/_vendor/platform-node/ipc.d.mts.map +1 -1
  87. package/dist/_vendor/platform-node/ipc.mjs.map +1 -1
  88. package/dist/_vendor/platform-web/external-change.d.ts +41 -0
  89. package/dist/_vendor/platform-web/external-change.d.ts.map +1 -1
  90. package/dist/_vendor/platform-web/external-change.js +30 -0
  91. package/dist/_vendor/platform-web/external-change.js.map +1 -1
  92. package/dist/_vendor/platform-web/index.d.ts +312 -37
  93. package/dist/_vendor/platform-web/index.d.ts.map +1 -1
  94. package/dist/_vendor/platform-web/index.js +247 -25
  95. package/dist/_vendor/platform-web/index.js.map +1 -1
  96. package/dist/_vendor/platform-web/indexeddb.d.ts +12 -0
  97. package/dist/_vendor/platform-web/indexeddb.d.ts.map +1 -1
  98. package/dist/_vendor/platform-web/indexeddb.js +10 -0
  99. package/dist/_vendor/platform-web/indexeddb.js.map +1 -1
  100. package/dist/_vendor/platform-web/opfs.d.ts +16 -1
  101. package/dist/_vendor/platform-web/opfs.d.ts.map +1 -1
  102. package/dist/_vendor/platform-web/opfs.js +41 -3
  103. package/dist/_vendor/platform-web/opfs.js.map +1 -1
  104. package/dist/_vendor/platform-web/persistence.d.ts +85 -1
  105. package/dist/_vendor/platform-web/persistence.d.ts.map +1 -1
  106. package/dist/_vendor/platform-web/persistence.js +15 -0
  107. package/dist/_vendor/platform-web/persistence.js.map +1 -1
  108. package/dist/_vendor/platform-web/react.d.ts +1 -2
  109. package/dist/_vendor/platform-web/react.d.ts.map +1 -1
  110. package/dist/_vendor/platform-web/react.js +11 -5
  111. package/dist/_vendor/platform-web/react.js.map +1 -1
  112. package/dist/_vendor/platform-web/sqljs.js +10 -1
  113. package/dist/_vendor/platform-web/sqljs.js.map +1 -1
  114. package/dist/_vendor/platform-web/web-sqljs-wasm.js +8 -0
  115. package/dist/_vendor/platform-web/web-sqljs-wasm.js.map +1 -0
  116. package/dist/_vendor/platform-web/worker.d.ts +60 -9
  117. package/dist/_vendor/platform-web/worker.d.ts.map +1 -1
  118. package/dist/_vendor/platform-web/worker.js +37 -4
  119. package/dist/_vendor/platform-web/worker.js.map +1 -1
  120. package/dist/_vendor/react/index.d.ts +197 -13
  121. package/dist/_vendor/react/index.d.ts.map +1 -1
  122. package/dist/_vendor/react/index.js +209 -17
  123. package/dist/_vendor/react/index.js.map +1 -1
  124. package/dist/_vendor/schema/definition.d.ts +129 -0
  125. package/dist/_vendor/schema/definition.d.ts.map +1 -1
  126. package/dist/_vendor/schema/definition.js +99 -0
  127. package/dist/_vendor/schema/definition.js.map +1 -1
  128. package/dist/_vendor/schema/planner.d.ts.map +1 -1
  129. package/dist/_vendor/schema/planner.js.map +1 -1
  130. package/dist/_vendor/schema/validators.d.ts +180 -4
  131. package/dist/_vendor/schema/validators.d.ts.map +1 -1
  132. package/dist/_vendor/schema/validators.js +35 -1
  133. package/dist/_vendor/schema/validators.js.map +1 -1
  134. package/dist/_vendor/svelte/index.d.ts +207 -7
  135. package/dist/_vendor/svelte/index.d.ts.map +1 -1
  136. package/dist/_vendor/svelte/index.js +201 -6
  137. package/dist/_vendor/svelte/index.js.map +1 -1
  138. package/dist/browser.d.ts.map +1 -1
  139. package/dist/cli.js +3 -1
  140. package/dist/cli.js.map +1 -1
  141. package/dist/index.d.ts +1 -1
  142. package/package.json +24 -21
@@ -19,42 +19,242 @@ type PaginatedQueryArgs<TReference extends FunctionReference<"query">> = Functio
19
19
  } ? Omit<FunctionArgs<TReference>, "paginationOpts"> : never;
20
20
  type PaginatedQueryItem<TReference extends FunctionReference<"query">> = FunctionResult<TReference> extends PaginationResult<infer TItem> ? TItem : never;
21
21
  /**
22
- * The reactive query state shape exposed by Syncore's Svelte stores.
22
+ * The reactive query state shape emitted by Syncore's Svelte store factories.
23
+ *
24
+ * Extends SyncoreQueryState with the same fields (`data`, `error`,
25
+ * `status`, `runtimeStatus`, `isLoading`, `isError`, `isReady`). Returned as
26
+ * the value of stores created by {@link createQueryStore} and
27
+ * {@link createClientQueryStore}.
23
28
  */
24
29
  interface SyncoreQueryStoreState<TResult> extends SyncoreQueryState<TResult> {}
30
+ /**
31
+ * A sentinel value that tells Syncore store factories to skip the query.
32
+ *
33
+ * Use `skip` in place of a query’s `args` argument to avoid firing the query
34
+ * while some required data is not yet available (e.g. a user ID that loads
35
+ * asynchronously). The store will remain in a `"loading"` / skipped state
36
+ * until a non-skip value is provided.
37
+ *
38
+ * ```svelte
39
+ * <script>
40
+ * import { createQueryValueStore, skip } from "syncorejs/svelte";
41
+ * import { api } from "../syncore/_generated/api";
42
+ *
43
+ * export let userId: string | undefined;
44
+ *
45
+ * $: profile = createQueryValueStore(
46
+ * api.users.get,
47
+ * userId ? { id: userId } : skip
48
+ * );
49
+ * </script>
50
+ * ```
51
+ */
25
52
  declare const skip: "skip";
26
53
  type Skip = typeof skip;
27
54
  /**
28
- * Stores a Syncore client in Svelte component context and returns it.
55
+ * Store the Syncore client in Svelte’s component context.
56
+ *
57
+ * Call this once at the root of your component tree (e.g. in a layout or
58
+ * root `+layout.svelte`) so that the context-aware store factories
59
+ * (`createQueryStore`, `createQueriesStore`, etc.) can retrieve it
60
+ * automatically without prop-drilling.
61
+ *
62
+ * ```svelte
63
+ * <!-- +layout.svelte -->
64
+ * <script>
65
+ * import { setSyncoreClient } from "syncorejs/svelte";
66
+ * export let data; // { client } from +layout.ts
67
+ * setSyncoreClient(data.client);
68
+ * </script>
69
+ * <slot />
70
+ * ```
71
+ *
72
+ * @param client - The ready Syncore client to store in context.
73
+ * @returns The same `client` for convenience.
29
74
  */
30
75
  declare function setSyncoreClient(client: SyncoreClient): SyncoreClient;
31
76
  /**
32
- * Reads the Syncore client previously stored in Svelte component context.
77
+ * Retrieve the Syncore client from Svelte’s component context.
78
+ *
79
+ * Throws if {@link setSyncoreClient} has not been called by an ancestor
80
+ * component. Only use this inside Svelte components; for standalone scripts
81
+ * keep an explicit reference to the client instead.
82
+ *
83
+ * @throws `Error` when no client is found in the component context.
33
84
  */
34
85
  declare function getSyncoreClient(): SyncoreClient;
86
+ /**
87
+ * Create a reactive Svelte store that tracks the Syncore runtime status.
88
+ *
89
+ * Uses the client from Svelte context (set via {@link setSyncoreClient}).
90
+ * Subscribe to gate your UI on `"ready"` before rendering data-dependent
91
+ * components.
92
+ *
93
+ * ```svelte
94
+ * <script>
95
+ * import { createSyncoreStatusStore } from "syncorejs/svelte";
96
+ * const status = createSyncoreStatusStore();
97
+ * </script>
98
+ *
99
+ * {#if $status.kind === "ready"}
100
+ * <App />
101
+ * {:else}
102
+ * <Loading />
103
+ * {/if}
104
+ * ```
105
+ */
35
106
  declare function createSyncoreStatusStore(): Readable<SyncoreRuntimeStatus>;
107
+ /**
108
+ * Create a reactive Svelte store that tracks the Syncore runtime status.
109
+ *
110
+ * Accepts an explicit `client` rather than reading from Svelte context,
111
+ * making it usable outside component trees (e.g. in module-level code or
112
+ * SvelteKit `load` functions).
113
+ *
114
+ * @param client - The Syncore client to observe.
115
+ */
36
116
  declare function createClientSyncoreStatusStore(client: SyncoreClient): Readable<SyncoreRuntimeStatus>;
37
117
  /**
38
- * Creates a reactive store for a Syncore query result using the contextual client.
118
+ * Create a reactive Svelte store that emits the current value of a Syncore
119
+ * query, or `undefined` while loading.
120
+ *
121
+ * Uses the client from Svelte context (set via {@link setSyncoreClient}).
122
+ * Pass `skip` as `args` to pause the query.
123
+ *
124
+ * ```svelte
125
+ * <script>
126
+ * import { createQueryValueStore } from "syncorejs/svelte";
127
+ * import { api } from "../syncore/_generated/api";
128
+ *
129
+ * const todos = createQueryValueStore(api.todos.list);
130
+ * </script>
131
+ *
132
+ * {#each $todos ?? [] as todo}
133
+ * <p>{todo.text}</p>
134
+ * {/each}
135
+ * ```
39
136
  */
40
137
  declare function createQueryValueStore<TReference extends FunctionReference<"query">>(reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<FunctionResult<TReference> | undefined>;
41
138
  /**
42
- * Creates a reactive store for a Syncore query result using an explicit client.
139
+ * Create a reactive Svelte store that emits the current value of a Syncore
140
+ * query, or `undefined` while loading.
141
+ *
142
+ * Accepts an explicit `client` instead of reading from Svelte context.
143
+ *
144
+ * @param client - The Syncore client to query against.
43
145
  */
44
146
  declare function createClientQueryValueStore<TReference extends FunctionReference<"query">>(client: SyncoreClient, reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<FunctionResult<TReference> | undefined>;
45
147
  /**
46
- * Creates a reactive store with the full Syncore query state.
148
+ * Create a reactive Svelte store that emits the full SyncoreQueryState
149
+ * for a query, including `data`, `error`, `status`, and `isPending`.
150
+ *
151
+ * Uses the client from Svelte context (set via {@link setSyncoreClient}).
152
+ *
153
+ * ```svelte
154
+ * <script>
155
+ * import { createQueryStore } from "syncorejs/svelte";
156
+ * import { api } from "../syncore/_generated/api";
157
+ *
158
+ * const state = createQueryStore(api.todos.list);
159
+ * </script>
160
+ *
161
+ * {#if $state.isPending}
162
+ * <Spinner />
163
+ * {:else if $state.error}
164
+ * <Error message={$state.error.message} />
165
+ * {:else}
166
+ * {#each $state.data as todo}<p>{todo.text}</p>{/each}
167
+ * {/if}
168
+ * ```
47
169
  */
48
170
  declare function createQueryStore<TReference extends FunctionReference<"query">>(reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>>;
49
171
  /**
50
- * Creates a reactive store with the full Syncore query state for an explicit client.
172
+ * Create a reactive Svelte store that emits the full SyncoreQueryState
173
+ * for a query, including `data`, `error`, `status`, and `isPending`.
174
+ *
175
+ * Accepts an explicit `client` instead of reading from Svelte context.
176
+ *
177
+ * @param client - The Syncore client to query against.
51
178
  */
52
179
  declare function createClientQueryStore<TReference extends FunctionReference<"query">>(client: SyncoreClient, reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>>;
180
+ /**
181
+ * Create a reactive Svelte store that simultaneously observes multiple
182
+ * Syncore queries.
183
+ *
184
+ * Uses the client from Svelte context (set via {@link setSyncoreClient}).
185
+ * Each key in `entries` corresponds to a key in the emitted result object.
186
+ *
187
+ * ```svelte
188
+ * <script>
189
+ * import { createQueriesStore } from "syncorejs/svelte";
190
+ * import { api } from "../syncore/_generated/api";
191
+ *
192
+ * const stores = createQueriesStore({
193
+ * todos: { query: api.todos.list },
194
+ * user: { query: api.users.me },
195
+ * });
196
+ * </script>
197
+ *
198
+ * <p>{$stores.user.data?.name} has {$stores.todos.data?.length} todos</p>
199
+ * ```
200
+ */
53
201
  declare function createQueriesStore<TEntries extends QueriesRequestInput>(entries: TEntries): Readable<CreateQueriesStoreResult<TEntries>>;
202
+ /**
203
+ * Create a reactive Svelte store that simultaneously observes multiple
204
+ * Syncore queries.
205
+ *
206
+ * Accepts an explicit `client` instead of reading from Svelte context.
207
+ *
208
+ * @param client - The Syncore client to query against.
209
+ */
54
210
  declare function createClientQueriesStore<TEntries extends QueriesRequestInput>(client: SyncoreClient, entries: TEntries): Readable<CreateQueriesStoreResult<TEntries>>;
211
+ /**
212
+ * Create a reactive Svelte store for cursor-based paginated Syncore queries.
213
+ *
214
+ * Uses the client from Svelte context (set via {@link setSyncoreClient}).
215
+ * The store handles page tracking and exposes a `loadMore()` function so you
216
+ * can implement “Load More” UIs without manual cursor management.
217
+ *
218
+ * The query referenced by `reference` must accept a `paginationOpts`
219
+ * argument and return a PaginationResult.
220
+ *
221
+ * ```svelte
222
+ * <script>
223
+ * import { createPaginatedQueryStore } from "syncorejs/svelte";
224
+ * import { api } from "../syncore/_generated/api";
225
+ *
226
+ * const result = createPaginatedQueryStore(
227
+ * api.todos.listPaginated,
228
+ * {},
229
+ * { initialNumItems: 10 }
230
+ * );
231
+ * </script>
232
+ *
233
+ * {#each $result.results as todo}<p>{todo.text}</p>{/each}
234
+ * {#if $result.canLoadMore}
235
+ * <button on:click={() => $result.loadMore(10)}>Load more</button>
236
+ * {/if}
237
+ * ```
238
+ *
239
+ * @param reference - A paginated query function reference.
240
+ * @param args - Query arguments excluding `paginationOpts`, or `skip`.
241
+ * @param options - Pagination options. `initialNumItems` controls the number
242
+ * of items to fetch on the first page.
243
+ */
55
244
  declare function createPaginatedQueryStore<TReference extends PaginatedQueryReference>(reference: TReference, args: PaginatedQueryArgs<TReference> | Skip, options: {
56
245
  initialNumItems: number;
57
246
  }): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>>;
247
+ /**
248
+ * Create a reactive Svelte store for cursor-based paginated Syncore queries.
249
+ *
250
+ * Accepts an explicit `client` instead of reading from Svelte context.
251
+ *
252
+ * @param client - The Syncore client to query against.
253
+ * @param reference - A paginated query function reference.
254
+ * @param args - Query arguments excluding `paginationOpts`, or `skip`.
255
+ * @param options - Pagination options. `initialNumItems` controls the number
256
+ * of items to fetch on the first page.
257
+ */
58
258
  declare function createClientPaginatedQueryStore<TReference extends PaginatedQueryReference>(client: SyncoreClient, reference: TReference, args: PaginatedQueryArgs<TReference> | Skip, options: {
59
259
  initialNumItems: number;
60
260
  }): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;KAoBY,iBAAA,UACV,MAAA,uBAA6B,KAAA,IAAS,IAAA,GAAO,KAAA,KAAU,IAAA,EAAM,KAAA;AAAA,KAM1D,iBAAA,oBACgB,iBAAA,YAA6B,iBAAA,aAC9C,MAAA,uBAA6B,YAAA,CAAa,UAAA;EAExC,KAAA,EAAO,UAAA;EACP,IAAA,GAAO,YAAA,CAAa,UAAA,IAAc,IAAA;AAAA;EAGlC,KAAA,EAAO,UAAA;EACP,IAAA,EAAM,YAAA,CAAa,UAAA,IAAc,IAAA;AAAA;AAAA,KAGlC,mBAAA,GAAsB,MAAA,SAAe,iBAAA;AAAA,KAErC,kBAAA,WAA6B,MAAA,SAAe,iBAAA,qBAG7C,iBAAA,CAAkB,cAAA,CAAe,UAAA;AAAA,KAGzB,wBAAA,kBAA0C,mBAAA,qBACrC,QAAA,GAAW,kBAAA,CAAmB,QAAA,CAAS,IAAA;AAAA,KAGnD,uBAAA,GAA0B,iBAAA,UAE7B,MAAA,mBACA,gBAAA;AAAA,KAGG,kBAAA,oBAAsC,iBAAA,aACzC,YAAA,CAAa,UAAA;EAAsB,cAAA,EAAgB,iBAAA;AAAA,IA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oBACK,uBAAA,CAAA,CAEnB,MAAA,EAAQ,aAAA,EACR,SAAA,EAAW,UAAA,EACX,IAAA,EAAM,kBAAA,CAAmB,UAAA,IAAc,IAAA,EACvC,OAAA;EACE,eAAA;AAAA,IAED,QAAA,CAAS,uBAAA,CAAwB,kBAAA,CAAmB,UAAA;;;;iBA0LvC,cAAA,oBACK,iBAAA,aAAA,CAEnB,SAAA,EAAW,UAAA,OAER,IAAA,EAAM,iBAAA,CAAkB,YAAA,CAAa,UAAA,OACrC,OAAA,CAAQ,cAAA,CAAe,UAAA;;;AAvbS;iBAkcrB,YAAA,oBAAgC,iBAAA,WAAA,CAC9C,SAAA,EAAW,UAAA,OAER,IAAA,EAAM,iBAAA,CAAkB,YAAA,CAAa,UAAA,OACrC,OAAA,CAAQ,cAAA,CAAe,UAAA"}
@@ -1,6 +1,28 @@
1
1
  import { derived, readable } from "svelte/store";
2
2
  import { getContext, setContext } from "svelte";
3
3
  //#region src/index.ts
4
+ /**
5
+ * A sentinel value that tells Syncore store factories to skip the query.
6
+ *
7
+ * Use `skip` in place of a query’s `args` argument to avoid firing the query
8
+ * while some required data is not yet available (e.g. a user ID that loads
9
+ * asynchronously). The store will remain in a `"loading"` / skipped state
10
+ * until a non-skip value is provided.
11
+ *
12
+ * ```svelte
13
+ * <script>
14
+ * import { createQueryValueStore, skip } from "syncorejs/svelte";
15
+ * import { api } from "../syncore/_generated/api";
16
+ *
17
+ * export let userId: string | undefined;
18
+ *
19
+ * $: profile = createQueryValueStore(
20
+ * api.users.get,
21
+ * userId ? { id: userId } : skip
22
+ * );
23
+ * <\/script>
24
+ * ```
25
+ */
4
26
  const skip = "skip";
5
27
  const defaultRuntimeStatus = {
6
28
  kind: "starting",
@@ -8,46 +30,146 @@ const defaultRuntimeStatus = {
8
30
  };
9
31
  const SYNCORE_CLIENT_CONTEXT = Symbol("syncore.client");
10
32
  /**
11
- * Stores a Syncore client in Svelte component context and returns it.
33
+ * Store the Syncore client in Svelte’s component context.
34
+ *
35
+ * Call this once at the root of your component tree (e.g. in a layout or
36
+ * root `+layout.svelte`) so that the context-aware store factories
37
+ * (`createQueryStore`, `createQueriesStore`, etc.) can retrieve it
38
+ * automatically without prop-drilling.
39
+ *
40
+ * ```svelte
41
+ * <!-- +layout.svelte -->
42
+ * <script>
43
+ * import { setSyncoreClient } from "syncorejs/svelte";
44
+ * export let data; // { client } from +layout.ts
45
+ * setSyncoreClient(data.client);
46
+ * <\/script>
47
+ * <slot />
48
+ * ```
49
+ *
50
+ * @param client - The ready Syncore client to store in context.
51
+ * @returns The same `client` for convenience.
12
52
  */
13
53
  function setSyncoreClient(client) {
14
54
  setContext(SYNCORE_CLIENT_CONTEXT, client);
15
55
  return client;
16
56
  }
17
57
  /**
18
- * Reads the Syncore client previously stored in Svelte component context.
58
+ * Retrieve the Syncore client from Svelte’s component context.
59
+ *
60
+ * Throws if {@link setSyncoreClient} has not been called by an ancestor
61
+ * component. Only use this inside Svelte components; for standalone scripts
62
+ * keep an explicit reference to the client instead.
63
+ *
64
+ * @throws `Error` when no client is found in the component context.
19
65
  */
20
66
  function getSyncoreClient() {
21
67
  const client = getContext(SYNCORE_CLIENT_CONTEXT);
22
68
  if (!client) throw new Error("Syncore client is missing from the Svelte component context.");
23
69
  return client;
24
70
  }
71
+ /**
72
+ * Create a reactive Svelte store that tracks the Syncore runtime status.
73
+ *
74
+ * Uses the client from Svelte context (set via {@link setSyncoreClient}).
75
+ * Subscribe to gate your UI on `"ready"` before rendering data-dependent
76
+ * components.
77
+ *
78
+ * ```svelte
79
+ * <script>
80
+ * import { createSyncoreStatusStore } from "syncorejs/svelte";
81
+ * const status = createSyncoreStatusStore();
82
+ * <\/script>
83
+ *
84
+ * {#if $status.kind === "ready"}
85
+ * <App />
86
+ * {:else}
87
+ * <Loading />
88
+ * {/if}
89
+ * ```
90
+ */
25
91
  function createSyncoreStatusStore() {
26
92
  return createClientSyncoreStatusStore(getSyncoreClient());
27
93
  }
94
+ /**
95
+ * Create a reactive Svelte store that tracks the Syncore runtime status.
96
+ *
97
+ * Accepts an explicit `client` rather than reading from Svelte context,
98
+ * making it usable outside component trees (e.g. in module-level code or
99
+ * SvelteKit `load` functions).
100
+ *
101
+ * @param client - The Syncore client to observe.
102
+ */
28
103
  function createClientSyncoreStatusStore(client) {
29
104
  return readable(defaultRuntimeStatus, createStatusStoreStart(client));
30
105
  }
31
106
  /**
32
- * Creates a reactive store for a Syncore query result using the contextual client.
107
+ * Create a reactive Svelte store that emits the current value of a Syncore
108
+ * query, or `undefined` while loading.
109
+ *
110
+ * Uses the client from Svelte context (set via {@link setSyncoreClient}).
111
+ * Pass `skip` as `args` to pause the query.
112
+ *
113
+ * ```svelte
114
+ * <script>
115
+ * import { createQueryValueStore } from "syncorejs/svelte";
116
+ * import { api } from "../syncore/_generated/api";
117
+ *
118
+ * const todos = createQueryValueStore(api.todos.list);
119
+ * <\/script>
120
+ *
121
+ * {#each $todos ?? [] as todo}
122
+ * <p>{todo.text}</p>
123
+ * {/each}
124
+ * ```
33
125
  */
34
126
  function createQueryValueStore(reference, ...args) {
35
127
  return createClientQueryValueStore(getSyncoreClient(), reference, ...args);
36
128
  }
37
129
  /**
38
- * Creates a reactive store for a Syncore query result using an explicit client.
130
+ * Create a reactive Svelte store that emits the current value of a Syncore
131
+ * query, or `undefined` while loading.
132
+ *
133
+ * Accepts an explicit `client` instead of reading from Svelte context.
134
+ *
135
+ * @param client - The Syncore client to query against.
39
136
  */
40
137
  function createClientQueryValueStore(client, reference, ...args) {
41
138
  return derived(createClientQueryStore(client, reference, ...args), ($state) => $state.data);
42
139
  }
43
140
  /**
44
- * Creates a reactive store with the full Syncore query state.
141
+ * Create a reactive Svelte store that emits the full SyncoreQueryState
142
+ * for a query, including `data`, `error`, `status`, and `isPending`.
143
+ *
144
+ * Uses the client from Svelte context (set via {@link setSyncoreClient}).
145
+ *
146
+ * ```svelte
147
+ * <script>
148
+ * import { createQueryStore } from "syncorejs/svelte";
149
+ * import { api } from "../syncore/_generated/api";
150
+ *
151
+ * const state = createQueryStore(api.todos.list);
152
+ * <\/script>
153
+ *
154
+ * {#if $state.isPending}
155
+ * <Spinner />
156
+ * {:else if $state.error}
157
+ * <Error message={$state.error.message} />
158
+ * {:else}
159
+ * {#each $state.data as todo}<p>{todo.text}</p>{/each}
160
+ * {/if}
161
+ * ```
45
162
  */
46
163
  function createQueryStore(reference, ...args) {
47
164
  return createClientQueryStore(getSyncoreClient(), reference, ...args);
48
165
  }
49
166
  /**
50
- * Creates a reactive store with the full Syncore query state for an explicit client.
167
+ * Create a reactive Svelte store that emits the full SyncoreQueryState
168
+ * for a query, including `data`, `error`, `status`, and `isPending`.
169
+ *
170
+ * Accepts an explicit `client` instead of reading from Svelte context.
171
+ *
172
+ * @param client - The Syncore client to query against.
51
173
  */
52
174
  function createClientQueryStore(client, reference, ...args) {
53
175
  const isSkipped = args[0] === skip;
@@ -57,9 +179,38 @@ function createClientQueryStore(client, reference, ...args) {
57
179
  error: void 0
58
180
  }, defaultRuntimeStatus, isSkipped), createQueryStoreStart(client, reference, normalizedArgs, isSkipped));
59
181
  }
182
+ /**
183
+ * Create a reactive Svelte store that simultaneously observes multiple
184
+ * Syncore queries.
185
+ *
186
+ * Uses the client from Svelte context (set via {@link setSyncoreClient}).
187
+ * Each key in `entries` corresponds to a key in the emitted result object.
188
+ *
189
+ * ```svelte
190
+ * <script>
191
+ * import { createQueriesStore } from "syncorejs/svelte";
192
+ * import { api } from "../syncore/_generated/api";
193
+ *
194
+ * const stores = createQueriesStore({
195
+ * todos: { query: api.todos.list },
196
+ * user: { query: api.users.me },
197
+ * });
198
+ * <\/script>
199
+ *
200
+ * <p>{$stores.user.data?.name} has {$stores.todos.data?.length} todos</p>
201
+ * ```
202
+ */
60
203
  function createQueriesStore(entries) {
61
204
  return createClientQueriesStore(getSyncoreClient(), entries);
62
205
  }
206
+ /**
207
+ * Create a reactive Svelte store that simultaneously observes multiple
208
+ * Syncore queries.
209
+ *
210
+ * Accepts an explicit `client` instead of reading from Svelte context.
211
+ *
212
+ * @param client - The Syncore client to query against.
213
+ */
63
214
  function createClientQueriesStore(client, entries) {
64
215
  const normalizedEntries = Object.entries(entries).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => ({
65
216
  key,
@@ -90,9 +241,53 @@ function createClientQueriesStore(client, entries) {
90
241
  };
91
242
  });
92
243
  }
244
+ /**
245
+ * Create a reactive Svelte store for cursor-based paginated Syncore queries.
246
+ *
247
+ * Uses the client from Svelte context (set via {@link setSyncoreClient}).
248
+ * The store handles page tracking and exposes a `loadMore()` function so you
249
+ * can implement “Load More” UIs without manual cursor management.
250
+ *
251
+ * The query referenced by `reference` must accept a `paginationOpts`
252
+ * argument and return a PaginationResult.
253
+ *
254
+ * ```svelte
255
+ * <script>
256
+ * import { createPaginatedQueryStore } from "syncorejs/svelte";
257
+ * import { api } from "../syncore/_generated/api";
258
+ *
259
+ * const result = createPaginatedQueryStore(
260
+ * api.todos.listPaginated,
261
+ * {},
262
+ * { initialNumItems: 10 }
263
+ * );
264
+ * <\/script>
265
+ *
266
+ * {#each $result.results as todo}<p>{todo.text}</p>{/each}
267
+ * {#if $result.canLoadMore}
268
+ * <button on:click={() => $result.loadMore(10)}>Load more</button>
269
+ * {/if}
270
+ * ```
271
+ *
272
+ * @param reference - A paginated query function reference.
273
+ * @param args - Query arguments excluding `paginationOpts`, or `skip`.
274
+ * @param options - Pagination options. `initialNumItems` controls the number
275
+ * of items to fetch on the first page.
276
+ */
93
277
  function createPaginatedQueryStore(reference, args, options) {
94
278
  return createClientPaginatedQueryStore(getSyncoreClient(), reference, args, options);
95
279
  }
280
+ /**
281
+ * Create a reactive Svelte store for cursor-based paginated Syncore queries.
282
+ *
283
+ * Accepts an explicit `client` instead of reading from Svelte context.
284
+ *
285
+ * @param client - The Syncore client to query against.
286
+ * @param reference - A paginated query function reference.
287
+ * @param args - Query arguments excluding `paginationOpts`, or `skip`.
288
+ * @param options - Pagination options. `initialNumItems` controls the number
289
+ * of items to fetch on the first page.
290
+ */
96
291
  function createClientPaginatedQueryStore(client, reference, args, options) {
97
292
  if (typeof options.initialNumItems !== "number" || options.initialNumItems <= 0) throw new Error(`options.initialNumItems must be a positive number. Received ${String(options.initialNumItems)}.`);
98
293
  const isSkipped = args === skip;