Primeiro commit do projeto Angular

This commit is contained in:
2026-03-14 20:41:55 +00:00
parent 9bebe1de72
commit 94f4f46395
22413 changed files with 3221690 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# `@napi-rs/nice-win32-x64-msvc`
This is the **x86_64-pc-windows-msvc** binary for `@napi-rs/nice`
Binary file not shown.
+36
View File
@@ -0,0 +1,36 @@
{
"name": "@napi-rs/nice-win32-x64-msvc",
"version": "1.1.1",
"cpu": [
"x64"
],
"main": "nice.win32-x64-msvc.node",
"files": [
"nice.win32-x64-msvc.node"
],
"description": "https://linux.die.net/man/2/nice binding for Node.js",
"keywords": [
"napi-rs",
"NAPI",
"N-API",
"Rust",
"node-addon",
"node-addon-api",
"nice"
],
"license": "MIT",
"engines": {
"node": ">= 10"
},
"repository": {
"url": "git+ssh://git@github.com/Brooooooklyn/nice.git",
"type": "git"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"os": [
"win32"
]
}
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 N-API for Rust
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+73
View File
@@ -0,0 +1,73 @@
# `@napi-rs/nice`
![https://github.com/Brooooooklyn/nice/actions](https://github.com/Brooooooklyn/nice/workflows/CI/badge.svg)
[![install size](https://packagephobia.com/badge?p=@napi-rs/nice)](https://packagephobia.com/result?p=@napi-rs/nice)
[![Downloads](https://img.shields.io/npm/dm/@napi-rs/nice.svg?sanitize=true)](https://npmcharts.com/compare/@napi-rs/nice?minimal=true)
> 🚀 Help me to become a full-time open-source developer by [sponsoring me on Github](https://github.com/sponsors/Brooooooklyn)
***https://linux.die.net/man/2/nice binding for Node.js***
# Usage
## Install this test package
```
pnpm add @napi-rs/nice
```
or
```
yarn add @napi-rs/nice
```
or
```
npm install @napi-rs/nice
```
## `nice`
On Unix, `nice()` adds inc to the nice value for the calling process. (A higher nice value means a low priority.) Only the superuser may specify a negative increment, or priority increase. The range for nice values is described in [getpriority(2)](https://linux.die.net/man/2/getpriority).
On Windows, it uses the [`SetThreadPriority`](https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadpriority) function.
```js
// on Unix
import { nice } from '@napi-rs/nice'
nice(2)
```
```js
// on Windows
import { nice, WindowsThreadPriority } from '@napi-rs/nice'
nice(WindowsThreadPriority.THREAD_PRIORITY_ABOVE_NORMAL)
```
## `getCurrentProcessPriority`
This function gets the priority of the current process.
On Unix, it uses the [`getpriority(2)`](https://linux.die.net/man/2/getpriority).
On Windows, it uses the [`GetThreadPriority`](https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreadpriority) function.
| Priority Constant | Value | Description |
| ----------------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| THREAD_MODE_BACKGROUND_BEGIN | 0x00010000 | Begin background processing mode. The system lowers the resource scheduling priorities of the thread so that it can perform background work without significantly affecting activity in the foreground. |
| | | This value can be specified only if hThread is a handle to the current thread. The function fails if the thread is already in background processing mode. |
| | | Windows Server 2003: This value is not supported. |
| THREAD_MODE_BACKGROUND_END | 0x00020000 | End background processing mode. The system restores the resource scheduling priorities of the thread as they were before the thread entered background processing mode. |
| | | This value can be specified only if hThread is a handle to the current thread. The function fails if the thread is not in background processing mode. |
| | | Windows Server 2003: This value is not supported. |
| THREAD_PRIORITY_ABOVE_NORMAL | 1 | Priority 1 point above the priority class. |
| THREAD_PRIORITY_BELOW_NORMAL | -1 | Priority 1 point below the priority class. |
| THREAD_PRIORITY_HIGHEST | 2 | Priority 2 points above the priority class. |
| THREAD_PRIORITY_IDLE | -15 | Base priority of 1 for IDLE_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS processes, and a base priority of 16 for REALTIME_PRIORITY_CLASS processes. |
| THREAD_PRIORITY_LOWEST | -2 | Priority 2 points below the priority class. |
| THREAD_PRIORITY_NORMAL | 0 | Normal priority for the priority class. |
| THREAD_PRIORITY_TIME_CRITICAL | 15 | Base priority of 15 for IDLE_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS processes, and a base priority of 31 for REALTIME_PRIORITY_CLASS processes. |
+45
View File
@@ -0,0 +1,45 @@
/* auto-generated by NAPI-RS */
/* eslint-disable */
/**
* This function get the priority of the current process.
* On Unix, it uses the [`getpriority(2)`](https://linux.die.net/man/2/getpriority).
*
* On Windows, it uses the [`GetThreadPriority`](https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreadpriority) function.
*
* | Priority Constant | Value | Description |
* |------------------------------------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
* | THREAD_MODE_BACKGROUND_BEGIN | 0x00010000| Begin background processing mode. The system lowers the resource scheduling priorities of the thread so that it can perform background work without significantly affecting activity in the foreground. |
* | | | This value can be specified only if hThread is a handle to the current thread. The function fails if the thread is already in background processing mode. |
* | | | Windows Server 2003: This value is not supported. |
* | THREAD_MODE_BACKGROUND_END | 0x00020000| End background processing mode. The system restores the resource scheduling priorities of the thread as they were before the thread entered background processing mode. |
* | | | This value can be specified only if hThread is a handle to the current thread. The function fails if the thread is not in background processing mode. |
* | | | Windows Server 2003: This value is not supported. |
* | THREAD_PRIORITY_ABOVE_NORMAL | 1 | Priority 1 point above the priority class. |
* | THREAD_PRIORITY_BELOW_NORMAL | -1 | Priority 1 point below the priority class. |
* | THREAD_PRIORITY_HIGHEST | 2 | Priority 2 points above the priority class. |
* | THREAD_PRIORITY_IDLE | -15 | Base priority of 1 for IDLE_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS processes, and a base priority of 16 for REALTIME_PRIORITY_CLASS processes. |
* | THREAD_PRIORITY_LOWEST | -2 | Priority 2 points below the priority class. |
* | THREAD_PRIORITY_NORMAL | 0 | Normal priority for the priority class. |
* | THREAD_PRIORITY_TIME_CRITICAL | 15 | Base priority of 15 for IDLE_PRIORITY_CLASS, BELOW_NORMAL_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS processes, and a base priority of 31 for REALTIME_PRIORITY_CLASS processes. |
*/
export declare function getCurrentProcessPriority(): number
/**
* This function set the priority of the current process.
* On Unix, it uses the [`nice`](https://linux.die.net/man/2/nice) function.
*
* On Windows, it uses the [`SetThreadPriority`](https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadpriority) function.
*/
export declare function nice(incr?: number | undefined | null): number
export declare enum WindowsThreadPriority {
ThreadModeBackgroundBegin = 65536,
ThreadModeBackgroundEnd = 131072,
ThreadPriorityAboveNormal = 1,
ThreadPriorityBelowNormal = -1,
ThreadPriorityHighest = 2,
ThreadPriorityIdle = -15,
ThreadPriorityLowest = -2,
ThreadPriorityNormal = 0,
ThreadPriorityTimeCritical = 15
}
+513
View File
@@ -0,0 +1,513 @@
// prettier-ignore
/* eslint-disable */
// @ts-nocheck
/* auto-generated by NAPI-RS */
const { createRequire } = require('node:module')
require = createRequire(__filename)
const { readFileSync } = require('node:fs')
let nativeBinding = null
const loadErrors = []
const isMusl = () => {
let musl = false
if (process.platform === 'linux') {
musl = isMuslFromFilesystem()
if (musl === null) {
musl = isMuslFromReport()
}
if (musl === null) {
musl = isMuslFromChildProcess()
}
}
return musl
}
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
const isMuslFromFilesystem = () => {
try {
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
} catch {
return null
}
}
const isMuslFromReport = () => {
let report = null
if (typeof process.report?.getReport === 'function') {
process.report.excludeNetwork = true
report = process.report.getReport()
}
if (!report) {
return null
}
if (report.header && report.header.glibcVersionRuntime) {
return false
}
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) {
return true
}
}
return false
}
const isMuslFromChildProcess = () => {
try {
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
} catch (e) {
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
return false
}
}
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
try {
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
} catch (err) {
loadErrors.push(err)
}
} else if (process.platform === 'android') {
if (process.arch === 'arm64') {
try {
return require('./nice.android-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-android-arm64')
const bindingPackageVersion = require('@napi-rs/nice-android-arm64/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./nice.android-arm-eabi.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-android-arm-eabi')
const bindingPackageVersion = require('@napi-rs/nice-android-arm-eabi/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
}
} else if (process.platform === 'win32') {
if (process.arch === 'x64') {
try {
return require('./nice.win32-x64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-win32-x64-msvc')
const bindingPackageVersion = require('@napi-rs/nice-win32-x64-msvc/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'ia32') {
try {
return require('./nice.win32-ia32-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-win32-ia32-msvc')
const bindingPackageVersion = require('@napi-rs/nice-win32-ia32-msvc/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./nice.win32-arm64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-win32-arm64-msvc')
const bindingPackageVersion = require('@napi-rs/nice-win32-arm64-msvc/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
}
} else if (process.platform === 'darwin') {
try {
return require('./nice.darwin-universal.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-darwin-universal')
const bindingPackageVersion = require('@napi-rs/nice-darwin-universal/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
if (process.arch === 'x64') {
try {
return require('./nice.darwin-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-darwin-x64')
const bindingPackageVersion = require('@napi-rs/nice-darwin-x64/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./nice.darwin-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-darwin-arm64')
const bindingPackageVersion = require('@napi-rs/nice-darwin-arm64/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
}
} else if (process.platform === 'freebsd') {
if (process.arch === 'x64') {
try {
return require('./nice.freebsd-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-freebsd-x64')
const bindingPackageVersion = require('@napi-rs/nice-freebsd-x64/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./nice.freebsd-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-freebsd-arm64')
const bindingPackageVersion = require('@napi-rs/nice-freebsd-arm64/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
}
} else if (process.platform === 'linux') {
if (process.arch === 'x64') {
if (isMusl()) {
try {
return require('./nice.linux-x64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-linux-x64-musl')
const bindingPackageVersion = require('@napi-rs/nice-linux-x64-musl/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./nice.linux-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-linux-x64-gnu')
const bindingPackageVersion = require('@napi-rs/nice-linux-x64-gnu/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm64') {
if (isMusl()) {
try {
return require('./nice.linux-arm64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-linux-arm64-musl')
const bindingPackageVersion = require('@napi-rs/nice-linux-arm64-musl/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./nice.linux-arm64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-linux-arm64-gnu')
const bindingPackageVersion = require('@napi-rs/nice-linux-arm64-gnu/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm') {
if (isMusl()) {
try {
return require('./nice.linux-arm-musleabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-linux-arm-musleabihf')
const bindingPackageVersion = require('@napi-rs/nice-linux-arm-musleabihf/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./nice.linux-arm-gnueabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-linux-arm-gnueabihf')
const bindingPackageVersion = require('@napi-rs/nice-linux-arm-gnueabihf/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'riscv64') {
if (isMusl()) {
try {
return require('./nice.linux-riscv64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-linux-riscv64-musl')
const bindingPackageVersion = require('@napi-rs/nice-linux-riscv64-musl/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./nice.linux-riscv64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-linux-riscv64-gnu')
const bindingPackageVersion = require('@napi-rs/nice-linux-riscv64-gnu/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'ppc64') {
try {
return require('./nice.linux-ppc64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-linux-ppc64-gnu')
const bindingPackageVersion = require('@napi-rs/nice-linux-ppc64-gnu/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 's390x') {
try {
return require('./nice.linux-s390x-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-linux-s390x-gnu')
const bindingPackageVersion = require('@napi-rs/nice-linux-s390x-gnu/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
}
} else if (process.platform === 'openharmony') {
if (process.arch === 'arm64') {
try {
return require('./nice.openharmony-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-openharmony-arm64')
const bindingPackageVersion = require('@napi-rs/nice-openharmony-arm64/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'x64') {
try {
return require('./nice.openharmony-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-openharmony-x64')
const bindingPackageVersion = require('@napi-rs/nice-openharmony-x64/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./nice.openharmony-arm.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@napi-rs/nice-openharmony-arm')
const bindingPackageVersion = require('@napi-rs/nice-openharmony-arm/package.json').version
if (bindingPackageVersion !== '1.1.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 1.1.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
}
} else {
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
}
}
nativeBinding = requireNative()
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
try {
nativeBinding = require('./nice.wasi.cjs')
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
loadErrors.push(err)
}
}
if (!nativeBinding) {
try {
nativeBinding = require('@napi-rs/nice-wasm32-wasi')
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
loadErrors.push(err)
}
}
}
}
if (!nativeBinding) {
if (loadErrors.length > 0) {
throw new Error(
`Cannot find native binding. ` +
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
{ cause: loadErrors }
)
}
throw new Error(`Failed to load native binding`)
}
module.exports = nativeBinding
module.exports.getCurrentProcessPriority = nativeBinding.getCurrentProcessPriority
module.exports.nice = nativeBinding.nice
module.exports.WindowsThreadPriority = nativeBinding.WindowsThreadPriority
+30
View File
@@ -0,0 +1,30 @@
let nice
let getCurrentProcessPriority
try {
const { nice: niceNative, getCurrentProcessPriority: getCurrentProcessPriorityNative } = require('./index.js')
nice = niceNative
getCurrentProcessPriority = getCurrentProcessPriorityNative
} catch (e) {
if (process.platform !== 'win32') {
throw e
}
// fallback on Windows
nice = function nice(incr) { return incr }
getCurrentProcessPriority = function getCurrentProcessPriority() { return 1 }
}
module.exports.nice = nice
module.exports.getCurrentProcessPriority = getCurrentProcessPriority
module.exports.WindowsThreadPriority = {};
(function (WindowsThreadPriority) {
WindowsThreadPriority[WindowsThreadPriority["ThreadModeBackgroundBegin"] = 65536] = "ThreadModeBackgroundBegin";
WindowsThreadPriority[WindowsThreadPriority["ThreadModeBackgroundEnd"] = 131072] = "ThreadModeBackgroundEnd";
WindowsThreadPriority[WindowsThreadPriority["ThreadPriorityAboveNormal"] = 1] = "ThreadPriorityAboveNormal";
WindowsThreadPriority[WindowsThreadPriority["ThreadPriorityBelowNormal"] = -1] = "ThreadPriorityBelowNormal";
WindowsThreadPriority[WindowsThreadPriority["ThreadPriorityHighest"] = 2] = "ThreadPriorityHighest";
WindowsThreadPriority[WindowsThreadPriority["ThreadPriorityIdle"] = -15] = "ThreadPriorityIdle";
WindowsThreadPriority[WindowsThreadPriority["ThreadPriorityLowest"] = -2] = "ThreadPriorityLowest";
WindowsThreadPriority[WindowsThreadPriority["ThreadPriorityNormal"] = 0] = "ThreadPriorityNormal";
WindowsThreadPriority[WindowsThreadPriority["ThreadPriorityTimeCritical"] = 15] = "ThreadPriorityTimeCritical";
})(module.exports.WindowsThreadPriority)
+139
View File
@@ -0,0 +1,139 @@
{
"name": "@napi-rs/nice",
"version": "1.1.1",
"description": "https://linux.die.net/man/2/nice binding for Node.js",
"main": "nice.js",
"types": "index.d.ts",
"repository": {
"url": "git+ssh://git@github.com/Brooooooklyn/nice.git",
"type": "git"
},
"license": "MIT",
"keywords": [
"napi-rs",
"NAPI",
"N-API",
"Rust",
"node-addon",
"node-addon-api",
"nice"
],
"files": [
"index.d.ts",
"index.js",
"nice.js"
],
"napi": {
"binaryName": "nice",
"targets": [
"x86_64-apple-darwin",
"aarch64-apple-darwin",
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-gnu",
"i686-pc-windows-msvc",
"armv7-unknown-linux-gnueabihf",
"aarch64-linux-android",
"x86_64-unknown-freebsd",
"aarch64-unknown-linux-musl",
"armv7-linux-androideabi",
"aarch64-pc-windows-msvc",
"powerpc64le-unknown-linux-gnu",
"s390x-unknown-linux-gnu",
"riscv64gc-unknown-linux-gnu",
"aarch64-unknown-linux-ohos"
],
"constEnum": false
},
"engines": {
"node": ">= 10"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"scripts": {
"artifacts": "napi artifacts",
"build": "napi build --platform --release",
"build:debug": "napi build --platform",
"format": "run-p format:prettier format:rs format:toml",
"format:prettier": "prettier . -w",
"format:toml": "taplo format",
"format:rs": "cargo fmt",
"lint": "oxlint",
"preversion": "napi build --platform && git add .",
"prepublishOnly": "napi prepublish -t npm",
"test": "ava",
"version": "napi version"
},
"devDependencies": {
"@napi-rs/cli": "3.1.4",
"@oxc-node/core": "^0.0.32",
"@taplo/cli": "^0.7.0",
"ava": "^6.4.1",
"chalk": "^5.5.0",
"husky": "^9.1.7",
"lint-staged": "^16.1.5",
"npm-run-all2": "^8.0.4",
"oxlint": "^1.11.2",
"prettier": "^3.6.2",
"typescript": "^5.9.2"
},
"lint-staged": {
"*.@(js|ts|tsx)": [
"oxlint --fix"
],
"*.@(js|ts|tsx|yml|yaml|md|json)": [
"prettier --write"
],
"*.toml": [
"taplo format"
]
},
"ava": {
"extensions": {
"ts": "module"
},
"timeout": "2m",
"workerThreads": false,
"environmentVariables": {
"TS_NODE_PROJECT": "./tsconfig.json"
},
"nodeArguments": [
"--import",
"@oxc-node/core/register"
]
},
"prettier": {
"printWidth": 120,
"semi": false,
"trailingComma": "all",
"singleQuote": true,
"arrowParens": "always"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
},
"packageManager": "pnpm@10.14.0",
"optionalDependencies": {
"@napi-rs/nice-darwin-x64": "1.1.1",
"@napi-rs/nice-darwin-arm64": "1.1.1",
"@napi-rs/nice-linux-x64-gnu": "1.1.1",
"@napi-rs/nice-win32-x64-msvc": "1.1.1",
"@napi-rs/nice-linux-x64-musl": "1.1.1",
"@napi-rs/nice-linux-arm64-gnu": "1.1.1",
"@napi-rs/nice-win32-ia32-msvc": "1.1.1",
"@napi-rs/nice-linux-arm-gnueabihf": "1.1.1",
"@napi-rs/nice-android-arm64": "1.1.1",
"@napi-rs/nice-freebsd-x64": "1.1.1",
"@napi-rs/nice-linux-arm64-musl": "1.1.1",
"@napi-rs/nice-android-arm-eabi": "1.1.1",
"@napi-rs/nice-win32-arm64-msvc": "1.1.1",
"@napi-rs/nice-linux-ppc64-gnu": "1.1.1",
"@napi-rs/nice-linux-s390x-gnu": "1.1.1",
"@napi-rs/nice-linux-riscv64-gnu": "1.1.1",
"@napi-rs/nice-openharmony-arm64": "1.1.1"
}
}
+264
View File
@@ -0,0 +1,264 @@
'use strict';
// @ts-check
/**
* @param {unknown} value
*/
const getType = (value) => {
if (value === undefined) return 0
if (value === null) return 1
const t = typeof value;
if (t === 'boolean') return 2
if (t === 'number') return 3
if (t === 'string') return 4
if (t === 'object') return 6
if (t === 'bigint') return 9
return -1
};
/**
* @param {import('memfs').IFs} memfs
* @param {any} value
* @param {ReturnType<typeof getType>} type
* @returns {Uint8Array}
*/
const encodeValue = (memfs, value, type) => {
switch (type) {
case 0:
case 1:
return new Uint8Array(0)
case 2: {
const view = new Int32Array(1);
view[0] = value ? 1 : 0;
return new Uint8Array(view.buffer)
}
case 3: {
const view = new Float64Array(1);
view[0] = value;
return new Uint8Array(view.buffer)
}
case 4: {
const view = new TextEncoder().encode(value);
return view
}
case 6: {
function storeConstructor(obj, memfs, processed = new WeakSet()) {
if (!obj || typeof obj !== 'object') {
return
}
if (processed.has(obj)) {
return
}
processed.add(obj);
const [entry] =
Object.entries(memfs).filter(([_, v]) => v === obj.constructor)[0] ??
[];
if (entry) {
Object.defineProperty(obj, '__constructor__', {
configurable: true,
writable: true,
enumerable: true,
value: entry,
});
}
for (const value of Object.values(obj)) {
storeConstructor(value, memfs, processed);
}
}
storeConstructor(value, memfs);
const json = JSON.stringify(value, (_, value) => {
if (typeof value === 'bigint') {
return `BigInt(${String(value)})`
}
if (value instanceof Error) {
return {
...value,
message: value.message,
stack: value.stack,
__error__: value.constructor.name,
}
}
return value
});
const view = new TextEncoder().encode(json);
return view
}
case 9: {
const view = new BigInt64Array(1);
view[0] = value;
return new Uint8Array(view.buffer)
}
case -1:
default:
throw new Error('unsupported data')
}
};
/**
* @param {typeof import('memfs')} memfs
* @param {Uint8Array} payload
* @param {number} type
* @returns {any}
*/
const decodeValue = (memfs, payload, type) => {
if (type === 0) return undefined
if (type === 1) return null
if (type === 2)
return Boolean(new Int32Array(payload.buffer, payload.byteOffset, 1)[0])
if (type === 3)
return new Float64Array(payload.buffer, payload.byteOffset, 1)[0]
if (type === 4) return new TextDecoder().decode(payload.slice())
if (type === 6) {
const obj = JSON.parse(
new TextDecoder().decode(payload.slice()),
(_key, value) => {
if (typeof value === 'string') {
const matched = value.match(/^BigInt\((-?\d+)\)$/);
if (matched && matched[1]) {
return BigInt(matched[1])
}
}
return value
},
);
function loadConstructor(obj, memfs, processed = new WeakSet()) {
if (!obj || typeof obj !== 'object') {
return
}
if (processed.has(obj)) {
return
}
processed.add(obj);
if (obj.__constructor__) {
const ctor = obj.__constructor__;
delete obj.__constructor__;
Object.setPrototypeOf(obj, memfs[ctor].prototype);
}
for (const value of Object.values(obj)) {
loadConstructor(value, memfs, processed);
}
}
loadConstructor(obj, memfs);
if (obj.__error__) {
const name = obj.__error__;
const ErrorConstructor = globalThis[name] || Error;
delete obj.__error__;
const err = new ErrorConstructor(obj.message);
Object.defineProperty(err, 'stack', {
configurable: true,
enumerable: false,
writable: true,
value: err.stack,
});
Object.defineProperty(err, Symbol.toStringTag, {
configurable: true,
enumerable: false,
writable: true,
value: name,
});
for (const [k, v] of Object.entries(obj)) {
if (k === 'message' || k === 'stack') continue
err[k] = v;
}
return err
}
return obj
}
if (type === 9)
return new BigInt64Array(payload.buffer, payload.byteOffset, 1)[0]
throw new Error('unsupported data')
};
/**
* @param {import('memfs').IFs} fs
* @returns {(e: { data: { __fs__: { sab: Int32Array, type: keyof import('memfs').IFs, payload: any[] } } }) => void}
*/
// oxlint-disable-next-line no-unused-vars -- fixed in an upcoming release
const createOnMessage = (fs) =>
function onMessage(e) {
if (e.data.__fs__) {
/**
* 0..4 status(int32_t): 21(waiting) 0(success) 1(error)
* 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) -1(unsupported)
* 9..16 payload_size(uint32_t) <= 1024
* 16..16 + payload_size payload_content
*/
const { sab, type, payload } = e.data.__fs__;
const fn = fs[type];
try {
const ret = fn.apply(fs, payload);
const t = getType(ret);
Atomics.store(sab, 1, t);
const v = encodeValue(fs, ret, t);
Atomics.store(sab, 2, v.length);
new Uint8Array(sab.buffer).set(v, 16);
Atomics.store(sab, 0, 0); // success
} catch (/** @type {any} */ err) {
const t = getType(err);
Atomics.store(sab, 1, t);
const v = encodeValue(fs, err, t);
Atomics.store(sab, 2, v.length);
new Uint8Array(sab.buffer).set(v, 16);
Atomics.store(sab, 0, 1); // error
} finally {
Atomics.notify(sab, 0);
}
}
};
/**
* @param {typeof import('memfs')} memfs
*/
const createFsProxy = (memfs) =>
new Proxy(
{},
{
get(_target, p, _receiver) {
/**
* @param {any[]} args
*/
return function (...args) {
const sab = new SharedArrayBuffer(16 + 10240);
const i32arr = new Int32Array(sab);
Atomics.store(i32arr, 0, 21);
postMessage({
__fs__: {
sab: i32arr,
type: p,
payload: args,
},
});
Atomics.wait(i32arr, 0, 21);
const status = Atomics.load(i32arr, 0);
const type = Atomics.load(i32arr, 1);
const size = Atomics.load(i32arr, 2);
const content = new Uint8Array(sab, 16, size);
const value = decodeValue(memfs, content, type);
if (status === 1) {
throw value
}
return value
}
},
},
);
exports.createFsProxy = createFsProxy;
exports.createOnMessage = createOnMessage;
+20983
View File
File diff suppressed because one or more lines are too long
+259
View File
@@ -0,0 +1,259 @@
// @ts-check
/**
* @param {unknown} value
*/
const getType = (value) => {
if (value === undefined) return 0
if (value === null) return 1
const t = typeof value
if (t === 'boolean') return 2
if (t === 'number') return 3
if (t === 'string') return 4
if (t === 'object') return 6
if (t === 'bigint') return 9
return -1
}
/**
* @param {import('memfs').IFs} memfs
* @param {any} value
* @param {ReturnType<typeof getType>} type
* @returns {Uint8Array}
*/
const encodeValue = (memfs, value, type) => {
switch (type) {
case 0:
case 1:
return new Uint8Array(0)
case 2: {
const view = new Int32Array(1)
view[0] = value ? 1 : 0
return new Uint8Array(view.buffer)
}
case 3: {
const view = new Float64Array(1)
view[0] = value
return new Uint8Array(view.buffer)
}
case 4: {
const view = new TextEncoder().encode(value)
return view
}
case 6: {
function storeConstructor(obj, memfs, processed = new WeakSet()) {
if (!obj || typeof obj !== 'object') {
return
}
if (processed.has(obj)) {
return
}
processed.add(obj)
const [entry] =
Object.entries(memfs).filter(([_, v]) => v === obj.constructor)[0] ??
[]
if (entry) {
Object.defineProperty(obj, '__constructor__', {
configurable: true,
writable: true,
enumerable: true,
value: entry,
})
}
for (const value of Object.values(obj)) {
storeConstructor(value, memfs, processed)
}
}
storeConstructor(value, memfs)
const json = JSON.stringify(value, (_, value) => {
if (typeof value === 'bigint') {
return `BigInt(${String(value)})`
}
if (value instanceof Error) {
return {
...value,
message: value.message,
stack: value.stack,
__error__: value.constructor.name,
}
}
return value
})
const view = new TextEncoder().encode(json)
return view
}
case 9: {
const view = new BigInt64Array(1)
view[0] = value
return new Uint8Array(view.buffer)
}
case -1:
default:
throw new Error('unsupported data')
}
}
/**
* @param {typeof import('memfs')} memfs
* @param {Uint8Array} payload
* @param {number} type
* @returns {any}
*/
const decodeValue = (memfs, payload, type) => {
if (type === 0) return undefined
if (type === 1) return null
if (type === 2)
return Boolean(new Int32Array(payload.buffer, payload.byteOffset, 1)[0])
if (type === 3)
return new Float64Array(payload.buffer, payload.byteOffset, 1)[0]
if (type === 4) return new TextDecoder().decode(payload.slice())
if (type === 6) {
const obj = JSON.parse(
new TextDecoder().decode(payload.slice()),
(_key, value) => {
if (typeof value === 'string') {
const matched = value.match(/^BigInt\((-?\d+)\)$/)
if (matched && matched[1]) {
return BigInt(matched[1])
}
}
return value
},
)
function loadConstructor(obj, memfs, processed = new WeakSet()) {
if (!obj || typeof obj !== 'object') {
return
}
if (processed.has(obj)) {
return
}
processed.add(obj)
if (obj.__constructor__) {
const ctor = obj.__constructor__
delete obj.__constructor__
Object.setPrototypeOf(obj, memfs[ctor].prototype)
}
for (const value of Object.values(obj)) {
loadConstructor(value, memfs, processed)
}
}
loadConstructor(obj, memfs)
if (obj.__error__) {
const name = obj.__error__
const ErrorConstructor = globalThis[name] || Error
delete obj.__error__
const err = new ErrorConstructor(obj.message)
Object.defineProperty(err, 'stack', {
configurable: true,
enumerable: false,
writable: true,
value: err.stack,
})
Object.defineProperty(err, Symbol.toStringTag, {
configurable: true,
enumerable: false,
writable: true,
value: name,
})
for (const [k, v] of Object.entries(obj)) {
if (k === 'message' || k === 'stack') continue
err[k] = v
}
return err
}
return obj
}
if (type === 9)
return new BigInt64Array(payload.buffer, payload.byteOffset, 1)[0]
throw new Error('unsupported data')
}
/**
* @param {import('memfs').IFs} fs
* @returns {(e: { data: { __fs__: { sab: Int32Array, type: keyof import('memfs').IFs, payload: any[] } } }) => void}
*/
// oxlint-disable-next-line no-unused-vars -- fixed in an upcoming release
export const createOnMessage = (fs) =>
function onMessage(e) {
if (e.data.__fs__) {
/**
* 0..4 status(int32_t): 21(waiting) 0(success) 1(error)
* 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) -1(unsupported)
* 9..16 payload_size(uint32_t) <= 1024
* 16..16 + payload_size payload_content
*/
const { sab, type, payload } = e.data.__fs__
const fn = fs[type]
try {
const ret = fn.apply(fs, payload)
const t = getType(ret)
Atomics.store(sab, 1, t)
const v = encodeValue(fs, ret, t)
Atomics.store(sab, 2, v.length)
new Uint8Array(sab.buffer).set(v, 16)
Atomics.store(sab, 0, 0) // success
} catch (/** @type {any} */ err) {
const t = getType(err)
Atomics.store(sab, 1, t)
const v = encodeValue(fs, err, t)
Atomics.store(sab, 2, v.length)
new Uint8Array(sab.buffer).set(v, 16)
Atomics.store(sab, 0, 1) // error
} finally {
Atomics.notify(sab, 0)
}
}
}
/**
* @param {typeof import('memfs')} memfs
*/
export const createFsProxy = (memfs) =>
new Proxy(
{},
{
get(_target, p, _receiver) {
/**
* @param {any[]} args
*/
return function (...args) {
const sab = new SharedArrayBuffer(16 + 10240)
const i32arr = new Int32Array(sab)
Atomics.store(i32arr, 0, 21)
postMessage({
__fs__: {
sab: i32arr,
type: p,
payload: args,
},
})
Atomics.wait(i32arr, 0, 21)
const status = Atomics.load(i32arr, 0)
const type = Atomics.load(i32arr, 1)
const size = Atomics.load(i32arr, 2)
const content = new Uint8Array(sab, 16, size)
const value = decodeValue(memfs, content, type)
if (status === 1) {
throw value
}
return value
}
},
},
)
+68
View File
@@ -0,0 +1,68 @@
{
"name": "@napi-rs/wasm-runtime",
"version": "1.1.1",
"type": "module",
"description": "Runtime and polyfill for wasm targets",
"homepage": "https://napi.rs/",
"author": {
"name": "LongYinan",
"url": "https://github.com/Brooooooklyn"
},
"repository": {
"type": "git",
"url": "git+https://github.com/napi-rs/napi-rs.git",
"directory": "wasi-runtime"
},
"license": "MIT",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"files": [
"runtime.cjs",
"runtime.js",
"fs-proxy.js",
"dist/*.cjs",
"dist/*.js"
],
"devDependencies": {
"@rollup/plugin-alias": "^6.0.0",
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-replace": "^6.0.3",
"buffer": "^6.0.3",
"events": "^3.3.0",
"memfs": "^4.50.0",
"node-inspect-extracted": "^3.2.2",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
"readable-stream": "^4.7.0",
"rollup": "^4.53.1",
"rollup-plugin-polyfill-node": "^0.13.0",
"tslib": "^2.8.1"
},
"dependencies": {
"@emnapi/core": "^1.7.1",
"@emnapi/runtime": "^1.7.1",
"@tybys/wasm-util": "^0.10.1"
},
"scripts": {
"build": "rollup -c rollup.config.js",
"test": "node --test"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
},
"exports": {
".": {
"import": "./runtime.js",
"require": "./runtime.cjs"
},
"./fs": {
"import": "./dist/fs.js"
}
}
}
+15
View File
@@ -0,0 +1,15 @@
const { MessageHandler, instantiateNapiModuleSync, instantiateNapiModule } = require('@emnapi/core')
const { getDefaultContext } = require('@emnapi/runtime')
const { WASI } = require('@tybys/wasm-util')
const { createFsProxy, createOnMessage } = require('./dist/fs-proxy.cjs')
module.exports = {
MessageHandler,
instantiateNapiModule,
instantiateNapiModuleSync,
getDefaultContext,
WASI,
createFsProxy,
createOnMessage,
}
+8
View File
@@ -0,0 +1,8 @@
export {
instantiateNapiModuleSync,
instantiateNapiModule,
MessageHandler,
} from '@emnapi/core'
export { getDefaultContext } from '@emnapi/runtime'
export * from '@tybys/wasm-util'
export { createOnMessage, createFsProxy } from './fs-proxy.js'