Skip to content

Commit 52a83fc

Browse files
committed
Update opsqlite demo proj to work better w/ monorepos
1 parent 6807713 commit 52a83fc

File tree

10 files changed

+7654
-2089
lines changed

10 files changed

+7654
-2089
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node-linker=hoisted
Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
11
import '@azure/core-asynciterator-polyfill';
22
import React, { useEffect } from 'react';
3-
import type {PropsWithChildren} from 'react';
4-
import {
5-
SafeAreaView,
6-
ScrollView,
7-
StatusBar,
8-
StyleSheet,
9-
Text,
10-
useColorScheme,
11-
View,
12-
} from 'react-native';
3+
import type { PropsWithChildren } from 'react';
4+
import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, useColorScheme, View } from 'react-native';
135

146
import {
157
Colors,
168
DebugInstructions,
179
Header,
1810
LearnMoreLinks,
19-
ReloadInstructions,
11+
ReloadInstructions
2012
} from 'react-native/Libraries/NewAppScreen';
2113
import { OPSqliteOpenFactory } from '@powersync/op-sqlite';
22-
import { column, Schema, Table, PowerSyncDatabase } from '@powersync/react-native';
14+
import { column, Table, Schema, type PowerSyncBackendConnector, PowerSyncDatabase } from '@powersync/react-native';
2315

2416
/**
2517
* A placeholder connector which doesn't do anything but used to confirm connect can run.
2618
*/
27-
class DummyConnector {
19+
class DummyConnector implements PowerSyncBackendConnector {
2820
async fetchCredentials() {
2921
return {
3022
endpoint: '',
31-
token: '',
23+
token: ''
3224
};
3325
}
3426

@@ -45,12 +37,12 @@ const setupDatabase = async () => {
4537
if (powerSync) return powerSync;
4638

4739
const factory = new OPSqliteOpenFactory({
48-
dbFilename: 'powersync.db',
40+
dbFilename: 'powersync.db'
4941
});
5042

5143
powerSync = new PowerSyncDatabase({
5244
schema,
53-
database: factory,
45+
database: factory
5446
});
5547

5648
await powerSync.init();
@@ -61,26 +53,28 @@ type SectionProps = PropsWithChildren<{
6153
title: string;
6254
}>;
6355

64-
function Section({children, title}: SectionProps): React.JSX.Element {
56+
function Section({ children, title }: SectionProps): React.JSX.Element {
6557
const isDarkMode = useColorScheme() === 'dark';
6658
return (
6759
<View style={styles.sectionContainer}>
6860
<Text
6961
style={[
7062
styles.sectionTitle,
7163
{
72-
color: isDarkMode ? Colors.white : Colors.black,
73-
},
74-
]}>
64+
color: isDarkMode ? Colors.white : Colors.black
65+
}
66+
]}
67+
>
7568
{title}
7669
</Text>
7770
<Text
7871
style={[
7972
styles.sectionDescription,
8073
{
81-
color: isDarkMode ? Colors.light : Colors.dark,
82-
},
83-
]}>
74+
color: isDarkMode ? Colors.light : Colors.dark
75+
}
76+
]}
77+
>
8478
{children}
8579
</Text>
8680
</View>
@@ -91,7 +85,7 @@ function App(): React.JSX.Element {
9185
const isDarkMode = useColorScheme() === 'dark';
9286

9387
const backgroundStyle = {
94-
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
88+
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter
9589
};
9690

9791
useEffect(() => {
@@ -120,27 +114,24 @@ function App(): React.JSX.Element {
120114
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
121115
backgroundColor={backgroundStyle.backgroundColor}
122116
/>
123-
<ScrollView
124-
contentInsetAdjustmentBehavior="automatic"
125-
style={backgroundStyle}>
117+
<ScrollView contentInsetAdjustmentBehavior="automatic" style={backgroundStyle}>
126118
<Header />
127119
<View
128120
style={{
129-
backgroundColor: isDarkMode ? Colors.black : Colors.white,
130-
}}>
121+
backgroundColor: isDarkMode ? Colors.black : Colors.white
122+
}}
123+
>
131124
<Section title="Step One">
132-
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
133-
screen and then come back to see your edits.
125+
Edit <Text style={styles.highlight}>App.tsx</Text> to change this screen and then come back to see your
126+
edits.
134127
</Section>
135128
<Section title="See Your Changes">
136129
<ReloadInstructions />
137130
</Section>
138131
<Section title="Debug">
139132
<DebugInstructions />
140133
</Section>
141-
<Section title="Learn More">
142-
Read the docs to discover what to do next:
143-
</Section>
134+
<Section title="Learn More">Read the docs to discover what to do next:</Section>
144135
<LearnMoreLinks />
145136
</View>
146137
</ScrollView>
@@ -151,20 +142,20 @@ function App(): React.JSX.Element {
151142
const styles = StyleSheet.create({
152143
sectionContainer: {
153144
marginTop: 32,
154-
paddingHorizontal: 24,
145+
paddingHorizontal: 24
155146
},
156147
sectionTitle: {
157148
fontSize: 24,
158-
fontWeight: '600',
149+
fontWeight: '600'
159150
},
160151
sectionDescription: {
161152
marginTop: 8,
162153
fontSize: 18,
163-
fontWeight: '400',
154+
fontWeight: '400'
164155
},
165156
highlight: {
166-
fontWeight: '700',
167-
},
157+
fontWeight: '700'
158+
}
168159
});
169160

170161
export default App;

demos/react-native-barebones-opsqlite/Gemfile.lock

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)