diff --git a/package-lock.json b/package-lock.json index 71899f99..2ace1483 100644 --- a/package-lock.json +++ b/package-lock.json @@ -432,11 +432,14 @@ "node": ">=12" } }, + "node_modules/@deephaven-enterprise/jsapi-types": { + "resolved": "packages/enterprise-jsapi-types", + "link": true + }, "node_modules/@deephaven/jsapi-types": { "version": "1.0.0-dev0.35.3", "resolved": "https://registry.npmjs.org/@deephaven/jsapi-types/-/jsapi-types-1.0.0-dev0.35.3.tgz", - "integrity": "sha512-0NMh2eRXT16ro4sE/wH0q5+fAdQMitqgKgQ7SwUEtEXq6mp0JWA0xr/x4msdyP3kJB+e6pveTYcgMcHwqrGO/A==", - "dev": true + "integrity": "sha512-0NMh2eRXT16ro4sE/wH0q5+fAdQMitqgKgQ7SwUEtEXq6mp0JWA0xr/x4msdyP3kJB+e6pveTYcgMcHwqrGO/A==" }, "node_modules/@deephaven/require-jsapi": { "resolved": "packages/require-jsapi", @@ -14121,10 +14124,20 @@ "safe-buffer": "~5.2.0" } }, + "packages/enterprise-jsapi-types": { + "version": "0.0.1", + "license": "SEE LICENSE IN LICENSE.md", + "dependencies": { + "@deephaven/jsapi-types": "^1.0.0-dev0.34.3" + } + }, "packages/require-jsapi": { "name": "@deephaven/require-jsapi", "version": "0.0.1", - "license": "SEE LICENSE IN LICENSE.md" + "license": "SEE LICENSE IN LICENSE.md", + "dependencies": { + "@deephaven-enterprise/jsapi-types": "file:../enterprise-jsapi-types" + } } }, "dependencies": { @@ -14450,14 +14463,22 @@ "@jridgewell/trace-mapping": "0.3.9" } }, + "@deephaven-enterprise/jsapi-types": { + "version": "file:packages/enterprise-jsapi-types", + "requires": { + "@deephaven/jsapi-types": "^1.0.0-dev0.34.3" + } + }, "@deephaven/jsapi-types": { "version": "1.0.0-dev0.35.3", "resolved": "https://registry.npmjs.org/@deephaven/jsapi-types/-/jsapi-types-1.0.0-dev0.35.3.tgz", - "integrity": "sha512-0NMh2eRXT16ro4sE/wH0q5+fAdQMitqgKgQ7SwUEtEXq6mp0JWA0xr/x4msdyP3kJB+e6pveTYcgMcHwqrGO/A==", - "dev": true + "integrity": "sha512-0NMh2eRXT16ro4sE/wH0q5+fAdQMitqgKgQ7SwUEtEXq6mp0JWA0xr/x4msdyP3kJB+e6pveTYcgMcHwqrGO/A==" }, "@deephaven/require-jsapi": { - "version": "file:packages/require-jsapi" + "version": "file:packages/require-jsapi", + "requires": { + "@deephaven-enterprise/jsapi-types": "file:../enterprise-jsapi-types" + } }, "@esbuild/aix-ppc64": { "version": "0.21.5", diff --git a/packages/enterprise-jsapi-types/package.json b/packages/enterprise-jsapi-types/package.json new file mode 100644 index 00000000..49512c12 --- /dev/null +++ b/packages/enterprise-jsapi-types/package.json @@ -0,0 +1,17 @@ +{ + "name": "@deephaven-enterprise/jsapi-types", + "version": "0.0.1", + "description": "Deephaven Enterprise Jsapi Types", + "author": "Deephaven Data Labs LLC", + "license": "SEE LICENSE IN LICENSE.md", + "type": "module", + "private": false, + "types": "types/index.d.ts", + "files": [ + "types" + ], + "sideEffects": false, + "dependencies": { + "@deephaven/jsapi-types": "^1.0.0-dev0.34.3" + } +} diff --git a/packages/enterprise-jsapi-types/tsconfig.json b/packages/enterprise-jsapi-types/tsconfig.json new file mode 100644 index 00000000..130026ee --- /dev/null +++ b/packages/enterprise-jsapi-types/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "types", + "noEmit": true, + "skipLibCheck": false + }, + "include": ["types/**/*.ts"], + "exclude": ["node_modules"] +} diff --git a/src/types/@deephaven-enterprise/jsapi-types/CommonTypes.d.ts b/packages/enterprise-jsapi-types/types/CommonTypes.d.ts similarity index 100% rename from src/types/@deephaven-enterprise/jsapi-types/CommonTypes.d.ts rename to packages/enterprise-jsapi-types/types/CommonTypes.d.ts diff --git a/src/types/@deephaven-enterprise/jsapi-types/Iris.d.ts b/packages/enterprise-jsapi-types/types/Iris.d.ts similarity index 100% rename from src/types/@deephaven-enterprise/jsapi-types/Iris.d.ts rename to packages/enterprise-jsapi-types/types/Iris.d.ts diff --git a/src/types/@deephaven-enterprise/jsapi-types/index.d.ts b/packages/enterprise-jsapi-types/types/index.d.ts similarity index 100% rename from src/types/@deephaven-enterprise/jsapi-types/index.d.ts rename to packages/enterprise-jsapi-types/types/index.d.ts diff --git a/src/types/@deephaven-enterprise/jsapi-types/parameterizedQueryTypes.d.ts b/packages/enterprise-jsapi-types/types/parameterizedQueryTypes.d.ts similarity index 100% rename from src/types/@deephaven-enterprise/jsapi-types/parameterizedQueryTypes.d.ts rename to packages/enterprise-jsapi-types/types/parameterizedQueryTypes.d.ts diff --git a/packages/require-jsapi/package.json b/packages/require-jsapi/package.json index dfaf0b9f..cf49113a 100644 --- a/packages/require-jsapi/package.json +++ b/packages/require-jsapi/package.json @@ -15,5 +15,8 @@ "sideEffects": false, "scripts": { "build": "tsc --build" + }, + "dependencies": { + "@deephaven-enterprise/jsapi-types": "file:../enterprise-jsapi-types" } } diff --git a/packages/require-jsapi/src/dhe.ts b/packages/require-jsapi/src/dhe.ts index 4cd736dc..4e6bf745 100644 --- a/packages/require-jsapi/src/dhe.ts +++ b/packages/require-jsapi/src/dhe.ts @@ -1,10 +1,11 @@ -import { hasStatusCode } from './serverUtils'; +import { downloadFromURL, hasStatusCode } from './serverUtils'; import * as fs from 'node:fs'; import * as path from 'node:path'; import type { EnterpriseDhType as DheType, EnterpriseClient, } from '@deephaven-enterprise/jsapi-types'; +import { polyfillDh } from './polyfill'; /** * Check if a given server is running by checking if the `irisapi/irisapi.nocache.js` @@ -39,9 +40,12 @@ export async function createDheClient( }); } -export async function initDheApi(serverUrl: URL): Promise { +export async function initDheApi( + serverUrl: URL, + storageDir: string +): Promise { polyfillDh(); - return getDhe(serverUrl, true); + return getDhe(serverUrl, true, storageDir); } declare global { @@ -50,10 +54,10 @@ declare global { export async function getDhe( serverUrl: URL, - download: boolean + download: boolean, + storageDir: string ): Promise { - const tmpDir = getTempDir(false, urlToDirectoryName(serverUrl)); - const dheFilePath = path.join(tmpDir, 'irisapi.nocache.js'); + const dheFilePath = path.join(storageDir, 'irisapi.nocache.js'); if (download) { const dhe = await downloadFromURL( diff --git a/src/controllers/ExtensionController.ts b/src/controllers/ExtensionController.ts index d908e2f0..d2d5212c 100644 --- a/src/controllers/ExtensionController.ts +++ b/src/controllers/ExtensionController.ts @@ -26,6 +26,7 @@ import { Logger, OutputChannelWithHistory, Toaster, + urlToDirectoryName, } from '../util'; import { RunCommandCodeLensProvider, @@ -60,7 +61,7 @@ import { ServerConnectionTreeDragAndDropController } from './ServerConnectionTre import { ConnectionController } from './ConnectionController'; import { PipServerController } from './PipServerController'; import { PanelController } from './PanelController'; -import { initDheApi } from '../dh/dhe'; +import { initDheApi } from '@deephaven/require-jsapi'; const logger = new Logger('ExtensionController'); @@ -268,7 +269,9 @@ export class ExtensionController implements Disposable { this._toaster ); - this._dheJsApiCache = new CacheByUrlService(initDheApi); + this._dheJsApiCache = new CacheByUrlService(url => + initDheApi(url, getTempDir({ subDirectory: urlToDirectoryName(url) })) + ); this._context.subscriptions.push(this._dheJsApiCache); this._serverManager = new ServerManager(