@appsent-co/react-native-watchos 0.1.2 → 0.1.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.
@@ -152,8 +152,16 @@ public final class ReactNativeWatchOSHost: ObservableObject {
152
152
  Bundle.main.url(forResource: name, withExtension: "jsbundle")
153
153
  }
154
154
 
155
+ /// - Parameter entry: Metro entry path (no extension). Defaults to
156
+ /// `"index.watchos"` so the request becomes `/index.watchos.bundle`,
157
+ /// which Metro resolves to the literal `index.watchos.{tsx,ts,jsx,js}`
158
+ /// on disk. A bare `"index"` would resolve to `index.ts` (the
159
+ /// iOS/Android entry from package.json `main`) — Metro applies the
160
+ /// `.watchos.*` extension to in-graph `require`s, not to the entry
161
+ /// path itself. Monorepo callers can override with e.g.
162
+ /// `entry: "my-app/index.watchos"`.
155
163
  public static func defaultBundleURL(
156
- entry: String = "index",
164
+ entry: String = "index.watchos",
157
165
  host: String = "127.0.0.1",
158
166
  port: Int = 8081,
159
167
  name: String = "main"
package/cli/init.js CHANGED
@@ -91,6 +91,22 @@ function isWatchTargetConfig(dir) {
91
91
 
92
92
  /** @param {string} targetDir */
93
93
  function writeContentView(targetDir) {
94
+ // `create-target watch` drops its own `content.swift` placeholder that
95
+ // declares `struct ContentView: View`. Ours does too, so leaving both in
96
+ // the target compiles to "Invalid redeclaration of 'ContentView'". Wipe
97
+ // the placeholder (root + preview/) before writing ours.
98
+ for (const dir of [targetDir, path.join(targetDir, 'preview')]) {
99
+ if (!fs.existsSync(dir)) continue;
100
+ for (const name of fs.readdirSync(dir)) {
101
+ if (name.toLowerCase() !== 'content.swift') continue;
102
+ const p = path.join(dir, name);
103
+ fs.rmSync(p);
104
+ console.log(
105
+ `› Removed ${path.relative(process.cwd(), p)} (create-target placeholder; conflicts with ContentView.swift).`
106
+ );
107
+ }
108
+ }
109
+
94
110
  const dest = path.join(targetDir, 'ContentView.swift');
95
111
  const src = path.join(TEMPLATES, 'ContentView.swift');
96
112
  fs.copyFileSync(src, dest);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsent-co/react-native-watchos",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Build WatchOS apps in react-native",
5
5
  "main": "./plugin/src/index.js",
6
6
  "bin": {
@@ -20,7 +20,7 @@ struct ContentView: View {
20
20
  // For real-device testing, pass the Mac's LAN IP:
21
21
  // ReactNativeWatchOSHost.defaultBundleURL(host: "192.168.1.42")
22
22
  // pnpm/monorepo setups serve bundles under `/<package>/index.bundle`:
23
- // ReactNativeWatchOSHost.defaultBundleURL(entry: "my-app/index")
23
+ // ReactNativeWatchOSHost.defaultBundleURL(entry: "my-app/index.watchos")
24
24
  private let bundleURL = ReactNativeWatchOSHost.defaultBundleURL()
25
25
 
26
26
  var body: some View {