feat: get wasm working from libparakeet
This commit is contained in:
parent
2c56c22c74
commit
fc2238ff39
@ -14,6 +14,7 @@
|
|||||||
"@chakra-ui/react": "^2.6.1",
|
"@chakra-ui/react": "^2.6.1",
|
||||||
"@emotion/react": "^11.11.0",
|
"@emotion/react": "^11.11.0",
|
||||||
"@emotion/styled": "^11.11.0",
|
"@emotion/styled": "^11.11.0",
|
||||||
|
"@jixun/libparakeet": "0.0.0-exp5",
|
||||||
"@reduxjs/toolkit": "^1.9.5",
|
"@reduxjs/toolkit": "^1.9.5",
|
||||||
"framer-motion": "^10.12.8",
|
"framer-motion": "^10.12.8",
|
||||||
"nanoid": "^4.0.2",
|
"nanoid": "^4.0.2",
|
||||||
@ -33,7 +34,9 @@
|
|||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"eslint-plugin-react-refresh": "^0.3.4",
|
"eslint-plugin-react-refresh": "^0.3.4",
|
||||||
"typescript": "^5.0.2",
|
"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": {
|
"prettier": {
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
|
162
pnpm-lock.yaml
162
pnpm-lock.yaml
@ -13,6 +13,9 @@ dependencies:
|
|||||||
'@emotion/styled':
|
'@emotion/styled':
|
||||||
specifier: ^11.11.0
|
specifier: ^11.11.0
|
||||||
version: 11.11.0(@emotion/react@11.11.0)(@types/react@18.0.28)(react@18.2.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':
|
'@reduxjs/toolkit':
|
||||||
specifier: ^1.9.5
|
specifier: ^1.9.5
|
||||||
version: 1.9.5(react-redux@8.0.5)(react@18.2.0)
|
version: 1.9.5(react-redux@8.0.5)(react@18.2.0)
|
||||||
@ -69,6 +72,12 @@ devDependencies:
|
|||||||
vite:
|
vite:
|
||||||
specifier: ^4.3.2
|
specifier: ^4.3.2
|
||||||
version: 4.3.2(@types/node@20.1.1)
|
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:
|
packages:
|
||||||
|
|
||||||
@ -1771,6 +1780,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==}
|
resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@jixun/libparakeet@0.0.0-exp5:
|
||||||
|
resolution: {integrity: sha512-qDGhEYEDUCl3GvpeVfBU7Jd6KuONULQUaA/SpBdKDT5sSuM+fgLIAwD7gxaR+Rp05QGLnG6VNKoLXMmvuW9JPQ==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@jridgewell/gen-mapping@0.3.3:
|
/@jridgewell/gen-mapping@0.3.3:
|
||||||
resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==}
|
resolution: {integrity: sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==}
|
||||||
engines: {node: '>=6.0.0'}
|
engines: {node: '>=6.0.0'}
|
||||||
@ -1849,6 +1862,128 @@ packages:
|
|||||||
reselect: 4.1.8
|
reselect: 4.1.8
|
||||||
dev: false
|
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:
|
/@types/hoist-non-react-statics@3.3.1:
|
||||||
resolution: {integrity: sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==}
|
resolution: {integrity: sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -3395,6 +3530,33 @@ packages:
|
|||||||
react: 18.2.0
|
react: 18.2.0
|
||||||
dev: false
|
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):
|
/vite@4.3.2(@types/node@20.1.1):
|
||||||
resolution: {integrity: sha512-9R53Mf+TBoXCYejcL+qFbZde+eZveQLDYd9XgULILLC1a5ZwPaqgmdVpL8/uvw2BM/1TzetWjglwm+3RO+xTyw==}
|
resolution: {integrity: sha512-9R53Mf+TBoXCYejcL+qFbZde+eZveQLDYd9XgULILLC1a5ZwPaqgmdVpL8/uvw2BM/1TzetWjglwm+3RO+xTyw==}
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
|
@ -3,6 +3,7 @@ import { SelectFile } from './SelectFile';
|
|||||||
|
|
||||||
import { FileListing } from './features/file-listing/FileListing';
|
import { FileListing } from './features/file-listing/FileListing';
|
||||||
import { Footer } from './Footer';
|
import { Footer } from './Footer';
|
||||||
|
import { WasmTest } from './WasmTest';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@ -14,6 +15,7 @@ function App() {
|
|||||||
<Box mt="8">
|
<Box mt="8">
|
||||||
<FileListing />
|
<FileListing />
|
||||||
</Box>
|
</Box>
|
||||||
|
{localStorage.__dev_test === '1' && <WasmTest />}
|
||||||
<Footer />
|
<Footer />
|
||||||
</Container>
|
</Container>
|
||||||
</Box>
|
</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 path from 'path';
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react';
|
||||||
|
import wasm from 'vite-plugin-wasm';
|
||||||
|
import topLevelAwait from 'vite-plugin-top-level-await';
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
base: './',
|
||||||
|
optimizeDeps: {
|
||||||
|
exclude: ['@jixun/libparakeet'],
|
||||||
|
},
|
||||||
|
plugins: [react(), wasm(), topLevelAwait()],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'~': path.resolve(__dirname, 'src'),
|
'~': path.resolve(__dirname, 'src'),
|
||||||
|
Loading…
Reference in New Issue
Block a user