@rool-dev/svelte 0.11.3-dev.a6a4bb1 → 0.11.4-dev.10ce346

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.
@@ -0,0 +1,82 @@
1
+ import type { RoolSpace, Interaction, RoolObject, ConversationHandle } from '@rool-dev/sdk';
2
+ import { ReactiveFileTree } from './file-tree.svelte.js';
3
+ /**
4
+ * Options for creating a reactive watch.
5
+ * Structured object filter for reactive updates.
6
+ */
7
+ export interface WatchOptions {
8
+ /** Field requirements for exact matching */
9
+ where?: Record<string, unknown>;
10
+ /** Filter by collection name. */
11
+ collection?: string;
12
+ /** Maximum number of objects */
13
+ limit?: number;
14
+ /** Sort order by modifiedAt: 'asc' or 'desc' (default: 'desc') */
15
+ order?: 'asc' | 'desc';
16
+ }
17
+ /**
18
+ * A reactive watch of objects that auto-updates when matching object files change.
19
+ */
20
+ export declare class ReactiveWatchImpl {
21
+ #private;
22
+ objects: RoolObject[];
23
+ loading: boolean;
24
+ constructor(space: RoolSpace, fileTree: ReactiveFileTree, options: WatchOptions);
25
+ /** Re-fetch matching objects using the canonical file tree for paths. */
26
+ refresh(): Promise<void>;
27
+ close(): void;
28
+ }
29
+ export type ReactiveWatch = ReactiveWatchImpl;
30
+ /**
31
+ * A reactive single object that auto-updates when the object changes.
32
+ */
33
+ export declare class ReactiveObjectImpl {
34
+ #private;
35
+ data: RoolObject | undefined;
36
+ loading: boolean;
37
+ constructor(space: RoolSpace, fileTree: ReactiveFileTree, path: string);
38
+ refresh(): Promise<void>;
39
+ close(): void;
40
+ }
41
+ export type ReactiveObject = ReactiveObjectImpl;
42
+ export declare class ReactiveConversationHandleImpl {
43
+ #private;
44
+ interactions: Interaction[];
45
+ constructor(space: RoolSpace, conversationId: string);
46
+ get conversationId(): string;
47
+ getInteractions(): Interaction[];
48
+ getTree(): Record<string, Interaction>;
49
+ get activeLeafId(): string | undefined;
50
+ setActiveLeaf(interactionId: string): void;
51
+ getSystemInstruction(): string | undefined;
52
+ setSystemInstruction(...args: Parameters<ConversationHandle['setSystemInstruction']>): Promise<void>;
53
+ rename(...args: Parameters<ConversationHandle['rename']>): Promise<void>;
54
+ delete(): Promise<void>;
55
+ putObject(...args: Parameters<ConversationHandle['putObject']>): Promise<{
56
+ object: RoolObject;
57
+ message: string;
58
+ }>;
59
+ patchObject(...args: Parameters<ConversationHandle['patchObject']>): Promise<{
60
+ object: RoolObject;
61
+ message: string;
62
+ }>;
63
+ moveObject(...args: Parameters<ConversationHandle['moveObject']>): Promise<{
64
+ object: RoolObject;
65
+ message: string;
66
+ }>;
67
+ deleteObjects(...args: Parameters<ConversationHandle['deleteObjects']>): Promise<void>;
68
+ /** @deprecated Use deleteObjects instead. */
69
+ deletePaths(...args: Parameters<ConversationHandle['deletePaths']>): Promise<void>;
70
+ prompt(...args: Parameters<ConversationHandle['prompt']>): Promise<{
71
+ message: string;
72
+ objects: RoolObject[];
73
+ }>;
74
+ stop(): Promise<boolean>;
75
+ createCollection(...args: Parameters<ConversationHandle['createCollection']>): Promise<import("@rool-dev/sdk").CollectionDef>;
76
+ alterCollection(...args: Parameters<ConversationHandle['alterCollection']>): Promise<import("@rool-dev/sdk").CollectionDef>;
77
+ dropCollection(...args: Parameters<ConversationHandle['dropCollection']>): Promise<void>;
78
+ setMetadata(...args: Parameters<ConversationHandle['setMetadata']>): void;
79
+ close(): void;
80
+ }
81
+ export type ReactiveConversationHandle = ReactiveConversationHandleImpl;
82
+ //# sourceMappingURL=space-session.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-session.svelte.d.ts","sourceRoot":"","sources":["../src/space-session.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,kBAAkB,EAEnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAqD,MAAM,uBAAuB,CAAC;AAE5G;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,4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,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;;;;IAC9D,WAAW,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;;;;IAClE,UAAU,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;;;;IAChE,aAAa,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACtE,6CAA6C;IAC7C,WAAW,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAGlE,MAAM,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;;;;IACxD,IAAI;IAGJ,gBAAgB,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IAC5E,eAAe,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;IAC1E,cAAc,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IAGxE,WAAW,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAElE,KAAK,IAAI,IAAI;CAId;AAED,MAAM,MAAM,0BAA0B,GAAG,8BAA8B,CAAC"}
@@ -0,0 +1,191 @@
1
+ import { isObjectPath, machinePath } from '@rool-dev/sdk';
2
+ function objectCollection(path) {
3
+ if (!isObjectPath(path))
4
+ return undefined;
5
+ return path.split('/')[2];
6
+ }
7
+ function eventTouchesObject(event, objectPath, collection) {
8
+ if (event.reset)
9
+ return true;
10
+ for (const path of [...event.changedPaths, ...event.deletedPaths]) {
11
+ if (objectPath && path === objectPath)
12
+ return true;
13
+ if (!objectPath && isObjectPath(path)) {
14
+ if (!collection || objectCollection(path) === collection)
15
+ return true;
16
+ }
17
+ }
18
+ return false;
19
+ }
20
+ function sameJsonValue(a, b) {
21
+ return JSON.stringify(a) === JSON.stringify(b);
22
+ }
23
+ async function watchObjectsFromTree(space, fileTree, options) {
24
+ if (fileTree.loading)
25
+ await fileTree.ready();
26
+ const paths = fileTree.objectPaths({ collection: options.collection, order: options.order });
27
+ const objects = [];
28
+ for (const path of paths) {
29
+ const object = await space.getObject(path);
30
+ if (!object)
31
+ continue;
32
+ if (options.where) {
33
+ let matches = true;
34
+ for (const [key, value] of Object.entries(options.where)) {
35
+ if (!sameJsonValue(object.body[key], value)) {
36
+ matches = false;
37
+ break;
38
+ }
39
+ }
40
+ if (!matches)
41
+ continue;
42
+ }
43
+ objects.push(object);
44
+ if (options.limit !== undefined && objects.length >= options.limit)
45
+ break;
46
+ }
47
+ return objects;
48
+ }
49
+ /**
50
+ * A reactive watch of objects that auto-updates when matching object files change.
51
+ */
52
+ export class ReactiveWatchImpl {
53
+ #space;
54
+ #fileTree;
55
+ #options;
56
+ #unsubscribers = [];
57
+ // Reactive state
58
+ objects = $state([]);
59
+ loading = $state(true);
60
+ constructor(space, fileTree, options) {
61
+ this.#space = space;
62
+ this.#fileTree = fileTree;
63
+ this.#options = options;
64
+ this.#setup();
65
+ }
66
+ #setup() {
67
+ this.refresh();
68
+ const unsubscribe = this.#fileTree.subscribe((event) => {
69
+ if (eventTouchesObject(event, undefined, this.#options.collection))
70
+ void this.refresh();
71
+ });
72
+ this.#unsubscribers.push(unsubscribe);
73
+ }
74
+ /** Re-fetch matching objects using the canonical file tree for paths. */
75
+ async refresh() {
76
+ this.loading = true;
77
+ try {
78
+ this.objects = await watchObjectsFromTree(this.#space, this.#fileTree, this.#options);
79
+ }
80
+ finally {
81
+ this.loading = false;
82
+ }
83
+ }
84
+ close() {
85
+ for (const unsub of this.#unsubscribers)
86
+ unsub();
87
+ this.#unsubscribers.length = 0;
88
+ }
89
+ }
90
+ /**
91
+ * A reactive single object that auto-updates when the object changes.
92
+ */
93
+ export class ReactiveObjectImpl {
94
+ #space;
95
+ #fileTree;
96
+ #path;
97
+ #unsubscribers = [];
98
+ // Reactive state
99
+ data = $state(undefined);
100
+ loading = $state(true);
101
+ constructor(space, fileTree, path) {
102
+ this.#space = space;
103
+ this.#fileTree = fileTree;
104
+ this.#path = machinePath(path);
105
+ this.#setup();
106
+ }
107
+ #setup() {
108
+ this.refresh();
109
+ const unsubscribe = this.#fileTree.subscribe((event) => {
110
+ if (event.deletedPaths.has(this.#path)) {
111
+ this.data = undefined;
112
+ return;
113
+ }
114
+ if (eventTouchesObject(event, this.#path))
115
+ void this.refresh();
116
+ });
117
+ this.#unsubscribers.push(unsubscribe);
118
+ }
119
+ async refresh() {
120
+ this.loading = true;
121
+ try {
122
+ this.data = await this.#space.getObject(this.#path);
123
+ }
124
+ finally {
125
+ this.loading = false;
126
+ }
127
+ }
128
+ close() {
129
+ for (const unsub of this.#unsubscribers)
130
+ unsub();
131
+ this.#unsubscribers.length = 0;
132
+ }
133
+ }
134
+ // ---------------------------------------------------------------------------
135
+ // ReactiveConversationHandle
136
+ // ---------------------------------------------------------------------------
137
+ export class ReactiveConversationHandleImpl {
138
+ #handle;
139
+ #conversationId;
140
+ #unsubscribers = [];
141
+ // Reactive state
142
+ interactions = $state([]);
143
+ constructor(space, conversationId) {
144
+ this.#conversationId = conversationId;
145
+ this.#handle = space.conversation(conversationId);
146
+ this.interactions = this.#handle.getInteractions();
147
+ const onConversationUpdated = (event) => {
148
+ if (event.conversationId === this.#conversationId) {
149
+ this.interactions = this.#handle.getInteractions();
150
+ }
151
+ };
152
+ space.on('conversationUpdated', onConversationUpdated);
153
+ this.#unsubscribers.push(() => space.off('conversationUpdated', onConversationUpdated));
154
+ const onReset = () => {
155
+ this.interactions = this.#handle.getInteractions();
156
+ };
157
+ space.on('reset', onReset);
158
+ this.#unsubscribers.push(() => space.off('reset', onReset));
159
+ }
160
+ get conversationId() { return this.#conversationId; }
161
+ // Conversation history
162
+ getInteractions() { return this.#handle.getInteractions(); }
163
+ getTree() { return this.#handle.getTree(); }
164
+ get activeLeafId() { return this.#handle.activeLeafId; }
165
+ setActiveLeaf(interactionId) { this.#handle.setActiveLeaf(interactionId); }
166
+ getSystemInstruction() { return this.#handle.getSystemInstruction(); }
167
+ setSystemInstruction(...args) { return this.#handle.setSystemInstruction(...args); }
168
+ rename(...args) { return this.#handle.rename(...args); }
169
+ delete() { return this.#handle.delete(); }
170
+ // Object operations
171
+ putObject(...args) { return this.#handle.putObject(...args); }
172
+ patchObject(...args) { return this.#handle.patchObject(...args); }
173
+ moveObject(...args) { return this.#handle.moveObject(...args); }
174
+ deleteObjects(...args) { return this.#handle.deleteObjects(...args); }
175
+ /** @deprecated Use deleteObjects instead. */
176
+ deletePaths(...args) { return this.#handle.deletePaths(...args); }
177
+ // AI
178
+ prompt(...args) { return this.#handle.prompt(...args); }
179
+ stop() { return this.#handle.stop(); }
180
+ // Schema
181
+ createCollection(...args) { return this.#handle.createCollection(...args); }
182
+ alterCollection(...args) { return this.#handle.alterCollection(...args); }
183
+ dropCollection(...args) { return this.#handle.dropCollection(...args); }
184
+ // Metadata
185
+ setMetadata(...args) { return this.#handle.setMetadata(...args); }
186
+ close() {
187
+ for (const unsub of this.#unsubscribers)
188
+ unsub();
189
+ this.#unsubscribers.length = 0;
190
+ }
191
+ }
@@ -1,35 +1,48 @@
1
- import type { RoolSpace, ChannelInfo, ConnectionState, RoolUserRole, SpaceMember } from '@rool-dev/sdk';
2
- import { type ReactiveChannel } from './channel.svelte.js';
1
+ import type { RoolSpace, ConversationInfo, ConnectionState, RoolUserRole, SpaceMember } from '@rool-dev/sdk';
2
+ import { ReactiveConversationHandleImpl, ReactiveObjectImpl, ReactiveWatchImpl, type WatchOptions } from './space-session.svelte.js';
3
3
  import { ReactiveFileTree } from './file-tree.svelte.js';
4
4
  /**
5
- * A reactive wrapper around a RoolSpace. Exposes reactive `channels` and
6
- * `connectionState`, and provides `openChannel()` that returns a ReactiveChannel.
5
+ * A reactive wrapper around a RoolSpace. Exposes reactive `conversations` and
6
+ * `connectionState`, plus space-level object/conversation/AI methods.
7
7
  *
8
- * Lifecycle: call `close()` when done. Closes all opened channels and stops the
9
- * space's SSE subscription.
8
+ * Lifecycle: call `close()` when done to stop the space's SSE subscription.
10
9
  */
11
10
  declare class ReactiveSpaceImpl {
12
11
  #private;
13
12
  connectionState: ConnectionState;
14
13
  constructor(space: RoolSpace);
15
14
  get isClosed(): boolean;
15
+ /** Get a reactive handle for a conversation in this space. */
16
+ conversation(conversationId: string): ReactiveConversationHandleImpl;
16
17
  /**
17
- * Open a channel on this space. Returns a ReactiveChannel with reactive state.
18
- * Repeated calls with the same channelId return the same instance (until closed).
19
- */
20
- openChannel(channelId: string): Promise<ReactiveChannel>;
21
- /**
22
- * Close this space: closes all open reactive channels and stops the SSE
23
- * subscription. Idempotent.
18
+ * Close this space and stop the SSE subscription. Idempotent.
24
19
  */
25
20
  close(): void;
26
- get channels(): ChannelInfo[];
21
+ get conversations(): ConversationInfo[];
27
22
  get id(): string;
28
23
  get name(): string;
29
24
  get role(): RoolUserRole;
30
25
  get memberCount(): number;
31
26
  get webdav(): import("@rool-dev/sdk").RoolWebDAV;
32
27
  get fileTree(): ReactiveFileTree;
28
+ getObject(...args: Parameters<RoolSpace['getObject']>): Promise<import("@rool-dev/sdk").RoolObject | undefined>;
29
+ getObjects(...args: Parameters<RoolSpace['getObjects']>): Promise<import("@rool-dev/sdk").GetObjectsResult>;
30
+ object(path: string): ReactiveObjectImpl;
31
+ watch(options: WatchOptions): ReactiveWatchImpl;
32
+ stat(...args: Parameters<RoolSpace['stat']>): import("@rool-dev/sdk").RoolObjectStat | undefined;
33
+ stopInteraction(...args: Parameters<RoolSpace['stopInteraction']>): Promise<boolean>;
34
+ checkpoint(...args: Parameters<RoolSpace['checkpoint']>): Promise<string>;
35
+ canUndo(...args: Parameters<RoolSpace['canUndo']>): Promise<boolean>;
36
+ canRedo(...args: Parameters<RoolSpace['canRedo']>): Promise<boolean>;
37
+ undo(...args: Parameters<RoolSpace['undo']>): Promise<boolean>;
38
+ redo(...args: Parameters<RoolSpace['redo']>): Promise<boolean>;
39
+ clearHistory(...args: Parameters<RoolSpace['clearHistory']>): Promise<void>;
40
+ getMetadata(...args: Parameters<RoolSpace['getMetadata']>): unknown;
41
+ getAllMetadata(...args: Parameters<RoolSpace['getAllMetadata']>): Record<string, unknown>;
42
+ getConversations(...args: Parameters<RoolSpace['getConversations']>): ConversationInfo[];
43
+ deleteConversation(...args: Parameters<RoolSpace['deleteConversation']>): Promise<void>;
44
+ getSchema(...args: Parameters<RoolSpace['getSchema']>): import("@rool-dev/sdk").SpaceSchema;
45
+ fetch(...args: Parameters<RoolSpace['fetch']>): Promise<Response>;
33
46
  getStorageUsage(...args: Parameters<RoolSpace['getStorageUsage']>): Promise<import("@rool-dev/sdk").SpaceFileStorageUsage>;
34
47
  fetchPath(...args: Parameters<RoolSpace['fetchPath']>): Promise<Response>;
35
48
  rename(newName: string): Promise<void>;
@@ -40,8 +53,6 @@ declare class ReactiveSpaceImpl {
40
53
  createInvite(...args: Parameters<RoolSpace['createInvite']>): Promise<import("@rool-dev/sdk").SpaceInviteCreated>;
41
54
  listInvites(...args: Parameters<RoolSpace['listInvites']>): Promise<import("@rool-dev/sdk").SpaceInvite[]>;
42
55
  revokeInvite(...args: Parameters<RoolSpace['revokeInvite']>): Promise<boolean>;
43
- renameChannel(channelId: string, name: string): Promise<void>;
44
- deleteChannel(channelId: string): Promise<void>;
45
56
  exportArchive(): Promise<Blob>;
46
57
  refresh(): Promise<void>;
47
58
  on(...args: Parameters<RoolSpace['on']>): () => void;
@@ -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,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxG,OAAO,EAAe,KA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S,CAAC,KAAK,EAAE,SAAS,GAAG,aAAa,CAEzD;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,CAAC"}
@@ -1,32 +1,28 @@
1
- import { wrapChannel } from './channel.svelte.js';
1
+ import { ReactiveConversationHandleImpl, ReactiveObjectImpl, ReactiveWatchImpl } from './space-session.svelte.js';
2
2
  import { ReactiveFileTree } from './file-tree.svelte.js';
3
3
  /**
4
- * A reactive wrapper around a RoolSpace. Exposes reactive `channels` and
5
- * `connectionState`, and provides `openChannel()` that returns a ReactiveChannel.
4
+ * A reactive wrapper around a RoolSpace. Exposes reactive `conversations` and
5
+ * `connectionState`, plus space-level object/conversation/AI methods.
6
6
  *
7
- * Lifecycle: call `close()` when done. Closes all opened channels and stops the
8
- * space's SSE subscription.
7
+ * Lifecycle: call `close()` when done to stop the space's SSE subscription.
9
8
  */
10
9
  class ReactiveSpaceImpl {
11
10
  #space;
12
- #channels = new Map();
13
11
  #unsubscribers = [];
14
12
  #fileTree;
15
13
  #closed = false;
16
14
  // Reactive state mirroring the underlying space
17
- #channelList = $state([]);
15
+ #conversationList = $state([]);
18
16
  connectionState = $state('reconnecting');
19
17
  constructor(space) {
20
18
  this.#space = space;
21
19
  this.#fileTree = new ReactiveFileTree(space);
22
- this.#channelList = space.channels;
23
- const refreshChannels = () => { this.#channelList = space.channels; };
24
- space.on('channelCreated', refreshChannels);
25
- space.on('channelUpdated', refreshChannels);
26
- space.on('channelDeleted', refreshChannels);
27
- this.#unsubscribers.push(() => space.off('channelCreated', refreshChannels));
28
- this.#unsubscribers.push(() => space.off('channelUpdated', refreshChannels));
29
- this.#unsubscribers.push(() => space.off('channelDeleted', refreshChannels));
20
+ this.#conversationList = [...space.conversations];
21
+ const refreshConversations = () => { this.#conversationList = [...space.conversations]; };
22
+ space.on('conversationUpdated', refreshConversations);
23
+ this.#unsubscribers.push(() => space.off('conversationUpdated', refreshConversations));
24
+ space.on('reset', refreshConversations);
25
+ this.#unsubscribers.push(() => space.off('reset', refreshConversations));
30
26
  const onConnectionStateChanged = (state) => {
31
27
  this.connectionState = state;
32
28
  };
@@ -34,33 +30,17 @@ class ReactiveSpaceImpl {
34
30
  this.#unsubscribers.push(() => space.off('connectionStateChanged', onConnectionStateChanged));
35
31
  }
36
32
  get isClosed() { return this.#closed; }
37
- /**
38
- * Open a channel on this space. Returns a ReactiveChannel with reactive state.
39
- * Repeated calls with the same channelId return the same instance (until closed).
40
- */
41
- async openChannel(channelId) {
42
- if (this.#closed)
43
- throw new Error('Cannot open channel: space is closed');
44
- const existing = this.#channels.get(channelId);
45
- if (existing && !existing.isClosed)
46
- return existing;
47
- const raw = await this.#space.openChannel(channelId);
48
- const reactive = wrapChannel(raw, this.#fileTree);
49
- this.#channels.set(channelId, reactive);
50
- return reactive;
33
+ /** Get a reactive handle for a conversation in this space. */
34
+ conversation(conversationId) {
35
+ return new ReactiveConversationHandleImpl(this.#space, conversationId);
51
36
  }
52
37
  /**
53
- * Close this space: closes all open reactive channels and stops the SSE
54
- * subscription. Idempotent.
38
+ * Close this space and stop the SSE subscription. Idempotent.
55
39
  */
56
40
  close() {
57
41
  if (this.#closed)
58
42
  return;
59
43
  this.#closed = true;
60
- for (const ch of this.#channels.values()) {
61
- ch.close();
62
- }
63
- this.#channels.clear();
64
44
  for (const unsub of this.#unsubscribers)
65
45
  unsub();
66
46
  this.#unsubscribers.length = 0;
@@ -68,7 +48,7 @@ class ReactiveSpaceImpl {
68
48
  this.#space.close();
69
49
  }
70
50
  // Reactive getters
71
- get channels() { return this.#channelList; }
51
+ get conversations() { return this.#conversationList; }
72
52
  // Proxy read-only properties
73
53
  get id() { return this.#space.id; }
74
54
  get name() { return this.#space.name; }
@@ -76,6 +56,25 @@ class ReactiveSpaceImpl {
76
56
  get memberCount() { return this.#space.memberCount; }
77
57
  get webdav() { return this.#space.webdav; }
78
58
  get fileTree() { return this.#fileTree; }
59
+ // Space-level methods
60
+ getObject(...args) { return this.#space.getObject(...args); }
61
+ getObjects(...args) { return this.#space.getObjects(...args); }
62
+ object(path) { return new ReactiveObjectImpl(this.#space, this.#fileTree, path); }
63
+ watch(options) { return new ReactiveWatchImpl(this.#space, this.#fileTree, options); }
64
+ stat(...args) { return this.#space.stat(...args); }
65
+ stopInteraction(...args) { return this.#space.stopInteraction(...args); }
66
+ checkpoint(...args) { return this.#space.checkpoint(...args); }
67
+ canUndo(...args) { return this.#space.canUndo(...args); }
68
+ canRedo(...args) { return this.#space.canRedo(...args); }
69
+ undo(...args) { return this.#space.undo(...args); }
70
+ redo(...args) { return this.#space.redo(...args); }
71
+ clearHistory(...args) { return this.#space.clearHistory(...args); }
72
+ getMetadata(...args) { return this.#space.getMetadata(...args); }
73
+ getAllMetadata(...args) { return this.#space.getAllMetadata(...args); }
74
+ getConversations(...args) { return this.#space.getConversations(...args); }
75
+ deleteConversation(...args) { return this.#space.deleteConversation(...args); }
76
+ getSchema(...args) { return this.#space.getSchema(...args); }
77
+ fetch(...args) { return this.#space.fetch(...args); }
79
78
  // Proxy resource methods
80
79
  getStorageUsage(...args) { return this.#space.getStorageUsage(...args); }
81
80
  fetchPath(...args) { return this.#space.fetchPath(...args); }
@@ -88,11 +87,9 @@ class ReactiveSpaceImpl {
88
87
  createInvite(...args) { return this.#space.createInvite(...args); }
89
88
  listInvites(...args) { return this.#space.listInvites(...args); }
90
89
  revokeInvite(...args) { return this.#space.revokeInvite(...args); }
91
- renameChannel(channelId, name) { return this.#space.renameChannel(channelId, name); }
92
- deleteChannel(channelId) { return this.#space.deleteChannel(channelId); }
93
90
  exportArchive() { return this.#space.exportArchive(); }
94
91
  refresh() { return this.#space.refresh(); }
95
- // Events on the underlying space (channelCreated/Updated/Deleted, connectionStateChanged)
92
+ // Events on the underlying space (conversationUpdated, filesChanged, connectionStateChanged)
96
93
  on(...args) { return this.#space.on(...args); }
97
94
  off(...args) { return this.#space.off(...args); }
98
95
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rool-dev/svelte",
3
- "version": "0.11.3-dev.a6a4bb1",
3
+ "version": "0.11.4-dev.10ce346",
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.11.3-dev.a6a4bb1"
44
+ "@rool-dev/sdk": "0.11.4-dev.10ce346"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "svelte": "^5.0.0"