@garretapp/sdk 0.1.0 → 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.
- package/dist/{chunk-ZJYHRC5C.js → chunk-YBYF7JQS.js} +4 -0
- package/dist/{platform-DnI7gJTx.d.cts → platform-DjRN9xTv.d.cts} +4 -0
- package/dist/{platform-CZHtdUK0.d.ts → platform-K2c4rKaG.d.ts} +4 -0
- package/dist/react.cjs +13 -2
- package/dist/react.d.cts +7 -4
- package/dist/react.d.ts +7 -4
- package/dist/react.js +10 -4
- package/dist/ui.cjs +4 -0
- package/dist/ui.d.cts +1 -1
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +1 -1
- package/package.json +1 -1
|
@@ -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: () => {
|
|
@@ -236,10 +240,10 @@ function getGarret() {
|
|
|
236
240
|
};
|
|
237
241
|
}
|
|
238
242
|
function EmptyState({ children }) {
|
|
239
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gx-empty", children });
|
|
243
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gx-empty", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gx-empty-msg", children }) });
|
|
240
244
|
}
|
|
241
245
|
function ErrorState({ children }) {
|
|
242
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gx-error", children });
|
|
246
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gx-error", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gx-empty-msg", children }) });
|
|
243
247
|
}
|
|
244
248
|
function Scroll({ children }) {
|
|
245
249
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "gx-scroll", children });
|
|
@@ -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-
|
|
3
|
-
export { S as SurfaceApi, a as SurfaceHandle, b as SurfaceOpenOptions, W as WindowControls } from './platform-
|
|
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
|
|
|
@@ -11,7 +11,8 @@ import './protocol-Do0BJdeE.cjs';
|
|
|
11
11
|
* Import from `@garretapp/sdk/react`.
|
|
12
12
|
*/
|
|
13
13
|
type Tone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger';
|
|
14
|
-
/** Centered muted message (supports rich children).
|
|
14
|
+
/** Centered muted message (supports rich children). The inner wrapper keeps the message a single flow
|
|
15
|
+
* so it centers as one block (rather than each inline piece becoming its own flex/grid line). */
|
|
15
16
|
declare function EmptyState({ children }: {
|
|
16
17
|
children: ReactNode;
|
|
17
18
|
}): JSX.Element;
|
|
@@ -111,6 +112,8 @@ declare function useConfig<T>(): [T, (patch: Partial<T>) => void, (value: T) =>
|
|
|
111
112
|
declare function useActive(): boolean;
|
|
112
113
|
/** Run `cb` when the host (frame ⋯→Settings) asks this widget to reveal its own config UI. */
|
|
113
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;
|
|
114
117
|
/** Per-placement config backed by `g.instanceStorage` (isolated per widget instance). Loads once the
|
|
115
118
|
* runtime binds (calls before bind reject); `set` writes through to storage + state. `loaded` gates
|
|
116
119
|
* the first data fetch so you don't fetch with defaults before the saved config arrives. */
|
|
@@ -125,4 +128,4 @@ declare function useInstanceConfig<T extends Record<string, unknown>>(defaults:
|
|
|
125
128
|
* time), so this re-renders when the runtime binds. The `T` is an unchecked cast — validate it yourself. */
|
|
126
129
|
declare function useProps<T = Record<string, unknown>>(): T;
|
|
127
130
|
|
|
128
|
-
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-
|
|
3
|
-
export { S as SurfaceApi, a as SurfaceHandle, b as SurfaceOpenOptions, W as WindowControls } from './platform-
|
|
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
|
|
|
@@ -11,7 +11,8 @@ import './protocol-Do0BJdeE.js';
|
|
|
11
11
|
* Import from `@garretapp/sdk/react`.
|
|
12
12
|
*/
|
|
13
13
|
type Tone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger';
|
|
14
|
-
/** Centered muted message (supports rich children).
|
|
14
|
+
/** Centered muted message (supports rich children). The inner wrapper keeps the message a single flow
|
|
15
|
+
* so it centers as one block (rather than each inline piece becoming its own flex/grid line). */
|
|
15
16
|
declare function EmptyState({ children }: {
|
|
16
17
|
children: ReactNode;
|
|
17
18
|
}): JSX.Element;
|
|
@@ -111,6 +112,8 @@ declare function useConfig<T>(): [T, (patch: Partial<T>) => void, (value: T) =>
|
|
|
111
112
|
declare function useActive(): boolean;
|
|
112
113
|
/** Run `cb` when the host (frame ⋯→Settings) asks this widget to reveal its own config UI. */
|
|
113
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;
|
|
114
117
|
/** Per-placement config backed by `g.instanceStorage` (isolated per widget instance). Loads once the
|
|
115
118
|
* runtime binds (calls before bind reject); `set` writes through to storage + state. `loaded` gates
|
|
116
119
|
* the first data fetch so you don't fetch with defaults before the saved config arrives. */
|
|
@@ -125,4 +128,4 @@ declare function useInstanceConfig<T extends Record<string, unknown>>(defaults:
|
|
|
125
128
|
* time), so this re-renders when the runtime binds. The `T` is an unchecked cast — validate it yourself. */
|
|
126
129
|
declare function useProps<T = Record<string, unknown>>(): T;
|
|
127
130
|
|
|
128
|
-
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,14 +1,14 @@
|
|
|
1
|
-
import { getGarret, getRuntime, getHostTransport, createHostClient, getInstanceId } from './chunk-
|
|
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';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
7
|
function EmptyState({ children }) {
|
|
8
|
-
return /* @__PURE__ */ jsx("div", { className: "gx-empty", children });
|
|
8
|
+
return /* @__PURE__ */ jsx("div", { className: "gx-empty", children: /* @__PURE__ */ jsx("div", { className: "gx-empty-msg", children }) });
|
|
9
9
|
}
|
|
10
10
|
function ErrorState({ children }) {
|
|
11
|
-
return /* @__PURE__ */ jsx("div", { className: "gx-error", children });
|
|
11
|
+
return /* @__PURE__ */ jsx("div", { className: "gx-error", children: /* @__PURE__ */ jsx("div", { className: "gx-empty-msg", children }) });
|
|
12
12
|
}
|
|
13
13
|
function Scroll({ children }) {
|
|
14
14
|
return /* @__PURE__ */ jsx("div", { className: "gx-scroll", children });
|
|
@@ -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
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-
|
|
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-
|
|
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-
|
|
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.
|
|
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",
|