simplify code

This commit is contained in:
Aiden Cline
2026-05-10 23:18:54 -05:00
parent 7f0b5dcbee
commit 7be017016c
2 changed files with 10 additions and 23 deletions

View File

@@ -188,10 +188,6 @@ for (const item of targets) {
const localPath = path.resolve(dir, "node_modules/@opentui/core/parser.worker.js")
const rootPath = path.resolve(dir, "../../node_modules/@opentui/core/parser.worker.js")
const parserWorker = fs.realpathSync(fs.existsSync(localPath) ? localPath : rootPath)
const photonWasm = path.relative(
dir,
fileURLToPath(import.meta.resolve("@silvia-odwyer/photon-node/photon_rs_bg.wasm")),
).replaceAll("\\", "/")
const workerPath = "./src/cli/cmd/tui/worker.ts"
// Use platform-specific bunfs root path based on target OS
@@ -218,13 +214,7 @@ for (const item of targets) {
windows: {},
},
files: embeddedFileMap ? { "opencode-web-ui.gen.ts": embeddedFileMap } : {},
entrypoints: [
"./src/index.ts",
parserWorker,
workerPath,
photonWasm,
...(embeddedFileMap ? ["opencode-web-ui.gen.ts"] : []),
],
entrypoints: ["./src/index.ts", parserWorker, workerPath, ...(embeddedFileMap ? ["opencode-web-ui.gen.ts"] : [])],
define: {
OPENCODE_VERSION: `'${Script.version}'`,
OPENCODE_MIGRATIONS: JSON.stringify(migrations),

View File

@@ -60,17 +60,15 @@ export const layer = Layer.effect(
Effect.gen(function* () {
const config = yield* Config.Service
const loadPhoton = yield* Effect.cached(
Effect.promise(async () => {
try {
// Patched photon-node reads this during module init so Bun compiled binaries use the embedded wasm path.
;(globalThis as typeof globalThis & { __OPENCODE_PHOTON_WASM_PATH?: string }).__OPENCODE_PHOTON_WASM_PATH =
photonWasm
return await import("@silvia-odwyer/photon-node")
} catch (error) {
log.warn("failed to load photon", { error })
return null
}
}),
Effect.sync(() => {
// Patched photon-node reads this during module init so Bun compiled binaries use the embedded wasm path.
;(globalThis as typeof globalThis & { __OPENCODE_PHOTON_WASM_PATH?: string }).__OPENCODE_PHOTON_WASM_PATH =
photonWasm
}).pipe(
Effect.andThen(() => Effect.tryPromise(() => import("@silvia-odwyer/photon-node"))),
Effect.tapError((error) => Effect.sync(() => log.warn("failed to load photon", { error }))),
Effect.mapError(() => new ResizerUnavailableError()),
),
)
const normalize = Effect.fn("Image.normalize")(function* (input: MessageV2.FilePart) {
@@ -89,7 +87,6 @@ export const layer = Layer.effect(
if (bytes <= info.maxBase64Bytes) return input
const photon = yield* loadPhoton
if (!photon) return yield* new ResizerUnavailableError()
const decoded = yield* Effect.try({
try: () => photon.PhotonImage.new_from_byteslice(Buffer.from(base64, "base64")),