diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
deleted file mode 100644
index 726c0a6d..00000000
--- a/.github/FUNDING.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-# These are supported funding model platforms
-
-github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
-patreon: streetwriters
-open_collective: # Replace with a single Open Collective username
-tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
-community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
-liberapay: # Replace with a single Liberapay username
-issuehunt: # Replace with a single IssueHunt username
-otechie: # Replace with a single Otechie username
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index 4ec272a6..00000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,32 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-title: "[Bug]"
-labels: ''
-assignees: ''
-
----
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-**To Reproduce**
-Steps to reproduce the behavior:
-1. Go to '...'
-2. Click on '....'
-3. Scroll down to '....'
-4. See error
-
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**Screenshots**
-If applicable, add screenshots to help explain your problem.
-
-**Platform Information:**
- - OS: [e.g. iOS/Android]
- - React Native Version [e.g. 0.64]
- - Library Version [e.g. 0.5.8]
-
-**Additional context**
-Add any other context about the problem here.
diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml
deleted file mode 100644
index dd08d893..00000000
--- a/.github/workflows/ios.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-name: iOS
-on:
- push:
- branches:
- - master
- - fix-ci
- pull_request:
- paths:
- - '.github/workflows/ios.yml'
- - 'src/**'
- - 'ios/**'
- - 'MMKV/**'
-jobs:
- build:
- runs-on: macos-latest
- steps:
- - uses: actions/checkout@v2
-
- - run: npm ci --legacy-peer-deps
- - run: npm run build
-
- - run: yarn
- working-directory: example
-
- - run: xcode-select -p
-
- - run: pod install
- working-directory: example/ios
- name: Install pod dependencies
- - name: Build iOS (debug)
- working-directory: example/ios
- run: "xcodebuild \
- -workspace example.xcworkspace \
- -scheme example \
- clean archive \
- -sdk iphonesimulator \
- -configuration Debug \
- -UseModernBuildSystem=YES \
- CODE_SIGNING_ALLOWED=NO"
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644
index 38301807..00000000
--- a/.github/workflows/main.yml
+++ /dev/null
@@ -1,57 +0,0 @@
-name: Android
-
-on:
- push:
- branches:
- - master
- - fix-ci
- pull_request:
- paths:
- - '.github/workflows/main.yml'
- - 'src/**'
- - 'android/**'
- - 'MMKV/**'
-
-jobs:
- build:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- include:
- - version: '0.75.x'
- folder: 'rn75'
-
- steps:
- - uses: actions/checkout@v2
-
- - run: printenv
-
- - name: Get yarn cache directory path
- id: yarn-cache-dir-path
- run: echo "::set-output name=dir::$(yarn cache dir)"
-
- - uses: actions/cache@v2
- id: yarn-cache
- with:
- path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
- key: ${{ runner.os }}-yarn-${{ matrix.version }}
- restore-keys: |
- ${{ runner.os }}-yarn-
-
- - name: Build Android apk (release & debug)
- env:
- RN_VERSION: ${{ matrix.version }}
- RN_FOLDER: ${{ matrix.folder }}
- ANDROID_NDK_HOME: /usr/local/lib/android/sdk/ndk/26.1.10909125
- run: |
- echo $RN_VERSION $RN_FOLDER $ANDROID_NDK_HOME
- [[ "$RN_VERSION" == "reanimated-2" ]] && git clone --depth=1 https://github.com/software-mansion-labs/reanimated-2-playground.git "$RN_FOLDER" || npx react-native init "$RN_FOLDER" --version "$RN_VERSION"
- npm ci --legacy-peer-deps
- npm run build
- rm -rf node_modules
- cd "$RN_FOLDER"
- yarn add file:..
- cd ./android
- ./gradlew assembleRelease
- ./gradlew assembleDebug
diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml
deleted file mode 100644
index 8cf67097..00000000
--- a/.github/workflows/npm-publish.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-name: NPM Publish
-
-on:
- release:
- types: [published]
-
-jobs:
- publish-npm:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-node@v2
- with:
- node-version: 16
- registry-url: https://registry.npmjs.org/
- - run: npm ci --legacy-peer-deps
- - run: npm run build
- - run: npm publish
- env:
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index fc33f4a7..00000000
--- a/.gitignore
+++ /dev/null
@@ -1,48 +0,0 @@
-
-# OSX
-#
-.DS_Store
-
-# node.js
-#
-node_modules/
-npm-debug.log
-yarn-error.log
-
-
-# Xcode
-#
-build/
-*.pbxuser
-!default.pbxuser
-*.mode1v3
-!default.mode1v3
-*.mode2v3
-!default.mode2v3
-*.perspectivev3
-!default.perspectivev3
-xcuserdata
-*.xccheckout
-*.moved-aside
-DerivedData
-*.hmap
-*.ipa
-*.xcuserstate
-project.xcworkspace
-
-
-# Android/IntelliJ
-#
-*.aar
-build/
-.cxx
-.idea
-.gradle
-local.properties
-*.iml
-
-# BUCK
-buck-out/
-\.buckd/
-*.keystore
-dist
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
deleted file mode 100644
index 187c844a..00000000
--- a/.npmignore
+++ /dev/null
@@ -1,66 +0,0 @@
-src/
-!dist/src
-!android/src
-.github
-.vscode
-.yarn
-index.ts
-tsconfig.json
-jest/tsconfig.json
-
-jest/memoryStore.ts
-
-# OSX
-#
-.DS_Store
-
-# node.js
-#
-node_modules/
-npm-debug.log
-yarn-error.log
-
-
-# Xcode
-#
-build/
-*.pbxuser
-!default.pbxuser
-*.mode1v3
-!default.mode1v3
-*.mode2v3
-!default.mode2v3
-*.perspectivev3
-!default.perspectivev3
-xcuserdata
-*.xccheckout
-*.moved-aside
-DerivedData
-*.hmap
-*.ipa
-*.xcuserstate
-project.xcworkspace
-
-
-# Docs
-docs/
-
-# Android/IntelliJ
-#
-build/
-.idea
-.gradle
-local.properties
-*.iml
-.cxx
-android/build
-
-# BUCK
-buck-out/
-\.buckd/
-*.keystore
-
-# Other
-
-example/
-
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index 8ac87f2a..00000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "cmake.sourceDirectory": "/Users/ammarahmed/Repos/react-native/react-native-mmkv-storage/MMKV/Core"
-}
diff --git a/README.md b/README.md
index 5fea89d3..b50d4b57 100644
--- a/README.md
+++ b/README.md
@@ -1,198 +1,13 @@
-
-

-
+# @react-native-oh-tpl/react-native-mmkv-storage
-#
+本项目基于 [react-native-mmkv-storage](https://github.com/ammarahm-ed/react-native-mmkv-storage)
-
+[中文 / Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-mmkv-storage.md)
-
-
Install the library
-
npm install react-native-mmkv-storage
-
+[英文 / English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-en/react-native-mmkv-storage.md)
-
-
For expo bare workflow
-
expo prebuild
-
+## 请悉知 / Acknowledgements
-
-
-## What it is
-
-This library aims to provide a fast & reliable solution for you data storage needs in react-native apps. It uses [MMKV](https://github.com/Tencent/MMKV) by Tencent under the hood on Android and iOS both that is used by their WeChat app(more than 1 Billion users). Unlike other storage solutions for React Native, this library lets you store any kind of data type, in any number of database instances, with or without encryption in a very fast and efficient way. Read about it on this blog post I wrote on [dev.to](https://dev.to/ammarahmed/best-data-storage-option-for-react-native-apps-42k)
-
-> Learn how to build your own module with JSI on my [blog](https://blog.notesnook.com/getting-started-react-native-jsi/)
-
-## 0.9.0 Breaking change
-
-Works only with react native 0.71.0 and above. If you are on older version of react native, keep using 0.8.x.
-
-## Features
-
-### **Written in C++ using JSI**
-
-Starting from `v0.5.0` the library has been rewritten in C++ on Android and iOS both. It employs React Native JSI making it the fastest storage option for React Native.
-
-### **Simple and lightweight**
-
-(~ 50K Android/30K iOS) and even smaller when packaged.
-
-### **Fast and Efficient (0.0002s Read/Write Speed)**
-
-MMKV uses mmap to keep memory synced with file, and protobuf to encode/decode values to achieve best performance.
-You can see the benchmarks here: [Android](https://github.com/Tencent/MMKV/wiki/android_benchmark) & [iOS](https://github.com/Tencent/MMKV/wiki/iOS_benchmark)
-
-### **Reactive using `useMMKVStorage` & `useIndex` Hooks**
-
-Hooks let's the storage update your app when a change takes place in storage.
-
-#### `useMMKVStorage` hook
-
-Starting from `v0.5.5`, thanks to the power of JSI, we now have our very own `useMMKVStorage` Hook. Think of it like a persisted state that will always write every change in storage and update your app UI instantly. It doesn't matter if you reload the app or restart it.
-
-```js
-import { MMKVLoader, useMMKVStorage } from 'react-native-mmkv-storage';
-
-const storage = new MMKVLoader().initialize();
-const App = () => {
- const [user, setUser] = useMMKVStorage('user', storage, 'robert');
- const [age, setAge] = useMMKVStorage('age', storage, 24);
-
- return (
-
-
- I am {user} and I am {age} years old.
-
-
- );
-};
-```
-
-Learn more about `useMMKVStorage` hook it in the [docs](https://rnmmkv.vercel.app/#/usemmkvstorage).
-
-#### `useIndex` hook
-
-A hook that will take an array of keys and returns an array of values for those keys. This is supposed to work in combination with Transactions. When you have build your custom index, you will need an easy and quick way to load values for your index. useIndex hook actively listens to all read/write changes and updates the values accordingly.
-
-```js
-const App = () => {
- // Get list of all post ids
- const postsIndex = useMMKVStorage("postsIndex",storage,[]); // ['post123','post234'];
- // Get the posts based on those ids.
- const [posts,update,remove] = useIndex(postsIndex,"object" storage);
-
- return
-
-
-
-}
-```
-
-Learn more about `useIndex` hook it in the [docs](https://rnmmkv.vercel.app/#/useindex).
-
-### **Lifecycle Control with Transaction Manager**
-
-Listen to a value's lifecycle and mutate it on the go. Transactions lets you register lifecycle functions with your storage instance such as Read, Write and Delete. This allows for a better and more managed control over the storage and also let's you **build custom indexes** with a few lines of code.
-
-```js
-MMKV.transactions.register('object', 'beforewrite', ({ key, value }) => {
- if (key.startsWith('post.')) {
- // Call this only when the key has the post prefix.
- let indexForTag = MMKV.getArray(`${value.tag}-index`) || [];
- MMKV.setArray(indexForTag.push(key));
- }
-});
-```
-
-Learn more about how to use Transactions in [docs](https://rnmmkv.vercel.app/#/transactionmanager)
-
-### **Multi-Process Support**
-
-MMKV supports concurrent read-read and read-write access between processes. This means that you can use MMKV for various extensions and widgets and your app.
-
-### **Create unlimited Database instances**
-
-You can create many database instances. This helps greatly if you have separate logics/modules in the same app that use data differently, It also helps in better performance since each database instance is small instead of a single bulky database which makes things slower as it grows.
-
-```js
-const userStorage = new MMKVLoader().withEncryption().withInstanceID('userdata').initialize();
-
-const settingsStorage = new MMKVLoader().withInstanceID('settings').initialize();
-```
-
-### **Full encryption support**
-
-The library supports full encryption (AES CFB-128) on Android and iOS. You can choose to store your encryption key securely for continuious usage. The library uses Keychain on iOS and Android Keystore on android (API 23 and above). Encrypting an instance is simple:
-
-```js
-const storage = new MMKVLoader()
- .withEncryption() // Generates a random key and stores it securely in Keychain
- .initialize();
-```
-
-And that's it.
-
-### **Simple indexer and data querying**
-
-For each database instance, there is one global key index and then there are indexes of each type of data. So querying is easy and fast.
-
-### **Supports redux-persist**
-
-Support for redux persist is also added starting from v0.3.2.
-
-### **Supports expo**
-
-You can use this library with expo [bare workflow](https://docs.expo.dev/workflow/customizing/).
-
-### **Flipper plugin**
-
-Thanks to [pnthach95](https://github.com/pnthach95/flipper-plugin-react-native-mmkv-storage/commits?author=pnthach95) Flipper plugin is finally here. https://github.com/pnthach95/flipper-plugin-react-native-mmkv-storage. It supports logging and manipulating storage values on the fly.
-
-## Consider supporting with a ⭐️ [star on GitHub](https://github.com/ammarahm-ed/react-native-mmkv-storage/)
-
-If you are using the library in one of your projects, consider supporting with a star. It takes a lot of time and effort to keep this maintained and address issues and bugs. Thank you.
-
-## Contact & Support
-
-- Create a GitHub issue for bug reports, feature requests, or questions
-- Follow [@ammarahm-ed](https://github.com/ammarahm-ed)
-
-## I want to contribute
-
-That is awesome news! There is a lot happening at a very fast pace in this library right now. Every little help is precious. You can contribute in many ways:
-
-- Suggest code improvements on native iOS and Android
-- If you have suggestion or idea you want to discuss, open an issue.
-- [Open an issue](https://github.com/ammarahm-ed/react-native-mmkv-storage/issues/) if you want to make a pull request, and tell me what you want to improve or add so we can discuss
-- I am always open to new ideas
-
-## Special thanks to
-
-- [ospfranco](https://github.com/ospfranco) and his work on [react-native-quick-sqlite](https://github.com/ospfranco/react-native-quick-sqlite) library which inspired async read/write.
-
-## License
-
-This library is licensed under the [MIT license](https://github.com/ammarahm-ed/react-native-mmkv-storage/blob/master/LICENSE).
-
-Copyright © Ammar Ahmed ([@ammarahm-ed](https://github.com/ammarahm-ed))
-
-#
-
-
-
-
+本项目基于 [The MIT License (MIT)](https://github.com/ammarahm-ed/react-native-mmkv-storage/blob/master/LICENSE) ,请自由地享受和参与开源。
\ No newline at end of file
diff --git a/android/.classpath b/android/.classpath
deleted file mode 100644
index 8d8d85f1..00000000
--- a/android/.classpath
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/android/.project b/android/.project
deleted file mode 100644
index 3865e0fa..00000000
--- a/android/.project
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
- android
- Project android created by Buildship.
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.buildship.core.gradleprojectbuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.eclipse.buildship.core.gradleprojectnature
-
-
diff --git a/android/build.gradle b/android/build.gradle
deleted file mode 100644
index f000c0d4..00000000
--- a/android/build.gradle
+++ /dev/null
@@ -1,108 +0,0 @@
-buildscript {
- repositories {
- maven {
- url "https://plugins.gradle.org/m2/"
- }
- mavenCentral()
- google()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:7.2.2'
- }
-}
-
-def resolveBuildType() {
- Gradle gradle = getGradle()
- String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()
-
- return tskReqStr.contains('Release') ? 'release' : 'debug'
-}
-
-apply plugin: 'com.android.library'
-
-def safeExtGet(prop, fallback) {
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
-}
-
-def reactNativeArchitectures() {
- def value = project.getProperties().get("reactNativeArchitectures")
- return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
-}
-
-def isNewArchitectureEnabled() {
- return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
-}
-
-def USE_HERMES = rootProject.ext.hermesEnabled
-
-repositories {
- mavenCentral()
-}
-
-android {
- compileSdkVersion safeExtGet("compileSdkVersion", 31)
-
- def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
- if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
- namespace "com.ammarahmed.mmkv"
- }
-
- if (rootProject.hasProperty("ndkPath")) {
- ndkPath rootProject.ext.ndkPath
- }
- if (rootProject.hasProperty("ndkVersion")) {
- ndkVersion rootProject.ext.ndkVersion
- }
-
- buildFeatures {
- prefab true
- buildConfig true
- }
-
-
-
- defaultConfig {
- minSdkVersion safeExtGet('minSdkVersion', 19)
- targetSdkVersion safeExtGet('targetSdkVersion', 31)
- buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
- var appProject = rootProject.allprojects.find {it.plugins.hasPlugin('com.android.application')}
- externalNativeBuild {
- cmake {
- cppFlags "-O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all"
- arguments "-DANDROID_STL=c++_shared"
- abiFilters (*reactNativeArchitectures())
- }
- }
- packagingOptions {
- doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
- excludes = [
- "META-INF",
- "META-INF/**",
- "**/libfbjni.so",
- "**/libjsi.so",
- "**/libreact_nativemodule_core.so",
- "**/libturbomodulejsijni.so",
- "**/libc++_shared.so"
- ]
- }
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- externalNativeBuild {
- cmake {
- path "./src/main/rnmmkv/CMakeLists.txt"
- }
- }
-}
-
-dependencies {
- //noinspection GradleDynamicVersion
- implementation 'com.facebook.react:react-android:+'
- implementation "androidx.security:security-crypto:1.1.0-alpha03"
- implementation 'com.google.code.gson:gson:2.8.6'
-}
-
diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100755
index f6b961fd..00000000
Binary files a/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100755
index 0d37ed4d..00000000
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Mon Mar 09 09:56:54 PKT 2020
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
diff --git a/android/gradlew b/android/gradlew
deleted file mode 100755
index cccdd3d5..00000000
--- a/android/gradlew
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/env sh
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/android/gradlew.bat b/android/gradlew.bat
deleted file mode 100755
index e95643d6..00000000
--- a/android/gradlew.bat
+++ /dev/null
@@ -1,84 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
deleted file mode 100644
index 09c8481f..00000000
--- a/android/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/android/src/main/java/com/ammarahmed/mmkv/Constants.java b/android/src/main/java/com/ammarahmed/mmkv/Constants.java
deleted file mode 100644
index 0e336d96..00000000
--- a/android/src/main/java/com/ammarahmed/mmkv/Constants.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.ammarahmed.mmkv;
-
-public class Constants {
-
- // Key Store
- public static final String KEYSTORE_PROVIDER_1 = "AndroidKeyStore";
- public static final String KEYSTORE_PROVIDER_2 = "AndroidKeyStoreBCWorkaround";
- public static final String KEYSTORE_PROVIDER_3 = "AndroidOpenSSL";
-
- public static final String RSA_ALGORITHM = "RSA/ECB/PKCS1Padding";
- public static final String AES_ALGORITHM = "AES/ECB/PKCS5Padding";
-
- public static final String TAG = "RNSecureStorage";
-
- // Internal storage file
- public static final String SKS_KEY_FILENAME = "SKS_KEY_FILE";
- public static final String SKS_DATA_FILENAME = "SKS_DATA_FILE";
-
-
- public static final int DATA_TYPE_STRING = 1;
- public static final int DATA_TYPE_INT = 2;
- public static final int DATA_TYPE_BOOL = 3;
- public static final int DATA_TYPE_MAP = 4;
- public static final int DATA_TYPE_ARRAY = 5;
-
-}
diff --git a/android/src/main/java/com/ammarahmed/mmkv/MMKV.java b/android/src/main/java/com/ammarahmed/mmkv/MMKV.java
deleted file mode 100644
index 0eefe5ae..00000000
--- a/android/src/main/java/com/ammarahmed/mmkv/MMKV.java
+++ /dev/null
@@ -1,261 +0,0 @@
-package com.ammarahmed.mmkv;
-
-import android.content.Context;
-import android.os.Parcel;
-import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import java.lang.reflect.Field;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-
-public class MMKV {
-
- static public final int SINGLE_PROCESS_MODE = 0x1;
- static public final int MULTI_PROCESS_MODE = 0x2;
- private long nativeHandle;
- private static final Set checkedHandleSet;
- private String rootDir;
-
- static {
- checkedHandleSet = Collections.synchronizedSet(new HashSet());
- }
-
- // call on program start
- public static String initialize(Context context) {
- String root = context.getFilesDir().getAbsolutePath() + "/mmkv";
- return initialize(root);
- }
-
- public static String initialize(String rootDir) {
-
- jniInitialize(rootDir, 0);
- rootDir = rootDir;
- return rootDir;
- }
-
- private static native void jniInitialize(String rootDir, int level);
-
-
- @Nullable
- public static MMKV mmkvWithID(String mmapID) {
-
- long handle = getMMKVWithID(mmapID, SINGLE_PROCESS_MODE, null, null);
- return checkProcessMode(handle, mmapID, SINGLE_PROCESS_MODE);
- }
-
- @Nullable
- public static MMKV mmkvWithID(String mmapID, int mode, @Nullable String cryptKey) {
-
- long handle = getMMKVWithID(mmapID, mode, cryptKey, null);
- return checkProcessMode(handle, mmapID, mode);
- }
-
- @Nullable
- public static MMKV mmkvWithID(String mmapID, int mode) {
-
-
- long handle = getMMKVWithID(mmapID, mode, null, null);
- return checkProcessMode(handle, mmapID, mode);
- }
-
- private native static long
- getMMKVWithID(String mmapID, int mode, @Nullable String cryptKey, @Nullable String rootPath);
-
-
- @Nullable
- private static MMKV checkProcessMode(long handle, String mmapID, int mode) {
- if (handle == 0) {
- return null;
- }
- if (!checkedHandleSet.contains(handle)) {
- if (!checkProcessMode(handle)) {
- String message;
- if (mode == SINGLE_PROCESS_MODE) {
- message = "Opening a multi-process MMKV instance [" + mmapID + "] with SINGLE_PROCESS_MODE!";
- } else {
- message = "Opening a MMKV instance [" + mmapID + "] with MULTI_PROCESS_MODE, ";
- message += "while it's already been opened with SINGLE_PROCESS_MODE by someone somewhere else!";
- }
- throw new IllegalArgumentException(message);
- }
- checkedHandleSet.add(handle);
- }
-
- return new MMKV(handle);
-
- }
-
- private MMKV(long handle) {
- nativeHandle = handle;
- }
-
- private static native boolean checkProcessMode(long handle);
-
- public boolean containsKey(String key) {
- return containsKey(nativeHandle, key);
- }
- private native boolean containsKey(long handle, String key);
-
- @SuppressWarnings("unchecked")
- @Nullable
- public T decodeParcelable(String key, Class tClass) {
- return decodeParcelable(key, tClass, null);
- }
-
- @SuppressWarnings("unchecked")
- @Nullable
- public T decodeParcelable(String key, Class tClass, @Nullable T defaultValue) {
- if (tClass == null) {
- return defaultValue;
- }
-
- byte[] bytes = decodeBytes(nativeHandle, key);
- if (bytes == null) {
- return defaultValue;
- }
-
- Parcel source = Parcel.obtain();
- source.unmarshall(bytes, 0, bytes.length);
- source.setDataPosition(0);
-
- try {
- String name = tClass.toString();
- Parcelable.Creator creator;
- synchronized (mCreators) {
- creator = (Parcelable.Creator) mCreators.get(name);
- if (creator == null) {
- Field f = tClass.getField("CREATOR");
- creator = (Parcelable.Creator) f.get(null);
- if (creator != null) {
- mCreators.put(name, creator);
- }
- }
- }
- if (creator != null) {
- return creator.createFromParcel(source);
- } else {
- throw new Exception("Parcelable protocol requires a "
- + "non-null static Parcelable.Creator object called "
- + "CREATOR on class " + name);
- }
- } catch (Exception e) {
-
- } finally {
- source.recycle();
- }
- return defaultValue;
- }
-
- private static final HashMap> mCreators = new HashMap<>();
-
- @Nullable
- private native byte[] decodeBytes(long handle, String key);
-
- public void removeValueForKey(String key) {
- removeValueForKey(nativeHandle, key);
- }
-
- private native void removeValueForKey(long handle, String key);
-
- @Nullable
- public Set decodeStringSet(String key) {
- return decodeStringSet(key, null);
- }
-
- @Nullable
- public Set decodeStringSet(String key, @Nullable Set defaultValue) {
- return decodeStringSet(key, defaultValue, HashSet.class);
- }
-
- @Nullable
- private native String[] decodeStringSet(long handle, String key);
-
- @SuppressWarnings("unchecked")
- @Nullable
- public Set decodeStringSet(String key, @Nullable Set defaultValue, Class extends Set> cls) {
- String[] result = decodeStringSet(nativeHandle, key);
- if (result == null) {
- return defaultValue;
- }
- Set a;
- try {
- a = cls.newInstance();
- } catch (IllegalAccessException e) {
- return defaultValue;
- } catch (InstantiationException e) {
- return defaultValue;
- }
- a.addAll(Arrays.asList(result));
- return a;
- }
-
- public int decodeInt(String key) {
- return decodeInt(nativeHandle, key, 0);
- }
-
- public int decodeInt(String key, int defaultValue) {
- return decodeInt(nativeHandle, key, defaultValue);
- }
-
- private native int decodeInt(long handle, String key, int defaultValue);
-
- public double decodeDouble(String key) {
- return decodeDouble(nativeHandle, key, 0);
- }
-
- public double decodeDouble(String key, double defaultValue) {
- return decodeDouble(nativeHandle, key, defaultValue);
- }
-
- private native double decodeDouble(long handle, String key, double defaultValue);
-
- public boolean encode(String key, @Nullable String value) {
- return encodeString(nativeHandle, key, value);
- }
-
- private native boolean encodeString(long handle, String key, @Nullable String value);
-
- public boolean encode(String key, double value) {
- return encodeDouble(nativeHandle, key, value);
- }
-
- private native boolean encodeDouble(long handle, String key, double value);
-
- public boolean encode(String key, int value) {
- return encodeInt(nativeHandle, key, value);
- }
-
- private native boolean encodeInt(long handle, String key, int value);
-
- public boolean encode(String key, @Nullable Set value) {
- return encodeSet(nativeHandle, key, (value == null) ? null : value.toArray(new String[0]));
- }
-
- private native boolean encodeSet(long handle, String key, @Nullable String[] value);
-
- @Nullable
- public native String[] getAllKeys(long handle);
-
- @NonNull
- public Set getAllKeys() {
- String[] result = getAllKeys(nativeHandle);
-
- if(result == null) {
- return Collections.emptySet();
- }
-
- return new HashSet<>(Arrays.asList(result));
- }
-
- @Nullable
- private native String decodeString(long handle, String key, String defaultValue);
-
- @Nullable
- public String decodeString(String key, @Nullable String defaultValue) {
- return decodeString(nativeHandle, key, defaultValue);
- }
-}
diff --git a/android/src/main/java/com/ammarahmed/mmkv/RNMMKVModule.java b/android/src/main/java/com/ammarahmed/mmkv/RNMMKVModule.java
deleted file mode 100644
index 80f3fdb7..00000000
--- a/android/src/main/java/com/ammarahmed/mmkv/RNMMKVModule.java
+++ /dev/null
@@ -1,199 +0,0 @@
-package com.ammarahmed.mmkv;
-
-import android.os.Bundle;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.util.Log;
-
-import androidx.annotation.Nullable;
-
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.Callback;
-import com.facebook.react.bridge.JavaScriptContextHolder;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.bridge.ReactContextBaseJavaModule;
-import com.facebook.react.bridge.ReactMethod;
-import com.facebook.react.bridge.ReadableMap;
-import com.facebook.react.bridge.WritableArray;
-import com.facebook.react.bridge.WritableMap;
-import com.facebook.react.module.annotations.ReactModule;
-import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
-import com.google.gson.Gson;
-import com.ammarahmed.mmkv.MMKV;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-@ReactModule(name = RNMMKVModule.NAME)
-public class RNMMKVModule extends ReactContextBaseJavaModule {
-
- public static final String NAME = "MMKVNative";
-
- private final ReactApplicationContext reactContext;
- private SecureKeystore secureKeystore;
-
- static {
- System.loadLibrary("rnmmkv");
- }
-
- private native void nativeInstall(long jsi, String rootPath);
-
- private native void destroy();
-
- public RNMMKVModule(ReactApplicationContext reactContext) {
- super(reactContext);
- this.reactContext = reactContext;
- secureKeystore = new SecureKeystore(reactContext);
- }
-
- public void installLib(JavaScriptContextHolder reactContext, String rootPath) {}
-
- // Installing JSI Bindings as done by
- // https://github.com/mrousavy/react-native-mmkv
- @ReactMethod(isBlockingSynchronousMethod = true)
- public boolean install() {
-
- String rootPath = reactContext.getFilesDir().getAbsolutePath() + "/mmkv";
- JavaScriptContextHolder jsContext = getReactApplicationContext().getJavaScriptContextHolder();
- CallInvokerHolderImpl jsCallInvokerHolder = (CallInvokerHolderImpl)reactContext.getCatalystInstance().getJSCallInvokerHolder();
-
- if (jsContext.get() != 0) {
- migrate();
- this.nativeInstall(
- jsContext.get(),
- rootPath
- );
- return true;
- } else {
- Log.e("RNMMKVModule","JSI Runtime is not available in debug mode");
- return false;
- }
-
- }
-
- @Override
- public void initialize() {
- super.initialize();
- }
-
- public void migrate() {
- MMKV.initialize(reactContext);
- MMKV kv = MMKV.mmkvWithID("mmkvIDStore");
- boolean hasKey = kv.containsKey("mmkvIdStore");
- HashMap IdStore = new HashMap<>();
- if (hasKey) {
- Bundle mmkvIdStore = kv.decodeParcelable("mmkvIdStore", Bundle.class);
- IdStore = (HashMap) mmkvIdStore.getSerializable("mmkvIdStore");
- Set keys = IdStore.keySet();
- for (String key : keys) {
- HashMap child = (HashMap) IdStore.get(key);
-
- boolean isEncrypted = false;
- if (child.containsKey("encrypted")) {
- isEncrypted = (boolean) child.get("encrypted");
- }
- if (isEncrypted && !child.containsKey("alias")) {
- Set storeKeys = child.keySet();
- String alias = (String) child.get("alias");
- for (String storeKey: storeKeys) {
- if (storeKey == null) continue;
- if (!storeKey.equals("ID") && !storeKey.equals("encrypted")) {
- alias = (String) child.get(storeKey);
- }
- }
- child.put("alias",alias);
- }
- Gson gson = new Gson();
- String json = gson.toJson(child);
- kv.encode(key, json);
-
- if (isEncrypted) {
- String alias = (String) child.get("alias");
- if (secureKeystore.secureKeyExists(alias)) {
- String cKey = secureKeystore.getSecureKey(alias);
- MMKV kvv = MMKV.mmkvWithID(key, MMKV.SINGLE_PROCESS_MODE, cKey);
- writeToJSON(kvv);
- }
- } else {
- MMKV kvv = MMKV.mmkvWithID(key, MMKV.SINGLE_PROCESS_MODE);
- writeToJSON(kvv);
- }
-
- }
- kv.removeValueForKey("mmkvIdStore");
- }
- }
-
- public void writeToJSON(MMKV kvv) {
- Gson gson = new Gson();
- Set mapIndex = new HashSet<>();
- mapIndex = kvv.decodeStringSet("mapIndex", mapIndex);
- if (mapIndex != null) {
- for (String string : mapIndex) {
- Bundle bundle = kvv.decodeParcelable(string, Bundle.class);
- if (bundle != null) {
- WritableMap map = Arguments.fromBundle(bundle);
- String obj = gson.toJson(map.toHashMap());
- kvv.encode(string, obj);
- }
-
- }
- }
- Set arrayIndex = new HashSet<>();
- arrayIndex = kvv.decodeStringSet("arrayIndex", arrayIndex);
- if (arrayIndex != null) {
- for (String string : arrayIndex) {
- Bundle bundle = kvv.decodeParcelable(string, Bundle.class);
- if (bundle != null) {
- WritableMap map = Arguments.fromBundle(bundle);
- if (map.getArray(string) != null) {
- ArrayList