hotwire-native-dev-tools 0.1.0-rc.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Leon Vogt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # Hotwire Native Dev Tools
2
+
3
+ Hotwire Native Dev Tools aims to support the development process of Hotwire Native apps by providing a set of tools to inspect and debug the app.
4
+
5
+ - 🔍 Inspect the bridge communication and native stack
6
+ - 🪵 View console logs right in the mobile app
7
+ - ⚠️ Detect common Turbo issues
8
+ - 📦 No dependencies
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install hotwire-native-dev-tools
14
+ ```
15
+ or
16
+
17
+ ```bash
18
+ yarn add hotwire-native-dev-tools
19
+ ```
20
+
21
+ ## How to use (JS)
22
+
23
+ **Basic usage:**
24
+ ```js
25
+ import { setupDevTools } from 'hotwire-native-dev-tools';
26
+ setupDevTools();
27
+ ```
28
+
29
+ However, since you probably want to use the dev tools only in mobile app development, **the recommend approach is to create a custom entrypoint** which you can load only when needed.
30
+
31
+ **Example Rails + Vite:**
32
+
33
+ ```erb
34
+ // layout/application.html.erb
35
+
36
+ <head>
37
+ <%= vite_javascript_tag "hotwire_native_dev_tools" if Rails.env.development? && hotwire_native_app? %>
38
+ </head>
39
+ ```
40
+
41
+ ```js
42
+ // app/javascript/entrypoints/hotwire_native_dev_tools.js
43
+
44
+ import { setupDevTools } from 'hotwire-native-dev-tools';
45
+ setupDevTools();
46
+ ```
47
+
48
+ ---
49
+
50
+ Alternatively, you could use a JS condition to check if the dev tools should be loaded:
51
+ ```js
52
+ import { setupDevTools } from 'hotwire-native-dev-tools';
53
+ const isDev = process.env.NODE_ENV === 'development';
54
+ setupDevTools({
55
+ enabled: isDev,
56
+ });
57
+ ```
58
+
59
+ Plase note that your JS condition may vary depending on your setup and needs.
60
+ The downside of this approach is, that you ship the JS code of the dev tools to the client, even if the client is not in development mode.
61
+ This dev tools package is quite small (~15kb), but if you want to avoid shipping unnecessary code to the client, you should use the custom entrypoint approach.
62
+
63
+ ## How to use (Native)
64
+
65
+ Some features like the **Native Stack** and **PathConfiguration properties** are only available, if you add the dev tool bridge components to your app:
66
+
67
+ ### iOS
68
+
69
+ 1. Copy the Swift file [DevToolsComponent.swift](./ios/DevToolsComponent.swift) into your Xcode project
70
+ 2. Register the component
71
+
72
+ ```diff
73
+ class AppDelegate: UIResponder, UIApplicationDelegate {
74
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
75
+ Hotwire.registerBridgeComponents([
76
+ + DevToolsComponent.self
77
+ ])
78
+ return true
79
+ }
80
+ }
81
+ ```
82
+
83
+ ### Android
84
+
85
+ 1. Copy the Kotlin file [DevToolsComponent.kt](./android/DevToolsComponent.kt) into your Android Studio project
86
+ 2. Update the package names where the comments say `// Replace with your package name`
87
+ 3. Register the component
88
+
89
+ ```diff
90
+ + import replace.with.your.package.name.DevToolsComponent
91
+
92
+ class DemoApplication : Application() {
93
+ override fun onCreate() {
94
+ super.onCreate()
95
+
96
+ Hotwire.registerBridgeComponents(
97
+ + BridgeComponentFactory("dev-tools", ::DevToolsComponent),
98
+ )
99
+ }
100
+ }
101
+ ```
102
+
103
+ ## Development
104
+
105
+ - Fork the project locally
106
+ - `npm install`
107
+ - `npm run dev`
108
+
109
+ **Setting Up the Package Locally**
110
+ One way to link the package locally is to use `yarn link`.
111
+ This allows you to develop the package and test it in another project.
112
+
113
+ In the root of this project run:
114
+ ```bash
115
+ yarn link
116
+ ```
117
+
118
+ In the project you want to use the package run:
119
+ ```bash
120
+ yarn link hotwire-native-dev-tools
121
+ ```
122
+
123
+
124
+ ## Contributing
125
+
126
+ Bug reports and pull requests are welcome on GitHub at https://github.com/leonvogt/hotwire-native-dev-tools.
127
+ Any contributions, whether it's a bug fix, a new feature, or just a suggestion for improvement, are most welcome.