Skip to content

Commit ad944f8

Browse files
krizzudependabot[bot]AsyncStorageBot
committed
sqlite-storage: scaffold workspace (#1071)
* chore(deps): bump follow-redirects from 1.15.4 to 1.15.6 (#1074) * feat(default-storage): Add Privacy Manifest for iOS (#1075) privacy file * chore(release): 1.23.0 [skip ci] * fix(default-storage): Privacy manifest missing key (#1076) add missing key * chore(release): 1.23.1 [skip ci] * chore(deps): bump webpack-dev-middleware from 5.3.3 to 5.3.4 (#1077) Bumps [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) from 5.3.3 to 5.3.4. - [Release notes](https://github.com/webpack/webpack-dev-middleware/releases) - [Changelog](https://github.com/webpack/webpack-dev-middleware/blob/v5.3.4/CHANGELOG.md) - [Commits](webpack/webpack-dev-middleware@v5.3.3...v5.3.4) --- updated-dependencies: - dependency-name: webpack-dev-middleware dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore: GH workflows, turbo and other chores (#1073) * explicit prettierrc * turbo * format test * pull-request workflow * update actions * bump to yarn 4 * build script * init * examples * comments * fix glob * namespace * windows build * fixing windows action * android example search for node_modules --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: AsyncStorageBot <[email protected]>
1 parent d4a3eee commit ad944f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4424
-140
lines changed

Diff for: .github/actions/setup-project/action.yml

+9
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@ inputs:
55
required: false
66
description: node version to install
77
default: 20.10.0 # is already cached in Ubuntu 22.04 runner
8+
windows-fix:
9+
required: false
10+
description: https://github.com/actions/setup-node/issues/899#issuecomment-1837381044
11+
default: "false"
812
runs:
913
using: composite
1014
steps:
15+
- uses: actions/setup-node@v4
16+
if: ${{ inputs.windows-fix == 'true' }}
17+
name: (Windows fix) Setup node without cache
18+
with:
19+
node-version: ${{ inputs.node-version }}
1120
- name: Enable corepack
1221
shell: bash
1322
run: |

Diff for: .github/workflows/default-storage.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
token: ${{ secrets.GH_RELEASE_TOKEN }}
1919
filters: |
2020
storage:
21-
- 'packages/default-storage'
21+
- 'packages/default-storage/**'
2222
2323
android:
2424
name: Android
@@ -127,6 +127,8 @@ jobs:
127127
uses: actions/checkout@v4
128128
- name: Setup project
129129
uses: ./.github/actions/setup-project
130+
with:
131+
windows-fix: true
130132
- name: Install JS dependencies
131133
run: |
132134
yarn

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ local.properties
3131
#workspaces
3232
/packages/*/lib
3333
.turbo
34+
build/

Diff for: packages/default-storage/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"src/",
1919
"windows/"
2020
],
21-
"author": "Krzysztof Borowy <[email protected]>",
21+
"author": "Krzysztof Borowy <[email protected]>",
2222
"contributors": [
2323
"Evan Bacon <[email protected]> (https://github.com/evanbacon)",
2424
"Tommy Nguyen <[email protected]> (https://github.com/tido64)"

Diff for: packages/default-storage/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "./tsconfig.build.json",
2+
"extends": "../../.config/tsconfig.base.json",
33
"compilerOptions": {
44
"noEmit": true,
55
"types": [

Diff for: packages/sqlite-storage/.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.pbxproj -text
2+
# specific for windows script files
3+
*.bat text eol=crlf

Diff for: packages/sqlite-storage/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Async Storage SQLite
2+
3+
Key-value persistent storage for React Native backed by SQLite.

Diff for: packages/sqlite-storage/RNAsyncStorageSQLite.podspec

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
require "json"
2+
3+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5+
6+
Pod::Spec.new do |s|
7+
s.name = File.basename(__FILE__, '.podspec')
8+
s.version = package["version"]
9+
s.summary = package["description"]
10+
s.homepage = package["homepage"]
11+
s.license = package["license"]
12+
s.authors = package["author"]
13+
14+
s.platforms = { :ios => min_ios_version_supported }
15+
s.source = { :git => "https://github.com/react-native-async-storage/async-storage.git", :tag => "#{s.version}" }
16+
17+
s.source_files = "ios/**/*.{h,m,mm,swift}"
18+
19+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21+
if respond_to?(:install_modules_dependencies, true)
22+
install_modules_dependencies(s)
23+
else
24+
s.dependency "React-Core"
25+
26+
# Don't install the dependencies when we run `pod install` in the old architecture.
27+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
28+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
29+
s.pod_target_xcconfig = {
30+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
31+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
32+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
33+
}
34+
s.dependency "React-Codegen"
35+
s.dependency "RCT-Folly"
36+
s.dependency "RCTRequired"
37+
s.dependency "RCTTypeSafety"
38+
s.dependency "ReactCommon/turbomodule/core"
39+
end
40+
end
41+
end

Diff for: packages/sqlite-storage/android/build.gradle

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
buildscript {
2+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
3+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["SqliteStorage_kotlinVersion"]
4+
5+
repositories {
6+
google()
7+
mavenCentral()
8+
}
9+
10+
dependencies {
11+
classpath "com.android.tools.build:gradle:7.2.1"
12+
// noinspection DifferentKotlinGradleVersion
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
}
15+
}
16+
17+
def isNewArchitectureEnabled() {
18+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19+
}
20+
21+
apply plugin: "com.android.library"
22+
apply plugin: "kotlin-android"
23+
24+
if (isNewArchitectureEnabled()) {
25+
apply plugin: "com.facebook.react"
26+
}
27+
28+
def getExtOrDefault(name) {
29+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["SqliteStorage_" + name]
30+
}
31+
32+
def getExtOrIntegerDefault(name) {
33+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["SqliteStorage_" + name]).toInteger()
34+
}
35+
36+
def supportsNamespace() {
37+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
38+
def major = parsed[0].toInteger()
39+
def minor = parsed[1].toInteger()
40+
41+
// Namespace support was added in 7.3.0
42+
return (major == 7 && minor >= 3) || major >= 8
43+
}
44+
45+
android {
46+
if (supportsNamespace()) {
47+
namespace "org.rnasyncstorage.sqlitestorage"
48+
49+
sourceSets {
50+
main {
51+
manifest.srcFile "src/main/AndroidManifestNew.xml"
52+
}
53+
}
54+
}
55+
56+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
57+
58+
defaultConfig {
59+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
60+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
61+
62+
}
63+
64+
buildTypes {
65+
release {
66+
minifyEnabled false
67+
}
68+
}
69+
70+
lintOptions {
71+
disable "GradleCompatible"
72+
}
73+
74+
compileOptions {
75+
sourceCompatibility JavaVersion.VERSION_1_8
76+
targetCompatibility JavaVersion.VERSION_1_8
77+
}
78+
}
79+
80+
repositories {
81+
mavenCentral()
82+
google()
83+
}
84+
85+
def kotlin_version = getExtOrDefault("kotlinVersion")
86+
87+
dependencies {
88+
// For < 0.71, this will be from the local maven repo
89+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
90+
//noinspection GradleDynamicVersion
91+
implementation "com.facebook.react:react-native:+"
92+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
93+
}
94+

Diff for: packages/sqlite-storage/android/gradle.properties

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SqliteStorage_kotlinVersion=1.7.0
2+
SqliteStorage_minSdkVersion=21
3+
SqliteStorage_targetSdkVersion=31
4+
SqliteStorage_compileSdkVersion=31
5+
SqliteStorage_ndkversion=21.4.7075529
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="org.rnasyncstorage.sqlitestorage">
3+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.rnasyncstorage.sqlitestorage
2+
3+
import com.facebook.react.bridge.ReactApplicationContext
4+
import com.facebook.react.bridge.ReactContextBaseJavaModule
5+
import com.facebook.react.bridge.ReactMethod
6+
import com.facebook.react.bridge.Promise
7+
8+
class SqliteStorageModule(reactContext: ReactApplicationContext) :
9+
ReactContextBaseJavaModule(reactContext) {
10+
11+
override fun getName(): String {
12+
return NAME
13+
}
14+
15+
// Example method
16+
// See https://reactnative.dev/docs/native-modules-android
17+
@ReactMethod
18+
fun multiply(a: Double, b: Double, promise: Promise) {
19+
promise.resolve(a * b)
20+
}
21+
22+
companion object {
23+
const val NAME = "SqliteStorage"
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.rnasyncstorage.sqlitestorage
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 SqliteStoragePackage : ReactPackage {
10+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11+
return listOf(SqliteStorageModule(reactContext))
12+
}
13+
14+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15+
return emptyList()
16+
}
17+
}

Diff for: packages/sqlite-storage/babel.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ["module:@react-native/babel-preset"],
3+
};

Diff for: packages/sqlite-storage/eslint.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("@react-native-async-storage/eslint-config");

Diff for: packages/sqlite-storage/example/.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

Diff for: packages/sqlite-storage/example/App.tsx

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import React, { useState } from "react";
2+
import {
3+
Button,
4+
SafeAreaView,
5+
ScrollView,
6+
Text,
7+
StatusBar,
8+
StyleSheet,
9+
useColorScheme,
10+
View,
11+
} from "react-native";
12+
import { Colors } from "react-native/Libraries/NewAppScreen";
13+
import { multiply } from "@react-native-async-storage/sqlite-storage";
14+
15+
function App(): React.JSX.Element {
16+
const isDarkMode = useColorScheme() === "dark";
17+
const [result, setResult] = useState<string | null>(null);
18+
19+
const backgroundStyle = {
20+
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
21+
};
22+
23+
async function test() {
24+
const random = Math.round(Math.random() * 100);
25+
const result = await multiply(random, 2);
26+
setResult(`${random} * 2 = ${result}`);
27+
}
28+
29+
return (
30+
<SafeAreaView style={[backgroundStyle, styles.container]}>
31+
<StatusBar
32+
barStyle={isDarkMode ? "light-content" : "dark-content"}
33+
backgroundColor={backgroundStyle.backgroundColor}
34+
/>
35+
<ScrollView
36+
contentInsetAdjustmentBehavior="automatic"
37+
style={backgroundStyle}
38+
>
39+
<Button title="test module" onPress={() => test()} />
40+
<View style={styles.result}>
41+
{result ? <Text style={styles.title}>{result}</Text> : null}
42+
</View>
43+
</ScrollView>
44+
</SafeAreaView>
45+
);
46+
}
47+
48+
const styles = StyleSheet.create({
49+
container: {
50+
marginTop: 32,
51+
paddingHorizontal: 24,
52+
},
53+
title: {
54+
fontSize: 24,
55+
fontWeight: "600",
56+
textAlign: "center",
57+
},
58+
sectionDescription: {
59+
marginTop: 8,
60+
fontSize: 24,
61+
fontWeight: "400",
62+
},
63+
result: {
64+
fontSize: 24,
65+
marginTop: 24,
66+
fontWeight: "700",
67+
},
68+
});
69+
70+
export default App;

Diff for: packages/sqlite-storage/example/android/build.gradle

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
buildscript {
2+
apply(from: {
3+
def searchDir = rootDir.toPath()
4+
do {
5+
def p = searchDir.resolve("node_modules/react-native-test-app/android/dependencies.gradle")
6+
if (p.toFile().exists()) {
7+
return p.toRealPath().toString()
8+
}
9+
} while (searchDir = searchDir.getParent())
10+
throw new GradleException("Could not find `react-native-test-app`");
11+
}())
12+
13+
repositories {
14+
mavenCentral()
15+
google()
16+
}
17+
18+
dependencies {
19+
getReactNativeDependencies().each { dependency ->
20+
classpath(dependency)
21+
}
22+
}
23+
}
24+
25+
allprojects {
26+
repositories {
27+
maven {
28+
url({
29+
def searchDir = rootDir.toPath()
30+
do {
31+
def p = searchDir.resolve("node_modules/react-native/android")
32+
if (p.toFile().exists()) {
33+
return p.toRealPath().toString()
34+
}
35+
} while (searchDir = searchDir.getParent())
36+
throw new GradleException("Could not find `react-native`");
37+
}())
38+
}
39+
mavenCentral()
40+
google()
41+
}
42+
}

0 commit comments

Comments
 (0)