@rool-dev/svelte 0.1.12 → 0.1.13-dev.045fad8
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 +27 -0
- package/dist/rool.svelte.d.ts +3 -9
- package/dist/rool.svelte.d.ts.map +1 -1
- package/dist/rool.svelte.js +17 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -49,6 +49,7 @@ The Svelte wrapper adds reactive state on top of the SDK:
|
|
|
49
49
|
| `rool.spacesLoading` | Whether spaces are loading |
|
|
50
50
|
| `rool.spacesError` | Error from loading spaces |
|
|
51
51
|
| `rool.connectionState` | SSE connection state |
|
|
52
|
+
| `rool.userStorage` | User storage (cross-device preferences) |
|
|
52
53
|
| `space.interactions` | Conversation interactions (auto-updates) |
|
|
53
54
|
| `collection.objects` | Objects matching a filter (auto-updates) |
|
|
54
55
|
| `collection.loading` | Whether collection is loading |
|
|
@@ -78,6 +79,7 @@ rool.destroy(); // Clean up all resources
|
|
|
78
79
|
// rool.spacesLoading → boolean
|
|
79
80
|
// rool.spacesError → Error | null
|
|
80
81
|
// rool.connectionState → 'connected' | 'disconnected' | 'reconnecting'
|
|
82
|
+
// rool.userStorage → Record<string, unknown>
|
|
81
83
|
</script>
|
|
82
84
|
|
|
83
85
|
{#if rool.spacesLoading}
|
|
@@ -91,6 +93,31 @@ rool.destroy(); // Clean up all resources
|
|
|
91
93
|
{/if}
|
|
92
94
|
```
|
|
93
95
|
|
|
96
|
+
### User Storage
|
|
97
|
+
|
|
98
|
+
Reactive cross-device storage for user preferences. Synced from server on `init()`, then kept up-to-date via SSE.
|
|
99
|
+
|
|
100
|
+
```svelte
|
|
101
|
+
<script>
|
|
102
|
+
const rool = createRool();
|
|
103
|
+
rool.init();
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<!-- Reactive binding to storage values -->
|
|
107
|
+
{#if rool.userStorage.onboarding_complete}
|
|
108
|
+
<Dashboard />
|
|
109
|
+
{:else}
|
|
110
|
+
<Onboarding onstep={(step) => rool.setUserStorage('onboarding_step', step)} />
|
|
111
|
+
{/if}
|
|
112
|
+
|
|
113
|
+
<!-- Theme toggle -->
|
|
114
|
+
<button onclick={() => rool.setUserStorage('theme',
|
|
115
|
+
rool.userStorage.theme === 'dark' ? 'light' : 'dark'
|
|
116
|
+
)}>
|
|
117
|
+
Toggle theme
|
|
118
|
+
</button>
|
|
119
|
+
```
|
|
120
|
+
|
|
94
121
|
### Opening Spaces
|
|
95
122
|
|
|
96
123
|
```typescript
|
package/dist/rool.svelte.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { type ReactiveSpace } from './space.svelte.js';
|
|
|
6
6
|
* Provides:
|
|
7
7
|
* - Reactive auth state (`authenticated`)
|
|
8
8
|
* - Reactive spaces list (`spaces`)
|
|
9
|
+
* - Reactive user storage (`userStorage`)
|
|
9
10
|
* - Direct access to SDK spaces (no wrapper abstraction)
|
|
10
11
|
*/
|
|
11
12
|
declare class RoolImpl {
|
|
@@ -15,6 +16,7 @@ declare class RoolImpl {
|
|
|
15
16
|
spacesLoading: boolean;
|
|
16
17
|
spacesError: Error | null;
|
|
17
18
|
connectionState: ConnectionState;
|
|
19
|
+
userStorage: Record<string, unknown>;
|
|
18
20
|
constructor(config?: RoolClientConfig);
|
|
19
21
|
/**
|
|
20
22
|
* Initialize the client. Call on app startup.
|
|
@@ -49,19 +51,11 @@ declare class RoolImpl {
|
|
|
49
51
|
* Delete a space.
|
|
50
52
|
*/
|
|
51
53
|
deleteSpace(spaceId: string): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Get a value from user storage (sync read from local cache).
|
|
54
|
-
*/
|
|
55
|
-
getUserStorage<T = unknown>(key: string): T | undefined;
|
|
56
54
|
/**
|
|
57
55
|
* Set a value in user storage.
|
|
58
|
-
* Updates
|
|
56
|
+
* Updates reactive state immediately, then syncs to server.
|
|
59
57
|
*/
|
|
60
58
|
setUserStorage(key: string, value: unknown): void;
|
|
61
|
-
/**
|
|
62
|
-
* Get all user storage data (sync read from local cache).
|
|
63
|
-
*/
|
|
64
|
-
getAllUserStorage(): Record<string, unknown>;
|
|
65
59
|
/**
|
|
66
60
|
* Search for a user by email.
|
|
67
61
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rool.svelte.d.ts","sourceRoot":"","sources":["../src/rool.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC5G,OAAO,EAAa,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElE
|
|
1
|
+
{"version":3,"file":"rool.svelte.d.ts","sourceRoot":"","sources":["../src/rool.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC5G,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;gBAEtC,MAAM,CAAC,EAAE,gBAAgB;IA2DrC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAU9B;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B;;OAEG;IACH,MAAM,IAAI,IAAI;IAQd;;OAEG;IACG,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAO1F;;OAEG;IACG,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAO/F;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C;;;OAGG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAKjD;;OAEG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM;IAIxB;;;OAGG;IACG,aAAa,CACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,IAAI,EACb,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GACpC,OAAO,CAAC,aAAa,CAAC;IAOzB;;OAEG;IACH,IAAI,QAAQ,qCAEX;IAED;;OAEG;IACH,cAAc;IAId;;OAEG;IACH,OAAO,IAAI,IAAI;CAahB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,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
|
@@ -6,6 +6,7 @@ import { wrapSpace } from './space.svelte.js';
|
|
|
6
6
|
* Provides:
|
|
7
7
|
* - Reactive auth state (`authenticated`)
|
|
8
8
|
* - Reactive spaces list (`spaces`)
|
|
9
|
+
* - Reactive user storage (`userStorage`)
|
|
9
10
|
* - Direct access to SDK spaces (no wrapper abstraction)
|
|
10
11
|
*/
|
|
11
12
|
class RoolImpl {
|
|
@@ -18,6 +19,7 @@ class RoolImpl {
|
|
|
18
19
|
spacesLoading = $state(false);
|
|
19
20
|
spacesError = $state(null);
|
|
20
21
|
connectionState = $state('disconnected');
|
|
22
|
+
userStorage = $state({});
|
|
21
23
|
constructor(config) {
|
|
22
24
|
this.#client = new RoolClient(config);
|
|
23
25
|
this.#setupEventListeners();
|
|
@@ -48,6 +50,17 @@ class RoolImpl {
|
|
|
48
50
|
const onSpaceRenamed = () => this.#refreshSpaces();
|
|
49
51
|
this.#client.on('spaceRenamed', onSpaceRenamed);
|
|
50
52
|
this.#unsubscribers.push(() => this.#client.off('spaceRenamed', onSpaceRenamed));
|
|
53
|
+
const onUserStorageChanged = ({ key, value }) => {
|
|
54
|
+
if (value === null || value === undefined) {
|
|
55
|
+
const { [key]: _, ...rest } = this.userStorage;
|
|
56
|
+
this.userStorage = rest;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.userStorage = { ...this.userStorage, [key]: value };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
this.#client.on('userStorageChanged', onUserStorageChanged);
|
|
63
|
+
this.#unsubscribers.push(() => this.#client.off('userStorageChanged', onUserStorageChanged));
|
|
51
64
|
}
|
|
52
65
|
async #refreshSpaces() {
|
|
53
66
|
this.spacesLoading = true;
|
|
@@ -69,6 +82,8 @@ class RoolImpl {
|
|
|
69
82
|
async init() {
|
|
70
83
|
this.authenticated = await this.#client.initialize();
|
|
71
84
|
if (this.authenticated) {
|
|
85
|
+
// Populate reactive storage from SDK cache (now fresh from server)
|
|
86
|
+
this.userStorage = this.#client.getAllUserStorage();
|
|
72
87
|
await this.#refreshSpaces();
|
|
73
88
|
}
|
|
74
89
|
return this.authenticated;
|
|
@@ -119,24 +134,13 @@ class RoolImpl {
|
|
|
119
134
|
deleteSpace(spaceId) {
|
|
120
135
|
return this.#client.deleteSpace(spaceId);
|
|
121
136
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Get a value from user storage (sync read from local cache).
|
|
124
|
-
*/
|
|
125
|
-
getUserStorage(key) {
|
|
126
|
-
return this.#client.getUserStorage(key);
|
|
127
|
-
}
|
|
128
137
|
/**
|
|
129
138
|
* Set a value in user storage.
|
|
130
|
-
* Updates
|
|
139
|
+
* Updates reactive state immediately, then syncs to server.
|
|
131
140
|
*/
|
|
132
141
|
setUserStorage(key, value) {
|
|
133
142
|
this.#client.setUserStorage(key, value);
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Get all user storage data (sync read from local cache).
|
|
137
|
-
*/
|
|
138
|
-
getAllUserStorage() {
|
|
139
|
-
return this.#client.getAllUserStorage();
|
|
143
|
+
// Reactive state updated via userStorageChanged event
|
|
140
144
|
}
|
|
141
145
|
/**
|
|
142
146
|
* Search for a user by email.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rool-dev/svelte",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13-dev.045fad8",
|
|
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.1.
|
|
44
|
+
"@rool-dev/sdk": "0.1.19"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"svelte": "^5.0.0"
|