@rool-dev/svelte 0.1.13 → 0.1.14-dev.90957df
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/space.svelte.d.ts +32 -2
- package/dist/space.svelte.d.ts.map +1 -1
- package/dist/space.svelte.js +99 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createRool, generateId } from './rool.svelte.js';
|
|
2
2
|
export { wrapSpace } from './space.svelte.js';
|
|
3
3
|
export type { Rool } from './rool.svelte.js';
|
|
4
|
-
export type { ReactiveSpace, ReactiveCollection, CollectionOptions } from './space.svelte.js';
|
|
4
|
+
export type { ReactiveSpace, ReactiveObject, ReactiveCollection, CollectionOptions } from './space.svelte.js';
|
|
5
5
|
export type { RoolClientConfig, RoolSpace, RoolSpaceInfo, RoolObject, RoolUserRole, ConnectionState, ConversationInfo, CurrentUser, Interaction, FindObjectsOptions, PromptOptions, CreateObjectOptions, UpdateObjectOptions, } from '@rool-dev/sdk';
|
|
6
6
|
//# 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,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,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,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG9G,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,UAAU,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,eAAe,CAAC"}
|
package/dist/space.svelte.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RoolSpace, Interaction, RoolObject } from '@rool-dev/sdk';
|
|
1
|
+
import type { RoolSpace, Interaction, RoolObject, ConversationInfo } from '@rool-dev/sdk';
|
|
2
2
|
/**
|
|
3
3
|
* Options for creating a reactive collection.
|
|
4
4
|
* Same as FindObjectsOptions but without `prompt` (AI queries are too slow for reactive updates).
|
|
@@ -29,6 +29,24 @@ declare class ReactiveCollectionImpl {
|
|
|
29
29
|
close(): void;
|
|
30
30
|
}
|
|
31
31
|
export type ReactiveCollection = ReactiveCollectionImpl;
|
|
32
|
+
/**
|
|
33
|
+
* A reactive single object that auto-updates when the object changes.
|
|
34
|
+
*/
|
|
35
|
+
declare class ReactiveObjectImpl {
|
|
36
|
+
#private;
|
|
37
|
+
data: RoolObject | undefined;
|
|
38
|
+
loading: boolean;
|
|
39
|
+
constructor(space: RoolSpace, objectId: string);
|
|
40
|
+
/**
|
|
41
|
+
* Re-fetch the object from the space.
|
|
42
|
+
*/
|
|
43
|
+
refresh(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Stop listening for updates and clean up.
|
|
46
|
+
*/
|
|
47
|
+
close(): void;
|
|
48
|
+
}
|
|
49
|
+
export type ReactiveObject = ReactiveObjectImpl;
|
|
32
50
|
/**
|
|
33
51
|
* Minimal wrapper that adds reactive `interactions` to RoolSpace.
|
|
34
52
|
* All other properties and methods are proxied to the underlying space.
|
|
@@ -36,6 +54,7 @@ export type ReactiveCollection = ReactiveCollectionImpl;
|
|
|
36
54
|
declare class ReactiveSpaceImpl {
|
|
37
55
|
#private;
|
|
38
56
|
interactions: Interaction[];
|
|
57
|
+
conversations: ConversationInfo[];
|
|
39
58
|
constructor(space: RoolSpace);
|
|
40
59
|
get id(): string;
|
|
41
60
|
get name(): string;
|
|
@@ -82,7 +101,7 @@ declare class ReactiveSpaceImpl {
|
|
|
82
101
|
getConversationIds(): string[];
|
|
83
102
|
deleteConversation(...args: Parameters<RoolSpace['deleteConversation']>): Promise<void>;
|
|
84
103
|
renameConversation(...args: Parameters<RoolSpace['renameConversation']>): Promise<void>;
|
|
85
|
-
listConversations(): Promise<
|
|
104
|
+
listConversations(): Promise<ConversationInfo[]>;
|
|
86
105
|
getSystemInstruction(): string | undefined;
|
|
87
106
|
setSystemInstruction(...args: Parameters<RoolSpace['setSystemInstruction']>): Promise<void>;
|
|
88
107
|
uploadMedia(...args: Parameters<RoolSpace['uploadMedia']>): Promise<string>;
|
|
@@ -92,6 +111,17 @@ declare class ReactiveSpaceImpl {
|
|
|
92
111
|
exportArchive(): Promise<Blob>;
|
|
93
112
|
on(...args: Parameters<RoolSpace['on']>): () => void;
|
|
94
113
|
off(...args: Parameters<RoolSpace['off']>): void;
|
|
114
|
+
/**
|
|
115
|
+
* Create a reactive object that auto-updates when the object changes.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* const article = space.object('article-123');
|
|
119
|
+
* // article.data is reactive (RoolObject | undefined)
|
|
120
|
+
* // article.loading indicates fetch status
|
|
121
|
+
* // article.refresh() to manually re-fetch
|
|
122
|
+
* // article.close() to stop listening
|
|
123
|
+
*/
|
|
124
|
+
object(objectId: string): ReactiveObject;
|
|
95
125
|
/**
|
|
96
126
|
* Create a reactive collection that auto-updates when matching objects change.
|
|
97
127
|
*
|
|
@@ -1 +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,UAAU,EAAsB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"space.svelte.d.ts","sourceRoot":"","sources":["../src/space.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAsB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE9G;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,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;AAED;;GAEG;AACH,cAAM,sBAAsB;;IAO1B,OAAO,eAA4B;IACnC,OAAO,UAAgB;gBAEX,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB;IAuDxD;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB9B;;OAEG;IACH,KAAK,IAAI,IAAI;CAId;AAED,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAExD;;GAEG;AACH,cAAM,kBAAkB;;IAMtB,IAAI,yBAA6C;IACjD,OAAO,UAAgB;gBAEX,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM;IA2C9C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B;;OAEG;IACH,KAAK,IAAI,IAAI;CAId;AAED,MAAM,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAEhD;;;GAGG;AACH,cAAM,iBAAiB;;IAKrB,YAAY,gBAA6B;IACzC,aAAa,qBAAkC;gBAG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AG,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC/C,OAAO;IACP,IAAI,UAAU,YAAqC;IACnD,OAAO,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACjD,UAAU,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACvD,SAAS;IACT,aAAa,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IAC7D,IAAI,UAAU,uCAAqC;CACpD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,aAAa,CAEzD;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC"}
|
package/dist/space.svelte.js
CHANGED
|
@@ -87,6 +87,74 @@ class ReactiveCollectionImpl {
|
|
|
87
87
|
this.#unsubscribers.length = 0;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* A reactive single object that auto-updates when the object changes.
|
|
92
|
+
*/
|
|
93
|
+
class ReactiveObjectImpl {
|
|
94
|
+
#space;
|
|
95
|
+
#objectId;
|
|
96
|
+
#unsubscribers = [];
|
|
97
|
+
// Reactive state
|
|
98
|
+
data = $state(undefined);
|
|
99
|
+
loading = $state(true);
|
|
100
|
+
constructor(space, objectId) {
|
|
101
|
+
this.#space = space;
|
|
102
|
+
this.#objectId = objectId;
|
|
103
|
+
this.#setup();
|
|
104
|
+
}
|
|
105
|
+
#setup() {
|
|
106
|
+
// Initial fetch
|
|
107
|
+
this.refresh();
|
|
108
|
+
// Listen for updates to this specific object
|
|
109
|
+
const onObjectUpdated = ({ objectId, object }) => {
|
|
110
|
+
if (objectId === this.#objectId) {
|
|
111
|
+
this.data = object;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
this.#space.on('objectUpdated', onObjectUpdated);
|
|
115
|
+
this.#unsubscribers.push(() => this.#space.off('objectUpdated', onObjectUpdated));
|
|
116
|
+
// Listen for creation (in case object didn't exist initially)
|
|
117
|
+
const onObjectCreated = ({ object }) => {
|
|
118
|
+
if (object.id === this.#objectId) {
|
|
119
|
+
this.data = object;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
this.#space.on('objectCreated', onObjectCreated);
|
|
123
|
+
this.#unsubscribers.push(() => this.#space.off('objectCreated', onObjectCreated));
|
|
124
|
+
// Listen for deletion
|
|
125
|
+
const onObjectDeleted = ({ objectId }) => {
|
|
126
|
+
if (objectId === this.#objectId) {
|
|
127
|
+
this.data = undefined;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
this.#space.on('objectDeleted', onObjectDeleted);
|
|
131
|
+
this.#unsubscribers.push(() => this.#space.off('objectDeleted', onObjectDeleted));
|
|
132
|
+
// Handle full resets
|
|
133
|
+
const onReset = () => this.refresh();
|
|
134
|
+
this.#space.on('reset', onReset);
|
|
135
|
+
this.#unsubscribers.push(() => this.#space.off('reset', onReset));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Re-fetch the object from the space.
|
|
139
|
+
*/
|
|
140
|
+
async refresh() {
|
|
141
|
+
this.loading = true;
|
|
142
|
+
try {
|
|
143
|
+
this.data = await this.#space.getObject(this.#objectId);
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
this.loading = false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Stop listening for updates and clean up.
|
|
151
|
+
*/
|
|
152
|
+
close() {
|
|
153
|
+
for (const unsub of this.#unsubscribers)
|
|
154
|
+
unsub();
|
|
155
|
+
this.#unsubscribers.length = 0;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
90
158
|
/**
|
|
91
159
|
* Minimal wrapper that adds reactive `interactions` to RoolSpace.
|
|
92
160
|
* All other properties and methods are proxied to the underlying space.
|
|
@@ -96,9 +164,14 @@ class ReactiveSpaceImpl {
|
|
|
96
164
|
#unsubscribers = [];
|
|
97
165
|
// Reactive state
|
|
98
166
|
interactions = $state([]);
|
|
167
|
+
conversations = $state([]);
|
|
168
|
+
#conversationId = $state('');
|
|
99
169
|
constructor(space) {
|
|
100
170
|
this.#space = space;
|
|
101
171
|
this.interactions = space.getInteractions();
|
|
172
|
+
this.#conversationId = space.conversationId;
|
|
173
|
+
// Initial fetch of conversations (async)
|
|
174
|
+
this.#refreshConversations();
|
|
102
175
|
// Subscribe to conversation updates
|
|
103
176
|
const onConversationUpdated = () => {
|
|
104
177
|
this.interactions = space.getInteractions();
|
|
@@ -110,19 +183,29 @@ class ReactiveSpaceImpl {
|
|
|
110
183
|
};
|
|
111
184
|
space.on('reset', onReset);
|
|
112
185
|
this.#unsubscribers.push(() => space.off('reset', onReset));
|
|
113
|
-
// Update interactions when switching conversations
|
|
186
|
+
// Update interactions and conversationId when switching conversations
|
|
114
187
|
const onConversationIdChanged = () => {
|
|
188
|
+
this.#conversationId = space.conversationId;
|
|
115
189
|
this.interactions = space.getInteractions();
|
|
116
190
|
};
|
|
117
191
|
space.on('conversationIdChanged', onConversationIdChanged);
|
|
118
192
|
this.#unsubscribers.push(() => space.off('conversationIdChanged', onConversationIdChanged));
|
|
193
|
+
// Update conversations list when conversations change
|
|
194
|
+
const onConversationsChanged = () => {
|
|
195
|
+
this.#refreshConversations();
|
|
196
|
+
};
|
|
197
|
+
space.on('conversationsChanged', onConversationsChanged);
|
|
198
|
+
this.#unsubscribers.push(() => space.off('conversationsChanged', onConversationsChanged));
|
|
199
|
+
}
|
|
200
|
+
async #refreshConversations() {
|
|
201
|
+
this.conversations = await this.#space.listConversations();
|
|
119
202
|
}
|
|
120
203
|
// Proxy read-only properties
|
|
121
204
|
get id() { return this.#space.id; }
|
|
122
205
|
get name() { return this.#space.name; }
|
|
123
206
|
get role() { return this.#space.role; }
|
|
124
207
|
get userId() { return this.#space.userId; }
|
|
125
|
-
get conversationId() { return this.#
|
|
208
|
+
get conversationId() { return this.#conversationId; }
|
|
126
209
|
set conversationId(id) { this.#space.conversationId = id; }
|
|
127
210
|
// Proxy all methods
|
|
128
211
|
close() {
|
|
@@ -176,7 +259,20 @@ class ReactiveSpaceImpl {
|
|
|
176
259
|
// Events
|
|
177
260
|
on(...args) { return this.#space.on(...args); }
|
|
178
261
|
off(...args) { return this.#space.off(...args); }
|
|
179
|
-
// Reactive
|
|
262
|
+
// Reactive primitives
|
|
263
|
+
/**
|
|
264
|
+
* Create a reactive object that auto-updates when the object changes.
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* const article = space.object('article-123');
|
|
268
|
+
* // article.data is reactive (RoolObject | undefined)
|
|
269
|
+
* // article.loading indicates fetch status
|
|
270
|
+
* // article.refresh() to manually re-fetch
|
|
271
|
+
* // article.close() to stop listening
|
|
272
|
+
*/
|
|
273
|
+
object(objectId) {
|
|
274
|
+
return new ReactiveObjectImpl(this.#space, objectId);
|
|
275
|
+
}
|
|
180
276
|
/**
|
|
181
277
|
* Create a reactive collection that auto-updates when matching objects change.
|
|
182
278
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rool-dev/svelte",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14-dev.90957df",
|
|
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.21"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"svelte": "^5.0.0"
|