mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-10 21:36:17 +00:00
fix: hotfixing video player
This commit is contained in:
@@ -1,2 +0,0 @@
|
|||||||
[target.x86_64-pc-windows-msvc]
|
|
||||||
rustflags = ["-C", "target-feature=+crt-static"]
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# EditorConfig helps developers define and maintain consistent
|
|
||||||
# coding styles between different editors or IDEs
|
|
||||||
# http://editorconfig.org
|
|
||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
end_of_line = lf
|
|
||||||
charset = utf-8
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
insert_final_newline = true
|
|
||||||
|
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
18
rust/.gitattributes
vendored
18
rust/.gitattributes
vendored
@@ -1,18 +0,0 @@
|
|||||||
# Auto detect text files and perform LF normalization
|
|
||||||
* text=auto
|
|
||||||
|
|
||||||
|
|
||||||
*.ts text eol=lf merge=union
|
|
||||||
*.tsx text eol=lf merge=union
|
|
||||||
*.rs text eol=lf merge=union
|
|
||||||
*.js text eol=lf merge=union
|
|
||||||
*.json text eol=lf merge=union
|
|
||||||
*.debug text eol=lf merge=union
|
|
||||||
|
|
||||||
# Generated codes
|
|
||||||
index.js linguist-detectable=false
|
|
||||||
index.d.ts linguist-detectable=false
|
|
||||||
rust.wasi-browser.js linguist-detectable=false
|
|
||||||
rust.wasi.cjs linguist-detectable=false
|
|
||||||
wasi-worker-browser.mjs linguist-detectable=false
|
|
||||||
wasi-worker.mjs linguist-detectable=false
|
|
||||||
20
rust/.github/renovate.json
vendored
20
rust/.github/renovate.json
vendored
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
||||||
"extends": ["config:base", "group:allNonMajor", ":preserveSemverRanges", ":disablePeerDependencies"],
|
|
||||||
"labels": ["dependencies"],
|
|
||||||
"packageRules": [
|
|
||||||
{
|
|
||||||
"matchPackageNames": ["@napi/cli", "napi", "napi-build", "napi-derive"],
|
|
||||||
"addLabels": ["napi-rs"],
|
|
||||||
"groupName": "napi-rs"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"matchPackagePatterns": ["^eslint", "^@typescript-eslint"],
|
|
||||||
"groupName": "linter"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"commitMessagePrefix": "chore: ",
|
|
||||||
"commitMessageAction": "bump up",
|
|
||||||
"commitMessageTopic": "{{depName}} version",
|
|
||||||
"ignoreDeps": []
|
|
||||||
}
|
|
||||||
268
rust/.github/workflows/CI.yml
vendored
268
rust/.github/workflows/CI.yml
vendored
@@ -1,268 +0,0 @@
|
|||||||
name: CI
|
|
||||||
env:
|
|
||||||
DEBUG: napi:*
|
|
||||||
APP_NAME: rust
|
|
||||||
MACOSX_DEPLOYMENT_TARGET: '10.13'
|
|
||||||
CARGO_INCREMENTAL: '1'
|
|
||||||
'on':
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
tags-ignore:
|
|
||||||
- '**'
|
|
||||||
paths-ignore:
|
|
||||||
- '**/*.md'
|
|
||||||
- LICENSE
|
|
||||||
- '**/*.gitignore'
|
|
||||||
- .editorconfig
|
|
||||||
- docs/**
|
|
||||||
pull_request: null
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
name: Lint
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@v6
|
|
||||||
with:
|
|
||||||
node-version: 24
|
|
||||||
cache: yarn
|
|
||||||
- name: Install
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
components: clippy, rustfmt
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn install
|
|
||||||
- name: Oxlint
|
|
||||||
run: yarn lint
|
|
||||||
- name: Cargo fmt
|
|
||||||
run: cargo fmt -- --check
|
|
||||||
- name: Clippy
|
|
||||||
run: cargo clippy
|
|
||||||
build:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
settings:
|
|
||||||
- host: macos-latest
|
|
||||||
target: x86_64-apple-darwin
|
|
||||||
build: yarn build --target x86_64-apple-darwin
|
|
||||||
- host: windows-latest
|
|
||||||
build: yarn build --target x86_64-pc-windows-msvc
|
|
||||||
target: x86_64-pc-windows-msvc
|
|
||||||
- host: ubuntu-latest
|
|
||||||
target: x86_64-unknown-linux-gnu
|
|
||||||
build: yarn build --target x86_64-unknown-linux-gnu --use-napi-cross
|
|
||||||
- host: macos-latest
|
|
||||||
target: aarch64-apple-darwin
|
|
||||||
build: yarn build --target aarch64-apple-darwin
|
|
||||||
name: stable - ${{ matrix.settings.target }} - node@22
|
|
||||||
runs-on: ${{ matrix.settings.host }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@v6
|
|
||||||
with:
|
|
||||||
node-version: 24
|
|
||||||
cache: yarn
|
|
||||||
- name: Install
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
toolchain: stable
|
|
||||||
targets: ${{ matrix.settings.target }}
|
|
||||||
- name: Cache cargo
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/registry/index/
|
|
||||||
~/.cargo/registry/cache/
|
|
||||||
~/.cargo/git/db/
|
|
||||||
~/.napi-rs
|
|
||||||
.cargo-cache
|
|
||||||
target/
|
|
||||||
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
|
|
||||||
- uses: mlugg/setup-zig@v2
|
|
||||||
if: ${{ contains(matrix.settings.target, 'musl') }}
|
|
||||||
with:
|
|
||||||
version: 0.14.1
|
|
||||||
- name: Install cargo-zigbuild
|
|
||||||
uses: taiki-e/install-action@v2
|
|
||||||
if: ${{ contains(matrix.settings.target, 'musl') }}
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ github.token }}
|
|
||||||
with:
|
|
||||||
tool: cargo-zigbuild
|
|
||||||
- name: Setup toolchain
|
|
||||||
run: ${{ matrix.settings.setup }}
|
|
||||||
if: ${{ matrix.settings.setup }}
|
|
||||||
shell: bash
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn install
|
|
||||||
- name: Build
|
|
||||||
run: ${{ matrix.settings.build }}
|
|
||||||
shell: bash
|
|
||||||
- name: Upload artifact
|
|
||||||
uses: actions/upload-artifact@v5
|
|
||||||
with:
|
|
||||||
name: bindings-${{ matrix.settings.target }}
|
|
||||||
path: |
|
|
||||||
${{ env.APP_NAME }}.*.node
|
|
||||||
${{ env.APP_NAME }}.*.wasm
|
|
||||||
if-no-files-found: error
|
|
||||||
test-macOS-windows-binding:
|
|
||||||
name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
|
|
||||||
needs:
|
|
||||||
- build
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
settings:
|
|
||||||
- host: windows-latest
|
|
||||||
target: x86_64-pc-windows-msvc
|
|
||||||
architecture: x64
|
|
||||||
- host: macos-latest
|
|
||||||
target: aarch64-apple-darwin
|
|
||||||
architecture: arm64
|
|
||||||
- host: macos-latest
|
|
||||||
target: x86_64-apple-darwin
|
|
||||||
architecture: x64
|
|
||||||
node:
|
|
||||||
- '20'
|
|
||||||
- '22'
|
|
||||||
runs-on: ${{ matrix.settings.host }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@v6
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node }}
|
|
||||||
cache: yarn
|
|
||||||
architecture: ${{ matrix.settings.architecture }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn install
|
|
||||||
- name: Download artifacts
|
|
||||||
uses: actions/download-artifact@v6
|
|
||||||
with:
|
|
||||||
name: bindings-${{ matrix.settings.target }}
|
|
||||||
path: .
|
|
||||||
- name: List packages
|
|
||||||
run: ls -R .
|
|
||||||
shell: bash
|
|
||||||
- name: Test bindings
|
|
||||||
run: yarn test
|
|
||||||
test-linux-binding:
|
|
||||||
name: Test ${{ matrix.target }} - node@${{ matrix.node }}
|
|
||||||
needs:
|
|
||||||
- build
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
target:
|
|
||||||
- x86_64-unknown-linux-gnu
|
|
||||||
node:
|
|
||||||
- '20'
|
|
||||||
- '22'
|
|
||||||
runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@v6
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node }}
|
|
||||||
cache: yarn
|
|
||||||
- name: Output docker params
|
|
||||||
id: docker
|
|
||||||
run: |
|
|
||||||
node -e "
|
|
||||||
if ('${{ matrix.target }}'.startsWith('aarch64')) {
|
|
||||||
console.log('PLATFORM=linux/arm64')
|
|
||||||
} else if ('${{ matrix.target }}'.startsWith('armv7')) {
|
|
||||||
console.log('PLATFORM=linux/arm/v7')
|
|
||||||
} else {
|
|
||||||
console.log('PLATFORM=linux/amd64')
|
|
||||||
}
|
|
||||||
" >> $GITHUB_OUTPUT
|
|
||||||
node -e "
|
|
||||||
if ('${{ matrix.target }}'.endsWith('-musl')) {
|
|
||||||
console.log('IMAGE=node:${{ matrix.node }}-alpine')
|
|
||||||
} else {
|
|
||||||
console.log('IMAGE=node:${{ matrix.node }}-slim')
|
|
||||||
}
|
|
||||||
" >> $GITHUB_OUTPUT
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
yarn config set --json supportedArchitectures.cpu '["current", "arm64", "x64", "arm"]'
|
|
||||||
yarn config set --json supportedArchitectures.libc '["current", "musl", "gnu"]'
|
|
||||||
yarn install
|
|
||||||
- name: Download artifacts
|
|
||||||
uses: actions/download-artifact@v6
|
|
||||||
with:
|
|
||||||
name: bindings-${{ matrix.target }}
|
|
||||||
path: .
|
|
||||||
- name: List packages
|
|
||||||
run: ls -R .
|
|
||||||
shell: bash
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
if: ${{ contains(matrix.target, 'armv7') }}
|
|
||||||
with:
|
|
||||||
platforms: all
|
|
||||||
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
||||||
if: ${{ contains(matrix.target, 'armv7') }}
|
|
||||||
- name: Test bindings
|
|
||||||
uses: addnab/docker-run-action@v3
|
|
||||||
with:
|
|
||||||
image: ${{ steps.docker.outputs.IMAGE }}
|
|
||||||
options: '-v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}'
|
|
||||||
run: yarn test
|
|
||||||
publish:
|
|
||||||
name: Publish
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
id-token: write
|
|
||||||
needs:
|
|
||||||
- lint
|
|
||||||
- test-macOS-windows-binding
|
|
||||||
- test-linux-binding
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- name: Setup node
|
|
||||||
uses: actions/setup-node@v6
|
|
||||||
with:
|
|
||||||
node-version: 24
|
|
||||||
cache: yarn
|
|
||||||
- name: Install dependencies
|
|
||||||
run: yarn install
|
|
||||||
- name: create npm dirs
|
|
||||||
run: yarn napi create-npm-dirs
|
|
||||||
- name: Download all artifacts
|
|
||||||
uses: actions/download-artifact@v6
|
|
||||||
with:
|
|
||||||
path: artifacts
|
|
||||||
- name: Move artifacts
|
|
||||||
run: yarn artifacts
|
|
||||||
- name: List packages
|
|
||||||
run: ls -R ./npm
|
|
||||||
shell: bash
|
|
||||||
- name: Publish
|
|
||||||
run: |
|
|
||||||
npm config set provenance true
|
|
||||||
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
|
|
||||||
then
|
|
||||||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
|
||||||
npm publish --access public
|
|
||||||
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
|
|
||||||
then
|
|
||||||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
|
||||||
npm publish --tag next --access public
|
|
||||||
else
|
|
||||||
echo "Not a release, skipping publish"
|
|
||||||
fi
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
130
rust/.gitignore
vendored
130
rust/.gitignore
vendored
@@ -1,130 +0,0 @@
|
|||||||
|
|
||||||
# Created by https://www.toptal.com/developers/gitignore/api/node
|
|
||||||
# Edit at https://www.toptal.com/developers/gitignore?templates=node
|
|
||||||
|
|
||||||
### Node ###
|
|
||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.pid.lock
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
*.lcov
|
|
||||||
|
|
||||||
# nyc test coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
|
||||||
bower_components
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
node_modules/
|
|
||||||
jspm_packages/
|
|
||||||
|
|
||||||
# TypeScript v1 declaration files
|
|
||||||
typings/
|
|
||||||
|
|
||||||
# TypeScript cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
|
||||||
.npm
|
|
||||||
|
|
||||||
# Optional eslint cache
|
|
||||||
.eslintcache
|
|
||||||
|
|
||||||
# Microbundle cache
|
|
||||||
.rpt2_cache/
|
|
||||||
.rts2_cache_cjs/
|
|
||||||
.rts2_cache_es/
|
|
||||||
.rts2_cache_umd/
|
|
||||||
|
|
||||||
# Optional REPL history
|
|
||||||
.node_repl_history
|
|
||||||
|
|
||||||
# Output of 'npm pack'
|
|
||||||
*.tgz
|
|
||||||
|
|
||||||
# Yarn Integrity file
|
|
||||||
.yarn-integrity
|
|
||||||
|
|
||||||
# dotenv environment variables file
|
|
||||||
.env
|
|
||||||
.env.test
|
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
|
||||||
.cache
|
|
||||||
|
|
||||||
# Next.js build output
|
|
||||||
.next
|
|
||||||
|
|
||||||
# Nuxt.js build / generate output
|
|
||||||
.nuxt
|
|
||||||
dist
|
|
||||||
|
|
||||||
# Gatsby files
|
|
||||||
.cache/
|
|
||||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
|
||||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
|
||||||
# public
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
|
||||||
# TernJS port file
|
|
||||||
.tern-port
|
|
||||||
|
|
||||||
# Stores VSCode versions used for testing VSCode extensions
|
|
||||||
.vscode-test
|
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/node
|
|
||||||
|
|
||||||
|
|
||||||
#Added by cargo
|
|
||||||
|
|
||||||
/target
|
|
||||||
Cargo.lock
|
|
||||||
|
|
||||||
*.node
|
|
||||||
.pnp.*
|
|
||||||
.yarn/*
|
|
||||||
!.yarn/patches
|
|
||||||
!.yarn/plugins
|
|
||||||
!.yarn/releases
|
|
||||||
!.yarn/sdks
|
|
||||||
!.yarn/versions
|
|
||||||
/npm
|
|
||||||
1
rust/.husky/.gitignore
vendored
1
rust/.husky/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
_
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
yarn lint-staged
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
target
|
|
||||||
.yarn
|
|
||||||
index.js
|
|
||||||
package-template.wasi-browser.js
|
|
||||||
package-template.wasi.cjs
|
|
||||||
wasi-worker-browser.mjs
|
|
||||||
wasi-worker.mjs
|
|
||||||
.yarnrc.yml
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
exclude = ["node_modules/**/*.toml"]
|
|
||||||
|
|
||||||
# https://taplo.tamasfe.dev/configuration/formatter-options.html
|
|
||||||
[formatting]
|
|
||||||
align_entries = true
|
|
||||||
indent_tables = true
|
|
||||||
reorder_keys = true
|
|
||||||
942
rust/.yarn/releases/yarn-4.11.0.cjs
vendored
942
rust/.yarn/releases/yarn-4.11.0.cjs
vendored
File diff suppressed because one or more lines are too long
@@ -1,5 +0,0 @@
|
|||||||
nodeLinker: node-modules
|
|
||||||
|
|
||||||
npmAuditRegistry: "https://registry.npmjs.org"
|
|
||||||
|
|
||||||
yarnPath: .yarn/releases/yarn-4.11.0.cjs
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
[package]
|
|
||||||
authors = ["LongYinan <lynweklm@gmail.com>"]
|
|
||||||
edition = "2021"
|
|
||||||
name = "rust"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
napi = "3.0.0"
|
|
||||||
napi-derive = "3.0.0"
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
napi-build = "2"
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
lto = true
|
|
||||||
strip = "symbols"
|
|
||||||
21
rust/LICENSE
21
rust/LICENSE
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2020 N-API for Rust
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
# `@napi-rs/package-template`
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
> Template project for writing node packages with napi-rs.
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
1. Click **Use this template**.
|
|
||||||
2. **Clone** your project.
|
|
||||||
3. Run `yarn install` to install dependencies.
|
|
||||||
4. Run `yarn napi rename -n [@your-scope/package-name] -b [binary-name]` command under the project folder to rename your package.
|
|
||||||
|
|
||||||
## Install this test package
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn add @napi-rs/package-template
|
|
||||||
```
|
|
||||||
|
|
||||||
## Ability
|
|
||||||
|
|
||||||
### Build
|
|
||||||
|
|
||||||
After `yarn build/npm run build` command, you can see `package-template.[darwin|win32|linux].node` file in project root. This is the native addon built from [lib.rs](./src/lib.rs).
|
|
||||||
|
|
||||||
### Test
|
|
||||||
|
|
||||||
With [ava](https://github.com/avajs/ava), run `yarn test/npm run test` to testing native addon. You can also switch to another testing framework if you want.
|
|
||||||
|
|
||||||
### CI
|
|
||||||
|
|
||||||
With GitHub Actions, each commit and pull request will be built and tested automatically in [`node@20`, `@node22`] x [`macOS`, `Linux`, `Windows`] matrix. You will never be afraid of the native addon broken in these platforms.
|
|
||||||
|
|
||||||
### Release
|
|
||||||
|
|
||||||
Release native package is very difficult in old days. Native packages may ask developers who use it to install `build toolchain` like `gcc/llvm`, `node-gyp` or something more.
|
|
||||||
|
|
||||||
With `GitHub actions`, we can easily prebuild a `binary` for major platforms. And with `N-API`, we should never be afraid of **ABI Compatible**.
|
|
||||||
|
|
||||||
The other problem is how to deliver prebuild `binary` to users. Downloading it in `postinstall` script is a common way that most packages do it right now. The problem with this solution is it introduced many other packages to download binary that has not been used by `runtime codes`. The other problem is some users may not easily download the binary from `GitHub/CDN` if they are behind a private network (But in most cases, they have a private NPM mirror).
|
|
||||||
|
|
||||||
In this package, we choose a better way to solve this problem. We release different `npm packages` for different platforms. And add it to `optionalDependencies` before releasing the `Major` package to npm.
|
|
||||||
|
|
||||||
`NPM` will choose which native package should download from `registry` automatically. You can see [npm](./npm) dir for details. And you can also run `yarn add @napi-rs/package-template` to see how it works.
|
|
||||||
|
|
||||||
## Develop requirements
|
|
||||||
|
|
||||||
- Install the latest `Rust`
|
|
||||||
- Install `Node.js@10+` which fully supported `Node-API`
|
|
||||||
- Install `yarn@1.x`
|
|
||||||
|
|
||||||
## Test in local
|
|
||||||
|
|
||||||
- yarn
|
|
||||||
- yarn build
|
|
||||||
- yarn test
|
|
||||||
|
|
||||||
And you will see:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ ava --verbose
|
|
||||||
|
|
||||||
✔ sync function from native code
|
|
||||||
✔ sleep function from native code (201ms)
|
|
||||||
─
|
|
||||||
|
|
||||||
2 tests passed
|
|
||||||
✨ Done in 1.12s.
|
|
||||||
```
|
|
||||||
|
|
||||||
## Release package
|
|
||||||
|
|
||||||
Ensure you have set your **NPM_TOKEN** in the `GitHub` project setting.
|
|
||||||
|
|
||||||
In `Settings -> Secrets`, add **NPM_TOKEN** into it.
|
|
||||||
|
|
||||||
When you want to release the package:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]
|
|
||||||
|
|
||||||
git push
|
|
||||||
```
|
|
||||||
|
|
||||||
GitHub actions will do the rest job for you.
|
|
||||||
|
|
||||||
> WARN: Don't run `npm publish` manually.
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import test from 'ava'
|
|
||||||
|
|
||||||
import { plus100 } from '../index'
|
|
||||||
|
|
||||||
test('sync function from native code', (t) => {
|
|
||||||
const fixture = 42
|
|
||||||
t.is(plus100(fixture), fixture + 100)
|
|
||||||
})
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "Bundler",
|
|
||||||
"outDir": "lib",
|
|
||||||
"rootDir": "."
|
|
||||||
},
|
|
||||||
"include": ["*.ts"],
|
|
||||||
"exclude": ["lib"]
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { Bench } from 'tinybench'
|
|
||||||
|
|
||||||
import { plus100 } from '../index.js'
|
|
||||||
|
|
||||||
function add(a: number) {
|
|
||||||
return a + 100
|
|
||||||
}
|
|
||||||
|
|
||||||
const b = new Bench()
|
|
||||||
|
|
||||||
b.add('Native a + 100', () => {
|
|
||||||
plus100(10)
|
|
||||||
})
|
|
||||||
|
|
||||||
b.add('JavaScript a + 100', () => {
|
|
||||||
add(10)
|
|
||||||
})
|
|
||||||
|
|
||||||
await b.run()
|
|
||||||
|
|
||||||
console.table(b.table())
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module"
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "../tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"moduleResolution": "NodeNext",
|
|
||||||
"module": "NodeNext",
|
|
||||||
"outDir": "lib"
|
|
||||||
},
|
|
||||||
"include": ["."],
|
|
||||||
"exclude": ["lib"]
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fn main() {
|
|
||||||
napi_build::setup();
|
|
||||||
}
|
|
||||||
5
rust/index.d.ts
vendored
5
rust/index.d.ts
vendored
@@ -1,5 +0,0 @@
|
|||||||
/* auto-generated by NAPI-RS */
|
|
||||||
/* eslint-disable */
|
|
||||||
export declare function gayChecker(name: string): boolean
|
|
||||||
|
|
||||||
export declare function plus100(input: number): number
|
|
||||||
710
rust/index.js
710
rust/index.js
@@ -1,710 +0,0 @@
|
|||||||
// prettier-ignore
|
|
||||||
/* eslint-disable */
|
|
||||||
// @ts-nocheck
|
|
||||||
/* auto-generated by NAPI-RS */
|
|
||||||
|
|
||||||
const { createRequire } = require('node:module')
|
|
||||||
require = createRequire(__filename)
|
|
||||||
|
|
||||||
const { readFileSync } = require('node:fs')
|
|
||||||
let nativeBinding = null
|
|
||||||
const loadErrors = []
|
|
||||||
|
|
||||||
const isMusl = () => {
|
|
||||||
let musl = false
|
|
||||||
if (process.platform === 'linux') {
|
|
||||||
musl = isMuslFromFilesystem()
|
|
||||||
if (musl === null) {
|
|
||||||
musl = isMuslFromReport()
|
|
||||||
}
|
|
||||||
if (musl === null) {
|
|
||||||
musl = isMuslFromChildProcess()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return musl
|
|
||||||
}
|
|
||||||
|
|
||||||
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
||||||
|
|
||||||
const isMuslFromFilesystem = () => {
|
|
||||||
try {
|
|
||||||
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
||||||
} catch {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const isMuslFromReport = () => {
|
|
||||||
let report = null
|
|
||||||
if (typeof process.report?.getReport === 'function') {
|
|
||||||
process.report.excludeNetwork = true
|
|
||||||
report = process.report.getReport()
|
|
||||||
}
|
|
||||||
if (!report) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
if (report.header && report.header.glibcVersionRuntime) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (Array.isArray(report.sharedObjects)) {
|
|
||||||
if (report.sharedObjects.some(isFileMusl)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
const isMuslFromChildProcess = () => {
|
|
||||||
try {
|
|
||||||
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
||||||
} catch (e) {
|
|
||||||
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function requireNative() {
|
|
||||||
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
||||||
try {
|
|
||||||
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
|
|
||||||
} catch (err) {
|
|
||||||
loadErrors.push(err)
|
|
||||||
}
|
|
||||||
} else if (process.platform === 'android') {
|
|
||||||
if (process.arch === 'arm64') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.android-arm64.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-android-arm64')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-android-arm64/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'arm') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.android-arm-eabi.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-android-arm-eabi')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-android-arm-eabi/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
||||||
}
|
|
||||||
} else if (process.platform === 'win32') {
|
|
||||||
if (process.arch === 'x64') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.win32-x64-msvc.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-win32-x64-msvc')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-win32-x64-msvc/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'ia32') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.win32-ia32-msvc.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-win32-ia32-msvc')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-win32-ia32-msvc/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'arm64') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.win32-arm64-msvc.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-win32-arm64-msvc')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-win32-arm64-msvc/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
||||||
}
|
|
||||||
} else if (process.platform === 'darwin') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.darwin-universal.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-darwin-universal')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-darwin-universal/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
if (process.arch === 'x64') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.darwin-x64.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-darwin-x64')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-darwin-x64/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'arm64') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.darwin-arm64.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-darwin-arm64')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-darwin-arm64/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
||||||
}
|
|
||||||
} else if (process.platform === 'freebsd') {
|
|
||||||
if (process.arch === 'x64') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.freebsd-x64.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-freebsd-x64')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-freebsd-x64/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'arm64') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.freebsd-arm64.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-freebsd-arm64')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-freebsd-arm64/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
||||||
}
|
|
||||||
} else if (process.platform === 'linux') {
|
|
||||||
if (process.arch === 'x64') {
|
|
||||||
if (isMusl()) {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-x64-musl.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-x64-musl')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-x64-musl/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-x64-gnu.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-x64-gnu')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-x64-gnu/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'arm64') {
|
|
||||||
if (isMusl()) {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-arm64-musl.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-arm64-musl')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-arm64-musl/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-arm64-gnu.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-arm64-gnu')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-arm64-gnu/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'arm') {
|
|
||||||
if (isMusl()) {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-arm-musleabihf.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-arm-musleabihf')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-arm-musleabihf/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-arm-gnueabihf.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-arm-gnueabihf')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-arm-gnueabihf/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'loong64') {
|
|
||||||
if (isMusl()) {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-loong64-musl.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-loong64-musl')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-loong64-musl/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-loong64-gnu.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-loong64-gnu')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-loong64-gnu/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'riscv64') {
|
|
||||||
if (isMusl()) {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-riscv64-musl.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-riscv64-musl')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-riscv64-musl/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-riscv64-gnu.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-riscv64-gnu')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-riscv64-gnu/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'ppc64') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-ppc64-gnu.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-ppc64-gnu')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-ppc64-gnu/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else if (process.arch === 's390x') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.linux-s390x-gnu.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-linux-s390x-gnu')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-linux-s390x-gnu/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
||||||
}
|
|
||||||
} else if (process.platform === 'openharmony') {
|
|
||||||
if (process.arch === 'arm64') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.openharmony-arm64.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-openharmony-arm64')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-openharmony-arm64/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'x64') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.openharmony-x64.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-openharmony-x64')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-openharmony-x64/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else if (process.arch === 'arm') {
|
|
||||||
try {
|
|
||||||
return require('./package-template.openharmony-arm.node')
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const binding = require('@napi-rs/package-template-openharmony-arm')
|
|
||||||
const bindingPackageVersion = require('@napi-rs/package-template-openharmony-arm/package.json').version
|
|
||||||
if (
|
|
||||||
bindingPackageVersion !== '1.0.0' &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
||||||
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
||||||
) {
|
|
||||||
throw new Error(
|
|
||||||
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return binding
|
|
||||||
} catch (e) {
|
|
||||||
loadErrors.push(e)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nativeBinding = requireNative()
|
|
||||||
|
|
||||||
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
||||||
let wasiBinding = null
|
|
||||||
let wasiBindingError = null
|
|
||||||
try {
|
|
||||||
wasiBinding = require('./package-template.wasi.cjs')
|
|
||||||
nativeBinding = wasiBinding
|
|
||||||
} catch (err) {
|
|
||||||
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
||||||
wasiBindingError = err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!nativeBinding) {
|
|
||||||
try {
|
|
||||||
wasiBinding = require('@napi-rs/package-template-wasm32-wasi')
|
|
||||||
nativeBinding = wasiBinding
|
|
||||||
} catch (err) {
|
|
||||||
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
||||||
wasiBindingError.cause = err
|
|
||||||
loadErrors.push(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
||||||
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
||||||
error.cause = wasiBindingError
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!nativeBinding) {
|
|
||||||
if (loadErrors.length > 0) {
|
|
||||||
throw new Error(
|
|
||||||
`Cannot find native binding. ` +
|
|
||||||
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
||||||
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
||||||
{
|
|
||||||
cause: loadErrors.reduce((err, cur) => {
|
|
||||||
cur.cause = err
|
|
||||||
return cur
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
throw new Error(`Failed to load native binding`)
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = nativeBinding
|
|
||||||
module.exports.plus100 = nativeBinding.plus100
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "rust",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "Template project for writing node package with napi-rs",
|
|
||||||
"main": "index.js",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+ssh://git@github.com/napi-rs/package-template.git"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"browser": "browser.js",
|
|
||||||
"keywords": [
|
|
||||||
"napi-rs",
|
|
||||||
"NAPI",
|
|
||||||
"N-API",
|
|
||||||
"Rust",
|
|
||||||
"node-addon",
|
|
||||||
"node-addon-api"
|
|
||||||
],
|
|
||||||
"files": [
|
|
||||||
"index.d.ts",
|
|
||||||
"index.js",
|
|
||||||
"browser.js"
|
|
||||||
],
|
|
||||||
"napi": {
|
|
||||||
"binaryName": "rust",
|
|
||||||
"targets": [
|
|
||||||
"x86_64-pc-windows-msvc",
|
|
||||||
"x86_64-apple-darwin",
|
|
||||||
"x86_64-unknown-linux-gnu",
|
|
||||||
"aarch64-apple-darwin"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0"
|
|
||||||
},
|
|
||||||
"publishConfig": {
|
|
||||||
"registry": "https://registry.npmjs.org/",
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"artifacts": "napi artifacts",
|
|
||||||
"bench": "node --import @oxc-node/core/register benchmark/bench.ts",
|
|
||||||
"build": "napi build --platform --release",
|
|
||||||
"build:debug": "napi build --platform",
|
|
||||||
"format": "run-p format:prettier format:rs format:toml",
|
|
||||||
"format:prettier": "prettier . -w",
|
|
||||||
"format:toml": "taplo format",
|
|
||||||
"format:rs": "cargo fmt",
|
|
||||||
"lint": "oxlint .",
|
|
||||||
"prepublishOnly": "napi prepublish -t npm",
|
|
||||||
"test": "ava",
|
|
||||||
"preversion": "napi build --platform && git add .",
|
|
||||||
"version": "napi version",
|
|
||||||
"prepare": "husky"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@emnapi/core": "^1.5.0",
|
|
||||||
"@emnapi/runtime": "^1.5.0",
|
|
||||||
"@napi-rs/cli": "^3.2.0",
|
|
||||||
"@oxc-node/core": "^0.0.34",
|
|
||||||
"@taplo/cli": "^0.7.0",
|
|
||||||
"@tybys/wasm-util": "^0.10.0",
|
|
||||||
"ava": "^6.4.1",
|
|
||||||
"chalk": "^5.6.2",
|
|
||||||
"husky": "^9.1.7",
|
|
||||||
"lint-staged": "^16.1.6",
|
|
||||||
"npm-run-all2": "^8.0.4",
|
|
||||||
"oxlint": "^1.14.0",
|
|
||||||
"prettier": "^3.6.2",
|
|
||||||
"tinybench": "^5.0.1",
|
|
||||||
"typescript": "^5.9.2"
|
|
||||||
},
|
|
||||||
"lint-staged": {
|
|
||||||
"*.@(js|ts|tsx)": [
|
|
||||||
"oxlint --fix"
|
|
||||||
],
|
|
||||||
"*.@(js|ts|tsx|yml|yaml|md|json)": [
|
|
||||||
"prettier --write"
|
|
||||||
],
|
|
||||||
"*.toml": [
|
|
||||||
"taplo format"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"ava": {
|
|
||||||
"extensions": {
|
|
||||||
"ts": "module"
|
|
||||||
},
|
|
||||||
"timeout": "2m",
|
|
||||||
"workerThreads": false,
|
|
||||||
"environmentVariables": {
|
|
||||||
"OXC_TSCONFIG_PATH": "./__test__/tsconfig.json"
|
|
||||||
},
|
|
||||||
"nodeArguments": [
|
|
||||||
"--import",
|
|
||||||
"@oxc-node/core/register"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"prettier": {
|
|
||||||
"printWidth": 120,
|
|
||||||
"semi": false,
|
|
||||||
"trailingComma": "all",
|
|
||||||
"singleQuote": true,
|
|
||||||
"arrowParens": "always"
|
|
||||||
},
|
|
||||||
"packageManager": "yarn@4.11.0"
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
tab_spaces = 2
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#![deny(clippy::all)]
|
|
||||||
|
|
||||||
use napi_derive::napi;
|
|
||||||
|
|
||||||
#[napi]
|
|
||||||
pub fn plus_100(input: u32) -> u32 {
|
|
||||||
input + 100
|
|
||||||
}
|
|
||||||
|
|
||||||
#[napi]
|
|
||||||
pub fn gay_checker(name: String) -> bool {
|
|
||||||
name.contains("gay")
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "ESNext",
|
|
||||||
"strict": true,
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"module": "CommonJS",
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"noUnusedParameters": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"allowSyntheticDefaultImports": true
|
|
||||||
},
|
|
||||||
"include": ["."],
|
|
||||||
"exclude": ["node_modules", "bench", "__test__"]
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
|
|
||||||
|
|
||||||
const handler = new MessageHandler({
|
|
||||||
onLoad({ wasmModule, wasmMemory }) {
|
|
||||||
const wasi = new WASI({
|
|
||||||
print: function () {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log.apply(console, arguments)
|
|
||||||
},
|
|
||||||
printErr: function() {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.error.apply(console, arguments)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return instantiateNapiModuleSync(wasmModule, {
|
|
||||||
childThread: true,
|
|
||||||
wasi,
|
|
||||||
overwriteImports(importObject) {
|
|
||||||
importObject.env = {
|
|
||||||
...importObject.env,
|
|
||||||
...importObject.napi,
|
|
||||||
...importObject.emnapi,
|
|
||||||
memory: wasmMemory,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
globalThis.onmessage = function (e) {
|
|
||||||
handler.handle(e)
|
|
||||||
}
|
|
||||||
3303
rust/yarn.lock
3303
rust/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user