expo-modules-macros 0.21.0 → 0.23.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.
Files changed (41) hide show
  1. package/.github/workflows/linux.yml +8 -5
  2. package/.github/workflows/publish.yml +26 -11
  3. package/.github/workflows/swift-format.yml +79 -0
  4. package/.github/workflows/swift.yml +7 -4
  5. package/.github/workflows/windows.yml +8 -5
  6. package/AGENTS.md +16 -9
  7. package/README.md +20 -5
  8. package/apple/ExpoModulesMacros +0 -0
  9. package/apple/Package.resolved +3 -3
  10. package/apple/Package.swift +1 -2
  11. package/apple/Sources/ExpoModulesMacros/ClosureArguments.swift +39 -14
  12. package/apple/Sources/ExpoModulesMacros/DecorateModuleBuilder.swift +144 -30
  13. package/apple/Sources/ExpoModulesMacros/EventMacro.swift +29 -15
  14. package/apple/Sources/ExpoModulesMacros/ExpoModuleMacro.swift +63 -68
  15. package/apple/Sources/ExpoModulesMacros/ExpoModulesOptimizedMacro.swift +2 -1
  16. package/apple/Sources/ExpoModulesMacros/FreeFormTypes.swift +2 -61
  17. package/apple/Sources/ExpoModulesMacros/JSConstructor.swift +6 -3
  18. package/apple/Sources/ExpoModulesMacros/JSMacro.swift +184 -48
  19. package/apple/Sources/ExpoModulesMacros/JSNameCollisions.swift +26 -6
  20. package/apple/Sources/ExpoModulesMacros/MacroHelpers.swift +172 -43
  21. package/apple/Sources/ExpoModulesMacros/RecordMacro.swift +286 -222
  22. package/apple/Sources/ExpoModulesMacros/SharedObjectMacro.swift +49 -56
  23. package/apple/Sources/ExpoModulesMacros/TypeConformanceAssertion.swift +57 -27
  24. package/apple/Sources/ExpoModulesMacros/UnionMacro.swift +23 -9
  25. package/apple/Sources/ExpoModulesMacros/ViewPropsMacro.swift +10 -5
  26. package/apple/Sources/ExpoModulesScanner/CLI.swift +3 -1
  27. package/apple/Sources/ExpoModulesScanner/Core/DetectionVisitor.swift +11 -7
  28. package/apple/Sources/ExpoModulesScanner/Core/ScanBuildConfiguration.swift +2 -1
  29. package/apple/Sources/ExpoModulesScanner/Core/SourceScan.swift +10 -7
  30. package/apple/Sources/ExpoModulesScanner/Exports/Availability.swift +6 -3
  31. package/apple/Sources/ExpoModulesScanner/Exports/ExportedSurface.swift +20 -4
  32. package/apple/Sources/ExpoModulesScanner/Exports/ResolveRefs.swift +18 -5
  33. package/apple/Sources/ExpoModulesScanner/Exports/ScanExports.swift +8 -3
  34. package/apple/Sources/ExpoModulesScanner/Exports/SurfaceVisitor.swift +179 -46
  35. package/apple/Sources/ExpoModulesScanner/Exports/TypeNode.swift +28 -8
  36. package/apple/Sources/ExpoModulesScanner/Modules/ScanModules.swift +8 -2
  37. package/build/index.d.ts +1 -1
  38. package/build/index.js +3 -3
  39. package/build/types.d.ts +32 -2
  40. package/build/types.js +1 -1
  41. package/package.json +8 -5
package/build/index.js CHANGED
@@ -75,7 +75,7 @@ function platformBinaryPackageName() {
75
75
  * `bin` directory.
76
76
  * - Windows and Linux: `ExpoModulesMacros.exe` or `ExpoModulesMacros` from the package for the
77
77
  * current platform and architecture (see `platformBinaryPackageName`). When that package isn't
78
- * installed, for example in this repository, it falls back to the executable that `npm run build`
78
+ * installed, for example in this repository, it falls back to the executable that `pnpm run build`
79
79
  * writes to `platforms/<platform>-<arch>`.
80
80
  *
81
81
  * The path isn't checked here; running a missing binary fails with a `ScannerError` that says how to
@@ -97,7 +97,7 @@ function getScannerBinaryPath() {
97
97
  /** The message for a scanner binary that doesn't exist at `binaryPath`. */
98
98
  function missingBinaryMessage(binaryPath) {
99
99
  if (process.platform === 'darwin') {
100
- return `The scanner binary is missing at ${binaryPath}. Run \`npm run build\` in this package to build it.`;
100
+ return `The scanner binary is missing at ${binaryPath}. Run \`pnpm run build\` in this package to build it.`;
101
101
  }
102
102
  const machines = platformPackageMachines[process.platform];
103
103
  if (machines === undefined) {
@@ -106,7 +106,7 @@ function missingBinaryMessage(binaryPath) {
106
106
  return (`The scanner binary is missing at ${binaryPath}. It comes from the optional package ` +
107
107
  `${platformBinaryPackageName()}, which your package manager installs only on ${machines}. ` +
108
108
  'Reinstall dependencies without skipping optional ones (for example without `--omit=optional`), ' +
109
- 'or run `npm run build` in this package to build it locally.');
109
+ 'or run `pnpm run build` in this package to build it locally.');
110
110
  }
111
111
  /**
112
112
  * Runs a scanner subcommand and parses its JSON report.
package/build/types.d.ts CHANGED
@@ -61,6 +61,15 @@ export type TypeNode = {
61
61
  name: string;
62
62
  refKind?: 'record' | 'sharedObject' | 'enum' | 'union';
63
63
  }
64
+ /**
65
+ * `SharedRef<T>`: a shared object that JS sees as an instance of `expo.SharedRef`. `native` is the
66
+ * `T` it holds on the native side. It never reaches JS, so refs in it are not resolved.
67
+ */
68
+ | {
69
+ kind: 'sharedRef';
70
+ typeof: JSType;
71
+ native: TypeNode;
72
+ }
64
73
  /** A type the scanner couldn't interpret; `text` is its source spelling. */
65
74
  | {
66
75
  kind: 'unknown';
@@ -139,8 +148,14 @@ export interface ExportedParameter {
139
148
  }
140
149
  /** One `@JS func` on a module or shared object. */
141
150
  export interface ExportedFunction extends ExportedAccess, ExportedAvailability {
151
+ /**
152
+ * The Swift declaration name. A function with `.withAsync("x")` has two entries with this name.
153
+ */
142
154
  name: string;
143
- /** The JS name it binds under: the `@JS("x")` override, else `name`. */
155
+ /**
156
+ * The JS name it binds under: the `@JS("x")` override, else `name`. The second entry of a function
157
+ * with `.withAsync("x")` binds under `x`.
158
+ */
144
159
  jsName: string;
145
160
  parameters: ExportedParameter[];
146
161
  /** Absent for a `Void` return. */
@@ -235,11 +250,26 @@ export interface ExportedSharedObject extends ExportedAccess, ExportedAvailabili
235
250
  * which every JS object inherits.
236
251
  */
237
252
  initializer?: ExportedInitializer;
253
+ /** What the class inherits from `SharedRef<T>`, or absent when its superclass isn't `SharedRef`. */
254
+ sharedRef?: ExportedSharedRef;
238
255
  functions: ExportedFunction[];
239
256
  properties: ExportedProperty[];
240
257
  events: ExportedEvent[];
241
258
  file: string;
242
259
  }
260
+ /**
261
+ * The `SharedRef<T>` superclass of a shared object. Only the superclass written on the class is read,
262
+ * so a class that inherits `SharedRef` through another subclass has none.
263
+ */
264
+ export interface ExportedSharedRef {
265
+ /** The `T` in `SharedRef<T>`: the native type the object holds, which JS never sees. */
266
+ native: TypeNode;
267
+ /**
268
+ * The `nativeRefType` JS reads to tell refs apart, for example `image`. `unknown` (core's default)
269
+ * when the class doesn't override it, and absent when the override isn't a plain string literal.
270
+ */
271
+ nativeRefType?: string;
272
+ }
243
273
  /** A `@Record` type and its properties. */
244
274
  export interface ExportedRecord extends ExportedAccess, ExportedAvailability {
245
275
  /** The Swift type name, qualified with the types it is nested in (`Outer.Options`). */
@@ -359,4 +389,4 @@ export interface ScanExportsResult {
359
389
  * as a clear error instead of silently misread fields.
360
390
  */
361
391
  export declare const SUPPORTED_SCAN_MODULES_SCHEMA_VERSION = 2;
362
- export declare const SUPPORTED_SCAN_EXPORTS_SCHEMA_VERSION = 8;
392
+ export declare const SUPPORTED_SCAN_EXPORTS_SCHEMA_VERSION = 9;
package/build/types.js CHANGED
@@ -12,4 +12,4 @@ exports.SUPPORTED_SCAN_EXPORTS_SCHEMA_VERSION = exports.SUPPORTED_SCAN_MODULES_S
12
12
  * as a clear error instead of silently misread fields.
13
13
  */
14
14
  exports.SUPPORTED_SCAN_MODULES_SCHEMA_VERSION = 2;
15
- exports.SUPPORTED_SCAN_EXPORTS_SCHEMA_VERSION = 8;
15
+ exports.SUPPORTED_SCAN_EXPORTS_SCHEMA_VERSION = 9;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-macros",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "description": "Swift macro plugin for Expo modules",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -11,11 +11,14 @@
11
11
  "type": "git",
12
12
  "url": "git+https://github.com/expo/expo-modules-macros.git"
13
13
  },
14
+ "packageManager": "pnpm@12.14.0",
14
15
  "scripts": {
15
16
  "build": "node scripts/build.js",
16
17
  "build:ts": "tsc -p tsconfig.json",
17
18
  "clean": "rm -rf build",
18
19
  "typecheck": "tsc -p tsconfig.json --noEmit",
20
+ "swift:format": "node scripts/swift-format.js",
21
+ "swift:lint": "node scripts/swift-format.js --lint",
19
22
  "prepublishOnly": "npm run build:ts"
20
23
  },
21
24
  "devDependencies": {
@@ -23,9 +26,9 @@
23
26
  "typescript": "^5.4.0"
24
27
  },
25
28
  "optionalDependencies": {
26
- "@expo/modules-macros-linux-arm64": "0.21.0",
27
- "@expo/modules-macros-linux-x64": "0.21.0",
28
- "@expo/modules-macros-win32-arm64": "0.21.0",
29
- "@expo/modules-macros-win32-x64": "0.21.0"
29
+ "@expo/modules-macros-linux-arm64": "0.23.0",
30
+ "@expo/modules-macros-linux-x64": "0.23.0",
31
+ "@expo/modules-macros-win32-arm64": "0.23.0",
32
+ "@expo/modules-macros-win32-x64": "0.23.0"
30
33
  }
31
34
  }