已关闭
chore: 调整文件结构 #22
suilyy创建于 2025年12月11日关闭于 2025年12月23日
chore: 调整文件结构 #22
已关闭
共 288 个文件变更+3962-9368
| @@ -1 +0,0 @@ | |||
| 1 | -github: software-mansion | ||
| @@ -1,154 +0,0 @@ | |||
| 1 | -name: Bug report | ||
| 2 | -description: Report an issue with Gesture Handler here. | ||
| 3 | -body: | ||
| 4 | - - type: markdown | ||
| 5 | - attributes: | ||
| 6 | - value: | | ||
| 7 | - Thanks for taking the time to fill out this bug report! | ||
| 8 | - | ||
| 9 | - Before you proceed: | ||
| 10 | - | ||
| 11 | - - Make sure to check whether there are similar issues in the repository | ||
| 12 | - - Make sure to clean cache in your project. Depending on your setup this could be done by: | ||
| 13 | - - `yarn start --reset-cache` or | ||
| 14 | - - `npm start -- --reset-cache` or | ||
| 15 | - - `expo start --clear` | ||
| 16 | - | ||
| 17 | - - type: markdown | ||
| 18 | - attributes: | ||
| 19 | - value: | | ||
| 20 | - ## Required information | ||
| 21 | - - type: textarea | ||
| 22 | - id: description | ||
| 23 | - attributes: | ||
| 24 | - label: Description | ||
| 25 | - description: Please provide a clear, concise and descriptive explanation of what the bug is. Include screenshots or a video if needed. Tell us what were you expecting to happen instead of what is happening now. | ||
| 26 | - validations: | ||
| 27 | - required: true | ||
| 28 | - | ||
| 29 | - - type: textarea | ||
| 30 | - id: steps-to-reproduce | ||
| 31 | - attributes: | ||
| 32 | - label: Steps to reproduce | ||
| 33 | - description: Provide a detailed list of steps that reproduce the issue. | ||
| 34 | - placeholder: | | ||
| 35 | - 1. | ||
| 36 | - 2. | ||
| 37 | - 3. | ||
| 38 | - validations: | ||
| 39 | - required: true | ||
| 40 | - | ||
| 41 | - - type: input | ||
| 42 | - id: repro | ||
| 43 | - attributes: | ||
| 44 | - label: Snack or a link to a repository | ||
| 45 | - description: | | ||
| 46 | - Please provide a Snack (https://snack.expo.io/) or a link to a repository on GitHub under your username that reproduces the issue. | ||
| 47 | - Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve. | ||
| 48 | - Issues without a reproduction are likely to stale. | ||
| 49 | - placeholder: Link to a Snack or a GitHub repository | ||
| 50 | - validations: | ||
| 51 | - required: true | ||
| 52 | - | ||
| 53 | - - type: input | ||
| 54 | - id: gesture-handler-version | ||
| 55 | - attributes: | ||
| 56 | - label: Gesture Handler version | ||
| 57 | - description: What version of react-native-gesture-handler are you using? | ||
| 58 | - placeholder: 2.5.0 | ||
| 59 | - validations: | ||
| 60 | - required: true | ||
| 61 | - | ||
| 62 | - - type: input | ||
| 63 | - id: react-native-version | ||
| 64 | - attributes: | ||
| 65 | - label: React Native version | ||
| 66 | - description: What version of react-native are you using? | ||
| 67 | - placeholder: 0.69.0 | ||
| 68 | - validations: | ||
| 69 | - required: true | ||
| 70 | - | ||
| 71 | - - type: dropdown | ||
| 72 | - id: platforms | ||
| 73 | - attributes: | ||
| 74 | - label: Platforms | ||
| 75 | - description: On what platform your application is running on? | ||
| 76 | - multiple: true | ||
| 77 | - options: | ||
| 78 | - - Android | ||
| 79 | - - iOS | ||
| 80 | - - Web | ||
| 81 | - validations: | ||
| 82 | - required: true | ||
| 83 | - | ||
| 84 | - - type: markdown | ||
| 85 | - attributes: | ||
| 86 | - value: | | ||
| 87 | - ## Additonal information | ||
| 88 | - | ||
| 89 | - Providing as much information as possible greatly helps us with reproducting the issues. | ||
| 90 | - | ||
| 91 | - - type: dropdown | ||
| 92 | - id: runtime | ||
| 93 | - attributes: | ||
| 94 | - label: JavaScript runtime | ||
| 95 | - description: What runtime is your application using? | ||
| 96 | - options: | ||
| 97 | - - JSC | ||
| 98 | - - Hermes | ||
| 99 | - - V8 | ||
| 100 | - | ||
| 101 | - - type: dropdown | ||
| 102 | - id: workflow | ||
| 103 | - attributes: | ||
| 104 | - label: Workflow | ||
| 105 | - description: How your application is managed? Not sure? Read [this part](https://docs.expo.dev/introduction/managed-vs-bare/) of Expo documentation | ||
| 106 | - options: | ||
| 107 | - - React Native (without Expo) | ||
| 108 | - - Expo bare workflow | ||
| 109 | - - Expo managed workflow | ||
| 110 | - | ||
| 111 | - - type: dropdown | ||
| 112 | - id: architecture | ||
| 113 | - attributes: | ||
| 114 | - label: Architecture | ||
| 115 | - description: What React Native architecture your application is running on? Currently, the default architecture on React Native is Paper so if you haven't changed it in your application select this option. | ||
| 116 | - options: | ||
| 117 | - - Paper (Old Architecture) | ||
| 118 | - - Fabric (New Architecture) | ||
| 119 | - | ||
| 120 | - - type: dropdown | ||
| 121 | - id: build-type | ||
| 122 | - attributes: | ||
| 123 | - label: Build type | ||
| 124 | - description: What mode your application is running? | ||
| 125 | - options: | ||
| 126 | - - Debug mode | ||
| 127 | - - Release mode | ||
| 128 | - | ||
| 129 | - - type: dropdown | ||
| 130 | - id: emulator | ||
| 131 | - attributes: | ||
| 132 | - label: Device | ||
| 133 | - description: How are you running your application? | ||
| 134 | - options: | ||
| 135 | - - iOS simulator | ||
| 136 | - - Android emulator | ||
| 137 | - - Real device | ||
| 138 | - | ||
| 139 | - - type: input | ||
| 140 | - id: device-model | ||
| 141 | - attributes: | ||
| 142 | - label: Device model | ||
| 143 | - description: What device you are experiencing this problem on? Specify full device name along with the version of the operating system it's running. | ||
| 144 | - placeholder: ex. Samsung Galaxy A22 (Android 12) | ||
| 145 | - | ||
| 146 | - - type: dropdown | ||
| 147 | - id: acknowledgements | ||
| 148 | - attributes: | ||
| 149 | - label: Acknowledgements | ||
| 150 | - description: I searched for similar issues in the repository. | ||
| 151 | - options: | ||
| 152 | - - 'Yes' | ||
| 153 | - validations: | ||
| 154 | - required: true | ||
| @@ -1,5 +0,0 @@ | |||
| 1 | -blank_issues_enabled: false | ||
| 2 | -contact_links: | ||
| 3 | - - name: Question | ||
| 4 | - url: https://github.com/software-mansion/react-native-gesture-handler/discussions/categories/q-a | ||
| 5 | - about: Please ask and answer questions here. | ||
| @@ -1,13 +0,0 @@ | |||
| 1 | -## Description | ||
| 2 | - | ||
| 3 | -<!-- | ||
| 4 | -Description and motivation for this PR. | ||
| 5 | - | ||
| 6 | -Include 'Fixes #<number>' if this is fixing some issue. | ||
| 7 | ---> | ||
| 8 | - | ||
| 9 | -## Test plan | ||
| 10 | - | ||
| 11 | -<!-- | ||
| 12 | -Describe how did you test this change here. | ||
| 13 | ---> | ||
| @@ -1,40 +0,0 @@ | |||
| 1 | -name: Test Android build | ||
| 2 | -on: | ||
| 3 | - pull_request: | ||
| 4 | - paths: | ||
| 5 | - - '.github/workflows/android-build.yml' | ||
| 6 | - - 'android/**' | ||
| 7 | - - 'Common/**' | ||
| 8 | - - 'Example/android/**' | ||
| 9 | - - 'FabricExample/android/**' | ||
| 10 | - push: | ||
| 11 | - branches: | ||
| 12 | - - main | ||
| 13 | -jobs: | ||
| 14 | - build: | ||
| 15 | - runs-on: ubuntu-latest | ||
| 16 | - strategy: | ||
| 17 | - matrix: | ||
| 18 | - working-directory: [example, FabricExample] | ||
| 19 | - concurrency: | ||
| 20 | - group: android-${{ matrix.working-directory }}-${{ github.ref }} | ||
| 21 | - cancel-in-progress: true | ||
| 22 | - steps: | ||
| 23 | - - name: checkout | ||
| 24 | - uses: actions/checkout@v2 | ||
| 25 | - - name: Use Java 17 | ||
| 26 | - uses: actions/setup-java@v3 | ||
| 27 | - with: | ||
| 28 | - distribution: 'oracle' | ||
| 29 | - java-version: '17' | ||
| 30 | - - name: Use Node.js 18 | ||
| 31 | - uses: actions/setup-node@v2 | ||
| 32 | - with: | ||
| 33 | - node-version: 18 | ||
| 34 | - cache: 'yarn' | ||
| 35 | - - name: Install node dependencies | ||
| 36 | - working-directory: ${{ matrix.working-directory }} | ||
| 37 | - run: yarn | ||
| 38 | - - name: Build app | ||
| 39 | - working-directory: ${{ matrix.working-directory }}/android | ||
| 40 | - run: ./gradlew assembleDebug --console=plain -PreactNativeArchitectures=arm64-v8a | ||
| @@ -1,33 +0,0 @@ | |||
| 1 | -name: Check for stale issues | ||
| 2 | -on: | ||
| 3 | - schedule: | ||
| 4 | - - cron: '37 21 * * *' # at 21:37 every day | ||
| 5 | - issues: | ||
| 6 | - types: [edited] | ||
| 7 | - issue_comment: | ||
| 8 | - types: [created, edited] | ||
| 9 | - workflow_dispatch: | ||
| 10 | - | ||
| 11 | -jobs: | ||
| 12 | - main: | ||
| 13 | - runs-on: ubuntu-latest | ||
| 14 | - steps: | ||
| 15 | - - name: Checkout Actions | ||
| 16 | - uses: actions/checkout@v2 | ||
| 17 | - with: | ||
| 18 | - repository: 'software-mansion-labs/swmansion-bot' | ||
| 19 | - ref: stable | ||
| 20 | - | ||
| 21 | - - uses: actions/cache@v2 | ||
| 22 | - with: | ||
| 23 | - path: '**/node_modules' | ||
| 24 | - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | ||
| 25 | - | ||
| 26 | - - name: Install Actions | ||
| 27 | - run: yarn install | ||
| 28 | - | ||
| 29 | - - name: Close when stale | ||
| 30 | - uses: ./close-when-stale | ||
| 31 | - with: | ||
| 32 | - close-when-stale-label: 'Close when stale' | ||
| 33 | - days-to-close: 20 | ||
| @@ -1,29 +0,0 @@ | |||
| 1 | -name: Check documentation | ||
| 2 | - | ||
| 3 | -on: | ||
| 4 | - pull_request: | ||
| 5 | - paths: | ||
| 6 | - - 'docs/**' | ||
| 7 | - | ||
| 8 | -jobs: | ||
| 9 | - check: | ||
| 10 | - runs-on: ubuntu-latest | ||
| 11 | - concurrency: | ||
| 12 | - group: docs-check-${{ github.ref }} | ||
| 13 | - cancel-in-progress: true | ||
| 14 | - env: | ||
| 15 | - WORKING_DIRECTORY: docs | ||
| 16 | - steps: | ||
| 17 | - - name: checkout | ||
| 18 | - uses: actions/checkout@v2 | ||
| 19 | - - name: Use Node.js 18 | ||
| 20 | - uses: actions/setup-node@v2 | ||
| 21 | - with: | ||
| 22 | - node-version: 18 | ||
| 23 | - cache: 'yarn' | ||
| 24 | - - name: Install node dependencies | ||
| 25 | - working-directory: ${{ env.WORKING_DIRECTORY }} | ||
| 26 | - run: yarn | ||
| 27 | - - name: Generate docs | ||
| 28 | - working-directory: ${{ env.WORKING_DIRECTORY }} | ||
| 29 | - run: yarn build | ||
| @@ -1,38 +0,0 @@ | |||
| 1 | -name: Test iOS build | ||
| 2 | -on: | ||
| 3 | - pull_request: | ||
| 4 | - paths: | ||
| 5 | - - '.github/workflows/ios-build.yml' | ||
| 6 | - - 'RNGestureHandler.podspec' | ||
| 7 | - - 'ios/**' | ||
| 8 | - - 'Example/ios/**' | ||
| 9 | - - 'FabricExample/ios/**' | ||
| 10 | - push: | ||
| 11 | - branches: | ||
| 12 | - - main | ||
| 13 | -jobs: | ||
| 14 | - build: | ||
| 15 | - runs-on: macos-12 | ||
| 16 | - strategy: | ||
| 17 | - matrix: | ||
| 18 | - working-directory: [example, FabricExample] | ||
| 19 | - concurrency: | ||
| 20 | - group: ios-${{ matrix.working-directory }}-${{ github.ref }} | ||
| 21 | - cancel-in-progress: true | ||
| 22 | - steps: | ||
| 23 | - - name: checkout | ||
| 24 | - uses: actions/checkout@v2 | ||
| 25 | - - name: Use Node.js 18 | ||
| 26 | - uses: actions/setup-node@v2 | ||
| 27 | - with: | ||
| 28 | - node-version: 18 | ||
| 29 | - cache: 'yarn' | ||
| 30 | - - name: Install node dependencies | ||
| 31 | - working-directory: ${{ matrix.working-directory }} | ||
| 32 | - run: yarn | ||
| 33 | - - name: Install pods | ||
| 34 | - working-directory: ${{ matrix.working-directory }}/ios | ||
| 35 | - run: pod install | ||
| 36 | - - name: Build app | ||
| 37 | - working-directory: ${{ matrix.working-directory }} | ||
| 38 | - run: yarn ios --simulator=\"iPhone 11\" --mode Debug | ||
| @@ -1,50 +0,0 @@ | |||
| 1 | -name: Kotlin Lint | ||
| 2 | -on: | ||
| 3 | - pull_request: | ||
| 4 | - paths: | ||
| 5 | - - 'android/**' | ||
| 6 | - push: | ||
| 7 | - branches: | ||
| 8 | - - main | ||
| 9 | -jobs: | ||
| 10 | - check: | ||
| 11 | - runs-on: ubuntu-latest | ||
| 12 | - concurrency: | ||
| 13 | - group: kotlin-lint-${{ github.ref }} | ||
| 14 | - cancel-in-progress: true | ||
| 15 | - steps: | ||
| 16 | - - name: checkout | ||
| 17 | - uses: actions/checkout@v2 | ||
| 18 | - | ||
| 19 | - - name: Use Java 17 | ||
| 20 | - uses: actions/setup-java@v3 | ||
| 21 | - with: | ||
| 22 | - distribution: 'oracle' | ||
| 23 | - java-version: '17' | ||
| 24 | - | ||
| 25 | - - name: Use Node.js 18 | ||
| 26 | - uses: actions/setup-node@v2 | ||
| 27 | - with: | ||
| 28 | - node-version: 18 | ||
| 29 | - cache: 'yarn' | ||
| 30 | - | ||
| 31 | - - uses: actions/cache@v2 | ||
| 32 | - with: | ||
| 33 | - path: '**/node_modules' | ||
| 34 | - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | ||
| 35 | - | ||
| 36 | - - name: Install node dependencies | ||
| 37 | - run: yarn install --frozen-lockfile | ||
| 38 | - | ||
| 39 | - - name: Restore build from cache | ||
| 40 | - uses: actions/cache@v3 | ||
| 41 | - with: | ||
| 42 | - path: | | ||
| 43 | - ~/.gradle/caches | ||
| 44 | - ~/.gradle/wrapper | ||
| 45 | - android/build | ||
| 46 | - android/.gradle | ||
| 47 | - key: ${{ runner.os }}-kotlin-lint-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'android/build.gradle') }} | ||
| 48 | - | ||
| 49 | - - name: Lint | ||
| 50 | - run: yarn lint:android | ||
| @@ -1,28 +0,0 @@ | |||
| 1 | -name: Publish to GitHub Pages | ||
| 2 | - | ||
| 3 | -on: | ||
| 4 | - push: | ||
| 5 | - branches: | ||
| 6 | - - main | ||
| 7 | - | ||
| 8 | -jobs: | ||
| 9 | - publish: | ||
| 10 | - runs-on: ubuntu-latest | ||
| 11 | - steps: | ||
| 12 | - - name: Check out | ||
| 13 | - uses: actions/checkout@v1 | ||
| 14 | - | ||
| 15 | - - name: Generate docs | ||
| 16 | - run: >- | ||
| 17 | - git config --local user.email "action@github.com" | ||
| 18 | - && git config --local user.name "GitHub Action" | ||
| 19 | - && cd docs | ||
| 20 | - && yarn | ||
| 21 | - && yarn build | ||
| 22 | - | ||
| 23 | - - name: Publish generated content to GitHub Pages | ||
| 24 | - uses: JamesIves/github-pages-deploy-action@releases/v3 | ||
| 25 | - with: | ||
| 26 | - FOLDER: docs/build | ||
| 27 | - BRANCH: gh-pages | ||
| 28 | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| @@ -1,35 +0,0 @@ | |||
| 1 | -name: Check issue template | ||
| 2 | -on: | ||
| 3 | - issues: | ||
| 4 | - types: [opened, edited] | ||
| 5 | - | ||
| 6 | -jobs: | ||
| 7 | - main: | ||
| 8 | - runs-on: ubuntu-latest | ||
| 9 | - concurrency: | ||
| 10 | - group: needs-more-info-${{ github.event.issue.number }} | ||
| 11 | - cancel-in-progress: true | ||
| 12 | - steps: | ||
| 13 | - - name: Checkout Actions | ||
| 14 | - uses: actions/checkout@v2 | ||
| 15 | - with: | ||
| 16 | - repository: 'software-mansion-labs/swmansion-bot' | ||
| 17 | - ref: stable | ||
| 18 | - | ||
| 19 | - - uses: actions/cache@v2 | ||
| 20 | - with: | ||
| 21 | - path: '**/node_modules' | ||
| 22 | - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | ||
| 23 | - | ||
| 24 | - - name: Install Actions | ||
| 25 | - run: yarn install | ||
| 26 | - | ||
| 27 | - - name: Needs More Info | ||
| 28 | - uses: ./needs-more-info | ||
| 29 | - with: | ||
| 30 | - github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| 31 | - needs-more-info-label: 'Missing info' | ||
| 32 | - required-sections: 'Description;Steps to reproduce;Snack or a link to a repository;Gesture Handler version;React Native version;Platforms' | ||
| 33 | - needs-more-info-response: "Hey! 👋 \n\nIt looks like you've omitted a few important sections from the issue template." | ||
| 34 | - # This action also appends something like: "Please complete X, Y and Z sections." to the response. | ||
| 35 | - # Code responsible for this can be found here: https://github.com/software-mansion-labs/swmansion-bot/blob/main/needs-more-info/MissingSectionsFormatter.js | ||
| @@ -1,36 +0,0 @@ | |||
| 1 | -name: Check for reproduction | ||
| 2 | -on: | ||
| 3 | - issues: | ||
| 4 | - types: [opened, edited] | ||
| 5 | - issue_comment: | ||
| 6 | - types: [created, edited, deleted] | ||
| 7 | - | ||
| 8 | -jobs: | ||
| 9 | - main: | ||
| 10 | - runs-on: ubuntu-latest | ||
| 11 | - concurrency: | ||
| 12 | - group: needs-repro-${{ github.event.issue.number }} | ||
| 13 | - cancel-in-progress: true | ||
| 14 | - steps: | ||
| 15 | - - name: Checkout Actions | ||
| 16 | - uses: actions/checkout@v2 | ||
| 17 | - with: | ||
| 18 | - repository: 'software-mansion-labs/swmansion-bot' | ||
| 19 | - ref: stable | ||
| 20 | - | ||
| 21 | - - uses: actions/cache@v2 | ||
| 22 | - with: | ||
| 23 | - path: '**/node_modules' | ||
| 24 | - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | ||
| 25 | - | ||
| 26 | - - name: Install Actions | ||
| 27 | - run: yarn install | ||
| 28 | - | ||
| 29 | - - name: Needs Repro | ||
| 30 | - uses: ./needs-repro | ||
| 31 | - with: | ||
| 32 | - github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| 33 | - needs-repro-label: 'Missing repro' | ||
| 34 | - needs-repro-response: "Hey! 👋 \n\nThe issue doesn't seem to contain a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example).\n\nCould you provide a [snack](https://snack.expo.dev/) or a link to a GitHub repository under your username that reproduces the problem?" | ||
| 35 | - repro-provided-label: 'Repro provided' | ||
| 36 | - check-issues-only-created-after: 2022-02-01 | ||
| @@ -1,33 +0,0 @@ | |||
| 1 | -name: Check for platforms | ||
| 2 | -on: | ||
| 3 | - issues: | ||
| 4 | - types: [opened, edited] | ||
| 5 | - | ||
| 6 | -jobs: | ||
| 7 | - main: | ||
| 8 | - runs-on: ubuntu-latest | ||
| 9 | - concurrency: | ||
| 10 | - group: platforms-${{ github.event.issue.number }} | ||
| 11 | - cancel-in-progress: true | ||
| 12 | - steps: | ||
| 13 | - - name: Checkout Actions | ||
| 14 | - uses: actions/checkout@v2 | ||
| 15 | - with: | ||
| 16 | - repository: 'software-mansion-labs/swmansion-bot' | ||
| 17 | - ref: stable | ||
| 18 | - | ||
| 19 | - - uses: actions/cache@v2 | ||
| 20 | - with: | ||
| 21 | - path: '**/node_modules' | ||
| 22 | - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | ||
| 23 | - | ||
| 24 | - - name: Install Actions | ||
| 25 | - run: yarn install | ||
| 26 | - | ||
| 27 | - - name: Platforms | ||
| 28 | - uses: ./platforms | ||
| 29 | - with: | ||
| 30 | - github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| 31 | - platforms-section-header: Platforms | ||
| 32 | - platforms-comma-separated: true | ||
| 33 | - platforms-with-labels: '{"Android": "Platform: Android", "iOS": "Platform: iOS", "Web": "Platform: Web"}' | ||
| @@ -1,37 +0,0 @@ | |||
| 1 | -name: Test TypeScript and Lint | ||
| 2 | -on: | ||
| 3 | - pull_request: | ||
| 4 | - paths: | ||
| 5 | - - 'example/**' | ||
| 6 | - - 'FabricExample/**' | ||
| 7 | - push: | ||
| 8 | - branches: | ||
| 9 | - - main | ||
| 10 | -jobs: | ||
| 11 | - check: | ||
| 12 | - runs-on: ubuntu-latest | ||
| 13 | - strategy: | ||
| 14 | - matrix: | ||
| 15 | - working-directory: [example, FabricExample] | ||
| 16 | - concurrency: | ||
| 17 | - group: typescript-${{ matrix.working-directory }}-${{ github.ref }} | ||
| 18 | - cancel-in-progress: true | ||
| 19 | - steps: | ||
| 20 | - - name: checkout | ||
| 21 | - uses: actions/checkout@v2 | ||
| 22 | - - name: Use Node.js 18 | ||
| 23 | - uses: actions/setup-node@v2 | ||
| 24 | - with: | ||
| 25 | - node-version: 18 | ||
| 26 | - cache: 'yarn' | ||
| 27 | - - name: Install root node dependencies | ||
| 28 | - run: yarn | ||
| 29 | - - name: Install ${{ matrix.working-directory }} app node dependencies | ||
| 30 | - working-directory: ${{ matrix.working-directory }} | ||
| 31 | - run: yarn | ||
| 32 | - - name: Check types | ||
| 33 | - working-directory: ${{ matrix.working-directory }} | ||
| 34 | - run: yarn tsc --noEmit | ||
| 35 | - - name: Lint | ||
| 36 | - working-directory: ${{ matrix.working-directory }} | ||
| 37 | - run: yarn lint-check | ||
| @@ -1,29 +0,0 @@ | |||
| 1 | -name: Test TypeScript and Lint | ||
| 2 | -on: | ||
| 3 | - pull_request: | ||
| 4 | - paths: | ||
| 5 | - - 'src/**' | ||
| 6 | - - '*' | ||
| 7 | - push: | ||
| 8 | - branches: | ||
| 9 | - - main | ||
| 10 | -jobs: | ||
| 11 | - check: | ||
| 12 | - runs-on: ubuntu-latest | ||
| 13 | - concurrency: | ||
| 14 | - group: static-root-${{ github.ref }} | ||
| 15 | - cancel-in-progress: true | ||
| 16 | - steps: | ||
| 17 | - - name: checkout | ||
| 18 | - uses: actions/checkout@v2 | ||
| 19 | - - name: Use Node.js 18 | ||
| 20 | - uses: actions/setup-node@v2 | ||
| 21 | - with: | ||
| 22 | - node-version: 18 | ||
| 23 | - cache: 'yarn' | ||
| 24 | - - name: Install node dependencies | ||
| 25 | - run: yarn | ||
| 26 | - - name: Check types | ||
| 27 | - run: yarn tsc --noEmit | ||
| 28 | - - name: Lint | ||
| 29 | - run: yarn lint:js-root | ||
| @@ -1,5 +0,0 @@ | |||
| 1 | -#!/usr/bin/env sh | ||
| 2 | -. "$(dirname -- "$0")/_/husky.sh" | ||
| 3 | - | ||
| 4 | -yarn lint-staged | ||
| 5 | -yarn ts-check | ||
| @@ -1 +0,0 @@ | |||
| 1 | -18 | ||
| @@ -1,3 +0,0 @@ | |||
| 1 | -module.exports = { | ||
| 2 | - presets: ['module:@react-native/babel-preset'], | ||
| 3 | -}; | ||
| @@ -1,12 +0,0 @@ | |||
| 1 | -{ | ||
| 2 | - license: '', | ||
| 3 | - devDependencies: {}, | ||
| 4 | - author: '', | ||
| 5 | - name: '@react-native-ohos/react-native-gesture-handler', | ||
| 6 | - description: '', | ||
| 7 | - type: 'module', | ||
| 8 | - version: '2.23.2-rc.1', | ||
| 9 | - dependencies: { | ||
| 10 | - "@rnoh/react-native-openharmony": "file:../react_native_openharmony.har" | ||
| 11 | - }, | ||
| 12 | -} | ||
| @@ -1,44 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -#pragma once | ||
| 25 | - | ||
| 26 | -#include "RNGestureHandlerButtonComponentInstance.h" | ||
| 27 | - | ||
| 28 | -namespace rnoh { | ||
| 29 | -RNGestureHandlerButtonComponentInstance::RNGestureHandlerButtonComponentInstance(Context context) | ||
| 30 | - : CppComponentInstance(std::move(context)){}; | ||
| 31 | - | ||
| 32 | -StackNode &RNGestureHandlerButtonComponentInstance::getLocalRootArkUINode() { return m_stackNode; }; | ||
| 33 | - | ||
| 34 | -void RNGestureHandlerButtonComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance, | ||
| 35 | - std::size_t index) { | ||
| 36 | - CppComponentInstance::onChildInserted(childComponentInstance, index); | ||
| 37 | - m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index); | ||
| 38 | -}; | ||
| 39 | - | ||
| 40 | -void RNGestureHandlerButtonComponentInstance::onChildRemoved(ComponentInstance::Shared const &childComponentInstance) { | ||
| 41 | - CppComponentInstance::onChildRemoved(childComponentInstance); | ||
| 42 | - m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode()); | ||
| 43 | -}; | ||
| 44 | -} // namespace rnoh | ||
| @@ -1,42 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -#pragma once | ||
| 25 | -#import "RNOH/CppComponentInstance.h" | ||
| 26 | -#import "RNOH/arkui/StackNode.h" | ||
| 27 | -#import "generated/RNGestureHandlerButtonComponentDescriptor.h" | ||
| 28 | - | ||
| 29 | -namespace rnoh { | ||
| 30 | -class RNGestureHandlerButtonComponentInstance | ||
| 31 | - : public CppComponentInstance<facebook::react::RNGestureHandlerButtonShadowNode> { | ||
| 32 | -public: | ||
| 33 | - RNGestureHandlerButtonComponentInstance(Context context); | ||
| 34 | - | ||
| 35 | - StackNode &getLocalRootArkUINode() override; | ||
| 36 | - void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override; | ||
| 37 | - void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override; | ||
| 38 | - | ||
| 39 | -private: | ||
| 40 | - StackNode m_stackNode; | ||
| 41 | -}; | ||
| 42 | -} // namespace rnoh | ||
| @@ -1,246 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -#include "RNGestureHandlerRootViewComponentInstance.h" | ||
| 25 | - | ||
| 26 | -namespace rnoh { | ||
| 27 | - | ||
| 28 | -RNGestureHandlerRootViewComponentInstance::RNGestureHandlerRootViewComponentInstance(Context context) | ||
| 29 | - : CppComponentInstance(std::move(context)), | ||
| 30 | - m_touchHandler(std::make_unique<RNGestureHandlerRootViewTouchHandler>(this)) { | ||
| 31 | - auto rnInstance = m_deps->rnInstance.lock(); | ||
| 32 | - if (rnInstance) { | ||
| 33 | - rnInstance->postMessageToArkTS("RNGH::ROOT_CREATED", m_tag); | ||
| 34 | - } | ||
| 35 | -} | ||
| 36 | - | ||
| 37 | -RNGestureHandlerRootViewComponentInstance::RNGestureHandlerRootViewTouchHandler::RNGestureHandlerRootViewTouchHandler( | ||
| 38 | - RNGestureHandlerRootViewComponentInstance *rootView) | ||
| 39 | - : UIInputEventHandler(rootView->getLocalRootArkUINode()), m_rootView(rootView) {} | ||
| 40 | - | ||
| 41 | -TouchTarget::Shared | ||
| 42 | -RNGestureHandlerRootViewComponentInstance::findTargetForTouchPoint(Point const &point, | ||
| 43 | - TouchTarget::Shared const &target) { | ||
| 44 | - bool canHandleTouch = | ||
| 45 | - target->canHandleTouch() && target->containsPoint(point) && (target->getTouchEventEmitter() != nullptr); | ||
| 46 | - bool canChildrenHandleTouch = target->canChildrenHandleTouch() && target->containsPointInBoundingBox(point); | ||
| 47 | - | ||
| 48 | - if (canChildrenHandleTouch) { | ||
| 49 | - auto children = target->getTouchTargetChildren(); | ||
| 50 | - // we want to check the children in reverse order, since the last child is the topmost one | ||
| 51 | - std::reverse(children.begin(), children.end()); | ||
| 52 | - for (auto const &child : children) { | ||
| 53 | - auto childPoint = target->computeChildPoint(point, child); | ||
| 54 | - auto result = findTargetForTouchPoint(childPoint, child); | ||
| 55 | - if (result != nullptr) { | ||
| 56 | - return result; | ||
| 57 | - } | ||
| 58 | - } | ||
| 59 | - } | ||
| 60 | - if (canHandleTouch) { | ||
| 61 | - return target; | ||
| 62 | - } | ||
| 63 | - return nullptr; | ||
| 64 | -} | ||
| 65 | - | ||
| 66 | -void RNGestureHandlerRootViewComponentInstance::RNGestureHandlerRootViewTouchHandler::onTouchEvent( | ||
| 67 | - ArkUI_UIInputEvent *e) { | ||
| 68 | - auto eventTime = OH_ArkUI_UIInputEvent_GetEventTime(e); | ||
| 69 | - if (eventTime < lastEventTime) { | ||
| 70 | - return; | ||
| 71 | - } | ||
| 72 | - lastEventTime = eventTime; | ||
| 73 | - auto ancestor = m_rootView->getParent().lock(); | ||
| 74 | - while (ancestor != nullptr) { | ||
| 75 | - auto ancestorRNGHRootView = std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>(ancestor); | ||
| 76 | - if (ancestorRNGHRootView != nullptr) { | ||
| 77 | - return; | ||
| 78 | - } | ||
| 79 | - ancestor = ancestor->getParent().lock(); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - auto ancestorTouchTarget = m_rootView->getTouchTargetParent(); | ||
| 83 | - auto rnInstance = m_rootView->m_deps->rnInstance.lock(); | ||
| 84 | - while (ancestorTouchTarget != nullptr) { | ||
| 85 | - if (ancestorTouchTarget->isHandlingTouches()) { | ||
| 86 | - rnInstance->postMessageToArkTS("RNGH::CANCEL_TOUCHES", m_rootView->getTag()); | ||
| 87 | - return; | ||
| 88 | - } | ||
| 89 | - ancestorTouchTarget = ancestorTouchTarget->getTouchTargetParent(); | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - folly::dynamic payload = folly::dynamic::object; | ||
| 93 | - folly::dynamic touchPoints = folly::dynamic::array(); | ||
| 94 | - std::vector<TouchableView> touchableViews; | ||
| 95 | - | ||
| 96 | - auto action = OH_ArkUI_UIInputEvent_GetAction(e); | ||
| 97 | - auto actionType = static_cast<ActionType>(action); | ||
| 98 | - | ||
| 99 | - if (actionType != ActionType::Move) { | ||
| 100 | - auto componentX = OH_ArkUI_PointerEvent_GetX(e); | ||
| 101 | - auto componentY = OH_ArkUI_PointerEvent_GetY(e); | ||
| 102 | - touchableViews = m_rootView->findTouchableViews(componentX, componentY); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - auto activeWindowX = OH_ArkUI_PointerEvent_GetWindowX(e); | ||
| 106 | - auto activeWindowY = OH_ArkUI_PointerEvent_GetWindowY(e); | ||
| 107 | - int32_t pointerCount = OH_ArkUI_PointerEvent_GetPointerCount(e); | ||
| 108 | - double minDist = -1; | ||
| 109 | - int activePointerIdx = 0; | ||
| 110 | - for (int i = 0; i < pointerCount; i++) { | ||
| 111 | - auto touchPoint = m_rootView->convertNodeTouchPointToDynamic(e, i); | ||
| 112 | - touchPoints.push_back(touchPoint); | ||
| 113 | - auto dist = pow(activeWindowX - touchPoint["windowX"].asDouble(), 2) + | ||
| 114 | - pow(activeWindowY - touchPoint["windowY"].asDouble(), 2); | ||
| 115 | - if (minDist < 0 || dist < minDist) { | ||
| 116 | - minDist = dist; | ||
| 117 | - activePointerIdx = i; | ||
| 118 | - } | ||
| 119 | - } | ||
| 120 | - payload["actionTouch"] = touchPoints[activePointerIdx]; | ||
| 121 | - payload["touchPoints"] = touchPoints; | ||
| 122 | - payload["sourceType"] = OH_ArkUI_UIInputEvent_GetSourceType(e); | ||
| 123 | - payload["timestamp"] = eventTime; | ||
| 124 | - payload["touchableViews"] = m_rootView->dynamicFromTouchableViews(touchableViews); | ||
| 125 | - payload["rootTag"] = m_rootView->getTag(); | ||
| 126 | - payload["action"] = action; | ||
| 127 | - if (rnInstance) { | ||
| 128 | - rnInstance->postMessageToArkTS("RNGH::TOUCH_EVENT", payload); | ||
| 129 | - } | ||
| 130 | -} | ||
| 131 | - | ||
| 132 | -StackNode &RNGestureHandlerRootViewComponentInstance::getLocalRootArkUINode() { return m_stackNode; } | ||
| 133 | - | ||
| 134 | -void RNGestureHandlerRootViewComponentInstance::setIsHandlingTouches(bool isHandlingTouches) { | ||
| 135 | - m_isHandlingTouches = isHandlingTouches; | ||
| 136 | -} | ||
| 137 | - | ||
| 138 | -bool RNGestureHandlerRootViewComponentInstance::isHandlingTouches() const { return m_isHandlingTouches; } | ||
| 139 | - | ||
| 140 | -void RNGestureHandlerRootViewComponentInstance::onChildInserted(ComponentInstance::Shared const &childComponentInstance, | ||
| 141 | - std::size_t index) { | ||
| 142 | - CppComponentInstance::onChildInserted(childComponentInstance, index); | ||
| 143 | - m_stackNode.insertChild(childComponentInstance->getLocalRootArkUINode(), index); | ||
| 144 | -} | ||
| 145 | - | ||
| 146 | -void RNGestureHandlerRootViewComponentInstance::onChildRemoved( | ||
| 147 | - ComponentInstance::Shared const &childComponentInstance) { | ||
| 148 | - CppComponentInstance::onChildRemoved(childComponentInstance); | ||
| 149 | - m_stackNode.removeChild(childComponentInstance->getLocalRootArkUINode()); | ||
| 150 | -} | ||
| 151 | - | ||
| 152 | -std::vector<RNGestureHandlerRootViewComponentInstance::TouchableView> | ||
| 153 | -RNGestureHandlerRootViewComponentInstance::findTouchableViews(float componentX, float componentY) { | ||
| 154 | - auto touchTarget = findTargetForTouchPoint({.x = componentX, .y = componentY}, this->shared_from_this()); | ||
| 155 | - std::vector<TouchTarget::Shared> touchTargets{}; | ||
| 156 | - auto tmp = touchTarget; | ||
| 157 | - while (tmp != nullptr) { | ||
| 158 | - touchTargets.push_back(tmp); | ||
| 159 | - tmp = tmp->getTouchTargetParent(); | ||
| 160 | - } | ||
| 161 | - std::reverse(touchTargets.begin(), touchTargets.end()); | ||
| 162 | - | ||
| 163 | - std::vector<TouchableView> touchableViews{}; | ||
| 164 | - float offsetX = 0; | ||
| 165 | - float offsetY = 0; | ||
| 166 | - auto surface = this->getSurface().lock(); | ||
| 167 | - if (surface != nullptr) { | ||
| 168 | - offsetX = surface->getLayoutContext().viewportOffset.x; | ||
| 169 | - offsetY = surface->getLayoutContext().viewportOffset.y; | ||
| 170 | - } else { | ||
| 171 | - LOG(WARNING) << "Surface is nullptr"; | ||
| 172 | - } | ||
| 173 | - for (auto &touchTarget : touchTargets) { | ||
| 174 | - auto buttonRole = dynamic_cast<RNGestureHandlerButtonComponentInstance *>(touchTarget.get()) != nullptr; | ||
| 175 | - auto frame = touchTarget->getLayoutMetrics().frame; | ||
| 176 | - auto transform = touchTarget->getTransform(); | ||
| 177 | - auto transformedFrame = frame * transform; | ||
| 178 | - touchableViews.push_back({ | ||
| 179 | - .tag = touchTarget->getTouchTargetTag(), | ||
| 180 | - .width = transformedFrame.size.width, | ||
| 181 | - .height = transformedFrame.size.height, | ||
| 182 | - .x = transformedFrame.origin.x + offsetX, | ||
| 183 | - .y = transformedFrame.origin.y + offsetY, | ||
| 184 | - .buttonRole = buttonRole, | ||
| 185 | - }); | ||
| 186 | - offsetX += transformedFrame.origin.x; | ||
| 187 | - offsetY += transformedFrame.origin.y; | ||
| 188 | - offsetX -= touchTarget->getCurrentOffset().x; | ||
| 189 | - offsetY -= touchTarget->getCurrentOffset().y; | ||
| 190 | - } | ||
| 191 | - | ||
| 192 | - return touchableViews; | ||
| 193 | -} | ||
| 194 | - | ||
| 195 | -folly::dynamic | ||
| 196 | -RNGestureHandlerRootViewComponentInstance::dynamicFromTouchableViews(const std::vector<TouchableView> &touchableViews) { | ||
| 197 | - folly::dynamic d_touchableViews = folly::dynamic::array(); | ||
| 198 | - for (auto touchableView : touchableViews) { | ||
| 199 | - folly::dynamic d_touchableView = folly::dynamic::object; | ||
| 200 | - d_touchableView["tag"] = touchableView.tag; | ||
| 201 | - d_touchableView["x"] = touchableView.x; | ||
| 202 | - d_touchableView["y"] = touchableView.y; | ||
| 203 | - d_touchableView["width"] = touchableView.width; | ||
| 204 | - d_touchableView["height"] = touchableView.height; | ||
| 205 | - d_touchableView["buttonRole"] = touchableView.buttonRole; | ||
| 206 | - d_touchableViews.push_back(d_touchableView); | ||
| 207 | - } | ||
| 208 | - return d_touchableViews; | ||
| 209 | -} | ||
| 210 | - | ||
| 211 | -folly::dynamic RNGestureHandlerRootViewComponentInstance::convertNodeTouchPointToDynamic(ArkUI_UIInputEvent *e, | ||
| 212 | - int32_t index) { | ||
| 213 | - folly::dynamic result = folly::dynamic::object; | ||
| 214 | - result["pointerId"] = OH_ArkUI_PointerEvent_GetPointerId(e, index); | ||
| 215 | - result["windowX"] = OH_ArkUI_PointerEvent_GetWindowXByIndex(e, index); | ||
| 216 | - result["windowY"] = OH_ArkUI_PointerEvent_GetWindowYByIndex(e, index); | ||
| 217 | - return result; | ||
| 218 | -} | ||
| 219 | - | ||
| 220 | -Surface::Weak RNGestureHandlerRootViewComponentInstance::getSurface() { | ||
| 221 | - if (m_surface.lock() != nullptr) { | ||
| 222 | - return m_surface; | ||
| 223 | - } | ||
| 224 | - auto rnInstance = m_deps->rnInstance.lock(); | ||
| 225 | - if (rnInstance == nullptr) { | ||
| 226 | - m_surface.reset(); | ||
| 227 | - return m_surface; | ||
| 228 | - } | ||
| 229 | - ComponentInstance::Shared currentRoot = shared_from_this(); | ||
| 230 | - while (true) { | ||
| 231 | - auto maybeNewCurrentRoot = currentRoot->getParent().lock(); | ||
| 232 | - if (maybeNewCurrentRoot == nullptr) { | ||
| 233 | - break; | ||
| 234 | - } | ||
| 235 | - currentRoot = maybeNewCurrentRoot; | ||
| 236 | - } | ||
| 237 | - auto maybeSurface = rnInstance->getSurfaceByRootTag(currentRoot->getTag()); | ||
| 238 | - if (!maybeSurface.has_value()) { | ||
| 239 | - m_surface.reset(); | ||
| 240 | - return m_surface; | ||
| 241 | - } | ||
| 242 | - m_surface = maybeSurface.value(); | ||
| 243 | - return m_surface; | ||
| 244 | -} | ||
| 245 | - | ||
| 246 | -} // namespace rnoh | ||
| @@ -1,89 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -#pragma once | ||
| 25 | -#import "RNOH/CppComponentInstance.h" | ||
| 26 | -#import "RNOH/arkui/StackNode.h" | ||
| 27 | -#import "RNOH/arkui/NativeNodeApi.h" | ||
| 28 | -#import "RNOH/arkui/UIInputEventHandler.h" | ||
| 29 | -#import "RNOH/RNInstanceCAPI.h" | ||
| 30 | -#import "generated/RNGestureHandlerRootViewComponentDescriptor.h" | ||
| 31 | -#import "RNGestureHandlerButtonComponentInstance.h" | ||
| 32 | - | ||
| 33 | -namespace rnoh { | ||
| 34 | -class RNGestureHandlerRootViewComponentInstance | ||
| 35 | - : public CppComponentInstance<facebook::react::RNGestureHandlerRootViewShadowNode> { | ||
| 36 | -public: | ||
| 37 | - class RNGestureHandlerRootViewTouchHandler : public UIInputEventHandler { | ||
| 38 | - public: | ||
| 39 | - RNGestureHandlerRootViewTouchHandler(RNGestureHandlerRootViewComponentInstance const &other) = delete; | ||
| 40 | - RNGestureHandlerRootViewTouchHandler & | ||
| 41 | - operator=(RNGestureHandlerRootViewComponentInstance const &other) = delete; | ||
| 42 | - RNGestureHandlerRootViewTouchHandler(RNGestureHandlerRootViewComponentInstance &&other) = delete; | ||
| 43 | - RNGestureHandlerRootViewTouchHandler &operator=(RNGestureHandlerRootViewComponentInstance &&other) = delete; | ||
| 44 | - RNGestureHandlerRootViewTouchHandler(RNGestureHandlerRootViewComponentInstance *rootView); | ||
| 45 | - | ||
| 46 | - void onTouchEvent(ArkUI_UIInputEvent *e) override; | ||
| 47 | - | ||
| 48 | - private: | ||
| 49 | - RNGestureHandlerRootViewComponentInstance *m_rootView; | ||
| 50 | - int64_t lastEventTime = 0; | ||
| 51 | - }; | ||
| 52 | - | ||
| 53 | - using Point = facebook::react::Point; | ||
| 54 | - enum class ActionType { Cancel, Down, Move, Up }; | ||
| 55 | - | ||
| 56 | - RNGestureHandlerRootViewComponentInstance(Context context); | ||
| 57 | - | ||
| 58 | - StackNode &getLocalRootArkUINode() override; | ||
| 59 | - void setIsHandlingTouches(bool isHandlingTouches); | ||
| 60 | - bool isHandlingTouches() const override; | ||
| 61 | - | ||
| 62 | - // This function is borrowed from TouchEventDispatcher | ||
| 63 | - TouchTarget::Shared findTargetForTouchPoint(Point const &point, TouchTarget::Shared const &target); | ||
| 64 | - | ||
| 65 | -protected: | ||
| 66 | - void onChildInserted(ComponentInstance::Shared const &childComponentInstance, std::size_t index) override; | ||
| 67 | - void onChildRemoved(ComponentInstance::Shared const &childComponentInstance) override; | ||
| 68 | - | ||
| 69 | -private: | ||
| 70 | - struct TouchableView { | ||
| 71 | - Tag tag; | ||
| 72 | - facebook::react::Float width; | ||
| 73 | - facebook::react::Float height; | ||
| 74 | - facebook::react::Float x; | ||
| 75 | - facebook::react::Float y; | ||
| 76 | - bool buttonRole; | ||
| 77 | - }; | ||
| 78 | - | ||
| 79 | - bool m_isHandlingTouches = false; | ||
| 80 | - StackNode m_stackNode; | ||
| 81 | - Surface::Weak m_surface; | ||
| 82 | - std::unique_ptr<UIInputEventHandler> m_touchHandler; | ||
| 83 | - | ||
| 84 | - std::vector<TouchableView> findTouchableViews(float componentX, float componentY); | ||
| 85 | - folly::dynamic dynamicFromTouchableViews(const std::vector<TouchableView> &touchableViews); | ||
| 86 | - folly::dynamic convertNodeTouchPointToDynamic(ArkUI_UIInputEvent *e, int32_t index = 0); | ||
| 87 | - Surface::Weak getSurface(); | ||
| 88 | -}; | ||
| 89 | -} // namespace rnoh | ||
| @@ -1,167 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -import { GestureHandler, Handler, GestureConfig as Config, GHTag } from "./GestureHandler" | ||
| 25 | -import { RNGHLogger } from "./RNGHLogger" | ||
| 26 | - | ||
| 27 | -export class InteractionManager { | ||
| 28 | - private readonly waitForRelations: Map<GHTag, Set<GHTag>> = new Map() | ||
| 29 | - private readonly simultaneousRelations: Map<GHTag, GHTag[]> = new Map() | ||
| 30 | - private readonly blocksHandlersRelations: Map<GHTag, GHTag[]> = new Map(); | ||
| 31 | - | ||
| 32 | - private logger: RNGHLogger | ||
| 33 | - | ||
| 34 | - constructor(logger: RNGHLogger) { | ||
| 35 | - this.logger = logger.cloneAndJoinPrefix("InteractionManager") | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | - public configureInteractions(handler: GestureHandler, config: Config) { | ||
| 39 | - this.dropRelationsForHandlerWithTag(handler.getTag()); | ||
| 40 | - | ||
| 41 | - if (config.waitFor) { | ||
| 42 | - const waitFor = new Set<GHTag>(); | ||
| 43 | - config.waitFor.forEach((otherHandler: Handler): void => { | ||
| 44 | - // New API reference | ||
| 45 | - if (typeof otherHandler === 'number') { | ||
| 46 | - waitFor.add(otherHandler); | ||
| 47 | - } else { | ||
| 48 | - // Old API reference | ||
| 49 | - waitFor.add(otherHandler.handlerTag); | ||
| 50 | - } | ||
| 51 | - }); | ||
| 52 | - | ||
| 53 | - this.waitForRelations.set(handler.getTag(), waitFor); | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - if (config.simultaneousHandlers) { | ||
| 57 | - const simultaneousHandlers: number[] = []; | ||
| 58 | - config.simultaneousHandlers.forEach((otherHandler: Handler): void => { | ||
| 59 | - if (typeof otherHandler === 'number') { | ||
| 60 | - simultaneousHandlers.push(otherHandler); | ||
| 61 | - } else { | ||
| 62 | - simultaneousHandlers.push(otherHandler.handlerTag); | ||
| 63 | - } | ||
| 64 | - }); | ||
| 65 | - | ||
| 66 | - this.simultaneousRelations.set(handler.getTag(), simultaneousHandlers); | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - if (config.blocksHandlers) { | ||
| 70 | - const blocksHandlers: number[] = []; | ||
| 71 | - config.blocksHandlers.forEach((otherHandler: Handler): void => { | ||
| 72 | - if (typeof otherHandler === 'number') { | ||
| 73 | - blocksHandlers.push(otherHandler); | ||
| 74 | - } else { | ||
| 75 | - blocksHandlers.push(otherHandler.handlerTag); | ||
| 76 | - } | ||
| 77 | - }); | ||
| 78 | - this.blocksHandlersRelations.set(handler.getTag(), blocksHandlers); | ||
| 79 | - } | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - public shouldWaitForHandlerFailure( | ||
| 83 | - handler: GestureHandler, | ||
| 84 | - otherHandler: GestureHandler | ||
| 85 | - ): boolean { | ||
| 86 | - const logger = this.logger.cloneAndJoinPrefix(`shouldWaitForHandlerFailure(${handler.getTag()}, ${otherHandler.getTag()})`) | ||
| 87 | - const waitFor = this.waitForRelations.get( | ||
| 88 | - handler.getTag() | ||
| 89 | - ); | ||
| 90 | - logger.debug({waitFor: Array.from(waitFor ?? [])}) | ||
| 91 | - if (!waitFor) { | ||
| 92 | - logger.debug("false") | ||
| 93 | - return false; | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - let shouldWait = false; | ||
| 97 | - waitFor.forEach((tag: number): void => { | ||
| 98 | - if (tag === otherHandler.getTag()) { | ||
| 99 | - shouldWait = true; | ||
| 100 | - return; //Returns from callback | ||
| 101 | - } | ||
| 102 | - }); | ||
| 103 | - logger.debug(shouldWait) | ||
| 104 | - return shouldWait; | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - public shouldRecognizeSimultaneously( | ||
| 108 | - handler: GestureHandler, | ||
| 109 | - otherHandler: GestureHandler | ||
| 110 | - ): boolean { | ||
| 111 | - const logger = this.logger.cloneAndJoinPrefix(`shouldRecognizeSimultaneously(${handler.getTag()}, ${otherHandler.getTag()})`) | ||
| 112 | - const simultaneousHandlers: number[] | undefined = | ||
| 113 | - this.simultaneousRelations.get(handler.getTag()); | ||
| 114 | - if (!simultaneousHandlers) { | ||
| 115 | - logger.debug(`false - Handler ${handler.getTag()} doesn't have simultaneousRelations specified`) | ||
| 116 | - return false; | ||
| 117 | - } | ||
| 118 | - let shouldRecognizeSimultaneously = false; | ||
| 119 | - simultaneousHandlers.forEach((tag: number): void => { | ||
| 120 | - if (tag === otherHandler.getTag()) { | ||
| 121 | - shouldRecognizeSimultaneously = true; | ||
| 122 | - return; | ||
| 123 | - } | ||
| 124 | - }); | ||
| 125 | - logger.debug(`${shouldRecognizeSimultaneously} ${JSON.stringify({ simultaneousHandlers })}`) | ||
| 126 | - return shouldRecognizeSimultaneously; | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - public shouldRequireHandlerToWaitForFailure( | ||
| 130 | - handler: GestureHandler, | ||
| 131 | - otherHandler: GestureHandler | ||
| 132 | - ): boolean { | ||
| 133 | - const waitFor: number[] | undefined = this.blocksHandlersRelations.get( | ||
| 134 | - handler.getTag() | ||
| 135 | - ); | ||
| 136 | - | ||
| 137 | - return ( | ||
| 138 | - waitFor?.find((tag: number) => { | ||
| 139 | - return tag === otherHandler.getTag(); | ||
| 140 | - }) !== undefined | ||
| 141 | - ); | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | - public shouldHandlerBeCancelledBy( | ||
| 145 | - handler: GestureHandler, | ||
| 146 | - otherHandler: GestureHandler | ||
| 147 | - ): boolean { | ||
| 148 | - const logger = this.logger.cloneAndJoinPrefix(`shouldHandlerBeCancelledBy(handler=${handler.getTag()}, otherHandler=${otherHandler.getTag()})`) | ||
| 149 | - // We check constructor name instead of using `instanceof` in order do avoid circular dependencies | ||
| 150 | - // const isNativeHandler = | ||
| 151 | - // otherHandler.constructor.name === 'NativeViewGestureHandler'; | ||
| 152 | - // const isActive = otherHandler.getState() === State.ACTIVE; | ||
| 153 | - // const isButton = otherHandler.isButton?.() === true; | ||
| 154 | - // return isNativeHandler && isActive && !isButton; | ||
| 155 | - return false | ||
| 156 | - } | ||
| 157 | - | ||
| 158 | - public dropRelationsForHandlerWithTag(handlerTag: number): void { | ||
| 159 | - this.waitForRelations.delete(handlerTag); | ||
| 160 | - this.simultaneousRelations.delete(handlerTag); | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - public reset() { | ||
| 164 | - this.waitForRelations.clear(); | ||
| 165 | - this.simultaneousRelations.clear(); | ||
| 166 | - } | ||
| 167 | -} | ||
| @@ -1,240 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -import { GestureHandler, GestureHandlerDependencies, IncomingEvent, EventType, State, getStateName } from "../core" | ||
| 25 | - | ||
| 26 | -const DEFAULT_MAX_DURATION_MS = 500; | ||
| 27 | -const DEFAULT_NUMBER_OF_TAPS = 1; | ||
| 28 | -const DEFAULT_MAX_DELAY_MS = 200; | ||
| 29 | - | ||
| 30 | -export class TapGestureHandler extends GestureHandler { | ||
| 31 | - private startX = 0; | ||
| 32 | - private startY = 0; | ||
| 33 | - private offsetX = 0; | ||
| 34 | - private offsetY = 0; | ||
| 35 | - private lastX = 0; | ||
| 36 | - private lastY = 0; | ||
| 37 | - private maxNumberOfPointersSoFar = 0; | ||
| 38 | - private numberOfTapsSoFar: number = 0; | ||
| 39 | - private waitTimeout: number | undefined; | ||
| 40 | - private delayTimeout: number | undefined; | ||
| 41 | - | ||
| 42 | - constructor(deps: GestureHandlerDependencies) { | ||
| 43 | - super({ ...deps, logger: deps.logger.cloneAndJoinPrefix(`TapGestureHandler${deps.handlerTag}`) }) | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - public override getName(): string { | ||
| 47 | - return "TapGestureHandler" | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - public override isGestureContinuous(): boolean { | ||
| 51 | - return false | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - onPointerDown(event) { | ||
| 55 | - this.tracker.addToTracker(event); | ||
| 56 | - super.onPointerDown(event); | ||
| 57 | - this.trySettingPosition(event); | ||
| 58 | - this.lastX = event.x; | ||
| 59 | - this.lastY = event.y; | ||
| 60 | - this.updateState(event); | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - onAdditionalPointerAdd(event: IncomingEvent): void { | ||
| 64 | - super.onAdditionalPointerAdd(event); | ||
| 65 | - this.tracker.addToTracker(event); | ||
| 66 | - this.trySettingPosition(event); | ||
| 67 | - | ||
| 68 | - this.offsetX += this.lastX - this.startX; | ||
| 69 | - this.offsetY += this.lastY - this.startY; | ||
| 70 | - | ||
| 71 | - this.lastX = this.tracker.getLastAvgX(); | ||
| 72 | - this.lastY = this.tracker.getLastAvgY(); | ||
| 73 | - | ||
| 74 | - this.startX = this.tracker.getLastAvgX(); | ||
| 75 | - this.startY = this.tracker.getLastAvgY(); | ||
| 76 | - | ||
| 77 | - this.updateState(event); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - onPointerUp(event: IncomingEvent): void { | ||
| 81 | - super.onPointerUp(event); | ||
| 82 | - this.lastX = this.tracker.getLastAvgX(); | ||
| 83 | - this.lastY = this.tracker.getLastAvgY(); | ||
| 84 | - | ||
| 85 | - this.tracker.removeFromTracker(event.pointerId); | ||
| 86 | - | ||
| 87 | - this.updateState(event); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - onAdditionalPointerRemove(event: IncomingEvent): void { | ||
| 91 | - super.onAdditionalPointerRemove(event); | ||
| 92 | - this.tracker.removeFromTracker(event.pointerId); | ||
| 93 | - | ||
| 94 | - this.offsetX += this.lastX - this.startX; | ||
| 95 | - this.offsetY += this.lastY = this.startY; | ||
| 96 | - | ||
| 97 | - this.lastX = this.tracker.getLastAvgX(); | ||
| 98 | - this.lastY = this.tracker.getLastAvgY(); | ||
| 99 | - | ||
| 100 | - this.startX = this.lastX; | ||
| 101 | - this.startY = this.lastY; | ||
| 102 | - | ||
| 103 | - this.updateState(event); | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - onPointerMove(event: IncomingEvent): void { | ||
| 107 | - this.trySettingPosition(event); | ||
| 108 | - this.tracker.track(event); | ||
| 109 | - | ||
| 110 | - this.lastX = this.tracker.getLastAvgX(); | ||
| 111 | - this.lastY = this.tracker.getLastAvgY(); | ||
| 112 | - | ||
| 113 | - this.updateState(event); | ||
| 114 | - | ||
| 115 | - super.onPointerMove(event); | ||
| 116 | - } | ||
| 117 | - | ||
| 118 | - onPointerOutOfBounds(event: IncomingEvent): void { | ||
| 119 | - this.trySettingPosition(event); | ||
| 120 | - this.tracker.track(event); | ||
| 121 | - | ||
| 122 | - this.lastX = this.tracker.getLastAvgX(); | ||
| 123 | - this.lastY = this.tracker.getLastAvgY(); | ||
| 124 | - | ||
| 125 | - this.updateState(event); | ||
| 126 | - | ||
| 127 | - super.onPointerOutOfBounds(event); | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - getDefaultConfig() { | ||
| 131 | - return {} | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - private trySettingPosition(event: IncomingEvent): void { | ||
| 135 | - if (this.currentState !== State.UNDETERMINED) { | ||
| 136 | - return; | ||
| 137 | - } | ||
| 138 | - this.offsetX = 0; | ||
| 139 | - this.offsetY = 0; | ||
| 140 | - this.startX = event.x; | ||
| 141 | - this.startY = event.y; | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | - private updateState(event: IncomingEvent): void { | ||
| 145 | - const logger = this.logger.cloneAndJoinPrefix("updateState") | ||
| 146 | - if (this.maxNumberOfPointersSoFar < this.tracker.getTrackedPointersCount()) { | ||
| 147 | - this.maxNumberOfPointersSoFar = this.tracker.getTrackedPointersCount() | ||
| 148 | - } | ||
| 149 | - if (this.shouldFail()) { | ||
| 150 | - logger.info("fail") | ||
| 151 | - this.fail() | ||
| 152 | - return; | ||
| 153 | - } | ||
| 154 | - switch (this.currentState) { | ||
| 155 | - case State.UNDETERMINED: | ||
| 156 | - if (event.eventType === EventType.DOWN) { | ||
| 157 | - this.begin() | ||
| 158 | - } | ||
| 159 | - this.startTap(); | ||
| 160 | - break; | ||
| 161 | - case State.BEGAN: | ||
| 162 | - if (event.eventType === EventType.UP) { | ||
| 163 | - logger.info("endTap") | ||
| 164 | - this.endTap(); | ||
| 165 | - } | ||
| 166 | - if (event.eventType === EventType.DOWN) { | ||
| 167 | - this.startTap(); | ||
| 168 | - } | ||
| 169 | - break; | ||
| 170 | - default: | ||
| 171 | - logger.info(`default case - currentState ${getStateName(this.currentState)}`) | ||
| 172 | - break; | ||
| 173 | - } | ||
| 174 | - } | ||
| 175 | - | ||
| 176 | - private shouldFail(): boolean { | ||
| 177 | - const maxDeltaX = this.config.maxDeltaX ?? Number.MIN_SAFE_INTEGER | ||
| 178 | - const maxDeltaY = this.config.maxDeltaY ?? Number.MIN_SAFE_INTEGER | ||
| 179 | - const maxDistSq = this.config.maxDistSq ?? Number.MIN_SAFE_INTEGER | ||
| 180 | - | ||
| 181 | - const dx = this.lastX - this.startX + this.offsetX; | ||
| 182 | - if ( | ||
| 183 | - maxDeltaX !== Number.MIN_SAFE_INTEGER && | ||
| 184 | - Math.abs(dx) > maxDeltaX | ||
| 185 | - ) { | ||
| 186 | - return true; | ||
| 187 | - } | ||
| 188 | - const dy = this.lastY - this.startY + this.offsetY; | ||
| 189 | - if ( | ||
| 190 | - maxDeltaY !== Number.MIN_SAFE_INTEGER && | ||
| 191 | - Math.abs(dy) > maxDeltaY | ||
| 192 | - ) { | ||
| 193 | - return true; | ||
| 194 | - } | ||
| 195 | - const distSq = dy * dy + dx * dx; | ||
| 196 | - const result = maxDistSq !== Number.MIN_SAFE_INTEGER && distSq > maxDistSq | ||
| 197 | - return result; | ||
| 198 | - } | ||
| 199 | - | ||
| 200 | - private startTap() { | ||
| 201 | - this.clearTimeouts(); | ||
| 202 | - this.waitTimeout = setTimeout(() => this.fail(), this.config.maxDurationMs ?? DEFAULT_MAX_DURATION_MS); | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - private clearTimeouts() { | ||
| 206 | - clearTimeout(this.waitTimeout); | ||
| 207 | - clearTimeout(this.delayTimeout); | ||
| 208 | - } | ||
| 209 | - | ||
| 210 | - private endTap() { | ||
| 211 | - const logger = this.logger.cloneAndJoinPrefix("endTap") | ||
| 212 | - this.clearTimeouts(); | ||
| 213 | - if ( | ||
| 214 | - this.tracker.getTrackedPointersCount() === 0 && | ||
| 215 | - ++this.numberOfTapsSoFar === (this.config.numberOfTaps ?? DEFAULT_NUMBER_OF_TAPS) && | ||
| 216 | - this.maxNumberOfPointersSoFar >= (this.config.minNumberOfPointers ?? 0) | ||
| 217 | - ) { | ||
| 218 | - logger.info(JSON.stringify({ numberOfTapsSoFar: this.numberOfTapsSoFar })) | ||
| 219 | - this.activate(); | ||
| 220 | - } else { | ||
| 221 | - this.delayTimeout = setTimeout(() => this.fail(), this.config.maxDelayMs ?? DEFAULT_MAX_DELAY_MS); | ||
| 222 | - } | ||
| 223 | - } | ||
| 224 | - | ||
| 225 | - public activate(): void { | ||
| 226 | - super.activate(); | ||
| 227 | - this.end(); | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - protected onCancel() { | ||
| 231 | - super.onCancel() | ||
| 232 | - this.resetProgress() | ||
| 233 | - } | ||
| 234 | - | ||
| 235 | - protected resetProgress(): void { | ||
| 236 | - this.clearTimeouts(); | ||
| 237 | - this.numberOfTapsSoFar = 0; | ||
| 238 | - this.maxNumberOfPointersSoFar = 0; | ||
| 239 | - } | ||
| 240 | -} | ||
| @@ -1,290 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -import { TurboModule, TurboModuleContext, Tag } from "@rnoh/react-native-openharmony/ts"; | ||
| 25 | -import { TM } from "../generated/ts" | ||
| 26 | -import { | ||
| 27 | - GestureHandlerRegistry, | ||
| 28 | - State, | ||
| 29 | - OutgoingEventDispatcher, | ||
| 30 | - RNGHLogger, | ||
| 31 | - InteractionManager, | ||
| 32 | - ViewRegistry | ||
| 33 | -} from '../core'; | ||
| 34 | -import { GestureHandlerFactory } from "../gesture-handlers" | ||
| 35 | -import { RNGHViewRegistry } from './RNGHViewRegistry'; | ||
| 36 | -import { DevelopmentRNGHLogger, ProductionRNGHLogger } from './Logger'; | ||
| 37 | -import { JSEventDispatcher, AnimatedEventDispatcher, ReanimatedEventDispatcher } from './OutgoingEventDispatchers' | ||
| 38 | -import { RNOHScrollLockerCAPI } from "./RNOHScrollLocker" | ||
| 39 | -import { RNGHRootViewController, RawTouchEvent } from "./RNGHRootViewController" | ||
| 40 | -import { RNGHView } from "./RNGHView" | ||
| 41 | -import { RNOHGestureResponder } from "./RNOHGestureResponder" | ||
| 42 | - | ||
| 43 | -export enum ActionType { | ||
| 44 | - REANIMATED_WORKLET = 1, | ||
| 45 | - NATIVE_ANIMATED_EVENT = 2, | ||
| 46 | - JS_FUNCTION_OLD_API = 3, | ||
| 47 | - JS_FUNCTION_NEW_API = 4, | ||
| 48 | -} | ||
| 49 | - | ||
| 50 | - | ||
| 51 | -export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureHandlerModule.Spec { | ||
| 52 | - static readonly NAME = "RNGestureHandlerModule" | ||
| 53 | - | ||
| 54 | - private gestureHandlerRegistry: GestureHandlerRegistry | ||
| 55 | - private gestureHandlerFactory: GestureHandlerFactory | undefined = undefined | ||
| 56 | - private viewRegistry: ViewRegistry | undefined = undefined | ||
| 57 | - private logger: RNGHLogger | ||
| 58 | - private cleanLogger: RNGHLogger | ||
| 59 | - private rootViewControllerByRootTag = new Map<Tag, RNGHRootViewController>() | ||
| 60 | - private interactionManager: InteractionManager | ||
| 61 | - | ||
| 62 | - constructor(ctx: TurboModuleContext, isDevModeEnabled: boolean = false) { | ||
| 63 | - super(ctx) | ||
| 64 | - this.cleanLogger = | ||
| 65 | - isDevModeEnabled && ctx.isDebugModeEnabled ? new DevelopmentRNGHLogger(ctx.logger, "RNGH") : | ||
| 66 | - new ProductionRNGHLogger(ctx.logger, "RNGH") | ||
| 67 | - this.logger = this.cleanLogger.cloneAndJoinPrefix("RNGestureHandlerModule") | ||
| 68 | - const logger = this.logger.cloneAndJoinPrefix("constructor") | ||
| 69 | - const stopTracing = logger.startTracing() | ||
| 70 | - this.interactionManager = new InteractionManager(this.cleanLogger) | ||
| 71 | - this.gestureHandlerRegistry = new GestureHandlerRegistry(this.viewRegistry, this.cleanLogger) | ||
| 72 | - if (this.ctx.rnInstance.getArchitecture() === "C_API") { | ||
| 73 | - this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::TOUCH_EVENT", (e: any) => { | ||
| 74 | - this.onTouch(e) | ||
| 75 | - }) | ||
| 76 | - this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::ROOT_CREATED", (rootTag: any) => { | ||
| 77 | - this.onGHRootCreated(rootTag) | ||
| 78 | - }) | ||
| 79 | - this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::CANCEL_TOUCHES", (rootTag: any) => { | ||
| 80 | - const touchHandler = this.rootViewControllerByRootTag.get(rootTag) | ||
| 81 | - touchHandler?.cancelTouches() | ||
| 82 | - }) | ||
| 83 | - } | ||
| 84 | - stopTracing() | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - /** | ||
| 88 | - * Called from C++. | ||
| 89 | - */ | ||
| 90 | - private onGHRootCreated(rootTag: Tag) { | ||
| 91 | - const stopTracing = this.logger.cloneAndJoinPrefix("onGHRootCreated").startTracing() | ||
| 92 | - this.rootViewControllerByRootTag.set(rootTag, new RNGHRootViewController(this.logger, this.gestureHandlerRegistry)); | ||
| 93 | - stopTracing() | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - /** | ||
| 97 | - * Called from C++. | ||
| 98 | - */ | ||
| 99 | - private onTouch(e: RawTouchEvent & { rootTag: Tag }) { | ||
| 100 | - const logger = this.logger.cloneAndJoinPrefix("onTouch") | ||
| 101 | - const stopTracing = logger.startTracing(); | ||
| 102 | - (() => { | ||
| 103 | - if (!(this.viewRegistry instanceof RNGHViewRegistry)) { | ||
| 104 | - logger.error("Expected ViewRegistryCAPI") | ||
| 105 | - return; | ||
| 106 | - } | ||
| 107 | - const rootViewController = this.rootViewControllerByRootTag.get(e.rootTag) | ||
| 108 | - if (!rootViewController) { | ||
| 109 | - logger.error(`Couldn't find a rootViewController for a gesture root tag: ${e.rootTag}`) | ||
| 110 | - return; | ||
| 111 | - } | ||
| 112 | - // update view registry | ||
| 113 | - e.touchableViews.forEach(touchableView => { | ||
| 114 | - const view = this.viewRegistry.getViewByTag(touchableView.tag) | ||
| 115 | - if (view) { | ||
| 116 | - if (!(view instanceof RNGHView)) { | ||
| 117 | - logger.error(`Expected ViewCAPI`) | ||
| 118 | - return | ||
| 119 | - } | ||
| 120 | - view.updateBoundingBox(touchableView) | ||
| 121 | - view.setButtonRole(touchableView.buttonRole) | ||
| 122 | - } else { | ||
| 123 | - this.viewRegistry.save(new RNGHView(touchableView)) | ||
| 124 | - } | ||
| 125 | - }) | ||
| 126 | - rootViewController.handleTouch(e, e.touchableViews.map(({ tag }) => this.viewRegistry.getViewByTag(tag))); | ||
| 127 | - })() | ||
| 128 | - stopTracing() | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | - // ------------------------------------------------------------------------------------------------------------------- | ||
| 132 | - | ||
| 133 | - public install() { | ||
| 134 | - const stopTracing = this.ctx.logger.clone("install").startTracing() | ||
| 135 | - this.viewRegistry = new RNGHViewRegistry() | ||
| 136 | - const scrollLocker = new RNOHScrollLockerCAPI(this.ctx.rnInstance, this.cleanLogger, this.gestureHandlerRegistry); | ||
| 137 | - const rnGestureResponder = new RNOHGestureResponder(this.ctx.rnInstance) | ||
| 138 | - this.gestureHandlerFactory = | ||
| 139 | - new GestureHandlerFactory(this.cleanLogger, scrollLocker, this.interactionManager, rnGestureResponder) | ||
| 140 | - stopTracing() | ||
| 141 | - return true | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | - public createGestureHandler( | ||
| 145 | - handlerName: string, | ||
| 146 | - handlerTag: number, | ||
| 147 | - config: Readonly<Record<string, unknown>> | ||
| 148 | - ) { | ||
| 149 | - const logger = this.logger.cloneAndJoinPrefix("createGestureHandler") | ||
| 150 | - const stopTracing = logger.startTracing(); | ||
| 151 | - (() => { | ||
| 152 | - if (!this.gestureHandlerFactory) { | ||
| 153 | - logger.error("Trying to create a gesture handler before creating gesture handler factory") | ||
| 154 | - return | ||
| 155 | - } | ||
| 156 | - logger.debug({ handlerName, handlerTag, config }) | ||
| 157 | - const gestureHandler = this.gestureHandlerFactory.create(handlerName, handlerTag) | ||
| 158 | - this.gestureHandlerRegistry.addGestureHandler(gestureHandler) | ||
| 159 | - this.interactionManager.configureInteractions(gestureHandler, config); | ||
| 160 | - gestureHandler.updateGestureConfig(config) | ||
| 161 | - })() | ||
| 162 | - stopTracing() | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | - public attachGestureHandler( | ||
| 166 | - handlerTag: number, | ||
| 167 | - viewTag: number, | ||
| 168 | - actionType: ActionType | ||
| 169 | - ) { | ||
| 170 | - const logger = this.logger.cloneAndJoinPrefix("attachGestureHandler") | ||
| 171 | - const stopTracing = logger.startTracing(); | ||
| 172 | - (() => { | ||
| 173 | - const eventDispatcher = this.createEventDispatcher(actionType, viewTag) | ||
| 174 | - if (!eventDispatcher) { | ||
| 175 | - logger.error("RNGH: Couldn't create EventDispatcher") | ||
| 176 | - return | ||
| 177 | - } | ||
| 178 | - const viewRegistry = this.viewRegistry | ||
| 179 | - let view = this.viewRegistry.getViewByTag(viewTag) | ||
| 180 | - if (!view && viewRegistry instanceof RNGHViewRegistry) { | ||
| 181 | - view = new RNGHView({ | ||
| 182 | - tag: viewTag, | ||
| 183 | - x: 0, | ||
| 184 | - y: 0, | ||
| 185 | - width: 0, | ||
| 186 | - height: 0, | ||
| 187 | - buttonRole: false | ||
| 188 | - }) | ||
| 189 | - viewRegistry.save(view) | ||
| 190 | - } | ||
| 191 | - if (!view) { | ||
| 192 | - logger.error("Expected view") | ||
| 193 | - return; | ||
| 194 | - } | ||
| 195 | - this.gestureHandlerRegistry.bindGestureHandlerWithView(handlerTag, view) | ||
| 196 | - this.gestureHandlerRegistry.getGestureHandlersByViewTag(view.getTag()).forEach((handler) => { | ||
| 197 | - if (handler.isGestureContinuous() && eventDispatcher instanceof JSEventDispatcher) { | ||
| 198 | - logger.warn(`Using JSEventDispatcher for a continuous gesture (${handler.getName()}). Gesture-driven animations may not be smooth. Consider using Animated.event.`) | ||
| 199 | - } | ||
| 200 | - }) | ||
| 201 | - this.gestureHandlerRegistry | ||
| 202 | - .getGestureHandlerByHandlerTag(handlerTag) | ||
| 203 | - .setEventDispatcher(eventDispatcher) | ||
| 204 | - })() | ||
| 205 | - stopTracing() | ||
| 206 | - } | ||
| 207 | - | ||
| 208 | - private createEventDispatcher(actionType: ActionType, viewTag: number): OutgoingEventDispatcher | null { | ||
| 209 | - switch (actionType) { | ||
| 210 | - case ActionType.REANIMATED_WORKLET: | ||
| 211 | - return new ReanimatedEventDispatcher(this.ctx.rnInstance, | ||
| 212 | - this.cleanLogger, viewTag) | ||
| 213 | - case ActionType.NATIVE_ANIMATED_EVENT: | ||
| 214 | - return new AnimatedEventDispatcher(this.ctx.rnInstance, | ||
| 215 | - this.cleanLogger, viewTag) | ||
| 216 | - case ActionType.JS_FUNCTION_OLD_API: | ||
| 217 | - case ActionType.JS_FUNCTION_NEW_API: | ||
| 218 | - return new JSEventDispatcher(this.ctx.rnInstance, this.cleanLogger); | ||
| 219 | - } | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - public updateGestureHandler( | ||
| 223 | - handlerTag: number, | ||
| 224 | - newConfig: Readonly<Record<string, unknown>> | ||
| 225 | - ) { | ||
| 226 | - const stopTracing = this.logger.cloneAndJoinPrefix("updateGestureHandler").startTracing() | ||
| 227 | - const gestureHandler = this.gestureHandlerRegistry.getGestureHandlerByHandlerTag(handlerTag) | ||
| 228 | - this.interactionManager.configureInteractions(gestureHandler, newConfig); | ||
| 229 | - gestureHandler.updateGestureConfig(newConfig) | ||
| 230 | - stopTracing() | ||
| 231 | - } | ||
| 232 | - | ||
| 233 | - public dropGestureHandler(handlerTag: number) { | ||
| 234 | - const stopTracing = this.logger.cloneAndJoinPrefix("dropGestureHandler").startTracing() | ||
| 235 | - this.interactionManager.dropRelationsForHandlerWithTag(handlerTag) | ||
| 236 | - this.gestureHandlerRegistry.removeGestureHandlerByHandlerTag(handlerTag) | ||
| 237 | - stopTracing() | ||
| 238 | - } | ||
| 239 | - | ||
| 240 | - public handleSetJSResponder(tag: number, blockNativeResponder: boolean) { | ||
| 241 | - this.logger.cloneAndJoinPrefix("handleSetJSResponder").warn("not implemented") | ||
| 242 | - } | ||
| 243 | - | ||
| 244 | - public handleClearJSResponder() { | ||
| 245 | - this.logger.cloneAndJoinPrefix("handleClearJSResponder").warn("not implemented") | ||
| 246 | - } | ||
| 247 | - | ||
| 248 | - public flushOperations() { | ||
| 249 | - // no-op | ||
| 250 | - } | ||
| 251 | - | ||
| 252 | - // ------------------------------------------------------------------------------------------------------------------- | ||
| 253 | - | ||
| 254 | - public getGestureHandlerRegistry() { | ||
| 255 | - return this.gestureHandlerRegistry | ||
| 256 | - } | ||
| 257 | - | ||
| 258 | - public getLogger() { | ||
| 259 | - return this.logger | ||
| 260 | - } | ||
| 261 | - | ||
| 262 | - public getViewRegistry() { | ||
| 263 | - if (!this.viewRegistry) { | ||
| 264 | - this.logger.error("Tried to get viewRegistry before it was initialized") | ||
| 265 | - throw new Error("Tried to get viewRegistry before it was initialized") | ||
| 266 | - } | ||
| 267 | - return this.viewRegistry | ||
| 268 | - } | ||
| 269 | - | ||
| 270 | - public setGestureHandlerState(handlerTag: number, newState: State) { | ||
| 271 | - const handler = this.getGestureHandlerRegistry().getGestureHandlerByHandlerTag(handlerTag); | ||
| 272 | - switch (newState) { | ||
| 273 | - case State.ACTIVE: | ||
| 274 | - handler.activate(); | ||
| 275 | - break; | ||
| 276 | - case State.BEGAN: | ||
| 277 | - handler.begin(); | ||
| 278 | - break; | ||
| 279 | - case State.END: | ||
| 280 | - handler.end(); | ||
| 281 | - break; | ||
| 282 | - case State.FAILED: | ||
| 283 | - handler.fail(); | ||
| 284 | - break; | ||
| 285 | - case State.CANCELLED: | ||
| 286 | - handler.cancel(); | ||
| 287 | - break; | ||
| 288 | - } | ||
| 289 | - } | ||
| 290 | -} | ||
| @@ -1,7 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | - * Use of this source code is governed by a MIT license that can be | ||
| 4 | - * found in the LICENSE file. | ||
| 5 | - */ | ||
| 6 | -export * from "./src/main/ets/rnoh/GestureHandlerPackage" | ||
| 7 | -export * from "./src/main/ets/rnoh/RNGestureHandlerModule" | ||
| @@ -1,7 +0,0 @@ | |||
| 1 | -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. | ||
| 2 | -import { appTasks } from '@ohos/hvigor-ohos-plugin'; | ||
| 3 | - | ||
| 4 | -export default { | ||
| 5 | - system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ | ||
| 6 | - plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ | ||
| 7 | -} | ||
| @@ -1,11 +0,0 @@ | |||
| 1 | -17:33:43:409 log timer task size: 1 | ||
| 2 | -17:33:44:955 log task queue not empty | ||
| 3 | -17:33:44:955 log task size: 1 | ||
| 4 | -17:33:44:955 log before pop task size: 1 | ||
| 5 | -17:33:44:955 log after task size: 0 | ||
| 6 | -17:33:45:467 log timer task size: 1 | ||
| 7 | -17:33:45:640 log task queue not empty | ||
| 8 | -17:33:45:640 log task size: 1 | ||
| 9 | -17:33:45:640 log before pop task size: 1 | ||
| 10 | -17:33:45:641 log after task size: 0 | ||
| 11 | -17:33:46:144 log timer task size: 1 | ||
| @@ -1,32 +0,0 @@ | |||
| 1 | -const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); | ||
| 2 | -const { createHarmonyMetroConfig } = require('react-native-harmony/metro.config'); | ||
| 3 | -/** | ||
| 4 | - * Metro configuration | ||
| 5 | - * https://reactnative.dev/docs/metro | ||
| 6 | - * | ||
| 7 | - * @type {import('@react-native/metro-config').MetroConfig} | ||
| 8 | - */ | ||
| 9 | -const config = { | ||
| 10 | - // resetCache: true, | ||
| 11 | - // serializer: { | ||
| 12 | - // getModulesRunBeforeMainModule: () => [ | ||
| 13 | - // require.resolve('@react-native-oh/react-native-harmony/Libraries/Core/InitializeCore'), | ||
| 14 | - // ] | ||
| 15 | - // }, | ||
| 16 | - transformer: { | ||
| 17 | - getTransformOptions: async () => ({ | ||
| 18 | - transform: { | ||
| 19 | - experimentalImportSupport: false, | ||
| 20 | - inlineRequires: true, | ||
| 21 | - }, | ||
| 22 | - }), | ||
| 23 | - }, | ||
| 24 | -}; | ||
| 25 | - | ||
| 26 | -module.exports = mergeConfig( | ||
| 27 | - getDefaultConfig(__dirname), | ||
| 28 | - createHarmonyMetroConfig({ | ||
| 29 | - reactNativeHarmonyPackageName: 'react-native-harmony', | ||
| 30 | - }), | ||
| 31 | - config, | ||
| 32 | -); | ||
| @@ -1,7 +0,0 @@ | |||
| 1 | -/node_modules | ||
| 2 | -/oh_modules | ||
| 3 | -/.preview | ||
| 4 | -/build | ||
| 5 | -/.cxx | ||
| 6 | -/.test | ||
| 7 | -./BuildProfile.ets | ||
| @@ -1,17 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Use these variables when you tailor your ArkTS code. They must be of the const type. | ||
| 3 | - */ | ||
| 4 | -export const HAR_VERSION = '2.23.2-rc.1'; | ||
| 5 | -export const BUILD_MODE_NAME = 'debug'; | ||
| 6 | -export const DEBUG = true; | ||
| 7 | -export const TARGET_NAME = 'default'; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * BuildProfile Class is used only for compatibility purposes. | ||
| 11 | - */ | ||
| 12 | -export default class BuildProfile { | ||
| 13 | - static readonly HAR_VERSION = HAR_VERSION; | ||
| 14 | - static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; | ||
| 15 | - static readonly DEBUG = DEBUG; | ||
| 16 | - static readonly TARGET_NAME = TARGET_NAME; | ||
| 17 | -} | ||
| @@ -1,12 +0,0 @@ | |||
| 1 | -{ | ||
| 2 | - "apiType": 'stageMode', | ||
| 3 | - "targets": [ | ||
| 4 | - { | ||
| 5 | - "name": "default", | ||
| 6 | - "runtimeOS": "HarmonyOS" | ||
| 7 | - }, | ||
| 8 | - { | ||
| 9 | - "name": "ohosTest", | ||
| 10 | - } | ||
| 11 | - ] | ||
| 12 | -} | ||
| @@ -1,7 +0,0 @@ | |||
| 1 | -/* | ||
| 2 | - * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved | ||
| 3 | - * Use of this source code is governed by a MIT license that can be | ||
| 4 | - * found in the LICENSE file. | ||
| 5 | - */ | ||
| 6 | -export * from "./ts" | ||
| 7 | -export { default } from "./src/main/ets/RNOHPackage" | ||
| @@ -1,10 +0,0 @@ | |||
| 1 | -cmake_minimum_required(VERSION 3.13) | ||
| 2 | -set(CMAKE_VERBOSE_MAKEFILE on) | ||
| 3 | - | ||
| 4 | -set(rnoh_gesture_handle_generated_dir "${CMAKE_CURRENT_SOURCE_DIR}/generated") | ||
| 5 | -file(GLOB_RECURSE rnoh_gesture_handle_generated_SRC "${rnoh_gesture_handle_generated_dir}/*.cpp") | ||
| 6 | -file(GLOB_RECURSE rnoh_gesture_handler_SRC CONFIGURE_DEPENDS *.cpp) | ||
| 7 | - | ||
| 8 | -add_library(rnoh_gesture_handler SHARED ${rnoh_gesture_handler_SRC} ${rnoh_gesture_handle_generated_SRC}) | ||
| 9 | -target_include_directories(rnoh_gesture_handler PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${rnoh_gesture_handle_generated_dir}) | ||
| 10 | -target_link_libraries(rnoh_gesture_handler PUBLIC rnoh) | ||
| @@ -1,35 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -#pragma once | ||
| 25 | -#include "RnohReactNativeHarmonyGestureHandlerPackage.h" | ||
| 26 | - | ||
| 27 | -namespace rnoh { | ||
| 28 | -/** | ||
| 29 | - * @deprecated: Use RnohReactNativeHarmonyGestureHandlerPackage instead (2024-10-10) | ||
| 30 | - */ | ||
| 31 | -class GestureHandlerPackage : public RnohReactNativeHarmonyGestureHandlerPackage { | ||
| 32 | - using Super = RnohReactNativeHarmonyGestureHandlerPackage; | ||
| 33 | - using Super::Super; | ||
| 34 | -}; | ||
| 35 | -} // namespace rnoh | ||
| @@ -1,178 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -#pragma once | ||
| 25 | -#include "RnohReactNativeHarmonyGestureHandlerPackage.h" | ||
| 26 | -#include "RNOH/RNInstanceCAPI.h" | ||
| 27 | -#include "componentInstances/RNGestureHandlerButtonComponentInstance.h" | ||
| 28 | -#include "componentInstances/RNGestureHandlerRootViewComponentInstance.h" | ||
| 29 | -#include <glog/logging.h> | ||
| 30 | -#include <cxxreact/SystraceSection.h> | ||
| 31 | -#include "RNOH/ArkTSTurboModule.h" | ||
| 32 | -#include "generated/RNGestureHandlerModule.h" | ||
| 33 | -#include "generated/RNGestureHandlerButtonComponentDescriptor.h" | ||
| 34 | -#include "generated/RNGestureHandlerRootViewComponentDescriptor.h" | ||
| 35 | -#include "generated/RNGestureHandlerButtonJSIBinder.h" | ||
| 36 | -#include "generated/RNGestureHandlerRootViewJSIBinder.h" | ||
| 37 | -using namespace rnoh; | ||
| 38 | -using namespace facebook; | ||
| 39 | - | ||
| 40 | -class GestureHandlerTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate { | ||
| 41 | -public: | ||
| 42 | - SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override { | ||
| 43 | - if (name == "RNGestureHandlerModule") { | ||
| 44 | - return std::make_shared<RNGestureHandlerModule>(ctx, name); | ||
| 45 | - } | ||
| 46 | - return nullptr; | ||
| 47 | - }; | ||
| 48 | -}; | ||
| 49 | - | ||
| 50 | -class RNGHEventEmitRequestHandler : public EventEmitRequestHandler { | ||
| 51 | - void handleEvent(EventEmitRequestHandler::Context const &ctx) override { | ||
| 52 | - facebook::react::SystraceSection s("RNGH::RNGHEventEmitRequestHandler::handleEvent"); | ||
| 53 | - auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::ViewEventEmitter>(ctx.tag); | ||
| 54 | - if (eventEmitter == nullptr) { | ||
| 55 | - return; | ||
| 56 | - } | ||
| 57 | - if (ctx.eventName == "onGestureHandlerEvent") { | ||
| 58 | - eventEmitter->dispatchUniqueEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload)); | ||
| 59 | - } else if (ctx.eventName == "onGestureHandlerStateChange") { | ||
| 60 | - eventEmitter->dispatchEvent("onGestureHandlerStateChange", ArkJS(ctx.env).getDynamic(ctx.payload)); | ||
| 61 | - } | ||
| 62 | - } | ||
| 63 | -}; | ||
| 64 | - | ||
| 65 | -class RNOHCorePackageComponentInstanceFactoryDelegate : public ComponentInstanceFactoryDelegate { | ||
| 66 | -public: | ||
| 67 | - using ComponentInstanceFactoryDelegate::ComponentInstanceFactoryDelegate; | ||
| 68 | - | ||
| 69 | - ComponentInstance::Shared create(ComponentInstance::Context ctx) override { | ||
| 70 | - if (ctx.componentName == "RNGestureHandlerButton") { | ||
| 71 | - return std::make_shared<RNGestureHandlerButtonComponentInstance>(ctx); | ||
| 72 | - } else if (ctx.componentName == "RNGestureHandlerRootView") { | ||
| 73 | - return std::make_shared<RNGestureHandlerRootViewComponentInstance>(ctx); | ||
| 74 | - } | ||
| 75 | - return nullptr; | ||
| 76 | - } | ||
| 77 | -}; | ||
| 78 | - | ||
| 79 | -std::unique_ptr<TurboModuleFactoryDelegate> RnohReactNativeHarmonyGestureHandlerPackage::createTurboModuleFactoryDelegate() { | ||
| 80 | - return std::make_unique<GestureHandlerTurboModuleFactoryDelegate>(); | ||
| 81 | -} | ||
| 82 | - | ||
| 83 | -std::vector<react::ComponentDescriptorProvider> RnohReactNativeHarmonyGestureHandlerPackage::createComponentDescriptorProviders() { | ||
| 84 | - return { | ||
| 85 | - react::concreteComponentDescriptorProvider<react::RNGestureHandlerRootViewComponentDescriptor>(), | ||
| 86 | - react::concreteComponentDescriptorProvider<react::RNGestureHandlerButtonComponentDescriptor>(), | ||
| 87 | - }; | ||
| 88 | -} | ||
| 89 | - | ||
| 90 | -ComponentJSIBinderByString RnohReactNativeHarmonyGestureHandlerPackage::createComponentJSIBinderByName() { | ||
| 91 | - return { | ||
| 92 | - {"RNGestureHandlerButton", std::make_shared<RNGestureHandlerButtonJSIBinder>()}, | ||
| 93 | - {"RNGestureHandlerRootView", std::make_shared<RNGestureHandlerRootViewJSIBinder>()}, | ||
| 94 | - }; | ||
| 95 | -}; | ||
| 96 | - | ||
| 97 | -EventEmitRequestHandlers RnohReactNativeHarmonyGestureHandlerPackage::createEventEmitRequestHandlers() { | ||
| 98 | - return { | ||
| 99 | - std::make_shared<RNGHEventEmitRequestHandler>(), | ||
| 100 | - }; | ||
| 101 | -} | ||
| 102 | - | ||
| 103 | -ComponentInstanceFactoryDelegate::Shared | ||
| 104 | -RnohReactNativeHarmonyGestureHandlerPackage::createComponentInstanceFactoryDelegate() { | ||
| 105 | - return std::make_shared<RNOHCorePackageComponentInstanceFactoryDelegate>(); | ||
| 106 | -} | ||
| 107 | - | ||
| 108 | -class ScrollLockerArkTSMessageHandler : public ArkTSMessageHandler { | ||
| 109 | -public: | ||
| 110 | - void handleArkTSMessage(const Context &ctx) override { | ||
| 111 | - facebook::react::SystraceSection s("RNGH::ScrollLockerArkTSMessageHandler::handleArkTSMessage"); | ||
| 112 | - if (ctx.messageName == "RNGH::SET_NATIVE_RESPONDERS_BLOCK") { | ||
| 113 | - auto targetComponentInstanceTag = ctx.messagePayload["targetTag"].asDouble(); | ||
| 114 | - auto shouldBlock = ctx.messagePayload["shouldBlock"].asBool(); | ||
| 115 | - auto rnInstance = ctx.rnInstance.lock(); | ||
| 116 | - if (rnInstance != nullptr) { | ||
| 117 | - auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance); | ||
| 118 | - if (rnInstanceCAPI != nullptr) { | ||
| 119 | - | ||
| 120 | - std::vector<ComponentInstance::Shared> ancestors; | ||
| 121 | - auto tmpComponentInstance = rnInstanceCAPI->findComponentInstanceByTag(targetComponentInstanceTag); | ||
| 122 | - while (tmpComponentInstance != nullptr) { | ||
| 123 | - ancestors.push_back(tmpComponentInstance); | ||
| 124 | - tmpComponentInstance = tmpComponentInstance->getParent().lock(); | ||
| 125 | - } | ||
| 126 | - if (ancestors.size() == 0) { | ||
| 127 | - return; | ||
| 128 | - } | ||
| 129 | - /** | ||
| 130 | - * Ensure consistent behavior with Android by not blocking | ||
| 131 | - * scrolls above the GestureHandlerRootView handling the | ||
| 132 | - * touch. If there are multiple nested | ||
| 133 | - * GestureHandlerRootViews, the one nearest to the actual | ||
| 134 | - * root will handle the touch. | ||
| 135 | - */ | ||
| 136 | - auto isChangingResponderStatusAllowed = false; | ||
| 137 | - for (int i = ancestors.size() - 1; i >= 0; i--) { | ||
| 138 | - auto ancestor = ancestors[i]; | ||
| 139 | - if (!isChangingResponderStatusAllowed) { | ||
| 140 | - auto rootView = | ||
| 141 | - std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>(ancestor); | ||
| 142 | - if (rootView != nullptr) { | ||
| 143 | - isChangingResponderStatusAllowed = true; | ||
| 144 | - } | ||
| 145 | - } else { | ||
| 146 | - ancestor->setNativeResponderBlocked(shouldBlock, "RNGH"); | ||
| 147 | - } | ||
| 148 | - } | ||
| 149 | - } | ||
| 150 | - } | ||
| 151 | - } else if (ctx.messageName == "RNGH::ROOT_VIEW_IS_HANDLING_TOUCHES") { | ||
| 152 | - auto descendantViewTag = ctx.messagePayload["descendantViewTag"].asDouble(); | ||
| 153 | - auto isHandlingTouches = ctx.messagePayload["isHandlingTouches"].asBool(); | ||
| 154 | - auto rnInstance = ctx.rnInstance.lock(); | ||
| 155 | - if (rnInstance != nullptr) { | ||
| 156 | - auto rnInstanceCAPI = std::dynamic_pointer_cast<RNInstanceCAPI>(rnInstance); | ||
| 157 | - if (rnInstanceCAPI != nullptr) { | ||
| 158 | - auto tmpComponentInstance = rnInstanceCAPI->findComponentInstanceByTag(descendantViewTag); | ||
| 159 | - while (tmpComponentInstance != nullptr) { | ||
| 160 | - tmpComponentInstance = tmpComponentInstance->getParent().lock(); | ||
| 161 | - if (tmpComponentInstance) { | ||
| 162 | - auto rnghRootViewComponentInstance = | ||
| 163 | - std::dynamic_pointer_cast<RNGestureHandlerRootViewComponentInstance>( | ||
| 164 | - tmpComponentInstance); | ||
| 165 | - if (rnghRootViewComponentInstance) { | ||
| 166 | - rnghRootViewComponentInstance->setIsHandlingTouches(isHandlingTouches); | ||
| 167 | - } | ||
| 168 | - } | ||
| 169 | - } | ||
| 170 | - } | ||
| 171 | - } | ||
| 172 | - } | ||
| 173 | - }; | ||
| 174 | -}; | ||
| 175 | - | ||
| 176 | -std::vector<ArkTSMessageHandler::Shared> RnohReactNativeHarmonyGestureHandlerPackage::createArkTSMessageHandlers() { | ||
| 177 | - return {std::make_shared<ScrollLockerArkTSMessageHandler>()}; | ||
| 178 | -} | ||
| @@ -1,44 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -#pragma once | ||
| 25 | -#include "RNOH/Package.h" | ||
| 26 | - | ||
| 27 | -namespace rnoh { | ||
| 28 | -class RnohReactNativeHarmonyGestureHandlerPackage : public Package { | ||
| 29 | -public: | ||
| 30 | - RnohReactNativeHarmonyGestureHandlerPackage(Package::Context ctx) : Package(ctx) {} | ||
| 31 | - | ||
| 32 | - std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override; | ||
| 33 | - | ||
| 34 | - std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override; | ||
| 35 | - | ||
| 36 | - ComponentJSIBinderByString createComponentJSIBinderByName() override; | ||
| 37 | - | ||
| 38 | - EventEmitRequestHandlers createEventEmitRequestHandlers(); | ||
| 39 | - | ||
| 40 | - ComponentInstanceFactoryDelegate::Shared createComponentInstanceFactoryDelegate(); | ||
| 41 | - | ||
| 42 | - std::vector<ArkTSMessageHandler::Shared> createArkTSMessageHandlers() override; | ||
| 43 | -}; | ||
| 44 | -} // namespace rnoh | ||
| @@ -1,44 +0,0 @@ | |||
| 1 | - | ||
| 2 | -/** | ||
| 3 | - * This code was generated by "react-native codegen-harmony" | ||
| 4 | - * | ||
| 5 | - * Do not edit this file as changes may cause incorrect behavior and will be | ||
| 6 | - * lost once the code is regenerated. | ||
| 7 | - * | ||
| 8 | - * @generatorVersion: 1 | ||
| 9 | - */ | ||
| 10 | - | ||
| 11 | -#pragma once | ||
| 12 | - | ||
| 13 | -#include <react/renderer/core/ConcreteComponentDescriptor.h> | ||
| 14 | -#include <react/renderer/components/view/ConcreteViewShadowNode.h> | ||
| 15 | -#include <react/renderer/components/view/ViewShadowNode.h> | ||
| 16 | - | ||
| 17 | -namespace facebook { | ||
| 18 | -namespace react { | ||
| 19 | - | ||
| 20 | -// RNOH patch | ||
| 21 | -constexpr char RNGestureHandlerButtonComponentName[] = "RNGestureHandlerButton"; | ||
| 22 | - | ||
| 23 | -class RNGestureHandlerButtonProps : public ViewProps { | ||
| 24 | - public: | ||
| 25 | - RNGestureHandlerButtonProps() = default; | ||
| 26 | - | ||
| 27 | - RNGestureHandlerButtonProps(const PropsParserContext &context, const RNGestureHandlerButtonProps &sourceProps, const RawProps &rawProps) | ||
| 28 | - : ViewProps(context, sourceProps, rawProps) {} | ||
| 29 | -}; | ||
| 30 | - | ||
| 31 | -using RNGestureHandlerButtonShadowNode = ConcreteViewShadowNode< | ||
| 32 | - RNGestureHandlerButtonComponentName, | ||
| 33 | - RNGestureHandlerButtonProps, | ||
| 34 | - ViewEventEmitter>; | ||
| 35 | - | ||
| 36 | -class RNGestureHandlerButtonComponentDescriptor final | ||
| 37 | - : public ConcreteComponentDescriptor<RNGestureHandlerButtonShadowNode> { | ||
| 38 | - public: | ||
| 39 | - RNGestureHandlerButtonComponentDescriptor(ComponentDescriptorParameters const ¶meters) | ||
| 40 | - : ConcreteComponentDescriptor(parameters) {} | ||
| 41 | -}; | ||
| 42 | - | ||
| 43 | -} // namespace react | ||
| 44 | -} // namespace facebook | ||
| @@ -1,41 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * This code was generated by "react-native codegen-harmony" | ||
| 3 | - * | ||
| 4 | - * Do not edit this file as changes may cause incorrect behavior and will be | ||
| 5 | - * lost once the code is regenerated. | ||
| 6 | - * | ||
| 7 | - * @generatorVersion: 1 | ||
| 8 | - */ | ||
| 9 | - | ||
| 10 | -#pragma once | ||
| 11 | -#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h" | ||
| 12 | - | ||
| 13 | -namespace rnoh { | ||
| 14 | -class RNGestureHandlerButtonJSIBinder : public ViewComponentJSIBinder { | ||
| 15 | - protected: | ||
| 16 | - facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override { | ||
| 17 | - auto object = ViewComponentJSIBinder::createNativeProps(rt); | ||
| 18 | - object.setProperty(rt, "exclusive", true); | ||
| 19 | - object.setProperty(rt, "foreground", true); | ||
| 20 | - object.setProperty(rt, "borderless", true); | ||
| 21 | - object.setProperty(rt, "enabled", true); | ||
| 22 | - object.setProperty(rt, "rippleColor", true); | ||
| 23 | - object.setProperty(rt, "rippleRadius", true); | ||
| 24 | - object.setProperty(rt, "touchSoundDisabled", true); | ||
| 25 | - object.setProperty(rt, "borderWidth", true); | ||
| 26 | - object.setProperty(rt, "borderColor", true); | ||
| 27 | - object.setProperty(rt, "borderStyle", true); | ||
| 28 | - return object; | ||
| 29 | - } | ||
| 30 | - | ||
| 31 | - facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override { | ||
| 32 | - facebook::jsi::Object events(rt); | ||
| 33 | - return events; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override { | ||
| 37 | - facebook::jsi::Object events(rt); | ||
| 38 | - return events; | ||
| 39 | - } | ||
| 40 | -}; | ||
| 41 | -} // namespace rnoh | ||
| @@ -1,28 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * This code was generated by "react-native codegen-harmony" | ||
| 3 | - * | ||
| 4 | - * Do not edit this file as changes may cause incorrect behavior and will be | ||
| 5 | - * lost once the code is regenerated. | ||
| 6 | - * | ||
| 7 | - * @generatorVersion: 1 | ||
| 8 | - */ | ||
| 9 | - | ||
| 10 | -#include "RNGestureHandlerModule.h" | ||
| 11 | - | ||
| 12 | -namespace rnoh { | ||
| 13 | -using namespace facebook; | ||
| 14 | - | ||
| 15 | -RNGestureHandlerModule::RNGestureHandlerModule(const ArkTSTurboModule::Context ctx, const std::string name) : ArkTSTurboModule(ctx, name) { | ||
| 16 | - methodMap_ = { | ||
| 17 | - ARK_METHOD_METADATA(handleSetJSResponder, 2), | ||
| 18 | - ARK_METHOD_METADATA(handleClearJSResponder, 0), | ||
| 19 | - ARK_METHOD_METADATA(createGestureHandler, 3), | ||
| 20 | - ARK_METHOD_METADATA(attachGestureHandler, 3), | ||
| 21 | - ARK_METHOD_METADATA(updateGestureHandler, 2), | ||
| 22 | - ARK_METHOD_METADATA(dropGestureHandler, 1), | ||
| 23 | - ARK_METHOD_METADATA(install, 0), | ||
| 24 | - ARK_METHOD_METADATA(flushOperations, 0), | ||
| 25 | - }; | ||
| 26 | -} | ||
| 27 | - | ||
| 28 | -} // namespace rnoh | ||
| @@ -1,21 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * This code was generated by "react-native codegen-harmony" | ||
| 3 | - * | ||
| 4 | - * Do not edit this file as changes may cause incorrect behavior and will be | ||
| 5 | - * lost once the code is regenerated. | ||
| 6 | - * | ||
| 7 | - * @generatorVersion: 1 | ||
| 8 | - */ | ||
| 9 | - | ||
| 10 | -#pragma once | ||
| 11 | - | ||
| 12 | -#include "RNOH/ArkTSTurboModule.h" | ||
| 13 | - | ||
| 14 | -namespace rnoh { | ||
| 15 | - | ||
| 16 | -class JSI_EXPORT RNGestureHandlerModule : public ArkTSTurboModule { | ||
| 17 | - public: | ||
| 18 | - RNGestureHandlerModule(const ArkTSTurboModule::Context ctx, const std::string name); | ||
| 19 | -}; | ||
| 20 | - | ||
| 21 | -} // namespace rnoh | ||
| @@ -1,44 +0,0 @@ | |||
| 1 | - | ||
| 2 | -/** | ||
| 3 | - * This code was generated by "react-native codegen-harmony" | ||
| 4 | - * | ||
| 5 | - * Do not edit this file as changes may cause incorrect behavior and will be | ||
| 6 | - * lost once the code is regenerated. | ||
| 7 | - * | ||
| 8 | - * @generatorVersion: 1 | ||
| 9 | - */ | ||
| 10 | - | ||
| 11 | -#pragma once | ||
| 12 | - | ||
| 13 | -#include <react/renderer/core/ConcreteComponentDescriptor.h> | ||
| 14 | -#include <react/renderer/components/view/ConcreteViewShadowNode.h> | ||
| 15 | -#include <react/renderer/components/view/ViewShadowNode.h> | ||
| 16 | - | ||
| 17 | -namespace facebook { | ||
| 18 | -namespace react { | ||
| 19 | - | ||
| 20 | -// RNOH patch | ||
| 21 | -constexpr char RNGestureHandlerRootViewComponentName[] = "RNGestureHandlerRootView"; | ||
| 22 | - | ||
| 23 | -class RNGestureHandlerRootViewProps : public ViewProps { | ||
| 24 | - public: | ||
| 25 | - RNGestureHandlerRootViewProps() = default; | ||
| 26 | - | ||
| 27 | - RNGestureHandlerRootViewProps(const PropsParserContext &context, const RNGestureHandlerRootViewProps &sourceProps, const RawProps &rawProps) | ||
| 28 | - : ViewProps(context, sourceProps, rawProps) {} | ||
| 29 | -}; | ||
| 30 | - | ||
| 31 | -using RNGestureHandlerRootViewShadowNode = ConcreteViewShadowNode< | ||
| 32 | - RNGestureHandlerRootViewComponentName, | ||
| 33 | - RNGestureHandlerRootViewProps, | ||
| 34 | - ViewEventEmitter>; | ||
| 35 | - | ||
| 36 | -class RNGestureHandlerRootViewComponentDescriptor final | ||
| 37 | - : public ConcreteComponentDescriptor<RNGestureHandlerRootViewShadowNode> { | ||
| 38 | - public: | ||
| 39 | - RNGestureHandlerRootViewComponentDescriptor(ComponentDescriptorParameters const ¶meters) | ||
| 40 | - : ConcreteComponentDescriptor(parameters) {} | ||
| 41 | -}; | ||
| 42 | - | ||
| 43 | -} // namespace react | ||
| 44 | -} // namespace facebook | ||
| @@ -1,31 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * This code was generated by "react-native codegen-harmony" | ||
| 3 | - * | ||
| 4 | - * Do not edit this file as changes may cause incorrect behavior and will be | ||
| 5 | - * lost once the code is regenerated. | ||
| 6 | - * | ||
| 7 | - * @generatorVersion: 1 | ||
| 8 | - */ | ||
| 9 | - | ||
| 10 | -#pragma once | ||
| 11 | -#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h" | ||
| 12 | - | ||
| 13 | -namespace rnoh { | ||
| 14 | -class RNGestureHandlerRootViewJSIBinder : public ViewComponentJSIBinder { | ||
| 15 | - protected: | ||
| 16 | - facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override { | ||
| 17 | - auto object = ViewComponentJSIBinder::createNativeProps(rt); | ||
| 18 | - return object; | ||
| 19 | - } | ||
| 20 | - | ||
| 21 | - facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override { | ||
| 22 | - facebook::jsi::Object events(rt); | ||
| 23 | - return events; | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override { | ||
| 27 | - facebook::jsi::Object events(rt); | ||
| 28 | - return events; | ||
| 29 | - } | ||
| 30 | -}; | ||
| 31 | -} // namespace rnoh | ||
| @@ -1,87 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * This code was generated by "react-native codegen-harmony" | ||
| 3 | - * | ||
| 4 | - * Do not edit this file as changes may cause incorrect behavior and will be | ||
| 5 | - * lost once the code is regenerated. | ||
| 6 | - * | ||
| 7 | - * @generatorVersion: 1 | ||
| 8 | - */ | ||
| 9 | - | ||
| 10 | -#pragma once | ||
| 11 | - | ||
| 12 | -#include "RNOH/Package.h" | ||
| 13 | -#include "RNOH/ArkTSTurboModule.h" | ||
| 14 | -#include "generated/RNGestureHandlerModule.h" | ||
| 15 | -#include "generated/RNGestureHandlerButtonComponentDescriptor.h" | ||
| 16 | -#include "generated/RNGestureHandlerRootViewComponentDescriptor.h" | ||
| 17 | -#include "generated/RNGestureHandlerButtonJSIBinder.h" | ||
| 18 | -#include "generated/RNGestureHandlerRootViewJSIBinder.h" | ||
| 19 | - | ||
| 20 | -namespace rnoh { | ||
| 21 | - | ||
| 22 | -class RNOHGeneratedPackageTurboModuleFactoryDelegate : public TurboModuleFactoryDelegate { | ||
| 23 | - public: | ||
| 24 | - SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override { | ||
| 25 | - | ||
| 26 | - if (name == "RNGestureHandlerModule") { | ||
| 27 | - return std::make_shared<RNGestureHandlerModule>(ctx, name); | ||
| 28 | - } | ||
| 29 | - return nullptr; | ||
| 30 | - }; | ||
| 31 | -}; | ||
| 32 | - | ||
| 33 | -class GeneratedEventEmitRequestHandler : public EventEmitRequestHandler { | ||
| 34 | - public: | ||
| 35 | - void handleEvent(Context const &ctx) override { | ||
| 36 | - auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag); | ||
| 37 | - auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag); | ||
| 38 | - | ||
| 39 | - if (eventEmitter == nullptr) { | ||
| 40 | - return; | ||
| 41 | - } | ||
| 42 | - | ||
| 43 | - std::vector<std::string> supportedComponentNames = { | ||
| 44 | - "RNGestureHandlerButton", | ||
| 45 | - "RNGestureHandlerRootView", | ||
| 46 | - }; | ||
| 47 | - | ||
| 48 | - std::vector<std::string> supportedEventNames = { | ||
| 49 | - }; | ||
| 50 | - | ||
| 51 | - if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() && | ||
| 52 | - std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) { | ||
| 53 | - eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload)); | ||
| 54 | - } | ||
| 55 | - } | ||
| 56 | -}; | ||
| 57 | - | ||
| 58 | -class RNOHGeneratedPackage : public Package { | ||
| 59 | - public: | ||
| 60 | - RNOHGeneratedPackage(Package::Context ctx) : Package(ctx){}; | ||
| 61 | - | ||
| 62 | - std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override { | ||
| 63 | - return std::make_unique<RNOHGeneratedPackageTurboModuleFactoryDelegate>(); | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override { | ||
| 67 | - return { | ||
| 68 | - facebook::react::concreteComponentDescriptorProvider<facebook::react::RNGestureHandlerButtonComponentDescriptor>(), | ||
| 69 | - facebook::react::concreteComponentDescriptorProvider<facebook::react::RNGestureHandlerRootViewComponentDescriptor>(), | ||
| 70 | - }; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - ComponentJSIBinderByString createComponentJSIBinderByName() override { | ||
| 74 | - return { | ||
| 75 | - {"RNGestureHandlerButton", std::make_shared<RNGestureHandlerButtonJSIBinder>()}, | ||
| 76 | - {"RNGestureHandlerRootView", std::make_shared<RNGestureHandlerRootViewJSIBinder>()}, | ||
| 77 | - }; | ||
| 78 | - }; | ||
| 79 | - | ||
| 80 | - EventEmitRequestHandlers createEventEmitRequestHandlers() override { | ||
| 81 | - return { | ||
| 82 | - std::make_shared<GeneratedEventEmitRequestHandler>(), | ||
| 83 | - }; | ||
| 84 | - } | ||
| 85 | -}; | ||
| 86 | - | ||
| 87 | -} // namespace rnoh | ||
| @@ -1,40 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -import { RNPackage, RNPackageContext } from "@rnoh/react-native-openharmony"; | ||
| 25 | -import type { TurboModule, TurboModuleContext } from "@rnoh/react-native-openharmony/ts"; | ||
| 26 | -import { RNGestureHandlerModule } from './rnoh/RNGestureHandlerModule'; | ||
| 27 | - | ||
| 28 | -export default class RnohReactNativeHarmonyGestureHandlerPackage extends RNPackage { | ||
| 29 | - private isRNGHDevModeEnabled: boolean | ||
| 30 | - | ||
| 31 | - constructor(ctx: RNPackageContext, isRNGHDevModeEnabled: boolean = false) { | ||
| 32 | - super(ctx) | ||
| 33 | - this.isRNGHDevModeEnabled = isRNGHDevModeEnabled | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - getUITurboModuleFactoryByNameMap(): Map<string, (ctx: TurboModuleContext) => TurboModule | null> { | ||
| 37 | - return new Map().set(RNGestureHandlerModule.NAME, | ||
| 38 | - (ctx: TurboModuleContext) => new RNGestureHandlerModule(ctx, this.isRNGHDevModeEnabled)) | ||
| 39 | - } | ||
| 40 | -} | ||
| @@ -1,65 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -export class CircularBuffer<T> { | ||
| 25 | - private bufferSize: number; | ||
| 26 | - private buffer: T[]; | ||
| 27 | - private index: number; | ||
| 28 | - private actualSize: number; | ||
| 29 | - | ||
| 30 | - constructor(size: number) { | ||
| 31 | - this.bufferSize = size; | ||
| 32 | - this.buffer = new Array<T>(size); | ||
| 33 | - this.index = 0; | ||
| 34 | - this.actualSize = 0; | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | - public get size(): number { | ||
| 38 | - return this.actualSize; | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - public push(element: T): void { | ||
| 42 | - this.buffer[this.index] = element; | ||
| 43 | - this.index = (this.index + 1) % this.bufferSize; | ||
| 44 | - this.actualSize = Math.min(this.actualSize + 1, this.bufferSize); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - public get(at: number): T { | ||
| 48 | - if (this.actualSize === this.bufferSize) { | ||
| 49 | - let index = (this.index + at) % this.bufferSize; | ||
| 50 | - if (index < 0) { | ||
| 51 | - index += this.bufferSize; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - return this.buffer[index]; | ||
| 55 | - } else { | ||
| 56 | - return this.buffer[at]; | ||
| 57 | - } | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - public clear(): void { | ||
| 61 | - this.buffer = new Array<T>(this.bufferSize); | ||
| 62 | - this.index = 0; | ||
| 63 | - this.actualSize = 0; | ||
| 64 | - } | ||
| 65 | -} | ||
| @@ -1,473 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * MIT License | ||
| 3 | - * | ||
| 4 | - * Copyright (C) 2025 Huawei Device Co., Ltd. | ||
| 5 | - * | ||
| 6 | - * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | - * of this software and associated documentation files (the "Software"), to deal | ||
| 8 | - * in the Software without restriction, including without limitation the rights | ||
| 9 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | - * copies of the Software, and to permit persons to whom the Software is | ||
| 11 | - * furnished to do so, subject to the following conditions: | ||
| 12 | - * | ||
| 13 | - * The above copyright notice and this permission notice shall be included in all | ||
| 14 | - * copies or substantial portions of the Software. | ||
| 15 | - * | ||
| 16 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | - * SOFTWARE. | ||
| 23 | - */ | ||
| 24 | -import {GestureHandler} from './GestureHandler'; | ||
| 25 | -import {getStateName, State} from './State'; | ||
| 26 | -import {PointerType} from './IncomingEvent'; | ||
| 27 | -import {RNGHLogger} from './RNGHLogger'; | ||
| 28 | -import {PointerTracker} from './PointerTracker'; | ||
| 29 | - | ||
| 30 | -export class GestureHandlerOrchestrator { | ||
| 31 | - private gestureHandlers: GestureHandler[] = []; | ||
| 32 | - private awaitingHandlers: GestureHandler[] = []; | ||
| 33 | - private awaitingHandlersTags: Set<number> = new Set(); | ||
| 34 | - | ||
| 35 | - private handlingChangeSemaphore = 0; | ||
| 36 | - private activationIndex = 0; | ||
| 37 | - | ||
| 38 | - private logger: RNGHLogger; | ||
| 39 | - | ||
| 40 | - constructor(logger: RNGHLogger) { | ||
| 41 | - this.logger = logger.cloneAndJoinPrefix('GestureHandlerOrchestrator'); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - public onHandlerStateChange( | ||
| 45 | - handler: GestureHandler, | ||
| 46 | - newState: State, | ||
| 47 | - oldState: State, | ||
| 48 | - sendIfDisabled?: boolean, | ||
| 49 | - ): void { | ||
| 50 | - const logger = this.logger.cloneAndJoinPrefix( | ||
| 51 | - `onHandlerStateChange(handler=${handler.getTag()}, newState=${getStateName( | ||
| 52 | - newState, | ||
| 53 | - )}, oldState=${getStateName(oldState)})`, | ||
| 54 | - ); | ||
| 55 | - logger.debug('start'); | ||
| 56 | - | ||
| 57 | - if (!handler.isEnabled() && !sendIfDisabled) { | ||
| 58 | - return; | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - this.handlingChangeSemaphore += 1; | ||
| 62 | - | ||
| 63 | - if (this.isFinished(newState)) { | ||
| 64 | - for (const otherHandler of this.awaitingHandlers) { | ||
| 65 | - if ( | ||
| 66 | - !this.shouldHandlerWaitForOther(otherHandler, handler) || | ||
| 67 | - !this.awaitingHandlersTags.has(otherHandler.getTag()) | ||
| 68 | - ) { | ||
| 69 | - continue; | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - if (newState !== State.END) { | ||
| 73 | - this.tryActivate(otherHandler); | ||
| 74 | - continue; | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - otherHandler.cancel(); | ||
| 78 | - | ||
| 79 | - if (otherHandler.getState() === State.END) { | ||
| 80 | - // Handle edge case, where discrete gestures end immediately after activation thus | ||
| 81 | - // their state is set to END and when the gesture they are waiting for activates they | ||
| 82 | - // should be cancelled, however `cancel` was never sent as gestures were already in the END state. | ||
| 83 | - // Send synthetic BEGAN -> CANCELLED to properly handle JS logic | ||
| 84 | - otherHandler.sendEvent({ | ||
| 85 | - newState: State.CANCELLED, | ||
| 86 | - oldState: State.BEGAN, | ||
| 87 | - }); | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - otherHandler.setAwaiting(false); | ||
| 91 | - } | ||
| 92 | - } | ||
| 93 | - | ||
| 94 | - if (newState === State.ACTIVE) { | ||
| 95 | - this.tryActivate(handler); | ||
| 96 | - } else if (oldState === State.ACTIVE || oldState === State.END) { | ||
| 97 | - if (handler.isActive()) { | ||
| 98 | - handler.sendEvent({newState, oldState}); | ||
| 99 | - } else if ( | ||
| 100 | - oldState === State.ACTIVE && | ||
| 101 | - (newState === State.CANCELLED || newState === State.FAILED) | ||
| 102 | - ) { | ||
| 103 | - handler.sendEvent({newState, oldState: State.BEGAN}); | ||
| 104 | - } | ||
| 105 | - } else if ( | ||
| 106 | - oldState !== State.UNDETERMINED || | ||
| 107 | - newState !== State.CANCELLED | ||
| 108 | - ) { | ||
| 109 | - handler.sendEvent({newState, oldState}); | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - this.handlingChangeSemaphore -= 1; | ||
| 113 | - | ||
| 114 | - this.scheduleFinishedHandlersCleanup(); | ||
| 115 | - | ||
| 116 | - if (!this.awaitingHandlers.includes(handler)) { | ||
| 117 | - this.cleanupAwaitingHandlers(handler); | ||
| 118 | - } | ||
| 119 | - } | ||
| 120 | - | ||
| 121 | - private isFinished(state: State): boolean { | ||
| 122 | - return ( | ||
| 123 | - state === State.END || state === State.FAILED || state === State.CANCELLED | ||
| 124 | - ); | ||
| 125 | - } | ||
| 126 | - | ||
| 127 | - private tryActivate(handler: GestureHandler): void { | ||
| 128 | - const logger = this.logger.cloneAndJoinPrefix( | ||
| 129 | - `tryActivate(${handler.getTag()})`, | ||
| 130 | - ); | ||
| 131 | - logger.debug({ | ||
| 132 | - gestureHandlers: this.gestureHandlers.map(gh => gh.getTag()), | ||
| 133 | - awaitingHandlers: Array.from(this.awaitingHandlers).map(gh => | ||
| 134 | - gh.getTag(), | ||
| 135 | - ), | ||
| 136 | - }); | ||
| 137 | - | ||
| 138 | - if (this.shouldBeCancelledByFinishedHandler(handler)) { | ||
| 139 | - logger.debug('failed to activate - cancelling'); | ||
| 140 | - handler.cancel(); | ||
| 141 | - return; | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | - if (this.hasOtherHandlerToWaitFor(handler)) { | ||
| 145 | - this.addAwaitingHandler(handler); | ||
| 146 | - logger.debug('request ignored - has other handler waiting'); | ||
| 147 | - return; | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - const handlerState = handler.getState(); | ||
| 151 | - | ||
| 152 | - if (handlerState === State.CANCELLED || handlerState === State.FAILED) { | ||
| 153 | - logger.debug('request ignored - handler is in cancelled or failed state'); | ||
| 154 | - return; | ||
| 155 | - } | ||
| 156 | - | ||
| 157 | - if (this.shouldActivate(handler)) { | ||
| 158 | - logger.debug('activating'); | ||
| 159 | - this.makeActive(handler); | ||
| 160 | - return; | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - if (handlerState === State.ACTIVE) { | ||
| 164 | - logger.debug( | ||
| 165 | - 'failed to activate - handler is already active, marking as fail', | ||
| 166 | - ); | ||
| 167 | - handler.fail(); | ||
| 168 | - return; | ||
| 169 | - } | ||
| 170 | - | ||
| 171 | - if (handlerState === State.BEGAN) { | ||
| 172 | - logger.debug( | ||
| 173 | - 'handler is in BEGAN state but shouldActivate returned false - cancelling', | ||
| 174 | - ); | ||
| 175 | - handler.cancel(); | ||
| 176 | - } | ||
| 177 | - } | ||
| 178 | - | ||
| 179 | - private shouldBeCancelledByFinishedHandler(handler: GestureHandler): boolean { | ||
| 180 | - const shouldBeCancelled = (otherHandler: GestureHandler) => { | ||
| 181 | - return ( | ||
| 182 | - this.shouldHandlerWaitForOther(handler, otherHandler) && | ||
| 183 | - otherHandler.getState() === State.END | ||
| 184 | - ); | ||
| 185 | - }; | ||
| 186 | - | ||
| 187 | - return this.gestureHandlers.some(shouldBeCancelled); | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - private hasOtherHandlerToWaitFor(handler: GestureHandler): boolean { | ||
| 191 | - const logger = this.logger.cloneAndJoinPrefix( | ||
| 192 | - `hasOtherHandlerToWaitFor(handler=${handler.getTag()})`, | ||
| 193 | - ); | ||
| 194 | - const hasToWaitFor = (otherHandler: GestureHandler) => { | ||
| 195 | - return ( | ||
| 196 | - !this.isFinished(otherHandler.getState()) && | ||
| 197 | - this.shouldHandlerWaitForOther(handler, otherHandler) | ||
| 198 | - ); | ||
| 199 | - }; | ||
| 200 | - const result = this.gestureHandlers.some(hasToWaitFor); | ||
| 201 | - logger.debug({ | ||
| 202 | - gestureHandlers: this.gestureHandlers.map(gh => gh.getTag()), | ||
| 203 | - awaitingHandlers: Array.from(this.awaitingHandlers).map(gh => | ||
| 204 | - gh.getTag(), | ||
| 205 | - ), | ||
| 206 | - result, | ||
| 207 | - }); | ||
| 208 | - return result; | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - private addAwaitingHandler(handler: GestureHandler): void { | ||
| 212 | - const logger = this.logger.cloneAndJoinPrefix( | ||
| 213 | - `addAwaitingHandler(handlerTag=${handler.getTag()})`, | ||
| 214 | - ); | ||
| 215 | - logger.debug({awaitingHandlers: this.awaitingHandlers}); | ||
| 216 | - if (this.awaitingHandlers.includes(handler)) { | ||
| 217 | - return; | ||
| 218 | - } | ||
| 219 | - | ||
| 220 | - this.awaitingHandlers.push(handler); | ||
| 221 | - this.awaitingHandlersTags.add(handler.getTag()); | ||
| 222 | - | ||
| 223 | - handler.setAwaiting(true); | ||
| 224 | - handler.setActivationIndex(this.activationIndex++); | ||
| 225 | - } | ||
| 226 | - | ||
| 227 | - private shouldActivate(handler: GestureHandler): boolean { | ||
| 228 | - const shouldBeCancelledBy = (otherHandler: GestureHandler) => { | ||
| 229 | - return this.shouldHandlerBeCancelledBy(handler, otherHandler); | ||
| 230 | - }; | ||
| 231 | - | ||
| 232 | - return !this.gestureHandlers.some(shouldBeCancelledBy); | ||
| 233 | - } | ||
| 234 | - | ||
| 235 | - private shouldHandlerBeCancelledBy( | ||
| 236 | - handler: GestureHandler, | ||
| 237 | - otherHandler: GestureHandler, | ||
| 238 | - ): boolean { | ||
| 239 | - if (this.canRunSimultaneously(handler, otherHandler)) { | ||
| 240 | - return false; | ||
| 241 | - } | ||
| 242 | - | ||
| 243 | - if (handler.isAwaiting() || handler.getState() === State.ACTIVE) { | ||
| 244 | - return handler.shouldBeCancelledByOther(otherHandler); | ||
| 245 | - } | ||
| 246 | - | ||
| 247 | - const handlerPointers: number[] = handler.getTrackedPointersID(); | ||
| 248 | - const otherPointers: number[] = otherHandler.getTrackedPointersID(); | ||
| 249 | - | ||
| 250 | - if ( | ||
| 251 | - !PointerTracker.shareCommonPointers(handlerPointers, otherPointers) && | ||
| 252 | - handler.getView() !== otherHandler.getView() | ||
| 253 | - ) { | ||
| 254 | - return this.checkOverlap(handler, otherHandler); | ||
| 255 | - } | ||
| 256 | - | ||
| 257 | - return true; | ||
| 258 | - } | ||
| 259 | - | ||
| 260 | - private canRunSimultaneously( | ||
| 261 | - gh1: GestureHandler, | ||
| 262 | - gh2: GestureHandler, | ||
| 263 | - ): boolean { | ||
| 264 | - return ( | ||
| 265 | - gh1 === gh2 || | ||
| 266 | - gh1.shouldRecognizeSimultaneously(gh2) || | ||
| 267 | - gh2.shouldRecognizeSimultaneously(gh1) | ||
| 268 | - ); | ||
| 269 | - } | ||
| 270 | - | ||
| 271 | - private checkOverlap( | ||
| 272 | - handler: GestureHandler, | ||
| 273 | - otherHandler: GestureHandler, | ||
| 274 | - ): boolean { | ||
| 275 | - // If handlers don't have common pointers, default return value is false. | ||
| 276 | - // However, if at least on pointer overlaps with both handlers, we return true | ||
| 277 | - // This solves issue in overlapping parents example | ||
| 278 | - | ||
| 279 | - // TODO: Find better way to handle that issue, for example by activation order and handler cancelling | ||
| 280 | - | ||
| 281 | - const handlerPointers: number[] = handler.getTrackedPointersID(); | ||
| 282 | - const otherPointers: number[] = otherHandler.getTrackedPointersID(); | ||
| 283 | - let overlap = false; | ||
| 284 | - handlerPointers.forEach((pointer: number) => { | ||
| 285 | - const handlerX: number = handler.getTracker().getLastX(pointer); | ||
| 286 | - const handlerY: number = handler.getTracker().getLastY(pointer); | ||
| 287 | - if ( | ||
| 288 | - handler.getView()?.isPositionInBounds({x: handlerX, y: handlerY}) && | ||
| 289 | - otherHandler.getView()?.isPositionInBounds({x: handlerX, y: handlerY}) | ||
| 290 | - ) { | ||
| 291 | - overlap = true; | ||
| 292 | - } | ||
| 293 | - }); | ||
| 294 | - otherPointers.forEach((pointer: number) => { | ||
| 295 | - const otherX: number = otherHandler.getTracker().getLastX(pointer); | ||
| 296 | - const otherY: number = otherHandler.getTracker().getLastY(pointer); | ||
| 297 | - if ( | ||
| 298 | - handler.getView()?.isPositionInBounds({x: otherX, y: otherY}) && | ||
| 299 | - otherHandler.getView()?.isPositionInBounds({x: otherX, y: otherY}) | ||
| 300 | - ) { | ||
| 301 | - overlap = true; | ||
| 302 | - } | ||
| 303 | - }); | ||
| 304 | - return overlap; | ||
| 305 | - } | ||
| 306 | - | ||
| 307 | - private makeActive(handler: GestureHandler): void { | ||
| 308 | - const currentState = handler.getState(); | ||
| 309 | - | ||
| 310 | - handler.setActive(true); | ||
| 311 | - handler.setShouldResetProgress(true); | ||
| 312 | - handler.setActivationIndex(this.activationIndex++); | ||
| 313 | - | ||
| 314 | - for (let i = this.gestureHandlers.length - 1; i >= 0; --i) { | ||
| 315 | - if (this.shouldHandlerBeCancelledBy(this.gestureHandlers[i], handler)) { | ||
| 316 | - this.gestureHandlers[i].cancel(); | ||
| 317 | - } | ||
| 318 | - } | ||
| 319 | - | ||
| 320 | - for (const otherHandler of this.awaitingHandlers) { | ||
| 321 | - if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) { | ||
| 322 | - otherHandler.setAwaiting(false); | ||
| 323 | - } | ||
| 324 | - } | ||
| 325 | - | ||
| 326 | - handler.sendEvent({newState: State.ACTIVE, oldState: State.BEGAN}); | ||
| 327 | - | ||
| 328 | - if (currentState !== State.ACTIVE) { | ||
| 329 | - handler.sendEvent({newState: State.END, oldState: State.ACTIVE}); | ||
| 330 | - if (currentState !== State.END) { | ||
| 331 | - handler.sendEvent({newState: State.UNDETERMINED, oldState: State.END}); | ||
| 332 | - } | ||
| 333 | - } | ||
| 334 | - | ||
| 335 | - if (!handler.isAwaiting()) { | ||
| 336 | - return; | ||
| 337 | - } | ||
| 338 | - | ||
| 339 | - handler.setAwaiting(false); | ||
| 340 | - | ||
| 341 | - this.awaitingHandlers = this.awaitingHandlers.filter( | ||
| 342 | - otherHandler => otherHandler !== handler, | ||
| 343 | - ); | ||
| 344 | - } | ||
| 345 | - | ||
| 346 | - private cleanupFinishedHandlers(): void { | ||
| 347 | - const handlersToRemove = new Set<GestureHandler>(); | ||
| 348 | - | ||
| 349 | - for (let i = this.gestureHandlers.length - 1; i >= 0; --i) { | ||
| 350 | - const handler = this.gestureHandlers[i]; | ||
| 351 | - | ||
| 352 | - if (this.isFinished(handler.getState()) && !handler.isAwaiting()) { | ||
| 353 | - this.cleanHandler(handler); | ||
| 354 | - handlersToRemove.add(handler); | ||
| 355 | - } | ||
| 356 | - } | ||
| 357 | - | ||
| 358 | - this.gestureHandlers = this.gestureHandlers.filter( | ||
| 359 | - handler => !handlersToRemove.has(handler), | ||
| 360 | - ); | ||
| 361 | - } | ||
| 362 | - | ||
| 363 | - private cleanupAwaitingHandlers(handler: GestureHandler): void { | ||
| 364 | - const shouldWait = (otherHandler: GestureHandler) => { | ||
| 365 | - return ( | ||
| 366 | - !otherHandler.isAwaiting() && | ||
| 367 | - this.shouldHandlerWaitForOther(otherHandler, handler) | ||
| 368 | - ); | ||
| 369 | - }; | ||
| 370 | - | ||
| 371 | - for (const otherHandler of this.awaitingHandlers) { | ||
| 372 | - if (shouldWait(otherHandler)) { | ||
| 373 | - this.cleanHandler(otherHandler); | ||
| 374 | - this.awaitingHandlersTags.delete(otherHandler.getTag()); | ||
| 375 | - } | ||
| 376 | - } | ||
| 377 | - | ||
| 378 | - this.awaitingHandlers = this.awaitingHandlers.filter(otherHandler => | ||
| 379 | - this.awaitingHandlersTags.has(otherHandler.getTag()), | ||
| 380 | - ); | ||
| 381 | - } | ||
| 382 | - | ||
| 383 | - private cleanHandler(handler: GestureHandler): void { | ||
| 384 | - handler.reset(); | ||
| 385 | - handler.setActive(false); | ||
| 386 | - handler.setAwaiting(false); | ||
| 387 | - handler.setActivationIndex(Number.MAX_VALUE); | ||
| 388 | - } | ||
| 389 | - | ||
| 390 | - public registerHandlerIfNotPresent(handler: GestureHandler) { | ||
| 391 | - this.logger.info(`registerHandlerIfNotPresent(${handler.getTag()})`); | ||
| 392 | - if (this.gestureHandlers.includes(handler)) { | ||
| 393 | - return; | ||
| 394 | - } | ||
| 395 | - this.gestureHandlers.push(handler); | ||
| 396 | - handler.setActive(false); | ||
| 397 | - handler.setAwaiting(false); | ||
| 398 | - handler.setActivationIndex(Number.MAX_SAFE_INTEGER); | ||
| 399 | - } | ||
| 400 | - | ||
| 401 | - // This function is called when handler receives touchdown event | ||
| 402 | - // If handler is using mouse or pen as a pointer and any handler receives touch event, | ||
| 403 | - // mouse/pen event dissappears - it doesn't send onPointerCancel nor onPointerUp (and others) | ||
| 404 | - // This became a problem because handler was left at active state without any signal to end or fail | ||
| 405 | - // To handle this, when new touch event is received, we loop through active handlers and check which type of | ||
| 406 | - // pointer they're using. If there are any handler with mouse/pen as a pointer, we cancel them | ||
| 407 | - public cancelMouseAndPenGestures(currentHandler: GestureHandler): void { | ||
| 408 | - this.gestureHandlers.forEach((handler: GestureHandler) => { | ||
| 409 | - if ( | ||
| 410 | - handler.getPointerType() !== PointerType.MOUSE && | ||
| 411 | - handler.getPointerType() !== PointerType.PEN | ||
| 412 | - ) { | ||
| 413 | - return; | ||
| 414 | - } | ||
| 415 | - | ||
| 416 | - if (handler !== currentHandler) { | ||
| 417 | - handler.cancel(); | ||
| 418 | - } else { | ||
| 419 | - // Handler that received touch event should have its pointer tracker reset | ||
| 420 | - // This allows handler to smoothly change from mouse/pen to touch | ||
| 421 | - // The drawback is, that when we try to use mouse/pen one more time, it doesn't send onPointerDown at the first time | ||
| 422 | - // so it is required to click two times to get handler to work | ||
| 423 | - // | ||
| 424 | - // However, handler will receive manually created onPointerEnter that is triggered in EventManager in onPointerMove method. | ||
| 425 | - // There may be possibility to use that fact to make handler respond properly to first mouse click | ||
| 426 | - handler.getTracker().resetTracker(); | ||
| 427 | - } | ||
| 428 | - }); | ||
| 429 | - } | ||
| 430 | - | ||
| 431 | - private scheduleFinishedHandlersCleanup(): void { | ||
| 432 | - if (this.handlingChangeSemaphore === 0) { | ||
| 433 | - this.cleanupFinishedHandlers(); | ||
| 434 | - } | ||
| 435 | - } | ||
| 436 | - | ||
| 437 | - public removeHandlerFromOrchestrator(handler: GestureHandler): void { | ||
| 438 | - const indexInGestureHandlers = this.gestureHandlers.indexOf(handler); | ||
| 439 | - const indexInAwaitingHandlers = this.awaitingHandlers.indexOf(handler); | ||
| 440 | - | ||
| 441 | - if (indexInGestureHandlers >= 0) { | ||
| 442 | - this.gestureHandlers.splice(indexInGestureHandlers, 1); | ||
| 443 | - } | ||
| 444 | - | ||
| 445 | - if (indexInAwaitingHandlers >= 0) { | ||
| 446 | - this.awaitingHandlers.splice(indexInAwaitingHandlers, 1); | ||
| 447 | - this.awaitingHandlersTags.delete(handler.getTag()); | ||
| 448 | - } | ||
| 449 | - } | ||
| 450 | - | ||
| 451 | - public recordHandlerIfNotPresent(handler: GestureHandler): void { | ||
| 452 | - if (this.gestureHandlers.includes(handler)) { | ||
| 453 | - return; | ||
| 454 | - } | ||
| 455 | - | ||
| 456 | - this.gestureHandlers.push(handler); | ||
| 457 | - | ||
| 458 | - handler.setActive(false); | ||
| 459 | - handler.setAwaiting(false); | ||
| 460 | - handler.setActivationIndex(Number.MAX_SAFE_INTEGER); | ||
| 461 | - } | ||
| 462 | - | ||
| 463 | - private shouldHandlerWaitForOther( | ||
| 464 | - handler: GestureHandler, | ||
| 465 | - otherHandler: GestureHandler, | ||
| 466 | - ): boolean { | ||
| 467 | - return ( | ||
| 468 | - handler !== otherHandler && | ||
| 469 | - (handler.shouldWaitForHandlerFailure(otherHandler) || | ||
| 470 | - otherHandler.shouldRequireToWaitForFailure(handler)) | ||
| 471 | - ); | ||
| 472 | - } | ||
| 473 | -} | ||
Rimg/react-native-gesture-handler.png→react-native-gesture-handler/img/react-native-gesture-handler.png+0-0
Rsrc/components/GestureHandlerRootView.tsx→react-native-gesture-handler/src/components/GestureHandlerRootView.tsx+0-0
Rsrc/handlers/customDirectEventTypes.ts→react-native-gesture-handler/src/handlers/customDirectEventTypes.ts+0-0
Rsrc/specs/NativeRNGestureHandlerModule.ts→react-native-gesture-handler/src/specs/NativeRNGestureHandlerModule.ts+0-0
Rsrc/specs/RNGestureHandlerButtonNativeComponent.ts→react-native-gesture-handler/src/specs/RNGestureHandlerButtonNativeComponent.ts+0-0
Rsrc/specs/RNGestureHandlerRootViewNativeComponent.ts→react-native-gesture-handler/src/specs/RNGestureHandlerRootViewNativeComponent.ts+0-0
Rexample/harmony/AppScope/resources/base/element/string.json→tester/harmony/AppScope/resources/base/element/string.json+0-0
Rexample/harmony/AppScope/resources/base/media/app_icon.png→tester/harmony/AppScope/resources/base/media/app_icon.png+0-0
Rexample/harmony/entry/src/main/cpp/CMakeLists.txt→tester/harmony/entry/src/main/cpp/CMakeLists.txt+2-2
Rexample/harmony/entry/src/main/cpp/PackageProvider.cpp→tester/harmony/entry/src/main/cpp/PackageProvider.cpp+0-0
Rexample/harmony/entry/src/main/ets/RNPackagesFactory.ets→tester/harmony/entry/src/main/ets/RNPackagesFactory.ets+2-2
Rexample/harmony/entry/src/main/ets/entryability/EntryAbility.ets→tester/harmony/entry/src/main/ets/entryability/EntryAbility.ets+0-0
Rexample/harmony/entry/src/main/ets/pages/Index.ets→tester/harmony/entry/src/main/ets/pages/Index.ets+0-0
Rexample/harmony/entry/src/main/resources/base/element/color.json→tester/harmony/entry/src/main/resources/base/element/color.json+0-0
Rexample/harmony/entry/src/main/resources/base/element/string.json→tester/harmony/entry/src/main/resources/base/element/string.json+0-0
Rexample/harmony/entry/src/main/resources/base/media/icon.png→tester/harmony/entry/src/main/resources/base/media/icon.png+0-0
Rexample/harmony/entry/src/main/resources/base/profile/main_pages.json→tester/harmony/entry/src/main/resources/base/profile/main_pages.json+0-0
Rexample/harmony/entry/src/main/resources/en_US/element/string.json→tester/harmony/entry/src/main/resources/en_US/element/string.json+0-0
Rexample/harmony/entry/src/main/resources/zh_CN/element/string.json→tester/harmony/entry/src/main/resources/zh_CN/element/string.json+0-0
Rexample/harmony/gesture_handler/BuildProfile.ets→tester/harmony/gesture_handler/BuildProfile.ets+0-0
Rexample/harmony/gesture_handler/build-profile.json5→tester/harmony/gesture_handler/build-profile.json5+0-0
Rexample/harmony/gesture_handler/src/main/cpp/CMakeLists.txt→tester/harmony/gesture_handler/src/main/cpp/CMakeLists.txt+0-0
Rexample/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h→tester/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h+0-0
Rexample/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.cpp→tester/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.cpp+0-0
Rexample/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.h→tester/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.h+0-0
Rharmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.cpp→tester/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.cpp+0-0
Rharmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.h→tester/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.h+0-0
Rharmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.cpp→tester/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.cpp+0-0
Rharmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.h→tester/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.h+0-0
Rexample/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerButtonComponentDescriptor.h→tester/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerButtonComponentDescriptor.h+0-0
Rexample/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerButtonJSIBinder.h→tester/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerButtonJSIBinder.h+0-0
Rexample/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerModule.cpp→tester/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerModule.cpp+0-0
Rexample/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerModule.h→tester/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerModule.h+0-0
Rexample/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerRootViewComponentDescriptor.h→tester/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerRootViewComponentDescriptor.h+0-0
Rexample/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerRootViewJSIBinder.h→tester/harmony/gesture_handler/src/main/cpp/generated/RNGestureHandlerRootViewJSIBinder.h+0-0
Rexample/harmony/gesture_handler/src/main/cpp/generated/RNOHGeneratedPackage.h→tester/harmony/gesture_handler/src/main/cpp/generated/RNOHGeneratedPackage.h+0-0
Rexample/harmony/gesture_handler/src/main/ets/RNOHPackage.ets→tester/harmony/gesture_handler/src/main/ets/RNOHPackage.ets+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/CircularBuffer.ts→tester/harmony/gesture_handler/src/main/ets/core/CircularBuffer.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/GestureHandler.ts→tester/harmony/gesture_handler/src/main/ets/core/GestureHandler.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/GestureHandlerOrchestrator.ts→tester/harmony/gesture_handler/src/main/ets/core/GestureHandlerOrchestrator.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/GestureHandlerRegistry.ts→tester/harmony/gesture_handler/src/main/ets/core/GestureHandlerRegistry.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/IncomingEvent.ts→tester/harmony/gesture_handler/src/main/ets/core/IncomingEvent.ts+0-0
Rharmony/gesture_handler/src/main/ets/core/InteractionManager.ts→tester/harmony/gesture_handler/src/main/ets/core/InteractionManager.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/LeastSquareSolver.ts→tester/harmony/gesture_handler/src/main/ets/core/LeastSquareSolver.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/Multiset.ts→tester/harmony/gesture_handler/src/main/ets/core/Multiset.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/OutgoingEvent.ts→tester/harmony/gesture_handler/src/main/ets/core/OutgoingEvent.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/OutgoingEventDispatcher.ts→tester/harmony/gesture_handler/src/main/ets/core/OutgoingEventDispatcher.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/PointerTracker.ts→tester/harmony/gesture_handler/src/main/ets/core/PointerTracker.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/RNGHError.ts→tester/harmony/gesture_handler/src/main/ets/core/RNGHError.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/RNGHLogger.ts→tester/harmony/gesture_handler/src/main/ets/core/RNGHLogger.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/State.ts→tester/harmony/gesture_handler/src/main/ets/core/State.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/Vector2D.ts→tester/harmony/gesture_handler/src/main/ets/core/Vector2D.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/VelocityTracker.ts→tester/harmony/gesture_handler/src/main/ets/core/VelocityTracker.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/View.ts→tester/harmony/gesture_handler/src/main/ets/core/View.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/ViewRegistry.ts→tester/harmony/gesture_handler/src/main/ets/core/ViewRegistry.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/core/index.ts→tester/harmony/gesture_handler/src/main/ets/core/index.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/detectors/ScaleGestureDetector.ts→tester/harmony/gesture_handler/src/main/ets/detectors/ScaleGestureDetector.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/generated/components/RNGestureHandlerButton.ts→tester/harmony/gesture_handler/src/main/ets/generated/components/RNGestureHandlerButton.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/generated/components/RNGestureHandlerRootView.ts→tester/harmony/gesture_handler/src/main/ets/generated/components/RNGestureHandlerRootView.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/generated/components/ts.ts→tester/harmony/gesture_handler/src/main/ets/generated/components/ts.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/generated/index.ets→tester/harmony/gesture_handler/src/main/ets/generated/index.ets+0-0
Rexample/harmony/gesture_handler/src/main/ets/generated/ts.ts→tester/harmony/gesture_handler/src/main/ets/generated/ts.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/generated/turboModules/RNGestureHandlerModule.ts→tester/harmony/gesture_handler/src/main/ets/generated/turboModules/RNGestureHandlerModule.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/generated/turboModules/ts.ts→tester/harmony/gesture_handler/src/main/ets/generated/turboModules/ts.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/gesture-handlers/FlingGestureHandler.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/FlingGestureHandler.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/gesture-handlers/GestureHandlerFactory.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/GestureHandlerFactory.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/gesture-handlers/LongPressGestureHandler.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/LongPressGestureHandler.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/gesture-handlers/ManualGestureHandler.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/ManualGestureHandler.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/gesture-handlers/NativeViewGestureHandler.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/NativeViewGestureHandler.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/gesture-handlers/PanGestureHandler.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/PanGestureHandler.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/gesture-handlers/PinchGestureHandler.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/PinchGestureHandler.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/gesture-handlers/RotationGestureHandler.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/RotationGestureHandler.ts+0-0
Rharmony/gesture_handler/src/main/ets/gesture-handlers/TapGestureHandler.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/TapGestureHandler.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/gesture-handlers/detectors/RotationGestureDetector.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/detectors/RotationGestureDetector.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/gesture-handlers/index.ts→tester/harmony/gesture_handler/src/main/ets/gesture-handlers/index.ts+23-23
Rexample/harmony/gesture_handler/src/main/ets/rnoh/GestureHandlerPackage.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/GestureHandlerPackage.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/rnoh/Logger.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/Logger.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/rnoh/OutgoingEventDispatchers.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/OutgoingEventDispatchers.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootViewController.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootViewController.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/rnoh/RNGHView.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/RNGHView.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewController.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewController.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewRegistry.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewRegistry.ts+0-0
Rharmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/rnoh/RNOHGestureResponder.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/RNOHGestureResponder.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/rnoh/RNOHScrollLocker.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/RNOHScrollLocker.ts+0-0
Rexample/harmony/gesture_handler/src/main/ets/rnoh/types.ts→tester/harmony/gesture_handler/src/main/ets/rnoh/types.ts+0-0
Rexample/harmony/gesture_handler/src/main/module.json5→tester/harmony/gesture_handler/src/main/module.json5+0-0
Rexample/harmony/gesture_handler/src/main/resources/base/element/color.json→tester/harmony/gesture_handler/src/main/resources/base/element/color.json+0-0
Rexample/harmony/gesture_handler/src/main/resources/base/element/string.json→tester/harmony/gesture_handler/src/main/resources/base/element/string.json+0-0
Rexample/harmony/gesture_handler/src/main/resources/base/media/icon.png→tester/harmony/gesture_handler/src/main/resources/base/media/icon.png+0-0
Rexample/harmony/gesture_handler/src/main/resources/base/profile/main_pages.json→tester/harmony/gesture_handler/src/main/resources/base/profile/main_pages.json+0-0
Rexample/harmony/gesture_handler/src/main/resources/en_US/element/string.json→tester/harmony/gesture_handler/src/main/resources/en_US/element/string.json+0-0
Rexample/harmony/gesture_handler/src/main/resources/zh_CN/element/string.json→tester/harmony/gesture_handler/src/main/resources/zh_CN/element/string.json+0-0