Skip to content

Commit 5e35b3b

Browse files
chore(Cocoon): Standardize naming conventions and casing across IPC and API components
- Rename all `Ipc` references to `IPC` for consistency with project acronym conventions - Convert `Vscode` to `VSCode` in type names and variables to match official branding - Normalize `Api` to `API` in service names and method calls (e.g. `ApiFactory` → `APIFactory`) - Adjust `Workspace` to `WorkSpace` in alignment with VS Code's internal naming patterns - Update ESLint configuration references from `Cocoon.js` to `Cocoon.ts` These changes maintain functional equivalence while ensuring naming consistency across the Cocoon sidecar's codebase, particularly in components interfacing with Mountain via gRPC. The standardization supports clearer cross-component communication in Land's architecture and aligns with established TypeScript conventions in the VS Code ecosystem.
1 parent 29c4dfd commit 5e35b3b

File tree

155 files changed

+1110
-1117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+1110
-1117
lines changed

Source/Cocoon.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212

1313
import * as Path from "path";
1414
import { Barrier, Context, Effect, Layer, Scope } from "effect";
15+
import type { IExtensionHostInitData } from "vs/workbench/services/extensions/common/extensionHostProtocol.js";
1516

1617
import { CoreServicesLayer } from "./Core.js";
1718
import { ExtensionHost } from "./Core/ExtensionHost.js";
1819
import { RequireInterceptor } from "./Core/RequireInterceptor.js";
19-
import { RunProcessPatches } from "./PatchProcess.js";
20+
import { RunProcessPatch } from "./PatchProcess.js";
2021
import { AllServicesLayer } from "./Service.js";
2122
import { InitDataLayer } from "./Service/InitData.js";
22-
import { IpcProvider, Live as LiveIpc } from "./Service/Ipc.js";
23-
import type { IExtensionHostInitData } from "./Type/vscode-proposed.js";
23+
import { IPCProvider, Live as LiveIPC } from "./Service/IPC.js";
2424

2525
// --- Pre-initialization Steps ---
2626
// Add the bundled VS Code module path to Node's search paths. This allows
2727
// imports like `vs/base/common/uri.js` to resolve correctly.
28-
const VscodeOutDir =
28+
const VSCodeOutDir =
2929
process.env["VSCODE_OUT_DIR"] ??
3030
Path.resolve(__dirname, "../../../Dependency/VSCode/out");
31-
(module as any).paths.unshift(VscodeOutDir);
31+
(module as any).paths.unshift(VSCodeOutDir);
3232

3333
// --- Application Logic ---
3434

@@ -58,13 +58,13 @@ const Main = Effect.gen(function* (_) {
5858
const InitBarrier = yield* _(Barrier.make());
5959

6060
// 1. Apply all low-level process patches (e.g., console piping, termination hooks).
61-
yield* _(RunProcessPatches);
61+
yield* _(RunProcessPatch);
6262

6363
// 2. Get the IPC provider.
64-
const Ipc = yield* _(IpcProvider.Tag);
64+
const IPC = yield* _(IPCProvider.Tag);
6565

6666
// 3. Register the handler that will be called by Mountain to kick off initialization.
67-
Ipc.RegisterInvokeHandler(
67+
IPC.RegisterInvokeHandler(
6868
"initExtensionHost",
6969
(InitData: IExtensionHostInitData) =>
7070
Effect.gen(function* (_) {
@@ -90,7 +90,7 @@ const Main = Effect.gen(function* (_) {
9090
);
9191

9292
// 4. Send the 'Ready' signal to Mountain, indicating we are ready for init data.
93-
yield* _(Ipc.SendNotification("$initialHandshake", []));
93+
yield* _(IPC.SendNotification("$initialHandshake", []));
9494
yield* _(Effect.logInfo("Cocoon is ready. Sent handshake to Mountain."));
9595

9696
// 5. Wait for the `initExtensionHost` handler to open the barrier.
@@ -120,7 +120,7 @@ const AppConfig = {
120120
* The base Layer for the application, providing the IPC connection.
121121
* Other layers will be built on top of this.
122122
*/
123-
const CocoonBaseLayer = LiveIpc(AppConfig);
123+
const CocoonBaseLayer = LiveIPC(AppConfig);
124124

125125
// --- Run the Application ---
126126

Source/Command/ProcessUserData/GetActiveTextEditor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
*/
55

66
import { Effect, Option } from "effect";
7-
import * as Vscode from "vscode";
7+
import * as VSCode from "vscode";
88

99
/**
1010
* An Effect that safely retrieves the active text editor.
11-
* @returns An `Effect` that resolves to an `Option<Vscode.TextEditor>`, which
11+
* @returns An `Effect` that resolves to an `Option<VSCode.TextEditor>`, which
1212
* will be `None` if no editor is active, and `Some` otherwise.
1313
*/
1414
export const GetActiveTextEditor = Effect.sync(() =>
15-
Option.fromNullable(Vscode.window.activeTextEditor),
15+
Option.fromNullable(VSCode.window.activeTextEditor),
1616
);

Source/Command/ProcessUserData/GetDocumentText.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
*/
55

66
import { Effect } from "effect";
7-
import type * as Vscode from "vscode";
7+
import type * as VSCode from "vscode";
88

99
/**
1010
* An Effect that gets the full text content of a given document.
1111
* @param Document - The `vscode.TextDocument` to read from.
1212
* @returns An `Effect` that synchronously resolves to the document's text content.
1313
*/
1414
export const GetDocumentText = (
15-
Document: Vscode.TextDocument,
15+
Document: VSCode.TextDocument,
1616
): Effect.Effect<string> => Effect.sync(() => Document.getText());

Source/Configuration/ESBuild/Cocoon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default {
3434
{
3535
name: "Target",
3636
// @ts-ignore
37-
setup({ onStart, initialOptions: { outdir } }) {
37+
setup({ onStart, initialOption: { outdir } }) {
3838
switch (true) {
3939
case Clean === true:
4040
onStart(async () => {

Source/Configuration/ESBuild/Cocoon.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Export: Clean, On
77
*/
88

9-
import type { BuildOptions } from "esbuild";
9+
import type { BuildOption } from "esbuild";
1010

1111
export const On =
1212
process.env["NODE_ENV"] === "development" ||
@@ -40,7 +40,7 @@ export default {
4040
{
4141
name: "Target",
4242
// @ts-ignore
43-
setup({ onStart, initialOptions: { outdir } }) {
43+
setup({ onStart, initialOption: { outdir } }) {
4444
switch (true) {
4545
case Clean === true:
4646
onStart(async () => {
@@ -66,6 +66,6 @@ export default {
6666
},
6767
],
6868
outbase: "Source/Configuration",
69-
} satisfies BuildOptions as BuildOptions;
69+
} satisfies BuildOption as BuildOption;
7070

7171
export const { sep, posix } = await import("node:path");

Source/Configuration/ESBuild/Target.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
//
3434
//--------------------------------------------------------------------------------------------*/
3535

36-
import type { BuildOptions } from "esbuild";
36+
import type { BuildOption } from "esbuild";
3737

3838
// Import the global API function name constant from the compiled interceptor module.
3939
// This ensures the build configuration uses the exact same string that the interceptor expects.
@@ -53,10 +53,10 @@ export const On = (await import("./Cocoon.js")).On;
5353
/**
5454
* ESBuild configuration module.
5555
*
56-
* @param Current - The current BuildOptions, potentially passed from a preceding build step or CLI.
57-
* @returns A Promise resolving to the configured BuildOptions for esbuild.
56+
* @param Current - The current BuildOption, potentially passed from a preceding build step or CLI.
57+
* @returns A Promise resolving to the configured BuildOption for esbuild.
5858
*/
59-
export default async (Current: BuildOptions): Promise<BuildOptions> => {
59+
export default async (Current: BuildOption): Promise<BuildOption> => {
6060
// Asynchronously import dependencies for the configuration logic.
6161
const [deepmergeMod, cocoonMod, ulidMod, playformBuildEntryMod] =
6262
await Promise.all([
@@ -76,20 +76,20 @@ export default async (Current: BuildOptions): Promise<BuildOptions> => {
7676
const { deepmerge } = deepmergeMod;
7777

7878
// Base configuration
79-
const CocoonDefaultConfig = cocoonMod.default as BuildOptions;
79+
const CocoonDefaultConfig = cocoonMod.default as BuildOption;
8080

8181
const { ulid } = ulidMod;
8282

8383
const getEntryPoints = playformBuildEntryMod.default as (
84-
current: BuildOptions,
84+
current: BuildOption,
8585

8686
patterns: string[],
8787

8888
// Type assertion for clarity
8989
) => string[] | Record<string, string>;
9090

9191
// Merge the base configuration with specific overrides and additions.
92-
return deepmerge<[BuildOptions, BuildOptions]>(CocoonDefaultConfig, {
92+
return deepmerge<[BuildOption, BuildOption]>(CocoonDefaultConfig, {
9393
// Specifies the output directory for compiled files.
9494
outdir: "Target",
9595

Source/Core.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import { Layer } from "effect";
44

5-
import { Live as LiveApiFactory } from "./ApiFactory.js";
6-
import { Live as LiveExtensionHost } from "./ExtensionHost.js";
7-
import { Live as LiveExtensionPaths } from "./ExtensionPath.js";
8-
import { Live as LiveRequireInterceptor } from "./RequireInterceptor.js";
5+
import { Live as LiveAPIFactory } from "./Core/APIFactory.js";
6+
import { Live as LiveExtensionHost } from "./Core/ExtensionHost.js";
7+
import { Live as LiveExtensionPaths } from "./Core/ExtensionPath.js";
8+
import { Live as LiveRequireInterceptor } from "./Core/RequireInterceptor.js";
99

1010
/**
1111
* @module Core
@@ -16,17 +16,17 @@ import { Live as LiveRequireInterceptor } from "./RequireInterceptor.js";
1616

1717
// --- Re-exporting the full public API (Tag, Interface, Live Layer) for each core service ---
1818

19-
export * as ApiFactory from "./ApiFactory.js";
20-
export * as ExtensionHost from "./ExtensionHost.js";
21-
export * as ExtensionPaths from "./ExtensionPath.js";
22-
export * as RequireInterceptor from "./RequireInterceptor.js";
19+
export * as APIFactory from "./Core/APIFactory.js";
20+
export * as ExtensionHost from "./Core/ExtensionHost.js";
21+
export * as ExtensionPaths from "./Core/ExtensionPath.js";
22+
export * as RequireInterceptor from "./Core/RequireInterceptor.js";
2323

2424
/**
2525
* A single, composed layer that provides all core services of the extension host.
2626
* This simplifies the process of building the final application layer in `Index.ts`.
2727
*/
2828
export const CoreServicesLayer = Layer.mergeAll(
29-
LiveApiFactory,
29+
LiveAPIFactory,
3030
LiveExtensionHost,
3131
LiveExtensionPaths,
3232
LiveRequireInterceptor,

Source/Core/APIFactory.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
11
/**
2-
* @module ApiFactory
3-
* @description The main module for the `ApiFactory` service, which is
2+
* @module APIFactory
3+
* @description The main module for the `APIFactory` service, which is
44
* responsible for creating sandboxed `vscode` API objects for extensions.
55
*/
66

77
import { Context, Effect, Layer } from "effect";
88
import type { IExtensionDescription } from "vs/platform/extensions/common/extensions.js";
9-
import type * as Vscode from "vscode";
9+
import type * as VSCode from "vscode";
1010

1111
import * as Service from "../../Service.js";
12-
import { CreateApiFactory } from "./CreateApiFactory.js";
12+
import { CreateAPIFactory } from "./CreateAPIFactory.js";
1313

1414
/**
15-
* The interface for the `ApiFactory` service.
15+
* The interface for the `APIFactory` service.
1616
*/
1717
export interface Interface {
1818
/**
1919
* Creates a new, sandboxed `vscode` API object for a specific extension.
2020
* @param Extension The full description of the extension requesting the API.
2121
* @returns A frozen `vscode` API object tailored for the extension.
2222
*/
23-
readonly Create: (Extension: IExtensionDescription) => typeof Vscode;
23+
readonly Create: (Extension: IExtensionDescription) => typeof VSCode;
2424
}
2525

2626
/**
27-
* The `Context.Tag` for the `ApiFactory` service.
27+
* The `Context.Tag` for the `APIFactory` service.
2828
*/
29-
export const Tag = Context.Tag<Interface>("ApiFactory");
29+
export const Tag = Context.Tag<Interface>("APIFactory");
3030

3131
/**
32-
* The live implementation `Layer` for the `ApiFactory` service.
32+
* The live implementation `Layer` for the `APIFactory` service.
3333
*
3434
* This layer has a comprehensive dependency graph, as it requires every
3535
* underlying service that contributes to the final `vscode` API object. It
36-
* injects all of these services into the `CreateApiFactory` function to
36+
* injects all of these services into the `CreateAPIFactory` function to
3737
* construct the final service implementation.
3838
*/
3939
export const Live = Layer.effect(
4040
Tag,
4141
Effect.gen(function* (_) {
4242
// --- Inject all necessary services ---
4343
const LogService = yield* _(Service.Log.Tag);
44-
const ProposedApiService = yield* _(Service.ProposedApi.Tag);
45-
const DeprecationService = yield* _(Service.ApiDeprecation.Tag);
46-
const CommandsService = yield* _(Service.Commands.Tag);
47-
const WorkspaceService = yield* _(Service.Workspace.Tag);
44+
const ProposedAPIService = yield* _(Service.ProposedAPI.Tag);
45+
const DeprecationService = yield* _(Service.APIDeprecation.Tag);
46+
const CommandService = yield* _(Service.Command.Tag);
47+
const WorkSpaceService = yield* _(Service.WorkSpace.Tag);
4848
const WindowService = yield* _(Service.Window.Tag);
4949
const LanguageFeaturesService = yield* _(Service.LanguageFeatures.Tag);
5050
const DebugService = yield* _(Service.Debug.Tag);
5151
const TasksService = yield* _(Service.Tasks.Tag);
5252
const ExtensionService = yield* _(Service.Extension.Tag);
53-
const WebviewPanelService = yield* _(Service.WebviewPanel.Tag);
53+
const WebViewPanelService = yield* _(Service.WebViewPanel.Tag);
5454
const CustomEditorService = yield* _(Service.CustomEditor.Tag);
5555
const TreeViewService = yield* _(Service.TreeView.Tag);
5656
const StatusBarService = yield* _(Service.StatusBar.Tag);
5757
// Add other services here as they are implemented.
5858

5959
// --- Construct the factory with all its dependencies ---
60-
return CreateApiFactory(
60+
return CreateAPIFactory(
6161
LogService,
62-
ProposedApiService,
62+
ProposedAPIService,
6363
DeprecationService,
64-
CommandsService,
65-
WorkspaceService,
64+
CommandService,
65+
WorkSpaceService,
6666
WindowService,
6767
LanguageFeaturesService,
6868
DebugService,
6969
TasksService,
7070
ExtensionService,
71-
WebviewPanelService,
71+
WebViewPanelService,
7272
CustomEditorService,
7373
TreeViewService,
7474
StatusBarService,

Source/Core/ApiFactory/AsExtensionEvent.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* to provide safe error handling for extension listeners.
55
*/
66

7-
import type * as Vscode from "vscode";
7+
import type * as VSCode from "vscode";
88

99
import type { Log } from "../../Service.js";
1010

@@ -23,10 +23,10 @@ import type { Log } from "../../Service.js";
2323
* @returns A new, safe `vscode.Event<T>` that can be exposed to extensions.
2424
*/
2525
export const AsExtensionEvent = <T>(
26-
ExtensionId: Vscode.ExtensionIdentifier,
26+
ExtensionId: VSCode.ExtensionIdentifier,
2727
LogService: Log.Interface,
28-
ActualEvent: Vscode.Event<T>,
29-
): Vscode.Event<T> => {
28+
ActualEvent: VSCode.Event<T>,
29+
): VSCode.Event<T> => {
3030
// Return a new event subscription function.
3131
return (Listener, ThisArgument, Disposables) => {
3232
// Create a "safe" listener that wraps the original extension-provided listener.

0 commit comments

Comments
 (0)