Added support for Streamdeck Pedal and updated UI to better fit the Packed UI style
This commit is contained in:
90
node_modules/@julusian/jpeg-turbo/CMakeLists.txt
generated
vendored
Normal file
90
node_modules/@julusian/jpeg-turbo/CMakeLists.txt
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
if(POLICY CMP0135)
|
||||
cmake_policy(SET CMP0135 NEW) # DOWNLOAD_EXTRACT_TIMESTAMP
|
||||
endif()
|
||||
include(ExternalProject)
|
||||
|
||||
project (jpeg-turbo)
|
||||
|
||||
# define NPI_VERSION
|
||||
add_definitions(-DNAPI_VERSION=10)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
include_directories(${CMAKE_JS_INC})
|
||||
|
||||
set(SOURCE_FILES
|
||||
"src/buffersize.cc"
|
||||
"src/buffersize.h"
|
||||
"src/compress.cc"
|
||||
"src/compress.h"
|
||||
"src/decompress.cc"
|
||||
"src/decompress.h"
|
||||
"src/enums.cc"
|
||||
"src/enums.h"
|
||||
"src/util.cc"
|
||||
"src/util.h"
|
||||
"src/exports.cc"
|
||||
"src/consts.h"
|
||||
)
|
||||
|
||||
set(libjpeg-turbo_version "3.1.3")
|
||||
set(libjpeg-turbo_url "https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/${libjpeg-turbo_version}/libjpeg-turbo-${libjpeg-turbo_version}.tar.gz")
|
||||
set(libjpeg-turbo_sha256 "075920b826834ac4ddf97661cc73491047855859affd671d52079c6867c1c6c0")
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
# build shared on linux, to avoid conflicts with libjpeg built into electron
|
||||
set(ENABLE_SHARED 1)
|
||||
set(ENABLE_STATIC 0)
|
||||
|
||||
else()
|
||||
# build static elsewhere
|
||||
set(ENABLE_SHARED 0)
|
||||
set(ENABLE_STATIC 1)
|
||||
endif()
|
||||
|
||||
# Download and build libjpeg-turbo
|
||||
ExternalProject_Add(libjpeg-turbo
|
||||
URL ${libjpeg-turbo_url}
|
||||
URL_HASH SHA256=${libjpeg-turbo_sha256}
|
||||
CMAKE_ARGS -DENABLE_SHARED=${ENABLE_SHARED} -DENABLE_STATIC=${ENABLE_STATIC} -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} -DREQUIRE_SIMD=ON ${LIBJPEG_TURBO_OPTIONS}
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
ExternalProject_Get_Property(libjpeg-turbo SOURCE_DIR)
|
||||
set(JPEG_INCLUDE_DIR ${SOURCE_DIR}/src)
|
||||
ExternalProject_Get_Property(libjpeg-turbo BINARY_DIR)
|
||||
set(JPEG_LIB_DIR ${BINARY_DIR})
|
||||
set(JPEG_LIB turbojpeg)
|
||||
|
||||
if (MSVC)
|
||||
# Windows uses a different path for some reason
|
||||
set(JPEG_LIB_DIR ${JPEG_LIB_DIR}/Release)
|
||||
set(JPEG_LIB turbojpeg-static)
|
||||
endif()
|
||||
|
||||
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN")
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${JPEG_INCLUDE_DIR})
|
||||
target_link_directories(${PROJECT_NAME} PRIVATE ${JPEG_LIB_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} ${JPEG_LIB})
|
||||
add_dependencies(${PROJECT_NAME} libjpeg-turbo)
|
||||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
|
||||
|
||||
if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
|
||||
# Generate node.lib
|
||||
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
# copy built lib into build dir
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${JPEG_LIB_DIR}/libturbojpeg.so.0 ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
|
||||
)
|
||||
endif()
|
||||
13
node_modules/@julusian/jpeg-turbo/LICENSE
generated
vendored
Normal file
13
node_modules/@julusian/jpeg-turbo/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Copyright © Simo Kinnunen. All Rights Reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
207
node_modules/@julusian/jpeg-turbo/README.md
generated
vendored
Normal file
207
node_modules/@julusian/jpeg-turbo/README.md
generated
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
# @julusian/jpeg-turbo
|
||||
|
||||

|
||||
[](https://www.npmjs.com/package/@julusian/jpeg-turbo)
|
||||
[](https://www.npmjs.com/package/@julusian/jpeg-turbo)
|
||||
[](LICENSE)
|
||||
|
||||
This is a fork of [jpeg-turbo](https://github.com/sorccu/node-jpeg-turbo) with the intention of being maintained and bringing support for new versions of node
|
||||
|
||||
**node-jpeg-turbo** provides minimal [libjpeg-turbo](http://libjpeg-turbo.org/) bindings for [Node.js](https://nodejs.org/). It is very, very fast compared to other alternatives, such as [node-imagemagick-native](https://github.com/mash/node-imagemagick-native) or [jpeg-js](https://github.com/eugeneware/jpeg-js).
|
||||
|
||||
Please ask if you need more methods exposed.
|
||||
|
||||
## Requirements
|
||||
|
||||
All versions of Node still in [_active_ Long-term Support](https://github.com/nodejs/LTS#lts-schedule) and the current development version are supported. Older versions may or may not work; they are not and will not be supported.
|
||||
|
||||
We provide prebuilds for some platforms, meaning that you should not have to compile native bindings from source very often. The bindings are hosted at and automatically installed from our [GitHub Releases](https://github.com/julusian/node-jpeg-turbo).
|
||||
|
||||
### If you must build from source
|
||||
|
||||
First, if you're building from the repo, make sure to init and update submodules or you'll get confusing errors about missing targets when building. We include `libjpeg-turbo` as a submodule.
|
||||
|
||||
```bash
|
||||
git submodule init
|
||||
git submodule update
|
||||
```
|
||||
|
||||
(or just use `git clone --recursive` when cloning the repo)
|
||||
|
||||
We build `libjpeg-turbo` directly with `cmake`, so both `cmake` and `nasm` are required on your machine. `nasm` is only required on x86 and x86_64 architectures.
|
||||
|
||||
To install:
|
||||
|
||||
**On OS X**
|
||||
|
||||
```bash
|
||||
brew install nasm
|
||||
brew install cmake
|
||||
```
|
||||
|
||||
**On Ubuntu/Debian**
|
||||
|
||||
```bash
|
||||
apt-get install nasm cmake
|
||||
```
|
||||
|
||||
**On Windows**
|
||||
|
||||
Download and install the latest from [here](https://cmake.org/download/). Make sure to select the option to put it on path for all users.
|
||||
|
||||
Download Win32 or Win64 nasm from [here](https://www.nasm.us/) and make sure it's found in path as nasm.exe. Use the "for general use" version. If the .exe doesn't run, or complains about a missing `MSVCR100.dll`, you can install the missing VS2010 Redist x64 from [KB2977003](https://www.microsoft.com/en-gb/download/details.aspx?id=14632). The .exe should work fine after installing the redistributable.
|
||||
|
||||
To verify your nasm setup, run:
|
||||
|
||||
```sh
|
||||
nasm
|
||||
```
|
||||
|
||||
This should give the output:
|
||||
|
||||
> nasm: fatal: no input file specified
|
||||
|
||||
Next, you need to make sure that you have a build environment set up. An easy way to do that is to use [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools).
|
||||
|
||||
Now, just to make sure things are set up properly, run:
|
||||
|
||||
```
|
||||
npm config get msvs_version
|
||||
```
|
||||
|
||||
If the output is `2015` or newer, you're good. If it's anything else, or not set, you must run:
|
||||
|
||||
```
|
||||
npm config set -g msvs_version 2015
|
||||
```
|
||||
|
||||
Alternatively, you can specify the option at install time with `--msvs_version=2015`.
|
||||
|
||||
**Others**
|
||||
|
||||
Search your package manager for `nasm`.
|
||||
|
||||
## Installation
|
||||
|
||||
Make sure you've got the [requirements](#requirements) installed first.
|
||||
|
||||
Using [yarn](https://yarnpkg.com/):
|
||||
|
||||
```sh
|
||||
yarn add @julusian/jpeg-turbo
|
||||
```
|
||||
|
||||
Using [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
npm install --save @julusian/jpeg-turbo
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `jpg.bufferSize(options)` → `Number`
|
||||
|
||||
If you'd like to preallocate a `Buffer` for `jpg.compressSync()`, use this method to get the worst-case upper bound. The `options` argument is fully compatible with the `jpg.compressSync()` method, so that you can pass the same options to both functions.
|
||||
|
||||
- **options** is an Object with the following properties:
|
||||
- **width** Required. The width of the image.
|
||||
- **height** Required. The height of the image.
|
||||
- **subsampling** Optional. The subsampling method to use. Defaults to `jpg.SAMP_420`.
|
||||
- **Returns** The `Number` of bytes required in a worst-case scenario.
|
||||
|
||||
```js
|
||||
var fs = require("fs");
|
||||
var jpg = require("@julusian/jpeg-turbo");
|
||||
|
||||
var raw = fs.readFileSync("raw.rgba");
|
||||
|
||||
var options = {
|
||||
format: jpg.FORMAT_RGBA,
|
||||
width: 1080,
|
||||
height: 1920,
|
||||
subsampling: jpg.SAMP_444,
|
||||
};
|
||||
|
||||
var preallocated = new Buffer(jpg.bufferSize(options));
|
||||
|
||||
var encoded = jpg.compressSync(raw, preallocated, options);
|
||||
```
|
||||
|
||||
### `jpg.compressSync(raw[, out], options)` → `Object`
|
||||
|
||||
Compresses (i.e. encodes) the raw pixel data into a JPG. This method is not capable of resizing the image.
|
||||
|
||||
For efficiency reasons you may choose to encode into a preallocated `Buffer`. While fast, it has a number of drawbacks. Namely, you'll have to be careful not to reuse the buffer in async processing before processing (e.g. saving, displaying or transmitting) the entire encoded image. Otherwise you risk corrupting the image. Also, it wastes a huge amount of space compared to on-demand allocation.
|
||||
|
||||
- **raw** is a `Buffer` with the raw pixel data in `options.format`.
|
||||
- **out** is an optional preallocated `Buffer` for the encoded image. The size of the buffer is checked. See `jpg.bufferSize()` for an example of how to preallocate a sufficient `Buffer`. If not given, memory is allocated and reallocated as needed, which eliminates most of the wasted space but is slower and lacks consistency with varying source images.
|
||||
- **options** is an Object with the following properties:
|
||||
- **format** Required. The format of the `raw` pixel data (e.g. `jpg.FORMAT_RGBA`).
|
||||
- **width** Required. The width of the image.
|
||||
- **height** Required. The height of the image.
|
||||
- **subsampling** Optional. The subsampling method to use. Defaults to `jpg.SAMP_420`.
|
||||
- **quality** Optional. The desired JPG quality. Defaults to 80.
|
||||
- **Returns** An `Object` with the following properties:
|
||||
- **data** The encoded image as a `Buffer`. Note that the buffer may actually be a slice of the preallocated `Buffer`, if given. _**Be careful not to reuse the preallocated buffer before you've finished processing the encoded image, as it may corrupt the image.**_
|
||||
- **size** The size of the used space in the buffer
|
||||
|
||||
```js
|
||||
var fs = require("fs");
|
||||
var jpg = require("@julusian/jpeg-turbo");
|
||||
|
||||
var raw = fs.readFileSync("raw.rgba");
|
||||
|
||||
var options = {
|
||||
format: jpg.FORMAT_RGBA,
|
||||
width: 1080,
|
||||
height: 1920,
|
||||
subsampling: jpg.SAMP_444,
|
||||
};
|
||||
|
||||
var encoded = jpg.compressSync(raw, options);
|
||||
```
|
||||
|
||||
See `jpg.bufferSize()` for an example of preallocated `Buffer` usage.
|
||||
|
||||
### `jpg.decompressSync(image[, out], options)` → `Object`
|
||||
|
||||
Decompresses (i.e. decodes) the JPG image into raw pixel data.
|
||||
|
||||
- **image** is a `Buffer` with the JPG image data.
|
||||
- **out** is an optional preallocated `Buffer` for the decoded image. The size of the buffer is checked, and should be at least `width * height * bytes_per_pixel` or larger. If not given, one is created for you. The only benefit of providing the `Buffer` yourself is that you can reuse the same buffer between multiple `jpg.decompressSync()` calls. Note that this can lead to issues with concurrency. See `jpg.compressSync()` for related discussion.
|
||||
- **options** is an Object with the following properties:
|
||||
- **format** Required. The desired format of the `raw` pixel data (e.g. `jpg.FORMAT_RGBA`).
|
||||
- **out** _Deprecated._ Use the `out` argument instead.
|
||||
- **Returns** An `Object` with the following properties:
|
||||
- **data** A `Buffer` with the raw pixel data.
|
||||
- **width** The width of the image.
|
||||
- **height** The height of the image.
|
||||
- **subsampling** The subsampling method used in the JPG.
|
||||
- **size** _Deprecated._ Use `data.length` instead.
|
||||
- **bpp** The number of bytes per pixel.
|
||||
|
||||
```js
|
||||
var fs = require("fs");
|
||||
var jpg = require("@julusian/jpeg-turbo");
|
||||
|
||||
var image = fs.readFileSync("image.jpg");
|
||||
|
||||
var options = {
|
||||
format: jpg.FORMAT_RGBA,
|
||||
};
|
||||
|
||||
var decoded = jpg.decompressSync(image, options);
|
||||
```
|
||||
|
||||
## Thanks
|
||||
|
||||
- https://github.com/A2K/node-jpeg-turbo-scaler
|
||||
- https://github.com/mash/node-imagemagick-native
|
||||
- https://github.com/google/skia/blob/master/gyp/libjpeg-turbo.gyp
|
||||
- https://github.com/openstf/android-libjpeg-turbo
|
||||
|
||||
## License
|
||||
|
||||
See [LICENSE](LICENSE).
|
||||
|
||||
Copyright © Julian Waller. All Rights Reserved.
|
||||
4
node_modules/@julusian/jpeg-turbo/binding-options.js
generated
vendored
Normal file
4
node_modules/@julusian/jpeg-turbo/binding-options.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
name: "jpeg-turbo",
|
||||
napi_versions: [10],
|
||||
};
|
||||
38
node_modules/@julusian/jpeg-turbo/index.js
generated
vendored
Normal file
38
node_modules/@julusian/jpeg-turbo/index.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
const binding = require("pkg-prebuilds")(
|
||||
__dirname,
|
||||
require("./binding-options")
|
||||
);
|
||||
|
||||
// Copy exports so that we can customize them on the JS side without
|
||||
// overwriting the binding itself.
|
||||
Object.keys(binding).forEach(function (key) {
|
||||
module.exports[key] = binding[key];
|
||||
});
|
||||
|
||||
// Convenience wrapper for Buffer slicing.
|
||||
module.exports.compressSync = function (buffer, optionalOutBuffer, options) {
|
||||
var out = binding.compressSync(buffer, optionalOutBuffer, options);
|
||||
return out.data.slice(0, out.size);
|
||||
};
|
||||
|
||||
// Convenience wrapper for Buffer slicing.
|
||||
module.exports.compress = function (a, b, c) {
|
||||
return binding.compress(a, b, c).then((out) => {
|
||||
return out.data.slice(0, out.size);
|
||||
});
|
||||
};
|
||||
|
||||
// Convenience wrapper for Buffer slicing.
|
||||
module.exports.decompressSync = function (buffer, optionalOutBuffer, options) {
|
||||
var out = binding.decompressSync(buffer, optionalOutBuffer, options);
|
||||
out.data = out.data.slice(0, out.size);
|
||||
return out;
|
||||
};
|
||||
|
||||
// Convenience wrapper for Buffer slicing.
|
||||
module.exports.decompress = function (a, b, c) {
|
||||
return binding.decompress(a, b, c).then((out) => {
|
||||
out.data = out.data.slice(0, out.size);
|
||||
return out;
|
||||
});
|
||||
};
|
||||
65
node_modules/@julusian/jpeg-turbo/module.d.ts
generated
vendored
Normal file
65
node_modules/@julusian/jpeg-turbo/module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
export type Format = number;
|
||||
export const FORMAT_RGB: Format;
|
||||
export const FORMAT_BGR: Format;
|
||||
export const FORMAT_RGBX: Format;
|
||||
export const FORMAT_BGRX: Format;
|
||||
export const FORMAT_XRGB: Format;
|
||||
export const FORMAT_XBGR: Format;
|
||||
export const FORMAT_GRAY: Format;
|
||||
export const FORMAT_RGBA: Format;
|
||||
export const FORMAT_BGRA: Format;
|
||||
export const FORMAT_ABGR: Format;
|
||||
export const FORMAT_ARGB: Format;
|
||||
|
||||
export type SubSampling = number;
|
||||
export const SAMP_444: SubSampling;
|
||||
export const SAMP_422: SubSampling;
|
||||
export const SAMP_420: SubSampling;
|
||||
export const SAMP_GRAY: SubSampling;
|
||||
export const SAMP_440: SubSampling;
|
||||
|
||||
export interface BufferSizeOptions {
|
||||
width: number;
|
||||
height: number;
|
||||
subsampling?: SubSampling;
|
||||
}
|
||||
|
||||
export interface EncodeOptions extends BufferSizeOptions {
|
||||
format: Format;
|
||||
stride?: number;
|
||||
quality?: number;
|
||||
}
|
||||
|
||||
export function bufferSize(options: BufferSizeOptions): number;
|
||||
|
||||
export function compressSync(raw: Buffer, options: EncodeOptions): Buffer;
|
||||
export function compressSync(raw: Buffer, preallocatedOut: Buffer, options: EncodeOptions): Buffer;
|
||||
|
||||
export function compress(raw: Buffer, options: EncodeOptions): Promise<Buffer>;
|
||||
export function compress(
|
||||
raw: Buffer,
|
||||
preallocatedOut: Buffer,
|
||||
options: EncodeOptions
|
||||
): Promise<Buffer>;
|
||||
|
||||
export interface DecodeOptions {
|
||||
format: Format;
|
||||
}
|
||||
|
||||
export interface DecompressReturn {
|
||||
data: Buffer;
|
||||
width: number;
|
||||
height: number;
|
||||
size: number;
|
||||
format: any;
|
||||
}
|
||||
|
||||
export function decompressSync(image: Buffer, preallocatedOut: Buffer, options?: DecodeOptions): DecompressReturn;
|
||||
export function decompressSync(image: Buffer, options?: DecodeOptions): DecompressReturn;
|
||||
|
||||
export function decompress(
|
||||
image: Buffer,
|
||||
preallocatedOut: Buffer,
|
||||
options?: DecodeOptions
|
||||
): Promise<DecompressReturn>;
|
||||
export function decompress(image: Buffer, options?: DecodeOptions): Promise<DecompressReturn>;
|
||||
9
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/LICENSE.md
generated
vendored
Normal file
9
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 [Node.js API collaborators](https://github.com/nodejs/node-addon-api#collaborators)
|
||||
|
||||
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.
|
||||
95
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/README.md
generated
vendored
Normal file
95
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/README.md
generated
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
# **node-addon-api module**
|
||||
|
||||
[](https://app.codecov.io/gh/nodejs/node-addon-api/tree/main)
|
||||
|
||||
[](https://nodei.co/npm/node-addon-api/) [](https://nodei.co/npm/node-addon-api/)
|
||||
|
||||
This module contains **header-only C++ wrapper classes** which simplify
|
||||
the use of the C based [Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
|
||||
provided by Node.js when using C++. It provides a C++ object model
|
||||
and exception handling semantics with low overhead.
|
||||
|
||||
- [API References](doc/README.md)
|
||||
- [Badges](#badges)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
## API References
|
||||
|
||||
API references are available in the [doc](doc/README.md) directory.
|
||||
|
||||
<!-- x-release-please-start-version -->
|
||||
## Current version: 8.6.0
|
||||
<!-- x-release-please-end -->
|
||||
|
||||
(See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
|
||||
|
||||
node-addon-api is based on [Node-API](https://nodejs.org/api/n-api.html) and supports using different Node-API versions.
|
||||
This allows addons built with it to run with Node.js versions which support the targeted Node-API version.
|
||||
**However** the node-addon-api support model is to support only the active LTS Node.js versions. This means that
|
||||
every year there will be a new major which drops support for the Node.js LTS version which has gone out of service.
|
||||
|
||||
The oldest Node.js version supported by the current version of node-addon-api is Node.js 18.x.
|
||||
|
||||
## Badges
|
||||
|
||||
The use of badges is recommended to indicate the minimum version of Node-API
|
||||
required for the module. This helps to determine which Node.js major versions are
|
||||
supported. Addon maintainers can consult the [Node-API support matrix][] to determine
|
||||
which Node.js versions provide a given Node-API version. The following badges are
|
||||
available:
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Contributing
|
||||
|
||||
We love contributions from the community to **node-addon-api**!
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on our philosophy around extending this module.
|
||||
|
||||
## Team members
|
||||
|
||||
### Active
|
||||
|
||||
| Name | GitHub Link |
|
||||
| ------------------- | ----------------------------------------------------- |
|
||||
| Anna Henningsen | [addaleax](https://github.com/addaleax) |
|
||||
| Chengzhong Wu | [legendecas](https://github.com/legendecas) |
|
||||
| Jack Xia | [JckXia](https://github.com/JckXia) |
|
||||
| Kevin Eady | [KevinEady](https://github.com/KevinEady) |
|
||||
| Michael Dawson | [mhdawson](https://github.com/mhdawson) |
|
||||
| Nicola Del Gobbo | [NickNaso](https://github.com/NickNaso) |
|
||||
| Vladimir Morozov | [vmoroz](https://github.com/vmoroz) |
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Emeritus</summary>
|
||||
|
||||
### Emeritus
|
||||
|
||||
| Name | GitHub Link |
|
||||
| ------------------- | ----------------------------------------------------- |
|
||||
| Arunesh Chandra | [aruneshchandra](https://github.com/aruneshchandra) |
|
||||
| Benjamin Byholm | [kkoopa](https://github.com/kkoopa) |
|
||||
| Gabriel Schulhof | [gabrielschulhof](https://github.com/gabrielschulhof) |
|
||||
| Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
|
||||
| Jason Ginchereau | [jasongin](https://github.com/jasongin) |
|
||||
| Jim Schlight | [jschlight](https://github.com/jschlight) |
|
||||
| Sampson Gao | [sampsongao](https://github.com/sampsongao) |
|
||||
| Taylor Woll | [boingoing](https://github.com/boingoing) |
|
||||
|
||||
</details>
|
||||
|
||||
## License
|
||||
|
||||
Licensed under [MIT](./LICENSE.md)
|
||||
|
||||
[Node-API support matrix]: https://nodejs.org/dist/latest/docs/api/n-api.html#node-api-version-matrix
|
||||
21
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/common.gypi
generated
vendored
Normal file
21
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/common.gypi
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
'variables': {
|
||||
'NAPI_VERSION%': "<!(node -p \"process.env.NAPI_VERSION || process.versions.napi\")",
|
||||
'disable_deprecated': "<!(node -p \"process.env['npm_config_disable_deprecated']\")"
|
||||
},
|
||||
'conditions': [
|
||||
['NAPI_VERSION!=""', { 'defines': ['NAPI_VERSION=<@(NAPI_VERSION)'] } ],
|
||||
['NAPI_VERSION==2147483647', { 'defines': ['NAPI_EXPERIMENTAL', 'NODE_API_EXPERIMENTAL_NO_WARNING'] } ],
|
||||
['disable_deprecated=="true"', {
|
||||
'defines': ['NODE_ADDON_API_DISABLE_DEPRECATED']
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
'cflags+': ['-fvisibility=hidden'],
|
||||
'xcode_settings': {
|
||||
'OTHER_CFLAGS': ['-fvisibility=hidden']
|
||||
}
|
||||
}]
|
||||
],
|
||||
'cflags': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ],
|
||||
'cflags_cc': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ]
|
||||
}
|
||||
25
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/except.gypi
generated
vendored
Normal file
25
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/except.gypi
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
'defines': [ 'NAPI_CPP_EXCEPTIONS' ],
|
||||
'cflags!': [ '-fno-exceptions' ],
|
||||
'cflags_cc!': [ '-fno-exceptions' ],
|
||||
'conditions': [
|
||||
["OS=='win'", {
|
||||
"defines": [
|
||||
"_HAS_EXCEPTIONS=1"
|
||||
],
|
||||
"msvs_settings": {
|
||||
"VCCLCompilerTool": {
|
||||
"ExceptionHandling": 1,
|
||||
'EnablePREfast': 'true',
|
||||
},
|
||||
},
|
||||
}],
|
||||
["OS=='mac'", {
|
||||
'xcode_settings': {
|
||||
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
|
||||
'CLANG_CXX_LIBRARY': 'libc++',
|
||||
'MACOSX_DEPLOYMENT_TARGET': '10.7',
|
||||
},
|
||||
}],
|
||||
],
|
||||
}
|
||||
14
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/index.js
generated
vendored
Normal file
14
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/index.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
const path = require('path');
|
||||
const { version } = require('./package.json');
|
||||
|
||||
const includeDir = path.relative('.', __dirname);
|
||||
|
||||
module.exports = {
|
||||
include: `"${__dirname}"`, // deprecated, can be removed as part of 4.0.0
|
||||
include_dir: includeDir,
|
||||
gyp: path.join(includeDir, 'node_api.gyp:nothing'), // deprecated.
|
||||
targets: path.join(includeDir, 'node_addon_api.gyp'),
|
||||
version,
|
||||
isNodeApiBuiltin: true,
|
||||
needsFlag: false
|
||||
};
|
||||
186
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/napi-inl.deprecated.h
generated
vendored
Normal file
186
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/napi-inl.deprecated.h
generated
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
#ifndef SRC_NAPI_INL_DEPRECATED_H_
|
||||
#define SRC_NAPI_INL_DEPRECATED_H_
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// PropertyDescriptor class
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename Getter>
|
||||
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
||||
const char* utf8name,
|
||||
Getter getter,
|
||||
napi_property_attributes attributes,
|
||||
void* /*data*/) {
|
||||
using CbData = details::CallbackData<Getter, Napi::Value>;
|
||||
// TODO: Delete when the function is destroyed
|
||||
auto callbackData = new CbData({getter, nullptr});
|
||||
|
||||
return PropertyDescriptor({utf8name,
|
||||
nullptr,
|
||||
nullptr,
|
||||
CbData::Wrapper,
|
||||
nullptr,
|
||||
nullptr,
|
||||
attributes,
|
||||
callbackData});
|
||||
}
|
||||
|
||||
template <typename Getter>
|
||||
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
||||
const std::string& utf8name,
|
||||
Getter getter,
|
||||
napi_property_attributes attributes,
|
||||
void* data) {
|
||||
return Accessor(utf8name.c_str(), getter, attributes, data);
|
||||
}
|
||||
|
||||
template <typename Getter>
|
||||
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
||||
napi_value name,
|
||||
Getter getter,
|
||||
napi_property_attributes attributes,
|
||||
void* /*data*/) {
|
||||
using CbData = details::CallbackData<Getter, Napi::Value>;
|
||||
// TODO: Delete when the function is destroyed
|
||||
auto callbackData = new CbData({getter, nullptr});
|
||||
|
||||
return PropertyDescriptor({nullptr,
|
||||
name,
|
||||
nullptr,
|
||||
CbData::Wrapper,
|
||||
nullptr,
|
||||
nullptr,
|
||||
attributes,
|
||||
callbackData});
|
||||
}
|
||||
|
||||
template <typename Getter>
|
||||
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
||||
Name name, Getter getter, napi_property_attributes attributes, void* data) {
|
||||
napi_value nameValue = name;
|
||||
return PropertyDescriptor::Accessor(nameValue, getter, attributes, data);
|
||||
}
|
||||
|
||||
template <typename Getter, typename Setter>
|
||||
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
||||
const char* utf8name,
|
||||
Getter getter,
|
||||
Setter setter,
|
||||
napi_property_attributes attributes,
|
||||
void* /*data*/) {
|
||||
using CbData = details::AccessorCallbackData<Getter, Setter>;
|
||||
// TODO: Delete when the function is destroyed
|
||||
auto callbackData = new CbData({getter, setter, nullptr});
|
||||
|
||||
return PropertyDescriptor({utf8name,
|
||||
nullptr,
|
||||
nullptr,
|
||||
CbData::GetterWrapper,
|
||||
CbData::SetterWrapper,
|
||||
nullptr,
|
||||
attributes,
|
||||
callbackData});
|
||||
}
|
||||
|
||||
template <typename Getter, typename Setter>
|
||||
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
||||
const std::string& utf8name,
|
||||
Getter getter,
|
||||
Setter setter,
|
||||
napi_property_attributes attributes,
|
||||
void* data) {
|
||||
return Accessor(utf8name.c_str(), getter, setter, attributes, data);
|
||||
}
|
||||
|
||||
template <typename Getter, typename Setter>
|
||||
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
||||
napi_value name,
|
||||
Getter getter,
|
||||
Setter setter,
|
||||
napi_property_attributes attributes,
|
||||
void* /*data*/) {
|
||||
using CbData = details::AccessorCallbackData<Getter, Setter>;
|
||||
// TODO: Delete when the function is destroyed
|
||||
auto callbackData = new CbData({getter, setter, nullptr});
|
||||
|
||||
return PropertyDescriptor({nullptr,
|
||||
name,
|
||||
nullptr,
|
||||
CbData::GetterWrapper,
|
||||
CbData::SetterWrapper,
|
||||
nullptr,
|
||||
attributes,
|
||||
callbackData});
|
||||
}
|
||||
|
||||
template <typename Getter, typename Setter>
|
||||
inline PropertyDescriptor PropertyDescriptor::Accessor(
|
||||
Name name,
|
||||
Getter getter,
|
||||
Setter setter,
|
||||
napi_property_attributes attributes,
|
||||
void* data) {
|
||||
napi_value nameValue = name;
|
||||
return PropertyDescriptor::Accessor(
|
||||
nameValue, getter, setter, attributes, data);
|
||||
}
|
||||
|
||||
template <typename Callable>
|
||||
inline PropertyDescriptor PropertyDescriptor::Function(
|
||||
const char* utf8name,
|
||||
Callable cb,
|
||||
napi_property_attributes attributes,
|
||||
void* /*data*/) {
|
||||
using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
|
||||
using CbData = details::CallbackData<Callable, ReturnType>;
|
||||
// TODO: Delete when the function is destroyed
|
||||
auto callbackData = new CbData({cb, nullptr});
|
||||
|
||||
return PropertyDescriptor({utf8name,
|
||||
nullptr,
|
||||
CbData::Wrapper,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
attributes,
|
||||
callbackData});
|
||||
}
|
||||
|
||||
template <typename Callable>
|
||||
inline PropertyDescriptor PropertyDescriptor::Function(
|
||||
const std::string& utf8name,
|
||||
Callable cb,
|
||||
napi_property_attributes attributes,
|
||||
void* data) {
|
||||
return Function(utf8name.c_str(), cb, attributes, data);
|
||||
}
|
||||
|
||||
template <typename Callable>
|
||||
inline PropertyDescriptor PropertyDescriptor::Function(
|
||||
napi_value name,
|
||||
Callable cb,
|
||||
napi_property_attributes attributes,
|
||||
void* /*data*/) {
|
||||
using ReturnType = decltype(cb(CallbackInfo(nullptr, nullptr)));
|
||||
using CbData = details::CallbackData<Callable, ReturnType>;
|
||||
// TODO: Delete when the function is destroyed
|
||||
auto callbackData = new CbData({cb, nullptr});
|
||||
|
||||
return PropertyDescriptor({nullptr,
|
||||
name,
|
||||
CbData::Wrapper,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
attributes,
|
||||
callbackData});
|
||||
}
|
||||
|
||||
template <typename Callable>
|
||||
inline PropertyDescriptor PropertyDescriptor::Function(
|
||||
Name name, Callable cb, napi_property_attributes attributes, void* data) {
|
||||
napi_value nameValue = name;
|
||||
return PropertyDescriptor::Function(nameValue, cb, attributes, data);
|
||||
}
|
||||
|
||||
#endif // !SRC_NAPI_INL_DEPRECATED_H_
|
||||
7108
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/napi-inl.h
generated
vendored
Normal file
7108
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/napi-inl.h
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3327
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/napi.h
generated
vendored
Normal file
3327
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/napi.h
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
42
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/node_addon_api.gyp
generated
vendored
Normal file
42
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/node_addon_api.gyp
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'node_addon_api',
|
||||
'type': 'none',
|
||||
'sources': [ 'napi.h', 'napi-inl.h' ],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [ '.' ],
|
||||
'includes': ['noexcept.gypi'],
|
||||
}
|
||||
},
|
||||
{
|
||||
'target_name': 'node_addon_api_except',
|
||||
'type': 'none',
|
||||
'sources': [ 'napi.h', 'napi-inl.h' ],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [ '.' ],
|
||||
'includes': ['except.gypi'],
|
||||
}
|
||||
},
|
||||
{
|
||||
'target_name': 'node_addon_api_except_all',
|
||||
'type': 'none',
|
||||
'sources': [ 'napi.h', 'napi-inl.h' ],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [ '.' ],
|
||||
'includes': ['except.gypi'],
|
||||
'defines': [ 'NODE_ADDON_API_CPP_EXCEPTIONS_ALL' ]
|
||||
}
|
||||
},
|
||||
{
|
||||
'target_name': 'node_addon_api_maybe',
|
||||
'type': 'none',
|
||||
'sources': [ 'napi.h', 'napi-inl.h' ],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [ '.' ],
|
||||
'includes': ['noexcept.gypi'],
|
||||
'defines': ['NODE_ADDON_API_ENABLE_MAYBE']
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
9
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/node_api.gyp
generated
vendored
Normal file
9
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/node_api.gyp
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'nothing',
|
||||
'type': 'static_library',
|
||||
'sources': [ 'nothing.c' ]
|
||||
}
|
||||
]
|
||||
}
|
||||
26
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/noexcept.gypi
generated
vendored
Normal file
26
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/noexcept.gypi
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
'defines': [ 'NODE_ADDON_API_DISABLE_CPP_EXCEPTIONS' ],
|
||||
'cflags': [ '-fno-exceptions' ],
|
||||
'cflags_cc': [ '-fno-exceptions' ],
|
||||
'conditions': [
|
||||
["OS=='win'", {
|
||||
# _HAS_EXCEPTIONS is already defined and set to 0 in common.gypi
|
||||
#"defines": [
|
||||
# "_HAS_EXCEPTIONS=0"
|
||||
#],
|
||||
"msvs_settings": {
|
||||
"VCCLCompilerTool": {
|
||||
'ExceptionHandling': 0,
|
||||
'EnablePREfast': 'true',
|
||||
},
|
||||
},
|
||||
}],
|
||||
["OS=='mac'", {
|
||||
'xcode_settings': {
|
||||
'CLANG_CXX_LIBRARY': 'libc++',
|
||||
'MACOSX_DEPLOYMENT_TARGET': '10.7',
|
||||
'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',
|
||||
},
|
||||
}],
|
||||
],
|
||||
}
|
||||
0
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/nothing.c
generated
vendored
Normal file
0
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/nothing.c
generated
vendored
Normal file
21
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/package-support.json
generated
vendored
Normal file
21
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/package-support.json
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"version": "*",
|
||||
"target": {
|
||||
"node": "active"
|
||||
},
|
||||
"response": {
|
||||
"type": "time-permitting",
|
||||
"paid": false,
|
||||
"contact": {
|
||||
"name": "node-addon-api team",
|
||||
"url": "https://github.com/nodejs/node-addon-api/issues"
|
||||
}
|
||||
},
|
||||
"backing": [ { "project": "https://github.com/nodejs" },
|
||||
{ "foundation": "https://openjsf.org/" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
480
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/package.json
generated
vendored
Normal file
480
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/package.json
generated
vendored
Normal file
@@ -0,0 +1,480 @@
|
||||
{
|
||||
"bugs": {
|
||||
"url": "https://github.com/nodejs/node-addon-api/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Abhishek Kumar Singh",
|
||||
"url": "https://github.com/abhi11210646"
|
||||
},
|
||||
{
|
||||
"name": "Alba Mendez",
|
||||
"url": "https://github.com/jmendeth"
|
||||
},
|
||||
{
|
||||
"name": "Alexander Floh",
|
||||
"url": "https://github.com/alexanderfloh"
|
||||
},
|
||||
{
|
||||
"name": "Ammar Faizi",
|
||||
"url": "https://github.com/ammarfaizi2"
|
||||
},
|
||||
{
|
||||
"name": "András Timár, Dr",
|
||||
"url": "https://github.com/timarandras"
|
||||
},
|
||||
{
|
||||
"name": "Andrew Petersen",
|
||||
"url": "https://github.com/kirbysayshi"
|
||||
},
|
||||
{
|
||||
"name": "Anisha Rohra",
|
||||
"url": "https://github.com/anisha-rohra"
|
||||
},
|
||||
{
|
||||
"name": "Anna Henningsen",
|
||||
"url": "https://github.com/addaleax"
|
||||
},
|
||||
{
|
||||
"name": "Arnaud Botella",
|
||||
"url": "https://github.com/BotellaA"
|
||||
},
|
||||
{
|
||||
"name": "Arunesh Chandra",
|
||||
"url": "https://github.com/aruneshchandra"
|
||||
},
|
||||
{
|
||||
"name": "Azlan Mukhtar",
|
||||
"url": "https://github.com/azlan"
|
||||
},
|
||||
{
|
||||
"name": "Ben Berman",
|
||||
"url": "https://github.com/rivertam"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Byholm",
|
||||
"url": "https://github.com/kkoopa"
|
||||
},
|
||||
{
|
||||
"name": "Bill Gallafent",
|
||||
"url": "https://github.com/gallafent"
|
||||
},
|
||||
{
|
||||
"name": "blagoev",
|
||||
"url": "https://github.com/blagoev"
|
||||
},
|
||||
{
|
||||
"name": "Bruce A. MacNaughton",
|
||||
"url": "https://github.com/bmacnaughton"
|
||||
},
|
||||
{
|
||||
"name": "Cory Mickelson",
|
||||
"url": "https://github.com/corymickelson"
|
||||
},
|
||||
{
|
||||
"name": "Daniel Bevenius",
|
||||
"url": "https://github.com/danbev"
|
||||
},
|
||||
{
|
||||
"name": "Dante Calderón",
|
||||
"url": "https://github.com/dantehemerson"
|
||||
},
|
||||
{
|
||||
"name": "Darshan Sen",
|
||||
"url": "https://github.com/RaisinTen"
|
||||
},
|
||||
{
|
||||
"name": "David Halls",
|
||||
"url": "https://github.com/davedoesdev"
|
||||
},
|
||||
{
|
||||
"name": "Deepak Rajamohan",
|
||||
"url": "https://github.com/deepakrkris"
|
||||
},
|
||||
{
|
||||
"name": "Dmitry Ashkadov",
|
||||
"url": "https://github.com/dmitryash"
|
||||
},
|
||||
{
|
||||
"name": "Dongjin Na",
|
||||
"url": "https://github.com/nadongguri"
|
||||
},
|
||||
{
|
||||
"name": "Doni Rubiagatra",
|
||||
"url": "https://github.com/rubiagatra"
|
||||
},
|
||||
{
|
||||
"name": "Eric Bickle",
|
||||
"url": "https://github.com/ebickle"
|
||||
},
|
||||
{
|
||||
"name": "extremeheat",
|
||||
"url": "https://github.com/extremeheat"
|
||||
},
|
||||
{
|
||||
"name": "Feng Yu",
|
||||
"url": "https://github.com/F3n67u"
|
||||
},
|
||||
{
|
||||
"name": "Ferdinand Holzer",
|
||||
"url": "https://github.com/fholzer"
|
||||
},
|
||||
{
|
||||
"name": "Gabriel Schulhof",
|
||||
"url": "https://github.com/gabrielschulhof"
|
||||
},
|
||||
{
|
||||
"name": "Guenter Sandner",
|
||||
"url": "https://github.com/gms1"
|
||||
},
|
||||
{
|
||||
"name": "Gus Caplan",
|
||||
"url": "https://github.com/devsnek"
|
||||
},
|
||||
{
|
||||
"name": "Helio Frota",
|
||||
"url": "https://github.com/helio-frota"
|
||||
},
|
||||
{
|
||||
"name": "Hitesh Kanwathirtha",
|
||||
"url": "https://github.com/digitalinfinity"
|
||||
},
|
||||
{
|
||||
"name": "ikokostya",
|
||||
"url": "https://github.com/ikokostya"
|
||||
},
|
||||
{
|
||||
"name": "Jack Xia",
|
||||
"url": "https://github.com/JckXia"
|
||||
},
|
||||
{
|
||||
"name": "Jake Barnes",
|
||||
"url": "https://github.com/DuBistKomisch"
|
||||
},
|
||||
{
|
||||
"name": "Jake Yoon",
|
||||
"url": "https://github.com/yjaeseok"
|
||||
},
|
||||
{
|
||||
"name": "Jason Ginchereau",
|
||||
"url": "https://github.com/jasongin"
|
||||
},
|
||||
{
|
||||
"name": "Jenny",
|
||||
"url": "https://github.com/egg-bread"
|
||||
},
|
||||
{
|
||||
"name": "Jeroen Janssen",
|
||||
"url": "https://github.com/japj"
|
||||
},
|
||||
{
|
||||
"name": "Jim Schlight",
|
||||
"url": "https://github.com/jschlight"
|
||||
},
|
||||
{
|
||||
"name": "Jinho Bang",
|
||||
"url": "https://github.com/romandev"
|
||||
},
|
||||
{
|
||||
"name": "José Expósito",
|
||||
"url": "https://github.com/JoseExposito"
|
||||
},
|
||||
{
|
||||
"name": "joshgarde",
|
||||
"url": "https://github.com/joshgarde"
|
||||
},
|
||||
{
|
||||
"name": "Julian Mesa",
|
||||
"url": "https://github.com/julianmesa-gitkraken"
|
||||
},
|
||||
{
|
||||
"name": "Kasumi Hanazuki",
|
||||
"url": "https://github.com/hanazuki"
|
||||
},
|
||||
{
|
||||
"name": "Kelvin",
|
||||
"url": "https://github.com/kelvinhammond"
|
||||
},
|
||||
{
|
||||
"name": "Kevin Eady",
|
||||
"url": "https://github.com/KevinEady"
|
||||
},
|
||||
{
|
||||
"name": "Kévin VOYER",
|
||||
"url": "https://github.com/kecsou"
|
||||
},
|
||||
{
|
||||
"name": "kidneysolo",
|
||||
"url": "https://github.com/kidneysolo"
|
||||
},
|
||||
{
|
||||
"name": "Koki Nishihara",
|
||||
"url": "https://github.com/Nishikoh"
|
||||
},
|
||||
{
|
||||
"name": "Konstantin Tarkus",
|
||||
"url": "https://github.com/koistya"
|
||||
},
|
||||
{
|
||||
"name": "Kyle Farnung",
|
||||
"url": "https://github.com/kfarnung"
|
||||
},
|
||||
{
|
||||
"name": "Kyle Kovacs",
|
||||
"url": "https://github.com/nullromo"
|
||||
},
|
||||
{
|
||||
"name": "legendecas",
|
||||
"url": "https://github.com/legendecas"
|
||||
},
|
||||
{
|
||||
"name": "LongYinan",
|
||||
"url": "https://github.com/Brooooooklyn"
|
||||
},
|
||||
{
|
||||
"name": "Lovell Fuller",
|
||||
"url": "https://github.com/lovell"
|
||||
},
|
||||
{
|
||||
"name": "Luciano Martorella",
|
||||
"url": "https://github.com/lmartorella"
|
||||
},
|
||||
{
|
||||
"name": "mastergberry",
|
||||
"url": "https://github.com/mastergberry"
|
||||
},
|
||||
{
|
||||
"name": "Mathias Küsel",
|
||||
"url": "https://github.com/mathiask88"
|
||||
},
|
||||
{
|
||||
"name": "Mathias Stearn",
|
||||
"url": "https://github.com/RedBeard0531"
|
||||
},
|
||||
{
|
||||
"name": "Matteo Collina",
|
||||
"url": "https://github.com/mcollina"
|
||||
},
|
||||
{
|
||||
"name": "Michael Dawson",
|
||||
"url": "https://github.com/mhdawson"
|
||||
},
|
||||
{
|
||||
"name": "Michael Price",
|
||||
"url": "https://github.com/mikepricedev"
|
||||
},
|
||||
{
|
||||
"name": "Michele Campus",
|
||||
"url": "https://github.com/kYroL01"
|
||||
},
|
||||
{
|
||||
"name": "Mikhail Cheshkov",
|
||||
"url": "https://github.com/mcheshkov"
|
||||
},
|
||||
{
|
||||
"name": "nempoBu4",
|
||||
"url": "https://github.com/nempoBu4"
|
||||
},
|
||||
{
|
||||
"name": "Nicola Del Gobbo",
|
||||
"url": "https://github.com/NickNaso"
|
||||
},
|
||||
{
|
||||
"name": "Nick Soggin",
|
||||
"url": "https://github.com/iSkore"
|
||||
},
|
||||
{
|
||||
"name": "Nikolai Vavilov",
|
||||
"url": "https://github.com/seishun"
|
||||
},
|
||||
{
|
||||
"name": "Nurbol Alpysbayev",
|
||||
"url": "https://github.com/anurbol"
|
||||
},
|
||||
{
|
||||
"name": "pacop",
|
||||
"url": "https://github.com/pacop"
|
||||
},
|
||||
{
|
||||
"name": "Peter Šándor",
|
||||
"url": "https://github.com/petersandor"
|
||||
},
|
||||
{
|
||||
"name": "Philipp Renoth",
|
||||
"url": "https://github.com/DaAitch"
|
||||
},
|
||||
{
|
||||
"name": "rgerd",
|
||||
"url": "https://github.com/rgerd"
|
||||
},
|
||||
{
|
||||
"name": "Richard Lau",
|
||||
"url": "https://github.com/richardlau"
|
||||
},
|
||||
{
|
||||
"name": "Rolf Timmermans",
|
||||
"url": "https://github.com/rolftimmermans"
|
||||
},
|
||||
{
|
||||
"name": "Ross Weir",
|
||||
"url": "https://github.com/ross-weir"
|
||||
},
|
||||
{
|
||||
"name": "Ryuichi Okumura",
|
||||
"url": "https://github.com/okuryu"
|
||||
},
|
||||
{
|
||||
"name": "Saint Gabriel",
|
||||
"url": "https://github.com/chineduG"
|
||||
},
|
||||
{
|
||||
"name": "Sampson Gao",
|
||||
"url": "https://github.com/sampsongao"
|
||||
},
|
||||
{
|
||||
"name": "Sam Roberts",
|
||||
"url": "https://github.com/sam-github"
|
||||
},
|
||||
{
|
||||
"name": "strager",
|
||||
"url": "https://github.com/strager"
|
||||
},
|
||||
{
|
||||
"name": "Taylor Woll",
|
||||
"url": "https://github.com/boingoing"
|
||||
},
|
||||
{
|
||||
"name": "Thomas Gentilhomme",
|
||||
"url": "https://github.com/fraxken"
|
||||
},
|
||||
{
|
||||
"name": "Tim Rach",
|
||||
"url": "https://github.com/timrach"
|
||||
},
|
||||
{
|
||||
"name": "Tobias Nießen",
|
||||
"url": "https://github.com/tniessen"
|
||||
},
|
||||
{
|
||||
"name": "todoroff",
|
||||
"url": "https://github.com/todoroff"
|
||||
},
|
||||
{
|
||||
"name": "Toyo Li",
|
||||
"url": "https://github.com/toyobayashi"
|
||||
},
|
||||
{
|
||||
"name": "Tux3",
|
||||
"url": "https://github.com/tux3"
|
||||
},
|
||||
{
|
||||
"name": "Vlad Velmisov",
|
||||
"url": "https://github.com/Velmisov"
|
||||
},
|
||||
{
|
||||
"name": "Vladimir Morozov",
|
||||
"url": "https://github.com/vmoroz"
|
||||
},
|
||||
{
|
||||
"name": "WenheLI",
|
||||
"url": "https://github.com/WenheLI"
|
||||
},
|
||||
{
|
||||
"name": "Xuguang Mei",
|
||||
"url": "https://github.com/meixg"
|
||||
},
|
||||
{
|
||||
"name": "Yohei Kishimoto",
|
||||
"url": "https://github.com/morokosi"
|
||||
},
|
||||
{
|
||||
"name": "Yulong Wang",
|
||||
"url": "https://github.com/fs-eire"
|
||||
},
|
||||
{
|
||||
"name": "Ziqiu Zhao",
|
||||
"url": "https://github.com/ZzqiZQute"
|
||||
},
|
||||
{
|
||||
"name": "Feng Yu",
|
||||
"url": "https://github.com/F3n67u"
|
||||
},
|
||||
{
|
||||
"name": "wanlu wang",
|
||||
"url": "https://github.com/wanlu"
|
||||
},
|
||||
{
|
||||
"name": "Caleb Hearon",
|
||||
"url": "https://github.com/chearon"
|
||||
},
|
||||
{
|
||||
"name": "Marx",
|
||||
"url": "https://github.com/MarxJiao"
|
||||
},
|
||||
{
|
||||
"name": "Ömer AKGÜL",
|
||||
"url": "https://github.com/tuhalf"
|
||||
}
|
||||
],
|
||||
"description": "Node.js API (Node-API)",
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"bindings": "^1.5.0",
|
||||
"clang-format": "^1.4.0",
|
||||
"eslint": "^9.13.0",
|
||||
"fs-extra": "^11.1.1",
|
||||
"neostandard": "^0.12.0",
|
||||
"pre-commit": "^1.2.2",
|
||||
"semver": "^7.6.0"
|
||||
},
|
||||
"directories": {},
|
||||
"gypfile": false,
|
||||
"homepage": "https://github.com/nodejs/node-addon-api",
|
||||
"keywords": [
|
||||
"n-api",
|
||||
"napi",
|
||||
"addon",
|
||||
"native",
|
||||
"bindings",
|
||||
"c",
|
||||
"c++",
|
||||
"nan",
|
||||
"node-addon-api"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "node-addon-api",
|
||||
"readme": "README.md",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/node-addon-api.git"
|
||||
},
|
||||
"files": [
|
||||
"*.{c,h,gyp,gypi}",
|
||||
"package-support.json",
|
||||
"tools/"
|
||||
],
|
||||
"scripts": {
|
||||
"prebenchmark": "node-gyp rebuild -C benchmark",
|
||||
"benchmark": "node benchmark",
|
||||
"create-coverage": "npm test --coverage",
|
||||
"report-coverage-html": "rm -rf coverage-html && mkdir coverage-html && gcovr -e test --merge-mode-functions merge-use-line-max --html-nested ./coverage-html/index.html test",
|
||||
"report-coverage-xml": "rm -rf coverage-xml && mkdir coverage-xml && gcovr -e test --merge-mode-functions merge-use-line-max --xml -o ./coverage-xml/coverage-cxx.xml test",
|
||||
"pretest": "node-gyp rebuild -C test",
|
||||
"test": "node test",
|
||||
"test:debug": "node-gyp rebuild -C test --debug && NODE_API_BUILD_CONFIG=Debug node ./test/index.js",
|
||||
"predev": "node-gyp rebuild -C test --debug",
|
||||
"dev": "node test",
|
||||
"predev:incremental": "node-gyp configure build -C test --debug",
|
||||
"dev:incremental": "node test",
|
||||
"doc": "doxygen doc/Doxyfile",
|
||||
"lint": "eslint && node tools/clang-format",
|
||||
"lint:fix": "eslint --fix && node tools/clang-format --fix"
|
||||
},
|
||||
"pre-commit": "lint",
|
||||
"version": "8.6.0",
|
||||
"support": true,
|
||||
"engines": {
|
||||
"node": "^18 || ^20 || >= 21"
|
||||
}
|
||||
}
|
||||
73
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/tools/README.md
generated
vendored
Normal file
73
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/tools/README.md
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
# Tools
|
||||
|
||||
## clang-format
|
||||
|
||||
The clang-format checking tools is designed to check changed lines of code compared to given git-refs.
|
||||
|
||||
## Migration Script
|
||||
|
||||
The migration tool is designed to reduce repetitive work in the migration process. However, the script is not aiming to convert every thing for you. There are usually some small fixes and major reconstruction required.
|
||||
|
||||
### How To Use
|
||||
|
||||
To run the conversion script, first make sure you have the latest `node-addon-api` in your `node_modules` directory.
|
||||
```
|
||||
npm install node-addon-api
|
||||
```
|
||||
|
||||
Then run the script passing your project directory
|
||||
```
|
||||
node ./node_modules/node-addon-api/tools/conversion.js ./
|
||||
```
|
||||
|
||||
After finish, recompile and debug things that are missed by the script.
|
||||
|
||||
|
||||
### Quick Fixes
|
||||
Here is the list of things that can be fixed easily.
|
||||
1. Change your methods' return value to void if it doesn't return value to JavaScript.
|
||||
2. Use `.` to access attribute or to invoke member function in Napi::Object instead of `->`.
|
||||
3. `Napi::New(env, value);` to `Napi::[Type]::New(env, value);
|
||||
|
||||
|
||||
### Major Reconstructions
|
||||
The implementation of `Napi::ObjectWrap` is significantly different from NAN's. `Napi::ObjectWrap` takes a pointer to the wrapped object and creates a reference to the wrapped object inside ObjectWrap constructor. `Napi::ObjectWrap` also associates wrapped object's instance methods to Javascript module instead of static methods like NAN.
|
||||
|
||||
So if you use Nan::ObjectWrap in your module, you will need to execute the following steps.
|
||||
|
||||
1. Convert your [ClassName]::New function to a constructor function that takes a `Napi::CallbackInfo`. Declare it as
|
||||
```
|
||||
[ClassName](const Napi::CallbackInfo& info);
|
||||
```
|
||||
and define it as
|
||||
```
|
||||
[ClassName]::[ClassName](const Napi::CallbackInfo& info) : Napi::ObjectWrap<[ClassName]>(info){
|
||||
...
|
||||
}
|
||||
```
|
||||
This way, the `Napi::ObjectWrap` constructor will be invoked after the object has been instantiated and `Napi::ObjectWrap` can use the `this` pointer to create a reference to the wrapped object.
|
||||
|
||||
2. Move your original constructor code into the new constructor. Delete your original constructor.
|
||||
3. In your class initialization function, associate native methods in the following way.
|
||||
```
|
||||
Napi::FunctionReference constructor;
|
||||
|
||||
void [ClassName]::Init(Napi::Env env, Napi::Object exports, Napi::Object module) {
|
||||
Napi::HandleScope scope(env);
|
||||
Napi::Function ctor = DefineClass(env, "Canvas", {
|
||||
InstanceMethod<&[ClassName]::Func1>("Func1"),
|
||||
InstanceMethod<&[ClassName]::Func2>("Func2"),
|
||||
InstanceAccessor<&[ClassName]::ValueGetter>("Value"),
|
||||
StaticMethod<&[ClassName]::StaticMethod>("MethodName"),
|
||||
InstanceValue("Value", Napi::[Type]::New(env, value)),
|
||||
});
|
||||
|
||||
constructor = Napi::Persistent(ctor);
|
||||
constructor .SuppressDestruct();
|
||||
exports.Set("[ClassName]", ctor);
|
||||
}
|
||||
```
|
||||
4. In function where you need to Unwrap the ObjectWrap in NAN like `[ClassName]* native = Nan::ObjectWrap::Unwrap<[ClassName]>(info.This());`, use `this` pointer directly as the unwrapped object as each ObjectWrap instance is associated with a unique object instance.
|
||||
|
||||
|
||||
If you still find issues after following this guide, please leave us an issue describing your problem and we will try to resolve it.
|
||||
99
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/tools/check-napi.js
generated
vendored
Normal file
99
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/tools/check-napi.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
'use strict';
|
||||
// Descend into a directory structure and, for each file matching *.node, output
|
||||
// based on the imports found in the file whether it's an N-API module or not.
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Read the output of the command, break it into lines, and use the reducer to
|
||||
// decide whether the file is an N-API module or not.
|
||||
function checkFile (file, command, argv, reducer) {
|
||||
const child = require('child_process').spawn(command, argv, {
|
||||
stdio: ['inherit', 'pipe', 'inherit']
|
||||
});
|
||||
let leftover = '';
|
||||
let isNapi;
|
||||
child.stdout.on('data', (chunk) => {
|
||||
if (isNapi === undefined) {
|
||||
chunk = (leftover + chunk.toString()).split(/[\r\n]+/);
|
||||
leftover = chunk.pop();
|
||||
isNapi = chunk.reduce(reducer, isNapi);
|
||||
if (isNapi !== undefined) {
|
||||
child.kill();
|
||||
}
|
||||
}
|
||||
});
|
||||
child.on('close', (code, signal) => {
|
||||
if ((code === null && signal !== null) || (code !== 0)) {
|
||||
console.log(
|
||||
command + ' exited with code: ' + code + ' and signal: ' + signal);
|
||||
} else {
|
||||
// Green if it's a N-API module, red otherwise.
|
||||
console.log(
|
||||
'\x1b[' + (isNapi ? '42' : '41') + 'm' +
|
||||
(isNapi ? ' N-API' : 'Not N-API') +
|
||||
'\x1b[0m: ' + file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Use nm -a to list symbols.
|
||||
function checkFileUNIX (file) {
|
||||
checkFile(file, 'nm', ['-a', file], (soFar, line) => {
|
||||
if (soFar === undefined) {
|
||||
line = line.match(/([0-9a-f]*)? ([a-zA-Z]) (.*$)/);
|
||||
if (line[2] === 'U') {
|
||||
if (/^napi/.test(line[3])) {
|
||||
soFar = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return soFar;
|
||||
});
|
||||
}
|
||||
|
||||
// Use dumpbin /imports to list symbols.
|
||||
function checkFileWin32 (file) {
|
||||
checkFile(file, 'dumpbin', ['/imports', file], (soFar, line) => {
|
||||
if (soFar === undefined) {
|
||||
line = line.match(/([0-9a-f]*)? +([a-zA-Z0-9]) (.*$)/);
|
||||
if (line && /^napi/.test(line[line.length - 1])) {
|
||||
soFar = true;
|
||||
}
|
||||
}
|
||||
return soFar;
|
||||
});
|
||||
}
|
||||
|
||||
// Descend into a directory structure and pass each file ending in '.node' to
|
||||
// one of the above checks, depending on the OS.
|
||||
function recurse (top) {
|
||||
fs.readdir(top, (error, items) => {
|
||||
if (error) {
|
||||
throw new Error('error reading directory ' + top + ': ' + error);
|
||||
}
|
||||
items.forEach((item) => {
|
||||
item = path.join(top, item);
|
||||
fs.stat(item, ((item) => (error, stats) => {
|
||||
if (error) {
|
||||
throw new Error('error about ' + item + ': ' + error);
|
||||
}
|
||||
if (stats.isDirectory()) {
|
||||
recurse(item);
|
||||
} else if (/[.]node$/.test(item) &&
|
||||
// Explicitly ignore files called 'nothing.node' because they are
|
||||
// artefacts of node-addon-api having identified a version of
|
||||
// Node.js that ships with a correct implementation of N-API.
|
||||
path.basename(item) !== 'nothing.node') {
|
||||
process.platform === 'win32'
|
||||
? checkFileWin32(item)
|
||||
: checkFileUNIX(item);
|
||||
}
|
||||
})(item));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Start with the directory given on the command line or the current directory
|
||||
// if nothing was given.
|
||||
recurse(process.argv.length > 3 ? process.argv[2] : '.');
|
||||
71
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/tools/clang-format.js
generated
vendored
Normal file
71
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/tools/clang-format.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const spawn = require('child_process').spawnSync;
|
||||
const path = require('path');
|
||||
|
||||
const filesToCheck = ['*.h', '*.cc'];
|
||||
const FORMAT_START = process.env.FORMAT_START || 'main';
|
||||
|
||||
function main (args) {
|
||||
let fix = false;
|
||||
while (args.length > 0) {
|
||||
switch (args[0]) {
|
||||
case '-f':
|
||||
case '--fix':
|
||||
fix = true;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
args.shift();
|
||||
}
|
||||
|
||||
const clangFormatPath = path.dirname(require.resolve('clang-format'));
|
||||
const binary = process.platform === 'win32'
|
||||
? 'node_modules\\.bin\\clang-format.cmd'
|
||||
: 'node_modules/.bin/clang-format';
|
||||
const options = ['--binary=' + binary, '--style=file'];
|
||||
if (fix) {
|
||||
options.push(FORMAT_START);
|
||||
} else {
|
||||
options.push('--diff', FORMAT_START);
|
||||
}
|
||||
|
||||
const gitClangFormatPath = path.join(clangFormatPath, 'bin/git-clang-format');
|
||||
const result = spawn(
|
||||
'python',
|
||||
[gitClangFormatPath, ...options, '--', ...filesToCheck],
|
||||
{ encoding: 'utf-8' }
|
||||
);
|
||||
|
||||
if (result.stderr) {
|
||||
console.error('Error running git-clang-format:', result.stderr);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const clangFormatOutput = result.stdout.trim();
|
||||
// Bail fast if in fix mode.
|
||||
if (fix) {
|
||||
console.log(clangFormatOutput);
|
||||
return 0;
|
||||
}
|
||||
// Detect if there is any complains from clang-format
|
||||
if (
|
||||
clangFormatOutput !== '' &&
|
||||
clangFormatOutput !== 'no modified files to format' &&
|
||||
clangFormatOutput !== 'clang-format did not modify any files'
|
||||
) {
|
||||
console.error(clangFormatOutput);
|
||||
const fixCmd = 'npm run lint:fix';
|
||||
console.error(`
|
||||
ERROR: please run "${fixCmd}" to format changes in your commit
|
||||
Note that when running the command locally, please keep your local
|
||||
main branch and working branch up to date with nodejs/node-addon-api
|
||||
to exclude un-related complains.
|
||||
Or you can run "env FORMAT_START=upstream/main ${fixCmd}".`);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
process.exitCode = main(process.argv.slice(2));
|
||||
}
|
||||
301
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/tools/conversion.js
generated
vendored
Executable file
301
node_modules/@julusian/jpeg-turbo/node_modules/node-addon-api/tools/conversion.js
generated
vendored
Executable file
@@ -0,0 +1,301 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const dir = args[0];
|
||||
if (!dir) {
|
||||
console.log('Usage: node ' + path.basename(__filename) + ' <target-dir>');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const NodeApiVersion = require('../').version;
|
||||
|
||||
const disable = args[1];
|
||||
let ConfigFileOperations;
|
||||
if (disable !== '--disable' && dir !== '--disable') {
|
||||
ConfigFileOperations = {
|
||||
'package.json': [
|
||||
[/([ ]*)"dependencies": {/g, '$1"dependencies": {\n$1 "node-addon-api": "' + NodeApiVersion + '",'],
|
||||
[/[ ]*"nan": *"[^"]+"(,|)[\n\r]/g, '']
|
||||
],
|
||||
'binding.gyp': [
|
||||
[/([ ]*)'include_dirs': \[/g, '$1\'include_dirs\': [\n$1 \'<!(node -p "require(\\\'node-addon-api\\\').include_dir")\','],
|
||||
[/([ ]*)"include_dirs": \[/g, '$1"include_dirs": [\n$1 "<!(node -p \\"require(\'node-addon-api\').include_dir\\")",'],
|
||||
[/[ ]*("|')<!\(node -e ("|'|\\"|\\')require\(("|'|\\"|\\')nan("|'|\\"|\\')\)("|'|\\"|\\')\)("|')(,|)[\r\n]/g, ''],
|
||||
[/([ ]*)("|')target_name("|'): ("|')(.+?)("|'),/g, '$1$2target_name$2: $4$5$6,\n $2cflags!$2: [ $2-fno-exceptions$2 ],\n $2cflags_cc!$2: [ $2-fno-exceptions$2 ],\n $2xcode_settings$2: { $2GCC_ENABLE_CPP_EXCEPTIONS$2: $2YES$2,\n $2CLANG_CXX_LIBRARY$2: $2libc++$2,\n $2MACOSX_DEPLOYMENT_TARGET$2: $210.7$2,\n },\n $2msvs_settings$2: {\n $2VCCLCompilerTool$2: { $2ExceptionHandling$2: 1 },\n },']
|
||||
]
|
||||
};
|
||||
} else {
|
||||
ConfigFileOperations = {
|
||||
'package.json': [
|
||||
[/([ ]*)"dependencies": {/g, '$1"dependencies": {\n$1 "node-addon-api": "' + NodeApiVersion + '",'],
|
||||
[/[ ]*"nan": *"[^"]+"(,|)[\n\r]/g, '']
|
||||
],
|
||||
'binding.gyp': [
|
||||
[/([ ]*)'include_dirs': \[/g, '$1\'include_dirs\': [\n$1 \'<!(node -p "require(\\\'node-addon-api\\\').include_dir")\','],
|
||||
[/([ ]*)"include_dirs": \[/g, '$1"include_dirs": [\n$1 "<!(node -p \'require(\\"node-addon-api\\").include_dir\')",'],
|
||||
[/[ ]*("|')<!\(node -e ("|'|\\"|\\')require\(("|'|\\"|\\')nan("|'|\\"|\\')\)("|'|\\"|\\')\)("|')(,|)[\r\n]/g, ''],
|
||||
[/([ ]*)("|')target_name("|'): ("|')(.+?)("|'),/g, '$1$2target_name$2: $4$5$6,\n $2cflags!$2: [ $2-fno-exceptions$2 ],\n $2cflags_cc!$2: [ $2-fno-exceptions$2 ],\n $2defines$2: [ $2NAPI_DISABLE_CPP_EXCEPTIONS$2 ],\n $2conditions$2: [\n [\'OS=="win"\', { $2defines$2: [ $2_HAS_EXCEPTIONS=1$2 ] }]\n ]']
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
const SourceFileOperations = [
|
||||
[/Nan::SetMethod\(target,[\s]*"(.*)"[\s]*,[\s]*([^)]+)\)/g, 'exports.Set(Napi::String::New(env, "$1"), Napi::Function::New(env, $2))'],
|
||||
|
||||
[/v8::Local<v8::FunctionTemplate>\s+(\w+)\s*=\s*Nan::New<FunctionTemplate>\([\w\d:]+\);(?:\w+->Reset\(\1\))?\s+\1->SetClassName\(Nan::String::New\("(\w+)"\)\);/g, 'Napi::Function $1 = DefineClass(env, "$2", {'],
|
||||
[/Local<FunctionTemplate>\s+(\w+)\s*=\s*Nan::New<FunctionTemplate>\([\w\d:]+\);\s+(\w+)\.Reset\((\1)\);\s+\1->SetClassName\((Nan::String::New|Nan::New<(v8::)*String>)\("(.+?)"\)\);/g, 'Napi::Function $1 = DefineClass(env, "$6", {'],
|
||||
[/Local<FunctionTemplate>\s+(\w+)\s*=\s*Nan::New<FunctionTemplate>\([\w\d:]+\);(?:\w+->Reset\(\1\))?\s+\1->SetClassName\(Nan::String::New\("(\w+)"\)\);/g, 'Napi::Function $1 = DefineClass(env, "$2", {'],
|
||||
[/Nan::New<v8::FunctionTemplate>\(([\w\d:]+)\)->GetFunction\(\)/g, 'Napi::Function::New(env, $1)'],
|
||||
[/Nan::New<FunctionTemplate>\(([\w\d:]+)\)->GetFunction()/g, 'Napi::Function::New(env, $1);'],
|
||||
[/Nan::New<v8::FunctionTemplate>\(([\w\d:]+)\)/g, 'Napi::Function::New(env, $1)'],
|
||||
[/Nan::New<FunctionTemplate>\(([\w\d:]+)\)/g, 'Napi::Function::New(env, $1)'],
|
||||
|
||||
// FunctionTemplate to FunctionReference
|
||||
[/Nan::Persistent<(v8::)*FunctionTemplate>/g, 'Napi::FunctionReference'],
|
||||
[/Nan::Persistent<(v8::)*Function>/g, 'Napi::FunctionReference'],
|
||||
[/v8::Local<v8::FunctionTemplate>/g, 'Napi::FunctionReference'],
|
||||
[/Local<FunctionTemplate>/g, 'Napi::FunctionReference'],
|
||||
[/v8::FunctionTemplate/g, 'Napi::FunctionReference'],
|
||||
[/FunctionTemplate/g, 'Napi::FunctionReference'],
|
||||
|
||||
[/([ ]*)Nan::SetPrototypeMethod\(\w+, "(\w+)", (\w+)\);/g, '$1InstanceMethod("$2", &$3),'],
|
||||
[/([ ]*)(?:\w+\.Reset\(\w+\);\s+)?\(target\)\.Set\("(\w+)",\s*Nan::GetFunction\((\w+)\)\);/gm,
|
||||
'});\n\n' +
|
||||
'$1constructor = Napi::Persistent($3);\n' +
|
||||
'$1constructor.SuppressDestruct();\n' +
|
||||
'$1target.Set("$2", $3);'],
|
||||
|
||||
// TODO: Other attribute combinations
|
||||
[/static_cast<PropertyAttribute>\(ReadOnly\s*\|\s*DontDelete\)/gm,
|
||||
'static_cast<napi_property_attributes>(napi_enumerable | napi_configurable)'],
|
||||
|
||||
[/([\w\d:<>]+?)::Cast\((.+?)\)/g, '$2.As<$1>()'],
|
||||
|
||||
[/\*Nan::Utf8String\(([^)]+)\)/g, '$1->As<Napi::String>().Utf8Value().c_str()'],
|
||||
[/Nan::Utf8String +(\w+)\(([^)]+)\)/g, 'std::string $1 = $2.As<Napi::String>()'],
|
||||
[/Nan::Utf8String/g, 'std::string'],
|
||||
|
||||
[/v8::String::Utf8Value (.+?)\((.+?)\)/g, 'Napi::String $1(env, $2)'],
|
||||
[/String::Utf8Value (.+?)\((.+?)\)/g, 'Napi::String $1(env, $2)'],
|
||||
[/\.length\(\)/g, '.Length()'],
|
||||
|
||||
[/Nan::MakeCallback\(([^,]+),[\s\\]+([^,]+),/gm, '$2.MakeCallback($1,'],
|
||||
|
||||
[/class\s+(\w+)\s*:\s*public\s+Nan::ObjectWrap/g, 'class $1 : public Napi::ObjectWrap<$1>'],
|
||||
[/(\w+)\(([^)]*)\)\s*:\s*Nan::ObjectWrap\(\)\s*(,)?/gm, '$1($2) : Napi::ObjectWrap<$1>()$3'],
|
||||
|
||||
// HandleOKCallback to OnOK
|
||||
[/HandleOKCallback/g, 'OnOK'],
|
||||
// HandleErrorCallback to OnError
|
||||
[/HandleErrorCallback/g, 'OnError'],
|
||||
|
||||
// ex. .As<Function>() to .As<Napi::Object>()
|
||||
[/\.As<v8::(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>\(\)/g, '.As<Napi::$1>()'],
|
||||
[/\.As<(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>\(\)/g, '.As<Napi::$1>()'],
|
||||
|
||||
// ex. Nan::New<Number>(info[0]) to Napi::Number::New(info[0])
|
||||
[/Nan::New<(v8::)*Integer>\((.+?)\)/g, 'Napi::Number::New(env, $2)'],
|
||||
[/Nan::New\(([0-9.]+)\)/g, 'Napi::Number::New(env, $1)'],
|
||||
[/Nan::New<(v8::)*String>\("(.+?)"\)/g, 'Napi::String::New(env, "$2")'],
|
||||
[/Nan::New\("(.+?)"\)/g, 'Napi::String::New(env, "$1")'],
|
||||
[/Nan::New<(v8::)*(.+?)>\(\)/g, 'Napi::$2::New(env)'],
|
||||
[/Nan::New<(.+?)>\(\)/g, 'Napi::$1::New(env)'],
|
||||
[/Nan::New<(v8::)*(.+?)>\(/g, 'Napi::$2::New(env, '],
|
||||
[/Nan::New<(.+?)>\(/g, 'Napi::$1::New(env, '],
|
||||
[/Nan::NewBuffer\(/g, 'Napi::Buffer<char>::New(env, '],
|
||||
// TODO: Properly handle this
|
||||
[/Nan::New\(/g, 'Napi::New(env, '],
|
||||
|
||||
[/\.IsInt32\(\)/g, '.IsNumber()'],
|
||||
[/->IsInt32\(\)/g, '.IsNumber()'],
|
||||
|
||||
[/(.+?)->BooleanValue\(\)/g, '$1.As<Napi::Boolean>().Value()'],
|
||||
[/(.+?)->Int32Value\(\)/g, '$1.As<Napi::Number>().Int32Value()'],
|
||||
[/(.+?)->Uint32Value\(\)/g, '$1.As<Napi::Number>().Uint32Value()'],
|
||||
[/(.+?)->IntegerValue\(\)/g, '$1.As<Napi::Number>().Int64Value()'],
|
||||
[/(.+?)->NumberValue\(\)/g, '$1.As<Napi::Number>().DoubleValue()'],
|
||||
|
||||
// ex. Nan::To<bool>(info[0]) to info[0].Value()
|
||||
[/Nan::To<v8::(Boolean|String|Number|Object|Array|Symbol|Function)>\((.+?)\)/g, '$2.To<Napi::$1>()'],
|
||||
[/Nan::To<(Boolean|String|Number|Object|Array|Symbol|Function)>\((.+?)\)/g, '$2.To<Napi::$1>()'],
|
||||
// ex. Nan::To<bool>(info[0]) to info[0].As<Napi::Boolean>().Value()
|
||||
[/Nan::To<bool>\((.+?)\)/g, '$1.As<Napi::Boolean>().Value()'],
|
||||
// ex. Nan::To<int>(info[0]) to info[0].As<Napi::Number>().Int32Value()
|
||||
[/Nan::To<int>\((.+?)\)/g, '$1.As<Napi::Number>().Int32Value()'],
|
||||
// ex. Nan::To<int32_t>(info[0]) to info[0].As<Napi::Number>().Int32Value()
|
||||
[/Nan::To<int32_t>\((.+?)\)/g, '$1.As<Napi::Number>().Int32Value()'],
|
||||
// ex. Nan::To<uint32_t>(info[0]) to info[0].As<Napi::Number>().Uint32Value()
|
||||
[/Nan::To<uint32_t>\((.+?)\)/g, '$1.As<Napi::Number>().Uint32Value()'],
|
||||
// ex. Nan::To<int64_t>(info[0]) to info[0].As<Napi::Number>().Int64Value()
|
||||
[/Nan::To<int64_t>\((.+?)\)/g, '$1.As<Napi::Number>().Int64Value()'],
|
||||
// ex. Nan::To<float>(info[0]) to info[0].As<Napi::Number>().FloatValue()
|
||||
[/Nan::To<float>\((.+?)\)/g, '$1.As<Napi::Number>().FloatValue()'],
|
||||
// ex. Nan::To<double>(info[0]) to info[0].As<Napi::Number>().DoubleValue()
|
||||
[/Nan::To<double>\((.+?)\)/g, '$1.As<Napi::Number>().DoubleValue()'],
|
||||
|
||||
[/Nan::New\((\w+)\)->HasInstance\((\w+)\)/g, '$2.InstanceOf($1.Value())'],
|
||||
|
||||
[/Nan::Has\(([^,]+),\s*/gm, '($1).Has('],
|
||||
[/\.Has\([\s|\\]*Nan::New<(v8::)*String>\(([^)]+)\)\)/gm, '.Has($1)'],
|
||||
[/\.Has\([\s|\\]*Nan::New\(([^)]+)\)\)/gm, '.Has($1)'],
|
||||
|
||||
[/Nan::Get\(([^,]+),\s*/gm, '($1).Get('],
|
||||
[/\.Get\([\s|\\]*Nan::New<(v8::)*String>\(([^)]+)\)\)/gm, '.Get($1)'],
|
||||
[/\.Get\([\s|\\]*Nan::New\(([^)]+)\)\)/gm, '.Get($1)'],
|
||||
|
||||
[/Nan::Set\(([^,]+),\s*/gm, '($1).Set('],
|
||||
[/\.Set\([\s|\\]*Nan::New<(v8::)*String>\(([^)]+)\)\s*,/gm, '.Set($1,'],
|
||||
[/\.Set\([\s|\\]*Nan::New\(([^)]+)\)\s*,/gm, '.Set($1,'],
|
||||
|
||||
// ex. node::Buffer::HasInstance(info[0]) to info[0].IsBuffer()
|
||||
[/node::Buffer::HasInstance\((.+?)\)/g, '$1.IsBuffer()'],
|
||||
// ex. node::Buffer::Length(info[0]) to info[0].Length()
|
||||
[/node::Buffer::Length\((.+?)\)/g, '$1.As<Napi::Buffer<char>>().Length()'],
|
||||
// ex. node::Buffer::Data(info[0]) to info[0].Data()
|
||||
[/node::Buffer::Data\((.+?)\)/g, '$1.As<Napi::Buffer<char>>().Data()'],
|
||||
[/Nan::CopyBuffer\(/g, 'Napi::Buffer::Copy(env, '],
|
||||
|
||||
// Nan::AsyncQueueWorker(worker)
|
||||
[/Nan::AsyncQueueWorker\((.+)\);/g, '$1.Queue();'],
|
||||
[/Nan::(Undefined|Null|True|False)\(\)/g, 'env.$1()'],
|
||||
|
||||
// Nan::ThrowError(error) to Napi::Error::New(env, error).ThrowAsJavaScriptException()
|
||||
[/([ ]*)return Nan::Throw(\w*?)Error\((.+?)\);/g, '$1Napi::$2Error::New(env, $3).ThrowAsJavaScriptException();\n$1return env.Null();'],
|
||||
[/Nan::Throw(\w*?)Error\((.+?)\);\n(\s*)return;/g, 'Napi::$1Error::New(env, $2).ThrowAsJavaScriptException();\n$3return env.Null();'],
|
||||
[/Nan::Throw(\w*?)Error\((.+?)\);/g, 'Napi::$1Error::New(env, $2).ThrowAsJavaScriptException();\n'],
|
||||
// Nan::RangeError(error) to Napi::RangeError::New(env, error)
|
||||
[/Nan::(\w*?)Error\((.+)\)/g, 'Napi::$1Error::New(env, $2)'],
|
||||
|
||||
[/Nan::Set\((.+?),\n* *(.+?),\n* *(.+?),\n* *(.+?)\)/g, '$1.Set($2, $3, $4)'],
|
||||
|
||||
[/Nan::(Escapable)?HandleScope\s+(\w+)\s*;/g, 'Napi::$1HandleScope $2(env);'],
|
||||
[/Nan::(Escapable)?HandleScope/g, 'Napi::$1HandleScope'],
|
||||
[/Nan::ForceSet\(([^,]+), ?/g, '$1->DefineProperty('],
|
||||
[/\.ForceSet\(Napi::String::New\(env, "(\w+)"\),\s*?/g, '.DefineProperty("$1", '],
|
||||
// [ /Nan::GetPropertyNames\(([^,]+)\)/, '$1->GetPropertyNames()' ],
|
||||
[/Nan::Equals\(([^,]+),/g, '$1.StrictEquals('],
|
||||
|
||||
[/(.+)->Set\(/g, '$1.Set('],
|
||||
|
||||
[/Nan::Callback/g, 'Napi::FunctionReference'],
|
||||
|
||||
[/Nan::Persistent<Object>/g, 'Napi::ObjectReference'],
|
||||
[/Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target/g, 'Napi::Env& env, Napi::Object& target'],
|
||||
|
||||
[/(\w+)\*\s+(\w+)\s*=\s*Nan::ObjectWrap::Unwrap<\w+>\(info\.This\(\)\);/g, '$1* $2 = this;'],
|
||||
[/Nan::ObjectWrap::Unwrap<(\w+)>\((.*)\);/g, '$2.Unwrap<$1>();'],
|
||||
|
||||
[/Nan::NAN_METHOD_RETURN_TYPE/g, 'void'],
|
||||
[/NAN_INLINE/g, 'inline'],
|
||||
|
||||
[/Nan::NAN_METHOD_ARGS_TYPE/g, 'const Napi::CallbackInfo&'],
|
||||
[/NAN_METHOD\(([\w\d:]+?)\)/g, 'Napi::Value $1(const Napi::CallbackInfo& info)'],
|
||||
[/static\s*NAN_GETTER\(([\w\d:]+?)\)/g, 'Napi::Value $1(const Napi::CallbackInfo& info)'],
|
||||
[/NAN_GETTER\(([\w\d:]+?)\)/g, 'Napi::Value $1(const Napi::CallbackInfo& info)'],
|
||||
[/static\s*NAN_SETTER\(([\w\d:]+?)\)/g, 'void $1(const Napi::CallbackInfo& info, const Napi::Value& value)'],
|
||||
[/NAN_SETTER\(([\w\d:]+?)\)/g, 'void $1(const Napi::CallbackInfo& info, const Napi::Value& value)'],
|
||||
[/void Init\((v8::)*Local<(v8::)*Object> exports\)/g, 'Napi::Object Init(Napi::Env env, Napi::Object exports)'],
|
||||
[/NAN_MODULE_INIT\(([\w\d:]+?)\);/g, 'Napi::Object $1(Napi::Env env, Napi::Object exports);'],
|
||||
[/NAN_MODULE_INIT\(([\w\d:]+?)\)/g, 'Napi::Object $1(Napi::Env env, Napi::Object exports)'],
|
||||
|
||||
[/::(Init(?:ialize)?)\(target\)/g, '::$1(env, target, module)'],
|
||||
[/constructor_template/g, 'constructor'],
|
||||
|
||||
[/Nan::FunctionCallbackInfo<(v8::)?Value>[ ]*& [ ]*info\)[ ]*{\n*([ ]*)/gm, 'Napi::CallbackInfo& info) {\n$2Napi::Env env = info.Env();\n$2'],
|
||||
[/Nan::FunctionCallbackInfo<(v8::)*Value>\s*&\s*info\);/g, 'Napi::CallbackInfo& info);'],
|
||||
[/Nan::FunctionCallbackInfo<(v8::)*Value>\s*&/g, 'Napi::CallbackInfo&'],
|
||||
|
||||
[/Buffer::HasInstance\(([^)]+)\)/g, '$1.IsBuffer()'],
|
||||
|
||||
[/info\[(\d+)\]->/g, 'info[$1].'],
|
||||
[/info\[([\w\d]+)\]->/g, 'info[$1].'],
|
||||
[/info\.This\(\)->/g, 'info.This().'],
|
||||
[/->Is(Object|String|Int32|Number)\(\)/g, '.Is$1()'],
|
||||
[/info.GetReturnValue\(\).SetUndefined\(\)/g, 'return env.Undefined()'],
|
||||
[/info\.GetReturnValue\(\)\.Set\(((\n|.)+?)\);/g, 'return $1;'],
|
||||
|
||||
// ex. Local<Value> to Napi::Value
|
||||
[/v8::Local<v8::(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>/g, 'Napi::$1'],
|
||||
[/Local<(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>/g, 'Napi::$1'],
|
||||
|
||||
// Declare an env in helper functions that take a Napi::Value
|
||||
[/(\w+)\(Napi::Value (\w+)(,\s*[^()]+)?\)\s*{\n*([ ]*)/gm, '$1(Napi::Value $2$3) {\n$4Napi::Env env = $2.Env();\n$4'],
|
||||
|
||||
// delete #include <node.h> and/or <v8.h>
|
||||
[/#include +(<|")(?:node|nan).h("|>)/g, '#include $1napi.h$2\n#include $1uv.h$2'],
|
||||
// NODE_MODULE to NODE_API_MODULE
|
||||
[/NODE_MODULE/g, 'NODE_API_MODULE'],
|
||||
[/Nan::/g, 'Napi::'],
|
||||
[/nan.h/g, 'napi.h'],
|
||||
|
||||
// delete .FromJust()
|
||||
[/\.FromJust\(\)/g, ''],
|
||||
// delete .ToLocalCheck()
|
||||
[/\.ToLocalChecked\(\)/g, ''],
|
||||
[/^.*->SetInternalFieldCount\(.*$/gm, ''],
|
||||
|
||||
// replace using node; and/or using v8; to using Napi;
|
||||
[/using (node|v8);/g, 'using Napi;'],
|
||||
[/using namespace (node|Nan|v8);/g, 'using namespace Napi;'],
|
||||
// delete using v8::Local;
|
||||
[/using v8::Local;\n/g, ''],
|
||||
// replace using v8::XXX; with using Napi::XXX
|
||||
[/using v8::([A-Za-z]+);/g, 'using Napi::$1;']
|
||||
|
||||
];
|
||||
|
||||
const paths = listFiles(dir);
|
||||
paths.forEach(function (dirEntry) {
|
||||
const filename = dirEntry.split('\\').pop().split('/').pop();
|
||||
|
||||
// Check whether the file is a source file or a config file
|
||||
// then execute function accordingly
|
||||
const sourcePattern = /.+\.h|.+\.cc|.+\.cpp/;
|
||||
if (sourcePattern.test(filename)) {
|
||||
convertFile(dirEntry, SourceFileOperations);
|
||||
} else if (ConfigFileOperations[filename] != null) {
|
||||
convertFile(dirEntry, ConfigFileOperations[filename]);
|
||||
}
|
||||
});
|
||||
|
||||
function listFiles (dir, filelist) {
|
||||
const files = fs.readdirSync(dir);
|
||||
filelist = filelist || [];
|
||||
files.forEach(function (file) {
|
||||
if (file === 'node_modules') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fs.statSync(path.join(dir, file)).isDirectory()) {
|
||||
filelist = listFiles(path.join(dir, file), filelist);
|
||||
} else {
|
||||
filelist.push(path.join(dir, file));
|
||||
}
|
||||
});
|
||||
return filelist;
|
||||
}
|
||||
|
||||
function convert (content, operations) {
|
||||
for (let i = 0; i < operations.length; i++) {
|
||||
const operation = operations[i];
|
||||
content = content.replace(operation[0], operation[1]);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
function convertFile (fileName, operations) {
|
||||
fs.readFile(fileName, 'utf-8', function (err, file) {
|
||||
if (err) throw err;
|
||||
|
||||
file = convert(file, operations);
|
||||
|
||||
fs.writeFile(fileName, file, function (err) {
|
||||
if (err) throw err;
|
||||
});
|
||||
});
|
||||
}
|
||||
48
node_modules/@julusian/jpeg-turbo/package.json
generated
vendored
Normal file
48
node_modules/@julusian/jpeg-turbo/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "@julusian/jpeg-turbo",
|
||||
"version": "3.0.1",
|
||||
"description": "Limited libjpeg-turbo bindings for Node.js.",
|
||||
"keywords": [
|
||||
"jpeg",
|
||||
"jpeg-turbo",
|
||||
"libjpeg-turbo"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Julusian/node-jpeg-turbo.git"
|
||||
},
|
||||
"binary": {
|
||||
"napi_versions": [
|
||||
10
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.18"
|
||||
},
|
||||
"main": "./index.js",
|
||||
"types": "./module.d.ts",
|
||||
"dependencies": {
|
||||
"cmake-js": "^8.0.0",
|
||||
"node-addon-api": "^8.5.0",
|
||||
"pkg-prebuilds": "^1.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"install": "pkg-prebuilds-verify ./binding-options.js || cmake-js compile --target jpeg-turbo",
|
||||
"build": "cmake-js build --target jpeg-turbo",
|
||||
"rebuild": "cmake-js rebuild --target jpeg-turbo",
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^30.2.0"
|
||||
},
|
||||
"files": [
|
||||
"/prebuilds",
|
||||
"/src",
|
||||
"/CMakeLists.txt",
|
||||
"/index.js",
|
||||
"/binding-options.js",
|
||||
"/module.d.ts"
|
||||
],
|
||||
"packageManager": "yarn@4.12.0"
|
||||
}
|
||||
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-darwin-arm64/node-napi-v10.node
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-darwin-arm64/node-napi-v10.node
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-darwin-x64/node-napi-v10.node
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-darwin-x64/node-napi-v10.node
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-arm/libturbojpeg.so.0
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-arm/libturbojpeg.so.0
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-arm/node-napi-v10.node
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-arm/node-napi-v10.node
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-arm64/libturbojpeg.so.0
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-arm64/libturbojpeg.so.0
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-arm64/node-napi-v10.node
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-arm64/node-napi-v10.node
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-x64-musl/libturbojpeg.so.0
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-x64-musl/libturbojpeg.so.0
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-x64-musl/node-napi-v10.node
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-x64-musl/node-napi-v10.node
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-x64/libturbojpeg.so.0
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-x64/libturbojpeg.so.0
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-x64/node-napi-v10.node
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-linux-x64/node-napi-v10.node
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-win32-arm64/node-napi-v10.node
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-win32-arm64/node-napi-v10.node
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-win32-ia32/node-napi-v10.node
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-win32-ia32/node-napi-v10.node
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-win32-x64/node-napi-v10.node
generated
vendored
Normal file
BIN
node_modules/@julusian/jpeg-turbo/prebuilds/jpeg-turbo-win32-x64/node-napi-v10.node
generated
vendored
Normal file
Binary file not shown.
32
node_modules/@julusian/jpeg-turbo/src/buffersize.cc
generated
vendored
Normal file
32
node_modules/@julusian/jpeg-turbo/src/buffersize.cc
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "buffersize.h"
|
||||
|
||||
Napi::Value BufferSize(const Napi::CallbackInfo &info)
|
||||
{
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
if (info.Length() < 1)
|
||||
{
|
||||
Napi::TypeError::New(env, "Not enough arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
if (!info[0].IsObject())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid options").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Object options = info[0].As<Napi::Object>();
|
||||
|
||||
BufferSizeOptions parsedOptions = ParseBufferSizeOptions(env, options);
|
||||
if (!parsedOptions.valid)
|
||||
{
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
// Finally, calculate the buffer size
|
||||
uint32_t dstLength = tjBufSize(parsedOptions.width, parsedOptions.height, parsedOptions.subsampling);
|
||||
Napi::Number result = Napi::Number::New(env, dstLength);
|
||||
|
||||
return result;
|
||||
}
|
||||
8
node_modules/@julusian/jpeg-turbo/src/buffersize.h
generated
vendored
Normal file
8
node_modules/@julusian/jpeg-turbo/src/buffersize.h
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef NODE_JPEGTURBO_BUFFERSIZE_H
|
||||
#define NODE_JPEGTURBO_BUFFERSIZE_H
|
||||
|
||||
#include "util.h"
|
||||
|
||||
Napi::Value BufferSize(const Napi::CallbackInfo &info);
|
||||
|
||||
#endif
|
||||
283
node_modules/@julusian/jpeg-turbo/src/compress.cc
generated
vendored
Normal file
283
node_modules/@julusian/jpeg-turbo/src/compress.cc
generated
vendored
Normal file
@@ -0,0 +1,283 @@
|
||||
#include "compress.h"
|
||||
|
||||
struct CompressProps
|
||||
{
|
||||
unsigned char *srcData;
|
||||
uint32_t format;
|
||||
uint32_t width;
|
||||
uint32_t stride;
|
||||
uint32_t height;
|
||||
uint32_t subsampling;
|
||||
int quality;
|
||||
int bpp;
|
||||
int flags;
|
||||
unsigned long resSize;
|
||||
unsigned char *resData;
|
||||
};
|
||||
|
||||
std::string DoCompress(CompressProps &props)
|
||||
{
|
||||
tjhandle handle = tjInitCompress();
|
||||
if (handle == nullptr)
|
||||
{
|
||||
return tjGetErrorStr();
|
||||
}
|
||||
|
||||
int err = tjCompress2(handle,
|
||||
props.srcData,
|
||||
props.width,
|
||||
props.stride * props.bpp,
|
||||
props.height,
|
||||
props.format,
|
||||
&props.resData,
|
||||
&props.resSize,
|
||||
props.subsampling,
|
||||
props.quality,
|
||||
props.flags);
|
||||
if (err != 0)
|
||||
{
|
||||
tjDestroy(handle);
|
||||
return tjGetErrorStr();
|
||||
}
|
||||
|
||||
err = tjDestroy(handle);
|
||||
if (err != 0)
|
||||
{
|
||||
return tjGetErrorStr();
|
||||
}
|
||||
|
||||
if (props.resData == nullptr)
|
||||
{
|
||||
return "No output data";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
Napi::Object CompressResult(const Napi::Env &env, const Napi::Buffer<unsigned char> dstBuffer, const CompressProps &props)
|
||||
{
|
||||
Napi::Object res = Napi::Object::New(env);
|
||||
res.Set("data", dstBuffer);
|
||||
res.Set("size", props.resSize);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
class CompressWorker : public Napi::AsyncWorker
|
||||
{
|
||||
public:
|
||||
CompressWorker(
|
||||
Napi::Env &env,
|
||||
Napi::Buffer<unsigned char> &srcBuffer,
|
||||
Napi::Buffer<unsigned char> &dstBuffer,
|
||||
CompressProps &props)
|
||||
: AsyncWorker(env),
|
||||
deferred(Napi::Promise::Deferred::New(env)),
|
||||
srcBuffer(Napi::Reference<Napi::Buffer<unsigned char>>::New(srcBuffer, 1)),
|
||||
dstBuffer(Napi::Reference<Napi::Buffer<unsigned char>>::New(dstBuffer, 1)),
|
||||
props(props)
|
||||
{
|
||||
}
|
||||
|
||||
~CompressWorker()
|
||||
{
|
||||
this->srcBuffer.Reset();
|
||||
this->dstBuffer.Reset();
|
||||
}
|
||||
|
||||
void Execute()
|
||||
{
|
||||
std::string err = DoCompress(this->props);
|
||||
if (!err.empty())
|
||||
{
|
||||
SetError(err);
|
||||
}
|
||||
}
|
||||
|
||||
void OnOK()
|
||||
{
|
||||
deferred.Resolve(CompressResult(Env(), this->dstBuffer.Value(), this->props));
|
||||
}
|
||||
|
||||
void OnError(Napi::Error const &error)
|
||||
{
|
||||
deferred.Reject(error.Value());
|
||||
}
|
||||
|
||||
Napi::Promise GetPromise() const
|
||||
{
|
||||
return deferred.Promise();
|
||||
}
|
||||
|
||||
private:
|
||||
Napi::Promise::Deferred deferred;
|
||||
Napi::Reference<Napi::Buffer<unsigned char>> srcBuffer;
|
||||
Napi::Reference<Napi::Buffer<unsigned char>> dstBuffer;
|
||||
CompressProps props;
|
||||
};
|
||||
|
||||
Napi::Value CompressInner(const Napi::CallbackInfo &info, bool async)
|
||||
{
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
if (info.Length() < 2)
|
||||
{
|
||||
Napi::TypeError::New(env, "Not enough arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
if (!info[0].IsBuffer())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid source buffer")
|
||||
.ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Buffer<unsigned char> srcBuffer = info[0].As<Napi::Buffer<unsigned char>>();
|
||||
|
||||
unsigned int offset = 0;
|
||||
Napi::Buffer<unsigned char> dstBuffer;
|
||||
if (info[1].IsBuffer())
|
||||
{
|
||||
dstBuffer = info[1].As<Napi::Buffer<unsigned char>>();
|
||||
offset++;
|
||||
if (dstBuffer.Length() == 0)
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid destination buffer")
|
||||
.ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
}
|
||||
|
||||
if (info.Length() < offset + 2 || !info[offset + 1].IsObject())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid options").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Object options = info[offset + 1].As<Napi::Object>();
|
||||
|
||||
BufferSizeOptions parsedOptions = ParseBufferSizeOptions(env, options);
|
||||
if (!parsedOptions.valid)
|
||||
{
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
CompressProps props = {};
|
||||
props.srcData = srcBuffer.Data();
|
||||
props.width = parsedOptions.width;
|
||||
props.height = parsedOptions.height;
|
||||
props.subsampling = parsedOptions.subsampling;
|
||||
|
||||
Napi::Value tmpFormat = options.Get("format");
|
||||
if (!tmpFormat.IsNumber())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid format").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
props.format = tmpFormat.As<Napi::Number>().Uint32Value();
|
||||
|
||||
// Figure out bpp from format (needed to calculate output buffer size)
|
||||
props.bpp = 0;
|
||||
switch (props.format)
|
||||
{
|
||||
case TJPF_GRAY:
|
||||
props.bpp = 1;
|
||||
break;
|
||||
case TJPF_RGB:
|
||||
case TJPF_BGR:
|
||||
props.bpp = 3;
|
||||
break;
|
||||
case TJPF_RGBX:
|
||||
case TJPF_BGRX:
|
||||
case TJPF_XRGB:
|
||||
case TJPF_XBGR:
|
||||
case TJPF_RGBA:
|
||||
case TJPF_BGRA:
|
||||
case TJPF_ABGR:
|
||||
case TJPF_ARGB:
|
||||
props.bpp = 4;
|
||||
break;
|
||||
default:
|
||||
Napi::TypeError::New(env, "Invalid input format").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
props.stride = parsedOptions.width;
|
||||
Napi::Value tmpStride = options.Get("stride");
|
||||
if (!tmpStride.IsUndefined())
|
||||
{
|
||||
if (!tmpStride.IsNumber())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid stride").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
props.stride = tmpStride.As<Napi::Number>().Uint32Value();
|
||||
}
|
||||
|
||||
props.quality = NJT_DEFAULT_QUALITY;
|
||||
Napi::Value tmpQuality = options.Get("quality");
|
||||
if (!tmpQuality.IsUndefined())
|
||||
{
|
||||
if (!tmpQuality.IsNumber())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid quality").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
props.quality = tmpQuality.As<Napi::Number>().Uint32Value();
|
||||
}
|
||||
if (props.quality <= 0 || props.quality > 100)
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid quality").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
if (srcBuffer.Length() < static_cast<size_t>(props.stride) * props.height * props.bpp)
|
||||
{
|
||||
Napi::TypeError::New(env, "Source data is not long enough").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
uint32_t dstLength = tjBufSize(props.width, props.height, props.subsampling);
|
||||
if (dstBuffer.IsEmpty())
|
||||
{
|
||||
dstBuffer = Napi::Buffer<unsigned char>::New(env, dstLength);
|
||||
}
|
||||
|
||||
if (dstLength > dstBuffer.Length())
|
||||
{
|
||||
Napi::TypeError::New(env, "Insufficient output buffer").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
props.flags = TJFLAG_FASTDCT | TJFLAG_NOREALLOC;
|
||||
props.resSize = dstBuffer.Length();
|
||||
props.resData = dstBuffer.Data();
|
||||
|
||||
if (async)
|
||||
{
|
||||
CompressWorker *wk = new CompressWorker(env, srcBuffer, dstBuffer, props);
|
||||
wk->Queue();
|
||||
return wk->GetPromise();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string errStr = DoCompress(props);
|
||||
if (!errStr.empty())
|
||||
{
|
||||
Napi::TypeError::New(env, errStr).ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
return CompressResult(env, dstBuffer, props);
|
||||
}
|
||||
}
|
||||
|
||||
Napi::Value CompressAsync(const Napi::CallbackInfo &info)
|
||||
{
|
||||
return CompressInner(info, true);
|
||||
}
|
||||
|
||||
Napi::Value CompressSync(const Napi::CallbackInfo &info)
|
||||
{
|
||||
return CompressInner(info, false);
|
||||
}
|
||||
9
node_modules/@julusian/jpeg-turbo/src/compress.h
generated
vendored
Normal file
9
node_modules/@julusian/jpeg-turbo/src/compress.h
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef NODE_JPEGTURBO_COMPRESS_H
|
||||
#define NODE_JPEGTURBO_COMPRESS_H
|
||||
|
||||
#include "util.h"
|
||||
|
||||
Napi::Value CompressAsync(const Napi::CallbackInfo &info);
|
||||
Napi::Value CompressSync(const Napi::CallbackInfo &info);
|
||||
|
||||
#endif
|
||||
8
node_modules/@julusian/jpeg-turbo/src/consts.h
generated
vendored
Normal file
8
node_modules/@julusian/jpeg-turbo/src/consts.h
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef NODE_JPEGTURBO_CONSTS_H
|
||||
#define NODE_JPEGTURBO_CONSTS_H
|
||||
|
||||
static int NJT_DEFAULT_QUALITY = 80;
|
||||
static int NJT_DEFAULT_SUBSAMPLING = TJSAMP_420;
|
||||
static int NJT_DEFAULT_FORMAT = TJPF_RGBA;
|
||||
|
||||
#endif
|
||||
244
node_modules/@julusian/jpeg-turbo/src/decompress.cc
generated
vendored
Normal file
244
node_modules/@julusian/jpeg-turbo/src/decompress.cc
generated
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
#include "compress.h"
|
||||
|
||||
struct DecompressProps
|
||||
{
|
||||
tjhandle handle;
|
||||
unsigned char *srcData;
|
||||
uint32_t srcLength;
|
||||
uint32_t format;
|
||||
int bpp;
|
||||
int resWidth;
|
||||
int resHeight;
|
||||
unsigned long resSize;
|
||||
unsigned char *resData;
|
||||
};
|
||||
|
||||
std::string DoDecompress(DecompressProps &props)
|
||||
{
|
||||
|
||||
int err = tjDecompress2(props.handle, props.srcData, props.srcLength, props.resData, props.resWidth, 0, props.resHeight, props.format, TJFLAG_FASTDCT);
|
||||
if (err != 0)
|
||||
{
|
||||
tjDestroy(props.handle);
|
||||
return tjGetErrorStr();
|
||||
}
|
||||
|
||||
err = tjDestroy(props.handle);
|
||||
if (err != 0)
|
||||
{
|
||||
return tjGetErrorStr();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
Napi::Object DecompressResult(const Napi::Env &env, const Napi::Buffer<unsigned char> dstBuffer, const DecompressProps &props)
|
||||
{
|
||||
Napi::Object res = Napi::Object::New(env);
|
||||
res.Set("data", dstBuffer);
|
||||
res.Set("size", props.resSize);
|
||||
res.Set("width", props.resWidth);
|
||||
res.Set("height", props.resHeight);
|
||||
res.Set("format", props.format);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
class DecompressWorker : public Napi::AsyncWorker
|
||||
{
|
||||
public:
|
||||
DecompressWorker(
|
||||
Napi::Env &env,
|
||||
Napi::Buffer<unsigned char> &srcBuffer,
|
||||
Napi::Buffer<unsigned char> &dstBuffer,
|
||||
DecompressProps &props)
|
||||
: AsyncWorker(env),
|
||||
deferred(Napi::Promise::Deferred::New(env)),
|
||||
srcBuffer(Napi::Reference<Napi::Buffer<unsigned char>>::New(srcBuffer, 1)),
|
||||
dstBuffer(Napi::Reference<Napi::Buffer<unsigned char>>::New(dstBuffer, 1)),
|
||||
props(props)
|
||||
{
|
||||
}
|
||||
|
||||
~DecompressWorker()
|
||||
{
|
||||
this->srcBuffer.Reset();
|
||||
this->dstBuffer.Reset();
|
||||
}
|
||||
|
||||
void Execute()
|
||||
{
|
||||
std::string err = DoDecompress(this->props);
|
||||
if (!err.empty())
|
||||
{
|
||||
SetError(err);
|
||||
}
|
||||
}
|
||||
|
||||
void OnOK()
|
||||
{
|
||||
deferred.Resolve(DecompressResult(Env(), this->dstBuffer.Value(), this->props));
|
||||
}
|
||||
|
||||
void OnError(Napi::Error const &error)
|
||||
{
|
||||
deferred.Reject(error.Value());
|
||||
}
|
||||
|
||||
Napi::Promise GetPromise() const
|
||||
{
|
||||
return deferred.Promise();
|
||||
}
|
||||
|
||||
private:
|
||||
Napi::Promise::Deferred deferred;
|
||||
Napi::Reference<Napi::Buffer<unsigned char>> srcBuffer;
|
||||
Napi::Reference<Napi::Buffer<unsigned char>> dstBuffer;
|
||||
DecompressProps props;
|
||||
};
|
||||
|
||||
Napi::Value DecompressInner(const Napi::CallbackInfo &info, bool async)
|
||||
{
|
||||
Napi::Env env = info.Env();
|
||||
|
||||
if (info.Length() < 1)
|
||||
{
|
||||
Napi::TypeError::New(env, "Not enough arguments")
|
||||
.ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
if (!info[0].IsBuffer())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid source buffer")
|
||||
.ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Buffer<unsigned char> srcBuffer = info[0].As<Napi::Buffer<unsigned char>>();
|
||||
|
||||
unsigned int offset = 0;
|
||||
Napi::Buffer<unsigned char> dstBuffer;
|
||||
if (info[1].IsBuffer())
|
||||
{
|
||||
dstBuffer = info[1].As<Napi::Buffer<unsigned char>>();
|
||||
offset++;
|
||||
if (dstBuffer.Length() == 0)
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid destination buffer")
|
||||
.ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
}
|
||||
|
||||
DecompressProps props = {};
|
||||
props.srcData = srcBuffer.Data();
|
||||
props.srcLength = srcBuffer.Length();
|
||||
|
||||
if (info.Length() >= offset + 2)
|
||||
{
|
||||
if (!info[offset + 1].IsObject())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid options").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
Napi::Object options = info[offset + 1].As<Napi::Object>();
|
||||
|
||||
Napi::Value tmpFormat = options.Get("format");
|
||||
if (!tmpFormat.IsNumber())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid format").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
props.format = tmpFormat.As<Napi::Number>().Uint32Value();
|
||||
}
|
||||
|
||||
// Figure out bpp from format (needed to calculate output buffer size)
|
||||
props.bpp = 0;
|
||||
switch (props.format)
|
||||
{
|
||||
case TJPF_GRAY:
|
||||
props.bpp = 1;
|
||||
break;
|
||||
case TJPF_RGB:
|
||||
case TJPF_BGR:
|
||||
props.bpp = 3;
|
||||
break;
|
||||
case TJPF_RGBX:
|
||||
case TJPF_BGRX:
|
||||
case TJPF_XRGB:
|
||||
case TJPF_XBGR:
|
||||
case TJPF_RGBA:
|
||||
case TJPF_BGRA:
|
||||
case TJPF_ABGR:
|
||||
case TJPF_ARGB:
|
||||
props.bpp = 4;
|
||||
break;
|
||||
default:
|
||||
Napi::TypeError::New(env, "Invalid output format").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
tjhandle handle = tjInitDecompress();
|
||||
if (handle == nullptr)
|
||||
{
|
||||
Napi::TypeError::New(env, tjGetErrorStr()).ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
props.handle = handle;
|
||||
|
||||
int err = tjDecompressHeader(handle, props.srcData, props.srcLength, &props.resWidth, &props.resHeight);
|
||||
if (err != 0)
|
||||
{
|
||||
tjDestroy(handle);
|
||||
|
||||
Napi::TypeError::New(env, tjGetErrorStr()).ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
auto targetSize = static_cast<size_t>(props.resWidth) * props.resHeight * props.bpp;
|
||||
if (dstBuffer.IsEmpty())
|
||||
{
|
||||
dstBuffer = Napi::Buffer<unsigned char>::New(env, targetSize);
|
||||
}
|
||||
|
||||
props.resSize = targetSize;
|
||||
props.resData = dstBuffer.Data();
|
||||
|
||||
if (targetSize > dstBuffer.Length())
|
||||
{
|
||||
tjDestroy(handle);
|
||||
|
||||
Napi::TypeError::New(env, "Insufficient output buffer").ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
if (async)
|
||||
{
|
||||
DecompressWorker *wk = new DecompressWorker(env, srcBuffer, dstBuffer, props);
|
||||
wk->Queue();
|
||||
return wk->GetPromise();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string errStr = DoDecompress(props);
|
||||
if (!errStr.empty())
|
||||
{
|
||||
Napi::TypeError::New(env, errStr).ThrowAsJavaScriptException();
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
return DecompressResult(env, dstBuffer, props);
|
||||
}
|
||||
return env.Null();
|
||||
}
|
||||
|
||||
Napi::Value DecompressAsync(const Napi::CallbackInfo &info)
|
||||
{
|
||||
return DecompressInner(info, true);
|
||||
}
|
||||
|
||||
Napi::Value DecompressSync(const Napi::CallbackInfo &info)
|
||||
{
|
||||
return DecompressInner(info, false);
|
||||
}
|
||||
9
node_modules/@julusian/jpeg-turbo/src/decompress.h
generated
vendored
Normal file
9
node_modules/@julusian/jpeg-turbo/src/decompress.h
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef NODE_JPEGTURBO_DECOMPRESS_H
|
||||
#define NODE_JPEGTURBO_DECOMPRESS_H
|
||||
|
||||
#include "util.h"
|
||||
|
||||
Napi::Value DecompressAsync(const Napi::CallbackInfo &info);
|
||||
Napi::Value DecompressSync(const Napi::CallbackInfo &info);
|
||||
|
||||
#endif
|
||||
22
node_modules/@julusian/jpeg-turbo/src/enums.cc
generated
vendored
Normal file
22
node_modules/@julusian/jpeg-turbo/src/enums.cc
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "enums.h"
|
||||
|
||||
void InitializeEnums(const Napi::Env &env, Napi::Object &exports)
|
||||
{
|
||||
exports.Set("FORMAT_RGB", static_cast<unsigned long>(TJPF_RGB));
|
||||
exports.Set("FORMAT_BGR", static_cast<unsigned long>(TJPF_BGR));
|
||||
exports.Set("FORMAT_RGBX", static_cast<unsigned long>(TJPF_RGBX));
|
||||
exports.Set("FORMAT_BGRX", static_cast<unsigned long>(TJPF_BGRX));
|
||||
exports.Set("FORMAT_XRGB", static_cast<unsigned long>(TJPF_XRGB));
|
||||
exports.Set("FORMAT_XBGR", static_cast<unsigned long>(TJPF_XBGR));
|
||||
exports.Set("FORMAT_GRAY", static_cast<unsigned long>(TJPF_GRAY));
|
||||
exports.Set("FORMAT_RGBA", static_cast<unsigned long>(TJPF_RGBA));
|
||||
exports.Set("FORMAT_BGRA", static_cast<unsigned long>(TJPF_BGRA));
|
||||
exports.Set("FORMAT_ABGR", static_cast<unsigned long>(TJPF_ABGR));
|
||||
exports.Set("FORMAT_ARGB", static_cast<unsigned long>(TJPF_ARGB));
|
||||
|
||||
exports.Set("SAMP_444", static_cast<unsigned long>(TJSAMP_444));
|
||||
exports.Set("SAMP_422", static_cast<unsigned long>(TJSAMP_422));
|
||||
exports.Set("SAMP_420", static_cast<unsigned long>(TJSAMP_420));
|
||||
exports.Set("SAMP_GRAY", static_cast<unsigned long>(TJSAMP_GRAY));
|
||||
exports.Set("SAMP_440", static_cast<unsigned long>(TJSAMP_440));
|
||||
}
|
||||
8
node_modules/@julusian/jpeg-turbo/src/enums.h
generated
vendored
Normal file
8
node_modules/@julusian/jpeg-turbo/src/enums.h
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef NODE_JPEGTURBO_ENUMS_H
|
||||
#define NODE_JPEGTURBO_ENUMS_H
|
||||
|
||||
#include "util.h"
|
||||
|
||||
void InitializeEnums(const Napi::Env &env, Napi::Object &exports);
|
||||
|
||||
#endif
|
||||
25
node_modules/@julusian/jpeg-turbo/src/exports.cc
generated
vendored
Normal file
25
node_modules/@julusian/jpeg-turbo/src/exports.cc
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "util.h"
|
||||
#include "enums.h"
|
||||
#include "buffersize.h"
|
||||
#include "compress.h"
|
||||
#include "decompress.h"
|
||||
|
||||
Napi::Object Init(Napi::Env env, Napi::Object exports)
|
||||
{
|
||||
// FT_Init_FreeType(&library);
|
||||
|
||||
// sprintf(version, "%i.%i.%i", FREETYPE_MAJOR, FREETYPE_MINOR, FREETYPE_PATCH);
|
||||
// exports.Set("FreeTypeVersion", version);
|
||||
|
||||
exports.Set("bufferSize", Napi::Function::New(env, BufferSize));
|
||||
exports.Set("compress", Napi::Function::New(env, CompressAsync));
|
||||
exports.Set("compressSync", Napi::Function::New(env, CompressSync));
|
||||
exports.Set("decompress", Napi::Function::New(env, DecompressAsync));
|
||||
exports.Set("decompressSync", Napi::Function::New(env, DecompressSync));
|
||||
|
||||
InitializeEnums(env, exports);
|
||||
|
||||
return exports;
|
||||
}
|
||||
|
||||
NODE_API_MODULE(jpegturbo, Init)
|
||||
51
node_modules/@julusian/jpeg-turbo/src/util.cc
generated
vendored
Normal file
51
node_modules/@julusian/jpeg-turbo/src/util.cc
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "util.h"
|
||||
|
||||
// Napi::Value getProperty(const Napi::Object &obj, const char *name)
|
||||
// {
|
||||
// }
|
||||
|
||||
BufferSizeOptions ParseBufferSizeOptions(const Napi::Env &env, const Napi::Object &options)
|
||||
{
|
||||
Napi::Value tmpWidth = options.Get("width");
|
||||
if (!tmpWidth.IsNumber())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid width").ThrowAsJavaScriptException();
|
||||
return BufferSizeOptions{false};
|
||||
}
|
||||
uint32_t width = tmpWidth.As<Napi::Number>().Uint32Value();
|
||||
|
||||
Napi::Value tmpHeight = options.Get("height");
|
||||
if (!tmpHeight.IsNumber())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid height").ThrowAsJavaScriptException();
|
||||
return BufferSizeOptions{false};
|
||||
}
|
||||
uint32_t height = tmpHeight.As<Napi::Number>().Uint32Value();
|
||||
|
||||
uint32_t subsampling = NJT_DEFAULT_SUBSAMPLING;
|
||||
Napi::Value tmpSubsampling = options.Get("subsampling");
|
||||
if (!tmpSubsampling.IsUndefined())
|
||||
{
|
||||
if (!tmpSubsampling.IsNumber())
|
||||
{
|
||||
Napi::TypeError::New(env, "Invalid subsampling").ThrowAsJavaScriptException();
|
||||
return BufferSizeOptions{false};
|
||||
}
|
||||
subsampling = tmpSubsampling.As<Napi::Number>().Uint32Value();
|
||||
}
|
||||
|
||||
switch (subsampling)
|
||||
{
|
||||
case TJSAMP_444:
|
||||
case TJSAMP_422:
|
||||
case TJSAMP_420:
|
||||
case TJSAMP_GRAY:
|
||||
case TJSAMP_440:
|
||||
break;
|
||||
default:
|
||||
Napi::TypeError::New(env, "Invalid subsampling").ThrowAsJavaScriptException();
|
||||
return BufferSizeOptions{false};
|
||||
}
|
||||
|
||||
return BufferSizeOptions{true, width, height, subsampling};
|
||||
}
|
||||
22
node_modules/@julusian/jpeg-turbo/src/util.h
generated
vendored
Normal file
22
node_modules/@julusian/jpeg-turbo/src/util.h
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef NODE_JPEGTURBO_UTIL_H
|
||||
#define NODE_JPEGTURBO_UTIL_H
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <turbojpeg.h>
|
||||
|
||||
#include "consts.h"
|
||||
|
||||
// Napi::Value getProperty(const Napi::Object &obj, const char *name);
|
||||
|
||||
struct BufferSizeOptions
|
||||
{
|
||||
bool valid;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t subsampling;
|
||||
};
|
||||
|
||||
BufferSizeOptions ParseBufferSizeOptions(const Napi::Env &env, const Napi::Object &obj);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user