syncorejs 0.2.3 → 0.2.5
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.
- package/dist/_dashboard/assets/ConfirmActionDialog-Db4VzVp6.js +1 -0
- package/dist/_dashboard/assets/circle-x-VsB4Z8W4.js +1 -0
- package/dist/_dashboard/assets/data.lazy-DjdU9CzX.js +18 -0
- package/dist/_dashboard/assets/file-code-BrOKjG4n.js +1 -0
- package/dist/_dashboard/assets/functions.lazy-DvDwAGHq.js +1 -0
- package/dist/_dashboard/assets/funnel-BH8EMMJI.js +1 -0
- package/dist/_dashboard/assets/index-DT9ZEELb.css +1 -0
- package/dist/_dashboard/assets/index-DrSG4qZZ.js +54 -0
- package/dist/_dashboard/assets/loader-circle-CmJFSYga.js +1 -0
- package/dist/_dashboard/assets/logs.lazy-50KTk5yd.js +1 -0
- package/dist/_dashboard/assets/play-DS52VsLN.js +1 -0
- package/dist/_dashboard/assets/queries.lazy-CfysRWkz.js +1 -0
- package/dist/_dashboard/assets/scheduler.lazy-BB88mZk-.js +1 -0
- package/dist/_dashboard/assets/select-THYcR8Wt.js +1 -0
- package/dist/_dashboard/assets/separator-BU7xg615.js +1 -0
- package/dist/_dashboard/assets/shared-Bh0wwC2k.js +1 -0
- package/dist/_dashboard/assets/sql.lazy-CHtU9Qnt.js +13 -0
- package/dist/_dashboard/assets/storage.lazy-CneN7wVU.js +1 -0
- package/dist/_dashboard/assets/table-2-CH8JoMXf.js +1 -0
- package/dist/_dashboard/index.html +18 -0
- package/dist/_vendor/cli/app.d.mts.map +1 -1
- package/dist/_vendor/cli/app.mjs +16 -5
- package/dist/_vendor/cli/app.mjs.map +1 -1
- package/dist/_vendor/core/cli.d.mts.map +1 -1
- package/dist/_vendor/core/cli.mjs +358 -16
- package/dist/_vendor/core/cli.mjs.map +1 -1
- package/dist/_vendor/core/index.d.mts +3 -3
- package/dist/_vendor/core/runtime/devtools.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/devtools.mjs +131 -0
- package/dist/_vendor/core/runtime/devtools.mjs.map +1 -1
- package/dist/_vendor/core/runtime/functions.d.mts +3 -3
- package/dist/_vendor/core/runtime/functions.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs +1 -1
- package/dist/_vendor/core/runtime/internal/engines/devtoolsEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs +4 -1
- package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs +6 -3
- package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs +5 -1
- package/dist/_vendor/core/runtime/internal/engines/shared.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs +99 -13
- package/dist/_vendor/core/runtime/internal/engines/storageEngine.mjs.map +1 -1
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs +38 -4
- package/dist/_vendor/core/runtime/internal/runtimeKernel.mjs.map +1 -1
- package/dist/_vendor/core/runtime/runtime.d.mts +65 -8
- package/dist/_vendor/core/runtime/runtime.d.mts.map +1 -1
- package/dist/_vendor/core/runtime/runtime.mjs.map +1 -1
- package/dist/_vendor/core/transport.d.mts.map +1 -1
- package/dist/_vendor/core/transport.mjs +30 -5
- package/dist/_vendor/core/transport.mjs.map +1 -1
- package/dist/_vendor/devtools-protocol/index.d.ts +75 -1
- package/dist/_vendor/devtools-protocol/index.d.ts.map +1 -1
- package/dist/_vendor/devtools-protocol/index.js.map +1 -1
- package/dist/_vendor/next/index.js +9 -1
- package/dist/_vendor/next/index.js.map +1 -1
- package/dist/_vendor/platform-expo/index.d.ts +1 -1
- package/dist/_vendor/platform-expo/index.d.ts.map +1 -1
- package/dist/_vendor/platform-expo/index.js +6 -1
- package/dist/_vendor/platform-expo/index.js.map +1 -1
- package/dist/_vendor/platform-node/index.d.mts +2 -1
- package/dist/_vendor/platform-node/index.d.mts.map +1 -1
- package/dist/_vendor/platform-node/index.mjs +27 -2
- package/dist/_vendor/platform-node/index.mjs.map +1 -1
- package/dist/_vendor/platform-node/ipc-react.mjs +4 -0
- package/dist/_vendor/platform-node/ipc-react.mjs.map +1 -1
- package/dist/_vendor/platform-web/external-change.d.ts +2 -2
- package/dist/_vendor/platform-web/external-change.js +2 -2
- package/dist/_vendor/platform-web/external-change.js.map +1 -1
- package/dist/_vendor/platform-web/index.d.ts +13 -10
- package/dist/_vendor/platform-web/index.d.ts.map +1 -1
- package/dist/_vendor/platform-web/index.js +66 -10
- package/dist/_vendor/platform-web/index.js.map +1 -1
- package/dist/_vendor/platform-web/indexeddb.d.ts +3 -3
- package/dist/_vendor/platform-web/indexeddb.js +3 -3
- package/dist/_vendor/platform-web/indexeddb.js.map +1 -1
- package/dist/_vendor/platform-web/opfs.d.ts +3 -1
- package/dist/_vendor/platform-web/opfs.d.ts.map +1 -1
- package/dist/_vendor/platform-web/opfs.js +29 -3
- package/dist/_vendor/platform-web/opfs.js.map +1 -1
- package/dist/_vendor/platform-web/persistence.d.ts +31 -1
- package/dist/_vendor/platform-web/persistence.d.ts.map +1 -1
- package/dist/_vendor/platform-web/persistence.js.map +1 -1
- package/dist/_vendor/platform-web/react.d.ts.map +1 -1
- package/dist/_vendor/platform-web/react.js +9 -1
- package/dist/_vendor/platform-web/react.js.map +1 -1
- package/dist/_vendor/react/index.d.ts +6 -5
- package/dist/_vendor/react/index.d.ts.map +1 -1
- package/dist/_vendor/react/index.js +6 -5
- package/dist/_vendor/react/index.js.map +1 -1
- package/dist/_vendor/svelte/index.d.ts +8 -6
- package/dist/_vendor/svelte/index.d.ts.map +1 -1
- package/dist/_vendor/svelte/index.js +7 -5
- package/dist/_vendor/svelte/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -21,7 +21,7 @@ type PaginatedQueryItem<TReference extends FunctionReference<"query">> = Functio
|
|
|
21
21
|
/**
|
|
22
22
|
* The reactive query state shape emitted by Syncore's Svelte store factories.
|
|
23
23
|
*
|
|
24
|
-
* Extends
|
|
24
|
+
* Extends SyncoreQueryState with the same fields (`data`, `error`,
|
|
25
25
|
* `status`, `runtimeStatus`, `isLoading`, `isError`, `isReady`). Returned as
|
|
26
26
|
* the value of stores created by {@link createQueryStore} and
|
|
27
27
|
* {@link createClientQueryStore}.
|
|
@@ -145,7 +145,7 @@ declare function createQueryValueStore<TReference extends FunctionReference<"que
|
|
|
145
145
|
*/
|
|
146
146
|
declare function createClientQueryValueStore<TReference extends FunctionReference<"query">>(client: SyncoreClient, reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<FunctionResult<TReference> | undefined>;
|
|
147
147
|
/**
|
|
148
|
-
* Create a reactive Svelte store that emits the full
|
|
148
|
+
* Create a reactive Svelte store that emits the full SyncoreQueryState
|
|
149
149
|
* for a query, including `data`, `error`, `status`, and `isPending`.
|
|
150
150
|
*
|
|
151
151
|
* Uses the client from Svelte context (set via {@link setSyncoreClient}).
|
|
@@ -169,7 +169,7 @@ declare function createClientQueryValueStore<TReference extends FunctionReferenc
|
|
|
169
169
|
*/
|
|
170
170
|
declare function createQueryStore<TReference extends FunctionReference<"query">>(reference: TReference, ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>>;
|
|
171
171
|
/**
|
|
172
|
-
* Create a reactive Svelte store that emits the full
|
|
172
|
+
* Create a reactive Svelte store that emits the full SyncoreQueryState
|
|
173
173
|
* for a query, including `data`, `error`, `status`, and `isPending`.
|
|
174
174
|
*
|
|
175
175
|
* Accepts an explicit `client` instead of reading from Svelte context.
|
|
@@ -216,7 +216,7 @@ declare function createClientQueriesStore<TEntries extends QueriesRequestInput>(
|
|
|
216
216
|
* can implement “Load More” UIs without manual cursor management.
|
|
217
217
|
*
|
|
218
218
|
* The query referenced by `reference` must accept a `paginationOpts`
|
|
219
|
-
* argument and return a
|
|
219
|
+
* argument and return a PaginationResult.
|
|
220
220
|
*
|
|
221
221
|
* ```svelte
|
|
222
222
|
* <script>
|
|
@@ -238,7 +238,8 @@ declare function createClientQueriesStore<TEntries extends QueriesRequestInput>(
|
|
|
238
238
|
*
|
|
239
239
|
* @param reference - A paginated query function reference.
|
|
240
240
|
* @param args - Query arguments excluding `paginationOpts`, or `skip`.
|
|
241
|
-
* @param options
|
|
241
|
+
* @param options - Pagination options. `initialNumItems` controls the number
|
|
242
|
+
* of items to fetch on the first page.
|
|
242
243
|
*/
|
|
243
244
|
declare function createPaginatedQueryStore<TReference extends PaginatedQueryReference>(reference: TReference, args: PaginatedQueryArgs<TReference> | Skip, options: {
|
|
244
245
|
initialNumItems: number;
|
|
@@ -251,7 +252,8 @@ declare function createPaginatedQueryStore<TReference extends PaginatedQueryRefe
|
|
|
251
252
|
* @param client - The Syncore client to query against.
|
|
252
253
|
* @param reference - A paginated query function reference.
|
|
253
254
|
* @param args - Query arguments excluding `paginationOpts`, or `skip`.
|
|
254
|
-
* @param options
|
|
255
|
+
* @param options - Pagination options. `initialNumItems` controls the number
|
|
256
|
+
* of items to fetch on the first page.
|
|
255
257
|
*/
|
|
256
258
|
declare function createClientPaginatedQueryStore<TReference extends PaginatedQueryReference>(client: SyncoreClient, reference: TReference, args: PaginatedQueryArgs<TReference> | Skip, options: {
|
|
257
259
|
initialNumItems: number;
|
|
@@ -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,UA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;EACE,eAAA;AAAA,IAED,QAAA,CAAS,uBAAA,CAAwB,kBAAA,CAAmB,UAAA;;;;;;;;;;;;iBAoBvC,+BAAA,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"}
|
|
@@ -138,7 +138,7 @@ function createClientQueryValueStore(client, reference, ...args) {
|
|
|
138
138
|
return derived(createClientQueryStore(client, reference, ...args), ($state) => $state.data);
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
|
-
* Create a reactive Svelte store that emits the full
|
|
141
|
+
* Create a reactive Svelte store that emits the full SyncoreQueryState
|
|
142
142
|
* for a query, including `data`, `error`, `status`, and `isPending`.
|
|
143
143
|
*
|
|
144
144
|
* Uses the client from Svelte context (set via {@link setSyncoreClient}).
|
|
@@ -164,7 +164,7 @@ function createQueryStore(reference, ...args) {
|
|
|
164
164
|
return createClientQueryStore(getSyncoreClient(), reference, ...args);
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
167
|
-
* Create a reactive Svelte store that emits the full
|
|
167
|
+
* Create a reactive Svelte store that emits the full SyncoreQueryState
|
|
168
168
|
* for a query, including `data`, `error`, `status`, and `isPending`.
|
|
169
169
|
*
|
|
170
170
|
* Accepts an explicit `client` instead of reading from Svelte context.
|
|
@@ -249,7 +249,7 @@ function createClientQueriesStore(client, entries) {
|
|
|
249
249
|
* can implement “Load More” UIs without manual cursor management.
|
|
250
250
|
*
|
|
251
251
|
* The query referenced by `reference` must accept a `paginationOpts`
|
|
252
|
-
* argument and return a
|
|
252
|
+
* argument and return a PaginationResult.
|
|
253
253
|
*
|
|
254
254
|
* ```svelte
|
|
255
255
|
* <script>
|
|
@@ -271,7 +271,8 @@ function createClientQueriesStore(client, entries) {
|
|
|
271
271
|
*
|
|
272
272
|
* @param reference - A paginated query function reference.
|
|
273
273
|
* @param args - Query arguments excluding `paginationOpts`, or `skip`.
|
|
274
|
-
* @param options
|
|
274
|
+
* @param options - Pagination options. `initialNumItems` controls the number
|
|
275
|
+
* of items to fetch on the first page.
|
|
275
276
|
*/
|
|
276
277
|
function createPaginatedQueryStore(reference, args, options) {
|
|
277
278
|
return createClientPaginatedQueryStore(getSyncoreClient(), reference, args, options);
|
|
@@ -284,7 +285,8 @@ function createPaginatedQueryStore(reference, args, options) {
|
|
|
284
285
|
* @param client - The Syncore client to query against.
|
|
285
286
|
* @param reference - A paginated query function reference.
|
|
286
287
|
* @param args - Query arguments excluding `paginationOpts`, or `skip`.
|
|
287
|
-
* @param options
|
|
288
|
+
* @param options - Pagination options. `initialNumItems` controls the number
|
|
289
|
+
* of items to fetch on the first page.
|
|
288
290
|
*/
|
|
289
291
|
function createClientPaginatedQueryStore(client, reference, args, options) {
|
|
290
292
|
if (typeof options.initialNumItems !== "number" || options.initialNumItems <= 0) throw new Error(`options.initialNumItems must be a positive number. Received ${String(options.initialNumItems)}.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n derived,\n type Readable,\n readable,\n type StartStopNotifier\n} from \"svelte/store\";\nimport { getContext, setContext } from \"svelte\";\nimport type {\n FunctionArgs,\n FunctionReference,\n FunctionResult,\n PaginationOptions,\n PaginationResult,\n SyncoreClient,\n SyncoreQueryState,\n SyncoreRuntimeStatus,\n SyncoreWatch,\n UsePaginatedQueryResult\n} from \"@syncore/core\";\n\nexport type OptionalArgsTuple<TArgs> =\n Record<never, never> extends TArgs ? [args?: TArgs] : [args: TArgs];\n\ntype ManagedSyncoreWatch<TResult> = SyncoreWatch<TResult> & {\n dispose?: () => void;\n};\n\ntype QueryRequestInput<\n TReference extends FunctionReference<\"query\"> = FunctionReference<\"query\">\n> = Record<never, never> extends FunctionArgs<TReference>\n ? {\n query: TReference;\n args?: FunctionArgs<TReference> | Skip;\n }\n : {\n query: TReference;\n args: FunctionArgs<TReference> | Skip;\n };\n\ntype QueriesRequestInput = Record<string, QueryRequestInput>;\n\ntype QueryStateForEntry<TEntry> = TEntry extends QueryRequestInput<\n infer TReference\n>\n ? SyncoreQueryState<FunctionResult<TReference>>\n : never;\n\nexport type CreateQueriesStoreResult<TEntries extends QueriesRequestInput> = {\n [TKey in keyof TEntries]: QueryStateForEntry<TEntries[TKey]>;\n};\n\ntype PaginatedQueryReference = FunctionReference<\n \"query\",\n Record<string, unknown>,\n PaginationResult<unknown>\n>;\n\ntype PaginatedQueryArgs<TReference extends FunctionReference<\"query\">> =\n FunctionArgs<TReference> extends { paginationOpts: PaginationOptions }\n ? Omit<FunctionArgs<TReference>, \"paginationOpts\">\n : never;\n\ntype PaginatedQueryItem<TReference extends FunctionReference<\"query\">> =\n FunctionResult<TReference> extends PaginationResult<infer TItem>\n ? TItem\n : never;\n\ntype PaginatedQueryInternalState = {\n nextPageKey: number;\n pages: Array<{\n key: string;\n cursor: string | null;\n numItems: number;\n }>;\n};\n\n/**\n * The reactive query state shape emitted by Syncore's Svelte store factories.\n *\n * Extends {@link SyncoreQueryState} with the same fields (`data`, `error`,\n * `status`, `runtimeStatus`, `isLoading`, `isError`, `isReady`). Returned as\n * the value of stores created by {@link createQueryStore} and\n * {@link createClientQueryStore}.\n */\nexport interface SyncoreQueryStoreState<TResult>\n extends SyncoreQueryState<TResult> {}\n\n/**\n * A sentinel value that tells Syncore store factories to skip the query.\n *\n * Use `skip` in place of a query’s `args` argument to avoid firing the query\n * while some required data is not yet available (e.g. a user ID that loads\n * asynchronously). The store will remain in a `\"loading\"` / skipped state\n * until a non-skip value is provided.\n *\n * ```svelte\n * <script>\n * import { createQueryValueStore, skip } from \"syncorejs/svelte\";\n * import { api } from \"../syncore/_generated/api\";\n *\n * export let userId: string | undefined;\n *\n * $: profile = createQueryValueStore(\n * api.users.get,\n * userId ? { id: userId } : skip\n * );\n * </script>\n * ```\n */\nexport const skip = \"skip\" as const;\ntype Skip = typeof skip;\n\nconst defaultRuntimeStatus: SyncoreRuntimeStatus = {\n kind: \"starting\",\n reason: \"booting\"\n};\n\nconst SYNCORE_CLIENT_CONTEXT = Symbol(\"syncore.client\");\n\n/**\n * Store the Syncore client in Svelte’s component context.\n *\n * Call this once at the root of your component tree (e.g. in a layout or\n * root `+layout.svelte`) so that the context-aware store factories\n * (`createQueryStore`, `createQueriesStore`, etc.) can retrieve it\n * automatically without prop-drilling.\n *\n * ```svelte\n * <!-- +layout.svelte -->\n * <script>\n * import { setSyncoreClient } from \"syncorejs/svelte\";\n * export let data; // { client } from +layout.ts\n * setSyncoreClient(data.client);\n * </script>\n * <slot />\n * ```\n *\n * @param client - The ready Syncore client to store in context.\n * @returns The same `client` for convenience.\n */\nexport function setSyncoreClient(client: SyncoreClient): SyncoreClient {\n setContext(SYNCORE_CLIENT_CONTEXT, client);\n return client;\n}\n\n/**\n * Retrieve the Syncore client from Svelte’s component context.\n *\n * Throws if {@link setSyncoreClient} has not been called by an ancestor\n * component. Only use this inside Svelte components; for standalone scripts\n * keep an explicit reference to the client instead.\n *\n * @throws `Error` when no client is found in the component context.\n */\nexport function getSyncoreClient(): SyncoreClient {\n const client = getContext<SyncoreClient | undefined>(SYNCORE_CLIENT_CONTEXT);\n if (!client) {\n throw new Error(\n \"Syncore client is missing from the Svelte component context.\"\n );\n }\n return client;\n}\n\n/**\n * Create a reactive Svelte store that tracks the Syncore runtime status.\n *\n * Uses the client from Svelte context (set via {@link setSyncoreClient}).\n * Subscribe to gate your UI on `\"ready\"` before rendering data-dependent\n * components.\n *\n * ```svelte\n * <script>\n * import { createSyncoreStatusStore } from \"syncorejs/svelte\";\n * const status = createSyncoreStatusStore();\n * </script>\n *\n * {#if $status.kind === \"ready\"}\n * <App />\n * {:else}\n * <Loading />\n * {/if}\n * ```\n */\nexport function createSyncoreStatusStore(): Readable<SyncoreRuntimeStatus> {\n return createClientSyncoreStatusStore(getSyncoreClient());\n}\n\n/**\n * Create a reactive Svelte store that tracks the Syncore runtime status.\n *\n * Accepts an explicit `client` rather than reading from Svelte context,\n * making it usable outside component trees (e.g. in module-level code or\n * SvelteKit `load` functions).\n *\n * @param client - The Syncore client to observe.\n */\nexport function createClientSyncoreStatusStore(\n client: SyncoreClient\n): Readable<SyncoreRuntimeStatus> {\n return readable<SyncoreRuntimeStatus>(\n defaultRuntimeStatus,\n createStatusStoreStart(client)\n );\n}\n\n/**\n * Create a reactive Svelte store that emits the current value of a Syncore\n * query, or `undefined` while loading.\n *\n * Uses the client from Svelte context (set via {@link setSyncoreClient}).\n * Pass `skip` as `args` to pause the query.\n *\n * ```svelte\n * <script>\n * import { createQueryValueStore } from \"syncorejs/svelte\";\n * import { api } from \"../syncore/_generated/api\";\n *\n * const todos = createQueryValueStore(api.todos.list);\n * </script>\n *\n * {#each $todos ?? [] as todo}\n * <p>{todo.text}</p>\n * {/each}\n * ```\n */\nexport function createQueryValueStore<\n TReference extends FunctionReference<\"query\">\n>(\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<FunctionResult<TReference> | undefined> {\n return createClientQueryValueStore(getSyncoreClient(), reference, ...args);\n}\n\n/**\n * Create a reactive Svelte store that emits the current value of a Syncore\n * query, or `undefined` while loading.\n *\n * Accepts an explicit `client` instead of reading from Svelte context.\n *\n * @param client - The Syncore client to query against.\n */\nexport function createClientQueryValueStore<\n TReference extends FunctionReference<\"query\">\n>(\n client: SyncoreClient,\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<FunctionResult<TReference> | undefined> {\n return derived(\n createClientQueryStore(client, reference, ...(args as OptionalArgsTuple<\n FunctionArgs<TReference>\n > | [Skip])),\n ($state) => $state.data\n );\n}\n\n/**\n * Create a reactive Svelte store that emits the full {@link SyncoreQueryState}\n * for a query, including `data`, `error`, `status`, and `isPending`.\n *\n * Uses the client from Svelte context (set via {@link setSyncoreClient}).\n *\n * ```svelte\n * <script>\n * import { createQueryStore } from \"syncorejs/svelte\";\n * import { api } from \"../syncore/_generated/api\";\n *\n * const state = createQueryStore(api.todos.list);\n * </script>\n *\n * {#if $state.isPending}\n * <Spinner />\n * {:else if $state.error}\n * <Error message={$state.error.message} />\n * {:else}\n * {#each $state.data as todo}<p>{todo.text}</p>{/each}\n * {/if}\n * ```\n */\nexport function createQueryStore<TReference extends FunctionReference<\"query\">>(\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n return createClientQueryStore(getSyncoreClient(), reference, ...args);\n}\n\n/**\n * Create a reactive Svelte store that emits the full {@link SyncoreQueryState}\n * for a query, including `data`, `error`, `status`, and `isPending`.\n *\n * Accepts an explicit `client` instead of reading from Svelte context.\n *\n * @param client - The Syncore client to query against.\n */\nexport function createClientQueryStore<\n TReference extends FunctionReference<\"query\">\n>(\n client: SyncoreClient,\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n const isSkipped = args[0] === skip;\n const normalizedArgs = isSkipped\n ? undefined\n : normalizeOptionalArgs(args as OptionalArgsTuple<FunctionArgs<TReference>>);\n return readable<SyncoreQueryStoreState<FunctionResult<TReference>>>(\n toQueryState<FunctionResult<TReference>>(\n {\n data: undefined,\n error: undefined\n },\n defaultRuntimeStatus,\n isSkipped\n ),\n createQueryStoreStart(client, reference, normalizedArgs, isSkipped)\n );\n}\n\n/**\n * Create a reactive Svelte store that simultaneously observes multiple\n * Syncore queries.\n *\n * Uses the client from Svelte context (set via {@link setSyncoreClient}).\n * Each key in `entries` corresponds to a key in the emitted result object.\n *\n * ```svelte\n * <script>\n * import { createQueriesStore } from \"syncorejs/svelte\";\n * import { api } from \"../syncore/_generated/api\";\n *\n * const stores = createQueriesStore({\n * todos: { query: api.todos.list },\n * user: { query: api.users.me },\n * });\n * </script>\n *\n * <p>{$stores.user.data?.name} has {$stores.todos.data?.length} todos</p>\n * ```\n */\nexport function createQueriesStore<TEntries extends QueriesRequestInput>(\n entries: TEntries\n): Readable<CreateQueriesStoreResult<TEntries>> {\n return createClientQueriesStore(getSyncoreClient(), entries);\n}\n\n/**\n * Create a reactive Svelte store that simultaneously observes multiple\n * Syncore queries.\n *\n * Accepts an explicit `client` instead of reading from Svelte context.\n *\n * @param client - The Syncore client to query against.\n */\nexport function createClientQueriesStore<TEntries extends QueriesRequestInput>(\n client: SyncoreClient,\n entries: TEntries\n): Readable<CreateQueriesStoreResult<TEntries>> {\n const normalizedEntries = Object.entries(entries)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, entry]) => ({\n key,\n query: entry.query,\n skipped: entry.args === skip,\n args:\n entry.args === skip\n ? {}\n : normalizeOptionalArgs([entry.args ?? {}] as [] | [unknown])\n }));\n\n return readable<CreateQueriesStoreResult<TEntries>>(\n {} as CreateQueriesStoreResult<TEntries>,\n (set) => {\n const runtimeWatch = client.watchRuntimeStatus();\n const watches = normalizedEntries.map((entry) => ({\n key: entry.key,\n skipped: entry.skipped,\n watch: entry.skipped\n ? (noOpWatch as ManagedSyncoreWatch<unknown>)\n : (client.watchQuery(entry.query, entry.args) as ManagedSyncoreWatch<\n unknown\n >)\n }));\n const publish = () => {\n const runtimeStatus = readRuntimeStatus(runtimeWatch);\n set(\n Object.fromEntries(\n watches.map((entry) => [\n entry.key,\n toQueryState(\n entry.skipped\n ? {\n data: undefined,\n error: undefined\n }\n : readWatchSnapshot(entry.watch),\n runtimeStatus,\n entry.skipped\n )\n ])\n ) as CreateQueriesStoreResult<TEntries>\n );\n };\n\n publish();\n const cleanups = [\n runtimeWatch.onUpdate(publish),\n ...watches.map((entry) => entry.watch.onUpdate(publish))\n ];\n\n return () => {\n for (const cleanup of cleanups) {\n cleanup();\n }\n runtimeWatch.dispose?.();\n for (const entry of watches) {\n if (!entry.skipped) {\n entry.watch.dispose?.();\n }\n }\n };\n }\n );\n}\n\n/**\n * Create a reactive Svelte store for cursor-based paginated Syncore queries.\n *\n * Uses the client from Svelte context (set via {@link setSyncoreClient}).\n * The store handles page tracking and exposes a `loadMore()` function so you\n * can implement “Load More” UIs without manual cursor management.\n *\n * The query referenced by `reference` must accept a `paginationOpts`\n * argument and return a {@link PaginationResult}.\n *\n * ```svelte\n * <script>\n * import { createPaginatedQueryStore } from \"syncorejs/svelte\";\n * import { api } from \"../syncore/_generated/api\";\n *\n * const result = createPaginatedQueryStore(\n * api.todos.listPaginated,\n * {},\n * { initialNumItems: 10 }\n * );\n * </script>\n *\n * {#each $result.results as todo}<p>{todo.text}</p>{/each}\n * {#if $result.canLoadMore}\n * <button on:click={() => $result.loadMore(10)}>Load more</button>\n * {/if}\n * ```\n *\n * @param reference - A paginated query function reference.\n * @param args - Query arguments excluding `paginationOpts`, or `skip`.\n * @param options.initialNumItems - Number of items to fetch on the first page.\n */\nexport function createPaginatedQueryStore<\n TReference extends PaginatedQueryReference\n>(\n reference: TReference,\n args: PaginatedQueryArgs<TReference> | Skip,\n options: {\n initialNumItems: number;\n }\n): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>> {\n return createClientPaginatedQueryStore(\n getSyncoreClient(),\n reference,\n args,\n options\n );\n}\n\n/**\n * Create a reactive Svelte store for cursor-based paginated Syncore queries.\n *\n * Accepts an explicit `client` instead of reading from Svelte context.\n *\n * @param client - The Syncore client to query against.\n * @param reference - A paginated query function reference.\n * @param args - Query arguments excluding `paginationOpts`, or `skip`.\n * @param options.initialNumItems - Number of items to fetch on the first page.\n */\nexport function createClientPaginatedQueryStore<\n TReference extends PaginatedQueryReference\n>(\n client: SyncoreClient,\n reference: TReference,\n args: PaginatedQueryArgs<TReference> | Skip,\n options: {\n initialNumItems: number;\n }\n): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>> {\n if (\n typeof options.initialNumItems !== \"number\" ||\n options.initialNumItems <= 0\n ) {\n throw new Error(\n `options.initialNumItems must be a positive number. Received ${String(\n options.initialNumItems\n )}.`\n );\n }\n\n const isSkipped = args === skip;\n const baseArgs = isSkipped ? {} : (args ?? {});\n\n return readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>>(\n createEmptyPaginatedResult(defaultRuntimeStatus),\n (set) => {\n const runtimeWatch = client.watchRuntimeStatus();\n let state: PaginatedQueryInternalState = {\n nextPageKey: 1,\n pages: isSkipped\n ? []\n : [\n {\n key: \"0\",\n cursor: null,\n numItems: options.initialNumItems\n }\n ]\n };\n const pageEntries = new Map<\n string,\n {\n cursor: string | null;\n numItems: number;\n watch: ManagedSyncoreWatch<PaginationResult<PaginatedQueryItem<TReference>>>;\n unsubscribe: () => void;\n }\n >();\n\n const disposePage = (key: string) => {\n const entry = pageEntries.get(key);\n if (!entry) {\n return;\n }\n entry.unsubscribe();\n entry.watch.dispose?.();\n pageEntries.delete(key);\n };\n\n const ensurePages = () => {\n const activeKeys = new Set(state.pages.map((page) => page.key));\n for (const page of state.pages) {\n if (pageEntries.has(page.key)) {\n continue;\n }\n const watch = client.watchQuery(reference, {\n ...(baseArgs as Record<string, unknown>),\n paginationOpts: {\n cursor: page.cursor,\n numItems: page.numItems\n }\n }) as ManagedSyncoreWatch<PaginationResult<PaginatedQueryItem<TReference>>>;\n const unsubscribe = watch.onUpdate(publish);\n pageEntries.set(page.key, {\n cursor: page.cursor,\n numItems: page.numItems,\n watch,\n unsubscribe\n });\n }\n for (const key of [...pageEntries.keys()]) {\n if (!activeKeys.has(key)) {\n disposePage(key);\n }\n }\n };\n\n const deriveResult = (\n runtimeStatus: SyncoreRuntimeStatus\n ): UsePaginatedQueryResult<PaginatedQueryItem<TReference>> => {\n if (isSkipped) {\n return createEmptyPaginatedResult(runtimeStatus);\n }\n\n const pages: Array<PaginationResult<PaginatedQueryItem<TReference>>> = [];\n let error: Error | undefined;\n\n for (const page of state.pages) {\n const entry = pageEntries.get(page.key);\n if (!entry) {\n break;\n }\n const pageError = entry.watch.localQueryError();\n if (pageError) {\n error = pageError;\n break;\n }\n const value = entry.watch.localQueryResult();\n if (!value) {\n break;\n }\n pages.push(value);\n }\n\n const results = pages.flatMap((page) => page.page);\n const lastLoadedPage = pages.at(-1);\n const lastRequestedPage = state.pages.at(-1);\n const lastRequestedEntry = lastRequestedPage\n ? pageEntries.get(lastRequestedPage.key)\n : undefined;\n const lastRequestedResult = lastRequestedEntry?.watch.localQueryResult();\n const isLoading = pages.length === 0 && !error;\n const isLoadingMore =\n state.pages.length > pages.length ||\n (!!lastRequestedEntry && !lastRequestedResult && pages.length > 0);\n const hasMore = !!lastLoadedPage && !lastLoadedPage.isDone;\n const status = error\n ? \"error\"\n : isLoading\n ? \"loading\"\n : isLoadingMore\n ? \"loadingMore\"\n : hasMore\n ? \"ready\"\n : \"exhausted\";\n\n return {\n results,\n pages,\n status,\n error,\n isLoading,\n isLoadingMore,\n hasMore,\n cursor: lastLoadedPage?.cursor ?? null,\n runtimeStatus,\n loadMore(numItems = options.initialNumItems) {\n if (\n error ||\n isLoadingMore ||\n !hasMore ||\n !lastLoadedPage?.cursor\n ) {\n return;\n }\n state = {\n nextPageKey: state.nextPageKey + 1,\n pages: [\n ...state.pages,\n {\n key: String(state.nextPageKey),\n cursor: lastLoadedPage.cursor,\n numItems\n }\n ]\n };\n ensurePages();\n publish();\n }\n };\n };\n\n function publish() {\n set(deriveResult(readRuntimeStatus(runtimeWatch)));\n }\n\n ensurePages();\n publish();\n const detachRuntime = runtimeWatch.onUpdate(publish);\n\n return () => {\n detachRuntime();\n runtimeWatch.dispose?.();\n for (const key of [...pageEntries.keys()]) {\n disposePage(key);\n }\n };\n }\n );\n}\n\n/**\n * Creates a callable wrapper for a Syncore mutation using the contextual client.\n */\nexport function createMutation<\n TReference extends FunctionReference<\"mutation\">\n>(\n reference: TReference\n): (\n ...args: OptionalArgsTuple<FunctionArgs<TReference>>\n) => Promise<FunctionResult<TReference>> {\n const client = getSyncoreClient();\n return (...args) =>\n client.mutation(reference, normalizeOptionalArgs(args)) as Promise<\n FunctionResult<TReference>\n >;\n}\n\n/**\n * Creates a callable wrapper for a Syncore action using the contextual client.\n */\nexport function createAction<TReference extends FunctionReference<\"action\">>(\n reference: TReference\n): (\n ...args: OptionalArgsTuple<FunctionArgs<TReference>>\n) => Promise<FunctionResult<TReference>> {\n const client = getSyncoreClient();\n return (...args) =>\n client.action(reference, normalizeOptionalArgs(args)) as Promise<\n FunctionResult<TReference>\n >;\n}\n\nfunction createStatusStoreStart(\n client: SyncoreClient\n): StartStopNotifier<SyncoreRuntimeStatus> {\n return (set) => {\n const watch = client.watchRuntimeStatus();\n const sync = () => {\n set(readRuntimeStatus(watch));\n };\n sync();\n const unsubscribe = watch.onUpdate(sync);\n return () => {\n unsubscribe();\n watch.dispose?.();\n };\n };\n}\n\nfunction createQueryStoreStart<TReference extends FunctionReference<\"query\">>(\n client: SyncoreClient,\n reference: TReference,\n args: FunctionArgs<TReference> | undefined,\n isSkipped: boolean\n): StartStopNotifier<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n return (\n set: (value: SyncoreQueryStoreState<FunctionResult<TReference>>) => void\n ) => {\n const runtimeWatch = client.watchRuntimeStatus();\n const watch = isSkipped\n ? (noOpWatch as ManagedSyncoreWatch<FunctionResult<TReference>>)\n : (client.watchQuery(reference, args ?? {}) as ManagedSyncoreWatch<\n FunctionResult<TReference>\n >);\n const sync = () => {\n set(\n toQueryState(\n isSkipped\n ? {\n data: undefined,\n error: undefined\n }\n : readWatchSnapshot(watch),\n readRuntimeStatus(runtimeWatch),\n isSkipped\n )\n );\n };\n sync();\n const unsubscribeWatch = watch.onUpdate(sync);\n const unsubscribeRuntime = runtimeWatch.onUpdate(sync);\n return () => {\n unsubscribeWatch();\n unsubscribeRuntime();\n runtimeWatch.dispose?.();\n if (!isSkipped) {\n watch.dispose?.();\n }\n };\n };\n}\n\nfunction normalizeOptionalArgs<TArgs>(\n args: [] | [TArgs] | readonly unknown[]\n): TArgs {\n return (args[0] ?? {}) as TArgs;\n}\n\nfunction readWatchSnapshot<TResult>(watch: SyncoreWatch<TResult>): {\n data: TResult | undefined;\n error: Error | undefined;\n} {\n return {\n data: watch.localQueryResult(),\n error: watch.localQueryError()\n };\n}\n\nfunction readRuntimeStatus(\n watch: SyncoreWatch<SyncoreRuntimeStatus>\n): SyncoreRuntimeStatus {\n return watch.localQueryResult() ?? defaultRuntimeStatus;\n}\n\nfunction toQueryState<TResult>(\n snapshot: {\n data: TResult | undefined;\n error: Error | undefined;\n },\n runtimeStatus: SyncoreRuntimeStatus,\n isSkipped: boolean\n): SyncoreQueryState<TResult> {\n if (isSkipped) {\n return {\n data: undefined,\n error: undefined,\n status: \"skipped\",\n runtimeStatus,\n isLoading: false,\n isError: false,\n isReady: false\n };\n }\n\n const status =\n snapshot.error !== undefined\n ? \"error\"\n : snapshot.data === undefined\n ? \"loading\"\n : \"success\";\n\n return {\n data: snapshot.data,\n error: snapshot.error,\n status,\n runtimeStatus,\n isLoading: status === \"loading\",\n isError: status === \"error\",\n isReady: status === \"success\"\n };\n}\n\nfunction createEmptyPaginatedResult<TItem>(\n runtimeStatus: SyncoreRuntimeStatus\n): UsePaginatedQueryResult<TItem> {\n return {\n results: [],\n pages: [],\n status: \"ready\",\n error: undefined,\n isLoading: false,\n isLoadingMore: false,\n hasMore: false,\n cursor: null,\n runtimeStatus,\n loadMore() {\n return;\n }\n };\n}\n\nconst noOpWatch: ManagedSyncoreWatch<never> = {\n onUpdate: () => () => undefined,\n localQueryResult: () =>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Q,KAAK,MAAM,CAAC;AACtB;AAEA,SAAS,kBAA2B,OAGlC;CACA,OAAO;EACL,MAAM,MAAM,iBAAiB;EAC7B,OAAO,MAAM,gBAAgB;CAC/B;AACF;AAEA,SAAS,kBACP,OACsB;CACtB,OAAO,MAAM,iBAAiB,KAAK;AACrC;AAEA,SAAS,aACP,UAIA,eACA,WAC4B;CAC5B,IAAI,WACF,OAAO;EACL,MAAM,KAAA;EACN,OAAO,KAAA;EACP,QAAQ;EACR;EACA,WAAW;EACX,SAAS;EACT,SAAS;CACX;CAGF,MAAM,SACJ,SAAS,UAAU,KAAA,IACf,UACA,SAAS,SAAS,KAAA,IAChB,YACA;CAER,OAAO;EACL,MAAM,SAAS;EACf,OAAO,SAAS;EAChB;EACA;EACA,WAAW,WAAW;EACtB,SAAS,WAAW;EACpB,SAAS,WAAW;CACtB;AACF;AAEA,SAAS,2BACP,eACgC;CAChC,OAAO;EACL,SAAS,CAAC;EACV,OAAO,CAAC;EACR,QAAQ;EACR,OAAO,KAAA;EACP,WAAW;EACX,eAAe;EACf,SAAS;EACT,QAAQ;EACR;EACA,WAAW,CAEX;CACF;AACF;AAEA,MAAM,YAAwC;CAC5C,sBAAsB,KAAA;CACtB,wBAAwB,KAAA;CACxB,uBAAuB,KAAA;AACzB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n derived,\n type Readable,\n readable,\n type StartStopNotifier\n} from \"svelte/store\";\nimport { getContext, setContext } from \"svelte\";\nimport type {\n FunctionArgs,\n FunctionReference,\n FunctionResult,\n PaginationOptions,\n PaginationResult,\n SyncoreClient,\n SyncoreQueryState,\n SyncoreRuntimeStatus,\n SyncoreWatch,\n UsePaginatedQueryResult\n} from \"@syncore/core\";\n\nexport type OptionalArgsTuple<TArgs> =\n Record<never, never> extends TArgs ? [args?: TArgs] : [args: TArgs];\n\ntype ManagedSyncoreWatch<TResult> = SyncoreWatch<TResult> & {\n dispose?: () => void;\n};\n\ntype QueryRequestInput<\n TReference extends FunctionReference<\"query\"> = FunctionReference<\"query\">\n> = Record<never, never> extends FunctionArgs<TReference>\n ? {\n query: TReference;\n args?: FunctionArgs<TReference> | Skip;\n }\n : {\n query: TReference;\n args: FunctionArgs<TReference> | Skip;\n };\n\ntype QueriesRequestInput = Record<string, QueryRequestInput>;\n\ntype QueryStateForEntry<TEntry> = TEntry extends QueryRequestInput<\n infer TReference\n>\n ? SyncoreQueryState<FunctionResult<TReference>>\n : never;\n\nexport type CreateQueriesStoreResult<TEntries extends QueriesRequestInput> = {\n [TKey in keyof TEntries]: QueryStateForEntry<TEntries[TKey]>;\n};\n\ntype PaginatedQueryReference = FunctionReference<\n \"query\",\n Record<string, unknown>,\n PaginationResult<unknown>\n>;\n\ntype PaginatedQueryArgs<TReference extends FunctionReference<\"query\">> =\n FunctionArgs<TReference> extends { paginationOpts: PaginationOptions }\n ? Omit<FunctionArgs<TReference>, \"paginationOpts\">\n : never;\n\ntype PaginatedQueryItem<TReference extends FunctionReference<\"query\">> =\n FunctionResult<TReference> extends PaginationResult<infer TItem>\n ? TItem\n : never;\n\ntype PaginatedQueryInternalState = {\n nextPageKey: number;\n pages: Array<{\n key: string;\n cursor: string | null;\n numItems: number;\n }>;\n};\n\n/**\n * The reactive query state shape emitted by Syncore's Svelte store factories.\n *\n * Extends SyncoreQueryState with the same fields (`data`, `error`,\n * `status`, `runtimeStatus`, `isLoading`, `isError`, `isReady`). Returned as\n * the value of stores created by {@link createQueryStore} and\n * {@link createClientQueryStore}.\n */\nexport interface SyncoreQueryStoreState<TResult>\n extends SyncoreQueryState<TResult> {}\n\n/**\n * A sentinel value that tells Syncore store factories to skip the query.\n *\n * Use `skip` in place of a query’s `args` argument to avoid firing the query\n * while some required data is not yet available (e.g. a user ID that loads\n * asynchronously). The store will remain in a `\"loading\"` / skipped state\n * until a non-skip value is provided.\n *\n * ```svelte\n * <script>\n * import { createQueryValueStore, skip } from \"syncorejs/svelte\";\n * import { api } from \"../syncore/_generated/api\";\n *\n * export let userId: string | undefined;\n *\n * $: profile = createQueryValueStore(\n * api.users.get,\n * userId ? { id: userId } : skip\n * );\n * </script>\n * ```\n */\nexport const skip = \"skip\" as const;\ntype Skip = typeof skip;\n\nconst defaultRuntimeStatus: SyncoreRuntimeStatus = {\n kind: \"starting\",\n reason: \"booting\"\n};\n\nconst SYNCORE_CLIENT_CONTEXT = Symbol(\"syncore.client\");\n\n/**\n * Store the Syncore client in Svelte’s component context.\n *\n * Call this once at the root of your component tree (e.g. in a layout or\n * root `+layout.svelte`) so that the context-aware store factories\n * (`createQueryStore`, `createQueriesStore`, etc.) can retrieve it\n * automatically without prop-drilling.\n *\n * ```svelte\n * <!-- +layout.svelte -->\n * <script>\n * import { setSyncoreClient } from \"syncorejs/svelte\";\n * export let data; // { client } from +layout.ts\n * setSyncoreClient(data.client);\n * </script>\n * <slot />\n * ```\n *\n * @param client - The ready Syncore client to store in context.\n * @returns The same `client` for convenience.\n */\nexport function setSyncoreClient(client: SyncoreClient): SyncoreClient {\n setContext(SYNCORE_CLIENT_CONTEXT, client);\n return client;\n}\n\n/**\n * Retrieve the Syncore client from Svelte’s component context.\n *\n * Throws if {@link setSyncoreClient} has not been called by an ancestor\n * component. Only use this inside Svelte components; for standalone scripts\n * keep an explicit reference to the client instead.\n *\n * @throws `Error` when no client is found in the component context.\n */\nexport function getSyncoreClient(): SyncoreClient {\n const client = getContext<SyncoreClient | undefined>(SYNCORE_CLIENT_CONTEXT);\n if (!client) {\n throw new Error(\n \"Syncore client is missing from the Svelte component context.\"\n );\n }\n return client;\n}\n\n/**\n * Create a reactive Svelte store that tracks the Syncore runtime status.\n *\n * Uses the client from Svelte context (set via {@link setSyncoreClient}).\n * Subscribe to gate your UI on `\"ready\"` before rendering data-dependent\n * components.\n *\n * ```svelte\n * <script>\n * import { createSyncoreStatusStore } from \"syncorejs/svelte\";\n * const status = createSyncoreStatusStore();\n * </script>\n *\n * {#if $status.kind === \"ready\"}\n * <App />\n * {:else}\n * <Loading />\n * {/if}\n * ```\n */\nexport function createSyncoreStatusStore(): Readable<SyncoreRuntimeStatus> {\n return createClientSyncoreStatusStore(getSyncoreClient());\n}\n\n/**\n * Create a reactive Svelte store that tracks the Syncore runtime status.\n *\n * Accepts an explicit `client` rather than reading from Svelte context,\n * making it usable outside component trees (e.g. in module-level code or\n * SvelteKit `load` functions).\n *\n * @param client - The Syncore client to observe.\n */\nexport function createClientSyncoreStatusStore(\n client: SyncoreClient\n): Readable<SyncoreRuntimeStatus> {\n return readable<SyncoreRuntimeStatus>(\n defaultRuntimeStatus,\n createStatusStoreStart(client)\n );\n}\n\n/**\n * Create a reactive Svelte store that emits the current value of a Syncore\n * query, or `undefined` while loading.\n *\n * Uses the client from Svelte context (set via {@link setSyncoreClient}).\n * Pass `skip` as `args` to pause the query.\n *\n * ```svelte\n * <script>\n * import { createQueryValueStore } from \"syncorejs/svelte\";\n * import { api } from \"../syncore/_generated/api\";\n *\n * const todos = createQueryValueStore(api.todos.list);\n * </script>\n *\n * {#each $todos ?? [] as todo}\n * <p>{todo.text}</p>\n * {/each}\n * ```\n */\nexport function createQueryValueStore<\n TReference extends FunctionReference<\"query\">\n>(\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<FunctionResult<TReference> | undefined> {\n return createClientQueryValueStore(getSyncoreClient(), reference, ...args);\n}\n\n/**\n * Create a reactive Svelte store that emits the current value of a Syncore\n * query, or `undefined` while loading.\n *\n * Accepts an explicit `client` instead of reading from Svelte context.\n *\n * @param client - The Syncore client to query against.\n */\nexport function createClientQueryValueStore<\n TReference extends FunctionReference<\"query\">\n>(\n client: SyncoreClient,\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<FunctionResult<TReference> | undefined> {\n return derived(\n createClientQueryStore(client, reference, ...(args as OptionalArgsTuple<\n FunctionArgs<TReference>\n > | [Skip])),\n ($state) => $state.data\n );\n}\n\n/**\n * Create a reactive Svelte store that emits the full SyncoreQueryState\n * for a query, including `data`, `error`, `status`, and `isPending`.\n *\n * Uses the client from Svelte context (set via {@link setSyncoreClient}).\n *\n * ```svelte\n * <script>\n * import { createQueryStore } from \"syncorejs/svelte\";\n * import { api } from \"../syncore/_generated/api\";\n *\n * const state = createQueryStore(api.todos.list);\n * </script>\n *\n * {#if $state.isPending}\n * <Spinner />\n * {:else if $state.error}\n * <Error message={$state.error.message} />\n * {:else}\n * {#each $state.data as todo}<p>{todo.text}</p>{/each}\n * {/if}\n * ```\n */\nexport function createQueryStore<TReference extends FunctionReference<\"query\">>(\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n return createClientQueryStore(getSyncoreClient(), reference, ...args);\n}\n\n/**\n * Create a reactive Svelte store that emits the full SyncoreQueryState\n * for a query, including `data`, `error`, `status`, and `isPending`.\n *\n * Accepts an explicit `client` instead of reading from Svelte context.\n *\n * @param client - The Syncore client to query against.\n */\nexport function createClientQueryStore<\n TReference extends FunctionReference<\"query\">\n>(\n client: SyncoreClient,\n reference: TReference,\n ...args: OptionalArgsTuple<FunctionArgs<TReference>> | [Skip]\n): Readable<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n const isSkipped = args[0] === skip;\n const normalizedArgs = isSkipped\n ? undefined\n : normalizeOptionalArgs(args as OptionalArgsTuple<FunctionArgs<TReference>>);\n return readable<SyncoreQueryStoreState<FunctionResult<TReference>>>(\n toQueryState<FunctionResult<TReference>>(\n {\n data: undefined,\n error: undefined\n },\n defaultRuntimeStatus,\n isSkipped\n ),\n createQueryStoreStart(client, reference, normalizedArgs, isSkipped)\n );\n}\n\n/**\n * Create a reactive Svelte store that simultaneously observes multiple\n * Syncore queries.\n *\n * Uses the client from Svelte context (set via {@link setSyncoreClient}).\n * Each key in `entries` corresponds to a key in the emitted result object.\n *\n * ```svelte\n * <script>\n * import { createQueriesStore } from \"syncorejs/svelte\";\n * import { api } from \"../syncore/_generated/api\";\n *\n * const stores = createQueriesStore({\n * todos: { query: api.todos.list },\n * user: { query: api.users.me },\n * });\n * </script>\n *\n * <p>{$stores.user.data?.name} has {$stores.todos.data?.length} todos</p>\n * ```\n */\nexport function createQueriesStore<TEntries extends QueriesRequestInput>(\n entries: TEntries\n): Readable<CreateQueriesStoreResult<TEntries>> {\n return createClientQueriesStore(getSyncoreClient(), entries);\n}\n\n/**\n * Create a reactive Svelte store that simultaneously observes multiple\n * Syncore queries.\n *\n * Accepts an explicit `client` instead of reading from Svelte context.\n *\n * @param client - The Syncore client to query against.\n */\nexport function createClientQueriesStore<TEntries extends QueriesRequestInput>(\n client: SyncoreClient,\n entries: TEntries\n): Readable<CreateQueriesStoreResult<TEntries>> {\n const normalizedEntries = Object.entries(entries)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, entry]) => ({\n key,\n query: entry.query,\n skipped: entry.args === skip,\n args:\n entry.args === skip\n ? {}\n : normalizeOptionalArgs([entry.args ?? {}] as [] | [unknown])\n }));\n\n return readable<CreateQueriesStoreResult<TEntries>>(\n {} as CreateQueriesStoreResult<TEntries>,\n (set) => {\n const runtimeWatch = client.watchRuntimeStatus();\n const watches = normalizedEntries.map((entry) => ({\n key: entry.key,\n skipped: entry.skipped,\n watch: entry.skipped\n ? (noOpWatch as ManagedSyncoreWatch<unknown>)\n : (client.watchQuery(entry.query, entry.args) as ManagedSyncoreWatch<\n unknown\n >)\n }));\n const publish = () => {\n const runtimeStatus = readRuntimeStatus(runtimeWatch);\n set(\n Object.fromEntries(\n watches.map((entry) => [\n entry.key,\n toQueryState(\n entry.skipped\n ? {\n data: undefined,\n error: undefined\n }\n : readWatchSnapshot(entry.watch),\n runtimeStatus,\n entry.skipped\n )\n ])\n ) as CreateQueriesStoreResult<TEntries>\n );\n };\n\n publish();\n const cleanups = [\n runtimeWatch.onUpdate(publish),\n ...watches.map((entry) => entry.watch.onUpdate(publish))\n ];\n\n return () => {\n for (const cleanup of cleanups) {\n cleanup();\n }\n runtimeWatch.dispose?.();\n for (const entry of watches) {\n if (!entry.skipped) {\n entry.watch.dispose?.();\n }\n }\n };\n }\n );\n}\n\n/**\n * Create a reactive Svelte store for cursor-based paginated Syncore queries.\n *\n * Uses the client from Svelte context (set via {@link setSyncoreClient}).\n * The store handles page tracking and exposes a `loadMore()` function so you\n * can implement “Load More” UIs without manual cursor management.\n *\n * The query referenced by `reference` must accept a `paginationOpts`\n * argument and return a PaginationResult.\n *\n * ```svelte\n * <script>\n * import { createPaginatedQueryStore } from \"syncorejs/svelte\";\n * import { api } from \"../syncore/_generated/api\";\n *\n * const result = createPaginatedQueryStore(\n * api.todos.listPaginated,\n * {},\n * { initialNumItems: 10 }\n * );\n * </script>\n *\n * {#each $result.results as todo}<p>{todo.text}</p>{/each}\n * {#if $result.canLoadMore}\n * <button on:click={() => $result.loadMore(10)}>Load more</button>\n * {/if}\n * ```\n *\n * @param reference - A paginated query function reference.\n * @param args - Query arguments excluding `paginationOpts`, or `skip`.\n * @param options - Pagination options. `initialNumItems` controls the number\n * of items to fetch on the first page.\n */\nexport function createPaginatedQueryStore<\n TReference extends PaginatedQueryReference\n>(\n reference: TReference,\n args: PaginatedQueryArgs<TReference> | Skip,\n options: {\n initialNumItems: number;\n }\n): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>> {\n return createClientPaginatedQueryStore(\n getSyncoreClient(),\n reference,\n args,\n options\n );\n}\n\n/**\n * Create a reactive Svelte store for cursor-based paginated Syncore queries.\n *\n * Accepts an explicit `client` instead of reading from Svelte context.\n *\n * @param client - The Syncore client to query against.\n * @param reference - A paginated query function reference.\n * @param args - Query arguments excluding `paginationOpts`, or `skip`.\n * @param options - Pagination options. `initialNumItems` controls the number\n * of items to fetch on the first page.\n */\nexport function createClientPaginatedQueryStore<\n TReference extends PaginatedQueryReference\n>(\n client: SyncoreClient,\n reference: TReference,\n args: PaginatedQueryArgs<TReference> | Skip,\n options: {\n initialNumItems: number;\n }\n): Readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>> {\n if (\n typeof options.initialNumItems !== \"number\" ||\n options.initialNumItems <= 0\n ) {\n throw new Error(\n `options.initialNumItems must be a positive number. Received ${String(\n options.initialNumItems\n )}.`\n );\n }\n\n const isSkipped = args === skip;\n const baseArgs = isSkipped ? {} : (args ?? {});\n\n return readable<UsePaginatedQueryResult<PaginatedQueryItem<TReference>>>(\n createEmptyPaginatedResult(defaultRuntimeStatus),\n (set) => {\n const runtimeWatch = client.watchRuntimeStatus();\n let state: PaginatedQueryInternalState = {\n nextPageKey: 1,\n pages: isSkipped\n ? []\n : [\n {\n key: \"0\",\n cursor: null,\n numItems: options.initialNumItems\n }\n ]\n };\n const pageEntries = new Map<\n string,\n {\n cursor: string | null;\n numItems: number;\n watch: ManagedSyncoreWatch<PaginationResult<PaginatedQueryItem<TReference>>>;\n unsubscribe: () => void;\n }\n >();\n\n const disposePage = (key: string) => {\n const entry = pageEntries.get(key);\n if (!entry) {\n return;\n }\n entry.unsubscribe();\n entry.watch.dispose?.();\n pageEntries.delete(key);\n };\n\n const ensurePages = () => {\n const activeKeys = new Set(state.pages.map((page) => page.key));\n for (const page of state.pages) {\n if (pageEntries.has(page.key)) {\n continue;\n }\n const watch = client.watchQuery(reference, {\n ...(baseArgs as Record<string, unknown>),\n paginationOpts: {\n cursor: page.cursor,\n numItems: page.numItems\n }\n }) as ManagedSyncoreWatch<PaginationResult<PaginatedQueryItem<TReference>>>;\n const unsubscribe = watch.onUpdate(publish);\n pageEntries.set(page.key, {\n cursor: page.cursor,\n numItems: page.numItems,\n watch,\n unsubscribe\n });\n }\n for (const key of [...pageEntries.keys()]) {\n if (!activeKeys.has(key)) {\n disposePage(key);\n }\n }\n };\n\n const deriveResult = (\n runtimeStatus: SyncoreRuntimeStatus\n ): UsePaginatedQueryResult<PaginatedQueryItem<TReference>> => {\n if (isSkipped) {\n return createEmptyPaginatedResult(runtimeStatus);\n }\n\n const pages: Array<PaginationResult<PaginatedQueryItem<TReference>>> = [];\n let error: Error | undefined;\n\n for (const page of state.pages) {\n const entry = pageEntries.get(page.key);\n if (!entry) {\n break;\n }\n const pageError = entry.watch.localQueryError();\n if (pageError) {\n error = pageError;\n break;\n }\n const value = entry.watch.localQueryResult();\n if (!value) {\n break;\n }\n pages.push(value);\n }\n\n const results = pages.flatMap((page) => page.page);\n const lastLoadedPage = pages.at(-1);\n const lastRequestedPage = state.pages.at(-1);\n const lastRequestedEntry = lastRequestedPage\n ? pageEntries.get(lastRequestedPage.key)\n : undefined;\n const lastRequestedResult = lastRequestedEntry?.watch.localQueryResult();\n const isLoading = pages.length === 0 && !error;\n const isLoadingMore =\n state.pages.length > pages.length ||\n (!!lastRequestedEntry && !lastRequestedResult && pages.length > 0);\n const hasMore = !!lastLoadedPage && !lastLoadedPage.isDone;\n const status = error\n ? \"error\"\n : isLoading\n ? \"loading\"\n : isLoadingMore\n ? \"loadingMore\"\n : hasMore\n ? \"ready\"\n : \"exhausted\";\n\n return {\n results,\n pages,\n status,\n error,\n isLoading,\n isLoadingMore,\n hasMore,\n cursor: lastLoadedPage?.cursor ?? null,\n runtimeStatus,\n loadMore(numItems = options.initialNumItems) {\n if (\n error ||\n isLoadingMore ||\n !hasMore ||\n !lastLoadedPage?.cursor\n ) {\n return;\n }\n state = {\n nextPageKey: state.nextPageKey + 1,\n pages: [\n ...state.pages,\n {\n key: String(state.nextPageKey),\n cursor: lastLoadedPage.cursor,\n numItems\n }\n ]\n };\n ensurePages();\n publish();\n }\n };\n };\n\n function publish() {\n set(deriveResult(readRuntimeStatus(runtimeWatch)));\n }\n\n ensurePages();\n publish();\n const detachRuntime = runtimeWatch.onUpdate(publish);\n\n return () => {\n detachRuntime();\n runtimeWatch.dispose?.();\n for (const key of [...pageEntries.keys()]) {\n disposePage(key);\n }\n };\n }\n );\n}\n\n/**\n * Creates a callable wrapper for a Syncore mutation using the contextual client.\n */\nexport function createMutation<\n TReference extends FunctionReference<\"mutation\">\n>(\n reference: TReference\n): (\n ...args: OptionalArgsTuple<FunctionArgs<TReference>>\n) => Promise<FunctionResult<TReference>> {\n const client = getSyncoreClient();\n return (...args) =>\n client.mutation(reference, normalizeOptionalArgs(args)) as Promise<\n FunctionResult<TReference>\n >;\n}\n\n/**\n * Creates a callable wrapper for a Syncore action using the contextual client.\n */\nexport function createAction<TReference extends FunctionReference<\"action\">>(\n reference: TReference\n): (\n ...args: OptionalArgsTuple<FunctionArgs<TReference>>\n) => Promise<FunctionResult<TReference>> {\n const client = getSyncoreClient();\n return (...args) =>\n client.action(reference, normalizeOptionalArgs(args)) as Promise<\n FunctionResult<TReference>\n >;\n}\n\nfunction createStatusStoreStart(\n client: SyncoreClient\n): StartStopNotifier<SyncoreRuntimeStatus> {\n return (set) => {\n const watch = client.watchRuntimeStatus();\n const sync = () => {\n set(readRuntimeStatus(watch));\n };\n sync();\n const unsubscribe = watch.onUpdate(sync);\n return () => {\n unsubscribe();\n watch.dispose?.();\n };\n };\n}\n\nfunction createQueryStoreStart<TReference extends FunctionReference<\"query\">>(\n client: SyncoreClient,\n reference: TReference,\n args: FunctionArgs<TReference> | undefined,\n isSkipped: boolean\n): StartStopNotifier<SyncoreQueryStoreState<FunctionResult<TReference>>> {\n return (\n set: (value: SyncoreQueryStoreState<FunctionResult<TReference>>) => void\n ) => {\n const runtimeWatch = client.watchRuntimeStatus();\n const watch = isSkipped\n ? (noOpWatch as ManagedSyncoreWatch<FunctionResult<TReference>>)\n : (client.watchQuery(reference, args ?? {}) as ManagedSyncoreWatch<\n FunctionResult<TReference>\n >);\n const sync = () => {\n set(\n toQueryState(\n isSkipped\n ? {\n data: undefined,\n error: undefined\n }\n : readWatchSnapshot(watch),\n readRuntimeStatus(runtimeWatch),\n isSkipped\n )\n );\n };\n sync();\n const unsubscribeWatch = watch.onUpdate(sync);\n const unsubscribeRuntime = runtimeWatch.onUpdate(sync);\n return () => {\n unsubscribeWatch();\n unsubscribeRuntime();\n runtimeWatch.dispose?.();\n if (!isSkipped) {\n watch.dispose?.();\n }\n };\n };\n}\n\nfunction normalizeOptionalArgs<TArgs>(\n args: [] | [TArgs] | readonly unknown[]\n): TArgs {\n return (args[0] ?? {}) as TArgs;\n}\n\nfunction readWatchSnapshot<TResult>(watch: SyncoreWatch<TResult>): {\n data: TResult | undefined;\n error: Error | undefined;\n} {\n return {\n data: watch.localQueryResult(),\n error: watch.localQueryError()\n };\n}\n\nfunction readRuntimeStatus(\n watch: SyncoreWatch<SyncoreRuntimeStatus>\n): SyncoreRuntimeStatus {\n return watch.localQueryResult() ?? defaultRuntimeStatus;\n}\n\nfunction toQueryState<TResult>(\n snapshot: {\n data: TResult | undefined;\n error: Error | undefined;\n },\n runtimeStatus: SyncoreRuntimeStatus,\n isSkipped: boolean\n): SyncoreQueryState<TResult> {\n if (isSkipped) {\n return {\n data: undefined,\n error: undefined,\n status: \"skipped\",\n runtimeStatus,\n isLoading: false,\n isError: false,\n isReady: false\n };\n }\n\n const status =\n snapshot.error !== undefined\n ? \"error\"\n : snapshot.data === undefined\n ? \"loading\"\n : \"success\";\n\n return {\n data: snapshot.data,\n error: snapshot.error,\n status,\n runtimeStatus,\n isLoading: status === \"loading\",\n isError: status === \"error\",\n isReady: status === \"success\"\n };\n}\n\nfunction createEmptyPaginatedResult<TItem>(\n runtimeStatus: SyncoreRuntimeStatus\n): UsePaginatedQueryResult<TItem> {\n return {\n results: [],\n pages: [],\n status: \"ready\",\n error: undefined,\n isLoading: false,\n isLoadingMore: false,\n hasMore: false,\n cursor: null,\n runtimeStatus,\n loadMore() {\n return;\n }\n };\n}\n\nconst noOpWatch: ManagedSyncoreWatch<never> = {\n onUpdate: () => () => undefined,\n localQueryResult: () => undefined,\n localQueryError: () => undefined\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6GA,MAAa,OAAO;AAGpB,MAAM,uBAA6C;CACjD,MAAM;CACN,QAAQ;AACV;AAEA,MAAM,yBAAyB,OAAO,gBAAgB;;;;;;;;;;;;;;;;;;;;;;A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AAEA,SAAS,aACP,UAIA,eACA,WAC4B;CAC5B,IAAI,WACF,OAAO;EACL,MAAM,KAAA;EACN,OAAO,KAAA;EACP,QAAQ;EACR;EACA,WAAW;EACX,SAAS;EACT,SAAS;CACX;CAGF,MAAM,SACJ,SAAS,UAAU,KAAA,IACf,UACA,SAAS,SAAS,KAAA,IAChB,YACA;CAER,OAAO;EACL,MAAM,SAAS;EACf,OAAO,SAAS;EAChB;EACA;EACA,WAAW,WAAW;EACtB,SAAS,WAAW;EACpB,SAAS,WAAW;CACtB;AACF;AAEA,SAAS,2BACP,eACgC;CAChC,OAAO;EACL,SAAS,CAAC;EACV,OAAO,CAAC;EACR,QAAQ;EACR,OAAO,KAAA;EACP,WAAW;EACX,eAAe;EACf,SAAS;EACT,QAAQ;EACR;EACA,WAAW,CAEX;CACF;AACF;AAEA,MAAM,YAAwC;CAC5C,sBAAsB,KAAA;CACtB,wBAAwB,KAAA;CACxB,uBAAuB,KAAA;AACzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "syncorejs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Local-first reactive backend toolkit for offline apps",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
|
-
"build": "npm run build:deps && tsdown --config tsdown.config.ts && tsx ../../scripts/vendor-syncore-internals.ts",
|
|
103
|
+
"build": "npm run build:deps && npm run build --workspace @syncore/dashboard && tsdown --config tsdown.config.ts && tsx ../../scripts/vendor-syncore-internals.ts",
|
|
104
104
|
"build:deps": "npm run build --workspace @syncore/core && npm run build --workspace @syncore/schema && npm run build --workspace @syncore/devtools-protocol && npm run build --workspace @syncore/cli && npm run build --workspace @syncore/react && npm run build --workspace @syncore/platform-web && npm run build --workspace @syncore/platform-node && npm run build --workspace @syncore/platform-expo && npm run build --workspace @syncore/next && npm run build --workspace @syncore/svelte",
|
|
105
105
|
"build:standalone": "npm run build",
|
|
106
106
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|