@get-bb/plugin-sdk 0.6.65 → 0.6.68

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.
@@ -1,4 +1,56 @@
1
- // src/internal/plugin-app-collector.ts
1
+ // src/internal/sidebar-footer-runtime.ts
2
+ var sidebarFooterCommandSequence = 0;
3
+ var SidebarFooterItemRuntime = class {
4
+ listeners = /* @__PURE__ */ new Set();
5
+ snapshot = {
6
+ command: null
7
+ };
8
+ subscribe = (listener) => {
9
+ this.listeners.add(listener);
10
+ return () => this.listeners.delete(listener);
11
+ };
12
+ getSnapshot = () => this.snapshot;
13
+ acknowledgeCommand = (sequence) => {
14
+ if (this.snapshot.command?.sequence !== sequence) return;
15
+ this.snapshot = { ...this.snapshot, command: null };
16
+ this.emit();
17
+ };
18
+ createDisclosureController() {
19
+ return Object.freeze({
20
+ open: () => this.request("open"),
21
+ close: () => this.request("close"),
22
+ toggle: () => this.request("toggle")
23
+ });
24
+ }
25
+ request(kind) {
26
+ sidebarFooterCommandSequence += 1;
27
+ this.snapshot = {
28
+ ...this.snapshot,
29
+ command: { sequence: sidebarFooterCommandSequence, kind }
30
+ };
31
+ this.emit();
32
+ }
33
+ emit() {
34
+ for (const listener of this.listeners) listener();
35
+ }
36
+ };
37
+ function adaptSidebarFooterAction(registration) {
38
+ return {
39
+ source: "sidebarFooterAction",
40
+ id: registration.id,
41
+ label: registration.title,
42
+ icon: registration.icon,
43
+ kind: "action",
44
+ onActivate: ({ openPluginDetails }) => registration.run({ openSettings: openPluginDetails }),
45
+ runtime: new SidebarFooterItemRuntime()
46
+ };
47
+ }
48
+ var sidebarFooterItemsByRegistrationSet = /* @__PURE__ */ new WeakMap();
49
+ function getCollectedSidebarFooterItems(registrations) {
50
+ return sidebarFooterItemsByRegistrationSet.get(registrations) ?? null;
51
+ }
52
+
53
+ // src/internal/plugin-app-registration-collector.ts
2
54
  import { z } from "zod";
3
55
 
4
56
  // src/internal/composer-customization-validation.ts
@@ -247,9 +299,8 @@ function collectComposerCustomization(registration, seenIds, onRejected, seenPop
247
299
  }
248
300
  }
249
301
 
250
- // src/internal/plugin-app-collector.ts
302
+ // src/internal/plugin-app-registration-collector.ts
251
303
  var CODE_FENCE_LANGUAGE_PATTERN = /^[a-z0-9][a-z0-9+#._-]*$/;
252
- var sidebarFooterCommandSequence = 0;
253
304
  var SIDEBAR_FOOTER_ACTION_KEYS = /* @__PURE__ */ new Set([
254
305
  "id",
255
306
  "label",
@@ -264,51 +315,6 @@ var SIDEBAR_FOOTER_DISCLOSURE_KEYS = /* @__PURE__ */ new Set([
264
315
  "kind",
265
316
  "component"
266
317
  ]);
267
- var SidebarFooterItemRuntime = class {
268
- listeners = /* @__PURE__ */ new Set();
269
- snapshot = {
270
- command: null
271
- };
272
- subscribe = (listener) => {
273
- this.listeners.add(listener);
274
- return () => this.listeners.delete(listener);
275
- };
276
- getSnapshot = () => this.snapshot;
277
- acknowledgeCommand = (sequence) => {
278
- if (this.snapshot.command?.sequence !== sequence) return;
279
- this.snapshot = { ...this.snapshot, command: null };
280
- this.emit();
281
- };
282
- createDisclosureController() {
283
- return Object.freeze({
284
- open: () => this.request("open"),
285
- close: () => this.request("close"),
286
- toggle: () => this.request("toggle")
287
- });
288
- }
289
- request(kind) {
290
- sidebarFooterCommandSequence += 1;
291
- this.snapshot = {
292
- ...this.snapshot,
293
- command: { sequence: sidebarFooterCommandSequence, kind }
294
- };
295
- this.emit();
296
- }
297
- emit() {
298
- for (const listener of this.listeners) listener();
299
- }
300
- };
301
- function adaptSidebarFooterAction(registration) {
302
- return {
303
- source: "sidebarFooterAction",
304
- id: registration.id,
305
- label: registration.title,
306
- icon: registration.icon,
307
- kind: "action",
308
- onActivate: ({ openPluginDetails }) => registration.run({ openSettings: openPluginDetails }),
309
- runtime: new SidebarFooterItemRuntime()
310
- };
311
- }
312
318
  var SidebarFooterCollector = class {
313
319
  constructor(collected, allCollected, seenIds) {
314
320
  this.collected = collected;
@@ -370,20 +376,18 @@ var SidebarFooterCollector = class {
370
376
  }
371
377
  }
372
378
  };
373
- var NAV_PANEL_REGISTRATION_KEYS = new Set(
374
- Object.keys({
375
- id: true,
376
- title: true,
377
- icon: true,
378
- path: true,
379
- component: true,
380
- fixedTabs: true,
381
- experimental_useBadge: true,
382
- experimental_usePageTitle: true,
383
- experimental_sidebar: true,
384
- headerContent: true
385
- })
386
- );
379
+ var NAV_PANEL_REGISTRATION_KEYS = {
380
+ id: true,
381
+ title: true,
382
+ icon: true,
383
+ path: true,
384
+ component: true,
385
+ fixedTabs: true,
386
+ experimental_useBadge: true,
387
+ experimental_usePageTitle: true,
388
+ experimental_sidebar: true,
389
+ headerContent: true
390
+ };
387
391
  var RENAMED_NAV_PANEL_KEYS = /* @__PURE__ */ new Map([
388
392
  ["experimental_fixedTabs", 'was renamed to "fixedTabs" in SDK 0.4.16']
389
393
  ]);
@@ -395,7 +399,7 @@ var RETIRED_NAV_PANEL_KEYS = /* @__PURE__ */ new Map([
395
399
  ]);
396
400
  function checkStaleNavPanelKeys(kind, registration, onWarning) {
397
401
  for (const key of Object.keys(registration)) {
398
- if (NAV_PANEL_REGISTRATION_KEYS.has(key)) continue;
402
+ if (Object.hasOwn(NAV_PANEL_REGISTRATION_KEYS, key)) continue;
399
403
  const renamed = RENAMED_NAV_PANEL_KEYS.get(key);
400
404
  if (renamed !== void 0) {
401
405
  throw new Error(`${kind}: "${key}" ${renamed}`);
@@ -410,30 +414,28 @@ function checkStaleNavPanelKeys(kind, registration, onWarning) {
410
414
  }
411
415
  }
412
416
  }
413
- var commandShortcutSchema = z.object({
414
- key: z.string().min(1).max(32).refine(
415
- (key) => ![
416
- "Alt",
417
- "Control",
418
- "Meta",
419
- "OS",
420
- "Shift",
421
- "Dead",
422
- "Unidentified"
423
- ].includes(key)
424
- ),
425
- mod: z.boolean().default(false),
426
- meta: z.boolean().default(false),
427
- control: z.boolean().default(false),
428
- alt: z.boolean().default(false),
429
- shift: z.boolean().default(false)
430
- }).strict().refine(
431
- (shortcut) => shortcut.mod || shortcut.meta || shortcut.control || shortcut.alt || /^F(?:[1-9]|1[0-9]|2[0-4])$/u.test(shortcut.key),
432
- "Use Command, Control, or Alt with a key, or a function key"
433
- );
434
- var sidebarFooterItemsByRegistrationSet = /* @__PURE__ */ new WeakMap();
435
- function getCollectedSidebarFooterItems(registrations) {
436
- return sidebarFooterItemsByRegistrationSet.get(registrations) ?? null;
417
+ function createCommandShortcutSchema() {
418
+ return z.object({
419
+ key: z.string().min(1).max(32).refine(
420
+ (key) => ![
421
+ "Alt",
422
+ "Control",
423
+ "Meta",
424
+ "OS",
425
+ "Shift",
426
+ "Dead",
427
+ "Unidentified"
428
+ ].includes(key)
429
+ ),
430
+ mod: z.boolean().default(false),
431
+ meta: z.boolean().default(false),
432
+ control: z.boolean().default(false),
433
+ alt: z.boolean().default(false),
434
+ shift: z.boolean().default(false)
435
+ }).strict().refine(
436
+ (shortcut) => shortcut.mod || shortcut.meta || shortcut.control || shortcut.alt || /^F(?:[1-9]|1[0-9]|2[0-4])$/u.test(shortcut.key),
437
+ "Use Command, Control, or Alt with a key, or a function key"
438
+ );
437
439
  }
438
440
  function collectTitledComponent(kind, seen, registration) {
439
441
  const id = requireSlotId(kind, registration?.id);
@@ -469,6 +471,7 @@ function collectPanelAction(kind, seen, registration) {
469
471
  };
470
472
  }
471
473
  function collectPluginAppRegistrations(definition, onWarning = (message) => console.warn(message)) {
474
+ const commandShortcutSchema = createCommandShortcutSchema();
472
475
  const sidebarFooterItems = [];
473
476
  const collected = {
474
477
  homepageSections: [],