This commit is contained in:
熊潇 2025-04-19 15:19:48 +08:00
parent b9386de0b1
commit c44d5925a4
7 changed files with 72 additions and 4 deletions

2
.gitignore vendored
View File

@ -5,3 +5,5 @@ node_modules
.env*
!.env*example
dist

3
assembly/index.ts Normal file
View File

@ -0,0 +1,3 @@
export function add(a: i32, b: i32): i32 {
return a + b;
}

33
deno-wasm/deno.json Normal file
View File

@ -0,0 +1,33 @@
{
"compilerOptions": {
"lib": [
"deno.window"
]
},
"tasks": {
"start": "deno run --allow-net deno-server/server.ts",
"build:wasm": "deno compile --target wasm -- --outfile dist/index.wasm src/index.ts"
},
"imports": {
"http/": "https://deno.land/std@0.220.1/http/"
},
"lint": {
"include": [
"./src/**/*.ts",
"index.ts"
],
"exclude": [
"./types"
],
"rules": {
"tags": [
"recommended"
],
"include": [],
"exclude": [
"require-await",
"no-explicit-any"
]
}
}
}

5
deno-wasm/src/index.ts Normal file
View File

@ -0,0 +1,5 @@
// export const add = (a: number, b: number) => a + b;
import { add } from "../../dist/index.wasm";
console.log(add(1, 2));

View File

@ -25,8 +25,7 @@
"include": [],
"exclude": [
"require-await",
"no-explicit-any",
"unused-vars"
"no-explicit-any"
]
}
}

View File

@ -4,7 +4,8 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"assembly:build": "asc assembly/index.ts --target release --outFile dist/index.wasm"
},
"keywords": [],
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
@ -14,6 +15,7 @@
"devDependencies": {
"@kevisual/router": "^0.0.13",
"@kevisual/use-config": "^1.0.10",
"assemblyscript": "^0.27.36",
"pino": "^9.6.0",
"pino-pretty": "^13.0.0"
}

24
pnpm-lock.yaml generated
View File

@ -14,6 +14,9 @@ importers:
'@kevisual/use-config':
specifier: ^1.0.10
version: 1.0.10(dotenv@16.5.0)
assemblyscript:
specifier: ^0.27.36
version: 0.27.36
pino:
specifier: ^9.6.0
version: 9.6.0
@ -40,10 +43,19 @@ packages:
'@types/node@22.14.1':
resolution: {integrity: sha512-u0HuPQwe/dHrItgHHpmw3N2fYCR6x4ivMNbPHRkBVP4CvN+kiRrKHWk3i8tXiO/joPwXLMYvF9TTF0eqgHIuOw==}
assemblyscript@0.27.36:
resolution: {integrity: sha512-1qX2zf6p7l/mNYv8r21jC/Yft7kX7XKR3xUHw41zvV4xad5lyC8w7jZiwZBGoy64VKZLc+bTDJDWi8Kb70YrHA==}
engines: {node: '>=18', npm: '>=10'}
hasBin: true
atomic-sleep@1.0.0:
resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==}
engines: {node: '>=8.0.0'}
binaryen@116.0.0-nightly.20240114:
resolution: {integrity: sha512-0GZrojJnuhoe+hiwji7QFaL3tBlJoA+KFUN7ouYSDGZLSo9CKM8swQX8n/UcbR0d1VuZKU+nhogNzv423JEu5A==}
hasBin: true
colorette@2.0.20:
resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==}
@ -77,6 +89,9 @@ packages:
resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==}
engines: {node: '>=10'}
long@5.3.2:
resolution: {integrity: sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==}
minimist@1.2.8:
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
@ -177,8 +192,15 @@ snapshots:
dependencies:
undici-types: 6.21.0
assemblyscript@0.27.36:
dependencies:
binaryen: 116.0.0-nightly.20240114
long: 5.3.2
atomic-sleep@1.0.0: {}
binaryen@116.0.0-nightly.20240114: {}
colorette@2.0.20: {}
dateformat@4.6.3: {}
@ -201,6 +223,8 @@ snapshots:
joycon@3.1.1: {}
long@5.3.2: {}
minimist@1.2.8: {}
node-forge@1.3.1: {}