@get-bb/plugin-sdk 0.6.49 → 0.6.54

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.
@@ -1098,21 +1098,30 @@ var NAV_PANEL_REGISTRATION_KEYS = new Set(
1098
1098
  path: true,
1099
1099
  component: true,
1100
1100
  fixedTabs: true,
1101
- experimental_sidebarAccessory: true,
1101
+ experimental_useBadge: true,
1102
1102
  headerContent: true
1103
1103
  })
1104
1104
  );
1105
1105
  var RENAMED_NAV_PANEL_KEYS = /* @__PURE__ */ new Map([
1106
- ["experimental_fixedTabs", "fixedTabs"]
1106
+ ["experimental_fixedTabs", 'was renamed to "fixedTabs" in SDK 0.4.16']
1107
1107
  ]);
1108
- function rejectStaleNavPanelKeys(kind, registration) {
1108
+ var RETIRED_NAV_PANEL_KEYS = /* @__PURE__ */ new Map([
1109
+ [
1110
+ "experimental_sidebarAccessory",
1111
+ 'is ignored: it was replaced by "experimental_useBadge", a hook returning a badge value, in SDK 0.6.53'
1112
+ ]
1113
+ ]);
1114
+ function checkStaleNavPanelKeys(kind, registration, onWarning) {
1109
1115
  for (const key of Object.keys(registration)) {
1110
1116
  if (NAV_PANEL_REGISTRATION_KEYS.has(key)) continue;
1111
- const renamedTo = RENAMED_NAV_PANEL_KEYS.get(key);
1112
- if (renamedTo !== void 0) {
1113
- throw new Error(
1114
- `${kind}: "${key}" was renamed to "${renamedTo}" in SDK 0.4.16`
1115
- );
1117
+ const renamed = RENAMED_NAV_PANEL_KEYS.get(key);
1118
+ if (renamed !== void 0) {
1119
+ throw new Error(`${kind}: "${key}" ${renamed}`);
1120
+ }
1121
+ const retired = RETIRED_NAV_PANEL_KEYS.get(key);
1122
+ if (retired !== void 0) {
1123
+ onWarning(`${kind}: "${key}" ${retired}`);
1124
+ continue;
1116
1125
  }
1117
1126
  if (key.startsWith("experimental_")) {
1118
1127
  throw new Error(`${kind}: unknown field "${key}"`);
@@ -1174,7 +1183,7 @@ function collectPanelAction(kind, seen, registration) {
1174
1183
  ...registration.run !== void 0 ? { run: registration.run } : {}
1175
1184
  };
1176
1185
  }
1177
- function collectPluginAppRegistrations(definition, onComposerCustomizationRejected = (reason) => console.warn(reason)) {
1186
+ function collectPluginAppRegistrations(definition, onWarning = (message) => console.warn(message)) {
1178
1187
  const sidebarFooterItems = [];
1179
1188
  const collected = {
1180
1189
  homepageSections: [],
@@ -1188,6 +1197,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1188
1197
  sidebarFooterActions: [],
1189
1198
  experimentalSidebarFooterItems: [],
1190
1199
  threadLists: [],
1200
+ experimentalSidebarNavigations: [],
1191
1201
  threadHeaderActions: [],
1192
1202
  threadActions: [],
1193
1203
  browserToolbarActions: [],
@@ -1218,6 +1228,8 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1218
1228
  pendingInteraction: /* @__PURE__ */ new Set(),
1219
1229
  sidebarFooterItem: /* @__PURE__ */ new Set(),
1220
1230
  threadList: /* @__PURE__ */ new Set(),
1231
+ sidebarNavigation: /* @__PURE__ */ new Set(),
1232
+ sidebarHeader: /* @__PURE__ */ new Set(),
1221
1233
  threadHeaderAction: /* @__PURE__ */ new Set(),
1222
1234
  threadAction: /* @__PURE__ */ new Set(),
1223
1235
  browserToolbarAction: /* @__PURE__ */ new Set(),
@@ -1267,9 +1279,22 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1267
1279
  run: registration.run
1268
1280
  });
1269
1281
  }
1282
+ const legacySidebarHeaders = [];
1283
+ const legacySlotAliases = {
1284
+ experimental_sidebarHeader(registration) {
1285
+ legacySidebarHeaders.push(
1286
+ collectTitledComponent(
1287
+ "slots.experimental_sidebarHeader",
1288
+ seenIds.sidebarHeader,
1289
+ registration
1290
+ ).component
1291
+ );
1292
+ }
1293
+ };
1270
1294
  definition.setup({
1271
1295
  commands: { register: registerCommand },
1272
1296
  slots: {
1297
+ ...legacySlotAliases,
1273
1298
  homepageSection(registration) {
1274
1299
  const kind = "slots.homepageSection";
1275
1300
  const id = requireSlotId(kind, registration?.id);
@@ -1315,7 +1340,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1315
1340
  const kind = "slots.navPanel";
1316
1341
  const id = requireSlotId(kind, registration?.id);
1317
1342
  requireUniqueId(kind, seenIds.navPanel, id);
1318
- rejectStaleNavPanelKeys(kind, registration);
1343
+ checkStaleNavPanelKeys(kind, registration, onWarning);
1319
1344
  const panelId = id;
1320
1345
  const path = requireNonEmptyString(kind, "path", registration.path);
1321
1346
  if (!PLUGIN_SLOT_ID_PATTERN.test(path)) {
@@ -1328,9 +1353,9 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1328
1353
  `${kind}: "headerContent" must be a React component function when set`
1329
1354
  );
1330
1355
  }
1331
- if (registration.experimental_sidebarAccessory !== void 0 && typeof registration.experimental_sidebarAccessory !== "function") {
1356
+ if (registration.experimental_useBadge !== void 0 && typeof registration.experimental_useBadge !== "function") {
1332
1357
  throw new Error(
1333
- `${kind}: "experimental_sidebarAccessory" must be a React component function when set`
1358
+ `${kind}: "experimental_useBadge" must be a React hook function when set`
1334
1359
  );
1335
1360
  }
1336
1361
  const fixedTabs = (() => {
@@ -1390,8 +1415,8 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1390
1415
  path,
1391
1416
  component: requireComponent(kind, registration.component),
1392
1417
  ...fixedTabs.length > 0 ? { fixedTabs } : {},
1393
- ...registration.experimental_sidebarAccessory !== void 0 ? {
1394
- experimental_sidebarAccessory: registration.experimental_sidebarAccessory
1418
+ ...registration.experimental_useBadge !== void 0 ? {
1419
+ experimental_useBadge: registration.experimental_useBadge
1395
1420
  } : {},
1396
1421
  ...registration.headerContent !== void 0 ? { headerContent: registration.headerContent } : {}
1397
1422
  });
@@ -1448,6 +1473,29 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1448
1473
  )
1449
1474
  );
1450
1475
  },
1476
+ experimental_sidebarNavigation(registration) {
1477
+ const kind = "slots.experimental_sidebarNavigation";
1478
+ const collectedRegistration = collectTitledComponent(
1479
+ kind,
1480
+ seenIds.sidebarNavigation,
1481
+ registration
1482
+ );
1483
+ const placement = registration.placement;
1484
+ if (placement !== void 0 && placement !== "rail" && placement !== "list") {
1485
+ throw new Error(`${kind}: "placement" must be "rail" or "list"`);
1486
+ }
1487
+ const headerComponent = registration.headerComponent;
1488
+ if (headerComponent !== void 0 && typeof headerComponent !== "function") {
1489
+ throw new Error(
1490
+ `${kind}: "headerComponent" must be a React component function`
1491
+ );
1492
+ }
1493
+ collected.experimentalSidebarNavigations.push({
1494
+ ...collectedRegistration,
1495
+ placement: placement ?? "list",
1496
+ ...headerComponent !== void 0 ? { headerComponent } : {}
1497
+ });
1498
+ },
1451
1499
  experimental_threadHeaderAction(registration) {
1452
1500
  const kind = "slots.experimental_threadHeaderAction";
1453
1501
  const id = requireSlotId(kind, registration?.id);
@@ -1657,7 +1705,7 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1657
1705
  const customization = collectComposerCustomization(
1658
1706
  registration,
1659
1707
  seenIds.composerCustomization,
1660
- onComposerCustomizationRejected,
1708
+ (reason) => onWarning(`composer customization rejected: ${reason}`),
1661
1709
  seenIds.composerPopup
1662
1710
  );
1663
1711
  if (customization !== null) {
@@ -1697,11 +1745,50 @@ function collectPluginAppRegistrations(definition, onComposerCustomizationReject
1697
1745
  }
1698
1746
  }
1699
1747
  });
1748
+ attachLegacySidebarHeaders(
1749
+ collected.experimentalSidebarNavigations,
1750
+ legacySidebarHeaders,
1751
+ onWarning
1752
+ );
1700
1753
  return collected;
1701
1754
  }
1755
+ function attachLegacySidebarHeaders(navigations, headers, onWarning) {
1756
+ const [header, ...extraHeaders] = headers;
1757
+ if (header === void 0) return;
1758
+ const kind = "slots.experimental_sidebarHeader";
1759
+ if (extraHeaders.length > 0) {
1760
+ onWarning(
1761
+ `${kind}: only the first header is used; pass "headerComponent" to each experimental_sidebarNavigation instead`
1762
+ );
1763
+ }
1764
+ let attached = false;
1765
+ navigations.forEach((navigation, index) => {
1766
+ if (navigation.headerComponent !== void 0) return;
1767
+ navigations[index] = { ...navigation, headerComponent: header };
1768
+ attached = true;
1769
+ });
1770
+ if (!attached) {
1771
+ onWarning(
1772
+ `${kind}: ignored because the plugin registers no navigation without a "headerComponent"`
1773
+ );
1774
+ }
1775
+ }
1702
1776
 
1703
1777
  // src/testing/app.tsx
1704
1778
  import { jsx, jsxs } from "react/jsx-runtime";
1779
+ function TestSidebarNavigationIcon({
1780
+ icon,
1781
+ className
1782
+ }) {
1783
+ return /* @__PURE__ */ jsx(
1784
+ "span",
1785
+ {
1786
+ "aria-hidden": "true",
1787
+ className,
1788
+ "data-sidebar-navigation-icon": icon.kind === "host" ? icon.name : `${icon.pluginId}/${icon.icon ?? ""}`
1789
+ }
1790
+ );
1791
+ }
1705
1792
  function testComposerKey(scope) {
1706
1793
  switch (scope.kind) {
1707
1794
  case "thread":
@@ -2548,6 +2635,28 @@ var testPluginSdkApp = {
2548
2635
  experimental_ThreadActionsMenu: TestThreadActionsMenu,
2549
2636
  experimental_ThreadActionsContextMenu: TestThreadActionsContextMenu,
2550
2637
  experimental_THREAD_ACTION_GROUPS,
2638
+ experimental_useSidebarNavigation() {
2639
+ return useSlotEnv("experimental_useSidebarNavigation").sidebarNavigation;
2640
+ },
2641
+ experimental_useSidebarNavigationSplit(itemId, _options) {
2642
+ const env = useSlotEnv("experimental_useSidebarNavigationSplit");
2643
+ return useMemo(
2644
+ () => ({
2645
+ splitProps: {
2646
+ onPointerDown: () => {
2647
+ env.sidebarNavigationCalls.push({
2648
+ method: "beginSplitDrag",
2649
+ itemId
2650
+ });
2651
+ }
2652
+ },
2653
+ isAvailable: true,
2654
+ layout: null
2655
+ }),
2656
+ [env, itemId]
2657
+ );
2658
+ },
2659
+ experimental_SidebarNavigationIcon: TestSidebarNavigationIcon,
2551
2660
  experimental_useSidebarThreadSplit(threadId) {
2552
2661
  const env = useSlotEnv("experimental_useSidebarThreadSplit");
2553
2662
  return useMemo(
@@ -2881,6 +2990,47 @@ function renderSlot(registration, props, options = {}) {
2881
2990
  }
2882
2991
  };
2883
2992
  const sidebarActionCalls = [];
2993
+ const sidebarNavigationCalls = [];
2994
+ const sidebarNavigation = {
2995
+ items: options.sidebarNavigation?.items ?? [],
2996
+ activeItemId: options.sidebarNavigation?.activeItemId ?? null,
2997
+ isHomeActive: options.sidebarNavigation?.isHomeActive ?? true,
2998
+ isShortcutModifierHeld: options.sidebarNavigation?.isShortcutModifierHeld ?? false,
2999
+ actions: {
3000
+ activate(itemId, activationOptions) {
3001
+ sidebarNavigationCalls.push({
3002
+ method: "activate",
3003
+ itemId,
3004
+ openInSplit: activationOptions.openInSplit
3005
+ });
3006
+ },
3007
+ goHome() {
3008
+ sidebarNavigationCalls.push({ method: "goHome" });
3009
+ },
3010
+ setVisible(itemId, isVisible) {
3011
+ sidebarNavigationCalls.push({
3012
+ method: "setVisible",
3013
+ itemId,
3014
+ isVisible
3015
+ });
3016
+ },
3017
+ setOrder(itemIds) {
3018
+ sidebarNavigationCalls.push({
3019
+ method: "setOrder",
3020
+ itemIds: [...itemIds]
3021
+ });
3022
+ },
3023
+ openCustomize() {
3024
+ sidebarNavigationCalls.push({ method: "openCustomize" });
3025
+ },
3026
+ openDetails(itemId) {
3027
+ sidebarNavigationCalls.push({ method: "openDetails", itemId });
3028
+ },
3029
+ async disablePlugin(itemId) {
3030
+ sidebarNavigationCalls.push({ method: "disablePlugin", itemId });
3031
+ }
3032
+ }
3033
+ };
2884
3034
  const environmentArchiveCalls = [];
2885
3035
  const sidebarPullRequests = new Map(
2886
3036
  Object.entries(options.sidebarPullRequests ?? {})
@@ -3266,6 +3416,8 @@ ${block}
3266
3416
  sidebarThreads,
3267
3417
  sidebarActions,
3268
3418
  sidebarActionCalls,
3419
+ sidebarNavigation,
3420
+ sidebarNavigationCalls,
3269
3421
  environmentArchiveCalls,
3270
3422
  threadActions: options.threadActions ?? NO_THREAD_ACTIONS,
3271
3423
  threadActionRegistrations: options.threadActionRegistrations ?? NO_THREAD_ACTION_REGISTRATIONS,
@@ -3345,6 +3497,7 @@ ${block}
3345
3497
  navigateCalls,
3346
3498
  experimental_fixedTabOpenCalls,
3347
3499
  sidebarActionCalls,
3500
+ sidebarNavigationCalls,
3348
3501
  experimental_environmentArchiveCalls: environmentArchiveCalls,
3349
3502
  sdkCalls,
3350
3503
  experimental_clipboardWrites,
@@ -3360,6 +3513,7 @@ ${block}
3360
3513
  navigateCalls,
3361
3514
  experimental_fixedTabOpenCalls,
3362
3515
  sidebarActionCalls,
3516
+ sidebarNavigationCalls,
3363
3517
  experimental_environmentArchiveCalls: environmentArchiveCalls,
3364
3518
  sdkCalls,
3365
3519
  experimental_clipboardWrites,
@@ -4280,6 +4280,7 @@ function makeThreadResponse(overrides = {}) {
4280
4280
  originKind: null,
4281
4281
  originPluginId: null,
4282
4282
  visibility: "visible",
4283
+ parentNotifications: "auto",
4283
4284
  archivedAt: null,
4284
4285
  pinnedAt: null,
4285
4286
  deletedAt: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@get-bb/plugin-sdk",
3
- "version": "0.6.49",
3
+ "version": "0.6.54",
4
4
  "homepage": "https://github.com/get-bb/bb#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/get-bb/bb/issues"