@get-bb/plugin-sdk 0.5.15 → 0.5.16

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/README.md CHANGED
@@ -178,13 +178,15 @@ slot.lifecycle.unmount();
178
178
  await scripts.lifecycle.dispose();
179
179
  ```
180
180
 
181
- `loadPluginApp` installs the runtime before a thunk import and validates all
182
- registrations. `mountPluginContentScripts` mirrors the host's ordered mount,
181
+ `loadPluginApp` installs the runtime and validates all registrations; pass the
182
+ imported module or a thunk. `@get-bb/plugin-sdk/app` exports look the runtime
183
+ up when they are called or rendered, so a static import of `app.tsx` or of
184
+ components works too. `mountPluginContentScripts` mirrors the host's ordered mount,
183
185
  rollback, independent per-window signal, and exact-once disposal. `renderSlot` supplies
184
186
  RPC, realtime, settings, navigation, context, and scoped composer behavior,
185
187
  then returns Testing Library queries plus the same behavior/inspection/lifecycle
186
- split. Use a setup-file `installTestPluginRuntime()` only when a static app
187
- import is unavoidable.
188
+ split; it installs the runtime too. Call `installTestPluginRuntime()` yourself
189
+ only when a test renders plugin components without `renderSlot`.
188
190
 
189
191
  ## Fidelity boundaries
190
192
 
@@ -275,6 +275,7 @@ declare const appKeybindingOverridesSchema: z$1.ZodArray<z$1.ZodObject<{
275
275
  "thread.previous": "thread.previous";
276
276
  "thread.rename": "thread.rename";
277
277
  "thread.search": "thread.search";
278
+ "window.find": "window.find";
278
279
  "window.new": "window.new";
279
280
  "workspace.openPreferred": "workspace.openPreferred";
280
281
  }>, z$1.ZodTemplateLiteral<`plugin:${string}/${string}`>]>;
@@ -9964,6 +9965,7 @@ declare const systemConfigResponseSchema: z$1.ZodObject<{
9964
9965
  "thread.previous": "thread.previous";
9965
9966
  "thread.rename": "thread.rename";
9966
9967
  "thread.search": "thread.search";
9968
+ "window.find": "window.find";
9967
9969
  "window.new": "window.new";
9968
9970
  "workspace.openPreferred": "workspace.openPreferred";
9969
9971
  }>, z$1.ZodTemplateLiteral<`plugin:${string}/${string}`>]>;
@@ -10107,6 +10109,7 @@ declare const systemConfigResponseSchema: z$1.ZodObject<{
10107
10109
  "thread.previous": "thread.previous";
10108
10110
  "thread.rename": "thread.rename";
10109
10111
  "thread.search": "thread.search";
10112
+ "window.find": "window.find";
10110
10113
  "window.new": "window.new";
10111
10114
  "workspace.openPreferred": "workspace.openPreferred";
10112
10115
  }>, z$1.ZodTemplateLiteral<`plugin:${string}/${string}`>]>;
@@ -10190,6 +10193,7 @@ declare const systemConfigResponseSchema: z$1.ZodObject<{
10190
10193
  "thread.previous": "thread.previous";
10191
10194
  "thread.rename": "thread.rename";
10192
10195
  "thread.search": "thread.search";
10196
+ "window.find": "window.find";
10193
10197
  "window.new": "window.new";
10194
10198
  "workspace.openPreferred": "workspace.openPreferred";
10195
10199
  }>, z$1.ZodTemplateLiteral<`plugin:${string}/${string}`>]>;
@@ -17772,7 +17776,7 @@ interface PluginSidebarThreadActions {
17772
17776
  setRead(threadId: string, read: boolean): Promise<void>;
17773
17777
  /** Silent rename — no dialog. For inline editing in your own row. */
17774
17778
  rename(threadId: string, title: string): Promise<void>;
17775
- /** Archives the thread AND its children, closing any panes showing them. */
17779
+ /** Opens bb's confirmation before archiving the thread and its children. */
17776
17780
  archive(threadId: string): void;
17777
17781
  /**
17778
17782
  * Opens bb's delete confirmation, which counts child threads first. Deletion
@@ -19355,6 +19359,15 @@ interface PluginSdkApp {
19355
19359
  useRealtimeConnectionState(): PluginRealtimeConnectionState;
19356
19360
  useSettings(): PluginSettingsState;
19357
19361
  useBbContext(): BbContext;
19362
+ /**
19363
+ * The id of the plugin that owns the calling component: the same id
19364
+ * `bb.pluginId` reports on the server, derived from the package name. Key
19365
+ * state the plugin keeps outside bb's per-plugin storage with it, such as
19366
+ * localStorage entries and log prefixes, so a copy of the plugin published
19367
+ * under another name does not collide with the original. Experimental: see
19368
+ * docs/api_to_audit.md.
19369
+ */
19370
+ experimental_usePluginId(): string;
19358
19371
  useBbNavigate(): BbNavigate;
19359
19372
  /** Select one of this plugin's eligible fixed tabs on the current surface. */
19360
19373
  experimental_useAppPanel(): ExperimentalAppPanel;
@@ -19585,7 +19598,7 @@ interface PluginSdkApp {
19585
19598
 
19586
19599
  declare const experimental_Icon: react.ComponentType<ExperimentalIconProps>;
19587
19600
  declare const experimental_ProviderIcon: react.ComponentType<ExperimentalProviderIconProps>;
19588
- declare const definePluginApp: (setup: PluginAppSetup) => PluginAppDefinition;
19601
+ declare const definePluginApp: PluginSdkApp["definePluginApp"];
19589
19602
  declare const ThreadChat: react.ComponentType<ThreadChatProps>;
19590
19603
  declare const Markdown: react.ComponentType<MarkdownProps>;
19591
19604
  declare const experimental_FileLink: react.ComponentType<ExperimentalFileLinkProps>;
@@ -19603,6 +19616,7 @@ declare const useRealtime: (channel: string, handler: (payload: unknown) => void
19603
19616
  declare const useRealtimeConnectionState: () => PluginRealtimeConnectionState;
19604
19617
  declare const useSettings: () => PluginSettingsState;
19605
19618
  declare const useBbContext: () => BbContext;
19619
+ declare const experimental_usePluginId: () => string;
19606
19620
  declare const useBbNavigate: () => BbNavigate;
19607
19621
  declare const experimental_useAppPanel: () => ExperimentalAppPanel;
19608
19622
  declare const experimental_useFixedTabTarget: <Target extends JsonValue$1>(tab: ExperimentalPluginFixedTabReference<Target>) => ExperimentalFixedTabTargetState<Target> | null;
@@ -19629,5 +19643,5 @@ declare const useSdk: () => PluginBrowserBbSdk;
19629
19643
  declare const experimental_useProviders: () => PluginProvidersState;
19630
19644
  declare const experimental_useCodeTheme: () => PluginCodeThemeState;
19631
19645
 
19632
- export { Markdown, ThreadChat, ThreadTitle, UrlLink, definePluginApp, experimental_BranchPicker, experimental_Diff, experimental_FileLink, experimental_Icon, experimental_NewThreadComposer, experimental_PermissionModePicker, experimental_ProviderIcon, experimental_ProviderModelPicker, experimental_SidebarNavigationIcon, experimental_SourceCode, experimental_useAppPanel, experimental_useBranches, experimental_useCheckoutState, experimental_useCodeTheme, experimental_useFixedTabTarget, experimental_useProviders, experimental_useSidebarNavigation, experimental_useSidebarNavigationSplit, experimental_useSidebarThreadActions, experimental_useSidebarThreadPullRequest, experimental_useSidebarThreadSplit, experimental_useSidebarThreads, useBbContext, useBbNavigate, useComposer, useComposerView, useEnvironmentProviders, useRealtime, useRealtimeConnectionState, useRpc, useSdk, useSettings, useSidebarSplitLayout, useSidebarThreadDraft, useSidebarThreadDraftIds, useSidebarThreadRowStatus, useSidebarThreadRowStatuses, useSidebarThreadShortcut };
19646
+ export { Markdown, ThreadChat, ThreadTitle, UrlLink, definePluginApp, experimental_BranchPicker, experimental_Diff, experimental_FileLink, experimental_Icon, experimental_NewThreadComposer, experimental_PermissionModePicker, experimental_ProviderIcon, experimental_ProviderModelPicker, experimental_SidebarNavigationIcon, experimental_SourceCode, experimental_useAppPanel, experimental_useBranches, experimental_useCheckoutState, experimental_useCodeTheme, experimental_useFixedTabTarget, experimental_usePluginId, experimental_useProviders, experimental_useSidebarNavigation, experimental_useSidebarNavigationSplit, experimental_useSidebarThreadActions, experimental_useSidebarThreadPullRequest, experimental_useSidebarThreadSplit, experimental_useSidebarThreads, useBbContext, useBbNavigate, useComposer, useComposerView, useEnvironmentProviders, useRealtime, useRealtimeConnectionState, useRpc, useSdk, useSettings, useSidebarSplitLayout, useSidebarThreadDraft, useSidebarThreadDraftIds, useSidebarThreadRowStatus, useSidebarThreadRowStatuses, useSidebarThreadShortcut };
19633
19647
  export type { BbContext, BbNavigate, BranchPickerProps, BranchesState, CheckoutState, CodeOverflowMode, ComposerCustomization, ComposerPlusMenuItem, ComposerRichTextSpec, ComposerStructuredDraft, ComposerView, DiffProps, DiffViewMode, ExperimentalAppIcons, ExperimentalAppOverlayProps, ExperimentalAppOverlayRegistration, ExperimentalAppPanel, ExperimentalAppPanelSurface, ExperimentalComposerSelection, ExperimentalComposerSubmitOptions, ExperimentalDiffFileContent, ExperimentalDiffFullFileContents, ExperimentalFileLinkProps, ExperimentalFileLocation, ExperimentalFileOpenOptions, ExperimentalFixedTabTargetContract, ExperimentalFixedTabTargetState, ExperimentalIconProps, ExperimentalIconRegistration, ExperimentalLiveFileTarget, ExperimentalOpenFixedTabOptions, ExperimentalPermissionModePickerProps, ExperimentalPluginBrowserPage, ExperimentalPluginBrowserPageEvaluateOptions, ExperimentalPluginBrowserPageWorld, ExperimentalPluginBrowserToolbarActionProps, ExperimentalPluginBrowserToolbarActionRegistration, ExperimentalPluginFixedTabReference, ExperimentalProviderIconProps, ExperimentalProviderModelPickerProps, ExperimentalProviderModelPickerRouting, ExperimentalProviderModelPickerValue, ExperimentalSidebarFooter, ExperimentalSidebarFooterActionContext, ExperimentalSidebarFooterActionRegistration, ExperimentalSidebarFooterDisclosureController, ExperimentalSidebarFooterDisclosureProps, ExperimentalSidebarFooterDisclosureRegistration, ExperimentalSidebarFooterItemBase, ExperimentalSidebarFooterItemRegistration, ExperimentalSidebarHeaderProps, ExperimentalSidebarHeaderRegistration, ExperimentalSidebarNavigationAction, ExperimentalSidebarNavigationActions, ExperimentalSidebarNavigationActivationOptions, ExperimentalSidebarNavigationIcon, ExperimentalSidebarNavigationIconProps, ExperimentalSidebarNavigationItem, ExperimentalSidebarNavigationProps, ExperimentalSidebarNavigationRegistration, ExperimentalSidebarNavigationShortcut, ExperimentalSidebarNavigationSplit, ExperimentalSidebarNavigationSplitOptions, ExperimentalSidebarNavigationState, JsonValue$1 as JsonValue, MarkdownProps, NewThreadComposerProps, NewThreadRequest, PluginAppBuilder, PluginAppCommands, PluginAppComposer, PluginAppContentScripts, PluginAppDefinition, PluginAppSetup, PluginAppSlots, PluginBoundThreadsArea, PluginBrowserBbSdk, PluginCodeThemeData, PluginCodeThemeState, PluginCodeThemeTokenRule, PluginCommandContext, PluginCommandRegistration, PluginCommandShortcut, PluginComposerApi, PluginComposerMention, PluginComposerScope, PluginComposerTextEffect, PluginComposerThreadRowStatus, PluginContentScriptContext, PluginContentScriptDisposer, PluginContentScriptRegistration, PluginDiffRendererProps, PluginDiffRendererRegistration, PluginEnvironmentProvider, PluginEnvironmentProviderInputsChange, PluginEnvironmentProviderInputsProps, PluginEnvironmentProviderInputsRegistration, PluginEnvironmentProvidersState, PluginFileOpenerProps, PluginFileOpenerRegistration, PluginFileOpenerSource, PluginFixedTabDeclaration, PluginFixedTabRegistration, PluginHomepageSectionProps, PluginHomepageSectionRegistration, PluginMachineProviderInputsChange, PluginMachineProviderInputsProps, PluginMachineProviderInputsRegistration, PluginMessageActionContext, PluginMessageActionRegistration, PluginMessageDirectiveMessage, PluginMessageDirectiveOpenWorkspaceFile, PluginMessageDirectiveProps, PluginMessageDirectiveRegistration, PluginNavPanelProps, PluginNavPanelRegistration, PluginNewThreadPanelActionContext, PluginNewThreadPanelActionRegistration, PluginNewThreadPanelProps, PluginPanelActionOpenOptions, PluginPendingInteractionProps, PluginPendingInteractionRegistration, PluginPendingInteractionView, PluginProviderIconRegistration, PluginProvidersState, PluginRealtimeConnectionState, PluginRpcCallArgs, PluginRpcClient, PluginRpcContract, PluginRpcError, PluginRpcErrorCode, PluginRpcHandlers, PluginRpcIssuePathSegment, PluginRpcMethodContract, PluginRpcResult, PluginRpcValidationIssue, PluginSdkApp, PluginSettingsSectionProps, PluginSettingsSectionRegistration, PluginSettingsState, PluginSidebarFooterActionContext, PluginSidebarFooterActionProps, PluginSidebarFooterActionRegistration, PluginSidebarProject, PluginSidebarPullRequest, PluginSidebarSection, PluginSidebarSplitLayout, PluginSidebarSplitPane, PluginSidebarThread, PluginSidebarThreadActions, PluginSidebarThreadActivity, PluginSidebarThreadDraftState, PluginSidebarThreadIndicator, PluginSidebarThreadPullRequestState, PluginSidebarThreadRowStatus, PluginSidebarThreadShortcut, PluginSidebarThreadSplit, PluginSidebarThreadsState, PluginSourceCodeRendererProps, PluginSourceCodeRendererRegistration, PluginTargetedPanelActionOpenOptions, PluginThreadHeaderActionProps, PluginThreadHeaderActionRegistration, PluginThreadListProps, PluginThreadListRegistration, PluginThreadPanelActionContext, PluginThreadPanelActionRegistration, PluginThreadPanelProps, PluginThreadTitleProps, PluginTimelineRendererProps, PluginTimelineRendererRegistration, PluginTimelineRendererRow, PluginTimelineRowPresentation, PluginTimelineRowStatus, ReadonlyJsonValue, SourceCodeLineRange, SourceCodeProps, StandardSchemaV1, StandardSchemaV1InferInput, StandardSchemaV1InferOutput, StandardSchemaV1Issue, StandardSchemaV1Result, ThreadChatMessageAction, ThreadChatMessageReference, ThreadChatProps, UrlLinkProps, UseBranchesArgs, UseCheckoutStateArgs };
@@ -35,11 +35,11 @@ type CollectedPluginProviderIconRegistration = Omit<PluginProviderIconRegistrati
35
35
  *
36
36
  * - {@link installTestPluginRuntime} fills `globalThis.__bbPluginRuntime.
37
37
  * pluginSdkApp` with a test implementation of the `@get-bb/plugin-sdk/app`
38
- * surface (the same seam `bb plugin build` shims to the real app). It must
39
- * run BEFORE the plugin's `app.tsx` module evaluates, because that module
40
- * binds the runtime at import time — so import `app.tsx` through
41
- * {@link loadPluginApp}'s thunk form, or call the installer from a vitest
42
- * setup file when you prefer static imports.
38
+ * surface (the same seam `bb plugin build` shims to the real app). The
39
+ * `@get-bb/plugin-sdk/app` exports look the runtime up when they are called
40
+ * or rendered, so import order does not matter: install the runtime any time
41
+ * before the first hook runs ({@link loadPluginApp} and {@link renderSlot}
42
+ * install it for you).
43
43
  * - {@link loadPluginApp} runs the definition's setup against a validating
44
44
  * collector (ported from the BB app's interpreter, same error messages)
45
45
  * and returns the typed slot registrations.
@@ -161,9 +161,11 @@ interface SidebarNavigationCall {
161
161
  openInSplit?: boolean;
162
162
  }
163
163
  /**
164
- * Install the test runtime at `globalThis.__bbPluginRuntime.pluginSdkApp`.
165
- * Idempotent per module instance; must run before the plugin's `app.tsx`
166
- * (and therefore `@get-bb/plugin-sdk/app`) is imported.
164
+ * Install the test runtime at `globalThis.__bbPluginRuntime.pluginSdkApp`,
165
+ * plus the React the `@get-bb/plugin-sdk/app` components render through.
166
+ * Idempotent per module instance. Call it before the first SDK hook runs or
167
+ * SDK component renders; when the plugin's modules are imported does not
168
+ * matter.
167
169
  */
168
170
  declare function installTestPluginRuntime(): void;
169
171
  interface CapturedPluginApp {
@@ -200,9 +202,8 @@ type PluginAppModule = {
200
202
  type PluginAppSource = PluginAppDefinition | PluginAppModule | (() => Promise<PluginAppDefinition | PluginAppModule>);
201
203
  /**
202
204
  * Install the test runtime, resolve the plugin app definition, and capture
203
- * its slot registrations. Pass a thunk (`() => import("../app.tsx")`) so the
204
- * plugin module evaluates after the runtime is installed — a static import
205
- * would bind `definePluginApp` before the installer runs.
205
+ * its slot registrations. Pass the imported module, its default export, or a
206
+ * thunk (`() => import("../app.tsx")`).
206
207
  */
207
208
  declare function loadPluginApp(source: PluginAppSource): Promise<CapturedPluginApp>;
208
209
  interface ContentScriptTestMountOptions {
@@ -256,6 +257,8 @@ interface RenderSlotOptions<Contract extends PluginRpcContract = PluginRpcContra
256
257
  projectId?: string | null;
257
258
  threadId?: string | null;
258
259
  };
260
+ /** `experimental_usePluginId()` value; defaults to `test-plugin`. */
261
+ pluginId?: string;
259
262
  /** Initial `useRealtimeConnectionState()` value; defaults to `connected`. */
260
263
  realtimeConnectionState?: PluginRealtimeConnectionState;
261
264
  /** Initial state for this render's isolated composer scope and view. */
@@ -224,6 +224,7 @@ declare const appKeybindingOverridesSchema: z$1.ZodArray<z$1.ZodObject<{
224
224
  "thread.previous": "thread.previous";
225
225
  "thread.rename": "thread.rename";
226
226
  "thread.search": "thread.search";
227
+ "window.find": "window.find";
227
228
  "window.new": "window.new";
228
229
  "workspace.openPreferred": "workspace.openPreferred";
229
230
  }>, z$1.ZodTemplateLiteral<`plugin:${string}/${string}`>]>;
@@ -10015,6 +10016,7 @@ declare const systemConfigResponseSchema: z$1.ZodObject<{
10015
10016
  "thread.previous": "thread.previous";
10016
10017
  "thread.rename": "thread.rename";
10017
10018
  "thread.search": "thread.search";
10019
+ "window.find": "window.find";
10018
10020
  "window.new": "window.new";
10019
10021
  "workspace.openPreferred": "workspace.openPreferred";
10020
10022
  }>, z$1.ZodTemplateLiteral<`plugin:${string}/${string}`>]>;
@@ -10158,6 +10160,7 @@ declare const systemConfigResponseSchema: z$1.ZodObject<{
10158
10160
  "thread.previous": "thread.previous";
10159
10161
  "thread.rename": "thread.rename";
10160
10162
  "thread.search": "thread.search";
10163
+ "window.find": "window.find";
10161
10164
  "window.new": "window.new";
10162
10165
  "workspace.openPreferred": "workspace.openPreferred";
10163
10166
  }>, z$1.ZodTemplateLiteral<`plugin:${string}/${string}`>]>;
@@ -10241,6 +10244,7 @@ declare const systemConfigResponseSchema: z$1.ZodObject<{
10241
10244
  "thread.previous": "thread.previous";
10242
10245
  "thread.rename": "thread.rename";
10243
10246
  "thread.search": "thread.search";
10247
+ "window.find": "window.find";
10244
10248
  "window.new": "window.new";
10245
10249
  "workspace.openPreferred": "workspace.openPreferred";
10246
10250
  }>, z$1.ZodTemplateLiteral<`plugin:${string}/${string}`>]>;
@@ -17924,7 +17928,7 @@ interface PluginSidebarThreadActions {
17924
17928
  setRead(threadId: string, read: boolean): Promise<void>;
17925
17929
  /** Silent rename — no dialog. For inline editing in your own row. */
17926
17930
  rename(threadId: string, title: string): Promise<void>;
17927
- /** Archives the thread AND its children, closing any panes showing them. */
17931
+ /** Opens bb's confirmation before archiving the thread and its children. */
17928
17932
  archive(threadId: string): void;
17929
17933
  /**
17930
17934
  * Opens bb's delete confirmation, which counts child threads first. Deletion
@@ -19507,6 +19511,15 @@ interface PluginSdkApp {
19507
19511
  useRealtimeConnectionState(): PluginRealtimeConnectionState;
19508
19512
  useSettings(): PluginSettingsState;
19509
19513
  useBbContext(): BbContext;
19514
+ /**
19515
+ * The id of the plugin that owns the calling component: the same id
19516
+ * `bb.pluginId` reports on the server, derived from the package name. Key
19517
+ * state the plugin keeps outside bb's per-plugin storage with it, such as
19518
+ * localStorage entries and log prefixes, so a copy of the plugin published
19519
+ * under another name does not collide with the original. Experimental: see
19520
+ * docs/api_to_audit.md.
19521
+ */
19522
+ experimental_usePluginId(): string;
19510
19523
  useBbNavigate(): BbNavigate;
19511
19524
  /** Select one of this plugin's eligible fixed tabs on the current surface. */
19512
19525
  experimental_useAppPanel(): ExperimentalAppPanel;
package/dist/app.js CHANGED
@@ -1,48 +1,139 @@
1
1
  // src/app.ts
2
- var runtime = globalThis.__bbPluginRuntime?.pluginSdkApp ?? {};
3
- var experimental_Icon = runtime.experimental_Icon;
4
- var experimental_ProviderIcon = runtime.experimental_ProviderIcon;
5
- var definePluginApp = runtime.definePluginApp;
6
- var ThreadChat = runtime.ThreadChat;
7
- var Markdown = runtime.Markdown;
8
- var experimental_FileLink = runtime.experimental_FileLink;
9
- var UrlLink = runtime.UrlLink;
10
- var experimental_NewThreadComposer = runtime.experimental_NewThreadComposer;
11
- var experimental_ProviderModelPicker = runtime.experimental_ProviderModelPicker;
12
- var experimental_PermissionModePicker = runtime.experimental_PermissionModePicker;
13
- var experimental_BranchPicker = runtime.experimental_BranchPicker;
14
- var experimental_useBranches = runtime.experimental_useBranches;
15
- var experimental_useCheckoutState = runtime.experimental_useCheckoutState;
16
- var experimental_SourceCode = runtime.experimental_SourceCode;
17
- var experimental_Diff = runtime.experimental_Diff;
18
- var useRpc = runtime.useRpc;
19
- var useRealtime = runtime.useRealtime;
20
- var useRealtimeConnectionState = runtime.useRealtimeConnectionState;
21
- var useSettings = runtime.useSettings;
22
- var useBbContext = runtime.useBbContext;
23
- var useBbNavigate = runtime.useBbNavigate;
24
- var experimental_useAppPanel = runtime.experimental_useAppPanel;
25
- var experimental_useFixedTabTarget = runtime.experimental_useFixedTabTarget;
26
- var useComposer = runtime.useComposer;
27
- var useComposerView = runtime.useComposerView;
28
- var experimental_useSidebarThreads = runtime.experimental_useSidebarThreads;
29
- var experimental_useSidebarThreadActions = runtime.experimental_useSidebarThreadActions;
30
- var experimental_useSidebarThreadPullRequest = runtime.experimental_useSidebarThreadPullRequest;
31
- var experimental_useSidebarThreadSplit = runtime.experimental_useSidebarThreadSplit;
32
- var experimental_useSidebarNavigation = runtime.experimental_useSidebarNavigation;
33
- var experimental_useSidebarNavigationSplit = runtime.experimental_useSidebarNavigationSplit;
34
- var experimental_SidebarNavigationIcon = runtime.experimental_SidebarNavigationIcon;
35
- var useSidebarThreadDraft = runtime.useSidebarThreadDraft;
36
- var useSidebarThreadDraftIds = runtime.useSidebarThreadDraftIds;
37
- var useSidebarThreadRowStatus = runtime.useSidebarThreadRowStatus;
38
- var useSidebarThreadRowStatuses = runtime.useSidebarThreadRowStatuses;
39
- var useSidebarSplitLayout = runtime.useSidebarSplitLayout;
40
- var useSidebarThreadShortcut = runtime.useSidebarThreadShortcut;
41
- var ThreadTitle = runtime.ThreadTitle;
42
- var useEnvironmentProviders = runtime.useEnvironmentProviders;
43
- var useSdk = runtime.useSdk;
44
- var experimental_useProviders = runtime.experimental_useProviders;
45
- var experimental_useCodeTheme = runtime.experimental_useCodeTheme;
2
+ function runtimeHost() {
3
+ return globalThis.__bbPluginRuntime;
4
+ }
5
+ function installedApp() {
6
+ return runtimeHost()?.pluginSdkApp;
7
+ }
8
+ function runtimeMember(name) {
9
+ const member = installedApp()?.[name];
10
+ if (member === void 0) {
11
+ throw new Error(
12
+ `@get-bb/plugin-sdk/app: ${name} needs the bb app's plugin runtime. In tests, call installTestPluginRuntime() from @get-bb/plugin-sdk/testing/app first.`
13
+ );
14
+ }
15
+ return member;
16
+ }
17
+ function runtimeFunction(name) {
18
+ const forward = (...args) => runtimeMember(name)(...args);
19
+ return forward;
20
+ }
21
+ function runtimeComponent(name) {
22
+ function RuntimeComponent(props) {
23
+ const react = runtimeHost()?.react;
24
+ if (react === void 0) {
25
+ throw new Error(
26
+ `@get-bb/plugin-sdk/app: ${name} needs React on the bb plugin runtime. In tests, call installTestPluginRuntime() from @get-bb/plugin-sdk/testing/app first.`
27
+ );
28
+ }
29
+ return react.createElement(runtimeMember(name), props);
30
+ }
31
+ RuntimeComponent.displayName = name;
32
+ return RuntimeComponent;
33
+ }
34
+ var experimental_Icon = runtimeComponent("experimental_Icon");
35
+ var experimental_ProviderIcon = runtimeComponent(
36
+ "experimental_ProviderIcon"
37
+ );
38
+ var definePluginApp = (setup) => {
39
+ const app = installedApp();
40
+ if (app?.definePluginApp !== void 0) return app.definePluginApp(setup);
41
+ if (typeof setup !== "function") {
42
+ throw new Error("definePluginApp expects a setup function");
43
+ }
44
+ return Object.freeze({ __bbPluginApp: true, setup });
45
+ };
46
+ var ThreadChat = runtimeComponent("ThreadChat");
47
+ var Markdown = runtimeComponent("Markdown");
48
+ var experimental_FileLink = runtimeComponent("experimental_FileLink");
49
+ var UrlLink = runtimeComponent("UrlLink");
50
+ var experimental_NewThreadComposer = runtimeComponent(
51
+ "experimental_NewThreadComposer"
52
+ );
53
+ var experimental_ProviderModelPicker = runtimeComponent(
54
+ "experimental_ProviderModelPicker"
55
+ );
56
+ var experimental_PermissionModePicker = runtimeComponent(
57
+ "experimental_PermissionModePicker"
58
+ );
59
+ var experimental_BranchPicker = runtimeComponent(
60
+ "experimental_BranchPicker"
61
+ );
62
+ var experimental_useBranches = runtimeFunction(
63
+ "experimental_useBranches"
64
+ );
65
+ var experimental_useCheckoutState = runtimeFunction(
66
+ "experimental_useCheckoutState"
67
+ );
68
+ var experimental_SourceCode = runtimeComponent(
69
+ "experimental_SourceCode"
70
+ );
71
+ var experimental_Diff = runtimeComponent("experimental_Diff");
72
+ var useRpc = runtimeFunction("useRpc");
73
+ var useRealtime = runtimeFunction("useRealtime");
74
+ var useRealtimeConnectionState = runtimeFunction(
75
+ "useRealtimeConnectionState"
76
+ );
77
+ var useSettings = runtimeFunction("useSettings");
78
+ var useBbContext = runtimeFunction("useBbContext");
79
+ var experimental_usePluginId = runtimeFunction(
80
+ "experimental_usePluginId"
81
+ );
82
+ var useBbNavigate = runtimeFunction("useBbNavigate");
83
+ var experimental_useAppPanel = runtimeFunction(
84
+ "experimental_useAppPanel"
85
+ );
86
+ var experimental_useFixedTabTarget = runtimeFunction(
87
+ "experimental_useFixedTabTarget"
88
+ );
89
+ var useComposer = runtimeFunction("useComposer");
90
+ var useComposerView = runtimeFunction("useComposerView");
91
+ var experimental_useSidebarThreads = runtimeFunction(
92
+ "experimental_useSidebarThreads"
93
+ );
94
+ var experimental_useSidebarThreadActions = runtimeFunction(
95
+ "experimental_useSidebarThreadActions"
96
+ );
97
+ var experimental_useSidebarThreadPullRequest = runtimeFunction(
98
+ "experimental_useSidebarThreadPullRequest"
99
+ );
100
+ var experimental_useSidebarThreadSplit = runtimeFunction(
101
+ "experimental_useSidebarThreadSplit"
102
+ );
103
+ var experimental_useSidebarNavigation = runtimeFunction(
104
+ "experimental_useSidebarNavigation"
105
+ );
106
+ var experimental_useSidebarNavigationSplit = runtimeFunction(
107
+ "experimental_useSidebarNavigationSplit"
108
+ );
109
+ var experimental_SidebarNavigationIcon = runtimeComponent(
110
+ "experimental_SidebarNavigationIcon"
111
+ );
112
+ var useSidebarThreadDraft = runtimeFunction("useSidebarThreadDraft");
113
+ var useSidebarThreadDraftIds = runtimeFunction(
114
+ "useSidebarThreadDraftIds"
115
+ );
116
+ var useSidebarThreadRowStatus = runtimeFunction(
117
+ "useSidebarThreadRowStatus"
118
+ );
119
+ var useSidebarThreadRowStatuses = runtimeFunction(
120
+ "useSidebarThreadRowStatuses"
121
+ );
122
+ var useSidebarSplitLayout = runtimeFunction("useSidebarSplitLayout");
123
+ var useSidebarThreadShortcut = runtimeFunction(
124
+ "useSidebarThreadShortcut"
125
+ );
126
+ var ThreadTitle = runtimeComponent("ThreadTitle");
127
+ var useEnvironmentProviders = runtimeFunction(
128
+ "useEnvironmentProviders"
129
+ );
130
+ var useSdk = runtimeFunction("useSdk");
131
+ var experimental_useProviders = runtimeFunction(
132
+ "experimental_useProviders"
133
+ );
134
+ var experimental_useCodeTheme = runtimeFunction(
135
+ "experimental_useCodeTheme"
136
+ );
46
137
  export {
47
138
  Markdown,
48
139
  ThreadChat,
@@ -64,6 +155,7 @@ export {
64
155
  experimental_useCheckoutState,
65
156
  experimental_useCodeTheme,
66
157
  experimental_useFixedTabTarget,
158
+ experimental_usePluginId,
67
159
  experimental_useProviders,
68
160
  experimental_useSidebarNavigation,
69
161
  experimental_useSidebarNavigationSplit,
@@ -1,4 +1,5 @@
1
1
  // src/testing/app.tsx
2
+ import * as React from "react";
2
3
  import {
3
4
  createContext,
4
5
  useContext,
@@ -1574,6 +1575,9 @@ var testPluginSdkApp = {
1574
1575
  useBbContext() {
1575
1576
  return useSlotEnv("useBbContext").bbContext;
1576
1577
  },
1578
+ experimental_usePluginId() {
1579
+ return useSlotEnv("experimental_usePluginId").pluginId;
1580
+ },
1577
1581
  useBbNavigate() {
1578
1582
  return useSlotEnv("useBbNavigate").navigate;
1579
1583
  },
@@ -1768,6 +1772,7 @@ function installTestPluginRuntime() {
1768
1772
  const host = globalThis;
1769
1773
  host.__bbPluginRuntime = {
1770
1774
  ...host.__bbPluginRuntime,
1775
+ react: host.__bbPluginRuntime?.react ?? React,
1771
1776
  pluginSdkApp: testPluginSdkApp
1772
1777
  };
1773
1778
  }
@@ -1914,6 +1919,7 @@ function strictJsonRoundTrip(value, label) {
1914
1919
  return JSON.parse(JSON.stringify(value));
1915
1920
  }
1916
1921
  function renderSlot(registration, props, options = {}) {
1922
+ installTestPluginRuntime();
1917
1923
  const rpcCalls = [];
1918
1924
  const rpcHandlers = options.rpc ?? {};
1919
1925
  const rpcClient = {
@@ -2303,6 +2309,7 @@ ${block}
2303
2309
  realtimeConnection,
2304
2310
  settingsState: { values: options.settings, isLoading: false },
2305
2311
  bbContext: { projectId, threadId },
2312
+ pluginId: options.pluginId ?? "test-plugin",
2306
2313
  navigate,
2307
2314
  navigateCalls,
2308
2315
  appPanel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@get-bb/plugin-sdk",
3
- "version": "0.5.15",
3
+ "version": "0.5.16",
4
4
  "homepage": "https://github.com/get-bb/bb#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/get-bb/bb/issues"