@tokamakdev/platform-ios-simulator-x64 0.1.1-beta.65 → 0.1.1-beta.69
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/ios-simulator-x64/build/entrypoint +17 -25
- package/ios-simulator-x64/frameworks/TokamakRuntime.framework/TokamakRuntime +0 -0
- package/ios-simulator-x64/native-shell/TokamakHost.swift +10 -7
- package/ios-simulator-x64/native-shell/TokamakPlugins.swift +6 -1
- package/ios-simulator-x64/platform-pack.json +5 -0
- package/ios-simulator-x64/tools/tokamak-apple-signing +0 -0
- package/package.json +1 -1
|
@@ -76,7 +76,7 @@ write_plist() {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
sign_bundle() {
|
|
79
|
-
if [[ "$
|
|
79
|
+
if [[ "$sdk" == iphonesimulator ]]; then
|
|
80
80
|
codesign --force --timestamp=none --sign - "$bundle"
|
|
81
81
|
return
|
|
82
82
|
fi
|
|
@@ -96,7 +96,7 @@ sign_bundle() {
|
|
|
96
96
|
bundle_key_file=$output_parent/.tokamak/$(basename "$output").input-key
|
|
97
97
|
if [[ -f "$metadata/input-key" ]]; then
|
|
98
98
|
case "$platform" in
|
|
99
|
-
ios
|
|
99
|
+
ios) app_files=("${TOKAMAK_IOS_PLIST:-}" "${TOKAMAK_IOS_ENTITLEMENTS:-}") ;;
|
|
100
100
|
macos) app_files=("${TOKAMAK_MACOS_PLIST:-}" "${TOKAMAK_MACOS_ENTITLEMENTS:-}") ;;
|
|
101
101
|
esac
|
|
102
102
|
bundle_key=$(
|
|
@@ -127,7 +127,7 @@ rm -rf "$bundle"
|
|
|
127
127
|
mkdir -p "$executable_dir" "$app_dir" "$module_cache"
|
|
128
128
|
cp -R "$input/app/." "$app_dir/"
|
|
129
129
|
|
|
130
|
-
if [[
|
|
130
|
+
if [[ -d "$icons/AppIcon.icon" ]]; then
|
|
131
131
|
if [[ "$platform" == macos ]]; then
|
|
132
132
|
icon_output=$contents/Resources
|
|
133
133
|
icon_minimum=14.0
|
|
@@ -160,10 +160,19 @@ if [[ ! -f "$native_shell/TokamakShell.swift" ]]; then
|
|
|
160
160
|
exit 1
|
|
161
161
|
fi
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
# A plugin's class is a Swift type name, which the registry creates, and its
|
|
164
|
+
# sources are Swift.
|
|
165
|
+
swift_type='^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$'
|
|
166
|
+
registry=$temporary/TokamakPluginRegistry.swift
|
|
167
|
+
printf '%s\n\n%s\n%s\n' 'import Foundation' 'func tokamakPlugins(host: TokamakHost) -> [any TokamakPlugin] {' ' [' > "$registry"
|
|
168
|
+
for plugin in "$input/plugins"/*/; do
|
|
169
|
+
class=$(cat "$plugin/class" 2>/dev/null || true)
|
|
170
|
+
if [[ ! "$class" =~ $swift_type ]]; then
|
|
171
|
+
echo "plugin '$(basename "$plugin")' has invalid $platform class '$class'" >&2
|
|
172
|
+
exit 1
|
|
173
|
+
fi
|
|
174
|
+
printf ' %s(host: host),\n' "$class" >> "$registry"
|
|
165
175
|
for source in "$plugin/sources"/*; do
|
|
166
|
-
[[ -f "$source" ]] || continue
|
|
167
176
|
case "$source" in
|
|
168
177
|
*.swift) swift_sources+=("$source") ;;
|
|
169
178
|
*)
|
|
@@ -173,17 +182,7 @@ for plugin in "$input/plugins"/*; do
|
|
|
173
182
|
esac
|
|
174
183
|
done
|
|
175
184
|
done
|
|
176
|
-
|
|
177
|
-
registry=$temporary/TokamakPluginRegistry.swift
|
|
178
|
-
{
|
|
179
|
-
printf '%s\n\n' 'import Foundation'
|
|
180
|
-
printf '%s\n' 'func tokamakPlugins(host: TokamakHost) -> [any TokamakPlugin] {' ' ['
|
|
181
|
-
for plugin in "$input/plugins"/*; do
|
|
182
|
-
[[ -d "$plugin" ]] || continue
|
|
183
|
-
printf ' %s(host: host),\n' "$(cat "$plugin/class")"
|
|
184
|
-
done
|
|
185
|
-
printf '%s\n' ' ]' '}'
|
|
186
|
-
} > "$registry"
|
|
185
|
+
printf '%s\n' ' ]' '}' >> "$registry"
|
|
187
186
|
|
|
188
187
|
# The executable exports only the entry points of the runtime parts the app
|
|
189
188
|
# links.
|
|
@@ -205,17 +204,10 @@ swift_args=(
|
|
|
205
204
|
-Xlinker -dead_strip
|
|
206
205
|
-Xlinker -exported_symbols_list -Xlinker "$exported_symbols"
|
|
207
206
|
)
|
|
208
|
-
for plugin in "$input/plugins"/*; do
|
|
209
|
-
[[ -d "$plugin" ]] || continue
|
|
210
|
-
for framework_file in "$plugin/frameworks"/*; do
|
|
211
|
-
[[ -f "$framework_file" ]] || continue
|
|
212
|
-
swift_args+=(-framework "$(cat "$framework_file")")
|
|
213
|
-
done
|
|
214
|
-
done
|
|
215
207
|
|
|
216
208
|
# Simulator builds embed their entitlements in __TEXT,__entitlements, where
|
|
217
209
|
# the simulator reads them.
|
|
218
|
-
if [[ "$
|
|
210
|
+
if [[ "$sdk" == iphonesimulator ]]; then
|
|
219
211
|
simulator_entitlements=$temporary/simulator.entitlements
|
|
220
212
|
"$apple_tool" simulator-entitlements --identifier "$identifier" --output "$simulator_entitlements"
|
|
221
213
|
swift_args+=(-Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker "$simulator_entitlements")
|
|
Binary file
|
|
@@ -33,22 +33,25 @@ final class TokamakHost {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/// Posts `body`, JSON-serialisable, to the Worker's `/tokamak/<name>`
|
|
36
|
-
/// endpoint and returns the response body
|
|
37
|
-
/// 200 within `timeout
|
|
38
|
-
/// the main thread.
|
|
36
|
+
/// endpoint and returns the response body, retrying a failed post. Fails
|
|
37
|
+
/// unless the Worker responds 200 within `timeout`, which includes runtime
|
|
38
|
+
/// startup. Call it on the main thread; `completion` runs on the main thread.
|
|
39
39
|
func call(
|
|
40
40
|
_ name: String,
|
|
41
41
|
body: Any,
|
|
42
42
|
timeout: TimeInterval,
|
|
43
43
|
completion: @escaping (Result<Data, Error>) -> Void
|
|
44
44
|
) {
|
|
45
|
+
let deadline = Date() + timeout
|
|
45
46
|
whenStarted { result in
|
|
46
47
|
switch result {
|
|
47
48
|
case .failure(let error):
|
|
48
49
|
completion(.failure(error))
|
|
49
50
|
case .success(let runtime):
|
|
50
51
|
DispatchQueue.global(qos: .userInitiated).async {
|
|
51
|
-
let outcome = Result {
|
|
52
|
+
let outcome = Result {
|
|
53
|
+
try runtime.call(name, body: body, timeout: deadline.timeIntervalSinceNow)
|
|
54
|
+
}
|
|
52
55
|
DispatchQueue.main.async { completion(outcome) }
|
|
53
56
|
}
|
|
54
57
|
}
|
|
@@ -229,8 +232,8 @@ final class RuntimeHandle {
|
|
|
229
232
|
return port
|
|
230
233
|
}
|
|
231
234
|
|
|
232
|
-
/// Posts `body` to the Worker's `/tokamak/<name>` endpoint,
|
|
233
|
-
/// it responds 200 or `timeout` passes.
|
|
235
|
+
/// Posts `body` to the Worker's `/tokamak/<name>` endpoint, retrying a
|
|
236
|
+
/// failed post, and blocks until it responds 200 or `timeout` passes.
|
|
234
237
|
func call(_ name: String, body: Any, timeout: TimeInterval) throws -> Data {
|
|
235
238
|
guard JSONSerialization.isValidJSONObject([body]) else {
|
|
236
239
|
throw RuntimeError.runtime("the \(name) call body is not JSON")
|
|
@@ -248,7 +251,7 @@ final class RuntimeHandle {
|
|
|
248
251
|
handle,
|
|
249
252
|
name,
|
|
250
253
|
body,
|
|
251
|
-
UInt64(timeout * 1000),
|
|
254
|
+
UInt64(max(timeout, 0) * 1000),
|
|
252
255
|
&response,
|
|
253
256
|
error.baseAddress,
|
|
254
257
|
error.count
|
|
@@ -200,7 +200,12 @@ final class TokamakPluginBridge: NSObject, WKScriptMessageHandler {
|
|
|
200
200
|
else {
|
|
201
201
|
return
|
|
202
202
|
}
|
|
203
|
-
webView?.
|
|
203
|
+
webView?.callAsyncJavaScript(
|
|
204
|
+
"globalThis.__tokamakNative?.onmessage?.({ data })",
|
|
205
|
+
arguments: ["data": json],
|
|
206
|
+
in: nil,
|
|
207
|
+
in: .page
|
|
208
|
+
)
|
|
204
209
|
}
|
|
205
210
|
|
|
206
211
|
private static func bootstrap(host: String) -> String {
|
|
Binary file
|