expo-modules-macros 0.28.0 → 0.30.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/.github/workflows/linux.yml +3 -7
- package/.github/workflows/publish.yml +2 -3
- package/.github/workflows/swift.yml +7 -13
- package/.github/workflows/windows.yml +3 -10
- package/AGENTS.md +11 -8
- package/Package.swift +110 -0
- package/README.md +56 -8
- package/apple/ExpoModulesMacros +0 -0
- package/apple/Sources/ExpoModulesCLI/CLI.swift +47 -10
- package/apple/Sources/ExpoModulesCLI/Commands/Expand/ExpandReport.swift +37 -1
- package/apple/Sources/{ExpoModulesMacros → ExpoModulesCLI/Commands}/Expand/MacroExpander.swift +118 -27
- package/apple/Sources/ExpoModulesCLI/Commands/Expand/RunExpand.swift +20 -10
- package/apple/Sources/ExpoModulesCLI/Commands/Fix/RunFix.swift +228 -0
- package/apple/Sources/ExpoModulesCLI/Commands/ScanExports/ExportedSurface.swift +1 -1
- package/apple/Sources/ExpoModulesCLI/Commands/ScanExports/SurfaceVisitor.swift +8 -10
- package/apple/Sources/ExpoModulesCLI/Commands/ScanModules/ScanModules.swift +48 -34
- package/apple/Sources/ExpoModulesMacros/main.swift +6 -0
- package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/EventMacro.swift +3 -3
- package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/ExpoModuleMacro.swift +8 -1
- package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/JSMacro.swift +54 -1
- package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/SharedObjectMacro.swift +9 -2
- package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/ViewPropsMacro.swift +36 -6
- package/apple/Sources/ExpoModulesMacrosCore/PluginServer.swift +40 -0
- package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/ProvidedMacros.swift +5 -5
- package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/MacroHelpers.swift +12 -26
- package/apple/Sources/ExpoModulesMacrosCore/Support/PublicAccess.swift +105 -0
- package/apple/Sources/ExpoModulesMacrosTool/main.swift +27 -0
- package/build/types.d.ts +15 -6
- package/package.json +5 -5
- package/apple/Package.swift +0 -66
- package/apple/Sources/ExpoModulesMacros/Plugin.swift +0 -36
- /package/{apple/Package.resolved → Package.resolved} +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/ExpoModulesOptimizedMacro.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/ExpoViewMacro.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/RecordMacro.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/UnionMacro.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/ClosureArguments.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/DecorateModuleBuilder.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/FreeFormTypes.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/JSConstructor.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/JSNameCollisions.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/OptimizedFunctionHelpers.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/Receiver.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/SendableConformance.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/TupleTypes.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/TypeAliases.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/TypeConformanceAssertion.swift +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ExpoModulesCLI
|
|
2
|
+
import ExpoModulesMacrosCore
|
|
3
|
+
|
|
4
|
+
#if canImport(Darwin)
|
|
5
|
+
import Darwin
|
|
6
|
+
#elseif canImport(Glibc)
|
|
7
|
+
import Glibc
|
|
8
|
+
#elseif os(Windows)
|
|
9
|
+
import CRT
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
// The binary that this package ships as `ExpoModulesMacros`: the compiler plugin, which CocoaPods
|
|
13
|
+
// builds load, and the scanner CLI, which `expo-modules-autolinking` and `expo-modules-cli` run. The
|
|
14
|
+
// compiler always launches a plugin executable without arguments and speaks the plugin protocol over
|
|
15
|
+
// stdin, so any argument means a scanner invocation (`ExpoModulesMacros scan-modules <path>...`);
|
|
16
|
+
// with none, this starts the plugin server. The CLI gets `expandMacros`, so `expand` runs the macros
|
|
17
|
+
// of this executable.
|
|
18
|
+
let arguments = Array(CommandLine.arguments.dropFirst())
|
|
19
|
+
if arguments.isEmpty {
|
|
20
|
+
try runPluginServer()
|
|
21
|
+
} else {
|
|
22
|
+
let expander = MacroExpander(
|
|
23
|
+
attributeNames: Set(ProvidedMacro.all.map(\.name)),
|
|
24
|
+
expand: expandMacros
|
|
25
|
+
)
|
|
26
|
+
exit(ScannerCLI.run(arguments: arguments, expander: expander))
|
|
27
|
+
}
|
package/build/types.d.ts
CHANGED
|
@@ -260,7 +260,7 @@ export interface ExportedEvent extends ExportedAccess, ExportedAvailability {
|
|
|
260
260
|
jsName: string;
|
|
261
261
|
/** The payload type, absent for a no-payload `() -> Void` event. */
|
|
262
262
|
payload?: TypeNode;
|
|
263
|
-
/** `@Event(sync
|
|
263
|
+
/** `@Event(.sync)`, dispatching inline on the JS thread instead of scheduling. */
|
|
264
264
|
sync: boolean;
|
|
265
265
|
}
|
|
266
266
|
/** The `@JS init` of a shared object: the constructor JS calls with `new`. */
|
|
@@ -391,10 +391,16 @@ export interface ScanStats {
|
|
|
391
391
|
/** Wall-clock duration of the scan, in milliseconds. */
|
|
392
392
|
durationMs: number;
|
|
393
393
|
}
|
|
394
|
-
/**
|
|
395
|
-
|
|
394
|
+
/**
|
|
395
|
+
* One class in the `scan-modules` output: an `@ExpoModule` class in `modules`, or a `@SharedObject`
|
|
396
|
+
* class in `sharedObjects`.
|
|
397
|
+
*/
|
|
398
|
+
export interface ScannedClass {
|
|
396
399
|
name: string;
|
|
397
|
-
/**
|
|
400
|
+
/**
|
|
401
|
+
* The resolved JS name: the `@ExpoModule("Foo")` or `@SharedObject("Foo")` override, else the class
|
|
402
|
+
* name.
|
|
403
|
+
*/
|
|
398
404
|
jsName: string;
|
|
399
405
|
/**
|
|
400
406
|
* The spelled access level, or `internal` when none is written. The generated provider references
|
|
@@ -403,7 +409,7 @@ export interface ScannedModule {
|
|
|
403
409
|
accessLevel: string;
|
|
404
410
|
/**
|
|
405
411
|
* The OSes whose builds include this class, resolved from the enclosing `#if` conditions. An
|
|
406
|
-
* unconditional
|
|
412
|
+
* unconditional class lists every OS. Empty means no build is known to include it, so don't
|
|
407
413
|
* register it.
|
|
408
414
|
*/
|
|
409
415
|
platforms: ScannedPlatform[];
|
|
@@ -412,7 +418,10 @@ export interface ScannedModule {
|
|
|
412
418
|
/** The `scan-modules` result. */
|
|
413
419
|
export interface ScanModulesResult {
|
|
414
420
|
schemaVersion: number;
|
|
415
|
-
|
|
421
|
+
/** The top-level `@ExpoModule` classes. */
|
|
422
|
+
modules: ScannedClass[];
|
|
423
|
+
/** The top-level `@SharedObject` classes, with the same platform rules as `modules`. */
|
|
424
|
+
sharedObjects: ScannedClass[];
|
|
416
425
|
warnings: ScanWarning[];
|
|
417
426
|
stats: ScanStats;
|
|
418
427
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-macros",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.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.30.0",
|
|
30
|
+
"@expo/modules-macros-linux-x64": "0.30.0",
|
|
31
|
+
"@expo/modules-macros-win32-arm64": "0.30.0",
|
|
32
|
+
"@expo/modules-macros-win32-x64": "0.30.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/apple/Package.swift
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// swift-tools-version: 6.2
|
|
2
|
-
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
|
3
|
-
|
|
4
|
-
import CompilerPluginSupport
|
|
5
|
-
import Foundation
|
|
6
|
-
import PackageDescription
|
|
7
|
-
|
|
8
|
-
let package = Package(
|
|
9
|
-
name: "ExpoModulesMacros",
|
|
10
|
-
platforms: [.macOS(.v13)],
|
|
11
|
-
dependencies: [
|
|
12
|
-
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "604.0.0-latest")
|
|
13
|
-
],
|
|
14
|
-
targets: [
|
|
15
|
-
// The plugin executable doubles as the scanner CLI: the compiler launches it without arguments
|
|
16
|
-
// and speaks the plugin protocol over stdin, while an invocation with arguments dispatches into
|
|
17
|
-
// `ScannerCLI` (see the entry point in Plugin.swift). Sharing the binary keeps the package to a
|
|
18
|
-
// single shipped executable; the scanner adds little on top of the SwiftSyntax the macros
|
|
19
|
-
// already link.
|
|
20
|
-
.macro(
|
|
21
|
-
name: "ExpoModulesMacros",
|
|
22
|
-
dependencies: [
|
|
23
|
-
"ExpoModulesCLI",
|
|
24
|
-
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
|
|
25
|
-
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
|
|
26
|
-
// For `expand`, which runs the macros in process.
|
|
27
|
-
.product(name: "SwiftSyntaxMacroExpansion", package: "swift-syntax"),
|
|
28
|
-
.product(name: "SwiftParser", package: "swift-syntax"),
|
|
29
|
-
.product(name: "SwiftParserDiagnostics", package: "swift-syntax"),
|
|
30
|
-
.product(name: "SwiftBasicFormat", package: "swift-syntax"),
|
|
31
|
-
]
|
|
32
|
-
),
|
|
33
|
-
.target(
|
|
34
|
-
name: "ExpoModulesCLI",
|
|
35
|
-
dependencies: [
|
|
36
|
-
.product(name: "SwiftSyntax", package: "swift-syntax"),
|
|
37
|
-
.product(name: "SwiftParser", package: "swift-syntax"),
|
|
38
|
-
.product(name: "SwiftIfConfig", package: "swift-syntax"),
|
|
39
|
-
]
|
|
40
|
-
),
|
|
41
|
-
]
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
// The Tests directory is excluded from the published npm package,
|
|
45
|
-
// so only declare the test target when building from the repository.
|
|
46
|
-
if FileManager.default.fileExists(atPath: Context.packageDirectory + "/Tests") {
|
|
47
|
-
package.targets.append(
|
|
48
|
-
.testTarget(
|
|
49
|
-
name: "ExpoModulesMacrosTests",
|
|
50
|
-
dependencies: [
|
|
51
|
-
"ExpoModulesMacros",
|
|
52
|
-
"ExpoModulesCLI",
|
|
53
|
-
.product(name: "SwiftSyntaxMacrosGenericTestSupport", package: "swift-syntax"),
|
|
54
|
-
]
|
|
55
|
-
)
|
|
56
|
-
)
|
|
57
|
-
package.targets.append(
|
|
58
|
-
.testTarget(
|
|
59
|
-
name: "ExpoModulesCLITests",
|
|
60
|
-
dependencies: [
|
|
61
|
-
"ExpoModulesCLI",
|
|
62
|
-
.product(name: "SwiftParser", package: "swift-syntax"),
|
|
63
|
-
]
|
|
64
|
-
)
|
|
65
|
-
)
|
|
66
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import ExpoModulesCLI
|
|
2
|
-
import SwiftCompilerPlugin
|
|
3
|
-
import SwiftSyntaxMacros
|
|
4
|
-
|
|
5
|
-
#if canImport(Darwin)
|
|
6
|
-
import Darwin
|
|
7
|
-
#elseif canImport(Glibc)
|
|
8
|
-
import Glibc
|
|
9
|
-
#elseif os(Windows)
|
|
10
|
-
import CRT
|
|
11
|
-
#endif
|
|
12
|
-
|
|
13
|
-
struct ExpoModulesMacrosPlugin: CompilerPlugin {
|
|
14
|
-
let providingMacros: [Macro.Type] = ProvidedMacro.all.map(\.type)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/// The executable doubles as the scanner CLI. The compiler always launches a plugin executable
|
|
18
|
-
/// without arguments and speaks the plugin protocol over stdin, so any argument means a scanner
|
|
19
|
-
/// invocation (`ExpoModulesMacros scan-modules <path>...`); with none, this starts the plugin
|
|
20
|
-
/// server exactly as `@main` on the `CompilerPlugin` type would. The CLI gets `expandMacros`, so
|
|
21
|
-
/// `expand` runs the macros of this executable.
|
|
22
|
-
@main
|
|
23
|
-
enum EntryPoint {
|
|
24
|
-
static func main() throws {
|
|
25
|
-
let arguments = Array(CommandLine.arguments.dropFirst())
|
|
26
|
-
if arguments.isEmpty {
|
|
27
|
-
try ExpoModulesMacrosPlugin.main()
|
|
28
|
-
} else {
|
|
29
|
-
let expander = MacroExpander(
|
|
30
|
-
attributeNames: Set(ProvidedMacro.all.map(\.name)),
|
|
31
|
-
expand: expandMacros
|
|
32
|
-
)
|
|
33
|
-
exit(ScannerCLI.run(arguments: arguments, expander: expander))
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
File without changes
|
|
File without changes
|
/package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/ExpoViewMacro.swift
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/ClosureArguments.swift
RENAMED
|
File without changes
|
|
File without changes
|
/package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/FreeFormTypes.swift
RENAMED
|
File without changes
|
/package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/JSConstructor.swift
RENAMED
|
File without changes
|
/package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/JSNameCollisions.swift
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/SendableConformance.swift
RENAMED
|
File without changes
|
|
File without changes
|
/package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/TypeAliases.swift
RENAMED
|
File without changes
|
|
File without changes
|