@parcel/rust 2.10.3-nightly.3047 → 2.10.3-nightly.3053
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.js +47 -21
- package/package.json +4 -4
- package/parcel-node-bindings.darwin-arm64.node +0 -0
- package/parcel-node-bindings.darwin-x64.node +0 -0
- package/parcel-node-bindings.linux-arm-gnueabihf.node +0 -0
- package/parcel-node-bindings.linux-arm64-gnu.node +0 -0
- package/parcel-node-bindings.linux-arm64-musl.node +0 -0
- package/parcel-node-bindings.linux-x64-gnu.node +0 -0
- package/parcel-node-bindings.linux-x64-musl.node +0 -0
- package/parcel-node-bindings.win32-x64-msvc.node +0 -0
package/browser.js
CHANGED
|
@@ -1,30 +1,56 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* global WebAssembly, crypto */
|
|
2
|
+
|
|
2
3
|
const {Environment, napi} = require('napi-wasm');
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
let env;
|
|
5
6
|
module.exports.init = async function init(input) {
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
require('fs').readFileSync(input),
|
|
16
|
-
{
|
|
17
|
-
env: napi,
|
|
7
|
+
if (env) return;
|
|
8
|
+
|
|
9
|
+
input = input ?? new URL('parcel_node_bindings.wasm', import.meta.url);
|
|
10
|
+
const {instance} = await WebAssembly.instantiateStreaming(fetch(input), {
|
|
11
|
+
env: {
|
|
12
|
+
...napi,
|
|
13
|
+
__getrandom_custom: (ptr, len) => {
|
|
14
|
+
let buf = env.memory.subarray(ptr, ptr + len);
|
|
15
|
+
crypto.getRandomValues(buf);
|
|
18
16
|
},
|
|
19
|
-
|
|
17
|
+
log: (ptr, len) => {
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.log(env.getString(ptr, len));
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// input =
|
|
25
|
+
// input ?? require('path').join(__dirname, 'parcel_node_bindings.wasm');
|
|
26
|
+
// const {instance} = await WebAssembly.instantiate(
|
|
27
|
+
// require('fs').readFileSync(input),
|
|
28
|
+
// {
|
|
29
|
+
// env: napi,
|
|
30
|
+
// },
|
|
31
|
+
// );
|
|
20
32
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
33
|
+
for (let key in instance.exports) {
|
|
34
|
+
if (key.startsWith('__napi_register__')) {
|
|
35
|
+
instance.exports[key]();
|
|
25
36
|
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
env = new Environment(instance);
|
|
26
40
|
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
for (let key in env.exports) {
|
|
42
|
+
if (key !== 'transform') {
|
|
43
|
+
module.exports[key] = env.exports[key];
|
|
44
|
+
}
|
|
29
45
|
}
|
|
46
|
+
module.exports.transform = function (config) {
|
|
47
|
+
let result = env.exports.transform(config);
|
|
48
|
+
return {
|
|
49
|
+
...result,
|
|
50
|
+
// Hydrate Uint8Array into Buffer
|
|
51
|
+
code: Buffer.from(result.code),
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
env.exports.initPanicHook();
|
|
30
56
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcel/rust",
|
|
3
|
-
"version": "2.10.3-nightly.
|
|
3
|
+
"version": "2.10.3-nightly.3053+febe16994",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"node": ">= 12.0.0"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
|
-
"
|
|
25
|
+
"browser.js",
|
|
26
26
|
"index.d.ts",
|
|
27
27
|
"index.js",
|
|
28
28
|
"index.js.flow",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"build": "napi build --platform --cargo-cwd ../../../crates/node-bindings",
|
|
38
38
|
"build-release": "napi build --platform --release --cargo-cwd ../../../crates/node-bindings",
|
|
39
39
|
"wasm:build": "cargo build -p parcel-node-bindings --target wasm32-unknown-unknown && cp ../../../target/wasm32-unknown-unknown/debug/parcel_node_bindings.wasm .",
|
|
40
|
-
"wasm:build-release": "CARGO_PROFILE_RELEASE_LTO=true cargo build --target wasm32-unknown-unknown --release && wasm-opt --strip-debug -O
|
|
40
|
+
"wasm:build-release": "CARGO_PROFILE_RELEASE_LTO=true cargo build -p parcel-node-bindings --target wasm32-unknown-unknown --release && wasm-opt --strip-debug -O ../../../target/wasm32-unknown-unknown/release/parcel_node_bindings.wasm -o parcel_node_bindings.wasm"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "febe169948376cceb60efd9d5a5982106dc80b5a"
|
|
43
43
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|