@nativue/core 0.6.0 → 0.7.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.
|
@@ -367,6 +367,12 @@ class ScrollContainerView(context: Context) : ContainerView(context) {
|
|
|
367
367
|
refreshIndicator.layout(indicatorLeft, -size, indicatorLeft + size, 0)
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
+
// The visible area changes with the size too: FlatList renders more rows when it grows.
|
|
371
|
+
override fun onSizeChanged(width: Int, height: Int, oldWidth: Int, oldHeight: Int) {
|
|
372
|
+
super.onSizeChanged(width, height, oldWidth, oldHeight)
|
|
373
|
+
reportScrollThrottled()
|
|
374
|
+
}
|
|
375
|
+
|
|
370
376
|
// Within the throttle, the report waits for its end, so the last position always reaches JS.
|
|
371
377
|
private fun reportScrollThrottled() {
|
|
372
378
|
if (onScroll == null || hasPendingReport) return
|
package/cli/run.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// or emulator when none is running, then installs and launches the app on it. `--device` picks one by
|
|
3
3
|
// name or id (a simulator, an emulator or a phone), or alone, the first phone connected.
|
|
4
4
|
import { execFileSync, spawn } from 'node:child_process'
|
|
5
|
+
import { X509Certificate } from 'node:crypto'
|
|
5
6
|
import { existsSync, readFileSync, rmSync } from 'node:fs'
|
|
6
7
|
import { homedir, tmpdir } from 'node:os'
|
|
7
8
|
import { join } from 'node:path'
|
|
@@ -22,20 +23,25 @@ const sleep = (milliseconds) => new Promise((resolve) => setTimeout(resolve, mil
|
|
|
22
23
|
|
|
23
24
|
// ---------- iOS ----------
|
|
24
25
|
|
|
26
|
+
const iOSVersion = (device) => Number(device.runtime.match(/iOS-(\d+)/)?.[1] ?? 0)
|
|
27
|
+
|
|
28
|
+
/** iOS simulators, the newest iOS first. */
|
|
25
29
|
function simulators() {
|
|
26
30
|
const { devices } = JSON.parse(run('xcrun', ['simctl', 'list', 'devices', 'available', '-j']))
|
|
27
31
|
|
|
28
|
-
return Object.entries(devices)
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
return Object.entries(devices)
|
|
33
|
+
.flatMap(([runtime, runtimeDevices]) =>
|
|
34
|
+
runtimeDevices.map((device) => ({ ...device, runtime })),
|
|
35
|
+
)
|
|
36
|
+
.filter(iOSVersion)
|
|
37
|
+
.sort((first, second) => iOSVersion(second) - iOSVersion(first))
|
|
31
38
|
}
|
|
32
39
|
|
|
33
|
-
|
|
40
|
+
const iPhoneSimulators = () => simulators().filter((device) => device.name.startsWith('iPhone'))
|
|
41
|
+
|
|
42
|
+
/** An iPhone on the newest iOS: one already booted if there is one. */
|
|
34
43
|
function defaultSimulator() {
|
|
35
|
-
const
|
|
36
|
-
const iPhones = simulators()
|
|
37
|
-
.filter((device) => device.name.startsWith('iPhone') && iOSVersion(device))
|
|
38
|
-
.sort((first, second) => iOSVersion(second) - iOSVersion(first))
|
|
44
|
+
const iPhones = iPhoneSimulators()
|
|
39
45
|
|
|
40
46
|
if (iPhones.length === 0)
|
|
41
47
|
throw new Error('No iPhone simulator found: add one in Xcode > Settings > Components.')
|
|
@@ -92,22 +98,65 @@ function pickIOSDevice(requested) {
|
|
|
92
98
|
...simulators().map((device) => ({ ...device, isSimulator: true })),
|
|
93
99
|
]
|
|
94
100
|
const device = candidates.find(({ name, udid }) => name === requested || udid === requested)
|
|
95
|
-
if (!device)
|
|
96
|
-
throw new Error(
|
|
97
|
-
noDeviceMessage(
|
|
98
|
-
requested,
|
|
99
|
-
candidates.map(({ name, udid }) => `${name} (${udid})`),
|
|
100
|
-
),
|
|
101
|
-
)
|
|
101
|
+
if (!device) throw new Error(noDeviceMessage(requested, suggestedIOSDevices(phones)))
|
|
102
102
|
|
|
103
103
|
return device
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
/** The phones, and the iPhone simulators on the newest iOS: the whole list runs long. */
|
|
107
|
+
function suggestedIOSDevices(phones) {
|
|
108
|
+
const iPhones = iPhoneSimulators()
|
|
109
|
+
const newestIPhones = iPhones.filter((device) => iOSVersion(device) === iOSVersion(iPhones[0]))
|
|
110
|
+
|
|
111
|
+
return [...phones, ...newestIPhones].map(({ name, udid }) => `${name} (${udid})`)
|
|
112
|
+
}
|
|
113
|
+
|
|
106
114
|
function noDeviceMessage(requested, available) {
|
|
107
115
|
return `No device named or with the id "${requested}". Available:\n ${available.join('\n ')}`
|
|
108
116
|
}
|
|
109
117
|
|
|
118
|
+
const IOS_PROJECT_FILE = 'ios/App.xcodeproj/project.pbxproj'
|
|
119
|
+
|
|
120
|
+
/** The teams of this Mac's valid "Apple Development" certificates (their OU). */
|
|
121
|
+
function developmentTeams() {
|
|
122
|
+
const certificates = run(
|
|
123
|
+
'security',
|
|
124
|
+
['find-certificate', '-a', '-c', 'Apple Development', '-p'],
|
|
125
|
+
{
|
|
126
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
127
|
+
},
|
|
128
|
+
).match(/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/g)
|
|
129
|
+
|
|
130
|
+
const teams = (certificates ?? [])
|
|
131
|
+
.map((pem) => new X509Certificate(pem))
|
|
132
|
+
.filter((certificate) => new Date(certificate.validTo) > new Date())
|
|
133
|
+
.map((certificate) => certificate.subject.match(/^OU=(\w+)$/m)?.[1])
|
|
134
|
+
|
|
135
|
+
return [...new Set(teams.filter(Boolean))]
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* A phone only runs signed apps. Without a team in the project, the one of this Mac's development
|
|
140
|
+
* certificate, for this build only: the project stays as it is.
|
|
141
|
+
*/
|
|
142
|
+
function signingSettings() {
|
|
143
|
+
if (readFileSync(IOS_PROJECT_FILE, 'utf8').includes('DEVELOPMENT_TEAM')) return []
|
|
144
|
+
|
|
145
|
+
const teams = developmentTeams()
|
|
146
|
+
if (teams.length === 1) return [`DEVELOPMENT_TEAM=${teams[0]}`]
|
|
147
|
+
|
|
148
|
+
const reason =
|
|
149
|
+
teams.length === 0
|
|
150
|
+
? 'No Apple Development certificate on this Mac: sign in to your Apple account in Xcode > Settings > Accounts,'
|
|
151
|
+
: 'Your certificates belong to several teams:'
|
|
152
|
+
throw new Error(
|
|
153
|
+
`${reason} then pick your team in ios/App.xcodeproj, under Signing & Capabilities.`,
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
|
|
110
157
|
function buildIOSApp(destination, isSimulator) {
|
|
158
|
+
const signing = isSimulator ? [] : ['-allowProvisioningUpdates', ...signingSettings()]
|
|
159
|
+
|
|
111
160
|
step('Building the iOS app')
|
|
112
161
|
|
|
113
162
|
try {
|
|
@@ -124,8 +173,8 @@ function buildIOSApp(destination, isSimulator) {
|
|
|
124
173
|
`id=${destination}`,
|
|
125
174
|
'-derivedDataPath',
|
|
126
175
|
IOS_BUILD_DIRECTORY,
|
|
127
|
-
//
|
|
128
|
-
...
|
|
176
|
+
// Xcode creates the provisioning profile.
|
|
177
|
+
...signing,
|
|
129
178
|
'-quiet',
|
|
130
179
|
'build',
|
|
131
180
|
],
|
|
@@ -135,7 +184,7 @@ function buildIOSApp(destination, isSimulator) {
|
|
|
135
184
|
if (isSimulator) throw error
|
|
136
185
|
|
|
137
186
|
throw new Error(
|
|
138
|
-
'The build for the phone failed. If it
|
|
187
|
+
'The build for the phone failed. If it is about signing, open ios/App.xcodeproj in Xcode and check Signing & Capabilities.',
|
|
139
188
|
)
|
|
140
189
|
}
|
|
141
190
|
}
|