@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.
- package/bundled-types/bb-plugin-sdk-app.d.ts +136 -86
- package/bundled-types/bb-plugin-sdk-internal-composer-handle.d.ts +60 -35
- package/bundled-types/bb-plugin-sdk-internal-plugin-app-collector.d.ts +5 -11
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +1 -0
- package/bundled-types/bb-plugin-sdk-testing.d.ts +18 -2
- package/bundled-types/bb-plugin-sdk.d.ts +231 -87
- package/dist/internal/composer-handle.js +13 -14
- package/dist/internal/plugin-app-collector.js +90 -87
- package/dist/internal/rpc-query-host.js +833 -181
- package/dist/provider-bridge-acp-next.js +2599 -2627
- package/dist/provider-bridge-acp.js +2599 -2627
- package/dist/provider-bridge-testing.js +1210 -1238
- package/dist/provider-bridge.js +1258 -1286
- package/dist/testing/app.js +919 -284
- package/dist/testing/index.js +55 -0
- package/package.json +1 -1
|
@@ -1,4 +1,56 @@
|
|
|
1
|
-
// src/internal/
|
|
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 =
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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 (
|
|
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
|
-
|
|
414
|
-
|
|
415
|
-
(
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
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: [],
|