Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/update-lockfiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ jobs:
cd example
bundle install
bun pods
bun pods:macos
cd ..

git add bun.lock
git add example/ios/Podfile.lock
git add example/macos/Podfile.lock
git add example/Gemfile.lock

git config --global user.name 'dependabot[bot]'
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ For a React Native macOS app, run CocoaPods from the `macos` directory:
cd macos && pod install
```

## Run the macOS example

The example targets macOS 14 or later with React Native macOS 0.81. This is the tested example configuration, not a guarantee that every older macOS version allowed by the podspec is supported.

Install the workspace dependencies and the example's Ruby dependencies, then run its `pods:macos` and `macos` scripts. The desktop app shares the mobile example's SQLite, TypeORM, sqlite-vec, SQL console, and benchmark screens.

To keep Metro in a separate terminal, run the `start` script in `example/macos` and launch the `macos` script with `--no-packager`. Use `--mode Release --no-packager` to build and launch the embedded production bundle.

---

# API overview
Expand Down
785 changes: 736 additions & 49 deletions bun.lock

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions example/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,15 @@ module.exports = {
project: true,
tsconfigRootDir: __dirname,
},
overrides: [
{
files: ['babel.config.shared.js', 'macos/**/*.{js,mjs}'],
parserOptions: {
project: null,
},
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
],
}
32 changes: 2 additions & 30 deletions example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
const path = require('path')
const pak = require('../packages/react-native-nitro-sqlite/package.json')
const createExampleBabelConfig = require('./babel.config.shared')

module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: [
[
'module-resolver',
{
extensions: ['.tsx', '.ts', '.js', '.json'],
alias: {
[pak.name]: path.join(
__dirname,
'../packages/react-native-nitro-sqlite',
pak.source,
),
'crypto': 'react-native-quick-crypto',
'stream': 'readable-stream',
'buffer': 'react-native-quick-crypto',
'react-native-sqlite-storage': 'react-native-nitro-sqlite',
'^@nitro-sqlite/(.+)':
'../packages/react-native-nitro-sqlite/src/\\1',
'^@/(.+)': './src/\\1',
'^@tests/(.+)': './tests/\\1',
},
},
],
'babel-plugin-transform-typescript-metadata',
['@babel/plugin-proposal-decorators', { legacy: true }],
],
}
module.exports = createExampleBabelConfig(__dirname)
47 changes: 47 additions & 0 deletions example/babel.config.shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const path = require('path')
const libraryPackage = require('../packages/react-native-nitro-sqlite/package.json')

function createExampleBabelConfig(projectRoot, { buffer, crypto } = {}) {
const sourceDirectory = path.join(projectRoot, 'src')
const testsDirectory = path.join(projectRoot, 'tests')
const aliases = {
[libraryPackage.name]: path.join(
__dirname,
'../packages/react-native-nitro-sqlite',
libraryPackage.source,
),
'stream': 'readable-stream',
'react-native-sqlite-storage': libraryPackage.name,
'^@nitro-sqlite/(.+)': path.join(
__dirname,
'../packages/react-native-nitro-sqlite/src/\\1',
),
'^@/(.+)': `${sourceDirectory}/\\1`,
'^@tests/(.+)': `${testsDirectory}/\\1`,
}

if (buffer !== false) {
aliases.buffer = buffer ?? 'react-native-quick-crypto'
}

if (crypto !== false) {
aliases.crypto = crypto ?? 'react-native-quick-crypto'
}

return {
presets: ['module:@react-native/babel-preset'],
plugins: [
[
'module-resolver',
{
extensions: ['.tsx', '.ts', '.js', '.json'],
alias: aliases,
},
],
'babel-plugin-transform-typescript-metadata',
['@babel/plugin-proposal-decorators', { legacy: true }],
],
}
}

module.exports = createExampleBabelConfig
2 changes: 2 additions & 0 deletions example/macos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# CocoaPods
Pods/
1 change: 1 addition & 0 deletions example/macos/.xcode.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export NODE_BINARY=$(command -v node)
6 changes: 6 additions & 0 deletions example/macos/NitroSQLiteExample-macOS/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import <RCTAppDelegate.h>
#import <Cocoa/Cocoa.h>

@interface AppDelegate : RCTAppDelegate

@end
45 changes: 45 additions & 0 deletions example/macos/NitroSQLiteExample-macOS/AppDelegate.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <ReactAppDependencyProvider/RCTAppDependencyProvider.h>

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
self.moduleName = @"NitroSQLiteExample";
self.initialProps = @{};
self.dependencyProvider = [RCTAppDependencyProvider new];

return [super applicationDidFinishLaunching:notification];
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
return [self bundleURL];
}

- (NSURL *)bundleURL
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
///
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
- (BOOL)concurrentRootEnabled
{
#ifdef RN_FABRIC_ENABLED
return true;
#else
return false;
#endif
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Loading