@triplit/svelte 0.2.33-canary-20250225192824 → 0.2.33-canary-20250306191454

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @triplit/svelte
2
2
 
3
+ ## 0.2.33-canary-20250306191454
4
+
5
+ ### Patch Changes
6
+
7
+ - @triplit/client@0.7.0-canary-20250306191454
8
+
9
+ ## 0.2.33-canary-20250228214718
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [2156db26]
14
+ - @triplit/client@0.7.0-canary-20250228214718
15
+
3
16
  ## 0.2.33-canary-20250225192824
4
17
 
5
18
  ### Patch Changes
@@ -1,5 +1,4 @@
1
- import type { ClientQuery, ClientQueryBuilder, CollectionNameFromModels, FetchResult, Models, SubscriptionOptions, TriplitClient, Unalias } from '@triplit/client';
2
- import { WorkerClient } from '@triplit/client/worker-client';
1
+ import type { Models, SchemaQuery, SubscriptionOptions, SubscriptionSignalPayload, TriplitClient } from '@triplit/client';
3
2
  /**
4
3
  * A hook that subscribes to a query
5
4
  *
@@ -10,20 +9,13 @@ import { WorkerClient } from '@triplit/client/worker-client';
10
9
  * @param options.onRemoteFulfilled - An optional callback that is called when the remote query has been fulfilled.
11
10
  * @returns An object containing the fetching state, the result of the query, any error that occurred, and a function to update the query
12
11
  */
13
- export declare function useQuery<M extends Models, CN extends CollectionNameFromModels<M>, Q extends ClientQuery<M, CN>>(client: TriplitClient<M> | WorkerClient<M>, query: ClientQueryBuilder<M, CN, Q>, options?: Partial<SubscriptionOptions>): {
14
- fetching: boolean;
15
- fetchingLocal: boolean;
16
- fetchingRemote: boolean;
17
- results: Unalias<FetchResult<M, Q>> | undefined;
18
- error: any;
19
- updateQuery: (query: ClientQueryBuilder<M, CN, Q>) => void;
20
- };
12
+ export declare function useQuery<M extends Models<M>, Q extends SchemaQuery<M>>(client: TriplitClient<M>, query: Q, options?: Partial<SubscriptionOptions>): SubscriptionSignalPayload<M, Q>;
21
13
  /**
22
14
  * A hook that subscribes to the connection status of a client with the server
23
15
  *
24
16
  * @param client - The client instance to get the connection status of
25
17
  * @returns An object containing `status`, the current connection status of the client with the server
26
18
  */
27
- export declare function useConnectionStatus(client: TriplitClient<any> | WorkerClient<any>): {
28
- readonly status: string;
19
+ export declare function useConnectionStatus(client: TriplitClient<any>): {
20
+ readonly status: import("@triplit/client").ConnectionStatus;
29
21
  };
@@ -10,6 +10,9 @@
10
10
  * @returns An object containing the fetching state, the result of the query, any error that occurred, and a function to update the query
11
11
  */
12
12
  export function useQuery(client, query, options) {
13
+ // & {
14
+ // updateQuery: (query: Q) => void;
15
+ // }
13
16
  let results = $state(undefined);
14
17
  let isInitialFetch = $state(true);
15
18
  let fetchingLocal = $state(true);
@@ -17,16 +20,9 @@ export function useQuery(client, query, options) {
17
20
  let fetching = $derived(fetchingLocal || (isInitialFetch && fetchingRemote));
18
21
  let error = $state(undefined);
19
22
  let hasResponseFromServer = false;
20
- let builtQuery = $state(query && query.build());
21
- function updateQuery(query) {
22
- builtQuery = query.build();
23
- results = undefined;
24
- fetchingLocal = true;
25
- hasResponseFromServer = false;
26
- }
27
23
  $effect(() => {
28
24
  client
29
- .isFirstTimeFetchingQuery($state.snapshot(builtQuery))
25
+ .isFirstTimeFetchingQuery($state.snapshot(query))
30
26
  .then((isFirstFetch) => {
31
27
  isInitialFetch = isFirstFetch;
32
28
  });
@@ -45,7 +41,7 @@ export function useQuery(client, query, options) {
45
41
  };
46
42
  });
47
43
  $effect(() => {
48
- const unsubscribe = client.subscribe($state.snapshot(builtQuery), (localResults) => {
44
+ const unsubscribe = client.subscribe($state.snapshot(query), (localResults) => {
49
45
  fetchingLocal = false;
50
46
  error = undefined;
51
47
  results = localResults;
@@ -79,7 +75,6 @@ export function useQuery(client, query, options) {
79
75
  get error() {
80
76
  return error;
81
77
  },
82
- updateQuery,
83
78
  };
84
79
  }
85
80
  /**
@@ -89,7 +84,7 @@ export function useQuery(client, query, options) {
89
84
  * @returns An object containing `status`, the current connection status of the client with the server
90
85
  */
91
86
  export function useConnectionStatus(client) {
92
- let status = $state('CONNECTING');
87
+ let status = $state(client.connectionStatus);
93
88
  $effect(() => {
94
89
  const unsub = client.onConnectionStatusChange((newStatus) => {
95
90
  status = newStatus;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@triplit/svelte",
3
3
  "packageManager": "yarn@3.4.1",
4
- "version": "0.2.33-canary-20250225192824",
4
+ "version": "0.2.33-canary-20250306191454",
5
5
  "source": "./src/index.svelte.ts",
6
6
  "main": "./dist/index.svelte.js",
7
7
  "module": "./dist/index.svelte.js",
@@ -29,7 +29,7 @@
29
29
  "/dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@triplit/client": "^0.7.0-canary-20250225192824"
32
+ "@triplit/client": "^0.7.0-canary-20250306191454"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@sveltejs/package": "^2.3.5",