forked from olcxjas-softworks/LarpixClient
Update gitignore (sorry)
This commit is contained in:
parent
a8f8c4d7ad
commit
cca8b02fea
6604 changed files with 1219661 additions and 4 deletions
104
electron/node_modules/lzma-native/.github/workflows/ci.yml
generated
vendored
Normal file
104
electron/node_modules/lzma-native/.github/workflows/ci.yml
generated
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- v[0-9]+.[0-9]+.[0-9]+*
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, macOS-latest, ubuntu-latest]
|
||||
node-version: [12.x, 14.x, 16.x]
|
||||
|
||||
steps:
|
||||
- name: Fix git checkout line endings
|
||||
run: git config --global core.autocrlf input
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2.3.0
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: Windows Setup
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: npm run prepare-win32
|
||||
- name: Install
|
||||
run: npm install
|
||||
- name: Lint
|
||||
run: npm run jshint
|
||||
- name: Test
|
||||
run: npm run test
|
||||
|
||||
prebuild:
|
||||
needs: test
|
||||
runs-on: ${{ matrix.os }}-latest
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows, macOS, ubuntu]
|
||||
arch: [x64, arm64]
|
||||
exclude:
|
||||
- os: windows
|
||||
arch: arm64
|
||||
include:
|
||||
- os: windows
|
||||
arch: ia32
|
||||
|
||||
steps:
|
||||
- name: Fix git checkout line endings
|
||||
run: git config --global core.autocrlf input
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2.3.0
|
||||
with:
|
||||
node-version: 12.x
|
||||
- name: Windows Setup
|
||||
if: matrix.os == 'windows'
|
||||
run: npm run prepare-win32
|
||||
- name: Install
|
||||
run: npm install
|
||||
- name: Prebuild binaries
|
||||
run: npm run prebuild --v8_enable_pointer_compression=false --v8_enable_31bit_smis_on_64bit_arch=false $([[ $OSTYPE != darwin* ]] && echo --llvm_version=0.0 || true)
|
||||
shell: bash
|
||||
env:
|
||||
PREBUILD_ARCH: ${{ matrix.arch }}
|
||||
- name: Upload binaries as an artifact
|
||||
uses: actions/upload-artifact@v2.3.1
|
||||
with:
|
||||
name: prebuild-${{ matrix.os }}-${{ matrix.arch }}
|
||||
path: prebuilds
|
||||
|
||||
publish:
|
||||
needs: prebuild
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref_type == 'tag'
|
||||
|
||||
steps:
|
||||
- name: Fix git checkout line endings
|
||||
run: git config --global core.autocrlf input
|
||||
- uses: actions/checkout@v2.3.4
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2.3.0
|
||||
with:
|
||||
node-version: 12.x
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- name: Install
|
||||
run: npm install
|
||||
- name: Download prebuild artifacts
|
||||
uses: actions/download-artifact@v2.1.0
|
||||
with:
|
||||
path: artifacts
|
||||
- name: Merge artifacts to prebuilds directory
|
||||
run: |
|
||||
mkdir prebuilds
|
||||
mv artifacts/*/* prebuilds/
|
||||
rm -r artifacts
|
||||
ls prebuilds
|
||||
- name: Publish to npm
|
||||
run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
179
electron/node_modules/lzma-native/CHANGELOG.md
generated
vendored
Normal file
179
electron/node_modules/lzma-native/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
# Changelog for lzma-native
|
||||
|
||||
## 8.0.6, Jan 18 2022
|
||||
|
||||
* [[`5bdb4b047c`](https://github.com/addaleax/lzma-native/commit/5bdb4b047c)] - **ci**: use npm instead of yarn (Anna Henningsen)
|
||||
* [[`204dfca905`](https://github.com/addaleax/lzma-native/commit/204dfca905)] - *Revert* "*Revert* "**ci**: set llvm_version to 0.0 on non-macOS hosts for prebuilds"" (Anna Henningsen)
|
||||
* [[`8c324b2672`](https://github.com/addaleax/lzma-native/commit/8c324b2672)] - *Revert* "**ci**: set llvm_version to 0.0 on non-macOS hosts for prebuilds" (Anna Henningsen)
|
||||
* [[`4639d45d73`](https://github.com/addaleax/lzma-native/commit/4639d45d73)] - **ci**: set llvm_version to 0.0 on non-macOS hosts for prebuilds (Anna Henningsen)
|
||||
* [[`d5164b3ded`](https://github.com/addaleax/lzma-native/commit/d5164b3ded)] - **test**: bump mocha timeout (Anna Henningsen)
|
||||
* [[`0ddd17aed8`](https://github.com/addaleax/lzma-native/commit/0ddd17aed8)] - **build**: fix dyld load error on Apple Silicon (#128) (tylinux)
|
||||
|
||||
## 8.0.5, Jan 11 2022
|
||||
|
||||
* [[`2ee1daa361`](https://github.com/addaleax/lzma-native/commit/2ee1daa361)] - fix(build): remove bash-isms (Anna Henningsen)
|
||||
* [[`da5832b0c4`](https://github.com/addaleax/lzma-native/commit/da5832b0c4)] - **ci**: replace Travis CI/AppVeyor with GitHub Actions, prebuild for macOS/arm64 (#126) (Mark Lee)
|
||||
* [[`8af909b058`](https://github.com/addaleax/lzma-native/commit/8af909b058)] - **build**: fix build on Apple Silicon (#123) (tylinux)
|
||||
|
||||
## 8.0.1, May 13 2021
|
||||
|
||||
* [[`5b724c30c1`](https://github.com/addaleax/lzma-native/commit/5b724c30c1)] - More prebuild updates (Anna Henningsen)
|
||||
* [[`43f11c229b`](https://github.com/addaleax/lzma-native/commit/43f11c229b)] - Try switching to prebuildify (Anna Henningsen)
|
||||
|
||||
## 7.0.1, Mar 11 2021
|
||||
|
||||
* [[`d9b0b90b66`](https://github.com/addaleax/lzma-native/commit/d9b0b90b66)] - Upgrade to @mapbox/node-pre-gyp (Luis Solorzano)
|
||||
|
||||
## 6.0.1, Apr 23 2020
|
||||
|
||||
* [[`d90d2fc354`](https://github.com/addaleax/lzma-native/commit/d90d2fc354)] - **build**: fix package filename for N-API (Anna Henningsen)
|
||||
|
||||
## 6.0.0, Jan 1 2020
|
||||
|
||||
* [[`f33038b345`](https://github.com/addaleax/lzma-native/commit/f33038b345)] - **ci**: update platform list (Anna Henningsen) [#72](https://github.com/addaleax/lzma-native/pull/72)
|
||||
* [[`66499a02b6`](https://github.com/addaleax/lzma-native/commit/66499a02b6)] - **build**: remove cflags.sh build step (Anna Henningsen) [#72](https://github.com/addaleax/lzma-native/pull/72)
|
||||
* [[`8bea0ff0cf`](https://github.com/addaleax/lzma-native/commit/8bea0ff0cf)] - **src**: convert to N-API (Anna Henningsen) [#72](https://github.com/addaleax/lzma-native/pull/72)
|
||||
|
||||
## 5.0.1, Dec 19 2019
|
||||
|
||||
* [[`56ff7693a8`](https://github.com/addaleax/lzma-native/commit/56ff7693a8)] - **ci**: revert back to using gcc 4.9 (Anna Henningsen)
|
||||
|
||||
## 5.0.0, Nov 23 2019
|
||||
|
||||
* [[`607c4f450c`](https://github.com/addaleax/lzma-native/commit/607c4f450c)] - **ci**: remove Node.js 6, 11 (Anna Henningsen) [#87](https://github.com/addaleax/lzma-native/pull/87)
|
||||
|
||||
## 4.0.6, Nov 22 2019
|
||||
|
||||
* [[`6ebced9b57`](https://github.com/addaleax/lzma-native/commit/6ebced9b57)] - Fix compatibility with Node 13 (Christian Moritz) [#86](https://github.com/addaleax/lzma-native/pull/86)
|
||||
|
||||
## 4.0.5, May 24 2019
|
||||
|
||||
* [[`dfd9098c85`](https://github.com/addaleax/lzma-native/commit/dfd9098c85)] - Ignore .git when publishing to npm (Juan Cruz Viotti) [#83](https://github.com/addaleax/lzma-native/pull/83)
|
||||
|
||||
## 4.0.4, May 23 2019
|
||||
|
||||
* [[`0dc31e34de`](https://github.com/addaleax/lzma-native/commit/0dc31e34de)] - Enable compilation for Node 12 (Gergely Imreh) [#81](https://github.com/addaleax/lzma-native/pull/81)
|
||||
|
||||
## 4.0.3, Nov 14 2018
|
||||
|
||||
* [[`d07d5f5571`](https://github.com/addaleax/lzma-native/commit/d07d5f5571)] - **ci**: update platform list with Node 11 (Anna Henningsen)
|
||||
* [[`8bbfb0a4d1`](https://github.com/addaleax/lzma-native/commit/8bbfb0a4d1)] - **ci**: fix Node 8 version at 8.10 (Anna Henningsen)
|
||||
|
||||
## 4.0.2, Oct 26 2018
|
||||
|
||||
* [[`bb6bfe0988`](https://github.com/addaleax/lzma-native/commit/bb6bfe0988)] - **package**: update node-pre-gyp to 0.11.0 (webcarrot) [#68](https://github.com/addaleax/lzma-native/pull/68)
|
||||
|
||||
## 4.0.1, Jul 26 2018
|
||||
|
||||
* [[`93b50cc2f7`](https://github.com/addaleax/lzma-native/commit/93b50cc2f7)] - **package**: fix rimraf invocation in install script (webcarrot) [#63](https://github.com/addaleax/lzma-native/pull/63)
|
||||
|
||||
## 4.0.0, Jul 26 2018
|
||||
|
||||
There are no breaking changes to the API provided by this module.
|
||||
|
||||
This drops pre-built binaries and testing for officially unsupported Node.js
|
||||
versions. Those versions have known security issues and should not be used
|
||||
anymore.
|
||||
|
||||
This also updates node-pre-gyp to a more recent version. In the past,
|
||||
this has caused trouble for some users, so this considered
|
||||
is a semver-major change as well.
|
||||
|
||||
* [[`b625b3e525`](https://github.com/addaleax/lzma-native/commit/b625b3e525)] - **package**: stop bundling dependencies (Anna Henningsen)
|
||||
* [[`98155a8179`](https://github.com/addaleax/lzma-native/commit/98155a8179)] - **ci**: drop unsupported Node.js versions (4, 5, 7, 9) (Anna Henningsen)
|
||||
* [[`d59574481f`](https://github.com/addaleax/lzma-native/commit/d59574481f)] - **package**: update bl to 2.0.1 (Anna Henningsen)
|
||||
* [[`f2c6e84d2c`](https://github.com/addaleax/lzma-native/commit/f2c6e84d2c)] - **package**: update node-pre-gyp to 0.10.3 (simlu) [#61](https://github.com/addaleax/lzma-native/pull/61)
|
||||
|
||||
## 3.0.8, May 12 2018
|
||||
|
||||
* [[`8c18848609`](https://github.com/addaleax/lzma-native/commit/8c18848609)] - **ci**: add Node.js 10 to matrix (Anna Henningsen)
|
||||
|
||||
## 3.0.7, Mar 26 2018
|
||||
|
||||
This likely fixed a regression related to node-pre-gyp.
|
||||
|
||||
* [[`430a440276`](https://github.com/addaleax/lzma-native/commit/430a440276)] - **package**: pin node-pre-gyp to 0.6.39 (Anna Henningsen)
|
||||
|
||||
## 3.0.6, Mar 26 2018
|
||||
|
||||
* [[`484c53577f`](https://github.com/addaleax/lzma-native/commit/484c53577f)] - **package**: update dependencies (Anna Henningsen)
|
||||
* [[`6513708704`](https://github.com/addaleax/lzma-native/commit/6513708704)] - **lib**: use `Buffer.*` instead of deprecated Buffer constructor (Anna Henningsen)
|
||||
|
||||
## 3.0.5, Feb 21 2018
|
||||
|
||||
* [[`c03299db13`](https://github.com/addaleax/lzma-native/commit/c03299db13)] - **ci**: remove OS X from coverage (Anna Henningsen)
|
||||
* [[`5f640416e0`](https://github.com/addaleax/lzma-native/commit/5f640416e0)] - **lib**: fix issue with invalid input (Anna Henningsen)
|
||||
|
||||
## 3.0.4, Nov 27 2017
|
||||
|
||||
* [[`669ee5098b`](https://github.com/addaleax/lzma-native/commit/669ee5098b)] - **package**: replace unavailable host to node-pre-gyp.addaleax.net (JianyingLi) [#48](https://github.com/addaleax/lzma-native/pull/48)
|
||||
|
||||
## 3.0.3, Nov 26 2017
|
||||
|
||||
* [[`fcba77ebe0`](https://github.com/addaleax/lzma-native/commit/fcba77ebe0)] - **ci**: include Node 9 support (Anna Henningsen)
|
||||
|
||||
## 3.0.2, Nov 07 2017
|
||||
|
||||
* [[`82b97dd94f`](https://github.com/addaleax/lzma-native/commit/82b97dd94f)] - **package**: update dependencies (Anna Henningsen)
|
||||
|
||||
## 3.0.1, Jul 04 2017
|
||||
|
||||
* [[`9e2ee5129f`](https://github.com/addaleax/lzma-native/commit/9e2ee5129f)] - **ci**: fix CI on Windows (Anna Henningsen)
|
||||
* [[`8d75757031`](https://github.com/addaleax/lzma-native/commit/8d75757031)] - **lib**: fix race condition (Alexander Sagen) [#40](https://github.com/addaleax/lzma-native/pull/40)
|
||||
|
||||
## 3.0.0, Jun 26 2017
|
||||
|
||||
This is unlikely to break anybody’s code, but removing the build files after install might qualify as semver-major.
|
||||
|
||||
* [[`d5a252e3de`](https://github.com/addaleax/lzma-native/commit/d5a252e3de)] - **build**: rimraf build/ after install (Anna Henningsen)
|
||||
* [[`fd2165e2ae`](https://github.com/addaleax/lzma-native/commit/fd2165e2ae)] - **ci**: add electron prebuilts again (Anna Henningsen)
|
||||
* [[`039ac523d0`](https://github.com/addaleax/lzma-native/commit/039ac523d0)] - **lib**: explicit util.promisify() compat (Anna Henningsen)
|
||||
|
||||
## 2.0.4, Jun 25 2017
|
||||
|
||||
* [[`0cc00000b3`](https://github.com/addaleax/lzma-native/commit/0cc00000b3)] - **ci**: fix macOS prebuild binaries (Anna Henningsen)
|
||||
|
||||
## 2.0.3, Jun 21 2017
|
||||
|
||||
* [[`621628abac`](https://github.com/addaleax/lzma-native/commit/621628abac)] - **ci**: add Node 8 to CI matrix (Anna Henningsen)
|
||||
|
||||
## 2.0.2, May 18 2017
|
||||
|
||||
* [[`39bd6a2dc0`](https://github.com/addaleax/lzma-native/commit/39bd6a2dc0)] - **package**: pin nan to 2.5.1 (Anna Henningsen)
|
||||
|
||||
## 2.0.1, March 24 2017
|
||||
|
||||
* [[`c0491a0a07`](https://github.com/addaleax/lzma-native/commit/c0491a0a07)] - refactored binding.gyp (Refael Ackermann)
|
||||
* [[`70883635b7`](https://github.com/addaleax/lzma-native/commit/70883635b7)] - **ci**: skip artifact encryption setup for non-tag builds (Anna Henningsen)
|
||||
|
||||
## 2.0.0, March 19 2017
|
||||
|
||||
Changes since 1.5.2
|
||||
|
||||
Notable changes:
|
||||
|
||||
* Dropped support for Node 0.10 and 0.12, which includes dropping `any-promise` and `util-extend` as dependencies.
|
||||
* A changed path for the prebuilt binaries, which now includes versioning information.
|
||||
|
||||
* [[`83e0007061`](https://github.com/addaleax/lzma-native/commit/83e0007061)] - Bump version to 1.5.3
|
||||
* [[`8021673b5d`](https://github.com/addaleax/lzma-native/commit/8021673b5d)] - Silence warnings about deprecated `NewInstance` usage
|
||||
* [[`061933c4c7`](https://github.com/addaleax/lzma-native/commit/061933c4c7)] - **bin**: drop `commander` dependency
|
||||
* [[`d752f96be4`](https://github.com/addaleax/lzma-native/commit/d752f96be4)] - **ci**: don’t use -flto for now
|
||||
* [[`92188bee5e`](https://github.com/addaleax/lzma-native/commit/92188bee5e)] - **ci**: fix AppVeyor allocation failures
|
||||
* [[`b79fa969d4`](https://github.com/addaleax/lzma-native/commit/b79fa969d4)] - **ci**: fix AppVeyor indexparser failures
|
||||
* [[`5fcc17e54f`](https://github.com/addaleax/lzma-native/commit/5fcc17e54f)] - **ci**: fix Travis gcc CI failures
|
||||
* [[`3f5d2609bd`](https://github.com/addaleax/lzma-native/commit/3f5d2609bd)] - **ci**: drop Node v0.10/v0.12 support
|
||||
* [[`48e48ea25a`](https://github.com/addaleax/lzma-native/commit/48e48ea25a)] - **ci**: ci file housekeeping
|
||||
* [[`c2d06b5e09`](https://github.com/addaleax/lzma-native/commit/c2d06b5e09)] - **ci**: work around node-gyp build failures
|
||||
* [[`f94287f711`](https://github.com/addaleax/lzma-native/commit/f94287f711)] - **ci,test**: drop explicit nw.js testing
|
||||
* [[`c61355984f`](https://github.com/addaleax/lzma-native/commit/c61355984f)] - **deps**: update xz to 5.2.3
|
||||
* [[`b07f501e26`](https://github.com/addaleax/lzma-native/commit/b07f501e26)] - **doc**: leave blank lines around headings in README
|
||||
* [[`dea30f3f20`](https://github.com/addaleax/lzma-native/commit/dea30f3f20)] - **lib**: drop util-extend dependency
|
||||
* [[`0988b8d360`](https://github.com/addaleax/lzma-native/commit/0988b8d360)] - **lib**: refactor js-facing Stream into class
|
||||
* [[`18bbdfc220`](https://github.com/addaleax/lzma-native/commit/18bbdfc220)] - **lib**: always use ES6 promises
|
||||
* [[`f5030e027e`](https://github.com/addaleax/lzma-native/commit/f5030e027e)] - **lib**: fix unhandled Promise rejections
|
||||
* [[`6e887ca52c`](https://github.com/addaleax/lzma-native/commit/6e887ca52c)] - **meta**: package.json housekeeping
|
||||
* [[`e884b2e7c1`](https://github.com/addaleax/lzma-native/commit/e884b2e7c1)] - **prebuild**: add versioning to the binding file path
|
||||
* [[`e8660b3728`](https://github.com/addaleax/lzma-native/commit/e8660b3728)] - **src**: use Nan::MakeCallback() for calling into JS
|
||||
* [[`bd7ee7ce3f`](https://github.com/addaleax/lzma-native/commit/bd7ee7ce3f)] - **test**: use `fs.unlinkSync` for synchronous unlinking
|
||||
|
||||
22
electron/node_modules/lzma-native/LICENSE
generated
vendored
Normal file
22
electron/node_modules/lzma-native/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2016 Anna Henningsen
|
||||
|
||||
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.
|
||||
|
||||
650
electron/node_modules/lzma-native/README.md
generated
vendored
Normal file
650
electron/node_modules/lzma-native/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,650 @@
|
|||
lzma-native
|
||||
===========
|
||||
|
||||
[](https://npmjs.org/package/lzma-native)
|
||||
[](https://npmjs.org/package/lzma-native)
|
||||
[](https://travis-ci.org/addaleax/lzma-native?branch=master)
|
||||
[](https://ci.appveyor.com/project/addaleax/lzma-native)
|
||||
[](https://coveralls.io/r/addaleax/lzma-native?branch=master)
|
||||
[](https://david-dm.org/addaleax/lzma-native)
|
||||
[](https://david-dm.org/addaleax/lzma-native#info=devDependencies)
|
||||
|
||||
Node.js interface to the native liblzma compression library (.xz file format, among others)
|
||||
|
||||
This package provides interfaces for compression and decompression
|
||||
of `.xz` (and legacy `.lzma`) files, both stream-based and string-based.
|
||||
|
||||
<a name="example-usage"></a>
|
||||
|
||||
## Example usage
|
||||
|
||||
<a name="installation"></a>
|
||||
|
||||
### Installation
|
||||
|
||||
Simply install `lzma-native` via npm:
|
||||
```bash
|
||||
$ npm install --save lzma-native
|
||||
```
|
||||
|
||||
*Note*: As of version 1.0.0, this module provides pre-built binaries for multiple Node.js
|
||||
versions and all major OS using [node-pre-gyp](https://github.com/mapbox/node-pre-gyp),
|
||||
so for 99 % of users no compiler toolchain is necessary.
|
||||
Please [create an issue here](https://github.com/addaleax/lzma-native/issues/new)
|
||||
if you have any trouble installing this module.
|
||||
|
||||
*Note*: `lzma-native@2.x` requires a Node version >= 4. If you want to support
|
||||
Node `0.10` or `0.12`, you can feel free to use `lzma-native@1.x`.
|
||||
|
||||
<a name="streams-usage"></a>
|
||||
|
||||
### For streams
|
||||
|
||||
If you don’t have any fancy requirements, using this library is quite simple:
|
||||
|
||||
<!--
|
||||
Some examples in this README file are executed as part of the automatic
|
||||
testing process. See test/readme-examples.js for details.
|
||||
-->
|
||||
|
||||
<!-- runtest:{Compress the README.md file} -->
|
||||
|
||||
```js
|
||||
var lzma = require('lzma-native');
|
||||
|
||||
var compressor = lzma.createCompressor();
|
||||
var input = fs.createReadStream('README.md');
|
||||
var output = fs.createWriteStream('README.md.xz');
|
||||
|
||||
input.pipe(compressor).pipe(output);
|
||||
```
|
||||
|
||||
For decompression, you can simply use `lzma.createDecompressor()`.
|
||||
|
||||
Both functions return a stream where you can pipe your
|
||||
input in and read your (de)compressed output from.
|
||||
|
||||
<a name="buffers-usage"></a>
|
||||
|
||||
### For simple strings/Buffers
|
||||
|
||||
If you want your input/output to be Buffers (strings will be accepted as input),
|
||||
this even gets a little simpler:
|
||||
|
||||
<!-- runtest:{Compress a simple string directly} -->
|
||||
|
||||
```js
|
||||
lzma.compress('Banana', function(result) {
|
||||
console.log(result); // <Buffer fd 37 7a 58 5a 00 00 01 69 22 de 36 02 00 21 ...>
|
||||
});
|
||||
```
|
||||
|
||||
Again, replace `lzma.compress` with `lzma.decompress` and you’ll get the inverse transformation.
|
||||
|
||||
`lzma.compress()` and `lzma.decompress()`
|
||||
will return promises and you don’t need to provide any kind of callback
|
||||
([Example code](#api-q-compress-examle)).
|
||||
|
||||
<a name="api"></a>
|
||||
|
||||
## API
|
||||
|
||||
<a name="api-compat-implementations"></a>
|
||||
|
||||
### Compatibility implementations
|
||||
|
||||
Apart from the API described here, `lzma-native` implements the APIs of the following
|
||||
other LZMA libraries so you can use it nearly as a drop-in replacement:
|
||||
|
||||
* [node-xz][node-xz] via `lzma.Compressor` and `lzma.Decompressor`
|
||||
* [LZMA-JS][LZMA-JS] via `lzma.LZMA().compress` and `lzma.LZMA().decompress`,
|
||||
though without actual support for progress functions and returning `Buffer` objects
|
||||
instead of integer arrays. (This produces output in the `.lzma` file format, *not* the `.xz` format!)
|
||||
|
||||
<a name="api-multithreading"></a>
|
||||
|
||||
### Multi-threaded encoding
|
||||
|
||||
Since version `1.5.0`, lzma-native supports liblzma’s built-in multi-threading
|
||||
encoding capabilities. To make use of them, set the `threads` option to
|
||||
an integer value: `lzma.createCompressor({ threads: n });`. You can use
|
||||
value of `0` to use the number of processor cores. This option is only
|
||||
available for the `easyEncoder` (the default) and `streamEncoder` encoders.
|
||||
|
||||
Note that, by default, encoding will take place in Node’s libuv thread pool
|
||||
regardless of this option, and setting it when multiple encoders are running
|
||||
is likely to affect performance negatively.
|
||||
|
||||
<a name="api-reference"></a>
|
||||
|
||||
### Reference
|
||||
|
||||
[Encoding strings and Buffer objects](#api-encoding-buffers)
|
||||
* [`compress()`](#api-compress) – Compress strings and Buffers
|
||||
* [`decompress()`](#api-decompress) – Decompress strings and Buffers
|
||||
* [`LZMA().compress()`](#api-LZMA_compress) ([LZMA-JS][LZMA-JS] compatibility)
|
||||
* [`LZMA().decompress()`](#api-LZMA_decompress) ([LZMA-JS][LZMA-JS] compatibility)
|
||||
|
||||
[Creating streams for encoding](#api-creating-streams)
|
||||
* [`createCompressor()`](#api-create-compressor) – Compress streams
|
||||
* [`createDecompressor()`](#api-create-decompressor) – Decompress streams
|
||||
* [`createStream()`](#api-create-stream) – (De-)Compression with advanced options
|
||||
* [`Compressor()`](#api-robey_compressor) ([node-xz][node-xz] compatibility)
|
||||
* [`Decompressor()`](#api-robey_decompressor) ([node-xz][node-xz] compatibility)
|
||||
|
||||
[.xz file metadata](#api-parse-indexes)
|
||||
* [`isXZ()`](#api-isxz) – Test Buffer for `.xz` file format
|
||||
* [`parseFileIndex()`](#api-parse-file-index) – Read `.xz` file metadata
|
||||
* [`parseFileIndexFD()`](#api-parse-file-index-fd) – Read `.xz` metadata from a file descriptor
|
||||
|
||||
[Miscellaneous functions](#api-functions)
|
||||
* [`crc32()`](#api-crc32) – Calculate CRC32 checksum
|
||||
* [`checkSize()`](#api-check-size) – Return required size for specific checksum type
|
||||
* [`easyDecoderMemusage()`](#api-easy-decoder-memusage) – Expected memory usage
|
||||
* [`easyEncoderMemusage()`](#api-easy-encoder-memusage) – Expected memory usage
|
||||
* [`rawDecoderMemusage()`](#api-raw-decoder-memusage) – Expected memory usage
|
||||
* [`rawEncoderMemusage()`](#api-raw-encoder-memusage) – Expected memory usage
|
||||
* [`versionString()`](#api-version-string) – Native library version string
|
||||
* [`versionNumber()`](#api-version-number) – Native library numerical version identifier
|
||||
|
||||
<a name="api-encoding-buffers"></a>
|
||||
|
||||
### Encoding strings and Buffer objects
|
||||
|
||||
<a name="api-compress"></a>
|
||||
<a name="api-decompress"></a>
|
||||
|
||||
#### `lzma.compress()`, `lzma.decompress()`
|
||||
|
||||
* `lzma.compress(string, [opt, ]on_finish)`
|
||||
* `lzma.decompress(string, [opt, ]on_finish)`
|
||||
|
||||
Param | Type | Description
|
||||
------------ | ---------------- | --------------
|
||||
`string` | Buffer / String | Any string or buffer to be (de)compressed (that can be passed to `stream.end(…)`)
|
||||
[`opt`] | Options / int | Optional. See [options](#api-options)
|
||||
`on_finish` | Callback | Will be invoked with the resulting Buffer as the first parameter when encoding is finished, and as `on_finish(null, err)` in case of an error.
|
||||
|
||||
These methods will also return a promise that you can use directly.
|
||||
|
||||
Example code:
|
||||
<!-- runtest:{Compress and decompress directly} -->
|
||||
|
||||
```js
|
||||
lzma.compress('Bananas', 6, function(result) {
|
||||
lzma.decompress(result, function(decompressedResult) {
|
||||
assert.equal(decompressedResult.toString(), 'Bananas');
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
<a name="api-q-compress-examle"></a>
|
||||
Example code for promises:
|
||||
<!-- runtest:{Compress and decompress directly using promises} -->
|
||||
|
||||
```js
|
||||
lzma.compress('Bananas', 6).then(function(result) {
|
||||
return lzma.decompress(result);
|
||||
}).then(function(decompressedResult) {
|
||||
assert.equal(decompressedResult.toString(), 'Bananas');
|
||||
}).catch(function(err) {
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
<a name="api-LZMA_compress"></a>
|
||||
<a name="api-LZMA_decompress"></a>
|
||||
|
||||
#### `lzma.LZMA().compress()`, `lzma.LZMA().decompress()`
|
||||
|
||||
* `lzma.LZMA().compress(string, mode, on_finish[, on_progress])`
|
||||
* `lzma.LZMA().decompress(string, on_finish[, on_progress])`
|
||||
|
||||
(Compatibility; See [LZMA-JS][LZMA-JS] for the original specs.)
|
||||
|
||||
**Note that the result of compression is in the older LZMA1 format (`.lzma` files).**
|
||||
This is different from the more universally used LZMA2 format (`.xz` files) and you will
|
||||
have to take care of possible compatibility issues with systems expecting `.xz` files.
|
||||
|
||||
Param | Type | Description
|
||||
------------- | ----------------------- | --------------
|
||||
`string` | Buffer / String / Array | Any string, buffer, or array of integers or typed integers (e.g. `Uint8Array`)
|
||||
`mode` | int | [A number between 0 and 9](#api-options-preset), indicating compression level
|
||||
`on_finish` | Callback | Will be invoked with the resulting Buffer as the first parameter when encoding is finished, and as `on_finish(null, err)` in case of an error.
|
||||
`on_progress` | Callback | Indicates progress by passing a number in [0.0, 1.0]. Currently, this package only invokes the callback with 0.0 and 1.0.
|
||||
|
||||
These methods will also return a promise that you can use directly.
|
||||
|
||||
This does not work exactly as described in the original [LZMA-JS][LZMA-JS] specification:
|
||||
* The results are `Buffer` objects, not integer arrays. This just makes a lot
|
||||
more sense in a Node.js environment.
|
||||
* `on_progress` is currently only called with `0.0` and `1.0`.
|
||||
|
||||
Example code:
|
||||
<!-- runtest:{Compress and decompress directly using LZMA-JS compatibility} -->
|
||||
|
||||
```js
|
||||
lzma.LZMA().compress('Bananas', 4, function(result) {
|
||||
lzma.LZMA().decompress(result, function(decompressedResult) {
|
||||
assert.equal(decompressedResult.toString(), 'Bananas');
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
For an example using promises, see [`compress()`](#api-q-compress-examle).
|
||||
|
||||
<a name="api-creating-streams"></a>
|
||||
|
||||
### Creating streams for encoding
|
||||
|
||||
<a name="api-create-compressor"></a>
|
||||
<a name="api-create-decompressor"></a>
|
||||
|
||||
#### `lzma.createCompressor()`, `lzma.createDecompressor()`
|
||||
|
||||
* `lzma.createCompressor([options])`
|
||||
* `lzma.createDecompressor([options])`
|
||||
|
||||
Param | Type | Description
|
||||
----------- | ---------------- | --------------
|
||||
[`options`] | Options / int | Optional. See [options](#api-options)
|
||||
|
||||
Return a [duplex][duplex] stream, i.e. a both readable and writable stream.
|
||||
Input will be read, (de)compressed and written out. You can use this to pipe
|
||||
input through this stream, i.e. to mimick the `xz` command line util, you can write:
|
||||
|
||||
<!-- runtest:{Compress and decompress using streams} -->
|
||||
|
||||
```js
|
||||
var compressor = lzma.createCompressor();
|
||||
|
||||
process.stdin.pipe(compressor).pipe(process.stdout);
|
||||
```
|
||||
|
||||
The output of compression will be in LZMA2 format (`.xz` files), while decompression
|
||||
will accept either format via automatic detection.
|
||||
|
||||
<a name="api-robey_compressor"></a>
|
||||
<a name="api-robey_decompressor"></a>
|
||||
|
||||
#### `lzma.Compressor()`, `lzma.Decompressor()`
|
||||
|
||||
* `lzma.Compressor([preset], [options])`
|
||||
* `lzma.Decompressor([options])`
|
||||
|
||||
(Compatibility; See [node-xz][node-xz] for the original specs.)
|
||||
|
||||
These methods handle the `.xz` file format.
|
||||
|
||||
Param | Type | Description
|
||||
----------- | ---------------- | --------------
|
||||
[`preset`] | int | Optional. See [options.preset](#api-options-preset)
|
||||
[`options`] | Options | Optional. See [options](#api-options)
|
||||
|
||||
Return a [duplex][duplex] stream, i.e. a both readable and writable stream.
|
||||
Input will be read, (de)compressed and written out. You can use this to pipe
|
||||
input through this stream, i.e. to mimick the `xz` command line util, you can write:
|
||||
|
||||
<!-- runtest:{Compress and decompress using streams with node-xz compatibility} -->
|
||||
|
||||
```js
|
||||
var compressor = lzma.Compressor();
|
||||
|
||||
process.stdin.pipe(compressor).pipe(process.stdout);
|
||||
```
|
||||
|
||||
<a name="api-create-stream"></a>
|
||||
|
||||
#### `lzma.createStream()`
|
||||
|
||||
* `lzma.createStream(coder, options)`
|
||||
|
||||
Param | Type | Description
|
||||
----------- | ---------------- | --------------
|
||||
[`coder`] | string | Any of the [supported coder names](#api-coders), e.g. `"easyEncoder"` (default) or `"autoDecoder"`.
|
||||
[`options`] | Options / int | Optional. See [options](#api-options)
|
||||
|
||||
Return a [duplex][duplex] stream for (de-)compression. You can use this to pipe
|
||||
input through this stream.
|
||||
|
||||
<a name="#api-coders"></a>
|
||||
The available coders are (the most interesting ones first):
|
||||
|
||||
* `easyEncoder`
|
||||
Standard LZMA2 ([`.xz` file format](https://en.wikipedia.org/wiki/.xz)) encoder.
|
||||
Supports [`options.preset`](#api-options-preset) and [`options.check`](#api-options-check) options.
|
||||
* `autoDecoder`
|
||||
Standard LZMA1/2 (both `.xz` and `.lzma`) decoder with auto detection of file format.
|
||||
Supports [`options.memlimit`](#api-options-memlimit) and [`options.flags`](#api-options-flags) options.
|
||||
* `aloneEncoder`
|
||||
Encoder which only uses the legacy `.lzma` format.
|
||||
Supports the whole range of [LZMA options](#api-options-lzma).
|
||||
|
||||
Less likely to be of interest to you, but also available:
|
||||
|
||||
* `aloneDecoder`
|
||||
Decoder which only uses the legacy `.lzma` format.
|
||||
Supports the [`options.memlimit`](#api-options-memlimit) option.
|
||||
* `rawEncoder`
|
||||
Custom encoder corresponding to `lzma_raw_encoder` (See the native library docs for details).
|
||||
Supports the [`options.filters`](#api-options-filters) option.
|
||||
* `rawDecoder`
|
||||
Custom decoder corresponding to `lzma_raw_decoder` (See the native library docs for details).
|
||||
Supports the [`options.filters`](#api-options-filters) option.
|
||||
* `streamEncoder`
|
||||
Custom encoder corresponding to `lzma_stream_encoder` (See the native library docs for details).
|
||||
Supports [`options.filters`](#api-options-filters) and [`options.check`](#api-options-check) options.
|
||||
* `streamDecoder`
|
||||
Custom decoder corresponding to `lzma_stream_decoder` (See the native library docs for details).
|
||||
Supports [`options.memlimit`](#api-options-memlimit) and [`options.flags`](#api-options-flags) options.
|
||||
|
||||
<a name="api-options"></a>
|
||||
|
||||
#### Options
|
||||
|
||||
<a name="api-options-check"></a>
|
||||
<a name="api-options-memlimit"></a>
|
||||
<a name="api-options-preset"></a>
|
||||
<a name="api-options-flags"></a>
|
||||
<a name="api-options-synchronous"></a>
|
||||
|
||||
Option name | Type | Description
|
||||
------------- | ---------- | -------------
|
||||
`check` | check | Any of `lzma.CHECK_CRC32`, `lzma.CHECK_CRC64`, `lzma.CHECK_NONE`, `lzma.CHECK_SHA256`
|
||||
`memlimit` | float | A memory limit for (de-)compression in bytes
|
||||
`preset` | int | A number from 0 to 9, 0 being the fastest and weakest compression, 9 the slowest and highest compression level. (Please also see the [xz(1) manpage][xz-manpage] for notes – don’t just blindly use 9!) You can also OR this with `lzma.PRESET_EXTREME` (the `-e` option to the `xz` command line utility).
|
||||
`flags` | int | A bitwise or of `lzma.LZMA_TELL_NO_CHECK`, `lzma.LZMA_TELL_UNSUPPORTED_CHECK`, `lzma.LZMA_TELL_ANY_CHECK`, `lzma.LZMA_CONCATENATED`
|
||||
`synchronous` | bool | If true, forces synchronous coding (i.e. no usage of threading)
|
||||
`bufsize` | int | The default size for allocated buffers
|
||||
`threads` | int | Set to an integer to use liblzma’s multi-threading support. 0 will choose the number of CPU cores.
|
||||
`blockSize` | int | Maximum uncompressed size of a block in multi-threading mode
|
||||
`timeout` | int | Timeout for a single encoding operation in multi-threading mode
|
||||
|
||||
<a name="api-options-filters"></a>
|
||||
|
||||
`options.filters` can, if the coder supports it, be an array of filter objects, each with the following properties:
|
||||
|
||||
* `.id`
|
||||
Any of `lzma.FILTERS_MAX`, `lzma.FILTER_ARM`, `lzma.FILTER_ARMTHUMB`, `lzma.FILTER_IA64`,
|
||||
`lzma.FILTER_POWERPC`, `lzma.FILTER_SPARC`, `lzma.FILTER_X86` or
|
||||
`lzma.FILTER_DELTA`, `lzma.FILTER_LZMA1`, `lzma.FILTER_LZMA2`
|
||||
|
||||
The delta filter supports the additional option `.dist` for a distance between bytes (see the [xz(1) manpage][xz-manpage]).
|
||||
|
||||
<a name="api-options-lzma"></a>
|
||||
|
||||
The LZMA filter supports the additional options `.dict_size`, `.lp`, `.lc`, `pb`, `.mode`, `nice_len`, `.mf`, `.depth`
|
||||
and `.preset`. See the [xz(1) manpage][xz-manpage] for meaning of these parameters and additional information.
|
||||
|
||||
<a name="api-functions"></a>
|
||||
|
||||
### Miscellaneous functions
|
||||
|
||||
<a name="api-crc32"></a>
|
||||
|
||||
#### `lzma.crc32()`
|
||||
|
||||
* `lzma.crc32(input[, encoding[, previous]])`
|
||||
|
||||
Compute the CRC32 checksum of a Buffer or string.
|
||||
|
||||
Param | Type | Description
|
||||
------------ | ---------------- | --------------
|
||||
`input` | string / Buffer | Any string or Buffer.
|
||||
[`encoding`] | string | Optional. If `input` is a string, an encoding to use when converting into binary.
|
||||
[`previous`] | int | The result of a previous CRC32 calculation so that you can compute the checksum per each chunk
|
||||
|
||||
Example usage:
|
||||
<!-- runtest:{Compute the CRC32 of a string} -->
|
||||
|
||||
```js
|
||||
lzma.crc32('Banana') // => 69690105
|
||||
```
|
||||
|
||||
<a name="api-check-size"></a>
|
||||
|
||||
#### `lzma.checkSize()`
|
||||
|
||||
* `lzma.checkSize(check)`
|
||||
|
||||
Return the byte size of a check sum.
|
||||
|
||||
Param | Type | Description
|
||||
------------ | ---------------- | --------------
|
||||
`check` | check | Any supported check constant.
|
||||
|
||||
Example usage:
|
||||
<!-- runtest:{Calculate some check sizes} -->
|
||||
|
||||
```js
|
||||
lzma.checkSize(lzma.CHECK_SHA256) // => 16
|
||||
lzma.checkSize(lzma.CHECK_CRC32) // => 4
|
||||
```
|
||||
|
||||
<a name="api-easy-decoder-memusage"></a>
|
||||
|
||||
#### `lzma.easyDecoderMemusage()`
|
||||
|
||||
* `lzma.easyDecoderMemusage(preset)`
|
||||
|
||||
Returns the approximate memory usage when decoding using easyDecoder for a given preset.
|
||||
|
||||
Param | Type | Description
|
||||
------------ | ----------- | --------------
|
||||
`preset` | preset | A compression level from 0 to 9
|
||||
|
||||
Example usage:
|
||||
<!-- runtest:{Return memory usage for decoding} -->
|
||||
|
||||
```js
|
||||
lzma.easyDecoderMemusage(6) // => 8454192
|
||||
```
|
||||
|
||||
<a name="api-easy-encoder-memusage"></a>
|
||||
|
||||
#### `lzma.easyEncoderMemusage()`
|
||||
|
||||
* `lzma.easyEncoderMemusage(preset)`
|
||||
|
||||
Returns the approximate memory usage when encoding using easyEncoder for a given preset.
|
||||
|
||||
Param | Type | Description
|
||||
------------ | ----------- | --------------
|
||||
`preset` | preset | A compression level from 0 to 9
|
||||
|
||||
Example usage:
|
||||
<!-- runtest:{Return memory usage for encoding} -->
|
||||
|
||||
```js
|
||||
lzma.easyEncoderMemusage(6) // => 97620499
|
||||
```
|
||||
|
||||
<a name="api-raw-decoder-memusage"></a>
|
||||
|
||||
#### `lzma.rawDecoderMemusage()`
|
||||
|
||||
* `lzma.rawDecoderMemusage(filters)`
|
||||
|
||||
Returns the approximate memory usage when decoding using rawDecoder for a given filter list.
|
||||
|
||||
Param | Type | Description
|
||||
------------ | ----------- | --------------
|
||||
`filters` | array | An array of [filters](#api-options-filters)
|
||||
|
||||
<a name="api-raw-encoder-memusage"></a>
|
||||
|
||||
#### `lzma.rawEncoderMemusage()`
|
||||
|
||||
* `lzma.rawEncoderMemusage(filters)`
|
||||
|
||||
Returns the approximate memory usage when encoding using rawEncoder for a given filter list.
|
||||
|
||||
Param | Type | Description
|
||||
------------ | ----------- | --------------
|
||||
`filters` | array | An array of [filters](#api-options-filters)
|
||||
|
||||
<a name="api-version-string"></a>
|
||||
|
||||
#### `lzma.versionString()`
|
||||
|
||||
* `lzma.versionString()`
|
||||
|
||||
Returns the version of the underlying C library.
|
||||
|
||||
Example usage:
|
||||
<!-- runtest:{Return a version string} -->
|
||||
|
||||
```js
|
||||
lzma.versionString() // => '5.2.3'
|
||||
```
|
||||
|
||||
<a name="api-version-number"></a>
|
||||
|
||||
#### `lzma.versionNumber()`
|
||||
|
||||
* `lzma.versionNumber()`
|
||||
|
||||
Returns the version of the underlying C library.
|
||||
|
||||
Example usage:
|
||||
<!-- runtest:{Return a numeric version identifier} -->
|
||||
|
||||
```js
|
||||
lzma.versionNumber() // => 50020012
|
||||
```
|
||||
|
||||
<a name="api-parse-indexes"></a>
|
||||
|
||||
### .xz file metadata
|
||||
|
||||
<a name="api-isxz"></a>
|
||||
|
||||
#### `lzma.isXZ()`
|
||||
|
||||
* `lzma.isXZ(input)`
|
||||
|
||||
Tells whether an input buffer is an XZ file (`.xz`, LZMA2 format) using the
|
||||
file format’s magic number. This is not a complete test, i.e. the data
|
||||
following the file header may still be invalid in some way.
|
||||
|
||||
Param | Type | Description
|
||||
------------ | ---------------- | --------------
|
||||
`input` | string / Buffer | Any string or Buffer (integer arrays accepted).
|
||||
|
||||
Example usage:
|
||||
<!-- runtest:{.isXZ() checks some strings correctly} -->
|
||||
|
||||
```js
|
||||
lzma.isXZ(fs.readFileSync('test/hamlet.txt.xz')); // => true
|
||||
lzma.isXZ(fs.readFileSync('test/hamlet.txt.lzma')); // => false
|
||||
lzma.isXZ('Banana'); // => false
|
||||
```
|
||||
|
||||
(The magic number of XZ files is hex `fd 37 7a 58 5a 00` at position 0.)
|
||||
|
||||
<a name="api-parse-file-index"></a>
|
||||
|
||||
#### `lzma.parseFileIndex()`
|
||||
|
||||
* `lzma.parseFileIndex(options[, callback])`
|
||||
|
||||
Read `.xz` file metadata.
|
||||
|
||||
`options.fileSize` needs to be an integer indicating the size of the file
|
||||
being inspected, e.g. obtained by `fs.stat()`.
|
||||
|
||||
`options.read(count, offset, cb)` must be a function that reads `count` bytes
|
||||
from the underlying file, starting at position `offset`. If that is not
|
||||
possible, e.g. because the file does not have enough bytes, the file should
|
||||
be considered corrupt. On success, `cb` should be called with a `Buffer`
|
||||
containing the read data. `cb` can be invoked as `cb(err, buffer)`, in which
|
||||
case `err` will be passed along to the original `callback` argument when set.
|
||||
|
||||
`callback` will be called with `err` and `info` as its arguments.
|
||||
|
||||
If no `callback` is provided, `options.read()` must work synchronously and
|
||||
the file info will be returned from `lzma.parseFileIndex()`.
|
||||
|
||||
Example usage:
|
||||
<!-- runtest:{Read .xz file metadata} -->
|
||||
|
||||
```js
|
||||
fs.readFile('test/hamlet.txt.xz', function(err, content) {
|
||||
// handle error
|
||||
|
||||
lzma.parseFileIndex({
|
||||
fileSize: content.length,
|
||||
read: function(count, offset, cb) {
|
||||
cb(content.slice(offset, offset + count));
|
||||
}
|
||||
}, function(err, info) {
|
||||
// handle error
|
||||
|
||||
// do something with e.g. info.uncompressedSize
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
<a name="api-parse-file-index-fd"></a>
|
||||
|
||||
#### `lzma.parseFileIndexFD()`
|
||||
|
||||
* `lzma.parseFileIndexFD(fd, callback)`
|
||||
|
||||
Read `.xz` metadata from a file descriptor.
|
||||
|
||||
This is like [`parseFileIndex()`](#api-parse-file-index), but lets you
|
||||
pass an file descriptor in `fd`. The file will be inspected using
|
||||
`fs.stat()` and `fs.read()`. The file descriptor will not be opened or closed
|
||||
by this call.
|
||||
|
||||
Example usage:
|
||||
<!-- runtest:{Read .xz file metadata from a file descriptor} -->
|
||||
|
||||
```js
|
||||
fs.open('test/hamlet.txt.xz', 'r', function(err, fd) {
|
||||
// handle error
|
||||
|
||||
lzma.parseFileIndexFD(fd, function(err, info) {
|
||||
// handle error
|
||||
|
||||
// do something with e.g. info.uncompressedSize
|
||||
|
||||
fs.close(fd, function(err) { /* handle error */ });
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
This package includes the native C library, so there is no need to install it separately.
|
||||
|
||||
## Licensing
|
||||
|
||||
The original C library package contains code under various licenses,
|
||||
with its core (liblzma) being public domain. See its contents for details.
|
||||
This wrapper is licensed under the MIT License.
|
||||
|
||||
## Related projects
|
||||
|
||||
Other implementations of the LZMA algorithms for node.js and/or web clients include:
|
||||
|
||||
* [lzma-purejs](https://github.com/cscott/lzma-purejs)
|
||||
* [LZMA-JS](https://github.com/nmrugg/LZMA-JS)
|
||||
* [node-xz](https://github.com/robey/node-xz) (native)
|
||||
* [node-liblzma](https://github.com/oorabona/node-liblzma) (native)
|
||||
|
||||
Note that LZMA has been designed to have much faster decompression than
|
||||
compression, which is something you may want to take into account when
|
||||
choosing an compression algorithm for large files. Almost always, LZMA achieves
|
||||
higher compression ratios than other algorithms, though.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Initial development of this project was financially supported by [Tradity](https://tradity.de/).
|
||||
|
||||
[node-xz]: https://github.com/robey/node-xz
|
||||
[LZMA-JS]: https://github.com/nmrugg/LZMA-JS
|
||||
[Q]: https://github.com/kriskowal/q
|
||||
[duplex]: https://nodejs.org/api/stream.html#stream_class_stream_duplex
|
||||
[xz-manpage]: https://www.freebsd.org/cgi/man.cgi?query=xz&sektion=1&manpath=FreeBSD+8.3-RELEASE
|
||||
84
electron/node_modules/lzma-native/bin/lzmajs
generated
vendored
Executable file
84
electron/node_modules/lzma-native/bin/lzmajs
generated
vendored
Executable file
|
|
@ -0,0 +1,84 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var program = require('commander');
|
||||
var lzma = require('../');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
var argv = process.argv.slice(2);
|
||||
var positionalArgs = [];
|
||||
|
||||
var level = undefined;
|
||||
var threads = undefined;
|
||||
var compress = true;
|
||||
|
||||
for (var i = 0; i < argv.length; ++i) {
|
||||
if (argv[i][0] !== '-') {
|
||||
positionalArgs.push(argv[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isNaN(+argv[i][1])) {
|
||||
level = +argv[i][1];
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (argv[i]) {
|
||||
case '-d':
|
||||
case '--decompress':
|
||||
compress = false;
|
||||
break;
|
||||
case '-z':
|
||||
case '--compress':
|
||||
compress = true;
|
||||
break;
|
||||
case '-t':
|
||||
case '--threads':
|
||||
if (!isNaN(+argv[i+1]))
|
||||
threads = +argv[++i];
|
||||
else
|
||||
threads = 0;
|
||||
break;
|
||||
default:
|
||||
case '-h':
|
||||
case '--help':
|
||||
usage();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function usage() {
|
||||
process.stdout.write('Usage: \n' +
|
||||
' ' + path.basename(process.argv[1]) +
|
||||
' [-d|-z] [-t num] [-1|...|-9] [infile] [outfile]\n' +
|
||||
'\n' +
|
||||
' -d, --decompress Decompress infile to outfile\n' +
|
||||
' -z, --compress Compress infile to outfile\n' +
|
||||
' -t n, --threads n Use n threads for compressing\n' +
|
||||
' -1, ..., -9 Specifiy compression level\n' +
|
||||
' -h, --help Display this text\n' +
|
||||
'\n' +
|
||||
' <infile> defaults to stdin and <outfile> defaults to stdout.\n');
|
||||
return;
|
||||
}
|
||||
|
||||
var input = process.stdin, output = process.stdout;
|
||||
|
||||
if (positionalArgs.length > 0) {
|
||||
input = fs.createReadStream(positionalArgs.shift());
|
||||
}
|
||||
|
||||
if (positionalArgs.length > 0) {
|
||||
output = fs.createWriteStream(positionalArgs.shift());
|
||||
}
|
||||
|
||||
var opts = {
|
||||
preset: level || lzma.PRESET_DEFAULT,
|
||||
threads: threads,
|
||||
};
|
||||
|
||||
var encoder = lzma.createStream(compress ? 'easyEncoder' : 'autoDecoder', opts);
|
||||
|
||||
input.pipe(encoder).pipe(output);
|
||||
|
||||
99
electron/node_modules/lzma-native/binding.gyp
generated
vendored
Normal file
99
electron/node_modules/lzma-native/binding.gyp
generated
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
{
|
||||
"variables": {
|
||||
"dlldir%": "<(module_root_dir)/build/Release"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "lzma_native",
|
||||
"sources": [
|
||||
"src/util.cpp",
|
||||
"src/liblzma-functions.cpp",
|
||||
"src/filter-array.cpp",
|
||||
"src/lzma-stream.cpp",
|
||||
"src/module.cpp",
|
||||
"src/mt-options.cpp",
|
||||
"src/index-parser.cpp"
|
||||
],
|
||||
'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
|
||||
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")", "liblzma"],
|
||||
'cflags!': [ '-fno-exceptions' ],
|
||||
'cflags_cc!': [ '-fno-exceptions' ],
|
||||
'xcode_settings': {
|
||||
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
|
||||
'CLANG_CXX_LIBRARY': 'libc++',
|
||||
'MACOSX_DEPLOYMENT_TARGET': '10.7',
|
||||
},
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
|
||||
},
|
||||
"conditions" : [
|
||||
[ 'OS!="win"' , {
|
||||
"include_dirs" : [ "<(module_root_dir)/build/liblzma/build/include" ],
|
||||
"libraries" : [ "<(module_root_dir)/build/liblzma/build/lib/liblzma.a" ],
|
||||
"cflags": ['-O3 -std=c++11']
|
||||
}, {
|
||||
"include_dirs" : [ "<(module_root_dir)\\deps\\include" ],
|
||||
"link_settings": {
|
||||
"libraries" : [ "-llzma" ],
|
||||
"conditions": [
|
||||
[ 'target_arch=="x64"', {
|
||||
"library_dirs" : [ "<(module_root_dir)\\deps\\bin_x86-64" ]
|
||||
}, {
|
||||
"library_dirs" : [ "<(module_root_dir)\\deps\\bin_i686" ]
|
||||
} ]
|
||||
]
|
||||
}
|
||||
} ],
|
||||
],
|
||||
},
|
||||
{
|
||||
"target_name" : "liblzma",
|
||||
"type" : "none",
|
||||
"conditions" : [
|
||||
[ 'OS!="win"' , {
|
||||
"actions" : [
|
||||
{
|
||||
"action_name" : "build",
|
||||
# a hack to run deps/xz-5.2.3 ./configure during `node-gyp configure`
|
||||
'inputs': ['<!@(sh liblzma-config.sh "<(module_root_dir)/build" "<(module_root_dir)/deps/xz-5.2.3.tar.bz2")'],
|
||||
'outputs': [''],
|
||||
'action': [
|
||||
'sh', '<(module_root_dir)/liblzma-build.sh', '<(module_root_dir)/build'
|
||||
]
|
||||
}
|
||||
]
|
||||
}, {
|
||||
"conditions": [
|
||||
[ 'target_arch=="x64"', {
|
||||
'variables': {
|
||||
"arch_lib_path" : 'bin_x86-64',
|
||||
"arch_lib_code" : 'x64'
|
||||
}
|
||||
}, {
|
||||
'variables': {
|
||||
"arch_lib_path" : 'bin_i686',
|
||||
"arch_lib_code" : 'ix86'
|
||||
}
|
||||
} ]
|
||||
],
|
||||
"actions" : [
|
||||
{
|
||||
"msvs_quote_cmd": 0,
|
||||
"action_name" : "build",
|
||||
'inputs': ['deps/doc/liblzma.def'],
|
||||
'outputs': [''],
|
||||
'action': ['lib.exe -def:"<(module_root_dir)/deps/doc/liblzma.def" -out:"<(module_root_dir)/deps/<(arch_lib_path)/lzma.lib" -machine:<(arch_lib_code)']
|
||||
},
|
||||
{
|
||||
"msvs_quote_cmd": 0,
|
||||
"action_name" : "deploy",
|
||||
'inputs': ['deps/<(arch_lib_path)/liblzma.dll'],
|
||||
'outputs': ['<(dlldir)/liblzma.dll'],
|
||||
'action': ['mkdir <(dlldir) > nul 2>&1 & copy "<(module_root_dir)/deps/<(arch_lib_path)/liblzma.dll" <(dlldir)/liblzma.dll']
|
||||
}
|
||||
]
|
||||
} ],
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
electron/node_modules/lzma-native/deps/bin_i686/liblzma.dll
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/deps/bin_i686/liblzma.dll
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/deps/bin_x86-64/liblzma.dll
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/deps/bin_x86-64/liblzma.dll
generated
vendored
Normal file
Binary file not shown.
99
electron/node_modules/lzma-native/deps/doc/liblzma.def
generated
vendored
Normal file
99
electron/node_modules/lzma-native/deps/doc/liblzma.def
generated
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
EXPORTS
|
||||
lzma_alone_decoder
|
||||
lzma_alone_encoder
|
||||
lzma_auto_decoder
|
||||
lzma_block_buffer_bound
|
||||
lzma_block_buffer_decode
|
||||
lzma_block_buffer_encode
|
||||
lzma_block_compressed_size
|
||||
lzma_block_decoder
|
||||
lzma_block_encoder
|
||||
lzma_block_header_decode
|
||||
lzma_block_header_encode
|
||||
lzma_block_header_size
|
||||
lzma_block_total_size
|
||||
lzma_block_uncomp_encode
|
||||
lzma_block_unpadded_size
|
||||
lzma_check_is_supported
|
||||
lzma_check_size
|
||||
lzma_code
|
||||
lzma_cputhreads
|
||||
lzma_crc32
|
||||
lzma_crc64
|
||||
lzma_easy_buffer_encode
|
||||
lzma_easy_decoder_memusage
|
||||
lzma_easy_encoder
|
||||
lzma_easy_encoder_memusage
|
||||
lzma_end
|
||||
lzma_filter_decoder_is_supported
|
||||
lzma_filter_encoder_is_supported
|
||||
lzma_filter_flags_decode
|
||||
lzma_filter_flags_encode
|
||||
lzma_filter_flags_size
|
||||
lzma_filters_copy
|
||||
lzma_filters_update
|
||||
lzma_get_check
|
||||
lzma_get_progress
|
||||
lzma_index_append
|
||||
lzma_index_block_count
|
||||
lzma_index_buffer_decode
|
||||
lzma_index_buffer_encode
|
||||
lzma_index_cat
|
||||
lzma_index_checks
|
||||
lzma_index_decoder
|
||||
lzma_index_dup
|
||||
lzma_index_encoder
|
||||
lzma_index_end
|
||||
lzma_index_file_size
|
||||
lzma_index_hash_append
|
||||
lzma_index_hash_decode
|
||||
lzma_index_hash_end
|
||||
lzma_index_hash_init
|
||||
lzma_index_hash_size
|
||||
lzma_index_init
|
||||
lzma_index_iter_init
|
||||
lzma_index_iter_locate
|
||||
lzma_index_iter_next
|
||||
lzma_index_iter_rewind
|
||||
lzma_index_memusage
|
||||
lzma_index_memused
|
||||
lzma_index_size
|
||||
lzma_index_stream_count
|
||||
lzma_index_stream_flags
|
||||
lzma_index_stream_padding
|
||||
lzma_index_stream_size
|
||||
lzma_index_total_size
|
||||
lzma_index_uncompressed_size
|
||||
lzma_lzma_preset
|
||||
lzma_memlimit_get
|
||||
lzma_memlimit_set
|
||||
lzma_memusage
|
||||
lzma_mf_is_supported
|
||||
lzma_mode_is_supported
|
||||
lzma_physmem
|
||||
lzma_properties_decode
|
||||
lzma_properties_encode
|
||||
lzma_properties_size
|
||||
lzma_raw_buffer_decode
|
||||
lzma_raw_buffer_encode
|
||||
lzma_raw_decoder
|
||||
lzma_raw_decoder_memusage
|
||||
lzma_raw_encoder
|
||||
lzma_raw_encoder_memusage
|
||||
lzma_stream_buffer_bound
|
||||
lzma_stream_buffer_decode
|
||||
lzma_stream_buffer_encode
|
||||
lzma_stream_decoder
|
||||
lzma_stream_encoder
|
||||
lzma_stream_encoder_mt
|
||||
lzma_stream_encoder_mt_memusage
|
||||
lzma_stream_flags_compare
|
||||
lzma_stream_footer_decode
|
||||
lzma_stream_footer_encode
|
||||
lzma_stream_header_decode
|
||||
lzma_stream_header_encode
|
||||
lzma_version_number
|
||||
lzma_version_string
|
||||
lzma_vli_decode
|
||||
lzma_vli_encode
|
||||
lzma_vli_size
|
||||
321
electron/node_modules/lzma-native/deps/include/lzma.h
generated
vendored
Normal file
321
electron/node_modules/lzma-native/deps/include/lzma.h
generated
vendored
Normal file
|
|
@ -0,0 +1,321 @@
|
|||
/**
|
||||
* \file api/lzma.h
|
||||
* \brief The public API of liblzma data compression library
|
||||
*
|
||||
* liblzma is a public domain general-purpose data compression library with
|
||||
* a zlib-like API. The native file format is .xz, but also the old .lzma
|
||||
* format and raw (no headers) streams are supported. Multiple compression
|
||||
* algorithms (filters) are supported. Currently LZMA2 is the primary filter.
|
||||
*
|
||||
* liblzma is part of XZ Utils <http://tukaani.org/xz/>. XZ Utils includes
|
||||
* a gzip-like command line tool named xz and some other tools. XZ Utils
|
||||
* is developed and maintained by Lasse Collin.
|
||||
*
|
||||
* Major parts of liblzma are based on Igor Pavlov's public domain LZMA SDK
|
||||
* <http://7-zip.org/sdk.html>.
|
||||
*
|
||||
* The SHA-256 implementation is based on the public domain code found from
|
||||
* 7-Zip <http://7-zip.org/>, which has a modified version of the public
|
||||
* domain SHA-256 code found from Crypto++ <http://www.cryptopp.com/>.
|
||||
* The SHA-256 code in Crypto++ was written by Kevin Springle and Wei Dai.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H
|
||||
#define LZMA_H
|
||||
|
||||
/*****************************
|
||||
* Required standard headers *
|
||||
*****************************/
|
||||
|
||||
/*
|
||||
* liblzma API headers need some standard types and macros. To allow
|
||||
* including lzma.h without requiring the application to include other
|
||||
* headers first, lzma.h includes the required standard headers unless
|
||||
* they already seem to be included already or if LZMA_MANUAL_HEADERS
|
||||
* has been defined.
|
||||
*
|
||||
* Here's what types and macros are needed and from which headers:
|
||||
* - stddef.h: size_t, NULL
|
||||
* - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n),
|
||||
* UINT32_MAX, UINT64_MAX
|
||||
*
|
||||
* However, inttypes.h is a little more portable than stdint.h, although
|
||||
* inttypes.h declares some unneeded things compared to plain stdint.h.
|
||||
*
|
||||
* The hacks below aren't perfect, specifically they assume that inttypes.h
|
||||
* exists and that it typedefs at least uint8_t, uint32_t, and uint64_t,
|
||||
* and that, in case of incomplete inttypes.h, unsigned int is 32-bit.
|
||||
* If the application already takes care of setting up all the types and
|
||||
* macros properly (for example by using gnulib's stdint.h or inttypes.h),
|
||||
* we try to detect that the macros are already defined and don't include
|
||||
* inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to
|
||||
* force this file to never include any system headers.
|
||||
*
|
||||
* Some could argue that liblzma API should provide all the required types,
|
||||
* for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was
|
||||
* seen as an unnecessary mess, since most systems already provide all the
|
||||
* necessary types and macros in the standard headers.
|
||||
*
|
||||
* Note that liblzma API still has lzma_bool, because using stdbool.h would
|
||||
* break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't
|
||||
* necessarily the same as sizeof(bool) in C++.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_MANUAL_HEADERS
|
||||
/*
|
||||
* I suppose this works portably also in C++. Note that in C++,
|
||||
* we need to get size_t into the global namespace.
|
||||
*/
|
||||
# include <stddef.h>
|
||||
|
||||
/*
|
||||
* Skip inttypes.h if we already have all the required macros. If we
|
||||
* have the macros, we assume that we have the matching typedefs too.
|
||||
*/
|
||||
# if !defined(UINT32_C) || !defined(UINT64_C) \
|
||||
|| !defined(UINT32_MAX) || !defined(UINT64_MAX)
|
||||
/*
|
||||
* MSVC versions older than 2013 have no C99 support, and
|
||||
* thus they cannot be used to compile liblzma. Using an
|
||||
* existing liblzma.dll with old MSVC can work though(*),
|
||||
* but we need to define the required standard integer
|
||||
* types here in a MSVC-specific way.
|
||||
*
|
||||
* (*) If you do this, the existing liblzma.dll probably uses
|
||||
* a different runtime library than your MSVC-built
|
||||
* application. Mixing runtimes is generally bad, but
|
||||
* in this case it should work as long as you avoid
|
||||
* the few rarely-needed liblzma functions that allocate
|
||||
* memory and expect the caller to free it using free().
|
||||
*/
|
||||
# if defined(_WIN32) && defined(_MSC_VER) && _MSC_VER < 1800
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
# else
|
||||
/* Use the standard inttypes.h. */
|
||||
# ifdef __cplusplus
|
||||
/*
|
||||
* C99 sections 7.18.2 and 7.18.4 specify
|
||||
* that C++ implementations define the limit
|
||||
* and constant macros only if specifically
|
||||
* requested. Note that if you want the
|
||||
* format macros (PRIu64 etc.) too, you need
|
||||
* to define __STDC_FORMAT_MACROS before
|
||||
* including lzma.h, since re-including
|
||||
* inttypes.h with __STDC_FORMAT_MACROS
|
||||
* defined doesn't necessarily work.
|
||||
*/
|
||||
# ifndef __STDC_LIMIT_MACROS
|
||||
# define __STDC_LIMIT_MACROS 1
|
||||
# endif
|
||||
# ifndef __STDC_CONSTANT_MACROS
|
||||
# define __STDC_CONSTANT_MACROS 1
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# include <inttypes.h>
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Some old systems have only the typedefs in inttypes.h, and
|
||||
* lack all the macros. For those systems, we need a few more
|
||||
* hacks. We assume that unsigned int is 32-bit and unsigned
|
||||
* long is either 32-bit or 64-bit. If these hacks aren't
|
||||
* enough, the application has to setup the types manually
|
||||
* before including lzma.h.
|
||||
*/
|
||||
# ifndef UINT32_C
|
||||
# if defined(_WIN32) && defined(_MSC_VER)
|
||||
# define UINT32_C(n) n ## UI32
|
||||
# else
|
||||
# define UINT32_C(n) n ## U
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef UINT64_C
|
||||
# if defined(_WIN32) && defined(_MSC_VER)
|
||||
# define UINT64_C(n) n ## UI64
|
||||
# else
|
||||
/* Get ULONG_MAX. */
|
||||
# include <limits.h>
|
||||
# if ULONG_MAX == 4294967295UL
|
||||
# define UINT64_C(n) n ## ULL
|
||||
# else
|
||||
# define UINT64_C(n) n ## UL
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef UINT32_MAX
|
||||
# define UINT32_MAX (UINT32_C(4294967295))
|
||||
# endif
|
||||
|
||||
# ifndef UINT64_MAX
|
||||
# define UINT64_MAX (UINT64_C(18446744073709551615))
|
||||
# endif
|
||||
# endif
|
||||
#endif /* ifdef LZMA_MANUAL_HEADERS */
|
||||
|
||||
|
||||
/******************
|
||||
* LZMA_API macro *
|
||||
******************/
|
||||
|
||||
/*
|
||||
* Some systems require that the functions and function pointers are
|
||||
* declared specially in the headers. LZMA_API_IMPORT is for importing
|
||||
* symbols and LZMA_API_CALL is to specify the calling convention.
|
||||
*
|
||||
* By default it is assumed that the application will link dynamically
|
||||
* against liblzma. #define LZMA_API_STATIC in your application if you
|
||||
* want to link against static liblzma. If you don't care about portability
|
||||
* to operating systems like Windows, or at least don't care about linking
|
||||
* against static liblzma on them, don't worry about LZMA_API_STATIC. That
|
||||
* is, most developers will never need to use LZMA_API_STATIC.
|
||||
*
|
||||
* The GCC variants are a special case on Windows (Cygwin and MinGW).
|
||||
* We rely on GCC doing the right thing with its auto-import feature,
|
||||
* and thus don't use __declspec(dllimport). This way developers don't
|
||||
* need to worry about LZMA_API_STATIC. Also the calling convention is
|
||||
* omitted on Cygwin but not on MinGW.
|
||||
*/
|
||||
#ifndef LZMA_API_IMPORT
|
||||
# if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__)
|
||||
# define LZMA_API_IMPORT __declspec(dllimport)
|
||||
# else
|
||||
# define LZMA_API_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef LZMA_API_CALL
|
||||
# if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
# define LZMA_API_CALL __cdecl
|
||||
# else
|
||||
# define LZMA_API_CALL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef LZMA_API
|
||||
# define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL
|
||||
#endif
|
||||
|
||||
|
||||
/***********
|
||||
* nothrow *
|
||||
***********/
|
||||
|
||||
/*
|
||||
* None of the functions in liblzma may throw an exception. Even
|
||||
* the functions that use callback functions won't throw exceptions,
|
||||
* because liblzma would break if a callback function threw an exception.
|
||||
*/
|
||||
#ifndef lzma_nothrow
|
||||
# if defined(__cplusplus)
|
||||
# define lzma_nothrow throw()
|
||||
# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
|
||||
# define lzma_nothrow __attribute__((__nothrow__))
|
||||
# else
|
||||
# define lzma_nothrow
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/********************
|
||||
* GNU C extensions *
|
||||
********************/
|
||||
|
||||
/*
|
||||
* GNU C extensions are used conditionally in the public API. It doesn't
|
||||
* break anything if these are sometimes enabled and sometimes not, only
|
||||
* affects warnings and optimizations.
|
||||
*/
|
||||
#if __GNUC__ >= 3
|
||||
# ifndef lzma_attribute
|
||||
# define lzma_attribute(attr) __attribute__(attr)
|
||||
# endif
|
||||
|
||||
/* warn_unused_result was added in GCC 3.4. */
|
||||
# ifndef lzma_attr_warn_unused_result
|
||||
# if __GNUC__ == 3 && __GNUC_MINOR__ < 4
|
||||
# define lzma_attr_warn_unused_result
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#else
|
||||
# ifndef lzma_attribute
|
||||
# define lzma_attribute(attr)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef lzma_attr_pure
|
||||
# define lzma_attr_pure lzma_attribute((__pure__))
|
||||
#endif
|
||||
|
||||
#ifndef lzma_attr_const
|
||||
# define lzma_attr_const lzma_attribute((__const__))
|
||||
#endif
|
||||
|
||||
#ifndef lzma_attr_warn_unused_result
|
||||
# define lzma_attr_warn_unused_result \
|
||||
lzma_attribute((__warn_unused_result__))
|
||||
#endif
|
||||
|
||||
|
||||
/**************
|
||||
* Subheaders *
|
||||
**************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Subheaders check that this is defined. It is to prevent including
|
||||
* them directly from applications.
|
||||
*/
|
||||
#define LZMA_H_INTERNAL 1
|
||||
|
||||
/* Basic features */
|
||||
#include "lzma/version.h"
|
||||
#include "lzma/base.h"
|
||||
#include "lzma/vli.h"
|
||||
#include "lzma/check.h"
|
||||
|
||||
/* Filters */
|
||||
#include "lzma/filter.h"
|
||||
#include "lzma/bcj.h"
|
||||
#include "lzma/delta.h"
|
||||
#include "lzma/lzma12.h"
|
||||
|
||||
/* Container formats */
|
||||
#include "lzma/container.h"
|
||||
|
||||
/* Advanced features */
|
||||
#include "lzma/stream_flags.h"
|
||||
#include "lzma/block.h"
|
||||
#include "lzma/index.h"
|
||||
#include "lzma/index_hash.h"
|
||||
|
||||
/* Hardware information */
|
||||
#include "lzma/hardware.h"
|
||||
|
||||
/*
|
||||
* All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications
|
||||
* re-including the subheaders.
|
||||
*/
|
||||
#undef LZMA_H_INTERNAL
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ifndef LZMA_H */
|
||||
654
electron/node_modules/lzma-native/deps/include/lzma/base.h
generated
vendored
Normal file
654
electron/node_modules/lzma-native/deps/include/lzma/base.h
generated
vendored
Normal file
|
|
@ -0,0 +1,654 @@
|
|||
/**
|
||||
* \file lzma/base.h
|
||||
* \brief Data types and functions used in many places in liblzma API
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Boolean
|
||||
*
|
||||
* This is here because C89 doesn't have stdbool.h. To set a value for
|
||||
* variables having type lzma_bool, you can use
|
||||
* - C99's `true' and `false' from stdbool.h;
|
||||
* - C++'s internal `true' and `false'; or
|
||||
* - integers one (true) and zero (false).
|
||||
*/
|
||||
typedef unsigned char lzma_bool;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Type of reserved enumeration variable in structures
|
||||
*
|
||||
* To avoid breaking library ABI when new features are added, several
|
||||
* structures contain extra variables that may be used in future. Since
|
||||
* sizeof(enum) can be different than sizeof(int), and sizeof(enum) may
|
||||
* even vary depending on the range of enumeration constants, we specify
|
||||
* a separate type to be used for reserved enumeration variables. All
|
||||
* enumeration constants in liblzma API will be non-negative and less
|
||||
* than 128, which should guarantee that the ABI won't break even when
|
||||
* new constants are added to existing enumerations.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_RESERVED_ENUM = 0
|
||||
} lzma_reserved_enum;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Return values used by several functions in liblzma
|
||||
*
|
||||
* Check the descriptions of specific functions to find out which return
|
||||
* values they can return. With some functions the return values may have
|
||||
* more specific meanings than described here; those differences are
|
||||
* described per-function basis.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_OK = 0,
|
||||
/**<
|
||||
* \brief Operation completed successfully
|
||||
*/
|
||||
|
||||
LZMA_STREAM_END = 1,
|
||||
/**<
|
||||
* \brief End of stream was reached
|
||||
*
|
||||
* In encoder, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or
|
||||
* LZMA_FINISH was finished. In decoder, this indicates
|
||||
* that all the data was successfully decoded.
|
||||
*
|
||||
* In all cases, when LZMA_STREAM_END is returned, the last
|
||||
* output bytes should be picked from strm->next_out.
|
||||
*/
|
||||
|
||||
LZMA_NO_CHECK = 2,
|
||||
/**<
|
||||
* \brief Input stream has no integrity check
|
||||
*
|
||||
* This return value can be returned only if the
|
||||
* LZMA_TELL_NO_CHECK flag was used when initializing
|
||||
* the decoder. LZMA_NO_CHECK is just a warning, and
|
||||
* the decoding can be continued normally.
|
||||
*
|
||||
* It is possible to call lzma_get_check() immediately after
|
||||
* lzma_code has returned LZMA_NO_CHECK. The result will
|
||||
* naturally be LZMA_CHECK_NONE, but the possibility to call
|
||||
* lzma_get_check() may be convenient in some applications.
|
||||
*/
|
||||
|
||||
LZMA_UNSUPPORTED_CHECK = 3,
|
||||
/**<
|
||||
* \brief Cannot calculate the integrity check
|
||||
*
|
||||
* The usage of this return value is different in encoders
|
||||
* and decoders.
|
||||
*
|
||||
* Encoders can return this value only from the initialization
|
||||
* function. If initialization fails with this value, the
|
||||
* encoding cannot be done, because there's no way to produce
|
||||
* output with the correct integrity check.
|
||||
*
|
||||
* Decoders can return this value only from lzma_code() and
|
||||
* only if the LZMA_TELL_UNSUPPORTED_CHECK flag was used when
|
||||
* initializing the decoder. The decoding can still be
|
||||
* continued normally even if the check type is unsupported,
|
||||
* but naturally the check will not be validated, and possible
|
||||
* errors may go undetected.
|
||||
*
|
||||
* With decoder, it is possible to call lzma_get_check()
|
||||
* immediately after lzma_code() has returned
|
||||
* LZMA_UNSUPPORTED_CHECK. This way it is possible to find
|
||||
* out what the unsupported Check ID was.
|
||||
*/
|
||||
|
||||
LZMA_GET_CHECK = 4,
|
||||
/**<
|
||||
* \brief Integrity check type is now available
|
||||
*
|
||||
* This value can be returned only by the lzma_code() function
|
||||
* and only if the decoder was initialized with the
|
||||
* LZMA_TELL_ANY_CHECK flag. LZMA_GET_CHECK tells the
|
||||
* application that it may now call lzma_get_check() to find
|
||||
* out the Check ID. This can be used, for example, to
|
||||
* implement a decoder that accepts only files that have
|
||||
* strong enough integrity check.
|
||||
*/
|
||||
|
||||
LZMA_MEM_ERROR = 5,
|
||||
/**<
|
||||
* \brief Cannot allocate memory
|
||||
*
|
||||
* Memory allocation failed, or the size of the allocation
|
||||
* would be greater than SIZE_MAX.
|
||||
*
|
||||
* Due to internal implementation reasons, the coding cannot
|
||||
* be continued even if more memory were made available after
|
||||
* LZMA_MEM_ERROR.
|
||||
*/
|
||||
|
||||
LZMA_MEMLIMIT_ERROR = 6,
|
||||
/**
|
||||
* \brief Memory usage limit was reached
|
||||
*
|
||||
* Decoder would need more memory than allowed by the
|
||||
* specified memory usage limit. To continue decoding,
|
||||
* the memory usage limit has to be increased with
|
||||
* lzma_memlimit_set().
|
||||
*/
|
||||
|
||||
LZMA_FORMAT_ERROR = 7,
|
||||
/**<
|
||||
* \brief File format not recognized
|
||||
*
|
||||
* The decoder did not recognize the input as supported file
|
||||
* format. This error can occur, for example, when trying to
|
||||
* decode .lzma format file with lzma_stream_decoder,
|
||||
* because lzma_stream_decoder accepts only the .xz format.
|
||||
*/
|
||||
|
||||
LZMA_OPTIONS_ERROR = 8,
|
||||
/**<
|
||||
* \brief Invalid or unsupported options
|
||||
*
|
||||
* Invalid or unsupported options, for example
|
||||
* - unsupported filter(s) or filter options; or
|
||||
* - reserved bits set in headers (decoder only).
|
||||
*
|
||||
* Rebuilding liblzma with more features enabled, or
|
||||
* upgrading to a newer version of liblzma may help.
|
||||
*/
|
||||
|
||||
LZMA_DATA_ERROR = 9,
|
||||
/**<
|
||||
* \brief Data is corrupt
|
||||
*
|
||||
* The usage of this return value is different in encoders
|
||||
* and decoders. In both encoder and decoder, the coding
|
||||
* cannot continue after this error.
|
||||
*
|
||||
* Encoders return this if size limits of the target file
|
||||
* format would be exceeded. These limits are huge, thus
|
||||
* getting this error from an encoder is mostly theoretical.
|
||||
* For example, the maximum compressed and uncompressed
|
||||
* size of a .xz Stream is roughly 8 EiB (2^63 bytes).
|
||||
*
|
||||
* Decoders return this error if the input data is corrupt.
|
||||
* This can mean, for example, invalid CRC32 in headers
|
||||
* or invalid check of uncompressed data.
|
||||
*/
|
||||
|
||||
LZMA_BUF_ERROR = 10,
|
||||
/**<
|
||||
* \brief No progress is possible
|
||||
*
|
||||
* This error code is returned when the coder cannot consume
|
||||
* any new input and produce any new output. The most common
|
||||
* reason for this error is that the input stream being
|
||||
* decoded is truncated or corrupt.
|
||||
*
|
||||
* This error is not fatal. Coding can be continued normally
|
||||
* by providing more input and/or more output space, if
|
||||
* possible.
|
||||
*
|
||||
* Typically the first call to lzma_code() that can do no
|
||||
* progress returns LZMA_OK instead of LZMA_BUF_ERROR. Only
|
||||
* the second consecutive call doing no progress will return
|
||||
* LZMA_BUF_ERROR. This is intentional.
|
||||
*
|
||||
* With zlib, Z_BUF_ERROR may be returned even if the
|
||||
* application is doing nothing wrong, so apps will need
|
||||
* to handle Z_BUF_ERROR specially. The above hack
|
||||
* guarantees that liblzma never returns LZMA_BUF_ERROR
|
||||
* to properly written applications unless the input file
|
||||
* is truncated or corrupt. This should simplify the
|
||||
* applications a little.
|
||||
*/
|
||||
|
||||
LZMA_PROG_ERROR = 11,
|
||||
/**<
|
||||
* \brief Programming error
|
||||
*
|
||||
* This indicates that the arguments given to the function are
|
||||
* invalid or the internal state of the decoder is corrupt.
|
||||
* - Function arguments are invalid or the structures
|
||||
* pointed by the argument pointers are invalid
|
||||
* e.g. if strm->next_out has been set to NULL and
|
||||
* strm->avail_out > 0 when calling lzma_code().
|
||||
* - lzma_* functions have been called in wrong order
|
||||
* e.g. lzma_code() was called right after lzma_end().
|
||||
* - If errors occur randomly, the reason might be flaky
|
||||
* hardware.
|
||||
*
|
||||
* If you think that your code is correct, this error code
|
||||
* can be a sign of a bug in liblzma. See the documentation
|
||||
* how to report bugs.
|
||||
*/
|
||||
} lzma_ret;
|
||||
|
||||
|
||||
/**
|
||||
* \brief The `action' argument for lzma_code()
|
||||
*
|
||||
* After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, LZMA_FULL_BARRIER,
|
||||
* or LZMA_FINISH, the same `action' must is used until lzma_code() returns
|
||||
* LZMA_STREAM_END. Also, the amount of input (that is, strm->avail_in) must
|
||||
* not be modified by the application until lzma_code() returns
|
||||
* LZMA_STREAM_END. Changing the `action' or modifying the amount of input
|
||||
* will make lzma_code() return LZMA_PROG_ERROR.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_RUN = 0,
|
||||
/**<
|
||||
* \brief Continue coding
|
||||
*
|
||||
* Encoder: Encode as much input as possible. Some internal
|
||||
* buffering will probably be done (depends on the filter
|
||||
* chain in use), which causes latency: the input used won't
|
||||
* usually be decodeable from the output of the same
|
||||
* lzma_code() call.
|
||||
*
|
||||
* Decoder: Decode as much input as possible and produce as
|
||||
* much output as possible.
|
||||
*/
|
||||
|
||||
LZMA_SYNC_FLUSH = 1,
|
||||
/**<
|
||||
* \brief Make all the input available at output
|
||||
*
|
||||
* Normally the encoder introduces some latency.
|
||||
* LZMA_SYNC_FLUSH forces all the buffered data to be
|
||||
* available at output without resetting the internal
|
||||
* state of the encoder. This way it is possible to use
|
||||
* compressed stream for example for communication over
|
||||
* network.
|
||||
*
|
||||
* Only some filters support LZMA_SYNC_FLUSH. Trying to use
|
||||
* LZMA_SYNC_FLUSH with filters that don't support it will
|
||||
* make lzma_code() return LZMA_OPTIONS_ERROR. For example,
|
||||
* LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does.
|
||||
*
|
||||
* Using LZMA_SYNC_FLUSH very often can dramatically reduce
|
||||
* the compression ratio. With some filters (for example,
|
||||
* LZMA2), fine-tuning the compression options may help
|
||||
* mitigate this problem significantly (for example,
|
||||
* match finder with LZMA2).
|
||||
*
|
||||
* Decoders don't support LZMA_SYNC_FLUSH.
|
||||
*/
|
||||
|
||||
LZMA_FULL_FLUSH = 2,
|
||||
/**<
|
||||
* \brief Finish encoding of the current Block
|
||||
*
|
||||
* All the input data going to the current Block must have
|
||||
* been given to the encoder (the last bytes can still be
|
||||
* pending in *next_in). Call lzma_code() with LZMA_FULL_FLUSH
|
||||
* until it returns LZMA_STREAM_END. Then continue normally
|
||||
* with LZMA_RUN or finish the Stream with LZMA_FINISH.
|
||||
*
|
||||
* This action is currently supported only by Stream encoder
|
||||
* and easy encoder (which uses Stream encoder). If there is
|
||||
* no unfinished Block, no empty Block is created.
|
||||
*/
|
||||
|
||||
LZMA_FULL_BARRIER = 4,
|
||||
/**<
|
||||
* \brief Finish encoding of the current Block
|
||||
*
|
||||
* This is like LZMA_FULL_FLUSH except that this doesn't
|
||||
* necessarily wait until all the input has been made
|
||||
* available via the output buffer. That is, lzma_code()
|
||||
* might return LZMA_STREAM_END as soon as all the input
|
||||
* has been consumed (avail_in == 0).
|
||||
*
|
||||
* LZMA_FULL_BARRIER is useful with a threaded encoder if
|
||||
* one wants to split the .xz Stream into Blocks at specific
|
||||
* offsets but doesn't care if the output isn't flushed
|
||||
* immediately. Using LZMA_FULL_BARRIER allows keeping
|
||||
* the threads busy while LZMA_FULL_FLUSH would make
|
||||
* lzma_code() wait until all the threads have finished
|
||||
* until more data could be passed to the encoder.
|
||||
*
|
||||
* With a lzma_stream initialized with the single-threaded
|
||||
* lzma_stream_encoder() or lzma_easy_encoder(),
|
||||
* LZMA_FULL_BARRIER is an alias for LZMA_FULL_FLUSH.
|
||||
*/
|
||||
|
||||
LZMA_FINISH = 3
|
||||
/**<
|
||||
* \brief Finish the coding operation
|
||||
*
|
||||
* All the input data must have been given to the encoder
|
||||
* (the last bytes can still be pending in next_in).
|
||||
* Call lzma_code() with LZMA_FINISH until it returns
|
||||
* LZMA_STREAM_END. Once LZMA_FINISH has been used,
|
||||
* the amount of input must no longer be changed by
|
||||
* the application.
|
||||
*
|
||||
* When decoding, using LZMA_FINISH is optional unless the
|
||||
* LZMA_CONCATENATED flag was used when the decoder was
|
||||
* initialized. When LZMA_CONCATENATED was not used, the only
|
||||
* effect of LZMA_FINISH is that the amount of input must not
|
||||
* be changed just like in the encoder.
|
||||
*/
|
||||
} lzma_action;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Custom functions for memory handling
|
||||
*
|
||||
* A pointer to lzma_allocator may be passed via lzma_stream structure
|
||||
* to liblzma, and some advanced functions take a pointer to lzma_allocator
|
||||
* as a separate function argument. The library will use the functions
|
||||
* specified in lzma_allocator for memory handling instead of the default
|
||||
* malloc() and free(). C++ users should note that the custom memory
|
||||
* handling functions must not throw exceptions.
|
||||
*
|
||||
* Single-threaded mode only: liblzma doesn't make an internal copy of
|
||||
* lzma_allocator. Thus, it is OK to change these function pointers in
|
||||
* the middle of the coding process, but obviously it must be done
|
||||
* carefully to make sure that the replacement `free' can deallocate
|
||||
* memory allocated by the earlier `alloc' function(s).
|
||||
*
|
||||
* Multithreaded mode: liblzma might internally store pointers to the
|
||||
* lzma_allocator given via the lzma_stream structure. The application
|
||||
* must not change the allocator pointer in lzma_stream or the contents
|
||||
* of the pointed lzma_allocator structure until lzma_end() has been used
|
||||
* to free the memory associated with that lzma_stream. The allocation
|
||||
* functions might be called simultaneously from multiple threads, and
|
||||
* thus they must be thread safe.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Pointer to a custom memory allocation function
|
||||
*
|
||||
* If you don't want a custom allocator, but still want
|
||||
* custom free(), set this to NULL and liblzma will use
|
||||
* the standard malloc().
|
||||
*
|
||||
* \param opaque lzma_allocator.opaque (see below)
|
||||
* \param nmemb Number of elements like in calloc(). liblzma
|
||||
* will always set nmemb to 1, so it is safe to
|
||||
* ignore nmemb in a custom allocator if you like.
|
||||
* The nmemb argument exists only for
|
||||
* compatibility with zlib and libbzip2.
|
||||
* \param size Size of an element in bytes.
|
||||
* liblzma never sets this to zero.
|
||||
*
|
||||
* \return Pointer to the beginning of a memory block of
|
||||
* `size' bytes, or NULL if allocation fails
|
||||
* for some reason. When allocation fails, functions
|
||||
* of liblzma return LZMA_MEM_ERROR.
|
||||
*
|
||||
* The allocator should not waste time zeroing the allocated buffers.
|
||||
* This is not only about speed, but also memory usage, since the
|
||||
* operating system kernel doesn't necessarily allocate the requested
|
||||
* memory in physical memory until it is actually used. With small
|
||||
* input files, liblzma may actually need only a fraction of the
|
||||
* memory that it requested for allocation.
|
||||
*
|
||||
* \note LZMA_MEM_ERROR is also used when the size of the
|
||||
* allocation would be greater than SIZE_MAX. Thus,
|
||||
* don't assume that the custom allocator must have
|
||||
* returned NULL if some function from liblzma
|
||||
* returns LZMA_MEM_ERROR.
|
||||
*/
|
||||
void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size);
|
||||
|
||||
/**
|
||||
* \brief Pointer to a custom memory freeing function
|
||||
*
|
||||
* If you don't want a custom freeing function, but still
|
||||
* want a custom allocator, set this to NULL and liblzma
|
||||
* will use the standard free().
|
||||
*
|
||||
* \param opaque lzma_allocator.opaque (see below)
|
||||
* \param ptr Pointer returned by lzma_allocator.alloc(),
|
||||
* or when it is set to NULL, a pointer returned
|
||||
* by the standard malloc().
|
||||
*/
|
||||
void (LZMA_API_CALL *free)(void *opaque, void *ptr);
|
||||
|
||||
/**
|
||||
* \brief Pointer passed to .alloc() and .free()
|
||||
*
|
||||
* opaque is passed as the first argument to lzma_allocator.alloc()
|
||||
* and lzma_allocator.free(). This intended to ease implementing
|
||||
* custom memory allocation functions for use with liblzma.
|
||||
*
|
||||
* If you don't need this, you should set this to NULL.
|
||||
*/
|
||||
void *opaque;
|
||||
|
||||
} lzma_allocator;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Internal data structure
|
||||
*
|
||||
* The contents of this structure is not visible outside the library.
|
||||
*/
|
||||
typedef struct lzma_internal_s lzma_internal;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Passing data to and from liblzma
|
||||
*
|
||||
* The lzma_stream structure is used for
|
||||
* - passing pointers to input and output buffers to liblzma;
|
||||
* - defining custom memory hander functions; and
|
||||
* - holding a pointer to coder-specific internal data structures.
|
||||
*
|
||||
* Typical usage:
|
||||
*
|
||||
* - After allocating lzma_stream (on stack or with malloc()), it must be
|
||||
* initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details).
|
||||
*
|
||||
* - Initialize a coder to the lzma_stream, for example by using
|
||||
* lzma_easy_encoder() or lzma_auto_decoder(). Some notes:
|
||||
* - In contrast to zlib, strm->next_in and strm->next_out are
|
||||
* ignored by all initialization functions, thus it is safe
|
||||
* to not initialize them yet.
|
||||
* - The initialization functions always set strm->total_in and
|
||||
* strm->total_out to zero.
|
||||
* - If the initialization function fails, no memory is left allocated
|
||||
* that would require freeing with lzma_end() even if some memory was
|
||||
* associated with the lzma_stream structure when the initialization
|
||||
* function was called.
|
||||
*
|
||||
* - Use lzma_code() to do the actual work.
|
||||
*
|
||||
* - Once the coding has been finished, the existing lzma_stream can be
|
||||
* reused. It is OK to reuse lzma_stream with different initialization
|
||||
* function without calling lzma_end() first. Old allocations are
|
||||
* automatically freed.
|
||||
*
|
||||
* - Finally, use lzma_end() to free the allocated memory. lzma_end() never
|
||||
* frees the lzma_stream structure itself.
|
||||
*
|
||||
* Application may modify the values of total_in and total_out as it wants.
|
||||
* They are updated by liblzma to match the amount of data read and
|
||||
* written but aren't used for anything else except as a possible return
|
||||
* values from lzma_get_progress().
|
||||
*/
|
||||
typedef struct {
|
||||
const uint8_t *next_in; /**< Pointer to the next input byte. */
|
||||
size_t avail_in; /**< Number of available input bytes in next_in. */
|
||||
uint64_t total_in; /**< Total number of bytes read by liblzma. */
|
||||
|
||||
uint8_t *next_out; /**< Pointer to the next output position. */
|
||||
size_t avail_out; /**< Amount of free space in next_out. */
|
||||
uint64_t total_out; /**< Total number of bytes written by liblzma. */
|
||||
|
||||
/**
|
||||
* \brief Custom memory allocation functions
|
||||
*
|
||||
* In most cases this is NULL which makes liblzma use
|
||||
* the standard malloc() and free().
|
||||
*
|
||||
* \note In 5.0.x this is not a const pointer.
|
||||
*/
|
||||
const lzma_allocator *allocator;
|
||||
|
||||
/** Internal state is not visible to applications. */
|
||||
lzma_internal *internal;
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. Excluding the initialization of this structure,
|
||||
* you should not touch these, because the names of these variables
|
||||
* may change.
|
||||
*/
|
||||
void *reserved_ptr1;
|
||||
void *reserved_ptr2;
|
||||
void *reserved_ptr3;
|
||||
void *reserved_ptr4;
|
||||
uint64_t reserved_int1;
|
||||
uint64_t reserved_int2;
|
||||
size_t reserved_int3;
|
||||
size_t reserved_int4;
|
||||
lzma_reserved_enum reserved_enum1;
|
||||
lzma_reserved_enum reserved_enum2;
|
||||
|
||||
} lzma_stream;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialization for lzma_stream
|
||||
*
|
||||
* When you declare an instance of lzma_stream, you can immediately
|
||||
* initialize it so that initialization functions know that no memory
|
||||
* has been allocated yet:
|
||||
*
|
||||
* lzma_stream strm = LZMA_STREAM_INIT;
|
||||
*
|
||||
* If you need to initialize a dynamically allocated lzma_stream, you can use
|
||||
* memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this
|
||||
* violates the C standard since NULL may have different internal
|
||||
* representation than zero, but it should be portable enough in practice.
|
||||
* Anyway, for maximum portability, you can use something like this:
|
||||
*
|
||||
* lzma_stream tmp = LZMA_STREAM_INIT;
|
||||
* *strm = tmp;
|
||||
*/
|
||||
#define LZMA_STREAM_INIT \
|
||||
{ NULL, 0, 0, NULL, 0, 0, NULL, NULL, \
|
||||
NULL, NULL, NULL, NULL, 0, 0, 0, 0, \
|
||||
LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM }
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode or decode data
|
||||
*
|
||||
* Once the lzma_stream has been successfully initialized (e.g. with
|
||||
* lzma_stream_encoder()), the actual encoding or decoding is done
|
||||
* using this function. The application has to update strm->next_in,
|
||||
* strm->avail_in, strm->next_out, and strm->avail_out to pass input
|
||||
* to and get output from liblzma.
|
||||
*
|
||||
* See the description of the coder-specific initialization function to find
|
||||
* out what `action' values are supported by the coder.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Free memory allocated for the coder data structures
|
||||
*
|
||||
* \param strm Pointer to lzma_stream that is at least initialized
|
||||
* with LZMA_STREAM_INIT.
|
||||
*
|
||||
* After lzma_end(strm), strm->internal is guaranteed to be NULL. No other
|
||||
* members of the lzma_stream structure are touched.
|
||||
*
|
||||
* \note zlib indicates an error if application end()s unfinished
|
||||
* stream structure. liblzma doesn't do this, and assumes that
|
||||
* application knows what it is doing.
|
||||
*/
|
||||
extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get progress information
|
||||
*
|
||||
* In single-threaded mode, applications can get progress information from
|
||||
* strm->total_in and strm->total_out. In multi-threaded mode this is less
|
||||
* useful because a significant amount of both input and output data gets
|
||||
* buffered internally by liblzma. This makes total_in and total_out give
|
||||
* misleading information and also makes the progress indicator updates
|
||||
* non-smooth.
|
||||
*
|
||||
* This function gives realistic progress information also in multi-threaded
|
||||
* mode by taking into account the progress made by each thread. In
|
||||
* single-threaded mode *progress_in and *progress_out are set to
|
||||
* strm->total_in and strm->total_out, respectively.
|
||||
*/
|
||||
extern LZMA_API(void) lzma_get_progress(lzma_stream *strm,
|
||||
uint64_t *progress_in, uint64_t *progress_out) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the memory usage of decoder filter chain
|
||||
*
|
||||
* This function is currently supported only when *strm has been initialized
|
||||
* with a function that takes a memlimit argument. With other functions, you
|
||||
* should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage()
|
||||
* to estimate the memory requirements.
|
||||
*
|
||||
* This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big
|
||||
* the memory usage limit should have been to decode the input. Note that
|
||||
* this may give misleading information if decoding .xz Streams that have
|
||||
* multiple Blocks, because each Block can have different memory requirements.
|
||||
*
|
||||
* \return How much memory is currently allocated for the filter
|
||||
* decoders. If no filter chain is currently allocated,
|
||||
* some non-zero value is still returned, which is less than
|
||||
* or equal to what any filter chain would indicate as its
|
||||
* memory requirement.
|
||||
*
|
||||
* If this function isn't supported by *strm or some other error
|
||||
* occurs, zero is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the current memory usage limit
|
||||
*
|
||||
* This function is supported only when *strm has been initialized with
|
||||
* a function that takes a memlimit argument.
|
||||
*
|
||||
* \return On success, the current memory usage limit is returned
|
||||
* (always non-zero). On error, zero is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set the memory usage limit
|
||||
*
|
||||
* This function is supported only when *strm has been initialized with
|
||||
* a function that takes a memlimit argument.
|
||||
*
|
||||
* \return - LZMA_OK: New memory usage limit successfully set.
|
||||
* - LZMA_MEMLIMIT_ERROR: The new limit is too small.
|
||||
* The limit was not changed.
|
||||
* - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't
|
||||
* support memory usage limit or memlimit was zero.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_memlimit_set(
|
||||
lzma_stream *strm, uint64_t memlimit) lzma_nothrow;
|
||||
90
electron/node_modules/lzma-native/deps/include/lzma/bcj.h
generated
vendored
Normal file
90
electron/node_modules/lzma-native/deps/include/lzma/bcj.h
generated
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* \file lzma/bcj.h
|
||||
* \brief Branch/Call/Jump conversion filters
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/* Filter IDs for lzma_filter.id */
|
||||
|
||||
#define LZMA_FILTER_X86 LZMA_VLI_C(0x04)
|
||||
/**<
|
||||
* Filter for x86 binaries
|
||||
*/
|
||||
|
||||
#define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05)
|
||||
/**<
|
||||
* Filter for Big endian PowerPC binaries
|
||||
*/
|
||||
|
||||
#define LZMA_FILTER_IA64 LZMA_VLI_C(0x06)
|
||||
/**<
|
||||
* Filter for IA-64 (Itanium) binaries.
|
||||
*/
|
||||
|
||||
#define LZMA_FILTER_ARM LZMA_VLI_C(0x07)
|
||||
/**<
|
||||
* Filter for ARM binaries.
|
||||
*/
|
||||
|
||||
#define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08)
|
||||
/**<
|
||||
* Filter for ARM-Thumb binaries.
|
||||
*/
|
||||
|
||||
#define LZMA_FILTER_SPARC LZMA_VLI_C(0x09)
|
||||
/**<
|
||||
* Filter for SPARC binaries.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for BCJ filters
|
||||
*
|
||||
* The BCJ filters never change the size of the data. Specifying options
|
||||
* for them is optional: if pointer to options is NULL, default value is
|
||||
* used. You probably never need to specify options to BCJ filters, so just
|
||||
* set the options pointer to NULL and be happy.
|
||||
*
|
||||
* If options with non-default values have been specified when encoding,
|
||||
* the same options must also be specified when decoding.
|
||||
*
|
||||
* \note At the moment, none of the BCJ filters support
|
||||
* LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified,
|
||||
* LZMA_OPTIONS_ERROR will be returned. If there is need,
|
||||
* partial support for LZMA_SYNC_FLUSH can be added in future.
|
||||
* Partial means that flushing would be possible only at
|
||||
* offsets that are multiple of 2, 4, or 16 depending on
|
||||
* the filter, except x86 which cannot be made to support
|
||||
* LZMA_SYNC_FLUSH predictably.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Start offset for conversions
|
||||
*
|
||||
* This setting is useful only when the same filter is used
|
||||
* _separately_ for multiple sections of the same executable file,
|
||||
* and the sections contain cross-section branch/call/jump
|
||||
* instructions. In that case it is beneficial to set the start
|
||||
* offset of the non-first sections so that the relative addresses
|
||||
* of the cross-section branch/call/jump instructions will use the
|
||||
* same absolute addresses as in the first section.
|
||||
*
|
||||
* When the pointer to options is NULL, the default value (zero)
|
||||
* is used.
|
||||
*/
|
||||
uint32_t start_offset;
|
||||
|
||||
} lzma_options_bcj;
|
||||
581
electron/node_modules/lzma-native/deps/include/lzma/block.h
generated
vendored
Normal file
581
electron/node_modules/lzma-native/deps/include/lzma/block.h
generated
vendored
Normal file
|
|
@ -0,0 +1,581 @@
|
|||
/**
|
||||
* \file lzma/block.h
|
||||
* \brief .xz Block handling
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for the Block and Block Header encoders and decoders
|
||||
*
|
||||
* Different Block handling functions use different parts of this structure.
|
||||
* Some read some members, other functions write, and some do both. Only the
|
||||
* members listed for reading need to be initialized when the specified
|
||||
* functions are called. The members marked for writing will be assigned
|
||||
* new values at some point either by calling the given function or by
|
||||
* later calls to lzma_code().
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Block format version
|
||||
*
|
||||
* To prevent API and ABI breakages when new features are needed,
|
||||
* a version number is used to indicate which fields in this
|
||||
* structure are in use:
|
||||
* - liblzma >= 5.0.0: version = 0 is supported.
|
||||
* - liblzma >= 5.1.4beta: Support for version = 1 was added,
|
||||
* which adds the ignore_check field.
|
||||
*
|
||||
* If version is greater than one, most Block related functions
|
||||
* will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works
|
||||
* with any version value).
|
||||
*
|
||||
* Read by:
|
||||
* - All functions that take pointer to lzma_block as argument,
|
||||
* including lzma_block_header_decode().
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decode()
|
||||
*/
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
* \brief Size of the Block Header field
|
||||
*
|
||||
* This is always a multiple of four.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_encode()
|
||||
* - lzma_block_header_decode()
|
||||
* - lzma_block_compressed_size()
|
||||
* - lzma_block_unpadded_size()
|
||||
* - lzma_block_total_size()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_decode()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_buffer_encode()
|
||||
*/
|
||||
uint32_t header_size;
|
||||
# define LZMA_BLOCK_HEADER_SIZE_MIN 8
|
||||
# define LZMA_BLOCK_HEADER_SIZE_MAX 1024
|
||||
|
||||
/**
|
||||
* \brief Type of integrity Check
|
||||
*
|
||||
* The Check ID is not stored into the Block Header, thus its value
|
||||
* must be provided also when decoding.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_encode()
|
||||
* - lzma_block_header_decode()
|
||||
* - lzma_block_compressed_size()
|
||||
* - lzma_block_unpadded_size()
|
||||
* - lzma_block_total_size()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_encode()
|
||||
* - lzma_block_buffer_decode()
|
||||
*/
|
||||
lzma_check check;
|
||||
|
||||
/**
|
||||
* \brief Size of the Compressed Data in bytes
|
||||
*
|
||||
* Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder
|
||||
* will store this value to the Block Header. Block encoder doesn't
|
||||
* care about this value, but will set it once the encoding has been
|
||||
* finished.
|
||||
*
|
||||
* Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will
|
||||
* verify that the size of the Compressed Data field matches
|
||||
* compressed_size.
|
||||
*
|
||||
* Usually you don't know this value when encoding in streamed mode,
|
||||
* and thus cannot write this field into the Block Header.
|
||||
*
|
||||
* In non-streamed mode you can reserve space for this field before
|
||||
* encoding the actual Block. After encoding the data, finish the
|
||||
* Block by encoding the Block Header. Steps in detail:
|
||||
*
|
||||
* - Set compressed_size to some big enough value. If you don't know
|
||||
* better, use LZMA_VLI_MAX, but remember that bigger values take
|
||||
* more space in Block Header.
|
||||
*
|
||||
* - Call lzma_block_header_size() to see how much space you need to
|
||||
* reserve for the Block Header.
|
||||
*
|
||||
* - Encode the Block using lzma_block_encoder() and lzma_code().
|
||||
* It sets compressed_size to the correct value.
|
||||
*
|
||||
* - Use lzma_block_header_encode() to encode the Block Header.
|
||||
* Because space was reserved in the first step, you don't need
|
||||
* to call lzma_block_header_size() anymore, because due to
|
||||
* reserving, header_size has to be big enough. If it is "too big",
|
||||
* lzma_block_header_encode() will add enough Header Padding to
|
||||
* make Block Header to match the size specified by header_size.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encode()
|
||||
* - lzma_block_compressed_size()
|
||||
* - lzma_block_unpadded_size()
|
||||
* - lzma_block_total_size()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_decode()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decode()
|
||||
* - lzma_block_compressed_size()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_encode()
|
||||
* - lzma_block_buffer_decode()
|
||||
*/
|
||||
lzma_vli compressed_size;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed Size in bytes
|
||||
*
|
||||
* This is handled very similarly to compressed_size above.
|
||||
*
|
||||
* uncompressed_size is needed by fewer functions than
|
||||
* compressed_size. This is because uncompressed_size isn't
|
||||
* needed to validate that Block stays within proper limits.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encode()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_decode()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decode()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_encode()
|
||||
* - lzma_block_buffer_decode()
|
||||
*/
|
||||
lzma_vli uncompressed_size;
|
||||
|
||||
/**
|
||||
* \brief Array of filters
|
||||
*
|
||||
* There can be 1-4 filters. The end of the array is marked with
|
||||
* .id = LZMA_VLI_UNKNOWN.
|
||||
*
|
||||
* Read by:
|
||||
* - lzma_block_header_size()
|
||||
* - lzma_block_header_encode()
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_encode()
|
||||
* - lzma_block_buffer_decode()
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_header_decode(): Note that this does NOT free()
|
||||
* the old filter options structures. All unused filters[] will
|
||||
* have .id == LZMA_VLI_UNKNOWN and .options == NULL. If
|
||||
* decoding fails, all filters[] are guaranteed to be
|
||||
* LZMA_VLI_UNKNOWN and NULL.
|
||||
*
|
||||
* \note Because of the array is terminated with
|
||||
* .id = LZMA_VLI_UNKNOWN, the actual array must
|
||||
* have LZMA_FILTERS_MAX + 1 members or the Block
|
||||
* Header decoder will overflow the buffer.
|
||||
*/
|
||||
lzma_filter *filters;
|
||||
|
||||
/**
|
||||
* \brief Raw value stored in the Check field
|
||||
*
|
||||
* After successful coding, the first lzma_check_size(check) bytes
|
||||
* of this array contain the raw value stored in the Check field.
|
||||
*
|
||||
* Note that CRC32 and CRC64 are stored in little endian byte order.
|
||||
* Take it into account if you display the Check values to the user.
|
||||
*
|
||||
* Written by:
|
||||
* - lzma_block_encoder()
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_encode()
|
||||
* - lzma_block_buffer_decode()
|
||||
*/
|
||||
uint8_t raw_check[LZMA_CHECK_SIZE_MAX];
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. You should not touch these, because the names
|
||||
* of these variables may change. These are and will never be used
|
||||
* with the currently supported options, so it is safe to leave these
|
||||
* uninitialized.
|
||||
*/
|
||||
void *reserved_ptr1;
|
||||
void *reserved_ptr2;
|
||||
void *reserved_ptr3;
|
||||
uint32_t reserved_int1;
|
||||
uint32_t reserved_int2;
|
||||
lzma_vli reserved_int3;
|
||||
lzma_vli reserved_int4;
|
||||
lzma_vli reserved_int5;
|
||||
lzma_vli reserved_int6;
|
||||
lzma_vli reserved_int7;
|
||||
lzma_vli reserved_int8;
|
||||
lzma_reserved_enum reserved_enum1;
|
||||
lzma_reserved_enum reserved_enum2;
|
||||
lzma_reserved_enum reserved_enum3;
|
||||
lzma_reserved_enum reserved_enum4;
|
||||
|
||||
/**
|
||||
* \brief A flag to Block decoder to not verify the Check field
|
||||
*
|
||||
* This field is supported by liblzma >= 5.1.4beta if .version >= 1.
|
||||
*
|
||||
* If this is set to true, the integrity check won't be calculated
|
||||
* and verified. Unless you know what you are doing, you should
|
||||
* leave this to false. (A reason to set this to true is when the
|
||||
* file integrity is verified externally anyway and you want to
|
||||
* speed up the decompression, which matters mostly when using
|
||||
* SHA-256 as the integrity check.)
|
||||
*
|
||||
* If .version >= 1, read by:
|
||||
* - lzma_block_decoder()
|
||||
* - lzma_block_buffer_decode()
|
||||
*
|
||||
* Written by (.version is ignored):
|
||||
* - lzma_block_header_decode() always sets this to false
|
||||
*/
|
||||
lzma_bool ignore_check;
|
||||
|
||||
lzma_bool reserved_bool2;
|
||||
lzma_bool reserved_bool3;
|
||||
lzma_bool reserved_bool4;
|
||||
lzma_bool reserved_bool5;
|
||||
lzma_bool reserved_bool6;
|
||||
lzma_bool reserved_bool7;
|
||||
lzma_bool reserved_bool8;
|
||||
|
||||
} lzma_block;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode the Block Header Size field
|
||||
*
|
||||
* To decode Block Header using lzma_block_header_decode(), the size of the
|
||||
* Block Header has to be known and stored into lzma_block.header_size.
|
||||
* The size can be calculated from the first byte of a Block using this macro.
|
||||
* Note that if the first byte is 0x00, it indicates beginning of Index; use
|
||||
* this macro only when the byte is not 0x00.
|
||||
*
|
||||
* There is no encoding macro, because Block Header encoder is enough for that.
|
||||
*/
|
||||
#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate Block Header Size
|
||||
*
|
||||
* Calculate the minimum size needed for the Block Header field using the
|
||||
* settings specified in the lzma_block structure. Note that it is OK to
|
||||
* increase the calculated header_size value as long as it is a multiple of
|
||||
* four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size
|
||||
* just means that lzma_block_header_encode() will add Header Padding.
|
||||
*
|
||||
* \return - LZMA_OK: Size calculated successfully and stored to
|
||||
* block->header_size.
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported version, filters or
|
||||
* filter options.
|
||||
* - LZMA_PROG_ERROR: Invalid values like compressed_size == 0.
|
||||
*
|
||||
* \note This doesn't check that all the options are valid i.e. this
|
||||
* may return LZMA_OK even if lzma_block_header_encode() or
|
||||
* lzma_block_encoder() would fail. If you want to validate the
|
||||
* filter chain, consider using lzma_memlimit_encoder() which as
|
||||
* a side-effect validates the filter chain.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode Block Header
|
||||
*
|
||||
* The caller must have calculated the size of the Block Header already with
|
||||
* lzma_block_header_size(). If a value larger than the one calculated by
|
||||
* lzma_block_header_size() is used, the Block Header will be padded to the
|
||||
* specified size.
|
||||
*
|
||||
* \param out Beginning of the output buffer. This must be
|
||||
* at least block->header_size bytes.
|
||||
* \param block Block options to be encoded.
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful. block->header_size
|
||||
* bytes were written to output buffer.
|
||||
* - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
|
||||
* - LZMA_PROG_ERROR: Invalid arguments, for example
|
||||
* block->header_size is invalid or block->filters is NULL.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_header_encode(
|
||||
const lzma_block *block, uint8_t *out)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode Block Header
|
||||
*
|
||||
* block->version should (usually) be set to the highest value supported
|
||||
* by the application. If the application sets block->version to a value
|
||||
* higher than supported by the current liblzma version, this function will
|
||||
* downgrade block->version to the highest value supported by it. Thus one
|
||||
* should check the value of block->version after calling this function if
|
||||
* block->version was set to a non-zero value and the application doesn't
|
||||
* otherwise know that the liblzma version being used is new enough to
|
||||
* support the specified block->version.
|
||||
*
|
||||
* The size of the Block Header must have already been decoded with
|
||||
* lzma_block_header_size_decode() macro and stored to block->header_size.
|
||||
*
|
||||
* The integrity check type from Stream Header must have been stored
|
||||
* to block->check.
|
||||
*
|
||||
* block->filters must have been allocated, but they don't need to be
|
||||
* initialized (possible existing filter options are not freed).
|
||||
*
|
||||
* \param block Destination for Block options.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() (and also free()
|
||||
* if an error occurs).
|
||||
* \param in Beginning of the input buffer. This must be
|
||||
* at least block->header_size bytes.
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful. block->header_size
|
||||
* bytes were read from the input buffer.
|
||||
* - LZMA_OPTIONS_ERROR: The Block Header specifies some
|
||||
* unsupported options such as unsupported filters. This can
|
||||
* happen also if block->version was set to a too low value
|
||||
* compared to what would be required to properly represent
|
||||
* the information stored in the Block Header.
|
||||
* - LZMA_DATA_ERROR: Block Header is corrupt, for example,
|
||||
* the CRC32 doesn't match.
|
||||
* - LZMA_PROG_ERROR: Invalid arguments, for example
|
||||
* block->header_size is invalid or block->filters is NULL.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block,
|
||||
const lzma_allocator *allocator, const uint8_t *in)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Validate and set Compressed Size according to Unpadded Size
|
||||
*
|
||||
* Block Header stores Compressed Size, but Index has Unpadded Size. If the
|
||||
* application has already parsed the Index and is now decoding Blocks,
|
||||
* it can calculate Compressed Size from Unpadded Size. This function does
|
||||
* exactly that with error checking:
|
||||
*
|
||||
* - Compressed Size calculated from Unpadded Size must be positive integer,
|
||||
* that is, Unpadded Size must be big enough that after Block Header and
|
||||
* Check fields there's still at least one byte for Compressed Size.
|
||||
*
|
||||
* - If Compressed Size was present in Block Header, the new value
|
||||
* calculated from Unpadded Size is compared against the value
|
||||
* from Block Header.
|
||||
*
|
||||
* \note This function must be called _after_ decoding the Block Header
|
||||
* field so that it can properly validate Compressed Size if it
|
||||
* was present in Block Header.
|
||||
*
|
||||
* \return - LZMA_OK: block->compressed_size was set successfully.
|
||||
* - LZMA_DATA_ERROR: unpadded_size is too small compared to
|
||||
* block->header_size and lzma_check_size(block->check).
|
||||
* - LZMA_PROG_ERROR: Some values are invalid. For example,
|
||||
* block->header_size must be a multiple of four and
|
||||
* between 8 and 1024 inclusive.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_compressed_size(
|
||||
lzma_block *block, lzma_vli unpadded_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate Unpadded Size
|
||||
*
|
||||
* The Index field stores Unpadded Size and Uncompressed Size. The latter
|
||||
* can be taken directly from the lzma_block structure after coding a Block,
|
||||
* but Unpadded Size needs to be calculated from Block Header Size,
|
||||
* Compressed Size, and size of the Check field. This is where this function
|
||||
* is needed.
|
||||
*
|
||||
* \return Unpadded Size on success, or zero on error.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate the total encoded size of a Block
|
||||
*
|
||||
* This is equivalent to lzma_block_unpadded_size() except that the returned
|
||||
* value includes the size of the Block Padding field.
|
||||
*
|
||||
* \return On success, total encoded size of the Block. On error,
|
||||
* zero is returned.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Block encoder
|
||||
*
|
||||
* Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the
|
||||
* filter chain supports it), and LZMA_FINISH.
|
||||
*
|
||||
* \return - LZMA_OK: All good, continue with lzma_code().
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID
|
||||
* that is not supported by this buid of liblzma. Initializing
|
||||
* the encoder failed.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_encoder(
|
||||
lzma_stream *strm, lzma_block *block)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Block decoder
|
||||
*
|
||||
* Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using
|
||||
* LZMA_FINISH is not required. It is supported only for convenience.
|
||||
*
|
||||
* \return - LZMA_OK: All good, continue with lzma_code().
|
||||
* - LZMA_UNSUPPORTED_CHECK: Initialization was successful, but
|
||||
* the given Check ID is not supported, thus Check will be
|
||||
* ignored.
|
||||
* - LZMA_PROG_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_decoder(
|
||||
lzma_stream *strm, lzma_block *block)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate maximum output size for single-call Block encoding
|
||||
*
|
||||
* This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks.
|
||||
* See the documentation of lzma_stream_buffer_bound().
|
||||
*/
|
||||
extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Block encoder
|
||||
*
|
||||
* In contrast to the multi-call encoder initialized with
|
||||
* lzma_block_encoder(), this function encodes also the Block Header. This
|
||||
* is required to make it possible to write appropriate Block Header also
|
||||
* in case the data isn't compressible, and different filter chain has to be
|
||||
* used to encode the data in uncompressed form using uncompressed chunks
|
||||
* of the LZMA2 filter.
|
||||
*
|
||||
* When the data isn't compressible, header_size, compressed_size, and
|
||||
* uncompressed_size are set just like when the data was compressible, but
|
||||
* it is possible that header_size is too small to hold the filter chain
|
||||
* specified in block->filters, because that isn't necessarily the filter
|
||||
* chain that was actually used to encode the data. lzma_block_unpadded_size()
|
||||
* still works normally, because it doesn't read the filters array.
|
||||
*
|
||||
* \param block Block options: block->version, block->check,
|
||||
* and block->filters must have been initialized.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_size Size of the input buffer
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
||||
* - LZMA_UNSUPPORTED_CHECK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_buffer_encode(
|
||||
lzma_block *block, const lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call uncompressed .xz Block encoder
|
||||
*
|
||||
* This is like lzma_block_buffer_encode() except this doesn't try to
|
||||
* compress the data and instead encodes the data using LZMA2 uncompressed
|
||||
* chunks. The required output buffer size can be determined with
|
||||
* lzma_block_buffer_bound().
|
||||
*
|
||||
* Since the data won't be compressed, this function ignores block->filters.
|
||||
* This function doesn't take lzma_allocator because this function doesn't
|
||||
* allocate any memory from the heap.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block,
|
||||
const uint8_t *in, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Block decoder
|
||||
*
|
||||
* This is single-call equivalent of lzma_block_decoder(), and requires that
|
||||
* the caller has already decoded Block Header and checked its memory usage.
|
||||
*
|
||||
* \param block Block options just like with lzma_block_decoder().
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_pos The next byte will be read from in[*in_pos].
|
||||
* *in_pos is updated only if decoding succeeds.
|
||||
* \param in_size Size of the input buffer; the first byte that
|
||||
* won't be read is in[in_size].
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful.
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_BUF_ERROR: Output buffer was too small.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_block_buffer_decode(
|
||||
lzma_block *block, const lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow;
|
||||
150
electron/node_modules/lzma-native/deps/include/lzma/check.h
generated
vendored
Normal file
150
electron/node_modules/lzma-native/deps/include/lzma/check.h
generated
vendored
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/**
|
||||
* \file lzma/check.h
|
||||
* \brief Integrity checks
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Type of the integrity check (Check ID)
|
||||
*
|
||||
* The .xz format supports multiple types of checks that are calculated
|
||||
* from the uncompressed data. They vary in both speed and ability to
|
||||
* detect errors.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_CHECK_NONE = 0,
|
||||
/**<
|
||||
* No Check is calculated.
|
||||
*
|
||||
* Size of the Check field: 0 bytes
|
||||
*/
|
||||
|
||||
LZMA_CHECK_CRC32 = 1,
|
||||
/**<
|
||||
* CRC32 using the polynomial from the IEEE 802.3 standard
|
||||
*
|
||||
* Size of the Check field: 4 bytes
|
||||
*/
|
||||
|
||||
LZMA_CHECK_CRC64 = 4,
|
||||
/**<
|
||||
* CRC64 using the polynomial from the ECMA-182 standard
|
||||
*
|
||||
* Size of the Check field: 8 bytes
|
||||
*/
|
||||
|
||||
LZMA_CHECK_SHA256 = 10
|
||||
/**<
|
||||
* SHA-256
|
||||
*
|
||||
* Size of the Check field: 32 bytes
|
||||
*/
|
||||
} lzma_check;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Maximum valid Check ID
|
||||
*
|
||||
* The .xz file format specification specifies 16 Check IDs (0-15). Some
|
||||
* of them are only reserved, that is, no actual Check algorithm has been
|
||||
* assigned. When decoding, liblzma still accepts unknown Check IDs for
|
||||
* future compatibility. If a valid but unsupported Check ID is detected,
|
||||
* liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK,
|
||||
* LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h.
|
||||
*/
|
||||
#define LZMA_CHECK_ID_MAX 15
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if the given Check ID is supported
|
||||
*
|
||||
* Return true if the given Check ID is supported by this liblzma build.
|
||||
* Otherwise false is returned. It is safe to call this with a value that
|
||||
* is not in the range [0, 15]; in that case the return value is always false.
|
||||
*
|
||||
* You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always
|
||||
* supported (even if liblzma is built with limited features).
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the size of the Check field with the given Check ID
|
||||
*
|
||||
* Although not all Check IDs have a check algorithm associated, the size of
|
||||
* every Check is already frozen. This function returns the size (in bytes) of
|
||||
* the Check field with the specified Check ID. The values are:
|
||||
* { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 }
|
||||
*
|
||||
* If the argument is not in the range [0, 15], UINT32_MAX is returned.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_check_size(lzma_check check)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Maximum size of a Check field
|
||||
*/
|
||||
#define LZMA_CHECK_SIZE_MAX 64
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate CRC32
|
||||
*
|
||||
* Calculate CRC32 using the polynomial from the IEEE 802.3 standard.
|
||||
*
|
||||
* \param buf Pointer to the input buffer
|
||||
* \param size Size of the input buffer
|
||||
* \param crc Previously returned CRC value. This is used to
|
||||
* calculate the CRC of a big buffer in smaller chunks.
|
||||
* Set to zero when starting a new calculation.
|
||||
*
|
||||
* \return Updated CRC value, which can be passed to this function
|
||||
* again to continue CRC calculation.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_crc32(
|
||||
const uint8_t *buf, size_t size, uint32_t crc)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate CRC64
|
||||
*
|
||||
* Calculate CRC64 using the polynomial from the ECMA-182 standard.
|
||||
*
|
||||
* This function is used similarly to lzma_crc32(). See its documentation.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_crc64(
|
||||
const uint8_t *buf, size_t size, uint64_t crc)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/*
|
||||
* SHA-256 functions are currently not exported to public API.
|
||||
* Contact Lasse Collin if you think it should be.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the type of the integrity check
|
||||
*
|
||||
* This function can be called only immediately after lzma_code() has
|
||||
* returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK.
|
||||
* Calling this function in any other situation has undefined behavior.
|
||||
*/
|
||||
extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm)
|
||||
lzma_nothrow;
|
||||
619
electron/node_modules/lzma-native/deps/include/lzma/container.h
generated
vendored
Normal file
619
electron/node_modules/lzma-native/deps/include/lzma/container.h
generated
vendored
Normal file
|
|
@ -0,0 +1,619 @@
|
|||
/**
|
||||
* \file lzma/container.h
|
||||
* \brief File formats
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/************
|
||||
* Encoding *
|
||||
************/
|
||||
|
||||
/**
|
||||
* \brief Default compression preset
|
||||
*
|
||||
* It's not straightforward to recommend a default preset, because in some
|
||||
* cases keeping the resource usage relatively low is more important that
|
||||
* getting the maximum compression ratio.
|
||||
*/
|
||||
#define LZMA_PRESET_DEFAULT UINT32_C(6)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mask for preset level
|
||||
*
|
||||
* This is useful only if you need to extract the level from the preset
|
||||
* variable. That should be rare.
|
||||
*/
|
||||
#define LZMA_PRESET_LEVEL_MASK UINT32_C(0x1F)
|
||||
|
||||
|
||||
/*
|
||||
* Preset flags
|
||||
*
|
||||
* Currently only one flag is defined.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief Extreme compression preset
|
||||
*
|
||||
* This flag modifies the preset to make the encoding significantly slower
|
||||
* while improving the compression ratio only marginally. This is useful
|
||||
* when you don't mind wasting time to get as small result as possible.
|
||||
*
|
||||
* This flag doesn't affect the memory usage requirements of the decoder (at
|
||||
* least not significantly). The memory usage of the encoder may be increased
|
||||
* a little but only at the lowest preset levels (0-3).
|
||||
*/
|
||||
#define LZMA_PRESET_EXTREME (UINT32_C(1) << 31)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Multithreading options
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Flags
|
||||
*
|
||||
* Set this to zero if no flags are wanted.
|
||||
*
|
||||
* No flags are currently supported.
|
||||
*/
|
||||
uint32_t flags;
|
||||
|
||||
/**
|
||||
* \brief Number of worker threads to use
|
||||
*/
|
||||
uint32_t threads;
|
||||
|
||||
/**
|
||||
* \brief Maximum uncompressed size of a Block
|
||||
*
|
||||
* The encoder will start a new .xz Block every block_size bytes.
|
||||
* Using LZMA_FULL_FLUSH or LZMA_FULL_BARRIER with lzma_code()
|
||||
* the caller may tell liblzma to start a new Block earlier.
|
||||
*
|
||||
* With LZMA2, a recommended block size is 2-4 times the LZMA2
|
||||
* dictionary size. With very small dictionaries, it is recommended
|
||||
* to use at least 1 MiB block size for good compression ratio, even
|
||||
* if this is more than four times the dictionary size. Note that
|
||||
* these are only recommendations for typical use cases; feel free
|
||||
* to use other values. Just keep in mind that using a block size
|
||||
* less than the LZMA2 dictionary size is waste of RAM.
|
||||
*
|
||||
* Set this to 0 to let liblzma choose the block size depending
|
||||
* on the compression options. For LZMA2 it will be 3*dict_size
|
||||
* or 1 MiB, whichever is more.
|
||||
*
|
||||
* For each thread, about 3 * block_size bytes of memory will be
|
||||
* allocated. This may change in later liblzma versions. If so,
|
||||
* the memory usage will probably be reduced, not increased.
|
||||
*/
|
||||
uint64_t block_size;
|
||||
|
||||
/**
|
||||
* \brief Timeout to allow lzma_code() to return early
|
||||
*
|
||||
* Multithreading can make liblzma to consume input and produce
|
||||
* output in a very bursty way: it may first read a lot of input
|
||||
* to fill internal buffers, then no input or output occurs for
|
||||
* a while.
|
||||
*
|
||||
* In single-threaded mode, lzma_code() won't return until it has
|
||||
* either consumed all the input or filled the output buffer. If
|
||||
* this is done in multithreaded mode, it may cause a call
|
||||
* lzma_code() to take even tens of seconds, which isn't acceptable
|
||||
* in all applications.
|
||||
*
|
||||
* To avoid very long blocking times in lzma_code(), a timeout
|
||||
* (in milliseconds) may be set here. If lzma_code() would block
|
||||
* longer than this number of milliseconds, it will return with
|
||||
* LZMA_OK. Reasonable values are 100 ms or more. The xz command
|
||||
* line tool uses 300 ms.
|
||||
*
|
||||
* If long blocking times are fine for you, set timeout to a special
|
||||
* value of 0, which will disable the timeout mechanism and will make
|
||||
* lzma_code() block until all the input is consumed or the output
|
||||
* buffer has been filled.
|
||||
*
|
||||
* \note Even with a timeout, lzma_code() might sometimes take
|
||||
* somewhat long time to return. No timing guarantees
|
||||
* are made.
|
||||
*/
|
||||
uint32_t timeout;
|
||||
|
||||
/**
|
||||
* \brief Compression preset (level and possible flags)
|
||||
*
|
||||
* The preset is set just like with lzma_easy_encoder().
|
||||
* The preset is ignored if filters below is non-NULL.
|
||||
*/
|
||||
uint32_t preset;
|
||||
|
||||
/**
|
||||
* \brief Filter chain (alternative to a preset)
|
||||
*
|
||||
* If this is NULL, the preset above is used. Otherwise the preset
|
||||
* is ignored and the filter chain specified here is used.
|
||||
*/
|
||||
const lzma_filter *filters;
|
||||
|
||||
/**
|
||||
* \brief Integrity check type
|
||||
*
|
||||
* See check.h for available checks. The xz command line tool
|
||||
* defaults to LZMA_CHECK_CRC64, which is a good choice if you
|
||||
* are unsure.
|
||||
*/
|
||||
lzma_check check;
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. You should not touch these, because the names
|
||||
* of these variables may change. These are and will never be used
|
||||
* with the currently supported options, so it is safe to leave these
|
||||
* uninitialized.
|
||||
*/
|
||||
lzma_reserved_enum reserved_enum1;
|
||||
lzma_reserved_enum reserved_enum2;
|
||||
lzma_reserved_enum reserved_enum3;
|
||||
uint32_t reserved_int1;
|
||||
uint32_t reserved_int2;
|
||||
uint32_t reserved_int3;
|
||||
uint32_t reserved_int4;
|
||||
uint64_t reserved_int5;
|
||||
uint64_t reserved_int6;
|
||||
uint64_t reserved_int7;
|
||||
uint64_t reserved_int8;
|
||||
void *reserved_ptr1;
|
||||
void *reserved_ptr2;
|
||||
void *reserved_ptr3;
|
||||
void *reserved_ptr4;
|
||||
|
||||
} lzma_mt;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate approximate memory usage of easy encoder
|
||||
*
|
||||
* This function is a wrapper for lzma_raw_encoder_memusage().
|
||||
*
|
||||
* \param preset Compression preset (level and possible flags)
|
||||
*
|
||||
* \return Number of bytes of memory required for the given
|
||||
* preset when encoding. If an error occurs, for example
|
||||
* due to unsupported preset, UINT64_MAX is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate approximate decoder memory usage of a preset
|
||||
*
|
||||
* This function is a wrapper for lzma_raw_decoder_memusage().
|
||||
*
|
||||
* \param preset Compression preset (level and possible flags)
|
||||
*
|
||||
* \return Number of bytes of memory required to decompress a file
|
||||
* that was compressed using the given preset. If an error
|
||||
* occurs, for example due to unsupported preset, UINT64_MAX
|
||||
* is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Stream encoder using a preset number
|
||||
*
|
||||
* This function is intended for those who just want to use the basic features
|
||||
* if liblzma (that is, most developers out there).
|
||||
*
|
||||
* \param strm Pointer to lzma_stream that is at least initialized
|
||||
* with LZMA_STREAM_INIT.
|
||||
* \param preset Compression preset to use. A preset consist of level
|
||||
* number and zero or more flags. Usually flags aren't
|
||||
* used, so preset is simply a number [0, 9] which match
|
||||
* the options -0 ... -9 of the xz command line tool.
|
||||
* Additional flags can be be set using bitwise-or with
|
||||
* the preset level number, e.g. 6 | LZMA_PRESET_EXTREME.
|
||||
* \param check Integrity check type to use. See check.h for available
|
||||
* checks. The xz command line tool defaults to
|
||||
* LZMA_CHECK_CRC64, which is a good choice if you are
|
||||
* unsure. LZMA_CHECK_CRC32 is good too as long as the
|
||||
* uncompressed file is not many gigabytes.
|
||||
*
|
||||
* \return - LZMA_OK: Initialization succeeded. Use lzma_code() to
|
||||
* encode your data.
|
||||
* - LZMA_MEM_ERROR: Memory allocation failed.
|
||||
* - LZMA_OPTIONS_ERROR: The given compression preset is not
|
||||
* supported by this build of liblzma.
|
||||
* - LZMA_UNSUPPORTED_CHECK: The given check type is not
|
||||
* supported by this liblzma build.
|
||||
* - LZMA_PROG_ERROR: One or more of the parameters have values
|
||||
* that will never be valid. For example, strm == NULL.
|
||||
*
|
||||
* If initialization fails (return value is not LZMA_OK), all the memory
|
||||
* allocated for *strm by liblzma is always freed. Thus, there is no need
|
||||
* to call lzma_end() after failed initialization.
|
||||
*
|
||||
* If initialization succeeds, use lzma_code() to do the actual encoding.
|
||||
* Valid values for `action' (the second argument of lzma_code()) are
|
||||
* LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future,
|
||||
* there may be compression levels or flags that don't support LZMA_SYNC_FLUSH.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_easy_encoder(
|
||||
lzma_stream *strm, uint32_t preset, lzma_check check)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Stream encoding using a preset number
|
||||
*
|
||||
* The maximum required output buffer size can be calculated with
|
||||
* lzma_stream_buffer_bound().
|
||||
*
|
||||
* \param preset Compression preset to use. See the description
|
||||
* in lzma_easy_encoder().
|
||||
* \param check Type of the integrity check to calculate from
|
||||
* uncompressed data.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_size Size of the input buffer
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
||||
* - LZMA_UNSUPPORTED_CHECK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_easy_buffer_encode(
|
||||
uint32_t preset, lzma_check check,
|
||||
const lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Stream encoder using a custom filter chain
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param filters Array of filters. This must be terminated with
|
||||
* filters[n].id = LZMA_VLI_UNKNOWN. See filter.h for
|
||||
* more information.
|
||||
* \param check Type of the integrity check to calculate from
|
||||
* uncompressed data.
|
||||
*
|
||||
* \return - LZMA_OK: Initialization was successful.
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_UNSUPPORTED_CHECK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm,
|
||||
const lzma_filter *filters, lzma_check check)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate approximate memory usage of multithreaded .xz encoder
|
||||
*
|
||||
* Since doing the encoding in threaded mode doesn't affect the memory
|
||||
* requirements of single-threaded decompressor, you can use
|
||||
* lzma_easy_decoder_memusage(options->preset) or
|
||||
* lzma_raw_decoder_memusage(options->filters) to calculate
|
||||
* the decompressor memory requirements.
|
||||
*
|
||||
* \param options Compression options
|
||||
*
|
||||
* \return Number of bytes of memory required for encoding with the
|
||||
* given options. If an error occurs, for example due to
|
||||
* unsupported preset or filter chain, UINT64_MAX is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_stream_encoder_mt_memusage(
|
||||
const lzma_mt *options) lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize multithreaded .xz Stream encoder
|
||||
*
|
||||
* This provides the functionality of lzma_easy_encoder() and
|
||||
* lzma_stream_encoder() as a single function for multithreaded use.
|
||||
*
|
||||
* The supported actions for lzma_code() are LZMA_RUN, LZMA_FULL_FLUSH,
|
||||
* LZMA_FULL_BARRIER, and LZMA_FINISH. Support for LZMA_SYNC_FLUSH might be
|
||||
* added in the future.
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param options Pointer to multithreaded compression options
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_UNSUPPORTED_CHECK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_encoder_mt(
|
||||
lzma_stream *strm, const lzma_mt *options)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .lzma encoder (legacy file format)
|
||||
*
|
||||
* The .lzma format is sometimes called the LZMA_Alone format, which is the
|
||||
* reason for the name of this function. The .lzma format supports only the
|
||||
* LZMA1 filter. There is no support for integrity checks like CRC32.
|
||||
*
|
||||
* Use this function if and only if you need to create files readable by
|
||||
* legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format
|
||||
* is strongly recommended.
|
||||
*
|
||||
* The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH.
|
||||
* No kind of flushing is supported, because the file format doesn't make
|
||||
* it possible.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_alone_encoder(
|
||||
lzma_stream *strm, const lzma_options_lzma *options)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate output buffer size for single-call Stream encoder
|
||||
*
|
||||
* When trying to compress uncompressible data, the encoded size will be
|
||||
* slightly bigger than the input data. This function calculates how much
|
||||
* output buffer space is required to be sure that lzma_stream_buffer_encode()
|
||||
* doesn't return LZMA_BUF_ERROR.
|
||||
*
|
||||
* The calculated value is not exact, but it is guaranteed to be big enough.
|
||||
* The actual maximum output space required may be slightly smaller (up to
|
||||
* about 100 bytes). This should not be a problem in practice.
|
||||
*
|
||||
* If the calculated maximum size doesn't fit into size_t or would make the
|
||||
* Stream grow past LZMA_VLI_MAX (which should never happen in practice),
|
||||
* zero is returned to indicate the error.
|
||||
*
|
||||
* \note The limit calculated by this function applies only to
|
||||
* single-call encoding. Multi-call encoding may (and probably
|
||||
* will) have larger maximum expansion when encoding
|
||||
* uncompressible data. Currently there is no function to
|
||||
* calculate the maximum expansion of multi-call encoding.
|
||||
*/
|
||||
extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Stream encoder
|
||||
*
|
||||
* \param filters Array of filters. This must be terminated with
|
||||
* filters[n].id = LZMA_VLI_UNKNOWN. See filter.h
|
||||
* for more information.
|
||||
* \param check Type of the integrity check to calculate from
|
||||
* uncompressed data.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_size Size of the input buffer
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
||||
* - LZMA_UNSUPPORTED_CHECK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_buffer_encode(
|
||||
lzma_filter *filters, lzma_check check,
|
||||
const lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/************
|
||||
* Decoding *
|
||||
************/
|
||||
|
||||
/**
|
||||
* This flag makes lzma_code() return LZMA_NO_CHECK if the input stream
|
||||
* being decoded has no integrity check. Note that when used with
|
||||
* lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK
|
||||
* if LZMA_TELL_NO_CHECK is used.
|
||||
*/
|
||||
#define LZMA_TELL_NO_CHECK UINT32_C(0x01)
|
||||
|
||||
|
||||
/**
|
||||
* This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input
|
||||
* stream has an integrity check, but the type of the integrity check is not
|
||||
* supported by this liblzma version or build. Such files can still be
|
||||
* decoded, but the integrity check cannot be verified.
|
||||
*/
|
||||
#define LZMA_TELL_UNSUPPORTED_CHECK UINT32_C(0x02)
|
||||
|
||||
|
||||
/**
|
||||
* This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type
|
||||
* of the integrity check is known. The type can then be got with
|
||||
* lzma_get_check().
|
||||
*/
|
||||
#define LZMA_TELL_ANY_CHECK UINT32_C(0x04)
|
||||
|
||||
|
||||
/**
|
||||
* This flag makes lzma_code() not calculate and verify the integrity check
|
||||
* of the compressed data in .xz files. This means that invalid integrity
|
||||
* check values won't be detected and LZMA_DATA_ERROR won't be returned in
|
||||
* such cases.
|
||||
*
|
||||
* This flag only affects the checks of the compressed data itself; the CRC32
|
||||
* values in the .xz headers will still be verified normally.
|
||||
*
|
||||
* Don't use this flag unless you know what you are doing. Possible reasons
|
||||
* to use this flag:
|
||||
*
|
||||
* - Trying to recover data from a corrupt .xz file.
|
||||
*
|
||||
* - Speeding up decompression, which matters mostly with SHA-256
|
||||
* or with files that have compressed extremely well. It's recommended
|
||||
* to not use this flag for this purpose unless the file integrity is
|
||||
* verified externally in some other way.
|
||||
*
|
||||
* Support for this flag was added in liblzma 5.1.4beta.
|
||||
*/
|
||||
#define LZMA_IGNORE_CHECK UINT32_C(0x10)
|
||||
|
||||
|
||||
/**
|
||||
* This flag enables decoding of concatenated files with file formats that
|
||||
* allow concatenating compressed files as is. From the formats currently
|
||||
* supported by liblzma, only the .xz format allows concatenated files.
|
||||
* Concatenated files are not allowed with the legacy .lzma format.
|
||||
*
|
||||
* This flag also affects the usage of the `action' argument for lzma_code().
|
||||
* When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END
|
||||
* unless LZMA_FINISH is used as `action'. Thus, the application has to set
|
||||
* LZMA_FINISH in the same way as it does when encoding.
|
||||
*
|
||||
* If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH
|
||||
* as `action' for lzma_code(), but the usage of LZMA_FINISH isn't required.
|
||||
*/
|
||||
#define LZMA_CONCATENATED UINT32_C(0x08)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Stream decoder
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
|
||||
* to effectively disable the limiter.
|
||||
* \param flags Bitwise-or of zero or more of the decoder flags:
|
||||
* LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
|
||||
* LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED
|
||||
*
|
||||
* \return - LZMA_OK: Initialization was successful.
|
||||
* - LZMA_MEM_ERROR: Cannot allocate memory.
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported flags
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_decoder(
|
||||
lzma_stream *strm, uint64_t memlimit, uint32_t flags)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode .xz Streams and .lzma files with autodetection
|
||||
*
|
||||
* This decoder autodetects between the .xz and .lzma file formats, and
|
||||
* calls lzma_stream_decoder() or lzma_alone_decoder() once the type
|
||||
* of the input file has been detected.
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
|
||||
* to effectively disable the limiter.
|
||||
* \param flags Bitwise-or of flags, or zero for no flags.
|
||||
*
|
||||
* \return - LZMA_OK: Initialization was successful.
|
||||
* - LZMA_MEM_ERROR: Cannot allocate memory.
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported flags
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_auto_decoder(
|
||||
lzma_stream *strm, uint64_t memlimit, uint32_t flags)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .lzma decoder (legacy file format)
|
||||
*
|
||||
* Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
|
||||
* There is no need to use LZMA_FINISH, but allowing it may simplify
|
||||
* certain types of applications.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_alone_decoder(
|
||||
lzma_stream *strm, uint64_t memlimit)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Stream decoder
|
||||
*
|
||||
* \param memlimit Pointer to how much memory the decoder is allowed
|
||||
* to allocate. The value pointed by this pointer is
|
||||
* modified if and only if LZMA_MEMLIMIT_ERROR is
|
||||
* returned.
|
||||
* \param flags Bitwise-or of zero or more of the decoder flags:
|
||||
* LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
|
||||
* LZMA_CONCATENATED. Note that LZMA_TELL_ANY_CHECK
|
||||
* is not allowed and will return LZMA_PROG_ERROR.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_pos The next byte will be read from in[*in_pos].
|
||||
* *in_pos is updated only if decoding succeeds.
|
||||
* \param in_size Size of the input buffer; the first byte that
|
||||
* won't be read is in[in_size].
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if decoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful.
|
||||
* - LZMA_FORMAT_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_NO_CHECK: This can be returned only if using
|
||||
* the LZMA_TELL_NO_CHECK flag.
|
||||
* - LZMA_UNSUPPORTED_CHECK: This can be returned only if using
|
||||
* the LZMA_TELL_UNSUPPORTED_CHECK flag.
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
|
||||
* The minimum required memlimit value was stored to *memlimit.
|
||||
* - LZMA_BUF_ERROR: Output buffer was too small.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_buffer_decode(
|
||||
uint64_t *memlimit, uint32_t flags,
|
||||
const lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
77
electron/node_modules/lzma-native/deps/include/lzma/delta.h
generated
vendored
Normal file
77
electron/node_modules/lzma-native/deps/include/lzma/delta.h
generated
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* \file lzma/delta.h
|
||||
* \brief Delta filter
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Filter ID
|
||||
*
|
||||
* Filter ID of the Delta filter. This is used as lzma_filter.id.
|
||||
*/
|
||||
#define LZMA_FILTER_DELTA LZMA_VLI_C(0x03)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Type of the delta calculation
|
||||
*
|
||||
* Currently only byte-wise delta is supported. Other possible types could
|
||||
* be, for example, delta of 16/32/64-bit little/big endian integers, but
|
||||
* these are not currently planned since byte-wise delta is almost as good.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_DELTA_TYPE_BYTE
|
||||
} lzma_delta_type;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for the Delta filter
|
||||
*
|
||||
* These options are needed by both encoder and decoder.
|
||||
*/
|
||||
typedef struct {
|
||||
/** For now, this must always be LZMA_DELTA_TYPE_BYTE. */
|
||||
lzma_delta_type type;
|
||||
|
||||
/**
|
||||
* \brief Delta distance
|
||||
*
|
||||
* With the only currently supported type, LZMA_DELTA_TYPE_BYTE,
|
||||
* the distance is as bytes.
|
||||
*
|
||||
* Examples:
|
||||
* - 16-bit stereo audio: distance = 4 bytes
|
||||
* - 24-bit RGB image data: distance = 3 bytes
|
||||
*/
|
||||
uint32_t dist;
|
||||
# define LZMA_DELTA_DIST_MIN 1
|
||||
# define LZMA_DELTA_DIST_MAX 256
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. You should not touch these, because the names
|
||||
* of these variables may change. These are and will never be used
|
||||
* when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these
|
||||
* uninitialized.
|
||||
*/
|
||||
uint32_t reserved_int1;
|
||||
uint32_t reserved_int2;
|
||||
uint32_t reserved_int3;
|
||||
uint32_t reserved_int4;
|
||||
void *reserved_ptr1;
|
||||
void *reserved_ptr2;
|
||||
|
||||
} lzma_options_delta;
|
||||
425
electron/node_modules/lzma-native/deps/include/lzma/filter.h
generated
vendored
Normal file
425
electron/node_modules/lzma-native/deps/include/lzma/filter.h
generated
vendored
Normal file
|
|
@ -0,0 +1,425 @@
|
|||
/**
|
||||
* \file lzma/filter.h
|
||||
* \brief Common filter related types and functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Maximum number of filters in a chain
|
||||
*
|
||||
* A filter chain can have 1-4 filters, of which three are allowed to change
|
||||
* the size of the data. Usually only one or two filters are needed.
|
||||
*/
|
||||
#define LZMA_FILTERS_MAX 4
|
||||
|
||||
|
||||
/**
|
||||
* \brief Filter options
|
||||
*
|
||||
* This structure is used to pass Filter ID and a pointer filter's
|
||||
* options to liblzma. A few functions work with a single lzma_filter
|
||||
* structure, while most functions expect a filter chain.
|
||||
*
|
||||
* A filter chain is indicated with an array of lzma_filter structures.
|
||||
* The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter
|
||||
* array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to
|
||||
* be able to hold any arbitrary filter chain. This is important when
|
||||
* using lzma_block_header_decode() from block.h, because too small
|
||||
* array would make liblzma write past the end of the filters array.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Filter ID
|
||||
*
|
||||
* Use constants whose name begin with `LZMA_FILTER_' to specify
|
||||
* different filters. In an array of lzma_filter structures, use
|
||||
* LZMA_VLI_UNKNOWN to indicate end of filters.
|
||||
*
|
||||
* \note This is not an enum, because on some systems enums
|
||||
* cannot be 64-bit.
|
||||
*/
|
||||
lzma_vli id;
|
||||
|
||||
/**
|
||||
* \brief Pointer to filter-specific options structure
|
||||
*
|
||||
* If the filter doesn't need options, set this to NULL. If id is
|
||||
* set to LZMA_VLI_UNKNOWN, options is ignored, and thus
|
||||
* doesn't need be initialized.
|
||||
*/
|
||||
void *options;
|
||||
|
||||
} lzma_filter;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if the given Filter ID is supported for encoding
|
||||
*
|
||||
* Return true if the give Filter ID is supported for encoding by this
|
||||
* liblzma build. Otherwise false is returned.
|
||||
*
|
||||
* There is no way to list which filters are available in this particular
|
||||
* liblzma version and build. It would be useless, because the application
|
||||
* couldn't know what kind of options the filter would need.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if the given Filter ID is supported for decoding
|
||||
*
|
||||
* Return true if the give Filter ID is supported for decoding by this
|
||||
* liblzma build. Otherwise false is returned.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Copy the filters array
|
||||
*
|
||||
* Copy the Filter IDs and filter-specific options from src to dest.
|
||||
* Up to LZMA_FILTERS_MAX filters are copied, plus the terminating
|
||||
* .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least
|
||||
* LZMA_FILTERS_MAX + 1 elements space unless the caller knows that
|
||||
* src is smaller than that.
|
||||
*
|
||||
* Unless the filter-specific options is NULL, the Filter ID has to be
|
||||
* supported by liblzma, because liblzma needs to know the size of every
|
||||
* filter-specific options structure. The filter-specific options are not
|
||||
* validated. If options is NULL, any unsupported Filter IDs are copied
|
||||
* without returning an error.
|
||||
*
|
||||
* Old filter-specific options in dest are not freed, so dest doesn't
|
||||
* need to be initialized by the caller in any way.
|
||||
*
|
||||
* If an error occurs, memory possibly already allocated by this function
|
||||
* is always freed.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options
|
||||
* is not NULL.
|
||||
* - LZMA_PROG_ERROR: src or dest is NULL.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_filters_copy(
|
||||
const lzma_filter *src, lzma_filter *dest,
|
||||
const lzma_allocator *allocator) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate approximate memory requirements for raw encoder
|
||||
*
|
||||
* This function can be used to calculate the memory requirements for
|
||||
* Block and Stream encoders too because Block and Stream encoders don't
|
||||
* need significantly more memory than raw encoder.
|
||||
*
|
||||
* \param filters Array of filters terminated with
|
||||
* .id == LZMA_VLI_UNKNOWN.
|
||||
*
|
||||
* \return Number of bytes of memory required for the given
|
||||
* filter chain when encoding. If an error occurs,
|
||||
* for example due to unsupported filter chain,
|
||||
* UINT64_MAX is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate approximate memory requirements for raw decoder
|
||||
*
|
||||
* This function can be used to calculate the memory requirements for
|
||||
* Block and Stream decoders too because Block and Stream decoders don't
|
||||
* need significantly more memory than raw decoder.
|
||||
*
|
||||
* \param filters Array of filters terminated with
|
||||
* .id == LZMA_VLI_UNKNOWN.
|
||||
*
|
||||
* \return Number of bytes of memory required for the given
|
||||
* filter chain when decoding. If an error occurs,
|
||||
* for example due to unsupported filter chain,
|
||||
* UINT64_MAX is returned.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize raw encoder
|
||||
*
|
||||
* This function may be useful when implementing custom file formats.
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param filters Array of lzma_filter structures. The end of the
|
||||
* array must be marked with .id = LZMA_VLI_UNKNOWN.
|
||||
*
|
||||
* The `action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the
|
||||
* filter chain supports it), or LZMA_FINISH.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_raw_encoder(
|
||||
lzma_stream *strm, const lzma_filter *filters)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize raw decoder
|
||||
*
|
||||
* The initialization of raw decoder goes similarly to raw encoder.
|
||||
*
|
||||
* The `action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using
|
||||
* LZMA_FINISH is not required, it is supported just for convenience.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_raw_decoder(
|
||||
lzma_stream *strm, const lzma_filter *filters)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Update the filter chain in the encoder
|
||||
*
|
||||
* This function is for advanced users only. This function has two slightly
|
||||
* different purposes:
|
||||
*
|
||||
* - After LZMA_FULL_FLUSH when using Stream encoder: Set a new filter
|
||||
* chain, which will be used starting from the next Block.
|
||||
*
|
||||
* - After LZMA_SYNC_FLUSH using Raw, Block, or Stream encoder: Change
|
||||
* the filter-specific options in the middle of encoding. The actual
|
||||
* filters in the chain (Filter IDs) cannot be changed. In the future,
|
||||
* it might become possible to change the filter options without
|
||||
* using LZMA_SYNC_FLUSH.
|
||||
*
|
||||
* While rarely useful, this function may be called also when no data has
|
||||
* been compressed yet. In that case, this function will behave as if
|
||||
* LZMA_FULL_FLUSH (Stream encoder) or LZMA_SYNC_FLUSH (Raw or Block
|
||||
* encoder) had been used right before calling this function.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_MEMLIMIT_ERROR
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_filters_update(
|
||||
lzma_stream *strm, const lzma_filter *filters) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call raw encoder
|
||||
*
|
||||
* \param filters Array of lzma_filter structures. The end of the
|
||||
* array must be marked with .id = LZMA_VLI_UNKNOWN.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_size Size of the input buffer
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*
|
||||
* \note There is no function to calculate how big output buffer
|
||||
* would surely be big enough. (lzma_stream_buffer_bound()
|
||||
* works only for lzma_stream_buffer_encode(); raw encoder
|
||||
* won't necessarily meet that bound.)
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_raw_buffer_encode(
|
||||
const lzma_filter *filters, const lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t in_size, uint8_t *out,
|
||||
size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call raw decoder
|
||||
*
|
||||
* \param filters Array of lzma_filter structures. The end of the
|
||||
* array must be marked with .id = LZMA_VLI_UNKNOWN.
|
||||
* \param allocator lzma_allocator for custom allocator functions.
|
||||
* Set to NULL to use malloc() and free().
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_pos The next byte will be read from in[*in_pos].
|
||||
* *in_pos is updated only if decoding succeeds.
|
||||
* \param in_size Size of the input buffer; the first byte that
|
||||
* won't be read is in[in_size].
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_raw_buffer_decode(
|
||||
const lzma_filter *filters, const lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the size of the Filter Properties field
|
||||
*
|
||||
* This function may be useful when implementing custom file formats
|
||||
* using the raw encoder and decoder.
|
||||
*
|
||||
* \param size Pointer to uint32_t to hold the size of the properties
|
||||
* \param filter Filter ID and options (the size of the properties may
|
||||
* vary depending on the options)
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*
|
||||
* \note This function validates the Filter ID, but does not
|
||||
* necessarily validate the options. Thus, it is possible
|
||||
* that this returns LZMA_OK while the following call to
|
||||
* lzma_properties_encode() returns LZMA_OPTIONS_ERROR.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_properties_size(
|
||||
uint32_t *size, const lzma_filter *filter) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode the Filter Properties field
|
||||
*
|
||||
* \param filter Filter ID and options
|
||||
* \param props Buffer to hold the encoded options. The size of
|
||||
* buffer must have been already determined with
|
||||
* lzma_properties_size().
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*
|
||||
* \note Even this function won't validate more options than actually
|
||||
* necessary. Thus, it is possible that encoding the properties
|
||||
* succeeds but using the same options to initialize the encoder
|
||||
* will fail.
|
||||
*
|
||||
* \note If lzma_properties_size() indicated that the size
|
||||
* of the Filter Properties field is zero, calling
|
||||
* lzma_properties_encode() is not required, but it
|
||||
* won't do any harm either.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_properties_encode(
|
||||
const lzma_filter *filter, uint8_t *props) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode the Filter Properties field
|
||||
*
|
||||
* \param filter filter->id must have been set to the correct
|
||||
* Filter ID. filter->options doesn't need to be
|
||||
* initialized (it's not freed by this function). The
|
||||
* decoded options will be stored to filter->options.
|
||||
* filter->options is set to NULL if there are no
|
||||
* properties or if an error occurs.
|
||||
* \param allocator Custom memory allocator used to allocate the
|
||||
* options. Set to NULL to use the default malloc(),
|
||||
* and in case of an error, also free().
|
||||
* \param props Input buffer containing the properties.
|
||||
* \param props_size Size of the properties. This must be the exact
|
||||
* size; giving too much or too little input will
|
||||
* return LZMA_OPTIONS_ERROR.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_properties_decode(
|
||||
lzma_filter *filter, const lzma_allocator *allocator,
|
||||
const uint8_t *props, size_t props_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate encoded size of a Filter Flags field
|
||||
*
|
||||
* Knowing the size of Filter Flags is useful to know when allocating
|
||||
* memory to hold the encoded Filter Flags.
|
||||
*
|
||||
* \param size Pointer to integer to hold the calculated size
|
||||
* \param filter Filter ID and associated options whose encoded
|
||||
* size is to be calculated
|
||||
*
|
||||
* \return - LZMA_OK: *size set successfully. Note that this doesn't
|
||||
* guarantee that filter->options is valid, thus
|
||||
* lzma_filter_flags_encode() may still fail.
|
||||
* - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options.
|
||||
* - LZMA_PROG_ERROR: Invalid options
|
||||
*
|
||||
* \note If you need to calculate size of List of Filter Flags,
|
||||
* you need to loop over every lzma_filter entry.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_filter_flags_size(
|
||||
uint32_t *size, const lzma_filter *filter)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode Filter Flags into given buffer
|
||||
*
|
||||
* In contrast to some functions, this doesn't allocate the needed buffer.
|
||||
* This is due to how this function is used internally by liblzma.
|
||||
*
|
||||
* \param filter Filter ID and options to be encoded
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos out[*out_pos] is the next write position. This
|
||||
* is updated by the encoder.
|
||||
* \param out_size out[out_size] is the first byte to not write.
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
|
||||
* - LZMA_PROG_ERROR: Invalid options or not enough output
|
||||
* buffer space (you should have checked it with
|
||||
* lzma_filter_flags_size()).
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode Filter Flags from given buffer
|
||||
*
|
||||
* The decoded result is stored into *filter. The old value of
|
||||
* filter->options is not free()d.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_OPTIONS_ERROR
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_filter_flags_decode(
|
||||
lzma_filter *filter, const lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
64
electron/node_modules/lzma-native/deps/include/lzma/hardware.h
generated
vendored
Normal file
64
electron/node_modules/lzma-native/deps/include/lzma/hardware.h
generated
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* \file lzma/hardware.h
|
||||
* \brief Hardware information
|
||||
*
|
||||
* Since liblzma can consume a lot of system resources, it also provides
|
||||
* ways to limit the resource usage. Applications linking against liblzma
|
||||
* need to do the actual decisions how much resources to let liblzma to use.
|
||||
* To ease making these decisions, liblzma provides functions to find out
|
||||
* the relevant capabilities of the underlaying hardware. Currently there
|
||||
* is only a function to find out the amount of RAM, but in the future there
|
||||
* will be also a function to detect how many concurrent threads the system
|
||||
* can run.
|
||||
*
|
||||
* \note On some operating systems, these function may temporarily
|
||||
* load a shared library or open file descriptor(s) to find out
|
||||
* the requested hardware information. Unless the application
|
||||
* assumes that specific file descriptors are not touched by
|
||||
* other threads, this should have no effect on thread safety.
|
||||
* Possible operations involving file descriptors will restart
|
||||
* the syscalls if they return EINTR.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the total amount of physical memory (RAM) in bytes
|
||||
*
|
||||
* This function may be useful when determining a reasonable memory
|
||||
* usage limit for decompressing or how much memory it is OK to use
|
||||
* for compressing.
|
||||
*
|
||||
* \return On success, the total amount of physical memory in bytes
|
||||
* is returned. If the amount of RAM cannot be determined,
|
||||
* zero is returned. This can happen if an error occurs
|
||||
* or if there is no code in liblzma to detect the amount
|
||||
* of RAM on the specific operating system.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the number of processor cores or threads
|
||||
*
|
||||
* This function may be useful when determining how many threads to use.
|
||||
* If the hardware supports more than one thread per CPU core, the number
|
||||
* of hardware threads is returned if that information is available.
|
||||
*
|
||||
* \brief On success, the number of available CPU threads or cores is
|
||||
* returned. If this information isn't available or an error
|
||||
* occurs, zero is returned.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow;
|
||||
682
electron/node_modules/lzma-native/deps/include/lzma/index.h
generated
vendored
Normal file
682
electron/node_modules/lzma-native/deps/include/lzma/index.h
generated
vendored
Normal file
|
|
@ -0,0 +1,682 @@
|
|||
/**
|
||||
* \file lzma/index.h
|
||||
* \brief Handling of .xz Index and related information
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Opaque data type to hold the Index(es) and other information
|
||||
*
|
||||
* lzma_index often holds just one .xz Index and possibly the Stream Flags
|
||||
* of the same Stream and size of the Stream Padding field. However,
|
||||
* multiple lzma_indexes can be concatenated with lzma_index_cat() and then
|
||||
* there may be information about multiple Streams in the same lzma_index.
|
||||
*
|
||||
* Notes about thread safety: Only one thread may modify lzma_index at
|
||||
* a time. All functions that take non-const pointer to lzma_index
|
||||
* modify it. As long as no thread is modifying the lzma_index, getting
|
||||
* information from the same lzma_index can be done from multiple threads
|
||||
* at the same time with functions that take a const pointer to
|
||||
* lzma_index or use lzma_index_iter. The same iterator must be used
|
||||
* only by one thread at a time, of course, but there can be as many
|
||||
* iterators for the same lzma_index as needed.
|
||||
*/
|
||||
typedef struct lzma_index_s lzma_index;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Iterator to get information about Blocks and Streams
|
||||
*/
|
||||
typedef struct {
|
||||
struct {
|
||||
/**
|
||||
* \brief Pointer to Stream Flags
|
||||
*
|
||||
* This is NULL if Stream Flags have not been set for
|
||||
* this Stream with lzma_index_stream_flags().
|
||||
*/
|
||||
const lzma_stream_flags *flags;
|
||||
|
||||
const void *reserved_ptr1;
|
||||
const void *reserved_ptr2;
|
||||
const void *reserved_ptr3;
|
||||
|
||||
/**
|
||||
* \brief Stream number in the lzma_index
|
||||
*
|
||||
* The first Stream is 1.
|
||||
*/
|
||||
lzma_vli number;
|
||||
|
||||
/**
|
||||
* \brief Number of Blocks in the Stream
|
||||
*
|
||||
* If this is zero, the block structure below has
|
||||
* undefined values.
|
||||
*/
|
||||
lzma_vli block_count;
|
||||
|
||||
/**
|
||||
* \brief Compressed start offset of this Stream
|
||||
*
|
||||
* The offset is relative to the beginning of the lzma_index
|
||||
* (i.e. usually the beginning of the .xz file).
|
||||
*/
|
||||
lzma_vli compressed_offset;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed start offset of this Stream
|
||||
*
|
||||
* The offset is relative to the beginning of the lzma_index
|
||||
* (i.e. usually the beginning of the .xz file).
|
||||
*/
|
||||
lzma_vli uncompressed_offset;
|
||||
|
||||
/**
|
||||
* \brief Compressed size of this Stream
|
||||
*
|
||||
* This includes all headers except the possible
|
||||
* Stream Padding after this Stream.
|
||||
*/
|
||||
lzma_vli compressed_size;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed size of this Stream
|
||||
*/
|
||||
lzma_vli uncompressed_size;
|
||||
|
||||
/**
|
||||
* \brief Size of Stream Padding after this Stream
|
||||
*
|
||||
* If it hasn't been set with lzma_index_stream_padding(),
|
||||
* this defaults to zero. Stream Padding is always
|
||||
* a multiple of four bytes.
|
||||
*/
|
||||
lzma_vli padding;
|
||||
|
||||
lzma_vli reserved_vli1;
|
||||
lzma_vli reserved_vli2;
|
||||
lzma_vli reserved_vli3;
|
||||
lzma_vli reserved_vli4;
|
||||
} stream;
|
||||
|
||||
struct {
|
||||
/**
|
||||
* \brief Block number in the file
|
||||
*
|
||||
* The first Block is 1.
|
||||
*/
|
||||
lzma_vli number_in_file;
|
||||
|
||||
/**
|
||||
* \brief Compressed start offset of this Block
|
||||
*
|
||||
* This offset is relative to the beginning of the
|
||||
* lzma_index (i.e. usually the beginning of the .xz file).
|
||||
* Normally this is where you should seek in the .xz file
|
||||
* to start decompressing this Block.
|
||||
*/
|
||||
lzma_vli compressed_file_offset;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed start offset of this Block
|
||||
*
|
||||
* This offset is relative to the beginning of the lzma_index
|
||||
* (i.e. usually the beginning of the .xz file).
|
||||
*
|
||||
* When doing random-access reading, it is possible that
|
||||
* the target offset is not exactly at Block boundary. One
|
||||
* will need to compare the target offset against
|
||||
* uncompressed_file_offset or uncompressed_stream_offset,
|
||||
* and possibly decode and throw away some amount of data
|
||||
* before reaching the target offset.
|
||||
*/
|
||||
lzma_vli uncompressed_file_offset;
|
||||
|
||||
/**
|
||||
* \brief Block number in this Stream
|
||||
*
|
||||
* The first Block is 1.
|
||||
*/
|
||||
lzma_vli number_in_stream;
|
||||
|
||||
/**
|
||||
* \brief Compressed start offset of this Block
|
||||
*
|
||||
* This offset is relative to the beginning of the Stream
|
||||
* containing this Block.
|
||||
*/
|
||||
lzma_vli compressed_stream_offset;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed start offset of this Block
|
||||
*
|
||||
* This offset is relative to the beginning of the Stream
|
||||
* containing this Block.
|
||||
*/
|
||||
lzma_vli uncompressed_stream_offset;
|
||||
|
||||
/**
|
||||
* \brief Uncompressed size of this Block
|
||||
*
|
||||
* You should pass this to the Block decoder if you will
|
||||
* decode this Block. It will allow the Block decoder to
|
||||
* validate the uncompressed size.
|
||||
*/
|
||||
lzma_vli uncompressed_size;
|
||||
|
||||
/**
|
||||
* \brief Unpadded size of this Block
|
||||
*
|
||||
* You should pass this to the Block decoder if you will
|
||||
* decode this Block. It will allow the Block decoder to
|
||||
* validate the unpadded size.
|
||||
*/
|
||||
lzma_vli unpadded_size;
|
||||
|
||||
/**
|
||||
* \brief Total compressed size
|
||||
*
|
||||
* This includes all headers and padding in this Block.
|
||||
* This is useful if you need to know how many bytes
|
||||
* the Block decoder will actually read.
|
||||
*/
|
||||
lzma_vli total_size;
|
||||
|
||||
lzma_vli reserved_vli1;
|
||||
lzma_vli reserved_vli2;
|
||||
lzma_vli reserved_vli3;
|
||||
lzma_vli reserved_vli4;
|
||||
|
||||
const void *reserved_ptr1;
|
||||
const void *reserved_ptr2;
|
||||
const void *reserved_ptr3;
|
||||
const void *reserved_ptr4;
|
||||
} block;
|
||||
|
||||
/*
|
||||
* Internal data which is used to store the state of the iterator.
|
||||
* The exact format may vary between liblzma versions, so don't
|
||||
* touch these in any way.
|
||||
*/
|
||||
union {
|
||||
const void *p;
|
||||
size_t s;
|
||||
lzma_vli v;
|
||||
} internal[6];
|
||||
} lzma_index_iter;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Operation mode for lzma_index_iter_next()
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_INDEX_ITER_ANY = 0,
|
||||
/**<
|
||||
* \brief Get the next Block or Stream
|
||||
*
|
||||
* Go to the next Block if the current Stream has at least
|
||||
* one Block left. Otherwise go to the next Stream even if
|
||||
* it has no Blocks. If the Stream has no Blocks
|
||||
* (lzma_index_iter.stream.block_count == 0),
|
||||
* lzma_index_iter.block will have undefined values.
|
||||
*/
|
||||
|
||||
LZMA_INDEX_ITER_STREAM = 1,
|
||||
/**<
|
||||
* \brief Get the next Stream
|
||||
*
|
||||
* Go to the next Stream even if the current Stream has
|
||||
* unread Blocks left. If the next Stream has at least one
|
||||
* Block, the iterator will point to the first Block.
|
||||
* If there are no Blocks, lzma_index_iter.block will have
|
||||
* undefined values.
|
||||
*/
|
||||
|
||||
LZMA_INDEX_ITER_BLOCK = 2,
|
||||
/**<
|
||||
* \brief Get the next Block
|
||||
*
|
||||
* Go to the next Block if the current Stream has at least
|
||||
* one Block left. If the current Stream has no Blocks left,
|
||||
* the next Stream with at least one Block is located and
|
||||
* the iterator will be made to point to the first Block of
|
||||
* that Stream.
|
||||
*/
|
||||
|
||||
LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3
|
||||
/**<
|
||||
* \brief Get the next non-empty Block
|
||||
*
|
||||
* This is like LZMA_INDEX_ITER_BLOCK except that it will
|
||||
* skip Blocks whose Uncompressed Size is zero.
|
||||
*/
|
||||
|
||||
} lzma_index_iter_mode;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate memory usage of lzma_index
|
||||
*
|
||||
* On disk, the size of the Index field depends on both the number of Records
|
||||
* stored and how big values the Records store (due to variable-length integer
|
||||
* encoding). When the Index is kept in lzma_index structure, the memory usage
|
||||
* depends only on the number of Records/Blocks stored in the Index(es), and
|
||||
* in case of concatenated lzma_indexes, the number of Streams. The size in
|
||||
* RAM is almost always significantly bigger than in the encoded form on disk.
|
||||
*
|
||||
* This function calculates an approximate amount of memory needed hold
|
||||
* the given number of Streams and Blocks in lzma_index structure. This
|
||||
* value may vary between CPU architectures and also between liblzma versions
|
||||
* if the internal implementation is modified.
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_index_memusage(
|
||||
lzma_vli streams, lzma_vli blocks) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calculate the memory usage of an existing lzma_index
|
||||
*
|
||||
* This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i),
|
||||
* lzma_index_block_count(i)).
|
||||
*/
|
||||
extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Allocate and initialize a new lzma_index structure
|
||||
*
|
||||
* \return On success, a pointer to an empty initialized lzma_index is
|
||||
* returned. If allocation fails, NULL is returned.
|
||||
*/
|
||||
extern LZMA_API(lzma_index *) lzma_index_init(const lzma_allocator *allocator)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Deallocate lzma_index
|
||||
*
|
||||
* If i is NULL, this does nothing.
|
||||
*/
|
||||
extern LZMA_API(void) lzma_index_end(
|
||||
lzma_index *i, const lzma_allocator *allocator) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Add a new Block to lzma_index
|
||||
*
|
||||
* \param i Pointer to a lzma_index structure
|
||||
* \param allocator Pointer to lzma_allocator, or NULL to
|
||||
* use malloc()
|
||||
* \param unpadded_size Unpadded Size of a Block. This can be
|
||||
* calculated with lzma_block_unpadded_size()
|
||||
* after encoding or decoding the Block.
|
||||
* \param uncompressed_size Uncompressed Size of a Block. This can be
|
||||
* taken directly from lzma_block structure
|
||||
* after encoding or decoding the Block.
|
||||
*
|
||||
* Appending a new Block does not invalidate iterators. For example,
|
||||
* if an iterator was pointing to the end of the lzma_index, after
|
||||
* lzma_index_append() it is possible to read the next Block with
|
||||
* an existing iterator.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_DATA_ERROR: Compressed or uncompressed size of the
|
||||
* Stream or size of the Index field would grow too big.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_append(
|
||||
lzma_index *i, const lzma_allocator *allocator,
|
||||
lzma_vli unpadded_size, lzma_vli uncompressed_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set the Stream Flags
|
||||
*
|
||||
* Set the Stream Flags of the last (and typically the only) Stream
|
||||
* in lzma_index. This can be useful when reading information from the
|
||||
* lzma_index, because to decode Blocks, knowing the integrity check type
|
||||
* is needed.
|
||||
*
|
||||
* The given Stream Flags are copied into internal preallocated structure
|
||||
* in the lzma_index, thus the caller doesn't need to keep the *stream_flags
|
||||
* available after calling this function.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_stream_flags(
|
||||
lzma_index *i, const lzma_stream_flags *stream_flags)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the types of integrity Checks
|
||||
*
|
||||
* If lzma_index_stream_flags() is used to set the Stream Flags for
|
||||
* every Stream, lzma_index_checks() can be used to get a bitmask to
|
||||
* indicate which Check types have been used. It can be useful e.g. if
|
||||
* showing the Check types to the user.
|
||||
*
|
||||
* The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set the amount of Stream Padding
|
||||
*
|
||||
* Set the amount of Stream Padding of the last (and typically the only)
|
||||
* Stream in the lzma_index. This is needed when planning to do random-access
|
||||
* reading within multiple concatenated Streams.
|
||||
*
|
||||
* By default, the amount of Stream Padding is assumed to be zero bytes.
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_DATA_ERROR: The file size would grow too big.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_stream_padding(
|
||||
lzma_index *i, lzma_vli stream_padding)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the number of Streams
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the number of Blocks
|
||||
*
|
||||
* This returns the total number of Blocks in lzma_index. To get number
|
||||
* of Blocks in individual Streams, use lzma_index_iter.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the size of the Index field as bytes
|
||||
*
|
||||
* This is needed to verify the Backward Size field in the Stream Footer.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the total size of the Stream
|
||||
*
|
||||
* If multiple lzma_indexes have been combined, this works as if the Blocks
|
||||
* were in a single Stream. This is useful if you are going to combine
|
||||
* Blocks from multiple Streams into a single new Stream.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the total size of the Blocks
|
||||
*
|
||||
* This doesn't include the Stream Header, Stream Footer, Stream Padding,
|
||||
* or Index fields.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the total size of the file
|
||||
*
|
||||
* When no lzma_indexes have been combined with lzma_index_cat() and there is
|
||||
* no Stream Padding, this function is identical to lzma_index_stream_size().
|
||||
* If multiple lzma_indexes have been combined, this includes also the headers
|
||||
* of each separate Stream and the possible Stream Padding fields.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the uncompressed size of the file
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize an iterator
|
||||
*
|
||||
* \param iter Pointer to a lzma_index_iter structure
|
||||
* \param i lzma_index to which the iterator will be associated
|
||||
*
|
||||
* This function associates the iterator with the given lzma_index, and calls
|
||||
* lzma_index_iter_rewind() on the iterator.
|
||||
*
|
||||
* This function doesn't allocate any memory, thus there is no
|
||||
* lzma_index_iter_end(). The iterator is valid as long as the
|
||||
* associated lzma_index is valid, that is, until lzma_index_end() or
|
||||
* using it as source in lzma_index_cat(). Specifically, lzma_index doesn't
|
||||
* become invalid if new Blocks are added to it with lzma_index_append() or
|
||||
* if it is used as the destination in lzma_index_cat().
|
||||
*
|
||||
* It is safe to make copies of an initialized lzma_index_iter, for example,
|
||||
* to easily restart reading at some particular position.
|
||||
*/
|
||||
extern LZMA_API(void) lzma_index_iter_init(
|
||||
lzma_index_iter *iter, const lzma_index *i) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Rewind the iterator
|
||||
*
|
||||
* Rewind the iterator so that next call to lzma_index_iter_next() will
|
||||
* return the first Block or Stream.
|
||||
*/
|
||||
extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the next Block or Stream
|
||||
*
|
||||
* \param iter Iterator initialized with lzma_index_iter_init()
|
||||
* \param mode Specify what kind of information the caller wants
|
||||
* to get. See lzma_index_iter_mode for details.
|
||||
*
|
||||
* \return If next Block or Stream matching the mode was found, *iter
|
||||
* is updated and this function returns false. If no Block or
|
||||
* Stream matching the mode is found, *iter is not modified
|
||||
* and this function returns true. If mode is set to an unknown
|
||||
* value, *iter is not modified and this function returns true.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_index_iter_next(
|
||||
lzma_index_iter *iter, lzma_index_iter_mode mode)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Locate a Block
|
||||
*
|
||||
* If it is possible to seek in the .xz file, it is possible to parse
|
||||
* the Index field(s) and use lzma_index_iter_locate() to do random-access
|
||||
* reading with granularity of Block size.
|
||||
*
|
||||
* \param iter Iterator that was earlier initialized with
|
||||
* lzma_index_iter_init().
|
||||
* \param target Uncompressed target offset which the caller would
|
||||
* like to locate from the Stream
|
||||
*
|
||||
* If the target is smaller than the uncompressed size of the Stream (can be
|
||||
* checked with lzma_index_uncompressed_size()):
|
||||
* - Information about the Stream and Block containing the requested
|
||||
* uncompressed offset is stored into *iter.
|
||||
* - Internal state of the iterator is adjusted so that
|
||||
* lzma_index_iter_next() can be used to read subsequent Blocks or Streams.
|
||||
* - This function returns false.
|
||||
*
|
||||
* If target is greater than the uncompressed size of the Stream, *iter
|
||||
* is not modified, and this function returns true.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_index_iter_locate(
|
||||
lzma_index_iter *iter, lzma_vli target) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Concatenate lzma_indexes
|
||||
*
|
||||
* Concatenating lzma_indexes is useful when doing random-access reading in
|
||||
* multi-Stream .xz file, or when combining multiple Streams into single
|
||||
* Stream.
|
||||
*
|
||||
* \param dest lzma_index after which src is appended
|
||||
* \param src lzma_index to be appended after dest. If this
|
||||
* function succeeds, the memory allocated for src
|
||||
* is freed or moved to be part of dest, and all
|
||||
* iterators pointing to src will become invalid.
|
||||
* \param allocator Custom memory allocator; can be NULL to use
|
||||
* malloc() and free().
|
||||
*
|
||||
* \return - LZMA_OK: lzma_indexes were concatenated successfully.
|
||||
* src is now a dangling pointer.
|
||||
* - LZMA_DATA_ERROR: *dest would grow too big.
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_cat(lzma_index *dest, lzma_index *src,
|
||||
const lzma_allocator *allocator)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Duplicate lzma_index
|
||||
*
|
||||
* \return A copy of the lzma_index, or NULL if memory allocation failed.
|
||||
*/
|
||||
extern LZMA_API(lzma_index *) lzma_index_dup(
|
||||
const lzma_index *i, const lzma_allocator *allocator)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Index encoder
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param i Pointer to lzma_index which should be encoded.
|
||||
*
|
||||
* The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
|
||||
* It is enough to use only one of them (you can choose freely; use LZMA_RUN
|
||||
* to support liblzma versions older than 5.0.0).
|
||||
*
|
||||
* \return - LZMA_OK: Initialization succeeded, continue with lzma_code().
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_encoder(
|
||||
lzma_stream *strm, const lzma_index *i)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Initialize .xz Index decoder
|
||||
*
|
||||
* \param strm Pointer to properly prepared lzma_stream
|
||||
* \param i The decoded Index will be made available via
|
||||
* this pointer. Initially this function will
|
||||
* set *i to NULL (the old value is ignored). If
|
||||
* decoding succeeds (lzma_code() returns
|
||||
* LZMA_STREAM_END), *i will be set to point
|
||||
* to a new lzma_index, which the application
|
||||
* has to later free with lzma_index_end().
|
||||
* \param memlimit How much memory the resulting lzma_index is
|
||||
* allowed to require.
|
||||
*
|
||||
* The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
|
||||
* It is enough to use only one of them (you can choose freely; use LZMA_RUN
|
||||
* to support liblzma versions older than 5.0.0).
|
||||
*
|
||||
* \return - LZMA_OK: Initialization succeeded, continue with lzma_code().
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_MEMLIMIT_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_decoder(
|
||||
lzma_stream *strm, lzma_index **i, uint64_t memlimit)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Index encoder
|
||||
*
|
||||
* \param i lzma_index to be encoded
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* *out_pos is updated only if encoding succeeds.
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_BUF_ERROR: Output buffer is too small. Use
|
||||
* lzma_index_size() to find out how much output
|
||||
* space is needed.
|
||||
* - LZMA_PROG_ERROR
|
||||
*
|
||||
* \note This function doesn't take allocator argument since all
|
||||
* the internal data is allocated on stack.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Single-call .xz Index decoder
|
||||
*
|
||||
* \param i If decoding succeeds, *i will point to a new
|
||||
* lzma_index, which the application has to
|
||||
* later free with lzma_index_end(). If an error
|
||||
* occurs, *i will be NULL. The old value of *i
|
||||
* is always ignored and thus doesn't need to be
|
||||
* initialized by the caller.
|
||||
* \param memlimit Pointer to how much memory the resulting
|
||||
* lzma_index is allowed to require. The value
|
||||
* pointed by this pointer is modified if and only
|
||||
* if LZMA_MEMLIMIT_ERROR is returned.
|
||||
* \param allocator Pointer to lzma_allocator, or NULL to use malloc()
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_pos The next byte will be read from in[*in_pos].
|
||||
* *in_pos is updated only if decoding succeeds.
|
||||
* \param in_size Size of the input buffer; the first byte that
|
||||
* won't be read is in[in_size].
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful.
|
||||
* - LZMA_MEM_ERROR
|
||||
* - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
|
||||
* The minimum required memlimit value was stored to *memlimit.
|
||||
* - LZMA_DATA_ERROR
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i,
|
||||
uint64_t *memlimit, const lzma_allocator *allocator,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||
lzma_nothrow;
|
||||
107
electron/node_modules/lzma-native/deps/include/lzma/index_hash.h
generated
vendored
Normal file
107
electron/node_modules/lzma-native/deps/include/lzma/index_hash.h
generated
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* \file lzma/index_hash.h
|
||||
* \brief Validate Index by using a hash function
|
||||
*
|
||||
* Hashing makes it possible to use constant amount of memory to validate
|
||||
* Index of arbitrary size.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Opaque data type to hold the Index hash
|
||||
*/
|
||||
typedef struct lzma_index_hash_s lzma_index_hash;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Allocate and initialize a new lzma_index_hash structure
|
||||
*
|
||||
* If index_hash is NULL, a new lzma_index_hash structure is allocated,
|
||||
* initialized, and a pointer to it returned. If allocation fails, NULL
|
||||
* is returned.
|
||||
*
|
||||
* If index_hash is non-NULL, it is reinitialized and the same pointer
|
||||
* returned. In this case, return value cannot be NULL or a different
|
||||
* pointer than the index_hash that was given as an argument.
|
||||
*/
|
||||
extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(
|
||||
lzma_index_hash *index_hash, const lzma_allocator *allocator)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Deallocate lzma_index_hash structure
|
||||
*/
|
||||
extern LZMA_API(void) lzma_index_hash_end(
|
||||
lzma_index_hash *index_hash, const lzma_allocator *allocator)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Add a new Record to an Index hash
|
||||
*
|
||||
* \param index Pointer to a lzma_index_hash structure
|
||||
* \param unpadded_size Unpadded Size of a Block
|
||||
* \param uncompressed_size Uncompressed Size of a Block
|
||||
*
|
||||
* \return - LZMA_OK
|
||||
* - LZMA_DATA_ERROR: Compressed or uncompressed size of the
|
||||
* Stream or size of the Index field would grow too big.
|
||||
* - LZMA_PROG_ERROR: Invalid arguments or this function is being
|
||||
* used when lzma_index_hash_decode() has already been used.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash,
|
||||
lzma_vli unpadded_size, lzma_vli uncompressed_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode and validate the Index field
|
||||
*
|
||||
* After telling the sizes of all Blocks with lzma_index_hash_append(),
|
||||
* the actual Index field is decoded with this function. Specifically,
|
||||
* once decoding of the Index field has been started, no more Records
|
||||
* can be added using lzma_index_hash_append().
|
||||
*
|
||||
* This function doesn't use lzma_stream structure to pass the input data.
|
||||
* Instead, the input buffer is specified using three arguments. This is
|
||||
* because it matches better the internal APIs of liblzma.
|
||||
*
|
||||
* \param index_hash Pointer to a lzma_index_hash structure
|
||||
* \param in Pointer to the beginning of the input buffer
|
||||
* \param in_pos in[*in_pos] is the next byte to process
|
||||
* \param in_size in[in_size] is the first byte not to process
|
||||
*
|
||||
* \return - LZMA_OK: So far good, but more input is needed.
|
||||
* - LZMA_STREAM_END: Index decoded successfully and it matches
|
||||
* the Records given with lzma_index_hash_append().
|
||||
* - LZMA_DATA_ERROR: Index is corrupt or doesn't match the
|
||||
* information given with lzma_index_hash_append().
|
||||
* - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size.
|
||||
* - LZMA_PROG_ERROR
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the size of the Index field as bytes
|
||||
*
|
||||
* This is needed to verify the Backward Size field in the Stream Footer.
|
||||
*/
|
||||
extern LZMA_API(lzma_vli) lzma_index_hash_size(
|
||||
const lzma_index_hash *index_hash)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
420
electron/node_modules/lzma-native/deps/include/lzma/lzma12.h
generated
vendored
Normal file
420
electron/node_modules/lzma-native/deps/include/lzma/lzma12.h
generated
vendored
Normal file
|
|
@ -0,0 +1,420 @@
|
|||
/**
|
||||
* \file lzma/lzma12.h
|
||||
* \brief LZMA1 and LZMA2 filters
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief LZMA1 Filter ID
|
||||
*
|
||||
* LZMA1 is the very same thing as what was called just LZMA in LZMA Utils,
|
||||
* 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from
|
||||
* accidentally using LZMA when they actually want LZMA2.
|
||||
*
|
||||
* LZMA1 shouldn't be used for new applications unless you _really_ know
|
||||
* what you are doing. LZMA2 is almost always a better choice.
|
||||
*/
|
||||
#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001)
|
||||
|
||||
/**
|
||||
* \brief LZMA2 Filter ID
|
||||
*
|
||||
* Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds
|
||||
* support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion
|
||||
* when trying to compress uncompressible data), possibility to change
|
||||
* lc/lp/pb in the middle of encoding, and some other internal improvements.
|
||||
*/
|
||||
#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Match finders
|
||||
*
|
||||
* Match finder has major effect on both speed and compression ratio.
|
||||
* Usually hash chains are faster than binary trees.
|
||||
*
|
||||
* If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better
|
||||
* choice, because binary trees get much higher compression ratio penalty
|
||||
* with LZMA_SYNC_FLUSH.
|
||||
*
|
||||
* The memory usage formulas are only rough estimates, which are closest to
|
||||
* reality when dict_size is a power of two. The formulas are more complex
|
||||
* in reality, and can also change a little between liblzma versions. Use
|
||||
* lzma_raw_encoder_memusage() to get more accurate estimate of memory usage.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_MF_HC3 = 0x03,
|
||||
/**<
|
||||
* \brief Hash Chain with 2- and 3-byte hashing
|
||||
*
|
||||
* Minimum nice_len: 3
|
||||
*
|
||||
* Memory usage:
|
||||
* - dict_size <= 16 MiB: dict_size * 7.5
|
||||
* - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB
|
||||
*/
|
||||
|
||||
LZMA_MF_HC4 = 0x04,
|
||||
/**<
|
||||
* \brief Hash Chain with 2-, 3-, and 4-byte hashing
|
||||
*
|
||||
* Minimum nice_len: 4
|
||||
*
|
||||
* Memory usage:
|
||||
* - dict_size <= 32 MiB: dict_size * 7.5
|
||||
* - dict_size > 32 MiB: dict_size * 6.5
|
||||
*/
|
||||
|
||||
LZMA_MF_BT2 = 0x12,
|
||||
/**<
|
||||
* \brief Binary Tree with 2-byte hashing
|
||||
*
|
||||
* Minimum nice_len: 2
|
||||
*
|
||||
* Memory usage: dict_size * 9.5
|
||||
*/
|
||||
|
||||
LZMA_MF_BT3 = 0x13,
|
||||
/**<
|
||||
* \brief Binary Tree with 2- and 3-byte hashing
|
||||
*
|
||||
* Minimum nice_len: 3
|
||||
*
|
||||
* Memory usage:
|
||||
* - dict_size <= 16 MiB: dict_size * 11.5
|
||||
* - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB
|
||||
*/
|
||||
|
||||
LZMA_MF_BT4 = 0x14
|
||||
/**<
|
||||
* \brief Binary Tree with 2-, 3-, and 4-byte hashing
|
||||
*
|
||||
* Minimum nice_len: 4
|
||||
*
|
||||
* Memory usage:
|
||||
* - dict_size <= 32 MiB: dict_size * 11.5
|
||||
* - dict_size > 32 MiB: dict_size * 10.5
|
||||
*/
|
||||
} lzma_match_finder;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if given match finder is supported
|
||||
*
|
||||
* Return true if the given match finder is supported by this liblzma build.
|
||||
* Otherwise false is returned. It is safe to call this with a value that
|
||||
* isn't listed in lzma_match_finder enumeration; the return value will be
|
||||
* false.
|
||||
*
|
||||
* There is no way to list which match finders are available in this
|
||||
* particular liblzma version and build. It would be useless, because
|
||||
* a new match finder, which the application developer wasn't aware,
|
||||
* could require giving additional options to the encoder that the older
|
||||
* match finders don't need.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Compression modes
|
||||
*
|
||||
* This selects the function used to analyze the data produced by the match
|
||||
* finder.
|
||||
*/
|
||||
typedef enum {
|
||||
LZMA_MODE_FAST = 1,
|
||||
/**<
|
||||
* \brief Fast compression
|
||||
*
|
||||
* Fast mode is usually at its best when combined with
|
||||
* a hash chain match finder.
|
||||
*/
|
||||
|
||||
LZMA_MODE_NORMAL = 2
|
||||
/**<
|
||||
* \brief Normal compression
|
||||
*
|
||||
* This is usually notably slower than fast mode. Use this
|
||||
* together with binary tree match finders to expose the
|
||||
* full potential of the LZMA1 or LZMA2 encoder.
|
||||
*/
|
||||
} lzma_mode;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if given compression mode is supported
|
||||
*
|
||||
* Return true if the given compression mode is supported by this liblzma
|
||||
* build. Otherwise false is returned. It is safe to call this with a value
|
||||
* that isn't listed in lzma_mode enumeration; the return value will be false.
|
||||
*
|
||||
* There is no way to list which modes are available in this particular
|
||||
* liblzma version and build. It would be useless, because a new compression
|
||||
* mode, which the application developer wasn't aware, could require giving
|
||||
* additional options to the encoder that the older modes don't need.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options specific to the LZMA1 and LZMA2 filters
|
||||
*
|
||||
* Since LZMA1 and LZMA2 share most of the code, it's simplest to share
|
||||
* the options structure too. For encoding, all but the reserved variables
|
||||
* need to be initialized unless specifically mentioned otherwise.
|
||||
* lzma_lzma_preset() can be used to get a good starting point.
|
||||
*
|
||||
* For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and
|
||||
* preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Dictionary size in bytes
|
||||
*
|
||||
* Dictionary size indicates how many bytes of the recently processed
|
||||
* uncompressed data is kept in memory. One method to reduce size of
|
||||
* the uncompressed data is to store distance-length pairs, which
|
||||
* indicate what data to repeat from the dictionary buffer. Thus,
|
||||
* the bigger the dictionary, the better the compression ratio
|
||||
* usually is.
|
||||
*
|
||||
* Maximum size of the dictionary depends on multiple things:
|
||||
* - Memory usage limit
|
||||
* - Available address space (not a problem on 64-bit systems)
|
||||
* - Selected match finder (encoder only)
|
||||
*
|
||||
* Currently the maximum dictionary size for encoding is 1.5 GiB
|
||||
* (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit
|
||||
* systems for certain match finder implementation reasons. In the
|
||||
* future, there may be match finders that support bigger
|
||||
* dictionaries.
|
||||
*
|
||||
* Decoder already supports dictionaries up to 4 GiB - 1 B (i.e.
|
||||
* UINT32_MAX), so increasing the maximum dictionary size of the
|
||||
* encoder won't cause problems for old decoders.
|
||||
*
|
||||
* Because extremely small dictionaries sizes would have unneeded
|
||||
* overhead in the decoder, the minimum dictionary size is 4096 bytes.
|
||||
*
|
||||
* \note When decoding, too big dictionary does no other harm
|
||||
* than wasting memory.
|
||||
*/
|
||||
uint32_t dict_size;
|
||||
# define LZMA_DICT_SIZE_MIN UINT32_C(4096)
|
||||
# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23)
|
||||
|
||||
/**
|
||||
* \brief Pointer to an initial dictionary
|
||||
*
|
||||
* It is possible to initialize the LZ77 history window using
|
||||
* a preset dictionary. It is useful when compressing many
|
||||
* similar, relatively small chunks of data independently from
|
||||
* each other. The preset dictionary should contain typical
|
||||
* strings that occur in the files being compressed. The most
|
||||
* probable strings should be near the end of the preset dictionary.
|
||||
*
|
||||
* This feature should be used only in special situations. For
|
||||
* now, it works correctly only with raw encoding and decoding.
|
||||
* Currently none of the container formats supported by
|
||||
* liblzma allow preset dictionary when decoding, thus if
|
||||
* you create a .xz or .lzma file with preset dictionary, it
|
||||
* cannot be decoded with the regular decoder functions. In the
|
||||
* future, the .xz format will likely get support for preset
|
||||
* dictionary though.
|
||||
*/
|
||||
const uint8_t *preset_dict;
|
||||
|
||||
/**
|
||||
* \brief Size of the preset dictionary
|
||||
*
|
||||
* Specifies the size of the preset dictionary. If the size is
|
||||
* bigger than dict_size, only the last dict_size bytes are
|
||||
* processed.
|
||||
*
|
||||
* This variable is read only when preset_dict is not NULL.
|
||||
* If preset_dict is not NULL but preset_dict_size is zero,
|
||||
* no preset dictionary is used (identical to only setting
|
||||
* preset_dict to NULL).
|
||||
*/
|
||||
uint32_t preset_dict_size;
|
||||
|
||||
/**
|
||||
* \brief Number of literal context bits
|
||||
*
|
||||
* How many of the highest bits of the previous uncompressed
|
||||
* eight-bit byte (also known as `literal') are taken into
|
||||
* account when predicting the bits of the next literal.
|
||||
*
|
||||
* E.g. in typical English text, an upper-case letter is
|
||||
* often followed by a lower-case letter, and a lower-case
|
||||
* letter is usually followed by another lower-case letter.
|
||||
* In the US-ASCII character set, the highest three bits are 010
|
||||
* for upper-case letters and 011 for lower-case letters.
|
||||
* When lc is at least 3, the literal coding can take advantage of
|
||||
* this property in the uncompressed data.
|
||||
*
|
||||
* There is a limit that applies to literal context bits and literal
|
||||
* position bits together: lc + lp <= 4. Without this limit the
|
||||
* decoding could become very slow, which could have security related
|
||||
* results in some cases like email servers doing virus scanning.
|
||||
* This limit also simplifies the internal implementation in liblzma.
|
||||
*
|
||||
* There may be LZMA1 streams that have lc + lp > 4 (maximum possible
|
||||
* lc would be 8). It is not possible to decode such streams with
|
||||
* liblzma.
|
||||
*/
|
||||
uint32_t lc;
|
||||
# define LZMA_LCLP_MIN 0
|
||||
# define LZMA_LCLP_MAX 4
|
||||
# define LZMA_LC_DEFAULT 3
|
||||
|
||||
/**
|
||||
* \brief Number of literal position bits
|
||||
*
|
||||
* lp affects what kind of alignment in the uncompressed data is
|
||||
* assumed when encoding literals. A literal is a single 8-bit byte.
|
||||
* See pb below for more information about alignment.
|
||||
*/
|
||||
uint32_t lp;
|
||||
# define LZMA_LP_DEFAULT 0
|
||||
|
||||
/**
|
||||
* \brief Number of position bits
|
||||
*
|
||||
* pb affects what kind of alignment in the uncompressed data is
|
||||
* assumed in general. The default means four-byte alignment
|
||||
* (2^ pb =2^2=4), which is often a good choice when there's
|
||||
* no better guess.
|
||||
*
|
||||
* When the aligment is known, setting pb accordingly may reduce
|
||||
* the file size a little. E.g. with text files having one-byte
|
||||
* alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can
|
||||
* improve compression slightly. For UTF-16 text, pb=1 is a good
|
||||
* choice. If the alignment is an odd number like 3 bytes, pb=0
|
||||
* might be the best choice.
|
||||
*
|
||||
* Even though the assumed alignment can be adjusted with pb and
|
||||
* lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment.
|
||||
* It might be worth taking into account when designing file formats
|
||||
* that are likely to be often compressed with LZMA1 or LZMA2.
|
||||
*/
|
||||
uint32_t pb;
|
||||
# define LZMA_PB_MIN 0
|
||||
# define LZMA_PB_MAX 4
|
||||
# define LZMA_PB_DEFAULT 2
|
||||
|
||||
/** Compression mode */
|
||||
lzma_mode mode;
|
||||
|
||||
/**
|
||||
* \brief Nice length of a match
|
||||
*
|
||||
* This determines how many bytes the encoder compares from the match
|
||||
* candidates when looking for the best match. Once a match of at
|
||||
* least nice_len bytes long is found, the encoder stops looking for
|
||||
* better candidates and encodes the match. (Naturally, if the found
|
||||
* match is actually longer than nice_len, the actual length is
|
||||
* encoded; it's not truncated to nice_len.)
|
||||
*
|
||||
* Bigger values usually increase the compression ratio and
|
||||
* compression time. For most files, 32 to 128 is a good value,
|
||||
* which gives very good compression ratio at good speed.
|
||||
*
|
||||
* The exact minimum value depends on the match finder. The maximum
|
||||
* is 273, which is the maximum length of a match that LZMA1 and
|
||||
* LZMA2 can encode.
|
||||
*/
|
||||
uint32_t nice_len;
|
||||
|
||||
/** Match finder ID */
|
||||
lzma_match_finder mf;
|
||||
|
||||
/**
|
||||
* \brief Maximum search depth in the match finder
|
||||
*
|
||||
* For every input byte, match finder searches through the hash chain
|
||||
* or binary tree in a loop, each iteration going one step deeper in
|
||||
* the chain or tree. The searching stops if
|
||||
* - a match of at least nice_len bytes long is found;
|
||||
* - all match candidates from the hash chain or binary tree have
|
||||
* been checked; or
|
||||
* - maximum search depth is reached.
|
||||
*
|
||||
* Maximum search depth is needed to prevent the match finder from
|
||||
* wasting too much time in case there are lots of short match
|
||||
* candidates. On the other hand, stopping the search before all
|
||||
* candidates have been checked can reduce compression ratio.
|
||||
*
|
||||
* Setting depth to zero tells liblzma to use an automatic default
|
||||
* value, that depends on the selected match finder and nice_len.
|
||||
* The default is in the range [4, 200] or so (it may vary between
|
||||
* liblzma versions).
|
||||
*
|
||||
* Using a bigger depth value than the default can increase
|
||||
* compression ratio in some cases. There is no strict maximum value,
|
||||
* but high values (thousands or millions) should be used with care:
|
||||
* the encoder could remain fast enough with typical input, but
|
||||
* malicious input could cause the match finder to slow down
|
||||
* dramatically, possibly creating a denial of service attack.
|
||||
*/
|
||||
uint32_t depth;
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. You should not touch these, because the names
|
||||
* of these variables may change. These are and will never be used
|
||||
* with the currently supported options, so it is safe to leave these
|
||||
* uninitialized.
|
||||
*/
|
||||
uint32_t reserved_int1;
|
||||
uint32_t reserved_int2;
|
||||
uint32_t reserved_int3;
|
||||
uint32_t reserved_int4;
|
||||
uint32_t reserved_int5;
|
||||
uint32_t reserved_int6;
|
||||
uint32_t reserved_int7;
|
||||
uint32_t reserved_int8;
|
||||
lzma_reserved_enum reserved_enum1;
|
||||
lzma_reserved_enum reserved_enum2;
|
||||
lzma_reserved_enum reserved_enum3;
|
||||
lzma_reserved_enum reserved_enum4;
|
||||
void *reserved_ptr1;
|
||||
void *reserved_ptr2;
|
||||
|
||||
} lzma_options_lzma;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Set a compression preset to lzma_options_lzma structure
|
||||
*
|
||||
* 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9
|
||||
* of the xz command line tool. In addition, it is possible to bitwise-or
|
||||
* flags to the preset. Currently only LZMA_PRESET_EXTREME is supported.
|
||||
* The flags are defined in container.h, because the flags are used also
|
||||
* with lzma_easy_encoder().
|
||||
*
|
||||
* The preset values are subject to changes between liblzma versions.
|
||||
*
|
||||
* This function is available only if LZMA1 or LZMA2 encoder has been enabled
|
||||
* when building liblzma.
|
||||
*
|
||||
* \return On success, false is returned. If the preset is not
|
||||
* supported, true is returned.
|
||||
*/
|
||||
extern LZMA_API(lzma_bool) lzma_lzma_preset(
|
||||
lzma_options_lzma *options, uint32_t preset) lzma_nothrow;
|
||||
223
electron/node_modules/lzma-native/deps/include/lzma/stream_flags.h
generated
vendored
Normal file
223
electron/node_modules/lzma-native/deps/include/lzma/stream_flags.h
generated
vendored
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
/**
|
||||
* \file lzma/stream_flags.h
|
||||
* \brief .xz Stream Header and Stream Footer encoder and decoder
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Size of Stream Header and Stream Footer
|
||||
*
|
||||
* Stream Header and Stream Footer have the same size and they are not
|
||||
* going to change even if a newer version of the .xz file format is
|
||||
* developed in future.
|
||||
*/
|
||||
#define LZMA_STREAM_HEADER_SIZE 12
|
||||
|
||||
|
||||
/**
|
||||
* \brief Options for encoding/decoding Stream Header and Stream Footer
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Stream Flags format version
|
||||
*
|
||||
* To prevent API and ABI breakages if new features are needed in
|
||||
* Stream Header or Stream Footer, a version number is used to
|
||||
* indicate which fields in this structure are in use. For now,
|
||||
* version must always be zero. With non-zero version, the
|
||||
* lzma_stream_header_encode() and lzma_stream_footer_encode()
|
||||
* will return LZMA_OPTIONS_ERROR.
|
||||
*
|
||||
* lzma_stream_header_decode() and lzma_stream_footer_decode()
|
||||
* will always set this to the lowest value that supports all the
|
||||
* features indicated by the Stream Flags field. The application
|
||||
* must check that the version number set by the decoding functions
|
||||
* is supported by the application. Otherwise it is possible that
|
||||
* the application will decode the Stream incorrectly.
|
||||
*/
|
||||
uint32_t version;
|
||||
|
||||
/**
|
||||
* \brief Backward Size
|
||||
*
|
||||
* Backward Size must be a multiple of four bytes. In this Stream
|
||||
* format version, Backward Size is the size of the Index field.
|
||||
*
|
||||
* Backward Size isn't actually part of the Stream Flags field, but
|
||||
* it is convenient to include in this structure anyway. Backward
|
||||
* Size is present only in the Stream Footer. There is no need to
|
||||
* initialize backward_size when encoding Stream Header.
|
||||
*
|
||||
* lzma_stream_header_decode() always sets backward_size to
|
||||
* LZMA_VLI_UNKNOWN so that it is convenient to use
|
||||
* lzma_stream_flags_compare() when both Stream Header and Stream
|
||||
* Footer have been decoded.
|
||||
*/
|
||||
lzma_vli backward_size;
|
||||
# define LZMA_BACKWARD_SIZE_MIN 4
|
||||
# define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34)
|
||||
|
||||
/**
|
||||
* \brief Check ID
|
||||
*
|
||||
* This indicates the type of the integrity check calculated from
|
||||
* uncompressed data.
|
||||
*/
|
||||
lzma_check check;
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. You should not touch these, because the
|
||||
* names of these variables may change.
|
||||
*
|
||||
* (We will never be able to use all of these since Stream Flags
|
||||
* is just two bytes plus Backward Size of four bytes. But it's
|
||||
* nice to have the proper types when they are needed.)
|
||||
*/
|
||||
lzma_reserved_enum reserved_enum1;
|
||||
lzma_reserved_enum reserved_enum2;
|
||||
lzma_reserved_enum reserved_enum3;
|
||||
lzma_reserved_enum reserved_enum4;
|
||||
lzma_bool reserved_bool1;
|
||||
lzma_bool reserved_bool2;
|
||||
lzma_bool reserved_bool3;
|
||||
lzma_bool reserved_bool4;
|
||||
lzma_bool reserved_bool5;
|
||||
lzma_bool reserved_bool6;
|
||||
lzma_bool reserved_bool7;
|
||||
lzma_bool reserved_bool8;
|
||||
uint32_t reserved_int1;
|
||||
uint32_t reserved_int2;
|
||||
|
||||
} lzma_stream_flags;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode Stream Header
|
||||
*
|
||||
* \param options Stream Header options to be encoded.
|
||||
* options->backward_size is ignored and doesn't
|
||||
* need to be initialized.
|
||||
* \param out Beginning of the output buffer of
|
||||
* LZMA_STREAM_HEADER_SIZE bytes.
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_OPTIONS_ERROR: options->version is not supported by
|
||||
* this liblzma version.
|
||||
* - LZMA_PROG_ERROR: Invalid options.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_header_encode(
|
||||
const lzma_stream_flags *options, uint8_t *out)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode Stream Footer
|
||||
*
|
||||
* \param options Stream Footer options to be encoded.
|
||||
* \param out Beginning of the output buffer of
|
||||
* LZMA_STREAM_HEADER_SIZE bytes.
|
||||
*
|
||||
* \return - LZMA_OK: Encoding was successful.
|
||||
* - LZMA_OPTIONS_ERROR: options->version is not supported by
|
||||
* this liblzma version.
|
||||
* - LZMA_PROG_ERROR: Invalid options.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_footer_encode(
|
||||
const lzma_stream_flags *options, uint8_t *out)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode Stream Header
|
||||
*
|
||||
* \param options Target for the decoded Stream Header options.
|
||||
* \param in Beginning of the input buffer of
|
||||
* LZMA_STREAM_HEADER_SIZE bytes.
|
||||
*
|
||||
* options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to
|
||||
* help comparing Stream Flags from Stream Header and Stream Footer with
|
||||
* lzma_stream_flags_compare().
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful.
|
||||
* - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
|
||||
* buffer cannot be Stream Header.
|
||||
* - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header
|
||||
* is corrupt.
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported options are present
|
||||
* in the header.
|
||||
*
|
||||
* \note When decoding .xz files that contain multiple Streams, it may
|
||||
* make sense to print "file format not recognized" only if
|
||||
* decoding of the Stream Header of the _first_ Stream gives
|
||||
* LZMA_FORMAT_ERROR. If non-first Stream Header gives
|
||||
* LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is
|
||||
* probably more appropriate.
|
||||
*
|
||||
* For example, Stream decoder in liblzma uses LZMA_DATA_ERROR if
|
||||
* LZMA_FORMAT_ERROR is returned by lzma_stream_header_decode()
|
||||
* when decoding non-first Stream.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_header_decode(
|
||||
lzma_stream_flags *options, const uint8_t *in)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode Stream Footer
|
||||
*
|
||||
* \param options Target for the decoded Stream Header options.
|
||||
* \param in Beginning of the input buffer of
|
||||
* LZMA_STREAM_HEADER_SIZE bytes.
|
||||
*
|
||||
* \return - LZMA_OK: Decoding was successful.
|
||||
* - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
|
||||
* buffer cannot be Stream Footer.
|
||||
* - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer
|
||||
* is corrupt.
|
||||
* - LZMA_OPTIONS_ERROR: Unsupported options are present
|
||||
* in Stream Footer.
|
||||
*
|
||||
* \note If Stream Header was already decoded successfully, but
|
||||
* decoding Stream Footer returns LZMA_FORMAT_ERROR, the
|
||||
* application should probably report some other error message
|
||||
* than "file format not recognized", since the file more likely
|
||||
* is corrupt (possibly truncated). Stream decoder in liblzma
|
||||
* uses LZMA_DATA_ERROR in this situation.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_footer_decode(
|
||||
lzma_stream_flags *options, const uint8_t *in)
|
||||
lzma_nothrow lzma_attr_warn_unused_result;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Compare two lzma_stream_flags structures
|
||||
*
|
||||
* backward_size values are compared only if both are not
|
||||
* LZMA_VLI_UNKNOWN.
|
||||
*
|
||||
* \return - LZMA_OK: Both are equal. If either had backward_size set
|
||||
* to LZMA_VLI_UNKNOWN, backward_size values were not
|
||||
* compared or validated.
|
||||
* - LZMA_DATA_ERROR: The structures differ.
|
||||
* - LZMA_OPTIONS_ERROR: version in either structure is greater
|
||||
* than the maximum supported version (currently zero).
|
||||
* - LZMA_PROG_ERROR: Invalid value, e.g. invalid check or
|
||||
* backward_size.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_stream_flags_compare(
|
||||
const lzma_stream_flags *a, const lzma_stream_flags *b)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
121
electron/node_modules/lzma-native/deps/include/lzma/version.h
generated
vendored
Normal file
121
electron/node_modules/lzma-native/deps/include/lzma/version.h
generated
vendored
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
/**
|
||||
* \file lzma/version.h
|
||||
* \brief Version number
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Version number split into components
|
||||
*/
|
||||
#define LZMA_VERSION_MAJOR 5
|
||||
#define LZMA_VERSION_MINOR 2
|
||||
#define LZMA_VERSION_PATCH 3
|
||||
#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE
|
||||
|
||||
#ifndef LZMA_VERSION_COMMIT
|
||||
# define LZMA_VERSION_COMMIT ""
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Map symbolic stability levels to integers.
|
||||
*/
|
||||
#define LZMA_VERSION_STABILITY_ALPHA 0
|
||||
#define LZMA_VERSION_STABILITY_BETA 1
|
||||
#define LZMA_VERSION_STABILITY_STABLE 2
|
||||
|
||||
|
||||
/**
|
||||
* \brief Compile-time version number
|
||||
*
|
||||
* The version number is of format xyyyzzzs where
|
||||
* - x = major
|
||||
* - yyy = minor
|
||||
* - zzz = revision
|
||||
* - s indicates stability: 0 = alpha, 1 = beta, 2 = stable
|
||||
*
|
||||
* The same xyyyzzz triplet is never reused with different stability levels.
|
||||
* For example, if 5.1.0alpha has been released, there will never be 5.1.0beta
|
||||
* or 5.1.0 stable.
|
||||
*
|
||||
* \note The version number of liblzma has nothing to with
|
||||
* the version number of Igor Pavlov's LZMA SDK.
|
||||
*/
|
||||
#define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \
|
||||
+ LZMA_VERSION_MINOR * UINT32_C(10000) \
|
||||
+ LZMA_VERSION_PATCH * UINT32_C(10) \
|
||||
+ LZMA_VERSION_STABILITY)
|
||||
|
||||
|
||||
/*
|
||||
* Macros to construct the compile-time version string
|
||||
*/
|
||||
#if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA
|
||||
# define LZMA_VERSION_STABILITY_STRING "alpha"
|
||||
#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA
|
||||
# define LZMA_VERSION_STABILITY_STRING "beta"
|
||||
#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE
|
||||
# define LZMA_VERSION_STABILITY_STRING ""
|
||||
#else
|
||||
# error Incorrect LZMA_VERSION_STABILITY
|
||||
#endif
|
||||
|
||||
#define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \
|
||||
#major "." #minor "." #patch stability commit
|
||||
|
||||
#define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \
|
||||
LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Compile-time version as a string
|
||||
*
|
||||
* This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable
|
||||
* versions don't have any "stable" suffix). In future, a snapshot built
|
||||
* from source code repository may include an additional suffix, for example
|
||||
* "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form
|
||||
* in LZMA_VERSION macro.
|
||||
*/
|
||||
#define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \
|
||||
LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \
|
||||
LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \
|
||||
LZMA_VERSION_COMMIT)
|
||||
|
||||
|
||||
/* #ifndef is needed for use with windres (MinGW or Cygwin). */
|
||||
#ifndef LZMA_H_INTERNAL_RC
|
||||
|
||||
/**
|
||||
* \brief Run-time version number as an integer
|
||||
*
|
||||
* Return the value of LZMA_VERSION macro at the compile time of liblzma.
|
||||
* This allows the application to compare if it was built against the same,
|
||||
* older, or newer version of liblzma that is currently running.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_version_number(void)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Run-time version as a string
|
||||
*
|
||||
* This function may be useful if you want to display which version of
|
||||
* liblzma your application is currently using.
|
||||
*/
|
||||
extern LZMA_API(const char *) lzma_version_string(void)
|
||||
lzma_nothrow lzma_attr_const;
|
||||
|
||||
#endif
|
||||
166
electron/node_modules/lzma-native/deps/include/lzma/vli.h
generated
vendored
Normal file
166
electron/node_modules/lzma-native/deps/include/lzma/vli.h
generated
vendored
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
/**
|
||||
* \file lzma/vli.h
|
||||
* \brief Variable-length integer handling
|
||||
*
|
||||
* In the .xz format, most integers are encoded in a variable-length
|
||||
* representation, which is sometimes called little endian base-128 encoding.
|
||||
* This saves space when smaller values are more likely than bigger values.
|
||||
*
|
||||
* The encoding scheme encodes seven bits to every byte, using minimum
|
||||
* number of bytes required to represent the given value. Encodings that use
|
||||
* non-minimum number of bytes are invalid, thus every integer has exactly
|
||||
* one encoded representation. The maximum number of bits in a VLI is 63,
|
||||
* thus the vli argument must be less than or equal to UINT64_MAX / 2. You
|
||||
* should use LZMA_VLI_MAX for clarity.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Author: Lasse Collin
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*
|
||||
* See ../lzma.h for information about liblzma as a whole.
|
||||
*/
|
||||
|
||||
#ifndef LZMA_H_INTERNAL
|
||||
# error Never include this file directly. Use <lzma.h> instead.
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* \brief Maximum supported value of a variable-length integer
|
||||
*/
|
||||
#define LZMA_VLI_MAX (UINT64_MAX / 2)
|
||||
|
||||
/**
|
||||
* \brief VLI value to denote that the value is unknown
|
||||
*/
|
||||
#define LZMA_VLI_UNKNOWN UINT64_MAX
|
||||
|
||||
/**
|
||||
* \brief Maximum supported encoded length of variable length integers
|
||||
*/
|
||||
#define LZMA_VLI_BYTES_MAX 9
|
||||
|
||||
/**
|
||||
* \brief VLI constant suffix
|
||||
*/
|
||||
#define LZMA_VLI_C(n) UINT64_C(n)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Variable-length integer type
|
||||
*
|
||||
* Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is
|
||||
* indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the
|
||||
* underlaying integer type.
|
||||
*
|
||||
* lzma_vli will be uint64_t for the foreseeable future. If a bigger size
|
||||
* is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will
|
||||
* not overflow lzma_vli. This simplifies integer overflow detection.
|
||||
*/
|
||||
typedef uint64_t lzma_vli;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Validate a variable-length integer
|
||||
*
|
||||
* This is useful to test that application has given acceptable values
|
||||
* for example in the uncompressed_size and compressed_size variables.
|
||||
*
|
||||
* \return True if the integer is representable as VLI or if it
|
||||
* indicates unknown value.
|
||||
*/
|
||||
#define lzma_vli_is_valid(vli) \
|
||||
((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN)
|
||||
|
||||
|
||||
/**
|
||||
* \brief Encode a variable-length integer
|
||||
*
|
||||
* This function has two modes: single-call and multi-call. Single-call mode
|
||||
* encodes the whole integer at once; it is an error if the output buffer is
|
||||
* too small. Multi-call mode saves the position in *vli_pos, and thus it is
|
||||
* possible to continue encoding if the buffer becomes full before the whole
|
||||
* integer has been encoded.
|
||||
*
|
||||
* \param vli Integer to be encoded
|
||||
* \param vli_pos How many VLI-encoded bytes have already been written
|
||||
* out. When starting to encode a new integer in
|
||||
* multi-call mode, *vli_pos must be set to zero.
|
||||
* To use single-call encoding, set vli_pos to NULL.
|
||||
* \param out Beginning of the output buffer
|
||||
* \param out_pos The next byte will be written to out[*out_pos].
|
||||
* \param out_size Size of the out buffer; the first byte into
|
||||
* which no data is written to is out[out_size].
|
||||
*
|
||||
* \return Slightly different return values are used in multi-call and
|
||||
* single-call modes.
|
||||
*
|
||||
* Single-call (vli_pos == NULL):
|
||||
* - LZMA_OK: Integer successfully encoded.
|
||||
* - LZMA_PROG_ERROR: Arguments are not sane. This can be due
|
||||
* to too little output space; single-call mode doesn't use
|
||||
* LZMA_BUF_ERROR, since the application should have checked
|
||||
* the encoded size with lzma_vli_size().
|
||||
*
|
||||
* Multi-call (vli_pos != NULL):
|
||||
* - LZMA_OK: So far all OK, but the integer is not
|
||||
* completely written out yet.
|
||||
* - LZMA_STREAM_END: Integer successfully encoded.
|
||||
* - LZMA_BUF_ERROR: No output space was provided.
|
||||
* - LZMA_PROG_ERROR: Arguments are not sane.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos,
|
||||
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Decode a variable-length integer
|
||||
*
|
||||
* Like lzma_vli_encode(), this function has single-call and multi-call modes.
|
||||
*
|
||||
* \param vli Pointer to decoded integer. The decoder will
|
||||
* initialize it to zero when *vli_pos == 0, so
|
||||
* application isn't required to initialize *vli.
|
||||
* \param vli_pos How many bytes have already been decoded. When
|
||||
* starting to decode a new integer in multi-call
|
||||
* mode, *vli_pos must be initialized to zero. To
|
||||
* use single-call decoding, set vli_pos to NULL.
|
||||
* \param in Beginning of the input buffer
|
||||
* \param in_pos The next byte will be read from in[*in_pos].
|
||||
* \param in_size Size of the input buffer; the first byte that
|
||||
* won't be read is in[in_size].
|
||||
*
|
||||
* \return Slightly different return values are used in multi-call and
|
||||
* single-call modes.
|
||||
*
|
||||
* Single-call (vli_pos == NULL):
|
||||
* - LZMA_OK: Integer successfully decoded.
|
||||
* - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting
|
||||
* the end of the input buffer before the whole integer was
|
||||
* decoded; providing no input at all will use LZMA_DATA_ERROR.
|
||||
* - LZMA_PROG_ERROR: Arguments are not sane.
|
||||
*
|
||||
* Multi-call (vli_pos != NULL):
|
||||
* - LZMA_OK: So far all OK, but the integer is not
|
||||
* completely decoded yet.
|
||||
* - LZMA_STREAM_END: Integer successfully decoded.
|
||||
* - LZMA_DATA_ERROR: Integer is corrupt.
|
||||
* - LZMA_BUF_ERROR: No input was provided.
|
||||
* - LZMA_PROG_ERROR: Arguments are not sane.
|
||||
*/
|
||||
extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||
lzma_nothrow;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Get the number of bytes required to encode a VLI
|
||||
*
|
||||
* \return Number of bytes on success (1-9). If vli isn't valid,
|
||||
* zero is returned.
|
||||
*/
|
||||
extern LZMA_API(uint32_t) lzma_vli_size(lzma_vli vli)
|
||||
lzma_nothrow lzma_attr_pure;
|
||||
BIN
electron/node_modules/lzma-native/deps/xz-5.2.3-windows.7z.sig
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/deps/xz-5.2.3-windows.7z.sig
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/deps/xz-5.2.3.tar.bz2
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/deps/xz-5.2.3.tar.bz2
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/deps/xz-5.2.3.tar.bz2.sig
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/deps/xz-5.2.3.tar.bz2.sig
generated
vendored
Normal file
Binary file not shown.
595
electron/node_modules/lzma-native/index.js
generated
vendored
Normal file
595
electron/node_modules/lzma-native/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,595 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var stream = require('readable-stream');
|
||||
var assert = require('assert');
|
||||
var fs = require('fs');
|
||||
var util = require('util');
|
||||
|
||||
var native = require('node-gyp-build')(__dirname);
|
||||
|
||||
Object.assign(exports, native);
|
||||
|
||||
// Please do not update this version except as part of a release commit.
|
||||
exports.version = '8.0.6';
|
||||
|
||||
var Stream = exports.Stream;
|
||||
|
||||
Stream.curAsyncStreamsCount = 0;
|
||||
|
||||
Stream.prototype.getStream = function(options) {
|
||||
options = options || {};
|
||||
|
||||
return new JSLzmaStream(this, options);
|
||||
};
|
||||
|
||||
class JSLzmaStream extends stream.Transform {
|
||||
constructor(nativeStream, options) {
|
||||
super(options);
|
||||
|
||||
this.nativeStream = nativeStream;
|
||||
this.synchronous = (options.synchronous || !native.asyncCodeAvailable) ? true : false;
|
||||
this.chunkCallbacks = [];
|
||||
|
||||
this.totalIn_ = 0;
|
||||
this.totalOut_ = 0;
|
||||
|
||||
this._writingLastChunk = false;
|
||||
this._isFinished = false;
|
||||
|
||||
if (!this.synchronous) {
|
||||
Stream.curAsyncStreamsCount++;
|
||||
|
||||
var oldCleanup = this.cleanup;
|
||||
var countedCleanup = false;
|
||||
this.cleanup = () => {
|
||||
if (countedCleanup === false) {
|
||||
Stream.curAsyncStreamsCount--;
|
||||
countedCleanup = true;
|
||||
}
|
||||
oldCleanup.call(this);
|
||||
};
|
||||
}
|
||||
|
||||
// always clean up in case of error
|
||||
this.once('error-cleanup', this.cleanup);
|
||||
|
||||
this.nativeStream.bufferHandler = (buf, processedChunks, err, totalIn, totalOut) => {
|
||||
if (totalIn !== null) {
|
||||
this.totalIn_ = totalIn;
|
||||
this.totalOut_ = totalOut;
|
||||
}
|
||||
|
||||
setImmediate(() => {
|
||||
if (err) {
|
||||
this.push(null);
|
||||
this.emit('error-cleanup', err);
|
||||
this.emit('error', err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (totalIn !== null) {
|
||||
this.emit('progress', {
|
||||
totalIn: this.totalIn_,
|
||||
totalOut: this.totalOut_
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof processedChunks === 'number') {
|
||||
assert.ok(processedChunks <= this.chunkCallbacks.length);
|
||||
|
||||
var chunkCallbacks = this.chunkCallbacks.splice(0, processedChunks);
|
||||
|
||||
while (chunkCallbacks.length > 0)
|
||||
chunkCallbacks.shift().call(this);
|
||||
} else if (buf === null) {
|
||||
if (this._writingLastChunk) {
|
||||
this.push(null);
|
||||
} else {
|
||||
// There may be additional members in the file.
|
||||
// Reset and set _isFinished to tell `_flush()` that nothing
|
||||
// needs to be done.
|
||||
this._isFinished = true;
|
||||
|
||||
if (this.nativeStream && this.nativeStream._restart) {
|
||||
this.nativeStream._restart();
|
||||
} else {
|
||||
this.push(null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.push(buf);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof options.bufsize !== 'undefined') {
|
||||
this.bufsize = options.bufsize;
|
||||
}
|
||||
}
|
||||
|
||||
get bufsize() {
|
||||
return this.setBufsize(null);
|
||||
}
|
||||
|
||||
set bufsize(n) {
|
||||
if (typeof n !== 'number' || n <= 0) {
|
||||
throw new TypeError('bufsize must be a positive number');
|
||||
}
|
||||
|
||||
return this.setBufsize(n);
|
||||
}
|
||||
|
||||
totalIn() {
|
||||
return this.totalIn_;
|
||||
}
|
||||
|
||||
totalOut() {
|
||||
return this.totalOut_;
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
if (this.nativeStream) {
|
||||
this.nativeStream.resetUnderlying();
|
||||
}
|
||||
|
||||
this.nativeStream = null;
|
||||
}
|
||||
|
||||
_transform(chunk, encoding, callback) {
|
||||
if (!this.nativeStream) return;
|
||||
// Split the chunk at 'YZ'. This is used to have a clean boundary at the
|
||||
// end of each `.xz` file stream.
|
||||
var possibleEndIndex = bufferIndexOfYZ(chunk);
|
||||
if (possibleEndIndex !== -1) {
|
||||
possibleEndIndex += 2;
|
||||
if (possibleEndIndex !== chunk.length) {
|
||||
this._transform(chunk.slice(0, possibleEndIndex), encoding, () => {
|
||||
this._transform(chunk.slice(possibleEndIndex), encoding, callback);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._isFinished && chunk) {
|
||||
chunk = skipLeadingZeroes(chunk);
|
||||
|
||||
if (chunk.length > 0) {
|
||||
// Real data from a second stream member in the file!
|
||||
this._isFinished = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (chunk && chunk.length === 0) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
this.chunkCallbacks.push(callback);
|
||||
|
||||
try {
|
||||
this.nativeStream.code(chunk, !this.synchronous);
|
||||
} catch (e) {
|
||||
this.emit('error-cleanup', e);
|
||||
this.emit('error', e);
|
||||
}
|
||||
}
|
||||
|
||||
_writev(chunks, callback) {
|
||||
chunks = chunks.map(chunk => chunk.chunk);
|
||||
this._write(Buffer.concat(chunks), null, callback);
|
||||
}
|
||||
|
||||
_flush(callback) {
|
||||
this._writingLastChunk = true;
|
||||
|
||||
if (this._isFinished) {
|
||||
this.cleanup();
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
|
||||
this._transform(null, null, function() {
|
||||
this.cleanup();
|
||||
callback.apply(this, arguments);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// add all methods from the native Stream
|
||||
Object.getOwnPropertyNames(native.Stream.prototype).forEach(function(key) {
|
||||
if (typeof native.Stream.prototype[key] !== 'function' || key === 'constructor')
|
||||
return;
|
||||
JSLzmaStream.prototype[key] = function() {
|
||||
return this.nativeStream[key].apply(this.nativeStream, arguments);
|
||||
};
|
||||
});
|
||||
|
||||
Stream.prototype.rawEncoder = function(options) {
|
||||
return this.rawEncoder_(options.filters || []);
|
||||
};
|
||||
|
||||
Stream.prototype.rawDecoder = function(options) {
|
||||
return this.rawDecoder_(options.filters || []);
|
||||
};
|
||||
|
||||
Stream.prototype.easyEncoder = function(options) {
|
||||
var preset = options.preset || exports.PRESET_DEFAULT;
|
||||
var check = options.check || exports.CHECK_CRC32;
|
||||
|
||||
if (typeof options.threads !== 'undefined' && options.threads !== null) {
|
||||
return this.mtEncoder_(Object.assign({
|
||||
preset: preset,
|
||||
filters: null,
|
||||
check: check
|
||||
}, options));
|
||||
} else {
|
||||
return this.easyEncoder_(preset, check);
|
||||
}
|
||||
};
|
||||
|
||||
Stream.prototype.streamEncoder = function(options) {
|
||||
var filters = options.filters || [];
|
||||
var check = options.check || exports.CHECK_CRC32;
|
||||
|
||||
if (typeof options.threads !== 'undefined' && options.threads !== null) {
|
||||
return this.mtEncoder_(Object.assign({
|
||||
preset: null,
|
||||
filters: filters,
|
||||
check: check
|
||||
}, options));
|
||||
} else {
|
||||
return this.streamEncoder_(filters, check);
|
||||
}
|
||||
};
|
||||
|
||||
Stream.prototype.streamDecoder = function(options) {
|
||||
this._initOptions = options;
|
||||
this._restart = function() {
|
||||
this.resetUnderlying();
|
||||
this.streamDecoder(this._initOptions);
|
||||
};
|
||||
|
||||
return this.streamDecoder_(options.memlimit || null, options.flags || 0);
|
||||
};
|
||||
|
||||
Stream.prototype.autoDecoder = function(options) {
|
||||
this._initOptions = options;
|
||||
this._restart = function() {
|
||||
this.resetUnderlying();
|
||||
this.autoDecoder(this._initOptions);
|
||||
};
|
||||
|
||||
return this.autoDecoder_(options.memlimit || null, options.flags || 0);
|
||||
};
|
||||
|
||||
Stream.prototype.aloneDecoder = function(options) {
|
||||
return this.aloneDecoder_(options.memlimit || null);
|
||||
};
|
||||
|
||||
/* helper functions for easy creation of streams */
|
||||
var createStream =
|
||||
exports.createStream = function(coder, options) {
|
||||
if (['number', 'object'].indexOf(typeof coder) !== -1 && !options) {
|
||||
options = coder;
|
||||
coder = null;
|
||||
}
|
||||
|
||||
if (parseInt(options) === parseInt(options))
|
||||
options = {preset: parseInt(options)};
|
||||
|
||||
coder = coder || 'easyEncoder';
|
||||
options = options || {};
|
||||
|
||||
var stream = new Stream();
|
||||
stream[coder](options);
|
||||
|
||||
if (options.memlimit)
|
||||
stream.memlimitSet(options.memlimit);
|
||||
|
||||
return stream.getStream(options);
|
||||
};
|
||||
|
||||
exports.createCompressor = function(options) {
|
||||
return createStream('easyEncoder', options);
|
||||
};
|
||||
|
||||
exports.createDecompressor = function(options) {
|
||||
return createStream('autoDecoder', options);
|
||||
};
|
||||
|
||||
exports.crc32 = function(input, encoding, presetCRC32) {
|
||||
if (typeof encoding === 'number') {
|
||||
presetCRC32 = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
if (typeof input === 'string')
|
||||
input = Buffer.from(input, encoding);
|
||||
|
||||
return exports.crc32_(input, presetCRC32 || 0);
|
||||
};
|
||||
|
||||
/* compatibility: node-xz (https://github.com/robey/node-xz) */
|
||||
exports.Compressor = function(preset, options) {
|
||||
options = Object.assign({}, options);
|
||||
|
||||
if (preset)
|
||||
options.preset = preset;
|
||||
|
||||
return createStream('easyEncoder', options);
|
||||
};
|
||||
|
||||
exports.Decompressor = function(options) {
|
||||
return createStream('autoDecoder', options);
|
||||
};
|
||||
|
||||
/* compatibility: LZMA-JS (https://github.com/nmrugg/LZMA-JS) */
|
||||
function singleStringCoding(stream, string, on_finish, on_progress) {
|
||||
on_progress = on_progress || function() {};
|
||||
on_finish = on_finish || function() {};
|
||||
|
||||
// possibly our input is an array of byte integers
|
||||
// or a typed array
|
||||
if (!Buffer.isBuffer(string))
|
||||
string = Buffer.from(string);
|
||||
|
||||
var deferred = {}, failed = false;
|
||||
|
||||
stream.once('error', function(err) {
|
||||
failed = true;
|
||||
on_finish(null, err);
|
||||
});
|
||||
|
||||
// emulate Promise.defer()
|
||||
deferred.promise = new Promise(function(resolve, reject) {
|
||||
deferred.resolve = resolve;
|
||||
deferred.reject = reject;
|
||||
});
|
||||
|
||||
// Since using the Promise API is optional, generating unhandled
|
||||
// rejections is not okay.
|
||||
deferred.promise.catch(noop);
|
||||
|
||||
stream.once('error', function(e) {
|
||||
deferred.reject(e);
|
||||
});
|
||||
|
||||
var buffers = [];
|
||||
|
||||
stream.on('data', function(b) {
|
||||
buffers.push(b);
|
||||
});
|
||||
|
||||
stream.once('end', function() {
|
||||
var result = Buffer.concat(buffers);
|
||||
|
||||
if (!failed) {
|
||||
on_progress(1.0);
|
||||
on_finish(result);
|
||||
}
|
||||
|
||||
if (deferred)
|
||||
deferred.resolve(result);
|
||||
});
|
||||
|
||||
on_progress(0.0);
|
||||
|
||||
stream.end(string);
|
||||
|
||||
if (deferred)
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
exports.LZMA = function() {
|
||||
return {
|
||||
compress: function(string, mode, on_finish, on_progress) {
|
||||
var opt = {};
|
||||
|
||||
if (parseInt(mode) === parseInt(mode) && mode >= 1 && mode <= 9)
|
||||
opt.preset = parseInt(mode);
|
||||
|
||||
var stream = createStream('aloneEncoder', opt);
|
||||
|
||||
return singleStringCoding(stream, string, on_finish, on_progress);
|
||||
},
|
||||
decompress: function(byte_array, on_finish, on_progress) {
|
||||
var stream = createStream('autoDecoder');
|
||||
|
||||
return singleStringCoding(stream, byte_array, on_finish, on_progress);
|
||||
},
|
||||
// dummy, we don’t use web workers
|
||||
worker: function() { return null; }
|
||||
};
|
||||
};
|
||||
|
||||
exports.compress = function(string, opt, on_finish) {
|
||||
if (typeof opt === 'function') {
|
||||
on_finish = opt;
|
||||
opt = {};
|
||||
}
|
||||
|
||||
var stream = createStream('easyEncoder', opt);
|
||||
return singleStringCoding(stream, string, on_finish);
|
||||
};
|
||||
|
||||
exports.decompress = function(string, opt, on_finish) {
|
||||
if (typeof opt === 'function') {
|
||||
on_finish = opt;
|
||||
opt = {};
|
||||
}
|
||||
|
||||
var stream = createStream('autoDecoder', opt);
|
||||
return singleStringCoding(stream, string, on_finish);
|
||||
};
|
||||
|
||||
if (util.promisify) {
|
||||
exports.compress[util.promisify.custom] = exports.compress;
|
||||
exports.decompress[util.promisify.custom] = exports.decompress;
|
||||
}
|
||||
|
||||
exports.isXZ = function(buf) {
|
||||
return buf && buf.length >= 6 &&
|
||||
buf[0] === 0xfd &&
|
||||
buf[1] === 0x37 &&
|
||||
buf[2] === 0x7a &&
|
||||
buf[3] === 0x58 &&
|
||||
buf[4] === 0x5a &&
|
||||
buf[5] === 0x00;
|
||||
};
|
||||
|
||||
exports.parseFileIndex = function(options, callback) {
|
||||
if (typeof options !== 'object') {
|
||||
throw new TypeError('parseFileIndex needs an options object');
|
||||
}
|
||||
|
||||
var p = new native.IndexParser();
|
||||
|
||||
if (typeof options.fileSize !== 'number') {
|
||||
throw new TypeError('parseFileeIndex needs options.fileSize');
|
||||
}
|
||||
|
||||
if (typeof options.read !== 'function') {
|
||||
throw new TypeError('parseFileIndex needs a read callback');
|
||||
}
|
||||
|
||||
p.init(options.fileSize, options.memlimit || 0);
|
||||
p.read_cb = function(count, offset) {
|
||||
var inSameTick = true;
|
||||
var bytesRead = count;
|
||||
|
||||
options.read(count, offset, function(err, buffer) {
|
||||
if (Buffer.isBuffer(err)) {
|
||||
buffer = err;
|
||||
err = null;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
if (typeof callback === 'undefined') {
|
||||
throw err;
|
||||
}
|
||||
|
||||
return callback(err, null);
|
||||
}
|
||||
|
||||
p.feed(buffer);
|
||||
bytesRead = buffer.length;
|
||||
|
||||
if (inSameTick) {
|
||||
// The call to parse() is still on the call stack and will continue
|
||||
// seamlessly.
|
||||
return;
|
||||
}
|
||||
|
||||
// Kick off parsing again.
|
||||
var info;
|
||||
|
||||
try {
|
||||
info = p.parse();
|
||||
} catch (e) {
|
||||
return callback(e, null);
|
||||
}
|
||||
|
||||
if (info !== true) {
|
||||
return callback(null, cleanupIndexInfo(info));
|
||||
}
|
||||
});
|
||||
|
||||
inSameTick = false;
|
||||
|
||||
return bytesRead;
|
||||
};
|
||||
|
||||
var info;
|
||||
try {
|
||||
info = p.parse();
|
||||
} catch (e) {
|
||||
if (typeof callback !== 'undefined') {
|
||||
callback(e, null);
|
||||
return;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (info !== true) {
|
||||
info = cleanupIndexInfo(info);
|
||||
if (typeof callback !== 'undefined' && info !== true) {
|
||||
callback(null, info);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
};
|
||||
|
||||
exports.parseFileIndexFD = function(fd, callback) {
|
||||
return fs.fstat(fd, function(err, stats) {
|
||||
if (err) {
|
||||
return callback(err, null);
|
||||
}
|
||||
|
||||
exports.parseFileIndex({
|
||||
fileSize: stats.size,
|
||||
read: function(count, offset, cb) {
|
||||
var buffer = Buffer.allocUnsafe(count);
|
||||
|
||||
fs.read(fd, buffer, 0, count, offset, function(err, bytesRead, buffer) {
|
||||
if (err) {
|
||||
return cb(err, null);
|
||||
}
|
||||
|
||||
if (bytesRead !== count) {
|
||||
return cb(new Error('Truncated file!'), null);
|
||||
}
|
||||
|
||||
cb(null, buffer);
|
||||
});
|
||||
}
|
||||
}, callback);
|
||||
});
|
||||
};
|
||||
|
||||
function cleanupIndexInfo(info) {
|
||||
var checkFlags = info.checks;
|
||||
|
||||
info.checks = [];
|
||||
for (var i = 0; i < exports.CHECK_ID_MAX; i++) {
|
||||
if (checkFlags & (1 << i))
|
||||
info.checks.push(i);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
function skipLeadingZeroes(buffer) {
|
||||
var i;
|
||||
for (i = 0; i < buffer.length; i++) {
|
||||
if (buffer[i] !== 0x00)
|
||||
break;
|
||||
}
|
||||
|
||||
return buffer.slice(i);
|
||||
}
|
||||
|
||||
function bufferIndexOfYZ(chunk) {
|
||||
if (!chunk) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (chunk.indexOf) {
|
||||
return chunk.indexOf('YZ');
|
||||
}
|
||||
|
||||
var i;
|
||||
for (i = 0; i < chunk.length - 1; i++) {
|
||||
if (chunk[i] === 0x59 && chunk[i+1] === 0x5a) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
})();
|
||||
11
electron/node_modules/lzma-native/liblzma-build.sh
generated
vendored
Executable file
11
electron/node_modules/lzma-native/liblzma-build.sh
generated
vendored
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
case $(uname | tr '[:upper:]' '[:lower:]') in
|
||||
*bsd) alias make='gmake';;
|
||||
*)
|
||||
esac
|
||||
|
||||
cd "$1/liblzma"
|
||||
make
|
||||
make install
|
||||
22
electron/node_modules/lzma-native/liblzma-config.sh
generated
vendored
Executable file
22
electron/node_modules/lzma-native/liblzma-config.sh
generated
vendored
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
SRC_TARBALL="$2"
|
||||
TARGET_DIR="$1/liblzma"
|
||||
|
||||
mkdir -p "$TARGET_DIR"
|
||||
cd "$TARGET_DIR"
|
||||
|
||||
tar xvjf "$SRC_TARBALL" >node_liblzma_config.log 2>&1
|
||||
|
||||
export CFLAGS="-fPIC $CFLAGS"
|
||||
|
||||
# Fix build on Apple Silicon
|
||||
if [ $(uname) = "Darwin" -a $(uname -m) = "arm64" ]; then
|
||||
XZ_SRC_DIR=$(ls | grep xz-*)
|
||||
sed -i '' 's/\tnone)/\tarm64-*)\n\t\tbasic_machine=$(echo $basic_machine | sed "s\/arm64\/aarch64\/")\n\t\t;;\n\t\tnone)/g' $XZ_SRC_DIR/build-aux/config.sub
|
||||
fi
|
||||
|
||||
sh xz-*/configure --enable-static --disable-shared --disable-scripts --disable-lzmainfo \
|
||||
--disable-lzma-links --disable-lzmadec --disable-xzdec --disable-xz --disable-rpath \
|
||||
--prefix="$TARGET_DIR/build" CFLAGS="$CFLAGS" >>node_liblzma_config.log 2>&1
|
||||
722
electron/node_modules/lzma-native/node_modules/node-addon-api/CHANGELOG.md
generated
vendored
Normal file
722
electron/node_modules/lzma-native/node_modules/node-addon-api/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,722 @@
|
|||
# node-addon-api Changelog
|
||||
|
||||
## 2021-05-28 Version 3.2.1, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Fixed documentation about the oldest Node.js version supported.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`6d41ee5a3a`](https://github.com/nodejs/node-addon-api/commit/6d41ee5a3a)] - Fixed readme for new release. (NickNaso)
|
||||
|
||||
## 2021-05-17 Version 3.2.0, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### API
|
||||
|
||||
- Remove unnecessary symbol exposure.
|
||||
- Fixed leak in `Napi::ObjectWrap` instance for getter and setter method.
|
||||
- Added `Napi::Object::Freeze` and `Napi::object::Seal` methods.
|
||||
- `Napi::Reference` is now copyable.
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Added docuemtnation for `Napi::Object::PropertyLValue`.
|
||||
- Changed all N-API references to Node-API.
|
||||
- Some minor corrections all over the documentation.
|
||||
|
||||
#### TEST
|
||||
|
||||
- Added tests relating to fetch property from Global Object.
|
||||
- Added addtiona tests for `Napi::Object`.
|
||||
- Added test for `Napi::Function` contructors.
|
||||
- Fixed intermittent failure for `Napi::ThreadSafeFunction` test.
|
||||
- Some minor corrections all over the test suite.
|
||||
|
||||
### TOOL
|
||||
|
||||
- Added Node.js v16.x to CI.
|
||||
- Added CI configuration for Windows.
|
||||
- Some fixex on linter command.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`52721312f6`](https://github.com/nodejs/node-addon-api/commit/52721312f6)] - **docs**: add napi-rs iin Other Bindings section (#999) (LongYinan)
|
||||
* [[`78a6570a42`](https://github.com/nodejs/node-addon-api/commit/78a6570a42)] - **doc**: fix typo in code example (#997) (Tobias Nießen)
|
||||
* [[`da3bd5778f`](https://github.com/nodejs/node-addon-api/commit/da3bd5778f)] - **test**: fix undoc assumptions about the timing of tsfn calls (legendecas) [#995](https://github.com/nodejs/node-addon-api/pull/995)
|
||||
* [[`410cf6a81e`](https://github.com/nodejs/node-addon-api/commit/410cf6a81e)] - **src**: return bool on object freeze and seal (#991) (legendecas)
|
||||
* [[`93f1898312`](https://github.com/nodejs/node-addon-api/commit/93f1898312)] - **src**: return bool on object set and define property (#977) (legendecas)
|
||||
* [[`331c2ee274`](https://github.com/nodejs/node-addon-api/commit/331c2ee274)] - **build**: add Node.js v16.x to CI (#983) (legendecas)
|
||||
* [[`b6f5eb15e6`](https://github.com/nodejs/node-addon-api/commit/b6f5eb15e6)] - **test**: run test suites with helpers (legendecas) [#976](https://github.com/nodejs/node-addon-api/pull/976)
|
||||
* [[`fbcdf00ea0`](https://github.com/nodejs/node-addon-api/commit/fbcdf00ea0)] - **test**: rename misspelled parameters (Tobias Nießen) [#973](https://github.com/nodejs/node-addon-api/pull/973)
|
||||
* [[`63a6c32e80`](https://github.com/nodejs/node-addon-api/commit/63a6c32e80)] - **test**: fix intermittent TSFN crashes (Kevin Eady) [#974](https://github.com/nodejs/node-addon-api/pull/974)
|
||||
* [[`8f120b033f`](https://github.com/nodejs/node-addon-api/commit/8f120b033f)] - **fix**: key for wapping drawing's system condition (#970) (Kévin VOYER)
|
||||
* [[`1c9d528d66`](https://github.com/nodejs/node-addon-api/commit/1c9d528d66)] - **doc**: correct struct definition (#969) (Darshan Sen)
|
||||
* [[`5e64d1fa61`](https://github.com/nodejs/node-addon-api/commit/5e64d1fa61)] - Added badges for Node-API v7 and v8. (#954) (Nicola Del Gobbo)
|
||||
* [[`6ce629b3fa`](https://github.com/nodejs/node-addon-api/commit/6ce629b3fa)] - **src**: add pull request template (#967) (Michael Dawson)
|
||||
* [[`98126661af`](https://github.com/nodejs/node-addon-api/commit/98126661af)] - Update CONTRIBUTING.md (#966) (Michael Dawson)
|
||||
* [[`77350eee98`](https://github.com/nodejs/node-addon-api/commit/77350eee98)] - **src**: added Freeze and Seal method to Object class. (NickNaso) [#955](https://github.com/nodejs/node-addon-api/pull/955)
|
||||
* [[`bc5147cc4a`](https://github.com/nodejs/node-addon-api/commit/bc5147cc4a)] - Finished tests relating to fetch property from Global Object (JckXia)
|
||||
* [[`0127813111`](https://github.com/nodejs/node-addon-api/commit/0127813111)] - **doc**: unambiguously mark deprecated signatures (Tobias Nießen) [#942](https://github.com/nodejs/node-addon-api/pull/942)
|
||||
* [[`787e216105`](https://github.com/nodejs/node-addon-api/commit/787e216105)] - **doc**: rename N-API with Node-API (Darshan Sen) [#951](https://github.com/nodejs/node-addon-api/pull/951)
|
||||
* [[`628023689a`](https://github.com/nodejs/node-addon-api/commit/628023689a)] - **src**: rename N-API with Node-API on comments (NickNaso) [#953](https://github.com/nodejs/node-addon-api/pull/953)
|
||||
* [[`5c6391578f`](https://github.com/nodejs/node-addon-api/commit/5c6391578f)] - **build**: add CI configuration for Windows (NickNaso) [#948](https://github.com/nodejs/node-addon-api/pull/948)
|
||||
* [[`8ef07251ec`](https://github.com/nodejs/node-addon-api/commit/8ef07251ec)] - **doc**: added some warnings for buffer and array buffer factory method. (#929) (Nicola Del Gobbo)
|
||||
* [[`6490b1f730`](https://github.com/nodejs/node-addon-api/commit/6490b1f730)] - **doc**: sync Object::Set value arg with Value::From (#933) (Tobias Nießen)
|
||||
* [[`7319a0d7a2`](https://github.com/nodejs/node-addon-api/commit/7319a0d7a2)] - Fix tab indent (#938) (Tobias Nießen)
|
||||
* [[`1916cb937e`](https://github.com/nodejs/node-addon-api/commit/1916cb937e)] - **chore**: fixup linter commands (#940) (legendecas)
|
||||
* [[`fc4585fa23`](https://github.com/nodejs/node-addon-api/commit/fc4585fa23)] - **test**: dd tests for Function constructors (JoseExposito) [#937](https://github.com/nodejs/node-addon-api/pull/937)
|
||||
* [[`87b7aae469`](https://github.com/nodejs/node-addon-api/commit/87b7aae469)] - **doc**: warn about SuppressDestruct() (#926) (Anna Henningsen)
|
||||
* [[`71494a49a3`](https://github.com/nodejs/node-addon-api/commit/71494a49a3)] - **src,doc**: refactor to replace typedefs with usings (Darshan Sen) [#910](https://github.com/nodejs/node-addon-api/pull/910)
|
||||
* [[`298ff8d9d2`](https://github.com/nodejs/node-addon-api/commit/298ff8d9d2)] - **test**: add additional tests for Object (JoseExposito) [#923](https://github.com/nodejs/node-addon-api/pull/923)
|
||||
* [[`8a1147b430`](https://github.com/nodejs/node-addon-api/commit/8a1147b430)] - **revert**: src: add additional tests for Function (Michael Dawson)
|
||||
* [[`bb56ffaa6f`](https://github.com/nodejs/node-addon-api/commit/bb56ffaa6f)] - **doc**: fix documentation for object api (Nicola Del Gobbo) [#931](https://github.com/nodejs/node-addon-api/pull/931)
|
||||
* [[`3b8bddab49`](https://github.com/nodejs/node-addon-api/commit/3b8bddab49)] - **src**: add additional tests for Function (José Expósito) [#928](https://github.com/nodejs/node-addon-api/pull/928)
|
||||
* [[`74ab50c775`](https://github.com/nodejs/node-addon-api/commit/74ab50c775)] - **src**: allow references to be copyable in APIs (legendecas) [#915](https://github.com/nodejs/node-addon-api/pull/915)
|
||||
* [[`929709d0fe`](https://github.com/nodejs/node-addon-api/commit/929709d0fe)] - **doc**: add propertylvalue.md (#925) (Gabriel Schulhof)
|
||||
* [[`69d0d98be4`](https://github.com/nodejs/node-addon-api/commit/69d0d98be4)] - fixup (Anna Henningsen)
|
||||
* [[`46e41d961b`](https://github.com/nodejs/node-addon-api/commit/46e41d961b)] - fixup (Anna Henningsen)
|
||||
* [[`1af1642fb7`](https://github.com/nodejs/node-addon-api/commit/1af1642fb7)] - **doc**: warn about SuppressDestruct() (Anna Henningsen)
|
||||
* [[`12c548b2ff`](https://github.com/nodejs/node-addon-api/commit/12c548b2ff)] - **tools**: fix error detection (#914) (Darshan Sen)
|
||||
* [[`458d895d5b`](https://github.com/nodejs/node-addon-api/commit/458d895d5b)] - **packaging**: list files to be published to npm (Lovell Fuller) [#889](https://github.com/nodejs/node-addon-api/pull/889)
|
||||
* [[`f7ed2490d4`](https://github.com/nodejs/node-addon-api/commit/f7ed2490d4)] - **test**: remove outdated V8 flag (Darshan Sen) [#895](https://github.com/nodejs/node-addon-api/pull/895)
|
||||
* [[`a575a6ec60`](https://github.com/nodejs/node-addon-api/commit/a575a6ec60)] - **src**: fix leak in ObjectWrap instance set/getters (Kevin Eady) [#899](https://github.com/nodejs/node-addon-api/pull/899)
|
||||
* [[`b6e844e0b0`](https://github.com/nodejs/node-addon-api/commit/b6e844e0b0)] - **doc**: fix spelling of "targeted" and "targeting" (#904) (Tobias Nießen)
|
||||
* [[`4d856f6e91`](https://github.com/nodejs/node-addon-api/commit/4d856f6e91)] - **src**: remove unnecessary symbol exposure (Gabriel Schulhof) [#896](https://github.com/nodejs/node-addon-api/pull/896)
|
||||
* [[`f35bb7d0d7`](https://github.com/nodejs/node-addon-api/commit/f35bb7d0d7)] - **doc**: Update GitHub URL references from 'master' to 'HEAD' (#898) (Jim Schlight)
|
||||
* [[`286ae215d1`](https://github.com/nodejs/node-addon-api/commit/286ae215d1)] - Add warning about branch rename (Michael Dawson)
|
||||
* [[`a4a7b28288`](https://github.com/nodejs/node-addon-api/commit/a4a7b28288)] - Update branch references from master to main (#886) (Jim Schlight)
|
||||
* [[`a2ad0a107a`](https://github.com/nodejs/node-addon-api/commit/a2ad0a107a)] - **docs**: add NAN to N-API resource link (#880) (kidneysolo)
|
||||
* [[`1c040eeb63`](https://github.com/nodejs/node-addon-api/commit/1c040eeb63)] - **test**: load testModules automatically (raisinten) [#876](https://github.com/nodejs/node-addon-api/pull/876)
|
||||
* [[`bf478e4496`](https://github.com/nodejs/node-addon-api/commit/bf478e4496)] - **src**: use NAPI\_NOEXCEPT macro instead of noexcept (NickNaso) [#864](https://github.com/nodejs/node-addon-api/pull/864)
|
||||
* [[`744705f2eb`](https://github.com/nodejs/node-addon-api/commit/744705f2eb)] - **test**: refactor remove repeated execution index.js (raisinten) [#839](https://github.com/nodejs/node-addon-api/pull/839)
|
||||
* [[`db62e3c811`](https://github.com/nodejs/node-addon-api/commit/db62e3c811)] - Update team members (Michael Dawson)
|
||||
|
||||
## 2020-12-17 Version 3.1.0, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### API
|
||||
|
||||
- Added `Napi::TypedThreadSafeFunction` class that is a new implementation for
|
||||
thread-safe functions.
|
||||
- Fixed leak on `Napi::AsyncProgressWorkerBase`.
|
||||
- Fixed empty data on `Napi::AsyncProgressWorker::OnProgress` caused by race
|
||||
conditions of `Napi::AsyncProgressWorker`.
|
||||
- Added `Napi::ArrayBuffer::Detach()` and `Napi::ArrayBuffer::IsDetached()`.
|
||||
- Fixed problem on `Napi::FinalizeCallback` it needs to create a
|
||||
`Napi::HandleScope` when it calls `Napi::ObjectWrap::~ObjectWrap()`.
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Added documentation for `Napi::TypedThreadSafeFunction`.
|
||||
- Removed unsued Doxygen file.
|
||||
- Clarified when to use N-API.
|
||||
- Added support information.
|
||||
- Some minor corrections all over the documentation.
|
||||
|
||||
#### TEST
|
||||
|
||||
- Added test for `Napi::TypedThreadSafeFunction`.
|
||||
- Fixed testing for specific N-API version.
|
||||
- Some minor corrections all over the test suite.
|
||||
|
||||
### TOOL
|
||||
|
||||
- Setup github actions for tests.
|
||||
- Added stale action.
|
||||
- Removed `sudo` tag from Travis CI.
|
||||
- Added clang-format.
|
||||
- Added pre-commit package for linting.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`ff642c5b85`](https://github.com/nodejs/node-addon-api/commit/ff642c5b85)] - **doc**: fix tsfn docs to reflect true implementation (#860) (Kevin Eady)
|
||||
* [[`86feeebf54`](https://github.com/nodejs/node-addon-api/commit/86feeebf54)] - **src**: empty data OnProgress in AsyncProgressWorker (legendecas) [#853](https://github.com/nodejs/node-addon-api/pull/853)
|
||||
* [[`a7fb5fb31c`](https://github.com/nodejs/node-addon-api/commit/a7fb5fb31c)] - **action**: add stale action (#856) (Michael Dawson)
|
||||
* [[`fd44609885`](https://github.com/nodejs/node-addon-api/commit/fd44609885)] - **chore**: setup github actions for tests (#854) (legendecas) [#854](https://github.com/nodejs/node-addon-api/pull/854)
|
||||
* [[`c52ace4813`](https://github.com/nodejs/node-addon-api/commit/c52ace4813)] - **script**: fix complains that js files are not supported on npm run lint:fix (#852) (legendecas)
|
||||
* [[`b4a3364ad5`](https://github.com/nodejs/node-addon-api/commit/b4a3364ad5)] - **doc**: remove unused Doxygen file (#851) (Michael Dawson)
|
||||
* [[`b810466ae2`](https://github.com/nodejs/node-addon-api/commit/b810466ae2)] - **doc**: clarify when to use N-API (#849) (Michael Dawson)
|
||||
* [[`528b9f6832`](https://github.com/nodejs/node-addon-api/commit/528b9f6832)] - **test**: remove sudo from travis (#850) (Michael Dawson)
|
||||
* [[`4bb680de4e`](https://github.com/nodejs/node-addon-api/commit/4bb680de4e)] - Remove misleading sentence (#847) (Nikolai Vavilov) [#847](https://github.com/nodejs/node-addon-api/pull/847)
|
||||
* [[`48e6b584a3`](https://github.com/nodejs/node-addon-api/commit/48e6b584a3)] - Merge pull request #742 from KevinEady/contexted-tsfn-api-gcc-4 (Gabriel Schulhof)
|
||||
* [[`d5e37210cc`](https://github.com/nodejs/node-addon-api/commit/d5e37210cc)] - **tools**: print more instructions on clang-format check failed (#846) (legendecas) [#846](https://github.com/nodejs/node-addon-api/pull/846)
|
||||
* [[`d9e11ff2c9`](https://github.com/nodejs/node-addon-api/commit/d9e11ff2c9)] - **doc**: add support info (#843) (Michael Dawson) [#843](https://github.com/nodejs/node-addon-api/pull/843)
|
||||
* [[`356e93d69a`](https://github.com/nodejs/node-addon-api/commit/356e93d69a)] - **test**: fixup testing for specific N-API version (#840) (Michael Dawson) [#840](https://github.com/nodejs/node-addon-api/pull/840)
|
||||
* [[`5e5b9ce1b7`](https://github.com/nodejs/node-addon-api/commit/5e5b9ce1b7)] - Apply formatting changes (Kevin Eady)
|
||||
* [[`559ad8c0c0`](https://github.com/nodejs/node-addon-api/commit/559ad8c0c0)] - Merge remote-tracking branch 'upstream/master' into contexted-tsfn-api-gcc-4 (Kevin Eady)
|
||||
* [[`c24c455ced`](https://github.com/nodejs/node-addon-api/commit/c24c455ced)] - Rename to TypedThreadSafeFunction (Kevin Eady)
|
||||
* [[`63b43f4125`](https://github.com/nodejs/node-addon-api/commit/63b43f4125)] - **test**: fix buildType bug objectwrap\_worker\_thread (raisinten) [#837](https://github.com/nodejs/node-addon-api/pull/837)
|
||||
* [[`6321f2ba1a`](https://github.com/nodejs/node-addon-api/commit/6321f2ba1a)] - **test**: fix typos in addon\_build/index.js (raisinten) [#838](https://github.com/nodejs/node-addon-api/pull/838)
|
||||
* [[`59c6a6aeb0`](https://github.com/nodejs/node-addon-api/commit/59c6a6aeb0)] - **fix**: git-clang-format doesn't recognize no changes requested on given files (#835) (legendecas)
|
||||
* [[`1427b3ef78`](https://github.com/nodejs/node-addon-api/commit/1427b3ef78)] - **src**: create a HandleScope in FinalizeCallback (blagoev) [#832](https://github.com/nodejs/node-addon-api/pull/832)
|
||||
* [[`8fb5820557`](https://github.com/nodejs/node-addon-api/commit/8fb5820557)] - **build**: add incremental clang-format checks (legendecas) [#819](https://github.com/nodejs/node-addon-api/pull/819)
|
||||
* [[`2c02d317e5`](https://github.com/nodejs/node-addon-api/commit/2c02d317e5)] - **build**: add pre-commit package for linting (#823) (Kevin Eady)
|
||||
* [[`1b52c28eb8`](https://github.com/nodejs/node-addon-api/commit/1b52c28eb8)] - Clean up AsyncProgressWorker documentation (#831) (mastergberry)
|
||||
* [[`4abe7cfe30`](https://github.com/nodejs/node-addon-api/commit/4abe7cfe30)] - **test**: rename tsfnex test files (Kevin Eady)
|
||||
* [[`c9563caa25`](https://github.com/nodejs/node-addon-api/commit/c9563caa25)] - **src**: add ArrayBuffer::Detach() and ::IsDetached() (Tobias Nießen) [#659](https://github.com/nodejs/node-addon-api/pull/659)
|
||||
* [[`c79cabaed2`](https://github.com/nodejs/node-addon-api/commit/c79cabaed2)] - **doc**: avoid directing users to HTTP (#828) (Tobias Nießen)
|
||||
* [[`7a13f861ab`](https://github.com/nodejs/node-addon-api/commit/7a13f861ab)] - **doc**: fix additional typo (Kevin Eady)
|
||||
* [[`7ec9741dd2`](https://github.com/nodejs/node-addon-api/commit/7ec9741dd2)] - Merge remote-tracking branch 'upstream/master' into contexted-tsfn-api-gcc-4 (Kevin Eady)
|
||||
* [[`f5fad239fa`](https://github.com/nodejs/node-addon-api/commit/f5fad239fa)] - Update object\_reference.md (#827) (kidneysolo)
|
||||
* [[`35b65712c2`](https://github.com/nodejs/node-addon-api/commit/35b65712c2)] - **Fix**: some typos in documentation (#826) (Helio Frota)
|
||||
* [[`8983383000`](https://github.com/nodejs/node-addon-api/commit/8983383000)] - **Fix**: some typos in the document (#825) (Ziqiu Zhao)
|
||||
* [[`826e466ef6`](https://github.com/nodejs/node-addon-api/commit/826e466ef6)] - Fixed example in addon.md. (#820) (nempoBu4) [#820](https://github.com/nodejs/node-addon-api/pull/820)
|
||||
* [[`b54f5eb788`](https://github.com/nodejs/node-addon-api/commit/b54f5eb788)] - Additional changes from review (Kevin Eady)
|
||||
* [[`59f27dac9a`](https://github.com/nodejs/node-addon-api/commit/59f27dac9a)] - Fix common.gypi (Kevin Eady)
|
||||
* [[`151a914c99`](https://github.com/nodejs/node-addon-api/commit/151a914c99)] - Apply documentation suggestions from code review (Kevin Eady)
|
||||
* [[`ceb27d4949`](https://github.com/nodejs/node-addon-api/commit/ceb27d4949)] - **src**: fix leak in AsyncProgressWorkerBase\<DataType\> (Ferdinand Holzer) [#795](https://github.com/nodejs/node-addon-api/pull/795)
|
||||
|
||||
## 2020-09-18 Version 3.0.2, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### API
|
||||
|
||||
- Introduced `include_dir` for use with **gyp** in a scalar context.
|
||||
- Added `Napi::Addon` to help handle the loading of a native add-on into
|
||||
multiple threads and or multiple times in the same thread.
|
||||
- Concentrate callbacks provided to core N-API.
|
||||
- Make sure wrapcallback is used.
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Added documentation for `Napi::Addon`.
|
||||
- Added documentation that reports the full class hierarchy.
|
||||
- Added link to N-API tutorial website.
|
||||
- Some minor corrections all over the documentation.
|
||||
|
||||
#### TEST
|
||||
|
||||
- Added tests to check the build process.
|
||||
- Refactored test for threasfafe function using async/await.
|
||||
- Converted tests that gc into async functions that await 10 ticks after
|
||||
each gc.
|
||||
- Some minor corrections all over the test suite.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`51e25f7c39`](https://github.com/nodejs/node-addon-api/commit/51e25f7c39)] - **doc**: remove a file (#815) (Gabriel Schulhof)
|
||||
* [[`8c9f1809a2`](https://github.com/nodejs/node-addon-api/commit/8c9f1809a2)] - **doc**: add inheritance links and other changes (Gabriel Schulhof) [#798](https://github.com/nodejs/node-addon-api/pull/798)
|
||||
* [[`6562e6b0ab`](https://github.com/nodejs/node-addon-api/commit/6562e6b0ab)] - **test**: added tests to check the build process (NickNaso) [#808](https://github.com/nodejs/node-addon-api/pull/808)
|
||||
* [[`a13b36c96e`](https://github.com/nodejs/node-addon-api/commit/a13b36c96e)] - **test**: fix the threasfafe function test (NickNaso) [#807](https://github.com/nodejs/node-addon-api/pull/807)
|
||||
* [[`f27623ff61`](https://github.com/nodejs/node-addon-api/commit/f27623ff61)] - **build**: introduce include\_dir (Lovell Fuller) [#766](https://github.com/nodejs/node-addon-api/pull/766)
|
||||
* [[`9aceea71fc`](https://github.com/nodejs/node-addon-api/commit/9aceea71fc)] - **src**: concentrate callbacks provided to core N-API (Gabriel Schulhof) [#786](https://github.com/nodejs/node-addon-api/pull/786)
|
||||
* [[`2bc45bbffd`](https://github.com/nodejs/node-addon-api/commit/2bc45bbffd)] - **test**: refactor test to use async/await (Velmisov) [#787](https://github.com/nodejs/node-addon-api/pull/787)
|
||||
* [[`518cfdcdc1`](https://github.com/nodejs/node-addon-api/commit/518cfdcdc1)] - **test**: test ObjectWrap destructor - no HandleScope (David Halls) [#729](https://github.com/nodejs/node-addon-api/pull/729)
|
||||
* [[`c2cbbd9191`](https://github.com/nodejs/node-addon-api/commit/c2cbbd9191)] - **doc**: add link to n-api tutorial website (#794) (Jim Schlight) [#794](https://github.com/nodejs/node-addon-api/pull/794)
|
||||
* [[`1c2a8d59b5`](https://github.com/nodejs/node-addon-api/commit/1c2a8d59b5)] - **doc**: Added required return to example (#793) (pacop) [#793](https://github.com/nodejs/node-addon-api/pull/793)
|
||||
* [[`cec2c76941`](https://github.com/nodejs/node-addon-api/commit/cec2c76941)] - **src**: wrap finalizer callback (Gabriel Schulhof) [#762](https://github.com/nodejs/node-addon-api/pull/762)
|
||||
* [[`4ce40d22a6`](https://github.com/nodejs/node-addon-api/commit/4ce40d22a6)] - **test**: use assert.strictEqual() (Koki Nishihara) [#777](https://github.com/nodejs/node-addon-api/pull/777)
|
||||
* [[`461e3640c6`](https://github.com/nodejs/node-addon-api/commit/461e3640c6)] - **test**: string tests together (Gabriel Schulhof) [#773](https://github.com/nodejs/node-addon-api/pull/773)
|
||||
* [[`5af645f649`](https://github.com/nodejs/node-addon-api/commit/5af645f649)] - **src**: add Addon\<T\> class (Gabriel Schulhof) [#749](https://github.com/nodejs/node-addon-api/pull/749)
|
||||
* [[`6148fb4bcc`](https://github.com/nodejs/node-addon-api/commit/6148fb4bcc)] - Synchronise Node.js versions in Appveyor Windows CI with Travis (#768) (Lovell Fuller)
|
||||
|
||||
## 2020-07-13 Version 3.0.1, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### API
|
||||
|
||||
- Fixed the usage of `Napi::Reference` with `Napi::TypedArray`.
|
||||
- Fixed `Napi::ObjectWrap` inheritance.
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Updated the example for `Napi::ObjectWrap`.
|
||||
- Added documentation for instance data APIs.
|
||||
- Some minor corrections all over the documentation.
|
||||
|
||||
#### TEST
|
||||
|
||||
- Fixed test for `Napi::ArrayBuffer` and `Napi::Buffer`.
|
||||
- Some minor corrections all over the test suite.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`40c7926342`](https://github.com/nodejs/node-addon-api/commit/40c7926342)] - **build**: ensure paths with spaces can be used (Lovell Fuller) [#757](https://github.com/nodejs/node-addon-api/pull/757)
|
||||
* [[`ef16dfb4a2`](https://github.com/nodejs/node-addon-api/commit/ef16dfb4a2)] - **doc**: update ObjectWrap example (Gabriel Schulhof) [#754](https://github.com/nodejs/node-addon-api/pull/754)
|
||||
* [[`48f6762bf6`](https://github.com/nodejs/node-addon-api/commit/48f6762bf6)] - **src**: add \_\_wasm32\_\_ guards (Gus Caplan)
|
||||
* [[`bd2c5ec502`](https://github.com/nodejs/node-addon-api/commit/bd2c5ec502)] - Fixes issue 745. (#748) (Nicola Del Gobbo)
|
||||
* [[`4c01af2d87`](https://github.com/nodejs/node-addon-api/commit/4c01af2d87)] - Fix typo in CHANGELOG (#715) (Kasumi Hanazuki)
|
||||
* [[`36e1af96d5`](https://github.com/nodejs/node-addon-api/commit/36e1af96d5)] - **src**: fix use of Reference with typed arrays (Michael Dawson) [#726](https://github.com/nodejs/node-addon-api/pull/726)
|
||||
* [[`d463f02bc7`](https://github.com/nodejs/node-addon-api/commit/d463f02bc7)] - **src**: fix testEnumerables on ObjectWrap (Ferdinand Holzer) [#736](https://github.com/nodejs/node-addon-api/pull/736)
|
||||
* [[`ba7ad37d44`](https://github.com/nodejs/node-addon-api/commit/ba7ad37d44)] - **src**: fix ObjectWrap inheritance (David Halls) [#732](https://github.com/nodejs/node-addon-api/pull/732)
|
||||
* [[`31504c862b`](https://github.com/nodejs/node-addon-api/commit/31504c862b)] - **doc**: fix minor typo in object\_wrap.md (#741) (Daniel Bevenius) [#741](https://github.com/nodejs/node-addon-api/pull/741)
|
||||
* [[`beccf2145d`](https://github.com/nodejs/node-addon-api/commit/beccf2145d)] - **test**: fix up delays for array buffer test (Michael Dawson) [#737](https://github.com/nodejs/node-addon-api/pull/737)
|
||||
* [[`45cb1d9748`](https://github.com/nodejs/node-addon-api/commit/45cb1d9748)] - Correct AsyncProgressWorker link in README (#716) (Jeroen Janssen)
|
||||
* [[`381c0da60c`](https://github.com/nodejs/node-addon-api/commit/381c0da60c)] - **doc**: add instance data APIs (Gabriel Schulhof) [#708](https://github.com/nodejs/node-addon-api/pull/708)
|
||||
|
||||
## 2020-04-30 Version 3.0.0, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### API
|
||||
|
||||
- `Napi::Object` added templated property descriptors.
|
||||
- `Napi::ObjectWrap` added templated methods.
|
||||
- `Napi::ObjectWrap` the wrap is removed only on failure.
|
||||
- `Napi::ObjectWrap` the constructor's exceptions are gracefully handled.
|
||||
- `Napi::Function` added templated factory functions.
|
||||
- Added `Env::RunScript` method to run JavaScript code contained in a string.
|
||||
- Added templated version of `Napi::Function`.
|
||||
- Added benchmarking framework.
|
||||
- Added support for native addon instance data.
|
||||
- Added `Napi::AsyncProgressQueueWorker` api.
|
||||
- Changed the guards to `NAPI_VERSION > 5`.
|
||||
- Removed N-API implementation (v6.x and v8.x support).
|
||||
- `Napi::AsyncWorker::OnWorkComplete` and `Napi::AsyncWorker::OnExecute` methods
|
||||
are override-able.
|
||||
- Removed erroneous finalizer cleanup in `Napi::ThreadSafeFunction`.
|
||||
- Disabled caching in `Napi::ArrayBuffer`.
|
||||
- Explicitly disallow assign and copy operator.
|
||||
- Some minor corrections and improvements.
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Updated documentation for `Napi::Object`.
|
||||
- Updated documentation for `Napi::Function`.
|
||||
- Updated documentation for `Napi::ObjectWrap`.
|
||||
- Added documentation on how to add benchmark.
|
||||
- Added documentation for `Napi::AsyncProgressQueueWorker`.
|
||||
- Added suggestion about tags to use on NPM.
|
||||
- Added reference to N-API badges.
|
||||
- Some minor corrections all over the documentation.
|
||||
|
||||
#### TEST
|
||||
|
||||
- Updated test cases for `Napi::Object`.
|
||||
- Updated test cases for `Napi::Function`.
|
||||
- Updated test cases for `Napi::ObjectWrap`.
|
||||
- Updated test cases for `Napi::Env`.
|
||||
- Added test cases for `Napi::AsyncProgressQueueWorker`.
|
||||
- Some minor corrections all over the test suite.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`187318e37f`](https://github.com/nodejs/node-addon-api/commit/187318e37f)] - **doc**: Removed references to Node.js lower than 10.x. (#709) (Nicola Del Gobbo)
|
||||
* [[`9c9accfbbe`](https://github.com/nodejs/node-addon-api/commit/9c9accfbbe)] - **src**: add support for addon instance data (Gabriel Schulhof) [#663](https://github.com/nodejs/node-addon-api/pull/663)
|
||||
* [[`82a96502a4`](https://github.com/nodejs/node-addon-api/commit/82a96502a4)] - **src**: change guards to NAPI\_VERSION \> 5 (Gabriel Schulhof) [#697](https://github.com/nodejs/node-addon-api/pull/697)
|
||||
* [[`a64e8a5641`](https://github.com/nodejs/node-addon-api/commit/a64e8a5641)] - **ci**: move travis from 13 to 14 (#707) (Gabriel Schulhof)
|
||||
* [[`4de23c9d6b`](https://github.com/nodejs/node-addon-api/commit/4de23c9d6b)] - **doc**: fix support bigint64/biguint64 guards (Yulong Wang) [#705](https://github.com/nodejs/node-addon-api/pull/705)
|
||||
* [[`fedc8195e3`](https://github.com/nodejs/node-addon-api/commit/fedc8195e3)] - **doc**: fix semicolon missing in async\_worker.md (Azlan Mukhtar) [#701](https://github.com/nodejs/node-addon-api/pull/701)
|
||||
* [[`cdb662506c`](https://github.com/nodejs/node-addon-api/commit/cdb662506c)] - **doc**: fix typo in bigint.md (#700) (Kelvin)
|
||||
* [[`e1a827ae29`](https://github.com/nodejs/node-addon-api/commit/e1a827ae29)] - **src**: fix AsyncProgressQueueWorker compilation (#696) (Gabriel Schulhof) [#696](https://github.com/nodejs/node-addon-api/pull/696)
|
||||
* [[`2c3d5df463`](https://github.com/nodejs/node-addon-api/commit/2c3d5df463)] - Merge pull request #692 from kelvinhammond/patch-1 (Nicola Del Gobbo)
|
||||
* [[`623e876949`](https://github.com/nodejs/node-addon-api/commit/623e876949)] - Merge pull request #688 from NickNaso/badges (Nicola Del Gobbo)
|
||||
* [[`6c97913d1f`](https://github.com/nodejs/node-addon-api/commit/6c97913d1f)] - Fix minor typo in object\_lifetime\_management.md (Kelvin)
|
||||
* [[`6b8dd47c55`](https://github.com/nodejs/node-addon-api/commit/6b8dd47c55)] - Added badge section to documentation. (NickNaso)
|
||||
* [[`89e62a9154`](https://github.com/nodejs/node-addon-api/commit/89e62a9154)] - **doc**: recommend tags of addon helpers (legendecas) [#683](https://github.com/nodejs/node-addon-api/pull/683)
|
||||
* [[`ab018444ae`](https://github.com/nodejs/node-addon-api/commit/ab018444ae)] - **src**: implement AsyncProgressQueueWorker (legendecas) [#585](https://github.com/nodejs/node-addon-api/pull/585)
|
||||
* [[`d43da6ac2b`](https://github.com/nodejs/node-addon-api/commit/d43da6ac2b)] - **doc**: add @legendecas to active member list (legendecas)
|
||||
* [[`cb498bbe7f`](https://github.com/nodejs/node-addon-api/commit/cb498bbe7f)] - **doc**: Add Napi::BigInt::New() overload for uint64\_t (ikokostya)
|
||||
* [[`baaaa8452c`](https://github.com/nodejs/node-addon-api/commit/baaaa8452c)] - **doc**: link threadsafe function from JS function (legendecas)
|
||||
* [[`7f56a78ff7`](https://github.com/nodejs/node-addon-api/commit/7f56a78ff7)] - **objectwrap**: remove wrap only on failure (Gabriel Schulhof)
|
||||
* [[`4d816183da`](https://github.com/nodejs/node-addon-api/commit/4d816183da)] - **doc**: fix example code (András Timár, Dr) [#657](https://github.com/nodejs/node-addon-api/pull/657)
|
||||
* [[`7ac6e21801`](https://github.com/nodejs/node-addon-api/commit/7ac6e21801)] - **gyp**: fix gypfile name in index.js (Anna Henningsen) [#658](https://github.com/nodejs/node-addon-api/pull/658)
|
||||
* [[`46484202ca`](https://github.com/nodejs/node-addon-api/commit/46484202ca)] - **test**: user data in function property descriptor (Kevin Eady) [#652](https://github.com/nodejs/node-addon-api/pull/652)
|
||||
* [[`0f8d730483`](https://github.com/nodejs/node-addon-api/commit/0f8d730483)] - **doc**: fix syntax error in example (András Timár, Dr) [#650](https://github.com/nodejs/node-addon-api/pull/650)
|
||||
* [[`4e885069f1`](https://github.com/nodejs/node-addon-api/commit/4e885069f1)] - **src**: call `napi\_remove\_wrap()` in `ObjectWrap` dtor (Anna Henningsen) [#475](https://github.com/nodejs/node-addon-api/pull/475)
|
||||
* [[`2fde5c3ca3`](https://github.com/nodejs/node-addon-api/commit/2fde5c3ca3)] - **test**: update BigInt test for recent change in core (Michael Dawson) [#649](https://github.com/nodejs/node-addon-api/pull/649)
|
||||
* [[`e8935bd8d9`](https://github.com/nodejs/node-addon-api/commit/e8935bd8d9)] - **test**: add test for own properties on ObjectWrap (Guenter Sandner) [#645](https://github.com/nodejs/node-addon-api/pull/645)
|
||||
* [[`23ff7f0b24`](https://github.com/nodejs/node-addon-api/commit/23ff7f0b24)] - **src**: make OnWorkComplete and OnExecute override-able (legendecas) [#589](https://github.com/nodejs/node-addon-api/pull/589)
|
||||
* [[`86384f94d3`](https://github.com/nodejs/node-addon-api/commit/86384f94d3)] - **objectwrap**: gracefully handle constructor exceptions (Gabriel Schulhof)
|
||||
* [[`9af69da01f`](https://github.com/nodejs/node-addon-api/commit/9af69da01f)] - remove N-API implementation, v6.x and v8.x support (Gabriel Schulhof) [#643](https://github.com/nodejs/node-addon-api/pull/643)
|
||||
* [[`920d544779`](https://github.com/nodejs/node-addon-api/commit/920d544779)] - **benchmark**: add templated version of Function (Gabriel Schulhof) [#637](https://github.com/nodejs/node-addon-api/pull/637)
|
||||
* [[`03759f7759`](https://github.com/nodejs/node-addon-api/commit/03759f7759)] - ignore benchmark built archives (legendecas) [#631](https://github.com/nodejs/node-addon-api/pull/631)
|
||||
* [[`5eeabb0214`](https://github.com/nodejs/node-addon-api/commit/5eeabb0214)] - **tsfn**: Remove erroneous finalizer cleanup (Kevin Eady) [#636](https://github.com/nodejs/node-addon-api/pull/636)
|
||||
* [[`9e0e0f31e4`](https://github.com/nodejs/node-addon-api/commit/9e0e0f31e4)] - **src**: remove unnecessary forward declarations (Gabriel Schulhof) [#633](https://github.com/nodejs/node-addon-api/pull/633)
|
||||
* [[`79deefb6f3`](https://github.com/nodejs/node-addon-api/commit/79deefb6f3)] - **src**: explicitly disallow assign and copy (legendecas) [#590](https://github.com/nodejs/node-addon-api/pull/590)
|
||||
* [[`af50ac281b`](https://github.com/nodejs/node-addon-api/commit/af50ac281b)] - **error**: do not replace pending exception (Gabriel Schulhof) [#629](https://github.com/nodejs/node-addon-api/pull/629)
|
||||
* [[`b72f1d6978`](https://github.com/nodejs/node-addon-api/commit/b72f1d6978)] - Disable caching in ArrayBuffer (Tobias Nießen) [#611](https://github.com/nodejs/node-addon-api/pull/611)
|
||||
* [[`0e7483eb7b`](https://github.com/nodejs/node-addon-api/commit/0e7483eb7b)] - Fix code format in tests (Tobias Nießen) [#617](https://github.com/nodejs/node-addon-api/pull/617)
|
||||
* [[`6a0646356d`](https://github.com/nodejs/node-addon-api/commit/6a0646356d)] - add benchmarking framework (Gabriel Schulhof) [#623](https://github.com/nodejs/node-addon-api/pull/623)
|
||||
* [[`ffc71edd54`](https://github.com/nodejs/node-addon-api/commit/ffc71edd54)] - Add Env::RunScript (Tobias Nießen) [#616](https://github.com/nodejs/node-addon-api/pull/616)
|
||||
* [[`a1b106066e`](https://github.com/nodejs/node-addon-api/commit/a1b106066e)] - **src**: add templated function factories (Gabriel Schulhof) [#608](https://github.com/nodejs/node-addon-api/pull/608)
|
||||
* [[`c584343217`](https://github.com/nodejs/node-addon-api/commit/c584343217)] - Add GetPropertyNames, HasOwnProperty, Delete (#615) (Tobias Nießen) [#615](https://github.com/nodejs/node-addon-api/pull/615)
|
||||
* [[`3acc4b32f5`](https://github.com/nodejs/node-addon-api/commit/3acc4b32f5)] - Fix std::string encoding (#619) (Tobias Nießen) [#619](https://github.com/nodejs/node-addon-api/pull/619)
|
||||
* [[`e71d0eadcc`](https://github.com/nodejs/node-addon-api/commit/e71d0eadcc)] - \[doc\] Fixed links to array documentation (#613) (Nicola Del Gobbo)
|
||||
* [[`3dfb1f0591`](https://github.com/nodejs/node-addon-api/commit/3dfb1f0591)] - Change "WG" to "team" (Tobias Nießen)
|
||||
* [[`ce91e14860`](https://github.com/nodejs/node-addon-api/commit/ce91e14860)] - **objectwrap**: add template methods (Dmitry Ashkadov) [#604](https://github.com/nodejs/node-addon-api/pull/604)
|
||||
* [[`cfa71b60f7`](https://github.com/nodejs/node-addon-api/commit/cfa71b60f7)] - **object**: add templated property descriptors (Gabriel Schulhof) [#610](https://github.com/nodejs/node-addon-api/pull/610)
|
||||
* [[`734725e971`](https://github.com/nodejs/node-addon-api/commit/734725e971)] - Correctly define copy assignment operators. (Rolf Timmermans)
|
||||
|
||||
## 2019-11-21 Version 2.0.0, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### API
|
||||
|
||||
- Added `Napi::AsyncProgressWorker` api.
|
||||
- Added error checking on `Napi::ThreadSafeFunction::GetContext`.
|
||||
- Added copy constructor to `Napi::ThreadSafeFunction`.
|
||||
- Added `Napi::ThreadSafeFunction::Ref` and `Napi::ThreadSafeFunction::Unref` to `Napi::ThreadSafeFunction`.
|
||||
- Added `Napi::Object::AddFinalizer` method.
|
||||
- Use `napi_add_finalizer()` to attach data when building against N-API 5.
|
||||
- Added `Napi::Date` api.
|
||||
- Added `Napi::ObjectWrap::Finalize` method.
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Added documentation for `Napi::AsyncProgressWorker`.
|
||||
- Improve `Napi::AsyncWorker` documentation.
|
||||
- Added documentation for `Napi::Object::AddFinalizer` method.
|
||||
- Improved documentation for `Napi::ThreadSafeFunction`.
|
||||
- Improved documentation about the usage of CMake as build tool.
|
||||
- Some minor corrections all over the documentation.
|
||||
|
||||
#### TEST
|
||||
|
||||
- Added test cases for `Napi::AsyncProgressWorker` api.
|
||||
- Added test cases for `Napi::Date` api.
|
||||
- Added test cases for new features added to `Napi::ThreadSafeFunction`.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`c881168d49`](https://github.com/nodejs/node-addon-api/commit/c881168d49)] - **tsfn**: add error checking on GetContext (#583) (Kevin Eady) [#583](https://github.com/nodejs/node-addon-api/pull/583)
|
||||
* [[`24d75dd82f`](https://github.com/nodejs/node-addon-api/commit/24d75dd82f)] - Merge pull request #588 from NickNaso/add-asyncprogress-worker-readme (Nicola Del Gobbo)
|
||||
* [[`aa79e37b62`](https://github.com/nodejs/node-addon-api/commit/aa79e37b62)] - Merge pull request #587 from timrach/patch-1 (Nicola Del Gobbo)
|
||||
* [[`df75e08c2b`](https://github.com/nodejs/node-addon-api/commit/df75e08c2b)] - **tsfn**: support direct calls to underlying napi\_tsfn (Kevin Eady) [#58](https://github.com/nodejs/node-addon-api/pull/58)
|
||||
* [[`2298dfae58`](https://github.com/nodejs/node-addon-api/commit/2298dfae58)] - **doc**: Added AsyncProgressWorker to readme (NickNaso)
|
||||
* [[`b3609d33b6`](https://github.com/nodejs/node-addon-api/commit/b3609d33b6)] - Fix return type and declaration of setter callback (Tim Rach)
|
||||
* [[`295e560f55`](https://github.com/nodejs/node-addon-api/commit/295e560f55)] - **test**: improve guards for experimental features (legendecas)
|
||||
* [[`2e71842f63`](https://github.com/nodejs/node-addon-api/commit/2e71842f63)] - **tsfn**: Implement copy constructor (Kevin Eady) [#546](https://github.com/nodejs/node-addon-api/pull/546)
|
||||
* [[`650562cab9`](https://github.com/nodejs/node-addon-api/commit/650562cab9)] - **src**: implement AsyncProgressWorker (legendecas) [#529](https://github.com/nodejs/node-addon-api/pull/529)
|
||||
* [[`bdfd14101f`](https://github.com/nodejs/node-addon-api/commit/bdfd14101f)] - **src**: attach data with napi\_add\_finalizer (Gabriel Schulhof) [#577](https://github.com/nodejs/node-addon-api/pull/577)
|
||||
* [[`9e955a802b`](https://github.com/nodejs/node-addon-api/commit/9e955a802b)] - **doc**: change node.js to Node.js per guideline (#579) (Tobias Nießen) [#579](https://github.com/nodejs/node-addon-api/pull/579)
|
||||
* [[`b42e21e3a9`](https://github.com/nodejs/node-addon-api/commit/b42e21e3a9)] - **build**: move node/6 to travis allowed failures and add node/13 (#573) (Gabriel Schulhof)
|
||||
* [[`8d6132f609`](https://github.com/nodejs/node-addon-api/commit/8d6132f609)] - **doc**: improve AsyncWorker docs (#571) (legendecas) [#571](https://github.com/nodejs/node-addon-api/pull/571)
|
||||
* [[`bc8fc23627`](https://github.com/nodejs/node-addon-api/commit/bc8fc23627)] - **test**: do not run TSFN tests on NAPI\_VERSION \< 4 (legendecas) [#576](https://github.com/nodejs/node-addon-api/pull/576)
|
||||
* [[`bcc1d58fc4`](https://github.com/nodejs/node-addon-api/commit/bcc1d58fc4)] - implement Object::AddFinalizer (Gabriel Schulhof)
|
||||
* [[`e9a4bcd52a`](https://github.com/nodejs/node-addon-api/commit/e9a4bcd52a)] - **doc**: updates Make.js doc to current best practices (Jim Schlight) [#558](https://github.com/nodejs/node-addon-api/pull/558)
|
||||
* [[`b513d1aa7a`](https://github.com/nodejs/node-addon-api/commit/b513d1aa7a)] - **doc**: fix return type of ArrayBuffer::Data (Tobias Nießen) [#552](https://github.com/nodejs/node-addon-api/pull/552)
|
||||
* [[`34c11cf0a4`](https://github.com/nodejs/node-addon-api/commit/34c11cf0a4)] - **src**: disallow copying, double close of scopes (legendecas) [#566](https://github.com/nodejs/node-addon-api/pull/566)
|
||||
* [[`ce139a05e8`](https://github.com/nodejs/node-addon-api/commit/ce139a05e8)] - **src**: make failure of closing scopes fatal (legendecas) [#566](https://github.com/nodejs/node-addon-api/pull/566)
|
||||
* [[`740c79823e`](https://github.com/nodejs/node-addon-api/commit/740c79823e)] - **src**: add Env() to AsyncContext (Rolf Timmermans) [#568](https://github.com/nodejs/node-addon-api/pull/568)
|
||||
* [[`ea9ce1c801`](https://github.com/nodejs/node-addon-api/commit/ea9ce1c801)] - **tsfn**: add wrappers for Ref and Unref (Kevin Eady) [#561](https://github.com/nodejs/node-addon-api/pull/561)
|
||||
* [[`2e1769e1a3`](https://github.com/nodejs/node-addon-api/commit/2e1769e1a3)] - **error**: remove unnecessary if condition (legendecas) [#562](https://github.com/nodejs/node-addon-api/pull/562)
|
||||
* [[`828f223a87`](https://github.com/nodejs/node-addon-api/commit/828f223a87)] - **doc**: fix spelling in ObjectWrap doc (#563) (Tobias Nießen) [#563](https://github.com/nodejs/node-addon-api/pull/563)
|
||||
* [[`dd9fa8a4a8`](https://github.com/nodejs/node-addon-api/commit/dd9fa8a4a8)] - **doc**: move Arunesh and Taylor to Emeritus (#540) (Michael Dawson) [#540](https://github.com/nodejs/node-addon-api/pull/540)
|
||||
* [[`cf8b8415df`](https://github.com/nodejs/node-addon-api/commit/cf8b8415df)] - **doc**: add Kevin to the list of collaborators (#539) (Michael Dawson) [#539](https://github.com/nodejs/node-addon-api/pull/539)
|
||||
* [[`5d6aeae7b5`](https://github.com/nodejs/node-addon-api/commit/5d6aeae7b5)] - **build**: enable travis for fast PR check (legendecas)
|
||||
* [[`6192e705cd`](https://github.com/nodejs/node-addon-api/commit/6192e705cd)] - **src**: add napi\_date (Mathias Küsel) [#497](https://github.com/nodejs/node-addon-api/pull/497)
|
||||
* [[`7b1ee96d52`](https://github.com/nodejs/node-addon-api/commit/7b1ee96d52)] - **doc**: update prebuild\_tools.md (Nurbol Alpysbayev) [#527](https://github.com/nodejs/node-addon-api/pull/527)
|
||||
* [[`0b4f3a5b8c`](https://github.com/nodejs/node-addon-api/commit/0b4f3a5b8c)] - **tsfn**: fix crash on releasing tsfn (legendecas) [#532](https://github.com/nodejs/node-addon-api/pull/532)
|
||||
* [[`c3c8814d2f`](https://github.com/nodejs/node-addon-api/commit/c3c8814d2f)] - implement virutal ObjectWrap::Finalize (Michael Price) [#515](https://github.com/nodejs/node-addon-api/pull/515)
|
||||
|
||||
## 2019-07-23 Version 1.7.1, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### API
|
||||
|
||||
- Fixed compilation problems that happen on Node.js with N-API version less than 4.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`c20bcbd069`](https://github.com/nodejs/node-addon-api/commit/c20bcbd069)] - Merge pull request #518 from NickNaso/master (Nicola Del Gobbo)
|
||||
* [[`6720d57253`](https://github.com/nodejs/node-addon-api/commit/6720d57253)] - Create the native threadsafe\_function for test only for N-API greater than 3. (NickNaso)
|
||||
* [[`37b6c185ad`](https://github.com/nodejs/node-addon-api/commit/37b6c185ad)] - Fix compilation breakage on 1.7.0 (NickNaso)
|
||||
|
||||
## 2019-07-23 Version 1.7.0, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### API
|
||||
|
||||
- Added `Napi::ThreadSafeFunction` api.
|
||||
- Added `Napi::AsyncWorker::GetResult()` method to `Napi::AsyncWorker`.
|
||||
- Added `Napi::AsyncWorker::Destroy()()` method to `Napi::AsyncWorker`.
|
||||
- Use full namespace on macros that create the errors.
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Added documentation about contribution philosophy.
|
||||
- Added documentation for `Napi::ThreadSafeFunction`.
|
||||
- Some minor corrections all over the documentation.
|
||||
|
||||
#### TEST
|
||||
|
||||
- Added test case for bool operator.
|
||||
- Fixed test case for `Napi::ObjectWrap`.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`717c9ab163`](https://github.com/nodejs/node-addon-api/commit/717c9ab163)] - **AsyncWorker**: add GetResult() method (Kevin Eady) [#512](https://github.com/nodejs/node-addon-api/pull/512)
|
||||
* [[`d9d991bbc9`](https://github.com/nodejs/node-addon-api/commit/d9d991bbc9)] - **doc**: add ThreadSafeFunction to main README (#513) (Kevin Eady) [#513](https://github.com/nodejs/node-addon-api/pull/513)
|
||||
* [[`ac6000d0fd`](https://github.com/nodejs/node-addon-api/commit/ac6000d0fd)] - **doc**: fix minor typo (Yohei Kishimoto) [#510](https://github.com/nodejs/node-addon-api/pull/510)
|
||||
* [[`e9fa1eaa86`](https://github.com/nodejs/node-addon-api/commit/e9fa1eaa86)] - **doc**: document ThreadSafeFunction (#494) (Kevin Eady) [#494](https://github.com/nodejs/node-addon-api/pull/494)
|
||||
* [[`cab3b1e2a2`](https://github.com/nodejs/node-addon-api/commit/cab3b1e2a2)] - **doc**: ClassPropertyDescriptor example (Ross Weir) [#507](https://github.com/nodejs/node-addon-api/pull/507)
|
||||
* [[`c32d7dbdcf`](https://github.com/nodejs/node-addon-api/commit/c32d7dbdcf)] - **macros**: create errors fully namespaced (Gabriel Schulhof) [#506](https://github.com/nodejs/node-addon-api/pull/506)
|
||||
* [[`0a90df2fcb`](https://github.com/nodejs/node-addon-api/commit/0a90df2fcb)] - Implement ThreadSafeFunction class (Jinho Bang)
|
||||
* [[`1fb540eeb5`](https://github.com/nodejs/node-addon-api/commit/1fb540eeb5)] - Use curly brackets to include node\_api.h (NickNaso) [#493](https://github.com/nodejs/node-addon-api/pull/493)
|
||||
* [[`b2b08122ea`](https://github.com/nodejs/node-addon-api/commit/b2b08122ea)] - **AsyncWorker**: make callback optional (Kevin Eady) [#489](https://github.com/nodejs/node-addon-api/pull/489)
|
||||
* [[`a0cac77c82`](https://github.com/nodejs/node-addon-api/commit/a0cac77c82)] - Added test for bool operator (NickNaso) [#490](https://github.com/nodejs/node-addon-api/pull/490)
|
||||
* [[`ab7d8fcc48`](https://github.com/nodejs/node-addon-api/commit/ab7d8fcc48)] - **src**: fix objectwrap test case (Michael Dawson) [#495](https://github.com/nodejs/node-addon-api/pull/495)
|
||||
* [[`3b6b9eb88a`](https://github.com/nodejs/node-addon-api/commit/3b6b9eb88a)] - **AsyncWorker**: introduce Destroy() method (Gabriel Schulhof) [#488](https://github.com/nodejs/node-addon-api/pull/488)
|
||||
* [[`f633fbd95d`](https://github.com/nodejs/node-addon-api/commit/f633fbd95d)] - string.md: Document existing New(env, value, length) APIs (Tux3) [#486](https://github.com/nodejs/node-addon-api/pull/486)
|
||||
* [[`aaea55eda9`](https://github.com/nodejs/node-addon-api/commit/aaea55eda9)] - Little fix on code example (Nicola Del Gobbo) [#470](https://github.com/nodejs/node-addon-api/pull/470)
|
||||
* [[`e1cf9a35a1`](https://github.com/nodejs/node-addon-api/commit/e1cf9a35a1)] - Use `Value::IsEmpty` to check for empty value (NickNaso) [#478](https://github.com/nodejs/node-addon-api/pull/478)
|
||||
* [[`3ad5dfc7d9`](https://github.com/nodejs/node-addon-api/commit/3ad5dfc7d9)] - Fix link (Alba Mendez) [#481](https://github.com/nodejs/node-addon-api/pull/481)
|
||||
* [[`a3b4d99c45`](https://github.com/nodejs/node-addon-api/commit/a3b4d99c45)] - **doc**: Add contribution philosophy doc (Hitesh Kanwathirtha)
|
||||
* [[`36863f087b`](https://github.com/nodejs/node-addon-api/commit/36863f087b)] - **doc**: refer to TypedArray and ArrayBuffer from Array (Gabriel "_|Nix|_" Schulhof) [#465](https://github.com/nodejs/node-addon-api/pull/465)
|
||||
|
||||
## 2019-04-03 Version 1.6.3, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### API
|
||||
|
||||
- Added `SuppressDestruct` method to `Napi::AsyncWorker`.
|
||||
- Added new build targets for debug.
|
||||
- Exposed macros that throw errors.
|
||||
- Fixed memory leaks caused by callback data when a napi error occurs.
|
||||
- Fixed missing `void *data` usage in `Napi::PropertyDescriptors`.
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Some minor corrections all over the documentation.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`83b41c2fe4`](https://github.com/nodejs/node-addon-api/commit/83b41c2fe4)] - Document adding -fvisibility=hidden flag for macOS users (Nicola Del Gobbo) [#460](https://github.com/nodejs/node-addon-api/pull/460)
|
||||
* [[`1ed7ad8769`](https://github.com/nodejs/node-addon-api/commit/1ed7ad8769)] - **doc**: correct return type of Int32Value to int32\_t (Bill Gallafent) [#459](https://github.com/nodejs/node-addon-api/pull/459)
|
||||
* [[`b0f6b601aa`](https://github.com/nodejs/node-addon-api/commit/b0f6b601aa)] - **src**: add AsyncWorker destruction suppression (Gabriel Schulhof) [#407](https://github.com/nodejs/node-addon-api/pull/407)
|
||||
* [[`72b1975cff`](https://github.com/nodejs/node-addon-api/commit/72b1975cff)] - **doc**: fix links to the Property Descriptor docs (Ryuichi Okumura) [#458](https://github.com/nodejs/node-addon-api/pull/458)
|
||||
* [[`fcfc612728`](https://github.com/nodejs/node-addon-api/commit/fcfc612728)] - **build**: new build targets for debug purposes (Jinho Bang) [#186](https://github.com/nodejs/node-addon-api/pull/186)
|
||||
* [[`c629553cd7`](https://github.com/nodejs/node-addon-api/commit/c629553cd7)] - **doc**: minor doc corrections and clarifications (Bruce A. MacNaughton) [#426](https://github.com/nodejs/node-addon-api/pull/426)
|
||||
* [[`7b87e0b999`](https://github.com/nodejs/node-addon-api/commit/7b87e0b999)] - **doc**: update number.md (Bernardo Heynemann) [#436](https://github.com/nodejs/node-addon-api/pull/436)
|
||||
* [[`fcf173d2a1`](https://github.com/nodejs/node-addon-api/commit/fcf173d2a1)] - **src**: expose macros that throw errors (Gabriel Schulhof) [#448](https://github.com/nodejs/node-addon-api/pull/448)
|
||||
* [[`b409a2f987`](https://github.com/nodejs/node-addon-api/commit/b409a2f987)] - **package**: add npm search keywords (Sam Roberts) [#452](https://github.com/nodejs/node-addon-api/pull/452)
|
||||
* [[`0bc7987806`](https://github.com/nodejs/node-addon-api/commit/0bc7987806)] - **doc**: fix references to Weak and Persistent (Jake Barnes) [#428](https://github.com/nodejs/node-addon-api/pull/428)
|
||||
* [[`ad6f569f85`](https://github.com/nodejs/node-addon-api/commit/ad6f569f85)] - **doc**: dix typo (Abhishek Kumar Singh) [#435](https://github.com/nodejs/node-addon-api/pull/435)
|
||||
* [[`28df833a49`](https://github.com/nodejs/node-addon-api/commit/28df833a49)] - Merge pull request #441 from jschlight/master (Jim Schlight)
|
||||
* [[`4921e74d83`](https://github.com/nodejs/node-addon-api/commit/4921e74d83)] - Rearranges names to be alphabetical (Jim Schlight)
|
||||
* [[`48220335b0`](https://github.com/nodejs/node-addon-api/commit/48220335b0)] - Membership review update (Jim Schlight)
|
||||
* [[`44f0695533`](https://github.com/nodejs/node-addon-api/commit/44f0695533)] - Merge pull request #394 from NickNaso/create\_release (Nicola DelGobbo)
|
||||
* [[`fa49d68416`](https://github.com/nodejs/node-addon-api/commit/fa49d68416)] - **doc**: fix some `Finalizer` signatures (Philipp Renoth) [#414](https://github.com/nodejs/node-addon-api/pull/414)
|
||||
* [[`020ac4a628`](https://github.com/nodejs/node-addon-api/commit/020ac4a628)] - **src**: make `Object::GetPropertyNames()` const (Philipp Renoth)[#415](https://github.com/nodejs/node-addon-api/pull/415)
|
||||
* [[`91eaa6f4cb`](https://github.com/nodejs/node-addon-api/commit/91eaa6f4cb)] - **src**: fix callbackData leaks on error napi status (Philipp Renoth) [#417](https://github.com/nodejs/node-addon-api/pull/417)
|
||||
* [[`0b40275752`](https://github.com/nodejs/node-addon-api/commit/0b40275752)] - **src**: fix noexcept control flow issues (Philipp Renoth) [#420](https://github.com/nodejs/node-addon-api/pull/420)
|
||||
* [[`c1ff2936f9`](https://github.com/nodejs/node-addon-api/commit/c1ff2936f9)] - **src**: fix missing void\*data usage in PropertyDescriptors (Luciano Martorella) [#374](https://github.com/nodejs/node-addon-api/pull/374)
|
||||
|
||||
## 2018-11-29 Version 1.6.2, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### API
|
||||
|
||||
- Fixed selection logic for version 6.x.
|
||||
|
||||
### Commmits
|
||||
|
||||
* [[`07a0fc4e95`](https://github.com/nodejs/node-addon-api/commit/07a0fc4e95)] - **src**: fix selection logic for 6.x (Michael Dawson) [#402](https://github.com/nodejs/node-addon-api/pull/402)
|
||||
|
||||
## 2018-11-14 Version 1.6.1, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Updated links for examples to point to node-addon-examples repo.
|
||||
- Fixed typos on some parts of documentation.
|
||||
|
||||
#### API
|
||||
|
||||
- Removed unused member on `Napi::CallbackScope`.
|
||||
- Enabled `Napi::CallbackScope` only with N-API v3.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`e7cd292a74`](https://github.com/nodejs/node-addon-api/commit/e7cd292a74)] - **src**: remove unused CallbackScope member (Gabriel Schulhof) [#391](https://github.com/nodejs/node-addon-api/pull/391)
|
||||
* [[`d47399fe25`](https://github.com/nodejs/node-addon-api/commit/d47399fe25)] - **src**: guard CallbackScope with N-API v3 (Michael Dawson) [#395](https://github.com/nodejs/node-addon-api/pull/395)
|
||||
* [[`29a0262ab9`](https://github.com/nodejs/node-addon-api/commit/29a0262ab9)] - **doc**: fix typo (Dongjin Na) [#385](https://github.com/nodejs/node-addon-api/pull/385)
|
||||
* [[`b6dc15b88d`](https://github.com/nodejs/node-addon-api/commit/b6dc15b88d)] - **doc**: make links point to node-addon-examples repo (Nicola Del Gobbo) [#389](https://github.com/nodejs/node-addon-api/pull/389)
|
||||
|
||||
## 2018-11-02 Version 1.6.0, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Improved documentation about ABI stability.
|
||||
|
||||
#### API
|
||||
|
||||
- Add `Napi::CallbackScope` class that help to have the equivalent of the scope
|
||||
associated with a callback in place when making certain N-API calls
|
||||
|
||||
#### TEST
|
||||
|
||||
- Added tests for `Napi::Array` class.
|
||||
- Added tests for `Napi::ArrayBuffer` class.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`8ce605c657`](https://github.com/nodejs/node-addon-api/commit/8ce605c657)] - **build**: avoid using package-lock.json (Jaeseok Yoon) [#359](https://github.com/nodejs/node-addon-api/pull/359)
|
||||
* [[`fa3a6150b3`](https://github.com/nodejs/node-addon-api/commit/fa3a6150b3)] - **src**: use MakeCallback() -\> Call() in AsyncWorker (Jinho Bang) [#361](https://github.com/nodejs/node-addon-api/pull/361)
|
||||
* [[`2342415463`](https://github.com/nodejs/node-addon-api/commit/2342415463)] - **test**: create test objects in the stack instead of the heap (Dongjin Na) [#371](https://github.com/nodejs/node-addon-api/pull/371)
|
||||
* [[`67b7db0a6f`](https://github.com/nodejs/node-addon-api/commit/67b7db0a6f)] - **test**: write tests for Array class (Jaeseok Yoon) [#363](https://github.com/nodejs/node-addon-api/pull/363)
|
||||
* [[`729f6dc4ee`](https://github.com/nodejs/node-addon-api/commit/729f6dc4ee)] - **test**: add arraybuffer tests (Dongjin Na) [#369](https://github.com/nodejs/node-addon-api/pull/369)
|
||||
* [[`405f3e5b5b`](https://github.com/nodejs/node-addon-api/commit/405f3e5b5b)] - **src**: implement CallbackScope class (Jinho Bang) [#362](https://github.com/nodejs/node-addon-api/pull/362)
|
||||
* [[`015d95312f`](https://github.com/nodejs/node-addon-api/commit/015d95312f)] - **doc**: fix Napi::Reference link (Gentilhomme) [#365](https://github.com/nodejs/node-addon-api/pull/365)
|
||||
* [[`fd65078e3c`](https://github.com/nodejs/node-addon-api/commit/fd65078e3c)] - README.md: link to new ABI stability guide (Gabriel Schulhof) [#367](https://github.com/nodejs/node-addon-api/pull/367)
|
||||
* [[`ffebf9ba9a`](https://github.com/nodejs/node-addon-api/commit/ffebf9ba9a)] - Updates for release 1.5.0 (NickNaso)
|
||||
|
||||
## 2018-10-03 Version 1.5.0, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Completed the documentation to cover all the API surface.
|
||||
- Numerous fixes to make documentation more consistent in all of its parts.
|
||||
|
||||
#### API
|
||||
|
||||
- Add `Napi::AsyncContext` class to handle asynchronous operation.
|
||||
- Add `Napi::BigInt` class to work with BigInt type.
|
||||
- Add `Napi::VersionManagement` class to retrieve the versions of Node.js and N-API.
|
||||
- Fix potential memory leaks.
|
||||
- DataView feature is enabled by default
|
||||
- Add descriptor for Symbols
|
||||
- Add new methods on `Napi::FunctionReference`.
|
||||
- Add the possibility to retrieve the environment on `Napi::Promise::Deferred`
|
||||
|
||||
#### TOOL
|
||||
|
||||
- Add tool to check if a native add-on is built using N-API
|
||||
|
||||
#### TEST
|
||||
|
||||
- Start to increase the test coverage
|
||||
- Fix in the test suite to better handle the experimental features that are not
|
||||
yet backported in the previous Node.js version.
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`2009c019af`](https://github.com/nodejs/node-addon-api/commit/2009c019af)] - Merge pull request #292 from devsnek/feature/bigint (Gus Caplan)
|
||||
* [[`e44aca985e`](https://github.com/nodejs/node-addon-api/commit/e44aca985e)] - add bigint class (Gus Caplan)
|
||||
* [[`a3951ab973`](https://github.com/nodejs/node-addon-api/commit/a3951ab973)] - Add documentation for Env(). (Rolf Timmermans) [#318](https://github.com/nodejs/node-addon-api/pull/318)
|
||||
* [[`a6f7a6ad51`](https://github.com/nodejs/node-addon-api/commit/a6f7a6ad51)] - Add Env() to Promise::Deferred. (Rolf Timmermans)
|
||||
* [[`0097e96b92`](https://github.com/nodejs/node-addon-api/commit/0097e96b92)] - Fixed broken links for Symbol and String (NickNaso)
|
||||
* [[`b0ecd38d76`](https://github.com/nodejs/node-addon-api/commit/b0ecd38d76)] - Fix Code of conduct link properly (#323) (Jake Yoon) [#323](https://github.com/nodejs/node-addon-api/pull/323)
|
||||
* [[`223474900f`](https://github.com/nodejs/node-addon-api/commit/223474900f)] - **doc**: update Version management (Dongjin Na) [#360](https://github.com/nodejs/node-addon-api/pull/360)
|
||||
* [[`4f76262a10`](https://github.com/nodejs/node-addon-api/commit/4f76262a10)] - **doc**: some fix on `Napi::Boolean` documentation (NickNaso) [#354](https://github.com/nodejs/node-addon-api/pull/354)
|
||||
* [[`78374f72d2`](https://github.com/nodejs/node-addon-api/commit/78374f72d2)] - **doc**: number documentation (NickNaso) [#356](https://github.com/nodejs/node-addon-api/pull/356)
|
||||
* [[`51ffe453f8`](https://github.com/nodejs/node-addon-api/commit/51ffe453f8)] - **doc**: doc cleanup (NickNaso) [#353](https://github.com/nodejs/node-addon-api/pull/353)
|
||||
* [[`fc11c944b2`](https://github.com/nodejs/node-addon-api/commit/fc11c944b2)] - **doc**: major doc cleanup (NickNaso) [#335](https://github.com/nodejs/node-addon-api/pull/335)
|
||||
* [[`100d0a7cb2`](https://github.com/nodejs/node-addon-api/commit/100d0a7cb2)] - **doc**: first pass on objectwrap documentation (NickNaso) [#321](https://github.com/nodejs/node-addon-api/pull/321)
|
||||
* [[`c7d54180ff`](https://github.com/nodejs/node-addon-api/commit/c7d54180ff)] - **doc**: the Napi::ObjectWrap example does not compile (Arnaud Botella) [#339](https://github.com/nodejs/node-addon-api/pull/339)
|
||||
* [[`7cdd78726a`](https://github.com/nodejs/node-addon-api/commit/7cdd78726a)] - **doc**: added cpp highlight for string.md (Jaeseok Yoon) [#329](https://github.com/nodejs/node-addon-api/pull/329)
|
||||
* [[`8ed29f547c`](https://github.com/nodejs/node-addon-api/commit/8ed29f547c)] - **doc**: add blurb about ABI stability (Gabriel Schulhof) [#326](https://github.com/nodejs/node-addon-api/pull/326)
|
||||
* [[`757eb1f5a3`](https://github.com/nodejs/node-addon-api/commit/757eb1f5a3)] - **doc**: add function and function reference doc (NickNaso) [#299](https://github.com/nodejs/node-addon-api/pull/299)
|
||||
* [[`2885c18591`](https://github.com/nodejs/node-addon-api/commit/2885c18591)] - **doc**: Create changelog for release 1.4.0 (Nicola Del Gobbo)
|
||||
* [[`917bd60baa`](https://github.com/nodejs/node-addon-api/commit/917bd60baa)] - **src**: remove TODOs by fixing memory leaks (Gabriel Schulhof) [#343](https://github.com/nodejs/node-addon-api/pull/343)
|
||||
* [[`dfcb93945f`](https://github.com/nodejs/node-addon-api/commit/dfcb93945f)] - **src**: implement AsyncContext class (Jinho Bang) [#252](https://github.com/nodejs/node-addon-api/pull/252)
|
||||
* [[`211ed38d0d`](https://github.com/nodejs/node-addon-api/commit/211ed38d0d)] - **src**: make 'nothing' target a static library (Gabriel Schulhof) [#348](https://github.com/nodejs/node-addon-api/pull/348)
|
||||
* [[`97c4ab5cf2`](https://github.com/nodejs/node-addon-api/commit/97c4ab5cf2)] - **src**: add Call and MakeCallback that accept cargs (NickNaso) [#344](https://github.com/nodejs/node-addon-api/pull/344)
|
||||
* [[`b6e2d92c09`](https://github.com/nodejs/node-addon-api/commit/b6e2d92c09)] - **src**: enable DataView feature by default (Jinho) [#331](https://github.com/nodejs/node-addon-api/pull/331)
|
||||
* [[`0a00e7c97b`](https://github.com/nodejs/node-addon-api/commit/0a00e7c97b)] - **src**: implement missing descriptor defs for symbols (Philipp Renoth) [#280](https://github.com/nodejs/node-addon-api/pull/280)
|
||||
* [[`38e01b7e3b`](https://github.com/nodejs/node-addon-api/commit/38e01b7e3b)] - **src**: first pass on adding version management apis (NickNaso) [#325](https://github.com/nodejs/node-addon-api/pull/325)
|
||||
* [[`79ee8381d2`](https://github.com/nodejs/node-addon-api/commit/79ee8381d2)] - **src**: fix compile failure in test (Michael Dawson) [#345](https://github.com/nodejs/node-addon-api/pull/345)
|
||||
* [[`4d92a6066f`](https://github.com/nodejs/node-addon-api/commit/4d92a6066f)] - **src**: Add ObjectReference test case (Anisha Rohra) [#212](https://github.com/nodejs/node-addon-api/pull/212)
|
||||
* [[`779560f397`](https://github.com/nodejs/node-addon-api/commit/779560f397)] - **test**: add operator overloading tests in Number (Your Name) [#355](https://github.com/nodejs/node-addon-api/pull/355)
|
||||
* [[`73fed84ceb`](https://github.com/nodejs/node-addon-api/commit/73fed84ceb)] - **test**: add ability to control experimental tests (Michael Dawson) [#350](https://github.com/nodejs/node-addon-api/pull/350)
|
||||
* [[`14c69abd46`](https://github.com/nodejs/node-addon-api/commit/14c69abd46)] - **test**: write tests for Boolean class (Jaeseok Yoon) [#328](https://github.com/nodejs/node-addon-api/pull/328)
|
||||
* [[`2ad47a83b1`](https://github.com/nodejs/node-addon-api/commit/2ad47a83b1)] - **test**: explicitly cast to uint32\_t in test (Gabriel Schulhof) [#341](https://github.com/nodejs/node-addon-api/pull/341)
|
||||
* [[`622ffaea76`](https://github.com/nodejs/node-addon-api/commit/622ffaea76)] - **test**: Tighten up compiler warnings (Mikhail Cheshkov) [#315](https://github.com/nodejs/node-addon-api/pull/315)
|
||||
* [[`fd3c37b0f2`](https://github.com/nodejs/node-addon-api/commit/fd3c37b0f2)] - **tools**: add tool to check for N-API modules (Gabriel Schulhof) [#346](https://github.com/nodejs/node-addon-api/pull/346)
|
||||
|
||||
## 2018-07-19 Version 1.4.0, @NickNaso
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### Documentation
|
||||
|
||||
- Numerous additions to the documentation, filling out coverage
|
||||
of API surface
|
||||
|
||||
#### API
|
||||
|
||||
- Add resource parameters to AsyncWorker constructor
|
||||
- Add memory management feature
|
||||
|
||||
### Commits
|
||||
|
||||
* [[`7dc5ac8bc3`](https://github.com/nodejs/node-addon-api/commit/7dc5ac8bc3)] - **doc**: update metadata for release (Nicola Del Gobbo)
|
||||
* [[`d68e86adb4`](https://github.com/nodejs/node-addon-api/commit/d68e86adb4)] - **doc**: Added documentation for PropertyDescriptor (Anisha Rohra) [#309](https://github.com/nodejs/node-addon-api/pull/309)
|
||||
* [[`968a5f2000`](https://github.com/nodejs/node-addon-api/commit/968a5f2000)] - **doc**: Add documentation for ObjectReference.md (Anisha Rohra) [#307](https://github.com/nodejs/node-addon-api/pull/307)
|
||||
* [[`908cdc314c`](https://github.com/nodejs/node-addon-api/commit/908cdc314c)] - **doc**: add `TypedArray` and `TypedArrayOf` (Kyle Farnung) [#305](https://github.com/nodejs/node-addon-api/pull/305)
|
||||
* [[`2ff776ffe3`](https://github.com/nodejs/node-addon-api/commit/2ff776ffe3)] - backport node::Persistent (Gabriel Schulhof) [#300](https://github.com/nodejs/node-addon-api/pull/300)
|
||||
* [[`98161970c9`](https://github.com/nodejs/node-addon-api/commit/98161970c9)] - Backport perf, crash and exception handling fixes (Gabriel Schulhof) [#295](https://github.com/nodejs/node-addon-api/pull/295)
|
||||
* [[`dd1191e086`](https://github.com/nodejs/node-addon-api/commit/dd1191e086)] - **test**: fix asyncworker test so it runs on 6.x (Michael Dawson) [#298](https://github.com/nodejs/node-addon-api/pull/298)
|
||||
* [[`11697fcecd`](https://github.com/nodejs/node-addon-api/commit/11697fcecd)] - **doc**: ArrayBuffer and Buffer documentation (Kyle Farnung) [#256](https://github.com/nodejs/node-addon-api/pull/256)
|
||||
* [[`605aa2babf`](https://github.com/nodejs/node-addon-api/commit/605aa2babf)] - Add memory management feature (NickNaso) [#286](https://github.com/nodejs/node-addon-api/pull/286)
|
||||
* [[`86be13a611`](https://github.com/nodejs/node-addon-api/commit/86be13a611)] - **doc**: Fix HandleScope docs (Ben Berman) [#287](https://github.com/nodejs/node-addon-api/pull/287)
|
||||
* [[`90f92c4dc0`](https://github.com/nodejs/node-addon-api/commit/90f92c4dc0)] - **doc**: Update broken links in README.md (Hitesh Kanwathirtha) [#290](https://github.com/nodejs/node-addon-api/pull/290)
|
||||
* [[`c2a620dc11`](https://github.com/nodejs/node-addon-api/commit/c2a620dc11)] - **doc**: Clarify positioning versus N-API (Michael Dawson) [#288](https://github.com/nodejs/node-addon-api/pull/288)
|
||||
* [[`6cff890ee5`](https://github.com/nodejs/node-addon-api/commit/6cff890ee5)] - **doc**: Fix typo in docs (Ben Berman) [#284](https://github.com/nodejs/node-addon-api/pull/284)
|
||||
* [[`7394bfd154`](https://github.com/nodejs/node-addon-api/commit/7394bfd154)] - **doc**: Fix typo in docs (Ben Berman) [#285](https://github.com/nodejs/node-addon-api/pull/285)
|
||||
* [[`12b2cdeed3`](https://github.com/nodejs/node-addon-api/commit/12b2cdeed3)] - fix test files (Kyle Farnung) [#257](https://github.com/nodejs/node-addon-api/pull/257)
|
||||
* [[`9ab6607242`](https://github.com/nodejs/node-addon-api/commit/9ab6607242)] - **doc**: Update Doc Version Number (joshgarde) [#277](https://github.com/nodejs/node-addon-api/pull/277)
|
||||
* [[`e029a076c6`](https://github.com/nodejs/node-addon-api/commit/e029a076c6)] - **doc**: First pass at basic Node Addon API docs (Hitesh Kanwathirtha) [#268](https://github.com/nodejs/node-addon-api/pull/268)
|
||||
* [[`74ff79717e`](https://github.com/nodejs/node-addon-api/commit/74ff79717e)] - **doc**: fix link to async\_worker.md (Michael Dawson)
|
||||
* [[`5a63f45eda`](https://github.com/nodejs/node-addon-api/commit/5a63f45eda)] - **doc**: First step of error and async doc (NickNaso) [#272](https://github.com/nodejs/node-addon-api/pull/272)
|
||||
* [[`9d38f61afb`](https://github.com/nodejs/node-addon-api/commit/9d38f61afb)] - **doc**: New Promise and Reference docs (Jim Schlight) [#243](https://github.com/nodejs/node-addon-api/pull/243)
|
||||
* [[`43ff9fa836`](https://github.com/nodejs/node-addon-api/commit/43ff9fa836)] - **doc**: Updated Object documentation (Anisha Rohra) [#254](https://github.com/nodejs/node-addon-api/pull/254)
|
||||
* [[`b197f7cc8b`](https://github.com/nodejs/node-addon-api/commit/b197f7cc8b)] - **doc**: minor typos (Nick Soggin) [#248](https://github.com/nodejs/node-addon-api/pull/248)
|
||||
* [[`4b8918b352`](https://github.com/nodejs/node-addon-api/commit/4b8918b352)] - Add resource parameters to AsyncWorker constructor (Jinho Bang) [#253](https://github.com/nodejs/node-addon-api/pull/253)
|
||||
* [[`1ecf7c19b6`](https://github.com/nodejs/node-addon-api/commit/1ecf7c19b6)] - **doc**: fix wrong link in readme (miloas) [#255](https://github.com/nodejs/node-addon-api/pull/255)
|
||||
* [[`a750ed1932`](https://github.com/nodejs/node-addon-api/commit/a750ed1932)] - **release**: updates to metadata for next release (Michael Dawson)
|
||||
|
||||
## 2018-05-08 Version 1.3.0, @mhdawson
|
||||
|
||||
### Notable changes:
|
||||
|
||||
#### Documentation
|
||||
- Added documentation for Scopes
|
||||
- Added documentation for migration from NAN
|
||||
- Update documentation to better explain the use of NODE_ADDON_API
|
||||
|
||||
#### API
|
||||
- Implement data manipulation methods for dataview
|
||||
- Use built-in N-API on Node.js >= 6.14.2
|
||||
- Value
|
||||
- Added IsExternal()
|
||||
- IsObject() allow functions
|
||||
- String
|
||||
- Fixed initialization of std::string to nullptr
|
||||
|
||||
#### Tests
|
||||
- Fix test failures on linuxOne and AIX
|
||||
- Added basic tests for Scopes
|
||||
- Fix MSVC warning C4244 in tests
|
||||
|
||||
### Commits
|
||||
|
||||
* [386c2aeb74] - test: remove dep on later C++ feature (Michael Dawson) https://github.com/nodejs/node-addon-api/pull/267
|
||||
* [10697734da] - Use built-in N-API on Node.js >= 6.14.2 (Gabriel Schulhof)
|
||||
* [75086da273] - test: add basic tests and doc for scopes (Michael Dawson) https://github.com/nodejs/node-addon-api/pull/250
|
||||
* [341dbd25d5] - doc: update blurb explaining NODE_ADDON_API (Gabriel Schulhof) https://github.com/nodejs/node-addon-api/pull/251
|
||||
* [cf6c93e4ee] - don't try to escape null (Michael Dawson) https://github.com/nodejs/node-addon-api/pull/245
|
||||
* [15e4b35fc2] - test: fix MSVC warning C4244 in tests (Kyle Farnung) https://github.com/nodejs/node-addon-api/pull/236
|
||||
* [7f3ca03b8e] - Create a doc for migration (Sampson Gao) https://github.com/nodejs/node-addon-api/pull/118
|
||||
* [0a2177debe] - Fix test failures on linuxOne and AIX (Jinho Bang) https://github.com/nodejs/node-addon-api/pull/232
|
||||
* [d567f4b6b5] - Added Napi::Value::IsExternal() (Eric Bickle) https://github.com/nodejs/node-addon-api/pull/227
|
||||
* [1b0f0e004a] - Update node-gyp.md (Michele Campus) https://github.com/nodejs/node-addon-api/pull/226
|
||||
* [faf19c4f7a] - Fixed initialization of std::string to nullptr (Eric Bickle) https://github.com/nodejs/node-addon-api/pull/228
|
||||
* [9c4d321b57] - Implement data manipulation methods for dataview (Jinho Bang) https://github.com/nodejs/node-addon-api/pull/218
|
||||
* [5a39fdca6f] - n-api: throw RangeError napi_create_typedarray() (Jinho Bang) https://github.com/nodejs/node-addon-api/pull/216
|
||||
* [1376377202] - Make IsObject() allow functions (Jinho Bang) https://github.com/nodejs/node-addon-api/pull/217
|
||||
* [673b59d319] - src: Initial implementation of DataView class (Jinho Bang) https://github.com/nodejs/node-addon-api/pull/205
|
||||
* [0a899bf1c5] - doc: update indication of latest version (Michael Dawson) https://github.com/nodejs/node-addon-api/pull/211
|
||||
* [17c74e5a5e] - n-api: RangeError in napi_create_dataview() (Jinho Bang) https://github.com/nodejs/node-addon-api/pull/214
|
||||
* [4058a29989] - n-api: fix memory leak in napi_async_destroy() (Jinho Bang) https://github.com/nodejs/node-addon-api/pull/213
|
||||
|
||||
|
||||
13
electron/node_modules/lzma-native/node_modules/node-addon-api/LICENSE.md
generated
vendored
Normal file
13
electron/node_modules/lzma-native/node_modules/node-addon-api/LICENSE.md
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
The MIT License (MIT)
|
||||
=====================
|
||||
|
||||
Copyright (c) 2017 Node.js API collaborators
|
||||
-----------------------------------
|
||||
|
||||
*Node.js API collaborators listed at <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.
|
||||
293
electron/node_modules/lzma-native/node_modules/node-addon-api/README.md
generated
vendored
Normal file
293
electron/node_modules/lzma-native/node_modules/node-addon-api/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,293 @@
|
|||
NOTE: The default branch has been renamed!
|
||||
master is now named main
|
||||
|
||||
If you have a local clone, you can update it by running:
|
||||
|
||||
```shell
|
||||
git branch -m master main
|
||||
git fetch origin
|
||||
git branch -u origin/main main
|
||||
```
|
||||
|
||||
# **node-addon-api module**
|
||||
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.
|
||||
|
||||
There are three options for implementing addons: Node-API, nan, or direct
|
||||
use of internal V8, libuv and Node.js libraries. Unless there is a need for
|
||||
direct access to functionality which is not exposed by Node-API as outlined
|
||||
in [C/C++ addons](https://nodejs.org/dist/latest/docs/api/addons.html)
|
||||
in Node.js core, use Node-API. Refer to
|
||||
[C/C++ addons with Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)
|
||||
for more information on Node-API.
|
||||
|
||||
Node-API is an ABI stable C interface provided by Node.js for building native
|
||||
addons. It is independent from the underlying JavaScript runtime (e.g. V8 or ChakraCore)
|
||||
and is maintained as part of Node.js itself. It is intended to insulate
|
||||
native addons from changes in the underlying JavaScript engine and allow
|
||||
modules compiled for one version to run on later versions of Node.js without
|
||||
recompilation.
|
||||
|
||||
The `node-addon-api` module, which is not part of Node.js, preserves the benefits
|
||||
of the Node-API as it consists only of inline code that depends only on the stable API
|
||||
provided by Node-API. As such, modules built against one version of Node.js
|
||||
using node-addon-api should run without having to be rebuilt with newer versions
|
||||
of Node.js.
|
||||
|
||||
It is important to remember that *other* Node.js interfaces such as
|
||||
`libuv` (included in a project via `#include <uv.h>`) are not ABI-stable across
|
||||
Node.js major versions. Thus, an addon must use Node-API and/or `node-addon-api`
|
||||
exclusively and build against a version of Node.js that includes an
|
||||
implementation of Node-API (meaning an active LTS version of Node.js) in
|
||||
order to benefit from ABI stability across Node.js major versions. Node.js
|
||||
provides an [ABI stability guide][] containing a detailed explanation of ABI
|
||||
stability in general, and the Node-API ABI stability guarantee in particular.
|
||||
|
||||
As new APIs are added to Node-API, node-addon-api must be updated to provide
|
||||
wrappers for those new APIs. For this reason node-addon-api provides
|
||||
methods that allow callers to obtain the underlying Node-API handles so
|
||||
direct calls to Node-API and the use of the objects/methods provided by
|
||||
node-addon-api can be used together. For example, in order to be able
|
||||
to use an API for which the node-addon-api does not yet provide a wrapper.
|
||||
|
||||
APIs exposed by node-addon-api are generally used to create and
|
||||
manipulate JavaScript values. Concepts and operations generally map
|
||||
to ideas specified in the **ECMA262 Language Specification**.
|
||||
|
||||
The [Node-API Resource](https://nodejs.github.io/node-addon-examples/) offers an
|
||||
excellent orientation and tips for developers just getting started with Node-API
|
||||
and node-addon-api.
|
||||
|
||||
- **[Setup](#setup)**
|
||||
- **[API Documentation](#api)**
|
||||
- **[Examples](#examples)**
|
||||
- **[Tests](#tests)**
|
||||
- **[More resource and info about native Addons](#resources)**
|
||||
- **[Badges](#badges)**
|
||||
- **[Code of Conduct](CODE_OF_CONDUCT.md)**
|
||||
- **[Contributors](#contributors)**
|
||||
- **[License](#license)**
|
||||
|
||||
## **Current version: 3.2.1**
|
||||
|
||||
(See [CHANGELOG.md](CHANGELOG.md) for complete Changelog)
|
||||
|
||||
[](https://nodei.co/npm/node-addon-api/) [](https://nodei.co/npm/node-addon-api/)
|
||||
|
||||
<a name="setup"></a>
|
||||
|
||||
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 10.x.
|
||||
|
||||
## Setup
|
||||
- [Installation and usage](doc/setup.md)
|
||||
- [node-gyp](doc/node-gyp.md)
|
||||
- [cmake-js](doc/cmake-js.md)
|
||||
- [Conversion tool](doc/conversion-tool.md)
|
||||
- [Checker tool](doc/checker-tool.md)
|
||||
- [Generator](doc/generator.md)
|
||||
- [Prebuild tools](doc/prebuild_tools.md)
|
||||
|
||||
<a name="api"></a>
|
||||
|
||||
### **API Documentation**
|
||||
|
||||
The following is the documentation for node-addon-api.
|
||||
|
||||
- [Full Class Hierarchy](doc/hierarchy.md)
|
||||
- [Addon Structure](doc/addon.md)
|
||||
- Data Types:
|
||||
- [Env](doc/env.md)
|
||||
- [CallbackInfo](doc/callbackinfo.md)
|
||||
- [Reference](doc/reference.md)
|
||||
- [Value](doc/value.md)
|
||||
- [Name](doc/name.md)
|
||||
- [Symbol](doc/symbol.md)
|
||||
- [String](doc/string.md)
|
||||
- [Number](doc/number.md)
|
||||
- [Date](doc/date.md)
|
||||
- [BigInt](doc/bigint.md)
|
||||
- [Boolean](doc/boolean.md)
|
||||
- [External](doc/external.md)
|
||||
- [Object](doc/object.md)
|
||||
- [Array](doc/array.md)
|
||||
- [ObjectReference](doc/object_reference.md)
|
||||
- [PropertyDescriptor](doc/property_descriptor.md)
|
||||
- [Function](doc/function.md)
|
||||
- [FunctionReference](doc/function_reference.md)
|
||||
- [ObjectWrap](doc/object_wrap.md)
|
||||
- [ClassPropertyDescriptor](doc/class_property_descriptor.md)
|
||||
- [Buffer](doc/buffer.md)
|
||||
- [ArrayBuffer](doc/array_buffer.md)
|
||||
- [TypedArray](doc/typed_array.md)
|
||||
- [TypedArrayOf](doc/typed_array_of.md)
|
||||
- [DataView](doc/dataview.md)
|
||||
- [Error Handling](doc/error_handling.md)
|
||||
- [Error](doc/error.md)
|
||||
- [TypeError](doc/type_error.md)
|
||||
- [RangeError](doc/range_error.md)
|
||||
- [Object Lifetime Management](doc/object_lifetime_management.md)
|
||||
- [HandleScope](doc/handle_scope.md)
|
||||
- [EscapableHandleScope](doc/escapable_handle_scope.md)
|
||||
- [Memory Management](doc/memory_management.md)
|
||||
- [Async Operations](doc/async_operations.md)
|
||||
- [AsyncWorker](doc/async_worker.md)
|
||||
- [AsyncContext](doc/async_context.md)
|
||||
- [AsyncWorker Variants](doc/async_worker_variants.md)
|
||||
- [Thread-safe Functions](doc/threadsafe.md)
|
||||
- [ThreadSafeFunction](doc/threadsafe_function.md)
|
||||
- [TypedThreadSafeFunction](doc/typed_threadsafe_function.md)
|
||||
- [Promises](doc/promises.md)
|
||||
- [Version management](doc/version_management.md)
|
||||
|
||||
<a name="examples"></a>
|
||||
|
||||
### **Examples**
|
||||
|
||||
Are you new to **node-addon-api**? Take a look at our **[examples](https://github.com/nodejs/node-addon-examples)**
|
||||
|
||||
- **[Hello World](https://github.com/nodejs/node-addon-examples/tree/HEAD/1_hello_world/node-addon-api)**
|
||||
- **[Pass arguments to a function](https://github.com/nodejs/node-addon-examples/tree/HEAD/2_function_arguments/node-addon-api)**
|
||||
- **[Callbacks](https://github.com/nodejs/node-addon-examples/tree/HEAD/3_callbacks/node-addon-api)**
|
||||
- **[Object factory](https://github.com/nodejs/node-addon-examples/tree/HEAD/4_object_factory/node-addon-api)**
|
||||
- **[Function factory](https://github.com/nodejs/node-addon-examples/tree/HEAD/5_function_factory/node-addon-api)**
|
||||
- **[Wrapping C++ Object](https://github.com/nodejs/node-addon-examples/tree/HEAD/6_object_wrap/node-addon-api)**
|
||||
- **[Factory of wrapped object](https://github.com/nodejs/node-addon-examples/tree/HEAD/7_factory_wrap/node-addon-api)**
|
||||
- **[Passing wrapped object around](https://github.com/nodejs/node-addon-examples/tree/HEAD/8_passing_wrapped/node-addon-api)**
|
||||
|
||||
<a name="tests"></a>
|
||||
|
||||
### **Tests**
|
||||
|
||||
To run the **node-addon-api** tests do:
|
||||
|
||||
```
|
||||
npm install
|
||||
npm test
|
||||
```
|
||||
|
||||
To avoid testing the deprecated portions of the API run
|
||||
```
|
||||
npm install
|
||||
npm test --disable-deprecated
|
||||
```
|
||||
|
||||
To run the tests targeting a specific version of Node-API run
|
||||
```
|
||||
npm install
|
||||
export NAPI_VERSION=X
|
||||
npm test --NAPI_VERSION=X
|
||||
```
|
||||
|
||||
where X is the version of Node-API you want to target.
|
||||
|
||||
### **Debug**
|
||||
|
||||
To run the **node-addon-api** tests with `--debug` option:
|
||||
|
||||
```
|
||||
npm run-script dev
|
||||
```
|
||||
|
||||
If you want faster build, you might use the following option:
|
||||
|
||||
```
|
||||
npm run-script dev:incremental
|
||||
```
|
||||
|
||||
Take a look and get inspired by our **[test suite](https://github.com/nodejs/node-addon-api/tree/HEAD/test)**
|
||||
|
||||
### **Benchmarks**
|
||||
|
||||
You can run the available benchmarks using the following command:
|
||||
|
||||
```
|
||||
npm run-script benchmark
|
||||
```
|
||||
|
||||
See [benchmark/README.md](benchmark/README.md) for more details about running and adding benchmarks.
|
||||
|
||||
<a name="resources"></a>
|
||||
|
||||
### **More resource and info about native Addons**
|
||||
- **[C++ Addons](https://nodejs.org/dist/latest/docs/api/addons.html)**
|
||||
- **[Node-API](https://nodejs.org/dist/latest/docs/api/n-api.html)**
|
||||
- **[Node-API - Next Generation Node API for Native Modules](https://youtu.be/-Oniup60Afs)**
|
||||
- **[How We Migrated Realm JavaScript From NAN to Node-API](https://developer.mongodb.com/article/realm-javascript-nan-to-n-api)**
|
||||
|
||||
As node-addon-api's core mission is to expose the plain C Node-API as C++
|
||||
wrappers, tools that facilitate n-api/node-addon-api providing more
|
||||
convenient patterns on developing a Node.js add-ons with n-api/node-addon-api
|
||||
can be published to NPM as standalone packages. It is also recommended to tag
|
||||
such packages with `node-addon-api` to provide more visibility to the community.
|
||||
|
||||
Quick links to NPM searches: [keywords:node-addon-api](https://www.npmjs.com/search?q=keywords%3Anode-addon-api).
|
||||
|
||||
<a name="other-bindings"></a>
|
||||
|
||||
### **Other bindings**
|
||||
|
||||
- **[napi-rs](https://napi.rs)** - (`Rust`)
|
||||
|
||||
<a name="badges"></a>
|
||||
|
||||
### **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.
|
||||
|
||||
<a name="contributors"></a>
|
||||
|
||||
## Team members
|
||||
|
||||
### Active
|
||||
| Name | GitHub Link |
|
||||
| ------------------- | ----------------------------------------------------- |
|
||||
| Anna Henningsen | [addaleax](https://github.com/addaleax) |
|
||||
| Chengzhong Wu | [legendecas](https://github.com/legendecas) |
|
||||
| Gabriel Schulhof | [gabrielschulhof](https://github.com/gabrielschulhof) |
|
||||
| Jim Schlight | [jschlight](https://github.com/jschlight) |
|
||||
| Michael Dawson | [mhdawson](https://github.com/mhdawson) |
|
||||
| Kevin Eady | [KevinEady](https://github.com/KevinEady)
|
||||
| Nicola Del Gobbo | [NickNaso](https://github.com/NickNaso) |
|
||||
|
||||
### Emeritus
|
||||
| Name | GitHub Link |
|
||||
| ------------------- | ----------------------------------------------------- |
|
||||
| Arunesh Chandra | [aruneshchandra](https://github.com/aruneshchandra) |
|
||||
| Benjamin Byholm | [kkoopa](https://github.com/kkoopa) |
|
||||
| Jason Ginchereau | [jasongin](https://github.com/jasongin) |
|
||||
| Hitesh Kanwathirtha | [digitalinfinity](https://github.com/digitalinfinity) |
|
||||
| Sampson Gao | [sampsongao](https://github.com/sampsongao) |
|
||||
| Taylor Woll | [boingoing](https://github.com/boingoing) |
|
||||
|
||||
<a name="license"></a>
|
||||
|
||||
Licensed under [MIT](./LICENSE.md)
|
||||
|
||||
[ABI stability guide]: https://nodejs.org/en/docs/guides/abi-stability/
|
||||
[Node-API support matrix]: https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api_version_matrix
|
||||
21
electron/node_modules/lzma-native/node_modules/node-addon-api/common.gypi
generated
vendored
Normal file
21
electron/node_modules/lzma-native/node_modules/node-addon-api/common.gypi
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
'variables': {
|
||||
'NAPI_VERSION%': "<!(node -p \"process.versions.napi\")",
|
||||
'disable_deprecated': "<!(node -p \"process.env['npm_config_disable_deprecated']\")"
|
||||
},
|
||||
'conditions': [
|
||||
['NAPI_VERSION!=""', { 'defines': ['NAPI_VERSION=<@(NAPI_VERSION)'] } ],
|
||||
['disable_deprecated=="true"', {
|
||||
'defines': ['NODE_ADDON_API_DISABLE_DEPRECATED']
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
'cflags+': ['-fvisibility=hidden'],
|
||||
'xcode_settings': {
|
||||
'OTHER_CFLAGS': ['-fvisibility=hidden']
|
||||
}
|
||||
}]
|
||||
],
|
||||
'include_dirs': ["<!(node -p \"require('../').include_dir\")"],
|
||||
'cflags': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ],
|
||||
'cflags_cc': [ '-Werror', '-Wall', '-Wextra', '-Wpedantic', '-Wunused-parameter' ]
|
||||
}
|
||||
16
electron/node_modules/lzma-native/node_modules/node-addon-api/except.gypi
generated
vendored
Normal file
16
electron/node_modules/lzma-native/node_modules/node-addon-api/except.gypi
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
'defines': [ 'NAPI_CPP_EXCEPTIONS' ],
|
||||
'cflags!': [ '-fno-exceptions' ],
|
||||
'cflags_cc!': [ '-fno-exceptions' ],
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
'ExceptionHandling': 1,
|
||||
'EnablePREfast': 'true',
|
||||
},
|
||||
},
|
||||
'xcode_settings': {
|
||||
'CLANG_CXX_LIBRARY': 'libc++',
|
||||
'MACOSX_DEPLOYMENT_TARGET': '10.7',
|
||||
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
|
||||
},
|
||||
}
|
||||
11
electron/node_modules/lzma-native/node_modules/node-addon-api/index.js
generated
vendored
Normal file
11
electron/node_modules/lzma-native/node_modules/node-addon-api/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
const path = require('path');
|
||||
|
||||
const include_dir = path.relative('.', __dirname);
|
||||
|
||||
module.exports = {
|
||||
include: `"${__dirname}"`, // deprecated, can be removed as part of 4.0.0
|
||||
include_dir,
|
||||
gyp: path.join(include_dir, 'node_api.gyp:nothing'),
|
||||
isNodeApiBuiltin: true,
|
||||
needsFlag: false
|
||||
};
|
||||
192
electron/node_modules/lzma-native/node_modules/node-addon-api/napi-inl.deprecated.h
generated
vendored
Normal file
192
electron/node_modules/lzma-native/node_modules/node-addon-api/napi-inl.deprecated.h
generated
vendored
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
#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_
|
||||
5671
electron/node_modules/lzma-native/node_modules/node-addon-api/napi-inl.h
generated
vendored
Normal file
5671
electron/node_modules/lzma-native/node_modules/node-addon-api/napi-inl.h
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
2727
electron/node_modules/lzma-native/node_modules/node-addon-api/napi.h
generated
vendored
Normal file
2727
electron/node_modules/lzma-native/node_modules/node-addon-api/napi.h
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
9
electron/node_modules/lzma-native/node_modules/node-addon-api/node_api.gyp
generated
vendored
Normal file
9
electron/node_modules/lzma-native/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' ]
|
||||
}
|
||||
]
|
||||
}
|
||||
16
electron/node_modules/lzma-native/node_modules/node-addon-api/noexcept.gypi
generated
vendored
Normal file
16
electron/node_modules/lzma-native/node_modules/node-addon-api/noexcept.gypi
generated
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
|
||||
'cflags': [ '-fno-exceptions' ],
|
||||
'cflags_cc': [ '-fno-exceptions' ],
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
'ExceptionHandling': 0,
|
||||
'EnablePREfast': 'true',
|
||||
},
|
||||
},
|
||||
'xcode_settings': {
|
||||
'CLANG_CXX_LIBRARY': 'libc++',
|
||||
'MACOSX_DEPLOYMENT_TARGET': '10.7',
|
||||
'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',
|
||||
},
|
||||
}
|
||||
0
electron/node_modules/lzma-native/node_modules/node-addon-api/nothing.c
generated
vendored
Normal file
0
electron/node_modules/lzma-native/node_modules/node-addon-api/nothing.c
generated
vendored
Normal file
21
electron/node_modules/lzma-native/node_modules/node-addon-api/package-support.json
generated
vendored
Normal file
21
electron/node_modules/lzma-native/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/" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
368
electron/node_modules/lzma-native/node_modules/node-addon-api/package.json
generated
vendored
Normal file
368
electron/node_modules/lzma-native/node_modules/node-addon-api/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,368 @@
|
|||
{
|
||||
"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": "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": "Darshan Sen",
|
||||
"url": "https://github.com/RaisinTen"
|
||||
},
|
||||
{
|
||||
"name": "David Halls",
|
||||
"url": "https://github.com/davedoesdev"
|
||||
},
|
||||
{
|
||||
"name": "Dmitry Ashkadov",
|
||||
"url": "https://github.com/dmitryash"
|
||||
},
|
||||
{
|
||||
"name": "Dongjin Na",
|
||||
"url": "https://github.com/nadongguri"
|
||||
},
|
||||
{
|
||||
"name": "Ferdinand Holzer",
|
||||
"url": "https://github.com/fholzer"
|
||||
},
|
||||
{
|
||||
"name": "Eric Bickle",
|
||||
"url": "https://github.com/ebickle"
|
||||
},
|
||||
{
|
||||
"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": "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": "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": "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": "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": "Philipp Renoth",
|
||||
"url": "https://github.com/DaAitch"
|
||||
},
|
||||
{
|
||||
"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": "Sampson Gao",
|
||||
"url": "https://github.com/sampsongao"
|
||||
},
|
||||
{
|
||||
"name": "Sam Roberts",
|
||||
"url": "https://github.com/sam-github"
|
||||
},
|
||||
{
|
||||
"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": "Tux3",
|
||||
"url": "https://github.com/tux3"
|
||||
},
|
||||
{
|
||||
"name": "Vlad Velmisov",
|
||||
"url": "https://github.com/Velmisov"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"description": "Node.js API (Node-API)",
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"bindings": "^1.5.0",
|
||||
"clang-format": "^1.4.0",
|
||||
"fs-extra": "^9.0.1",
|
||||
"pre-commit": "^1.2.2",
|
||||
"safe-buffer": "^5.1.1"
|
||||
},
|
||||
"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",
|
||||
"optionalDependencies": {},
|
||||
"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",
|
||||
"pretest": "node-gyp rebuild -C test",
|
||||
"test": "node test",
|
||||
"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": "node tools/clang-format",
|
||||
"lint:fix": "node tools/clang-format --fix"
|
||||
},
|
||||
"pre-commit": "lint",
|
||||
"version": "3.2.1",
|
||||
"support": true
|
||||
}
|
||||
73
electron/node_modules/lzma-native/node_modules/node-addon-api/tools/README.md
generated
vendored
Normal file
73
electron/node_modules/lzma-native/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.
|
||||
100
electron/node_modules/lzma-native/node_modules/node-addon-api/tools/check-napi.js
generated
vendored
Normal file
100
electron/node_modules/lzma-native/node_modules/node-addon-api/tools/check-napi.js
generated
vendored
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
'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');
|
||||
const child_process = require('child_process');
|
||||
|
||||
// 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 = child_process.spawn(command, argv, {
|
||||
stdio: ['inherit', 'pipe', 'inherit']
|
||||
});
|
||||
let leftover = '';
|
||||
let isNapi = undefined;
|
||||
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 ("error reading directory " + top + ": " + error);
|
||||
}
|
||||
items.forEach((item) => {
|
||||
item = path.join(top, item);
|
||||
fs.stat(item, ((item) => (error, stats) => {
|
||||
if (error) {
|
||||
throw ("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] : '.');
|
||||
67
electron/node_modules/lzma-native/node_modules/node-addon-api/tools/clang-format.js
generated
vendored
Normal file
67
electron/node_modules/lzma-native/node_modules/node-addon-api/tools/clang-format.js
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const spawn = require('child_process').spawnSync;
|
||||
const path = require('path');
|
||||
|
||||
const filesToCheck = ['*.h', '*.cc'];
|
||||
const CLANG_FORMAT_START = process.env.CLANG_FORMAT_START || 'main';
|
||||
|
||||
function main(args) {
|
||||
let fix = false;
|
||||
while (args.length > 0) {
|
||||
switch (args[0]) {
|
||||
case '-f':
|
||||
case '--fix':
|
||||
fix = true;
|
||||
default:
|
||||
}
|
||||
args.shift();
|
||||
}
|
||||
|
||||
let clangFormatPath = path.dirname(require.resolve('clang-format'));
|
||||
const options = ['--binary=node_modules/.bin/clang-format', '--style=file'];
|
||||
if (fix) {
|
||||
options.push(CLANG_FORMAT_START);
|
||||
} else {
|
||||
options.push('--diff', CLANG_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 CLANG_FORMAT_START=upstream/main ${fixCmd}".`);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
process.exitCode = main(process.argv.slice(2));
|
||||
}
|
||||
309
electron/node_modules/lzma-native/node_modules/node-addon-api/tools/conversion.js
generated
vendored
Executable file
309
electron/node_modules/lzma-native/node_modules/node-addon-api/tools/conversion.js
generated
vendored
Executable file
|
|
@ -0,0 +1,309 @@
|
|||
#! /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('../package.json').version;
|
||||
|
||||
const disable = args[1];
|
||||
if (disable != "--disable" && dir != "--disable") {
|
||||
var 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 {
|
||||
var 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 ]' ],
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
var 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;' ],
|
||||
|
||||
];
|
||||
|
||||
var paths = listFiles(dir);
|
||||
paths.forEach(function(dirEntry) {
|
||||
var filename = dirEntry.split('\\').pop().split('/').pop();
|
||||
|
||||
// Check whether the file is a source file or a config file
|
||||
// then execute function accordingly
|
||||
var sourcePattern = /.+\.h|.+\.cc|.+\.cpp/;
|
||||
if (sourcePattern.test(filename)) {
|
||||
convertFile(dirEntry, SourceFileOperations);
|
||||
} else if (ConfigFileOperations[filename] != null) {
|
||||
convertFile(dirEntry, ConfigFileOperations[filename]);
|
||||
}
|
||||
});
|
||||
|
||||
function listFiles(dir, filelist) {
|
||||
var 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 ++) {
|
||||
let 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;
|
||||
});
|
||||
});
|
||||
}
|
||||
53
electron/node_modules/lzma-native/package.json
generated
vendored
Normal file
53
electron/node_modules/lzma-native/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"name": "lzma-native",
|
||||
"version": "8.0.6",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"author": {
|
||||
"name": "Anna Henningsen",
|
||||
"email": "anna@addaleax.net"
|
||||
},
|
||||
"description": "Provides bindings to the native liblzma library (.xz file format, among others)",
|
||||
"main": "index",
|
||||
"bin": {
|
||||
"lzmajs": "bin/lzmajs"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-addon-api": "^3.1.0",
|
||||
"node-gyp-build": "^4.2.1",
|
||||
"readable-stream": "^3.6.0"
|
||||
},
|
||||
"keywords": [
|
||||
"lzma",
|
||||
"compression",
|
||||
"crc32",
|
||||
"xz",
|
||||
"liblzma"
|
||||
],
|
||||
"homepage": "https://github.com/addaleax/lzma-native",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/addaleax/lzma-native.git"
|
||||
},
|
||||
"scripts": {
|
||||
"install": "node-gyp-build",
|
||||
"prebuild": "prebuildify --napi --electron-compat",
|
||||
"prepack": "[ $(ls prebuilds | wc -l) = '6' ] || (echo 'Some prebuilds are missing'; exit 1)",
|
||||
"test": "mocha --expose-gc -s 1000 -t 15000",
|
||||
"prepare": "npm run prepare-win32 || true",
|
||||
"prepare-win32": "cd deps && 7z x -y xz-5.2.3-windows.7z bin_i686/liblzma.dll bin_x86-64/liblzma.dll include doc/liblzma.def",
|
||||
"jshint": "jshint ."
|
||||
},
|
||||
"gypfile": true,
|
||||
"bugs": {
|
||||
"url": "https://github.com/addaleax/lzma-native/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bl": "^4.1.0",
|
||||
"jshint": "^2.12.0",
|
||||
"mocha": "^8.3.1",
|
||||
"prebuildify": "^5.0.0"
|
||||
}
|
||||
}
|
||||
BIN
electron/node_modules/lzma-native/prebuilds/darwin-arm64/electron.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/darwin-arm64/electron.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/darwin-arm64/node.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/darwin-arm64/node.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/darwin-x64/electron.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/darwin-x64/electron.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/darwin-x64/node.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/darwin-x64/node.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/linux-arm64/electron.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/linux-arm64/electron.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/linux-arm64/node.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/linux-arm64/node.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/linux-x64/electron.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/linux-x64/electron.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/linux-x64/node.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/linux-x64/node.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/win32-ia32/electron.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/win32-ia32/electron.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/win32-ia32/liblzma.dll
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/win32-ia32/liblzma.dll
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/win32-ia32/node.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/win32-ia32/node.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/win32-x64/electron.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/win32-x64/electron.napi.node
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/win32-x64/liblzma.dll
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/win32-x64/liblzma.dll
generated
vendored
Normal file
Binary file not shown.
BIN
electron/node_modules/lzma-native/prebuilds/win32-x64/node.napi.node
generated
vendored
Normal file
BIN
electron/node_modules/lzma-native/prebuilds/win32-x64/node.napi.node
generated
vendored
Normal file
Binary file not shown.
65
electron/node_modules/lzma-native/src/filter-array.cpp
generated
vendored
Normal file
65
electron/node_modules/lzma-native/src/filter-array.cpp
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#include "liblzma-node.hpp"
|
||||
|
||||
namespace lzma {
|
||||
|
||||
FilterArray::FilterArray(Value val) {
|
||||
Env env = val.Env();
|
||||
HandleScope handle_scope(env);
|
||||
|
||||
if (!val.IsArray())
|
||||
throw TypeError::New(env, "Filter array expected");
|
||||
Array arr = val.As<Array>();
|
||||
|
||||
size_t len = arr.Length();
|
||||
|
||||
String id_ = String::New(env, "id");
|
||||
String options_ = String::New(env, "options");
|
||||
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
Value entry_v = arr[i];
|
||||
if (!entry_v.IsObject() || !entry_v.As<Object>().Has(id_))
|
||||
throw TypeError::New(env, "Filter array expected");
|
||||
Object entry = entry_v.As<Object>();
|
||||
|
||||
String id = Value(entry[id_]).ToString();
|
||||
Value opt_v = entry[options_];
|
||||
|
||||
lzma_filter f;
|
||||
f.id = FilterByName(id);
|
||||
f.options = nullptr;
|
||||
|
||||
bool has_options = !opt_v.IsUndefined() && !opt_v.IsNull();
|
||||
if (!has_options && (f.id != LZMA_FILTER_LZMA1 && f.id != LZMA_FILTER_LZMA2)) {
|
||||
filters.push_back(f);
|
||||
continue;
|
||||
}
|
||||
|
||||
Object opt = has_options ? opt_v.ToObject() : Object::New(env);
|
||||
|
||||
optbuf.push_back(options());
|
||||
union options& bopt = optbuf.back();
|
||||
|
||||
switch (f.id) {
|
||||
case LZMA_FILTER_DELTA:
|
||||
bopt.delta.type = (lzma_delta_type) GetIntegerProperty(opt, "type", LZMA_DELTA_TYPE_BYTE);
|
||||
bopt.delta.dist = GetIntegerProperty(opt, "dist", 1);
|
||||
f.options = &bopt.delta;
|
||||
break;
|
||||
case LZMA_FILTER_LZMA1:
|
||||
case LZMA_FILTER_LZMA2:
|
||||
bopt.lzma = parseOptionsLZMA(opt);
|
||||
f.options = &bopt.lzma;
|
||||
break;
|
||||
default:
|
||||
throw TypeError::New(env, "LZMA wrapper library understands .options only for DELTA and LZMA1, LZMA2 filters");
|
||||
}
|
||||
|
||||
filters.push_back(f);
|
||||
}
|
||||
|
||||
lzma_filter end;
|
||||
end.id = LZMA_VLI_UNKNOWN;
|
||||
filters.push_back(end);
|
||||
}
|
||||
|
||||
}
|
||||
596
electron/node_modules/lzma-native/src/index-parser.cpp
generated
vendored
Normal file
596
electron/node_modules/lzma-native/src/index-parser.cpp
generated
vendored
Normal file
|
|
@ -0,0 +1,596 @@
|
|||
// The contents from this file are from a proposed API that is not yet
|
||||
// implemented in upstream liblzma.
|
||||
|
||||
#include "index-parser.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#undef my_min
|
||||
#define my_min(x, y) ((x) < (y) ? (x) : (y))
|
||||
|
||||
namespace lzma {
|
||||
|
||||
void *
|
||||
lzma_alloc(size_t size, const lzma_allocator *allocator)
|
||||
{
|
||||
// Some malloc() variants return NULL if called with size == 0.
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
|
||||
void *ptr;
|
||||
|
||||
if (allocator != NULL && allocator->alloc != NULL)
|
||||
ptr = allocator->alloc(allocator->opaque, 1, size);
|
||||
else
|
||||
ptr = malloc(size);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void
|
||||
lzma_free(void *ptr, const lzma_allocator *allocator)
|
||||
{
|
||||
if (allocator != NULL && allocator->free != NULL)
|
||||
allocator->free(allocator->opaque, ptr);
|
||||
else
|
||||
free(ptr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
enum lip_state {
|
||||
PARSE_INDEX_INITED,
|
||||
PARSE_INDEX_READ_FOOTER,
|
||||
PARSE_INDEX_READ_INDEX,
|
||||
PARSE_INDEX_READ_STREAM_HEADER
|
||||
};
|
||||
|
||||
struct lzma_index_parser_internal_s {
|
||||
/// Current state.
|
||||
lip_state state;
|
||||
|
||||
/// Current position in the file. We parse the file backwards so
|
||||
/// initialize it to point to the end of the file.
|
||||
int64_t pos;
|
||||
|
||||
/// The footer flags of the current XZ stream.
|
||||
lzma_stream_flags footer_flags;
|
||||
|
||||
/// All Indexes decoded so far.
|
||||
lzma_index *combined_index;
|
||||
|
||||
/// The Index currently being decoded.
|
||||
lzma_index *this_index;
|
||||
|
||||
/// Padding of the stream currently being decoded.
|
||||
lzma_vli stream_padding;
|
||||
|
||||
/// Size of the Index currently being decoded.
|
||||
lzma_vli index_size;
|
||||
|
||||
/// Keep track of how much memory is being used for Index decoding.
|
||||
uint64_t memused;
|
||||
|
||||
/// lzma_stream for the Index decoder.
|
||||
lzma_stream strm;
|
||||
|
||||
/// Keep the buffer coming as the last member to so all data that is
|
||||
/// ever actually used fits in a few cache lines.
|
||||
uint8_t buf[8192];
|
||||
};
|
||||
|
||||
static lzma_ret
|
||||
parse_indexes_read(lzma_index_parser_data *info,
|
||||
uint8_t *buf,
|
||||
size_t size,
|
||||
int64_t pos)
|
||||
{
|
||||
int64_t read = info->read_callback(info->opaque, buf, size, pos);
|
||||
|
||||
if (read < 0) {
|
||||
return LZMA_DATA_ERROR;
|
||||
}
|
||||
|
||||
if ((size_t)read != size) {
|
||||
info->message = "Unexpected end of file";
|
||||
return LZMA_DATA_ERROR;
|
||||
}
|
||||
|
||||
return LZMA_OK;
|
||||
}
|
||||
|
||||
extern lzma_ret
|
||||
my_lzma_parse_indexes_from_file(lzma_index_parser_data *info)
|
||||
{
|
||||
lzma_ret ret;
|
||||
lzma_index_parser_internal *internal = info->internal;
|
||||
info->message = NULL;
|
||||
|
||||
// Apparently, we are already done.
|
||||
if (info->index != NULL) {
|
||||
ret = LZMA_PROG_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Passing file_size == SIZE_MAX can be used to safely clean up
|
||||
// everything when I/O failed asynchronously.
|
||||
if (info->file_size == SIZE_MAX) {
|
||||
ret = LZMA_OPTIONS_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (info->memlimit == 0) {
|
||||
info->memlimit = UINT64_MAX;
|
||||
}
|
||||
|
||||
if (internal == NULL) {
|
||||
if (info->memlimit <= sizeof(lzma_index_parser_internal)) {
|
||||
// We don't really have a good figure for how much
|
||||
// memory may be necessary. Set memlimit to 0 to
|
||||
// indicate that something is obviously inacceptable.
|
||||
info->memlimit = 0;
|
||||
return LZMA_MEMLIMIT_ERROR;
|
||||
}
|
||||
|
||||
internal = (lzma_index_parser_internal*)lzma_alloc(sizeof(lzma_index_parser_internal),
|
||||
info->allocator);
|
||||
|
||||
if (internal == NULL)
|
||||
return LZMA_MEM_ERROR;
|
||||
|
||||
internal->state = PARSE_INDEX_INITED;
|
||||
internal->pos = info->file_size;
|
||||
internal->combined_index = NULL;
|
||||
internal->this_index = NULL;
|
||||
info->internal = internal;
|
||||
|
||||
lzma_stream strm_ = LZMA_STREAM_INIT;
|
||||
memcpy(&internal->strm, &strm_, sizeof(lzma_stream));
|
||||
internal->strm.allocator = info->allocator;
|
||||
}
|
||||
|
||||
// The header flags of the current stream are only ever used within a
|
||||
// call and don't need to go into the internals struct.
|
||||
lzma_stream_flags header_flags;
|
||||
|
||||
int i;
|
||||
uint64_t memlimit;
|
||||
|
||||
switch (internal->state) {
|
||||
case PARSE_INDEX_INITED:
|
||||
if (info->file_size <= 0) {
|
||||
// These strings are fixed so they can be translated by the xz
|
||||
// command line utility.
|
||||
info->message = "File is empty";
|
||||
return LZMA_DATA_ERROR;
|
||||
}
|
||||
|
||||
if (info->file_size < 2 * LZMA_STREAM_HEADER_SIZE) {
|
||||
info->message = "Too small to be a valid .xz file";
|
||||
return LZMA_DATA_ERROR;
|
||||
}
|
||||
|
||||
// Each loop iteration decodes one Index.
|
||||
do {
|
||||
// Check that there is enough data left to contain at least
|
||||
// the Stream Header and Stream Footer. This check cannot
|
||||
// fail in the first pass of this loop.
|
||||
if (internal->pos < 2 * LZMA_STREAM_HEADER_SIZE) {
|
||||
ret = LZMA_DATA_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
internal->pos -= LZMA_STREAM_HEADER_SIZE;
|
||||
internal->stream_padding = 0;
|
||||
|
||||
// Locate the Stream Footer. There may be Stream Padding which
|
||||
// we must skip when reading backwards.
|
||||
while (true) {
|
||||
if (internal->pos < LZMA_STREAM_HEADER_SIZE) {
|
||||
ret = LZMA_DATA_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = parse_indexes_read(info,
|
||||
internal->buf,
|
||||
LZMA_STREAM_HEADER_SIZE,
|
||||
internal->pos);
|
||||
|
||||
if (ret != LZMA_OK)
|
||||
goto error;
|
||||
internal->state = PARSE_INDEX_READ_FOOTER;
|
||||
if (info->async) return LZMA_OK;
|
||||
case PARSE_INDEX_READ_FOOTER:
|
||||
|
||||
// Stream Padding is always a multiple of four bytes.
|
||||
i = 2;
|
||||
if (((uint32_t *)internal->buf)[i] != 0)
|
||||
break;
|
||||
|
||||
// To avoid calling the read callback for every four
|
||||
// bytes of Stream Padding, take advantage that we
|
||||
// read 12 bytes (LZMA_STREAM_HEADER_SIZE) already
|
||||
// and check them too before calling the read
|
||||
// callback again.
|
||||
do {
|
||||
internal->stream_padding += 4;
|
||||
internal->pos -= 4;
|
||||
--i;
|
||||
} while (i >= 0 && ((uint32_t *)internal->buf)[i] == 0);
|
||||
}
|
||||
|
||||
// Decode the Stream Footer.
|
||||
ret = lzma_stream_footer_decode(&internal->footer_flags,
|
||||
internal->buf);
|
||||
if (ret != LZMA_OK) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Check that the Stream Footer doesn't specify something
|
||||
// that we don't support. This can only happen if the xz
|
||||
// version is older than liblzma and liblzma supports
|
||||
// something new.
|
||||
//
|
||||
// It is enough to check Stream Footer. Stream Header must
|
||||
// match when it is compared against Stream Footer with
|
||||
// lzma_stream_flags_compare().
|
||||
if (internal->footer_flags.version != 0) {
|
||||
ret = LZMA_OPTIONS_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Check that the size of the Index field looks sane.
|
||||
internal->index_size = internal->footer_flags.backward_size;
|
||||
if ((lzma_vli)(internal->pos) <
|
||||
internal->index_size +
|
||||
LZMA_STREAM_HEADER_SIZE) {
|
||||
ret = LZMA_DATA_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Set pos to the beginning of the Index.
|
||||
internal->pos -= internal->index_size;
|
||||
|
||||
// See how much memory we can use for decoding this Index.
|
||||
memlimit = info->memlimit;
|
||||
internal->memused = sizeof(lzma_index_parser_internal);
|
||||
if (internal->combined_index != NULL) {
|
||||
internal->memused = lzma_index_memused(
|
||||
internal->combined_index);
|
||||
assert(internal->memused <= memlimit);
|
||||
|
||||
memlimit -= internal->memused;
|
||||
}
|
||||
|
||||
// Decode the Index.
|
||||
ret = lzma_index_decoder(&internal->strm,
|
||||
&internal->this_index,
|
||||
memlimit);
|
||||
if (ret != LZMA_OK) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
do {
|
||||
// Don't give the decoder more input than the
|
||||
// Index size.
|
||||
internal->strm.avail_in = my_min(sizeof(internal->buf),
|
||||
internal->index_size);
|
||||
|
||||
ret = parse_indexes_read(info,
|
||||
internal->buf,
|
||||
internal->strm.avail_in,
|
||||
internal->pos);
|
||||
|
||||
if (ret != LZMA_OK)
|
||||
goto error;
|
||||
internal->state = PARSE_INDEX_READ_INDEX;
|
||||
if (info->async) return LZMA_OK;
|
||||
case PARSE_INDEX_READ_INDEX:
|
||||
|
||||
internal->pos += internal->strm.avail_in;
|
||||
internal->index_size -= internal->strm.avail_in;
|
||||
|
||||
internal->strm.next_in = internal->buf;
|
||||
ret = lzma_code(&internal->strm, LZMA_RUN);
|
||||
|
||||
} while (ret == LZMA_OK);
|
||||
|
||||
// If the decoding seems to be successful, check also that
|
||||
// the Index decoder consumed as much input as indicated
|
||||
// by the Backward Size field.
|
||||
if (ret == LZMA_STREAM_END && (
|
||||
internal->index_size != 0 ||
|
||||
internal->strm.avail_in != 0)) {
|
||||
ret = LZMA_DATA_ERROR;
|
||||
}
|
||||
|
||||
if (ret != LZMA_STREAM_END) {
|
||||
// LZMA_BUFFER_ERROR means that the Index decoder
|
||||
// would have liked more input than what the Index
|
||||
// size should be according to Stream Footer.
|
||||
// The message for LZMA_DATA_ERROR makes more
|
||||
// sense in that case.
|
||||
if (ret == LZMA_BUF_ERROR)
|
||||
ret = LZMA_DATA_ERROR;
|
||||
|
||||
// If the error was too low memory usage limit,
|
||||
// indicate also how much memory would have been needed.
|
||||
if (ret == LZMA_MEMLIMIT_ERROR) {
|
||||
uint64_t needed = lzma_memusage(
|
||||
&internal->strm);
|
||||
if (UINT64_MAX - needed < internal->memused)
|
||||
needed = UINT64_MAX;
|
||||
else
|
||||
needed += internal->memused;
|
||||
|
||||
info->memlimit = needed;
|
||||
}
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Decode the Stream Header and check that its Stream Flags
|
||||
// match the Stream Footer.
|
||||
internal->pos -= internal->footer_flags.backward_size;
|
||||
internal->pos -= LZMA_STREAM_HEADER_SIZE;
|
||||
if ((lzma_vli)(internal->pos) <
|
||||
lzma_index_total_size(internal->this_index)) {
|
||||
ret = LZMA_DATA_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
internal->pos -= lzma_index_total_size(internal->this_index);
|
||||
|
||||
ret = parse_indexes_read(info,
|
||||
internal->buf,
|
||||
LZMA_STREAM_HEADER_SIZE,
|
||||
internal->pos);
|
||||
|
||||
if (ret != LZMA_OK)
|
||||
goto error;
|
||||
|
||||
internal->state = PARSE_INDEX_READ_STREAM_HEADER;
|
||||
if (info->async) return LZMA_OK;
|
||||
case PARSE_INDEX_READ_STREAM_HEADER:
|
||||
|
||||
ret = lzma_stream_header_decode(&header_flags, internal->buf);
|
||||
if (ret != LZMA_OK) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = lzma_stream_flags_compare(&header_flags,
|
||||
&internal->footer_flags);
|
||||
if (ret != LZMA_OK) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
// Store the decoded Stream Flags into this_index. This is
|
||||
// needed so that we can print which Check is used in each
|
||||
// Stream.
|
||||
ret = lzma_index_stream_flags(internal->this_index,
|
||||
&internal->footer_flags);
|
||||
assert(ret == LZMA_OK);
|
||||
|
||||
// Store also the size of the Stream Padding field. It is
|
||||
// needed to show the offsets of the Streams correctly.
|
||||
ret = lzma_index_stream_padding(internal->this_index,
|
||||
internal->stream_padding);
|
||||
assert(ret == LZMA_OK);
|
||||
|
||||
if (internal->combined_index != NULL) {
|
||||
// Append the earlier decoded Indexes
|
||||
// after this_index.
|
||||
ret = lzma_index_cat(
|
||||
internal->this_index,
|
||||
internal->combined_index,
|
||||
info->allocator);
|
||||
if (ret != LZMA_OK) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
internal->combined_index = internal->this_index;
|
||||
internal->this_index = NULL;
|
||||
|
||||
info->stream_padding += internal->stream_padding;
|
||||
|
||||
} while (internal->pos > 0);
|
||||
|
||||
lzma_end(&internal->strm);
|
||||
|
||||
// All OK. Make combined_index available to the caller.
|
||||
info->index = internal->combined_index;
|
||||
|
||||
lzma_free(internal, info->allocator);
|
||||
info->internal = NULL;
|
||||
return LZMA_STREAM_END;
|
||||
} // end switch(internal->state)
|
||||
|
||||
error:
|
||||
// Something went wrong, free the allocated memory.
|
||||
if (internal) {
|
||||
lzma_end(&internal->strm);
|
||||
lzma_index_end(internal->combined_index, info->allocator);
|
||||
lzma_index_end(internal->this_index, info->allocator);
|
||||
lzma_free(internal, info->allocator);
|
||||
}
|
||||
|
||||
info->internal = NULL;
|
||||
|
||||
// Doing this will prevent people from calling lzma_parse_indexes_from_file()
|
||||
// again without re-initializing.
|
||||
info->file_size = SIZE_MAX;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "liblzma-node.hpp"
|
||||
|
||||
namespace lzma {
|
||||
|
||||
void IndexParser::InitializeExports(Object exports) {
|
||||
exports["IndexParser"] = DefineClass(exports.Env(), "IndexParser", {
|
||||
InstanceMethod("init", &IndexParser::Init),
|
||||
InstanceMethod("feed", &IndexParser::Feed),
|
||||
InstanceMethod("parse", &IndexParser::Parse),
|
||||
});
|
||||
}
|
||||
|
||||
namespace {
|
||||
extern "C" int64_t LZMA_API_CALL
|
||||
read_cb(void* opaque, uint8_t* buf, size_t count, int64_t offset) {
|
||||
IndexParser* p = static_cast<IndexParser*>(opaque);
|
||||
return p->readCallback(opaque, buf, count, offset);
|
||||
}
|
||||
|
||||
extern "C" void* LZMA_API_CALL
|
||||
alloc_for_lzma_index(void *opaque, size_t nmemb, size_t size) {
|
||||
IndexParser* p = static_cast<IndexParser*>(opaque);
|
||||
size_t nBytes = nmemb * size + sizeof(size_t);
|
||||
|
||||
size_t* result = static_cast<size_t*>(::malloc(nBytes));
|
||||
if (!result)
|
||||
return result;
|
||||
|
||||
*result = nBytes;
|
||||
MemoryManagement::AdjustExternalMemory(p->Env(), static_cast<int64_t>(nBytes));
|
||||
return static_cast<void*>(result + 1);
|
||||
}
|
||||
|
||||
extern "C" void LZMA_API_CALL
|
||||
free_for_lzma_index(void *opaque, void *ptr) {
|
||||
IndexParser* p = static_cast<IndexParser*>(opaque);
|
||||
if (!ptr)
|
||||
return;
|
||||
|
||||
size_t* orig = static_cast<size_t*>(ptr) - 1;
|
||||
|
||||
MemoryManagement::AdjustExternalMemory(p->Env(), -static_cast<int64_t>(*orig));
|
||||
return ::free(static_cast<void*>(orig));
|
||||
}
|
||||
}
|
||||
|
||||
int64_t IndexParser::readCallback(void* opaque, uint8_t* buf, size_t count, int64_t offset) {
|
||||
currentReadBuffer = buf;
|
||||
currentReadSize = count;
|
||||
|
||||
napi_value argv[2] = {
|
||||
Uint64ToNumberMaxNull(Env(), count),
|
||||
Uint64ToNumberMaxNull(Env(), offset)
|
||||
};
|
||||
|
||||
Function read_cb = Napi::Value(Value()["read_cb"]).As<Function>();
|
||||
Napi::Value ret = read_cb.Call(Value(), 2, argv);
|
||||
|
||||
if (currentReadBuffer) {
|
||||
info.async = true;
|
||||
return count;
|
||||
} else {
|
||||
// .feed() has been alreay been called synchronously
|
||||
info.async = false;
|
||||
return NumberToUint64ClampNullMax(ret);
|
||||
}
|
||||
}
|
||||
|
||||
IndexParser::IndexParser(const CallbackInfo& args)
|
||||
: ObjectWrap(args),
|
||||
isCurrentlyInParseCall(false) {
|
||||
lzma_index_parser_data info_ = LZMA_INDEX_PARSER_DATA_INIT;
|
||||
info = info_;
|
||||
|
||||
allocator.alloc = alloc_for_lzma_index;
|
||||
allocator.free = free_for_lzma_index;
|
||||
allocator.opaque = static_cast<void*>(this);
|
||||
|
||||
info.read_callback = read_cb;
|
||||
info.opaque = static_cast<void*>(this);
|
||||
info.allocator = &allocator;
|
||||
}
|
||||
|
||||
void IndexParser::Init(const CallbackInfo& args) {
|
||||
info.file_size = NumberToUint64ClampNullMax(args[0]);
|
||||
info.memlimit = NumberToUint64ClampNullMax(args[1]);
|
||||
}
|
||||
|
||||
Object IndexParser::getObject() const {
|
||||
Napi::Env env = Env();
|
||||
Object obj = Object::New(env);
|
||||
|
||||
obj["streamPadding"] = Uint64ToNumberMaxNull(env, info.stream_padding);
|
||||
obj["memlimit"] = Uint64ToNumberMaxNull(env, info.memlimit);
|
||||
obj["streams"] = Uint64ToNumberMaxNull(env, lzma_index_stream_count(info.index));
|
||||
obj["blocks"] = Uint64ToNumberMaxNull(env, lzma_index_block_count(info.index));
|
||||
obj["fileSize"] = Uint64ToNumberMaxNull(env, lzma_index_file_size(info.index));
|
||||
obj["uncompressedSize"] = Uint64ToNumberMaxNull(env, lzma_index_uncompressed_size(info.index));
|
||||
obj["checks"] = Uint64ToNumberMaxNull(env, lzma_index_checks(info.index));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
Value IndexParser::Parse(const CallbackInfo& args) {
|
||||
if (isCurrentlyInParseCall)
|
||||
throw Error::New(Env(), "Cannot call IndexParser::Parse recursively");
|
||||
|
||||
struct RecursionGuard {
|
||||
explicit RecursionGuard(IndexParser* p) : p(p) {
|
||||
p->isCurrentlyInParseCall = true;
|
||||
}
|
||||
~RecursionGuard() {
|
||||
p->isCurrentlyInParseCall = false;
|
||||
}
|
||||
IndexParser* p;
|
||||
};
|
||||
|
||||
lzma_ret ret;
|
||||
{
|
||||
RecursionGuard guard(this);
|
||||
ret = my_lzma_parse_indexes_from_file(&info);
|
||||
}
|
||||
|
||||
if (ret == LZMA_OK) {
|
||||
return Boolean::New(Env(), true);
|
||||
} else if (ret == LZMA_STREAM_END) {
|
||||
return getObject();
|
||||
}
|
||||
|
||||
Error error = lzmaRetError(Env(), ret);
|
||||
if (info.message) {
|
||||
error.Value()["message"] = String::New(Env(), info.message);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
Value IndexParser::Feed(const CallbackInfo& info) {
|
||||
Napi::Value value_v = info[0];
|
||||
if (!value_v.IsTypedArray())
|
||||
throw TypeError::New(Env(), "Expected Buffer as input");
|
||||
TypedArray value = value_v.As<TypedArray>();
|
||||
|
||||
if (currentReadBuffer == nullptr)
|
||||
throw Error::New(Env(), "No input data was expected");
|
||||
size_t length = value.ByteLength();
|
||||
|
||||
if (length > currentReadSize)
|
||||
length = currentReadSize;
|
||||
|
||||
memcpy(currentReadBuffer,
|
||||
static_cast<const uint8_t*>(value.ArrayBuffer().Data()) + value.ByteOffset(),
|
||||
length);
|
||||
currentReadBuffer = nullptr;
|
||||
|
||||
return Uint64ToNumberMaxNull(Env(), length);
|
||||
}
|
||||
|
||||
IndexParser::~IndexParser() {
|
||||
assert(!isCurrentlyInParseCall);
|
||||
info.file_size = SIZE_MAX;
|
||||
lzma_index_end(info.index, &allocator);
|
||||
info.index = nullptr;
|
||||
info.read_callback = nullptr;
|
||||
lzma_ret ret = my_lzma_parse_indexes_from_file(&info);
|
||||
assert(ret == LZMA_OPTIONS_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
208
electron/node_modules/lzma-native/src/index-parser.h
generated
vendored
Normal file
208
electron/node_modules/lzma-native/src/index-parser.h
generated
vendored
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
// The contents from this file are from a proposed API that is not yet
|
||||
// implemented in upstream liblzma.
|
||||
|
||||
#ifndef INDEX_PARSER_H
|
||||
#define INDEX_PARSER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <lzma.h>
|
||||
|
||||
namespace lzma {
|
||||
|
||||
/**
|
||||
* \brief Internal data structure
|
||||
*
|
||||
* The contents of this structure is not visible outside the library.
|
||||
*/
|
||||
typedef struct lzma_index_parser_internal_s lzma_index_parser_internal;
|
||||
|
||||
/**
|
||||
* \brief Reading the indexes of an .xz file
|
||||
*
|
||||
* The lzma_index_parser_data data structure is passed to
|
||||
* lzma_parse_indexes_from_file(), which can be used to retrieve the index
|
||||
* information for a given .xz file.
|
||||
*
|
||||
* It should be initialized with LZMA_INDEX_PARSER_DATA_INIT,
|
||||
* and, minimally, the file_size and read_callback() members need to be set.
|
||||
*
|
||||
* The allocation of internals happens transparently upon usage and does not
|
||||
* need to be taken care of.
|
||||
* In the case of an error, lzma_parse_indexes_from_file() performs all
|
||||
* necessary cleanup.
|
||||
* In the case of success, the index member will be set and needs to be
|
||||
* freed using lzma_index_end after the caller is done with it. If a custom
|
||||
* allocator was set on this struct, it needs to be used for freeing the
|
||||
* resulting index, too.
|
||||
*
|
||||
* Reading the data from the underlying file may happen synchronously or
|
||||
* asynchronously, see the description of the read_callback().
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* \brief Combined Index of all Streams in the file
|
||||
*
|
||||
* This will be set to an lzma_index * when parsing the file was
|
||||
* successful, as indicated by a LZMA_STREAM_END return status.
|
||||
*/
|
||||
lzma_index *index;
|
||||
|
||||
/**
|
||||
* \brief Total amount of Stream Padding
|
||||
*
|
||||
* This will be set when the file was successfully read.
|
||||
*/
|
||||
size_t stream_padding;
|
||||
|
||||
/**
|
||||
* \brief Callback for reading data from the input file
|
||||
*
|
||||
* This member needs to be set to a function that provides a slice of
|
||||
* the input file.
|
||||
*
|
||||
* The opaque pointer will have the same value as the opaque pointer
|
||||
* set on this struct.
|
||||
*
|
||||
* When being invoked, it should read count bytes from the underlying
|
||||
* file, starting at the specified offset, into buf.
|
||||
* The return value may be -1, in which case
|
||||
* lzma_parse_indexes_from_file() will return with LZMA_DATA_ERROR.
|
||||
* Otherwise, the number of read bytes should be returned. If this is
|
||||
* not the number of requested bytes, it will be assumed that the file
|
||||
* was truncated, and lzma_parse_indexes_from_file() will fail with
|
||||
* LZMA_DATA_ERROR.
|
||||
*
|
||||
* It is possible to perform the underlying I/O operations in an
|
||||
* asynchronous manner. To do so, set the async flag on this struct
|
||||
* to true. After read_callback() is invoked,
|
||||
* lzma_parse_indexes_from_file() will return immediately with
|
||||
* LZMA_OK (unless the read_callback() return value indicates failure),
|
||||
* and you are expected to call lzma_parse_indexes_from_file() with
|
||||
* the same struct as soon as the buffer has been filled.
|
||||
*
|
||||
* If asynchronous reading is used and the underlying read operation
|
||||
* fails, you should set file_size to SIZE_MAX and call
|
||||
* lzma_parse_indexes_from_file() to trigger an error clean up all
|
||||
* remaining internal state.
|
||||
*
|
||||
* You should not perform any operations on this structure until
|
||||
* the data has been read in any case.
|
||||
*
|
||||
* This function is modelled after pread(2), which is a available on
|
||||
* some platforms and can be easily wrapped to be used here.
|
||||
*/
|
||||
int64_t (LZMA_API_CALL *read_callback)(void *opaque,
|
||||
uint8_t *buf,
|
||||
size_t count,
|
||||
int64_t offset);
|
||||
|
||||
/// Opaque pointer that is passed to read_callback.
|
||||
void *opaque;
|
||||
|
||||
/// Whether to return after calling read_callback and wait for
|
||||
/// another call. Defaults to synchronous operations.
|
||||
lzma_bool async;
|
||||
|
||||
/** \brief Callback for reading data from the input file
|
||||
*
|
||||
* This needs to be set to the size of the input file before all
|
||||
* other operations. If this is set to SIZE_MAX, the parser will
|
||||
* fail with LZMA_OPTIONS_ERROR. This can be used to clean up
|
||||
* after a failed asynchronous read_callback().
|
||||
*
|
||||
* On error, this will be set to SIZE_MAX.
|
||||
*/
|
||||
size_t file_size;
|
||||
|
||||
/** \brief Memory limit for decoding the indexes.
|
||||
*
|
||||
* Set a memory limit for decoding. Default to UINT64_MAX for no limit.
|
||||
* If this is set too low to allocate the internal data structure
|
||||
* that is minimally required for parsing, this will be set to 0.
|
||||
* If this is set too low to parse the underlying .xz file,
|
||||
* this will be set to the amount of memory that would have
|
||||
* been necessary for parsing the file.
|
||||
*/
|
||||
uint64_t memlimit;
|
||||
|
||||
/// Message that may be set when additional information is available
|
||||
/// on error.
|
||||
const char *message;
|
||||
|
||||
/**
|
||||
* \brief Custom memory allocation functions
|
||||
*
|
||||
* In most cases this is NULL which makes liblzma use
|
||||
* the standard malloc() and free().
|
||||
*/
|
||||
const lzma_allocator *allocator;
|
||||
|
||||
/**
|
||||
* \brief Data which is internal to the index parser.
|
||||
*
|
||||
* Do not touch. You can check whether this is NULL to see if this
|
||||
* structure currently holds external resources, not counting the
|
||||
* possible index member that is set on success.
|
||||
*/
|
||||
lzma_index_parser_internal* internal;
|
||||
|
||||
/*
|
||||
* Reserved space to allow possible future extensions without
|
||||
* breaking the ABI. Excluding the initialization of this structure,
|
||||
* you should not touch these, because the names of these variables
|
||||
* may change.
|
||||
*/
|
||||
void *reserved_ptr1;
|
||||
void *reserved_ptr2;
|
||||
void *reserved_ptr3;
|
||||
void *reserved_ptr4;
|
||||
uint64_t reserved_int1;
|
||||
uint64_t reserved_int2;
|
||||
size_t reserved_int3;
|
||||
size_t reserved_int4;
|
||||
lzma_reserved_enum reserved_enum1;
|
||||
lzma_reserved_enum reserved_enum2;
|
||||
} lzma_index_parser_data;
|
||||
|
||||
/**
|
||||
* \brief Initialization for lzma_index_parser_data
|
||||
*
|
||||
* When you declare an instance of lzma_index_parser_data, you should
|
||||
* immediately initialize it to this value:
|
||||
*
|
||||
* lzma_index_parser_data strm = LZMA_INDEX_PARSER_DATA_INIT;
|
||||
*
|
||||
* Anything which applies for LZMA_STREAM_INIT applies here, too.
|
||||
*/
|
||||
#define LZMA_INDEX_PARSER_DATA_INIT \
|
||||
{ NULL, 0, NULL, NULL, 0, 0, 0, NULL, NULL, NULL, \
|
||||
NULL, NULL, NULL, NULL, 0, 0, 0, 0, \
|
||||
LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM }
|
||||
|
||||
/** \brief Parse the Index(es) from the given .xz file
|
||||
*
|
||||
* Read metadata from the underlying file.
|
||||
* The info pointer should refer to a lzma_index_parser_data struct that
|
||||
* has been initialized using LZMA_INDEX_PARSER_DATA_INIT.
|
||||
*
|
||||
* This will call info->read_callback() multiple times to read parts of the
|
||||
* underlying .xz file and, upon success, fill info->index with an
|
||||
* lzma_index pointer that contains metadata for the whole file, accumulated
|
||||
* across multiple streams.
|
||||
*
|
||||
* \param info Pointer to a lzma_index_parser_data structure.
|
||||
*
|
||||
* \return On success, LZMA_STREAM_END is returned.
|
||||
* On error, another value is returned, and info->message may
|
||||
* be set to provide additional information.
|
||||
* If info->async is set, LZMA_OK may be returned to indicate
|
||||
* that another call to lzma_parse_indexes_from_file() should be
|
||||
* performed after the data has been read.
|
||||
*/
|
||||
extern lzma_ret
|
||||
my_lzma_parse_indexes_from_file(lzma_index_parser_data *info);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
84
electron/node_modules/lzma-native/src/liblzma-functions.cpp
generated
vendored
Normal file
84
electron/node_modules/lzma-native/src/liblzma-functions.cpp
generated
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
#include "liblzma-node.hpp"
|
||||
|
||||
namespace lzma {
|
||||
|
||||
Value lzmaVersionNumber(const CallbackInfo& info) {
|
||||
return Number::New(info.Env(), lzma_version_number());
|
||||
}
|
||||
|
||||
Value lzmaVersionString(const CallbackInfo& info) {
|
||||
return String::New(info.Env(), lzma_version_string());
|
||||
}
|
||||
|
||||
Value lzmaCheckIsSupported(const CallbackInfo& info) {
|
||||
lzma_check arg = (lzma_check) info[0].ToNumber().Int64Value();
|
||||
|
||||
return Boolean::New(info.Env(), lzma_check_is_supported(arg));
|
||||
}
|
||||
|
||||
Value lzmaCheckSize(const CallbackInfo& info) {
|
||||
lzma_check arg = (lzma_check) info[0].ToNumber().Int64Value();
|
||||
|
||||
return Number::New(info.Env(), lzma_check_size(arg));
|
||||
}
|
||||
|
||||
Value lzmaFilterEncoderIsSupported(const CallbackInfo& info) {
|
||||
uint64_t arg = FilterByName(info[0]);
|
||||
|
||||
return Boolean::New(info.Env(), lzma_filter_encoder_is_supported(arg));
|
||||
}
|
||||
|
||||
Value lzmaFilterDecoderIsSupported(const CallbackInfo& info) {
|
||||
uint64_t arg = FilterByName(info[0]);
|
||||
|
||||
return Boolean::New(info.Env(), lzma_filter_decoder_is_supported(arg));
|
||||
}
|
||||
|
||||
Value lzmaMfIsSupported(const CallbackInfo& info) {
|
||||
lzma_match_finder arg = (lzma_match_finder) info[0].ToNumber().Int64Value();
|
||||
|
||||
return Boolean::New(info.Env(), lzma_mf_is_supported(arg));
|
||||
}
|
||||
|
||||
Value lzmaModeIsSupported(const CallbackInfo& info) {
|
||||
lzma_mode arg = (lzma_mode) info[0].ToNumber().Int64Value();
|
||||
|
||||
return Boolean::New(info.Env(), lzma_mode_is_supported(arg));
|
||||
}
|
||||
|
||||
Value lzmaEasyEncoderMemusage(const CallbackInfo& info) {
|
||||
int64_t arg = info[0].ToNumber();
|
||||
|
||||
return Uint64ToNumberMaxNull(info.Env(), lzma_easy_encoder_memusage(arg));
|
||||
}
|
||||
|
||||
Value lzmaEasyDecoderMemusage(const CallbackInfo& info) {
|
||||
int64_t arg = info[0].ToNumber();
|
||||
|
||||
return Uint64ToNumberMaxNull(info.Env(), lzma_easy_decoder_memusage(arg));
|
||||
}
|
||||
|
||||
Value lzmaCRC32(const CallbackInfo& info) {
|
||||
int64_t arg = info[1].ToNumber();
|
||||
|
||||
std::vector<uint8_t> data;
|
||||
|
||||
if (!readBufferFromObj(info[0], &data))
|
||||
throw TypeError::New(info.Env(), "CRC32 expects Buffer as input");
|
||||
|
||||
return Number::New(info.Env(), lzma_crc32(data.data(), data.size(), arg));
|
||||
}
|
||||
|
||||
Value lzmaRawEncoderMemusage(const CallbackInfo& info) {
|
||||
const FilterArray filters(info[0]);
|
||||
|
||||
return Uint64ToNumberMaxNull(info.Env(), lzma_raw_encoder_memusage(filters.array()));
|
||||
}
|
||||
|
||||
Value lzmaRawDecoderMemusage(const CallbackInfo& info) {
|
||||
const FilterArray filters(info[0]);
|
||||
|
||||
return Uint64ToNumberMaxNull(info.Env(), lzma_raw_decoder_memusage(filters.array()));
|
||||
}
|
||||
|
||||
}
|
||||
258
electron/node_modules/lzma-native/src/liblzma-node.hpp
generated
vendored
Normal file
258
electron/node_modules/lzma-native/src/liblzma-node.hpp
generated
vendored
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
#ifndef BUILDING_NODE_EXTENSION
|
||||
#define BUILDING_NODE_EXTENSION
|
||||
#endif
|
||||
|
||||
#ifndef LIBLZMA_NODE_HPP
|
||||
#define LIBLZMA_NODE_HPP
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
#include <lzma.h>
|
||||
#include "index-parser.h"
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
||||
namespace lzma {
|
||||
using namespace Napi;
|
||||
|
||||
/* util */
|
||||
/**
|
||||
* Return the filter constant associated with a v8 String handle
|
||||
*/
|
||||
lzma_vli FilterByName(Value name);
|
||||
|
||||
/**
|
||||
* If rv represents an error, throw a javascript exception representing it.
|
||||
* Always returns rv as a v8 Integer.
|
||||
*/
|
||||
Number lzmaRet(Env env, lzma_ret rv);
|
||||
|
||||
/**
|
||||
* Return a javascript exception representing rv.
|
||||
*/
|
||||
Error lzmaRetError(Env env, lzma_ret rv);
|
||||
|
||||
/**
|
||||
* Takes a Node.js SlowBuffer or Buffer as input and populates data accordingly.
|
||||
* Returns true on success, false on failure.
|
||||
*/
|
||||
bool readBufferFromObj(Value value, std::vector<uint8_t>* data);
|
||||
|
||||
/**
|
||||
* Return a lzma_options_lzma struct as described by the v8 Object obj.
|
||||
*/
|
||||
lzma_options_lzma parseOptionsLZMA(Value obj);
|
||||
|
||||
/**
|
||||
* Return a v8 Number representation of an uint64_t where UINT64_MAX will be mapped to null
|
||||
*/
|
||||
Value Uint64ToNumberMaxNull(Env env, uint64_t in);
|
||||
|
||||
/**
|
||||
* Return a v8 Number representation of an uint64_t where 0 will be mapped to null
|
||||
*/
|
||||
Value Uint64ToNumber0Null(Env env, uint64_t in);
|
||||
|
||||
/**
|
||||
* Return a uint64_t representation of a v8 Number,
|
||||
* where values above UINT64_MAX map to UINT64_MAX and null to UINT64_MAX.
|
||||
* Throws an TypeError if the input is not a number.
|
||||
*/
|
||||
uint64_t NumberToUint64ClampNullMax(Value in);
|
||||
|
||||
/**
|
||||
* Return an integer property of an object (which can be passed to Nan::Get),
|
||||
* providing a default value if no such property is present
|
||||
*/
|
||||
inline int64_t GetIntegerProperty(Object obj, const char* name, int64_t def) {
|
||||
Value v = obj[name];
|
||||
|
||||
if (v.IsUndefined())
|
||||
return def;
|
||||
|
||||
return v.ToNumber().Int64Value();
|
||||
}
|
||||
|
||||
/* bindings in one-to-one correspondence to the lzma functions */
|
||||
Value lzmaVersionNumber(const CallbackInfo& info);
|
||||
Value lzmaVersionString(const CallbackInfo& info);
|
||||
Value lzmaCheckIsSupported(const CallbackInfo& info);
|
||||
Value lzmaCheckSize(const CallbackInfo& info);
|
||||
Value lzmaFilterEncoderIsSupported(const CallbackInfo& info);
|
||||
Value lzmaFilterDecoderIsSupported(const CallbackInfo& info);
|
||||
Value lzmaMfIsSupported(const CallbackInfo& info);
|
||||
Value lzmaModeIsSupported(const CallbackInfo& info);
|
||||
Value lzmaEasyEncoderMemusage(const CallbackInfo& info);
|
||||
Value lzmaEasyDecoderMemusage(const CallbackInfo& info);
|
||||
Value lzmaCRC32(const CallbackInfo& info);
|
||||
Value lzmaRawEncoderMemusage(const CallbackInfo& info);
|
||||
Value lzmaRawDecoderMemusage(const CallbackInfo& info);
|
||||
|
||||
/* wrappers */
|
||||
/**
|
||||
* List of liblzma filters with corresponding options
|
||||
*/
|
||||
class FilterArray {
|
||||
public:
|
||||
FilterArray() = default;
|
||||
explicit FilterArray(Value arr);
|
||||
|
||||
lzma_filter* array() { return filters.data(); }
|
||||
const lzma_filter* array() const { return filters.data(); }
|
||||
|
||||
private:
|
||||
FilterArray(const FilterArray&);
|
||||
FilterArray& operator=(const FilterArray&);
|
||||
|
||||
union options {
|
||||
lzma_options_delta delta;
|
||||
lzma_options_lzma lzma;
|
||||
};
|
||||
|
||||
std::vector<lzma_filter> filters;
|
||||
std::list<options> optbuf;
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper for lzma_mt (multi-threading options).
|
||||
*/
|
||||
class MTOptions {
|
||||
public:
|
||||
MTOptions() = default;
|
||||
explicit MTOptions(Value val);
|
||||
|
||||
lzma_mt* opts() { return &opts_; }
|
||||
const lzma_mt* opts() const { return &opts_; }
|
||||
|
||||
private:
|
||||
std::unique_ptr<FilterArray> filters_;
|
||||
lzma_mt opts_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Node.js object wrap for lzma_stream wrapper. Corresponds to exports.Stream
|
||||
*/
|
||||
class LZMAStream : public ObjectWrap<LZMAStream> {
|
||||
public:
|
||||
explicit LZMAStream(const CallbackInfo& info);
|
||||
~LZMAStream();
|
||||
static void InitializeExports(Object exports);
|
||||
|
||||
/* regard as private: */
|
||||
void doLZMACodeFromAsync();
|
||||
void invokeBufferHandlers(bool hasLock);
|
||||
void* alloc(size_t nmemb, size_t size);
|
||||
void free(void* ptr);
|
||||
|
||||
private:
|
||||
void resetUnderlying();
|
||||
void doLZMACode();
|
||||
|
||||
static Napi::Value New(const CallbackInfo& info);
|
||||
|
||||
void adjustExternalMemory(int64_t bytesChange);
|
||||
void reportAdjustedExternalMemoryToV8();
|
||||
|
||||
struct MemScope {
|
||||
explicit MemScope(LZMAStream* stream) : stream(stream) { }
|
||||
~MemScope() { stream->reportAdjustedExternalMemoryToV8(); }
|
||||
LZMAStream* stream;
|
||||
};
|
||||
|
||||
AsyncContext async_context;
|
||||
std::atomic<int64_t> nonAdjustedExternalMemory;
|
||||
std::mutex mutex;
|
||||
|
||||
void ResetUnderlying(const CallbackInfo& info);
|
||||
Napi::Value SetBufsize(const CallbackInfo& info);
|
||||
void Code(const CallbackInfo& info);
|
||||
Napi::Value Memusage(const CallbackInfo& info);
|
||||
Napi::Value MemlimitGet(const CallbackInfo& info);
|
||||
Napi::Value MemlimitSet(const CallbackInfo& info);
|
||||
Napi::Value RawEncoder(const CallbackInfo& info);
|
||||
Napi::Value RawDecoder(const CallbackInfo& info);
|
||||
Napi::Value FiltersUpdate(const CallbackInfo& info);
|
||||
Napi::Value EasyEncoder(const CallbackInfo& info);
|
||||
Napi::Value StreamEncoder(const CallbackInfo& info);
|
||||
Napi::Value AloneEncoder(const CallbackInfo& info);
|
||||
Napi::Value MTEncoder(const CallbackInfo& info);
|
||||
Napi::Value StreamDecoder(const CallbackInfo& info);
|
||||
Napi::Value AutoDecoder(const CallbackInfo& info);
|
||||
Napi::Value AloneDecoder(const CallbackInfo& info);
|
||||
|
||||
lzma_allocator allocator;
|
||||
lzma_stream _;
|
||||
size_t bufsize;
|
||||
std::string error;
|
||||
|
||||
bool shouldFinish;
|
||||
size_t processedChunks;
|
||||
lzma_ret lastCodeResult;
|
||||
std::queue<std::vector<uint8_t>> inbufs;
|
||||
std::queue<std::vector<uint8_t>> outbufs;
|
||||
};
|
||||
|
||||
/**
|
||||
* Async worker for a single coding step.
|
||||
*/
|
||||
class LZMAStreamCodingWorker : public AsyncWorker {
|
||||
public:
|
||||
LZMAStreamCodingWorker(LZMAStream* stream_)
|
||||
: AsyncWorker(Function(stream_->Env(), nullptr), "LZMAStreamCodingWorker"),
|
||||
stream(stream_) {
|
||||
Receiver().Set(static_cast<uint32_t>(0), stream->Value());
|
||||
}
|
||||
|
||||
~LZMAStreamCodingWorker() {}
|
||||
|
||||
void Execute() override {
|
||||
stream->doLZMACodeFromAsync();
|
||||
}
|
||||
|
||||
private:
|
||||
void OnOK() {
|
||||
stream->invokeBufferHandlers(false);
|
||||
}
|
||||
|
||||
void OnOK(const Error& e) {
|
||||
stream->invokeBufferHandlers(false);
|
||||
}
|
||||
|
||||
LZMAStream* stream;
|
||||
};
|
||||
|
||||
class IndexParser : public ObjectWrap<IndexParser> {
|
||||
public:
|
||||
explicit IndexParser(const CallbackInfo& info);
|
||||
~IndexParser();
|
||||
|
||||
static void InitializeExports(Object exports);
|
||||
|
||||
/* regard as private: */
|
||||
int64_t readCallback(void* opaque, uint8_t* buf, size_t count, int64_t offset);
|
||||
|
||||
private:
|
||||
lzma_index_parser_data info;
|
||||
lzma_allocator allocator;
|
||||
|
||||
uint8_t* currentReadBuffer;
|
||||
size_t currentReadSize;
|
||||
bool isCurrentlyInParseCall;
|
||||
|
||||
Object getObject() const;
|
||||
|
||||
void Init(const CallbackInfo& info);
|
||||
Napi::Value Feed(const CallbackInfo& info);
|
||||
Napi::Value Parse(const CallbackInfo& info);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
416
electron/node_modules/lzma-native/src/lzma-stream.cpp
generated
vendored
Normal file
416
electron/node_modules/lzma-native/src/lzma-stream.cpp
generated
vendored
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
#include "liblzma-node.hpp"
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <climits>
|
||||
|
||||
namespace lzma {
|
||||
|
||||
namespace {
|
||||
extern "C" void* LZMA_API_CALL
|
||||
alloc_for_lzma(void *opaque, size_t nmemb, size_t size) {
|
||||
LZMAStream* strm = static_cast<LZMAStream*>(opaque);
|
||||
|
||||
return strm->alloc(nmemb, size);
|
||||
}
|
||||
|
||||
extern "C" void LZMA_API_CALL
|
||||
free_for_lzma(void *opaque, void *ptr) {
|
||||
LZMAStream* strm = static_cast<LZMAStream*>(opaque);
|
||||
|
||||
return strm->free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
LZMAStream::LZMAStream(const CallbackInfo& info) :
|
||||
ObjectWrap(info),
|
||||
async_context(info.Env(), "LZMAStream"),
|
||||
bufsize(65536),
|
||||
shouldFinish(false),
|
||||
processedChunks(0),
|
||||
lastCodeResult(LZMA_OK)
|
||||
{
|
||||
std::memset(&_, 0, sizeof(lzma_stream));
|
||||
|
||||
allocator.alloc = alloc_for_lzma;
|
||||
allocator.free = free_for_lzma;
|
||||
allocator.opaque = static_cast<void*>(this);
|
||||
_.allocator = &allocator;
|
||||
|
||||
nonAdjustedExternalMemory = 0;
|
||||
MemoryManagement::AdjustExternalMemory(info.Env(), sizeof(LZMAStream));
|
||||
}
|
||||
|
||||
void LZMAStream::resetUnderlying() {
|
||||
if (_.internal != nullptr)
|
||||
lzma_end(&_);
|
||||
|
||||
reportAdjustedExternalMemoryToV8();
|
||||
std::memset(&_, 0, sizeof(lzma_stream));
|
||||
_.allocator = &allocator;
|
||||
lastCodeResult = LZMA_OK;
|
||||
processedChunks = 0;
|
||||
}
|
||||
|
||||
LZMAStream::~LZMAStream() {
|
||||
resetUnderlying();
|
||||
|
||||
MemoryManagement::AdjustExternalMemory(Env(), -int64_t(sizeof(LZMAStream)));
|
||||
}
|
||||
|
||||
void* LZMAStream::alloc(size_t nmemb, size_t size) {
|
||||
size_t nBytes = nmemb * size + sizeof(size_t);
|
||||
|
||||
size_t* result = static_cast<size_t*>(::malloc(nBytes));
|
||||
if (!result)
|
||||
return result;
|
||||
|
||||
*result = nBytes;
|
||||
adjustExternalMemory(static_cast<int64_t>(nBytes));
|
||||
return static_cast<void*>(result + 1);
|
||||
}
|
||||
|
||||
void LZMAStream::free(void* ptr) {
|
||||
if (!ptr)
|
||||
return;
|
||||
|
||||
size_t* orig = static_cast<size_t*>(ptr) - 1;
|
||||
|
||||
adjustExternalMemory(-static_cast<int64_t>(*orig));
|
||||
return ::free(static_cast<void*>(orig));
|
||||
}
|
||||
|
||||
void LZMAStream::reportAdjustedExternalMemoryToV8() {
|
||||
int64_t to_be_reported = nonAdjustedExternalMemory.exchange(0);
|
||||
if (to_be_reported == 0)
|
||||
return;
|
||||
|
||||
MemoryManagement::AdjustExternalMemory(Env(), nonAdjustedExternalMemory);
|
||||
}
|
||||
|
||||
void LZMAStream::adjustExternalMemory(int64_t bytesChange) {
|
||||
nonAdjustedExternalMemory += bytesChange;
|
||||
}
|
||||
|
||||
void LZMAStream::ResetUnderlying(const CallbackInfo& info) {
|
||||
MemScope mem_scope(this);
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
resetUnderlying();
|
||||
}
|
||||
|
||||
Value LZMAStream::SetBufsize(const CallbackInfo& info) {
|
||||
size_t oldBufsize, newBufsize = NumberToUint64ClampNullMax(info[0]);
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
oldBufsize = bufsize;
|
||||
|
||||
if (newBufsize && newBufsize != UINT_MAX)
|
||||
bufsize = newBufsize;
|
||||
}
|
||||
|
||||
return Number::New(Env(), oldBufsize);
|
||||
}
|
||||
|
||||
void LZMAStream::Code(const CallbackInfo& info) {
|
||||
MemScope mem_scope(this);
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
std::vector<uint8_t> inputData;
|
||||
|
||||
if (info[0].IsUndefined() || info[0].IsNull()) {
|
||||
shouldFinish = true;
|
||||
} else {
|
||||
if (!readBufferFromObj(info[0], &inputData))
|
||||
return;
|
||||
|
||||
if (inputData.empty())
|
||||
shouldFinish = true;
|
||||
}
|
||||
inbufs.push(std::move(inputData));
|
||||
|
||||
bool async = info[1].ToBoolean();
|
||||
|
||||
if (async) {
|
||||
(new LZMAStreamCodingWorker(this))->Queue();
|
||||
} else {
|
||||
doLZMACode();
|
||||
invokeBufferHandlers(true);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct Maybe {
|
||||
|
||||
};
|
||||
|
||||
void LZMAStream::invokeBufferHandlers(bool hasLock) {
|
||||
Napi::Env env = Env();
|
||||
HandleScope scope(env);
|
||||
MemScope mem_scope(this);
|
||||
|
||||
std::unique_lock<std::mutex> lock;
|
||||
if (!hasLock)
|
||||
lock = std::unique_lock<std::mutex>(mutex);
|
||||
|
||||
Function bufferHandler = Napi::Value(Value()["bufferHandler"]).As<Function>();
|
||||
std::vector<uint8_t> outbuf;
|
||||
|
||||
auto CallBufferHandlerWithArgv = [&](size_t argc, const napi_value* argv) {
|
||||
if (!hasLock) lock.unlock();
|
||||
bufferHandler.MakeCallback(Value(), 5, argv, async_context);
|
||||
if (!hasLock) lock.lock();
|
||||
};
|
||||
|
||||
uint64_t in = UINT64_MAX, out = UINT64_MAX;
|
||||
if (_.internal)
|
||||
lzma_get_progress(&_, &in, &out);
|
||||
Napi::Value in_ = Uint64ToNumberMaxNull(env, in);
|
||||
Napi::Value out_ = Uint64ToNumberMaxNull(env, out);
|
||||
|
||||
while (outbufs.size() > 0) {
|
||||
outbuf = std::move(outbufs.front());
|
||||
outbufs.pop();
|
||||
|
||||
napi_value argv[5] = {
|
||||
Buffer<char>::Copy(env, reinterpret_cast<const char*>(outbuf.data()), outbuf.size()),
|
||||
env.Undefined(), env.Undefined(), in_, out_
|
||||
};
|
||||
CallBufferHandlerWithArgv(5, argv);
|
||||
}
|
||||
|
||||
bool reset = false;
|
||||
if (lastCodeResult != LZMA_OK) {
|
||||
Napi::Value errorArg = env.Null();
|
||||
|
||||
if (lastCodeResult != LZMA_STREAM_END)
|
||||
errorArg = lzmaRetError(env, lastCodeResult).Value();
|
||||
|
||||
reset = true;
|
||||
|
||||
napi_value argv[5] = { env.Null(), env.Undefined(), errorArg, in_, out_ };
|
||||
CallBufferHandlerWithArgv(5, argv);
|
||||
}
|
||||
|
||||
if (processedChunks) {
|
||||
size_t pc = processedChunks;
|
||||
processedChunks = 0;
|
||||
|
||||
napi_value argv[5] = {
|
||||
env.Undefined(), Number::New(env, static_cast<uint32_t>(pc)),
|
||||
env.Undefined(), in_, out_
|
||||
};
|
||||
CallBufferHandlerWithArgv(5, argv);
|
||||
}
|
||||
|
||||
if (reset)
|
||||
resetUnderlying(); // resets lastCodeResult!
|
||||
}
|
||||
|
||||
void LZMAStream::doLZMACodeFromAsync() {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
doLZMACode();
|
||||
}
|
||||
|
||||
void LZMAStream::doLZMACode() {
|
||||
std::vector<uint8_t> outbuf(bufsize), inbuf;
|
||||
_.next_out = outbuf.data();
|
||||
_.avail_out = outbuf.size();
|
||||
_.avail_in = 0;
|
||||
|
||||
lzma_action action = LZMA_RUN;
|
||||
|
||||
size_t readChunks = 0;
|
||||
|
||||
// _.internal is set to nullptr when lzma_end() is called via resetUnderlying()
|
||||
while (_.internal) {
|
||||
if (_.avail_in == 0) { // more input neccessary?
|
||||
while (_.avail_in == 0 && !inbufs.empty()) {
|
||||
inbuf = std::move(inbufs.front());
|
||||
inbufs.pop();
|
||||
readChunks++;
|
||||
|
||||
_.next_in = inbuf.data();
|
||||
_.avail_in = inbuf.size();
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldFinish && inbufs.empty())
|
||||
action = LZMA_FINISH;
|
||||
|
||||
_.next_out = outbuf.data();
|
||||
_.avail_out = outbuf.size();
|
||||
|
||||
lastCodeResult = lzma_code(&_, action);
|
||||
|
||||
if (lastCodeResult != LZMA_OK && lastCodeResult != LZMA_STREAM_END) {
|
||||
processedChunks += readChunks;
|
||||
readChunks = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (_.avail_out == 0 || _.avail_in == 0 || lastCodeResult == LZMA_STREAM_END) {
|
||||
size_t outsz = outbuf.size() - _.avail_out;
|
||||
|
||||
if (outsz > 0) {
|
||||
#ifndef LZMA_NO_CXX11_RVALUE_REFERENCES // C++11
|
||||
outbufs.emplace(outbuf.data(), outbuf.data() + outsz);
|
||||
#else
|
||||
outbufs.push(std::vector<uint8_t>(outbuf.data(), outbuf.data() + outsz));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (lastCodeResult == LZMA_STREAM_END) {
|
||||
processedChunks += readChunks;
|
||||
readChunks = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_.avail_out == outbuf.size()) { // no progress was made
|
||||
if (!shouldFinish) {
|
||||
processedChunks += readChunks;
|
||||
readChunks = 0;
|
||||
}
|
||||
|
||||
|
||||
if (!shouldFinish)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LZMAStream::InitializeExports(Object exports) {
|
||||
exports["Stream"] = DefineClass(exports.Env(), "LZMAStream", {
|
||||
InstanceMethod("setBufsize", &LZMAStream::SetBufsize),
|
||||
InstanceMethod("resetUnderlying", &LZMAStream::ResetUnderlying),
|
||||
InstanceMethod("code", &LZMAStream::Code),
|
||||
InstanceMethod("memusage", &LZMAStream::Memusage),
|
||||
InstanceMethod("memlimitGet", &LZMAStream::MemlimitGet),
|
||||
InstanceMethod("memlimitSet", &LZMAStream::MemlimitSet),
|
||||
InstanceMethod("rawEncoder_", &LZMAStream::RawEncoder),
|
||||
InstanceMethod("rawDecoder_", &LZMAStream::RawDecoder),
|
||||
InstanceMethod("filtersUpdate", &LZMAStream::FiltersUpdate),
|
||||
InstanceMethod("easyEncoder_", &LZMAStream::EasyEncoder),
|
||||
InstanceMethod("streamEncoder_", &LZMAStream::StreamEncoder),
|
||||
InstanceMethod("aloneEncoder", &LZMAStream::AloneEncoder),
|
||||
InstanceMethod("mtEncoder_", &LZMAStream::MTEncoder),
|
||||
InstanceMethod("streamDecoder_", &LZMAStream::StreamDecoder),
|
||||
InstanceMethod("autoDecoder_", &LZMAStream::AutoDecoder),
|
||||
InstanceMethod("aloneDecoder_", &LZMAStream::AloneDecoder),
|
||||
});
|
||||
}
|
||||
|
||||
Value LZMAStream::Memusage(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
return Uint64ToNumber0Null(Env(), lzma_memusage(&_));
|
||||
}
|
||||
|
||||
Value LZMAStream::MemlimitGet(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
return Uint64ToNumber0Null(Env(), lzma_memlimit_get(&_));
|
||||
}
|
||||
|
||||
Value LZMAStream::MemlimitSet(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
if (!info[0].IsNumber())
|
||||
throw TypeError::New(Env(), "memlimitSet() needs a numerical argument");
|
||||
|
||||
Number arg = info[0].As<Number>();
|
||||
|
||||
return lzmaRet(Env(), lzma_memlimit_set(&_, NumberToUint64ClampNullMax(arg)));
|
||||
}
|
||||
|
||||
Value LZMAStream::RawEncoder(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
const FilterArray filters(info[0]);
|
||||
|
||||
return lzmaRet(Env(), lzma_raw_encoder(&_, filters.array()));
|
||||
}
|
||||
|
||||
Value LZMAStream::RawDecoder(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
const FilterArray filters(info[0]);
|
||||
|
||||
return lzmaRet(Env(), lzma_raw_decoder(&_, filters.array()));
|
||||
}
|
||||
|
||||
Value LZMAStream::FiltersUpdate(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
const FilterArray filters(info[0]);
|
||||
|
||||
return lzmaRet(Env(), lzma_filters_update(&_, filters.array()));
|
||||
}
|
||||
|
||||
Value LZMAStream::EasyEncoder(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
int64_t preset = info[0].ToNumber().Int64Value();
|
||||
int64_t check = info[1].ToNumber().Int64Value();
|
||||
|
||||
return lzmaRet(Env(), lzma_easy_encoder(&_, preset, (lzma_check) check));
|
||||
}
|
||||
|
||||
Value LZMAStream::StreamEncoder(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
const FilterArray filters(info[0]);
|
||||
int64_t check = info[1].ToNumber().Int64Value();
|
||||
|
||||
return lzmaRet(Env(), lzma_stream_encoder(&_, filters.array(), (lzma_check) check));
|
||||
}
|
||||
|
||||
Value LZMAStream::MTEncoder(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
const MTOptions mt(info[0]);
|
||||
|
||||
return lzmaRet(Env(), lzma_stream_encoder_mt(&_, mt.opts()));
|
||||
}
|
||||
|
||||
Value LZMAStream::AloneEncoder(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
lzma_options_lzma o = parseOptionsLZMA(info[0]);
|
||||
|
||||
return lzmaRet(Env(), lzma_alone_encoder(&_, &o));
|
||||
}
|
||||
|
||||
Value LZMAStream::StreamDecoder(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
uint64_t memlimit = NumberToUint64ClampNullMax(info[0]);
|
||||
int64_t flags = info[1].ToNumber().Int64Value();
|
||||
|
||||
return lzmaRet(Env(), lzma_stream_decoder(&_, memlimit, flags));
|
||||
}
|
||||
|
||||
Value LZMAStream::AutoDecoder(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
uint64_t memlimit = NumberToUint64ClampNullMax(info[0]);
|
||||
int64_t flags = info[1].ToNumber().Int64Value();
|
||||
|
||||
return lzmaRet(Env(), lzma_auto_decoder(&_, memlimit, flags));
|
||||
}
|
||||
|
||||
Value LZMAStream::AloneDecoder(const CallbackInfo& info) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
|
||||
uint64_t memlimit = NumberToUint64ClampNullMax(info[0]);
|
||||
|
||||
return lzmaRet(Env(), lzma_alone_decoder(&_, memlimit));
|
||||
}
|
||||
|
||||
}
|
||||
99
electron/node_modules/lzma-native/src/module.cpp
generated
vendored
Normal file
99
electron/node_modules/lzma-native/src/module.cpp
generated
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
#include "liblzma-node.hpp"
|
||||
|
||||
using namespace lzma;
|
||||
|
||||
static Napi::Object moduleInit(Env env, Object exports) {
|
||||
LZMAStream::InitializeExports(exports);
|
||||
IndexParser::InitializeExports(exports);
|
||||
|
||||
exports["versionNumber"] = Function::New(env, lzmaVersionNumber);
|
||||
exports["versionString"] = Function::New(env, lzmaVersionString);
|
||||
exports["checkIsSupported"] = Function::New(env, lzmaCheckIsSupported);
|
||||
exports["checkSize"] = Function::New(env, lzmaCheckSize);
|
||||
exports["crc32_"] = Function::New(env, lzmaCRC32);
|
||||
exports["filterEncoderIsSupported"] = Function::New(env, lzmaFilterEncoderIsSupported);
|
||||
exports["filterDecoderIsSupported"] = Function::New(env, lzmaFilterDecoderIsSupported);
|
||||
exports["rawEncoderMemusage"] = Function::New(env, lzmaRawEncoderMemusage);
|
||||
exports["rawDecoderMemusage"] = Function::New(env, lzmaRawDecoderMemusage);
|
||||
exports["mfIsSupported"] = Function::New(env, lzmaMfIsSupported);
|
||||
exports["modeIsSupported"] = Function::New(env, lzmaModeIsSupported);
|
||||
exports["easyEncoderMemusage"] = Function::New(env, lzmaEasyEncoderMemusage);
|
||||
exports["easyDecoderMemusage"] = Function::New(env, lzmaEasyDecoderMemusage);
|
||||
|
||||
// enum lzma_ret
|
||||
exports["OK"] = Number::New(env, LZMA_OK);
|
||||
exports["STREAM_END"] = Number::New(env, LZMA_STREAM_END);
|
||||
exports["NO_CHECK"] = Number::New(env, LZMA_NO_CHECK);
|
||||
exports["UNSUPPORTED_CHECK"] = Number::New(env, LZMA_UNSUPPORTED_CHECK);
|
||||
exports["GET_CHECK"] = Number::New(env, LZMA_GET_CHECK);
|
||||
exports["MEM_ERROR"] = Number::New(env, LZMA_MEM_ERROR);
|
||||
exports["MEMLIMIT_ERROR"] = Number::New(env, LZMA_MEMLIMIT_ERROR);
|
||||
exports["FORMAT_ERROR"] = Number::New(env, LZMA_FORMAT_ERROR);
|
||||
exports["OPTIONS_ERROR"] = Number::New(env, LZMA_OPTIONS_ERROR);
|
||||
exports["DATA_ERROR"] = Number::New(env, LZMA_DATA_ERROR);
|
||||
exports["BUF_ERROR"] = Number::New(env, LZMA_BUF_ERROR);
|
||||
exports["PROG_ERROR"] = Number::New(env, LZMA_PROG_ERROR);
|
||||
|
||||
// enum lzma_action
|
||||
exports["RUN"] = Number::New(env, LZMA_RUN);
|
||||
exports["SYNC_FLUSH"] = Number::New(env, LZMA_SYNC_FLUSH);
|
||||
exports["FULL_FLUSH"] = Number::New(env, LZMA_FULL_FLUSH);
|
||||
exports["FINISH"] = Number::New(env, LZMA_FINISH);
|
||||
|
||||
// enum lzma_check
|
||||
exports["CHECK_NONE"] = Number::New(env, LZMA_CHECK_NONE);
|
||||
exports["CHECK_CRC32"] = Number::New(env, LZMA_CHECK_CRC32);
|
||||
exports["CHECK_CRC64"] = Number::New(env, LZMA_CHECK_CRC64);
|
||||
exports["CHECK_SHA256"] = Number::New(env, LZMA_CHECK_SHA256);
|
||||
|
||||
// lzma_match_finder
|
||||
exports["MF_HC3"] = Number::New(env, LZMA_MF_HC3);
|
||||
exports["MF_HC4"] = Number::New(env, LZMA_MF_HC4);
|
||||
exports["MF_BT2"] = Number::New(env, LZMA_MF_BT2);
|
||||
exports["MF_BT3"] = Number::New(env, LZMA_MF_BT3);
|
||||
exports["MF_BT4"] = Number::New(env, LZMA_MF_BT4);
|
||||
|
||||
// lzma_mode
|
||||
exports["MODE_FAST"] = Number::New(env, LZMA_MODE_FAST);
|
||||
exports["MODE_NORMAL"] = Number::New(env, LZMA_MODE_NORMAL);
|
||||
|
||||
// defines
|
||||
exports["FILTER_X86"] = String::New(env, "LZMA_FILTER_X86");
|
||||
exports["FILTER_POWERPC"] = String::New(env, "LZMA_FILTER_POWERPC");
|
||||
exports["FILTER_IA64"] = String::New(env, "LZMA_FILTER_IA64");
|
||||
exports["FILTER_ARM"] = String::New(env, "LZMA_FILTER_ARM");
|
||||
exports["FILTER_ARMTHUMB"] = String::New(env, "LZMA_FILTER_ARMTHUMB");
|
||||
exports["FILTER_SPARC"] = String::New(env, "LZMA_FILTER_SPARC");
|
||||
exports["FILTER_DELTA"] = String::New(env, "LZMA_FILTER_DELTA");
|
||||
exports["FILTERS_MAX"] = String::New(env, "LZMA_FILTERS_MAX");
|
||||
exports["FILTER_LZMA1"] = String::New(env, "LZMA_FILTER_LZMA1");
|
||||
exports["FILTER_LZMA2"] = String::New(env, "LZMA_FILTER_LZMA2");
|
||||
exports["VLI_UNKNOWN"] = String::New(env, "LZMA_VLI_UNKNOWN");
|
||||
|
||||
exports["VLI_BYTES_MAX"] = Number::New(env, LZMA_VLI_BYTES_MAX);
|
||||
exports["CHECK_ID_MAX"] = Number::New(env, LZMA_CHECK_ID_MAX);
|
||||
exports["CHECK_SIZE_MAX"] = Number::New(env, LZMA_CHECK_SIZE_MAX);
|
||||
exports["PRESET_DEFAULT"] = Number::New(env, LZMA_PRESET_DEFAULT);
|
||||
exports["PRESET_LEVEL_MASK"] = Number::New(env, LZMA_PRESET_LEVEL_MASK);
|
||||
exports["PRESET_EXTREME"] = Number::New(env, LZMA_PRESET_EXTREME);
|
||||
exports["TELL_NO_CHECK"] = Number::New(env, LZMA_TELL_NO_CHECK);
|
||||
exports["TELL_UNSUPPORTED_CHECK"] = Number::New(env, LZMA_TELL_UNSUPPORTED_CHECK);
|
||||
exports["TELL_ANY_CHECK"] = Number::New(env, LZMA_TELL_ANY_CHECK);
|
||||
exports["CONCATENATED"] = Number::New(env, LZMA_CONCATENATED);
|
||||
exports["STREAM_HEADER_SIZE"] = Number::New(env, LZMA_STREAM_HEADER_SIZE);
|
||||
exports["VERSION_MAJOR"] = Number::New(env, LZMA_VERSION_MAJOR);
|
||||
exports["VERSION_MINOR"] = Number::New(env, LZMA_VERSION_MINOR);
|
||||
exports["VERSION_PATCH"] = Number::New(env, LZMA_VERSION_PATCH);
|
||||
exports["VERSION_STABILITY"] = Number::New(env, LZMA_VERSION_STABILITY);
|
||||
exports["VERSION_STABILITY_ALPHA"] = Number::New(env, LZMA_VERSION_STABILITY_ALPHA);
|
||||
exports["VERSION_STABILITY_BETA"] = Number::New(env, LZMA_VERSION_STABILITY_BETA);
|
||||
exports["VERSION_STABILITY_STABLE"] = Number::New(env, LZMA_VERSION_STABILITY_STABLE);
|
||||
exports["VERSION"] = Number::New(env, LZMA_VERSION);
|
||||
exports["VERSION_STRING"] = String::New(env, LZMA_VERSION_STRING);
|
||||
|
||||
exports["asyncCodeAvailable"] = Boolean::New(env, true);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NODE_API_MODULE(lzma_native, moduleInit)
|
||||
|
||||
28
electron/node_modules/lzma-native/src/mt-options.cpp
generated
vendored
Normal file
28
electron/node_modules/lzma-native/src/mt-options.cpp
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "liblzma-node.hpp"
|
||||
|
||||
namespace lzma {
|
||||
|
||||
MTOptions::MTOptions(Value val) {
|
||||
Object opt = val.IsUndefined() || val.IsNull() ?
|
||||
Object::New(val.Env()) : val.ToObject();
|
||||
opts_.flags = 0;
|
||||
opts_.filters = nullptr;
|
||||
|
||||
opts_.block_size = Value(opt["blockSize"]).ToNumber().Int64Value();
|
||||
opts_.timeout = Value(opt["timeout"]).ToNumber().Uint32Value();
|
||||
opts_.preset = Value(opt["preset"]).ToNumber().Uint32Value();
|
||||
opts_.check = (lzma_check)Value(opt["check"]).ToNumber().Int32Value();
|
||||
opts_.threads = Value(opt["threads"]).ToNumber().Uint32Value();
|
||||
|
||||
if (opts_.threads == 0) {
|
||||
opts_.threads = lzma_cputhreads();
|
||||
}
|
||||
|
||||
Value filters = opt["filters"];
|
||||
if (filters.IsArray()) {
|
||||
filters_.reset(new FilterArray(filters));
|
||||
opts_.filters = filters_->array();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
140
electron/node_modules/lzma-native/src/util.cpp
generated
vendored
Normal file
140
electron/node_modules/lzma-native/src/util.cpp
generated
vendored
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
#include "liblzma-node.hpp"
|
||||
#include <cstring>
|
||||
|
||||
namespace lzma {
|
||||
|
||||
lzma_vli FilterByName(Value name) {
|
||||
std::string cpp_string(name.ToString());
|
||||
|
||||
struct SearchEntry {
|
||||
const char* str;
|
||||
lzma_vli value;
|
||||
};
|
||||
|
||||
static const struct SearchEntry search[] = {
|
||||
{ "LZMA_FILTER_X86", LZMA_FILTER_X86 },
|
||||
{ "LZMA_FILTER_POWERPC", LZMA_FILTER_POWERPC },
|
||||
{ "LZMA_FILTER_IA64", LZMA_FILTER_IA64 },
|
||||
{ "LZMA_FILTER_ARM", LZMA_FILTER_ARM },
|
||||
{ "LZMA_FILTER_ARMTHUMB", LZMA_FILTER_ARMTHUMB },
|
||||
{ "LZMA_FILTER_SPARC", LZMA_FILTER_SPARC },
|
||||
{ "LZMA_FILTER_DELTA", LZMA_FILTER_DELTA },
|
||||
{ "LZMA_FILTER_LZMA1", LZMA_FILTER_LZMA1 },
|
||||
{ "LZMA_FILTER_LZMA2", LZMA_FILTER_LZMA2 },
|
||||
{ "LZMA_FILTERS_MAX", LZMA_FILTERS_MAX },
|
||||
{ "LZMA_VLI_UNKNOWN", LZMA_VLI_UNKNOWN }
|
||||
};
|
||||
|
||||
for (const struct SearchEntry* p = search; ; ++p)
|
||||
if (p->value == LZMA_VLI_UNKNOWN || cpp_string == p->str)
|
||||
return p->value;
|
||||
}
|
||||
|
||||
Error lzmaRetError(Env env, lzma_ret rv) {
|
||||
struct ErrorInfo {
|
||||
lzma_ret code;
|
||||
const char* name;
|
||||
const char* desc;
|
||||
};
|
||||
|
||||
/* description strings taken from liblzma/…/api/base.h */
|
||||
static const struct ErrorInfo searchErrorInfo[] = {
|
||||
{ LZMA_OK, "LZMA_OK", "Operation completed successfully" },
|
||||
{ LZMA_STREAM_END, "LZMA_STREAM_END", "End of stream was reached" },
|
||||
{ LZMA_NO_CHECK, "LZMA_NO_CHECK", "Input stream has no integrity check" },
|
||||
{ LZMA_UNSUPPORTED_CHECK, "LZMA_UNSUPPORTED_CHECK", "Cannot calculate the integrity check" },
|
||||
{ LZMA_GET_CHECK, "LZMA_GET_CHECK", "Integrity check type is now available" },
|
||||
{ LZMA_MEM_ERROR, "LZMA_MEM_ERROR", "Cannot allocate memory" },
|
||||
{ LZMA_MEMLIMIT_ERROR, "LZMA_MEMLIMIT_ERROR", "Memory usage limit was reached" },
|
||||
{ LZMA_FORMAT_ERROR, "LZMA_FORMAT_ERROR", "File format not recognized" },
|
||||
{ LZMA_OPTIONS_ERROR, "LZMA_OPTIONS_ERROR", "Invalid or unsupported options" },
|
||||
{ LZMA_DATA_ERROR, "LZMA_DATA_ERROR", "Data is corrupt" },
|
||||
{ LZMA_PROG_ERROR, "LZMA_PROG_ERROR", "Programming error" },
|
||||
{ LZMA_BUF_ERROR, "LZMA_BUF_ERROR", "No progress is possible" },
|
||||
{ (lzma_ret)-1, "LZMA_UNKNOWN_ERROR", "Unknown error code" }
|
||||
};
|
||||
|
||||
const struct ErrorInfo* p = searchErrorInfo;
|
||||
while (p->code != rv && p->code != (lzma_ret)-1)
|
||||
++p;
|
||||
|
||||
Error err = Error::New(env, p->desc);
|
||||
err.Set("code", Number::New(env, rv));
|
||||
err.Set("name", String::New(env, p->name));
|
||||
err.Set("desc", String::New(env, p->desc));
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
Number lzmaRet(Env env, lzma_ret rv) {
|
||||
if (rv != LZMA_OK && rv != LZMA_STREAM_END)
|
||||
throw lzmaRetError(env, rv);
|
||||
|
||||
return Number::New(env, rv);
|
||||
}
|
||||
|
||||
bool readBufferFromObj(Value buf_, std::vector<uint8_t>* data) {
|
||||
if (!buf_.IsTypedArray()) {
|
||||
throw TypeError::New(buf_.Env(), "Expected Buffer as input");
|
||||
return false;
|
||||
}
|
||||
|
||||
TypedArray buf = buf_.As<TypedArray>();
|
||||
size_t len = buf.ByteLength();
|
||||
const uint8_t* ptr = len > 0 ?
|
||||
static_cast<const uint8_t*>(buf.ArrayBuffer().Data()) + buf.ByteOffset() :
|
||||
reinterpret_cast<const uint8_t*>("");
|
||||
|
||||
*data = std::vector<uint8_t>(ptr, ptr + len);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
lzma_options_lzma parseOptionsLZMA (Value val) {
|
||||
HandleScope scope(val.Env());
|
||||
Object obj = val.IsUndefined() || val.IsNull() ?
|
||||
Object::New(val.Env()) : val.ToObject();
|
||||
|
||||
lzma_options_lzma r;
|
||||
r.dict_size = GetIntegerProperty(obj, "dictSize", LZMA_DICT_SIZE_DEFAULT);
|
||||
r.lp = GetIntegerProperty(obj, "lp", LZMA_LP_DEFAULT);
|
||||
r.lc = GetIntegerProperty(obj, "lc", LZMA_LC_DEFAULT);
|
||||
r.pb = GetIntegerProperty(obj, "pb", LZMA_PB_DEFAULT);
|
||||
r.mode = (lzma_mode)GetIntegerProperty(obj, "mode", (int64_t)LZMA_MODE_FAST);
|
||||
r.nice_len = GetIntegerProperty(obj, "niceLen", 64);
|
||||
r.mf = (lzma_match_finder)GetIntegerProperty(obj, "mf", (int64_t)LZMA_MF_HC4);
|
||||
r.depth = GetIntegerProperty(obj, "depth", 0);
|
||||
uint64_t preset_ = GetIntegerProperty(obj, "preset", UINT64_MAX);
|
||||
|
||||
r.preset_dict = nullptr;
|
||||
|
||||
if (preset_ != UINT64_MAX)
|
||||
lzma_lzma_preset(&r, preset_);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
Value Uint64ToNumberMaxNull(Env env, uint64_t in) {
|
||||
if (in == UINT64_MAX)
|
||||
return env.Null();
|
||||
else
|
||||
return Number::New(env, in);
|
||||
}
|
||||
|
||||
Value Uint64ToNumber0Null(Env env, uint64_t in) {
|
||||
if (in == 0)
|
||||
return env.Null();
|
||||
else
|
||||
return Number::New(env, in);
|
||||
}
|
||||
|
||||
uint64_t NumberToUint64ClampNullMax(Value in) {
|
||||
if (in.IsNull() || in.IsUndefined())
|
||||
return UINT64_MAX;
|
||||
|
||||
Number n = in.ToNumber();
|
||||
|
||||
return n.Int64Value();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue