From 4fa9fa359077d3454edd174e34cfaee7454d6f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?He=CC=84sperus?= Date: Sat, 17 Jan 2026 16:34:06 +0800 Subject: [PATCH] chore(lint & fmt): discard biome in favor of oxlint and oxfmt --- .github/dependabot.yml | 16 +- .github/workflows/ci-main.yml | 146 +++++------ .github/workflows/ci-pr.yml | 90 +++---- .github/workflows/publish.yml | 74 +++--- .gitignore | 2 +- .oxfmtrc.json | 18 ++ .oxlintrc.json | 136 ++++++++++ README.md | 24 +- SECURITY.md | 1 + TODO.md | 2 +- biome.json | 50 ---- docs/.vitepress/config.ts | 1 + docs/.vitepress/theme/index.ts | 10 +- docs/.vitepress/theme/layout.vue | 58 ++--- docs/components/playground.vue | 8 +- docs/en/basic/index.md | 2 +- docs/en/basic/lifecycle.md | 7 +- docs/en/basic/module-lifecycle.md | 3 +- docs/en/basic/options.md | 3 +- docs/en/basic/subscribe-unsubscribe.md | 2 +- docs/en/development/custom-events.md | 21 +- docs/en/development/custom-modules.md | 32 +-- docs/en/development/custom-options.md | 4 +- docs/en/development/modifier.md | 4 +- docs/en/development/testing.md | 3 +- docs/en/events/drag.md | 2 +- docs/en/events/index.md | 14 +- docs/en/events/pan.md | 2 +- docs/en/events/true-click.md | 2 +- docs/en/events/zoom.md | 2 +- docs/en/get-started.md | 17 +- docs/en/index.md | 58 ++--- docs/en/modules/click.md | 2 +- docs/en/modules/index.md | 15 +- docs/en/modules/prevent-default.md | 2 +- docs/en/modules/wheel-pan-zoom.md | 5 +- docs/en/playground.md | 6 +- docs/en/whats-pointeract.md | 18 +- package.json | 61 +++-- pnpm-lock.yaml | 335 ++++++++++++++++++------- src/baseModule.ts | 9 +- src/declarations.ts | 4 +- src/modules/multitouchPanZoom.ts | 4 +- src/pointeract.ts | 8 +- tests/click.test.ts | 15 +- tests/dev/index.html | 50 ++-- tests/dev/script.ts | 10 +- tests/drag.test.ts | 7 +- tests/integration.test.ts | 11 +- tests/mockRect.ts | 40 +-- tests/multiTouch.test.ts | 7 +- tests/testUtils.ts | 3 +- tests/wheel.test.ts | 11 +- vite.config.ts | 3 +- 54 files changed, 875 insertions(+), 565 deletions(-) create mode 100644 .oxfmtrc.json create mode 100644 .oxlintrc.json delete mode 100644 biome.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml index dd7bd1d..6de8c1a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,10 +1,10 @@ version: 2 updates: - - package-ecosystem: "npm" - directory: "/" - schedule: - interval: "weekly" - groups: - all: - patterns: - - "*" \ No newline at end of file + - package-ecosystem: 'npm' + directory: '/' + schedule: + interval: 'weekly' + groups: + all: + patterns: + - '*' diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index b210006..bf4763a 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -1,82 +1,82 @@ name: CI for Main on: - push: - branches: [main] + push: + branches: [main] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true # Cancel previous runs for same PR/branch + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true # Cancel previous runs for same PR/branch permissions: - contents: read - pages: write - id-token: write + contents: read + pages: write + id-token: write jobs: - ci-main: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - - name: Set up pnpm - uses: pnpm/action-setup@v4.2.0 - - - name: Set up Node.js - uses: actions/setup-node@v6 - with: - node-version: latest - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install - - - name: Detect changed roots - id: detect - run: ./.github/scripts/detect_changes.sh - - - name: Run checks - run: pnpm check - - - name: Run build - run: pnpm build - - # region Test - - name: Run coverage tests (src or test changes) - if: | - contains(steps.detect.outputs.changed_roots, 'src') || - contains(steps.detect.outputs.changed_roots, 'test') - run: pnpm test:coverage - - - name: Upload coverage reports to Codecov - if: | - contains(steps.detect.outputs.changed_roots, 'src') || - contains(steps.detect.outputs.changed_roots, 'test') - uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} - # endregion ======================================================================== - - # region Deploy Documentation - - name: Build - if: contains(steps.detect.outputs.changed_roots, 'docs') - run: pnpm docs:build - - - name: Setup Pages - if: contains(steps.detect.outputs.changed_roots, 'docs') - uses: actions/configure-pages@v5.0.0 - - - name: Upload artifact - if: contains(steps.detect.outputs.changed_roots, 'docs') - uses: actions/upload-pages-artifact@v4.0.0 - with: - path: './docs/.vitepress/dist' - - - name: Deploy to GitHub Pages - if: contains(steps.detect.outputs.changed_roots, 'docs') - uses: actions/deploy-pages@v4.0.5 - # endregion ======================================================================== \ No newline at end of file + ci-main: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set up pnpm + uses: pnpm/action-setup@v4.2.0 + + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version: latest + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Detect changed roots + id: detect + run: ./.github/scripts/detect_changes.sh + + - name: Run checks + run: pnpm check + + - name: Run build + run: pnpm build + + # region Test + - name: Run coverage tests (src or test changes) + if: | + contains(steps.detect.outputs.changed_roots, 'src') || + contains(steps.detect.outputs.changed_roots, 'test') + run: pnpm test:coverage + + - name: Upload coverage reports to Codecov + if: | + contains(steps.detect.outputs.changed_roots, 'src') || + contains(steps.detect.outputs.changed_roots, 'test') + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + # endregion ======================================================================== + + # region Deploy Documentation + - name: Build + if: contains(steps.detect.outputs.changed_roots, 'docs') + run: pnpm docs:build + + - name: Setup Pages + if: contains(steps.detect.outputs.changed_roots, 'docs') + uses: actions/configure-pages@v5.0.0 + + - name: Upload artifact + if: contains(steps.detect.outputs.changed_roots, 'docs') + uses: actions/upload-pages-artifact@v4.0.0 + with: + path: './docs/.vitepress/dist' + + - name: Deploy to GitHub Pages + if: contains(steps.detect.outputs.changed_roots, 'docs') + uses: actions/deploy-pages@v4.0.5 + # endregion ======================================================================== diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 5a7a7ce..4a0fd2e 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -1,52 +1,52 @@ name: CI for Pull Requests on: - pull_request: - branches: [main] - types: [opened, synchronize, reopened, ready_for_review] + pull_request: + branches: [main] + types: [opened, synchronize, reopened, ready_for_review] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true # Cancel previous runs for same PR/branch + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true # Cancel previous runs for same PR/branch jobs: - ci-pr: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - - name: Set up pnpm - uses: pnpm/action-setup@v4.2.0 - - - name: Set up Node.js - uses: actions/setup-node@v6 - with: - node-version: latest - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install - - - name: Detect changed roots - id: detect - run: ./.github/scripts/detect_changes.sh - - - name: Run checks - run: pnpm check - - - name: Run build - run: pnpm build - - - name: Run tests (src or test changes) - if: | - contains(steps.detect.outputs.changed_roots, 'src') || - contains(steps.detect.outputs.changed_roots, 'test') - run: pnpm test - - - name: Run docs build (docs changes) - if: contains(steps.detect.outputs.changed_roots, 'docs') - run: pnpm docs:build \ No newline at end of file + ci-pr: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set up pnpm + uses: pnpm/action-setup@v4.2.0 + + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version: latest + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Detect changed roots + id: detect + run: ./.github/scripts/detect_changes.sh + + - name: Run checks + run: pnpm check + + - name: Run build + run: pnpm build + + - name: Run tests (src or test changes) + if: | + contains(steps.detect.outputs.changed_roots, 'src') || + contains(steps.detect.outputs.changed_roots, 'test') + run: pnpm test + + - name: Run docs build (docs changes) + if: contains(steps.detect.outputs.changed_roots, 'docs') + run: pnpm docs:build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bc7ad99..6033929 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,37 +1,37 @@ -name: Build and Publish to npm - -on: - push: - tags: - - 'v*.*.*' - -permissions: - id-token: write - contents: read - -jobs: - build-and-publish: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v6 - - - name: Set up pnpm - uses: pnpm/action-setup@v4.2.0 - - - name: Set up Node.js - uses: actions/setup-node@v6 - with: - node-version: latest - registry-url: 'https://registry.npmjs.org' - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install - - - name: Build - run: pnpm build - - - name: Publish to npm - run: pnpm publish --no-git-checks \ No newline at end of file +name: Build and Publish to npm + +on: + push: + tags: + - 'v*.*.*' + +permissions: + id-token: write + contents: read + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up pnpm + uses: pnpm/action-setup@v4.2.0 + + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version: latest + registry-url: 'https://registry.npmjs.org' + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm build + + - name: Publish to npm + run: pnpm publish --no-git-checks diff --git a/.gitignore b/.gitignore index b7d83b9..6060557 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ node_modules # dot files -.vscode .cursor .continue +.vscode # generated files *.js diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 0000000..af8250d --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,18 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "printWidth": 100, + "tabWidth": 4, + "useTabs": true, + "singleQuote": true, + "experimentalSortImports": { + "groups": [ + ["side-effect"], + ["builtin"], + ["external", "external-type"], + ["internal", "internal-type"], + ["parent", "parent-type"], + ["sibling", "sibling-type"], + ["index", "index-type"] + ] + } +} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 0000000..f60e904 --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,136 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "plugins": ["unicorn", "typescript", "oxc", "import", "vitest", "vue"], + "categories": {}, + "rules": { + "constructor-super": "warn", + "for-direction": "warn", + "no-async-promise-executor": "warn", + "no-caller": "warn", + "no-class-assign": "warn", + "no-compare-neg-zero": "warn", + "no-cond-assign": "warn", + "no-const-assign": "warn", + "no-constant-binary-expression": "warn", + "no-constant-condition": "warn", + "no-control-regex": "warn", + "no-debugger": "warn", + "no-delete-var": "warn", + "no-dupe-class-members": "warn", + "no-dupe-else-if": "warn", + "no-dupe-keys": "warn", + "no-duplicate-case": "warn", + "no-empty-character-class": "warn", + "no-empty-pattern": "warn", + "no-empty-static-block": "warn", + "no-eval": "warn", + "no-ex-assign": "warn", + "no-extra-boolean-cast": "warn", + "no-func-assign": "warn", + "no-global-assign": "warn", + "no-import-assign": "warn", + "no-invalid-regexp": "warn", + "no-irregular-whitespace": "warn", + "no-loss-of-precision": "warn", + "no-new-native-nonconstructor": "warn", + "no-nonoctal-decimal-escape": "warn", + "no-obj-calls": "warn", + "no-self-assign": "warn", + "no-setter-return": "warn", + "no-shadow-restricted-names": "warn", + "no-sparse-arrays": "warn", + "no-this-before-super": "warn", + "no-unassigned-vars": "warn", + "no-unsafe-finally": "warn", + "no-unsafe-negation": "warn", + "no-unsafe-optional-chaining": "warn", + "no-unused-expressions": "warn", + "no-unused-labels": "warn", + "no-unused-private-class-members": "warn", + "no-unused-vars": "warn", + "no-useless-backreference": "warn", + "no-useless-catch": "warn", + "no-useless-escape": "warn", + "no-useless-rename": "warn", + "no-with": "warn", + "require-yield": "warn", + "use-isnan": "warn", + "valid-typeof": "warn", + "oxc/bad-array-method-on-arguments": "warn", + "oxc/bad-char-at-comparison": "warn", + "oxc/bad-comparison-sequence": "warn", + "oxc/bad-min-max-func": "warn", + "oxc/bad-object-literal-comparison": "warn", + "oxc/bad-replace-all-arg": "warn", + "oxc/const-comparisons": "warn", + "oxc/double-comparisons": "warn", + "oxc/erasing-op": "warn", + "oxc/missing-throw": "warn", + "oxc/number-arg-out-of-range": "warn", + "oxc/only-used-in-recursion": "warn", + "oxc/uninvoked-array-callback": "warn", + "typescript/await-thenable": "warn", + "typescript/no-array-delete": "warn", + "typescript/no-base-to-string": "warn", + "typescript/no-duplicate-enum-values": "warn", + "typescript/no-duplicate-type-constituents": "warn", + "typescript/no-extra-non-null-assertion": "warn", + "typescript/no-floating-promises": "warn", + "typescript/no-for-in-array": "warn", + "typescript/no-implied-eval": "warn", + "typescript/no-meaningless-void-operator": "warn", + "typescript/no-misused-new": "warn", + "typescript/no-misused-spread": "warn", + "typescript/no-non-null-asserted-optional-chain": "warn", + "typescript/no-redundant-type-constituents": "warn", + "typescript/no-this-alias": "warn", + "typescript/no-unnecessary-parameter-property-assignment": "warn", + "typescript/no-unsafe-declaration-merging": "warn", + "typescript/no-unsafe-unary-minus": "warn", + "typescript/no-useless-empty-export": "warn", + "typescript/no-wrapper-object-types": "warn", + "typescript/prefer-as-const": "warn", + "typescript/require-array-sort-compare": "warn", + "typescript/restrict-template-expressions": "warn", + "typescript/triple-slash-reference": "warn", + "typescript/unbound-method": "warn", + "unicorn/no-await-in-promise-methods": "warn", + "unicorn/no-empty-file": "warn", + "unicorn/no-invalid-fetch-options": "warn", + "unicorn/no-invalid-remove-event-listener": "warn", + "unicorn/no-new-array": "warn", + "unicorn/no-single-promise-in-promise-methods": "warn", + "unicorn/no-thenable": "warn", + "unicorn/no-unnecessary-await": "warn", + "unicorn/no-useless-fallback-in-spread": "warn", + "unicorn/no-useless-length-check": "warn", + "unicorn/no-useless-spread": "warn", + "unicorn/prefer-set-size": "warn", + "unicorn/prefer-string-starts-ends-with": "warn" + }, + "settings": { + "jsdoc": { + "ignorePrivate": false, + "ignoreInternal": false, + "ignoreReplacesDocs": true, + "overrideReplacesDocs": true, + "augmentsExtendsReplacesDocs": false, + "implementsReplacesDocs": false, + "exemptDestructuredRootsFromChecks": false, + "tagNamePreference": {} + }, + "vitest": { + "typecheck": false + }, + "plugins": ["typescript"], + "rules": { + "typescript/no-floating-promises": "error", + "typescript/no-unsafe-assignment": "warn" + } + }, + "env": { + "builtin": true + }, + "globals": {}, + "ignorePatterns": [] +} diff --git a/README.md b/README.md index f2a6b37..6a72e28 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ FeaturesComparisonGet Involved • - License + License

## What's Pointeract? @@ -49,7 +49,7 @@ Pointeract is a tiny utility library focusing on one thing - handling user inter It is built in an extensible architecture with base bundle size only **1KB** minified + gzipped, functionalities come from also byte-sized modules. It's fully **tree-shakable**, the fewer modules you use, the smaller your bundle is. -Access our documentation [here](https://pointeract.consensia.cc/). +Access our documentation [in the website](https://pointeract.consensia.cc/). ## Advantages @@ -81,7 +81,7 @@ Or include the following lines directly in your HTML file: ```html ``` @@ -108,15 +108,15 @@ Missing your desired interaction? [Write your own module](https://pointeract.con There're already plenty of interaction libraries out there, most famous ones are `Interact.js` and `Hammer.js`, but Pointeract is different. -| Criteria | Pointeract | [Hammer.js](https://hammerjs.github.io) | [Interact.js](https://interactjs.io) | -|:---------------------------------------------------------------------------------------------|:-----------------------------------------------------:|:------------------------------------------------:|:---------------------------------------------------:| -| Written in TypeScript? | ✅ | ❌ | ✅ | -| Tree-shakeable? | [✅](https://bundlephobia.com/package/pointeract) | [❌](https://bundlephobia.com/package/hammerjs) | [❌](https://bundlephobia.com/package/interactjs) | +| Criteria | Pointeract | [Hammer.js](https://hammerjs.github.io) | [Interact.js](https://interactjs.io) | +| :------------------------------------------------------------------------------------------- | :---------------------------------------------------: | :----------------------------------------------: | :-------------------------------------------------: | +| Written in TypeScript? | ✅ | ❌ | ✅ | +| Tree-shakeable? | [✅](https://bundlephobia.com/package/pointeract) | [❌](https://bundlephobia.com/package/hammerjs) | [❌](https://bundlephobia.com/package/interactjs) | | Bundle Size (Minified + Gzipped) | 👑 [2KB](https://bundlephobia.com/package/pointeract) | [7KB](https://bundlephobia.com/package/hammerjs) | [28KB](https://bundlephobia.com/package/interactjs) | -| Last Updated | 👑 Actively Maintained | 2015 | 2023 | -| Features | Pointer and Wheel Related | Pointer Related | 👑 Pointer and Wheel Related + Comprehensive Utils | -| Robust? (See [Testing](https://pointeract.consensia.cc/development/testing#chaotic-testing)) | ✅ | ❌ Element Jerks | ❌ Element Ignores the Second Touch | -| Extensible? | ✅ | ❌ | ❌ | +| Last Updated | 👑 Actively Maintained | 2015 | 2023 | +| Features | Pointer and Wheel Related | Pointer Related | 👑 Pointer and Wheel Related + Comprehensive Utils | +| Robust? (See [Testing](https://pointeract.consensia.cc/development/testing#chaotic-testing)) | ✅ | ❌ Element Jerks | ❌ Element Ignores the Second Touch | +| Extensible? | ✅ | ❌ | ❌ | ## Get Involved @@ -129,4 +129,4 @@ This project welcomes anyone that have ideas to improve it. ## Copyright and License -Copyright ©️ 2025-2026 Hesprs (Hēsperus) | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html) \ No newline at end of file +Copyright ©️ 2025-2026 Hesprs (Hēsperus) | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html) diff --git a/SECURITY.md b/SECURITY.md index d701697..e40f1fc 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -5,6 +5,7 @@ If you believe you have found a security vulnerability of `Pointeract`, please r Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests. Please include as much of the information listed below as you can to help us better understand and resolve the issue: + - The type of issue - Full paths of source file(s) that causes this issue - Places that would malfunction or be used maliciously due to the issue diff --git a/TODO.md b/TODO.md index bc4c9a0..d1881db 100644 --- a/TODO.md +++ b/TODO.md @@ -5,4 +5,4 @@ This file is used to show the current focus of maintainers, your contributions a - [x] transform to adapt modularity practice (main class maintains `pointers` map only, other imports share map and register hooks) - [ ] add rotate functionality to `multiPointer_zanZoom`. - [ ] support multi-element init, add / remove monitoring element and API. -- [ ] prototype `PointeractManager`. \ No newline at end of file +- [ ] prototype `PointeractManager`. diff --git a/biome.json b/biome.json deleted file mode 100644 index f782e6b..0000000 --- a/biome.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "$schema": "https://biomejs.dev/schemas/2.3.11/schema.json", - "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true }, - "files": { "includes": ["**", "!!**/dist", "!!docs/.vitepress/theme"] }, - "formatter": { - "enabled": true, - "formatWithErrors": false, - "indentWidth": 4, - "lineEnding": "lf", - "lineWidth": 110, - "bracketSameLine": false, - "expand": "auto", - "useEditorconfig": true - }, - "linter": { - "enabled": true, - "rules": { "recommended": true }, - "domains": { - "vue": "recommended" - } - }, - "javascript": { - "formatter": { - "jsxQuoteStyle": "double", - "quoteProperties": "asNeeded", - "trailingCommas": "all", - "semicolons": "always", - "arrowParentheses": "asNeeded", - "bracketSameLine": false, - "quoteStyle": "single", - "attributePosition": "auto", - "bracketSpacing": true - }, - "globals": [] - }, - "html": { - "formatter": { - "indentScriptAndStyle": false, - "enabled": true, - "selfCloseVoidElements": "always" - }, - "experimentalFullSupportEnabled": true - }, - "assist": { - "enabled": true, - "actions": { - "source": { "organizeImports": "on" } - } - } -} diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 24f72dd..d5a6342 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,4 +1,5 @@ import { resolve } from 'node:path'; + import { defineConfig } from 'vitepress'; import { groupIconMdPlugin, groupIconVitePlugin } from 'vitepress-plugin-group-icons'; diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 0a18693..183e5ed 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,16 +1,14 @@ // https://vitepress.dev/guide/custom-theme -import type { Theme } from 'vitepress'; -import DefaultTheme from 'vitepress/theme'; -import { h } from 'vue'; import './style.css'; import 'virtual:group-icons.css'; + +import type { Theme } from 'vitepress'; +import DefaultTheme from 'vitepress/theme'; + import Layout from './layout.vue'; export default { extends: DefaultTheme, Layout: Layout, - enhanceApp({ app, router, siteData }) { - // ... - }, } satisfies Theme; diff --git a/docs/.vitepress/theme/layout.vue b/docs/.vitepress/theme/layout.vue index 2f0410f..3e9097e 100644 --- a/docs/.vitepress/theme/layout.vue +++ b/docs/.vitepress/theme/layout.vue @@ -4,26 +4,28 @@ import { useData } from 'vitepress'; import DefaultTheme from 'vitepress/theme'; const enableTransitions = () => { - return 'startViewTransition' in document - && window.matchMedia('(prefers-reduced-motion: no-preference)').matches; -} + return ( + 'startViewTransition' in document && + window.matchMedia('(prefers-reduced-motion: no-preference)').matches + ); +}; const setupToggleDark = (isDark: Ref) => { - provide('toggle-appearance', async ({ clientX: x, clientY: y }: PointerEvent) => { - if (!enableTransitions()) { - isDark.value = !isDark.value; - return; - } - - console.log('toggle-appearance'); - document.documentElement.style.setProperty('--darkX', x + 'px'); - document.documentElement.style.setProperty('--darkY', y + 'px'); - - await document.startViewTransition(async () => { - isDark.value = !isDark.value; - await nextTick(); - }).ready; - }); + provide('toggle-appearance', async ({ clientX: x, clientY: y }: PointerEvent) => { + if (!enableTransitions()) { + isDark.value = !isDark.value; + return; + } + + console.log('toggle-appearance'); + document.documentElement.style.setProperty('--darkX', x + 'px'); + document.documentElement.style.setProperty('--darkY', y + 'px'); + + await document.startViewTransition(async () => { + isDark.value = !isDark.value; + await nextTick(); + }).ready; + }); }; const { isDark } = useData(); @@ -31,25 +33,25 @@ setupToggleDark(isDark); \ No newline at end of file + diff --git a/docs/components/playground.vue b/docs/components/playground.vue index 57d04be..c1a5629 100644 --- a/docs/components/playground.vue +++ b/docs/components/playground.vue @@ -30,21 +30,21 @@ onMounted(() => { Click, Drag, ]).start(); - pointeract.on('pan', e => { + pointeract.on('pan', (e) => { data.x += e.detail.x; data.y += e.detail.y; }); - pointeract.on('drag', e => { + pointeract.on('drag', (e) => { data.x += e.detail.x; data.y += e.detail.y; }); - pointeract.on('zoom', e => { + pointeract.on('zoom', (e) => { const detail = e.detail; data.scale *= detail.factor; data.x += detail.x * (1 - detail.factor); data.y += detail.y * (1 - detail.factor); }); - pointeract.on('trueClick', e => { + pointeract.on('trueClick', (e) => { data.streak = e.detail.streak; if (streakTimeout) clearTimeout(streakTimeout); streakTimeout = setTimeout(() => { diff --git a/docs/en/basic/index.md b/docs/en/basic/index.md index ff7ae5e..ef7f595 100644 --- a/docs/en/basic/index.md +++ b/docs/en/basic/index.md @@ -48,4 +48,4 @@ pointeract.stop(PreventDefault); // Disable PreventDefault only // Dispose pointeract.dispose(); -``` \ No newline at end of file +``` diff --git a/docs/en/basic/lifecycle.md b/docs/en/basic/lifecycle.md index 9ece658..9d412c5 100644 --- a/docs/en/basic/lifecycle.md +++ b/docs/en/basic/lifecycle.md @@ -17,12 +17,15 @@ import { Drag, PreventDefault } from 'pointeract'; Then, you need a DOM element to attach to, below shows how to do that in Vanilla DOM: ::: code-group + ```TypeScript [TypeScript] const app = document.getElementById('app') as HTMLDivElement; ``` + ```HTML [HTML]
``` + ::: Finally, you may want to define options, read elaboration in [Options](./options): @@ -58,6 +61,7 @@ pointeract.start(); const pointeract = new Pointeract(app, [Drag, PreventDefault]); // [!code --] const pointeract = new Pointeract(app, [Drag, PreventDefault]).start(); // [!code ++] ``` + ::: ## Stop @@ -76,6 +80,7 @@ pointeract.stop(); // ... some logic here pointeract.start(); ``` + ::: ## Disposal @@ -88,4 +93,4 @@ pointeract.dispose(); ::: tip You don't need to call `stop()` before disposal, `dispose()` handles everything for you. -::: \ No newline at end of file +::: diff --git a/docs/en/basic/module-lifecycle.md b/docs/en/basic/module-lifecycle.md index 9c1f8ec..37a1535 100644 --- a/docs/en/basic/module-lifecycle.md +++ b/docs/en/basic/module-lifecycle.md @@ -25,6 +25,7 @@ pointeract.stop(PreventDefault); // no apparent change, but PreventDefault is di pointeract.start(); // only the base class and Drag are started pointeract.start(PreventDefault); // PreventDefault will not be restarted unless explicitly reenabled here ``` + ::: ::: warning @@ -33,4 +34,4 @@ You cannot start/stop a module that is not passed into the Pointeract constructo ## Disposal -All modules of a instance are collectively disposed when the `dispose()` it is called. \ No newline at end of file +All modules of a instance are collectively disposed when the `dispose()` it is called. diff --git a/docs/en/basic/options.md b/docs/en/basic/options.md index fccb92b..b1c1cc5 100644 --- a/docs/en/basic/options.md +++ b/docs/en/basic/options.md @@ -22,6 +22,7 @@ type options = { ``` It defines how the coordinates are output across Pointeract, options are: + - `absolute`: screen coordinates in pixels - `relative`(default): relative to the top-left corner of the element in pixels - `relativeFraction`: relative to the top-left corner of the element divided by the element's size @@ -46,4 +47,4 @@ options.coordinateOutput = 'relative'; // output format instantly changes to rel To ensure type safety of options, you can import `Options` from `pointeract` and assign it to your options object, it accepts a single module constructor or a list of modules constructors as type parameter. You need to use `typeof ` to get the constructor type of the module. -::: \ No newline at end of file +::: diff --git a/docs/en/basic/subscribe-unsubscribe.md b/docs/en/basic/subscribe-unsubscribe.md index 8542c39..7b068b2 100644 --- a/docs/en/basic/subscribe-unsubscribe.md +++ b/docs/en/basic/subscribe-unsubscribe.md @@ -25,4 +25,4 @@ pointeract.off('drag', hook); ::: tip Its good practice to unsubscribe all the events **before** the disposal of a Pointeract instance. -::: \ No newline at end of file +::: diff --git a/docs/en/development/custom-events.md b/docs/en/development/custom-events.md index 8566385..820c503 100644 --- a/docs/en/development/custom-events.md +++ b/docs/en/development/custom-events.md @@ -10,9 +10,9 @@ You may have seen a type error when trying to emit a custom event within a modul import { BaseModule } from 'pointeract'; class YourModule extends BaseModule { - onPointerMove = () => { - this.utils.dispatch('moveMove'); // TypeError: Argument of type '"moveMove"' is not assignable to parameter of type '"pan" | "drag" | "trueClick" | "zoom"'. - }; + onPointerMove = () => { + this.utils.dispatch('moveMove'); // TypeError: Argument of type '"moveMove"' is not assignable to parameter of type '"pan" | "drag" | "trueClick" | "zoom"'. + }; } ``` @@ -22,8 +22,8 @@ That's because Pointeract aims to provide the best-in-class type safety, if you import { BaseModule } from 'pointeract'; // [!code --] import { BaseModule, StdEvents } from 'pointeract'; // [!code ++] interface CustomEvents extends StdEvents { // [!code ++] - moveMove: CustomEvent; // add an event with no detail // [!code ++] - moveDetail: CustomEvent<{ x: number; y: number }>; // add an event with detail of coordinates // [!code ++] + moveMove: CustomEvent; // add an event with no detail // [!code ++] + moveDetail: CustomEvent<{ x: number; y: number }>; // add an event with detail of coordinates // [!code ++] } // [!code ++] ``` @@ -32,14 +32,15 @@ Then you can pass your custom events to `BaseClass` as a type parameter: ```TypeScript class YourModule extends BaseModule { // [!code --] class YourModule extends BaseModule { // [!code ++] - onPointerMove = () => { - this.utils.dispatch('moveMove'); // no error - this.utils.dispatch('moveDetail', { x: 0, y: 0 }); // no error - }; + onPointerMove = () => { + this.utils.dispatch('moveMove'); // no error + this.utils.dispatch('moveDetail', { x: 0, y: 0 }); // no error + }; } ``` Then you can dispatch your custom events. Yourself and your module users will gain full type safety. > **Reference to**: -> - [MDN CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) \ No newline at end of file +> +> - [MDN CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) diff --git a/docs/en/development/custom-modules.md b/docs/en/development/custom-modules.md index 288e578..6662262 100644 --- a/docs/en/development/custom-modules.md +++ b/docs/en/development/custom-modules.md @@ -15,7 +15,7 @@ class MyModule extends BaseModule { ``` ::: tip -In most cases, a Pointeract module does not need construction by yourself, which is done in `BaseModule`. +In most cases, a Pointeract module does not need construction by yourself, which is done in `BaseModule`. ::: ## Properties @@ -36,9 +36,9 @@ class BaseModule { } type Pointer = { - records: Array<{ x: number; y: number; timestamp: number }>; // pointer records, coordinates are absolute screen coords - target: EventTarget | null; - [key: Indexable]: any; // your can add your own properties into a pointer, the key can be a string, number or symbol + records: Array<{ x: number; y: number; timestamp: number }>; // pointer records, coordinates are absolute screen coords + target: EventTarget | null; + [key: Indexable]: any; // your can add your own properties into a pointer, the key can be a string, number or symbol }; ``` @@ -46,22 +46,21 @@ type Pointer = { - `window`: The window context of the monitoring element. It's always better practice to use `this.window` instead of direct `window` in a module. - `pointers`: A hot-updated map of pointers, the key is the pointer ID, the value is a pointer object. - `utils`: A set of utilities for a module: - - `getNthValue`: Get the nth pointer value in the pointers map. - - `screenToTarget`: Convert screen coordinates to target coordinates that is configured by `coordinateOutput`, always use it if you are emitting events that involve coordinates. - - `dispatch`: Dispatch an event with a given name and detail. - - `getLast`: A pure functional utility: get the last element in an array.import { BaseModule } from 'pointeract'; - + - `getNthValue`: Get the nth pointer value in the pointers map. + - `screenToTarget`: Convert screen coordinates to target coordinates that is configured by `coordinateOutput`, always use it if you are emitting events that involve coordinates. + - `dispatch`: Dispatch an event with a given name and detail. + - `getLast`: A pure functional utility: get the last element in an array.import { BaseModule } from 'pointeract'; ## Hooks ```TypeScript class BaseModule { - onPointerDown?: (...args: [PointerEvent, Pointer, Pointers]) => void; - onPointerMove?: (...args: [PointerEvent, Pointer, Pointers]) => void; - onPointerUp?: (...args: [PointerEvent, Pointer, Pointers]) => void; - onWheel?: (...args: [WheelEvent]) => void; - onStart?: () => void; - onStop?: () => void; + onPointerDown?: (...args: [PointerEvent, Pointer, Pointers]) => void; + onPointerMove?: (...args: [PointerEvent, Pointer, Pointers]) => void; + onPointerUp?: (...args: [PointerEvent, Pointer, Pointers]) => void; + onWheel?: (...args: [WheelEvent]) => void; + onStart?: () => void; + onStop?: () => void; modifier?: () => ModifierReturn; dispose?: () => void; } @@ -83,6 +82,7 @@ Always remember to use arrow functions when defining these hooks, otherwise the ::: > **Reference to**: +> > - [MDN PointerEvent](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent) > - [MDN WheelEvent](https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent) @@ -90,4 +90,4 @@ Always remember to use arrow functions when defining these hooks, otherwise the Use `this.utils.dispatch()` to dispatch an event, the second argument will be assigned to the `detail` property of the event. -There are [existing event types](/events/) that you can follow, or you can [write your own events](/development/custom-events). \ No newline at end of file +There are [existing event types](/events/) that you can follow, or you can [write your own events](/development/custom-events). diff --git a/docs/en/development/custom-options.md b/docs/en/development/custom-options.md index 7b30271..3a3431f 100644 --- a/docs/en/development/custom-options.md +++ b/docs/en/development/custom-options.md @@ -10,7 +10,7 @@ Simply use the `options` property to define options with their default values: import { BaseModule } from 'pointeract'; class YourModule extends BaseModule { - options = { + options = { customModule: true, }; } @@ -30,4 +30,4 @@ class YourModule extends BaseModule { } ``` -Your options will be merged into the user options passed into Pointeract. So when you access your options, it's already polyfilled with the user's options. \ No newline at end of file +Your options will be merged into the user options passed into Pointeract. So when you access your options, it's already polyfilled with the user's options. diff --git a/docs/en/development/modifier.md b/docs/en/development/modifier.md index 007bcfb..bea5140 100644 --- a/docs/en/development/modifier.md +++ b/docs/en/development/modifier.md @@ -34,8 +34,8 @@ class YourModule extends BaseModule { } ``` -The example above monitors the zoom event and logs the number of times it has been dispatched. It keeps all events unchanged. +The example above monitors the zoom event and logs the number of times it has been dispatched. It keeps all events unchanged. ::: info When multiple modifiers are used, the first modifier that does not return `true` will be the only one that is executed. -::: \ No newline at end of file +::: diff --git a/docs/en/development/testing.md b/docs/en/development/testing.md index 58df4f9..669d77c 100644 --- a/docs/en/development/testing.md +++ b/docs/en/development/testing.md @@ -14,6 +14,7 @@ Above is the current test coverage. ## Standards Pointeract should obey the test requirements as follows: + - When developing a new module, it is mandatory to write a unit test unless it's untestable. - The overall test coverage should be higher than 90%. @@ -27,4 +28,4 @@ The interaction denoted by the code is visualized as follows: ![Chaotic Testing](/chaoticTest.svg) -The aim of this test is to simulate chaotic multitouch drag, pan and zoom intends to ensure `drag` and `multitouchPanZoom` modules can survive extreme conditions. Pointeract coped it well. But when the similar test (manual human test) is conducted in other libraries like `Hammer.js` or `Interact.js`, [they failed](/whats-pointeract#how-pointeract-stands-out). \ No newline at end of file +The aim of this test is to simulate chaotic multitouch drag, pan and zoom intends to ensure `drag` and `multitouchPanZoom` modules can survive extreme conditions. Pointeract coped it well. But when the similar test (manual human test) is conducted in other libraries like `Hammer.js` or `Interact.js`, [they failed](/whats-pointeract#how-pointeract-stands-out). diff --git a/docs/en/events/drag.md b/docs/en/events/drag.md index bdf43ac..d3a7a95 100644 --- a/docs/en/events/drag.md +++ b/docs/en/events/drag.md @@ -17,4 +17,4 @@ type event = { ``` - `x/y`: the amount of drag - the difference between the current position and the position of the last dispatch. -- `clientX/clientY`: The position of the pointer when the drag event is triggered. \ No newline at end of file +- `clientX/clientY`: The position of the pointer when the drag event is triggered. diff --git a/docs/en/events/index.md b/docs/en/events/index.md index 51e2307..cbfdd19 100644 --- a/docs/en/events/index.md +++ b/docs/en/events/index.md @@ -6,12 +6,12 @@ The following events are parts of Pointeract standard schema: -| Event Name | Description (often appears when intending to) | -| :-------------------------------: | ------------------------------------------------- | -| [`drag`](/events/pan) | move a single element | -| [`pan`](/events/drag) | move the viewport in a canvas APP | -| [`zoom`](/events/drag) | change the scale of elements / an element | -| [`trueClick`](/events/true-click) | perform a simple click on an element | +| Event Name | Description (often appears when intending to) | +| :-------------------------------: | --------------------------------------------- | +| [`drag`](/events/pan) | move a single element | +| [`pan`](/events/drag) | move the viewport in a canvas APP | +| [`zoom`](/events/drag) | change the scale of elements / an element | +| [`trueClick`](/events/true-click) | perform a simple click on an element | ## Obtain Event Types @@ -34,4 +34,4 @@ function hook(event: typeof pointeract.events.drag) { ::: warning Do not use `pointeract.events.` directly as real events, they contain only event types. -::: \ No newline at end of file +::: diff --git a/docs/en/events/pan.md b/docs/en/events/pan.md index 765ed7d..cd75983 100644 --- a/docs/en/events/pan.md +++ b/docs/en/events/pan.md @@ -14,4 +14,4 @@ type event = { } ``` -- `x/y`: Amount of pan - the difference between the current position and the position of the last dispatch. \ No newline at end of file +- `x/y`: Amount of pan - the difference between the current position and the position of the last dispatch. diff --git a/docs/en/events/true-click.md b/docs/en/events/true-click.md index cb2c5a6..4d2fb8d 100644 --- a/docs/en/events/true-click.md +++ b/docs/en/events/true-click.md @@ -22,4 +22,4 @@ type event = { - `x/y`: The coordinates of the pointer when the click event is triggered. - `target`: The target element of the click event. -- `streak`: The number of clicks in a streak, you can use this ti detect double/triple/quadruple/any click or tap. \ No newline at end of file +- `streak`: The number of clicks in a streak, you can use this ti detect double/triple/quadruple/any click or tap. diff --git a/docs/en/events/zoom.md b/docs/en/events/zoom.md index d0a8ed3..7f362d4 100644 --- a/docs/en/events/zoom.md +++ b/docs/en/events/zoom.md @@ -16,4 +16,4 @@ type event = { ``` - `x/y`: The coordinates of the zoom origin. -- `factor`: The zoom factor, smaller than 1 zooms out, larger than 1 zooms in. \ No newline at end of file +- `factor`: The zoom factor, smaller than 1 zooms out, larger than 1 zooms in. diff --git a/docs/en/get-started.md b/docs/en/get-started.md index 6e5c6da..a46e157 100644 --- a/docs/en/get-started.md +++ b/docs/en/get-started.md @@ -11,25 +11,30 @@ Install Pointeract using your favorite package manager: ::: code-group + ```sh [npm] -$ npm add pointeract +npm add pointeract ``` + ```sh [pnpm] -$ pnpm add pointeract +pnpm add pointeract ``` + ```sh [yarn] -$ yarn add pointeract +yarn add pointeract ``` + ```sh [bun] -$ bun add pointeract +bun add pointeract ``` + ::: Or include the following lines directly in your HTML file: ```html ``` @@ -39,4 +44,4 @@ This link ships the latest ESM version by default, to access CJS version or earl ``` -The link above ships version 1.0.0 in CJS. \ No newline at end of file +The link above ships version 1.0.0 in CJS. diff --git a/docs/en/index.md b/docs/en/index.md index 9cc4df7..69f52c9 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -3,34 +3,34 @@ layout: home hero: - name: Pointeract - text: Modular Resolver of User Interactions - tagline: Modern, lightweight and robust alternative to Hammer.js and Interact.js. - actions: - - theme: brand - text: What's Pointeract? - link: /whats-pointeract - - theme: alt - text: Get Started - link: /get-started - - theme: alt - text: Playground - link: /playground - image: - src: /logo.svg - alt: Pointeract Logo + name: Pointeract + text: Modular Resolver of User Interactions + tagline: Modern, lightweight and robust alternative to Hammer.js and Interact.js. + actions: + - theme: brand + text: What's Pointeract? + link: /whats-pointeract + - theme: alt + text: Get Started + link: /get-started + - theme: alt + text: Playground + link: /playground + image: + src: /logo.svg + alt: Pointeract Logo features: - - title: Modern - icon: 🧪 - details: Written in TypeScript, succinct in size, wide compatibility. - - title: Scale from 1KB - icon: 🐣 - details: Grab what you need via modules, the base class is only 1KB gzipped. - - title: Extensible - icon: 🧩 - details: Write your own modules and plug into Pointeract via its module API. - - title: Robust - icon: 💪 - details: Full touchpad support, excels at complex gestures where most interaction libraries fail. ---- \ No newline at end of file + - title: Modern + icon: 🧪 + details: Written in TypeScript, succinct in size, wide compatibility. + - title: Scale from 1KB + icon: 🐣 + details: Grab what you need via modules, the base class is only 1KB gzipped. + - title: Extensible + icon: 🧩 + details: Write your own modules and plug into Pointeract via its module API. + - title: Robust + icon: 💪 + details: Full touchpad support, excels at complex gestures where most interaction libraries fail. +--- diff --git a/docs/en/modules/click.md b/docs/en/modules/click.md index aa026e5..d61f0bd 100644 --- a/docs/en/modules/click.md +++ b/docs/en/modules/click.md @@ -21,4 +21,4 @@ type options = { ``` - `clickPreserveTime`: The interval in milliseconds between which two click event are considered in a streak. Defaults to **400**. -- `moveThreshold`: The upper limit in pixels for pointer movement to be considered a click. Defaults to **5**. \ No newline at end of file +- `moveThreshold`: The upper limit in pixels for pointer movement to be considered a click. Defaults to **5**. diff --git a/docs/en/modules/index.md b/docs/en/modules/index.md index c8cb21d..807cd42 100644 --- a/docs/en/modules/index.md +++ b/docs/en/modules/index.md @@ -6,17 +6,18 @@ Modules are the heart of Pointeract. Here you can find all modules shipped with Pointeract: -| Module | Target | Description | +| Module | Target | Description | | :-----------------------------------------------: | :------------: | ------------------------------------------------------- | -| [PreventDefault](/modules/prevent-default) | The Element | Prevents default browser behavior. | -| [Click](/modules/click) | Single Pointer | Checks if a click was performed without any movement. | -| [Drag](/modules/drag) | Single Pointer | Tracks pointer movement and emits drag events. | -| [WheelPanZoom](/modules/wheel-pan-zoom) | Mouse Wheel | Tracks pointer wheel movement and key press. | -| [MultiTouchPanZoom](/modules/multitouch-pan-zoom) | Multitouch | Resolves pan/zoom by analyzing movement of two touches. | +| [PreventDefault](/modules/prevent-default) | The Element | Prevents default browser behavior. | +| [Click](/modules/click) | Single Pointer | Checks if a click was performed without any movement. | +| [Drag](/modules/drag) | Single Pointer | Tracks pointer movement and emits drag events. | +| [WheelPanZoom](/modules/wheel-pan-zoom) | Mouse Wheel | Tracks pointer wheel movement and key press. | +| [MultiTouchPanZoom](/modules/multitouch-pan-zoom) | Multitouch | Resolves pan/zoom by analyzing movement of two touches. | ## Module Types Conversion TypeScript class behavior is weird: + - In actual runtime logic, a constructor is constructor. - But When you are passing a class constructor as a type, it actually infers the class instance type. - You need to use `typeof` to get the constructor type. @@ -49,4 +50,4 @@ For this reason, Pointeract has a type helper export `Ctors>; type options = Options>; -``` \ No newline at end of file +``` diff --git a/docs/en/modules/prevent-default.md b/docs/en/modules/prevent-default.md index 0015492..5030ca8 100644 --- a/docs/en/modules/prevent-default.md +++ b/docs/en/modules/prevent-default.md @@ -7,4 +7,4 @@ This module disables all default browser behaviors related to touch/mouse/wheel ```TypeScript import { PreventDefault, Pointeract } from 'pointeract'; const pointeract = new Pointeract(app, PreventDefault); -``` \ No newline at end of file +``` diff --git a/docs/en/modules/wheel-pan-zoom.md b/docs/en/modules/wheel-pan-zoom.md index 51cb408..2bc8be2 100644 --- a/docs/en/modules/wheel-pan-zoom.md +++ b/docs/en/modules/wheel-pan-zoom.md @@ -9,6 +9,7 @@ This module monitors wheel events, resolves them and emits pan/zoom events. It s **Normal Control Schema**: uses the mouse wheel to zoom. **Professional Control Schema**: + - **Zoom**: mouse wheel + `ctrl` key - **Pan Horizontally**: mouse wheel + `shift` key - **Pan Vertically**: mouse wheel @@ -30,10 +31,10 @@ const pointeract = new Pointeract(app, WheelPanZoom); type options = { proControlSchema: boolean; lockControlSchema: boolean; - zoomFactor: number; + zoomFactor: number; } ``` - `proControlSchema`: Whether to use the professional control schema, you can reactively change this during runtime. Defaults to **false**. - `lockControlSchema`: Whether to disable schema auto-detection. Defaults to **false**. -- `zoomFactor`: How fast it zooms. Defaults to **0.1**. \ No newline at end of file +- `zoomFactor`: How fast it zooms. Defaults to **0.1**. diff --git a/docs/en/playground.md b/docs/en/playground.md index 3c4d217..e0ac6a8 100644 --- a/docs/en/playground.md +++ b/docs/en/playground.md @@ -6,8 +6,6 @@ Loaded modules: [`PreventDefault`](/modules/prevent-default) [`Drag`](/modules/d import Playground from '../components/playground.vue' - - - + -Try it out! drag, pan, zoom, pinch, click, etc. \ No newline at end of file +Try it out! drag, pan, zoom, pinch, click, etc. diff --git a/docs/en/whats-pointeract.md b/docs/en/whats-pointeract.md index b59c6e9..682820a 100644 --- a/docs/en/whats-pointeract.md +++ b/docs/en/whats-pointeract.md @@ -29,16 +29,16 @@ Missing your desired interaction? [Write your own module](/development/custom-mo There're already plenty of interaction libraries out there, most famous ones are `Interact.js` and `Hammer.js`, but Pointeract is different. -| Criteria | Pointeract | [Hammer.js](https://hammerjs.github.io) | [Interact.js](https://interactjs.io) | -|:--------------------------------------------------------------|:-----------------------------------------------------:|:------------------------------------------------:|:---------------------------------------------------:| -| Written in TypeScript? | ✅ | ❌ | ✅ | -| Tree-shakeable? | [✅](https://bundlephobia.com/package/pointeract) | [❌](https://bundlephobia.com/package/hammerjs) | [❌](https://bundlephobia.com/package/interactjs) | +| Criteria | Pointeract | [Hammer.js](https://hammerjs.github.io) | [Interact.js](https://interactjs.io) | +| :------------------------------------------------------------ | :---------------------------------------------------: | :----------------------------------------------: | :-------------------------------------------------: | +| Written in TypeScript? | ✅ | ❌ | ✅ | +| Tree-shakeable? | [✅](https://bundlephobia.com/package/pointeract) | [❌](https://bundlephobia.com/package/hammerjs) | [❌](https://bundlephobia.com/package/interactjs) | | Bundle Size (Minified + Gzipped) | 👑 [2KB](https://bundlephobia.com/package/pointeract) | [7KB](https://bundlephobia.com/package/hammerjs) | [28KB](https://bundlephobia.com/package/interactjs) | -| Last Updated | 👑 Actively Maintained | 2015 | 2023 | -| Features | Pointer and Wheel Related | Pointer Related | 👑 Pointer and Wheel Related + Comprehensive Utils | -| Robust? (See [Testing](/development/testing#chaotic-testing)) | ✅ | ❌ Element Jerks | ❌ Element Ignores the Second Touch | -| Extensible? | ✅ | ❌ | ❌ | +| Last Updated | 👑 Actively Maintained | 2015 | 2023 | +| Features | Pointer and Wheel Related | Pointer Related | 👑 Pointer and Wheel Related + Comprehensive Utils | +| Robust? (See [Testing](/development/testing#chaotic-testing)) | ✅ | ❌ Element Jerks | ❌ Element Ignores the Second Touch | +| Extensible? | ✅ | ❌ | ❌ | ## License -Pointeract is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html). \ No newline at end of file +Pointeract is licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html). diff --git a/package.json b/package.json index 07f263e..90e0ff6 100644 --- a/package.json +++ b/package.json @@ -2,47 +2,55 @@ "name": "pointeract", "version": "1.0.1", "description": "Modern, lightweight, robust and extensible user interaction resolver.", + "keywords": [ + "frontend", + "interaction", + "pointer-events", + "typescript" + ], + "homepage": "https://pointeract.consensia.cc", + "bugs": { + "url": "https://github.com/hesprs/pointeract/issues" + }, + "license": "MIT", + "author": { + "name": "Hēsperus", + "email": "hesprs@outlook.com" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/hesprs/pointeract.git" + }, + "files": [ + "dist" + ], + "type": "module", + "sideEffects": false, "main": "./dist/index.cjs", "module": "./dist/index.js", "types": "./dist/types/index.d.ts", - "type": "module", + "publishConfig": { + "access": "public", + "provenance": true + }, "scripts": { "build": "vite build && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json", "test": "vitest run", - "lint": "biome check --write", + "lint": "oxlint --type-aware --fix && oxfmt", "test:coverage": "vitest run --coverage", - "check": "tsc && biome check", + "check": "tsc && oxfmt --check && oxlint --type-aware", "dev": "vite", "docs:dev": "vitepress dev docs", "docs:build": "vitepress build docs", "docs:preview": "vitepress preview docs" }, - "repository": { - "type": "git", - "url": "git+https://github.com/hesprs/pointeract.git" - }, - "homepage": "https://pointeract.consensia.cc", - "bugs": { - "url": "https://github.com/hesprs/pointeract/issues" - }, - "files": ["dist"], - "publishConfig": { - "provenance": true, - "access": "public" - }, - "keywords": ["frontend", "pointer-events", "interaction", "typescript"], - "sideEffects": false, - "author": { - "name": "Hēsperus", - "email": "hesprs@outlook.com" - }, - "license": "MIT", - "packageManager": "pnpm@10.23.0", "devDependencies": { - "@biomejs/biome": "^2.3.10", "@types/node": "^25.0.3", "@vitest/coverage-v8": "^4.0.16", "happy-dom": "^20.0.11", + "oxfmt": "^0.24.0", + "oxlint": "^1.39.0", + "oxlint-tsgolint": "^0.11.1", "terser": "^5.44.1", "tsc-alias": "^1.8.16", "typescript": "^5.9.3", @@ -51,5 +59,6 @@ "vitepress-plugin-group-icons": "^1.6.5", "vitest": "^4.0.16", "vue": "^3.5.26" - } + }, + "packageManager": "pnpm@10.23.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index af10cee..6bf920d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,6 @@ importers: .: devDependencies: - '@biomejs/biome': - specifier: ^2.3.10 - version: 2.3.11 '@types/node': specifier: ^25.0.3 version: 25.0.7 @@ -20,6 +17,15 @@ importers: happy-dom: specifier: ^20.0.11 version: 20.1.0 + oxfmt: + specifier: ^0.24.0 + version: 0.24.0 + oxlint: + specifier: ^1.39.0 + version: 1.39.0(oxlint-tsgolint@0.11.1) + oxlint-tsgolint: + specifier: ^0.11.1 + version: 0.11.1 terser: specifier: ^5.44.1 version: 5.44.1 @@ -88,59 +94,6 @@ packages: resolution: {integrity: sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==} engines: {node: '>=18'} - '@biomejs/biome@2.3.11': - resolution: {integrity: sha512-/zt+6qazBWguPG6+eWmiELqO+9jRsMZ/DBU3lfuU2ngtIQYzymocHhKiZRyrbra4aCOoyTg/BmY+6WH5mv9xmQ==} - engines: {node: '>=14.21.3'} - hasBin: true - - '@biomejs/cli-darwin-arm64@2.3.11': - resolution: {integrity: sha512-/uXXkBcPKVQY7rc9Ys2CrlirBJYbpESEDme7RKiBD6MmqR2w3j0+ZZXRIL2xiaNPsIMMNhP1YnA+jRRxoOAFrA==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [darwin] - - '@biomejs/cli-darwin-x64@2.3.11': - resolution: {integrity: sha512-fh7nnvbweDPm2xEmFjfmq7zSUiox88plgdHF9OIW4i99WnXrAC3o2P3ag9judoUMv8FCSUnlwJCM1B64nO5Fbg==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [darwin] - - '@biomejs/cli-linux-arm64-musl@2.3.11': - resolution: {integrity: sha512-XPSQ+XIPZMLaZ6zveQdwNjbX+QdROEd1zPgMwD47zvHV+tCGB88VH+aynyGxAHdzL+Tm/+DtKST5SECs4iwCLg==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [linux] - - '@biomejs/cli-linux-arm64@2.3.11': - resolution: {integrity: sha512-l4xkGa9E7Uc0/05qU2lMYfN1H+fzzkHgaJoy98wO+b/7Gl78srbCRRgwYSW+BTLixTBrM6Ede5NSBwt7rd/i6g==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [linux] - - '@biomejs/cli-linux-x64-musl@2.3.11': - resolution: {integrity: sha512-vU7a8wLs5C9yJ4CB8a44r12aXYb8yYgBn+WeyzbMjaCMklzCv1oXr8x+VEyWodgJt9bDmhiaW/I0RHbn7rsNmw==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [linux] - - '@biomejs/cli-linux-x64@2.3.11': - resolution: {integrity: sha512-/1s9V/H3cSe0r0Mv/Z8JryF5x9ywRxywomqZVLHAoa/uN0eY7F8gEngWKNS5vbbN/BsfpCG5yeBT5ENh50Frxg==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [linux] - - '@biomejs/cli-win32-arm64@2.3.11': - resolution: {integrity: sha512-PZQ6ElCOnkYapSsysiTy0+fYX+agXPlWugh6+eQ6uPKI3vKAqNp6TnMhoM3oY2NltSB89hz59o8xIfOdyhi9Iw==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [win32] - - '@biomejs/cli-win32-x64@2.3.11': - resolution: {integrity: sha512-43VrG813EW+b5+YbDbz31uUsheX+qFKCpXeY9kfdAx+ww3naKxeVkTD9zLIWxUPfJquANMHrmW3wbe/037G0Qg==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [win32] - '@csstools/color-helpers@5.1.0': resolution: {integrity: sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA==} engines: {node: '>=18'} @@ -378,6 +331,116 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} + '@oxfmt/darwin-arm64@0.24.0': + resolution: {integrity: sha512-aYXuGf/yq8nsyEcHindGhiz9I+GEqLkVq8CfPbd+6VE259CpPEH+CaGHEO1j6vIOmNr8KHRq+IAjeRO2uJpb8A==} + cpu: [arm64] + os: [darwin] + + '@oxfmt/darwin-x64@0.24.0': + resolution: {integrity: sha512-vs3b8Bs53hbiNvcNeBilzE/+IhDTWKjSBB3v/ztr664nZk65j0xr+5IHMBNz3CFppmX7o/aBta2PxY+t+4KoPg==} + cpu: [x64] + os: [darwin] + + '@oxfmt/linux-arm64-gnu@0.24.0': + resolution: {integrity: sha512-ItPDOPoQ0wLj/s8osc5ch57uUcA1Wk8r0YdO8vLRpXA3UNg7KPOm1vdbkIZRRiSUphZcuX5ioOEetEK8H7RlTw==} + cpu: [arm64] + os: [linux] + + '@oxfmt/linux-arm64-musl@0.24.0': + resolution: {integrity: sha512-JkQO3WnQjQTJONx8nxdgVBfl6BBFfpp9bKhChYhWeakwJdr7QPOAWJ/v3FGZfr0TbqINwnNR74aVZayDDRyXEA==} + cpu: [arm64] + os: [linux] + + '@oxfmt/linux-x64-gnu@0.24.0': + resolution: {integrity: sha512-N/SXlFO+2kak5gMt0oxApi0WXQDhwA0PShR0UbkY0PwtHjfSiDqJSOumyNqgQVoroKr1GNnoRmUqjZIz6DKIcw==} + cpu: [x64] + os: [linux] + + '@oxfmt/linux-x64-musl@0.24.0': + resolution: {integrity: sha512-WM0pek5YDCQf50XQ7GLCE9sMBCMPW/NPAEPH/Hx6Qyir37lEsP4rUmSECo/QFNTU6KBc9NnsviAyJruWPpCMXw==} + cpu: [x64] + os: [linux] + + '@oxfmt/win32-arm64@0.24.0': + resolution: {integrity: sha512-vFCseli1KWtwdHrVlT/jWfZ8jP8oYpnPPEjI23mPLW8K/6GEJmmvy0PZP5NpWUFNTzX0lqie58XnrATJYAe9Xw==} + cpu: [arm64] + os: [win32] + + '@oxfmt/win32-x64@0.24.0': + resolution: {integrity: sha512-0tmlNzcyewAnauNeBCq0xmAkmiKzl+H09p0IdHy+QKrTQdtixtf+AOjDAADbRfihkS+heF15Pjc4IyJMdAAJjw==} + cpu: [x64] + os: [win32] + + '@oxlint-tsgolint/darwin-arm64@0.11.1': + resolution: {integrity: sha512-UJIOFeJZpFTJIGS+bMdFXcvjslvnXBEouMvzynfQD7RTazcFIRLbokYgEbhrN2P6B352Ut1TUtvR0CLAp/9QfA==} + cpu: [arm64] + os: [darwin] + + '@oxlint-tsgolint/darwin-x64@0.11.1': + resolution: {integrity: sha512-68O8YvexIm+ISZKl2vBFII1dMfLrteDyPcuCIecDuiBIj2tV0KYq13zpSCMz4dvJUWJW6RmOOGZKrkkvOAy6uQ==} + cpu: [x64] + os: [darwin] + + '@oxlint-tsgolint/linux-arm64@0.11.1': + resolution: {integrity: sha512-hXBInrFxPNbPPbPQYozo8YpSsFFYdtHBWRUiLMxul71vTy1CdSA7H5Qq2KbrKomr/ASmhvIDVAQZxh9hIJNHMA==} + cpu: [arm64] + os: [linux] + + '@oxlint-tsgolint/linux-x64@0.11.1': + resolution: {integrity: sha512-aMaGctlwrJhaIQPOdVJR+AGHZGPm4D1pJ457l0SqZt4dLXAhuUt2ene6cUUGF+864R7bDyFVGZqbZHODYpENyA==} + cpu: [x64] + os: [linux] + + '@oxlint-tsgolint/win32-arm64@0.11.1': + resolution: {integrity: sha512-ipOs6kKo8fz5n5LSHvcbyZFmEpEIsh2m7+B03RW3jGjBEPMiXb4PfKNuxnusFYTtJM9WaR3bCVm5UxeJTA8r3w==} + cpu: [arm64] + os: [win32] + + '@oxlint-tsgolint/win32-x64@0.11.1': + resolution: {integrity: sha512-m2apsAXg6qU3ulQG45W/qshyEpOjoL+uaQyXJG5dBoDoa66XPtCaSkBlKltD0EwGu0aoB8lM4I5I3OzQ6raNhw==} + cpu: [x64] + os: [win32] + + '@oxlint/darwin-arm64@1.39.0': + resolution: {integrity: sha512-lT3hNhIa02xCujI6YGgjmYGg3Ht/X9ag5ipUVETaMpx5Rd4BbTNWUPif1WN1YZHxt3KLCIqaAe7zVhatv83HOQ==} + cpu: [arm64] + os: [darwin] + + '@oxlint/darwin-x64@1.39.0': + resolution: {integrity: sha512-UT+rfTWd+Yr7iJeSLd/7nF8X4gTYssKh+n77hxl6Oilp3NnG1CKRHxZDy3o3lIBnwgzJkdyUAiYWO1bTMXQ1lA==} + cpu: [x64] + os: [darwin] + + '@oxlint/linux-arm64-gnu@1.39.0': + resolution: {integrity: sha512-qocBkvS2V6rH0t9AT3DfQunMnj3xkM7srs5/Ycj2j5ZqMoaWd/FxHNVJDFP++35roKSvsRJoS0mtA8/77jqm6Q==} + cpu: [arm64] + os: [linux] + + '@oxlint/linux-arm64-musl@1.39.0': + resolution: {integrity: sha512-arZzAc1PPcz9epvGBBCMHICeyQloKtHX3eoOe62B3Dskn7gf6Q14wnDHr1r9Vp4vtcBATNq6HlKV14smdlC/qA==} + cpu: [arm64] + os: [linux] + + '@oxlint/linux-x64-gnu@1.39.0': + resolution: {integrity: sha512-ZVt5qsECpuNprdWxAPpDBwoixr1VTcZ4qAEQA2l/wmFyVPDYFD3oBY/SWACNnWBddMrswjTg9O8ALxYWoEpmXw==} + cpu: [x64] + os: [linux] + + '@oxlint/linux-x64-musl@1.39.0': + resolution: {integrity: sha512-pB0hlGyKPbxr9NMIV783lD6cWL3MpaqnZRM9MWni4yBdHPTKyFNYdg5hGD0Bwg+UP4S2rOevq/+OO9x9Bi7E6g==} + cpu: [x64] + os: [linux] + + '@oxlint/win32-arm64@1.39.0': + resolution: {integrity: sha512-Gg2SFaJohI9+tIQVKXlPw3FsPQFi/eCSWiCgwPtPn5uzQxHRTeQEZKuluz1fuzR5U70TXubb2liZi4Dgl8LJQA==} + cpu: [arm64] + os: [win32] + + '@oxlint/win32-x64@1.39.0': + resolution: {integrity: sha512-sbi25lfj74hH+6qQtb7s1wEvd1j8OQbTaH8v3xTcDjrwm579Cyh0HBv1YSZ2+gsnVwfVDiCTL1D0JsNqYXszVA==} + cpu: [x64] + os: [win32] + '@rolldown/pluginutils@1.0.0-beta.53': resolution: {integrity: sha512-vENRlFU4YbrwVqNDZ7fLvy+JR1CRkyr01jhSiDpE1u6py3OMzQfztQU2jxykW3ALNxO4kSlqIDeYyD0Y9RcQeQ==} @@ -1070,6 +1133,25 @@ packages: oniguruma-to-es@4.3.4: resolution: {integrity: sha512-3VhUGN3w2eYxnTzHn+ikMI+fp/96KoRSVK9/kMTcFqj1NRDh2IhQCKvYxDnWePKRXY/AqH+Fuiyb7VHSzBjHfA==} + oxfmt@0.24.0: + resolution: {integrity: sha512-UjeM3Peez8Tl7IJ9s5UwAoZSiDRMww7BEc21gDYxLq3S3/KqJnM3mjNxsoSHgmBvSeX6RBhoVc2MfC/+96RdSw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + oxlint-tsgolint@0.11.1: + resolution: {integrity: sha512-WulCp+0/6RvpM4zPv+dAXybf03QvRA8ATxaBlmj4XMIQqTs5jeq3cUTk48WCt4CpLwKhyyGZPHmjLl1KHQ/cvA==} + hasBin: true + + oxlint@1.39.0: + resolution: {integrity: sha512-wSiLr0wjG+KTU6c1LpVoQk7JZ7l8HCKlAkVDVTJKWmCGazsNxexxnOXl7dsar92mQcRnzko5g077ggP3RINSjA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + oxlint-tsgolint: '>=0.10.0' + peerDependenciesMeta: + oxlint-tsgolint: + optional: true + package-manager-detector@1.6.0: resolution: {integrity: sha512-61A5ThoTiDG/C8s8UMZwSorAGwMJ0ERVGj2OjoW5pAalsNOg15+iQiPzrLJ4jhZ1HJzmC2PIHT2oEiH3R5fzNA==} @@ -1236,6 +1318,10 @@ packages: resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} engines: {node: '>=12.0.0'} + tinypool@2.0.0: + resolution: {integrity: sha512-/RX9RzeH2xU5ADE7n2Ykvmi9ED3FBGPAjw9u3zucrNNaEBIO0HPSYgL0NT7+3p147ojeSdaVu08F6hjpv31HJg==} + engines: {node: ^20.0.0 || >=22.0.0} + tinyrainbow@3.0.3: resolution: {integrity: sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==} engines: {node: '>=14.0.0'} @@ -1509,41 +1595,6 @@ snapshots: '@bcoe/v8-coverage@1.0.2': {} - '@biomejs/biome@2.3.11': - optionalDependencies: - '@biomejs/cli-darwin-arm64': 2.3.11 - '@biomejs/cli-darwin-x64': 2.3.11 - '@biomejs/cli-linux-arm64': 2.3.11 - '@biomejs/cli-linux-arm64-musl': 2.3.11 - '@biomejs/cli-linux-x64': 2.3.11 - '@biomejs/cli-linux-x64-musl': 2.3.11 - '@biomejs/cli-win32-arm64': 2.3.11 - '@biomejs/cli-win32-x64': 2.3.11 - - '@biomejs/cli-darwin-arm64@2.3.11': - optional: true - - '@biomejs/cli-darwin-x64@2.3.11': - optional: true - - '@biomejs/cli-linux-arm64-musl@2.3.11': - optional: true - - '@biomejs/cli-linux-arm64@2.3.11': - optional: true - - '@biomejs/cli-linux-x64-musl@2.3.11': - optional: true - - '@biomejs/cli-linux-x64@2.3.11': - optional: true - - '@biomejs/cli-win32-arm64@2.3.11': - optional: true - - '@biomejs/cli-win32-x64@2.3.11': - optional: true - '@csstools/color-helpers@5.1.0': optional: true @@ -1707,6 +1758,72 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.19.1 + '@oxfmt/darwin-arm64@0.24.0': + optional: true + + '@oxfmt/darwin-x64@0.24.0': + optional: true + + '@oxfmt/linux-arm64-gnu@0.24.0': + optional: true + + '@oxfmt/linux-arm64-musl@0.24.0': + optional: true + + '@oxfmt/linux-x64-gnu@0.24.0': + optional: true + + '@oxfmt/linux-x64-musl@0.24.0': + optional: true + + '@oxfmt/win32-arm64@0.24.0': + optional: true + + '@oxfmt/win32-x64@0.24.0': + optional: true + + '@oxlint-tsgolint/darwin-arm64@0.11.1': + optional: true + + '@oxlint-tsgolint/darwin-x64@0.11.1': + optional: true + + '@oxlint-tsgolint/linux-arm64@0.11.1': + optional: true + + '@oxlint-tsgolint/linux-x64@0.11.1': + optional: true + + '@oxlint-tsgolint/win32-arm64@0.11.1': + optional: true + + '@oxlint-tsgolint/win32-x64@0.11.1': + optional: true + + '@oxlint/darwin-arm64@1.39.0': + optional: true + + '@oxlint/darwin-x64@1.39.0': + optional: true + + '@oxlint/linux-arm64-gnu@1.39.0': + optional: true + + '@oxlint/linux-arm64-musl@1.39.0': + optional: true + + '@oxlint/linux-x64-gnu@1.39.0': + optional: true + + '@oxlint/linux-x64-musl@1.39.0': + optional: true + + '@oxlint/win32-arm64@1.39.0': + optional: true + + '@oxlint/win32-x64@1.39.0': + optional: true + '@rolldown/pluginutils@1.0.0-beta.53': {} '@rollup/rollup-android-arm-eabi@4.55.1': @@ -2434,6 +2551,40 @@ snapshots: regex: 6.1.0 regex-recursion: 6.0.2 + oxfmt@0.24.0: + dependencies: + tinypool: 2.0.0 + optionalDependencies: + '@oxfmt/darwin-arm64': 0.24.0 + '@oxfmt/darwin-x64': 0.24.0 + '@oxfmt/linux-arm64-gnu': 0.24.0 + '@oxfmt/linux-arm64-musl': 0.24.0 + '@oxfmt/linux-x64-gnu': 0.24.0 + '@oxfmt/linux-x64-musl': 0.24.0 + '@oxfmt/win32-arm64': 0.24.0 + '@oxfmt/win32-x64': 0.24.0 + + oxlint-tsgolint@0.11.1: + optionalDependencies: + '@oxlint-tsgolint/darwin-arm64': 0.11.1 + '@oxlint-tsgolint/darwin-x64': 0.11.1 + '@oxlint-tsgolint/linux-arm64': 0.11.1 + '@oxlint-tsgolint/linux-x64': 0.11.1 + '@oxlint-tsgolint/win32-arm64': 0.11.1 + '@oxlint-tsgolint/win32-x64': 0.11.1 + + oxlint@1.39.0(oxlint-tsgolint@0.11.1): + optionalDependencies: + '@oxlint/darwin-arm64': 1.39.0 + '@oxlint/darwin-x64': 1.39.0 + '@oxlint/linux-arm64-gnu': 1.39.0 + '@oxlint/linux-arm64-musl': 1.39.0 + '@oxlint/linux-x64-gnu': 1.39.0 + '@oxlint/linux-x64-musl': 1.39.0 + '@oxlint/win32-arm64': 1.39.0 + '@oxlint/win32-x64': 1.39.0 + oxlint-tsgolint: 0.11.1 + package-manager-detector@1.6.0: {} parse5@8.0.0: @@ -2612,6 +2763,8 @@ snapshots: fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 + tinypool@2.0.0: {} + tinyrainbow@3.0.3: {} tldts-core@7.0.19: diff --git a/src/baseModule.ts b/src/baseModule.ts index bb1a118..5a56e5d 100644 --- a/src/baseModule.ts +++ b/src/baseModule.ts @@ -1,4 +1,11 @@ -import type { Constrain, GeneralObject, ModifierReturn, Pointer, Pointers, StdEvents } from '@/declarations'; +import type { + Constrain, + GeneralObject, + ModifierReturn, + Pointer, + Pointers, + StdEvents, +} from '@/declarations'; import type Pointeract from '@/pointeract'; type IsAny = 0 extends 1 & T ? true : false; diff --git a/src/declarations.ts b/src/declarations.ts index 6793740..f8d2d1b 100644 --- a/src/declarations.ts +++ b/src/declarations.ts @@ -36,7 +36,9 @@ export type Options = Partial< UnionToIntersection['options']>> & BaseOptions >; -export type EventMap = Constrain['events']>>; +export type EventMap = Constrain< + UnionToIntersection['events']> +>; export type Reloadable = WrapInArray[number]; diff --git a/src/modules/multitouchPanZoom.ts b/src/modules/multitouchPanZoom.ts index ef488f2..3a3b1f3 100644 --- a/src/modules/multitouchPanZoom.ts +++ b/src/modules/multitouchPanZoom.ts @@ -28,7 +28,9 @@ export default class MultitouchPanZoom extends BaseModule { onPointerDown = (_e: PointerEvent, _pointer: Pointer, pointers: Pointers) => { if (pointers.size === 2) { this.#pinchZoomState.lastDistance = this.#getPointerDistance(); - this.#pinchZoomState.lastMidpoint = this.utils.screenToTarget(this.#getPointerMidpoint()); + this.#pinchZoomState.lastMidpoint = this.utils.screenToTarget( + this.#getPointerMidpoint(), + ); } }; diff --git a/src/pointeract.ts b/src/pointeract.ts index d351db3..af7227f 100644 --- a/src/pointeract.ts +++ b/src/pointeract.ts @@ -33,7 +33,7 @@ export default class Pointeract extends EventTarget this.#monitoringElement = monitoringElement; this.options = options; this.#fillIn({ coordinateOutput: 'relative' }); - modules.forEach(module => { + modules.forEach((module) => { const instance = new module( this.moduleUtils, this.#window, @@ -103,7 +103,7 @@ export default class Pointeract extends EventTarget }; #runHooks(field: Hooks, ...args: GeneralArguments) { - Object.values(this.#modules).forEach(module => { + Object.values(this.#modules).forEach((module) => { if (module[field]) module[field](...args); }); } @@ -152,7 +152,7 @@ export default class Pointeract extends EventTarget }; if (!_toStop) stopPointeract(); else - toArray(_toStop).forEach(module => { + toArray(_toStop).forEach((module) => { stopModule(module); }); return this; @@ -175,7 +175,7 @@ export default class Pointeract extends EventTarget }; if (!_toStart) startPointeract(); else - toArray(_toStart).forEach(module => { + toArray(_toStart).forEach((module) => { startModule(module); }); return this; diff --git a/tests/click.test.ts b/tests/click.test.ts index 91d9c72..2d052cf 100644 --- a/tests/click.test.ts +++ b/tests/click.test.ts @@ -1,8 +1,9 @@ -import { expect, test } from 'vitest'; import { Click } from '@'; +import { expect, test } from 'vitest'; + import setup from './testUtils'; -test('trigger a trueClick', () => { +test('trigger a trueClick', async () => { const { acc, dispose, Pointer } = setup(Click); const p = new Pointer(); for (let i = 0; i < 3; i++) { @@ -10,20 +11,20 @@ test('trigger a trueClick', () => { p.up(); } expect(acc.clicks).toBe(3); - dispose(); + await dispose(); }); -test('trigger an shifted click that is not a trueClick', () => { +test('trigger an shifted click that is not a trueClick', async () => { const { acc, dispose, Pointer } = setup(Click); const p = new Pointer(); p.down(); p.move({ x: 10, y: 10 }); p.up(); expect(acc.clicks).toBe(0); - dispose(); + await dispose(); }); -test('trigger an interrupted click that is not a trueClick', () => { +test('trigger an interrupted click that is not a trueClick', async () => { const { acc, dispose, Pointer } = setup(Click); const p1 = new Pointer(); const p2 = new Pointer(); @@ -32,5 +33,5 @@ test('trigger an interrupted click that is not a trueClick', () => { p2.up(); p1.up(); expect(acc.clicks).toBe(0); - dispose(); + await dispose(); }); diff --git a/tests/dev/index.html b/tests/dev/index.html index edae5f6..78ce67f 100644 --- a/tests/dev/index.html +++ b/tests/dev/index.html @@ -1,38 +1,38 @@ - + Pointeract Test diff --git a/tests/dev/script.ts b/tests/dev/script.ts index 8f76f4f..213aaa8 100644 --- a/tests/dev/script.ts +++ b/tests/dev/script.ts @@ -1,4 +1,12 @@ -import { Click, Drag, MultitouchPanZoom, Pointeract, PreventDefault, type StdEvents, WheelPanZoom } from '@'; +import { + Click, + Drag, + MultitouchPanZoom, + Pointeract, + PreventDefault, + type StdEvents, + WheelPanZoom, +} from '@'; const square = document.getElementById('test-square') as HTMLElement; const data = { diff --git a/tests/drag.test.ts b/tests/drag.test.ts index 572d1c7..3e89112 100644 --- a/tests/drag.test.ts +++ b/tests/drag.test.ts @@ -1,13 +1,14 @@ -import { expect, test } from 'vitest'; import { Drag } from '@'; +import { expect, test } from 'vitest'; + import setup from './testUtils'; -test('drag', () => { +test('drag', async () => { const { acc, dispose, Pointer } = setup(Drag); const p = new Pointer(); p.down(); p.move({ x: 100, y: 100 }); p.up(); expect(acc.drag).toEqual({ x: 100, y: 100 }); - dispose(); + await dispose(); }); diff --git a/tests/integration.test.ts b/tests/integration.test.ts index 718209d..7a88400 100644 --- a/tests/integration.test.ts +++ b/tests/integration.test.ts @@ -1,8 +1,9 @@ -import { expect, test } from 'vitest'; import { Click, Drag, MultitouchPanZoom, PreventDefault } from '@'; +import { expect, test } from 'vitest'; + import setup from './testUtils'; -test('hot stop / start a module', () => { +test('hot stop / start a module', async () => { const { acc, dispose, Pointer, pointeract } = setup([Click, PreventDefault], { coordinateOutput: 'relativeFraction', }); @@ -22,11 +23,11 @@ test('hot stop / start a module', () => { } expect(acc.clicks).toBe(3); - dispose(); + await dispose(); }); // #region chaotic-test -test('chaotic movements', () => { +test('chaotic movements', async () => { const { acc, dispose, Pointer } = setup([MultitouchPanZoom, Drag]); const p1 = new Pointer(); const p2 = new Pointer(); @@ -68,6 +69,6 @@ test('chaotic movements', () => { expect(pos).toEqual({ x: -100, y: -300 }); // result: left 100, up 300 expect(1.7 < acc.scale && acc.scale < 1.72).toBe(true); - dispose(); + await dispose(); }); // #endregion diff --git a/tests/mockRect.ts b/tests/mockRect.ts index aa5bd51..628d9af 100644 --- a/tests/mockRect.ts +++ b/tests/mockRect.ts @@ -2,29 +2,31 @@ import { beforeEach, vi } from 'vitest'; beforeEach(() => { // Mock getBoundingClientRect globally - vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (this: HTMLElement) { - // Only mock for our test element - if (this.id === 'test-square') { + vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation( + function (this: HTMLElement) { + // Only mock for our test element + if (this.id === 'test-square') { + return { + width: 200, + height: 200, + left: 0, + top: 0, + right: 200, + bottom: 200, + x: 0, + y: 0, + } as DOMRect; + } return { - width: 200, - height: 200, + width: 0, + height: 0, left: 0, top: 0, - right: 200, - bottom: 200, + right: 0, + bottom: 0, x: 0, y: 0, } as DOMRect; - } - return { - width: 0, - height: 0, - left: 0, - top: 0, - right: 0, - bottom: 0, - x: 0, - y: 0, - } as DOMRect; - }); + }, + ); }); diff --git a/tests/multiTouch.test.ts b/tests/multiTouch.test.ts index 674c07b..fa0a84d 100644 --- a/tests/multiTouch.test.ts +++ b/tests/multiTouch.test.ts @@ -1,8 +1,9 @@ -import { expect, test } from 'vitest'; import { MultitouchPanZoom } from '@'; +import { expect, test } from 'vitest'; + import setup from './testUtils'; -test('two touches 100px apart, zoom in and pan up', () => { +test('two touches 100px apart, zoom in and pan up', async () => { const { acc, dispose, Pointer } = setup(MultitouchPanZoom); const p1 = new Pointer(); const p2 = new Pointer(); @@ -20,5 +21,5 @@ test('two touches 100px apart, zoom in and pan up', () => { expect(acc.scale).toEqual(2); expect(acc.pan).toEqual({ x: 0, y: 100 }); - dispose(); + await dispose(); }); diff --git a/tests/testUtils.ts b/tests/testUtils.ts index b553d80..79fdd3d 100644 --- a/tests/testUtils.ts +++ b/tests/testUtils.ts @@ -1,5 +1,6 @@ -import { Window as HappyWindow } from 'happy-dom'; import { type Click, type Ctors, type Drag, Pointeract, type WheelPanZoom } from '@'; +import { Window as HappyWindow } from 'happy-dom'; + import type { Coordinates, ModuleInput, Options, StdEvents } from '@/declarations'; type ModulePreset = Ctors<[WheelPanZoom, Drag, Click]>; diff --git a/tests/wheel.test.ts b/tests/wheel.test.ts index 11c8e27..8ed9440 100644 --- a/tests/wheel.test.ts +++ b/tests/wheel.test.ts @@ -1,18 +1,19 @@ -import { expect, test } from 'vitest'; import { WheelPanZoom } from '@'; +import { expect, test } from 'vitest'; + import setup from './testUtils'; -test('normal wheel', () => { +test('normal wheel', async () => { const { acc, dispose, wheel } = setup(WheelPanZoom); wheel({ x: 0, y: 200 }); const smallerScale = acc.scale; expect(smallerScale < 0.9).toBe(true); wheel({ x: 0, y: -200 }); expect(acc.scale > smallerScale).toBe(true); - dispose(); + await dispose(); }); -test('professional control schema', () => { +test('professional control schema', async () => { const options = { proControlSchema: false }; const { acc, dispose, wheel } = setup(WheelPanZoom, options); @@ -46,5 +47,5 @@ test('professional control schema', () => { expect(acc.scale > 1).toBe(true); expect(options.proControlSchema).toBe(true); - dispose(); + await dispose(); }); diff --git a/vite.config.ts b/vite.config.ts index af850d2..2a880f8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,7 @@ /// import { resolve } from 'node:path'; + import { defineConfig } from 'vite'; export default defineConfig({ @@ -21,7 +22,7 @@ export default defineConfig({ }, name: 'Pointeract', formats: ['es', 'cjs'], - fileName: format => `index.${format === 'cjs' ? 'cjs' : 'js'}`, + fileName: (format) => `index.${format === 'cjs' ? 'cjs' : 'js'}`, }, }, test: {