bundo-appgen 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bundo-appgen",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "App generator CLI for React Native macOS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "RakaDoank <rakaaudira@gmail.com> (https://github.com/RakaDoank)",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"bin.mjs",
|
|
21
21
|
"lib",
|
|
22
22
|
"src",
|
|
23
|
+
"template",
|
|
23
24
|
"!*.tsbuildinfo"
|
|
24
25
|
],
|
|
25
26
|
"exports": {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import SwiftUI
|
|
2
|
+
import React
|
|
3
|
+
import React_RCTAppDelegate
|
|
4
|
+
import ReactAppDependencyProvider
|
|
5
|
+
|
|
6
|
+
@main
|
|
7
|
+
struct HelloWorldApp: App {
|
|
8
|
+
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
|
9
|
+
|
|
10
|
+
var body: some Scene {
|
|
11
|
+
Window("HelloWorld", id: "main") {
|
|
12
|
+
ReactNativeView(factory: appDelegate.reactNativeFactory)
|
|
13
|
+
}
|
|
14
|
+
.defaultSize(width: 1280, height: 720)
|
|
15
|
+
}
|
|
16
|
+
} // struct HelloWorldApp
|
|
17
|
+
|
|
18
|
+
// MARK: - App Delegate
|
|
19
|
+
|
|
20
|
+
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
21
|
+
private let reactNativeDelegate: ReactNativeDelegate
|
|
22
|
+
let reactNativeFactory: RCTReactNativeFactory
|
|
23
|
+
|
|
24
|
+
override init() {
|
|
25
|
+
self.reactNativeDelegate = ReactNativeDelegate()
|
|
26
|
+
self.reactNativeFactory = RCTReactNativeFactory(delegate: reactNativeDelegate)
|
|
27
|
+
self.reactNativeDelegate.dependencyProvider = RCTAppDependencyProvider()
|
|
28
|
+
|
|
29
|
+
super.init()
|
|
30
|
+
}
|
|
31
|
+
} // class AppDelegate
|
|
32
|
+
|
|
33
|
+
// MARK: - React Native Delegate
|
|
34
|
+
|
|
35
|
+
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
|
|
36
|
+
override func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
37
|
+
bundleURL()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override func bundleURL() -> URL? {
|
|
41
|
+
#if DEBUG
|
|
42
|
+
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
|
|
43
|
+
#else
|
|
44
|
+
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
|
|
45
|
+
#endif
|
|
46
|
+
}
|
|
47
|
+
} // class ReactNativeDelegate
|
|
48
|
+
|
|
49
|
+
// MARK: - React Native SwiftUI View
|
|
50
|
+
|
|
51
|
+
struct ReactNativeView: NSViewRepresentable {
|
|
52
|
+
let factory: RCTReactNativeFactory
|
|
53
|
+
|
|
54
|
+
func makeNSView(context: Context) -> NSView {
|
|
55
|
+
factory.rootViewFactory.view(withModuleName: "main")
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
func updateNSView(_ nsView: NSView, context: Context) {
|
|
59
|
+
}
|
|
60
|
+
} // struct ReactNativeView
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Resolve react_native_pods.rb with node to allow for hoisting
|
|
2
|
+
require Pod::Executable.execute_command('node', ['-p',
|
|
3
|
+
'require.resolve(
|
|
4
|
+
"react-native-macos/scripts/react_native_pods.rb",
|
|
5
|
+
{paths: [process.argv[1]]},
|
|
6
|
+
)', __dir__]).strip
|
|
7
|
+
|
|
8
|
+
prepare_react_native_project!
|
|
9
|
+
|
|
10
|
+
target 'HelloWorld' do
|
|
11
|
+
platform :macos, '14.0'
|
|
12
|
+
|
|
13
|
+
config = use_native_modules!
|
|
14
|
+
|
|
15
|
+
# Flags change depending on the env values.
|
|
16
|
+
flags = get_default_flags()
|
|
17
|
+
|
|
18
|
+
use_react_native!(
|
|
19
|
+
:path => config[:reactNativePath].gsub("node_modules/react-native", "node_modules/react-native-macos"),
|
|
20
|
+
:fabric_enabled => true,
|
|
21
|
+
# An absolute path to your application root.
|
|
22
|
+
:app_path => "#{Pod::Config.instance.installation_root}/.."
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
post_install do |installer|
|
|
26
|
+
react_native_post_install(
|
|
27
|
+
installer,
|
|
28
|
+
config[:reactNativePath],
|
|
29
|
+
:mac_catalyst_enabled => false,
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
end
|