Compare commits

...

8 Commits

Author SHA1 Message Date
abeatrix 58ef69d632 Convert esbuild config to ESM and fix import.meta.url handling
- Rename esbuild.js to esbuild.mjs for ES module support
- Add import.meta.url polyfill for CommonJS compatibility
- Fix async/await usage in openExternal function
- Update package.json scripts to use new .mjs extension
2025-07-25 19:29:26 -07:00
abeatrix af2bf8acfd woops 2025-07-25 18:47:28 -07:00
abeatrix 33224a8575 Modernize Node.js imports and replace simple-open-url with open
- Update esbuild.js to use node: protocol imports and ES modules
- Replace simple-open-url dependency with open package in env.ts
- Add proper __dirname handling for ES modules
2025-07-25 18:43:52 -07:00
Sarah Fortune 4747a7f35c Rm unused imports 2025-07-25 02:13:37 -04:00
Sarah Fortune ffa3720a00 Remove vscode hostbridge handler for openExternal 2025-07-25 02:10:42 -04:00
Sarah Fortune 02a8c1a770 Use the simple-open-url module to open URLs in the system browser.
Log failures of ProtoBus RPCs
2025-07-25 02:06:04 -04:00
Sarah Fortune 7d2240571c Change log statement 2025-07-25 01:30:07 -04:00
Sarah Fortune 8e6d5c6a56 Use npm open to open URLs in the external browser
# Conflicts:
#	src/utils/env.ts
2025-07-25 01:30:04 -04:00
9 changed files with 43 additions and 41 deletions
+13 -7
View File
@@ -1,6 +1,10 @@
const esbuild = require("esbuild")
const fs = require("fs")
const path = require("path")
import fs from "node:fs"
import * as esbuild from "esbuild"
import path from "node:path"
import { fileURLToPath } from "node:url"
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const production = process.argv.includes("--production")
const watch = process.argv.includes("--watch")
@@ -127,10 +131,8 @@ const baseConfig = {
sourcemap: !production,
logLevel: "silent",
define: production
? {
"process.env.IS_DEV": JSON.stringify(!production),
}
: undefined,
? { "import.meta.url": "_importMetaUrl", "process.env.IS_DEV": JSON.stringify(!production) }
: { "import.meta.url": "_importMetaUrl" },
tsconfig: path.resolve(__dirname, "tsconfig.json"),
plugins: [
copyWasmFiles,
@@ -141,6 +143,10 @@ const baseConfig = {
format: "cjs",
sourcesContent: false,
platform: "node",
define: { "import.meta.url": "_importMetaUrl" },
banner: {
js: "const _importMetaUrl=require('url').pathToFileURL(__filename)",
},
}
// Extension-specific configuration
+20 -2
View File
@@ -1,12 +1,12 @@
{
"name": "claude-dev",
"version": "3.20.0",
"version": "3.20.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "claude-dev",
"version": "3.20.0",
"version": "3.20.1",
"license": "Apache-2.0",
"dependencies": {
"@anthropic-ai/sdk": "^0.37.0",
@@ -114,6 +114,7 @@
"proxyquire": "^2.1.3",
"rimraf": "^6.0.1",
"should": "^13.2.3",
"simple-open-url": "^3.0.1",
"sinon": "^19.0.2",
"ts-node": "^10.9.2",
"ts-proto": "^2.6.1",
@@ -17132,6 +17133,17 @@
"url": "https://github.com/steveukx/git-js?sponsor=1"
}
},
"node_modules/simple-open-url": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/simple-open-url/-/simple-open-url-3.0.1.tgz",
"integrity": "sha512-JDp3wXr1Ibm3JP7jrm0t2CuKwox2wl51ArEm1DlkEbiLwzGz5jJHxcR96pKZRnVBNLbZDynNInGMANdK+q15zA==",
"dev": true,
"license": "MIT",
"bin": {
"browse": "lib/cli.js",
"simple-open-url": "lib/cli.js"
}
},
"node_modules/sinon": {
"version": "19.0.2",
"resolved": "https://registry.npmjs.org/sinon/-/sinon-19.0.2.tgz",
@@ -31350,6 +31362,12 @@
"debug": "^4.3.5"
}
},
"simple-open-url": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/simple-open-url/-/simple-open-url-3.0.1.tgz",
"integrity": "sha512-JDp3wXr1Ibm3JP7jrm0t2CuKwox2wl51ArEm1DlkEbiLwzGz5jJHxcR96pKZRnVBNLbZDynNInGMANdK+q15zA==",
"dev": true
},
"sinon": {
"version": "19.0.2",
"resolved": "https://registry.npmjs.org/sinon/-/sinon-19.0.2.tgz",
+5 -4
View File
@@ -338,13 +338,13 @@
},
"scripts": {
"vscode:prepublish": "npm run package",
"compile": "npm run check-types && npm run lint && node esbuild.js",
"compile-standalone": "npm run check-types && npm run lint && node esbuild.js --standalone",
"compile": "npm run check-types && npm run lint && node esbuild.mjs",
"compile-standalone": "npm run check-types && npm run lint && node esbuild.mjs --standalone",
"postcompile-standalone": "node scripts/package-standalone.mjs",
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.js --watch",
"watch:esbuild": "node esbuild.mjs --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"package": "npm run check-types && npm run build:webview && npm run lint && node esbuild.js --production",
"package": "npm run check-types && npm run build:webview && npm run lint && node esbuild.mjs --production",
"protos": "node scripts/build-proto.mjs && node scripts/generate-protobus-setup.mjs && node scripts/generate-host-bridge-client.mjs",
"postprotos": "prettier src/shared/proto src/core/controller src/hosts/ webview-ui/src/services src/generated --write --log-level warn",
"clean": "rimraf dist dist-standalone webview-ui/build src/generated out/",
@@ -418,6 +418,7 @@
"proxyquire": "^2.1.3",
"rimraf": "^6.0.1",
"should": "^13.2.3",
"simple-open-url": "^3.0.1",
"sinon": "^19.0.2",
"ts-node": "^10.9.2",
"ts-proto": "^2.6.1",
-3
View File
@@ -13,7 +13,4 @@ service EnvService {
// Reads text from the system clipboard.
rpc clipboardReadText(cline.EmptyRequest) returns (cline.String);
// Opens a URL in the user's default browser or application.
rpc openExternal(cline.StringRequest) returns (cline.Empty);
}
+1
View File
@@ -53,6 +53,7 @@ export class GrpcHandler {
request_id: requestId,
}
} catch (error) {
console.log("Protobus error:", error)
return {
error: error instanceof Error ? error.message : String(error),
request_id: requestId,
+1 -1
View File
@@ -8,7 +8,7 @@ import { openExternal } from "@utils/env"
* @param request The URL to open
* @returns Empty response since the client doesn't need a return value
*/
export async function openInBrowser(controller: Controller, request: StringRequest): Promise<Empty> {
export async function openInBrowser(_controller: Controller, request: StringRequest): Promise<Empty> {
try {
if (request.value) {
await openExternal(request.value)
-8
View File
@@ -1,8 +0,0 @@
import { Empty, StringRequest } from "@/shared/proto/common"
import * as vscode from "vscode"
export async function openExternal(request: StringRequest): Promise<Empty> {
console.log("openExternal called with request:", request)
await vscode.env.openExternal(vscode.Uri.parse(request.value))
return Empty.create()
}
+3 -6
View File
@@ -1,5 +1,6 @@
import { HostProvider } from "@/hosts/host-provider"
import { StringRequest, EmptyRequest } from "@/shared/proto/common"
import open from "open"
/**
* Writes text to the system clipboard
@@ -38,10 +39,6 @@ export async function readTextFromClipboard(): Promise<string> {
* @throws Error if the operation fails
*/
export async function openExternal(url: string): Promise<void> {
try {
await HostProvider.env.openExternal(StringRequest.create({ value: url }))
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error)
throw new Error(`Failed to open external URL: ${errorMessage}`)
}
console.log("Opening browser:", url)
await open(url)
}
@@ -1,9 +1,6 @@
console.log("Loading stub impls...")
const { createStub } = require("./stub-utils")
const open = require("open").default
const fs = require("fs")
const path = require("path")
const { StandaloneTerminalManager } = require("./enhanced-terminal")
// Import the base vscode object from stubs
@@ -174,13 +171,6 @@ vscode.Uri = {
},
}
vscode.env.openExternal = async (uri) => {
const url = typeof uri === "string" ? uri : (uri.toString?.() ?? "")
console.log("Opening browser:", url)
await open(url)
return true
}
// Export the terminal manager globally for Cline core to use
global.standaloneTerminalManager = globalTerminalManager