expo-modules-jsi 56.0.7 → 56.0.8

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/CLAUDE.md +4 -0
  3. package/apple/Package.swift +15 -11
  4. package/apple/Sources/ExpoModulesJSI/Contexts/CleanupContext.swift +2 -4
  5. package/apple/Sources/ExpoModulesJSI/Contexts/HostFunctionContext.swift +1 -3
  6. package/apple/Sources/ExpoModulesJSI/Contexts/HostObjectContext.swift +1 -3
  7. package/apple/Sources/ExpoModulesJSI/Extensions/Task+immediate.swift +2 -0
  8. package/apple/Sources/ExpoModulesJSI/Protocols/JSIRepresentable.swift +17 -14
  9. package/apple/Sources/ExpoModulesJSI/Protocols/JavaScriptRepresentable.swift +3 -9
  10. package/apple/Sources/ExpoModulesJSI/Protocols/JavaScriptThrowable.swift +21 -27
  11. package/apple/Sources/ExpoModulesJSI/Protocols/JavaScriptType.swift +10 -18
  12. package/apple/Sources/ExpoModulesJSI/Runtime/JavaScriptActor.swift +22 -41
  13. package/apple/Sources/ExpoModulesJSI/Runtime/JavaScriptNativeState.swift +7 -15
  14. package/apple/Sources/ExpoModulesJSI/Runtime/JavaScriptPropNameID.swift +5 -15
  15. package/apple/Sources/ExpoModulesJSI/Runtime/JavaScriptRef.swift +21 -43
  16. package/apple/Sources/ExpoModulesJSI/Runtime/JavaScriptRuntime.swift +152 -202
  17. package/apple/Sources/ExpoModulesJSI/Runtime/JavaScriptValuesBuffer.swift +38 -41
  18. package/apple/Sources/ExpoModulesJSI/Runtime/Values/JavaScriptArray.swift +340 -381
  19. package/apple/Sources/ExpoModulesJSI/Runtime/Values/JavaScriptArrayBuffer.swift +9 -21
  20. package/apple/Sources/ExpoModulesJSI/Runtime/Values/JavaScriptBigInt.swift +162 -190
  21. package/apple/Sources/ExpoModulesJSI/Runtime/Values/JavaScriptError.swift +12 -15
  22. package/apple/Sources/ExpoModulesJSI/Runtime/Values/JavaScriptFunction.swift +23 -27
  23. package/apple/Sources/ExpoModulesJSI/Runtime/Values/JavaScriptObject.swift +175 -207
  24. package/apple/Sources/ExpoModulesJSI/Runtime/Values/JavaScriptPromise.swift +22 -24
  25. package/apple/Sources/ExpoModulesJSI/Runtime/Values/JavaScriptTypedArray.swift +34 -49
  26. package/apple/Sources/ExpoModulesJSI/Runtime/Values/JavaScriptValue.swift +122 -176
  27. package/apple/Sources/ExpoModulesJSI/Runtime/Values/JavaScriptWeakObject.swift +6 -14
  28. package/apple/Sources/ExpoModulesJSI/Utilities/ErrorHandling.swift +12 -20
  29. package/apple/Sources/ExpoModulesJSI/Utilities/Errors.swift +10 -22
  30. package/apple/Sources/ExpoModulesJSI/Utilities/NonisolatedUnsafeVar.swift +2 -4
  31. package/apple/Sources/ExpoModulesJSI-Cxx/include/JSIUtils.h +11 -0
  32. package/apple/Tests/JavaScriptActorTests.swift +3 -3
  33. package/apple/Tests/JavaScriptArrayBufferTests.swift +1 -1
  34. package/apple/Tests/JavaScriptArrayTests.swift +6 -4
  35. package/apple/Tests/JavaScriptBigIntTests.swift +20 -20
  36. package/apple/Tests/JavaScriptErrorTests.swift +15 -11
  37. package/apple/Tests/JavaScriptFunctionTests.swift +26 -26
  38. package/apple/Tests/JavaScriptNativeStateTests.swift +1 -1
  39. package/apple/Tests/JavaScriptObjectTests.swift +25 -13
  40. package/apple/Tests/JavaScriptPromiseTests.swift +56 -28
  41. package/apple/Tests/JavaScriptRefTests.swift +1 -1
  42. package/apple/Tests/JavaScriptRuntimeTests.swift +93 -60
  43. package/apple/Tests/JavaScriptTypedArrayTests.swift +20 -14
  44. package/apple/Tests/JavaScriptValueTests.swift +1 -1
  45. package/apple/Tests/JavaScriptValuesBufferTests.swift +1 -1
  46. package/apple/Tests/JavaScriptWeakObjectTests.swift +1 -1
  47. package/apple/scripts/build-xcframework.sh +96 -13
  48. package/apple/scripts/xcframework-helpers.sh +4 -0
  49. package/package.json +4 -2
@@ -1,7 +1,7 @@
1
1
  // Copyright 2025-present 650 Industries. All rights reserved.
2
2
 
3
- internal import jsi
4
3
  internal import ExpoModulesJSI_Cxx
4
+ internal import jsi
5
5
 
6
6
  public struct JavaScriptFunction: JavaScriptType, ~Copyable {
7
7
  internal weak let runtime: JavaScriptRuntime?
@@ -17,37 +17,39 @@ public struct JavaScriptFunction: JavaScriptType, ~Copyable {
17
17
  /// however it would require consuming `this` that we rather want to avoid (unwrapping is consuming).
18
18
  /// If `this` is consumed, something obvious like `object.getPropertyAsFunction("fn").call(this: object)` would be impossible.
19
19
 
20
- /**
21
- Calls the function with the given `this` object and buffer of arguments.
22
- */
20
+ /// Calls the function with the given `this` object and buffer of arguments.
23
21
  @discardableResult
24
- public func call(this: borrowing JavaScriptObject, arguments: consuming JavaScriptValuesBuffer? = nil) throws -> JavaScriptValue {
22
+ public func call(this: borrowing JavaScriptObject, arguments: consuming JavaScriptValuesBuffer? = nil) throws
23
+ -> JavaScriptValue
24
+ {
25
25
  guard let runtime else {
26
26
  FatalError.runtimeLost()
27
27
  }
28
28
  return try capturingCppErrors {
29
- return JavaScriptValue(runtime, expo.callFunctionWithThis(runtime.pointee, pointee, this.pointee, arguments?.baseAddress, arguments?.count ?? 0))
29
+ return JavaScriptValue(
30
+ runtime,
31
+ expo.callFunctionWithThis(runtime.pointee, pointee, this.pointee, arguments?.baseAddress, arguments?.count ?? 0)
32
+ )
30
33
  }
31
34
  }
32
35
 
33
- /**
34
- Calls the function with the given buffer of arguments.
35
- */
36
+ /// Calls the function with the given buffer of arguments.
36
37
  @discardableResult
37
38
  public func call(arguments: consuming JavaScriptValuesBuffer? = nil) throws -> JavaScriptValue {
38
39
  guard let runtime else {
39
40
  FatalError.runtimeLost()
40
41
  }
41
42
  return try capturingCppErrors {
42
- return JavaScriptValue(runtime, expo.callFunction(runtime.pointee, pointee, arguments?.baseAddress, arguments?.count ?? 0))
43
+ return JavaScriptValue(
44
+ runtime, expo.callFunction(runtime.pointee, pointee, arguments?.baseAddress, arguments?.count ?? 0))
43
45
  }
44
46
  }
45
47
 
46
- /**
47
- Calls the function with the given `this` object and JS-representable arguments.
48
- */
48
+ /// Calls the function with the given `this` object and JS-representable arguments.
49
49
  @discardableResult
50
- public func call<each T: JavaScriptRepresentable>(this: borrowing JavaScriptObject, arguments: repeat each T) throws -> JavaScriptValue {
50
+ public func call<each T: JavaScriptRepresentable>(this: borrowing JavaScriptObject, arguments: repeat each T) throws
51
+ -> JavaScriptValue
52
+ {
51
53
  guard let runtime else {
52
54
  FatalError.runtimeLost()
53
55
  }
@@ -55,9 +57,7 @@ public struct JavaScriptFunction: JavaScriptType, ~Copyable {
55
57
  return try self.call(this: this, arguments: argumentsBuffer)
56
58
  }
57
59
 
58
- /**
59
- Calls the function with the given JS-representable arguments.
60
- */
60
+ /// Calls the function with the given JS-representable arguments.
61
61
  @discardableResult
62
62
  public func call<each T: JavaScriptRepresentable>(arguments: repeat each T) throws -> JavaScriptValue {
63
63
  guard let runtime else {
@@ -67,9 +67,7 @@ public struct JavaScriptFunction: JavaScriptType, ~Copyable {
67
67
  return try self.call(arguments: argumentsBuffer)
68
68
  }
69
69
 
70
- /**
71
- Calls the function as a constructor with the given buffer of arguments. It's like calling a function with the `new` keyword.
72
- */
70
+ /// Calls the function as a constructor with the given buffer of arguments. It's like calling a function with the `new` keyword.
73
71
  public func callAsConstructor(_ arguments: consuming JavaScriptValuesBuffer? = nil) throws -> JavaScriptValue {
74
72
  guard let runtime else {
75
73
  FatalError.runtimeLost()
@@ -80,9 +78,7 @@ public struct JavaScriptFunction: JavaScriptType, ~Copyable {
80
78
  }
81
79
  }
82
80
 
83
- /**
84
- Calls the function as a constructor with the given arguments. It's like calling a function with the `new` keyword.
85
- */
81
+ /// Calls the function as a constructor with the given arguments. It's like calling a function with the `new` keyword.
86
82
  public func callAsConstructor<each T: JavaScriptRepresentable>(_ arguments: repeat each T) throws -> JavaScriptValue {
87
83
  guard let runtime else {
88
84
  FatalError.runtimeLost()
@@ -100,9 +96,7 @@ public struct JavaScriptFunction: JavaScriptType, ~Copyable {
100
96
  return JavaScriptValue(runtime, expo.valueFromFunction(jsiRuntime, pointee))
101
97
  }
102
98
 
103
- /**
104
- Returns the function as a `facebook.jsi.Value` instance.
105
- */
99
+ /// Returns the function as a `facebook.jsi.Value` instance.
106
100
  internal func asJSIValue() -> facebook.jsi.Value {
107
101
  guard let jsiRuntime = runtime?.pointee else {
108
102
  FatalError.runtimeLost()
@@ -130,7 +124,9 @@ extension JavaScriptFunction: JavaScriptRepresentable {
130
124
  }
131
125
 
132
126
  extension JavaScriptFunction: JSIRepresentable {
133
- static func fromJSIValue(_ value: borrowing facebook.jsi.Value, in runtime: facebook.jsi.IRuntime) -> JavaScriptFunction {
127
+ static func fromJSIValue(_ value: borrowing facebook.jsi.Value, in runtime: facebook.jsi.IRuntime)
128
+ -> JavaScriptFunction
129
+ {
134
130
  FatalError.unimplemented()
135
131
  }
136
132