diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6de8c1a..12566c2 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: - - '*' + - package-ecosystem: 'npm' + directory: '/' + schedule: + interval: 'weekly' + groups: + all: + patterns: + - '*' diff --git a/.github/scripts/detect_changes.sh b/.github/scripts/detect_changes.sh deleted file mode 100755 index 9041c73..0000000 --- a/.github/scripts/detect_changes.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -set -eo pipefail - -# Get event payload -payload=$(cat "$GITHUB_EVENT_PATH") - -# Determine commit range based on event type -case "$GITHUB_EVENT_NAME" in - pull_request) - # Handle fork PRs safely - if [ "$(jq -r '.pull_request.head.repo.full_name' <<< "$payload")" != "$(jq -r '.pull_request.base.repo.full_name' <<< "$payload")" ]; then - echo "::warning::Fork PR detected - using full repository state" - changed_files=$(git ls-files) - else - base_sha=$(jq -r '.pull_request.base.sha' <<< "$payload") - head_sha=$(jq -r '.pull_request.head.sha' <<< "$payload") - changed_files=$(git diff --name-only "$base_sha" "$head_sha") - fi - ;; - - push) - before_sha=$(jq -r '.before' <<< "$payload") - after_sha=$(jq -r '.after' <<< "$payload") - - # Handle initial commit - if [ "$before_sha" = "0000000000000000000000000000000000000000" ]; then - changed_files=$(git ls-files) - else - changed_files=$(git diff --name-only "$before_sha" "$after_sha") - fi - ;; - - *) - echo "::error::Unsupported event: $GITHUB_EVENT_NAME" >&2 - exit 1 - ;; -esac - -# Extract unique root items -printf "%s" "$changed_files" | awk -F/ '{ - if (NF > 1) print $1 - else print $0 -}' | sort -u > /tmp/changed_roots - -# Output results -{ - echo "changed_roots<> "$GITHUB_OUTPUT" - -echo "Changes Detected:" -cat /tmp/changed_roots - -rm -f /tmp/changed_roots \ No newline at end of file diff --git a/.github/workflows/ci-docs.yml b/.github/workflows/ci-docs.yml new file mode 100644 index 0000000..95f6528 --- /dev/null +++ b/.github/workflows/ci-docs.yml @@ -0,0 +1,55 @@ +name: CI for Docs + +on: + pull_request: + branches: [main] + types: [opened, synchronize, reopened, ready_for_review] + paths: + - docs/** + push: + branches: [main] + paths: + - docs/** + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + ci: + runs-on: ubuntu-slim + + 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: Build Docs + run: pnpm docs:build + + - name: Setup Pages + if: github.event_name == 'push' + uses: actions/configure-pages@v5.0.0 + + - name: Upload artifact + if: github.event_name == 'push' + uses: actions/upload-pages-artifact@v4.0.0 + with: + path: './docs/.vitepress/dist' + + - name: Deploy to GitHub Pages + if: github.event_name == 'push' + uses: actions/deploy-pages@v4.0.5 diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml deleted file mode 100644 index bf4763a..0000000 --- a/.github/workflows/ci-main.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: CI for Main - -on: - push: - branches: [main] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true # Cancel previous runs for same PR/branch - -permissions: - 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 ======================================================================== diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml deleted file mode 100644 index 4a0fd2e..0000000 --- a/.github/workflows/ci-pr.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: CI for Pull Requests - -on: - 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 - -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 diff --git a/.github/workflows/ci-routine.yml b/.github/workflows/ci-routine.yml new file mode 100644 index 0000000..d871a30 --- /dev/null +++ b/.github/workflows/ci-routine.yml @@ -0,0 +1,40 @@ +name: CI for Routine Checks + +on: + pull_request: + branches: [main] + types: [opened, synchronize, reopened, ready_for_review] + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + ci: + runs-on: ubuntu-slim + + 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: Run checks + run: pnpm check + + - name: Run test build + run: pnpm build diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml new file mode 100644 index 0000000..6a40080 --- /dev/null +++ b/.github/workflows/ci-test.yml @@ -0,0 +1,54 @@ +name: CI for Tests + +on: + pull_request: + branches: [main] + types: [opened, synchronize, reopened, ready_for_review] + paths: + - src/** + - test/** + push: + branches: [main] + paths: + - src/** + - test/** + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + ci: + runs-on: ubuntu-slim + + 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: Run tests (pull requests) + if: github.event_name == 'pull_request' + run: pnpm test + + - name: Run coverage tests (push to main) + if: github.event_name == 'push' + run: pnpm test:coverage + + - name: Upload coverage reports to Codecov (push to main) + if: github.event_name == 'push' + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6033929..9dd086e 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*.*.*' + push: + tags: + - 'v*.*.*' permissions: - id-token: write - contents: read + id-token: write + contents: read jobs: - build-and-publish: - runs-on: ubuntu-latest + build-and-publish: + runs-on: ubuntu-slim - steps: - - name: Checkout code - uses: actions/checkout@v6 + steps: + - name: Checkout code + uses: actions/checkout@v6 - - name: Set up pnpm - uses: pnpm/action-setup@v4.2.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 - registry-url: 'https://registry.npmjs.org' - cache: 'pnpm' + - 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: Install dependencies + run: pnpm install - - name: Build - run: pnpm build + - name: Build + run: pnpm build - - name: Publish to npm - run: pnpm publish --no-git-checks + - name: Publish to npm + run: pnpm publish --no-git-checks diff --git a/.oxfmtrc.json b/.oxfmtrc.json index af8250d..72b3864 100644 --- a/.oxfmtrc.json +++ b/.oxfmtrc.json @@ -14,5 +14,13 @@ ["sibling", "sibling-type"], ["index", "index-type"] ] - } + }, + "overrides": [ + { + "files": ["*.md", "*.yaml", "*.yml"], + "options": { + "tabWidth": 2 + } + } + ] } diff --git a/.oxlintrc.json b/.oxlintrc.json index f60e904..b9b43a2 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -77,6 +77,8 @@ "typescript/no-extra-non-null-assertion": "warn", "typescript/no-floating-promises": "warn", "typescript/no-for-in-array": "warn", + "typescript/no-non-null-assertion": "warn", + "typescript/no-explicit-any": "warn", "typescript/no-implied-eval": "warn", "typescript/no-meaningless-void-operator": "warn", "typescript/no-misused-new": "warn", @@ -108,26 +110,6 @@ "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 }, diff --git a/README.md b/README.md index 6a72e28..c284e46 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@

- CI Status + CI Status Test Coverage @@ -54,7 +54,7 @@ Access our documentation [in the website](https://pointeract.consensia.cc/). ## Advantages - **🐣 Tiny**: With base **1KB** minified and gzipped, **1-2KB** for normal usage. -- **πŸ’ͺ Robust**: Excels at complex gestures where most interaction libraries fail, [Why?](https://pointeract.consensia.cc/development/testing#chaotic-testing) +- **πŸ’ͺ Robust**: Excels at complex gestures where most interaction libraries fail, [Why?](https://pointeract.consensia.cc/development/testing#monkey-test) - **🧩 Extensible**: Extend Pointeract effortlessly via our module API. - **πŸ”Œ Flexible during Runtime**: Options are updated reactively. Stop/start any module during runtime. - **πŸ›‘οΈ Safe**: Not modifying the DOM (except the `PreventDefault` module). Meticulous clean up prevents memory leaks. @@ -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) | -| 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? | βœ… | ❌ | ❌ | +| 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#monkey-test)) | βœ… | ❌ Element Jerks | ❌ Element Ignores the Second Touch | +| Extensible? | βœ… | ❌ | ❌ | ## Get Involved diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index d5a6342..26301be 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -20,7 +20,8 @@ export default defineConfig({ 'meta', { name: 'keywords', - content: 'user interaction,pan zoom,multitouch,custom modules,modern lightweight', + content: + 'user interaction,pan zoom,multitouch,custom modules,gestures,javascript,typescript,pointeract', }, ], ], diff --git a/docs/components/playground.vue b/docs/components/playground.vue index c1a5629..6697ec8 100644 --- a/docs/components/playground.vue +++ b/docs/components/playground.vue @@ -11,8 +11,20 @@