├── .editorconfig
├── .gitattributes
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.yml
│ └── config.yml
├── actions
│ └── setup
│ │ └── action.yml
└── workflows
│ └── ci.yml
├── .gitignore
├── .nvmrc
├── .watchmanconfig
├── .yarn
├── plugins
│ └── @yarnpkg
│ │ ├── plugin-interactive-tools.cjs
│ │ └── plugin-workspace-tools.cjs
└── releases
│ └── yarn-3.6.1.cjs
├── .yarnrc.yml
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SyncTasks.podspec
├── android
├── CMakeLists.txt
├── build.gradle
├── cpp-adapter.cpp
├── gradle.properties
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── AndroidManifestNew.xml
│ ├── java
│ └── com
│ │ └── synctasks
│ │ ├── SyncTasksModule.kt
│ │ └── SyncTasksPackage.kt
│ └── libs
│ ├── arm64-v8a
│ └── libfetcher.a
│ ├── armeabi-v7a
│ └── libfetcher.a
│ ├── x86
│ └── libfetcher.a
│ └── x86_64
│ └── libfetcher.a
├── assets
└── img.png
├── babel.config.js
├── cpp
├── JSManager.cpp
├── JSManager.hpp
├── JSTask.cpp
├── JSTask.hpp
├── constants.hpp
├── core
│ └── TaskScheduler.hpp
├── fetcher.h
├── helpers
│ └── helpers.hpp
├── react-native-sync-tasks.cpp
└── react-native-sync-tasks.hpp
├── eslint.config.mjs
├── example
├── .bundle
│ └── config
├── .watchmanconfig
├── Gemfile
├── README.md
├── android
│ ├── app
│ │ ├── build.gradle
│ │ ├── debug.keystore
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── synctasks
│ │ │ │ └── example
│ │ │ │ ├── MainActivity.kt
│ │ │ │ └── MainApplication.kt
│ │ │ └── res
│ │ │ ├── drawable
│ │ │ └── rn_edit_text_material.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── app.json
├── babel.config.js
├── index.js
├── ios
│ ├── .xcode.env
│ ├── Podfile
│ ├── Podfile.lock
│ ├── SyncTasksExample.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── SyncTasksExample.xcscheme
│ ├── SyncTasksExample.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── SyncTasksExample
│ │ ├── AppDelegate.swift
│ │ ├── Images.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ │ ├── Info.plist
│ │ ├── LaunchScreen.storyboard
│ │ └── PrivacyInfo.xcprivacy
├── jest.config.js
├── metro.config.js
├── package.json
├── react-native.config.js
└── src
│ └── App.tsx
├── ios
├── SyncTasks.h
├── SyncTasks.mm
└── rust
│ └── fetcher.xcframework
│ ├── Info.plist
│ ├── ios-arm64-simulator
│ ├── Headers
│ │ └── fetcher.h
│ └── libfetcher.a
│ └── ios-arm64
│ ├── Headers
│ └── fetcher.h
│ └── libfetcher.a
├── package.json
├── rust
└── fetcher-rust
│ ├── Cargo.lock
│ ├── Cargo.toml
│ ├── android
│ └── build-android.sh
│ ├── include
│ └── fetcher.h
│ ├── ios
│ ├── Cargo.toml
│ └── build-ios.sh
│ └── src
│ └── lib.rs
├── src
└── index.tsx
├── tsconfig.build.json
├── tsconfig.json
├── turbo.json
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 | [*]
8 |
9 | indent_style = space
10 | indent_size = 2
11 |
12 | end_of_line = lf
13 | charset = utf-8
14 | trim_trailing_whitespace = true
15 | insert_final_newline = true
16 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 | # specific for windows script files
3 | *.bat text eol=crlf
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.yml:
--------------------------------------------------------------------------------
1 | name: 🐛 Bug report
2 | description: Report a reproducible bug or regression in this library.
3 | labels: [bug]
4 | body:
5 | - type: markdown
6 | attributes:
7 | value: |
8 | # Bug report
9 |
10 | 👋 Hi!
11 |
12 | **Please fill the following carefully before opening a new issue ❗**
13 | *(Your issue may be closed if it doesn't provide the required pieces of information)*
14 | - type: checkboxes
15 | attributes:
16 | label: Before submitting a new issue
17 | description: Please perform simple checks first.
18 | options:
19 | - label: I tested using the latest version of the library, as the bug might be already fixed.
20 | required: true
21 | - label: I tested using a [supported version](https://github.com/reactwg/react-native-releases/blob/main/docs/support.md) of react native.
22 | required: true
23 | - label: I checked for possible duplicate issues, with possible answers.
24 | required: true
25 | - type: textarea
26 | id: summary
27 | attributes:
28 | label: Bug summary
29 | description: |
30 | Provide a clear and concise description of what the bug is.
31 | If needed, you can also provide other samples: error messages / stack traces, screenshots, gifs, etc.
32 | validations:
33 | required: true
34 | - type: input
35 | id: library-version
36 | attributes:
37 | label: Library version
38 | description: What version of the library are you using?
39 | placeholder: "x.x.x"
40 | validations:
41 | required: true
42 | - type: textarea
43 | id: react-native-info
44 | attributes:
45 | label: Environment info
46 | description: Run `react-native info` in your terminal and paste the results here.
47 | render: shell
48 | validations:
49 | required: true
50 | - type: textarea
51 | id: steps-to-reproduce
52 | attributes:
53 | label: Steps to reproduce
54 | description: |
55 | You must provide a clear list of steps and code to reproduce the problem.
56 | value: |
57 | 1. …
58 | 2. …
59 | validations:
60 | required: true
61 | - type: input
62 | id: reproducible-example
63 | attributes:
64 | label: Reproducible example repository
65 | description: Please provide a link to a repository on GitHub with a reproducible example.
66 | render: js
67 | validations:
68 | required: true
69 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: Feature Request 💡
4 | url: https://github.com/pioner92/react-native-sync-tasks/discussions/new?category=ideas
5 | about: If you have a feature request, please create a new discussion on GitHub.
6 | - name: Discussions on GitHub 💬
7 | url: https://github.com/pioner92/react-native-sync-tasks/discussions
8 | about: If this library works as promised but you need help, please ask questions there.
9 |
--------------------------------------------------------------------------------
/.github/actions/setup/action.yml:
--------------------------------------------------------------------------------
1 | name: Setup
2 | description: Setup Node.js and install dependencies
3 |
4 | runs:
5 | using: composite
6 | steps:
7 | - name: Setup Node.js
8 | uses: actions/setup-node@v4
9 | with:
10 | node-version-file: .nvmrc
11 |
12 | - name: Restore dependencies
13 | id: yarn-cache
14 | uses: actions/cache/restore@v4
15 | with:
16 | path: |
17 | **/node_modules
18 | .yarn/install-state.gz
19 | key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
20 | restore-keys: |
21 | ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
22 | ${{ runner.os }}-yarn-
23 |
24 | - name: Install dependencies
25 | if: steps.yarn-cache.outputs.cache-hit != 'true'
26 | run: yarn install --immutable
27 | shell: bash
28 |
29 | - name: Cache dependencies
30 | if: steps.yarn-cache.outputs.cache-hit != 'true'
31 | uses: actions/cache/save@v4
32 | with:
33 | path: |
34 | **/node_modules
35 | .yarn/install-state.gz
36 | key: ${{ steps.yarn-cache.outputs.cache-primary-key }}
37 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | push:
4 | branches:
5 | - main
6 | pull_request:
7 | branches:
8 | - main
9 | merge_group:
10 | types:
11 | - checks_requested
12 |
13 | jobs:
14 | lint:
15 | runs-on: ubuntu-latest
16 | steps:
17 | - name: Checkout
18 | uses: actions/checkout@v4
19 |
20 | - name: Setup
21 | uses: ./.github/actions/setup
22 |
23 | - name: Lint files
24 | run: yarn lint
25 |
26 | - name: Typecheck files
27 | run: yarn typecheck
28 |
29 | test:
30 | runs-on: ubuntu-latest
31 | steps:
32 | - name: Checkout
33 | uses: actions/checkout@v4
34 |
35 | - name: Setup
36 | uses: ./.github/actions/setup
37 |
38 | - name: Run unit tests
39 | run: yarn test --maxWorkers=2 --coverage
40 |
41 | build-library:
42 | runs-on: ubuntu-latest
43 | steps:
44 | - name: Checkout
45 | uses: actions/checkout@v4
46 |
47 | - name: Setup
48 | uses: ./.github/actions/setup
49 |
50 | - name: Build package
51 | run: yarn prepare
52 |
53 | build-android:
54 | runs-on: ubuntu-latest
55 | env:
56 | TURBO_CACHE_DIR: .turbo/android
57 | steps:
58 | - name: Checkout
59 | uses: actions/checkout@v4
60 |
61 | - name: Setup
62 | uses: ./.github/actions/setup
63 |
64 | - name: Cache turborepo for Android
65 | uses: actions/cache@v4
66 | with:
67 | path: ${{ env.TURBO_CACHE_DIR }}
68 | key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
69 | restore-keys: |
70 | ${{ runner.os }}-turborepo-android-
71 |
72 | - name: Check turborepo cache for Android
73 | run: |
74 | TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
75 |
76 | if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
77 | echo "turbo_cache_hit=1" >> $GITHUB_ENV
78 | fi
79 |
80 | - name: Install JDK
81 | if: env.turbo_cache_hit != 1
82 | uses: actions/setup-java@v4
83 | with:
84 | distribution: 'zulu'
85 | java-version: '17'
86 |
87 | - name: Finalize Android SDK
88 | if: env.turbo_cache_hit != 1
89 | run: |
90 | /bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
91 |
92 | - name: Cache Gradle
93 | if: env.turbo_cache_hit != 1
94 | uses: actions/cache@v4
95 | with:
96 | path: |
97 | ~/.gradle/wrapper
98 | ~/.gradle/caches
99 | key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
100 | restore-keys: |
101 | ${{ runner.os }}-gradle-
102 |
103 | - name: Build example for Android
104 | env:
105 | JAVA_OPTS: "-XX:MaxHeapSize=6g"
106 | run: |
107 | yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
108 |
109 | build-ios:
110 | runs-on: macos-latest
111 | env:
112 | TURBO_CACHE_DIR: .turbo/ios
113 | steps:
114 | - name: Checkout
115 | uses: actions/checkout@v4
116 |
117 | - name: Setup
118 | uses: ./.github/actions/setup
119 |
120 | - name: Cache turborepo for iOS
121 | uses: actions/cache@v4
122 | with:
123 | path: ${{ env.TURBO_CACHE_DIR }}
124 | key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
125 | restore-keys: |
126 | ${{ runner.os }}-turborepo-ios-
127 |
128 | - name: Check turborepo cache for iOS
129 | run: |
130 | TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
131 |
132 | if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
133 | echo "turbo_cache_hit=1" >> $GITHUB_ENV
134 | fi
135 |
136 | - name: Restore cocoapods
137 | if: env.turbo_cache_hit != 1
138 | id: cocoapods-cache
139 | uses: actions/cache/restore@v4
140 | with:
141 | path: |
142 | **/ios/Pods
143 | key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
144 | restore-keys: |
145 | ${{ runner.os }}-cocoapods-
146 |
147 | - name: Install cocoapods
148 | if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
149 | run: |
150 | cd example/ios
151 | pod install
152 | env:
153 | NO_FLIPPER: 1
154 |
155 | - name: Cache cocoapods
156 | if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
157 | uses: actions/cache/save@v4
158 | with:
159 | path: |
160 | **/ios/Pods
161 | key: ${{ steps.cocoapods-cache.outputs.cache-key }}
162 |
163 | - name: Build example for iOS
164 | run: |
165 | yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
166 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # XDE
6 | .expo/
7 |
8 | # VSCode
9 | .vscode/
10 | jsconfig.json
11 |
12 | # Xcode
13 | #
14 | build/
15 | *.pbxuser
16 | !default.pbxuser
17 | *.mode1v3
18 | !default.mode1v3
19 | *.mode2v3
20 | !default.mode2v3
21 | *.perspectivev3
22 | !default.perspectivev3
23 | xcuserdata
24 | *.xccheckout
25 | *.moved-aside
26 | DerivedData
27 | *.hmap
28 | *.ipa
29 | *.xcuserstate
30 | project.xcworkspace
31 | **/.xcode.env.local
32 |
33 | # Android/IJ
34 | #
35 | .classpath
36 | .cxx
37 | .gradle
38 | .idea
39 | .project
40 | .settings
41 | local.properties
42 | android.iml
43 |
44 | # Cocoapods
45 | #
46 | example/ios/Pods
47 |
48 | # Ruby
49 | example/vendor/
50 |
51 | # node.js
52 | #
53 | node_modules/
54 | npm-debug.log
55 | yarn-debug.log
56 | yarn-error.log
57 |
58 | # BUCK
59 | buck-out/
60 | \.buckd/
61 | android/app/libs
62 | android/keystores/debug.keystore
63 |
64 | # Yarn
65 | .yarn/*
66 | !.yarn/patches
67 | !.yarn/plugins
68 | !.yarn/releases
69 | !.yarn/sdks
70 | !.yarn/versions
71 |
72 | # Expo
73 | .expo/
74 |
75 | # Turborepo
76 | .turbo/
77 |
78 | # generated by bob
79 | lib/
80 |
81 | # React Native Codegen
82 | ios/generated
83 | android/generated
84 |
85 | # React Native Nitro Modules
86 | nitrogen/
87 |
88 | rust/fetcher-rust/target
89 | rust/fetcher-rust/ios/universal
--------------------------------------------------------------------------------
/.nvmrc:
--------------------------------------------------------------------------------
1 | v20.19.0
2 |
--------------------------------------------------------------------------------
/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/.yarnrc.yml:
--------------------------------------------------------------------------------
1 | nodeLinker: node-modules
2 | nmHoistingLimits: workspaces
3 |
4 | plugins:
5 | - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
6 | spec: "@yarnpkg/plugin-interactive-tools"
7 | - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
8 | spec: "@yarnpkg/plugin-workspace-tools"
9 |
10 | yarnPath: .yarn/releases/yarn-3.6.1.cjs
11 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 |
2 | # Contributor Covenant Code of Conduct
3 |
4 | ## Our Pledge
5 |
6 | We as members, contributors, and leaders pledge to make participation in our
7 | community a harassment-free experience for everyone, regardless of age, body
8 | size, visible or invisible disability, ethnicity, sex characteristics, gender
9 | identity and expression, level of experience, education, socio-economic status,
10 | nationality, personal appearance, race, caste, color, religion, or sexual
11 | identity and orientation.
12 |
13 | We pledge to act and interact in ways that contribute to an open, welcoming,
14 | diverse, inclusive, and healthy community.
15 |
16 | ## Our Standards
17 |
18 | Examples of behavior that contributes to a positive environment for our
19 | community include:
20 |
21 | * Demonstrating empathy and kindness toward other people
22 | * Being respectful of differing opinions, viewpoints, and experiences
23 | * Giving and gracefully accepting constructive feedback
24 | * Accepting responsibility and apologizing to those affected by our mistakes,
25 | and learning from the experience
26 | * Focusing on what is best not just for us as individuals, but for the overall
27 | community
28 |
29 | Examples of unacceptable behavior include:
30 |
31 | * The use of sexualized language or imagery, and sexual attention or advances of
32 | any kind
33 | * Trolling, insulting or derogatory comments, and personal or political attacks
34 | * Public or private harassment
35 | * Publishing others' private information, such as a physical or email address,
36 | without their explicit permission
37 | * Other conduct which could reasonably be considered inappropriate in a
38 | professional setting
39 |
40 | ## Enforcement Responsibilities
41 |
42 | Community leaders are responsible for clarifying and enforcing our standards of
43 | acceptable behavior and will take appropriate and fair corrective action in
44 | response to any behavior that they deem inappropriate, threatening, offensive,
45 | or harmful.
46 |
47 | Community leaders have the right and responsibility to remove, edit, or reject
48 | comments, commits, code, wiki edits, issues, and other contributions that are
49 | not aligned to this Code of Conduct, and will communicate reasons for moderation
50 | decisions when appropriate.
51 |
52 | ## Scope
53 |
54 | This Code of Conduct applies within all community spaces, and also applies when
55 | an individual is officially representing the community in public spaces.
56 | Examples of representing our community include using an official e-mail address,
57 | posting via an official social media account, or acting as an appointed
58 | representative at an online or offline event.
59 |
60 | ## Enforcement
61 |
62 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
63 | reported to the community leaders responsible for enforcement at
64 | [INSERT CONTACT METHOD].
65 | All complaints will be reviewed and investigated promptly and fairly.
66 |
67 | All community leaders are obligated to respect the privacy and security of the
68 | reporter of any incident.
69 |
70 | ## Enforcement Guidelines
71 |
72 | Community leaders will follow these Community Impact Guidelines in determining
73 | the consequences for any action they deem in violation of this Code of Conduct:
74 |
75 | ### 1. Correction
76 |
77 | **Community Impact**: Use of inappropriate language or other behavior deemed
78 | unprofessional or unwelcome in the community.
79 |
80 | **Consequence**: A private, written warning from community leaders, providing
81 | clarity around the nature of the violation and an explanation of why the
82 | behavior was inappropriate. A public apology may be requested.
83 |
84 | ### 2. Warning
85 |
86 | **Community Impact**: A violation through a single incident or series of
87 | actions.
88 |
89 | **Consequence**: A warning with consequences for continued behavior. No
90 | interaction with the people involved, including unsolicited interaction with
91 | those enforcing the Code of Conduct, for a specified period of time. This
92 | includes avoiding interactions in community spaces as well as external channels
93 | like social media. Violating these terms may lead to a temporary or permanent
94 | ban.
95 |
96 | ### 3. Temporary Ban
97 |
98 | **Community Impact**: A serious violation of community standards, including
99 | sustained inappropriate behavior.
100 |
101 | **Consequence**: A temporary ban from any sort of interaction or public
102 | communication with the community for a specified period of time. No public or
103 | private interaction with the people involved, including unsolicited interaction
104 | with those enforcing the Code of Conduct, is allowed during this period.
105 | Violating these terms may lead to a permanent ban.
106 |
107 | ### 4. Permanent Ban
108 |
109 | **Community Impact**: Demonstrating a pattern of violation of community
110 | standards, including sustained inappropriate behavior, harassment of an
111 | individual, or aggression toward or disparagement of classes of individuals.
112 |
113 | **Consequence**: A permanent ban from any sort of public interaction within the
114 | community.
115 |
116 | ## Attribution
117 |
118 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119 | version 2.1, available at
120 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
121 |
122 | Community Impact Guidelines were inspired by
123 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124 |
125 | For answers to common questions about this code of conduct, see the FAQ at
126 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
127 | [https://www.contributor-covenant.org/translations][translations].
128 |
129 | [homepage]: https://www.contributor-covenant.org
130 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
131 | [Mozilla CoC]: https://github.com/mozilla/diversity
132 | [FAQ]: https://www.contributor-covenant.org/faq
133 | [translations]: https://www.contributor-covenant.org/translations
134 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Contributions are always welcome, no matter how large or small!
4 |
5 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. Before contributing, please read the [code of conduct](./CODE_OF_CONDUCT.md).
6 |
7 | ## Development workflow
8 |
9 | This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
10 |
11 | - The library package in the root directory.
12 | - An example app in the `example/` directory.
13 |
14 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
15 |
16 | ```sh
17 | yarn
18 | ```
19 |
20 | > Since the project relies on Yarn workspaces, you cannot use [`npm`](https://github.com/npm/cli) for development.
21 |
22 | The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make.
23 |
24 | It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
25 |
26 | If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/SyncTasksExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-sync-tasks`.
27 |
28 | To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-sync-tasks` under `Android`.
29 |
30 | You can use various commands from the root directory to work with the project.
31 |
32 | To start the packager:
33 |
34 | ```sh
35 | yarn example start
36 | ```
37 |
38 | To run the example app on Android:
39 |
40 | ```sh
41 | yarn example android
42 | ```
43 |
44 | To run the example app on iOS:
45 |
46 | ```sh
47 | yarn example ios
48 | ```
49 |
50 | Make sure your code passes TypeScript and ESLint. Run the following to verify:
51 |
52 | ```sh
53 | yarn typecheck
54 | yarn lint
55 | ```
56 |
57 | To fix formatting errors, run the following:
58 |
59 | ```sh
60 | yarn lint --fix
61 | ```
62 |
63 | Remember to add tests for your change if possible. Run the unit tests by:
64 |
65 | ```sh
66 | yarn test
67 | ```
68 |
69 | ### Commit message convention
70 |
71 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
72 |
73 | - `fix`: bug fixes, e.g. fix crash due to deprecated method.
74 | - `feat`: new features, e.g. add new method to the module.
75 | - `refactor`: code refactor, e.g. migrate from class components to hooks.
76 | - `docs`: changes into documentation, e.g. add usage example for the module..
77 | - `test`: adding or updating tests, e.g. add integration tests using detox.
78 | - `chore`: tooling changes, e.g. change CI config.
79 |
80 | Our pre-commit hooks verify that your commit message matches this format when committing.
81 |
82 | ### Linting and tests
83 |
84 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
85 |
86 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
87 |
88 | Our pre-commit hooks verify that the linter and tests pass when committing.
89 |
90 | ### Publishing to npm
91 |
92 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
93 |
94 | To publish new versions, run the following:
95 |
96 | ```sh
97 | yarn release
98 | ```
99 |
100 | ### Scripts
101 |
102 | The `package.json` file contains various scripts for common tasks:
103 |
104 | - `yarn`: setup project by installing dependencies.
105 | - `yarn typecheck`: type-check files with TypeScript.
106 | - `yarn lint`: lint files with ESLint.
107 | - `yarn test`: run unit tests with Jest.
108 | - `yarn example start`: start the Metro server for the example app.
109 | - `yarn example android`: run the example app on Android.
110 | - `yarn example ios`: run the example app on iOS.
111 |
112 | ### Sending a pull request
113 |
114 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
115 |
116 | When you're sending a pull request:
117 |
118 | - Prefer small pull requests focused on one change.
119 | - Verify that linters and tests are passing.
120 | - Review the documentation to make sure it looks good.
121 | - Follow the pull request template when opening a pull request.
122 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
123 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2025 pioner921227
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 🚀 SyncTasksManager (JSI)
2 |
3 |
4 |
5 |
6 |
7 | **SyncTasksManager** is a native JSI-based library for React Native that allows you to manage and execute **native-threaded sync tasks** (such as periodic API polling) efficiently from JavaScript, while delegating the actual execution to the native layer for better performance.
8 |
9 | > ⚠️ **Note**: This is not a background task manager — tasks do not continue running when the app is in the background or killed. The polling happens while the app is active, on a native thread, outside the JS thread.
10 |
11 | ---
12 |
13 | ## ⚙️ Features
14 |
15 | - 🔁 Periodic HTTP polling with configurable interval
16 | - 📡 Callback on data reception or error
17 | - 🧵 High-performance execution via native thread using JSI
18 | - 🧠 Centralized task management (start/stop all tasks)
19 | - ✅ Seamless integration with native modules (C++/JSI)
20 | - ✨ Built-in response deduplication using response body hash — avoids redundant `onData` calls if the response has not changed
21 |
22 | ---
23 |
24 | ## 📦 Installation
25 | ```bash
26 | npm install react-native-sync-tasks
27 | ```
28 |
29 | > Don’t forget to run `pod install` for iOS if using CocoaPods.
30 |
31 | ---
32 |
33 | ## 🛠️ Usage
34 |
35 | ```ts
36 | import { createTask, SyncTasksManager } from 'react-native-sync-tasks';
37 |
38 | type TData = {
39 | userId: number;
40 | id: number;
41 | title: string;
42 | body: string;
43 | };
44 |
45 | const task = createTask({
46 | config: {
47 | url: 'https://jsonplaceholder.typicode.com/posts/1',
48 | // 2000ms / default 1000ms
49 | interval: 2000,
50 | // headers optional
51 | headers: {
52 | 'Content-Type': 'application/json',
53 | 'Accept': 'application/json',
54 | },
55 | },
56 | // { body: TData, status_code: number }
57 | onData: (data) => {
58 | console.log('DATA', data);
59 | },
60 | // { error: string, status_code: number }
61 | onError: (error) => {
62 | console.log('ERROR', error);
63 | },
64 | });
65 |
66 | SyncTasksManager.addTask(task);
67 | SyncTasksManager.startAll();
68 | ...
69 | // stop all tasks
70 | SyncTasksManager.stopAll();
71 | // or stop only 1 task
72 | task.stop();
73 | ```
74 |
75 | ---
76 |
77 | ## 🔍 API
78 |
79 | ### `createTask(props: CreateTaskParams): Task`
80 |
81 | Creates a task that will periodically fetch data from the specified URL, executed on a native thread.
82 |
83 | #### Params:
84 |
85 | | Name | Type | Description |
86 | |-----------|----------------------------------------------------------------------|-----------------------------------------------|
87 | | `config` | `{ url: string; interval: number; headers?: Record }` | HTTP polling configuration |
88 | | `onData` | `(data: { body: T, status_code: number }) => void` | Callback when data is successfully received |
89 | | `onError` | `(error: { error: string, status_code: number }) => void` | Callback when request fails (optional) |
90 |
91 | > Under the hood, the task stores a hash of the last response body. If the newly fetched response is identical (hash matches), the `onData` callback will **not** be triggered.
92 |
93 | ### `Task`
94 |
95 | Represents an individual polling task running on a native thread.
96 |
97 | #### Methods:
98 |
99 | - `start(): void` — Manually start the task
100 | - `stop(): void` — Stop the task
101 | - `isRunning(): boolean` — Check if the task is currently running
102 |
103 | ---
104 |
105 | ### `SyncTasksManager`
106 |
107 | A global manager to control multiple polling tasks.
108 |
109 | #### Methods:
110 |
111 | - `addTask(task: Task): void` — Add a single task
112 | - `addTasks(tasks: Task[]): void` — Add multiple tasks
113 | - `startAll(): void` — Start all registered tasks
114 | - `stopAll(): void` — Stop all running tasks
115 |
116 | ---
117 |
118 | ## 📄 License
119 |
120 | MIT
121 |
122 | ---
123 |
124 | 🎉 **Enjoy using react-native-sync-tasks!** Offload polling to native threads and keep your JS thread free.
125 |
126 |
--------------------------------------------------------------------------------
/SyncTasks.podspec:
--------------------------------------------------------------------------------
1 | require "json"
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4 |
5 | Pod::Spec.new do |s|
6 | s.name = "SyncTasks"
7 | s.version = package["version"]
8 | s.summary = package["description"]
9 | s.homepage = package["homepage"]
10 | s.license = package["license"]
11 | s.authors = package["author"]
12 |
13 | s.platforms = { :ios => min_ios_version_supported }
14 | s.source = { :git => "https://github.com/pioner92/react-native-sync-tasks.git", :tag => "#{s.version}" }
15 |
16 | s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}"
17 | s.vendored_frameworks = 'ios/rust/fetcher.xcframework'
18 |
19 |
20 | # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
21 | # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
22 | if respond_to?(:install_modules_dependencies, true)
23 | install_modules_dependencies(s)
24 | else
25 | s.dependency "React-Core"
26 | end
27 | end
28 |
--------------------------------------------------------------------------------
/android/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.4.1)
2 | project(rnsynctasks)
3 |
4 | set (CMAKE_VERBOSE_MAKEFILE ON)
5 | set (CMAKE_CXX_STANDARD 20)
6 |
7 | add_library(fetcher STATIC IMPORTED)
8 |
9 | set_target_properties(fetcher PROPERTIES IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/src/main/libs/${ANDROID_ABI}/libfetcher.a")
10 |
11 |
12 | add_library(rnsynctasks SHARED
13 | ../cpp/react-native-sync-tasks.cpp
14 | ../cpp/react-native-sync-tasks.hpp
15 | ../cpp/constants.hpp
16 | ../cpp/JSTask.hpp
17 | ../cpp/JSTask.cpp
18 | ../cpp/JSManager.hpp
19 | ../cpp/JSManager.cpp
20 | ../cpp/helpers/helpers.hpp
21 | ../cpp/core/TaskScheduler.hpp
22 | ../cpp/fetcher.h
23 | cpp-adapter.cpp
24 |
25 | )
26 |
27 | include_directories(
28 | ../cpp
29 | )
30 |
31 | find_package(ReactAndroid REQUIRED CONFIG)
32 |
33 | find_package(fbjni REQUIRED CONFIG)
34 |
35 | target_include_directories(
36 | rnsynctasks PRIVATE
37 | "${NODE_MODULES_DIR}/react-native/React"
38 | "${NODE_MODULES_DIR}/react-native/React/Base"
39 | "${NODE_MODULES_DIR}/react-native/ReactCommon"
40 | "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
41 | "${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
42 | "${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule"
43 | "${NODE_MODULES_DIR}/react-native/ReactCommon/runtimeexecutor"
44 | )
45 |
46 |
47 | target_link_libraries(rnsynctasks
48 | ReactAndroid::jsi
49 | log
50 | ReactAndroid::reactnative
51 | fbjni::fbjni
52 | fetcher
53 | )
54 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | import groovy.json.JsonSlurper
2 | import org.apache.tools.ant.filters.ReplaceTokens
3 | import java.nio.file.Paths
4 |
5 | static def findNodeModules(baseDir) {
6 | def basePath = baseDir.toPath().normalize()
7 | // Node's module resolution algorithm searches up to the root directory,
8 | // after which the base path will be null
9 | while (basePath) {
10 | def nodeModulesPath = Paths.get(basePath.toString(), "node_modules")
11 | def reactNativePath = Paths.get(nodeModulesPath.toString(), "react-native")
12 | if (nodeModulesPath.toFile().exists() && reactNativePath.toFile().exists()) {
13 | return nodeModulesPath.toString()
14 | }
15 | basePath = basePath.getParent()
16 | }
17 | throw new GradleException("SyncTasks: Failed to find node_modules/ path!")
18 | }
19 |
20 | def nodeModules = findNodeModules(projectDir)
21 | logger.warn("SyncTasks: node_modules/ found at: ${nodeModules}")
22 |
23 | buildscript {
24 | ext.getExtOrDefault = {name ->
25 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['SyncTasks_' + name]
26 | }
27 |
28 | repositories {
29 | google()
30 | mavenCentral()
31 | }
32 |
33 | dependencies {
34 | classpath "com.android.tools.build:gradle:8.7.2"
35 | // noinspection DifferentKotlinGradleVersion
36 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
37 | }
38 | }
39 |
40 | def reactNativeArchitectures() {
41 | def value = rootProject.getProperties().get("reactNativeArchitectures")
42 | return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
43 | }
44 |
45 | def isNewArchitectureEnabled() {
46 | return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
47 | }
48 |
49 | apply plugin: "com.android.library"
50 | apply plugin: "kotlin-android"
51 |
52 | if (isNewArchitectureEnabled()) {
53 | apply plugin: "com.facebook.react"
54 | }
55 |
56 | def getExtOrIntegerDefault(name) {
57 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["SyncTasks_" + name]).toInteger()
58 | }
59 |
60 | def supportsNamespace() {
61 | def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
62 | def major = parsed[0].toInteger()
63 | def minor = parsed[1].toInteger()
64 |
65 | // Namespace support was added in 7.3.0
66 | return (major == 7 && minor >= 3) || major >= 8
67 | }
68 |
69 | android {
70 | if (supportsNamespace()) {
71 | namespace "com.synctasks"
72 |
73 | sourceSets {
74 | main {
75 | manifest.srcFile "src/main/AndroidManifestNew.xml"
76 | }
77 | }
78 | }
79 |
80 | // ndkVersion getExtOrDefault("ndkVersion")
81 | compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
82 |
83 | defaultConfig {
84 | minSdkVersion getExtOrIntegerDefault("minSdkVersion")
85 | targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
86 | buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
87 |
88 | externalNativeBuild {
89 | cmake {
90 | cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all"
91 | abiFilters (*reactNativeArchitectures())
92 | arguments "-DANDROID_STL=c++_shared",
93 | "-DNODE_MODULES_DIR=${nodeModules}"
94 | }
95 | }
96 | }
97 |
98 | externalNativeBuild {
99 | cmake {
100 | path "CMakeLists.txt"
101 | }
102 | }
103 |
104 | buildFeatures {
105 | buildConfig true
106 | prefab true
107 | }
108 |
109 | packagingOptions {
110 | excludes = [
111 | "**/libjsi.so",
112 | "**/libreactnativejni.so",
113 | "**/libreact_nativemodule_core.so",
114 | "**/libturbomodulejsijni.so",
115 | "**/libc++_shared.so",
116 | "**/libfbjni.so",
117 | "**/libreactnative.so",
118 | ]
119 | }
120 |
121 | buildTypes {
122 | release {
123 | minifyEnabled false
124 | }
125 | }
126 |
127 | lintOptions {
128 | disable "GradleCompatible"
129 | }
130 |
131 | compileOptions {
132 | sourceCompatibility JavaVersion.VERSION_1_8
133 | targetCompatibility JavaVersion.VERSION_1_8
134 | }
135 |
136 | sourceSets {
137 | main {
138 | // jniLibs.srcDirs = ['main/jniLibs']
139 | jniLibs.srcDirs = ['src/main/jniLibs']
140 | // jniLibs.srcDirs = ['jniLibs']
141 | if (isNewArchitectureEnabled()) {
142 | java.srcDirs += [
143 | "generated/java",
144 | "generated/jni"
145 | ]
146 | }
147 | }
148 | }
149 | }
150 |
151 | repositories {
152 | mavenCentral()
153 | google()
154 | }
155 |
156 | def kotlin_version = getExtOrDefault("kotlinVersion")
157 |
158 | dependencies {
159 | implementation "com.facebook.react:react-android"
160 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
161 | implementation("com.squareup.okhttp3:okhttp:4.12.0")
162 | }
163 |
164 | if (isNewArchitectureEnabled()) {
165 | react {
166 | jsRootDir = file("../src/")
167 | libraryName = "ConfigJsi"
168 | codegenJavaPackageName = "com.configjsi"
169 | }
170 | }
171 |
172 |
--------------------------------------------------------------------------------
/android/cpp-adapter.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "jsi/jsi.h"
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include "react-native-sync-tasks.hpp"
10 |
11 |
12 | using namespace facebook;
13 |
14 | struct SyncTasksBridge : jni::JavaClass {
15 | public:
16 | static constexpr auto kJavaDescriptor = "Lcom/synctasks/SyncTasksModule;";
17 |
18 | static void registerNatives() {
19 | javaClassStatic()->registerNatives({makeNativeMethod("nativeInstall", SyncTasksBridge::nativeInstall)});
20 | }
21 | private:
22 | static void nativeInstall(
23 | jni::alias_ref thiz,
24 | jlong jsiRuntimePointer,
25 | jni::alias_ref jsCallInvokerHolder
26 | ) {
27 |
28 | // Реализация
29 | auto jsiRuntime = reinterpret_cast(jsiRuntimePointer);
30 | auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker();
31 |
32 | sh::synctasks::install(jsiRuntime, jsCallInvoker);
33 | }
34 | };
35 |
36 | JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *) {
37 | return jni::initialize(vm, [] { SyncTasksBridge::registerNatives(); });
38 | }
39 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | SyncTasks_kotlinVersion=2.0.21
2 | SyncTasks_minSdkVersion=24
3 | SyncTasks_targetSdkVersion=34
4 | SyncTasks_compileSdkVersion=35
5 | SyncTasks_ndkVersion=27.1.12297006
6 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifestNew.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/android/src/main/java/com/synctasks/SyncTasksModule.kt:
--------------------------------------------------------------------------------
1 | package com.synctasks
2 |
3 | import android.util.Log
4 | import com.facebook.react.bridge.ReactApplicationContext
5 | import com.facebook.react.bridge.ReactContextBaseJavaModule
6 | import com.facebook.react.bridge.ReactMethod
7 | import com.facebook.react.common.annotations.FrameworkAPI
8 | import com.facebook.react.turbomodule.core.CallInvokerHolderImpl
9 | import okhttp3.OkHttpClient
10 | import okhttp3.Request
11 |
12 |
13 | object Fetcher {
14 | @JvmStatic
15 | fun fetch(url: String, headers: Map): String {
16 | val client = OkHttpClient()
17 |
18 | val builder = Request.Builder()
19 | .url(url)
20 |
21 | headers.forEach { (k, v) -> builder.addHeader(k, v) }
22 |
23 | val response = client.newCall(builder.build()).execute()
24 |
25 | val body = response.body?.string() ?: ""
26 |
27 | return body;
28 | }
29 | }
30 |
31 | @OptIn(FrameworkAPI::class)
32 | class SyncTasksModule internal constructor(val context: ReactApplicationContext) :
33 | ReactContextBaseJavaModule(context) {
34 |
35 | companion object {
36 |
37 | const val NAME = "SyncTasksManager"
38 |
39 | init {
40 | System.loadLibrary("rnsynctasks")
41 | }
42 |
43 | lateinit var instance: SyncTasksModule
44 |
45 | @OptIn(FrameworkAPI::class)
46 | @JvmStatic
47 | external fun nativeInstall(jsiRuntimePointer: Long, jsCallInvoker: CallInvokerHolderImpl)
48 | }
49 |
50 | private val reactContext = context
51 |
52 | init {
53 | instance = this
54 | }
55 |
56 | override fun getName(): String {
57 | return NAME
58 | }
59 |
60 | @OptIn(FrameworkAPI::class)
61 | @ReactMethod(isBlockingSynchronousMethod = true)
62 | fun install(): Boolean {
63 | Log.d(NAME, "install() called")
64 |
65 |
66 | val callInvokerHolder = reactContext.catalystInstance.jsCallInvokerHolder as CallInvokerHolderImpl
67 |
68 | nativeInstall(
69 | context.javaScriptContextHolder!!.get(),
70 | callInvokerHolder,
71 | )
72 | return true
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/android/src/main/java/com/synctasks/SyncTasksPackage.kt:
--------------------------------------------------------------------------------
1 | package com.synctasks
2 |
3 | import com.facebook.react.ReactPackage
4 | import com.facebook.react.bridge.NativeModule
5 | import com.facebook.react.bridge.ReactApplicationContext
6 | import com.facebook.react.uimanager.ViewManager
7 |
8 |
9 | class SyncTasksPackage : ReactPackage {
10 | override fun createNativeModules(reactContext: ReactApplicationContext): List {
11 | return listOf(SyncTasksModule(reactContext))
12 | }
13 |
14 | override fun createViewManagers(reactContext: ReactApplicationContext): List> {
15 | return emptyList()
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/android/src/main/libs/arm64-v8a/libfetcher.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/android/src/main/libs/arm64-v8a/libfetcher.a
--------------------------------------------------------------------------------
/android/src/main/libs/armeabi-v7a/libfetcher.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/android/src/main/libs/armeabi-v7a/libfetcher.a
--------------------------------------------------------------------------------
/android/src/main/libs/x86/libfetcher.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/android/src/main/libs/x86/libfetcher.a
--------------------------------------------------------------------------------
/android/src/main/libs/x86_64/libfetcher.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/android/src/main/libs/x86_64/libfetcher.a
--------------------------------------------------------------------------------
/assets/img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/assets/img.png
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:react-native-builder-bob/babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/cpp/JSManager.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // JSManager2.cpp
3 | // SyncTasks
4 | //
5 | // Created by Oleksandr Shumihin on 12/4/25.
6 | //
7 |
8 | #include "JSManager.hpp"
9 | #include "core/TaskScheduler.hpp"
10 | #include "constants.hpp"
11 | #include "helpers/helpers.hpp"
12 |
13 | jsi::Object createJSTaskManager(jsi::Runtime& rt) {
14 | jsi::Object taskManagerJS = jsi::Object(rt);
15 |
16 | auto t_manager = std::make_shared(THREADS_COUNT);
17 |
18 | jsi::Function addTask = jsi::Function::createFromHostFunction(
19 | rt, jsi::PropNameID::forAscii(rt, ADD_TASK_KEY), 1,
20 | [t_manager](jsi::Runtime& rt, const jsi::Value& thisVal,
21 | const jsi::Value* args, size_t count) {
22 |
23 | if(!args[0].isObject() || !args[0].asObject(rt).hasNativeState(rt)){
24 | throw jsi::JSError(rt, createErrorString("addTask -> Invalid argument").data());
25 | }
26 |
27 | t_manager->addTask(args[0].asObject(rt).getNativeState(rt));
28 |
29 | return jsi::Value(true);
30 | });
31 |
32 | jsi::Function addTasks = jsi::Function::createFromHostFunction(
33 | rt, jsi::PropNameID::forAscii(rt, ADD_TASKS_KEY), 1,
34 | [t_manager](jsi::Runtime& rt, const jsi::Value& thisVal,
35 | const jsi::Value* args, size_t count) {
36 | if (!checkJSType(rt, args[0])) {
37 | throw jsi::JSError(rt, createErrorString("addTasks -> Argument must be an array").data());
38 | }
39 |
40 | jsi::Array jsTasks = args[0].asObject(rt).asArray(rt);
41 |
42 | for (int i = 0; i < jsTasks.length(rt); ++i) {
43 |
44 | jsi::Value taskValue = jsTasks.getValueAtIndex(rt, i);
45 |
46 | if(!taskValue.isObject() || !taskValue.asObject(rt).hasNativeState(rt)){
47 | throw jsi::JSError(rt, createErrorString("addTasks -> Invalid argument").data());
48 | }
49 |
50 | std::shared_ptr task = taskValue.asObject(rt).getNativeState(rt);
51 |
52 | t_manager->addTask(std::move(task));
53 | }
54 |
55 | return jsi::Value(true);
56 | });
57 |
58 | jsi::Function startAll = jsi::Function::createFromHostFunction(
59 | rt, jsi::PropNameID::forAscii(rt, START_ALL_KEY), 1,
60 | [t_manager](jsi::Runtime& rt, const jsi::Value& thisVal,
61 | const jsi::Value* args, size_t count) {
62 | t_manager->start();
63 | return jsi::Value(true);
64 | });
65 |
66 | jsi::Function stopAll = jsi::Function::createFromHostFunction(
67 | rt, jsi::PropNameID::forAscii(rt, STOP_ALL_KEY), 1,
68 | [t_manager](jsi::Runtime& rt, const jsi::Value& thisVal,
69 | const jsi::Value* args, size_t count) {
70 | t_manager->stop();
71 | return jsi::Value(true);
72 | });
73 |
74 | taskManagerJS.setNativeState(rt, t_manager);
75 |
76 | taskManagerJS.setProperty(rt, ADD_TASK_KEY, std::move(addTask));
77 | taskManagerJS.setProperty(rt, ADD_TASKS_KEY, std::move(addTasks));
78 | taskManagerJS.setProperty(rt, START_ALL_KEY, std::move(startAll));
79 | taskManagerJS.setProperty(rt, STOP_ALL_KEY, std::move(stopAll));
80 |
81 | taskManagerJS.setExternalMemoryPressure(rt, sizeof(TaskScheduler));
82 |
83 | return taskManagerJS;
84 | }
85 |
--------------------------------------------------------------------------------
/cpp/JSManager.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // JSManager2.hpp
3 | // SyncTasks
4 | //
5 | // Created by Oleksandr Shumihin on 12/4/25.
6 | //
7 |
8 | #ifndef JSManager_hpp
9 | #define JSManager_hpp
10 |
11 | #include "jsi/jsi.h"
12 |
13 |
14 | facebook::jsi::Object createJSTaskManager(facebook::jsi::Runtime& rt);
15 |
16 | #endif /* JSManager_hpp */
17 |
--------------------------------------------------------------------------------
/cpp/JSTask.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // JSTask2.cpp
3 | // SyncTasks
4 | //
5 | // Created by Oleksandr Shumihin on 12/4/25.
6 | //
7 |
8 | #include "JSTask.hpp"
9 |
10 | #include "core/TaskScheduler.hpp"
11 | #include "constants.hpp"
12 | #include "helpers/helpers.hpp"
13 | #include "iostream"
14 |
15 | extern "C" {
16 | #include "fetcher.h"
17 | }
18 |
19 | using namespace facebook;
20 |
21 | using RustHeader = Header;
22 |
23 | constexpr std::hash hasher;
24 |
25 | jsi::Function createJSTaskCreator(
26 | jsi::Runtime& rt,
27 | std::shared_ptr callInvoker) {
28 | jsi::Function createTask = jsi::Function::createFromHostFunction(
29 | rt, jsi::PropNameID::forAscii(rt, CREATE_TASK_KEY), 1,
30 | [callInvoker = std::move(callInvoker)](
31 | jsi::Runtime& rt, const jsi::Value& thisVal, const jsi::Value* args,
32 | size_t count) {
33 | jsi::Object taskJS(rt);
34 |
35 | if (!args[0].isObject()) {
36 | throw jsi::JSError(
37 | rt, createErrorString("createTask -> argument must be an object")
38 | .data());
39 | }
40 |
41 | jsi::Object props = args[0].asObject(rt);
42 |
43 | jsi::Object config = props.getPropertyAsObject(rt, CONFIG_KEY);
44 |
45 | CPPHeaders cppHeaders = getFetchHeadersFromJSObject(rt, config);
46 |
47 | int interval = config.getProperty(rt, INTERVAL_KEY).asNumber();
48 | std::string url = config.getProperty(rt, URL_KEY).asString(rt).utf8(rt);
49 |
50 | if (!checkJSType(rt,
51 | props.getProperty(rt, ON_DATA_KEY))) {
52 | throw jsi::JSError(
53 | rt, createErrorString("onData must be a function").data());
54 | }
55 |
56 | auto onData = std::make_shared(
57 | props.getPropertyAsFunction(rt, ON_DATA_KEY));
58 |
59 | jsi::Value onErrorValue = props.getProperty(rt, ON_ERROR_KEY);
60 |
61 | std::shared_ptr onError;
62 |
63 | if (checkJSType(rt, onErrorValue)) {
64 | onError = std::make_shared(
65 | props.getPropertyAsFunction(rt, ON_ERROR_KEY));
66 | }
67 |
68 | auto task = std::make_shared(
69 | url, interval,
70 | [url, cppHeaders = std::move(cppHeaders), callInvoker, onData,
71 | onError, &rt](Task& self) mutable {
72 | std::vector rustHeaders;
73 |
74 | if (cppHeaders.size()) {
75 | for (auto& h : cppHeaders) {
76 | rustHeaders.emplace_back(h.key.c_str(), h.value.c_str());
77 | }
78 | }
79 |
80 | FetchResult result = rust_fetch(url.c_str(), rustHeaders.data(),
81 | rustHeaders.size());
82 |
83 | std::string body = result.body;
84 | rust_free_string(result.body);
85 |
86 | if (result.ok) {
87 | size_t bodyHash = hasher(body);
88 |
89 | if (self.hasSameBodyHash(bodyHash)) {
90 | return;
91 | }
92 |
93 | self.setLastBodyHash(bodyHash);
94 |
95 | callInvoker->invokeAsync([&rt, onData, body = std::move(body),
96 | statuc_code = result.code] {
97 | jsi::Object jsRes(rt);
98 |
99 | jsi::Value json = jsi::Value::createFromJsonUtf8(
100 | rt, reinterpret_cast(body.data()),
101 | body.size());
102 |
103 | jsRes.setProperty(rt, "body", json);
104 | jsRes.setProperty(rt, "status_code", statuc_code);
105 |
106 | onData->call(rt, jsRes);
107 | });
108 |
109 | } else {
110 | callInvoker->invokeAsync([onError, &rt, body = std::move(body),
111 | status_code = result.code] {
112 | if (onError) {
113 | jsi::Object error(rt);
114 | error.setProperty(rt, "error",
115 | jsi::String::createFromUtf8(rt, body));
116 | error.setProperty(rt, "status_code", status_code);
117 |
118 | onError->call(rt, error);
119 | }
120 | });
121 | }
122 | });
123 |
124 | jsi::Function stopTask = jsi::Function::createFromHostFunction(
125 | rt, jsi::PropNameID::forAscii(rt, "stopTask"), 0,
126 | [task](jsi::Runtime& rt, const jsi::Value& thisVal,
127 | const jsi::Value* args, size_t count) {
128 | task->stop();
129 |
130 | return jsi::Value(true);
131 | });
132 |
133 | jsi::Function startTask = jsi::Function::createFromHostFunction(
134 | rt, jsi::PropNameID::forAscii(rt, "startTask"), 0,
135 | [task](jsi::Runtime& rt, const jsi::Value& thisVal,
136 | const jsi::Value* args, size_t count) {
137 | task->start();
138 |
139 | return jsi::Value(true);
140 | });
141 |
142 | jsi::Function isRunning = jsi::Function::createFromHostFunction(
143 | rt, jsi::PropNameID::forAscii(rt, "isRunning"), 0,
144 | [task](jsi::Runtime& rt, const jsi::Value& thisVal,
145 | const jsi::Value* args,
146 | size_t count) { return jsi::Value(!task->isStopped()); });
147 |
148 | taskJS.setNativeState(rt, task);
149 |
150 | taskJS.setProperty(rt, "stop", std::move(stopTask));
151 | taskJS.setProperty(rt, "start", std::move(startTask));
152 | taskJS.setProperty(rt, "isRunning", std::move(isRunning));
153 |
154 | taskJS.setExternalMemoryPressure(rt, sizeof(Task));
155 |
156 | return taskJS;
157 | });
158 |
159 | return createTask;
160 | }
161 |
--------------------------------------------------------------------------------
/cpp/JSTask.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // JSTask2.hpp
3 | // SyncTasks
4 | //
5 | // Created by Oleksandr Shumihin on 12/4/25.
6 | //
7 |
8 | #ifndef JSTask_hpp
9 | #define JSTask_hpp
10 |
11 | #include "jsi/jsi.h"
12 | #include
13 |
14 |
15 | facebook::jsi::Function createJSTaskCreator(facebook::jsi::Runtime& rt,
16 | std::shared_ptr callInvoker);
17 |
18 | #endif /* JSTask_hpp */
19 |
--------------------------------------------------------------------------------
/cpp/constants.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // constants.hpp
3 | // Pods
4 | //
5 | // Created by Oleksandr Shumihin on 12/4/25.
6 | //
7 |
8 | #pragma once
9 |
10 | constexpr const char* LIB_NAME = "SyncTasksManager";
11 |
12 | constexpr const char* CONFIG_KEY = "config";
13 | constexpr const char* URL_KEY = "url";
14 | constexpr const char* INTERVAL_KEY = "interval";
15 | constexpr const char* HEADERS_KEY = "headers";
16 | constexpr const char* ON_DATA_KEY = "onData";
17 | constexpr const char* ON_ERROR_KEY = "onError";
18 | constexpr const char* SYNC_TASK_MANAGER_KEY = "SyncTasksManager";
19 | constexpr const char* CREATE_TASK_KEY = "createTask";
20 |
21 | constexpr const char* ADD_TASK_KEY = "addTask";
22 | constexpr const char* ADD_TASKS_KEY = "addTasks";
23 | constexpr const char* START_ALL_KEY = "startAll";
24 | constexpr const char* STOP_ALL_KEY = "stopAll";
25 |
26 | constexpr const char* FETCHER_KEY = "__fetcher";
27 |
28 | constexpr int THREADS_COUNT = 4;
29 |
--------------------------------------------------------------------------------
/cpp/core/TaskScheduler.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // TaskScheduler.cpp
3 | // intch_application
4 | //
5 | // Created by Oleksandr Shumihin on 10/4/25.
6 | // Copyright © 2025 Facebook. All rights reserved.
7 | //
8 |
9 | #pragma once
10 |
11 | #include "atomic"
12 | #include "jsi/jsi.h"
13 | #include "queue"
14 | #include "thread"
15 | #include "constants.hpp"
16 |
17 | using namespace std;
18 | using namespace facebook;
19 |
20 | class Task : public jsi::NativeState {
21 | public:
22 | Task(std::string id, int intervalMs, std::function job)
23 | : id_(std::move(id)),job_(std::move(job)), intervalMs_(intervalMs) {}
24 |
25 | ~Task() = default;
26 |
27 | void run() {
28 | if (job_ && ready_ && !stopped_)
29 | job_(*this);
30 | }
31 |
32 | const std::string& getId() const { return id_; }
33 | int getInterval() const { return intervalMs_; }
34 |
35 | void stop() { stopped_ = true; }
36 |
37 | void start() {
38 | if (ready_) {
39 | stopped_ = false;
40 | }
41 | }
42 |
43 | bool isStopped() const { return stopped_; }
44 | bool isReady() const { return ready_; }
45 |
46 | void makeReady() { ready_ = true; }
47 |
48 | void setLastBodyHash(size_t value){
49 | lastBodyHash_ = value;
50 | }
51 |
52 | bool hasSameBodyHash(size_t value) const {
53 | return lastBodyHash_ == value;
54 | }
55 |
56 | private:
57 | std::string id_;
58 | std::function job_;
59 | std::atomic stopped_ = true;
60 | size_t lastBodyHash_;
61 | int intervalMs_;
62 | bool ready_ = false;
63 | };
64 |
65 | // ========== ThreadPool ==========
66 | class ThreadPool {
67 | public:
68 | ThreadPool(size_t numThreads) {
69 | stop_ = false;
70 | for (size_t i = 0; i < numThreads; ++i) {
71 | workers_.emplace_back([this]() {
72 | while (true) {
73 | std::function task;
74 |
75 | {
76 | std::unique_lock lock(queueMutex_);
77 | cv_.wait(lock, [this]() { return stop_ || !tasks_.empty(); });
78 |
79 | if (stop_ && tasks_.empty())
80 | return;
81 |
82 | task = std::move(tasks_.front());
83 | tasks_.pop();
84 | }
85 |
86 | task();
87 | }
88 | });
89 | }
90 | }
91 |
92 | ~ThreadPool() {
93 | {
94 | std::unique_lock lock(queueMutex_);
95 | stop_ = true;
96 | }
97 | cv_.notify_all();
98 | for (auto& worker : workers_) {
99 | if (worker.joinable())
100 | worker.join();
101 | }
102 | }
103 |
104 | void enqueue(std::function job) {
105 | {
106 | std::unique_lock lock(queueMutex_);
107 | tasks_.push(std::move(job));
108 | }
109 | cv_.notify_one();
110 | }
111 |
112 | private:
113 | std::vector workers_;
114 | std::queue> tasks_;
115 | std::mutex queueMutex_;
116 | std::condition_variable cv_;
117 | bool stop_;
118 | };
119 |
120 | // ========== TaskEntry (for priority_queue) ==========
121 | struct TaskEntry {
122 | std::chrono::steady_clock::time_point nextRun;
123 | std::shared_ptr task;
124 |
125 | TaskEntry(std::chrono::steady_clock::time_point next,std::shared_ptr t):nextRun(std::move(next)), task(std::move(t)) {
126 | task->makeReady();
127 | }
128 |
129 | bool operator<(const TaskEntry& other) const {
130 | return nextRun > other.nextRun; // min-heap
131 | }
132 | };
133 |
134 | // ========== TaskScheduler ==========
135 | class TaskScheduler : public jsi::NativeState {
136 | public:
137 | TaskScheduler(int numThreads = 4) : pool_(numThreads), running_(false) {}
138 | ~TaskScheduler() { stop(); };
139 |
140 | void addTask(std::shared_ptr task) {
141 | std::unique_lock lock(mutex_);
142 |
143 | if(taskMap_.contains(task->getId())){
144 | return;
145 | }
146 |
147 | tasks_.emplace(std::chrono::steady_clock::now() +
148 | std::chrono::milliseconds(task->getInterval()),
149 | task);
150 |
151 | taskMap_[task->getId()] = task;
152 | cv_.notify_all();
153 | }
154 |
155 | void start() {
156 | if (!running_) {
157 | running_ = true;
158 | schedulerThread_ = std::thread(&TaskScheduler::schedulerLoop, this);
159 | }
160 |
161 | for (auto& [id, task] : taskMap_) {
162 | task->start();
163 | }
164 | }
165 |
166 | void stop() {
167 | {
168 | std::unique_lock lock(mutex_);
169 | running_ = false;
170 | }
171 |
172 | for (auto& [id, task] : taskMap_) {
173 | task->stop();
174 | }
175 |
176 | cv_.notify_all();
177 | if (schedulerThread_.joinable())
178 | schedulerThread_.join();
179 | }
180 |
181 | bool hasTaskWithId(const std::string& id){
182 | return taskMap_.contains(id);
183 | }
184 |
185 | private:
186 | std::priority_queue tasks_;
187 | std::unordered_map> taskMap_;
188 | std::mutex mutex_;
189 | std::condition_variable cv_;
190 | ThreadPool pool_;
191 | std::thread schedulerThread_;
192 | bool running_;
193 |
194 | void schedulerLoop() {
195 | while (running_) {
196 | std::unique_lock lock(mutex_);
197 |
198 | if (tasks_.empty()) {
199 | cv_.wait(lock);
200 | continue;
201 | }
202 |
203 | auto now = std::chrono::steady_clock::now();
204 | TaskEntry entry = tasks_.top();
205 |
206 | if (entry.nextRun <= now) {
207 | tasks_.pop();
208 |
209 | auto taskToRun = entry.task;
210 | pool_.enqueue([taskToRun]() { taskToRun->run(); });
211 |
212 | // Reschedule
213 | entry.nextRun =
214 | now + std::chrono::milliseconds(taskToRun->getInterval());
215 | tasks_.emplace(entry);
216 | } else {
217 | cv_.wait_until(lock, entry.nextRun);
218 | }
219 | }
220 | }
221 | };
222 |
--------------------------------------------------------------------------------
/cpp/fetcher.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | typedef struct {
8 | const char* key;
9 | const char* value;
10 | } Header;
11 |
12 | typedef struct {
13 | bool ok;
14 | int code;
15 | char* body;
16 | } FetchResult;
17 |
18 | FetchResult rust_fetch(const char* url, const Header* headers, int header_count);
19 | void rust_free_string(char* ptr);
20 |
21 | #ifdef __cplusplus
22 | }
23 | #endif
24 |
--------------------------------------------------------------------------------
/cpp/helpers/helpers.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // helpers.hpp
3 | // Pods
4 | //
5 | // Created by Oleksandr Shumihin on 12/4/25.
6 | //
7 |
8 | #pragma once
9 |
10 | #include "jsi/jsi.h"
11 | #include "constants.hpp"
12 |
13 |
14 | extern "C" {
15 | #include "fetcher.h"
16 | }
17 |
18 | template
19 | inline consteval auto createErrorString(const char(&str)[N]){
20 | constexpr const char prefix[] = "[SyncTasksManager]: ";
21 | constexpr size_t prefix_len = sizeof(prefix) - 1;
22 | std::array result{};
23 |
24 | for (size_t i = 0; i < prefix_len; ++i) {
25 | result[i] = prefix[i];
26 | }
27 | for (size_t i = 0; i < N; ++i) {
28 | result[prefix_len + i] = str[i];
29 | }
30 |
31 | return result;
32 | }
33 |
34 | template
35 | inline bool checkJSType(facebook::jsi::Runtime& rt, const facebook::jsi::Value& val);
36 |
37 | template<>
38 | inline bool checkJSType(facebook::jsi::Runtime& rt, const facebook::jsi::Value& val) {
39 | return val.isObject() && val.asObject(rt).isFunction(rt);
40 | };
41 |
42 | template<>
43 | inline bool checkJSType(facebook::jsi::Runtime& rt, const facebook::jsi::Value& val) {
44 | return val.isObject() && val.asObject(rt).isArray(rt);
45 | };
46 |
47 |
48 | struct CPPHeaderItem {
49 | std::string key;
50 | std::string value;
51 | };
52 |
53 | using CPPHeaders = std::vector;
54 |
55 | inline CPPHeaders getFetchHeadersFromJSObject(jsi::Runtime&rt, const jsi::Object& obj){
56 | CPPHeaders cppHeaders;
57 |
58 | jsi::Value headers = obj.getProperty(rt, HEADERS_KEY);
59 |
60 | if (headers.isObject()) {
61 | jsi::Object h = headers.asObject(rt);
62 |
63 | jsi::Array names = h.getPropertyNames(rt);
64 |
65 | cppHeaders.reserve(names.size(rt));
66 |
67 | for (int i = 0; i < names.size(rt); ++i) {
68 | jsi::Value keyValue = names.getValueAtIndex(rt, i);
69 |
70 | if (!keyValue.isString()) [[unlikely]] {
71 | throw jsi::JSError(
72 | rt,
73 | createErrorString("Invalid Header, key must be a string").data());
74 | }
75 |
76 | jsi::String key = keyValue.asString(rt);
77 |
78 | jsi::Value valValue = h.getProperty(rt, key);
79 |
80 | if (!valValue.isString()) [[unlikely]] {
81 | throw jsi::JSError(
82 | rt,
83 | createErrorString("Invalid Header, value must be a string").data());
84 | }
85 |
86 | jsi::String value = valValue.asString(rt);
87 |
88 | cppHeaders.emplace_back(key.utf8(rt),value.utf8(rt));
89 | }
90 | }
91 |
92 | return cppHeaders;
93 | }
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/cpp/react-native-sync-tasks.cpp:
--------------------------------------------------------------------------------
1 | #include "react-native-sync-tasks.hpp"
2 | #include "JSManager.hpp"
3 | #include "JSTask.hpp"
4 | #include "constants.hpp"
5 |
6 |
7 | using namespace sh;
8 | using namespace facebook;
9 | using namespace std;
10 |
11 |
12 | void synctasks::install(jsi::Runtime* rt,
13 | std::shared_ptr callInvoker
14 | ) {
15 | jsi::Runtime& runtime = *rt;
16 |
17 |
18 | jsi::Object jsTaskManager = createJSTaskManager(runtime);
19 |
20 | jsi::Function taskCreator = createJSTaskCreator(runtime, callInvoker);
21 |
22 | runtime.global().setProperty(runtime, SYNC_TASK_MANAGER_KEY,
23 | std::move(jsTaskManager));
24 |
25 | runtime.global().setProperty(runtime, CREATE_TASK_KEY,
26 | std::move(taskCreator));
27 |
28 | runtime.global().setProperty(runtime, CREATE_TASK_KEY,
29 | std::move(taskCreator));
30 | }
31 |
--------------------------------------------------------------------------------
/cpp/react-native-sync-tasks.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SYNCTASKS_H
2 | #define SYNCTASKS_H
3 |
4 | #import "jsi/jsi.h"
5 | #include
6 |
7 |
8 |
9 | namespace sh::synctasks {
10 |
11 | using namespace std;
12 | using namespace facebook;
13 |
14 | void install(jsi::Runtime* rt,
15 | std::shared_ptr callInvoker);
16 |
17 | }
18 |
19 | #endif /* SYNCTASKS_H */
20 |
--------------------------------------------------------------------------------
/eslint.config.mjs:
--------------------------------------------------------------------------------
1 | import { fixupConfigRules } from '@eslint/compat';
2 | import { FlatCompat } from '@eslint/eslintrc';
3 | import js from '@eslint/js';
4 | import prettier from 'eslint-plugin-prettier';
5 | import { defineConfig } from 'eslint/config';
6 | import path from 'node:path';
7 | import { fileURLToPath } from 'node:url';
8 |
9 | const __filename = fileURLToPath(import.meta.url);
10 | const __dirname = path.dirname(__filename);
11 | const compat = new FlatCompat({
12 | baseDirectory: __dirname,
13 | recommendedConfig: js.configs.recommended,
14 | allConfig: js.configs.all,
15 | });
16 |
17 | export default defineConfig([
18 | {
19 | extends: fixupConfigRules(compat.extends('@react-native', 'prettier')),
20 | plugins: { prettier },
21 | rules: {
22 | 'react/react-in-jsx-scope': 'off',
23 | 'prettier/prettier': [
24 | 'error',
25 | {
26 | quoteProps: 'consistent',
27 | singleQuote: true,
28 | tabWidth: 2,
29 | trailingComma: 'es5',
30 | useTabs: false,
31 | },
32 | ],
33 | },
34 | },
35 | {
36 | ignores: [
37 | 'node_modules/',
38 | 'lib/'
39 | ],
40 | },
41 | ]);
42 |
--------------------------------------------------------------------------------
/example/.bundle/config:
--------------------------------------------------------------------------------
1 | BUNDLE_PATH: "vendor/bundle"
2 | BUNDLE_FORCE_RUBY_PLATFORM: 1
3 |
--------------------------------------------------------------------------------
/example/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/example/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4 | ruby ">= 2.6.10"
5 |
6 | # Exclude problematic versions of cocoapods and activesupport that causes build failures.
7 | gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
8 | gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
9 | gem 'xcodeproj', '< 1.26.0'
10 | gem 'concurrent-ruby', '< 1.3.4'
11 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
2 |
3 | # Getting Started
4 |
5 | > **Note**: Make sure you have completed the [Set Up Your Environment](https://reactnative.dev/docs/set-up-your-environment) guide before proceeding.
6 |
7 | ## Step 1: Start Metro
8 |
9 | First, you will need to run **Metro**, the JavaScript build tool for React Native.
10 |
11 | To start the Metro dev server, run the following command from the root of your React Native project:
12 |
13 | ```sh
14 | # Using npm
15 | npm start
16 |
17 | # OR using Yarn
18 | yarn start
19 | ```
20 |
21 | ## Step 2: Build and run your app
22 |
23 | With Metro running, open a new terminal window/pane from the root of your React Native project, and use one of the following commands to build and run your Android or iOS app:
24 |
25 | ### Android
26 |
27 | ```sh
28 | # Using npm
29 | npm run android
30 |
31 | # OR using Yarn
32 | yarn android
33 | ```
34 |
35 | ### iOS
36 |
37 | For iOS, remember to install CocoaPods dependencies (this only needs to be run on first clone or after updating native deps).
38 |
39 | The first time you create a new project, run the Ruby bundler to install CocoaPods itself:
40 |
41 | ```sh
42 | bundle install
43 | ```
44 |
45 | Then, and every time you update your native dependencies, run:
46 |
47 | ```sh
48 | bundle exec pod install
49 | ```
50 |
51 | For more information, please visit [CocoaPods Getting Started guide](https://guides.cocoapods.org/using/getting-started.html).
52 |
53 | ```sh
54 | # Using npm
55 | npm run ios
56 |
57 | # OR using Yarn
58 | yarn ios
59 | ```
60 |
61 | If everything is set up correctly, you should see your new app running in the Android Emulator, iOS Simulator, or your connected device.
62 |
63 | This is one way to run your app — you can also build it directly from Android Studio or Xcode.
64 |
65 | ## Step 3: Modify your app
66 |
67 | Now that you have successfully run the app, let's make changes!
68 |
69 | Open `App.tsx` in your text editor of choice and make some changes. When you save, your app will automatically update and reflect these changes — this is powered by [Fast Refresh](https://reactnative.dev/docs/fast-refresh).
70 |
71 | When you want to forcefully reload, for example to reset the state of your app, you can perform a full reload:
72 |
73 | - **Android**: Press the R key twice or select **"Reload"** from the **Dev Menu**, accessed via Ctrl + M (Windows/Linux) or Cmd ⌘ + M (macOS).
74 | - **iOS**: Press R in iOS Simulator.
75 |
76 | ## Congratulations! :tada:
77 |
78 | You've successfully run and modified your React Native App. :partying_face:
79 |
80 | ### Now what?
81 |
82 | - If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
83 | - If you're curious to learn more about React Native, check out the [docs](https://reactnative.dev/docs/getting-started).
84 |
85 | # Troubleshooting
86 |
87 | If you're having issues getting the above steps to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
88 |
89 | # Learn More
90 |
91 | To learn more about React Native, take a look at the following resources:
92 |
93 | - [React Native Website](https://reactnative.dev) - learn more about React Native.
94 | - [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
95 | - [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
96 | - [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
97 | - [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
98 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.android.application"
2 | apply plugin: "org.jetbrains.kotlin.android"
3 | apply plugin: "com.facebook.react"
4 |
5 | /**
6 | * This is the configuration block to customize your React Native Android app.
7 | * By default you don't need to apply any configuration, just uncomment the lines you need.
8 | */
9 | react {
10 | /* Folders */
11 | // The root of your project, i.e. where "package.json" lives. Default is '../..'
12 | // root = file("../../")
13 | // The folder where the react-native NPM package is. Default is ../../node_modules/react-native
14 | // reactNativeDir = file("../../node_modules/react-native")
15 | // The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
16 | // codegenDir = file("../../node_modules/@react-native/codegen")
17 | // The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
18 | // cliFile = file("../../node_modules/react-native/cli.js")
19 |
20 | /* Variants */
21 | // The list of variants to that are debuggable. For those we're going to
22 | // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
23 | // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
24 | // debuggableVariants = ["liteDebug", "prodDebug"]
25 |
26 | /* Bundling */
27 | // A list containing the node command and its flags. Default is just 'node'.
28 | // nodeExecutableAndArgs = ["node"]
29 | //
30 | // The command to run when bundling. By default is 'bundle'
31 | // bundleCommand = "ram-bundle"
32 | //
33 | // The path to the CLI configuration file. Default is empty.
34 | // bundleConfig = file(../rn-cli.config.js)
35 | //
36 | // The name of the generated asset file containing your JS bundle
37 | // bundleAssetName = "MyApplication.android.bundle"
38 | //
39 | // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
40 | // entryFile = file("../js/MyApplication.android.js")
41 | //
42 | // A list of extra flags to pass to the 'bundle' commands.
43 | // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
44 | // extraPackagerArgs = []
45 |
46 | /* Hermes Commands */
47 | // The hermes compiler command to run. By default it is 'hermesc'
48 | // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
49 | //
50 | // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
51 | // hermesFlags = ["-O", "-output-source-map"]
52 |
53 | /* Autolinking */
54 | autolinkLibrariesWithApp()
55 | }
56 |
57 | /**
58 | * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
59 | */
60 | def enableProguardInReleaseBuilds = false
61 |
62 | /**
63 | * The preferred build flavor of JavaScriptCore (JSC)
64 | *
65 | * For example, to use the international variant, you can use:
66 | * `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
67 | *
68 | * The international variant includes ICU i18n library and necessary data
69 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
70 | * give correct results when using with locales other than en-US. Note that
71 | * this variant is about 6MiB larger per architecture than default.
72 | */
73 | def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+'
74 |
75 | android {
76 | ndkVersion rootProject.ext.ndkVersion
77 | buildToolsVersion rootProject.ext.buildToolsVersion
78 | compileSdk rootProject.ext.compileSdkVersion
79 |
80 | namespace "synctasks.example"
81 | defaultConfig {
82 | applicationId "synctasks.example"
83 | minSdkVersion rootProject.ext.minSdkVersion
84 | targetSdkVersion rootProject.ext.targetSdkVersion
85 | versionCode 1
86 | versionName "1.0"
87 | }
88 | signingConfigs {
89 | debug {
90 | storeFile file('debug.keystore')
91 | storePassword 'android'
92 | keyAlias 'androiddebugkey'
93 | keyPassword 'android'
94 | }
95 | }
96 | buildTypes {
97 | debug {
98 | signingConfig signingConfigs.debug
99 | }
100 | release {
101 | // Caution! In production, you need to generate your own keystore file.
102 | // see https://reactnative.dev/docs/signed-apk-android.
103 | signingConfig signingConfigs.debug
104 | minifyEnabled enableProguardInReleaseBuilds
105 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
106 | }
107 | }
108 | }
109 |
110 | dependencies {
111 | // The version of react-native is set by the React Native Gradle Plugin
112 | implementation("com.facebook.react:react-android")
113 |
114 | if (hermesEnabled.toBoolean()) {
115 | implementation("com.facebook.react:hermes-android")
116 | } else {
117 | implementation jscFlavor
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/example/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/debug.keystore
--------------------------------------------------------------------------------
/example/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/synctasks/example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package synctasks.example
2 |
3 | import com.facebook.react.ReactActivity
4 | import com.facebook.react.ReactActivityDelegate
5 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
6 | import com.facebook.react.defaults.DefaultReactActivityDelegate
7 |
8 | class MainActivity : ReactActivity() {
9 |
10 | /**
11 | * Returns the name of the main component registered from JavaScript. This is used to schedule
12 | * rendering of the component.
13 | */
14 | override fun getMainComponentName(): String = "SyncTasksExample"
15 |
16 | /**
17 | * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
18 | * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
19 | */
20 | override fun createReactActivityDelegate(): ReactActivityDelegate =
21 | DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
22 | }
23 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/synctasks/example/MainApplication.kt:
--------------------------------------------------------------------------------
1 | package synctasks.example
2 |
3 | import android.app.Application
4 | import com.facebook.react.PackageList
5 | import com.facebook.react.ReactApplication
6 | import com.facebook.react.ReactHost
7 | import com.facebook.react.ReactNativeHost
8 | import com.facebook.react.ReactPackage
9 | import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
10 | import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
11 | import com.facebook.react.defaults.DefaultReactNativeHost
12 | import com.facebook.react.soloader.OpenSourceMergedSoMapping
13 | import com.facebook.soloader.SoLoader
14 | import com.synctasks.SyncTasksPackage
15 |
16 | class MainApplication : Application(), ReactApplication {
17 |
18 | override val reactNativeHost: ReactNativeHost =
19 | object : DefaultReactNativeHost(this) {
20 | override fun getPackages(): List =
21 | PackageList(this).packages.apply {
22 | // Packages that cannot be autolinked yet can be added manually here, for example:
23 | add(SyncTasksPackage())
24 | }
25 |
26 | override fun getJSMainModuleName(): String = "index"
27 |
28 | override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
29 |
30 | override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
31 | override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
32 | }
33 |
34 | override val reactHost: ReactHost
35 | get() = getDefaultReactHost(applicationContext, reactNativeHost)
36 |
37 | override fun onCreate() {
38 | super.onCreate()
39 | SoLoader.init(this, OpenSourceMergedSoMapping)
40 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
41 | // If you opted-in for the New Architecture, we load the native entry point for this app.
42 | load()
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/rn_edit_text_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
22 |
23 |
24 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SyncTasksExample
3 |
4 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | buildToolsVersion = "35.0.0"
4 | minSdkVersion = 24
5 | compileSdkVersion = 35
6 | targetSdkVersion = 35
7 | ndkVersion = "27.1.12297006"
8 | kotlinVersion = "2.0.21"
9 | }
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | dependencies {
15 | classpath("com.android.tools.build:gradle")
16 | classpath("com.facebook.react:react-native-gradle-plugin")
17 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
18 | }
19 | }
20 |
21 | apply plugin: "com.facebook.react.rootproject"
22 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | # AndroidX package structure to make it clearer which packages are bundled with the
21 | # Android operating system, and which are packaged with your app's APK
22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
23 | android.useAndroidX=true
24 |
25 | # Use this property to specify which architecture you want to build.
26 | # You can also override it from the CLI using
27 | # ./gradlew -PreactNativeArchitectures=x86_64
28 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
29 |
30 | # Use this property to enable support to the new architecture.
31 | # This will allow you to use TurboModules and the Fabric render in
32 | # your application. You should enable this flag either if you want
33 | # to write custom TurboModules/Fabric components OR use libraries that
34 | # are providing them.
35 | newArchEnabled=true
36 |
37 | # Use this property to enable or disable the Hermes JS engine.
38 | # If set to false, you will be using JSC instead.
39 | hermesEnabled=true
40 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/example/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/example/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | if ! command -v java >/dev/null 2>&1
137 | then
138 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139 |
140 | Please set the JAVA_HOME variable in your environment to match the
141 | location of your Java installation."
142 | fi
143 | fi
144 |
145 | # Increase the maximum file descriptors if we can.
146 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147 | case $MAX_FD in #(
148 | max*)
149 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150 | # shellcheck disable=SC2039,SC3045
151 | MAX_FD=$( ulimit -H -n ) ||
152 | warn "Could not query maximum file descriptor limit"
153 | esac
154 | case $MAX_FD in #(
155 | '' | soft) :;; #(
156 | *)
157 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158 | # shellcheck disable=SC2039,SC3045
159 | ulimit -n "$MAX_FD" ||
160 | warn "Could not set maximum file descriptor limit to $MAX_FD"
161 | esac
162 | fi
163 |
164 | # Collect all arguments for the java command, stacking in reverse order:
165 | # * args from the command line
166 | # * the main class name
167 | # * -classpath
168 | # * -D...appname settings
169 | # * --module-path (only if needed)
170 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
171 |
172 | # For Cygwin or MSYS, switch paths to Windows format before running java
173 | if "$cygwin" || "$msys" ; then
174 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176 |
177 | JAVACMD=$( cygpath --unix "$JAVACMD" )
178 |
179 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
180 | for arg do
181 | if
182 | case $arg in #(
183 | -*) false ;; # don't mess with options #(
184 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185 | [ -e "$t" ] ;; #(
186 | *) false ;;
187 | esac
188 | then
189 | arg=$( cygpath --path --ignore --mixed "$arg" )
190 | fi
191 | # Roll the args list around exactly as many times as the number of
192 | # args, so each arg winds up back in the position where it started, but
193 | # possibly modified.
194 | #
195 | # NB: a `for` loop captures its iteration list before it begins, so
196 | # changing the positional parameters here affects neither the number of
197 | # iterations, nor the values presented in `arg`.
198 | shift # remove old arg
199 | set -- "$@" "$arg" # push replacement arg
200 | done
201 | fi
202 |
203 |
204 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206 |
207 | # Collect all arguments for the java command:
208 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209 | # and any embedded shellness will be escaped.
210 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211 | # treated as '${Hostname}' itself on the command line.
212 |
213 | set -- \
214 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
215 | -classpath "$CLASSPATH" \
216 | org.gradle.wrapper.GradleWrapperMain \
217 | "$@"
218 |
219 | # Stop when "xargs" is not available.
220 | if ! command -v xargs >/dev/null 2>&1
221 | then
222 | die "xargs is not available"
223 | fi
224 |
225 | # Use "xargs" to parse quoted args.
226 | #
227 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228 | #
229 | # In Bash we could simply go:
230 | #
231 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232 | # set -- "${ARGS[@]}" "$@"
233 | #
234 | # but POSIX shell has neither arrays nor command substitution, so instead we
235 | # post-process each arg (as a line of input to sed) to backslash-escape any
236 | # character that might be a shell metacharacter, then use eval to reverse
237 | # that process (while maintaining the separation between arguments), and wrap
238 | # the whole thing up as a single "set" statement.
239 | #
240 | # This will of course break if any of these variables contains a newline or
241 | # an unmatched quote.
242 | #
243 |
244 | eval "set -- $(
245 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246 | xargs -n1 |
247 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248 | tr '\n' ' '
249 | )" '"$@"'
250 |
251 | exec "$JAVACMD" "$@"
252 |
--------------------------------------------------------------------------------
/example/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
2 | plugins { id("com.facebook.react.settings") }
3 | extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
4 | rootProject.name = 'synctasks.example'
5 | include ':app'
6 | includeBuild('../node_modules/@react-native/gradle-plugin')
7 |
--------------------------------------------------------------------------------
/example/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "SyncTasksExample",
3 | "displayName": "SyncTasksExample"
4 | }
5 |
--------------------------------------------------------------------------------
/example/babel.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const { getConfig } = require('react-native-builder-bob/babel-config');
3 | const pkg = require('../package.json');
4 |
5 | const root = path.resolve(__dirname, '..');
6 |
7 | module.exports = getConfig(
8 | {
9 | presets: ['module:@react-native/babel-preset'],
10 | },
11 | { root, pkg }
12 | );
13 |
--------------------------------------------------------------------------------
/example/index.js:
--------------------------------------------------------------------------------
1 | import { AppRegistry } from 'react-native';
2 | import App from './src/App';
3 | import { name as appName } from './app.json';
4 |
5 | AppRegistry.registerComponent(appName, () => App);
6 |
--------------------------------------------------------------------------------
/example/ios/.xcode.env:
--------------------------------------------------------------------------------
1 | # This `.xcode.env` file is versioned and is used to source the environment
2 | # used when running script phases inside Xcode.
3 | # To customize your local environment, you can create an `.xcode.env.local`
4 | # file that is not versioned.
5 |
6 | # NODE_BINARY variable contains the PATH to the node executable.
7 | #
8 | # Customize the NODE_BINARY variable here.
9 | # For example, to use nvm with brew, add the following line
10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use
11 | export NODE_BINARY=$(command -v node)
12 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Resolve react_native_pods.rb with node to allow for hoisting
2 | require Pod::Executable.execute_command('node', ['-p',
3 | 'require.resolve(
4 | "react-native/scripts/react_native_pods.rb",
5 | {paths: [process.argv[1]]},
6 | )', __dir__]).strip
7 |
8 | platform :ios, min_ios_version_supported
9 | prepare_react_native_project!
10 |
11 | linkage = ENV['USE_FRAMEWORKS']
12 | if linkage != nil
13 | Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
14 | use_frameworks! :linkage => linkage.to_sym
15 | end
16 |
17 | target 'SyncTasksExample' do
18 | config = use_native_modules!
19 |
20 | use_react_native!(
21 | :path => config[:reactNativePath],
22 | # An absolute path to your application root.
23 | :app_path => "#{Pod::Config.instance.installation_root}/.."
24 | )
25 |
26 | post_install do |installer|
27 | # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
28 | react_native_post_install(
29 | installer,
30 | config[:reactNativePath],
31 | :mac_catalyst_enabled => false,
32 | # :ccache_enabled => true
33 | )
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/example/ios/SyncTasksExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 54;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 0C80B921A6F3F58F76C31292 /* libPods-SyncTasksExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DCACB8F33CDC322A6C60F78 /* libPods-SyncTasksExample.a */; };
11 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
12 | 761780ED2CA45674006654EE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 761780EC2CA45674006654EE /* AppDelegate.swift */; };
13 | 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
14 | 8792A5FAE3D66D6F29E27D41 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */; };
15 | /* End PBXBuildFile section */
16 |
17 | /* Begin PBXFileReference section */
18 | 13B07F961A680F5B00A75B9A /* SyncTasksExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SyncTasksExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
19 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = SyncTasksExample/Images.xcassets; sourceTree = ""; };
20 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = SyncTasksExample/Info.plist; sourceTree = ""; };
21 | 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = SyncTasksExample/PrivacyInfo.xcprivacy; sourceTree = ""; };
22 | 3B4392A12AC88292D35C810B /* Pods-SyncTasksExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SyncTasksExample.debug.xcconfig"; path = "Target Support Files/Pods-SyncTasksExample/Pods-SyncTasksExample.debug.xcconfig"; sourceTree = ""; };
23 | 5709B34CF0A7D63546082F79 /* Pods-SyncTasksExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SyncTasksExample.release.xcconfig"; path = "Target Support Files/Pods-SyncTasksExample/Pods-SyncTasksExample.release.xcconfig"; sourceTree = ""; };
24 | 5DCACB8F33CDC322A6C60F78 /* libPods-SyncTasksExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SyncTasksExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
25 | 761780EC2CA45674006654EE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = SyncTasksExample/AppDelegate.swift; sourceTree = ""; };
26 | 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = SyncTasksExample/LaunchScreen.storyboard; sourceTree = ""; };
27 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
28 | /* End PBXFileReference section */
29 |
30 | /* Begin PBXFrameworksBuildPhase section */
31 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = {
32 | isa = PBXFrameworksBuildPhase;
33 | buildActionMask = 2147483647;
34 | files = (
35 | 0C80B921A6F3F58F76C31292 /* libPods-SyncTasksExample.a in Frameworks */,
36 | );
37 | runOnlyForDeploymentPostprocessing = 0;
38 | };
39 | /* End PBXFrameworksBuildPhase section */
40 |
41 | /* Begin PBXGroup section */
42 | 13B07FAE1A68108700A75B9A /* SyncTasksExample */ = {
43 | isa = PBXGroup;
44 | children = (
45 | 13B07FB51A68108700A75B9A /* Images.xcassets */,
46 | 761780EC2CA45674006654EE /* AppDelegate.swift */,
47 | 13B07FB61A68108700A75B9A /* Info.plist */,
48 | 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
49 | 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */,
50 | );
51 | name = SyncTasksExample;
52 | sourceTree = "";
53 | };
54 | 2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
55 | isa = PBXGroup;
56 | children = (
57 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
58 | 5DCACB8F33CDC322A6C60F78 /* libPods-SyncTasksExample.a */,
59 | );
60 | name = Frameworks;
61 | sourceTree = "";
62 | };
63 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = {
64 | isa = PBXGroup;
65 | children = (
66 | );
67 | name = Libraries;
68 | sourceTree = "";
69 | };
70 | 83CBB9F61A601CBA00E9B192 = {
71 | isa = PBXGroup;
72 | children = (
73 | 13B07FAE1A68108700A75B9A /* SyncTasksExample */,
74 | 832341AE1AAA6A7D00B99B32 /* Libraries */,
75 | 83CBBA001A601CBA00E9B192 /* Products */,
76 | 2D16E6871FA4F8E400B85C8A /* Frameworks */,
77 | BBD78D7AC51CEA395F1C20DB /* Pods */,
78 | );
79 | indentWidth = 2;
80 | sourceTree = "";
81 | tabWidth = 2;
82 | usesTabs = 0;
83 | };
84 | 83CBBA001A601CBA00E9B192 /* Products */ = {
85 | isa = PBXGroup;
86 | children = (
87 | 13B07F961A680F5B00A75B9A /* SyncTasksExample.app */,
88 | );
89 | name = Products;
90 | sourceTree = "";
91 | };
92 | BBD78D7AC51CEA395F1C20DB /* Pods */ = {
93 | isa = PBXGroup;
94 | children = (
95 | 3B4392A12AC88292D35C810B /* Pods-SyncTasksExample.debug.xcconfig */,
96 | 5709B34CF0A7D63546082F79 /* Pods-SyncTasksExample.release.xcconfig */,
97 | );
98 | path = Pods;
99 | sourceTree = "";
100 | };
101 | /* End PBXGroup section */
102 |
103 | /* Begin PBXNativeTarget section */
104 | 13B07F861A680F5B00A75B9A /* SyncTasksExample */ = {
105 | isa = PBXNativeTarget;
106 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "SyncTasksExample" */;
107 | buildPhases = (
108 | C38B50BA6285516D6DCD4F65 /* [CP] Check Pods Manifest.lock */,
109 | 13B07F871A680F5B00A75B9A /* Sources */,
110 | 13B07F8C1A680F5B00A75B9A /* Frameworks */,
111 | 13B07F8E1A680F5B00A75B9A /* Resources */,
112 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
113 | 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */,
114 | E235C05ADACE081382539298 /* [CP] Copy Pods Resources */,
115 | );
116 | buildRules = (
117 | );
118 | dependencies = (
119 | );
120 | name = SyncTasksExample;
121 | productName = SyncTasksExample;
122 | productReference = 13B07F961A680F5B00A75B9A /* SyncTasksExample.app */;
123 | productType = "com.apple.product-type.application";
124 | };
125 | /* End PBXNativeTarget section */
126 |
127 | /* Begin PBXProject section */
128 | 83CBB9F71A601CBA00E9B192 /* Project object */ = {
129 | isa = PBXProject;
130 | attributes = {
131 | LastUpgradeCheck = 1210;
132 | TargetAttributes = {
133 | 13B07F861A680F5B00A75B9A = {
134 | LastSwiftMigration = 1120;
135 | };
136 | };
137 | };
138 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "SyncTasksExample" */;
139 | compatibilityVersion = "Xcode 12.0";
140 | developmentRegion = en;
141 | hasScannedForEncodings = 0;
142 | knownRegions = (
143 | en,
144 | Base,
145 | );
146 | mainGroup = 83CBB9F61A601CBA00E9B192;
147 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
148 | projectDirPath = "";
149 | projectRoot = "";
150 | targets = (
151 | 13B07F861A680F5B00A75B9A /* SyncTasksExample */,
152 | );
153 | };
154 | /* End PBXProject section */
155 |
156 | /* Begin PBXResourcesBuildPhase section */
157 | 13B07F8E1A680F5B00A75B9A /* Resources */ = {
158 | isa = PBXResourcesBuildPhase;
159 | buildActionMask = 2147483647;
160 | files = (
161 | 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
162 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
163 | 8792A5FAE3D66D6F29E27D41 /* PrivacyInfo.xcprivacy in Resources */,
164 | );
165 | runOnlyForDeploymentPostprocessing = 0;
166 | };
167 | /* End PBXResourcesBuildPhase section */
168 |
169 | /* Begin PBXShellScriptBuildPhase section */
170 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
171 | isa = PBXShellScriptBuildPhase;
172 | buildActionMask = 2147483647;
173 | files = (
174 | );
175 | inputPaths = (
176 | "$(SRCROOT)/.xcode.env.local",
177 | "$(SRCROOT)/.xcode.env",
178 | );
179 | name = "Bundle React Native code and images";
180 | outputPaths = (
181 | );
182 | runOnlyForDeploymentPostprocessing = 0;
183 | shellPath = /bin/sh;
184 | shellScript = "set -e\n\nWITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"$REACT_NATIVE_PATH/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
185 | };
186 | 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
187 | isa = PBXShellScriptBuildPhase;
188 | buildActionMask = 2147483647;
189 | files = (
190 | );
191 | inputFileListPaths = (
192 | "${PODS_ROOT}/Target Support Files/Pods-SyncTasksExample/Pods-SyncTasksExample-frameworks-${CONFIGURATION}-input-files.xcfilelist",
193 | );
194 | name = "[CP] Embed Pods Frameworks";
195 | outputFileListPaths = (
196 | "${PODS_ROOT}/Target Support Files/Pods-SyncTasksExample/Pods-SyncTasksExample-frameworks-${CONFIGURATION}-output-files.xcfilelist",
197 | );
198 | runOnlyForDeploymentPostprocessing = 0;
199 | shellPath = /bin/sh;
200 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SyncTasksExample/Pods-SyncTasksExample-frameworks.sh\"\n";
201 | showEnvVarsInLog = 0;
202 | };
203 | C38B50BA6285516D6DCD4F65 /* [CP] Check Pods Manifest.lock */ = {
204 | isa = PBXShellScriptBuildPhase;
205 | buildActionMask = 2147483647;
206 | files = (
207 | );
208 | inputFileListPaths = (
209 | );
210 | inputPaths = (
211 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
212 | "${PODS_ROOT}/Manifest.lock",
213 | );
214 | name = "[CP] Check Pods Manifest.lock";
215 | outputFileListPaths = (
216 | );
217 | outputPaths = (
218 | "$(DERIVED_FILE_DIR)/Pods-SyncTasksExample-checkManifestLockResult.txt",
219 | );
220 | runOnlyForDeploymentPostprocessing = 0;
221 | shellPath = /bin/sh;
222 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
223 | showEnvVarsInLog = 0;
224 | };
225 | E235C05ADACE081382539298 /* [CP] Copy Pods Resources */ = {
226 | isa = PBXShellScriptBuildPhase;
227 | buildActionMask = 2147483647;
228 | files = (
229 | );
230 | inputFileListPaths = (
231 | "${PODS_ROOT}/Target Support Files/Pods-SyncTasksExample/Pods-SyncTasksExample-resources-${CONFIGURATION}-input-files.xcfilelist",
232 | );
233 | name = "[CP] Copy Pods Resources";
234 | outputFileListPaths = (
235 | "${PODS_ROOT}/Target Support Files/Pods-SyncTasksExample/Pods-SyncTasksExample-resources-${CONFIGURATION}-output-files.xcfilelist",
236 | );
237 | runOnlyForDeploymentPostprocessing = 0;
238 | shellPath = /bin/sh;
239 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SyncTasksExample/Pods-SyncTasksExample-resources.sh\"\n";
240 | showEnvVarsInLog = 0;
241 | };
242 | /* End PBXShellScriptBuildPhase section */
243 |
244 | /* Begin PBXSourcesBuildPhase section */
245 | 13B07F871A680F5B00A75B9A /* Sources */ = {
246 | isa = PBXSourcesBuildPhase;
247 | buildActionMask = 2147483647;
248 | files = (
249 | 761780ED2CA45674006654EE /* AppDelegate.swift in Sources */,
250 | );
251 | runOnlyForDeploymentPostprocessing = 0;
252 | };
253 | /* End PBXSourcesBuildPhase section */
254 |
255 | /* Begin XCBuildConfiguration section */
256 | 13B07F941A680F5B00A75B9A /* Debug */ = {
257 | isa = XCBuildConfiguration;
258 | baseConfigurationReference = 3B4392A12AC88292D35C810B /* Pods-SyncTasksExample.debug.xcconfig */;
259 | buildSettings = {
260 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
261 | CLANG_ENABLE_MODULES = YES;
262 | CURRENT_PROJECT_VERSION = 1;
263 | ENABLE_BITCODE = NO;
264 | INFOPLIST_FILE = SyncTasksExample/Info.plist;
265 | IPHONEOS_DEPLOYMENT_TARGET = 15.1;
266 | LD_RUNPATH_SEARCH_PATHS = (
267 | "$(inherited)",
268 | "@executable_path/Frameworks",
269 | );
270 | MARKETING_VERSION = 1.0;
271 | OTHER_LDFLAGS = (
272 | "$(inherited)",
273 | "-ObjC",
274 | "-lc++",
275 | );
276 | PRODUCT_BUNDLE_IDENTIFIER = synctasks.example;
277 | PRODUCT_NAME = SyncTasksExample;
278 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
279 | SWIFT_VERSION = 5.0;
280 | VERSIONING_SYSTEM = "apple-generic";
281 | };
282 | name = Debug;
283 | };
284 | 13B07F951A680F5B00A75B9A /* Release */ = {
285 | isa = XCBuildConfiguration;
286 | baseConfigurationReference = 5709B34CF0A7D63546082F79 /* Pods-SyncTasksExample.release.xcconfig */;
287 | buildSettings = {
288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
289 | CLANG_ENABLE_MODULES = YES;
290 | CURRENT_PROJECT_VERSION = 1;
291 | INFOPLIST_FILE = SyncTasksExample/Info.plist;
292 | IPHONEOS_DEPLOYMENT_TARGET = 15.1;
293 | LD_RUNPATH_SEARCH_PATHS = (
294 | "$(inherited)",
295 | "@executable_path/Frameworks",
296 | );
297 | MARKETING_VERSION = 1.0;
298 | OTHER_LDFLAGS = (
299 | "$(inherited)",
300 | "-ObjC",
301 | "-lc++",
302 | );
303 | PRODUCT_BUNDLE_IDENTIFIER = synctasks.example;
304 | PRODUCT_NAME = SyncTasksExample;
305 | SWIFT_VERSION = 5.0;
306 | VERSIONING_SYSTEM = "apple-generic";
307 | };
308 | name = Release;
309 | };
310 | 83CBBA201A601CBA00E9B192 /* Debug */ = {
311 | isa = XCBuildConfiguration;
312 | buildSettings = {
313 | ALWAYS_SEARCH_USER_PATHS = NO;
314 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
315 | CLANG_CXX_LANGUAGE_STANDARD = "c++20";
316 | CLANG_CXX_LIBRARY = "libc++";
317 | CLANG_ENABLE_MODULES = YES;
318 | CLANG_ENABLE_OBJC_ARC = YES;
319 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
320 | CLANG_WARN_BOOL_CONVERSION = YES;
321 | CLANG_WARN_COMMA = YES;
322 | CLANG_WARN_CONSTANT_CONVERSION = YES;
323 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
324 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
325 | CLANG_WARN_EMPTY_BODY = YES;
326 | CLANG_WARN_ENUM_CONVERSION = YES;
327 | CLANG_WARN_INFINITE_RECURSION = YES;
328 | CLANG_WARN_INT_CONVERSION = YES;
329 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
330 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
331 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
332 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
333 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
334 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
335 | CLANG_WARN_STRICT_PROTOTYPES = YES;
336 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
337 | CLANG_WARN_UNREACHABLE_CODE = YES;
338 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
339 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
340 | COPY_PHASE_STRIP = NO;
341 | ENABLE_STRICT_OBJC_MSGSEND = YES;
342 | ENABLE_TESTABILITY = YES;
343 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
344 | GCC_C_LANGUAGE_STANDARD = gnu99;
345 | GCC_DYNAMIC_NO_PIC = NO;
346 | GCC_NO_COMMON_BLOCKS = YES;
347 | GCC_OPTIMIZATION_LEVEL = 0;
348 | GCC_PREPROCESSOR_DEFINITIONS = (
349 | "DEBUG=1",
350 | "$(inherited)",
351 | );
352 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
353 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
354 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
355 | GCC_WARN_UNDECLARED_SELECTOR = YES;
356 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
357 | GCC_WARN_UNUSED_FUNCTION = YES;
358 | GCC_WARN_UNUSED_VARIABLE = YES;
359 | IPHONEOS_DEPLOYMENT_TARGET = 15.1;
360 | LD_RUNPATH_SEARCH_PATHS = (
361 | /usr/lib/swift,
362 | "$(inherited)",
363 | );
364 | LIBRARY_SEARCH_PATHS = (
365 | "\"$(SDKROOT)/usr/lib/swift\"",
366 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
367 | "\"$(inherited)\"",
368 | );
369 | MTL_ENABLE_DEBUG_INFO = YES;
370 | ONLY_ACTIVE_ARCH = YES;
371 | OTHER_CPLUSPLUSFLAGS = (
372 | "$(OTHER_CFLAGS)",
373 | "-DFOLLY_NO_CONFIG",
374 | "-DFOLLY_MOBILE=1",
375 | "-DFOLLY_USE_LIBCPP=1",
376 | "-DFOLLY_CFG_NO_COROUTINES=1",
377 | "-DFOLLY_HAVE_CLOCK_GETTIME=1",
378 | );
379 | OTHER_LDFLAGS = (
380 | "$(inherited)",
381 | " ",
382 | );
383 | REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
384 | SDKROOT = iphoneos;
385 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
386 | USE_HERMES = true;
387 | };
388 | name = Debug;
389 | };
390 | 83CBBA211A601CBA00E9B192 /* Release */ = {
391 | isa = XCBuildConfiguration;
392 | buildSettings = {
393 | ALWAYS_SEARCH_USER_PATHS = NO;
394 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
395 | CLANG_CXX_LANGUAGE_STANDARD = "c++20";
396 | CLANG_CXX_LIBRARY = "libc++";
397 | CLANG_ENABLE_MODULES = YES;
398 | CLANG_ENABLE_OBJC_ARC = YES;
399 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
400 | CLANG_WARN_BOOL_CONVERSION = YES;
401 | CLANG_WARN_COMMA = YES;
402 | CLANG_WARN_CONSTANT_CONVERSION = YES;
403 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
404 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
405 | CLANG_WARN_EMPTY_BODY = YES;
406 | CLANG_WARN_ENUM_CONVERSION = YES;
407 | CLANG_WARN_INFINITE_RECURSION = YES;
408 | CLANG_WARN_INT_CONVERSION = YES;
409 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
410 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
411 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
412 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
413 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
414 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
415 | CLANG_WARN_STRICT_PROTOTYPES = YES;
416 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
417 | CLANG_WARN_UNREACHABLE_CODE = YES;
418 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
419 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
420 | COPY_PHASE_STRIP = YES;
421 | ENABLE_NS_ASSERTIONS = NO;
422 | ENABLE_STRICT_OBJC_MSGSEND = YES;
423 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
424 | GCC_C_LANGUAGE_STANDARD = gnu99;
425 | GCC_NO_COMMON_BLOCKS = YES;
426 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
427 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
428 | GCC_WARN_UNDECLARED_SELECTOR = YES;
429 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
430 | GCC_WARN_UNUSED_FUNCTION = YES;
431 | GCC_WARN_UNUSED_VARIABLE = YES;
432 | IPHONEOS_DEPLOYMENT_TARGET = 15.1;
433 | LD_RUNPATH_SEARCH_PATHS = (
434 | /usr/lib/swift,
435 | "$(inherited)",
436 | );
437 | LIBRARY_SEARCH_PATHS = (
438 | "\"$(SDKROOT)/usr/lib/swift\"",
439 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
440 | "\"$(inherited)\"",
441 | );
442 | MTL_ENABLE_DEBUG_INFO = NO;
443 | OTHER_CPLUSPLUSFLAGS = (
444 | "$(OTHER_CFLAGS)",
445 | "-DFOLLY_NO_CONFIG",
446 | "-DFOLLY_MOBILE=1",
447 | "-DFOLLY_USE_LIBCPP=1",
448 | "-DFOLLY_CFG_NO_COROUTINES=1",
449 | "-DFOLLY_HAVE_CLOCK_GETTIME=1",
450 | );
451 | OTHER_LDFLAGS = (
452 | "$(inherited)",
453 | " ",
454 | );
455 | REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
456 | SDKROOT = iphoneos;
457 | USE_HERMES = true;
458 | VALIDATE_PRODUCT = YES;
459 | };
460 | name = Release;
461 | };
462 | /* End XCBuildConfiguration section */
463 |
464 | /* Begin XCConfigurationList section */
465 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "SyncTasksExample" */ = {
466 | isa = XCConfigurationList;
467 | buildConfigurations = (
468 | 13B07F941A680F5B00A75B9A /* Debug */,
469 | 13B07F951A680F5B00A75B9A /* Release */,
470 | );
471 | defaultConfigurationIsVisible = 0;
472 | defaultConfigurationName = Release;
473 | };
474 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "SyncTasksExample" */ = {
475 | isa = XCConfigurationList;
476 | buildConfigurations = (
477 | 83CBBA201A601CBA00E9B192 /* Debug */,
478 | 83CBBA211A601CBA00E9B192 /* Release */,
479 | );
480 | defaultConfigurationIsVisible = 0;
481 | defaultConfigurationName = Release;
482 | };
483 | /* End XCConfigurationList section */
484 | };
485 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
486 | }
487 |
--------------------------------------------------------------------------------
/example/ios/SyncTasksExample.xcodeproj/xcshareddata/xcschemes/SyncTasksExample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/example/ios/SyncTasksExample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/SyncTasksExample/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import React
3 | import React_RCTAppDelegate
4 | import ReactAppDependencyProvider
5 |
6 | @main
7 | class AppDelegate: RCTAppDelegate {
8 | override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
9 | self.moduleName = "SyncTasksExample"
10 | self.dependencyProvider = RCTAppDependencyProvider()
11 |
12 | // You can add your custom initial props in the dictionary below.
13 | // They will be passed down to the ViewController used by React Native.
14 | self.initialProps = [:]
15 |
16 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
17 | }
18 |
19 | override func sourceURL(for bridge: RCTBridge) -> URL? {
20 | self.bundleURL()
21 | }
22 |
23 | override func bundleURL() -> URL? {
24 | #if DEBUG
25 | RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
26 | #else
27 | Bundle.main.url(forResource: "main", withExtension: "jsbundle")
28 | #endif
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/example/ios/SyncTasksExample/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ios-marketing",
45 | "scale" : "1x",
46 | "size" : "1024x1024"
47 | }
48 | ],
49 | "info" : {
50 | "author" : "xcode",
51 | "version" : 1
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/example/ios/SyncTasksExample/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/example/ios/SyncTasksExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | SyncTasksExample
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(MARKETING_VERSION)
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | $(CURRENT_PROJECT_VERSION)
25 | LSRequiresIPhoneOS
26 |
27 | NSAppTransportSecurity
28 |
29 |
30 | NSAllowsArbitraryLoads
31 |
32 | NSAllowsLocalNetworking
33 |
34 |
35 | NSLocationWhenInUseUsageDescription
36 |
37 | UILaunchStoryboardName
38 | LaunchScreen
39 | UIRequiredDeviceCapabilities
40 |
41 | arm64
42 |
43 | UISupportedInterfaceOrientations
44 |
45 | UIInterfaceOrientationPortrait
46 | UIInterfaceOrientationLandscapeLeft
47 | UIInterfaceOrientationLandscapeRight
48 |
49 | UIViewControllerBasedStatusBarAppearance
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/example/ios/SyncTasksExample/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
24 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/example/ios/SyncTasksExample/PrivacyInfo.xcprivacy:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSPrivacyAccessedAPITypes
6 |
7 |
8 | NSPrivacyAccessedAPIType
9 | NSPrivacyAccessedAPICategoryFileTimestamp
10 | NSPrivacyAccessedAPITypeReasons
11 |
12 | C617.1
13 |
14 |
15 |
16 | NSPrivacyAccessedAPIType
17 | NSPrivacyAccessedAPICategoryUserDefaults
18 | NSPrivacyAccessedAPITypeReasons
19 |
20 | CA92.1
21 |
22 |
23 |
24 | NSPrivacyAccessedAPIType
25 | NSPrivacyAccessedAPICategorySystemBootTime
26 | NSPrivacyAccessedAPITypeReasons
27 |
28 | 35F9.1
29 |
30 |
31 |
32 | NSPrivacyCollectedDataTypes
33 |
34 | NSPrivacyTracking
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | preset: 'react-native',
3 | };
4 |
--------------------------------------------------------------------------------
/example/metro.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const { getDefaultConfig } = require('@react-native/metro-config');
3 | const { getConfig } = require('react-native-builder-bob/metro-config');
4 | const pkg = require('../package.json');
5 |
6 | const root = path.resolve(__dirname, '..');
7 |
8 | /**
9 | * Metro configuration
10 | * https://facebook.github.io/metro/docs/configuration
11 | *
12 | * @type {import('metro-config').MetroConfig}
13 | */
14 | module.exports = getConfig(getDefaultConfig(__dirname), {
15 | root,
16 | pkg,
17 | project: __dirname,
18 | });
19 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-sync-tasks-example",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "android": "react-native run-android",
7 | "ios": "react-native run-ios",
8 | "start": "react-native start",
9 | "build:android": "react-native build-android --extra-params \"--no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a\"",
10 | "build:ios": "react-native build-ios --scheme SyncTasksExample --mode Debug --extra-params \"-sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO\""
11 | },
12 | "dependencies": {
13 | "react": "19.0.0",
14 | "react-native": "0.78.2",
15 | "react-native-sync-tasks": "link:../"
16 | },
17 | "devDependencies": {
18 | "@babel/core": "^7.25.2",
19 | "@babel/preset-env": "^7.25.3",
20 | "@babel/runtime": "^7.25.0",
21 | "@react-native-community/cli": "15.0.1",
22 | "@react-native-community/cli-platform-android": "15.0.1",
23 | "@react-native-community/cli-platform-ios": "15.0.1",
24 | "@react-native/babel-preset": "0.78.2",
25 | "@react-native/metro-config": "0.78.2",
26 | "@react-native/typescript-config": "0.78.2",
27 | "@types/react": "^19.0.0",
28 | "react-native-builder-bob": "^0.40.6"
29 | },
30 | "engines": {
31 | "node": ">=18"
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/example/react-native.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const pkg = require('../package.json');
3 |
4 | module.exports = {
5 | project: {
6 | ios: {
7 | automaticPodsInstallation: true,
8 | },
9 | },
10 | dependencies: {
11 | [pkg.name]: {
12 | root: path.join(__dirname, '..'),
13 | platforms: {
14 | // Codegen script incorrectly fails without this
15 | // So we explicitly specify the platforms with empty object
16 | ios: {},
17 | android: {},
18 | },
19 | },
20 | },
21 | };
22 |
--------------------------------------------------------------------------------
/example/src/App.tsx:
--------------------------------------------------------------------------------
1 | import { Text, View, StyleSheet, TouchableOpacity } from 'react-native';
2 | import { createTask, SyncTasksManager } from 'react-native-sync-tasks';
3 |
4 | type TData = {
5 | userId: number;
6 | id: number;
7 | title: string;
8 | body: string;
9 | };
10 |
11 | const task = createTask({
12 | config: {
13 | url: 'https://jsonplaceholder.typicode.com/posts/1/',
14 | interval: 2000,
15 | headers: {
16 | 'Content-Type': 'application/json',
17 | 'Accept': 'application/json',
18 | },
19 | },
20 | onData: (data: { body: TData; status_code: number }) => {
21 | console.log('DATA 1 ', data.body);
22 | },
23 | onError: (error: { error: string; status_code: number }) => {
24 | console.log('ERROR 1 ', error);
25 | },
26 | });
27 |
28 | const task2 = createTask({
29 | config: {
30 | url: 'https://jsonplaceholder.typicode.com/posts/2/',
31 | interval: 2000,
32 | headers: {
33 | 'Content-Type': 'application/json',
34 | 'Accept': 'application/json',
35 | },
36 | },
37 | onData: (data: { body: TData; status_code: number }) => {
38 | console.log('DATA 2 ', data.body.id);
39 | },
40 | onError: (error: { error: string; status_code: number }) => {
41 | console.log('ERROR 2 ', error);
42 | },
43 | });
44 |
45 | export default function App() {
46 | const onStart = () => {
47 | SyncTasksManager.addTasks([task]);
48 | SyncTasksManager.startAll();
49 | };
50 |
51 | const onStop = () => {
52 | SyncTasksManager.stopAll();
53 | // task.stop();
54 | };
55 |
56 | const onRestart = () => {
57 | SyncTasksManager.startAll();
58 | // task.start();
59 | };
60 |
61 | return (
62 |
63 |
64 | START
65 |
66 |
67 |
68 | CHECK STATUS
69 |
70 |
71 |
72 | STOP
73 |
74 |
75 | RESTART
76 |
77 |
78 | );
79 | }
80 |
81 | const styles = StyleSheet.create({
82 | container: {
83 | flex: 1,
84 | alignItems: 'center',
85 | justifyContent: 'center',
86 | },
87 | });
88 |
--------------------------------------------------------------------------------
/ios/SyncTasks.h:
--------------------------------------------------------------------------------
1 | #ifdef __cplusplus
2 | #import "react-native-sync-tasks.hpp"
3 | #endif
4 |
5 | #import
6 |
7 | @interface SyncTasksManager : NSObject
8 |
9 | @end
10 |
11 |
--------------------------------------------------------------------------------
/ios/SyncTasks.mm:
--------------------------------------------------------------------------------
1 | #import "SyncTasks.h"
2 | #import "react-native-sync-tasks.hpp"
3 |
4 | #import
5 | #import
6 | #import
7 | #import
8 | #import
9 | #include
10 |
11 | #include
12 | #include "iostream"
13 |
14 |
15 | using namespace std;
16 | using namespace facebook;
17 |
18 |
19 | @implementation SyncTasksManager
20 |
21 | RCT_EXPORT_MODULE(SyncTasksManager)
22 |
23 | @synthesize bridge = _bridge;
24 | @synthesize methodQueue = _methodQueue;
25 |
26 | + (BOOL)requiresMainQueueSetup {
27 | return YES;
28 | }
29 |
30 |
31 | RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
32 | {
33 | RCTBridge* bridge = [RCTBridge currentBridge];
34 | RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
35 |
36 | if (cxxBridge == nil) {
37 | return @false;
38 | }
39 |
40 | auto jsiRuntime = (jsi::Runtime*) cxxBridge.runtime;
41 | if (jsiRuntime == nil) {
42 | return @false;
43 | }
44 |
45 | auto jsCallInvoker = bridge.jsCallInvoker;
46 |
47 |
48 | sh::synctasks::install(jsiRuntime, jsCallInvoker);
49 |
50 |
51 | return @true;
52 | }
53 |
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/ios/rust/fetcher.xcframework/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AvailableLibraries
6 |
7 |
8 | BinaryPath
9 | libfetcher.a
10 | HeadersPath
11 | Headers
12 | LibraryIdentifier
13 | ios-arm64
14 | LibraryPath
15 | libfetcher.a
16 | SupportedArchitectures
17 |
18 | arm64
19 |
20 | SupportedPlatform
21 | ios
22 |
23 |
24 | BinaryPath
25 | libfetcher.a
26 | HeadersPath
27 | Headers
28 | LibraryIdentifier
29 | ios-arm64-simulator
30 | LibraryPath
31 | libfetcher.a
32 | SupportedArchitectures
33 |
34 | arm64
35 |
36 | SupportedPlatform
37 | ios
38 | SupportedPlatformVariant
39 | simulator
40 |
41 |
42 | CFBundlePackageType
43 | XFWK
44 | XCFrameworkFormatVersion
45 | 1.0
46 |
47 |
48 |
--------------------------------------------------------------------------------
/ios/rust/fetcher.xcframework/ios-arm64-simulator/Headers/fetcher.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | typedef struct {
8 | const char* key;
9 | const char* value;
10 | } Header;
11 |
12 | typedef struct {
13 | bool ok;
14 | int code;
15 | char* body;
16 | } FetchResult;
17 |
18 | FetchResult rust_fetch(const char* url, const Header* headers, int header_count);
19 | void rust_free_string(char* ptr);
20 |
21 | #ifdef __cplusplus
22 | }
23 | #endif
24 |
--------------------------------------------------------------------------------
/ios/rust/fetcher.xcframework/ios-arm64-simulator/libfetcher.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/ios/rust/fetcher.xcframework/ios-arm64-simulator/libfetcher.a
--------------------------------------------------------------------------------
/ios/rust/fetcher.xcframework/ios-arm64/Headers/fetcher.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | typedef struct {
8 | const char* key;
9 | const char* value;
10 | } Header;
11 |
12 | typedef struct {
13 | bool ok;
14 | int code;
15 | char* body;
16 | } FetchResult;
17 |
18 | FetchResult rust_fetch(const char* url, const Header* headers, int header_count);
19 | void rust_free_string(char* ptr);
20 |
21 | #ifdef __cplusplus
22 | }
23 | #endif
24 |
--------------------------------------------------------------------------------
/ios/rust/fetcher.xcframework/ios-arm64/libfetcher.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pioner92/react-native-sync-tasks/a639c61d40223f07102c43177f1af9126dd38e14/ios/rust/fetcher.xcframework/ios-arm64/libfetcher.a
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-sync-tasks",
3 | "version": "0.1.1",
4 | "description": "JSI-based task manager for React Native that periodically fetches data from a server, deduplicates responses using hashing, and provides centralized task control via native C++ module.",
5 | "main": "./lib/commonjs/index.js",
6 | "module": "./lib/module/index.js",
7 | "types": "lib/typescript/index.d.ts",
8 | "react-native": "src/index",
9 | "source": "./src/index",
10 | "files": [
11 | "src",
12 | "lib",
13 | "android",
14 | "ios",
15 | "cpp",
16 | "*.podspec",
17 | "react-native.config.js",
18 | "!ios/build",
19 | "!android/build",
20 | "!android/gradle",
21 | "!android/gradlew",
22 | "!android/gradlew.bat",
23 | "!android/local.properties",
24 | "!**/__tests__",
25 | "!**/__fixtures__",
26 | "!**/__mocks__",
27 | "!**/.*"
28 | ],
29 | "scripts": {
30 | "example": "yarn workspace react-native-sync-tasks-example",
31 | "test": "jest",
32 | "typecheck": "tsc",
33 | "lint": "eslint \"**/*.{js,ts,tsx}\"",
34 | "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
35 | "prepare": "bob build",
36 | "release": "release-it"
37 | },
38 | "keywords": [
39 | "react-native",
40 | "ios",
41 | "android",
42 | "react-native",
43 | "jsi",
44 | "native-module",
45 | "task-manager",
46 | "background-tasks",
47 | "http-polling",
48 | "api-sync",
49 | "react-native-native-module",
50 | "high-performance",
51 | "c++",
52 | "jni",
53 | "bridge-less",
54 | "sync",
55 | "data-fetching",
56 | "react-native-jsi",
57 | "react-native-task-manager",
58 | "react-native-background-fetch",
59 | "react-native-background-tasks",
60 | "react-native-background-job",
61 | "react-native-background-fetching",
62 | "react-native-background-api",
63 | "react-native-background-sync",
64 | "react-native-background-polling",
65 | "react-native-sync"
66 | ],
67 | "repository": {
68 | "type": "git",
69 | "url": "git+https://github.com/pioner92/react-native-sync-tasks.git"
70 | },
71 | "author": "pioner921227 (https://github.com/pioner92)",
72 | "license": "MIT",
73 | "bugs": {
74 | "url": "https://github.com/pioner92/react-native-sync-tasks/issues"
75 | },
76 | "homepage": "https://github.com/pioner92/react-native-sync-tasks#readme",
77 | "publishConfig": {
78 | "registry": "https://registry.npmjs.org/"
79 | },
80 | "devDependencies": {
81 | "@commitlint/config-conventional": "^19.6.0",
82 | "@eslint/compat": "^1.2.7",
83 | "@eslint/eslintrc": "^3.3.0",
84 | "@eslint/js": "^9.22.0",
85 | "@evilmartians/lefthook": "^1.5.0",
86 | "@react-native/eslint-config": "^0.78.0",
87 | "@release-it/conventional-changelog": "^9.0.2",
88 | "@types/jest": "^29.5.5",
89 | "@types/react": "^19.0.0",
90 | "commitlint": "^19.6.1",
91 | "del-cli": "^5.1.0",
92 | "eslint": "^9.22.0",
93 | "eslint-config-prettier": "^10.1.1",
94 | "eslint-plugin-prettier": "^5.2.3",
95 | "jest": "^29.7.0",
96 | "prettier": "^3.0.3",
97 | "react": "19.0.0",
98 | "react-native": "0.78.2",
99 | "react-native-builder-bob": "0.37.0",
100 | "release-it": "^17.10.0",
101 | "turbo": "^1.10.7",
102 | "typescript": "^5.2.2"
103 | },
104 | "peerDependencies": {
105 | "react": "*",
106 | "react-native": "*"
107 | },
108 | "workspaces": [
109 | "example"
110 | ],
111 | "packageManager": "yarn@3.6.1",
112 | "jest": {
113 | "preset": "react-native",
114 | "modulePathIgnorePatterns": [
115 | "/example/node_modules",
116 | "/lib/"
117 | ]
118 | },
119 | "commitlint": {
120 | "extends": [
121 | "@commitlint/config-conventional"
122 | ]
123 | },
124 | "release-it": {
125 | "git": {
126 | "commitMessage": "chore: release ${version}",
127 | "tagName": "v${version}"
128 | },
129 | "npm": {
130 | "publish": true
131 | },
132 | "github": {
133 | "release": true
134 | },
135 | "plugins": {
136 | "@release-it/conventional-changelog": {
137 | "preset": {
138 | "name": "angular"
139 | }
140 | }
141 | }
142 | },
143 | "prettier": {
144 | "quoteProps": "consistent",
145 | "singleQuote": true,
146 | "tabWidth": 2,
147 | "trailingComma": "es5",
148 | "useTabs": false
149 | },
150 | "react-native-builder-bob": {
151 | "source": "src",
152 | "output": "lib",
153 | "targets": [
154 | "commonjs",
155 | "module",
156 | [
157 | "typescript",
158 | {
159 | "project": "tsconfig.build.json"
160 | }
161 | ]
162 | ]
163 | },
164 | "create-react-native-library": {
165 | "type": "legacy-module",
166 | "languages": "cpp",
167 | "version": "0.49.8"
168 | }
169 | }
170 |
--------------------------------------------------------------------------------
/rust/fetcher-rust/Cargo.lock:
--------------------------------------------------------------------------------
1 | # This file is automatically @generated by Cargo.
2 | # It is not intended for manual editing.
3 | version = 4
4 |
5 | [[package]]
6 | name = "adler2"
7 | version = "2.0.0"
8 | source = "registry+https://github.com/rust-lang/crates.io-index"
9 | checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
10 |
11 | [[package]]
12 | name = "base64"
13 | version = "0.22.1"
14 | source = "registry+https://github.com/rust-lang/crates.io-index"
15 | checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
16 |
17 | [[package]]
18 | name = "cc"
19 | version = "1.2.19"
20 | source = "registry+https://github.com/rust-lang/crates.io-index"
21 | checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362"
22 | dependencies = [
23 | "shlex",
24 | ]
25 |
26 | [[package]]
27 | name = "cfg-if"
28 | version = "1.0.0"
29 | source = "registry+https://github.com/rust-lang/crates.io-index"
30 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
31 |
32 | [[package]]
33 | name = "crc32fast"
34 | version = "1.4.2"
35 | source = "registry+https://github.com/rust-lang/crates.io-index"
36 | checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
37 | dependencies = [
38 | "cfg-if",
39 | ]
40 |
41 | [[package]]
42 | name = "displaydoc"
43 | version = "0.2.5"
44 | source = "registry+https://github.com/rust-lang/crates.io-index"
45 | checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
46 | dependencies = [
47 | "proc-macro2",
48 | "quote",
49 | "syn",
50 | ]
51 |
52 | [[package]]
53 | name = "fetcher"
54 | version = "0.1.0"
55 | dependencies = [
56 | "ureq",
57 | ]
58 |
59 | [[package]]
60 | name = "flate2"
61 | version = "1.1.1"
62 | source = "registry+https://github.com/rust-lang/crates.io-index"
63 | checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece"
64 | dependencies = [
65 | "crc32fast",
66 | "miniz_oxide",
67 | ]
68 |
69 | [[package]]
70 | name = "form_urlencoded"
71 | version = "1.2.1"
72 | source = "registry+https://github.com/rust-lang/crates.io-index"
73 | checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
74 | dependencies = [
75 | "percent-encoding",
76 | ]
77 |
78 | [[package]]
79 | name = "getrandom"
80 | version = "0.2.15"
81 | source = "registry+https://github.com/rust-lang/crates.io-index"
82 | checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
83 | dependencies = [
84 | "cfg-if",
85 | "libc",
86 | "wasi",
87 | ]
88 |
89 | [[package]]
90 | name = "icu_collections"
91 | version = "1.5.0"
92 | source = "registry+https://github.com/rust-lang/crates.io-index"
93 | checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526"
94 | dependencies = [
95 | "displaydoc",
96 | "yoke",
97 | "zerofrom",
98 | "zerovec",
99 | ]
100 |
101 | [[package]]
102 | name = "icu_locid"
103 | version = "1.5.0"
104 | source = "registry+https://github.com/rust-lang/crates.io-index"
105 | checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637"
106 | dependencies = [
107 | "displaydoc",
108 | "litemap",
109 | "tinystr",
110 | "writeable",
111 | "zerovec",
112 | ]
113 |
114 | [[package]]
115 | name = "icu_locid_transform"
116 | version = "1.5.0"
117 | source = "registry+https://github.com/rust-lang/crates.io-index"
118 | checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e"
119 | dependencies = [
120 | "displaydoc",
121 | "icu_locid",
122 | "icu_locid_transform_data",
123 | "icu_provider",
124 | "tinystr",
125 | "zerovec",
126 | ]
127 |
128 | [[package]]
129 | name = "icu_locid_transform_data"
130 | version = "1.5.1"
131 | source = "registry+https://github.com/rust-lang/crates.io-index"
132 | checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d"
133 |
134 | [[package]]
135 | name = "icu_normalizer"
136 | version = "1.5.0"
137 | source = "registry+https://github.com/rust-lang/crates.io-index"
138 | checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f"
139 | dependencies = [
140 | "displaydoc",
141 | "icu_collections",
142 | "icu_normalizer_data",
143 | "icu_properties",
144 | "icu_provider",
145 | "smallvec",
146 | "utf16_iter",
147 | "utf8_iter",
148 | "write16",
149 | "zerovec",
150 | ]
151 |
152 | [[package]]
153 | name = "icu_normalizer_data"
154 | version = "1.5.1"
155 | source = "registry+https://github.com/rust-lang/crates.io-index"
156 | checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7"
157 |
158 | [[package]]
159 | name = "icu_properties"
160 | version = "1.5.1"
161 | source = "registry+https://github.com/rust-lang/crates.io-index"
162 | checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5"
163 | dependencies = [
164 | "displaydoc",
165 | "icu_collections",
166 | "icu_locid_transform",
167 | "icu_properties_data",
168 | "icu_provider",
169 | "tinystr",
170 | "zerovec",
171 | ]
172 |
173 | [[package]]
174 | name = "icu_properties_data"
175 | version = "1.5.1"
176 | source = "registry+https://github.com/rust-lang/crates.io-index"
177 | checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2"
178 |
179 | [[package]]
180 | name = "icu_provider"
181 | version = "1.5.0"
182 | source = "registry+https://github.com/rust-lang/crates.io-index"
183 | checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9"
184 | dependencies = [
185 | "displaydoc",
186 | "icu_locid",
187 | "icu_provider_macros",
188 | "stable_deref_trait",
189 | "tinystr",
190 | "writeable",
191 | "yoke",
192 | "zerofrom",
193 | "zerovec",
194 | ]
195 |
196 | [[package]]
197 | name = "icu_provider_macros"
198 | version = "1.5.0"
199 | source = "registry+https://github.com/rust-lang/crates.io-index"
200 | checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
201 | dependencies = [
202 | "proc-macro2",
203 | "quote",
204 | "syn",
205 | ]
206 |
207 | [[package]]
208 | name = "idna"
209 | version = "1.0.3"
210 | source = "registry+https://github.com/rust-lang/crates.io-index"
211 | checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
212 | dependencies = [
213 | "idna_adapter",
214 | "smallvec",
215 | "utf8_iter",
216 | ]
217 |
218 | [[package]]
219 | name = "idna_adapter"
220 | version = "1.2.0"
221 | source = "registry+https://github.com/rust-lang/crates.io-index"
222 | checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71"
223 | dependencies = [
224 | "icu_normalizer",
225 | "icu_properties",
226 | ]
227 |
228 | [[package]]
229 | name = "libc"
230 | version = "0.2.171"
231 | source = "registry+https://github.com/rust-lang/crates.io-index"
232 | checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
233 |
234 | [[package]]
235 | name = "litemap"
236 | version = "0.7.5"
237 | source = "registry+https://github.com/rust-lang/crates.io-index"
238 | checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856"
239 |
240 | [[package]]
241 | name = "log"
242 | version = "0.4.27"
243 | source = "registry+https://github.com/rust-lang/crates.io-index"
244 | checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
245 |
246 | [[package]]
247 | name = "miniz_oxide"
248 | version = "0.8.8"
249 | source = "registry+https://github.com/rust-lang/crates.io-index"
250 | checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a"
251 | dependencies = [
252 | "adler2",
253 | ]
254 |
255 | [[package]]
256 | name = "once_cell"
257 | version = "1.21.3"
258 | source = "registry+https://github.com/rust-lang/crates.io-index"
259 | checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
260 |
261 | [[package]]
262 | name = "percent-encoding"
263 | version = "2.3.1"
264 | source = "registry+https://github.com/rust-lang/crates.io-index"
265 | checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
266 |
267 | [[package]]
268 | name = "proc-macro2"
269 | version = "1.0.94"
270 | source = "registry+https://github.com/rust-lang/crates.io-index"
271 | checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
272 | dependencies = [
273 | "unicode-ident",
274 | ]
275 |
276 | [[package]]
277 | name = "quote"
278 | version = "1.0.40"
279 | source = "registry+https://github.com/rust-lang/crates.io-index"
280 | checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
281 | dependencies = [
282 | "proc-macro2",
283 | ]
284 |
285 | [[package]]
286 | name = "ring"
287 | version = "0.17.14"
288 | source = "registry+https://github.com/rust-lang/crates.io-index"
289 | checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
290 | dependencies = [
291 | "cc",
292 | "cfg-if",
293 | "getrandom",
294 | "libc",
295 | "untrusted",
296 | "windows-sys",
297 | ]
298 |
299 | [[package]]
300 | name = "rustls"
301 | version = "0.23.26"
302 | source = "registry+https://github.com/rust-lang/crates.io-index"
303 | checksum = "df51b5869f3a441595eac5e8ff14d486ff285f7b8c0df8770e49c3b56351f0f0"
304 | dependencies = [
305 | "log",
306 | "once_cell",
307 | "ring",
308 | "rustls-pki-types",
309 | "rustls-webpki",
310 | "subtle",
311 | "zeroize",
312 | ]
313 |
314 | [[package]]
315 | name = "rustls-pki-types"
316 | version = "1.11.0"
317 | source = "registry+https://github.com/rust-lang/crates.io-index"
318 | checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c"
319 |
320 | [[package]]
321 | name = "rustls-webpki"
322 | version = "0.103.1"
323 | source = "registry+https://github.com/rust-lang/crates.io-index"
324 | checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03"
325 | dependencies = [
326 | "ring",
327 | "rustls-pki-types",
328 | "untrusted",
329 | ]
330 |
331 | [[package]]
332 | name = "serde"
333 | version = "1.0.219"
334 | source = "registry+https://github.com/rust-lang/crates.io-index"
335 | checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
336 | dependencies = [
337 | "serde_derive",
338 | ]
339 |
340 | [[package]]
341 | name = "serde_derive"
342 | version = "1.0.219"
343 | source = "registry+https://github.com/rust-lang/crates.io-index"
344 | checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
345 | dependencies = [
346 | "proc-macro2",
347 | "quote",
348 | "syn",
349 | ]
350 |
351 | [[package]]
352 | name = "shlex"
353 | version = "1.3.0"
354 | source = "registry+https://github.com/rust-lang/crates.io-index"
355 | checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
356 |
357 | [[package]]
358 | name = "smallvec"
359 | version = "1.15.0"
360 | source = "registry+https://github.com/rust-lang/crates.io-index"
361 | checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9"
362 |
363 | [[package]]
364 | name = "stable_deref_trait"
365 | version = "1.2.0"
366 | source = "registry+https://github.com/rust-lang/crates.io-index"
367 | checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
368 |
369 | [[package]]
370 | name = "subtle"
371 | version = "2.6.1"
372 | source = "registry+https://github.com/rust-lang/crates.io-index"
373 | checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
374 |
375 | [[package]]
376 | name = "syn"
377 | version = "2.0.100"
378 | source = "registry+https://github.com/rust-lang/crates.io-index"
379 | checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
380 | dependencies = [
381 | "proc-macro2",
382 | "quote",
383 | "unicode-ident",
384 | ]
385 |
386 | [[package]]
387 | name = "synstructure"
388 | version = "0.13.1"
389 | source = "registry+https://github.com/rust-lang/crates.io-index"
390 | checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
391 | dependencies = [
392 | "proc-macro2",
393 | "quote",
394 | "syn",
395 | ]
396 |
397 | [[package]]
398 | name = "tinystr"
399 | version = "0.7.6"
400 | source = "registry+https://github.com/rust-lang/crates.io-index"
401 | checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f"
402 | dependencies = [
403 | "displaydoc",
404 | "zerovec",
405 | ]
406 |
407 | [[package]]
408 | name = "unicode-ident"
409 | version = "1.0.18"
410 | source = "registry+https://github.com/rust-lang/crates.io-index"
411 | checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
412 |
413 | [[package]]
414 | name = "untrusted"
415 | version = "0.9.0"
416 | source = "registry+https://github.com/rust-lang/crates.io-index"
417 | checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
418 |
419 | [[package]]
420 | name = "ureq"
421 | version = "2.12.1"
422 | source = "registry+https://github.com/rust-lang/crates.io-index"
423 | checksum = "02d1a66277ed75f640d608235660df48c8e3c19f3b4edb6a263315626cc3c01d"
424 | dependencies = [
425 | "base64",
426 | "flate2",
427 | "log",
428 | "once_cell",
429 | "rustls",
430 | "rustls-pki-types",
431 | "url",
432 | "webpki-roots",
433 | ]
434 |
435 | [[package]]
436 | name = "url"
437 | version = "2.5.4"
438 | source = "registry+https://github.com/rust-lang/crates.io-index"
439 | checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
440 | dependencies = [
441 | "form_urlencoded",
442 | "idna",
443 | "percent-encoding",
444 | ]
445 |
446 | [[package]]
447 | name = "utf16_iter"
448 | version = "1.0.5"
449 | source = "registry+https://github.com/rust-lang/crates.io-index"
450 | checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246"
451 |
452 | [[package]]
453 | name = "utf8_iter"
454 | version = "1.0.4"
455 | source = "registry+https://github.com/rust-lang/crates.io-index"
456 | checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
457 |
458 | [[package]]
459 | name = "wasi"
460 | version = "0.11.0+wasi-snapshot-preview1"
461 | source = "registry+https://github.com/rust-lang/crates.io-index"
462 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
463 |
464 | [[package]]
465 | name = "webpki-roots"
466 | version = "0.26.8"
467 | source = "registry+https://github.com/rust-lang/crates.io-index"
468 | checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9"
469 | dependencies = [
470 | "rustls-pki-types",
471 | ]
472 |
473 | [[package]]
474 | name = "windows-sys"
475 | version = "0.52.0"
476 | source = "registry+https://github.com/rust-lang/crates.io-index"
477 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
478 | dependencies = [
479 | "windows-targets",
480 | ]
481 |
482 | [[package]]
483 | name = "windows-targets"
484 | version = "0.52.6"
485 | source = "registry+https://github.com/rust-lang/crates.io-index"
486 | checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
487 | dependencies = [
488 | "windows_aarch64_gnullvm",
489 | "windows_aarch64_msvc",
490 | "windows_i686_gnu",
491 | "windows_i686_gnullvm",
492 | "windows_i686_msvc",
493 | "windows_x86_64_gnu",
494 | "windows_x86_64_gnullvm",
495 | "windows_x86_64_msvc",
496 | ]
497 |
498 | [[package]]
499 | name = "windows_aarch64_gnullvm"
500 | version = "0.52.6"
501 | source = "registry+https://github.com/rust-lang/crates.io-index"
502 | checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
503 |
504 | [[package]]
505 | name = "windows_aarch64_msvc"
506 | version = "0.52.6"
507 | source = "registry+https://github.com/rust-lang/crates.io-index"
508 | checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
509 |
510 | [[package]]
511 | name = "windows_i686_gnu"
512 | version = "0.52.6"
513 | source = "registry+https://github.com/rust-lang/crates.io-index"
514 | checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
515 |
516 | [[package]]
517 | name = "windows_i686_gnullvm"
518 | version = "0.52.6"
519 | source = "registry+https://github.com/rust-lang/crates.io-index"
520 | checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
521 |
522 | [[package]]
523 | name = "windows_i686_msvc"
524 | version = "0.52.6"
525 | source = "registry+https://github.com/rust-lang/crates.io-index"
526 | checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
527 |
528 | [[package]]
529 | name = "windows_x86_64_gnu"
530 | version = "0.52.6"
531 | source = "registry+https://github.com/rust-lang/crates.io-index"
532 | checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
533 |
534 | [[package]]
535 | name = "windows_x86_64_gnullvm"
536 | version = "0.52.6"
537 | source = "registry+https://github.com/rust-lang/crates.io-index"
538 | checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
539 |
540 | [[package]]
541 | name = "windows_x86_64_msvc"
542 | version = "0.52.6"
543 | source = "registry+https://github.com/rust-lang/crates.io-index"
544 | checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
545 |
546 | [[package]]
547 | name = "write16"
548 | version = "1.0.0"
549 | source = "registry+https://github.com/rust-lang/crates.io-index"
550 | checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936"
551 |
552 | [[package]]
553 | name = "writeable"
554 | version = "0.5.5"
555 | source = "registry+https://github.com/rust-lang/crates.io-index"
556 | checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
557 |
558 | [[package]]
559 | name = "yoke"
560 | version = "0.7.5"
561 | source = "registry+https://github.com/rust-lang/crates.io-index"
562 | checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40"
563 | dependencies = [
564 | "serde",
565 | "stable_deref_trait",
566 | "yoke-derive",
567 | "zerofrom",
568 | ]
569 |
570 | [[package]]
571 | name = "yoke-derive"
572 | version = "0.7.5"
573 | source = "registry+https://github.com/rust-lang/crates.io-index"
574 | checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
575 | dependencies = [
576 | "proc-macro2",
577 | "quote",
578 | "syn",
579 | "synstructure",
580 | ]
581 |
582 | [[package]]
583 | name = "zerofrom"
584 | version = "0.1.6"
585 | source = "registry+https://github.com/rust-lang/crates.io-index"
586 | checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5"
587 | dependencies = [
588 | "zerofrom-derive",
589 | ]
590 |
591 | [[package]]
592 | name = "zerofrom-derive"
593 | version = "0.1.6"
594 | source = "registry+https://github.com/rust-lang/crates.io-index"
595 | checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
596 | dependencies = [
597 | "proc-macro2",
598 | "quote",
599 | "syn",
600 | "synstructure",
601 | ]
602 |
603 | [[package]]
604 | name = "zeroize"
605 | version = "1.8.1"
606 | source = "registry+https://github.com/rust-lang/crates.io-index"
607 | checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
608 |
609 | [[package]]
610 | name = "zerovec"
611 | version = "0.10.4"
612 | source = "registry+https://github.com/rust-lang/crates.io-index"
613 | checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079"
614 | dependencies = [
615 | "yoke",
616 | "zerofrom",
617 | "zerovec-derive",
618 | ]
619 |
620 | [[package]]
621 | name = "zerovec-derive"
622 | version = "0.10.3"
623 | source = "registry+https://github.com/rust-lang/crates.io-index"
624 | checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
625 | dependencies = [
626 | "proc-macro2",
627 | "quote",
628 | "syn",
629 | ]
630 |
--------------------------------------------------------------------------------
/rust/fetcher-rust/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "fetcher"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [lib]
7 | crate-type = ["staticlib"]
8 |
9 | [dependencies]
10 | ureq = { version = "2", features = ["tls"] }
--------------------------------------------------------------------------------
/rust/fetcher-rust/android/build-android.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | NDK_VERSION=27.2.12479018
4 | ANDROID_NDK=~/Library/Android/sdk/ndk/$NDK_VERSION
5 | PREBUILT=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64
6 |
7 | CLANG=$PREBUILT/bin/x86_64-linux-android21-clang
8 | AR=$PREBUILT/bin/llvm-ar
9 |
10 | if [ ! -f "$CLANG" ]; then
11 | echo "❌ Compiler not found: $CLANG"
12 | exit 1
13 | fi
14 |
15 | export CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=$CLANG
16 | export CC_x86_64_linux_android=$CLANG
17 | export AR_x86_64_linux_android=$AR
18 |
19 | # cargo build --release --target x86_64-linux-android
20 | cargo build --release --target aarch64-linux-android
21 | # cargo build --release --target armv7-linux-androideabi
22 | # cargo build --release --target x86_64-linux-android
23 | # cargo build --release --target i686-linux-android
24 |
--------------------------------------------------------------------------------
/rust/fetcher-rust/include/fetcher.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef __cplusplus
4 | extern "C" {
5 | #endif
6 |
7 | typedef struct {
8 | const char* key;
9 | const char* value;
10 | } Header;
11 |
12 | typedef struct {
13 | bool ok;
14 | int code;
15 | char* body;
16 | } FetchResult;
17 |
18 | FetchResult rust_fetch(const char* url, const Header* headers, int header_count);
19 | void rust_free_string(char* ptr);
20 |
21 | #ifdef __cplusplus
22 | }
23 | #endif
24 |
--------------------------------------------------------------------------------
/rust/fetcher-rust/ios/Cargo.toml:
--------------------------------------------------------------------------------
1 | [lib]
2 | crate-type = ["staticlib"]
3 |
--------------------------------------------------------------------------------
/rust/fetcher-rust/ios/build-ios.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5 | PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
6 | cd "$PROJECT_ROOT"
7 |
8 | echo "📦 Building libfetcher.a for device and simulator (arm64)..."
9 |
10 | # Ensure targets are installed
11 | rustup target add aarch64-apple-ios aarch64-apple-ios-sim
12 |
13 | # Build for device
14 | echo "🚀 Building for device (aarch64-apple-ios)..."
15 | cargo build --release --target aarch64-apple-ios
16 |
17 | # Build for simulator (ARM64 Mac)
18 | echo "🧪 Building for simulator (aarch64-apple-ios-sim)..."
19 | cargo build --release --target aarch64-apple-ios-sim
20 |
21 | # Create xcframework (универсальный подход для всех случаев)
22 | echo "📦 Creating xcframework..."
23 | mkdir -p ios/universal
24 |
25 | xcodebuild -create-xcframework \
26 | -library target/aarch64-apple-ios/release/libfetcher.a \
27 | -headers include \
28 | -library target/aarch64-apple-ios-sim/release/libfetcher.a \
29 | -headers include \
30 | -output ios/universal/fetcher.xcframework
31 |
32 | echo "✅ Done: ios/universal/fetcher.xcframework created."
33 |
--------------------------------------------------------------------------------
/rust/fetcher-rust/src/lib.rs:
--------------------------------------------------------------------------------
1 | use std::ffi::{CStr, CString};
2 | use std::os::raw::{c_char, c_int};
3 |
4 | #[repr(C)]
5 | pub struct Header {
6 | key: *const c_char,
7 | value: *const c_char,
8 | }
9 |
10 | #[repr(C)]
11 | pub struct FetchResult {
12 | pub ok: bool,
13 | pub code: i32,
14 | pub body: *mut c_char,
15 | }
16 |
17 | #[no_mangle]
18 | pub extern "C" fn rust_fetch(
19 | url: *const c_char,
20 | headers: *const Header,
21 | header_count: c_int,
22 | ) -> FetchResult {
23 | let url_str = match unsafe { CStr::from_ptr(url) }.to_str() {
24 | Ok(s) => s,
25 | Err(_) => {
26 | return FetchResult {
27 | ok: false,
28 | code: 0,
29 | body: CString::new("Invalid URL").unwrap().into_raw(),
30 | }
31 | }
32 | };
33 |
34 | let mut request = ureq::get(url_str);
35 |
36 | if !headers.is_null() {
37 | let header_slice = unsafe { std::slice::from_raw_parts(headers, header_count as usize) };
38 | for Header { key, value } in header_slice {
39 | if let (Ok(k), Ok(v)) = (
40 | unsafe { CStr::from_ptr(*key) }.to_str(),
41 | unsafe { CStr::from_ptr(*value) }.to_str(),
42 | ) {
43 | request = request.set(k, v);
44 | }
45 | }
46 | }
47 |
48 | match request.call() {
49 | Ok(res) => {
50 | let code = res.status();
51 | let body = res.into_string().unwrap_or_default();
52 |
53 | FetchResult {
54 | ok: code < 400,
55 | code: code.into(),
56 | body: CString::new(body).unwrap().into_raw(),
57 | }
58 | }
59 | Err(ureq::Error::Status(code, response)) => {
60 | let body = response
61 | .into_string()
62 | .unwrap_or_else(|_| "".to_string());
63 | FetchResult {
64 | ok: false,
65 | code: code.into(),
66 | body: CString::new(body).unwrap().into_raw(),
67 | }
68 | }
69 | Err(e) => {
70 | let msg = format!("Request error: {}", e);
71 | FetchResult {
72 | ok: false,
73 | code: 0,
74 | body: CString::new(msg).unwrap().into_raw(),
75 | }
76 | }
77 | }
78 | }
79 |
80 | #[no_mangle]
81 | pub extern "C" fn rust_free_string(ptr: *mut c_char) {
82 | if !ptr.is_null() {
83 | unsafe {
84 | drop(CString::from_raw(ptr));
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/index.tsx:
--------------------------------------------------------------------------------
1 | import { NativeModules } from 'react-native';
2 |
3 | type Task = {
4 | stop: () => void;
5 | start: () => void;
6 | isRunning: () => boolean;
7 | };
8 |
9 | interface ITaskManager {
10 | addTask(task: Task): void;
11 | addTasks(tasks: Task[]): void;
12 | startAll(): void;
13 | stopAll(): void;
14 | }
15 |
16 | type TCreateTaskProps = {
17 | config: {
18 | url: string;
19 | interval: number; // default 1000 ms
20 | headers?: Record;
21 | };
22 | onData: (data: { body: T; status_code: number }) => void;
23 | onError?: (error: { error: string; status_code: number }) => void;
24 | };
25 |
26 | declare global {
27 | var createTask: (props: TCreateTaskProps) => Task;
28 |
29 | var SyncTasksManager: ITaskManager;
30 | }
31 |
32 | // Ссылка на глобальный объект SqlDb
33 | let __SyncTasksManager = global.SyncTasksManager;
34 |
35 | // Автоинициализация
36 | if (!__SyncTasksManager) {
37 | if (NativeModules.SyncTasksManager?.install) {
38 | NativeModules.SyncTasksManager.install(); // Вызываем native install метод
39 | __SyncTasksManager = global.SyncTasksManager; // Сохраняем глобальную ссылку на объект SqlDb
40 | console.log('✅ TaskManager initialized successfully');
41 | }
42 | }
43 |
44 | // Класс SqlDb для работы с базой данных
45 | export class SyncTasksManager {
46 | static instance: ITaskManager | null = __SyncTasksManager;
47 |
48 | static addTask(task: Task) {
49 | if (!this.instance) {
50 | throw new Error('TaskManager not initialized');
51 | }
52 | this.instance.addTask(task);
53 | }
54 |
55 | static addTasks(tasks: Task[]) {
56 | if (!this.instance) {
57 | throw new Error('TaskManager not initialized');
58 | }
59 | this.instance.addTasks(tasks);
60 | }
61 |
62 | static startAll() {
63 | if (!this.instance) {
64 | throw new Error('TaskManager not initialized');
65 | }
66 | this.instance.startAll();
67 | }
68 |
69 | static stopAll() {
70 | if (!this.instance) {
71 | throw new Error('TaskManager not initialized');
72 | }
73 | this.instance.stopAll();
74 | }
75 | }
76 |
77 | export const createTask = (
78 | props: TCreateTaskProps
79 | ): Task => {
80 | const params = {
81 | ...props,
82 | interval: props.config.interval ?? 1000,
83 | };
84 |
85 | return global.createTask(params);
86 | };
87 |
--------------------------------------------------------------------------------
/tsconfig.build.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig",
3 | "exclude": ["example", "lib"]
4 | }
5 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": ".",
4 | "paths": {
5 | "react-native-sync-tasks": [
6 | "./src/index"
7 | ]
8 | },
9 | "allowUnreachableCode": false,
10 | "allowUnusedLabels": false,
11 | "esModuleInterop": true,
12 | "forceConsistentCasingInFileNames": true,
13 | "jsx": "react-native",
14 | "lib": [
15 | "esnext",
16 | "DOM"
17 | ],
18 | "module": "esnext",
19 | "moduleResolution": "node",
20 | "noFallthroughCasesInSwitch": true,
21 | "noImplicitReturns": true,
22 | "noImplicitUseStrict": false,
23 | "noStrictGenericChecks": false,
24 | "noUnusedLocals": true,
25 | "noUnusedParameters": true,
26 | "resolveJsonModule": true,
27 | "skipLibCheck": true,
28 | "strict": true,
29 | "target": "esnext"
30 | },
31 | "exclude": [
32 | "example",
33 | "node_modules",
34 | "dist"
35 | ]
36 | }
--------------------------------------------------------------------------------
/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://turbo.build/schema.json",
3 | "pipeline": {
4 | "build:android": {
5 | "env": ["ORG_GRADLE_PROJECT_newArchEnabled"],
6 | "inputs": [
7 | "package.json",
8 | "android",
9 | "!android/build",
10 | "src/*.ts",
11 | "src/*.tsx",
12 | "example/package.json",
13 | "example/android",
14 | "!example/android/.gradle",
15 | "!example/android/build",
16 | "!example/android/app/build"
17 | ],
18 | "outputs": []
19 | },
20 | "build:ios": {
21 | "env": ["RCT_NEW_ARCH_ENABLED"],
22 | "inputs": [
23 | "package.json",
24 | "*.podspec",
25 | "ios",
26 | "src/*.ts",
27 | "src/*.tsx",
28 | "example/package.json",
29 | "example/ios",
30 | "!example/ios/build",
31 | "!example/ios/Pods"
32 | ],
33 | "outputs": []
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------