-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
077170e
commit 289d96c
Showing
5 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
12 changes: 7 additions & 5 deletions
12
packages/cloudflare/test/fixtures/wasm/src/pages/add/[a]/[b].ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
import { type APIContext } from 'astro'; | ||
import { add } from '../../../util/add'; | ||
// @ts-ignore | ||
import mod from '../../../util/add.wasm?module'; | ||
|
||
const addModule: any = new WebAssembly.Instance(mod); | ||
|
||
export const prerender = false; | ||
|
||
export async function GET( | ||
context: APIContext | ||
): Promise<Response> { | ||
const a = Number.parseInt(context.params.a ?? "0"); | ||
const b = Number.parseInt(context.params.b ?? "0"); | ||
return new Response(JSON.stringify({ answer: add(a, b) }), { | ||
const a = Number.parseInt(context.params.a!); | ||
const b = Number.parseInt(context.params.b!); | ||
return new Response(JSON.stringify({ answer: addModule.exports.add(a, b) }), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
import { type APIContext } from 'astro'; | ||
// @ts-ignore | ||
import mod from '../util/add.wasm?module'; | ||
|
||
import {add} from '../util/add'; | ||
|
||
export const prerender = true | ||
const addModule: any = new WebAssembly.Instance(mod); | ||
|
||
export async function GET( | ||
context: APIContext | ||
): Promise<Response> { | ||
return new Response(JSON.stringify({ answer: add(20, 1) }), { | ||
return new Response(JSON.stringify({ answer: addModule.exports.add(20, 1) }), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/cloudflare/test/fixtures/wasm/src/pages/hybridshared.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { type APIContext } from 'astro'; | ||
|
||
import {add} from '../util/add'; | ||
|
||
export const prerender = true | ||
|
||
export async function GET( | ||
context: APIContext | ||
): Promise<Response> { | ||
return new Response(JSON.stringify({ answer: add(20, 1) }), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/cloudflare/test/fixtures/wasm/src/pages/shared/[a]/[b].ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { type APIContext } from 'astro'; | ||
import { add } from '../../../util/add'; | ||
|
||
|
||
export const prerender = false; | ||
|
||
export async function GET( | ||
context: APIContext | ||
): Promise<Response> { | ||
const a = Number.parseInt(context.params.a ?? "0"); | ||
const b = Number.parseInt(context.params.b ?? "0"); | ||
return new Response(JSON.stringify({ answer: add(a, b) }), { | ||
status: 200, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters