@rool-dev/svelte 0.6.5 → 0.7.0-dev.541aa22
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 +51 -47
- package/dist/channel.svelte.d.ts +1 -0
- package/dist/channel.svelte.d.ts.map +1 -1
- package/dist/channel.svelte.js +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/rool.svelte.d.ts +12 -17
- package/dist/rool.svelte.d.ts.map +1 -1
- package/dist/rool.svelte.js +30 -31
- package/dist/space.svelte.d.ts +46 -0
- package/dist/space.svelte.d.ts.map +1 -0
- package/dist/space.svelte.js +90 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -28,9 +28,12 @@ npm install @rool-dev/svelte
|
|
|
28
28
|
<button onclick={() => rool.login('My App')}>Login</button>
|
|
29
29
|
{:else}
|
|
30
30
|
<h1>My Spaces</h1>
|
|
31
|
-
{#each rool.spaces ?? [] as
|
|
32
|
-
<button onclick={async () =>
|
|
33
|
-
|
|
31
|
+
{#each rool.spaces ?? [] as spaceInfo}
|
|
32
|
+
<button onclick={async () => {
|
|
33
|
+
const space = await rool.openSpace(spaceInfo.id);
|
|
34
|
+
channel = await space.openChannel('main');
|
|
35
|
+
}}>
|
|
36
|
+
{spaceInfo.name}
|
|
34
37
|
</button>
|
|
35
38
|
{/each}
|
|
36
39
|
|
|
@@ -73,7 +76,7 @@ rool.init(); // Process auth callbacks (call on app startup)
|
|
|
73
76
|
rool.login('My App'); // Redirect to login page
|
|
74
77
|
rool.signup('My App'); // Redirect to signup page
|
|
75
78
|
rool.verify(token); // Sign in from an email verification link (used by the official Rool app)
|
|
76
|
-
rool.logout(); // Clear auth state and close all
|
|
79
|
+
rool.logout(); // Clear auth state and close all open spaces
|
|
77
80
|
rool.destroy(); // Clean up all resources
|
|
78
81
|
```
|
|
79
82
|
|
|
@@ -128,42 +131,46 @@ Reactive cross-device storage for user preferences. Synced from server on `init(
|
|
|
128
131
|
|
|
129
132
|
### Spaces & Channels
|
|
130
133
|
|
|
131
|
-
|
|
132
|
-
// Open a channel — reactive, with SSE (default conversation)
|
|
133
|
-
const channel = await rool.openChannel('space-id', 'my-channel');
|
|
134
|
+
Every space has its own SSE subscription. Open a space, then open channels on it. Call `space.close()` when done — this closes all open channels and stops the subscription.
|
|
134
135
|
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
```typescript
|
|
137
|
+
// Open a space — reactive, with SSE
|
|
138
|
+
const space = await rool.openSpace('space-id');
|
|
137
139
|
|
|
138
|
-
//
|
|
139
|
-
const
|
|
140
|
-
const
|
|
140
|
+
// Open channels on the space
|
|
141
|
+
const channel = await space.openChannel('my-channel');
|
|
142
|
+
const other = await space.openChannel('research'); // Independent channel, same space
|
|
141
143
|
|
|
142
|
-
//
|
|
143
|
-
const space = await rool.openSpace('space-id');
|
|
144
|
+
// Space admin
|
|
144
145
|
await space.rename('New Name');
|
|
145
146
|
await space.addUser(userId, 'editor');
|
|
146
147
|
|
|
147
|
-
//
|
|
148
|
-
await rool.
|
|
148
|
+
// Create a new space
|
|
149
|
+
const fresh = await rool.createSpace('My New Space');
|
|
150
|
+
const ch = await fresh.openChannel('main');
|
|
151
|
+
|
|
152
|
+
// Import from a zip archive
|
|
153
|
+
const imported = await rool.importArchive('Imported', archiveBlob);
|
|
149
154
|
|
|
150
|
-
//
|
|
151
|
-
|
|
155
|
+
// Delete a space permanently
|
|
156
|
+
await rool.deleteSpace('space-id');
|
|
152
157
|
|
|
153
|
-
// Clean up
|
|
154
|
-
|
|
158
|
+
// Clean up — closes all open channels AND stops the subscription
|
|
159
|
+
space.close();
|
|
155
160
|
```
|
|
156
161
|
|
|
157
162
|
### ReactiveChannel
|
|
158
163
|
|
|
159
|
-
`openChannel` returns a `ReactiveChannel` — the SDK's `RoolChannel` with reactive `interactions` and `objectIds`:
|
|
164
|
+
`space.openChannel()` returns a `ReactiveChannel` — the SDK's `RoolChannel` with reactive `interactions` and `objectIds`:
|
|
160
165
|
|
|
161
166
|
```svelte
|
|
162
167
|
<script>
|
|
168
|
+
let space = $state(null);
|
|
163
169
|
let channel = $state(null);
|
|
164
170
|
|
|
165
171
|
async function open(spaceId) {
|
|
166
|
-
|
|
172
|
+
space = await rool.openSpace(spaceId);
|
|
173
|
+
channel = await space.openChannel('main');
|
|
167
174
|
}
|
|
168
175
|
</script>
|
|
169
176
|
|
|
@@ -189,8 +196,11 @@ Track a single object by ID with auto-updates:
|
|
|
189
196
|
let channel = $state(null);
|
|
190
197
|
let item = $state(null);
|
|
191
198
|
|
|
199
|
+
let space = $state(null);
|
|
200
|
+
|
|
192
201
|
async function open(spaceId, objectId) {
|
|
193
|
-
|
|
202
|
+
space = await rool.openSpace(spaceId);
|
|
203
|
+
channel = await space.openChannel('main');
|
|
194
204
|
item = channel.object(objectId);
|
|
195
205
|
}
|
|
196
206
|
</script>
|
|
@@ -227,8 +237,11 @@ Create auto-updating watches of objects filtered by field values:
|
|
|
227
237
|
let channel = $state(null);
|
|
228
238
|
let articles = $state(null);
|
|
229
239
|
|
|
240
|
+
let space = $state(null);
|
|
241
|
+
|
|
230
242
|
async function open(spaceId) {
|
|
231
|
-
|
|
243
|
+
space = await rool.openSpace(spaceId);
|
|
244
|
+
channel = await space.openChannel('main');
|
|
232
245
|
// Create a reactive watch of all objects where type === 'article'
|
|
233
246
|
articles = channel.watch({ collection: 'article' });
|
|
234
247
|
}
|
|
@@ -269,36 +282,24 @@ articles.close() // Stop listening for updates
|
|
|
269
282
|
|
|
270
283
|
### Reactive Channel List
|
|
271
284
|
|
|
272
|
-
|
|
285
|
+
`space.channels` is a reactive `ChannelInfo[]` that auto-updates as channels are created, renamed, or deleted.
|
|
273
286
|
|
|
274
287
|
```svelte
|
|
275
288
|
<script>
|
|
276
|
-
|
|
289
|
+
let space = $state(null);
|
|
277
290
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
291
|
+
async function open(spaceId) {
|
|
292
|
+
space = await rool.openSpace(spaceId);
|
|
293
|
+
}
|
|
281
294
|
</script>
|
|
282
295
|
|
|
283
|
-
{#if
|
|
284
|
-
|
|
285
|
-
{
|
|
286
|
-
{#each channelList.list as ch}
|
|
287
|
-
<button onclick={() => openChannel(ch.id)}>{ch.name ?? ch.id}</button>
|
|
296
|
+
{#if space}
|
|
297
|
+
{#each space.channels as ch}
|
|
298
|
+
<button onclick={() => space.openChannel(ch.id)}>{ch.name ?? ch.id}</button>
|
|
288
299
|
{/each}
|
|
289
300
|
{/if}
|
|
290
301
|
```
|
|
291
302
|
|
|
292
|
-
```typescript
|
|
293
|
-
// Reactive state
|
|
294
|
-
channelList.list // $state<ChannelInfo[]>
|
|
295
|
-
channelList.loading // $state<boolean>
|
|
296
|
-
|
|
297
|
-
// Methods
|
|
298
|
-
channelList.refresh() // Manual re-fetch
|
|
299
|
-
channelList.close() // Stop listening for updates
|
|
300
|
-
```
|
|
301
|
-
|
|
302
303
|
### Reactive Conversation Handle
|
|
303
304
|
|
|
304
305
|
For apps with multiple independent interaction threads (e.g., chat with threads), use `channel.conversation()` to get a handle with reactive interactions:
|
|
@@ -308,8 +309,11 @@ For apps with multiple independent interaction threads (e.g., chat with threads)
|
|
|
308
309
|
let channel = $state(null);
|
|
309
310
|
let thread = $state(null);
|
|
310
311
|
|
|
312
|
+
let space = $state(null);
|
|
313
|
+
|
|
311
314
|
async function openThread(spaceId, threadId) {
|
|
312
|
-
|
|
315
|
+
space = await rool.openSpace(spaceId);
|
|
316
|
+
channel = await space.openChannel('main');
|
|
313
317
|
thread = channel.conversation(threadId);
|
|
314
318
|
}
|
|
315
319
|
</script>
|
|
@@ -329,7 +333,7 @@ thread.interactions // $state<Interaction[]> — auto-updates via SSE
|
|
|
329
333
|
|
|
330
334
|
// All conversation-scoped methods
|
|
331
335
|
await thread.prompt('Hello')
|
|
332
|
-
await thread.createObject({ data: { text: 'Note' } })
|
|
336
|
+
await thread.createObject({ data: { type: 'note', text: 'Note' } })
|
|
333
337
|
await thread.setSystemInstruction('Respond in haiku')
|
|
334
338
|
await thread.rename('Research Thread')
|
|
335
339
|
thread.getInteractions() // Manual read
|
|
@@ -367,7 +371,7 @@ channel.channelId
|
|
|
367
371
|
|
|
368
372
|
// Object operations
|
|
369
373
|
await channel.getObject(id)
|
|
370
|
-
await channel.createObject({ data: { text: 'Hello' } })
|
|
374
|
+
await channel.createObject({ data: { type: 'note', text: 'Hello' } })
|
|
371
375
|
await channel.updateObject(id, { data: { text: 'Updated' } })
|
|
372
376
|
await channel.deleteObjects([id])
|
|
373
377
|
await channel.findObjects({ collection: 'note' })
|
package/dist/channel.svelte.d.ts
CHANGED
|
@@ -115,6 +115,7 @@ declare class ReactiveChannelImpl {
|
|
|
115
115
|
get linkAccess(): import("@rool-dev/sdk").LinkAccess;
|
|
116
116
|
get extensionUrl(): string | null;
|
|
117
117
|
get manifest(): import("@rool-dev/sdk").ExtensionManifest | null;
|
|
118
|
+
get isClosed(): boolean;
|
|
118
119
|
close(): void;
|
|
119
120
|
getObject(...args: Parameters<RoolChannel['getObject']>): Promise<RoolObject | undefined>;
|
|
120
121
|
stat(...args: Parameters<RoolChannel['stat']>): import("@rool-dev/sdk").RoolObjectStat | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.svelte.d.ts","sourceRoot":"","sources":["../src/channel.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAsB,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EAA4B,MAAM,eAAe,CAAC;AAEtL;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,gGAAgG;IAChG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kE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AAe,CAEjE;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAElD;;;;GAIG;AACH,cAAM,uBAAuB;;IAK3B,IAAI,gBAA6B;IACjC,OAAO,UAAgB;gBAEX,cAAc,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAqC1D;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAW9B;;OAEG;IACH,KAAK,IAAI,IAAI;CAId;AAED,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,mBAAmB,CAErG;AAED,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAC"}
|
package/dist/channel.svelte.js
CHANGED
|
@@ -318,8 +318,11 @@ class ReactiveChannelImpl {
|
|
|
318
318
|
get linkAccess() { return this.#channel.linkAccess; }
|
|
319
319
|
get extensionUrl() { return this.#channel.extensionUrl; }
|
|
320
320
|
get manifest() { return this.#channel.manifest; }
|
|
321
|
+
get isClosed() { return this.#closed; }
|
|
321
322
|
// Proxy all methods
|
|
322
323
|
close() {
|
|
324
|
+
if (this.#closed)
|
|
325
|
+
return;
|
|
323
326
|
this.#closed = true;
|
|
324
327
|
for (const unsub of this.#unsubscribers)
|
|
325
328
|
unsub();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { createRool, generateId } from './rool.svelte.js';
|
|
2
2
|
export { wrapChannel } from './channel.svelte.js';
|
|
3
|
+
export { wrapSpace } from './space.svelte.js';
|
|
3
4
|
export type { Rool } from './rool.svelte.js';
|
|
4
5
|
export type { ReactiveChannel, ReactiveConversationHandle, ReactiveObject, ReactiveWatch, ReactiveChannelList, WatchOptions } from './channel.svelte.js';
|
|
6
|
+
export type { ReactiveSpace } from './space.svelte.js';
|
|
5
7
|
export type { RoolClientConfig, RoolChannel, RoolSpace, RoolSpaceInfo, RoolObject, RoolObjectStat, RoolUserRole, ConnectionState, ChannelInfo, Conversation, ConversationInfo, CurrentUser, Interaction, FindObjectsOptions, PromptOptions, CreateObjectOptions, UpdateObjectOptions, FieldType, FieldDef, CollectionDef, SpaceSchema, SpaceMember, UserResult, RoolClient, ExtensionInfo, PublishedExtensionInfo, UploadExtensionOptions, ExtensionManifest, FindExtensionsOptions, RoolSpaceEvents, } from '@rool-dev/sdk';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,0BAA0B,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzJ,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,aAAa,EACb,UAAU,EACV,cAAc,EACd,YAAY,EACZ,eAAe,EACf,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EACT,QAAQ,EACR,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,GAChB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/rool.svelte.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { RoolClient, type
|
|
2
|
-
import { type
|
|
1
|
+
import { RoolClient, type RoolSpaceInfo, type ConnectionState, type RoolClientConfig, type CurrentUser, type FindExtensionsOptions, type ExtensionInfo, type PublishedExtensionInfo, type UploadExtensionOptions } from '@rool-dev/sdk';
|
|
2
|
+
import { type ReactiveChannelList } from './channel.svelte.js';
|
|
3
|
+
import { type ReactiveSpace } from './space.svelte.js';
|
|
3
4
|
/**
|
|
4
5
|
* Rool client with reactive state for Svelte 5.
|
|
5
6
|
*
|
|
@@ -44,24 +45,19 @@ declare class RoolImpl {
|
|
|
44
45
|
*/
|
|
45
46
|
verify(token: string): Promise<boolean>;
|
|
46
47
|
/**
|
|
47
|
-
* Log out and close all open
|
|
48
|
+
* Log out and close all open spaces.
|
|
48
49
|
*/
|
|
49
50
|
logout(): void;
|
|
50
51
|
/**
|
|
51
|
-
* Open a
|
|
52
|
-
*
|
|
52
|
+
* Open a space with a live SSE subscription. Returns a ReactiveSpace.
|
|
53
|
+
* Call `space.openChannel(channelId)` to get a ReactiveChannel.
|
|
54
|
+
* Call `space.close()` when done to stop the subscription.
|
|
53
55
|
*/
|
|
54
|
-
|
|
56
|
+
openSpace(spaceId: string): Promise<ReactiveSpace>;
|
|
55
57
|
/**
|
|
56
|
-
*
|
|
57
|
-
* Returns a lightweight RoolSpace handle (not reactive).
|
|
58
|
+
* Create a new space. Returns a ReactiveSpace.
|
|
58
59
|
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Create a new space.
|
|
62
|
-
* Returns a lightweight RoolSpace handle (not reactive).
|
|
63
|
-
*/
|
|
64
|
-
createSpace(name: string): Promise<RoolSpace>;
|
|
60
|
+
createSpace(name: string): Promise<ReactiveSpace>;
|
|
65
61
|
/**
|
|
66
62
|
* Manually refresh the spaces list.
|
|
67
63
|
*/
|
|
@@ -85,10 +81,9 @@ declare class RoolImpl {
|
|
|
85
81
|
*/
|
|
86
82
|
searchUser(email: string): Promise<import("@rool-dev/sdk").UserResult | null>;
|
|
87
83
|
/**
|
|
88
|
-
* Import a space from a zip archive.
|
|
89
|
-
* Returns a lightweight RoolSpace handle (not reactive).
|
|
84
|
+
* Import a space from a zip archive. Returns a ReactiveSpace.
|
|
90
85
|
*/
|
|
91
|
-
importArchive(name: string, archive: Blob): Promise<
|
|
86
|
+
importArchive(name: string, archive: Blob): Promise<ReactiveSpace>;
|
|
92
87
|
/**
|
|
93
88
|
* Get auth user info from JWT token.
|
|
94
89
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rool.svelte.d.ts","sourceRoot":"","sources":["../src/rool.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"rool.svelte.d.ts","sourceRoot":"","sources":["../src/rool.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,KAAK,qBAAqB,EAAE,KAAK,aAAa,EAAE,KAAK,sBAAsB,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACxO,OAAO,EAAqB,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElE;;;;;;;;GAQG;AACH,cAAM,QAAQ;;IAMZ,aAAa,iBAAgC;IAC7C,MAAM,8BAAkD;IACxD,aAAa,UAAiB;IAC9B,WAAW,eAA8B;IACzC,eAAe,kBAA2C;IAC1D,WAAW,0BAAuC;IAClD,WAAW,qBAAoC;gBAEnC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CAAC,EAAE,gBAAgB,GAAG,IAAI,CAE1D;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,MAAM,MAAM,IAAI,GAAG,QAAQ,CAAC"}
|
package/dist/rool.svelte.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RoolClient } from '@rool-dev/sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { createChannelList } from './channel.svelte.js';
|
|
3
|
+
import { wrapSpace } from './space.svelte.js';
|
|
3
4
|
/**
|
|
4
5
|
* Rool client with reactive state for Svelte 5.
|
|
5
6
|
*
|
|
@@ -12,7 +13,7 @@ import { wrapChannel, createChannelList } from './channel.svelte.js';
|
|
|
12
13
|
class RoolImpl {
|
|
13
14
|
#client;
|
|
14
15
|
#unsubscribers = [];
|
|
15
|
-
#
|
|
16
|
+
#openSpaces = new Set();
|
|
16
17
|
// Reactive state
|
|
17
18
|
authenticated = $state(null); // null = checking, false = not auth, true = auth
|
|
18
19
|
spaces = $state(undefined);
|
|
@@ -133,38 +134,34 @@ class RoolImpl {
|
|
|
133
134
|
return ok;
|
|
134
135
|
}
|
|
135
136
|
/**
|
|
136
|
-
* Log out and close all open
|
|
137
|
+
* Log out and close all open spaces.
|
|
137
138
|
*/
|
|
138
139
|
logout() {
|
|
139
|
-
for (const
|
|
140
|
-
|
|
140
|
+
for (const space of this.#openSpaces) {
|
|
141
|
+
space.close();
|
|
141
142
|
}
|
|
142
|
-
this.#
|
|
143
|
+
this.#openSpaces.clear();
|
|
143
144
|
this.#client.logout();
|
|
144
145
|
}
|
|
145
146
|
/**
|
|
146
|
-
* Open a
|
|
147
|
-
*
|
|
147
|
+
* Open a space with a live SSE subscription. Returns a ReactiveSpace.
|
|
148
|
+
* Call `space.openChannel(channelId)` to get a ReactiveChannel.
|
|
149
|
+
* Call `space.close()` when done to stop the subscription.
|
|
148
150
|
*/
|
|
149
|
-
async
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
this.#
|
|
153
|
-
return
|
|
151
|
+
async openSpace(spaceId) {
|
|
152
|
+
const raw = await this.#client.openSpace(spaceId);
|
|
153
|
+
const reactive = wrapSpace(raw);
|
|
154
|
+
this.#openSpaces.add(reactive);
|
|
155
|
+
return reactive;
|
|
154
156
|
}
|
|
155
157
|
/**
|
|
156
|
-
*
|
|
157
|
-
* Returns a lightweight RoolSpace handle (not reactive).
|
|
158
|
+
* Create a new space. Returns a ReactiveSpace.
|
|
158
159
|
*/
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
* Returns a lightweight RoolSpace handle (not reactive).
|
|
165
|
-
*/
|
|
166
|
-
createSpace(name) {
|
|
167
|
-
return this.#client.createSpace(name);
|
|
160
|
+
async createSpace(name) {
|
|
161
|
+
const raw = await this.#client.createSpace(name);
|
|
162
|
+
const reactive = wrapSpace(raw);
|
|
163
|
+
this.#openSpaces.add(reactive);
|
|
164
|
+
return reactive;
|
|
168
165
|
}
|
|
169
166
|
/**
|
|
170
167
|
* Manually refresh the spaces list.
|
|
@@ -200,11 +197,13 @@ class RoolImpl {
|
|
|
200
197
|
return this.#client.searchUser(email);
|
|
201
198
|
}
|
|
202
199
|
/**
|
|
203
|
-
* Import a space from a zip archive.
|
|
204
|
-
* Returns a lightweight RoolSpace handle (not reactive).
|
|
200
|
+
* Import a space from a zip archive. Returns a ReactiveSpace.
|
|
205
201
|
*/
|
|
206
|
-
importArchive(name, archive) {
|
|
207
|
-
|
|
202
|
+
async importArchive(name, archive) {
|
|
203
|
+
const raw = await this.#client.importArchive(name, archive);
|
|
204
|
+
const reactive = wrapSpace(raw);
|
|
205
|
+
this.#openSpaces.add(reactive);
|
|
206
|
+
return reactive;
|
|
208
207
|
}
|
|
209
208
|
/**
|
|
210
209
|
* Get auth user info from JWT token.
|
|
@@ -292,10 +291,10 @@ class RoolImpl {
|
|
|
292
291
|
* Clean up resources.
|
|
293
292
|
*/
|
|
294
293
|
destroy() {
|
|
295
|
-
for (const
|
|
296
|
-
|
|
294
|
+
for (const space of this.#openSpaces) {
|
|
295
|
+
space.close();
|
|
297
296
|
}
|
|
298
|
-
this.#
|
|
297
|
+
this.#openSpaces.clear();
|
|
299
298
|
for (const unsub of this.#unsubscribers) {
|
|
300
299
|
unsub();
|
|
301
300
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { RoolSpace, ChannelInfo, ConnectionState, RoolUserRole, LinkAccess, SpaceMember } from '@rool-dev/sdk';
|
|
2
|
+
import { type ReactiveChannel } from './channel.svelte.js';
|
|
3
|
+
/**
|
|
4
|
+
* A reactive wrapper around a RoolSpace. Exposes reactive `channels` and
|
|
5
|
+
* `connectionState`, and provides `openChannel()` that returns a ReactiveChannel.
|
|
6
|
+
*
|
|
7
|
+
* Lifecycle: call `close()` when done. Closes all opened channels and stops the
|
|
8
|
+
* space's SSE subscription.
|
|
9
|
+
*/
|
|
10
|
+
declare class ReactiveSpaceImpl {
|
|
11
|
+
#private;
|
|
12
|
+
connectionState: ConnectionState;
|
|
13
|
+
constructor(space: RoolSpace);
|
|
14
|
+
get isClosed(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Open a channel on this space. Returns a ReactiveChannel with reactive state.
|
|
17
|
+
* Repeated calls with the same channelId return the same instance (until closed).
|
|
18
|
+
*/
|
|
19
|
+
openChannel(channelId: string): Promise<ReactiveChannel>;
|
|
20
|
+
/**
|
|
21
|
+
* Close this space: closes all open reactive channels and stops the SSE
|
|
22
|
+
* subscription. Idempotent.
|
|
23
|
+
*/
|
|
24
|
+
close(): void;
|
|
25
|
+
get channels(): ChannelInfo[];
|
|
26
|
+
get id(): string;
|
|
27
|
+
get name(): string;
|
|
28
|
+
get role(): RoolUserRole;
|
|
29
|
+
get linkAccess(): LinkAccess;
|
|
30
|
+
get memberCount(): number;
|
|
31
|
+
rename(newName: string): Promise<void>;
|
|
32
|
+
delete(): Promise<void>;
|
|
33
|
+
listUsers(): Promise<SpaceMember[]>;
|
|
34
|
+
addUser(...args: Parameters<RoolSpace['addUser']>): Promise<void>;
|
|
35
|
+
removeUser(userId: string): Promise<void>;
|
|
36
|
+
setLinkAccess(...args: Parameters<RoolSpace['setLinkAccess']>): Promise<void>;
|
|
37
|
+
deleteChannel(channelId: string): Promise<void>;
|
|
38
|
+
exportArchive(): Promise<Blob>;
|
|
39
|
+
refresh(): Promise<void>;
|
|
40
|
+
on(...args: Parameters<RoolSpace['on']>): () => void;
|
|
41
|
+
off(...args: Parameters<RoolSpace['off']>): void;
|
|
42
|
+
}
|
|
43
|
+
export declare function wrapSpace(space: RoolSpace): ReactiveSpace;
|
|
44
|
+
export type ReactiveSpace = ReactiveSpaceImpl;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=space.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"space.svelte.d.ts","sourceRoot":"","sources":["../src/space.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpH,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAExE;;;;;;GAMG;AACH,cAAM,iBAAiB;;IAQrB,eAAe,kBAA2C;gBAE9C,KAAK,EAAE,SAAS;IAmB5B,IAAI,QAAQ,YAA2B;IAEvC;;;OAGG;IACG,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAY9D;;;OAGG;IACH,KAAK,IAAI,IAAI;IAgBb,IAAI,QAAQ,IAAI,WAAW,EAAE,CAA8B;IAG3D,IAAI,EAAE,IAAI,MAAM,CAA2B;IAC3C,IAAI,IAAI,IAAI,MAAM,CAA6B;IAC/C,IAAI,IAAI,IAAI,YAAY,CAA6B;IACrD,IAAI,UAAU,IAAI,UAAU,CAAmC;IAC/D,IAAI,WAAW,IAAI,MAAM,CAAoC;IAG7D,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACtC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IACvB,SAAS,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IACnC,OAAO,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACjD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACzC,aAAa,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAC7D,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAC/C,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAC9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAGxB,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACvC,GAAG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;CAC1C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,aAAa,CAEzD;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { wrapChannel } from './channel.svelte.js';
|
|
2
|
+
/**
|
|
3
|
+
* A reactive wrapper around a RoolSpace. Exposes reactive `channels` and
|
|
4
|
+
* `connectionState`, and provides `openChannel()` that returns a ReactiveChannel.
|
|
5
|
+
*
|
|
6
|
+
* Lifecycle: call `close()` when done. Closes all opened channels and stops the
|
|
7
|
+
* space's SSE subscription.
|
|
8
|
+
*/
|
|
9
|
+
class ReactiveSpaceImpl {
|
|
10
|
+
#space;
|
|
11
|
+
#channels = new Map();
|
|
12
|
+
#unsubscribers = [];
|
|
13
|
+
#closed = false;
|
|
14
|
+
// Reactive state mirroring the underlying space
|
|
15
|
+
#channelList = $state([]);
|
|
16
|
+
connectionState = $state('reconnecting');
|
|
17
|
+
constructor(space) {
|
|
18
|
+
this.#space = space;
|
|
19
|
+
this.#channelList = space.channels;
|
|
20
|
+
const refreshChannels = () => { this.#channelList = space.channels; };
|
|
21
|
+
space.on('channelCreated', refreshChannels);
|
|
22
|
+
space.on('channelUpdated', refreshChannels);
|
|
23
|
+
space.on('channelDeleted', refreshChannels);
|
|
24
|
+
this.#unsubscribers.push(() => space.off('channelCreated', refreshChannels));
|
|
25
|
+
this.#unsubscribers.push(() => space.off('channelUpdated', refreshChannels));
|
|
26
|
+
this.#unsubscribers.push(() => space.off('channelDeleted', refreshChannels));
|
|
27
|
+
const onConnectionStateChanged = (state) => {
|
|
28
|
+
this.connectionState = state;
|
|
29
|
+
};
|
|
30
|
+
space.on('connectionStateChanged', onConnectionStateChanged);
|
|
31
|
+
this.#unsubscribers.push(() => space.off('connectionStateChanged', onConnectionStateChanged));
|
|
32
|
+
}
|
|
33
|
+
get isClosed() { return this.#closed; }
|
|
34
|
+
/**
|
|
35
|
+
* Open a channel on this space. Returns a ReactiveChannel with reactive state.
|
|
36
|
+
* Repeated calls with the same channelId return the same instance (until closed).
|
|
37
|
+
*/
|
|
38
|
+
async openChannel(channelId) {
|
|
39
|
+
if (this.#closed)
|
|
40
|
+
throw new Error('Cannot open channel: space is closed');
|
|
41
|
+
const existing = this.#channels.get(channelId);
|
|
42
|
+
if (existing && !existing.isClosed)
|
|
43
|
+
return existing;
|
|
44
|
+
const raw = await this.#space.openChannel(channelId);
|
|
45
|
+
const reactive = wrapChannel(raw);
|
|
46
|
+
this.#channels.set(channelId, reactive);
|
|
47
|
+
return reactive;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Close this space: closes all open reactive channels and stops the SSE
|
|
51
|
+
* subscription. Idempotent.
|
|
52
|
+
*/
|
|
53
|
+
close() {
|
|
54
|
+
if (this.#closed)
|
|
55
|
+
return;
|
|
56
|
+
this.#closed = true;
|
|
57
|
+
for (const ch of this.#channels.values()) {
|
|
58
|
+
ch.close();
|
|
59
|
+
}
|
|
60
|
+
this.#channels.clear();
|
|
61
|
+
for (const unsub of this.#unsubscribers)
|
|
62
|
+
unsub();
|
|
63
|
+
this.#unsubscribers.length = 0;
|
|
64
|
+
this.#space.close();
|
|
65
|
+
}
|
|
66
|
+
// Reactive getters
|
|
67
|
+
get channels() { return this.#channelList; }
|
|
68
|
+
// Proxy read-only properties
|
|
69
|
+
get id() { return this.#space.id; }
|
|
70
|
+
get name() { return this.#space.name; }
|
|
71
|
+
get role() { return this.#space.role; }
|
|
72
|
+
get linkAccess() { return this.#space.linkAccess; }
|
|
73
|
+
get memberCount() { return this.#space.memberCount; }
|
|
74
|
+
// Proxy admin methods
|
|
75
|
+
rename(newName) { return this.#space.rename(newName); }
|
|
76
|
+
delete() { return this.#space.delete(); }
|
|
77
|
+
listUsers() { return this.#space.listUsers(); }
|
|
78
|
+
addUser(...args) { return this.#space.addUser(...args); }
|
|
79
|
+
removeUser(userId) { return this.#space.removeUser(userId); }
|
|
80
|
+
setLinkAccess(...args) { return this.#space.setLinkAccess(...args); }
|
|
81
|
+
deleteChannel(channelId) { return this.#space.deleteChannel(channelId); }
|
|
82
|
+
exportArchive() { return this.#space.exportArchive(); }
|
|
83
|
+
refresh() { return this.#space.refresh(); }
|
|
84
|
+
// Events on the underlying space (channelCreated/Updated/Deleted, connectionStateChanged)
|
|
85
|
+
on(...args) { return this.#space.on(...args); }
|
|
86
|
+
off(...args) { return this.#space.off(...args); }
|
|
87
|
+
}
|
|
88
|
+
export function wrapSpace(space) {
|
|
89
|
+
return new ReactiveSpaceImpl(space);
|
|
90
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rool-dev/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-dev.541aa22",
|
|
4
4
|
"description": "Svelte 5 runes for Rool Spaces",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
},
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@rool-dev/sdk": "0.
|
|
44
|
+
"@rool-dev/sdk": "0.7.0-dev.541aa22"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"svelte": "^5.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@sveltejs/package": "^2.5.7",
|
|
51
|
-
"svelte": "^5.55.
|
|
51
|
+
"svelte": "^5.55.4",
|
|
52
52
|
"svelte-check": "^4.4.6",
|
|
53
53
|
"typescript": "^5.9.3"
|
|
54
54
|
},
|