@rool-dev/svelte 0.3.1-dev.7549492 → 0.3.1-dev.fa375c5
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/README.md +6 -4
- package/dist/channel.svelte.d.ts +3 -0
- package/dist/channel.svelte.d.ts.map +1 -1
- package/dist/channel.svelte.js +13 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ The Svelte wrapper adds reactive state on top of the SDK:
|
|
|
54
54
|
| `rool.userStorage` | User storage (cross-device preferences) |
|
|
55
55
|
| `channel.interactions` | Channel interactions (auto-updates) |
|
|
56
56
|
| `channel.objectIds` | All object IDs in the space (auto-updates on create/delete) |
|
|
57
|
+
| `channel.collections` | Collection names from the schema (auto-updates) |
|
|
57
58
|
| `watch.objects` | Objects matching a filter (auto-updates) |
|
|
58
59
|
| `watch.loading` | Whether watch is loading |
|
|
59
60
|
|
|
@@ -222,7 +223,7 @@ Create auto-updating watches of objects filtered by field values:
|
|
|
222
223
|
async function open(spaceId) {
|
|
223
224
|
channel = await rool.openChannel(spaceId, 'main');
|
|
224
225
|
// Create a reactive watch of all objects where type === 'article'
|
|
225
|
-
articles = channel.watch({
|
|
226
|
+
articles = channel.watch({ collection: 'article' });
|
|
226
227
|
}
|
|
227
228
|
</script>
|
|
228
229
|
|
|
@@ -244,7 +245,8 @@ Watches automatically re-fetch when objects matching the filter are created, upd
|
|
|
244
245
|
```typescript
|
|
245
246
|
// Watch options (same as findObjects, but no AI prompt)
|
|
246
247
|
const articles = channel.watch({
|
|
247
|
-
|
|
248
|
+
collection: 'article',
|
|
249
|
+
where: { status: 'published' },
|
|
248
250
|
order: 'desc', // by modifiedAt (default)
|
|
249
251
|
limit: 20,
|
|
250
252
|
});
|
|
@@ -316,10 +318,10 @@ channel.channelId
|
|
|
316
318
|
|
|
317
319
|
// Object operations
|
|
318
320
|
await channel.getObject(id)
|
|
319
|
-
await channel.createObject({ data: {
|
|
321
|
+
await channel.createObject({ data: { text: 'Hello' } })
|
|
320
322
|
await channel.updateObject(id, { data: { text: 'Updated' } })
|
|
321
323
|
await channel.deleteObjects([id])
|
|
322
|
-
await channel.findObjects({
|
|
324
|
+
await channel.findObjects({ collection: 'note' })
|
|
323
325
|
|
|
324
326
|
// AI
|
|
325
327
|
await channel.prompt('Summarize everything')
|
package/dist/channel.svelte.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { RoolChannel, RoolClient, Interaction, RoolObject, ChannelInfo } fr
|
|
|
6
6
|
export interface WatchOptions {
|
|
7
7
|
/** Field requirements for exact matching */
|
|
8
8
|
where?: Record<string, unknown>;
|
|
9
|
+
/** Filter by collection name. Only returns objects whose shape matches the named collection. */
|
|
10
|
+
collection?: string;
|
|
9
11
|
/** Maximum number of objects */
|
|
10
12
|
limit?: number;
|
|
11
13
|
/** Sort order by modifiedAt: 'asc' or 'desc' (default: 'desc') */
|
|
@@ -55,6 +57,7 @@ declare class ReactiveChannelImpl {
|
|
|
55
57
|
#private;
|
|
56
58
|
interactions: Interaction[];
|
|
57
59
|
objectIds: string[];
|
|
60
|
+
collections: string[];
|
|
58
61
|
constructor(channel: RoolChannel);
|
|
59
62
|
get id(): string;
|
|
60
63
|
get name(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.svelte.d.ts","sourceRoot":"","sources":["../src/channel.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAsB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEvH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACxB;AAGD;;GAE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AC;IAU9B;;OAEG;IACH,KAAK,IAAI,IAAI;CAId;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAE1F;AAED,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAC"}
|
package/dist/channel.svelte.js
CHANGED
|
@@ -77,6 +77,9 @@ class ReactiveWatchImpl {
|
|
|
77
77
|
* Check if an object matches the `where` filter.
|
|
78
78
|
*/
|
|
79
79
|
#matches(object) {
|
|
80
|
+
// Collection membership is shape-based and resolved server-side — can't match locally
|
|
81
|
+
if (this.#options.collection)
|
|
82
|
+
return true;
|
|
80
83
|
const where = this.#options.where;
|
|
81
84
|
if (!where)
|
|
82
85
|
return true;
|
|
@@ -94,6 +97,7 @@ class ReactiveWatchImpl {
|
|
|
94
97
|
try {
|
|
95
98
|
const findOptions = {
|
|
96
99
|
where: this.#options.where,
|
|
100
|
+
collection: this.#options.collection,
|
|
97
101
|
limit: this.#options.limit,
|
|
98
102
|
order: this.#options.order,
|
|
99
103
|
ephemeral: true, // Don't pollute interaction history
|
|
@@ -194,10 +198,12 @@ class ReactiveChannelImpl {
|
|
|
194
198
|
// Reactive state
|
|
195
199
|
interactions = $state([]);
|
|
196
200
|
objectIds = $state([]);
|
|
201
|
+
collections = $state([]);
|
|
197
202
|
constructor(channel) {
|
|
198
203
|
this.#channel = channel;
|
|
199
204
|
this.interactions = channel.getInteractions();
|
|
200
205
|
this.objectIds = channel.getObjectIds();
|
|
206
|
+
this.collections = Object.keys(channel.getSchema());
|
|
201
207
|
// Subscribe to channel updates
|
|
202
208
|
const onChannelUpdated = () => {
|
|
203
209
|
this.interactions = channel.getInteractions();
|
|
@@ -212,9 +218,16 @@ class ReactiveChannelImpl {
|
|
|
212
218
|
this.#unsubscribers.push(() => channel.off('objectCreated', refreshObjectIds));
|
|
213
219
|
channel.on('objectDeleted', refreshObjectIds);
|
|
214
220
|
this.#unsubscribers.push(() => channel.off('objectDeleted', refreshObjectIds));
|
|
221
|
+
// Subscribe to schema updates for collections
|
|
222
|
+
const onSchemaUpdated = () => {
|
|
223
|
+
this.collections = Object.keys(channel.getSchema());
|
|
224
|
+
};
|
|
225
|
+
channel.on('schemaUpdated', onSchemaUpdated);
|
|
226
|
+
this.#unsubscribers.push(() => channel.off('schemaUpdated', onSchemaUpdated));
|
|
215
227
|
const onReset = () => {
|
|
216
228
|
this.interactions = channel.getInteractions();
|
|
217
229
|
this.objectIds = channel.getObjectIds();
|
|
230
|
+
this.collections = Object.keys(channel.getSchema());
|
|
218
231
|
};
|
|
219
232
|
channel.on('reset', onReset);
|
|
220
233
|
this.#unsubscribers.push(() => channel.off('reset', onReset));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rool-dev/svelte",
|
|
3
|
-
"version": "0.3.1-dev.
|
|
3
|
+
"version": "0.3.1-dev.fa375c5",
|
|
4
4
|
"description": "Svelte 5 runes for Rool Spaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@rool-dev/sdk": "0.3.1-dev.
|
|
44
|
+
"@rool-dev/sdk": "0.3.1-dev.fa375c5"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"svelte": "^5.0.0"
|