@vue-jsx-vapor/compiler-rs-wasm32-wasi 2.7.2 → 2.7.3

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.
@@ -1,21 +1,20 @@
1
- /* eslint-disable */
2
- /* prettier-ignore */
3
-
4
1
  import {
2
+ createOnMessage as __wasmCreateOnMessageForFsProxy,
5
3
  getDefaultContext as __emnapiGetDefaultContext,
6
4
  instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync,
7
5
  WASI as __WASI,
8
- createOnMessage as __wasmCreateOnMessageForFsProxy,
9
6
  } from '@napi-rs/wasm-runtime'
10
7
 
8
+
9
+
11
10
  const __wasi = new __WASI({
12
11
  version: 'preview1',
13
12
  })
14
13
 
15
- const __wasmUrl = new URL('./compiler-rs.wasm32-wasi.wasm', import.meta.url)
16
- .href
14
+ const __wasmUrl = new URL('./compiler-rs.wasm32-wasi.wasm', import.meta.url).href
17
15
  const __emnapiContext = __emnapiGetDefaultContext()
18
16
 
17
+
19
18
  const __sharedMemory = new WebAssembly.Memory({
20
19
  initial: 4000,
21
20
  maximum: 65536,
@@ -33,12 +32,9 @@ const {
33
32
  asyncWorkPoolSize: 4,
34
33
  wasi: __wasi,
35
34
  onCreateWorker() {
36
- const worker = new Worker(
37
- new URL('@vue-jsx-vapor/compiler-rs-wasm32-wasi/wasi-worker-browser.mjs', import.meta.url),
38
- {
39
- type: 'module',
40
- },
41
- )
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
+ })
42
38
 
43
39
  return worker
44
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.7.2",
3
+ "version": "2.7.3",
4
4
  "cpu": [
5
5
  "wasm32"
6
6
  ],
@@ -1,18 +1,14 @@
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 }) {
9
5
  const wasi = new WASI({
10
- print() {
11
- // eslint-disable-next-line prefer-spread, prefer-rest-params, no-console
6
+ print: function () {
7
+ // eslint-disable-next-line no-console
12
8
  console.log.apply(console, arguments)
13
9
  },
14
- printErr() {
15
- // eslint-disable-next-line prefer-spread, prefer-rest-params
10
+ printErr: function() {
11
+ // eslint-disable-next-line no-console
16
12
  console.error.apply(console, arguments)
17
13
  },
18
14
  })
@@ -31,7 +27,6 @@ const handler = new MessageHandler({
31
27
  },
32
28
  })
33
29
 
34
- // eslint-disable-next-line unicorn/prefer-add-event-listener
35
30
  globalThis.onmessage = function (e) {
36
31
  handler.handle(e)
37
32
  }
package/wasi-worker.mjs CHANGED
@@ -1,41 +1,36 @@
1
- import fs from 'node:fs'
2
- import { createRequire } from 'node:module'
3
- import { parse } from 'node:path'
4
- import process from 'node:process'
5
- import { WASI } from 'node:wasi'
6
- 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";
7
6
 
8
- const require = createRequire(import.meta.url)
7
+ const require = createRequire(import.meta.url);
9
8
 
10
- const {
11
- instantiateNapiModuleSync,
12
- MessageHandler,
13
- getDefaultContext,
14
- } = require('@napi-rs/wasm-runtime')
9
+ const { instantiateNapiModuleSync, MessageHandler, getDefaultContext } = require("@napi-rs/wasm-runtime");
15
10
 
16
11
  if (parentPort) {
17
- parentPort.on('message', (data) => {
18
- globalThis.onmessage({ data })
19
- })
12
+ parentPort.on("message", (data) => {
13
+ globalThis.onmessage({ data });
14
+ });
20
15
  }
21
16
 
22
17
  Object.assign(globalThis, {
23
18
  self: globalThis,
24
19
  require,
25
20
  Worker,
26
- importScripts(f) {
27
- ;(0, eval)(`${fs.readFileSync(f, 'utf8')}//# sourceURL=${f}`)
21
+ importScripts: function (f) {
22
+ ;(0, eval)(fs.readFileSync(f, "utf8") + "//# sourceURL=" + f);
28
23
  },
29
- postMessage(msg) {
24
+ postMessage: function (msg) {
30
25
  if (parentPort) {
31
- parentPort.postMessage(msg)
26
+ parentPort.postMessage(msg);
32
27
  }
33
28
  },
34
- })
29
+ });
35
30
 
36
- const emnapiContext = getDefaultContext()
31
+ const emnapiContext = getDefaultContext();
37
32
 
38
- const __rootDir = parse(process.cwd()).root
33
+ const __rootDir = parse(process.cwd()).root;
39
34
 
40
35
  const handler = new MessageHandler({
41
36
  onLoad({ wasmModule, wasmMemory }) {
@@ -45,7 +40,7 @@ const handler = new MessageHandler({
45
40
  preopens: {
46
41
  [__rootDir]: __rootDir,
47
42
  },
48
- })
43
+ });
49
44
 
50
45
  return instantiateNapiModuleSync(wasmModule, {
51
46
  childThread: true,
@@ -56,14 +51,13 @@ const handler = new MessageHandler({
56
51
  ...importObject.env,
57
52
  ...importObject.napi,
58
53
  ...importObject.emnapi,
59
- memory: wasmMemory,
60
- }
54
+ memory: wasmMemory
55
+ };
61
56
  },
62
- })
57
+ });
63
58
  },
64
- })
59
+ });
65
60
 
66
- // eslint-disable-next-line unicorn/prefer-add-event-listener
67
61
  globalThis.onmessage = function (e) {
68
- handler.handle(e)
69
- }
62
+ handler.handle(e);
63
+ };