diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index daa489d..46af818 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,9 +1,9 @@ name: Deploy on: push: - branches: deno-edge + branches: [deno-edge] pull_request: - branches: deno-edge + branches: [deno-edge] jobs: deploy: @@ -16,29 +16,33 @@ jobs: steps: - name: Clone repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install Deno uses: denoland/setup-deno@v2 with: deno-version: v2.x - - name: Install Node.js - uses: actions/setup-node@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: '10' + + - name: Use Node.js + uses: actions/setup-node@v6 with: node-version: lts/* + cache: 'pnpm' - - name: Install step - run: "deno install" + - name: Install dependencies + run: pnpm install - name: Build step - run: "deno task -r build:wasm" + run: "deno task build:wasm" - name: Upload to Deno Deploy uses: denoland/deployctl@v1 with: - project: "okikiojo-bundlejs-85" + project: "bundlejs" entrypoint: "packages/edge/mod.ts" - root: "" - - exclude: **/node_modules + root: "." diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml new file mode 100644 index 0000000..0adba6e --- /dev/null +++ b/.github/workflows/test-deploy.yml @@ -0,0 +1,42 @@ +name: Deploy +on: + push: + branches: [deno-edge] + pull_request: + branches: [deno-edge] + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + + permissions: + id-token: write # Needed for auth with Deno Deploy + contents: read # Needed to clone the repository + + steps: + - name: Clone repository + uses: actions/checkout@v6 + + - name: Install Deno + uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + + - name: Install Node.js + uses: actions/setup-node@v6 + with: + node-version: lts/* + + - name: Install step + run: "deno install" + + - name: Build step + run: "deno task build:wasm" + + - name: Upload to Deno Deploy + uses: denoland/deployctl@v1 + with: + project: "okikiojo-bundlejs-85" + entrypoint: "packages/edge/mod.ts" + root: "." diff --git a/packages/core/scripts/build-wasm.ts b/packages/core/scripts/build-wasm.ts index 6386ece..a56d11e 100644 --- a/packages/core/scripts/build-wasm.ts +++ b/packages/core/scripts/build-wasm.ts @@ -17,7 +17,7 @@ export async function build([mode = "zstd", encoding = "base64"]: Partial<["zstd const value = await src; if (typeof value === "string") console.log(`\n- Source file: ${value}`); - const res = typeof value === "string" ? await fs.readFile(join(import.meta.dirname!, "..", value)) : value; + const res = typeof value === "string" ? await fs.readFile(join(import.meta.dirname!, "..", "..", "..", value)) : value; const wasm = new Uint8Array(res); console.log(`- Read WASM (size: ${bytes(wasm.length)} bytes)`); diff --git a/packages/core/src/deno/zstd/mod.ts b/packages/core/src/deno/zstd/mod.ts index b202ad0..297da75 100644 --- a/packages/core/src/deno/zstd/mod.ts +++ b/packages/core/src/deno/zstd/mod.ts @@ -7,12 +7,13 @@ const initialized = (() => }))(); -let initWASM: Uint8Array; +let initWASM: Uint8Array; export const getWASM = async () => { if (initWASM) return initWASM; const { source } = await import("./zstd.encoded.wasm.ts"); - return (initWASM = await source()); + initWASM = await source(); + return (initWASM); }; let initResolved = false; @@ -115,7 +116,7 @@ export const compressUsingDict = async ( } }; -export const compress = async (buf: ArrayBuffer, level?: number) => { +export const compress = async (buf: Uint8Array, level?: number) => { await init(); const bound = await compressBound(buf.byteLength); @@ -232,7 +233,7 @@ export type DecompressOption = { }; export const decompress = async ( - buf: ArrayBuffer, + buf: Uint8Array, opts: DecompressOption = { defaultHeapSize: 1024 * 1024 } // Use 1MB on default if it is failed to get content size. ): Promise => { await init(); diff --git a/packages/core/src/utils/fetch-and-cache.ts b/packages/core/src/utils/fetch-and-cache.ts index 816bdc0..1c59be3 100644 --- a/packages/core/src/utils/fetch-and-cache.ts +++ b/packages/core/src/utils/fetch-and-cache.ts @@ -39,7 +39,8 @@ export async function newRequest(request: RequestInfo, cache?: Cache, fetchOpts? export let OPEN_CACHE: Cache; export async function openCache() { if (OPEN_CACHE) return OPEN_CACHE; - return (OPEN_CACHE = await caches.open(CACHE_NAME)); + OPEN_CACHE = await caches.open(CACHE_NAME); + return (OPEN_CACHE); } export async function getRequest(url: RequestInfo | URL, permanent = false, fetchOpts?: RequestInit) {