Primeiro commit do projeto Angular
This commit is contained in:
+21
@@ -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
@@ -0,0 +1,73 @@
|
||||
# `@napi-rs/nice`
|
||||
|
||||

|
||||
[](https://packagephobia.com/result?p=@napi-rs/nice)
|
||||
[](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
@@ -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
@@ -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
@@ -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
@@ -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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user