Skip to content

Commit

Permalink
chore(es/typescript): Remove the workaround for wasm-bindgen (#9428)
Browse files Browse the repository at this point in the history
**Related issue:**

 - rustwasm/wasm-bindgen#4015
  • Loading branch information
magic-akari authored Aug 14, 2024
1 parent baf4928 commit 55f7268
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions bindings/binding_typescript_wasm/scripts/patch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,7 @@ const base64 = rawWasmFile.toString('base64');

const patchedJsFile = origJsFile
.replace(`const path = require('path').join(__dirname, 'wasm_bg.wasm');`, '')
.replaceAll(/=\s*getInt32Memory0\(\)\[(\w+)\s*\/\s*(\d+)\s*\+\s*(\d+)\]/g, `= getDataView().getInt32($1 + $2 * $3, true)`)
.replaceAll(/getInt32Memory0\(\)\[(\w+)\s*\/\s*(\d+)\s*\+\s*(\d+)\]\s*=\s*(.*);/g, `getDataView().setInt32($1 + $2 * $3, $4, true);`)
.replaceAll(/getFloat64Memory0\(\)\[(\w+)\s*\/\s*(\d+)\s*\+\s*(\d+)\]\s*=\s*(.*);/g, `getDataView().setFloat64($1 + $2 * $3, $4, true);`)
.replace(', fatal: true', '')
.replace('let cachedFloat64Memory0 = null;',
`
let cachedDataView = null;
/** @returns {DataView} */
function getDataView() {
if (cachedDataView === null || cachedDataView.buffer !== wasm.memory.buffer) {
cachedDataView = new DataView(wasm.memory.buffer);
}
return cachedDataView;
}
let cachedFloat64Memory0 = null;
`)
.replace(`const bytes = require('fs').readFileSync(path);`, `
const { Buffer } = require('node:buffer');
const bytes = Buffer.from('${base64}', 'base64');`)
Expand Down

0 comments on commit 55f7268

Please sign in to comment.