@vue-jsx-vapor/compiler-rs-wasm32-wasi 2.6.12 → 2.6.13

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.
@@ -5,14 +5,16 @@ import {
5
5
  WASI as __WASI,
6
6
  } from '@napi-rs/wasm-runtime'
7
7
 
8
+
9
+
8
10
  const __wasi = new __WASI({
9
11
  version: 'preview1',
10
12
  })
11
13
 
12
- const __wasmUrl = new URL('./compiler-rs.wasm32-wasi.wasm', import.meta.url)
13
- .href
14
+ const __wasmUrl = new URL('./compiler-rs.wasm32-wasi.wasm', import.meta.url).href
14
15
  const __emnapiContext = __emnapiGetDefaultContext()
15
16
 
17
+
16
18
  const __sharedMemory = new WebAssembly.Memory({
17
19
  initial: 4000,
18
20
  maximum: 65536,
@@ -30,12 +32,9 @@ const {
30
32
  asyncWorkPoolSize: 4,
31
33
  wasi: __wasi,
32
34
  onCreateWorker() {
33
- const worker = new Worker(
34
- new URL('@vue-jsx-vapor/compiler-rs-wasm32-wasi/wasi-worker-browser.mjs', import.meta.url),
35
- {
36
- type: 'module',
37
- },
38
- )
35
+ const worker = new Worker(new URL('@vue-jsx-vapor/compiler-rs-wasm32-wasi/wasi-worker-browser.mjs', import.meta.url), {
36
+ type: 'module',
37
+ })
39
38
 
40
39
  return worker
41
40
  },
@@ -21,7 +21,7 @@ const __wasi = new __nodeWASI({
21
21
  env: process.env,
22
22
  preopens: {
23
23
  [__rootDir]: __rootDir,
24
- },
24
+ }
25
25
  })
26
26
 
27
27
  const __emnapiContext = __emnapiGetDefaultContext()
@@ -33,36 +33,22 @@ const __sharedMemory = new WebAssembly.Memory({
33
33
  })
34
34
 
35
35
  let __wasmFilePath = __nodePath.join(__dirname, 'compiler-rs.wasm32-wasi.wasm')
36
- const __wasmDebugFilePath = __nodePath.join(
37
- __dirname,
38
- 'compiler-rs.wasm32-wasi.debug.wasm',
39
- )
36
+ const __wasmDebugFilePath = __nodePath.join(__dirname, 'compiler-rs.wasm32-wasi.debug.wasm')
40
37
 
41
38
  if (__nodeFs.existsSync(__wasmDebugFilePath)) {
42
39
  __wasmFilePath = __wasmDebugFilePath
43
40
  } else if (!__nodeFs.existsSync(__wasmFilePath)) {
44
41
  try {
45
- __wasmFilePath = __nodePath.resolve(
46
- '@vue-jsx-vapor/compiler-rs-wasm32-wasi',
47
- )
42
+ __wasmFilePath = __nodePath.resolve('@vue-jsx-vapor/compiler-rs-wasm32-wasi')
48
43
  } catch {
49
- throw new Error(
50
- 'Cannot find compiler-rs.wasm32-wasi.wasm file, and @vue-jsx-vapor/compiler-rs-wasm32-wasi package is not installed.',
51
- )
44
+ throw new Error('Cannot find compiler-rs.wasm32-wasi.wasm file, and @vue-jsx-vapor/compiler-rs-wasm32-wasi package is not installed.')
52
45
  }
53
46
  }
54
47
 
55
- const {
56
- instance: __napiInstance,
57
- module: __wasiModule,
58
- napiModule: __napiModule,
59
- } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), {
48
+ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), {
60
49
  context: __emnapiContext,
61
- asyncWorkPoolSize: (function () {
62
- const threadsSizeFromEnv = Number(
63
- process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ??
64
- process.env.UV_THREADPOOL_SIZE,
65
- )
50
+ asyncWorkPoolSize: (function() {
51
+ const threadsSizeFromEnv = Number(process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ?? process.env.UV_THREADPOOL_SIZE)
66
52
  // NaN > 0 is false
67
53
  if (threadsSizeFromEnv > 0) {
68
54
  return threadsSizeFromEnv
@@ -86,21 +72,21 @@ const {
86
72
  // According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415,
87
73
  // a worker is consist of two handles: kPublicPort and kHandle.
88
74
  {
89
- const kPublicPort = Object.getOwnPropertySymbols(worker).find((s) =>
90
- s.toString().includes('kPublicPort'),
91
- )
75
+ const kPublicPort = Object.getOwnPropertySymbols(worker).find(s =>
76
+ s.toString().includes("kPublicPort")
77
+ );
92
78
  if (kPublicPort) {
93
- worker[kPublicPort].ref = () => {}
79
+ worker[kPublicPort].ref = () => {};
94
80
  }
95
81
 
96
- const kHandle = Object.getOwnPropertySymbols(worker).find((s) =>
97
- s.toString().includes('kHandle'),
98
- )
82
+ const kHandle = Object.getOwnPropertySymbols(worker).find(s =>
83
+ s.toString().includes("kHandle")
84
+ );
99
85
  if (kHandle) {
100
- worker[kHandle].ref = () => {}
86
+ worker[kHandle].ref = () => {};
101
87
  }
102
88
 
103
- worker.unref()
89
+ worker.unref();
104
90
  }
105
91
  return worker
106
92
  },
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-jsx-vapor/compiler-rs-wasm32-wasi",
3
- "version": "2.6.12",
3
+ "version": "2.6.13",
4
4
  "cpu": [
5
5
  "wasm32"
6
6
  ],
@@ -1,8 +1,4 @@
1
- import {
2
- instantiateNapiModuleSync,
3
- MessageHandler,
4
- WASI,
5
- } from '@napi-rs/wasm-runtime'
1
+ import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
6
2
 
7
3
  const handler = new MessageHandler({
8
4
  onLoad({ wasmModule, wasmMemory }) {
@@ -11,7 +7,7 @@ const handler = new MessageHandler({
11
7
  // eslint-disable-next-line no-console
12
8
  console.log.apply(console, arguments)
13
9
  },
14
- printErr: function () {
10
+ printErr: function() {
15
11
  // eslint-disable-next-line no-console
16
12
  console.error.apply(console, arguments)
17
13
  },
package/wasi-worker.mjs CHANGED
@@ -1,21 +1,17 @@
1
- import fs from 'node:fs'
2
- import { createRequire } from 'node:module'
3
- import { parse } from 'node:path'
4
- import { WASI } from 'node:wasi'
5
- import { parentPort, Worker } from 'node:worker_threads'
1
+ import fs from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import { parse } from "node:path";
4
+ import { WASI } from "node:wasi";
5
+ import { parentPort, Worker } from "node:worker_threads";
6
6
 
7
- const require = createRequire(import.meta.url)
7
+ const require = createRequire(import.meta.url);
8
8
 
9
- const {
10
- instantiateNapiModuleSync,
11
- MessageHandler,
12
- getDefaultContext,
13
- } = require('@napi-rs/wasm-runtime')
9
+ const { instantiateNapiModuleSync, MessageHandler, getDefaultContext } = require("@napi-rs/wasm-runtime");
14
10
 
15
11
  if (parentPort) {
16
- parentPort.on('message', (data) => {
17
- globalThis.onmessage({ data })
18
- })
12
+ parentPort.on("message", (data) => {
13
+ globalThis.onmessage({ data });
14
+ });
19
15
  }
20
16
 
21
17
  Object.assign(globalThis, {
@@ -23,18 +19,18 @@ Object.assign(globalThis, {
23
19
  require,
24
20
  Worker,
25
21
  importScripts: function (f) {
26
- ;(0, eval)(fs.readFileSync(f, 'utf8') + '//# sourceURL=' + f)
22
+ ;(0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f);
27
23
  },
28
24
  postMessage: function (msg) {
29
25
  if (parentPort) {
30
- parentPort.postMessage(msg)
26
+ parentPort.postMessage(msg);
31
27
  }
32
28
  },
33
- })
29
+ });
34
30
 
35
- const emnapiContext = getDefaultContext()
31
+ const emnapiContext = getDefaultContext();
36
32
 
37
- const __rootDir = parse(process.cwd()).root
33
+ const __rootDir = parse(process.cwd()).root;
38
34
 
39
35
  const handler = new MessageHandler({
40
36
  onLoad({ wasmModule, wasmMemory }) {
@@ -44,7 +40,7 @@ const handler = new MessageHandler({
44
40
  preopens: {
45
41
  [__rootDir]: __rootDir,
46
42
  },
47
- })
43
+ });
48
44
 
49
45
  return instantiateNapiModuleSync(wasmModule, {
50
46
  childThread: true,
@@ -55,13 +51,13 @@ const handler = new MessageHandler({
55
51
  ...importObject.env,
56
52
  ...importObject.napi,
57
53
  ...importObject.emnapi,
58
- memory: wasmMemory,
59
- }
54
+ memory: wasmMemory
55
+ };
60
56
  },
61
- })
57
+ });
62
58
  },
63
- })
59
+ });
64
60
 
65
61
  globalThis.onmessage = function (e) {
66
- handler.handle(e)
67
- }
62
+ handler.handle(e);
63
+ };