@get-bb/plugin-sdk 0.6.60 → 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 +477 -169
- package/bundled-types/bb-plugin-sdk-host.d.ts +196 -214
- package/bundled-types/bb-plugin-sdk-internal-composer-handle.d.ts +60 -35
- package/bundled-types/bb-plugin-sdk-internal-host-policy.d.ts +17 -7
- package/bundled-types/bb-plugin-sdk-internal-plugin-app-collector.d.ts +5 -11
- package/bundled-types/bb-plugin-sdk-internal-rpc-query-host.d.ts +192 -0
- package/bundled-types/bb-plugin-sdk-internal-rpc-tags.d.ts +23 -0
- package/bundled-types/bb-plugin-sdk-testing-app.d.ts +8 -2
- package/bundled-types/bb-plugin-sdk-testing.d.ts +29 -5
- package/bundled-types/bb-plugin-sdk.d.ts +622 -195
- package/dist/app.js +98 -0
- package/dist/host.js +12 -0
- package/dist/index.js +81 -0
- package/dist/internal/composer-handle.js +13 -14
- package/dist/internal/host-policy.js +33 -1
- package/dist/internal/plugin-app-collector.js +104 -85
- package/dist/internal/rpc-query-host.js +1574 -0
- package/dist/internal/rpc-tags.js +18 -0
- package/dist/provider-bridge-acp-next.js +2636 -2653
- package/dist/provider-bridge-acp.js +2636 -2653
- package/dist/provider-bridge-testing.js +1210 -1238
- package/dist/provider-bridge.js +1279 -1306
- package/dist/replay-provider-child.mjs +6 -2
- package/dist/testing/app.js +1826 -163
- package/dist/testing/index.js +302 -104
- package/package.json +16 -2
package/dist/app.js
CHANGED
|
@@ -1,3 +1,84 @@
|
|
|
1
|
+
// src/rpc-contract.ts
|
|
2
|
+
var rpcErrorCodes = [
|
|
3
|
+
"forbidden",
|
|
4
|
+
"not_found",
|
|
5
|
+
"conflict",
|
|
6
|
+
"invalid",
|
|
7
|
+
"invalid_json",
|
|
8
|
+
"invalid_input",
|
|
9
|
+
"handler_error",
|
|
10
|
+
"invalid_output",
|
|
11
|
+
"non_json_result",
|
|
12
|
+
"unknown_method",
|
|
13
|
+
"transport_error",
|
|
14
|
+
"invalid_response",
|
|
15
|
+
"unknown_error"
|
|
16
|
+
];
|
|
17
|
+
var callErrorBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-call-error");
|
|
18
|
+
var experimental_PluginRpcCallError = class _experimental_PluginRpcCallError extends Error {
|
|
19
|
+
/** Recognizes errors across the packed SDK's separately bundled entries. */
|
|
20
|
+
static [Symbol.hasInstance](value) {
|
|
21
|
+
return typeof value === "object" && value !== null && Reflect.get(value, callErrorBrand) === true && rpcErrorCodes.some((code) => code === Reflect.get(value, "code")) && typeof Reflect.get(value, "message") === "string";
|
|
22
|
+
}
|
|
23
|
+
code;
|
|
24
|
+
issues;
|
|
25
|
+
status;
|
|
26
|
+
serverCode;
|
|
27
|
+
constructor(args) {
|
|
28
|
+
super(args.message);
|
|
29
|
+
this.name = "experimental_PluginRpcCallError";
|
|
30
|
+
Object.defineProperty(this, callErrorBrand, { value: true });
|
|
31
|
+
this.code = args.code;
|
|
32
|
+
this.issues = args.issues;
|
|
33
|
+
this.status = args.status;
|
|
34
|
+
this.serverCode = args.serverCode;
|
|
35
|
+
}
|
|
36
|
+
/** Normalize failures at the RPC boundary; preserves an existing client error. */
|
|
37
|
+
static from(error, fallback = "transport_error") {
|
|
38
|
+
if (error instanceof _experimental_PluginRpcCallError) return error;
|
|
39
|
+
const record = typeof error === "object" && error !== null ? error : {};
|
|
40
|
+
const rawCode = Reflect.get(record, "code");
|
|
41
|
+
const code = rpcErrorCodes.find((value) => value === rawCode);
|
|
42
|
+
const message = Reflect.get(record, "message");
|
|
43
|
+
const status = Reflect.get(record, "status");
|
|
44
|
+
const rawIssues = Reflect.get(record, "issues");
|
|
45
|
+
const issues = [];
|
|
46
|
+
if (Array.isArray(rawIssues))
|
|
47
|
+
for (const issue of rawIssues) {
|
|
48
|
+
if (typeof issue !== "object" || issue === null || typeof Reflect.get(issue, "message") !== "string")
|
|
49
|
+
continue;
|
|
50
|
+
const path = Reflect.get(issue, "path");
|
|
51
|
+
if (path !== void 0 && (!Array.isArray(path) || !path.every(
|
|
52
|
+
(part) => typeof part === "string" || typeof part === "number" && Number.isFinite(part)
|
|
53
|
+
)))
|
|
54
|
+
continue;
|
|
55
|
+
issues.push({
|
|
56
|
+
message: Reflect.get(issue, "message"),
|
|
57
|
+
...path === void 0 ? {} : { path }
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return new _experimental_PluginRpcCallError({
|
|
61
|
+
code: code ?? (typeof rawCode === "string" ? "unknown_error" : fallback),
|
|
62
|
+
message: typeof message === "string" ? message : typeof error === "string" ? error : "Plugin RPC request failed",
|
|
63
|
+
...issues.length === 0 ? {} : { issues },
|
|
64
|
+
...typeof status === "number" ? { status } : {},
|
|
65
|
+
...typeof rawCode === "string" && code === void 0 ? { serverCode: rawCode } : {}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var refusalBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-refusal");
|
|
70
|
+
var experimental_PluginRpcRefusal = class extends Error {
|
|
71
|
+
[refusalBrand] = true;
|
|
72
|
+
code;
|
|
73
|
+
issues;
|
|
74
|
+
constructor(args) {
|
|
75
|
+
super(args.message);
|
|
76
|
+
this.name = "experimental_PluginRpcRefusal";
|
|
77
|
+
this.code = args.code;
|
|
78
|
+
this.issues = args.issues;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
1
82
|
// src/thread-action-groups.ts
|
|
2
83
|
var experimental_THREAD_ACTION_GROUPS = {
|
|
3
84
|
open: "1_open",
|
|
@@ -81,6 +162,18 @@ var experimental_SourceCode = runtimeComponent(
|
|
|
81
162
|
"experimental_SourceCode"
|
|
82
163
|
);
|
|
83
164
|
var experimental_Diff = runtimeComponent("experimental_Diff");
|
|
165
|
+
var experimental_useRpcQuery = runtimeFunction(
|
|
166
|
+
"experimental_useRpcQuery"
|
|
167
|
+
);
|
|
168
|
+
var experimental_useRpcKeyedQuery = runtimeFunction(
|
|
169
|
+
"experimental_useRpcKeyedQuery"
|
|
170
|
+
);
|
|
171
|
+
var experimental_useRpcMutation = runtimeFunction(
|
|
172
|
+
"experimental_useRpcMutation"
|
|
173
|
+
);
|
|
174
|
+
var experimental_useRpcRefresh = runtimeFunction(
|
|
175
|
+
"experimental_useRpcRefresh"
|
|
176
|
+
);
|
|
84
177
|
var useRpc = runtimeFunction("useRpc");
|
|
85
178
|
var useRealtime = runtimeFunction("useRealtime");
|
|
86
179
|
var useRealtimeConnectionState = runtimeFunction(
|
|
@@ -184,6 +277,7 @@ export {
|
|
|
184
277
|
experimental_Icon,
|
|
185
278
|
experimental_NewThreadComposer,
|
|
186
279
|
experimental_PermissionModePicker,
|
|
280
|
+
experimental_PluginRpcCallError,
|
|
187
281
|
experimental_ProviderIcon,
|
|
188
282
|
experimental_ProviderModelPicker,
|
|
189
283
|
experimental_SidebarNavigationIcon,
|
|
@@ -204,6 +298,10 @@ export {
|
|
|
204
298
|
experimental_usePluginId,
|
|
205
299
|
experimental_useProviders,
|
|
206
300
|
experimental_useQuestionFormHost,
|
|
301
|
+
experimental_useRpcKeyedQuery,
|
|
302
|
+
experimental_useRpcMutation,
|
|
303
|
+
experimental_useRpcQuery,
|
|
304
|
+
experimental_useRpcRefresh,
|
|
207
305
|
experimental_useSidebarNavigation,
|
|
208
306
|
experimental_useSidebarNavigationSplit,
|
|
209
307
|
experimental_useSidebarThreadActions,
|
package/dist/host.js
CHANGED
|
@@ -214,6 +214,18 @@ var providerNativeRootSetSchema = z.object({
|
|
|
214
214
|
}).strict();
|
|
215
215
|
|
|
216
216
|
// src/rpc-contract.ts
|
|
217
|
+
var refusalBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-refusal");
|
|
218
|
+
var experimental_PluginRpcRefusal = class extends Error {
|
|
219
|
+
[refusalBrand] = true;
|
|
220
|
+
code;
|
|
221
|
+
issues;
|
|
222
|
+
constructor(args) {
|
|
223
|
+
super(args.message);
|
|
224
|
+
this.name = "experimental_PluginRpcRefusal";
|
|
225
|
+
this.code = args.code;
|
|
226
|
+
this.issues = args.issues;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
217
229
|
function defineRpcContract(contract) {
|
|
218
230
|
return contract;
|
|
219
231
|
}
|
package/dist/index.js
CHANGED
|
@@ -809,6 +809,85 @@ function experimental_defineHostEntry(args) {
|
|
|
809
809
|
}
|
|
810
810
|
|
|
811
811
|
// src/rpc-contract.ts
|
|
812
|
+
var rpcErrorCodes = [
|
|
813
|
+
"forbidden",
|
|
814
|
+
"not_found",
|
|
815
|
+
"conflict",
|
|
816
|
+
"invalid",
|
|
817
|
+
"invalid_json",
|
|
818
|
+
"invalid_input",
|
|
819
|
+
"handler_error",
|
|
820
|
+
"invalid_output",
|
|
821
|
+
"non_json_result",
|
|
822
|
+
"unknown_method",
|
|
823
|
+
"transport_error",
|
|
824
|
+
"invalid_response",
|
|
825
|
+
"unknown_error"
|
|
826
|
+
];
|
|
827
|
+
var callErrorBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-call-error");
|
|
828
|
+
var experimental_PluginRpcCallError = class _experimental_PluginRpcCallError extends Error {
|
|
829
|
+
/** Recognizes errors across the packed SDK's separately bundled entries. */
|
|
830
|
+
static [Symbol.hasInstance](value) {
|
|
831
|
+
return typeof value === "object" && value !== null && Reflect.get(value, callErrorBrand) === true && rpcErrorCodes.some((code) => code === Reflect.get(value, "code")) && typeof Reflect.get(value, "message") === "string";
|
|
832
|
+
}
|
|
833
|
+
code;
|
|
834
|
+
issues;
|
|
835
|
+
status;
|
|
836
|
+
serverCode;
|
|
837
|
+
constructor(args) {
|
|
838
|
+
super(args.message);
|
|
839
|
+
this.name = "experimental_PluginRpcCallError";
|
|
840
|
+
Object.defineProperty(this, callErrorBrand, { value: true });
|
|
841
|
+
this.code = args.code;
|
|
842
|
+
this.issues = args.issues;
|
|
843
|
+
this.status = args.status;
|
|
844
|
+
this.serverCode = args.serverCode;
|
|
845
|
+
}
|
|
846
|
+
/** Normalize failures at the RPC boundary; preserves an existing client error. */
|
|
847
|
+
static from(error, fallback = "transport_error") {
|
|
848
|
+
if (error instanceof _experimental_PluginRpcCallError) return error;
|
|
849
|
+
const record = typeof error === "object" && error !== null ? error : {};
|
|
850
|
+
const rawCode = Reflect.get(record, "code");
|
|
851
|
+
const code = rpcErrorCodes.find((value) => value === rawCode);
|
|
852
|
+
const message = Reflect.get(record, "message");
|
|
853
|
+
const status = Reflect.get(record, "status");
|
|
854
|
+
const rawIssues = Reflect.get(record, "issues");
|
|
855
|
+
const issues = [];
|
|
856
|
+
if (Array.isArray(rawIssues))
|
|
857
|
+
for (const issue of rawIssues) {
|
|
858
|
+
if (typeof issue !== "object" || issue === null || typeof Reflect.get(issue, "message") !== "string")
|
|
859
|
+
continue;
|
|
860
|
+
const path = Reflect.get(issue, "path");
|
|
861
|
+
if (path !== void 0 && (!Array.isArray(path) || !path.every(
|
|
862
|
+
(part) => typeof part === "string" || typeof part === "number" && Number.isFinite(part)
|
|
863
|
+
)))
|
|
864
|
+
continue;
|
|
865
|
+
issues.push({
|
|
866
|
+
message: Reflect.get(issue, "message"),
|
|
867
|
+
...path === void 0 ? {} : { path }
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
return new _experimental_PluginRpcCallError({
|
|
871
|
+
code: code ?? (typeof rawCode === "string" ? "unknown_error" : fallback),
|
|
872
|
+
message: typeof message === "string" ? message : typeof error === "string" ? error : "Plugin RPC request failed",
|
|
873
|
+
...issues.length === 0 ? {} : { issues },
|
|
874
|
+
...typeof status === "number" ? { status } : {},
|
|
875
|
+
...typeof rawCode === "string" && code === void 0 ? { serverCode: rawCode } : {}
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
var refusalBrand = /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-refusal");
|
|
880
|
+
var experimental_PluginRpcRefusal = class extends Error {
|
|
881
|
+
[refusalBrand] = true;
|
|
882
|
+
code;
|
|
883
|
+
issues;
|
|
884
|
+
constructor(args) {
|
|
885
|
+
super(args.message);
|
|
886
|
+
this.name = "experimental_PluginRpcRefusal";
|
|
887
|
+
this.code = args.code;
|
|
888
|
+
this.issues = args.issues;
|
|
889
|
+
}
|
|
890
|
+
};
|
|
812
891
|
function defineRpcContract(contract) {
|
|
813
892
|
return contract;
|
|
814
893
|
}
|
|
@@ -827,6 +906,8 @@ export {
|
|
|
827
906
|
cliCommand,
|
|
828
907
|
defineCli,
|
|
829
908
|
defineRpcContract,
|
|
909
|
+
experimental_PluginRpcCallError,
|
|
910
|
+
experimental_PluginRpcRefusal,
|
|
830
911
|
experimental_THREAD_ACTION_GROUPS,
|
|
831
912
|
experimental_defineHostEntry
|
|
832
913
|
};
|
|
@@ -365,12 +365,8 @@ function createComposerHandleBinding(key, initial) {
|
|
|
365
365
|
}
|
|
366
366
|
target().setDraft(appendComposerDraft(target().getDraft(), value, block));
|
|
367
367
|
};
|
|
368
|
-
const submit = async (options) => {
|
|
368
|
+
const submit = async (options = {}) => {
|
|
369
369
|
requireAvailable();
|
|
370
|
-
const hostSubmit = target().submit;
|
|
371
|
-
if (hostSubmit === void 0) {
|
|
372
|
-
throw new Error("This composer cannot submit programmatically.");
|
|
373
|
-
}
|
|
374
370
|
if (options.sendAt !== void 0 && (!Number.isFinite(options.sendAt) || options.sendAt <= Date.now())) {
|
|
375
371
|
throw new Error("Pick a time in the future.");
|
|
376
372
|
}
|
|
@@ -380,15 +376,18 @@ function createComposerHandleBinding(key, initial) {
|
|
|
380
376
|
if (state.attachmentError !== null && state.attachmentError !== errorBefore) {
|
|
381
377
|
throw new Error(state.attachmentError);
|
|
382
378
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
379
|
+
const submission = target().editorSubmit({
|
|
380
|
+
mode: options.experimental_mode ?? "enter",
|
|
381
|
+
...options.sendAt === void 0 ? {} : { sendAt: options.sendAt },
|
|
382
|
+
...options.experimental_data === void 0 ? {} : {
|
|
383
|
+
pluginSubmission: {
|
|
384
|
+
pluginId: controller.pluginId,
|
|
385
|
+
data: options.experimental_data
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
if (submission === null) throw new Error(OFF_SCREEN_MESSAGE);
|
|
390
|
+
await submission;
|
|
392
391
|
};
|
|
393
392
|
const setSelection = async (selection) => {
|
|
394
393
|
requireAvailable();
|
|
@@ -1444,7 +1444,21 @@ function readRpcMethodContract(method, value) {
|
|
|
1444
1444
|
const description = rpcDescriptionSchema.parse(
|
|
1445
1445
|
Reflect.get(value, "experimental_description")
|
|
1446
1446
|
);
|
|
1447
|
-
|
|
1447
|
+
const declarations = {};
|
|
1448
|
+
for (const name of ["tags", "keyTags", "invalidates"]) {
|
|
1449
|
+
const declaration = Reflect.get(value, name);
|
|
1450
|
+
if (declaration !== void 0) {
|
|
1451
|
+
if (typeof declaration !== "function")
|
|
1452
|
+
throw new Error(`rpc ${method} ${name} must be a function`);
|
|
1453
|
+
Reflect.set(declarations, name, declaration);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
return {
|
|
1457
|
+
input,
|
|
1458
|
+
output,
|
|
1459
|
+
...declarations,
|
|
1460
|
+
...description === null ? {} : { experimental_description: description }
|
|
1461
|
+
};
|
|
1448
1462
|
}
|
|
1449
1463
|
function readRpcPublicationOptions(value) {
|
|
1450
1464
|
return rpcPublicationOptionsSchema.parse(value ?? {});
|
|
@@ -2215,6 +2229,7 @@ function normalizeRpcRegistration(contract, handlers, registered, options) {
|
|
|
2215
2229
|
name,
|
|
2216
2230
|
{
|
|
2217
2231
|
publication: publishRpcMethod(name, methodContract, publicationOptions),
|
|
2232
|
+
declarations: methodContract,
|
|
2218
2233
|
inputSchema: methodContract.input,
|
|
2219
2234
|
outputSchema: methodContract.output,
|
|
2220
2235
|
handler
|
|
@@ -2684,6 +2699,22 @@ function normalizeRpcIssues(issues) {
|
|
|
2684
2699
|
};
|
|
2685
2700
|
});
|
|
2686
2701
|
}
|
|
2702
|
+
var rpcRefusalSchema = z5.object({
|
|
2703
|
+
code: z5.enum(["forbidden", "not_found", "conflict", "invalid"]),
|
|
2704
|
+
message: z5.string(),
|
|
2705
|
+
issues: z5.array(
|
|
2706
|
+
z5.object({
|
|
2707
|
+
message: z5.string(),
|
|
2708
|
+
path: z5.array(z5.union([z5.string(), z5.number()])).optional()
|
|
2709
|
+
})
|
|
2710
|
+
).optional()
|
|
2711
|
+
});
|
|
2712
|
+
function readPluginRpcRefusal(error) {
|
|
2713
|
+
if (typeof error !== "object" || error === null || Reflect.get(error, /* @__PURE__ */ Symbol.for("@get-bb/plugin-sdk/rpc-refusal")) !== true)
|
|
2714
|
+
return null;
|
|
2715
|
+
const parsed = rpcRefusalSchema.safeParse(error);
|
|
2716
|
+
return parsed.success ? parsed.data : null;
|
|
2717
|
+
}
|
|
2687
2718
|
async function validateRpcValue(schema, value, phase, fail) {
|
|
2688
2719
|
let result;
|
|
2689
2720
|
try {
|
|
@@ -2806,6 +2837,7 @@ export {
|
|
|
2806
2837
|
providerIconRefusalMessage,
|
|
2807
2838
|
providerWithoutBridgeMessage,
|
|
2808
2839
|
publishRpcMethod,
|
|
2840
|
+
readPluginRpcRefusal,
|
|
2809
2841
|
readRpcPublicationOptions,
|
|
2810
2842
|
registerSettingDescriptors,
|
|
2811
2843
|
runPluginStorageMigrations,
|
|
@@ -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,18 +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
|
-
|
|
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
|
+
};
|
|
385
391
|
var RENAMED_NAV_PANEL_KEYS = /* @__PURE__ */ new Map([
|
|
386
392
|
["experimental_fixedTabs", 'was renamed to "fixedTabs" in SDK 0.4.16']
|
|
387
393
|
]);
|
|
@@ -393,7 +399,7 @@ var RETIRED_NAV_PANEL_KEYS = /* @__PURE__ */ new Map([
|
|
|
393
399
|
]);
|
|
394
400
|
function checkStaleNavPanelKeys(kind, registration, onWarning) {
|
|
395
401
|
for (const key of Object.keys(registration)) {
|
|
396
|
-
if (
|
|
402
|
+
if (Object.hasOwn(NAV_PANEL_REGISTRATION_KEYS, key)) continue;
|
|
397
403
|
const renamed = RENAMED_NAV_PANEL_KEYS.get(key);
|
|
398
404
|
if (renamed !== void 0) {
|
|
399
405
|
throw new Error(`${kind}: "${key}" ${renamed}`);
|
|
@@ -408,30 +414,28 @@ function checkStaleNavPanelKeys(kind, registration, onWarning) {
|
|
|
408
414
|
}
|
|
409
415
|
}
|
|
410
416
|
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
function getCollectedSidebarFooterItems(registrations) {
|
|
434
|
-
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
|
+
);
|
|
435
439
|
}
|
|
436
440
|
function collectTitledComponent(kind, seen, registration) {
|
|
437
441
|
const id = requireSlotId(kind, registration?.id);
|
|
@@ -467,6 +471,7 @@ function collectPanelAction(kind, seen, registration) {
|
|
|
467
471
|
};
|
|
468
472
|
}
|
|
469
473
|
function collectPluginAppRegistrations(definition, onWarning = (message) => console.warn(message)) {
|
|
474
|
+
const commandShortcutSchema = createCommandShortcutSchema();
|
|
470
475
|
const sidebarFooterItems = [];
|
|
471
476
|
const collected = {
|
|
472
477
|
homepageSections: [],
|
|
@@ -641,6 +646,16 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
641
646
|
`${kind}: "experimental_useBadge" must be a React hook function when set`
|
|
642
647
|
);
|
|
643
648
|
}
|
|
649
|
+
if (registration.experimental_sidebar !== void 0 && typeof registration.experimental_sidebar !== "function") {
|
|
650
|
+
throw new Error(
|
|
651
|
+
`${kind}: "experimental_sidebar" must be a React component function when set`
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
if (registration.experimental_usePageTitle !== void 0 && typeof registration.experimental_usePageTitle !== "function") {
|
|
655
|
+
throw new Error(
|
|
656
|
+
`${kind}: "experimental_usePageTitle" must be a React hook function when set`
|
|
657
|
+
);
|
|
658
|
+
}
|
|
644
659
|
const fixedTabs = (() => {
|
|
645
660
|
if (registration.fixedTabs === void 0) return [];
|
|
646
661
|
if (!Array.isArray(registration.fixedTabs)) {
|
|
@@ -701,6 +716,10 @@ function collectPluginAppRegistrations(definition, onWarning = (message) => cons
|
|
|
701
716
|
...registration.experimental_useBadge !== void 0 ? {
|
|
702
717
|
experimental_useBadge: registration.experimental_useBadge
|
|
703
718
|
} : {},
|
|
719
|
+
...registration.experimental_usePageTitle !== void 0 ? {
|
|
720
|
+
experimental_usePageTitle: registration.experimental_usePageTitle
|
|
721
|
+
} : {},
|
|
722
|
+
...registration.experimental_sidebar !== void 0 ? { experimental_sidebar: registration.experimental_sidebar } : {},
|
|
704
723
|
...registration.headerContent !== void 0 ? { headerContent: registration.headerContent } : {}
|
|
705
724
|
});
|
|
706
725
|
},
|