expo-modules-macros 0.23.1 → 0.24.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.
package/apple/ExpoModulesMacros
CHANGED
|
Binary file
|
|
@@ -141,7 +141,17 @@ private func closureLiteralLines(_ closure: JSClosureType, callback: String) ->
|
|
|
141
141
|
let parameters = closure.parameters.indices.map { "p\($0)" }
|
|
142
142
|
let header = parameters.isEmpty ? "{ @Sendable in" : "{ @Sendable \(parameters.joined(separator: ", ")) in"
|
|
143
143
|
|
|
144
|
+
// A sync closure with parameters passes them as one value, a tuple when there are several, and an
|
|
145
|
+
// `emplacing` closure moves each one into the arguments buffer at its index. Capturing the
|
|
146
|
+
// parameters instead would send non-`Sendable` values to the `@JavaScriptActor` closure, which
|
|
147
|
+
// Swift 6 rejects. The closure captures nothing, so it needs no allocation. Without parameters
|
|
148
|
+
// there is nothing to emplace, and `invokeAsync` takes the parameters variadically.
|
|
149
|
+
let emplaces = !closure.isAsync && !parameters.isEmpty
|
|
144
150
|
var arguments = parameters
|
|
151
|
+
if emplaces {
|
|
152
|
+
let values = parameters.count == 1 ? "p0" : "(" + parameters.joined(separator: ", ") + ")"
|
|
153
|
+
arguments = [values, "argumentCount: \(parameters.count)"]
|
|
154
|
+
}
|
|
145
155
|
if let returnType = closure.returnType {
|
|
146
156
|
arguments.append("returning: \(expressionType(returnType)).self")
|
|
147
157
|
}
|
|
@@ -156,6 +166,14 @@ private func closureLiteralLines(_ closure: JSClosureType, callback: String) ->
|
|
|
156
166
|
call = "\(callback).invokeDetached(\(argumentList))"
|
|
157
167
|
}
|
|
158
168
|
|
|
169
|
+
if emplaces {
|
|
170
|
+
var lines = [header, " \(call) { _values, _arguments, _runtime in"]
|
|
171
|
+
for index in parameters.indices {
|
|
172
|
+
let value = parameters.count == 1 ? "_values" : "_values.\(index)"
|
|
173
|
+
lines.append(" try _arguments.emplace(\(value), at: \(index), in: _runtime)")
|
|
174
|
+
}
|
|
175
|
+
return lines + [" }", "}"]
|
|
176
|
+
}
|
|
159
177
|
guard closure.isAsync && !closure.isThrowing else {
|
|
160
178
|
return [header, " " + call, "}"]
|
|
161
179
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-macros",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Swift macro plugin for Expo modules",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"typescript": "^5.4.0"
|
|
27
27
|
},
|
|
28
28
|
"optionalDependencies": {
|
|
29
|
-
"@expo/modules-macros-linux-arm64": "0.
|
|
30
|
-
"@expo/modules-macros-linux-x64": "0.
|
|
31
|
-
"@expo/modules-macros-win32-arm64": "0.
|
|
32
|
-
"@expo/modules-macros-win32-x64": "0.
|
|
29
|
+
"@expo/modules-macros-linux-arm64": "0.24.0",
|
|
30
|
+
"@expo/modules-macros-linux-x64": "0.24.0",
|
|
31
|
+
"@expo/modules-macros-win32-arm64": "0.24.0",
|
|
32
|
+
"@expo/modules-macros-win32-x64": "0.24.0"
|
|
33
33
|
}
|
|
34
34
|
}
|