Skip to content

Commit 8a60905

Browse files
committed
feat: move to separate package
1 parent 1f67936 commit 8a60905

26 files changed

Lines changed: 675 additions & 247 deletions

apps/example/App.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
1-
import React, { useCallback, useSyncExternalStore } from 'react';
21
import { StyleSheet, Text, View, Button, TextInput } from 'react-native';
3-
import {
4-
subscribe,
5-
getSnapshot,
6-
setState,
7-
} from '@callstack/react-native-brownfield';
2+
import { useBrownieStore, setState } from '@callstack/brownie';
83
import type { BrownfieldStore } from './brownfield-store.schema';
94

105
const STORE_KEY = 'BrownfieldStore';
116

12-
function useBrownfieldStore<T>(key: string): T {
13-
const sub = useCallback(
14-
(listener: () => void) => subscribe(key, listener),
15-
[key]
16-
);
17-
const snap = useCallback(() => getSnapshot<T>(key), [key]);
18-
return useSyncExternalStore(sub, snap, snap);
19-
}
20-
217
function HomeScreen() {
22-
const state = useBrownfieldStore<BrownfieldStore>(STORE_KEY);
8+
const state = useBrownieStore<BrownfieldStore>(STORE_KEY);
239

2410
const handleIncrement = () => {
2511
setState<BrownfieldStore>(STORE_KEY, { counter: state.counter + 1 });

apps/example/metro.config.cjs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
21
const path = require('path');
2+
const { getDefaultConfig } = require('@react-native/metro-config'); // Import from `@expo/metro-config` if using Expo CLI
3+
const { withMetroConfig } = require('react-native-monorepo-config');
34

4-
const root = path.resolve(__dirname, '../..');
5-
6-
/**
7-
* Metro configuration
8-
* https://reactnative.dev/docs/metro
9-
*
10-
* @type {import('@react-native/metro-config').MetroConfig}
11-
*/
12-
const config = {
13-
watchFolders: [root],
14-
};
15-
16-
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
5+
module.exports = withMetroConfig(
6+
getDefaultConfig(__dirname), // Metro config to extend
7+
{
8+
root: path.resolve(__dirname, '../..'), // Path to the monorepo root
9+
dirname: __dirname, // Path to the current directory
10+
}
11+
);

apps/example/package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66
"start": "react-native start"
77
},
88
"dependencies": {
9+
"@callstack/brownie": "*",
910
"@callstack/react-native-brownfield": "*",
11+
"@react-navigation/native": "^7.0.15",
12+
"@react-navigation/native-stack": "^7.2.1",
1013
"react": "19.1.1",
11-
"react-native": "0.82.1"
14+
"react-native": "0.82.1",
15+
"react-native-safe-area-context": "^5.3.0",
16+
"react-native-screens": "^4.15.2"
1217
},
1318
"devDependencies": {
1419
"@babel/core": "^7.25.2",
@@ -20,15 +25,14 @@
2025
"@react-native/babel-preset": "0.82.1",
2126
"@react-native/metro-config": "0.82.1",
2227
"@react-native/typescript-config": "0.82.1",
23-
"@react-navigation/native": "^7.0.15",
24-
"@react-navigation/native-stack": "^7.2.1",
25-
"react-native-safe-area-context": "^5.3.0",
26-
"react-native-screens": "^4.15.2"
28+
"@types/react": "^19.1.1",
29+
"babel-plugin-module-resolver": "^5.0.2",
30+
"react-native-monorepo-config": "^0.3.1"
2731
},
2832
"engines": {
2933
"node": ">=20"
3034
},
31-
"brownfield": {
35+
"brownie": {
3236
"stores": {
3337
"schema": "./brownfield-store.schema.ts",
3438
"typeName": "BrownfieldStore",

apps/example/react-native.config.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require('path');
2-
const pkg = require('../../packages/react-native-brownfield/package.json');
2+
const brownfieldPkg = require('../../packages/react-native-brownfield/package.json');
3+
const browniePkg = require('../../packages/brownie/package.json');
34

45
module.exports = {
56
project: {
@@ -11,12 +12,19 @@ module.exports = {
1112
},
1213
},
1314
dependencies: {
14-
[pkg.name]: {
15+
[brownfieldPkg.name]: {
1516
root: path.join(__dirname, '../../packages/react-native-brownfield'),
1617
platforms: {
1718
ios: {},
1819
android: {},
1920
},
2021
},
22+
[browniePkg.name]: {
23+
root: path.join(__dirname, '../../packages/brownie'),
24+
platforms: {
25+
ios: {},
26+
android: {},
27+
},
28+
},
2129
},
2230
};

apps/example/swift/App.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Brownie
12
import ReactBrownfield
23
import SwiftUI
34

apps/example/swift/Podfile.lock

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
PODS:
22
- boost (1.84.0)
3+
- Brownie (0.1.0):
4+
- boost
5+
- DoubleConversion
6+
- fast_float
7+
- fmt
8+
- glog
9+
- hermes-engine
10+
- RCT-Folly
11+
- RCT-Folly/Fabric
12+
- RCTRequired
13+
- RCTTypeSafety
14+
- React-Core
15+
- React-debug
16+
- React-Fabric
17+
- React-featureflags
18+
- React-graphics
19+
- React-ImageManager
20+
- React-jsi
21+
- React-NativeModulesApple
22+
- React-RCTFabric
23+
- React-renderercss
24+
- React-rendererdebug
25+
- React-utils
26+
- ReactCodegen
27+
- ReactCommon/turbomodule/bridging
28+
- ReactCommon/turbomodule/core
29+
- SocketRocket
30+
- Yoga
331
- DoubleConversion (1.1.6)
432
- fast_float (8.0.0)
533
- FBLazyVector (0.82.1)
@@ -2502,6 +2530,7 @@ PODS:
25022530

25032531
DEPENDENCIES:
25042532
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
2533+
- Brownie (from `../../../packages/brownie`)
25052534
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
25062535
- fast_float (from `../node_modules/react-native/third-party-podspecs/fast_float.podspec`)
25072536
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
@@ -2587,6 +2616,8 @@ SPEC REPOS:
25872616
EXTERNAL SOURCES:
25882617
boost:
25892618
:podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec"
2619+
Brownie:
2620+
:path: "../../../packages/brownie"
25902621
DoubleConversion:
25912622
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
25922623
fast_float:
@@ -2741,6 +2772,7 @@ EXTERNAL SOURCES:
27412772

27422773
SPEC CHECKSUMS:
27432774
boost: 7e761d76ca2ce687f7cc98e698152abd03a18f90
2775+
Brownie: d1a36299ae5b669a71da298023b7eb970ef7bd2c
27442776
DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
27452777
fast_float: b32c788ed9c6a8c584d114d0047beda9664e7cc6
27462778
FBLazyVector: 0aa6183b9afe3c31fc65b5d1eeef1f3c19b63bfa

apps/example/tsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../../tsconfig",
3+
"references": [
4+
{ "path": "../../packages/brownie" },
5+
{ "path": "../../packages/react-native-brownfield" }
6+
],
7+
"compilerOptions": {
8+
"rootDir": "."
9+
}
10+
}

packages/brownie/Brownie.podspec

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
require 'json'
2+
3+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4+
5+
Pod::Spec.new do |spec|
6+
spec.name = "Brownie"
7+
spec.version = package['version']
8+
spec.summary = package['description']
9+
spec.license = package['license']
10+
11+
spec.authors = package['author']
12+
spec.homepage = package['homepage']
13+
spec.platform = :ios, "14.0"
14+
15+
spec.module_name = "Brownie"
16+
spec.source = { :git => "git@github.com:callstack/react-native-brownfield.git", :tag => "#{spec.version}" }
17+
spec.source_files = "ios/**/*.{h,m,mm,swift}"
18+
spec.pod_target_xcconfig = {
19+
'DEFINES_MODULE' => 'YES',
20+
'OTHER_SWIFT_FLAGS' => "-enable-experimental-feature AccessLevelOnImport"
21+
}
22+
23+
install_modules_dependencies(spec)
24+
end

packages/brownie/babel.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'module:@react-native/babel-preset',
5+
{ useTransformReactJSXExperimental: true },
6+
],
7+
],
8+
};

packages/brownie/bob.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
source: 'src',
3+
output: 'lib',
4+
targets: [
5+
[
6+
'commonjs',
7+
{
8+
esm: true,
9+
configFile: true,
10+
},
11+
],
12+
[
13+
'module',
14+
{
15+
esm: true,
16+
configFile: true,
17+
},
18+
],
19+
[
20+
'typescript',
21+
{
22+
project: 'tsconfig.build.json',
23+
},
24+
],
25+
],
26+
};

0 commit comments

Comments
 (0)