diff --git a/cli/package.json b/cli/package.json index 7bb6f6d2..2226a311 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "hapi", - "version": "0.12.0-0", + "version": "0.12.0-1", "description": "Mobile and Web client for Claude Code and Codex", "author": "Kirill Dubovitskiy", "license": "MIT", @@ -51,6 +51,12 @@ } } }, + "imports": { + "#embedded-assets": { + "bun": "./src/runtime/embeddedAssets.bun.ts", + "default": "./src/runtime/embeddedAssets.stub.ts" + } + }, "files": [ "dist", "bin", diff --git a/cli/src/bootstrap.ts b/cli/src/bootstrap.ts index 411ff21f..e582eaa0 100644 --- a/cli/src/bootstrap.ts +++ b/cli/src/bootstrap.ts @@ -2,3 +2,5 @@ process.env.DEV = 'false'; await import('./index'); + +export {}; diff --git a/cli/src/runtime/assets.ts b/cli/src/runtime/assets.ts index 9b13ff56..e0723f05 100644 --- a/cli/src/runtime/assets.ts +++ b/cli/src/runtime/assets.ts @@ -3,7 +3,7 @@ import { dirname, join } from 'node:path'; import { arch, platform } from 'node:os'; import * as tar from 'tar'; import packageJson from '../../package.json'; -import type { EmbeddedAsset } from './embeddedAssets'; +import type { EmbeddedAsset } from '#embedded-assets'; import { isBunCompiled, runtimePath } from '@/projectPath'; const RUNTIME_MARKER = '.runtime-version'; @@ -131,7 +131,7 @@ export async function ensureRuntimeAssets(): Promise { return; } - const { loadEmbeddedAssets } = await import('./embeddedAssets'); + const { loadEmbeddedAssets } = await import('#embedded-assets'); const runtimeRoot = runtimePath(); const markerPath = join(runtimeRoot, RUNTIME_MARKER); if (existsSync(markerPath)) { diff --git a/cli/src/runtime/embeddedAssets.ts b/cli/src/runtime/embeddedAssets.bun.ts similarity index 99% rename from cli/src/runtime/embeddedAssets.ts rename to cli/src/runtime/embeddedAssets.bun.ts index 97f3fb43..d7042f1c 100644 --- a/cli/src/runtime/embeddedAssets.ts +++ b/cli/src/runtime/embeddedAssets.bun.ts @@ -10,7 +10,6 @@ import ripgrepArchiveLicense from '../../tools/archives/ripgrep-LICENSE' assert import difftasticLicense from '../../tools/licenses/difftastic-LICENSE' assert { type: 'file' }; import ripgrepLicense from '../../tools/licenses/ripgrep-LICENSE' assert { type: 'file' }; - export interface EmbeddedAsset { relativePath: string; sourcePath: string; diff --git a/cli/src/runtime/embeddedAssets.stub.ts b/cli/src/runtime/embeddedAssets.stub.ts new file mode 100644 index 00000000..b42aab5d --- /dev/null +++ b/cli/src/runtime/embeddedAssets.stub.ts @@ -0,0 +1,8 @@ +export interface EmbeddedAsset { + relativePath: string; + sourcePath: string; +} + +export async function loadEmbeddedAssets(): Promise { + throw new Error('Embedded assets are only available in Bun-compiled binaries.'); +} diff --git a/cli/src/types/bunBundle.d.ts b/cli/src/types/bunBundle.d.ts index a46766cb..46523caf 100644 --- a/cli/src/types/bunBundle.d.ts +++ b/cli/src/types/bunBundle.d.ts @@ -8,4 +8,6 @@ declare module 'bun:bundle' { | 'HAPI_TARGET_WIN32_X64' | 'HAPI_TARGET_WIN32_ARM64'; } + + export function feature(name: Registry['features']): boolean; }