@garretapp/sdk 0.1.1 → 0.1.2

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.
@@ -189,6 +189,10 @@ function getGarret() {
189
189
  },
190
190
  onOpenSettings: () => () => {
191
191
  },
192
+ onRefresh: () => () => {
193
+ },
194
+ setTitle: () => {
195
+ },
192
196
  surfaces: { open: nope, onClosed: () => () => {
193
197
  } },
194
198
  window: { setAspectRatio: () => {
@@ -117,6 +117,10 @@ interface GarretPlatform {
117
117
  onActiveChange(cb: (active: boolean) => void): () => void;
118
118
  /** The host (frame ⋯→Settings) asks this widget to open its own config UI. */
119
119
  onOpenSettings(cb: () => void): () => void;
120
+ /** The host (frame ⋯→Refresh) asks this widget to reload its data. */
121
+ onRefresh(cb: () => void): () => void;
122
+ /** Set this placement's title in the board frame header (persisted in the board config). */
123
+ setTitle(title: string): void;
120
124
  /** Open sibling surfaces (same package) as floating windows. Requires the `windows` capability. */
121
125
  surfaces: SurfaceApi;
122
126
  /** Controls for this UI's own surface window (no-op for a board-placed widget). */
@@ -117,6 +117,10 @@ interface GarretPlatform {
117
117
  onActiveChange(cb: (active: boolean) => void): () => void;
118
118
  /** The host (frame ⋯→Settings) asks this widget to open its own config UI. */
119
119
  onOpenSettings(cb: () => void): () => void;
120
+ /** The host (frame ⋯→Refresh) asks this widget to reload its data. */
121
+ onRefresh(cb: () => void): () => void;
122
+ /** Set this placement's title in the board frame header (persisted in the board config). */
123
+ setTitle(title: string): void;
120
124
  /** Open sibling surfaces (same package) as floating windows. Requires the `windows` capability. */
121
125
  surfaces: SurfaceApi;
122
126
  /** Controls for this UI's own surface window (no-op for a board-placed widget). */
package/dist/react.cjs CHANGED
@@ -222,6 +222,10 @@ function getGarret() {
222
222
  },
223
223
  onOpenSettings: () => () => {
224
224
  },
225
+ onRefresh: () => () => {
226
+ },
227
+ setTitle: () => {
228
+ },
225
229
  surfaces: { open: nope, onClosed: () => () => {
226
230
  } },
227
231
  window: { setAspectRatio: () => {
@@ -428,6 +432,12 @@ function useOpenSettings(cb) {
428
432
  ref.current = cb;
429
433
  react.useEffect(() => g.onOpenSettings(() => ref.current()), [g]);
430
434
  }
435
+ function useRefresh(cb) {
436
+ const g = getGarret();
437
+ const ref = react.useRef(cb);
438
+ ref.current = cb;
439
+ react.useEffect(() => g.onRefresh(() => ref.current()), [g]);
440
+ }
431
441
  function useInstanceConfig(defaults) {
432
442
  const g = getGarret();
433
443
  const [cfg, setCfg] = react.useState(defaults);
@@ -493,4 +503,5 @@ exports.useHostEvent = useHostEvent;
493
503
  exports.useInstanceConfig = useInstanceConfig;
494
504
  exports.useOpenSettings = useOpenSettings;
495
505
  exports.useProps = useProps;
506
+ exports.useRefresh = useRefresh;
496
507
  exports.useStream = useStream;
package/dist/react.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { G as GarretError, E as EventMap, H as HostClient, f as StreamCall } from './types-BxSYAH_H.cjs';
2
- import { G as GarretPlatform } from './platform-DnI7gJTx.cjs';
3
- export { S as SurfaceApi, a as SurfaceHandle, b as SurfaceOpenOptions, W as WindowControls } from './platform-DnI7gJTx.cjs';
2
+ import { G as GarretPlatform } from './platform-DjRN9xTv.cjs';
3
+ export { S as SurfaceApi, a as SurfaceHandle, b as SurfaceOpenOptions, W as WindowControls } from './platform-DjRN9xTv.cjs';
4
4
  import { ReactNode } from 'react';
5
5
  import './protocol-Do0BJdeE.cjs';
6
6
 
@@ -112,6 +112,8 @@ declare function useConfig<T>(): [T, (patch: Partial<T>) => void, (value: T) =>
112
112
  declare function useActive(): boolean;
113
113
  /** Run `cb` when the host (frame ⋯→Settings) asks this widget to reveal its own config UI. */
114
114
  declare function useOpenSettings(cb: () => void): void;
115
+ /** Run `cb` when the host (frame ⋯→Refresh) asks this widget to reload. */
116
+ declare function useRefresh(cb: () => void): void;
115
117
  /** Per-placement config backed by `g.instanceStorage` (isolated per widget instance). Loads once the
116
118
  * runtime binds (calls before bind reject); `set` writes through to storage + state. `loaded` gates
117
119
  * the first data fetch so you don't fetch with defaults before the saved config arrives. */
@@ -126,4 +128,4 @@ declare function useInstanceConfig<T extends Record<string, unknown>>(defaults:
126
128
  * time), so this re-renders when the runtime binds. The `T` is an unchecked cast — validate it yourself. */
127
129
  declare function useProps<T = Record<string, unknown>>(): T;
128
130
 
129
- export { Accordion, Badge, Dot, EmptyState, ErrorState, Field, FieldGroup, GarretError, GarretPlatform, Item, NumberInput, Scroll, Select, SettingsPanel, type StreamStatus, Switch, TextInput, type Tone, type UseStreamResult, useActive, useConfig, useGarret, useHost, useHostEvent, useInstanceConfig, useOpenSettings, useProps, useStream };
131
+ export { Accordion, Badge, Dot, EmptyState, ErrorState, Field, FieldGroup, GarretError, GarretPlatform, Item, NumberInput, Scroll, Select, SettingsPanel, type StreamStatus, Switch, TextInput, type Tone, type UseStreamResult, useActive, useConfig, useGarret, useHost, useHostEvent, useInstanceConfig, useOpenSettings, useProps, useRefresh, useStream };
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { G as GarretError, E as EventMap, H as HostClient, f as StreamCall } from './types-BxSYAH_H.js';
2
- import { G as GarretPlatform } from './platform-CZHtdUK0.js';
3
- export { S as SurfaceApi, a as SurfaceHandle, b as SurfaceOpenOptions, W as WindowControls } from './platform-CZHtdUK0.js';
2
+ import { G as GarretPlatform } from './platform-K2c4rKaG.js';
3
+ export { S as SurfaceApi, a as SurfaceHandle, b as SurfaceOpenOptions, W as WindowControls } from './platform-K2c4rKaG.js';
4
4
  import { ReactNode } from 'react';
5
5
  import './protocol-Do0BJdeE.js';
6
6
 
@@ -112,6 +112,8 @@ declare function useConfig<T>(): [T, (patch: Partial<T>) => void, (value: T) =>
112
112
  declare function useActive(): boolean;
113
113
  /** Run `cb` when the host (frame ⋯→Settings) asks this widget to reveal its own config UI. */
114
114
  declare function useOpenSettings(cb: () => void): void;
115
+ /** Run `cb` when the host (frame ⋯→Refresh) asks this widget to reload. */
116
+ declare function useRefresh(cb: () => void): void;
115
117
  /** Per-placement config backed by `g.instanceStorage` (isolated per widget instance). Loads once the
116
118
  * runtime binds (calls before bind reject); `set` writes through to storage + state. `loaded` gates
117
119
  * the first data fetch so you don't fetch with defaults before the saved config arrives. */
@@ -126,4 +128,4 @@ declare function useInstanceConfig<T extends Record<string, unknown>>(defaults:
126
128
  * time), so this re-renders when the runtime binds. The `T` is an unchecked cast — validate it yourself. */
127
129
  declare function useProps<T = Record<string, unknown>>(): T;
128
130
 
129
- export { Accordion, Badge, Dot, EmptyState, ErrorState, Field, FieldGroup, GarretError, GarretPlatform, Item, NumberInput, Scroll, Select, SettingsPanel, type StreamStatus, Switch, TextInput, type Tone, type UseStreamResult, useActive, useConfig, useGarret, useHost, useHostEvent, useInstanceConfig, useOpenSettings, useProps, useStream };
131
+ export { Accordion, Badge, Dot, EmptyState, ErrorState, Field, FieldGroup, GarretError, GarretPlatform, Item, NumberInput, Scroll, Select, SettingsPanel, type StreamStatus, Switch, TextInput, type Tone, type UseStreamResult, useActive, useConfig, useGarret, useHost, useHostEvent, useInstanceConfig, useOpenSettings, useProps, useRefresh, useStream };
package/dist/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { getGarret, getRuntime, getHostTransport, createHostClient, getInstanceId } from './chunk-ZJYHRC5C.js';
1
+ import { getGarret, getRuntime, getHostTransport, createHostClient, getInstanceId } from './chunk-YBYF7JQS.js';
2
2
  import { GarretError } from './chunk-ENIDFSMM.js';
3
3
  export { GarretError } from './chunk-ENIDFSMM.js';
4
4
  import { useState, useMemo, useEffect, useRef, useCallback } from 'react';
@@ -197,6 +197,12 @@ function useOpenSettings(cb) {
197
197
  ref.current = cb;
198
198
  useEffect(() => g.onOpenSettings(() => ref.current()), [g]);
199
199
  }
200
+ function useRefresh(cb) {
201
+ const g = getGarret();
202
+ const ref = useRef(cb);
203
+ ref.current = cb;
204
+ useEffect(() => g.onRefresh(() => ref.current()), [g]);
205
+ }
200
206
  function useInstanceConfig(defaults) {
201
207
  const g = getGarret();
202
208
  const [cfg, setCfg] = useState(defaults);
@@ -239,4 +245,4 @@ function useProps() {
239
245
  return props;
240
246
  }
241
247
 
242
- export { Accordion, Badge, Dot, EmptyState, ErrorState, Field, FieldGroup, Item, NumberInput, Scroll, Select, SettingsPanel, Switch, TextInput, useActive, useConfig, useGarret, useHost, useHostEvent, useInstanceConfig, useOpenSettings, useProps, useStream };
248
+ export { Accordion, Badge, Dot, EmptyState, ErrorState, Field, FieldGroup, Item, NumberInput, Scroll, Select, SettingsPanel, Switch, TextInput, useActive, useConfig, useGarret, useHost, useHostEvent, useInstanceConfig, useOpenSettings, useProps, useRefresh, useStream };
package/dist/ui.cjs CHANGED
@@ -217,6 +217,10 @@ function getGarret() {
217
217
  },
218
218
  onOpenSettings: () => () => {
219
219
  },
220
+ onRefresh: () => () => {
221
+ },
222
+ setTitle: () => {
223
+ },
220
224
  surfaces: { open: nope, onClosed: () => () => {
221
225
  } },
222
226
  window: { setAspectRatio: () => {
package/dist/ui.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { T as Transport } from './protocol-Do0BJdeE.cjs';
2
2
  import { E as EventMap, H as HostClient } from './types-BxSYAH_H.cjs';
3
3
  export { C as Capability, G as GarretError, M as Manifest, S as Stream, f as StreamCall, g as defineConfig, h as defineManifest } from './types-BxSYAH_H.cjs';
4
- export { G as GarretPlatform, c as GarretRuntime, d as SecretsApi, e as ServiceClient, f as StorageApi, S as SurfaceApi, a as SurfaceHandle, b as SurfaceOpenOptions, W as WindowControls, g as getGarret, h as getHostTransport, i as getInstanceId, j as getRuntime } from './platform-DnI7gJTx.cjs';
4
+ export { G as GarretPlatform, c as GarretRuntime, d as SecretsApi, e as ServiceClient, f as StorageApi, S as SurfaceApi, a as SurfaceHandle, b as SurfaceOpenOptions, W as WindowControls, g as getGarret, h as getHostTransport, i as getInstanceId, j as getRuntime } from './platform-DjRN9xTv.cjs';
5
5
 
6
6
  /**
7
7
  * UI-side host client — a typed proxy over the wire (protocol.ts). Every call returns ONE handle
package/dist/ui.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { T as Transport } from './protocol-Do0BJdeE.js';
2
2
  import { E as EventMap, H as HostClient } from './types-BxSYAH_H.js';
3
3
  export { C as Capability, G as GarretError, M as Manifest, S as Stream, f as StreamCall, g as defineConfig, h as defineManifest } from './types-BxSYAH_H.js';
4
- export { G as GarretPlatform, c as GarretRuntime, d as SecretsApi, e as ServiceClient, f as StorageApi, S as SurfaceApi, a as SurfaceHandle, b as SurfaceOpenOptions, W as WindowControls, g as getGarret, h as getHostTransport, i as getInstanceId, j as getRuntime } from './platform-CZHtdUK0.js';
4
+ export { G as GarretPlatform, c as GarretRuntime, d as SecretsApi, e as ServiceClient, f as StorageApi, S as SurfaceApi, a as SurfaceHandle, b as SurfaceOpenOptions, W as WindowControls, g as getGarret, h as getHostTransport, i as getInstanceId, j as getRuntime } from './platform-K2c4rKaG.js';
5
5
 
6
6
  /**
7
7
  * UI-side host client — a typed proxy over the wire (protocol.ts). Every call returns ONE handle
package/dist/ui.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { defineConfig, defineManifest } from './chunk-RZJO3X6O.js';
2
- export { createHostClient, getGarret, getHostTransport, getInstanceId, getRuntime } from './chunk-ZJYHRC5C.js';
2
+ export { createHostClient, getGarret, getHostTransport, getInstanceId, getRuntime } from './chunk-YBYF7JQS.js';
3
3
  export { GarretError } from './chunk-ENIDFSMM.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@garretapp/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Build extensions for Garret — one SDK for both web widgets and full-access native extensions. Host runtime (defineHost), UI client + React hooks. See docs/garret.html.",
5
5
  "license": "MIT",
6
6
  "author": "Sudharsan Selvaraj",