@rool-dev/app 0.3.0

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.
Files changed (59) hide show
  1. package/README.md +306 -0
  2. package/dist/cli/dev.d.ts +10 -0
  3. package/dist/cli/dev.d.ts.map +1 -0
  4. package/dist/cli/dev.js +241 -0
  5. package/dist/cli/index.d.ts +3 -0
  6. package/dist/cli/index.d.ts.map +1 -0
  7. package/dist/cli/index.js +22 -0
  8. package/dist/cli/init.d.ts +7 -0
  9. package/dist/cli/init.d.ts.map +1 -0
  10. package/dist/cli/init.js +108 -0
  11. package/dist/cli/publish.d.ts +9 -0
  12. package/dist/cli/publish.d.ts.map +1 -0
  13. package/dist/cli/publish.js +213 -0
  14. package/dist/cli/vite-utils.d.ts +22 -0
  15. package/dist/cli/vite-utils.d.ts.map +1 -0
  16. package/dist/cli/vite-utils.js +96 -0
  17. package/dist/client.d.ts +79 -0
  18. package/dist/client.d.ts.map +1 -0
  19. package/dist/client.js +235 -0
  20. package/dist/dev/AppGrid.svelte +246 -0
  21. package/dist/dev/AppGrid.svelte.d.ts +14 -0
  22. package/dist/dev/AppGrid.svelte.d.ts.map +1 -0
  23. package/dist/dev/DevHostController.d.ts +86 -0
  24. package/dist/dev/DevHostController.d.ts.map +1 -0
  25. package/dist/dev/DevHostController.js +395 -0
  26. package/dist/dev/HostShell.svelte +110 -0
  27. package/dist/dev/HostShell.svelte.d.ts +11 -0
  28. package/dist/dev/HostShell.svelte.d.ts.map +1 -0
  29. package/dist/dev/Sidebar.svelte +223 -0
  30. package/dist/dev/Sidebar.svelte.d.ts +19 -0
  31. package/dist/dev/Sidebar.svelte.d.ts.map +1 -0
  32. package/dist/dev/TabBar.svelte +83 -0
  33. package/dist/dev/TabBar.svelte.d.ts +14 -0
  34. package/dist/dev/TabBar.svelte.d.ts.map +1 -0
  35. package/dist/dev/app.css +1 -0
  36. package/dist/dev/host-shell.d.ts +8 -0
  37. package/dist/dev/host-shell.d.ts.map +1 -0
  38. package/dist/dev/host-shell.js +14807 -0
  39. package/dist/dev/host-shell.js.map +1 -0
  40. package/dist/dev/vite-env.d.ts +4 -0
  41. package/dist/host.d.ts +54 -0
  42. package/dist/host.d.ts.map +1 -0
  43. package/dist/host.js +171 -0
  44. package/dist/index.d.ts +10 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +8 -0
  47. package/dist/manifest.d.ts +35 -0
  48. package/dist/manifest.d.ts.map +1 -0
  49. package/dist/manifest.js +10 -0
  50. package/dist/protocol.d.ts +46 -0
  51. package/dist/protocol.d.ts.map +1 -0
  52. package/dist/protocol.js +14 -0
  53. package/dist/reactive.svelte.d.ts +100 -0
  54. package/dist/reactive.svelte.d.ts.map +1 -0
  55. package/dist/reactive.svelte.js +267 -0
  56. package/dist/types.d.ts +119 -0
  57. package/dist/types.d.ts.map +1 -0
  58. package/dist/types.js +7 -0
  59. package/package.json +78 -0
@@ -0,0 +1,4 @@
1
+ declare module '*.css?inline' {
2
+ const css: string;
3
+ export default css;
4
+ }
package/dist/host.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @rool-dev/app/host — Host-side bridge for iframe-sandboxed apps.
3
+ *
4
+ * The host creates a `BridgeHost` with a real `BridgeableChannel` and an iframe.
5
+ * It handles the handshake, proxies method calls, and forwards events.
6
+ *
7
+ * Used by both the console's AppHost component and the local dev shell.
8
+ */
9
+ /**
10
+ * Minimal channel interface accepted by the bridge host.
11
+ * Works with both BridgeableChannel (SDK) and ReactiveChannel (@rool-dev/svelte).
12
+ */
13
+ export interface BridgeableChannel {
14
+ id: string;
15
+ name: string;
16
+ role: string;
17
+ linkAccess: string;
18
+ userId: string;
19
+ channelId: string;
20
+ getSchema(): Record<string, unknown>;
21
+ getAllMetadata(): Record<string, unknown>;
22
+ on(event: string, handler: (...args: unknown[]) => void): void;
23
+ off(event: string, handler: (...args: unknown[]) => void): void;
24
+ }
25
+ export interface BridgeHostOptions {
26
+ /** The real channel to proxy calls to */
27
+ channel: BridgeableChannel;
28
+ /** The iframe element hosting the app */
29
+ iframe: HTMLIFrameElement;
30
+ }
31
+ export declare class BridgeHost {
32
+ private channel;
33
+ private iframe;
34
+ private eventCleanups;
35
+ private _destroyed;
36
+ constructor(options: BridgeHostOptions);
37
+ private _sendInit;
38
+ private _onMessage;
39
+ private _handleRequest;
40
+ private _postToApp;
41
+ destroy(): void;
42
+ }
43
+ /**
44
+ * Create a bridge host that proxies a BridgeableChannel to an iframe.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const host = createBridgeHost({ channel, iframe });
49
+ * // ... later
50
+ * host.destroy();
51
+ * ```
52
+ */
53
+ export declare function createBridgeHost(options: BridgeHostOptions): BridgeHost;
54
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;;GAGG;AAEH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;IAC/D,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,IAAI,CAAC;CACjE;AA0CD,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,yCAAyC;IACzC,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,aAAa,CAAyB;IAC9C,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,EAAE,iBAAiB;IA0BtC,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,UAAU,CAchB;YAEY,cAAc;IAuC5B,OAAO,CAAC,UAAU;IASlB,OAAO,IAAI,IAAI;CAQhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAEvE"}
package/dist/host.js ADDED
@@ -0,0 +1,171 @@
1
+ /**
2
+ * @rool-dev/app/host — Host-side bridge for iframe-sandboxed apps.
3
+ *
4
+ * The host creates a `BridgeHost` with a real `BridgeableChannel` and an iframe.
5
+ * It handles the handshake, proxies method calls, and forwards events.
6
+ *
7
+ * Used by both the console's AppHost component and the local dev shell.
8
+ */
9
+ import { isBridgeMessage } from './protocol.js';
10
+ // Channel events to forward to the app
11
+ const FORWARDED_EVENTS = [
12
+ 'objectCreated',
13
+ 'objectUpdated',
14
+ 'objectDeleted',
15
+ 'metadataUpdated',
16
+ 'channelUpdated',
17
+ 'reset',
18
+ 'syncError',
19
+ ];
20
+ // Channel methods the app can call.
21
+ // Sync methods (getObjectIds, getSchema, etc.) are wrapped as async on the host side.
22
+ const ALLOWED_METHODS = new Set([
23
+ 'getObject',
24
+ 'stat',
25
+ 'findObjects',
26
+ 'getObjectIds',
27
+ 'createObject',
28
+ 'updateObject',
29
+ 'deleteObjects',
30
+ 'getSchema',
31
+ 'createCollection',
32
+ 'alterCollection',
33
+ 'dropCollection',
34
+ 'getInteractions',
35
+ 'getSystemInstruction',
36
+ 'setSystemInstruction',
37
+ 'setMetadata',
38
+ 'getMetadata',
39
+ 'getAllMetadata',
40
+ 'prompt',
41
+ 'checkpoint',
42
+ 'canUndo',
43
+ 'canRedo',
44
+ 'undo',
45
+ 'redo',
46
+ 'clearHistory',
47
+ ]);
48
+ export class BridgeHost {
49
+ channel;
50
+ iframe;
51
+ eventCleanups = [];
52
+ _destroyed = false;
53
+ constructor(options) {
54
+ this.channel = options.channel;
55
+ this.iframe = options.iframe;
56
+ window.addEventListener('message', this._onMessage);
57
+ // Forward channel events to the app iframe
58
+ for (const eventName of FORWARDED_EVENTS) {
59
+ const handler = (data) => {
60
+ this._postToApp({
61
+ type: 'rool:event',
62
+ name: eventName,
63
+ data,
64
+ });
65
+ };
66
+ this.channel.on(eventName, handler);
67
+ this.eventCleanups.push(() => {
68
+ this.channel.off(eventName, handler);
69
+ });
70
+ }
71
+ }
72
+ // ---------------------------------------------------------------------------
73
+ // Handshake
74
+ // ---------------------------------------------------------------------------
75
+ _sendInit() {
76
+ const init = {
77
+ type: 'rool:init',
78
+ channelId: this.channel.channelId,
79
+ spaceId: this.channel.id,
80
+ spaceName: this.channel.name,
81
+ role: this.channel.role,
82
+ linkAccess: this.channel.linkAccess,
83
+ userId: this.channel.userId,
84
+ schema: this.channel.getSchema(),
85
+ metadata: this.channel.getAllMetadata(),
86
+ };
87
+ this._postToApp(init);
88
+ }
89
+ // ---------------------------------------------------------------------------
90
+ // Message handling
91
+ // ---------------------------------------------------------------------------
92
+ _onMessage = async (event) => {
93
+ // Only accept messages from our iframe
94
+ if (event.source !== this.iframe.contentWindow)
95
+ return;
96
+ if (!isBridgeMessage(event.data))
97
+ return;
98
+ if (event.data.type === 'rool:ready') {
99
+ this._sendInit();
100
+ return;
101
+ }
102
+ if (event.data.type === 'rool:request') {
103
+ await this._handleRequest(event.data);
104
+ return;
105
+ }
106
+ };
107
+ async _handleRequest(req) {
108
+ const { id, method, args } = req;
109
+ if (!ALLOWED_METHODS.has(method)) {
110
+ this._postToApp({
111
+ type: 'rool:response',
112
+ id,
113
+ error: `Method "${method}" is not available to apps`,
114
+ });
115
+ return;
116
+ }
117
+ try {
118
+ // Get the method from the channel (cast for dynamic dispatch)
119
+ const fn = this.channel[method];
120
+ let result;
121
+ if (typeof fn === 'function') {
122
+ result = fn.apply(this.channel, args);
123
+ // Await if it returns a promise
124
+ if (result instanceof Promise) {
125
+ result = await result;
126
+ }
127
+ }
128
+ else {
129
+ // Property access (shouldn't happen with current ALLOWED_METHODS, but just in case)
130
+ result = fn;
131
+ }
132
+ this._postToApp({ type: 'rool:response', id, result });
133
+ }
134
+ catch (e) {
135
+ const message = e instanceof Error ? e.message : String(e);
136
+ this._postToApp({ type: 'rool:response', id, error: message });
137
+ }
138
+ }
139
+ // ---------------------------------------------------------------------------
140
+ // Helpers
141
+ // ---------------------------------------------------------------------------
142
+ _postToApp(message) {
143
+ if (this._destroyed)
144
+ return;
145
+ this.iframe.contentWindow?.postMessage(message, '*');
146
+ }
147
+ // ---------------------------------------------------------------------------
148
+ // Cleanup
149
+ // ---------------------------------------------------------------------------
150
+ destroy() {
151
+ this._destroyed = true;
152
+ window.removeEventListener('message', this._onMessage);
153
+ for (const cleanup of this.eventCleanups) {
154
+ cleanup();
155
+ }
156
+ this.eventCleanups = [];
157
+ }
158
+ }
159
+ /**
160
+ * Create a bridge host that proxies a BridgeableChannel to an iframe.
161
+ *
162
+ * @example
163
+ * ```typescript
164
+ * const host = createBridgeHost({ channel, iframe });
165
+ * // ... later
166
+ * host.destroy();
167
+ * ```
168
+ */
169
+ export function createBridgeHost(options) {
170
+ return new BridgeHost(options);
171
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @rool-dev/app — Svelte-first app SDK for Rool.
3
+ *
4
+ * `initApp()` connects to the host via the iframe bridge and returns
5
+ * a reactive channel with $state properties, matching the @rool-dev/svelte API.
6
+ */
7
+ export { initApp } from './reactive.svelte.js';
8
+ export type { ReactiveAppChannel, ReactiveObject, ReactiveWatch, WatchOptions } from './reactive.svelte.js';
9
+ export type { RoolObject, RoolObjectStat, SpaceSchema, CollectionDef, FieldDef, FieldType, Interaction, ToolCall, PromptOptions, PromptEffort, FindObjectsOptions, CreateObjectOptions, UpdateObjectOptions, ChangeSource, RoolUserRole, LinkAccess, AppChannelEvents, } from './types.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,YAAY,EAAE,kBAAkB,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG5G,YAAY,EACV,UAAU,EACV,cAAc,EACd,WAAW,EACX,aAAa,EACb,QAAQ,EACR,SAAS,EACT,WAAW,EACX,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @rool-dev/app — Svelte-first app SDK for Rool.
3
+ *
4
+ * `initApp()` connects to the host via the iframe bridge and returns
5
+ * a reactive channel with $state properties, matching the @rool-dev/svelte API.
6
+ */
7
+ // Public API — reactive channel
8
+ export { initApp } from './reactive.svelte.js';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Shared manifest types and environment config.
3
+ *
4
+ * Browser-safe — no Node.js imports. Used by CLI code, the dev host shell,
5
+ * and the publish command.
6
+ */
7
+ export interface ManifestFieldDef {
8
+ name: string;
9
+ type: Record<string, unknown>;
10
+ }
11
+ export interface ManifestCollections {
12
+ write?: Record<string, ManifestFieldDef[]> | '*';
13
+ read?: Record<string, ManifestFieldDef[]> | '*';
14
+ }
15
+ export interface AppManifest {
16
+ id: string;
17
+ name: string;
18
+ description?: string;
19
+ systemInstruction?: string | null;
20
+ collections?: ManifestCollections;
21
+ [key: string]: unknown;
22
+ }
23
+ export interface ManifestResult {
24
+ manifest: AppManifest | null;
25
+ error: string | null;
26
+ }
27
+ export type Environment = 'dev' | 'prod';
28
+ export interface EnvironmentConfig {
29
+ baseUrl: string;
30
+ authUrl: string;
31
+ label: string;
32
+ appsDomain: string;
33
+ }
34
+ export declare const ENV_URLS: Record<Environment, EnvironmentConfig>;
35
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,GAAG,GAAG,CAAC;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,GAAG,GAAG,CAAC;CACjD;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAMD,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,CAAC;AAEzC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,iBAAiB,CAG3D,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Shared manifest types and environment config.
3
+ *
4
+ * Browser-safe — no Node.js imports. Used by CLI code, the dev host shell,
5
+ * and the publish command.
6
+ */
7
+ export const ENV_URLS = {
8
+ dev: { baseUrl: 'https://api.dev.rool.dev', authUrl: 'https://api.dev.rool.dev/auth', label: 'api.dev.rool.dev', appsDomain: 'dev.rool.app' },
9
+ prod: { baseUrl: 'https://api.rool.dev', authUrl: 'https://api.rool.dev/auth', label: 'api.rool.dev', appsDomain: 'rool.app' },
10
+ };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Bridge protocol types shared between app (client) and host.
3
+ *
4
+ * All communication between the sandboxed iframe and the host happens
5
+ * via window.postMessage using these message shapes.
6
+ */
7
+ /** App → Host: invoke a channel method */
8
+ export interface BridgeRequest {
9
+ type: 'rool:request';
10
+ id: string;
11
+ method: string;
12
+ args: unknown[];
13
+ }
14
+ /** Host → App: result of a channel method call */
15
+ export interface BridgeResponse {
16
+ type: 'rool:response';
17
+ id: string;
18
+ result?: unknown;
19
+ error?: string;
20
+ }
21
+ /** Host → App: channel event pushed in real-time */
22
+ export interface BridgeEvent {
23
+ type: 'rool:event';
24
+ name: string;
25
+ data: unknown;
26
+ }
27
+ /** App → Host: app is loaded and ready for handshake */
28
+ export interface BridgeReady {
29
+ type: 'rool:ready';
30
+ }
31
+ /** Host → App: handshake response with channel metadata */
32
+ export interface BridgeInit {
33
+ type: 'rool:init';
34
+ channelId: string;
35
+ spaceId: string;
36
+ spaceName: string;
37
+ role: string;
38
+ linkAccess: string;
39
+ userId: string;
40
+ schema: Record<string, unknown>;
41
+ metadata: Record<string, unknown>;
42
+ }
43
+ export type BridgeMessage = BridgeRequest | BridgeResponse | BridgeEvent | BridgeReady | BridgeInit;
44
+ /** Type guard for bridge messages */
45
+ export declare function isBridgeMessage(data: unknown): data is BridgeMessage;
46
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0CAA0C;AAC1C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,cAAc,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AAED,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,eAAe,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAED,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,2DAA2D;AAC3D,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,cAAc,GACd,WAAW,GACX,WAAW,GACX,UAAU,CAAC;AAEf,qCAAqC;AACrC,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAQpE"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Bridge protocol types shared between app (client) and host.
3
+ *
4
+ * All communication between the sandboxed iframe and the host happens
5
+ * via window.postMessage using these message shapes.
6
+ */
7
+ /** Type guard for bridge messages */
8
+ export function isBridgeMessage(data) {
9
+ return (typeof data === 'object' &&
10
+ data !== null &&
11
+ 'type' in data &&
12
+ typeof data.type === 'string' &&
13
+ data.type.startsWith('rool:'));
14
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Reactive Svelte wrapper around AppChannel (bridge client).
3
+ *
4
+ * Mirrors the @rool-dev/svelte ReactiveChannel API: same $state properties,
5
+ * same methods, same reactive primitives (object(), watch()).
6
+ * The underlying transport is the postMessage bridge, not the SDK directly.
7
+ */
8
+ import { AppChannel } from './client.js';
9
+ import type { RoolObject, FieldDef, Interaction, PromptOptions, FindObjectsOptions, CreateObjectOptions, UpdateObjectOptions } from './types.js';
10
+ export interface WatchOptions {
11
+ where?: Record<string, unknown>;
12
+ limit?: number;
13
+ order?: 'asc' | 'desc';
14
+ }
15
+ declare class ReactiveWatchImpl {
16
+ #private;
17
+ objects: RoolObject[];
18
+ loading: boolean;
19
+ constructor(channel: AppChannel, options: WatchOptions);
20
+ refresh(): Promise<void>;
21
+ close(): void;
22
+ }
23
+ export type ReactiveWatch = ReactiveWatchImpl;
24
+ declare class ReactiveObjectImpl {
25
+ #private;
26
+ data: RoolObject | undefined;
27
+ loading: boolean;
28
+ constructor(channel: AppChannel, objectId: string);
29
+ refresh(): Promise<void>;
30
+ close(): void;
31
+ }
32
+ export type ReactiveObject = ReactiveObjectImpl;
33
+ declare class ReactiveAppChannelImpl {
34
+ #private;
35
+ interactions: Interaction[];
36
+ objectIds: string[];
37
+ constructor(channel: AppChannel);
38
+ get channelId(): string;
39
+ get spaceId(): string;
40
+ get spaceName(): string;
41
+ get role(): import("./types.js").RoolUserRole;
42
+ get linkAccess(): import("./types.js").LinkAccess;
43
+ get userId(): string;
44
+ get isReadOnly(): boolean;
45
+ getObject(objectId: string): Promise<RoolObject | undefined>;
46
+ stat(objectId: string): Promise<import("./types.js").RoolObjectStat | undefined>;
47
+ findObjects(options: FindObjectsOptions): Promise<{
48
+ objects: RoolObject[];
49
+ message: string;
50
+ }>;
51
+ getObjectIds(options?: {
52
+ limit?: number;
53
+ order?: 'asc' | 'desc';
54
+ }): Promise<string[]>;
55
+ createObject(options: CreateObjectOptions): Promise<{
56
+ object: RoolObject;
57
+ message: string;
58
+ }>;
59
+ updateObject(objectId: string, options: UpdateObjectOptions): Promise<{
60
+ object: RoolObject;
61
+ message: string;
62
+ }>;
63
+ deleteObjects(objectIds: string[]): Promise<void>;
64
+ prompt(text: string, options?: PromptOptions): Promise<{
65
+ message: string;
66
+ objects: RoolObject[];
67
+ }>;
68
+ checkpoint(label?: string): Promise<string>;
69
+ canUndo(): Promise<boolean>;
70
+ canRedo(): Promise<boolean>;
71
+ undo(): Promise<boolean>;
72
+ redo(): Promise<boolean>;
73
+ clearHistory(): Promise<void>;
74
+ setMetadata(key: string, value: unknown): Promise<void>;
75
+ getMetadata(key: string): unknown;
76
+ getAllMetadata(): Record<string, unknown>;
77
+ getInteractions(): Promise<Interaction[]>;
78
+ getSystemInstruction(): Promise<string | undefined>;
79
+ setSystemInstruction(instruction: string | null): Promise<void>;
80
+ getSchema(): import("./types.js").SpaceSchema;
81
+ createCollection(name: string, fields: FieldDef[]): Promise<import("./types.js").CollectionDef>;
82
+ alterCollection(name: string, fields: FieldDef[]): Promise<import("./types.js").CollectionDef>;
83
+ dropCollection(name: string): Promise<void>;
84
+ on(...args: Parameters<AppChannel['on']>): void;
85
+ off(...args: Parameters<AppChannel['off']>): void;
86
+ object(objectId: string): ReactiveObject;
87
+ watch(options: WatchOptions): ReactiveWatch;
88
+ destroy(): void;
89
+ }
90
+ export type ReactiveAppChannel = ReactiveAppChannelImpl;
91
+ /**
92
+ * Initialize the app and return a reactive channel.
93
+ *
94
+ * Sends `rool:ready` to the host, waits for the handshake, and returns
95
+ * a reactive channel with $state properties (interactions, objectIds)
96
+ * and reactive primitives (object(), watch()).
97
+ */
98
+ export declare function initApp(timeout?: number): Promise<ReactiveAppChannel>;
99
+ export {};
100
+ //# sourceMappingURL=reactive.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive.svelte.d.ts","sourceRoot":"","sources":["../src/reactive.svelte.ts"],"names":[],"mappings":"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"}