Skip to content

Commit 0f1a4f6

Browse files
committed
fix
1 parent 31e3fe8 commit 0f1a4f6

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

packages/opencode/src/image/image.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ const AUTO_RESIZE = true
1010
const JPEG_QUALITIES = [80, 85, 70, 55, 40]
1111
const log = Log.create({ service: "image" })
1212

13-
type Photon = typeof import("@silvia-odwyer/photon-node")
14-
1513
export class PhotonUnavailableError extends Schema.TaggedErrorClass<PhotonUnavailableError>()(
1614
"ImagePhotonUnavailableError",
1715
{},
@@ -62,8 +60,10 @@ export const layer = Layer.effect(
6260
const config = yield* Config.Service
6361
const loadPhoton = yield* Effect.cached(
6462
Effect.promise(async () => {
65-
const photonWasm = (await import("@silvia-odwyer/photon-node/photon_rs_bg.wasm", { with: { type: "file" } })).default
66-
;(globalThis as typeof globalThis & { __OPENCODE_PHOTON_WASM_PATH?: string }).__OPENCODE_PHOTON_WASM_PATH = photonWasm
63+
const photonWasm = (await import("@silvia-odwyer/photon-node/photon_rs_bg.wasm", { with: { type: "file" } }))
64+
.default
65+
;(globalThis as typeof globalThis & { __OPENCODE_PHOTON_WASM_PATH?: string }).__OPENCODE_PHOTON_WASM_PATH =
66+
photonWasm
6767
try {
6868
return await import("@silvia-odwyer/photon-node")
6969
} catch {
@@ -121,12 +121,13 @@ export const layer = Layer.effect(
121121
width: Math.max(1, Math.round(originalWidth * scale)),
122122
height: Math.max(1, Math.round(originalHeight * scale)),
123123
}
124-
const next = acc.length === 0
125-
? previous
126-
: {
127-
width: previous.width === 1 ? 1 : Math.max(1, Math.floor(previous.width * 0.75)),
128-
height: previous.height === 1 ? 1 : Math.max(1, Math.floor(previous.height * 0.75)),
129-
}
124+
const next =
125+
acc.length === 0
126+
? previous
127+
: {
128+
width: previous.width === 1 ? 1 : Math.max(1, Math.floor(previous.width * 0.75)),
129+
height: previous.height === 1 ? 1 : Math.max(1, Math.floor(previous.height * 0.75)),
130+
}
130131
return acc.some((item) => item.width === next.width && item.height === next.height) ? acc : [...acc, next]
131132
}, [])) {
132133
const resized = photon.resize(decoded, size.width, size.height, photon.SamplingFilter.Lanczos3)

0 commit comments

Comments
 (0)