Skip to content

Commit d00f255

Browse files
committed
Merge remote-tracking branch 'origin/main' into node-commonjs
2 parents 3d0f3eb + fcddc7b commit d00f255

File tree

71 files changed

+7959
-4703
lines changed

Some content is hidden

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

71 files changed

+7959
-4703
lines changed

.changeset/slimy-glasses-jog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@powersync/react': patch
3+
'@powersync/react-native': patch
4+
---
5+
6+
Fixed an issue with `useQuery` where initial query/parameter changes could cause a race condition if the first query took long.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/node': patch
3+
---
4+
5+
Update readme to refer to Node.js docs

demos/angular-supabase-todolist/src/app/supabase.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
type User
99
} from '@supabase/supabase-js';
1010
import { environment } from '../environment';
11-
import { type AbstractPowerSyncDatabase, type CrudEntry, UpdateType, PowerSyncBackendConnector } from '@powersync/web';
11+
import { type AbstractPowerSyncDatabase, type CrudEntry, UpdateType, PowerSyncBackendConnector, type PowerSyncCredentials } from '@powersync/web';
1212

1313
/// Postgres Response codes that we cannot recover from by retrying.
1414
const FATAL_RESPONSE_CODES = [
@@ -67,7 +67,7 @@ export class SupabaseService implements PowerSyncBackendConnector {
6767
return {
6868
endpoint: environment.powersyncUrl,
6969
token: session.access_token ?? ''
70-
};
70+
} satisfies PowerSyncCredentials;
7171
}
7272

7373
authChanges(callback: (event: AuthChangeEvent, session: Session | null) => void) {
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
**/.xcode.env.local
24+
25+
# Android/IntelliJ
26+
#
27+
build/
28+
.idea
29+
.gradle
30+
local.properties
31+
*.iml
32+
*.hprof
33+
.cxx/
34+
*.keystore
35+
!debug.keystore
36+
37+
# node.js
38+
#
39+
node_modules/
40+
npm-debug.log
41+
yarn-error.log
42+
43+
# fastlane
44+
#
45+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
46+
# screenshots whenever they are needed.
47+
# For more information about the recommended setup visit:
48+
# https://docs.fastlane.tools/best-practices/source-control/
49+
50+
**/fastlane/report.xml
51+
**/fastlane/Preview.html
52+
**/fastlane/screenshots
53+
**/fastlane/test_output
54+
55+
# Bundle artifact
56+
*.jsbundle
57+
58+
# Ruby / CocoaPods
59+
**/Pods/
60+
/vendor/bundle/
61+
62+
# Temporary files created by Metro to check the health of the file watcher
63+
.metro-health-check*
64+
65+
# testing
66+
/coverage
67+
68+
# Yarn
69+
.yarn/*
70+
!.yarn/patches
71+
!.yarn/plugins
72+
!.yarn/releases
73+
!.yarn/sdks
74+
!.yarn/versions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
import '@azure/core-asynciterator-polyfill';
2+
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';
13+
14+
import {
15+
Colors,
16+
DebugInstructions,
17+
Header,
18+
LearnMoreLinks,
19+
ReloadInstructions,
20+
} from 'react-native/Libraries/NewAppScreen';
21+
import { OPSqliteOpenFactory } from '@powersync/op-sqlite';
22+
import { column, Schema, Table, PowerSyncDatabase } from '@powersync/react-native';
23+
24+
/**
25+
* A placeholder connector which doesn't do anything but used to confirm connect can run.
26+
*/
27+
class DummyConnector {
28+
async fetchCredentials() {
29+
return {
30+
endpoint: '',
31+
token: '',
32+
};
33+
}
34+
35+
async uploadData() {}
36+
}
37+
38+
const customers = new Table({ name: column.text });
39+
40+
const schema = new Schema({ customers });
41+
42+
let powerSync: PowerSyncDatabase | null = null;
43+
44+
const setupDatabase = async () => {
45+
if (powerSync) return powerSync;
46+
47+
const factory = new OPSqliteOpenFactory({
48+
dbFilename: 'powersync.db',
49+
});
50+
51+
powerSync = new PowerSyncDatabase({
52+
schema,
53+
database: factory,
54+
});
55+
56+
await powerSync.init();
57+
return powerSync;
58+
};
59+
60+
type SectionProps = PropsWithChildren<{
61+
title: string;
62+
}>;
63+
64+
function Section({children, title}: SectionProps): React.JSX.Element {
65+
const isDarkMode = useColorScheme() === 'dark';
66+
return (
67+
<View style={styles.sectionContainer}>
68+
<Text
69+
style={[
70+
styles.sectionTitle,
71+
{
72+
color: isDarkMode ? Colors.white : Colors.black,
73+
},
74+
]}>
75+
{title}
76+
</Text>
77+
<Text
78+
style={[
79+
styles.sectionDescription,
80+
{
81+
color: isDarkMode ? Colors.light : Colors.dark,
82+
},
83+
]}>
84+
{children}
85+
</Text>
86+
</View>
87+
);
88+
}
89+
90+
function App(): React.JSX.Element {
91+
const isDarkMode = useColorScheme() === 'dark';
92+
93+
const backgroundStyle = {
94+
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
95+
};
96+
97+
useEffect(() => {
98+
const initDB = async () => {
99+
try {
100+
const db = await setupDatabase();
101+
102+
// Test database operations
103+
await db.execute('INSERT INTO customers(id, name) VALUES(uuid(), ?)', ['Fred']);
104+
const result = await db.getAll('SELECT * FROM customers');
105+
console.log('Customers:', result);
106+
107+
// Connect with dummy connector
108+
await db.connect(new DummyConnector());
109+
} catch (error) {
110+
console.error('Database initialization error:', error);
111+
}
112+
};
113+
114+
initDB();
115+
}, []);
116+
117+
return (
118+
<SafeAreaView style={backgroundStyle}>
119+
<StatusBar
120+
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
121+
backgroundColor={backgroundStyle.backgroundColor}
122+
/>
123+
<ScrollView
124+
contentInsetAdjustmentBehavior="automatic"
125+
style={backgroundStyle}>
126+
<Header />
127+
<View
128+
style={{
129+
backgroundColor: isDarkMode ? Colors.black : Colors.white,
130+
}}>
131+
<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.
134+
</Section>
135+
<Section title="See Your Changes">
136+
<ReloadInstructions />
137+
</Section>
138+
<Section title="Debug">
139+
<DebugInstructions />
140+
</Section>
141+
<Section title="Learn More">
142+
Read the docs to discover what to do next:
143+
</Section>
144+
<LearnMoreLinks />
145+
</View>
146+
</ScrollView>
147+
</SafeAreaView>
148+
);
149+
}
150+
151+
const styles = StyleSheet.create({
152+
sectionContainer: {
153+
marginTop: 32,
154+
paddingHorizontal: 24,
155+
},
156+
sectionTitle: {
157+
fontSize: 24,
158+
fontWeight: '600',
159+
},
160+
sectionDescription: {
161+
marginTop: 8,
162+
fontSize: 18,
163+
fontWeight: '400',
164+
},
165+
highlight: {
166+
fontWeight: '700',
167+
},
168+
});
169+
170+
export default App;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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'

0 commit comments

Comments
 (0)