@happyvertical/smrt-svelte 0.37.10 → 0.37.11
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.
|
@@ -104,9 +104,9 @@ export interface LiveCollectionOptions {
|
|
|
104
104
|
* <script lang="ts">
|
|
105
105
|
* import { createSmrtCollection } from '@happyvertical/smrt-web';
|
|
106
106
|
* import { liveCollection } from '@happyvertical/smrt-svelte/web';
|
|
107
|
-
* import {
|
|
107
|
+
* import { getCollectionDefinition } from '@happyvertical/smrt-virt-web';
|
|
108
108
|
*
|
|
109
|
-
* const products = createSmrtCollection(
|
|
109
|
+
* const products = createSmrtCollection(getCollectionDefinition('products'), {});
|
|
110
110
|
* const view = liveCollection(products);
|
|
111
111
|
*
|
|
112
112
|
* async function add() {
|
|
@@ -127,6 +127,46 @@ export interface LiveCollectionOptions {
|
|
|
127
127
|
* </ul>
|
|
128
128
|
* {/if}
|
|
129
129
|
* ```
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* SvelteKit hydration seeding (#1761): fetch rows in a server load and pass
|
|
133
|
+
* them as `initialData` so the first client render serves them with NO
|
|
134
|
+
* duplicate fetch. The live view starts populated at `ready`.
|
|
135
|
+
* ```ts
|
|
136
|
+
* // +page.server.ts — read the collection server-side, return plain rows.
|
|
137
|
+
* import { getCollection } from '../lib/server/smrt';
|
|
138
|
+
* import type { PageServerLoad } from './$types';
|
|
139
|
+
*
|
|
140
|
+
* export const load: PageServerLoad = async () => {
|
|
141
|
+
* const products = await getCollection('Product');
|
|
142
|
+
* const rows = await products.list({ limit: 50 });
|
|
143
|
+
* return { products: rows.map((p) => ({ id: p.id, name: p.name })) };
|
|
144
|
+
* };
|
|
145
|
+
* ```
|
|
146
|
+
* ```svelte
|
|
147
|
+
* <!-- +page.svelte — seed the client collection from the hydrated load data. -->
|
|
148
|
+
* <script lang="ts">
|
|
149
|
+
* import { createSmrtCollection } from '@happyvertical/smrt-web';
|
|
150
|
+
* import { liveCollection } from '@happyvertical/smrt-svelte/web';
|
|
151
|
+
* import { getCollectionDefinition } from '@happyvertical/smrt-virt-web';
|
|
152
|
+
* import type { PageProps } from './$types';
|
|
153
|
+
*
|
|
154
|
+
* let { data }: PageProps = $props();
|
|
155
|
+
*
|
|
156
|
+
* // initialData seeds the cache: the first read is served from data.products
|
|
157
|
+
* // (no network request) and revalidates only after staleTimeMs.
|
|
158
|
+
* const products = createSmrtCollection(getCollectionDefinition('products'), {
|
|
159
|
+
* initialData: data.products,
|
|
160
|
+
* });
|
|
161
|
+
* const view = liveCollection(products);
|
|
162
|
+
* </script>
|
|
163
|
+
*
|
|
164
|
+
* <ul>
|
|
165
|
+
* {#each view.rows as row (row.id)}
|
|
166
|
+
* <li>{row.name}</li>
|
|
167
|
+
* {/each}
|
|
168
|
+
* </ul>
|
|
169
|
+
* ```
|
|
130
170
|
*/
|
|
131
171
|
export declare function liveCollection<TData extends object>(handle: SmrtWebCollection<TData>, options?: LiveCollectionOptions): LiveCollection<TData>;
|
|
132
172
|
//# sourceMappingURL=live-collection.svelte.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-collection.svelte.d.ts","sourceRoot":"","sources":["../../src/web/live-collection.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AASjC;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK,SAAS,MAAM;IAClD,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC;;;;OAIG;I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AC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,KAAK,CAAC,GAAG,sBAAsB,CAAC;CACxD;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,kFAAkF;AAClF,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAkCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,wBAAgB,cAAc,CAAC,KAAK,SAAS,MAAM,EACjD,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAChC,OAAO,GAAE,qBAA0B,GAClC,cAAc,CAAC,KAAK,CAAC,CA6DvB"}
|
|
@@ -60,9 +60,9 @@ function toLiveStatus(isReady, isError) {
|
|
|
60
60
|
* <script lang="ts">
|
|
61
61
|
* import { createSmrtCollection } from '@happyvertical/smrt-web';
|
|
62
62
|
* import { liveCollection } from '@happyvertical/smrt-svelte/web';
|
|
63
|
-
* import {
|
|
63
|
+
* import { getCollectionDefinition } from '@happyvertical/smrt-virt-web';
|
|
64
64
|
*
|
|
65
|
-
* const products = createSmrtCollection(
|
|
65
|
+
* const products = createSmrtCollection(getCollectionDefinition('products'), {});
|
|
66
66
|
* const view = liveCollection(products);
|
|
67
67
|
*
|
|
68
68
|
* async function add() {
|
|
@@ -83,6 +83,46 @@ function toLiveStatus(isReady, isError) {
|
|
|
83
83
|
* </ul>
|
|
84
84
|
* {/if}
|
|
85
85
|
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* SvelteKit hydration seeding (#1761): fetch rows in a server load and pass
|
|
89
|
+
* them as `initialData` so the first client render serves them with NO
|
|
90
|
+
* duplicate fetch. The live view starts populated at `ready`.
|
|
91
|
+
* ```ts
|
|
92
|
+
* // +page.server.ts — read the collection server-side, return plain rows.
|
|
93
|
+
* import { getCollection } from '../lib/server/smrt';
|
|
94
|
+
* import type { PageServerLoad } from './$types';
|
|
95
|
+
*
|
|
96
|
+
* export const load: PageServerLoad = async () => {
|
|
97
|
+
* const products = await getCollection('Product');
|
|
98
|
+
* const rows = await products.list({ limit: 50 });
|
|
99
|
+
* return { products: rows.map((p) => ({ id: p.id, name: p.name })) };
|
|
100
|
+
* };
|
|
101
|
+
* ```
|
|
102
|
+
* ```svelte
|
|
103
|
+
* <!-- +page.svelte — seed the client collection from the hydrated load data. -->
|
|
104
|
+
* <script lang="ts">
|
|
105
|
+
* import { createSmrtCollection } from '@happyvertical/smrt-web';
|
|
106
|
+
* import { liveCollection } from '@happyvertical/smrt-svelte/web';
|
|
107
|
+
* import { getCollectionDefinition } from '@happyvertical/smrt-virt-web';
|
|
108
|
+
* import type { PageProps } from './$types';
|
|
109
|
+
*
|
|
110
|
+
* let { data }: PageProps = $props();
|
|
111
|
+
*
|
|
112
|
+
* // initialData seeds the cache: the first read is served from data.products
|
|
113
|
+
* // (no network request) and revalidates only after staleTimeMs.
|
|
114
|
+
* const products = createSmrtCollection(getCollectionDefinition('products'), {
|
|
115
|
+
* initialData: data.products,
|
|
116
|
+
* });
|
|
117
|
+
* const view = liveCollection(products);
|
|
118
|
+
* </script>
|
|
119
|
+
*
|
|
120
|
+
* <ul>
|
|
121
|
+
* {#each view.rows as row (row.id)}
|
|
122
|
+
* <li>{row.name}</li>
|
|
123
|
+
* {/each}
|
|
124
|
+
* </ul>
|
|
125
|
+
* ```
|
|
86
126
|
*/
|
|
87
127
|
export function liveCollection(handle, options = {}) {
|
|
88
128
|
const { preload = true } = options;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-svelte",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.11",
|
|
4
4
|
"description": "Svelte 5 components for SMRT user management - auth, users, tenants, roles, permissions, groups",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"smrtRawPrimitives": "strict",
|
|
@@ -86,10 +86,10 @@
|
|
|
86
86
|
"@tanstack/db": "^0.6.14",
|
|
87
87
|
"@tanstack/svelte-db": "^0.1.91",
|
|
88
88
|
"esm-env": "^1.2.2",
|
|
89
|
-
"@happyvertical/smrt-languages": "0.37.
|
|
90
|
-
"@happyvertical/smrt-types": "0.37.
|
|
91
|
-
"@happyvertical/smrt-ui": "0.37.
|
|
92
|
-
"@happyvertical/smrt-web": "0.37.
|
|
89
|
+
"@happyvertical/smrt-languages": "0.37.11",
|
|
90
|
+
"@happyvertical/smrt-types": "0.37.11",
|
|
91
|
+
"@happyvertical/smrt-ui": "0.37.11",
|
|
92
|
+
"@happyvertical/smrt-web": "0.37.11"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"@huggingface/transformers": ">=3.8.1",
|