@appsent-co/react-native-watchos 0.1.1 → 0.1.2
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/build/xcframework/Hermes.xcframework/watchos-arm64/hermes.framework/hermes +0 -0
- package/build/xcframework/Hermes.xcframework/watchos-arm64-simulator/hermes.framework/hermes +0 -0
- package/build/xcframework/ReactNativeWatchOSCxx.xcframework/Info.plist +4 -4
- package/build/xcframework/ReactNativeWatchOSCxx.xcframework/watchos-arm64/libReactNativeWatchOSCxx.a +0 -0
- package/build/xcframework/ReactNativeWatchOSCxx.xcframework/watchos-arm64-simulator/libReactNativeWatchOSCxx.a +0 -0
- package/build/xcframework/device/libReactNativeWatchOSCxx.a +0 -0
- package/build/xcframework/simulator/libReactNativeWatchOSCxx.a +0 -0
- package/cli/init.js +60 -5
- package/package.json +1 -1
|
Binary file
|
package/build/xcframework/Hermes.xcframework/watchos-arm64-simulator/hermes.framework/hermes
CHANGED
|
Binary file
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<key>HeadersPath</key>
|
|
11
11
|
<string>Headers</string>
|
|
12
12
|
<key>LibraryIdentifier</key>
|
|
13
|
-
<string>watchos-arm64</string>
|
|
13
|
+
<string>watchos-arm64-simulator</string>
|
|
14
14
|
<key>LibraryPath</key>
|
|
15
15
|
<string>libReactNativeWatchOSCxx.a</string>
|
|
16
16
|
<key>SupportedArchitectures</key>
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
</array>
|
|
20
20
|
<key>SupportedPlatform</key>
|
|
21
21
|
<string>watchos</string>
|
|
22
|
+
<key>SupportedPlatformVariant</key>
|
|
23
|
+
<string>simulator</string>
|
|
22
24
|
</dict>
|
|
23
25
|
<dict>
|
|
24
26
|
<key>BinaryPath</key>
|
|
@@ -26,7 +28,7 @@
|
|
|
26
28
|
<key>HeadersPath</key>
|
|
27
29
|
<string>Headers</string>
|
|
28
30
|
<key>LibraryIdentifier</key>
|
|
29
|
-
<string>watchos-arm64
|
|
31
|
+
<string>watchos-arm64</string>
|
|
30
32
|
<key>LibraryPath</key>
|
|
31
33
|
<string>libReactNativeWatchOSCxx.a</string>
|
|
32
34
|
<key>SupportedArchitectures</key>
|
|
@@ -35,8 +37,6 @@
|
|
|
35
37
|
</array>
|
|
36
38
|
<key>SupportedPlatform</key>
|
|
37
39
|
<string>watchos</string>
|
|
38
|
-
<key>SupportedPlatformVariant</key>
|
|
39
|
-
<string>simulator</string>
|
|
40
40
|
</dict>
|
|
41
41
|
</array>
|
|
42
42
|
<key>CFBundlePackageType</key>
|
package/build/xcframework/ReactNativeWatchOSCxx.xcframework/watchos-arm64/libReactNativeWatchOSCxx.a
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/cli/init.js
CHANGED
|
@@ -34,6 +34,13 @@ async function main() {
|
|
|
34
34
|
const targetsRoot = path.join(cwd, 'targets');
|
|
35
35
|
const existing = listWatchTargets(targetsRoot);
|
|
36
36
|
|
|
37
|
+
// `create-target watch` loads the Expo config internally, which runs our
|
|
38
|
+
// plugin's order assertion. If `npx expo install` auto-added us before
|
|
39
|
+
// `@bacons/apple-targets`, that assertion throws and create-target exits 1
|
|
40
|
+
// before we ever get to patchAppJson. Strip our entry first; patchAppJson
|
|
41
|
+
// reinserts it in the correct position after create-target succeeds.
|
|
42
|
+
stripOurPluginFromAppJson(cwd);
|
|
43
|
+
|
|
37
44
|
console.log('› Running `npx create-target watch`…');
|
|
38
45
|
await spawnInherit('npx', ['--yes', 'create-target', 'watch']);
|
|
39
46
|
|
|
@@ -59,6 +66,7 @@ async function main() {
|
|
|
59
66
|
console.log(' • Next: npx expo prebuild -p ios --clean');
|
|
60
67
|
}
|
|
61
68
|
|
|
69
|
+
/** @param {string} targetsRoot */
|
|
62
70
|
function listWatchTargets(targetsRoot) {
|
|
63
71
|
if (!fs.existsSync(targetsRoot)) return [];
|
|
64
72
|
const out = [];
|
|
@@ -70,6 +78,7 @@ function listWatchTargets(targetsRoot) {
|
|
|
70
78
|
return out;
|
|
71
79
|
}
|
|
72
80
|
|
|
81
|
+
/** @param {string} dir */
|
|
73
82
|
function isWatchTargetConfig(dir) {
|
|
74
83
|
for (const f of ['expo-target.config.json', 'expo-target.config.js']) {
|
|
75
84
|
const p = path.join(dir, f);
|
|
@@ -80,6 +89,7 @@ function isWatchTargetConfig(dir) {
|
|
|
80
89
|
return false;
|
|
81
90
|
}
|
|
82
91
|
|
|
92
|
+
/** @param {string} targetDir */
|
|
83
93
|
function writeContentView(targetDir) {
|
|
84
94
|
const dest = path.join(targetDir, 'ContentView.swift');
|
|
85
95
|
const src = path.join(TEMPLATES, 'ContentView.swift');
|
|
@@ -87,6 +97,7 @@ function writeContentView(targetDir) {
|
|
|
87
97
|
console.log(`› Wrote ${path.relative(process.cwd(), dest)}`);
|
|
88
98
|
}
|
|
89
99
|
|
|
100
|
+
/** @param {string} cwd */
|
|
90
101
|
function writeEntryFile(cwd) {
|
|
91
102
|
for (const name of ENTRY_NAMES) {
|
|
92
103
|
if (fs.existsSync(path.join(cwd, name))) {
|
|
@@ -99,6 +110,47 @@ function writeEntryFile(cwd) {
|
|
|
99
110
|
console.log(`› Wrote ${path.relative(cwd, dest)}`);
|
|
100
111
|
}
|
|
101
112
|
|
|
113
|
+
/**
|
|
114
|
+
* @param {unknown} entry
|
|
115
|
+
* @param {string} name
|
|
116
|
+
*/
|
|
117
|
+
const isEntry = (entry, name) =>
|
|
118
|
+
Array.isArray(entry) ? entry[0] === name : entry === name;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @param {string} cwd
|
|
122
|
+
*/
|
|
123
|
+
function stripOurPluginFromAppJson(cwd) {
|
|
124
|
+
const p = path.join(cwd, 'app.json');
|
|
125
|
+
if (!fs.existsSync(p)) return;
|
|
126
|
+
|
|
127
|
+
/** @type {{ expo?: { plugins?: Array<unknown> } }} */
|
|
128
|
+
const json = JSON.parse(fs.readFileSync(p, 'utf8'));
|
|
129
|
+
const plugins =
|
|
130
|
+
json && json.expo && Array.isArray(json.expo.plugins)
|
|
131
|
+
? json.expo.plugins
|
|
132
|
+
: null;
|
|
133
|
+
if (!plugins) return;
|
|
134
|
+
|
|
135
|
+
let removed = 0;
|
|
136
|
+
for (let i = plugins.length - 1; i >= 0; i--) {
|
|
137
|
+
if (isEntry(plugins[i], '@appsent-co/react-native-watchos')) {
|
|
138
|
+
plugins.splice(i, 1);
|
|
139
|
+
removed++;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (removed) {
|
|
143
|
+
fs.writeFileSync(p, JSON.stringify(json, null, 2) + '\n');
|
|
144
|
+
console.log(
|
|
145
|
+
`› Removed pre-existing @appsent-co/react-native-watchos entry from ${path.relative(cwd, p)} (will reinsert in correct position).`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @param {string} cwd
|
|
152
|
+
* @param {string} targetName
|
|
153
|
+
*/
|
|
102
154
|
function patchAppJson(cwd, targetName) {
|
|
103
155
|
const p = path.join(cwd, 'app.json');
|
|
104
156
|
if (!fs.existsSync(p)) {
|
|
@@ -112,13 +164,11 @@ function patchAppJson(cwd, targetName) {
|
|
|
112
164
|
}
|
|
113
165
|
|
|
114
166
|
const raw = fs.readFileSync(p, 'utf8');
|
|
167
|
+
/** @type {{ expo?: { plugins?: Array<unknown> } }} */
|
|
115
168
|
const json = JSON.parse(raw);
|
|
116
169
|
const expo = (json.expo = json.expo || {});
|
|
117
170
|
const plugins = (expo.plugins = expo.plugins || []);
|
|
118
171
|
|
|
119
|
-
const isEntry = (entry, name) =>
|
|
120
|
-
Array.isArray(entry) ? entry[0] === name : entry === name;
|
|
121
|
-
|
|
122
172
|
// `npx expo install` auto-adds the plugin as a bare string in the wrong
|
|
123
173
|
// position (before @bacons/apple-targets) and with no targetName. Strip
|
|
124
174
|
// any existing entry so we can reinsert it in the correct position.
|
|
@@ -131,8 +181,8 @@ function patchAppJson(cwd, targetName) {
|
|
|
131
181
|
}
|
|
132
182
|
|
|
133
183
|
const entry = ['@appsent-co/react-native-watchos', { targetName }];
|
|
134
|
-
const baconIdx = plugins.findIndex(
|
|
135
|
-
isEntry(e, '@bacons/apple-targets')
|
|
184
|
+
const baconIdx = plugins.findIndex(
|
|
185
|
+
/** @param {unknown} e */ (e) => isEntry(e, '@bacons/apple-targets')
|
|
136
186
|
);
|
|
137
187
|
if (baconIdx >= 0) plugins.splice(baconIdx + 1, 0, entry);
|
|
138
188
|
else plugins.push(entry);
|
|
@@ -147,6 +197,11 @@ function patchAppJson(cwd, targetName) {
|
|
|
147
197
|
}
|
|
148
198
|
}
|
|
149
199
|
|
|
200
|
+
/**
|
|
201
|
+
* @param {string} cmd
|
|
202
|
+
* @param {string[]} args
|
|
203
|
+
* @returns {Promise<void>}
|
|
204
|
+
*/
|
|
150
205
|
function spawnInherit(cmd, args) {
|
|
151
206
|
return new Promise((resolve, reject) => {
|
|
152
207
|
const child = spawn(cmd, args, { stdio: 'inherit' });
|