expo-modules-macros 0.28.0 → 0.29.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 +10 -7
- package/Package.swift +110 -0
- package/README.md +21 -4
- package/apple/ExpoModulesMacros +0 -0
- package/apple/Sources/ExpoModulesCLI/CLI.swift +1 -1
- package/apple/Sources/{ExpoModulesMacros → ExpoModulesCLI/Commands}/Expand/MacroExpander.swift +1 -1
- package/apple/Sources/ExpoModulesMacros/main.swift +6 -0
- 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 +1 -1
- package/apple/Sources/ExpoModulesMacrosTool/main.swift +27 -0
- 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/EventMacro.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/ExpoModuleMacro.swift +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/JSMacro.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/RecordMacro.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/SharedObjectMacro.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/UnionMacro.swift +0 -0
- /package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/ViewPropsMacro.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
|
@@ -15,7 +15,6 @@ concurrency:
|
|
|
15
15
|
|
|
16
16
|
defaults:
|
|
17
17
|
run:
|
|
18
|
-
working-directory: apple
|
|
19
18
|
shell: bash
|
|
20
19
|
|
|
21
20
|
jobs:
|
|
@@ -56,8 +55,8 @@ jobs:
|
|
|
56
55
|
- name: Cache SwiftPM build
|
|
57
56
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
58
57
|
with:
|
|
59
|
-
path:
|
|
60
|
-
key: spm-${{ github.repository }}-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('
|
|
58
|
+
path: .build
|
|
59
|
+
key: spm-${{ github.repository }}-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('Package.resolved') }}
|
|
61
60
|
restore-keys: |
|
|
62
61
|
spm-${{ github.repository }}-${{ runner.os }}-${{ matrix.arch }}-
|
|
63
62
|
|
|
@@ -70,14 +69,13 @@ jobs:
|
|
|
70
69
|
- name: Build release tool
|
|
71
70
|
# Runs `pnpm run build` (scripts/build.js): builds the release plugin binary for this
|
|
72
71
|
# architecture as platforms/linux-<arch>/ExpoModulesMacros.
|
|
73
|
-
working-directory: ${{ github.workspace }}
|
|
74
72
|
run: pnpm run build
|
|
75
73
|
|
|
76
74
|
- name: Verify the release tool
|
|
77
75
|
# With no arguments it is the plugin server, which exits when stdin closes; with arguments it
|
|
78
76
|
# is the scanner CLI.
|
|
79
77
|
run: |
|
|
80
|
-
tool="
|
|
78
|
+
tool="platforms/linux-${{ matrix.arch }}/ExpoModulesMacros"
|
|
81
79
|
# The Swift runtime must be linked in statically, so no Swift library may be a dependency.
|
|
82
80
|
needed="$(readelf --dynamic "$tool" | sed -n 's/.*(NEEDED).*\[\(.*\)\]$/\1/p')"
|
|
83
81
|
echo "Needed libraries:" $needed
|
|
@@ -98,7 +96,6 @@ jobs:
|
|
|
98
96
|
# Checks what `npm pack` would publish from `platforms/linux-<arch>`, where the release build
|
|
99
97
|
# put the tool: the executable with its executable bit, the README, the license and the
|
|
100
98
|
# manifest, with the `os`, `cpu` and `libc` fields for this machine.
|
|
101
|
-
working-directory: ${{ github.workspace }}
|
|
102
99
|
run: |
|
|
103
100
|
# The `./` matters: npm reads `platforms/linux-<arch>` as a GitHub repository.
|
|
104
101
|
npm pack "./platforms/linux-${{ matrix.arch }}" --pack-destination "$RUNNER_TEMP" --json > "$RUNNER_TEMP/pack.json"
|
|
@@ -126,7 +123,6 @@ jobs:
|
|
|
126
123
|
- name: Scan through the TypeScript wrapper
|
|
127
124
|
# Installs the packed platform package. The wrapper must find the executable in
|
|
128
125
|
# `@expo/modules-macros-linux-<arch>`, as it would in a project, not the local build.
|
|
129
|
-
working-directory: ${{ github.workspace }}
|
|
130
126
|
run: |
|
|
131
127
|
pnpm install
|
|
132
128
|
pnpm add --save-optional "$PLATFORM_PACKAGE_TARBALL"
|
|
@@ -284,14 +284,13 @@ jobs:
|
|
|
284
284
|
- name: Cache SwiftPM build
|
|
285
285
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
286
286
|
with:
|
|
287
|
-
path:
|
|
288
|
-
key: spm-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('
|
|
287
|
+
path: .build
|
|
288
|
+
key: spm-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('Package.resolved') }}
|
|
289
289
|
restore-keys: |
|
|
290
290
|
spm-${{ github.repository }}-${{ runner.os }}-
|
|
291
291
|
|
|
292
292
|
- name: Resolve dependencies
|
|
293
293
|
run: swift package resolve
|
|
294
|
-
working-directory: apple
|
|
295
294
|
|
|
296
295
|
- name: Install dependencies
|
|
297
296
|
# The wrapper's `prepublishOnly` build needs `tsc`; the tool binary needs none.
|
|
@@ -11,10 +11,6 @@ concurrency:
|
|
|
11
11
|
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
12
12
|
cancel-in-progress: true
|
|
13
13
|
|
|
14
|
-
defaults:
|
|
15
|
-
run:
|
|
16
|
-
working-directory: apple
|
|
17
|
-
|
|
18
14
|
jobs:
|
|
19
15
|
build-and-test:
|
|
20
16
|
name: Build & test
|
|
@@ -34,8 +30,8 @@ jobs:
|
|
|
34
30
|
- name: Cache SwiftPM build
|
|
35
31
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
36
32
|
with:
|
|
37
|
-
path:
|
|
38
|
-
key: spm-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('
|
|
33
|
+
path: .build
|
|
34
|
+
key: spm-${{ github.repository }}-${{ runner.os }}-${{ hashFiles('Package.resolved') }}
|
|
39
35
|
restore-keys: |
|
|
40
36
|
spm-${{ github.repository }}-${{ runner.os }}-
|
|
41
37
|
|
|
@@ -46,26 +42,24 @@ jobs:
|
|
|
46
42
|
# Runs `pnpm run build` (scripts/build.js): builds the universal
|
|
47
43
|
# (arm64 + x86_64) release plugin binary, copies it to
|
|
48
44
|
# apple/ExpoModulesMacros, and strips it.
|
|
49
|
-
working-directory: ${{ github.workspace }}
|
|
50
45
|
run: pnpm run build
|
|
51
46
|
|
|
52
47
|
- name: Verify universal binary
|
|
53
48
|
run: |
|
|
54
|
-
archs="$(lipo -archs ExpoModulesMacros)"
|
|
49
|
+
archs="$(lipo -archs apple/ExpoModulesMacros)"
|
|
55
50
|
echo "Architectures: $archs"
|
|
56
51
|
case "$archs" in *arm64*) ;; *) echo "Missing arm64 slice"; exit 1;; esac
|
|
57
52
|
case "$archs" in *x86_64*) ;; *) echo "Missing x86_64 slice"; exit 1;; esac
|
|
58
|
-
arch -arm64
|
|
59
|
-
arch -x86_64
|
|
53
|
+
arch -arm64 apple/ExpoModulesMacros < /dev/null
|
|
54
|
+
arch -x86_64 apple/ExpoModulesMacros < /dev/null
|
|
60
55
|
# With arguments the same binary runs the scanner CLI instead of the plugin server.
|
|
61
|
-
arch -arm64
|
|
62
|
-
arch -x86_64
|
|
56
|
+
arch -arm64 apple/ExpoModulesMacros --help > /dev/null
|
|
57
|
+
arch -x86_64 apple/ExpoModulesMacros --help > /dev/null
|
|
63
58
|
|
|
64
59
|
- name: Test
|
|
65
60
|
run: swift test -v
|
|
66
61
|
|
|
67
62
|
- name: Typecheck the TypeScript wrapper
|
|
68
|
-
working-directory: ${{ github.workspace }}
|
|
69
63
|
run: |
|
|
70
64
|
pnpm install
|
|
71
65
|
pnpm run typecheck
|
|
@@ -13,10 +13,6 @@ concurrency:
|
|
|
13
13
|
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
14
14
|
cancel-in-progress: true
|
|
15
15
|
|
|
16
|
-
defaults:
|
|
17
|
-
run:
|
|
18
|
-
working-directory: apple
|
|
19
|
-
|
|
20
16
|
jobs:
|
|
21
17
|
windows:
|
|
22
18
|
name: Build & test (Windows ${{ matrix.arch }})
|
|
@@ -56,8 +52,8 @@ jobs:
|
|
|
56
52
|
- name: Cache SwiftPM build
|
|
57
53
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
58
54
|
with:
|
|
59
|
-
path:
|
|
60
|
-
key: spm-${{ github.repository }}-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('
|
|
55
|
+
path: .build
|
|
56
|
+
key: spm-${{ github.repository }}-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('Package.resolved') }}
|
|
61
57
|
restore-keys: |
|
|
62
58
|
spm-${{ github.repository }}-${{ runner.os }}-${{ matrix.arch }}-
|
|
63
59
|
|
|
@@ -70,7 +66,6 @@ jobs:
|
|
|
70
66
|
- name: Build release tool
|
|
71
67
|
# Runs `pnpm run build` (scripts/build.js): builds the release plugin binary for this
|
|
72
68
|
# architecture as platforms/win32-<arch>/ExpoModulesMacros.exe.
|
|
73
|
-
working-directory: ${{ github.workspace }}
|
|
74
69
|
run: pnpm run build
|
|
75
70
|
|
|
76
71
|
- name: Verify the release tool
|
|
@@ -79,7 +74,7 @@ jobs:
|
|
|
79
74
|
# is the scanner CLI.
|
|
80
75
|
shell: pwsh
|
|
81
76
|
run: |
|
|
82
|
-
$exe = (Resolve-Path "
|
|
77
|
+
$exe = (Resolve-Path "platforms/win32-${{ matrix.arch }}/ExpoModulesMacros.exe").Path
|
|
83
78
|
$env:PATH = "$env:SystemRoot\System32;$env:SystemRoot"
|
|
84
79
|
cmd /c "`"$exe`" < NUL"
|
|
85
80
|
if ($LASTEXITCODE -ne 0) { throw "The plugin server exited with $LASTEXITCODE" }
|
|
@@ -90,7 +85,6 @@ jobs:
|
|
|
90
85
|
# Checks what `npm pack` would publish from `platforms/win32-<arch>`, where the release build
|
|
91
86
|
# put the tool: the executable, the README, the license and the manifest, with the `os` and
|
|
92
87
|
# `cpu` fields for this machine.
|
|
93
|
-
working-directory: ${{ github.workspace }}
|
|
94
88
|
shell: pwsh
|
|
95
89
|
run: |
|
|
96
90
|
# The `./` matters: npm reads `platforms/win32-<arch>` as a GitHub repository.
|
|
@@ -109,7 +103,6 @@ jobs:
|
|
|
109
103
|
- name: Scan through the TypeScript wrapper
|
|
110
104
|
# Installs the packed platform package. The wrapper must find the executable in
|
|
111
105
|
# `@expo/modules-macros-win32-<arch>`, as it would in a project, not the local build.
|
|
112
|
-
working-directory: ${{ github.workspace }}
|
|
113
106
|
shell: pwsh
|
|
114
107
|
run: |
|
|
115
108
|
pnpm install
|
package/AGENTS.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
## Layout
|
|
6
6
|
|
|
7
|
-
- `
|
|
8
|
-
- `apple/Sources/
|
|
9
|
-
- `apple/Sources/
|
|
7
|
+
- `Package.swift`: the SwiftPM package, at the root so that its identity is `expo-modules-macros` (an `apple/` manifest would have the identity `apple`, which conflicts with other packages that keep theirs in `apple/`). The targets name their paths under `apple/`. The `ExpoModulesMacrosPlugin` library product vends the macro target to Swift packages, and its name must differ from the target's. The test targets are declared only when `apple/Tests` exists, because the published npm package leaves it out.
|
|
8
|
+
- `apple/Sources/ExpoModulesMacrosCore`: the macro implementations, in a library target so that both executables below can link them. `Macros/` holds one file per macro, and `Support/` the code that several macros share. `ProvidedMacros.swift` lists every macro with its attribute name and conformances in `ProvidedMacro.all`. `PluginServer.swift` runs the compiler plugin protocol with a provider that resolves the macros of `ProvidedMacro.all` by type name, because the default `CompilerPlugin` lookup expects them in a module named `ExpoModulesMacros`. It uses the `@_spi(PluginMessage)` API of swift-syntax.
|
|
9
|
+
- `apple/Sources/ExpoModulesMacros`: the `.macro` target that the `ExpoModulesMacrosPlugin` product vends to Swift packages. It only runs the plugin server, so Swift packages don't compile the CLI.
|
|
10
|
+
- `apple/Sources/ExpoModulesMacrosTool`: the executable that ships as `apple/ExpoModulesMacros` and in the Windows and Linux packages. `main.swift` runs the plugin server without arguments and sends any invocation with arguments to the CLI.
|
|
11
|
+
- `apple/Sources/ExpoModulesCLI`: the library behind the command-line tool. `CLI.swift` parses the arguments, `Commands/` holds one directory per subcommand (`ScanModules/` for autolinking, `ScanExports/` for type generation, `Expand/` for `expand`, with `MacroExpander.swift`, which runs the macros in process), and `Core/` holds the shared parsing, `#if` evaluation and output.
|
|
10
12
|
- `apple/Sources/ExpoModulesOptimized`: declarations for the `@OptimizedFunction` macro.
|
|
11
13
|
- `apple/Tests`: `ExpoModulesMacrosTests` (expansion tests) and `ExpoModulesCLITests`.
|
|
12
14
|
- `platforms/`: the Windows packages `@expo/modules-macros-win32-x64` and `-arm64`, and the Linux packages `@expo/modules-macros-linux-x64` and `-arm64` (a `package.json` with `os` and `cpu`, plus `libc` on Linux, a README and a copy of `LICENSE`). The Publish workflow runs `scripts/set-platform-versions.js` to give them the version of this package. Their `ExpoModulesMacros.exe` (Windows) or `ExpoModulesMacros` (Linux) is written there by `pnpm run build` on that platform and isn't committed.
|
|
@@ -20,8 +22,8 @@
|
|
|
20
22
|
Swift 6.2 is required (Xcode 26 or newer on macOS). The package manager is pnpm, at the version in `packageManager` in `package.json`.
|
|
21
23
|
|
|
22
24
|
```sh
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
swift build # debug build
|
|
26
|
+
swift test # all Swift tests
|
|
25
27
|
pnpm install # TypeScript dependencies
|
|
26
28
|
pnpm run typecheck # TypeScript wrapper
|
|
27
29
|
pnpm run build # release binary (slow; on macOS uses Rosetta for x86_64)
|
|
@@ -56,7 +58,7 @@ CI runs on macOS (`.github/workflows/swift.yml`), on Windows x64 and arm64 (`.gi
|
|
|
56
58
|
|
|
57
59
|
- The scanner re-implements the macros' naming and member rules on the syntax tree; it does not call the macro code. When a macro changes which members it binds or how it names them (the `@JS` name override, the `on` prefix `@Event` strips, which properties `@Record` treats as fields), change `scan-exports` to match, or generated TypeScript types drift from the runtime.
|
|
58
60
|
- The scanner only parses files that pass the pre-filter, `MacroPrefilter` in `ExpoModulesCLI/Core/SourceScan.swift`. Each command builds it from the `macros` and `conformances` arguments of its `scanFiles` call. A new attribute or conformance the scanner must detect has to be added to those arguments (an attribute also needs a `DetectedMacro` case), or files that use it are skipped without an error.
|
|
59
|
-
- A new macro needs: the implementation in `apple/Sources/
|
|
61
|
+
- A new macro needs: the implementation in `apple/Sources/ExpoModulesMacrosCore/Macros`, an entry in `ProvidedMacro.all` in `ProvidedMacros.swift` (with the attribute name and the extension conformances of its declaration), an expansion test file, the `#externalMacro` declaration in `expo-modules-core`, and an entry in the macro list in `README.md`.
|
|
60
62
|
|
|
61
63
|
## Contracts with other packages
|
|
62
64
|
|
|
@@ -64,6 +66,7 @@ CI runs on macOS (`.github/workflows/swift.yml`), on Windows x64 and arm64 (`.gi
|
|
|
64
66
|
- **Generated code calls `expo-modules-core` API.** An expansion that uses a new core symbol only works with a core version that has it.
|
|
65
67
|
- **Scanner output is versioned.** `scanModulesSchemaVersion` (`Commands/ScanModules/ScanModules.swift`), `scanExportsSchemaVersion` (`Commands/ScanExports/ExportedSurface.swift`) and `expandSchemaVersion` (`Commands/Expand/ExpandReport.swift`) change independently. When the output shape of a command changes, bump its version and update the matching `SUPPORTED_*_SCHEMA_VERSION` constant and mirror types in `src/types.ts`. `expo-modules-autolinking` also checks the `scan-modules` version.
|
|
66
68
|
- **The binary path is part of the contract.** `expo-modules-autolinking` resolves this package from `expo-modules-core` and passes `-load-plugin-executable <package>/apple/<binary>#ExpoModulesMacros` to the compiler. The scanner wrapper in autolinking uses the same path, and `expo-modules-cli` uses `getScannerBinaryPath()`. On Windows the binary is `ExpoModulesMacros.exe` in `@expo/modules-macros-win32-<arch>`, and on Linux `ExpoModulesMacros` in `@expo/modules-macros-linux-<arch>`. Renaming or moving a binary needs a matching change in `expo/expo`.
|
|
69
|
+
- **Swift packages depend on the product.** A Swift package that declares or uses the macros depends on the `ExpoModulesMacrosPlugin` product and builds the plugin from source, without the binary. Renaming the product or the macro target, or moving `Package.swift`, needs a matching change in `expo/expo`.
|
|
67
70
|
|
|
68
71
|
## Releases
|
|
69
72
|
|
|
@@ -74,4 +77,4 @@ CI runs on macOS (`.github/workflows/swift.yml`), on Windows x64 and arm64 (`.gi
|
|
|
74
77
|
|
|
75
78
|
## Installed copies
|
|
76
79
|
|
|
77
|
-
In `node_modules`,
|
|
80
|
+
In `node_modules`, a CocoaPods build runs the prebuilt binary `apple/ExpoModulesMacros` (on Windows and Linux, the binary from `@expo/modules-macros-<platform>-<arch>`); editing the Swift sources there has no effect. Macro and scanner fixes belong in this repository and ship in a new release. The TypeScript wrapper ships compiled in `build/`, since `src/` is not published.
|
package/Package.swift
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
products: [
|
|
12
|
+
// Lets a SwiftPM package depend on the macros, so the compiler builds and loads the plugin from
|
|
13
|
+
// source, with no `-load-plugin-executable` flag. A target that declares the macros with
|
|
14
|
+
// `#externalMacro(module: "ExpoModulesMacros", ...)` depends on this product, and the targets that
|
|
15
|
+
// depend on it get the plugin too. CocoaPods builds keep loading the prebuilt binary. The name
|
|
16
|
+
// differs from the macro target's, because SwiftPM already has a product of that name for it.
|
|
17
|
+
.library(name: "ExpoModulesMacrosPlugin", targets: ["ExpoModulesMacros"]),
|
|
18
|
+
.executable(name: "ExpoModulesMacrosTool", targets: ["ExpoModulesMacrosTool"]),
|
|
19
|
+
],
|
|
20
|
+
dependencies: [
|
|
21
|
+
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "604.0.0-latest")
|
|
22
|
+
],
|
|
23
|
+
targets: [
|
|
24
|
+
// The macro implementations, shared by the plugin and the tool. The macro target can't be a
|
|
25
|
+
// dependency of an executable, so they live in a library target.
|
|
26
|
+
.target(
|
|
27
|
+
name: "ExpoModulesMacrosCore",
|
|
28
|
+
dependencies: [
|
|
29
|
+
.product(name: "SwiftSyntax", package: "swift-syntax"),
|
|
30
|
+
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
|
|
31
|
+
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
|
|
32
|
+
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
|
|
33
|
+
// For the plugin server, which resolves the macros by type name (see PluginServer.swift).
|
|
34
|
+
.product(name: "_SwiftCompilerPluginMessageHandling", package: "swift-syntax"),
|
|
35
|
+
],
|
|
36
|
+
path: "apple/Sources/ExpoModulesMacrosCore"
|
|
37
|
+
),
|
|
38
|
+
// The plugin that Swift packages build from source. It serves only the macros, so it doesn't
|
|
39
|
+
// compile the CLI. It lists the swift-syntax products of the implementation again: when SwiftPM
|
|
40
|
+
// uses its prebuilt swift-syntax, it links the prebuilt library only for the products that the
|
|
41
|
+
// macro target itself depends on, and the link fails without them.
|
|
42
|
+
.macro(
|
|
43
|
+
name: "ExpoModulesMacros",
|
|
44
|
+
dependencies: [
|
|
45
|
+
"ExpoModulesMacrosCore",
|
|
46
|
+
.product(name: "SwiftSyntax", package: "swift-syntax"),
|
|
47
|
+
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
|
|
48
|
+
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
|
|
49
|
+
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
|
|
50
|
+
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
|
|
51
|
+
],
|
|
52
|
+
path: "apple/Sources/ExpoModulesMacros"
|
|
53
|
+
),
|
|
54
|
+
// The shipped binary, `apple/ExpoModulesMacros` and the Windows and Linux binaries. It is both the
|
|
55
|
+
// compiler plugin and the scanner CLI: the compiler launches it without arguments and speaks the
|
|
56
|
+
// plugin protocol over stdin, while an invocation with arguments dispatches into `ScannerCLI`
|
|
57
|
+
// (see main.swift). CocoaPods builds, `expo-modules-autolinking` and `expo-modules-cli` all
|
|
58
|
+
// use this one executable.
|
|
59
|
+
.executableTarget(
|
|
60
|
+
name: "ExpoModulesMacrosTool",
|
|
61
|
+
dependencies: [
|
|
62
|
+
"ExpoModulesCLI",
|
|
63
|
+
"ExpoModulesMacrosCore",
|
|
64
|
+
],
|
|
65
|
+
path: "apple/Sources/ExpoModulesMacrosTool"
|
|
66
|
+
),
|
|
67
|
+
.target(
|
|
68
|
+
name: "ExpoModulesCLI",
|
|
69
|
+
dependencies: [
|
|
70
|
+
"ExpoModulesMacrosCore",
|
|
71
|
+
.product(name: "SwiftSyntax", package: "swift-syntax"),
|
|
72
|
+
.product(name: "SwiftParser", package: "swift-syntax"),
|
|
73
|
+
.product(name: "SwiftIfConfig", package: "swift-syntax"),
|
|
74
|
+
// For `expand`, which runs the macros in process.
|
|
75
|
+
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
|
|
76
|
+
.product(name: "SwiftSyntaxMacroExpansion", package: "swift-syntax"),
|
|
77
|
+
.product(name: "SwiftParserDiagnostics", package: "swift-syntax"),
|
|
78
|
+
.product(name: "SwiftBasicFormat", package: "swift-syntax"),
|
|
79
|
+
.product(name: "SwiftDiagnostics", package: "swift-syntax"),
|
|
80
|
+
],
|
|
81
|
+
path: "apple/Sources/ExpoModulesCLI"
|
|
82
|
+
),
|
|
83
|
+
]
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
// The Tests directory is excluded from the published npm package,
|
|
87
|
+
// so only declare the test target when building from the repository.
|
|
88
|
+
if FileManager.default.fileExists(atPath: Context.packageDirectory + "/apple/Tests") {
|
|
89
|
+
package.targets.append(
|
|
90
|
+
.testTarget(
|
|
91
|
+
name: "ExpoModulesMacrosTests",
|
|
92
|
+
dependencies: [
|
|
93
|
+
"ExpoModulesMacrosCore",
|
|
94
|
+
"ExpoModulesCLI",
|
|
95
|
+
.product(name: "SwiftSyntaxMacrosGenericTestSupport", package: "swift-syntax"),
|
|
96
|
+
],
|
|
97
|
+
path: "apple/Tests/ExpoModulesMacrosTests"
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
package.targets.append(
|
|
101
|
+
.testTarget(
|
|
102
|
+
name: "ExpoModulesCLITests",
|
|
103
|
+
dependencies: [
|
|
104
|
+
"ExpoModulesCLI",
|
|
105
|
+
.product(name: "SwiftParser", package: "swift-syntax"),
|
|
106
|
+
],
|
|
107
|
+
path: "apple/Tests/ExpoModulesCLITests"
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
}
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ The same executable doubles as a source scanner CLI.
|
|
|
13
13
|
|
|
14
14
|
# Installation
|
|
15
15
|
|
|
16
|
-
This package is not meant to be installed directly. It is a dependency of `expo-modules-core`, so every Expo project already has it. The published package contains a prebuilt universal (arm64 + x86_64) macOS binary at `apple/ExpoModulesMacros`, so
|
|
16
|
+
This package is not meant to be installed directly. It is a dependency of `expo-modules-core`, so every Expo project already has it. The published package contains a prebuilt universal (arm64 + x86_64) macOS binary at `apple/ExpoModulesMacros`, so CocoaPods builds never build the plugin themselves. A Swift package can build it from source instead (see [Swift packages](#swift-packages)).
|
|
17
17
|
|
|
18
18
|
The Windows and Linux binaries ship in their own packages, one per platform and architecture:
|
|
19
19
|
|
|
@@ -145,16 +145,33 @@ The binary is a compiled executable, so each call still spawns a process. What t
|
|
|
145
145
|
|
|
146
146
|
to `OTHER_SWIFT_FLAGS` for `ExpoModulesCore`, every pod that depends on it, and their test specs. Expo's SPM prebuilds pass the same flag when they generate `Package.swift`, so both build systems load the same binary.
|
|
147
147
|
|
|
148
|
+
## Swift packages
|
|
149
|
+
|
|
150
|
+
The package manifest is `Package.swift` at the root of this package, so a Swift package can depend on it by its path in `node_modules` or by the URL of this repository. Its identity is then `expo-modules-macros`. The `ExpoModulesMacrosPlugin` library product holds the `ExpoModulesMacros` macro target:
|
|
151
|
+
|
|
152
|
+
```swift
|
|
153
|
+
dependencies: [
|
|
154
|
+
.package(path: "../node_modules/expo-modules-macros")
|
|
155
|
+
],
|
|
156
|
+
targets: [
|
|
157
|
+
.target(
|
|
158
|
+
name: "ExpoModulesCore",
|
|
159
|
+
dependencies: [.product(name: "ExpoModulesMacrosPlugin", package: "expo-modules-macros")]
|
|
160
|
+
)
|
|
161
|
+
]
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
SwiftPM then builds the plugin from source for the host (the macros, without the scanner CLI) and loads it into every target that depends on that target, with no `-load-plugin-executable` flag and no unsafe flags. When the resolved swift-syntax version is a release, SwiftPM and Xcode can use their prebuilt swift-syntax for it, so only the sources of this package compile.
|
|
165
|
+
|
|
148
166
|
On Windows and Linux, the compiler loads `ExpoModulesMacros.exe` from `@expo/modules-macros-win32-<arch>` or `ExpoModulesMacros` from `@expo/modules-macros-linux-<arch>` with the same flag. `getScannerBinaryPath()` in the TypeScript wrapper returns the binary for the current platform and architecture. On Windows and Linux it falls back to the local `pnpm run build` output in `platforms/<platform>-<arch>` when the platform package isn't installed, for example in this repository.
|
|
149
167
|
|
|
150
|
-
The module and type names in `#externalMacro` must stay in sync with `apple/Sources/
|
|
168
|
+
The module and type names in `#externalMacro` must stay in sync with `ProvidedMacro.all` in `apple/Sources/ExpoModulesMacrosCore/ProvidedMacros.swift`.
|
|
151
169
|
|
|
152
170
|
# Development
|
|
153
171
|
|
|
154
172
|
Requires a toolchain with Swift 6.2 or newer: on macOS 13 or newer that means Xcode 26 or newer, and on Windows and Linux the Swift toolchain from swift.org (CI uses 6.4).
|
|
155
173
|
|
|
156
174
|
```sh
|
|
157
|
-
cd apple
|
|
158
175
|
swift build
|
|
159
176
|
swift test
|
|
160
177
|
```
|
|
@@ -174,7 +191,7 @@ cp "$(cd /tmp/swift-format && swift build -c release --show-bin-path)/swift-form
|
|
|
174
191
|
|
|
175
192
|
Then add `~/.local/bin` to `PATH`.
|
|
176
193
|
|
|
177
|
-
`pnpm run build` runs `scripts/build.js`, which builds the release binary with SwiftPM's native build system
|
|
194
|
+
`pnpm run build` runs `scripts/build.js`, which builds the release binary, the `ExpoModulesMacrosTool` executable, with SwiftPM's native build system.
|
|
178
195
|
|
|
179
196
|
- On macOS, it builds for arm64 and x86_64, merges the slices into `apple/ExpoModulesMacros` with `lipo`, strips it, and verifies both slices are present. SwiftPM only builds macro tools for the host architecture, so the x86_64 slice is produced by running the toolchain under Rosetta; the script installs Rosetta if it is missing.
|
|
180
197
|
- On Windows, it builds for the host architecture only, with the Swift runtime linked in statically and without debug info, and writes `platforms/win32-<arch>/ExpoModulesMacros.exe` (`x64` or `arm64`, as Node's `process.arch` names them), the file that the package for that architecture publishes. It strips the executable with `llvm-strip` from the Swift toolchain and checks the architecture in its header.
|
package/apple/ExpoModulesMacros
CHANGED
|
Binary file
|
|
@@ -110,7 +110,7 @@ public enum ScannerCLI {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
/// The invoked executable's basename, so the usage text matches however the tool was launched
|
|
113
|
-
/// (the `ExpoModulesMacros` shipped in the package, or a locally built `
|
|
113
|
+
/// (the `ExpoModulesMacros` shipped in the package, or a locally built `ExpoModulesMacrosTool`).
|
|
114
114
|
private var toolName: String {
|
|
115
115
|
guard let path = CommandLine.arguments.first else {
|
|
116
116
|
return "ExpoModulesMacros"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ExpoModulesMacrosCore
|
|
2
|
+
|
|
3
|
+
// The plugin executable that SwiftPM builds for the packages that depend on the
|
|
4
|
+
// `ExpoModulesMacrosPlugin` product. It only serves the macros, so it doesn't link the CLI; the
|
|
5
|
+
// binary that this package ships is `ExpoModulesMacrosTool`, which does both.
|
|
6
|
+
try runPluginServer()
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@_spi(PluginMessage) import SwiftCompilerPluginMessageHandling
|
|
2
|
+
import SwiftSyntaxMacros
|
|
3
|
+
|
|
4
|
+
/// The module name that `expo-modules-core` passes to `#externalMacro`, and the name of the macro
|
|
5
|
+
/// target that SwiftPM loads as the plugin.
|
|
6
|
+
private let pluginModuleName = "ExpoModulesMacros"
|
|
7
|
+
|
|
8
|
+
/// Runs the compiler plugin server on stdin and stdout until the compiler closes the connection.
|
|
9
|
+
///
|
|
10
|
+
/// `CompilerPlugin.main()` finds a macro by comparing `String(reflecting:)` of each type with
|
|
11
|
+
/// `<module>.<type>` from `#externalMacro`. The macro types live in this module, not in a module
|
|
12
|
+
/// named `ExpoModulesMacros`, so both executables that serve the plugin (the SwiftPM macro target and
|
|
13
|
+
/// the shipped tool) use this provider, which matches the type name under the plugin module name.
|
|
14
|
+
public func runPluginServer() throws {
|
|
15
|
+
let connection = try StandardIOMessageConnection()
|
|
16
|
+
let listener = CompilerPluginMessageListener(connection: connection, provider: ProvidedMacroProvider())
|
|
17
|
+
try listener.main()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private struct ProvidedMacroProvider: PluginProvider {
|
|
21
|
+
let macros: [String: Macro.Type] = Dictionary(
|
|
22
|
+
uniqueKeysWithValues: ProvidedMacro.all.map { (String(describing: $0.type), $0.type) }
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
func resolveMacro(moduleName: String, typeName: String) throws -> Macro.Type {
|
|
26
|
+
guard moduleName == pluginModuleName, let type = macros[typeName] else {
|
|
27
|
+
throw UnknownMacroError(moduleName: moduleName, typeName: typeName)
|
|
28
|
+
}
|
|
29
|
+
return type
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private struct UnknownMacroError: Error, CustomStringConvertible {
|
|
34
|
+
let moduleName: String
|
|
35
|
+
let typeName: String
|
|
36
|
+
|
|
37
|
+
var description: String {
|
|
38
|
+
"macro implementation type '\(moduleName).\(typeName)' could not be found in the Expo Modules macro plugin"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -3,15 +3,15 @@ import SwiftSyntaxMacros
|
|
|
3
3
|
|
|
4
4
|
/// A macro that the plugin provides, with the attribute name and the extension conformances of its
|
|
5
5
|
/// declaration in `expo-modules-core`.
|
|
6
|
-
struct ProvidedMacro {
|
|
7
|
-
let name: String
|
|
8
|
-
let type: Macro.Type
|
|
9
|
-
var conformances: [TypeSyntax] = []
|
|
6
|
+
public struct ProvidedMacro {
|
|
7
|
+
public let name: String
|
|
8
|
+
public let type: Macro.Type
|
|
9
|
+
public var conformances: [TypeSyntax] = []
|
|
10
10
|
|
|
11
11
|
/// Every macro of the plugin. The compiler gets the types from `providingMacros`, and `expand`
|
|
12
12
|
/// matches the attributes by name and passes the same conformances as the compiler, so both read
|
|
13
13
|
/// this list.
|
|
14
|
-
static var all: [ProvidedMacro] {
|
|
14
|
+
public static var all: [ProvidedMacro] {
|
|
15
15
|
[
|
|
16
16
|
ProvidedMacro(name: "OptimizedFunction", type: OptimizedFunctionAttachedMacro.self),
|
|
17
17
|
ProvidedMacro(name: "JS", type: JSMacro.self),
|
package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Support/MacroHelpers.swift
RENAMED
|
@@ -524,7 +524,7 @@ internal func encodeCall(_ type: String, freeForm: FreeFormConversion?, of value
|
|
|
524
524
|
/// `name` without the backticks that escape it: `` `default` `` becomes `default`. Swift needs the
|
|
525
525
|
/// backticks in every identifier position, but a name JavaScript sees (a JS member name, an event
|
|
526
526
|
/// name, a record key) is the bare name.
|
|
527
|
-
|
|
527
|
+
public func withoutBackticks(_ name: String) -> String {
|
|
528
528
|
var name = Substring(name)
|
|
529
529
|
while name.first == "`" {
|
|
530
530
|
name.removeFirst()
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-macros",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.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.29.0",
|
|
30
|
+
"@expo/modules-macros-linux-x64": "0.29.0",
|
|
31
|
+
"@expo/modules-macros-win32-arm64": "0.29.0",
|
|
32
|
+
"@expo/modules-macros-win32-x64": "0.29.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/ExpoModuleMacro.swift
RENAMED
|
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}/Macros/SharedObjectMacro.swift
RENAMED
|
File without changes
|
|
File without changes
|
/package/apple/Sources/{ExpoModulesMacros → ExpoModulesMacrosCore}/Macros/ViewPropsMacro.swift
RENAMED
|
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
|