bundo-appgen 0.0.2 → 0.0.4

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.2",
3
+ "version": "0.0.4",
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,6 @@
1
+ {
2
+ "info": {
3
+ "version": 1,
4
+ "author": "dev.bundo"
5
+ }
6
+ }
@@ -0,0 +1,48 @@
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
+ require 'pathname'
9
+
10
+ # Find the real "react-native-macos" path.
11
+ react_native_macos_path = Pathname.new(
12
+ Pod::Executable.execute_command(
13
+ 'node',
14
+ [
15
+ '-p',
16
+ 'require.resolve("react-native-macos/package.json")',
17
+ ],
18
+ ).strip.gsub('/package.json', '')
19
+ ).relative_path_from(__dir__).to_path
20
+
21
+ prepare_react_native_project!
22
+
23
+ target 'HelloWorld' do
24
+ platform :macos, '14.0'
25
+
26
+ # Do not use `config[:reactNativePath]` from here because,
27
+ # the `use_native_modules` def is still trying to find the "react-native" instead of "react-native-macos" path.
28
+ # We should fix this in "react-native-macos/scripts" Ruby script files.
29
+ config = use_native_modules!
30
+
31
+ # Flags change depending on the env values.
32
+ flags = get_default_flags()
33
+
34
+ use_react_native!(
35
+ :path => react_native_macos_path,
36
+ :fabric_enabled => true,
37
+ # An absolute path to your application root.
38
+ :app_path => "#{Pod::Config.instance.installation_root}/.."
39
+ )
40
+
41
+ post_install do |installer|
42
+ react_native_post_install(
43
+ installer,
44
+ react_native_macos_path,
45
+ :mac_catalyst_enabled => false,
46
+ )
47
+ end
48
+ end