svas 1.0.0 → 1.2.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/async/Async.svelte +14 -20
- package/dist/awaited.d.ts +3 -0
- package/dist/awaited.js +4 -0
- package/dist/having.d.ts +0 -4
- package/dist/having.js +3 -21
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/sync.d.ts +1 -1
- package/dist/sync.js +1 -1
- package/dist/waitUntil.d.ts +2 -0
- package/dist/waitUntil.js +16 -0
- package/package.json +1 -6
package/dist/async/Async.svelte
CHANGED
|
@@ -12,24 +12,18 @@
|
|
|
12
12
|
}: Props<T> = $props();
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
{#if
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<div class="w-full h-full flex justify-center items-center">
|
|
21
|
-
<LoaderCircle class="animate-spin text-gray-400" />
|
|
22
|
-
</div>
|
|
23
|
-
{/if}
|
|
24
|
-
{:else if $store instanceof Error}
|
|
25
|
-
{#if error}
|
|
26
|
-
{@render error($store)}
|
|
27
|
-
{:else if !silent}
|
|
28
|
-
<div class="w-full h-full flex justify-center items-center">
|
|
29
|
-
Something went terribly wrong
|
|
30
|
-
</div>
|
|
31
|
-
{/if}
|
|
32
|
-
{:else}
|
|
33
|
-
{@render awaited($store)}
|
|
15
|
+
{#if $store === null}
|
|
16
|
+
{#if waiting}
|
|
17
|
+
{@render waiting()}
|
|
18
|
+
{:else if !silent}
|
|
19
|
+
<LoaderCircle class="animate-spin m-auto text-muted-foreground" />
|
|
34
20
|
{/if}
|
|
35
|
-
|
|
21
|
+
{:else if $store instanceof Error}
|
|
22
|
+
{#if error}
|
|
23
|
+
{@render error($store)}
|
|
24
|
+
{:else if !silent}
|
|
25
|
+
<span class="text-destructive">Something went terribly wrong</span>
|
|
26
|
+
{/if}
|
|
27
|
+
{:else}
|
|
28
|
+
{@render awaited($store)}
|
|
29
|
+
{/if}
|
package/dist/awaited.js
ADDED
package/dist/having.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import type { Readable } from 'svelte/store';
|
|
2
2
|
import type { Maybe } from './Maybe';
|
|
3
|
-
/**
|
|
4
|
-
* Execute a callback once the store has a non-null and non-error value.
|
|
5
|
-
*/
|
|
6
3
|
export declare function having<T>(store: Readable<Maybe<T>>): Promise<T>;
|
|
7
|
-
export declare function having<T>(store: Readable<Maybe<T>>, callback: (value: T) => unknown | Promise<unknown>): void;
|
package/dist/having.js
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let unsubscribe = null;
|
|
5
|
-
unsubscribe = store.subscribe((value) => {
|
|
6
|
-
if (value === null || value instanceof Error)
|
|
7
|
-
return;
|
|
8
|
-
// A
|
|
9
|
-
unsubscribe?.();
|
|
10
|
-
completed = true;
|
|
11
|
-
resolve(value);
|
|
12
|
-
});
|
|
13
|
-
// B
|
|
14
|
-
if (completed)
|
|
15
|
-
unsubscribe?.();
|
|
16
|
-
// the execution order of A and B is uncertain
|
|
17
|
-
});
|
|
18
|
-
if (callback === undefined)
|
|
19
|
-
return promise;
|
|
20
|
-
else
|
|
21
|
-
promise.then(callback);
|
|
1
|
+
import { waitUntil } from './waitUntil';
|
|
2
|
+
export function having(store) {
|
|
3
|
+
return waitUntil(store, (value) => value !== null && !(value instanceof Error));
|
|
22
4
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { collection, type Collection } from './collection';
|
|
2
2
|
export { values, type Values } from './values';
|
|
3
3
|
export { value } from './value';
|
|
4
|
+
export { awaited } from './awaited';
|
|
4
5
|
export { having } from './having';
|
|
5
6
|
export { ensure } from './ensure';
|
|
6
7
|
export { sync } from './sync';
|
package/dist/index.js
CHANGED
package/dist/sync.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Collection, Identifiable, SetOptions } from './collection';
|
|
2
|
-
export declare function sync<T extends Comparable>(
|
|
2
|
+
export declare function sync<T extends Comparable>(collection: Collection<T>, tobe: T, options?: Options): void;
|
|
3
3
|
interface Comparable extends Identifiable {
|
|
4
4
|
_version: number;
|
|
5
5
|
_deleted?: number | null;
|
package/dist/sync.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function waitUntil(store, condition) {
|
|
2
|
+
const promise = new Promise((resolve) => {
|
|
3
|
+
let completed = false;
|
|
4
|
+
let unsubscribe = null;
|
|
5
|
+
unsubscribe = store.subscribe((value) => {
|
|
6
|
+
if (!condition(value))
|
|
7
|
+
return;
|
|
8
|
+
unsubscribe?.();
|
|
9
|
+
completed = true;
|
|
10
|
+
resolve(value);
|
|
11
|
+
});
|
|
12
|
+
if (completed)
|
|
13
|
+
unsubscribe?.();
|
|
14
|
+
});
|
|
15
|
+
return promise;
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svas",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"repository": "https://github.com/temich/svas",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev",
|
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
"!dist/**/*.test.*",
|
|
19
19
|
"!dist/**/*.spec.*"
|
|
20
20
|
],
|
|
21
|
-
"sideEffects": [
|
|
22
|
-
"**/*.css"
|
|
23
|
-
],
|
|
24
21
|
"svelte": "./dist/index.js",
|
|
25
22
|
"types": "./dist/index.d.ts",
|
|
26
23
|
"type": "module",
|
|
@@ -48,14 +45,12 @@
|
|
|
48
45
|
"@sveltejs/kit": "^2.49.2",
|
|
49
46
|
"@sveltejs/package": "^2.5.7",
|
|
50
47
|
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
51
|
-
"autoprefixer": "^10.4.22",
|
|
52
48
|
"eslint": "^9.39.1",
|
|
53
49
|
"eslint-plugin-svelte": "^3.13.1",
|
|
54
50
|
"globals": "^16.5.0",
|
|
55
51
|
"publint": "^0.3.15",
|
|
56
52
|
"svelte": "^5.45.8",
|
|
57
53
|
"svelte-check": "^4.3.4",
|
|
58
|
-
"tailwindcss": "^4.1.17",
|
|
59
54
|
"typescript": "^5.9.3",
|
|
60
55
|
"typescript-eslint": "^8.49.0",
|
|
61
56
|
"vite": "^7.2.7"
|