diff --git a/.eslintignore b/.eslintignore deleted file mode 120000 index 3e4e48b..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -.gitignore \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index e3e89d2..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,48 +0,0 @@ -const copyrightTemplate = `/* - * Copyright (c) 2018-Present, Spotify AB. - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -`; - -module.exports = { - extends: [ - //"plugin:@typescript-eslint/recommended", - 'prettier', - 'prettier/@typescript-eslint' - ], - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint', 'notice'], - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - ecmaFeatures: { - jsx: true - } - }, - rules: { - 'notice/notice': [ - 'error', - { - template: copyrightTemplate, - onNonMatchingHeader: 'replace' - } - ] - } -}; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9792a90 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: ci + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + with: + node-version: 22 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm typecheck + - run: pnpm lint + - run: pnpm test + - run: pnpm build + - run: pnpm validate + - name: Build demo + working-directory: demo + run: pnpm build diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..e60b083 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,48 @@ +name: pages + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + with: + node-version: 22 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm build + - name: Build demo + working-directory: demo + run: pnpm build + - uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 + - uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 + with: + path: demo/dist + + deploy: + needs: build + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b040ff0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: release + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + environment: npm + permissions: + contents: read + id-token: write # npm provenance + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 + - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 + with: + node-version: 22 + cache: pnpm + registry-url: https://registry.npmjs.org + - run: pnpm install --frozen-lockfile + - run: pnpm typecheck + - run: pnpm test + - run: pnpm build + - run: pnpm validate + - run: pnpm publish --provenance --access public --no-git-checks + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index e6d416e..e050d08 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ dist-debug .cache-demo demo/.cache coverage +*.tgz +demo/monaco-declarations/*.d.ts +test-results diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..5ee7abd --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +pnpm exec lint-staged diff --git a/.pinact.yaml b/.pinact.yaml new file mode 100644 index 0000000..a57366d --- /dev/null +++ b/.pinact.yaml @@ -0,0 +1,5 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/suzuki-shunsuke/pinact/refs/heads/main/json-schema/pinact.json +# pinact - https://github.com/suzuki-shunsuke/pinact +version: 3 +min_age: + value: 7 diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..544138b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": true +} diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index bdf6f9a..0000000 --- a/.prettierrc.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - singleQuote: true -}; \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1355964..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: node_js -before_install: -- npm i -g npm@6.8 -cache: npm -node_js: -- '10' -script: -- npm run setup:ci -- npm run build -- npm test -- --coverage -- npm run predeploy:demo -deploy: - - provider: npm - email: kibysayshi@gmail.com - skip_cleanup: true - api_key: - secure: LFF+TBDO2lguN5rpciP09qUKWIoVVWA2arapTtX+zGMZHBa7QmDV+iBDZSLkf+5iJAgrgXsehIazXyQ7HKDad59y5kjJBOtQOqcSkENn1RTx10FHGvH/lrsO6FxLa5JD0r2cd9KdUjz2EC+4AlgrJo8wr6SKA2/cNOZ2gMVV/6cZVS/sPWfDx9Y1EDQwWlT+74G/vj4FFI+cuHQ2t28aywguaYdMQXPlORo0hXOde4JysewvO2mXcP9viMLg2qckEOeNo0ONDoQtJc4ZDJo7AmOqKmbf14sUQU04ejaw4RLveTe+ebkLYFKC72ABR0RN/VJIlUR78MZXTpJ9tM9A3iLRz1J4ca++3HQMcHQKOG+4P6lSk3bjyUg2pqrYLeUVzAoDIBABJUy0rbhiDMluKiPizO+Y9MmBf57d68+Ks+7ptDuVdYu6J01oyep0D2Mx25IlpgVOORMY05K1CbbWKNAdL8zn54SifqbCDVfDRgrMD0+iQC2D8gKMtOhap3OwtZWOEysUf5wwDz4cEzaeDcL5iOPwxKc6CpjyhdchJDxWozZTA+2wtSAUoddQ4c/iQM1FFQYQ5IugdVOA4/f66aWGftT0CzImT4jC1EHFF6QqAC5R5NAmpt6WaHDt3T/kmSIwXpDxnVq80nzK4t6k1VYjjQhum+IYMq1bx3g6DOM= - on: - tags: true - repo: spotify/NFPlayerJS - branch: main - - provider: pages - github-token: $GITHUB_TOKEN - skip_cleanup: true - keep-history: true - local-dir: demo/dist/ - on: - branch: main diff --git a/README.md b/README.md index ef3ef60..5fcc407 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,15 @@
[](LICENSE) -[](https://slackin.spotify.com) -[](http://clayallsopp.github.io/readme-score?url=https://github.com/spotify/NFPlayerJS) A JavaScript/TypeScript audio engine for the Web and Server capable of multitrack time stretching, pitch shifting, declarative effects, faster than realtime processing, and more! -Developed at Spotify 2017-2018, Discontinued and handed over to new maintainers January 2023 +Developed at Spotify 2017-2018, Discontinued and handed over to new maintainers January 2023 # Getting Started (Browser) 🚀 -1. Install the player: `npm install --save nf-player` -2. Describe your audio experience using [NFGrapher][nfgrapher] `npm install --save nf-grapher`, or use a prebuilt [JSON Score](./fixtures). +1. Install the player: `pnpm add nf-player` +2. Describe your audio experience using [NFGrapher][nfgrapher] (`pnpm add nf-grapher`), or use a prebuilt [JSON Score](./fixtures). 3. Listen to it! ```js @@ -22,7 +20,7 @@ Developed at Spotify 2017-2018, Discontinued and handed over to new maintainers import { SmartPlayer, TimeInstant } from 'nf-player'; import * as ScoreJSON from './your-score.json'; -(async function() { +(async function () { // Create player. By default it uses Web Audio to insert audio data into // the current audio device. const p = new SmartPlayer(); @@ -47,7 +45,7 @@ There are also in-progress [API Docs][api docs]. A [CLI](./src/cli.ts) also ships with this package! ```sh -$ npx nf-player save --duration 120 --input-file ./fixtures/roxanne-30s-preview-shifted-infinite.json --output-file ./roxanne.wav +$ pnpm dlx nf-player save --duration 120 --input-file ./fixtures/roxanne-30s-preview-shifted-infinite.json --output-file ./roxanne.wav ``` The above command will load the Score JSON, download the audio files, and render 120 seconds of audio to a file called `tng.wav`. This should happen in about 5 seconds of realtime, depending on your computer and internet connection. @@ -117,42 +115,46 @@ See the [Playground][playground]! # Development 🏗 -Clone this repo, then: +Requires Node ≥20 and [pnpm](https://pnpm.io/). ```sh -$ npm install +$ pnpm install # installs the package + the demo workspace +$ pnpm build # build the library (tsdown → dist/, ESM + CJS + .d.ts) +$ pnpm test # vitest +$ pnpm typecheck # tsc -b (whole solution) +$ pnpm lint ``` -To build the library and start the development environment: +To run the demo / playground locally: ```sh -$ npm start +$ pnpm --filter ./demo dev ``` -To build and publish the demo to [gh-pages](playground) manually, run: +The demo also exposes a cut-down debug entry at `demo/debug.html` (source: `demo/src/debug.ts`) for poking at single Scores or scripts. -```sh -$ npm run deploy:demo:manual -``` +# Deployment / Publishing / Release 🚢 -Otherwise the demo is actually built and deployed on each push to main. +### Publishing: -There is also a more cut-down [debug environment](./debug-harness/index.ts) useful for debugging / developing single Scores or scripts: +1. Bump the version: `pnpm version