Skip to content

Commit

Permalink
chore: run format
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicGBauer committed Aug 22, 2024
1 parent 7d04f74 commit a768991
Show file tree
Hide file tree
Showing 27 changed files with 112 additions and 92 deletions.
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
**/android/**
**/assets/**
**/bin/**
**/ios/**
**/ios/**

**/devlink/**
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a href="https://www.powersync.com" target="_blank"><img src="https://github.com/powersync-ja/.github/assets/7372448/d2538c43-c1a0-4c47-9a76-41462dba484f"/></a>
</p>

*[PowerSync](https://www.powersync.com) is a Postgres-SQLite sync layer, which helps developers to create local-first real-time reactive apps that work seamlessly both online and offline.*
_[PowerSync](https://www.powersync.com) is a Postgres-SQLite sync layer, which helps developers to create local-first real-time reactive apps that work seamlessly both online and offline._

# PowerSync JavaScript SDKs

Expand All @@ -17,7 +17,7 @@
- [packages/web](./packages/web/README.md)

- JS Web SDK implementation (extension of `packages/common`)

- [packages/react](./packages/react/README.md)

- React integration for PowerSync.
Expand Down
5 changes: 1 addition & 4 deletions demos/angular-supabase-todolist/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
"customWebpackConfig": {
"path": "./extra-webpack.config.js"
},
"allowedCommonJsDependencies": [
"js-logger",
"ws"
],
"allowedCommonJsDependencies": ["js-logger", "ws"],
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
Expand Down
4 changes: 2 additions & 2 deletions demos/django-react-native-todolist/app/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export default function Signin() {
<TextInputWidget
style={SignInStyles.input}
placeholder="Username"
autoCapitalize='none'
autoCapitalize="none"
onChangeText={(value) => setCredentials({ ...credentials, username: value.toLowerCase().trim() })}
/>
<TextInputWidget
style={SignInStyles.input}
placeholder="Password"
secureTextEntry={true}
autoCapitalize='none'
autoCapitalize="none"
onChangeText={(value) => setCredentials({ ...credentials, password: value })}
/>
{error ? <Text style={{ color: 'red' }}>{error}</Text> : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const ListItemWidget: React.FC<{
pathname: 'views/todos/edit/[id]',
params: { id: record.id }
});
}}></ListItem.Chevron>
}}
></ListItem.Chevron>
</ListItem>
</View>
);
Expand Down
8 changes: 4 additions & 4 deletions demos/example-capacitor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ To see it in action:

To run the iOS version of the app run:

1. `pnpm sync`
2. `pnpm ios`
1. `pnpm sync`
2. `pnpm ios`

## Android

To run the Android version of the app run:

1. `pnpm sync`
2. `pnpm android` (to see console run `chrome://inspect/#devices` in browser)
1. `pnpm sync`
2. `pnpm android` (to see console run `chrome://inspect/#devices` in browser)
3 changes: 1 addition & 2 deletions demos/example-capacitor/src/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
margin: auto;
max-width: 38rem;
padding: 2rem;
Expand Down
12 changes: 7 additions & 5 deletions demos/example-capacitor/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"short_name": "App",
"start_url": "index.html",
"display": "standalone",
"icons": [{
"src": "assets/imgs/logo.png",
"sizes": "512x512",
"type": "image/png"
}],
"icons": [
{
"src": "assets/imgs/logo.png",
"sizes": "512x512",
"type": "image/png"
}
],
"background_color": "#31d53d",
"theme_color": "#31d53d"
}
2 changes: 1 addition & 1 deletion demos/example-electron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ To see it in action:
2. Copy `.env.local.template` to `.env.local`, and complete the environment variables. You can generate a [temporary development token](https://docs.powersync.com/usage/installation/authentication-setup/development-tokens), or leave blank to test with local-only data.
3. `cd` into this directory and run `pnpm start`.

The Electron app should open automatically.
The Electron app should open automatically.
3 changes: 2 additions & 1 deletion demos/example-electron/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const EntryPage = () => {
return (
<S.MainGrid container>
<p>
Syncing down from the backend. This will load indefinitely if you have not set up the connection correctly. Check the console for issues.
Syncing down from the backend. This will load indefinitely if you have not set up the connection correctly.
Check the console for issues.
</p>
<CircularProgress />
</S.MainGrid>
Expand Down
3 changes: 1 addition & 2 deletions demos/example-electron/src/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
Arial, sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
margin: auto;
max-width: 38rem;
padding: 2rem;
Expand Down
4 changes: 2 additions & 2 deletions demos/example-nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const EntryPage = () => {
return (
<S.MainGrid container>
<p>
Syncing down from the backend. This will load indefinitely if you have not set up the connection correctly. Check the console for issues.
Syncing down from the backend. This will load indefinitely if you have not set up the connection correctly.
Check the console for issues.
</p>
<CircularProgress />
</S.MainGrid>
Expand Down Expand Up @@ -52,7 +53,6 @@ const EntryPage = () => {
);
};


namespace S {
export const CenteredGrid = styled(Grid)`
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion demos/react-multi-client/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"singleQuote": true,
"bracketSameLine": true,
"trailingComma": "none"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ export default function GroupSettings() {
backgroundColor="$red10"
color="white"
onPress={handleDelete}
margin="$3">
margin="$3"
>
Delete group
</Button>
</YStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function ContactsIndex() {
icon={<Search size="$1.5" />}
backgroundColor="$brand1"
borderRadius="$3"
// circular
// circular
/>
</XStack>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const SystemProvider = ({ children }: { children: React.ReactNode }) => {
const l = connector.registerListener({
initialized: () => {},
sessionStarted: () => {
powerSync.connect(connector, {connectionMethod: SyncStreamConnectionMethod.WEB_SOCKET});
powerSync.connect(connector, { connectionMethod: SyncStreamConnectionMethod.WEB_SOCKET });
}
});

Expand Down
28 changes: 14 additions & 14 deletions docs/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,31 @@
#returns + p + p + table,
#returns + div,
#returns + div + table,
[id^="returns-"],
[id^="returns-"] + p,
[id^="returns-"] + p + p,
[id^="returns-"] + p + p,
[id^="returns-"] + p + p + table,
[id^="returns-"] + div,
[id^="returns-"] + div + table,
[id^='returns-'],
[id^='returns-'] + p,
[id^='returns-'] + p + p,
[id^='returns-'] + p + p,
[id^='returns-'] + p + p + table,
[id^='returns-'] + div,
[id^='returns-'] + div + table,
#type-parameters,
#type-parameters + table,
[id^="type-parameters-"],
[id^="type-parameters-"] + table,
[id^='type-parameters-'],
[id^='type-parameters-'] + table,
#inherited-from,
#inherited-from + p,
[id^="inherited-from-"],
[id^="inherited-from-"] + p {
[id^='inherited-from-'],
[id^='inherited-from-'] + p {
display: none;
}

/* Expand parameter and enumeration tables to full width */
#parameters + table,
[id^="parameters-"] + table,
[id^='parameters-'] + table,
#properties + table,
[id^="properties-"] + table,
[id^='properties-'] + table,
#enumeration-members + table,
[id^="enumeration-members-"] + table {
[id^='enumeration-members-'] + table {
width: 100%;
table-layout: fixed;
display: table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
*/
private async deleteBucket(bucket: string) {
await this.writeTransaction(async (tx) => {
await tx.execute(
'INSERT INTO powersync_operations(op, data) VALUES(?, ?)',
['delete_bucket', bucket]);
await tx.execute('INSERT INTO powersync_operations(op, data) VALUES(?, ?)', ['delete_bucket', bucket]);
});

this.logger.debug('done deleting bucket');
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export * from './client/sync/bucket/OplogEntry';
export * from './client/sync/stream/AbstractRemote';
export * from './client/sync/stream/AbstractStreamingSyncImplementation';
export * from './client/sync/stream/streaming-sync-types';
export { MAX_OP_ID } from './client/constants'
export { MAX_OP_ID } from './client/constants';

export * from './db/crud/SyncStatus';
export * from './db/crud/UploadQueueStatus';
Expand Down
2 changes: 1 addition & 1 deletion packages/kysely-driver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const powerSyncDb = new PowerSyncDatabase({
database: {
dbFilename: 'test.sqlite'
},
schema: appSchema,
schema: appSchema
});

export const db = wrapPowerSyncWithKysely(powerSyncDb);
Expand Down
69 changes: 43 additions & 26 deletions packages/react-native/vendor/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,100 @@
// Modifications:
// - Instead of applying to all global references of crypto, provide a ponyfill export.

const base64Decode = require('fast-base64-decode')
const { NativeModules } = require('react-native')
const base64Decode = require('fast-base64-decode');
const { NativeModules } = require('react-native');

class TypeMismatchError extends Error {}
class QuotaExceededError extends Error {}

let warned = false
function insecureRandomValues (array) {
let warned = false;
function insecureRandomValues(array) {
if (!warned) {
console.warn('Using an insecure random number generator, this should only happen when running in a debugger without support for crypto.getRandomValues')
warned = true
console.warn(
'Using an insecure random number generator, this should only happen when running in a debugger without support for crypto.getRandomValues'
);
warned = true;
}

for (let i = 0, r; i < array.length; i++) {
if ((i & 0x03) === 0) r = Math.random() * 0x100000000
array[i] = (r >>> ((i & 0x03) << 3)) & 0xff
if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
array[i] = (r >>> ((i & 0x03) << 3)) & 0xff;
}

return array
return array;
}

/**
* @param {number} byteLength
* @returns {string}
*/
function getRandomBase64 (byteLength) {
function getRandomBase64(byteLength) {
if (NativeModules.RNGetRandomValues) {
return NativeModules.RNGetRandomValues.getRandomBase64(byteLength)
return NativeModules.RNGetRandomValues.getRandomBase64(byteLength);
} else if (NativeModules.ExpoRandom) {
// Expo SDK 41-44
return NativeModules.ExpoRandom.getRandomBase64String(byteLength)
return NativeModules.ExpoRandom.getRandomBase64String(byteLength);
} else if (global.ExpoModules) {
// Expo SDK 45+
return global.ExpoModules.ExpoRandom.getRandomBase64String(byteLength);
} else {
throw new Error('Native module not found')
throw new Error('Native module not found');
}
}

/**
* @param {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Uint8ClampedArray} array
*/
function getRandomValues (array) {
if (!(array instanceof Int8Array || array instanceof Uint8Array || array instanceof Int16Array || array instanceof Uint16Array || array instanceof Int32Array || array instanceof Uint32Array || array instanceof Uint8ClampedArray)) {
throw new TypeMismatchError('Expected an integer array')
function getRandomValues(array) {
if (
!(
array instanceof Int8Array ||
array instanceof Uint8Array ||
array instanceof Int16Array ||
array instanceof Uint16Array ||
array instanceof Int32Array ||
array instanceof Uint32Array ||
array instanceof Uint8ClampedArray
)
) {
throw new TypeMismatchError('Expected an integer array');
}

if (array.byteLength > 65536) {
throw new QuotaExceededError('Can only request a maximum of 65536 bytes')
throw new QuotaExceededError('Can only request a maximum of 65536 bytes');
}

// Expo SDK 48+
if (global.expo && global.expo.modules && global.expo.modules.ExpoCrypto && global.expo.modules.ExpoCrypto.getRandomValues) {
if (
global.expo &&
global.expo.modules &&
global.expo.modules.ExpoCrypto &&
global.expo.modules.ExpoCrypto.getRandomValues
) {
// ExpoCrypto.getRandomValues doesn't return the array
global.expo.modules.ExpoCrypto.getRandomValues(array)
return array
global.expo.modules.ExpoCrypto.getRandomValues(array);
return array;
}

// Calling getRandomBase64 in remote debugging mode leads to the error
// "Calling synchronous methods on native modules is not supported in Chrome".
// So in that specific case we fall back to just using Math.random().
if (isRemoteDebuggingInChrome()) {
return insecureRandomValues(array)
return insecureRandomValues(array);
}

base64Decode(getRandomBase64(array.byteLength), new Uint8Array(array.buffer, array.byteOffset, array.byteLength))
base64Decode(getRandomBase64(array.byteLength), new Uint8Array(array.buffer, array.byteOffset, array.byteLength));

return array
return array;
}

function isRemoteDebuggingInChrome () {
function isRemoteDebuggingInChrome() {
// Remote debugging in Chrome is not supported in bridgeless
if ('RN$Bridgeless' in global && RN$Bridgeless === true) {
return false
return false;
}

return __DEV__ && typeof global.nativeCallSyncHook === 'undefined'
return __DEV__ && typeof global.nativeCallSyncHook === 'undefined';
}

export default { getRandomValues };
Loading

0 comments on commit a768991

Please sign in to comment.