diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5d12634 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# 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 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 6c12b9c..0311546 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -87,7 +87,7 @@ Once all feedback is addressed and the PR is approved, we'll ensure the branch i #### Post-Merge Recognition -Once your PR is merged, if you haven't yet been added to the [_Contributors_ table in the README.md](../README.md#contributors) for its [type of contribution](https://allcontributors.org/docs/en/emoji-key "Allcontributors emoji key"), you should be soon. +Once your PR is merged, if you haven't yet been added to the [_Contributors_ table in the README.md](../README.md#contributors) for its [type of contribution](https://allcontributors.org/docs/en/emoji-key 'Allcontributors emoji key'), you should be soon. Please do ping the maintainer who merged your PR if that doesn't happen within 24 hours - it was likely an oversight on our end! ## Emojis & Appreciation diff --git a/.github/DEVELOPMENT.md b/.github/DEVELOPMENT.md index 470b01d..a7ae3ff 100644 --- a/.github/DEVELOPMENT.md +++ b/.github/DEVELOPMENT.md @@ -3,17 +3,18 @@ After [forking the repo from GitHub](https://help.github.com/articles/fork-a-repo) and [installing npm](https://npm.io/installation): ```shell -git clone https://github.com/ < your-name-here > /impvol +git clone https://github.com/boneskull/impvol cd impvol npm install ``` +> [!TIP] > This repository includes a list of suggested VS Code extensions. > It's a good idea to use [VS Code](https://code.visualstudio.com) and accept its suggestion to install them, as they'll help with development. ## Building -Run [**tsup**](https://tsup.egoist.dev) locally to build source files from `src/` into output files in `lib/`: +Run [**tshy**](https://npm.im/tshy) locally to build source files from `src/` into output files in `lib/`: ```shell npm run build @@ -22,18 +23,17 @@ npm run build Add `--watch` to run the builder in a watch mode that continuously cleans and recreates `lib/` as you save files: ```shell -npm run build --watch +npm run build -- --watch ``` ## Formatting -[Prettier](https://prettier.io) is used to format code. -It should be applied automatically when you save files in VS Code or make a Git commit. +[Prettier](https://prettier.io) is used to format code. It should be applied automatically when you save files in VS Code or make a Git commit. To manually reformat all files, you can run: ```shell -npm run format --write +npm run format -- --write ``` ## Linting @@ -51,7 +51,7 @@ Read the individual documentation for each linter to understand how it can be co For example, ESLint can be run with `--fix` to auto-fix some lint rule complaints: ```shell -npm run lint --fix +npm run lint -- --fix ``` Note that you'll likely need to run `npm run build` before `npm run lint` so that lint rules which check the file system can pick up on any built files. @@ -71,3 +71,6 @@ Add `--watch` to keep the type checker running in a watch mode that updates the ```shell npm run tsc --watch ``` + +> [!CAUTION] +> Do not attempt to run `tsc` directly; this will place output files in the wrong location and you'll have to clean them up manually! diff --git a/.github/ISSUE_TEMPLATE/01-bug.yml b/.github/ISSUE_TEMPLATE/01-bug.yml index 9f36870..1f1bb5c 100644 --- a/.github/ISSUE_TEMPLATE/01-bug.yml +++ b/.github/ISSUE_TEMPLATE/01-bug.yml @@ -28,6 +28,6 @@ body: type: textarea description: Report a bug trying to run the code labels: - - "type: bug" + - 'type: bug' name: 🐛 Bug -title: "🐛 Bug: " +title: '🐛 Bug: ' diff --git a/.github/ISSUE_TEMPLATE/02-documentation.yml b/.github/ISSUE_TEMPLATE/02-documentation.yml index 3769900..3160c79 100644 --- a/.github/ISSUE_TEMPLATE/02-documentation.yml +++ b/.github/ISSUE_TEMPLATE/02-documentation.yml @@ -20,6 +20,6 @@ body: type: textarea description: Report a typo or missing area of documentation labels: - - "area: documentation" + - 'area: documentation' name: 📝 Documentation -title: "📝 Documentation: " +title: '📝 Documentation: ' diff --git a/.github/ISSUE_TEMPLATE/03-feature.yml b/.github/ISSUE_TEMPLATE/03-feature.yml index 9607e05..8e634d0 100644 --- a/.github/ISSUE_TEMPLATE/03-feature.yml +++ b/.github/ISSUE_TEMPLATE/03-feature.yml @@ -20,6 +20,6 @@ body: type: textarea description: Request that a new feature be added or an existing feature improved labels: - - "type: feature" + - 'type: feature' name: 🚀 Feature -title: "🚀 Feature: " +title: '🚀 Feature: ' diff --git a/.github/ISSUE_TEMPLATE/04-tooling.yml b/.github/ISSUE_TEMPLATE/04-tooling.yml index cf7015d..c8fd6a2 100644 --- a/.github/ISSUE_TEMPLATE/04-tooling.yml +++ b/.github/ISSUE_TEMPLATE/04-tooling.yml @@ -22,6 +22,6 @@ body: type: textarea description: Report a bug or request an enhancement in repository tooling labels: - - "area: tooling" + - 'area: tooling' name: 🛠 Tooling -title: "🛠 Tooling: " +title: '🛠 Tooling: ' diff --git a/.github/actions/prepare/action.yml b/.github/actions/prepare/action.yml index 1c10c25..5c99658 100644 --- a/.github/actions/prepare/action.yml +++ b/.github/actions/prepare/action.yml @@ -4,13 +4,11 @@ name: Prepare runs: steps: - - uses: pnpm/action-setup@v2 - with: - version: 9 - uses: actions/setup-node@v4 with: - cache: pnpm - node-version: "20" - - run: pnpm install --frozen-lockfile - shell: bash + node-version: '20' + - name: Install dependencies + uses: bahmutov/npm-install@2509f13e8485d88340a789a3f7ca11aaac47c9fc # v1.8.36 + with: + install-command: npm ci --foreground-scripts using: composite diff --git a/.github/renovate.json b/.github/renovate.json index 26f5a6a..0690774 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,9 +1,9 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "automerge": true, - "extends": ["config:best-practices", "replacements:all"], - "ignoreDeps": ["codecov/codecov-action"], - "internalChecksFilter": "strict", - "labels": ["dependencies"], - "minimumReleaseAge": "3 days" + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "automerge": true, + "extends": ["config:best-practices", "replacements:all"], + "ignoreDeps": ["codecov/codecov-action"], + "internalChecksFilter": "strict", + "labels": ["dependencies"], + "minimumReleaseAge": "3 days" } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 057fc54..bc881ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,8 +4,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare - - run: pnpm build - - run: node ./lib/index.js + - run: npm run build name: Build diff --git a/.github/workflows/lint-knip.yml b/.github/workflows/lint-knip.yml index 781d52e..dbe8d9f 100644 --- a/.github/workflows/lint-knip.yml +++ b/.github/workflows/lint-knip.yml @@ -4,7 +4,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare - - run: pnpm lint:knip + - run: npm run lint:knip name: Lint Knip diff --git a/.github/workflows/lint-markdown.yml b/.github/workflows/lint-markdown.yml index acac714..1337e67 100644 --- a/.github/workflows/lint-markdown.yml +++ b/.github/workflows/lint-markdown.yml @@ -4,7 +4,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare - - run: pnpm lint:md + - run: npm run lint:md name: Lint Markdown diff --git a/.github/workflows/lint-spelling.yml b/.github/workflows/lint-spelling.yml index ef020b6..82a9a23 100644 --- a/.github/workflows/lint-spelling.yml +++ b/.github/workflows/lint-spelling.yml @@ -4,7 +4,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare - - run: pnpm lint:spelling + - run: npm run lint:spelling name: Lint spelling diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f174caa..7fc65dc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,7 +4,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare - - run: pnpm lint + - run: npm run lint name: Lint diff --git a/.github/workflows/pr-review-requested.yml b/.github/workflows/pr-review-requested.yml index e2e518c..3124a7f 100644 --- a/.github/workflows/pr-review-requested.yml +++ b/.github/workflows/pr-review-requested.yml @@ -4,7 +4,7 @@ jobs: steps: - uses: actions-ecosystem/action-remove-labels@v1 with: - labels: "status: waiting for author" + labels: 'status: waiting for author' - if: failure() run: | echo "Don't worry if the previous step failed." diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index ae43fc4..a4b279a 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -4,7 +4,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare - - run: pnpm format --list-different + - run: npm run format -- --list-different name: Prettier diff --git a/.github/workflows/tsc.yml b/.github/workflows/tsc.yml index 3b20f24..095177f 100644 --- a/.github/workflows/tsc.yml +++ b/.github/workflows/tsc.yml @@ -4,7 +4,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare - - run: pnpm tsc + - run: npm run tsc name: Type Check diff --git a/.prettierrc.json b/.prettierrc.json index 09eacbf..98a56d1 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,11 +1,17 @@ { "$schema": "http://json.schemastore.org/prettierrc", - "overrides": [{ "files": ".nvmrc", "options": { "parser": "yaml" } }], + "overrides": [{"files": ".nvmrc", "options": {"parser": "yaml"}}], "plugins": [ "prettier-plugin-curly", "prettier-plugin-sh", - "prettier-plugin-packagejson" + "prettier-plugin-organize-imports", + "prettier-plugin-pkg", + "prettier-plugin-jsdoc" ], "useTabs": false, - "singleQuote": true + "singleQuote": true, + "bracketSpacing": false, + "endOfLine": "auto", + "jsdocCommentLineStrategy": "multiline", + "tsdoc": true } diff --git a/eslint.config.js b/eslint.config.js index 7b06825..e4ebcb7 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -75,7 +75,7 @@ export default tseslint.config( '@typescript-eslint/consistent-type-exports': [ 'error', - { fixMixedExportsWithInlineTypeSpecifier: true }, + {fixMixedExportsWithInlineTypeSpecifier: true}, ], '@typescript-eslint/switch-exhaustiveness-check': 'error', @@ -106,7 +106,7 @@ export default tseslint.config( '@stylistic/padding-line-between-statements': [ 'error', - { blankLine: 'always', prev: '*', next: 'export' }, + {blankLine: 'always', prev: '*', next: 'export'}, ], '@stylistic/lines-between-class-members': 'error', @@ -124,7 +124,7 @@ export default tseslint.config( extends: [tseslint.configs.disableTypeChecked], files: ['**/*.md/*.ts'], rules: { - 'n/no-missing-import': ['error', { allowModules: ['impvol'] }], + 'n/no-missing-import': ['error', {allowModules: ['impvol']}], }, }, ); diff --git a/knip.json b/knip.json index d73a20f..e4b32ba 100644 --- a/knip.json +++ b/knip.json @@ -1,6 +1,6 @@ { - "$schema": "https://unpkg.com/knip@latest/schema.json", - "entry": ["src/index.ts!"], - "ignoreExportsUsedInFile": { "interface": true, "type": true }, - "project": ["src/**/*.ts!"] + "$schema": "https://unpkg.com/knip@latest/schema.json", + "entry": ["src/index.ts!"], + "ignoreExportsUsedInFile": {"interface": true, "type": true}, + "project": ["src/**/*.ts!"] } diff --git a/package-lock.json b/package-lock.json index bd87731..e2a72cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,9 @@ "memfs": "^4.9.4", "prettier": "^3.3.3", "prettier-plugin-curly": "^0.2.2", - "prettier-plugin-packagejson": "^2.5.1", + "prettier-plugin-jsdoc": "^1.3.0", + "prettier-plugin-organize-imports": "^4.0.0", + "prettier-plugin-pkg": "^0.18.1", "prettier-plugin-sh": "^0.14.0", "sentences-per-line": "^0.2.1", "tshy": "^3.0.2", @@ -1833,6 +1835,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/binary-searching": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/binary-searching/-/binary-searching-2.0.5.tgz", + "integrity": "sha512-v4N2l3RxL+m4zDxyxz3Ne2aTmiPn8ZUpKFpdPtO+ItW1NcTCXA7JeHG5GMBSvoKSkQZ9ycS+EouDVxYB9ufKWA==", + "dev": true, + "license": "MIT" + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -2328,6 +2337,31 @@ } } }, + "node_modules/decode-named-character-reference": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.0.2.tgz", + "integrity": "sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "character-entities": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/decode-named-character-reference/node_modules/character-entities": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz", + "integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==", + "dev": true, + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -2349,6 +2383,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/detect-indent": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", @@ -2369,6 +2413,20 @@ "node": ">=8" } }, + "node_modules/devlop": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz", + "integrity": "sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==", + "dev": true, + "license": "MIT", + "dependencies": { + "dequal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -4482,6 +4540,433 @@ "parse-entities": "^2.0.0" } }, + "node_modules/micromark-core-commonmark": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-core-commonmark/-/micromark-core-commonmark-2.0.1.tgz", + "integrity": "sha512-CUQyKr1e///ZODyD1U3xit6zXwy1a8q2a1S1HKtIlmgvurrEpaw/Y9y6KSIbF8P59cn/NjzHyO+Q2fAyYLQrAA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-factory-destination": "^2.0.0", + "micromark-factory-label": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-factory-title": "^2.0.0", + "micromark-factory-whitespace": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-classify-character": "^2.0.0", + "micromark-util-html-tag-name": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-destination": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.0.tgz", + "integrity": "sha512-j9DGrQLm/Uhl2tCzcbLhy5kXsgkHUrjJHg4fFAeoMRwJmJerT9aw4FEhIbZStWN8A3qMwOp1uzHr4UL8AInxtA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-label": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-label/-/micromark-factory-label-2.0.0.tgz", + "integrity": "sha512-RR3i96ohZGde//4WSe/dJsxOX6vxIg9TimLAS3i4EhBAFx8Sm5SmqVfR8E87DPSR31nEAjZfbt91OMZWcNgdZw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-space": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.0.tgz", + "integrity": "sha512-TKr+LIDX2pkBJXFLzpyPyljzYK3MtmllMUMODTQJIUfDGncESaqB90db9IAUcz4AZAJFdd8U9zOp9ty1458rxg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-title": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-title/-/micromark-factory-title-2.0.0.tgz", + "integrity": "sha512-jY8CSxmpWLOxS+t8W+FG3Xigc0RDQA9bKMY/EwILvsesiRniiVMejYTE4wumNc2f4UbAa4WsHqe3J1QS1sli+A==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-factory-whitespace": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-whitespace/-/micromark-factory-whitespace-2.0.0.tgz", + "integrity": "sha512-28kbwaBjc5yAI1XadbdPYHX/eDnqaUFVikLwrO7FDnKG7lpgxnvk/XGRhX/PN0mOZ+dBSZ+LgunHS+6tYQAzhA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-character": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.0.tgz", + "integrity": "sha512-KvOVV+X1yLBfs9dCBSopq/+G1PcgT3lAK07mC4BzXi5E7ahzMAF8oIupDDJ6mievI6F+lAATkbQQlQixJfT3aQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-chunked": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-chunked/-/micromark-util-chunked-2.0.0.tgz", + "integrity": "sha512-anK8SWmNphkXdaKgz5hJvGa7l00qmcaUQoMYsBwDlSKFKjc6gjGXPDw3FNL3Nbwq5L8gE+RCbGqTw49FK5Qyvg==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-classify-character": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-classify-character/-/micromark-util-classify-character-2.0.0.tgz", + "integrity": "sha512-S0ze2R9GH+fu41FA7pbSqNWObo/kzwf8rN/+IGlW/4tC6oACOs8B++bh+i9bVyNnwCcuksbFwsBme5OCKXCwIw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-combine-extensions": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-combine-extensions/-/micromark-util-combine-extensions-2.0.0.tgz", + "integrity": "sha512-vZZio48k7ON0fVS3CUgFatWHoKbbLTK/rT7pzpJ4Bjp5JjkZeasRfrS9wsBdDJK2cJLHMckXZdzPSSr1B8a4oQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-chunked": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-numeric-character-reference": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-decode-numeric-character-reference/-/micromark-util-decode-numeric-character-reference-2.0.1.tgz", + "integrity": "sha512-bmkNc7z8Wn6kgjZmVHOX3SowGmVdhYS7yBpMnuMnPzDq/6xwVA604DuOXMZTO1lvq01g+Adfa0pE2UKGlxL1XQ==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-decode-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-decode-string/-/micromark-util-decode-string-2.0.0.tgz", + "integrity": "sha512-r4Sc6leeUTn3P6gk20aFMj2ntPwn6qpDZqWvYmAG6NgvFTIlj4WtrAudLi65qYoaGdXYViXYw2pkmn7QnIFasA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "decode-named-character-reference": "^1.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-encode": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.0.tgz", + "integrity": "sha512-pS+ROfCXAGLWCOc8egcBvT0kf27GoWMqtdarNfDcjb6YLuV5cM3ioG45Ys2qOVqeqSbjaKg72vU+Wby3eddPsA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-html-tag-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-html-tag-name/-/micromark-util-html-tag-name-2.0.0.tgz", + "integrity": "sha512-xNn4Pqkj2puRhKdKTm8t1YHC/BAjx6CEwRFXntTaRf/x16aqka6ouVoutm+QdkISTlT7e2zU7U4ZdlDLJd2Mcw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-normalize-identifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-normalize-identifier/-/micromark-util-normalize-identifier-2.0.0.tgz", + "integrity": "sha512-2xhYT0sfo85FMrUPtHcPo2rrp1lwbDEEzpx7jiH2xXJLqBuy4H0GgXk5ToU8IEwoROtXuL8ND0ttVa4rNqYK3w==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-resolve-all": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-resolve-all/-/micromark-util-resolve-all-2.0.0.tgz", + "integrity": "sha512-6KU6qO7DZ7GJkaCgwBNtplXCvGkJToU86ybBAUdavvgsCiG8lSSvYxr9MhwmQ+udpzywHsl4RpGJsYWG1pDOcA==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-sanitize-uri": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.0.tgz", + "integrity": "sha512-WhYv5UEcZrbAtlsnPuChHUAsu/iBPOVaEVsntLBIdpibO0ddy8OzavZz3iL2xVvBZOpolujSliP65Kq0/7KIYw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-symbol": "^2.0.0" + } + }, + "node_modules/micromark-util-subtokenize": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-subtokenize/-/micromark-util-subtokenize-2.0.1.tgz", + "integrity": "sha512-jZNtiFl/1aY73yS3UGQkutD0UbhTt68qnRpw2Pifmz5wV9h8gOVsN70v+Lq/f1rKaU/W8pxRe8y8Q9FX1AOe1Q==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "devlop": "^1.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-util-symbol": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.0.tgz", + "integrity": "sha512-8JZt9ElZ5kyTnO94muPxIGS8oyElRJaiJO8EzV6ZSyGQ1Is8xwl4Q45qU5UOg+bGH4AikWziz0iN4sFLWs8PGw==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, + "node_modules/micromark-util-types": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.0.tgz", + "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==", + "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT" + }, "node_modules/micromatch": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", @@ -4962,122 +5447,158 @@ "prettier": "^2 || ^3" } }, - "node_modules/prettier-plugin-packagejson": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/prettier-plugin-packagejson/-/prettier-plugin-packagejson-2.5.1.tgz", - "integrity": "sha512-6i4PW1KxEA+VrokYNGeI/q8qQX3u5DNBc7eLr9GX4OrvWr9DMls1lhbuNopkKG7Li9rTNxerWnYQyjxoUO4ROA==", + "node_modules/prettier-plugin-jsdoc": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-jsdoc/-/prettier-plugin-jsdoc-1.3.0.tgz", + "integrity": "sha512-cQm8xIa0fN9ieJFMXACQd6JPycl+8ouOijAqUqu44EF/s4fXL3Wi9sKXuEaodsEWgCN42Xby/bNhqgM1iWx4uw==", "dev": true, "license": "MIT", "dependencies": { - "sort-package-json": "2.10.0", - "synckit": "0.9.1" + "binary-searching": "^2.0.5", + "comment-parser": "^1.4.0", + "mdast-util-from-markdown": "^2.0.0" }, - "peerDependencies": { - "prettier": ">= 1.16.0" + "engines": { + "node": ">=14.13.1 || >=16.0.0" }, - "peerDependenciesMeta": { - "prettier": { - "optional": true - } + "peerDependencies": { + "prettier": "^3.0.0" } }, - "node_modules/prettier-plugin-packagejson/node_modules/detect-indent": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-7.0.1.tgz", - "integrity": "sha512-Mc7QhQ8s+cLrnUfU/Ji94vG/r8M26m8f++vyres4ZoojaRDpZ1eSIh/EpzLNwlWuvzSZ3UbDFspjFvTDXe6e/g==", + "node_modules/prettier-plugin-jsdoc/node_modules/@types/mdast": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", + "integrity": "sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==", "dev": true, "license": "MIT", - "engines": { - "node": ">=12.20" + "dependencies": { + "@types/unist": "*" } }, - "node_modules/prettier-plugin-packagejson/node_modules/detect-newline": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-4.0.1.tgz", - "integrity": "sha512-qE3Veg1YXzGHQhlA6jzebZN2qVf6NX+A7m7qlhCGG30dJixrAQhYOsJjsnBjJkCSmuOPpCk30145fr8FV0bzog==", + "node_modules/prettier-plugin-jsdoc/node_modules/mdast-util-from-markdown": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.1.tgz", + "integrity": "sha512-aJEUyzZ6TzlsX2s5B4Of7lN7EQtAxvtradMMglCQDyaTFgse6CmtmdJ15ElnVRlCg1vpNyVtbem0PWzlNieZsA==", "dev": true, "license": "MIT", - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "dependencies": { + "@types/mdast": "^4.0.0", + "@types/unist": "^3.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "mdast-util-to-string": "^4.0.0", + "micromark": "^4.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-decode-string": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0", + "unist-util-stringify-position": "^4.0.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/prettier-plugin-packagejson/node_modules/git-hooks-list": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/git-hooks-list/-/git-hooks-list-3.1.0.tgz", - "integrity": "sha512-LF8VeHeR7v+wAbXqfgRlTSX/1BJR9Q1vEMR8JAz1cEg6GX07+zyj3sAdDvYjj/xnlIfVuGgj4qBei1K3hKH+PA==", + "node_modules/prettier-plugin-jsdoc/node_modules/mdast-util-to-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-4.0.0.tgz", + "integrity": "sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==", "dev": true, "license": "MIT", + "dependencies": { + "@types/mdast": "^4.0.0" + }, "funding": { - "url": "https://github.com/fisker/git-hooks-list?sponsor=1" + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/prettier-plugin-packagejson/node_modules/globby": { - "version": "13.2.2", - "resolved": "https://registry.npmjs.org/globby/-/globby-13.2.2.tgz", - "integrity": "sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w==", + "node_modules/prettier-plugin-jsdoc/node_modules/micromark": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.0.tgz", + "integrity": "sha512-o/sd0nMof8kYff+TqcDx3VSrgBTcZpSvYcAHIfHhv5VAuNmisCxjhx6YmxS8PFEpb9z5WKWKPdzf0jM23ro3RQ==", "dev": true, + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], "license": "MIT", "dependencies": { - "dir-glob": "^3.0.1", - "fast-glob": "^3.3.0", - "ignore": "^5.2.4", - "merge2": "^1.4.1", - "slash": "^4.0.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/prettier-plugin-packagejson/node_modules/is-plain-obj": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", - "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==", + "@types/debug": "^4.0.0", + "debug": "^4.0.0", + "decode-named-character-reference": "^1.0.0", + "devlop": "^1.0.0", + "micromark-core-commonmark": "^2.0.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-chunked": "^2.0.0", + "micromark-util-combine-extensions": "^2.0.0", + "micromark-util-decode-numeric-character-reference": "^2.0.0", + "micromark-util-encode": "^2.0.0", + "micromark-util-normalize-identifier": "^2.0.0", + "micromark-util-resolve-all": "^2.0.0", + "micromark-util-sanitize-uri": "^2.0.0", + "micromark-util-subtokenize": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/prettier-plugin-jsdoc/node_modules/unist-util-stringify-position": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz", + "integrity": "sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==", "dev": true, "license": "MIT", - "engines": { - "node": ">=12" + "dependencies": { + "@types/unist": "^3.0.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "type": "opencollective", + "url": "https://opencollective.com/unified" } }, - "node_modules/prettier-plugin-packagejson/node_modules/slash": { + "node_modules/prettier-plugin-organize-imports": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", - "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "resolved": "https://registry.npmjs.org/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-4.0.0.tgz", + "integrity": "sha512-vnKSdgv9aOlqKeEFGhf9SCBsTyzDSyScy1k7E0R1Uo4L0cTcOV7c1XQaT7jfXIOc/p08WLBfN2QUQA9zDSZMxA==", "dev": true, "license": "MIT", - "engines": { - "node": ">=12" + "peerDependencies": { + "@vue/language-plugin-pug": "^2.0.24", + "prettier": ">=2.0", + "typescript": ">=2.9", + "vue-tsc": "^2.0.24" }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "peerDependenciesMeta": { + "@vue/language-plugin-pug": { + "optional": true + }, + "vue-tsc": { + "optional": true + } } }, - "node_modules/prettier-plugin-packagejson/node_modules/sort-package-json": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/sort-package-json/-/sort-package-json-2.10.0.tgz", - "integrity": "sha512-MYecfvObMwJjjJskhxYfuOADkXp1ZMMnCFC8yhp+9HDsk7HhR336hd7eiBs96lTXfiqmUNI+WQCeCMRBhl251g==", + "node_modules/prettier-plugin-pkg": { + "version": "0.18.1", + "resolved": "https://registry.npmjs.org/prettier-plugin-pkg/-/prettier-plugin-pkg-0.18.1.tgz", + "integrity": "sha512-FuUxvsYZR/8rsLH8s/jbPQmgYvv0yxW8LoIHCy6+Q7p4FBjjdP3DNKx8fMTOsc0SlEB1skB4o1LcahRceIh87A==", "dev": true, - "license": "MIT", - "dependencies": { - "detect-indent": "^7.0.1", - "detect-newline": "^4.0.0", - "get-stdin": "^9.0.0", - "git-hooks-list": "^3.0.0", - "globby": "^13.1.2", - "is-plain-obj": "^4.1.0", - "semver": "^7.6.0", - "sort-object-keys": "^1.1.3" + "license": "MPL-2.0", + "engines": { + "node": "^14.18.0 || >=16.0.0" }, - "bin": { - "sort-package-json": "cli.js" + "funding": { + "url": "https://opencollective.com/unts" + }, + "peerDependencies": { + "prettier": "^3.0.3" } }, "node_modules/prettier-plugin-sh": { diff --git a/package.json b/package.json index e30c8e0..068a580 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,22 @@ { "name": "impvol", "version": "0.0.0", + "type": "module", "description": "stuff", "repository": { "type": "git", "url": "https://github.com/boneskull/impvol" }, - "license": "Apache-2.0", "author": { "name": "Christopher Hiller", "email": "boneskull@boneskull.com" }, - "type": "module", + "license": "Apache-2.0", + "engines": { + "node": ">=20" + }, + "main": "./dist/commonjs/index.js", + "module": "./dist/esm/index.js", "exports": { "./package.json": "./package.json", ".": { @@ -25,14 +30,12 @@ } } }, - "main": "./dist/commonjs/index.js", - "module": "./dist/esm/index.js", "types": "./dist/commonjs/index.d.ts", "files": [ + "LICENSE.md", "dist", - "src", "package.json", - "LICENSE.md", + "src", "README.md" ], "scripts": { @@ -43,10 +46,7 @@ "lint:md": "markdownlint-cli2 \"**/*.md\" \".github/**/*.md\"", "lint:spelling": "cspell \"**\" \".github/**/*\"", "prepare": "husky", - "tsc": "tsc" - }, - "lint-staged": { - "*": "prettier --ignore-unknown --write" + "tsc": "tsc -p tsconfig.tsc.json" }, "dependencies": { "debug": "^4.3.5" @@ -78,19 +78,21 @@ "memfs": "^4.9.4", "prettier": "^3.3.3", "prettier-plugin-curly": "^0.2.2", - "prettier-plugin-packagejson": "^2.5.1", + "prettier-plugin-jsdoc": "^1.3.0", + "prettier-plugin-organize-imports": "^4.0.0", + "prettier-plugin-pkg": "^0.18.1", "prettier-plugin-sh": "^0.14.0", "sentences-per-line": "^0.2.1", "tshy": "^3.0.2", "typescript": "^5.5.4", "typescript-eslint": "^7.17.0" }, - "engines": { - "node": ">=20" - }, "publishConfig": { "provenance": true }, + "lint-staged": { + "*": "prettier --ignore-unknown --write" + }, "tshy": { "exports": { "./package.json": "./package.json", diff --git a/src/impvol-event.ts b/src/impvol-event.ts index aa8a9e7..e1663be 100644 --- a/src/impvol-event.ts +++ b/src/impvol-event.ts @@ -1,9 +1,12 @@ -import { type JsonUint8Array, type SnapshotNode } from 'memfs/lib/snapshot'; -import type { MessagePort } from 'worker_threads'; +// eslint-disable-next-line n/no-missing-import +import {type SnapshotNode} from 'memfs/lib/snapshot/types.js'; +// eslint-disable-next-line n/no-missing-import +import {type JsonUint8Array} from 'memfs/lib/snapshot/json.js'; +import type {MessagePort} from 'node:worker_threads'; declare const tag: unique symbol; -export type Tagged = K & { [tag]: T }; +export type Tagged = K & {[tag]: T}; export type ImpVolId = Tagged; diff --git a/src/impvol-hooks.ts b/src/impvol-hooks.ts index 56f0cce..39acd60 100644 --- a/src/impvol-hooks.ts +++ b/src/impvol-hooks.ts @@ -10,17 +10,17 @@ import Debug from 'debug'; // eslint-disable-next-line n/no-missing-import -import { fromJsonSnapshotSync } from 'memfs/lib/snapshot/json.js'; +import {fromJsonSnapshotSync} from 'memfs/lib/snapshot/json.js'; // eslint-disable-next-line n/no-missing-import -import { Volume } from 'memfs/lib/volume.js'; +import {Volume} from 'memfs/lib/volume.js'; import { type InitializeHook, type LoadHook, type ResolveHook, } from 'node:module'; import path from 'node:path'; -import { inspect } from 'node:util'; -import { type MessagePort } from 'node:worker_threads'; +import {inspect} from 'node:util'; +import {type MessagePort} from 'node:worker_threads'; import { type ImpVolAckEvent, type ImpVolEvent, @@ -55,13 +55,13 @@ function ack(port: MessagePort, event: ImpVolEvent): void { port.postMessage(ackEvent); } -export const initialize: InitializeHook = ({ port }) => { +export const initialize: InitializeHook = ({port}) => { port.on('message', (event: ImpVolEvent) => { const start = performance.now(); const vol = getVolume(); switch (event.type) { case 'UPDATE': { - fromJsonSnapshotSync(event.json, { fs: vol }); + fromJsonSnapshotSync(event.json, {fs: vol}); updateVolumeMap(); break; } @@ -124,7 +124,8 @@ export const load: LoadHook = (specifier, context, nextLoad) => { return nextLoad(specifier, context); } if (url.protocol.startsWith(PROTOCOL)) { - const { format } = context; + const {format} = context; + if (DISALLOWED_FORMATS.has(format)) { debug( 'Warning: %s with unsupported format %s tried to load via VFS', @@ -134,9 +135,18 @@ export const load: LoadHook = (specifier, context, nextLoad) => { return nextLoad(specifier, context); } const filepath = url.pathname; + + if (!knownPaths.has(filepath)) { + debug('Warning: %s not found in VFS', filepath); + return nextLoad(specifier, context); + } return getVolume() .promises.readFile(filepath) .then((source) => { + if (!knownPaths.has(filepath)) { + debug('Warning: %s not found in VFS', filepath); + return nextLoad(specifier, context); + } debug( 'Loaded %s from VFS (%sms)', filepath, diff --git a/src/impvol.ts b/src/impvol.ts index b274383..fa80bb5 100644 --- a/src/impvol.ts +++ b/src/impvol.ts @@ -7,16 +7,16 @@ import Debug from 'debug'; // eslint-disable-next-line n/no-missing-import -import { type Link, type Node } from 'memfs/lib/node.js'; +import {type Link, type Node} from 'memfs/lib/node.js'; // eslint-disable-next-line n/no-missing-import -import { toJsonSnapshotSync } from 'memfs/lib/snapshot/json.js'; +import {toJsonSnapshotSync} from 'memfs/lib/snapshot/json.js'; // eslint-disable-next-line n/no-missing-import -import { Volume, type DirectoryJSON } from 'memfs/lib/volume.js'; -import { once } from 'node:events'; +import {Volume, type DirectoryJSON} from 'memfs/lib/volume.js'; +import {once} from 'node:events'; // eslint-disable-next-line n/no-unsupported-features/node-builtins -import { register } from 'node:module'; -import { pathToFileURL } from 'node:url'; -import { MessageChannel, type MessagePort } from 'node:worker_threads'; +import {register} from 'node:module'; +import {pathToFileURL} from 'node:url'; +import {MessageChannel, type MessagePort} from 'node:worker_threads'; import { type ImpVolClearEvent, type ImpVolEvent, @@ -25,7 +25,7 @@ import { type ImpVolInitData, type ImpVolUpdateEvent, } from './impvol-event.js'; -import { RESOLVE_HOOKS_PATH } from './resolve-hooks.js'; +import {RESOLVE_HOOKS_PATH} from './resolve-hooks.js'; type ImpVolQueueItem = { event: ImpVolEvent; @@ -46,7 +46,7 @@ export class ImportableVolume extends Volume { constructor( private readonly port: MessagePort, - props: { Node?: Node; Link?: Link; File?: File } = {}, + props: {Node?: Node; Link?: Link; File?: File} = {}, ) { super(props); } @@ -80,7 +80,7 @@ export class ImportableVolume extends Volume { * easily ignored. Maybe use a `Proxy` or something instead. */ async __update__(): Promise { - const json = toJsonSnapshotSync({ fs: this }); + const json = toJsonSnapshotSync({fs: this}); const event: ImpVolUpdateEvent = { type: 'UPDATE', json, @@ -120,7 +120,7 @@ export class ImportableVolume extends Volume { if (!item) { return; } - const { resolve, reject, event } = item; + const {resolve, reject, event} = item; try { this.#pending = true; this.port.postMessage(event); @@ -137,7 +137,7 @@ export class ImportableVolume extends Volume { #enqueue(event: ImpVolEvent): Promise { return new Promise((resolve, reject) => { - this.#queue.push({ event, resolve, reject }); + this.#queue.push({event, resolve, reject}); void this.#dequeue(); }); } @@ -227,7 +227,7 @@ function registerLoaderHook(hooksPath: string): MessagePort { if (registerLoaderHook.cache.has(hooksPath)) { return registerLoaderHook.cache.get(hooksPath)!; } - const { port1: port, port2: hookPort } = new MessageChannel(); + const {port1: port, port2: hookPort} = new MessageChannel(); register(hooksPath, { parentURL, diff --git a/src/package.json b/src/package.json new file mode 100644 index 0000000..3dbc1ca --- /dev/null +++ b/src/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/src/resolve-hooks.ts b/src/resolve-hooks.ts index 5b691f0..503736c 100644 --- a/src/resolve-hooks.ts +++ b/src/resolve-hooks.ts @@ -1,7 +1,7 @@ -import { fileURLToPath } from 'url'; +import {fileURLToPath} from 'url'; export const RESOLVE_HOOKS_PATH = fileURLToPath( // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore for tshy - new URL('./resolve-hooks.js', import.meta.url), + new URL('./impvol-hooks.js', import.meta.url), ); diff --git a/tsconfig.tsc.json b/tsconfig.tsc.json new file mode 100644 index 0000000..9f910a2 --- /dev/null +++ b/tsconfig.tsc.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": true + } +}