@tokamakdev/platform-macos-arm64 0.1.1-beta.142 → 0.1.1-beta.144

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.
@@ -220,16 +220,7 @@ if [[ -n "$icon" ]]; then
220
220
  fi
221
221
 
222
222
  shopt -s nullglob
223
- swift_sources=()
224
- for source in "$pack/native-shell"/*.swift; do
225
- [[ -f "$source" ]] || continue
226
- swift_sources+=("$source")
227
- done
228
-
229
- if [[ ! -f "$pack/native-shell/TokamakShell.swift" ]]; then
230
- echo "Apple native shell source is missing: $pack/native-shell/TokamakShell.swift" >&2
231
- exit 1
232
- fi
223
+ swift_sources=("$pack/native-shell"/*.swift)
233
224
 
234
225
  # A plugin's class is a Swift type name, which the registry creates, and its
235
226
  # sources are the Swift files in its native directory.
@@ -311,16 +311,8 @@ enum TokamakBackgroundResult {
311
311
  }
312
312
  }
313
313
 
314
- enum RuntimeError: Error, CustomStringConvertible {
315
- case configuration(String)
316
- case runtime(String)
317
-
318
- var description: String {
319
- switch self {
320
- case .configuration(let message), .runtime(let message):
321
- return message
322
- }
323
- }
314
+ struct RuntimeError: Error, CustomStringConvertible {
315
+ let description: String
324
316
  }
325
317
 
326
318
  enum AuthenticationMaterial<Value> {
@@ -338,7 +330,7 @@ final class RuntimeHandle {
338
330
  /// Worker calls `plugins`.
339
331
  init(foreground: Bool, plugins: TokamakPluginHandler) throws {
340
332
  guard let appHost = Bundle.main.tokamakHost, !appHost.isEmpty else {
341
- throw RuntimeError.configuration("TokamakHost is required")
333
+ throw RuntimeError(description: "TokamakHost is required")
342
334
  }
343
335
  self.appHost = appHost
344
336
 
@@ -371,7 +363,7 @@ final class RuntimeHandle {
371
363
  } else {
372
364
  let bundle = Bundle.main.resourceURL?.appendingPathComponent("app")
373
365
  guard let bundle else {
374
- throw RuntimeError.configuration("app bundle resources are unavailable")
366
+ throw RuntimeError(description: "app bundle resources are unavailable")
375
367
  }
376
368
  let storage = try Self.storageDirectory()
377
369
  handle = bundle.path.withCString { bundlePath in
@@ -396,7 +388,7 @@ final class RuntimeHandle {
396
388
  }
397
389
  }
398
390
  guard handle != nil else {
399
- throw RuntimeError.runtime(String(cString: error))
391
+ throw RuntimeError(description: String(cString: error))
400
392
  }
401
393
  try? FileManager.default.removeItem(at: state.appendingPathComponent(startupErrorFile))
402
394
  }
@@ -424,7 +416,7 @@ final class RuntimeHandle {
424
416
  tokamak_runtime_restore_gateway(handle, error.baseAddress, error.count)
425
417
  }
426
418
  guard port != 0 else {
427
- throw RuntimeError.runtime(String(cString: error))
419
+ throw RuntimeError(description: String(cString: error))
428
420
  }
429
421
  return port
430
422
  }
@@ -453,7 +445,7 @@ final class RuntimeHandle {
453
445
  }
454
446
  defer { tokamak_bytes_free(reply) }
455
447
  guard succeeded else {
456
- throw RuntimeError.runtime(String(cString: error))
448
+ throw RuntimeError(description: String(cString: error))
457
449
  }
458
450
  return reply.contents ?? Data()
459
451
  }
@@ -477,7 +469,7 @@ final class RuntimeHandle {
477
469
  }
478
470
  defer { tokamak_bytes_free(body) }
479
471
  guard succeeded else {
480
- throw RuntimeError.runtime(String(cString: error))
472
+ throw RuntimeError(description: String(cString: error))
481
473
  }
482
474
  return body.contents ?? Data()
483
475
  }
@@ -574,7 +566,7 @@ final class RuntimeHandle {
574
566
  /// This app's folder in the user's `directory`.
575
567
  private static func appDirectory(_ directory: FileManager.SearchPathDirectory) throws -> URL {
576
568
  guard let identifier = Bundle.main.bundleIdentifier else {
577
- throw RuntimeError.configuration("CFBundleIdentifier is required")
569
+ throw RuntimeError(description: "CFBundleIdentifier is required")
578
570
  }
579
571
  return try FileManager.default.url(
580
572
  for: directory,
@@ -36,7 +36,9 @@ final class TokamakCorePlugin: TokamakPlugin {
36
36
  /// Starts navigation to the app URL `path`, relative to the current page or
37
37
  /// the app origin.
38
38
  private func navigate(to path: Any) -> Result<Void, TokamakPluginError> {
39
- guard let view = host.webView else { return .failure(noView) }
39
+ guard let view = host.webView else {
40
+ return .failure(.init(name: "InvalidStateError", message: "The app has no WebView"))
41
+ }
40
42
  let appHost = Bundle.main.tokamakHost ?? ""
41
43
  guard let path = path as? String,
42
44
  let base = view.url ?? URL(string: "https://\(appHost)/"),
@@ -60,8 +62,4 @@ final class TokamakCorePlugin: TokamakPlugin {
60
62
  reply(result.map { _ in nil }.mapError { TokamakPluginError($0) })
61
63
  }
62
64
  }
63
-
64
- private var noView: TokamakPluginError {
65
- .init(name: "InvalidStateError", message: "The app has no WebView")
66
- }
67
65
  }
@@ -1,4 +1,5 @@
1
1
  import Foundation
2
+ import Security
2
3
  import WebKit
3
4
 
4
5
  #if os(iOS)
@@ -56,13 +57,9 @@ struct TokamakPluginResult {
56
57
  let payload: Data
57
58
  let failed: Bool
58
59
  let done: Bool
60
+ }
59
61
 
60
- init(payload: Data, failed: Bool, done: Bool) {
61
- self.payload = payload
62
- self.failed = failed
63
- self.done = done
64
- }
65
-
62
+ extension TokamakPluginResult {
66
63
  init(_ result: Result<Data, TokamakPluginError>, done: Bool) {
67
64
  self.done = done
68
65
  switch result {
@@ -95,6 +92,14 @@ func decodePluginValue(_ payload: Data) throws(TokamakPluginError) -> Any {
95
92
  }
96
93
  }
97
94
 
95
+ #if os(macOS)
96
+ /// The value of the app's entitlement `key`, or nil when its signature lacks it.
97
+ func tokamakEntitlement(_ key: String) -> Any? {
98
+ guard let task = SecTaskCreateFromSelf(nil) else { return nil }
99
+ return SecTaskCopyValueForEntitlement(task, key as CFString, nil)
100
+ }
101
+ #endif
102
+
98
103
  /// The app as one plugin sees it.
99
104
  final class TokamakHost {
100
105
  private unowned let app: TokamakApp
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/macos-arm64/tools/tokamak-swift-describe
3
3
  size: 34569672 bytes
4
- sha256: d3852fed69ed0d74bca87bf62a0417e616e92ca269149fe990e23654a95a94dc
4
+ sha256: f1660801317e44cfbfd7f6d2c135fbf9d305fbe1c6d5465a2f5ac34525564cb4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokamakdev/platform-macos-arm64",
3
- "version": "0.1.1-beta.142",
3
+ "version": "0.1.1-beta.144",
4
4
  "description": "The tokamak platform pack for macos-arm64",
5
5
  "repository": {
6
6
  "type": "git",