diff --git a/.cargo/config.toml b/.cargo/config.toml index 808a2c6..1261fea 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,14 +1,3 @@ -[target.x86_64-unknown-linux-gnu] -rustflags = ["-L", "native=/usr/lib/x86_64-linux-gnu/"] - -[target.aarch64-unknown-linux-gnu] -rustflags = ["-L", "native=/usr/aarch64-unknown-linux-gnu/"] - [target.aarch64-unknown-linux-musl] linker = "aarch64-linux-musl-gcc" -rustflags = [ - "-C", - "target-feature=-crt-static", - "-L", - "native=/usr/lib/", -] +rustflags = ["-C", "target-feature=-crt-static"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index fe1506e..8263886 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,35 +1,35 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node { - "name": "Node.js & TypeScript", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/typescript-node:1-18-bullseye", - // Features to add to the dev container. More info: https://containers.dev/features. - "features": { - "ghcr.io/devcontainers/features/desktop-lite:1": {}, - "ghcr.io/devcontainers/features/rust:1": {} - }, + "name": "Node.js & TypeScript", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/typescript-node:1-18-bullseye", + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/desktop-lite:1": {}, + "ghcr.io/devcontainers/features/rust:1": {} + }, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [6080], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [6080], - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "yarn install", + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "wengerk.highlight-bad-chars", - "streetsidesoftware.code-spell-checker", - "EditorConfig.EditorConfig", - "esbenp.prettier-vscode", - "rust-lang.rust-analyzer", - "foxundermoon.shell-format" - ] + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": [ + "wengerk.highlight-bad-chars", + "streetsidesoftware.code-spell-checker", + "EditorConfig.EditorConfig", + "esbenp.prettier-vscode", + "rust-lang.rust-analyzer", + "foxundermoon.shell-format" + ] + } } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" } diff --git a/.editorconfig b/.editorconfig index 9d08a1a..e291365 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,7 +3,7 @@ root = true [*] charset = utf-8 indent_style = space -indent_size = 2 +indent_size = 4 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index d83def7..9e32c8a 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,65 +1,65 @@ name: docker-publish on: - workflow_dispatch: # 手动触发 - push: - branches: ["master"] - # Publish semver tags as releases. - tags: ["v*.*.*"] - pull_request: - branches: ["master"] + workflow_dispatch: # 手动触发 + push: + branches: ["master"] + # Publish semver tags as releases. + tags: ["v*.*.*"] + pull_request: + branches: ["master"] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true env: - # Use docker.io for Docker Hub if empty - REGISTRY: ghcr.io + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io jobs: - build-desktop: - strategy: - fail-fast: false - matrix: - platform: - - alpine - - debian - node: - - 14 - - 16 - - 18 - name: build node-desktop:${{ matrix.node }}-${{ matrix.platform }} - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 + build-desktop: + strategy: + fail-fast: false + matrix: + platform: + - alpine + - debian + node: + - 14 + - 16 + - 18 + name: build node-desktop:${{ matrix.node }}-${{ matrix.platform }} + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 - - name: Setup QEMU - uses: docker/setup-qemu-action@v2 + - name: Setup QEMU + uses: docker/setup-qemu-action@v2 - # Workaround: https://github.com/docker/build-push-action/issues/461 - - name: Docker Setup Buildx - uses: docker/setup-buildx-action@v2 + # Workaround: https://github.com/docker/build-push-action/issues/461 + - name: Docker Setup Buildx + uses: docker/setup-buildx-action@v2 - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - uses: docker/build-push-action@v3 - with: - context: ./docker - file: ./docker/${{ matrix.platform }}.Dockerfile - push: ${{ github.event_name != 'pull_request' }} - build-args: | - VERSION=${{ matrix.node }} - tags: ${{ env.REGISTRY }}/${{ github.repository }}/node-desktop:${{ matrix.node }}-${{ matrix.platform }} + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: ./docker + file: ./docker/${{ matrix.platform }}.Dockerfile + push: ${{ github.event_name != 'pull_request' }} + build-args: | + VERSION=${{ matrix.node }} + tags: ${{ env.REGISTRY }}/${{ github.repository }}/node-desktop:${{ matrix.node }}-${{ matrix.platform }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..46e3601 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,39 @@ +name: Lint + +on: + push: + branches: + - master + tags-ignore: + - "**" + pull_request: null + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint: + strategy: + fail-fast: false + matrix: + host: + - macos-latest + - windows-latest + - ubuntu-latest + name: Lint on ${{ matrix.host }} + runs-on: ${{ matrix.host }} + steps: + - uses: actions/checkout@v3 + + - name: Install rust toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt, clippy + + - name: Cargo fmt + run: cargo fmt -- --check + + - name: Clippy + run: cargo clippy diff --git a/.github/workflows/napi.yml b/.github/workflows/napi.yml index dc46abd..93a4ad5 100644 --- a/.github/workflows/napi.yml +++ b/.github/workflows/napi.yml @@ -1,416 +1,422 @@ name: napi env: - DEBUG: napi:* - APP_NAME: node-screenshots - MACOSX_DEPLOYMENT_TARGET: "10.13" + DEBUG: napi:* + APP_NAME: node-screenshots + MACOSX_DEPLOYMENT_TARGET: "10.13" + on: - push: - branches: - - master - tags-ignore: - - "**" - paths-ignore: - - "**/*.md" - - LICENSE - - "**/*.gitignore" - - .editorconfig - - docs/** - pull_request: null + push: + branches: + - master + tags-ignore: + - "**" + paths-ignore: + - "**/*.md" + - LICENSE + - "**/*.gitignore" + - .editorconfig + - docs/** + pull_request: null concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - build: - strategy: - fail-fast: false - matrix: - settings: - - host: macos-latest - target: x86_64-apple-darwin - build: | - yarn build - strip -x *.node - - host: macos-latest - target: aarch64-apple-darwin - build: | - yarn build --target aarch64-apple-darwin - strip -x *.node + build: + strategy: + fail-fast: false + matrix: + settings: + - host: macos-latest + target: x86_64-apple-darwin + build: | + yarn build + strip -x *.node + - host: macos-latest + target: aarch64-apple-darwin + build: | + yarn build --target aarch64-apple-darwin + strip -x *.node + + - host: windows-latest + build: yarn build + target: x86_64-pc-windows-msvc + - host: windows-latest + build: | + yarn build --target i686-pc-windows-msvc + yarn test + target: i686-pc-windows-msvc + - host: windows-latest + target: aarch64-pc-windows-msvc + build: yarn build --target aarch64-pc-windows-msvc + + - host: ubuntu-latest + target: x86_64-unknown-linux-gnu + docker: node:14-buster + build: |- + set -e && + apt-get update && + apt-get install libxcb1-dev curl -y && + curl https://sh.rustup.rs -sSf | bash -s -- -y && + source ~/.bashrc && + yarn build --target x86_64-unknown-linux-gnu && + strip *.node + - host: ubuntu-latest + target: x86_64-unknown-linux-musl + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine + build: |- + set -e && + apk update && + apk add libxcb-dev && + yarn build && + strip *.node + # - host: ubuntu-latest + # target: aarch64-unknown-linux-gnu + # docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 + # build: |- + # set -e && + # apt-get update && + # apt-get install libxcb1-dev -y && + # ln -s /usr/lib/x86_64-linux-gnu/libxcb.so /usr/aarch64-unknown-linux-gnu/lib/libxcb.so && + # ln -s /usr/lib/x86_64-linux-gnu/libxcb.a /usr/aarch64-unknown-linux-gnu/lib/libxcb.a && + # ln -s /usr/lib/x86_64-linux-gnu/libxcb.so /usr/aarch64-unknown-linux-gnu/lib/gcc/aarch64-unknown-linux-gnu/libxcb.so && + # ln -s /usr/lib/x86_64-linux-gnu/libxcb.a /usr/aarch64-unknown-linux-gnu/lib/gcc/aarch64-unknown-linux-gnu/libxcb.a && + # ln -s /usr/lib/x86_64-linux-gnu/libxcb.so /usr/aarch64-unknown-linux-gnu/lib/gcc/libxcb.so && + # ln -s /usr/lib/x86_64-linux-gnu/libxcb.a /usr/aarch64-unknown-linux-gnu/lib/gcc/libxcb.a && + # ln -s /usr/lib/x86_64-linux-gnu/libxcb.so /usr/aarch64-unknown-linux-gnu/libxcb.so && + # ln -s /usr/lib/x86_64-linux-gnu/libxcb.a /usr/aarch64-unknown-linux-gnu/libxcb.a && + # rustup target add aarch64-unknown-linux-gnu && + # rustup toolchain install stable-aarch64-unknown-linux-gnu && + # yarn build --target aarch64-unknown-linux-gnu && + # aarch64-unknown-linux-gnu-strip *.node + # - host: ubuntu-latest + # target: aarch64-unknown-linux-musl + # docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine + # build: |- + # set -e && + # apk update && + # apk add libxcb-dev libxrandr-dev && \ + # rustup target add aarch64-unknown-linux-musl && \ + # yarn build --target aarch64-unknown-linux-musl && + # /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node + name: stable - ${{ matrix.settings.target }} - node@18 + runs-on: ${{ matrix.settings.host }} + steps: + - uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + if: ${{ !matrix.settings.docker }} + with: + node-version: 18 + check-latest: true + cache: yarn + - name: Install + uses: dtolnay/rust-toolchain@stable + if: ${{ !matrix.settings.docker }} + with: + toolchain: stable + targets: ${{ matrix.settings.target }} + - name: Cache cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + .cargo-cache + target/ + key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} + - uses: goto-bus-stop/setup-zig@v2 + if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} + with: + version: 0.10.1 + - name: Setup toolchain + run: ${{ matrix.settings.setup }} + if: ${{ matrix.settings.setup }} + shell: bash + - name: Setup node x86 + if: matrix.settings.target == 'i686-pc-windows-msvc' + run: yarn config set supportedArchitectures.cpu "ia32" + shell: bash + - name: Install dependencies + run: yarn install + - name: Setup node x86 + uses: actions/setup-node@v3 + if: matrix.settings.target == 'i686-pc-windows-msvc' + with: + node-version: 18 + check-latest: true + cache: yarn + architecture: x86 - - host: windows-latest - build: yarn build - target: x86_64-pc-windows-msvc - - host: windows-latest - build: | - yarn build --target i686-pc-windows-msvc - yarn test - target: i686-pc-windows-msvc - - host: windows-latest - target: aarch64-pc-windows-msvc - build: yarn build --target aarch64-pc-windows-msvc + - name: Build in docker + uses: addnab/docker-run-action@v3 + if: ${{ matrix.settings.docker }} + with: + image: ${{ matrix.settings.docker }} + shell: bash + options: "--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build" + run: ${{ matrix.settings.build }} + - name: Build + run: ${{ matrix.settings.build }} + if: ${{ !matrix.settings.docker }} + shell: bash + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: bindings-${{ matrix.settings.target }} + path: ${{ env.APP_NAME }}.*.node + if-no-files-found: error - - host: ubuntu-latest - target: x86_64-unknown-linux-gnu - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian - build: |- - set -e && - apt-get update && - apt-get install libxcb1-dev -y && - yarn build --target x86_64-unknown-linux-gnu && - strip *.node - - host: ubuntu-latest - target: x86_64-unknown-linux-musl - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine - build: |- - set -e && - apk update && - apk add libxcb-dev && - yarn build && - strip *.node - # - host: ubuntu-latest - # target: aarch64-unknown-linux-gnu - # docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian-aarch64 - # build: |- - # set -e && - # apt-get update && - # apt-get install libxcb1-dev -y && - # ln -s /usr/lib/x86_64-linux-gnu/libxcb.so /usr/aarch64-unknown-linux-gnu/lib/libxcb.so && - # ln -s /usr/lib/x86_64-linux-gnu/libxcb.a /usr/aarch64-unknown-linux-gnu/lib/libxcb.a && - # ln -s /usr/lib/x86_64-linux-gnu/libxcb.so /usr/aarch64-unknown-linux-gnu/lib/gcc/aarch64-unknown-linux-gnu/libxcb.so && - # ln -s /usr/lib/x86_64-linux-gnu/libxcb.a /usr/aarch64-unknown-linux-gnu/lib/gcc/aarch64-unknown-linux-gnu/libxcb.a && - # ln -s /usr/lib/x86_64-linux-gnu/libxcb.so /usr/aarch64-unknown-linux-gnu/lib/gcc/libxcb.so && - # ln -s /usr/lib/x86_64-linux-gnu/libxcb.a /usr/aarch64-unknown-linux-gnu/lib/gcc/libxcb.a && - # ln -s /usr/lib/x86_64-linux-gnu/libxcb.so /usr/aarch64-unknown-linux-gnu/libxcb.so && - # ln -s /usr/lib/x86_64-linux-gnu/libxcb.a /usr/aarch64-unknown-linux-gnu/libxcb.a && - # rustup target add aarch64-unknown-linux-gnu && - # rustup toolchain install stable-aarch64-unknown-linux-gnu && - # yarn build --target aarch64-unknown-linux-gnu && - # aarch64-unknown-linux-gnu-strip *.node - # - host: ubuntu-latest - # target: aarch64-unknown-linux-musl - # docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine - # build: |- - # set -e && - # apk update && - # apk add libxcb-dev libxrandr-dev && \ - # rustup target add aarch64-unknown-linux-musl && \ - # yarn build --target aarch64-unknown-linux-musl && - # /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node - name: stable - ${{ matrix.settings.target }} - node@18 - runs-on: ${{ matrix.settings.host }} - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - if: ${{ !matrix.settings.docker }} - with: - node-version: 18 - check-latest: true - cache: yarn - - name: Install - uses: dtolnay/rust-toolchain@stable - if: ${{ !matrix.settings.docker }} - with: - toolchain: stable - targets: ${{ matrix.settings.target }} - - name: Cache cargo - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - .cargo-cache - target/ - key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }} - - uses: goto-bus-stop/setup-zig@v2 - if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }} - with: - version: 0.10.1 - - name: Setup toolchain - run: ${{ matrix.settings.setup }} - if: ${{ matrix.settings.setup }} - shell: bash - - name: Setup node x86 - if: matrix.settings.target == 'i686-pc-windows-msvc' - run: yarn config set supportedArchitectures.cpu "ia32" - shell: bash - - name: Install dependencies - run: yarn install - - name: Setup node x86 - uses: actions/setup-node@v3 - if: matrix.settings.target == 'i686-pc-windows-msvc' - with: - node-version: 18 - check-latest: true - cache: yarn - architecture: x86 - - name: Build in docker - uses: addnab/docker-run-action@v3 - if: ${{ matrix.settings.docker }} - with: - image: ${{ matrix.settings.docker }} - options: "--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build" - run: ${{ matrix.settings.build }} - - name: Build - run: ${{ matrix.settings.build }} - if: ${{ !matrix.settings.docker }} - shell: bash - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: bindings-${{ matrix.settings.target }} - path: ${{ env.APP_NAME }}.*.node - 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 - node: - - "14" - - "16" - - "18" - runs-on: ${{ matrix.settings.host }} - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - check-latest: true - cache: yarn - - name: Install dependencies - run: yarn install - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-${{ matrix.settings.target }} - path: . - - name: List packages - run: ls -R . - shell: bash - - name: Test bindings - run: yarn test - test-linux-x64-gnu-binding: - name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - "18" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - check-latest: true - cache: yarn - - name: Install dependencies - run: yarn install - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-x86_64-unknown-linux-gnu - path: . - - name: List packages - run: ls -R . - shell: bash - - name: Test bindings - run: docker run --rm -v $(pwd):/build -w /build ghcr.io/nashaofu/node-screenshots/node-desktop:${{ matrix.node }}-debian yarn test - test-linux-x64-musl-binding: - name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - "14" - - "16" - - "18" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - check-latest: true - cache: yarn - - name: Install dependencies - run: | - yarn config set supportedArchitectures.libc "musl" - yarn install - - name: Download artifacts - uses: actions/download-artifact@v3 - with: - name: bindings-x86_64-unknown-linux-musl - path: . - - name: List packages - run: ls -R . - shell: bash - - name: Test bindings - run: docker run --rm -v $(pwd):/build -w /build ghcr.io/nashaofu/node-screenshots/node-desktop:${{ matrix.node }}-alpine yarn test - # test-linux-aarch64-gnu-binding: - # name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} - # needs: - # - build - # strategy: - # fail-fast: false - # matrix: - # node: - # - '14' - # - '16' - # - '18' - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - name: Download artifacts - # uses: actions/download-artifact@v3 - # with: - # name: bindings-aarch64-unknown-linux-gnu - # path: . - # - name: List packages - # run: ls -R . - # shell: bash - # - name: Install dependencies - # run: | - # yarn config set supportedArchitectures.cpu "arm64" - # yarn config set supportedArchitectures.libc "glibc" - # yarn install - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v2 - # with: - # platforms: arm64 - # - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - # - name: Setup and run tests - # uses: addnab/docker-run-action@v3 - # with: - # image: ghcr.io/nashaofu/node-screenshots/node-desktop:${{ matrix.node }}-slim - # options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build' - # run: | - # set -e - # yarn test - # ls -la - # test-linux-aarch64-musl-binding: - # name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }} - # needs: - # - build - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - name: Download artifacts - # uses: actions/download-artifact@v3 - # with: - # name: bindings-aarch64-unknown-linux-musl - # path: . - # - name: List packages - # run: ls -R . - # shell: bash - # - name: Install dependencies - # run: | - # yarn config set supportedArchitectures.cpu "arm64" - # yarn config set supportedArchitectures.libc "musl" - # yarn install - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v2 - # with: - # platforms: arm64 - # - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - # - name: Setup and run tests - # uses: addnab/docker-run-action@v3 - # with: - # image: ghcr.io/nashaofu/node-screenshots/node-desktop:lts-alpine - # options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build' - # run: | - # set -e - # yarn test - universal-macOS: - name: Build universal macOS binary - needs: - - build - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - check-latest: true - cache: yarn - - name: Install dependencies - run: yarn install - - name: Download macOS x64 artifact - uses: actions/download-artifact@v3 - with: - name: bindings-x86_64-apple-darwin - path: artifacts - - name: Download macOS arm64 artifact - uses: actions/download-artifact@v3 - with: - name: bindings-aarch64-apple-darwin - path: artifacts - - name: Combine binaries - run: yarn universal - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: bindings-universal-apple-darwin - path: ${{ env.APP_NAME }}.*.node - if-no-files-found: error - publish: - name: Publish - runs-on: ubuntu-latest - needs: - - test-macOS-windows-binding - # - test-linux-x64-gnu-binding - - test-linux-x64-musl-binding - # - test-linux-aarch64-gnu-binding - # - test-linux-aarch64-musl-binding - - universal-macOS - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - check-latest: true - cache: yarn - - name: Install dependencies - run: yarn install - - name: Download all artifacts - uses: actions/download-artifact@v3 - with: - path: artifacts - - name: Move artifacts - run: yarn artifacts - - name: List packages - run: ls -R ./npm - shell: bash - - name: Publish - run: | - 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 }} + 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 + node: + - "14" + - "16" + - "18" + runs-on: ${{ matrix.settings.host }} + steps: + - uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + check-latest: true + cache: yarn + - name: Install dependencies + run: yarn install + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: bindings-${{ matrix.settings.target }} + path: . + - name: List packages + run: ls -R . + shell: bash + - name: Test bindings + run: yarn test + test-linux-x64-gnu-binding: + name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} + needs: + - build + strategy: + fail-fast: false + matrix: + node: + - "18" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + check-latest: true + cache: yarn + - name: Install dependencies + run: yarn install + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-unknown-linux-gnu + path: . + - name: List packages + run: ls -R . + shell: bash + - name: Test bindings + run: docker run --rm -v $(pwd):/build -w /build ghcr.io/nashaofu/node-screenshots/node-desktop:${{ matrix.node }}-debian yarn test + test-linux-x64-musl-binding: + name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} + needs: + - build + strategy: + fail-fast: false + matrix: + node: + - "14" + - "16" + - "18" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + check-latest: true + cache: yarn + - name: Install dependencies + run: | + yarn config set supportedArchitectures.libc "musl" + yarn install + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-unknown-linux-musl + path: . + - name: List packages + run: ls -R . + shell: bash + - name: Test bindings + run: docker run --rm -v $(pwd):/build -w /build ghcr.io/nashaofu/node-screenshots/node-desktop:${{ matrix.node }}-alpine yarn test + # test-linux-aarch64-gnu-binding: + # name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} + # needs: + # - build + # strategy: + # fail-fast: false + # matrix: + # node: + # - '14' + # - '16' + # - '18' + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - name: Download artifacts + # uses: actions/download-artifact@v3 + # with: + # name: bindings-aarch64-unknown-linux-gnu + # path: . + # - name: List packages + # run: ls -R . + # shell: bash + # - name: Install dependencies + # run: | + # yarn config set supportedArchitectures.cpu "arm64" + # yarn config set supportedArchitectures.libc "glibc" + # yarn install + # - name: Set up QEMU + # uses: docker/setup-qemu-action@v2 + # with: + # platforms: arm64 + # - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + # - name: Setup and run tests + # uses: addnab/docker-run-action@v3 + # with: + # image: ghcr.io/nashaofu/node-screenshots/node-desktop:${{ matrix.node }}-slim + # options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build' + # run: | + # set -e + # yarn test + # ls -la + # test-linux-aarch64-musl-binding: + # name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }} + # needs: + # - build + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # - name: Download artifacts + # uses: actions/download-artifact@v3 + # with: + # name: bindings-aarch64-unknown-linux-musl + # path: . + # - name: List packages + # run: ls -R . + # shell: bash + # - name: Install dependencies + # run: | + # yarn config set supportedArchitectures.cpu "arm64" + # yarn config set supportedArchitectures.libc "musl" + # yarn install + # - name: Set up QEMU + # uses: docker/setup-qemu-action@v2 + # with: + # platforms: arm64 + # - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + # - name: Setup and run tests + # uses: addnab/docker-run-action@v3 + # with: + # image: ghcr.io/nashaofu/node-screenshots/node-desktop:lts-alpine + # options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build' + # run: | + # set -e + # yarn test + universal-macOS: + name: Build universal macOS binary + needs: + - build + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + check-latest: true + cache: yarn + - name: Install dependencies + run: yarn install + - name: Download macOS x64 artifact + uses: actions/download-artifact@v3 + with: + name: bindings-x86_64-apple-darwin + path: artifacts + - name: Download macOS arm64 artifact + uses: actions/download-artifact@v3 + with: + name: bindings-aarch64-apple-darwin + path: artifacts + - name: Combine binaries + run: yarn universal + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: bindings-universal-apple-darwin + path: ${{ env.APP_NAME }}.*.node + if-no-files-found: error + publish: + name: Publish + runs-on: ubuntu-latest + needs: + - test-macOS-windows-binding + # - test-linux-x64-gnu-binding + - test-linux-x64-musl-binding + # - test-linux-aarch64-gnu-binding + # - test-linux-aarch64-musl-binding + - universal-macOS + steps: + - uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + check-latest: true + cache: yarn + - name: Install dependencies + run: yarn install + - name: Download all artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + - name: Move artifacts + run: yarn artifacts + - name: List packages + run: ls -R ./npm + shell: bash + - name: Publish + run: | + 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 }} diff --git a/.gitignore b/.gitignore index 68aa003..fe393f5 100644 --- a/.gitignore +++ b/.gitignore @@ -195,5 +195,3 @@ Cargo.lock !.yarn/versions *.node - -/temp-*.png diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 743793b..0d492be 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,10 +1,10 @@ { - "recommendations": [ - "wengerk.highlight-bad-chars", - "streetsidesoftware.code-spell-checker", - "editorconfig.editorconfig", - "esbenp.prettier-vscode", - "rust-lang.rust-analyzer", - "foxundermoon.shell-format" - ] + "recommendations": [ + "wengerk.highlight-bad-chars", + "streetsidesoftware.code-spell-checker", + "editorconfig.editorconfig", + "esbenp.prettier-vscode", + "rust-lang.rust-analyzer", + "foxundermoon.shell-format" + ] } diff --git a/Cargo.toml b/Cargo.toml index 0257063..3f2a0c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,13 +7,14 @@ version = "0.0.0" crate-type = ["cdylib"] [dependencies] +image = "0.24" # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix -napi = { version = "2.12.0", default-features = false, features = ["napi4"] } -napi-derive = "2.12.2" -screenshots = "0.7.0" +napi = { version = "2.13", default-features = false, features = ["napi4"] } +napi-derive = "2.13" +screenshots = "0.8" [build-dependencies] -napi-build = "2.0.1" +napi-build = "2.0" [profile.release] lto = true diff --git a/README-zh_CN.md b/README-zh_CN.md index d78757f..668eac5 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -34,36 +34,38 @@ fs.writeFileSync("./a.png", image); // 异步截图 capturer.capture().then((data) => { - console.log(data); - fs.writeFileSync(`${capturer.id}.png`, data); + console.log(data); + fs.writeFileSync(`${capturer.id}.png`, data); }); // 获取所有屏幕截图 let all = Screenshots.all() ?? []; all.forEach((capturer) => { - console.log({ - id: capturer.id, - x: capturer.x, - y: capturer.y, - width: capturer.width, - height: capturer.height, - rotation: capturer.rotation, - scaleFactor: capturer.scaleFactor, - isPrimary: capturer.isPrimary, - }); - capturer.captureSync(); + console.log({ + id: capturer.id, + x: capturer.x, + y: capturer.y, + width: capturer.width, + height: capturer.height, + rotation: capturer.rotation, + scaleFactor: capturer.scaleFactor, + isPrimary: capturer.isPrimary, + }); + capturer.captureSync(true); }); ``` ## API -- `Screenshots.fromPoint(x, y)`: 获取指定坐标的截图 -- `Screenshots.all()`: 获取所有截图 -- `screenshots.capture()`: 异步截取全屏 -- `screenshots.captureSync()`: 同步截取全屏 -- `screenshots.captureArea(x, y, width, height)`: 异步截取指定区域 -- `screenshots.captureAreaSync(x, y, width, height)`: 同步截取指定区域 +- `Screenshots.fromPoint(x, y)`: 获取指定坐标的截图 +- `Screenshots.all()`: 获取所有截图 +- `screenshots.capture(copyOutputData)`: 异步截取全屏 +- `screenshots.captureSync(copyOutputData)`: 同步截取全屏 +- `screenshots.captureArea(x, y, width, height, copyOutputData)`: 异步截取指定区域 +- `screenshots.captureAreaSync(x, y, width, height, copyOutputData)`: 同步截取指定区域 + +`copyOutputData`: electron 中传递传递相关参数,否则 electron 会崩溃,nodejs 不传或者传递 false,性能会更好,详细信息参考 https://github.com/napi-rs/napi-rs/issues/1346 ## Linux 系统需求 diff --git a/README.md b/README.md index 22e4551..c72c7b8 100644 --- a/README.md +++ b/README.md @@ -34,36 +34,38 @@ fs.writeFileSync("./a.png", image); // Asynchronous capture capturer.capture().then((data) => { - console.log(data); - fs.writeFileSync(`${capturer.id}.png`, data); + console.log(data); + fs.writeFileSync(`${capturer.id}.png`, data); }); // Get all screen captures let all = Screenshots.all() ?? []; all.forEach((capturer) => { - console.log({ - id: capturer.id, - x: capturer.x, - y: capturer.y, - width: capturer.width, - height: capturer.height, - rotation: capturer.rotation, - scaleFactor: capturer.scaleFactor, - isPrimary: capturer.isPrimary, - }); - capturer.captureSync(); + console.log({ + id: capturer.id, + x: capturer.x, + y: capturer.y, + width: capturer.width, + height: capturer.height, + rotation: capturer.rotation, + scaleFactor: capturer.scaleFactor, + isPrimary: capturer.isPrimary, + }); + capturer.captureSync(true); }); ``` ## API -- `Screenshots.fromPoint(x, y)`: Get a screenshot from the specified coordinates -- `Screenshots.all()`: Get all screenshots -- `screenshots.capture()`: Asynchronously capture full screen -- `screenshots.captureSync()`: Synchronously capture full screen -- `screenshots.captureArea(x, y, width, height)`: Asynchronously capture the specified area -- `screenshots.captureAreaSync(x, y, width, height)`: Synchronously capture the specified area +- `Screenshots.fromPoint(x, y)`: Get a screenshot from the specified coordinates +- `Screenshots.all()`: Get all screenshots +- `screenshots.capture(copyOutputData)`: Asynchronously capture full screen +- `screenshots.captureSync(copyOutputData)`: Synchronously capture full screen +- `screenshots.captureArea(x, y, width, height, copyOutputData)`: Asynchronously capture the specified area +- `screenshots.captureAreaSync(x, y, width, height, copyOutputData)`: Synchronously capture the specified area + +`copyOutputData`: pass related parameters in electron, otherwise electron will crash, nodejs does not pass or passes false, performance will be better, for more information refer to https://github.com/napi-rs/napi-rs/issues/1346 ## Linux System Requirements diff --git a/__test__/index.spec.mjs b/__test__/index.spec.mjs index 634e0e6..e58cfcc 100644 --- a/__test__/index.spec.mjs +++ b/__test__/index.spec.mjs @@ -1,42 +1,42 @@ -import test from 'ava' -import { Screenshots } from '../index.js' +import test from "ava"; +import { Screenshots } from "../index.js"; -test('Screenshots.all()', t => { - let all = Screenshots.all() - t.true(all.length == 1) - t.true(typeof all[0].id === 'number') -}) +test("Screenshots.all()", (t) => { + let all = Screenshots.all(); + t.true(all.length == 1); + t.true(typeof all[0].id === "number"); +}); -test('Screenshots.fromPoint(100, 100)', t => { - let screenshots = Screenshots.fromPoint(100, 100) - t.true(screenshots !== null) -}) +test("Screenshots.fromPoint(100, 100)", (t) => { + let screenshots = Screenshots.fromPoint(100, 100); + t.true(screenshots !== null); +}); -test('Screenshots.fromPoint(-10, -10)', t => { - let screenshots = Screenshots.fromPoint(-10, -10) - t.true(screenshots === null) -}) +test("Screenshots.fromPoint(-10, -10)", (t) => { + let screenshots = Screenshots.fromPoint(-10, -10); + t.true(screenshots === null); +}); -test('screenshots.capture()', async t => { - let screenshots = Screenshots.fromPoint(100, 100) - let buffer = await screenshots.capture() - t.true(buffer !== null) -}) +test("screenshots.capture()", async (t) => { + let screenshots = Screenshots.fromPoint(100, 100); + let buffer = await screenshots.capture(false); + t.true(buffer !== null); +}); -test('screenshots.captureSync()', t => { - let screenshots = Screenshots.fromPoint(100, 100) - let buffer = screenshots.captureSync() - t.true(buffer !== null) -}) +test("screenshots.captureSync()", (t) => { + let screenshots = Screenshots.fromPoint(100, 100); + let buffer = screenshots.captureSync(true); + t.true(buffer !== null); +}); -test('screenshots.captureArea(0, 0, 10, 10)', async t => { - let screenshots = Screenshots.fromPoint(100, 100) - let buffer = await screenshots.captureArea(0, 0, 10, 10) - t.true(buffer !== null) -}) +test("screenshots.captureArea(0, 0, 10, 10)", async (t) => { + let screenshots = Screenshots.fromPoint(100, 100); + let buffer = await screenshots.captureArea(0, 0, 10, 10, true); + t.true(buffer !== null); +}); -test('screenshots.captureAreaSync(0, 0, 10, 10)', t => { - let screenshots = Screenshots.fromPoint(100, 100) - let buffer = screenshots.captureAreaSync(0, 0, 10, 10) - t.true(buffer !== null) -}) +test("screenshots.captureAreaSync(0, 0, 10, 10)", (t) => { + let screenshots = Screenshots.fromPoint(100, 100); + let buffer = screenshots.captureAreaSync(0, 0, 10, 10, false); + t.true(buffer !== null); +}); diff --git a/build.rs b/build.rs index 1f866b6..9fc2367 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,5 @@ extern crate napi_build; fn main() { - napi_build::setup(); + napi_build::setup(); } diff --git a/docker/alpine-init.sh b/docker/alpine-init.sh index fa1db8d..fc4dd5d 100755 --- a/docker/alpine-init.sh +++ b/docker/alpine-init.sh @@ -6,17 +6,17 @@ DISPLAY_HEIGHT="${DISPLAY_HEIGHT:-720}" # 后台运行程序 startInBackgroundIfNotRunning() { - echo "Starting $1." - if ! pidof $1 >/dev/null; then - $@ & - while ! pidof $1 >/dev/null; do - echo "Waiting $1 start" - sleep 1 - done - echo "$1 started." - else - echo "$1 is already running." - fi + echo "Starting $1." + if ! pidof $1 >/dev/null; then + $@ & + while ! pidof $1 >/dev/null; do + echo "Waiting $1 start" + sleep 1 + done + echo "$1 started." + else + echo "$1 is already running." + fi } startInBackgroundIfNotRunning Xvfb ${DISPLAY} -screen 0 ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}x24 -dpi 96 -listen tcp -ac diff --git a/docker/alpine.Dockerfile b/docker/alpine.Dockerfile index 1e97ef1..dbf7f98 100644 --- a/docker/alpine.Dockerfile +++ b/docker/alpine.Dockerfile @@ -4,13 +4,13 @@ FROM node:${VERSION}-alpine # Setup environment variables ENV DISPLAY=":0" \ - DISPLAY_WIDTH="1280" \ - DISPLAY_HEIGHT="720" + DISPLAY_WIDTH="1280" \ + DISPLAY_HEIGHT="720" COPY alpine-init.sh /usr/local/share/alpine-init.sh RUN apk update && \ - apk add xvfb libxcb libxrandr + apk add xvfb libxcb libxrandr ENTRYPOINT [ "/usr/local/share/alpine-init.sh" ] diff --git a/docker/debian-init.sh b/docker/debian-init.sh index ba68125..a914b80 100755 --- a/docker/debian-init.sh +++ b/docker/debian-init.sh @@ -6,17 +6,17 @@ DISPLAY_HEIGHT="${DISPLAY_HEIGHT:-720}" # 后台运行程序 startInBackgroundIfNotRunning() { - echo "Starting $1." - if ! pidof $1 >/dev/null; then - $@ & - while ! pidof $1 >/dev/null; do - echo "Waiting $1 start" - sleep 1 - done - echo "$1 started." - else - echo "$1 is already running." - fi + echo "Starting $1." + if ! pidof $1 >/dev/null; then + $@ & + while ! pidof $1 >/dev/null; do + echo "Waiting $1 start" + sleep 1 + done + echo "$1 started." + else + echo "$1 is already running." + fi } startInBackgroundIfNotRunning Xvfb ${DISPLAY} -screen 0 ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}x24 -dpi 96 -listen tcp -ac diff --git a/docker/debian.Dockerfile b/docker/debian.Dockerfile index aae4f6e..e95579f 100644 --- a/docker/debian.Dockerfile +++ b/docker/debian.Dockerfile @@ -4,17 +4,17 @@ FROM node:${VERSION}-slim # Setup environment variables ENV DEBIAN_FRONTEND=noninteractive \ - DISPLAY=":0" \ - DISPLAY_WIDTH="1280" \ - DISPLAY_HEIGHT="720" + DISPLAY=":0" \ + DISPLAY_WIDTH="1280" \ + DISPLAY_HEIGHT="720" COPY debian-init.sh /usr/local/share/debian-init.sh RUN apt-get update && \ - apt-get -y install --no-install-recommends xvfb libxcb1 libxrandr2 && \ - apt-get autoclean -y && \ - apt-get autoremove -y && \ - rm -rf /var/lib/apt/lists/* + apt-get -y install --no-install-recommends xvfb libxcb1 libxrandr2 && \ + apt-get autoclean -y && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* ENTRYPOINT [ "/usr/local/share/debian-init.sh" ] diff --git a/example.js b/example.js index b13f4c8..528b88b 100644 --- a/example.js +++ b/example.js @@ -1,52 +1,62 @@ -console.time('require') -const { Screenshots } = require('.') -console.timeEnd('require') -const fs = require('fs') - -console.time('fromPoint') -let capturer = Screenshots.fromPoint(100, 100) -console.timeEnd('fromPoint') - -console.time('display') -console.log(capturer, capturer.id) -console.timeEnd('display') - -console.time('captureSync') -let image = capturer.captureSync() -console.timeEnd('captureSync') -console.log(image) -fs.writeFileSync('./temp-a.png', image) - -console.time('captureAsync') -console.time('captureAsync task') -let captureAsync = capturer.capture() -console.timeEnd('captureAsync') -console.log('captureAsync', captureAsync) - -captureAsync.then(data => { - console.timeEnd('captureAsync task') - console.log(data) - fs.writeFileSync(`temp-${capturer.id}.png`, data) -}) - -console.time('Screenshots.all()') -let all = Screenshots.all() -console.timeEnd('Screenshots.all()') - -all.forEach(capturer => { - // capturer.captureSync() - console.log({ - id: capturer.id, - x: capturer.x, - y: capturer.y, - width: capturer.width, - height: capturer.height, - rotation: capturer.rotation, - scaleFactor: capturer.scaleFactor, - isPrimary: capturer.isPrimary - }) -}) - -capturer.captureArea(300, 300, 300, 300).then(buffer => { - fs.writeFileSync(`temp-captureArea-${capturer.id}.png`, buffer) -}) +console.time("require"); +const { Screenshots } = require("."); +console.timeEnd("require"); +const fs = require("fs"); +const path = require("path"); + +function writeFile(filename, buf) { + if (!fs.existsSync("target")) { + fs.mkdirSync("target"); + } + + fs.writeFileSync(path.join("target", filename), buf); +} + +console.time("fromPoint"); +let capturer = Screenshots.fromPoint(100, 100); +console.timeEnd("fromPoint"); + +console.time("display"); +console.log(capturer, capturer.id); +console.timeEnd("display"); + +console.time("captureSync"); +let image = capturer.captureSync(true); +console.timeEnd("captureSync"); +console.log(image); +writeFile("temp-a.png", image); +writeFile("temp-a2.png", image); + +console.time("captureAsync"); +console.time("captureAsync task"); +let captureAsync = capturer.capture(); +console.timeEnd("captureAsync"); +console.log("captureAsync", captureAsync); + +captureAsync.then((data) => { + console.timeEnd("captureAsync task"); + console.log(data); + writeFile(`temp-${capturer.id}.png`, data); +}); + +console.time("Screenshots.all()"); +let all = Screenshots.all(); +console.timeEnd("Screenshots.all()"); + +all.forEach((capturer) => { + // capturer.captureSync() + console.log({ + id: capturer.id, + x: capturer.x, + y: capturer.y, + width: capturer.width, + height: capturer.height, + rotation: capturer.rotation, + scaleFactor: capturer.scaleFactor, + isPrimary: capturer.isPrimary, + }); +}); + +capturer.captureArea(300, 300, 300, 300, false).then((buffer) => { + writeFile(`temp-captureArea-${capturer.id}.png`, buffer); +}); diff --git a/index.d.ts b/index.d.ts index 00ad4a9..c85d321 100644 --- a/index.d.ts +++ b/index.d.ts @@ -14,8 +14,8 @@ export class Screenshots { isPrimary: boolean static all(): Array static fromPoint(x: number, y: number): Screenshots | null - captureSync(): Buffer - capture(): Promise - captureAreaSync(x: number, y: number, width: number, height: number): Buffer - captureArea(x: number, y: number, width: number, height: number): Promise + captureSync(copyOutputData?: boolean | undefined | null): Buffer + capture(copyOutputData?: boolean | undefined | null): Promise + captureAreaSync(x: number, y: number, width: number, height: number, copyOutputData?: boolean | undefined | null): Buffer + captureArea(x: number, y: number, width: number, height: number, copyOutputData?: boolean | undefined | null): Promise } diff --git a/index.js b/index.js index 6843ef6..3453b54 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ function isMusl() { // For Node 10 if (!process.report || typeof process.report.getReport !== 'function') { try { - const lddPath = require('child_process').execSync('which ldd').toString().trim(); + const lddPath = require('child_process').execSync('which ldd').toString().trim() return readFileSync(lddPath, 'utf8').includes('musl') } catch (e) { return true diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index 061373e..dd03b97 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,18 +1,18 @@ { - "name": "node-screenshots-darwin-arm64", - "version": "0.0.0", - "os": [ - "darwin" - ], - "cpu": [ - "arm64" - ], - "main": "node-screenshots.darwin-arm64.node", - "files": [ - "node-screenshots.darwin-arm64.node" - ], - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - } + "name": "node-screenshots-darwin-arm64", + "version": "0.0.0", + "os": [ + "darwin" + ], + "cpu": [ + "arm64" + ], + "main": "node-screenshots.darwin-arm64.node", + "files": [ + "node-screenshots.darwin-arm64.node" + ], + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + } } diff --git a/npm/darwin-universal/package.json b/npm/darwin-universal/package.json index 2ecdbd4..eaa0bad 100644 --- a/npm/darwin-universal/package.json +++ b/npm/darwin-universal/package.json @@ -1,15 +1,15 @@ { - "name": "node-screenshots-darwin-universal", - "version": "0.0.0", - "os": [ - "darwin" - ], - "main": "node-screenshots.darwin-universal.node", - "files": [ - "node-screenshots.darwin-universal.node" - ], - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - } + "name": "node-screenshots-darwin-universal", + "version": "0.0.0", + "os": [ + "darwin" + ], + "main": "node-screenshots.darwin-universal.node", + "files": [ + "node-screenshots.darwin-universal.node" + ], + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + } } diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index 45d9806..13579b3 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,18 +1,18 @@ { - "name": "node-screenshots-darwin-x64", - "version": "0.0.0", - "os": [ - "darwin" - ], - "cpu": [ - "x64" - ], - "main": "node-screenshots.darwin-x64.node", - "files": [ - "node-screenshots.darwin-x64.node" - ], - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - } + "name": "node-screenshots-darwin-x64", + "version": "0.0.0", + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ], + "main": "node-screenshots.darwin-x64.node", + "files": [ + "node-screenshots.darwin-x64.node" + ], + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + } } diff --git a/npm/linux-arm64-gnu/package.json b/npm/linux-arm64-gnu/package.json index dda0e0c..90c4e0e 100644 --- a/npm/linux-arm64-gnu/package.json +++ b/npm/linux-arm64-gnu/package.json @@ -1,21 +1,21 @@ { - "name": "node-screenshots-linux-arm64-gnu", - "version": "0.0.0", - "os": [ - "linux" - ], - "cpu": [ - "arm64" - ], - "main": "node-screenshots.linux-arm64-gnu.node", - "files": [ - "node-screenshots.linux-arm64-gnu.node" - ], - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - }, - "libc": [ - "glibc" - ] + "name": "node-screenshots-linux-arm64-gnu", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "arm64" + ], + "main": "node-screenshots.linux-arm64-gnu.node", + "files": [ + "node-screenshots.linux-arm64-gnu.node" + ], + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + }, + "libc": [ + "glibc" + ] } diff --git a/npm/linux-arm64-musl/package.json b/npm/linux-arm64-musl/package.json index 2b6a007..1ea17c1 100644 --- a/npm/linux-arm64-musl/package.json +++ b/npm/linux-arm64-musl/package.json @@ -1,21 +1,21 @@ { - "name": "node-screenshots-linux-arm64-musl", - "version": "0.0.0", - "os": [ - "linux" - ], - "cpu": [ - "arm64" - ], - "main": "node-screenshots.linux-arm64-musl.node", - "files": [ - "node-screenshots.linux-arm64-musl.node" - ], - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - }, - "libc": [ - "musl" - ] + "name": "node-screenshots-linux-arm64-musl", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "arm64" + ], + "main": "node-screenshots.linux-arm64-musl.node", + "files": [ + "node-screenshots.linux-arm64-musl.node" + ], + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + }, + "libc": [ + "musl" + ] } diff --git a/npm/linux-x64-gnu/package.json b/npm/linux-x64-gnu/package.json index 213297e..5393ecc 100644 --- a/npm/linux-x64-gnu/package.json +++ b/npm/linux-x64-gnu/package.json @@ -1,21 +1,21 @@ { - "name": "node-screenshots-linux-x64-gnu", - "version": "0.0.0", - "os": [ - "linux" - ], - "cpu": [ - "x64" - ], - "main": "node-screenshots.linux-x64-gnu.node", - "files": [ - "node-screenshots.linux-x64-gnu.node" - ], - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - }, - "libc": [ - "glibc" - ] + "name": "node-screenshots-linux-x64-gnu", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "main": "node-screenshots.linux-x64-gnu.node", + "files": [ + "node-screenshots.linux-x64-gnu.node" + ], + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + }, + "libc": [ + "glibc" + ] } diff --git a/npm/linux-x64-musl/package.json b/npm/linux-x64-musl/package.json index cc20230..799fffc 100644 --- a/npm/linux-x64-musl/package.json +++ b/npm/linux-x64-musl/package.json @@ -1,21 +1,21 @@ { - "name": "node-screenshots-linux-x64-musl", - "version": "0.0.0", - "os": [ - "linux" - ], - "cpu": [ - "x64" - ], - "main": "node-screenshots.linux-x64-musl.node", - "files": [ - "node-screenshots.linux-x64-musl.node" - ], - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - }, - "libc": [ - "musl" - ] + "name": "node-screenshots-linux-x64-musl", + "version": "0.0.0", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "main": "node-screenshots.linux-x64-musl.node", + "files": [ + "node-screenshots.linux-x64-musl.node" + ], + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + }, + "libc": [ + "musl" + ] } diff --git a/npm/win32-arm64-msvc/package.json b/npm/win32-arm64-msvc/package.json index e5dbf53..4755875 100644 --- a/npm/win32-arm64-msvc/package.json +++ b/npm/win32-arm64-msvc/package.json @@ -1,18 +1,18 @@ { - "name": "node-screenshots-win32-arm64-msvc", - "version": "0.0.0", - "os": [ - "win32" - ], - "cpu": [ - "arm64" - ], - "main": "node-screenshots.win32-arm64-msvc.node", - "files": [ - "node-screenshots.win32-arm64-msvc.node" - ], - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - } + "name": "node-screenshots-win32-arm64-msvc", + "version": "0.0.0", + "os": [ + "win32" + ], + "cpu": [ + "arm64" + ], + "main": "node-screenshots.win32-arm64-msvc.node", + "files": [ + "node-screenshots.win32-arm64-msvc.node" + ], + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + } } diff --git a/npm/win32-ia32-msvc/package.json b/npm/win32-ia32-msvc/package.json index 7f31532..bf1c6fc 100644 --- a/npm/win32-ia32-msvc/package.json +++ b/npm/win32-ia32-msvc/package.json @@ -1,18 +1,18 @@ { - "name": "node-screenshots-win32-ia32-msvc", - "version": "0.0.0", - "os": [ - "win32" - ], - "cpu": [ - "ia32" - ], - "main": "node-screenshots.win32-ia32-msvc.node", - "files": [ - "node-screenshots.win32-ia32-msvc.node" - ], - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - } + "name": "node-screenshots-win32-ia32-msvc", + "version": "0.0.0", + "os": [ + "win32" + ], + "cpu": [ + "ia32" + ], + "main": "node-screenshots.win32-ia32-msvc.node", + "files": [ + "node-screenshots.win32-ia32-msvc.node" + ], + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + } } diff --git a/npm/win32-x64-msvc/package.json b/npm/win32-x64-msvc/package.json index 9856621..51d022c 100644 --- a/npm/win32-x64-msvc/package.json +++ b/npm/win32-x64-msvc/package.json @@ -1,18 +1,18 @@ { - "name": "node-screenshots-win32-x64-msvc", - "version": "0.0.0", - "os": [ - "win32" - ], - "cpu": [ - "x64" - ], - "main": "node-screenshots.win32-x64-msvc.node", - "files": [ - "node-screenshots.win32-x64-msvc.node" - ], - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - } + "name": "node-screenshots-win32-x64-msvc", + "version": "0.0.0", + "os": [ + "win32" + ], + "cpu": [ + "x64" + ], + "main": "node-screenshots.win32-x64-msvc.node", + "files": [ + "node-screenshots.win32-x64-msvc.node" + ], + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + } } diff --git a/package.json b/package.json index 3dc60f1..d924ba0 100644 --- a/package.json +++ b/package.json @@ -1,40 +1,40 @@ { - "name": "node-screenshots", - "version": "0.1.6", - "main": "index.js", - "types": "index.d.ts", - "files": [ - "index.js", - "index.d.ts" - ], - "scripts": { - "artifacts": "napi artifacts", - "build": "napi build --platform --release", - "build:debug": "napi build --platform", - "prepublishOnly": "napi prepublish -t npm", - "test": "ava", - "universal": "napi universal", - "version": "napi version" - }, - "napi": { "name": "node-screenshots", - "triples": { - "additional": [ - "aarch64-apple-darwin", - "aarch64-pc-windows-msvc", - "x86_64-unknown-linux-musl", - "i686-pc-windows-msvc", - "universal-apple-darwin" - ] + "version": "0.1.7", + "main": "index.js", + "types": "index.d.ts", + "files": [ + "index.js", + "index.d.ts" + ], + "scripts": { + "artifacts": "napi artifacts", + "build": "napi build --platform --release", + "build:debug": "napi build --platform", + "prepublishOnly": "napi prepublish -t npm", + "test": "ava", + "universal": "napi universal", + "version": "napi version" + }, + "napi": { + "name": "node-screenshots", + "triples": { + "additional": [ + "aarch64-apple-darwin", + "aarch64-pc-windows-msvc", + "x86_64-unknown-linux-musl", + "i686-pc-windows-msvc", + "universal-apple-darwin" + ] + } + }, + "license": "Apache-2.0", + "engines": { + "node": ">= 10" + }, + "packageManager": "yarn@3.5.0", + "devDependencies": { + "@napi-rs/cli": "^2.16.3", + "ava": "^5.3.1" } - }, - "license": "Apache-2.0", - "engines": { - "node": ">= 10" - }, - "packageManager": "yarn@3.5.0", - "devDependencies": { - "@napi-rs/cli": "^2.15.2", - "ava": "^5.1.1" - } } diff --git a/rustfmt.toml b/rustfmt.toml index cab5731..3a26366 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1 @@ -tab_spaces = 2 edition = "2021" diff --git a/src/lib.rs b/src/lib.rs index 41260ef..7b85343 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,149 +4,178 @@ extern crate napi_derive; use napi::{ - bindgen_prelude::{AsyncTask, Error, Result}, - Env, JsBuffer, Task, + bindgen_prelude::{AsyncTask, Error, Result}, + Env, JsBuffer, Task, }; -use screenshots::Screen; +use screenshots::{ + image::{codecs::png::PngEncoder, RgbaImage}, + Screen, +}; use std::thread; -#[napi] -#[derive(Debug)] -pub struct Screenshots { - screen: Screen, - pub id: u32, - pub x: i32, - pub y: i32, - pub width: u32, - pub height: u32, - pub rotation: f64, - pub scale_factor: f64, - pub is_primary: bool, +fn rgba_image_to_bytes(rgba_image: RgbaImage) -> Result> { + let mut bytes = Vec::new(); + let encoder = PngEncoder::new(&mut bytes); + + rgba_image + .write_with_encoder(encoder) + .map_err(|err| Error::from_reason(err.to_string()))?; + + Ok(bytes) +} + +fn bytes_to_buffer(env: Env, bytes: Vec, copy_output_data: Option) -> Result { + let buffer = if copy_output_data == Some(true) { + env.create_buffer_copy(bytes)? + } else { + env.create_buffer_with_data(bytes)? + }; + + Ok(buffer.into_raw()) } pub struct AsyncCapture { - screen: Screen, - area: Option<(i32, i32, u32, u32)>, + screen: Screen, + area: Option<(i32, i32, u32, u32)>, + copy_output_data: Option, } #[napi] impl Task for AsyncCapture { - type Output = Vec; - type JsValue = JsBuffer; - - fn compute(&mut self) -> Result { - let AsyncCapture { screen, area } = *self; - let handle = thread::spawn(move || { - let image = if let Some((x, y, width, height)) = area { - screen - .capture_area(x, y, width, height) - .map_err(|err| Error::from_reason(err.to_string()))? - .to_png(None) - .map_err(|err| Error::from_reason(err.to_string()))? - } else { - screen - .capture() - .map_err(|err| Error::from_reason(err.to_string()))? - .to_png(None) - .map_err(|err| Error::from_reason(err.to_string()))? - }; - - Ok(image) - }); - - handle - .join() - .map_err(|_| Error::from_reason(String::from("Async Capture failed")))? - } - - fn resolve(&mut self, env: Env, output: Self::Output) -> Result { - let buffer = env.create_buffer_copy(output)?; - Ok(buffer.into_raw()) - } + type Output = Vec; + type JsValue = JsBuffer; + + fn compute(&mut self) -> Result { + let screen = self.screen; + let area = self.area; + + let handle = thread::spawn(move || { + let rgba_image = if let Some((x, y, width, height)) = area { + screen + .capture_area(x, y, width, height) + .map_err(|err| Error::from_reason(err.to_string()))? + } else { + screen + .capture() + .map_err(|err| Error::from_reason(err.to_string()))? + }; + + rgba_image_to_bytes(rgba_image) + }); + + handle + .join() + .map_err(|_| Error::from_reason(String::from("Async Capture failed")))? + } + + fn resolve(&mut self, env: Env, output: Self::Output) -> Result { + bytes_to_buffer(env, output, self.copy_output_data) + } +} + +#[napi] +#[derive(Debug)] +pub struct Screenshots { + screen: Screen, + pub id: u32, + pub x: i32, + pub y: i32, + pub width: u32, + pub height: u32, + pub rotation: f64, + pub scale_factor: f64, + pub is_primary: bool, } #[napi] impl Screenshots { - fn new(screen: &Screen) -> Self { - let display_info = screen.display_info; - - Screenshots { - screen: *screen, - id: display_info.id, - x: display_info.x, - y: display_info.y, - width: display_info.width, - height: display_info.height, - rotation: display_info.rotation as f64, - scale_factor: display_info.scale_factor as f64, - is_primary: display_info.is_primary, + fn new(screen: &Screen) -> Self { + let display_info = screen.display_info; + + Screenshots { + screen: *screen, + id: display_info.id, + x: display_info.x, + y: display_info.y, + width: display_info.width, + height: display_info.height, + rotation: display_info.rotation as f64, + scale_factor: display_info.scale_factor as f64, + is_primary: display_info.is_primary, + } } - } - #[napi] - pub fn all() -> Result> { - let screens = Screen::all() - .map_err(|e| Error::from_reason(e.to_string()))? - .iter() - .map(Screenshots::new) - .collect(); - - Ok(screens) - } - - #[napi] - pub fn from_point(x: i32, y: i32) -> Option { - let screen = Screen::from_point(x, y).ok()?; - - Some(Screenshots::new(&screen)) - } - - #[napi] - pub fn capture_sync(&self, env: Env) -> Result { - let image = self - .screen - .capture() - .map_err(|e| Error::from_reason(e.to_string()))? - .to_png(None) - .map_err(|err| Error::from_reason(err.to_string()))?; - let buffer = env.create_buffer_copy(image)?; - Ok(buffer.into_raw()) - } - - #[napi] - pub fn capture(&self) -> AsyncTask { - AsyncTask::new(AsyncCapture { - screen: self.screen, - area: None, - }) - } - - #[napi] - pub fn capture_area_sync( - &self, - env: Env, - x: i32, - y: i32, - width: u32, - height: u32, - ) -> Result { - let image = self - .screen - .capture_area(x, y, width, height) - .map_err(|e| Error::from_reason(e.to_string()))? - .to_png(None) - .map_err(|err| Error::from_reason(err.to_string()))?; - let buffer = env.create_buffer_copy(image)?; + #[napi] + pub fn all() -> Result> { + let screens = Screen::all() + .map_err(|e| Error::from_reason(e.to_string()))? + .iter() + .map(Screenshots::new) + .collect(); - Ok(buffer.into_raw()) - } - - #[napi] - pub fn capture_area(&self, x: i32, y: i32, width: u32, height: u32) -> AsyncTask { - AsyncTask::new(AsyncCapture { - screen: self.screen, - area: Some((x, y, width, height)), - }) - } + Ok(screens) + } + + #[napi] + pub fn from_point(x: i32, y: i32) -> Option { + let screen = Screen::from_point(x, y).ok()?; + + Some(Screenshots::new(&screen)) + } + + #[napi] + pub fn capture_sync(&self, env: Env, copy_output_data: Option) -> Result { + let rgba_image = self + .screen + .capture() + .map_err(|err| Error::from_reason(err.to_string()))?; + + let bytes = rgba_image_to_bytes(rgba_image)?; + bytes_to_buffer(env, bytes, copy_output_data) + } + + #[napi] + pub fn capture(&self, copy_output_data: Option) -> AsyncTask { + AsyncTask::new(AsyncCapture { + screen: self.screen, + area: None, + copy_output_data, + }) + } + + #[napi] + pub fn capture_area_sync( + &self, + env: Env, + x: i32, + y: i32, + width: u32, + height: u32, + copy_output_data: Option, + ) -> Result { + let rgba_image = self + .screen + .capture_area(x, y, width, height) + .map_err(|err| Error::from_reason(err.to_string()))?; + + let bytes = rgba_image_to_bytes(rgba_image)?; + bytes_to_buffer(env, bytes, copy_output_data) + } + + #[napi] + pub fn capture_area( + &self, + x: i32, + y: i32, + width: u32, + height: u32, + copy_output_data: Option, + ) -> AsyncTask { + AsyncTask::new(AsyncCapture { + screen: self.screen, + area: Some((x, y, width, height)), + copy_output_data, + }) + } } diff --git a/yarn.lock b/yarn.lock index 9784ca4..70948f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,12 +12,12 @@ __metadata: languageName: node linkType: hard -"@napi-rs/cli@npm:^2.15.2": - version: 2.15.2 - resolution: "@napi-rs/cli@npm:2.15.2" +"@napi-rs/cli@npm:^2.16.3": + version: 2.16.3 + resolution: "@napi-rs/cli@npm:2.16.3" bin: napi: scripts/index.js - checksum: dedcbd339f634e4a4c442febbfaee7c0fd907f3b8082c1f3ddba18b0e02ae2f0e4bff75688763669db5fb1a0f5ab26a7200cb6c01fe8825effd0a70a44bcbbc7 + checksum: 11f78b09548bc5c22df56e4fab4a87b68c2d3f2a18a55cf11e775e6a4cb5739ec0e21a14e614db2cdc2b9773cb42536c6bd00c3f85d3b461f956594f8a89ddcb languageName: node linkType: hard @@ -89,12 +89,12 @@ __metadata: languageName: node linkType: hard -"acorn@npm:^8.8.1": - version: 8.8.1 - resolution: "acorn@npm:8.8.1" +"acorn@npm:^8.8.2": + version: 8.10.0 + resolution: "acorn@npm:8.10.0" bin: acorn: bin/acorn - checksum: 4079b67283b94935157698831967642f24a075c52ce3feaaaafe095776dfbe15d86a1b33b1e53860fc0d062ed6c83f4284a5c87c85b9ad51853a01173da6097f + checksum: 538ba38af0cc9e5ef983aee196c4b8b4d87c0c94532334fa7e065b2c8a1f85863467bb774231aae91613fcda5e68740c15d97b1967ae3394d20faddddd8af61d languageName: node linkType: hard @@ -225,11 +225,11 @@ __metadata: languageName: node linkType: hard -"ava@npm:^5.1.1": - version: 5.2.0 - resolution: "ava@npm:5.2.0" +"ava@npm:^5.3.1": + version: 5.3.1 + resolution: "ava@npm:5.3.1" dependencies: - acorn: ^8.8.1 + acorn: ^8.8.2 acorn-walk: ^8.2.0 ansi-styles: ^6.2.1 arrgv: ^1.0.2 @@ -239,7 +239,7 @@ __metadata: chalk: ^5.2.0 chokidar: ^3.5.3 chunkd: ^2.0.1 - ci-info: ^3.7.1 + ci-info: ^3.8.0 ci-parallel-vars: ^1.0.1 clean-yaml-object: ^0.1.0 cli-truncate: ^3.1.0 @@ -248,10 +248,9 @@ __metadata: concordance: ^5.0.4 currently-unhandled: ^0.4.1 debug: ^4.3.4 - del: ^7.0.0 emittery: ^1.0.1 figures: ^5.0.0 - globby: ^13.1.3 + globby: ^13.1.4 ignore-by-default: ^2.1.0 indent-string: ^5.0.0 is-error: ^2.2.2 @@ -267,13 +266,12 @@ __metadata: plur: ^5.1.0 pretty-ms: ^8.0.0 resolve-cwd: ^3.0.0 - slash: ^3.0.0 stack-utils: ^2.0.6 strip-ansi: ^7.0.1 supertap: ^3.0.1 temp-dir: ^3.0.0 - write-file-atomic: ^5.0.0 - yargs: ^17.6.2 + write-file-atomic: ^5.0.1 + yargs: ^17.7.2 peerDependencies: "@ava/typescript": "*" peerDependenciesMeta: @@ -281,7 +279,7 @@ __metadata: optional: true bin: ava: entrypoints/cli.mjs - checksum: d5991f1f3d7ca0e63e0df185c5c025a9c80614dd42537336a9b96ea29e8a8d5ad680c1e775dacabb55f3b1b2d63764e468f201d52a44166c8a88d4e9309cde61 + checksum: 126a5932baef74eccd8bec992bd522e25c05b6ee4985dde87c20cece76c2377f0bf9448f242f3f9cd2abbf7a5ac932fe4e4abde2a23792d6271a6088e5a1984e languageName: node linkType: hard @@ -416,10 +414,10 @@ __metadata: languageName: node linkType: hard -"ci-info@npm:^3.7.1": - version: 3.7.1 - resolution: "ci-info@npm:3.7.1" - checksum: 72d93d5101ea1c186511277fbd8d06ae8a6e028cc2fb94361e92bf735b39c5ebd192e8d15a66ff8c4e3ed569f87c2f844e96f90e141b2de5c649f77ec34ff601 +"ci-info@npm:^3.8.0": + version: 3.8.0 + resolution: "ci-info@npm:3.8.0" + checksum: d0a4d3160497cae54294974a7246202244fff031b0a6ea20dd57b10ec510aa17399c41a1b0982142c105f3255aff2173e5c0dd7302ee1b2f28ba3debda375098 languageName: node linkType: hard @@ -582,22 +580,6 @@ __metadata: languageName: node linkType: hard -"del@npm:^7.0.0": - version: 7.0.0 - resolution: "del@npm:7.0.0" - dependencies: - globby: ^13.1.2 - graceful-fs: ^4.2.10 - is-glob: ^4.0.3 - is-path-cwd: ^3.0.0 - is-path-inside: ^4.0.0 - p-map: ^5.5.0 - rimraf: ^3.0.2 - slash: ^4.0.0 - checksum: 33e5077f18b5dfbe81971d1f8a2cd8bf676dd5ede491bab85ec17a4a1d59001bd3ec47fd38e9a4ae01a3c98c07b98c7b3dc56190b86d88926798802d7858d827 - languageName: node - linkType: hard - "delegates@npm:^1.0.0": version: 1.0.0 resolution: "delegates@npm:1.0.0" @@ -717,16 +699,16 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:^3.2.11": - version: 3.2.12 - resolution: "fast-glob@npm:3.2.12" +"fast-glob@npm:^3.3.0": + version: 3.3.1 + resolution: "fast-glob@npm:3.3.1" dependencies: "@nodelib/fs.stat": ^2.0.2 "@nodelib/fs.walk": ^1.2.3 glob-parent: ^5.1.2 merge2: ^1.3.0 micromatch: ^4.0.4 - checksum: 0b1990f6ce831c7e28c4d505edcdaad8e27e88ab9fa65eedadb730438cfc7cde4910d6c975d6b7b8dc8a73da4773702ebcfcd6e3518e73938bb1383badfe01c2 + checksum: b6f3add6403e02cf3a798bfbb1183d0f6da2afd368f27456010c0bc1f9640aea308243d4cb2c0ab142f618276e65ecb8be1661d7c62a7b4e5ba774b9ce5432e5 languageName: node linkType: hard @@ -862,33 +844,20 @@ __metadata: languageName: node linkType: hard -"globby@npm:^13.1.2": - version: 13.1.2 - resolution: "globby@npm:13.1.2" - dependencies: - dir-glob: ^3.0.1 - fast-glob: ^3.2.11 - ignore: ^5.2.0 - merge2: ^1.4.1 - slash: ^4.0.0 - checksum: c148fcda0c981f00fb434bb94ca258f0a9d23cedbde6fb3f37098e1abde5b065019e2c63fe2aa2fad4daf2b54bf360b4d0423d85fb3a63d09ed75a2837d4de0f - languageName: node - linkType: hard - -"globby@npm:^13.1.3": - version: 13.1.3 - resolution: "globby@npm:13.1.3" +"globby@npm:^13.1.4": + version: 13.2.2 + resolution: "globby@npm:13.2.2" dependencies: dir-glob: ^3.0.1 - fast-glob: ^3.2.11 - ignore: ^5.2.0 + fast-glob: ^3.3.0 + ignore: ^5.2.4 merge2: ^1.4.1 slash: ^4.0.0 - checksum: 93f06e02002cdf368f7e3d55bd59e7b00784c7cc8fe92c7ee5082cc7171ff6109fda45e1c97a80bb48bc811dedaf7843c7c9186f5f84bde4883ab630e13c43df + checksum: f3d84ced58a901b4fcc29c846983108c426631fe47e94872868b65565495f7bee7b3defd68923bd480582771fd4bbe819217803a164a618ad76f1d22f666f41e languageName: node linkType: hard -"graceful-fs@npm:^4.2.10, graceful-fs@npm:^4.2.6": +"graceful-fs@npm:^4.2.6": version: 4.2.10 resolution: "graceful-fs@npm:4.2.10" checksum: 3f109d70ae123951905d85032ebeae3c2a5a7a997430df00ea30df0e3a6c60cf6689b109654d6fdacd28810a053348c4d14642da1d075049e6be1ba5216218da @@ -955,10 +924,10 @@ __metadata: languageName: node linkType: hard -"ignore@npm:^5.2.0": - version: 5.2.1 - resolution: "ignore@npm:5.2.1" - checksum: 7251d00cba49fe88c4f3565fadeb4aa726ba38294a9a79ffed542edc47bafd989d4b2ccf65700c5b1b26a1e91dfc7218fb23017937c79216025d5caeec0ee9d5 +"ignore@npm:^5.2.4": + version: 5.2.4 + resolution: "ignore@npm:5.2.4" + checksum: 3d4c309c6006e2621659311783eaea7ebcd41fe4ca1d78c91c473157ad6666a57a2df790fe0d07a12300d9aac2888204d7be8d59f9aaf665b1c7fcdb432517ef languageName: node linkType: hard @@ -1058,7 +1027,7 @@ __metadata: languageName: node linkType: hard -"is-glob@npm:^4.0.1, is-glob@npm:^4.0.3, is-glob@npm:~4.0.1": +"is-glob@npm:^4.0.1, is-glob@npm:~4.0.1": version: 4.0.3 resolution: "is-glob@npm:4.0.3" dependencies: @@ -1081,20 +1050,6 @@ __metadata: languageName: node linkType: hard -"is-path-cwd@npm:^3.0.0": - version: 3.0.0 - resolution: "is-path-cwd@npm:3.0.0" - checksum: bc34d13b6a03dfca4a3ab6a8a5ba78ae4b24f4f1db4b2b031d2760c60d0913bd16a4b980dcb4e590adfc906649d5f5132684079a3972bd219da49deebb9adea8 - languageName: node - linkType: hard - -"is-path-inside@npm:^4.0.0": - version: 4.0.0 - resolution: "is-path-inside@npm:4.0.0" - checksum: 8810fa11c58e6360b82c3e0d6cd7d9c7d0392d3ac9eb10f980b81f9839f40ac6d1d6d6f05d069db0d227759801228f0b072e1b6c343e4469b065ab5fe0b68fe5 - languageName: node - linkType: hard - "is-plain-object@npm:^5.0.0": version: 5.0.0 resolution: "is-plain-object@npm:5.0.0" @@ -1408,8 +1363,8 @@ __metadata: version: 0.0.0-use.local resolution: "node-screenshots@workspace:." dependencies: - "@napi-rs/cli": ^2.15.2 - ava: ^5.1.1 + "@napi-rs/cli": ^2.16.3 + ava: ^5.3.1 languageName: unknown linkType: soft @@ -1730,10 +1685,10 @@ __metadata: languageName: node linkType: hard -"slash@npm:^3.0.0": - version: 3.0.0 - resolution: "slash@npm:3.0.0" - checksum: 94a93fff615f25a999ad4b83c9d5e257a7280c90a32a7cb8b4a87996e4babf322e469c42b7f649fd5796edd8687652f3fb452a86dc97a816f01113183393f11c +"signal-exit@npm:^4.0.1": + version: 4.1.0 + resolution: "signal-exit@npm:4.1.0" + checksum: 64c757b498cb8629ffa5f75485340594d2f8189e9b08700e69199069c8e3070fb3e255f7ab873c05dc0b3cec412aea7402e10a5990cb6a050bd33ba062a6c549 languageName: node linkType: hard @@ -1982,13 +1937,13 @@ __metadata: languageName: node linkType: hard -"write-file-atomic@npm:^5.0.0": - version: 5.0.0 - resolution: "write-file-atomic@npm:5.0.0" +"write-file-atomic@npm:^5.0.1": + version: 5.0.1 + resolution: "write-file-atomic@npm:5.0.1" dependencies: imurmurhash: ^0.1.4 - signal-exit: ^3.0.7 - checksum: 6ee16b195572386cb1c905f9d29808f77f4de2fd063d74a6f1ab6b566363832d8906a493b764ee715e57ab497271d5fc91642a913724960e8e845adf504a9837 + signal-exit: ^4.0.1 + checksum: 8dbb0e2512c2f72ccc20ccedab9986c7d02d04039ed6e8780c987dc4940b793339c50172a1008eed7747001bfacc0ca47562668a069a7506c46c77d7ba3926a9 languageName: node linkType: hard @@ -2013,9 +1968,9 @@ __metadata: languageName: node linkType: hard -"yargs@npm:^17.6.2": - version: 17.6.2 - resolution: "yargs@npm:17.6.2" +"yargs@npm:^17.7.2": + version: 17.7.2 + resolution: "yargs@npm:17.7.2" dependencies: cliui: ^8.0.1 escalade: ^3.1.1 @@ -2024,7 +1979,7 @@ __metadata: string-width: ^4.2.3 y18n: ^5.0.5 yargs-parser: ^21.1.1 - checksum: 47da1b0d854fa16d45a3ded57b716b013b2179022352a5f7467409da5a04a1eef5b3b3d97a2dfc13e8bbe5f2ffc0afe3bc6a4a72f8254e60f5a4bd7947138643 + checksum: 73b572e863aa4a8cbef323dd911d79d193b772defd5a51aab0aca2d446655216f5002c42c5306033968193bdbf892a7a4c110b0d77954a7fdf563e653967b56a languageName: node linkType: hard