feat: get wasm working from libparakeet
This commit is contained in:
parent
6ca0f46af3
commit
2b9defbb3b
@ -14,6 +14,7 @@
|
||||
"@chakra-ui/react": "^2.6.1",
|
||||
"@emotion/react": "^11.11.0",
|
||||
"@emotion/styled": "^11.11.0",
|
||||
"@jixun/libparakeet": "0.0.0-exp5",
|
||||
"@reduxjs/toolkit": "^1.9.5",
|
||||
"framer-motion": "^10.12.8",
|
||||
"nanoid": "^4.0.2",
|
||||
@ -33,7 +34,9 @@
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.3.4",
|
||||
"typescript": "^5.0.2",
|
||||
"vite": "^4.3.2"
|
||||
"vite": "^4.3.2",
|
||||
"vite-plugin-top-level-await": "^1.3.0",
|
||||
"vite-plugin-wasm": "^3.2.2"
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true,
|
||||
|
162
pnpm-lock.yaml
162
pnpm-lock.yaml
@ -13,6 +13,9 @@ dependencies:
|
||||
'@emotion/styled':
|
||||
specifier: ^11.11.0
|
||||
version: 11.11.0(@emotion/react@11.11.0)(@types/react@18.0.28)(react@18.2.0)
|
||||
'@jixun/libparakeet':
|
||||
specifier: 0.0.0-exp5
|
||||
version: 0.0.0-exp5
|
||||
'@reduxjs/toolkit':
|
||||
specifier: ^1.9.5
|
||||
version: 1.9.5(react-redux@8.0.5)(react@18.2.0)
|
||||
@ -69,6 +72,12 @@ devDependencies:
|
||||
vite:
|
||||
specifier: ^4.3.2
|
||||
version: 4.3.2(@types/node@20.1.1)
|
||||
vite-plugin-top-level-await:
|
||||
specifier: ^1.3.0
|
||||
version: 1.3.0(vite@4.3.2)
|
||||
vite-plugin-wasm:
|
||||
specifier: ^3.2.2
|
||||
version: 3.2.2(vite@4.3.2)
|
||||
|
||||
packages:
|
||||
|
||||
@ -1771,6 +1780,10 @@ packages:
|
||||
resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==}
|
||||
dev: true
|
||||
|
||||
/@jixun/libparakeet@0.0.0-exp5:
|
||||
resolution: {integrity: sha512-qDGhEYEDUCl3GvpeVfBU7Jd6KuONULQUaA/SpBdKDT5sSuM+fgLIAwD7gxaR+Rp05QGLnG6VNKoLXMmvuW9JPQ==}
|
||||
dev: false
|
||||
|
||||
/@jridgewell/gen-mapping@0.3.3:
|
||||
resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
@ -1849,6 +1862,128 @@ packages:
|
||||
reselect: 4.1.8
|
||||
dev: false
|
||||
|
||||
/@rollup/plugin-virtual@3.0.1:
|
||||
resolution: {integrity: sha512-fK8O0IL5+q+GrsMLuACVNk2x21g3yaw+sG2qn16SnUd3IlBsQyvWxLMGHmCmXRMecPjGRSZ/1LmZB4rjQm68og==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
peerDependencies:
|
||||
rollup: ^1.20.0||^2.0.0||^3.0.0
|
||||
peerDependenciesMeta:
|
||||
rollup:
|
||||
optional: true
|
||||
dev: true
|
||||
|
||||
/@swc/core-darwin-arm64@1.3.57:
|
||||
resolution: {integrity: sha512-lhAK9kF/ppZdNTdaxJl2gE0bXubzQXTgxB2Xojme/1sbOipaLTskBbJ3FLySChpmVOzD0QSCTiW8w/dmQxqNIQ==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@swc/core-darwin-x64@1.3.57:
|
||||
resolution: {integrity: sha512-jsTDH8Et/xdOM/ZCNvtrT6J8FT255OrMhEDvHZQZTgoky4oW/3FHUfji4J2FE97gitJqNJI8MuNuiGq81pIJRw==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@swc/core-linux-arm-gnueabihf@1.3.57:
|
||||
resolution: {integrity: sha512-MZv3fwcCmppbwfCWaE8cZvzbXOjX7n5SEC1hF2lgItTqp4S04dFk1iX50jKr6xS6xSLlRBPqDxwZH0sBpHaEuA==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@swc/core-linux-arm64-gnu@1.3.57:
|
||||
resolution: {integrity: sha512-wUeqa/qbkOEGl6TaDQZZL7txrQXs1vL7ERjPYhi9El+ywacFY/rTW2pK5DqaNk2eulVnLhbbNjsE1OMGSEWGkQ==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@swc/core-linux-arm64-musl@1.3.57:
|
||||
resolution: {integrity: sha512-pZfp1B9XfH7ZhDKFjr4qbyM093zU2Ri0IZq2M2A4W9q92+Ivy8oEIqw+gSRO3jwMDqRMEtFD49YuFhkJQakxdA==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@swc/core-linux-x64-gnu@1.3.57:
|
||||
resolution: {integrity: sha512-dvtQnv07NikV+CJ+9PYJ3fqphSigzfvSUH6wRCmb5OzLDDLFnPLMrEO0pGeURvdIWCOhngcHF252C1Hl5uFSzA==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@swc/core-linux-x64-musl@1.3.57:
|
||||
resolution: {integrity: sha512-1TKCSngyQxpzwBYDzF5MrEfYRDhlzt/GN1ZqlSnsJIPGkABOWZxYDvWJuMrkASdIztn3jSTPU2ih7rR7YQ8IIw==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@swc/core-win32-arm64-msvc@1.3.57:
|
||||
resolution: {integrity: sha512-HvBYFyf4uBua/jyTrcFLKcq8SIbKVYfz2qWsbgSAZvuQPZvDC1XhN5EDH2tPZmT97F0CJx3fltH5nli6XY1/EQ==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@swc/core-win32-ia32-msvc@1.3.57:
|
||||
resolution: {integrity: sha512-PS8AtK9e6Rp97S0ek9W5VCZNCbDaHBUasiJUmaYqRVCq/Mn6S7eQlhd0iUDnjsagigQtoCRgMUzkVknd1tarsQ==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@swc/core-win32-x64-msvc@1.3.57:
|
||||
resolution: {integrity: sha512-A6aX/Rpp0v3g7Spf3LSwR+ivviH8x+1xla612KLZmlc0yymWt9BMd3CmBkzyRBr2e41zGCrkf6tra6wgtCbAwA==}
|
||||
engines: {node: '>=10'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
||||
/@swc/core@1.3.57:
|
||||
resolution: {integrity: sha512-gAT80hOVeK5qoi+BRlgXWgJYI9cbQn2oi05A09Tvb6vjFgBsr9SlQGNZB9uMlcXRXspkZFf9l3yyWRtT4we3Yw==}
|
||||
engines: {node: '>=10'}
|
||||
requiresBuild: true
|
||||
peerDependencies:
|
||||
'@swc/helpers': ^0.5.0
|
||||
peerDependenciesMeta:
|
||||
'@swc/helpers':
|
||||
optional: true
|
||||
optionalDependencies:
|
||||
'@swc/core-darwin-arm64': 1.3.57
|
||||
'@swc/core-darwin-x64': 1.3.57
|
||||
'@swc/core-linux-arm-gnueabihf': 1.3.57
|
||||
'@swc/core-linux-arm64-gnu': 1.3.57
|
||||
'@swc/core-linux-arm64-musl': 1.3.57
|
||||
'@swc/core-linux-x64-gnu': 1.3.57
|
||||
'@swc/core-linux-x64-musl': 1.3.57
|
||||
'@swc/core-win32-arm64-msvc': 1.3.57
|
||||
'@swc/core-win32-ia32-msvc': 1.3.57
|
||||
'@swc/core-win32-x64-msvc': 1.3.57
|
||||
dev: true
|
||||
|
||||
/@types/hoist-non-react-statics@3.3.1:
|
||||
resolution: {integrity: sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==}
|
||||
dependencies:
|
||||
@ -3395,6 +3530,33 @@ packages:
|
||||
react: 18.2.0
|
||||
dev: false
|
||||
|
||||
/uuid@9.0.0:
|
||||
resolution: {integrity: sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/vite-plugin-top-level-await@1.3.0(vite@4.3.2):
|
||||
resolution: {integrity: sha512-owIfsgWudMlQODWJSwp0sQB3AZZu3qsMygeBjZy8CyjEk6OB9AGd8lHqmgwrcEqgvy9N58lYxSBLVk3/4ejEiA==}
|
||||
peerDependencies:
|
||||
vite: '>=2.8'
|
||||
dependencies:
|
||||
'@rollup/plugin-virtual': 3.0.1
|
||||
'@swc/core': 1.3.57
|
||||
uuid: 9.0.0
|
||||
vite: 4.3.2(@types/node@20.1.1)
|
||||
transitivePeerDependencies:
|
||||
- '@swc/helpers'
|
||||
- rollup
|
||||
dev: true
|
||||
|
||||
/vite-plugin-wasm@3.2.2(vite@4.3.2):
|
||||
resolution: {integrity: sha512-cdbBUNR850AEoMd5nvLmnyeq63CSfoP1ctD/L2vLk/5+wsgAPlAVAzUK5nGKWO/jtehNlrSSHLteN+gFQw7VOA==}
|
||||
peerDependencies:
|
||||
vite: ^2 || ^3 || ^4
|
||||
dependencies:
|
||||
vite: 4.3.2(@types/node@20.1.1)
|
||||
dev: true
|
||||
|
||||
/vite@4.3.2(@types/node@20.1.1):
|
||||
resolution: {integrity: sha512-9R53Mf+TBoXCYejcL+qFbZde+eZveQLDYd9XgULILLC1a5ZwPaqgmdVpL8/uvw2BM/1TzetWjglwm+3RO+xTyw==}
|
||||
engines: {node: ^14.18.0 || >=16.0.0}
|
||||
|
@ -3,6 +3,7 @@ import { SelectFile } from './SelectFile';
|
||||
|
||||
import { FileListing } from './features/file-listing/FileListing';
|
||||
import { Footer } from './Footer';
|
||||
import { WasmTest } from './WasmTest';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
@ -14,6 +15,7 @@ function App() {
|
||||
<Box mt="8">
|
||||
<FileListing />
|
||||
</Box>
|
||||
{localStorage.__dev_test === '1' && <WasmTest />}
|
||||
<Footer />
|
||||
</Container>
|
||||
</Box>
|
||||
|
31
src/WasmTest.tsx
Normal file
31
src/WasmTest.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
import { LibParakeetInit, BlobSink, createArrayBufferReader } from '@jixun/libparakeet';
|
||||
|
||||
function testWasm() {
|
||||
LibParakeetInit().then(async (mod) => {
|
||||
const data = new Uint8Array(0x2000);
|
||||
for (let i = 0; i < data.byteLength; i++) {
|
||||
data[i] = i & 0xff;
|
||||
}
|
||||
const src = createArrayBufferReader(data, mod);
|
||||
const sink = new BlobSink(mod);
|
||||
mod.rw_test(sink.getWriter(), src);
|
||||
const collected = sink.collectBlob();
|
||||
const copied = await collected.arrayBuffer();
|
||||
const copiedView = new Uint8Array(copied);
|
||||
for (let i = 0; i < copied.byteLength; i++) {
|
||||
if (copiedView[i] !== (i & 0xff)) {
|
||||
alert(`validate at pos ${i} failed`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
alert('wasm validate ok!');
|
||||
});
|
||||
}
|
||||
|
||||
export function WasmTest() {
|
||||
return (
|
||||
<button onClick={testWasm} type="button">
|
||||
Test WASM
|
||||
</button>
|
||||
);
|
||||
}
|
@ -1,10 +1,16 @@
|
||||
import path from 'path';
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import wasm from 'vite-plugin-wasm';
|
||||
import topLevelAwait from 'vite-plugin-top-level-await';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
base: './',
|
||||
optimizeDeps: {
|
||||
exclude: ['@jixun/libparakeet'],
|
||||
},
|
||||
plugins: [react(), wasm(), topLevelAwait()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'~': path.resolve(__dirname, 'src'),
|
||||
|
Loading…
Reference in New Issue
Block a user