@capybara-hq/plugin-client 0.1.0-rc.6 → 0.1.0-rc.7
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/context.d.ts +5 -1
- package/dist/hooks.d.ts +9 -1
- package/dist/hooks.js +12 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/testing/index.d.ts +5 -1
- package/dist/testing/index.js +2 -0
- package/dist/types.d.ts +11 -2
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentSlotId } from "./slots.generated.js";
|
|
2
|
-
import type { CapybaraEvent, ClientRole, ClientStorage, JsonValue, RunState, SignIn, UiView } from "./types.js";
|
|
2
|
+
import type { CapybaraEvent, ClientRole, ClientStorage, JsonValue, RunState, SignIn, SizeClass, UiView, ViewportSegment } from "./types.js";
|
|
3
3
|
/** Thrown by a hook used outside a component the host rendered. */
|
|
4
4
|
export declare class PluginClientContextError extends Error {
|
|
5
5
|
constructor(hook: string);
|
|
@@ -37,6 +37,10 @@ export interface HostApi {
|
|
|
37
37
|
storage: ClientStorage;
|
|
38
38
|
assetUrl(path: string): string;
|
|
39
39
|
signIn: SignIn;
|
|
40
|
+
/** The window's size class; null while the host does not know it (server render). */
|
|
41
|
+
sizeClass: SizeClass | null;
|
|
42
|
+
/** The two segments of a window spanning two screens, else null. */
|
|
43
|
+
viewportSegments: ViewportSegment[] | null;
|
|
40
44
|
/** Subscribes to client events; returns the unsubscribe function. */
|
|
41
45
|
subscribe(handler: (e: CapybaraEvent) => void): () => void;
|
|
42
46
|
}
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ActionFn, type ViewState } from "./context.js";
|
|
2
|
-
import type { CapybaraEvent, CapybaraEventType, ClientStorage, RunState, SignIn } from "./types.js";
|
|
2
|
+
import type { CapybaraEvent, CapybaraEventType, ClientStorage, RunState, SignIn, SizeClass, ViewportSegment } from "./types.js";
|
|
3
3
|
/** The view the extension registered under this component's id, refreshed like any view. */
|
|
4
4
|
export declare function useView(): ViewState;
|
|
5
5
|
/** Calls the `ctx.ui.action` registered under this component's id. */
|
|
@@ -37,3 +37,11 @@ export declare function useAssetUrl(): (path: string) => string;
|
|
|
37
37
|
* next one (once per sign-in: compare it with the id stored when the thing last ran).
|
|
38
38
|
*/
|
|
39
39
|
export declare function useSignIn(): SignIn;
|
|
40
|
+
/**
|
|
41
|
+
* The window's size class (`compact` below 600 CSS px, `medium` up to 840, else `expanded`),
|
|
42
|
+
* live as the window changes; `null` until the host knows it. Layout that can be expressed in CSS
|
|
43
|
+
* should be: this is for behavior that cannot.
|
|
44
|
+
*/
|
|
45
|
+
export declare function useSizeClass(): SizeClass | null;
|
|
46
|
+
/** The two screens of a window that spans a folded or dual-screen display, else `null`. */
|
|
47
|
+
export declare function useViewportSegments(): ViewportSegment[] | null;
|
package/dist/hooks.js
CHANGED
|
@@ -61,3 +61,15 @@ export function useAssetUrl() {
|
|
|
61
61
|
export function useSignIn() {
|
|
62
62
|
return useHost("useSignIn").api.signIn;
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* The window's size class (`compact` below 600 CSS px, `medium` up to 840, else `expanded`),
|
|
66
|
+
* live as the window changes; `null` until the host knows it. Layout that can be expressed in CSS
|
|
67
|
+
* should be: this is for behavior that cannot.
|
|
68
|
+
*/
|
|
69
|
+
export function useSizeClass() {
|
|
70
|
+
return useHost("useSizeClass").api.sizeClass;
|
|
71
|
+
}
|
|
72
|
+
/** The two screens of a window that spans a folded or dual-screen display, else `null`. */
|
|
73
|
+
export function useViewportSegments() {
|
|
74
|
+
return useHost("useViewportSegments").api.viewportSegments;
|
|
75
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { type ActionFn, PluginClientContextError, type ViewState } from "./context.js";
|
|
2
2
|
export { CLIENT_API_VERSION, type ClientComponent, type ClientExtension, type ClientExtensionDefinition, type ComponentProps, defineClientExtension, defineComponent, } from "./define.js";
|
|
3
3
|
export { Badge, type BadgeProps, Button, type ButtonProps, Icon, type IconProps, Kbd, type KbdProps, KeyValue, type KeyValueProps, Logo, type LogoProps, PropertySection, type PropertySectionProps, Select, type SelectOption, type SelectProps, Spinner, type SpinnerProps, Stack, type StackProps, Text, type TextProps, Tooltip, type TooltipProps, ViewBlocks, type ViewBlocksProps, } from "./design.js";
|
|
4
|
-
export { useAccess, useAction, useAssetUrl, useCapybaraEvents, useClientStorage, useLocale, usePrefersReducedMotion, useRunState, useSignIn, useTheme, useView, } from "./hooks.js";
|
|
4
|
+
export { useAccess, useAction, useAssetUrl, useCapybaraEvents, useClientStorage, useLocale, usePrefersReducedMotion, useRunState, useSignIn, useSizeClass, useTheme, useView, useViewportSegments, } from "./hooks.js";
|
|
5
5
|
export type { ComponentSlotId } from "./slots.generated.js";
|
|
6
|
-
export type { BaseComponentProps, CapybaraEvent, CapybaraEventOf, CapybaraEventType, ClientApi, ClientRole, ClientStorage, EventBase, JsonValue, RunState, SignIn, SlotComponentProps, UiView, } from "./types.js";
|
|
6
|
+
export type { BaseComponentProps, CapybaraEvent, CapybaraEventOf, CapybaraEventType, ClientApi, ClientRole, ClientStorage, EventBase, JsonValue, RunState, SignIn, SizeClass, SlotComponentProps, UiView, ViewportSegment, } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { PluginClientContextError } from "./context.js";
|
|
2
2
|
export { CLIENT_API_VERSION, defineClientExtension, defineComponent, } from "./define.js";
|
|
3
3
|
export { Badge, Button, Icon, Kbd, KeyValue, Logo, PropertySection, Select, Spinner, Stack, Text, Tooltip, ViewBlocks, } from "./design.js";
|
|
4
|
-
export { useAccess, useAction, useAssetUrl, useCapybaraEvents, useClientStorage, useLocale, usePrefersReducedMotion, useRunState, useSignIn, useTheme, useView, } from "./hooks.js";
|
|
4
|
+
export { useAccess, useAction, useAssetUrl, useCapybaraEvents, useClientStorage, useLocale, usePrefersReducedMotion, useRunState, useSignIn, useSizeClass, useTheme, useView, useViewportSegments, } from "./hooks.js";
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type ReactElement } from "react";
|
|
|
2
2
|
import { type HostApi } from "../context.js";
|
|
3
3
|
import type { ClientExtension } from "../define.js";
|
|
4
4
|
import type { ComponentSlotId } from "../slots.generated.js";
|
|
5
|
-
import type { CapybaraEvent, ClientRole, RunState, UiView } from "../types.js";
|
|
5
|
+
import type { CapybaraEvent, ClientRole, RunState, SizeClass, UiView, ViewportSegment } from "../types.js";
|
|
6
6
|
export interface FakeHostOptions {
|
|
7
7
|
slot: ComponentSlotId;
|
|
8
8
|
/** The slot's render args (`conversationId`, `agentId`, ...). */
|
|
@@ -22,6 +22,10 @@ export interface FakeHostOptions {
|
|
|
22
22
|
reducedMotion?: boolean;
|
|
23
23
|
/** The id `useSignIn()` and the listeners' `api.signIn` carry; default "test-sign-in". */
|
|
24
24
|
signInId?: string;
|
|
25
|
+
/** What `useSizeClass()` returns; default null. */
|
|
26
|
+
sizeClass?: SizeClass | null;
|
|
27
|
+
/** What `useViewportSegments()` returns; default null. */
|
|
28
|
+
viewportSegments?: ViewportSegment[] | null;
|
|
25
29
|
}
|
|
26
30
|
export interface FakeHost {
|
|
27
31
|
emit(e: CapybaraEvent): void;
|
package/dist/testing/index.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -17,6 +17,15 @@ export interface UiView {
|
|
|
17
17
|
/** Only a component's view carries data (at most 32 768 bytes of JSON). */
|
|
18
18
|
data?: JsonValue;
|
|
19
19
|
}
|
|
20
|
+
/** The window's size class, by width only (mobile layout spec §3). */
|
|
21
|
+
export type SizeClass = "compact" | "medium" | "expanded";
|
|
22
|
+
/** One screen of a window that spans two (folded or dual-screen display), in CSS px. */
|
|
23
|
+
export interface ViewportSegment {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
}
|
|
20
29
|
export type RunState = "idle" | "running" | "waiting" | "failed";
|
|
21
30
|
export type ClientRole = "owner" | "admin" | "member" | "guest" | "superAdmin";
|
|
22
31
|
/** localStorage / sessionStorage under the prefix "cap-ext:<plugin>:"; never throws. */
|
|
@@ -106,12 +115,12 @@ export interface SlotComponentProps {
|
|
|
106
115
|
"org.settings.section": Record<string, never>;
|
|
107
116
|
"platform.page": Record<string, never>;
|
|
108
117
|
"shell.brand": {
|
|
109
|
-
/** The built-in brand (the Logo, its wordmark only in the full sidebar
|
|
118
|
+
/** The built-in brand (the Logo, its wordmark only in the full sidebar). */
|
|
110
119
|
builtin: ReactNode;
|
|
111
120
|
/** The sidebar is the rail. */
|
|
112
121
|
collapsed: boolean;
|
|
113
122
|
/** The sidebar panel this node is drawn in; the host renders the brand once per drawn panel. */
|
|
114
|
-
panel: "full" | "rail"
|
|
123
|
+
panel: "full" | "rail";
|
|
115
124
|
};
|
|
116
125
|
"shell.overlay": Record<string, never>;
|
|
117
126
|
"conversation.empty": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/plugin-client",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.7",
|
|
4
4
|
"description": "Capybara plugin client SDK: the types, hooks and design re-exports a plugin's client entry is written against",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|