Skip to content

Commit 87f1977

Browse files
1 parent 262885a commit 87f1977

19 files changed

Lines changed: 180 additions & 53 deletions

File tree

Source/Codegen/Emit/EmitBridgeShape.ts

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ export interface EmitBridgeShapeOptions {
4242
* `<ServiceFolder>BridgeShape`.
4343
*/
4444
readonly BridgeFileName?: string;
45+
/** Override the `__CEL_SERVICES__` accessor key. Defaults to
46+
* `decoratorName.replace(/^I/, "")`. Set to align with the
47+
* actual Output binding (e.g. `Clipboard` for `IClipboardService`).
48+
*/
49+
readonly AccessorName?: string;
50+
/** Override the exported Globals interface name. Defaults to
51+
* `<decoratorName>Globals`.
52+
*/
53+
readonly GlobalsInterfaceName?: string;
54+
/** Override the exported Pick<> type alias name. Defaults to
55+
* `BridgeFileName` with any trailing `Generated` suffix stripped.
56+
*/
57+
readonly ShapeTypeName?: string;
4558
}
4659

4760
export interface EmitBridgeShapeOutcome {
@@ -59,11 +72,13 @@ const FormatOutput = (
5972
record: ServiceDecoratorRecord,
6073
pickedMembers: ReadonlyArray<string>,
6174
bridgeFileName: string,
75+
accessorName: string,
76+
globalsInterfaceName: string,
77+
shapeTypeName: string,
6278
): string => {
6379
const UpstreamModule = `../../Generated/${record.DecoratorName}/${record.DecoratorName}Upstream.js`;
6480
const UpstreamType = `${record.DecoratorName}Upstream`;
6581
const PickClause = FormatPickUnion(pickedMembers);
66-
const ShapeName = bridgeFileName.replace(/Shape$/, "Shape");
6782
return [
6883
"/**",
6984
` * @module Effect/${record.DecoratorName}/Bridge/${bridgeFileName}`,
@@ -81,11 +96,11 @@ const FormatOutput = (
8196
"",
8297
`import type { ${UpstreamType} } from "${UpstreamModule}";`,
8398
"",
84-
`export type ${ShapeName} = Pick<${UpstreamType}, ${PickClause}>;`,
99+
`export type ${shapeTypeName} = Pick<${UpstreamType}, ${PickClause}>;`,
85100
"",
86-
`export interface ${record.DecoratorName}Globals {`,
101+
`export interface ${globalsInterfaceName} {`,
87102
"\treadonly __CEL_SERVICES__?: {",
88-
`\t\treadonly ${record.DecoratorName.replace(/^I/, "")}?: ${ShapeName} | null;`,
103+
`\t\treadonly ${accessorName}?: ${shapeTypeName} | null;`,
89104
"\t};",
90105
"}",
91106
"",
@@ -103,7 +118,35 @@ export const EmitBridgeShape = async (
103118
const FileName =
104119
options.BridgeFileName ?? `${options.ServiceFolder}BridgeShape`;
105120

106-
const Output = FormatOutput(options.Record, ResolvedPicks, FileName);
121+
// `ShapeTypeName` defaults to FileName with trailing `Generated`
122+
// stripped so the exported type is e.g. `WorkbenchClipboardBridgeShape`
123+
// even when the file is `WorkbenchClipboardBridgeShapeGenerated.ts`.
124+
// This lets the hand-authored `BridgeShape.ts` collapse to a one-line
125+
// `export type {...} from "./WorkbenchClipboardBridgeShapeGenerated.js"`.
126+
const ShapeTypeName =
127+
options.ShapeTypeName ?? FileName.replace(/Generated$/, "");
128+
// `AccessorName` defaults to `decoratorName.replace(/^I/, "")` for
129+
// backward-compat (so e.g. `IClipboardService` → `ClipboardService`).
130+
// Output's `ExposeWorkbenchAccessor` typically exposes a shorter
131+
// name (`Clipboard`); manifest entries opt in via `AccessorName`.
132+
const AccessorName =
133+
options.AccessorName ??
134+
options.Record.DecoratorName.replace(/^I/, "");
135+
// `GlobalsInterfaceName` defaults to `<DecoratorName>Globals`. Set
136+
// to `Workbench<X>Globals` in manifest entries that want the
137+
// hand-authored layer to re-export both Shape + Globals together.
138+
const GlobalsInterfaceName =
139+
options.GlobalsInterfaceName ??
140+
`${options.Record.DecoratorName}Globals`;
141+
142+
const Output = FormatOutput(
143+
options.Record,
144+
ResolvedPicks,
145+
FileName,
146+
AccessorName,
147+
GlobalsInterfaceName,
148+
ShapeTypeName,
149+
);
107150
const OutputPath = join(
108151
options.OutputRoot,
109152
"Effect",

Source/Codegen/Emit/EmitBridgeShapeBatch.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,33 @@ export interface BridgeShapeManifestEntry {
2222
readonly ServiceFolder: string;
2323
readonly BridgeFileName?: string;
2424
readonly PickMembers: ReadonlyArray<string>;
25+
/**
26+
* Override for the `__CEL_SERVICES__` accessor key emitted in the
27+
* Globals interface. Defaults to `decoratorName.replace(/^I/, "")`
28+
* (e.g. `IClipboardService` → `ClipboardService`). Set this when
29+
* Output's `ExposeWorkbenchAccessor` exposes the service under a
30+
* shorter name (e.g. `Clipboard`, `Storage`, `Theme`, `Lifecycle`,
31+
* `Keybinding`, `Notification`, `Dialog`, `Host`, `Editor`,
32+
* `Workspace`, `Product`, `Progress`, `Activity`, `Command`,
33+
* `ContextKey`).
34+
*/
35+
readonly AccessorName?: string;
36+
/**
37+
* Override for the exported globals interface name. Defaults to
38+
* `<decoratorName>Globals`. Set to e.g. `Workbench<X>Globals` to
39+
* line up with the hand-authored `BridgeShape.ts` re-exports so
40+
* Live layers can swap in the Generated shape via a one-line
41+
* `export type {...} from "./...Generated.js"`.
42+
*/
43+
readonly GlobalsInterfaceName?: string;
44+
/**
45+
* Override for the exported Pick<> type alias name. Defaults to the
46+
* `BridgeFileName` verbatim (or `<ServiceFolder>BridgeShape` if
47+
* unset). When `BridgeFileName` ends in `Generated`, the suffix is
48+
* stripped so the exported type matches the hand-authored shape's
49+
* canonical name.
50+
*/
51+
readonly ShapeTypeName?: string;
2552
}
2653

2754
export interface EmitBridgeShapeBatchOptions {
@@ -68,6 +95,9 @@ export const EmitBridgeShapeBatch = async (
6895
ServiceFolder: Entry.ServiceFolder,
6996
BridgeFileName: Entry.BridgeFileName,
7097
PickMembers: Entry.PickMembers,
98+
AccessorName: Entry.AccessorName,
99+
GlobalsInterfaceName: Entry.GlobalsInterfaceName,
100+
ShapeTypeName: Entry.ShapeTypeName,
71101
});
72102
if ("_tag" in Outcome) {
73103
Failures.push(Outcome);

Source/Codegen/Manifest/WorkbenchBridgeShapeManifest.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
2525
DecoratorName: "IClipboardService",
2626
ServiceFolder: "WorkbenchClipboard",
2727
BridgeFileName: "WorkbenchClipboardBridgeShapeGenerated",
28+
AccessorName: "Clipboard",
29+
GlobalsInterfaceName: "WorkbenchClipboardGlobals",
30+
ShapeTypeName: "WorkbenchClipboardBridgeShape",
2831
PickMembers: [
2932
"readText",
3033
"writeText",
@@ -37,6 +40,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
3740
DecoratorName: "ICommandService",
3841
ServiceFolder: "WorkbenchCommand",
3942
BridgeFileName: "WorkbenchCommandBridgeShapeGenerated",
43+
AccessorName: "Commands",
44+
GlobalsInterfaceName: "WorkbenchCommandGlobals",
45+
ShapeTypeName: "WorkbenchCommandBridgeShape",
4046
PickMembers: [
4147
"executeCommand",
4248
"onWillExecuteCommand",
@@ -48,6 +54,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
4854
DecoratorName: "IConfigurationService",
4955
ServiceFolder: "UserSettings",
5056
BridgeFileName: "UserSettingsBridgeShapeGenerated",
57+
AccessorName: "Configuration",
58+
GlobalsInterfaceName: "UserSettingsGlobals",
59+
ShapeTypeName: "UserSettingsBridgeShape",
5160
PickMembers: [
5261
"getValue",
5362
"updateValue",
@@ -60,6 +69,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
6069
DecoratorName: "IContextKeyService",
6170
ServiceFolder: "WorkbenchContextKey",
6271
BridgeFileName: "WorkbenchContextKeyBridgeShapeGenerated",
72+
AccessorName: "ContextKey",
73+
GlobalsInterfaceName: "WorkbenchContextKeyGlobals",
74+
ShapeTypeName: "WorkbenchContextKeyBridgeShape",
6375
PickMembers: [
6476
"getContextKeyValue",
6577
"createKey",
@@ -72,13 +84,19 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
7284
DecoratorName: "IDialogService",
7385
ServiceFolder: "WorkbenchDialog",
7486
BridgeFileName: "WorkbenchDialogBridgeShapeGenerated",
87+
AccessorName: "Dialog",
88+
GlobalsInterfaceName: "WorkbenchDialogGlobals",
89+
ShapeTypeName: "WorkbenchDialogBridgeShape",
7590
PickMembers: ["confirm", "prompt", "info", "warn", "error"],
7691
},
7792
{
7893
// @upstream src/vs/workbench/services/editor/common/editorService.ts
7994
DecoratorName: "IEditorService",
8095
ServiceFolder: "WorkbenchEditor",
8196
BridgeFileName: "WorkbenchEditorBridgeShapeGenerated",
97+
AccessorName: "Editor",
98+
GlobalsInterfaceName: "WorkbenchEditorGlobals",
99+
ShapeTypeName: "WorkbenchEditorBridgeShape",
82100
PickMembers: [
83101
"activeEditorPane",
84102
"openEditor",
@@ -91,6 +109,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
91109
DecoratorName: "IExtensionService",
92110
ServiceFolder: "WorkbenchExtension",
93111
BridgeFileName: "WorkbenchExtensionBridgeShapeGenerated",
112+
AccessorName: "Extension",
113+
GlobalsInterfaceName: "WorkbenchExtensionGlobals",
114+
ShapeTypeName: "WorkbenchExtensionBridgeShape",
94115
PickMembers: [
95116
"extensions",
96117
"activateById",
@@ -103,6 +124,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
103124
DecoratorName: "IHostService",
104125
ServiceFolder: "WorkbenchHost",
105126
BridgeFileName: "WorkbenchHostBridgeShapeGenerated",
127+
AccessorName: "Host",
128+
GlobalsInterfaceName: "WorkbenchHostGlobals",
129+
ShapeTypeName: "WorkbenchHostBridgeShape",
106130
PickMembers: [
107131
"reload",
108132
"restart",
@@ -118,6 +142,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
118142
DecoratorName: "IKeybindingService",
119143
ServiceFolder: "WorkbenchKeybinding",
120144
BridgeFileName: "WorkbenchKeybindingBridgeShapeGenerated",
145+
AccessorName: "Keybinding",
146+
GlobalsInterfaceName: "WorkbenchKeybindingGlobals",
147+
ShapeTypeName: "WorkbenchKeybindingBridgeShape",
121148
PickMembers: [
122149
"lookupKeybindings",
123150
"resolveKeyboardEvent",
@@ -129,20 +156,29 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
129156
DecoratorName: "ILifecycleService",
130157
ServiceFolder: "WorkbenchLifecycle",
131158
BridgeFileName: "WorkbenchLifecycleBridgeShapeGenerated",
159+
AccessorName: "Lifecycle",
160+
GlobalsInterfaceName: "WorkbenchLifecycleGlobals",
161+
ShapeTypeName: "WorkbenchLifecycleBridgeShape",
132162
PickMembers: ["phase", "when", "onWillShutdown", "onDidShutdown"],
133163
},
134164
{
135165
// @upstream src/vs/platform/notification/common/notification.ts
136166
DecoratorName: "INotificationService",
137167
ServiceFolder: "WorkbenchNotification",
138168
BridgeFileName: "WorkbenchNotificationBridgeShapeGenerated",
169+
AccessorName: "Notification",
170+
GlobalsInterfaceName: "WorkbenchNotificationGlobals",
171+
ShapeTypeName: "WorkbenchNotificationBridgeShape",
139172
PickMembers: ["notify", "info", "warn", "error"],
140173
},
141174
{
142175
// @upstream src/vs/platform/product/common/productService.ts
143176
DecoratorName: "IProductService",
144177
ServiceFolder: "WorkbenchProduct",
145178
BridgeFileName: "WorkbenchProductBridgeShapeGenerated",
179+
AccessorName: "Product",
180+
GlobalsInterfaceName: "WorkbenchProductGlobals",
181+
ShapeTypeName: "WorkbenchProductBridgeShape",
146182
PickMembers: [
147183
"nameLong",
148184
"nameShort",
@@ -159,13 +195,19 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
159195
DecoratorName: "IProgressService",
160196
ServiceFolder: "WorkbenchProgress",
161197
BridgeFileName: "WorkbenchProgressBridgeShapeGenerated",
198+
AccessorName: "Progress",
199+
GlobalsInterfaceName: "WorkbenchProgressGlobals",
200+
ShapeTypeName: "WorkbenchProgressBridgeShape",
162201
PickMembers: ["withProgress"],
163202
},
164203
{
165204
// @upstream src/vs/platform/storage/common/storage.ts
166205
DecoratorName: "IStorageService",
167206
ServiceFolder: "WorkbenchStorage",
168207
BridgeFileName: "WorkbenchStorageBridgeShapeGenerated",
208+
AccessorName: "Storage",
209+
GlobalsInterfaceName: "WorkbenchStorageGlobals",
210+
ShapeTypeName: "WorkbenchStorageBridgeShape",
169211
PickMembers: [
170212
"get",
171213
"getBoolean",
@@ -182,6 +224,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
182224
DecoratorName: "IWorkbenchThemeService",
183225
ServiceFolder: "WorkbenchTheme",
184226
BridgeFileName: "WorkbenchThemeBridgeShapeGenerated",
227+
AccessorName: "WorkbenchTheme",
228+
GlobalsInterfaceName: "WorkbenchThemeGlobals",
229+
ShapeTypeName: "WorkbenchThemeBridgeShape",
185230
PickMembers: [
186231
"getColorTheme",
187232
"getColorThemes",
@@ -194,6 +239,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
194239
DecoratorName: "IWorkspaceContextService",
195240
ServiceFolder: "WorkbenchWorkspace",
196241
BridgeFileName: "WorkbenchWorkspaceBridgeShapeGenerated",
242+
AccessorName: "Workspace",
243+
GlobalsInterfaceName: "WorkbenchWorkspaceGlobals",
244+
ShapeTypeName: "WorkbenchWorkspaceBridgeShape",
197245
PickMembers: [
198246
"getWorkspace",
199247
"getWorkspaceFolder",
@@ -205,6 +253,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
205253
DecoratorName: "IActivityService",
206254
ServiceFolder: "WorkbenchActivity",
207255
BridgeFileName: "WorkbenchActivityBridgeShapeGenerated",
256+
AccessorName: "Activity",
257+
GlobalsInterfaceName: "WorkbenchActivityGlobals",
258+
ShapeTypeName: "WorkbenchActivityBridgeShape",
208259
PickMembers: [
209260
"showViewContainerActivity",
210261
"showViewActivity",
@@ -217,6 +268,9 @@ export const WorkbenchBridgeShapeManifest: ReadonlyArray<BridgeShapeManifestEntr
217268
DecoratorName: "IWorkbenchLayoutService",
218269
ServiceFolder: "WorkbenchLayout",
219270
BridgeFileName: "WorkbenchLayoutBridgeShapeGenerated",
271+
AccessorName: "Layout",
272+
GlobalsInterfaceName: "WorkbenchLayoutGlobals",
273+
ShapeTypeName: "WorkbenchLayoutBridgeShape",
220274
PickMembers: [
221275
"isVisible",
222276
"setPartHidden",

Source/Effect/UserSettings/Implementation/UserSettingsBridgeShapeGenerated.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
import type { IConfigurationServiceUpstream } from "../../Generated/IConfigurationService/IConfigurationServiceUpstream.js";
1616

17-
export type UserSettingsBridgeShapeGenerated = Pick<IConfigurationServiceUpstream, "getValue" | "updateValue" | "inspect" | "onDidChangeConfiguration">;
17+
export type UserSettingsBridgeShape = Pick<IConfigurationServiceUpstream, "getValue" | "updateValue" | "inspect" | "onDidChangeConfiguration">;
1818

19-
export interface IConfigurationServiceGlobals {
19+
export interface UserSettingsGlobals {
2020
readonly __CEL_SERVICES__?: {
21-
readonly ConfigurationService?: UserSettingsBridgeShapeGenerated | null;
21+
readonly Configuration?: UserSettingsBridgeShape | null;
2222
};
2323
}

Source/Effect/WorkbenchActivity/Implementation/WorkbenchActivityBridgeShapeGenerated.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
import type { IActivityServiceUpstream } from "../../Generated/IActivityService/IActivityServiceUpstream.js";
1616

17-
export type WorkbenchActivityBridgeShapeGenerated = Pick<IActivityServiceUpstream, "showViewContainerActivity" | "showViewActivity" | "showAccountsActivity" | "showGlobalActivity">;
17+
export type WorkbenchActivityBridgeShape = Pick<IActivityServiceUpstream, "showViewContainerActivity" | "showViewActivity" | "showAccountsActivity" | "showGlobalActivity">;
1818

19-
export interface IActivityServiceGlobals {
19+
export interface WorkbenchActivityGlobals {
2020
readonly __CEL_SERVICES__?: {
21-
readonly ActivityService?: WorkbenchActivityBridgeShapeGenerated | null;
21+
readonly Activity?: WorkbenchActivityBridgeShape | null;
2222
};
2323
}

Source/Effect/WorkbenchClipboard/Implementation/WorkbenchClipboardBridgeShapeGenerated.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
import type { IClipboardServiceUpstream } from "../../Generated/IClipboardService/IClipboardServiceUpstream.js";
1616

17-
export type WorkbenchClipboardBridgeShapeGenerated = Pick<IClipboardServiceUpstream, "readText" | "writeText" | "readResources" | "writeResources">;
17+
export type WorkbenchClipboardBridgeShape = Pick<IClipboardServiceUpstream, "readText" | "writeText" | "readResources" | "writeResources">;
1818

19-
export interface IClipboardServiceGlobals {
19+
export interface WorkbenchClipboardGlobals {
2020
readonly __CEL_SERVICES__?: {
21-
readonly ClipboardService?: WorkbenchClipboardBridgeShapeGenerated | null;
21+
readonly Clipboard?: WorkbenchClipboardBridgeShape | null;
2222
};
2323
}

Source/Effect/WorkbenchCommand/Implementation/WorkbenchCommandBridgeShapeGenerated.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
import type { ICommandServiceUpstream } from "../../Generated/ICommandService/ICommandServiceUpstream.js";
1616

17-
export type WorkbenchCommandBridgeShapeGenerated = Pick<ICommandServiceUpstream, "executeCommand" | "onWillExecuteCommand" | "onDidExecuteCommand">;
17+
export type WorkbenchCommandBridgeShape = Pick<ICommandServiceUpstream, "executeCommand" | "onWillExecuteCommand" | "onDidExecuteCommand">;
1818

19-
export interface ICommandServiceGlobals {
19+
export interface WorkbenchCommandGlobals {
2020
readonly __CEL_SERVICES__?: {
21-
readonly CommandService?: WorkbenchCommandBridgeShapeGenerated | null;
21+
readonly Commands?: WorkbenchCommandBridgeShape | null;
2222
};
2323
}

Source/Effect/WorkbenchContextKey/Implementation/WorkbenchContextKeyBridgeShapeGenerated.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
import type { IContextKeyServiceUpstream } from "../../Generated/IContextKeyService/IContextKeyServiceUpstream.js";
1616

17-
export type WorkbenchContextKeyBridgeShapeGenerated = Pick<IContextKeyServiceUpstream, "getContextKeyValue" | "createKey" | "contextMatchesRules" | "onDidChangeContext">;
17+
export type WorkbenchContextKeyBridgeShape = Pick<IContextKeyServiceUpstream, "getContextKeyValue" | "createKey" | "contextMatchesRules" | "onDidChangeContext">;
1818

19-
export interface IContextKeyServiceGlobals {
19+
export interface WorkbenchContextKeyGlobals {
2020
readonly __CEL_SERVICES__?: {
21-
readonly ContextKeyService?: WorkbenchContextKeyBridgeShapeGenerated | null;
21+
readonly ContextKey?: WorkbenchContextKeyBridgeShape | null;
2222
};
2323
}

Source/Effect/WorkbenchDialog/Implementation/WorkbenchDialogBridgeShapeGenerated.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
import type { IDialogServiceUpstream } from "../../Generated/IDialogService/IDialogServiceUpstream.js";
1616

17-
export type WorkbenchDialogBridgeShapeGenerated = Pick<IDialogServiceUpstream, "confirm" | "prompt" | "info" | "warn" | "error">;
17+
export type WorkbenchDialogBridgeShape = Pick<IDialogServiceUpstream, "confirm" | "prompt" | "info" | "warn" | "error">;
1818

19-
export interface IDialogServiceGlobals {
19+
export interface WorkbenchDialogGlobals {
2020
readonly __CEL_SERVICES__?: {
21-
readonly DialogService?: WorkbenchDialogBridgeShapeGenerated | null;
21+
readonly Dialog?: WorkbenchDialogBridgeShape | null;
2222
};
2323
}

0 commit comments

Comments
 (0)