@evolu/svelte 1.0.1-preview.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.svelte.d.ts +18 -1
- package/dist/index.svelte.js +32 -4
- package/package.json +24 -23
package/dist/index.svelte.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* This file needs to be named .svelte.ts to be recognized by the Svelte
|
|
3
3
|
* compiler in the app itself.
|
|
4
4
|
*/
|
|
5
|
-
import type { Evolu, EvoluDeps, EvoluSchema, InferRow, Query, Row } from "@evolu/common/evolu";
|
|
5
|
+
import type { AppOwner, Evolu, EvoluDeps, EvoluSchema, InferRow, Query, Row } from "@evolu/common/evolu";
|
|
6
6
|
export declare const evoluSvelteDeps: EvoluDeps;
|
|
7
7
|
/**
|
|
8
8
|
* Load and subscribe to the Query, and return an object with `rows` property
|
|
@@ -51,3 +51,20 @@ observedQuery: () => Query<R> | undefined, options?: {
|
|
|
51
51
|
}): {
|
|
52
52
|
readonly rows: Array<MappedRow>;
|
|
53
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Get the {@link AppOwner} promise that resolves when available.
|
|
56
|
+
*
|
|
57
|
+
* ### Example
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { appOwnerState } from "@evolu/svelte";
|
|
61
|
+
*
|
|
62
|
+
* const owner = appOwnerState(evolu);
|
|
63
|
+
*
|
|
64
|
+
* // use owner.current in your Svelte templates
|
|
65
|
+
* // it will be undefined initially and set once the promise resolves
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function appOwnerState<Schema extends EvoluSchema>(evolu: Evolu<Schema>): {
|
|
69
|
+
readonly current: AppOwner | undefined;
|
|
70
|
+
};
|
package/dist/index.svelte.js
CHANGED
|
@@ -64,13 +64,10 @@ observedQuery, options) {
|
|
|
64
64
|
// for b) if you sub/unsub in a very short time can cause the subscription not to trigger a callback
|
|
65
65
|
// => this is also for HMR
|
|
66
66
|
void evolu.loadQuery(query).then(updateState);
|
|
67
|
-
|
|
67
|
+
return evolu.subscribeQuery(query)(() => {
|
|
68
68
|
const rows = evolu.getQueryRows(query);
|
|
69
69
|
updateState(rows);
|
|
70
70
|
});
|
|
71
|
-
return () => {
|
|
72
|
-
unsubEvoluSub();
|
|
73
|
-
};
|
|
74
71
|
});
|
|
75
72
|
return {
|
|
76
73
|
// Svelte reactivity: it needs to be a getter
|
|
@@ -80,3 +77,34 @@ observedQuery, options) {
|
|
|
80
77
|
};
|
|
81
78
|
}
|
|
82
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the {@link AppOwner} promise that resolves when available.
|
|
82
|
+
*
|
|
83
|
+
* ### Example
|
|
84
|
+
*
|
|
85
|
+
* ```ts
|
|
86
|
+
* import { appOwnerState } from "@evolu/svelte";
|
|
87
|
+
*
|
|
88
|
+
* const owner = appOwnerState(evolu);
|
|
89
|
+
*
|
|
90
|
+
* // use owner.current in your Svelte templates
|
|
91
|
+
* // it will be undefined initially and set once the promise resolves
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export function appOwnerState(evolu) {
|
|
95
|
+
{
|
|
96
|
+
// writing to this variable - svelte's compiler will track it
|
|
97
|
+
let writableState = $state(undefined);
|
|
98
|
+
$effect(() => {
|
|
99
|
+
void evolu.appOwner.then((appOwner) => {
|
|
100
|
+
writableState = appOwner;
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
// Svelte reactivity: it needs to be a getter
|
|
105
|
+
get current() {
|
|
106
|
+
return writableState;
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evolu/svelte",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Evolu for Svelte",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"evolu",
|
|
7
7
|
"svelte"
|
|
8
8
|
],
|
|
9
|
-
"
|
|
10
|
-
"repository": "evoluhq/evolu",
|
|
9
|
+
"homepage": "https://evolu.dev",
|
|
11
10
|
"bugs": {
|
|
12
11
|
"url": "https://github.com/evoluhq/evolu/issues"
|
|
13
12
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"dist",
|
|
17
|
-
"!dist/**/*.test.*",
|
|
18
|
-
"!dist/**/*.spec.*"
|
|
19
|
-
],
|
|
13
|
+
"repository": "evoluhq/evolu",
|
|
14
|
+
"license": "MIT",
|
|
20
15
|
"sideEffects": [],
|
|
21
|
-
"svelte": "./dist/index.svelte.js",
|
|
22
|
-
"types": "./dist/index.svelte.d.ts",
|
|
23
16
|
"type": "module",
|
|
24
17
|
"exports": {
|
|
25
18
|
".": {
|
|
@@ -27,30 +20,38 @@
|
|
|
27
20
|
"svelte": "./dist/index.svelte.js"
|
|
28
21
|
}
|
|
29
22
|
},
|
|
23
|
+
"svelte": "./dist/index.svelte.js",
|
|
24
|
+
"types": "./dist/index.svelte.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"!dist/**/*.test.*",
|
|
28
|
+
"!dist/**/*.spec.*"
|
|
29
|
+
],
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@sveltejs/package": "^2.
|
|
32
|
-
"@tsconfig/svelte": "^5.0.
|
|
33
|
-
"
|
|
31
|
+
"@sveltejs/package": "^2.5.0",
|
|
32
|
+
"@tsconfig/svelte": "^5.0.5",
|
|
33
|
+
"shx": "^0.4.0",
|
|
34
|
+
"svelte": "^5.38.2",
|
|
34
35
|
"svelte-check": "^4.3.1",
|
|
35
36
|
"typescript": "^5.9.2",
|
|
37
|
+
"@evolu/common": "7.0.0",
|
|
36
38
|
"@evolu/tsconfig": "0.0.2",
|
|
37
|
-
"@evolu/web": "
|
|
38
|
-
"@evolu/common": "6.0.1-preview.18"
|
|
39
|
+
"@evolu/web": "2.0.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
|
-
"@evolu/common": "^
|
|
42
|
-
"@evolu/web": "^
|
|
43
|
-
"svelte": "
|
|
42
|
+
"@evolu/common": "^7.0.0",
|
|
43
|
+
"@evolu/web": "^2.0.0",
|
|
44
|
+
"svelte": ">=5"
|
|
44
45
|
},
|
|
45
46
|
"publishConfig": {
|
|
46
47
|
"access": "public"
|
|
47
48
|
},
|
|
48
49
|
"scripts": {
|
|
49
|
-
"dev": "tsc --watch",
|
|
50
50
|
"build": "shx rm -rf dist && tsc && pnpm run package",
|
|
51
|
-
"preview": "vite preview",
|
|
52
|
-
"package": "svelte-package",
|
|
53
51
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
54
|
-
"clean": "shx rm -rf .turbo .svelte-kit node_modules dist"
|
|
52
|
+
"clean": "shx rm -rf .turbo .svelte-kit node_modules dist",
|
|
53
|
+
"dev": "tsc --watch",
|
|
54
|
+
"package": "svelte-package",
|
|
55
|
+
"preview": "vite preview"
|
|
55
56
|
}
|
|
56
57
|
}
|