/** * Hand-written mirrors of the scanner's JSON output. The Swift `Codable` types in * `apple/Sources/ExpoModulesCLI` are the source of truth; these are kept in sync by hand, which * is why each command carries a `schemaVersion` the wrapper checks at runtime. */ /** The JS `typeof` category a boundary type reports, mirroring `JSType`. */ export type JSType = 'undefined' | 'object' | 'boolean' | 'number' | 'bigint' | 'string' | 'symbol' | 'function'; /** * A boundary type as a tagged tree, mirroring `TypeNode`. Discriminate on `kind`. * * `unknown` carries no `typeof`, and an `optional` reports its *wrapped* node's category, so * `(Int, String)?` (an optional around an unknown) has none either. Every other node always has one. * The absent (`undefined`) case is carried by the `optional` wrapper itself rather than by its * wrapped node. */ export type TypeNode = { kind: 'primitive'; typeof: JSType; name: string; } | { kind: 'optional'; typeof?: JSType; wrapped: TypeNode; } | { kind: 'array'; typeof: JSType; element: TypeNode; } | { kind: 'dictionary'; typeof: JSType; key: TypeNode; value: TypeNode; } | { kind: 'promise'; typeof: JSType; value: TypeNode; } | { kind: 'function'; typeof: JSType; parameters: TypeNode[]; /** Absent for a `Void` result. */ returns?: TypeNode; async: boolean; throws: boolean; } /** * Any other named type. When `refKind` is present, `name` is the declaration's qualified name, * equal to the `name` of the matching entry in the surface (`Encoding` written in `Options` reports * `Options.Encoding`). Otherwise it is the spelling as written, which may be qualified. * * `refKind` says which of this surface's arrays declares that name, so you don't have to look it * up. It is absent when the scan declares no such type: a platform convertible (`CGPoint`, `URL`) * or a type from another module, which your own catalog resolves. * * `typeof` follows the resolved kind, so a raw-value enum reports `string` or `number` rather than * `object`. Only the scanner can determine that, since it comes from the declaration's `rawType`. */ | { kind: 'ref'; typeof: JSType; name: string; refKind?: 'record' | 'sharedObject' | 'enum' | 'union'; } /** * An unlabeled Swift tuple of two or more elements, `(A, B)`. It crosses as an array with one value per * element, like a TypeScript tuple. */ | { kind: 'tuple'; typeof: JSType; elements: TypeNode[]; /** * The qualified name of the type alias the tuple was written through, such as `MyModule.Pair`. * Absent when the tuple is spelled out. */ name?: string; } /** * An object with a fixed set of properties. A labeled Swift tuple of two or more elements, * `(x: A, y: B)`, crosses as one, with one property per label. */ | { kind: 'object'; typeof: JSType; properties: { name: string; type: TypeNode; }[]; /** * The qualified name of the type alias the labeled tuple was written through, such as * `MyModule.Span`. Absent when the tuple is spelled out. */ name?: string; } /** * `SharedRef`: a shared object that JS sees as an instance of `expo.SharedRef`. `native` is the * `T` it holds on the native side. It never reaches JS, so refs in it are not resolved. */ | { kind: 'sharedRef'; typeof: JSType; native: TypeNode; } /** A type the scanner couldn't interpret; `text` is its source spelling. */ | { kind: 'unknown'; text: string; }; /** * An Apple OS the scanner attributes declarations to, spelled as `os(...)` spells it. The casing is * part of the output contract, so consumers with a lowercase convention must fold the case themselves. */ export type ScannedPlatform = 'iOS' | 'macOS' | 'tvOS' | 'watchOS' | 'visionOS'; /** One Apple OS that builds a declaration in the `scan-exports` output. */ export interface ExportedPlatform { name: ScannedPlatform; /** * The version spelled in `@available` (`17.0` in `@available(iOS 17.0, *)`), or absent when no * attribute on the declaration or its enclosing types names one. The latest version wins when * several do. */ introduced?: string; /** * How the declaration's own `@available` attributes deprecate it on this OS, or absent when they * don't. Enclosing types are not read: a member of a deprecated type is not itself reported as * deprecated. */ deprecated?: ExportedDeprecation; } /** * A deprecation from `@available`: `@available(*, deprecated, ...)` on every OS, or * `@available(iOS, deprecated: 16, obsoleted: 18, ...)` on one. Each field is absent when not * written. When a platform has its own attribute and a `*` one also applies, they combine and the * platform's fields win. */ export interface ExportedDeprecation { /** The version from `deprecated: 16`; absent for a bare `deprecated`. */ since?: string; /** * The version from `obsoleted: 18`, from which the declaration is no longer available. A * declaration that is only obsoleted is still reported as deprecated. */ obsoleted?: string; /** The `message:` text. */ message?: string; /** * The `renamed:` text: the Swift name of the replacement, as written (`newName`, * `other(value:)`). It is not resolved to a JS name. */ renamed?: string; } /** * The parts of a declaration or member that say where and to whom it is available. A declaration no * platform builds is not reported, so `platforms` is never empty. */ export interface ExportedAvailability { /** The OSes that build it: its `#if` conditions hold and no `@available` makes it unavailable. */ platforms: ExportedPlatform[]; } /** The spelled Swift access modifier of a declaration. */ export interface ExportedAccess { /** * `open`, `public`, `package`, `internal`, `fileprivate`, or `private`, or absent when none is * written. A setter-only modifier like `private(set)` is not reported. */ accessLevel?: string; } /** One parameter of a `@JS` function or `@JS init`. */ export interface ExportedParameter { /** The argument label, or `_` when unlabeled. */ label: string; /** The internal parameter name. */ name: string; type: TypeNode; /** True when the caller may omit it: a default value or an optional type. */ optional: boolean; /** The default value as Swift source text (`1`, `"x"`, `.fast`), absent when none is written. */ defaultValue?: string; } /** The symbol that a `@JS(symbol: ...)` member binds under. */ export interface ExportedSymbol { /** * `wellKnown` for a well-known symbol such as `Symbol.iterator`, from `@JS(symbol: .iterator)`; * `registered` for the symbol that the global registry holds for a key, `Symbol.for("app.id")`, from * `@JS(symbol: "app.id")`. */ kind: 'wellKnown' | 'registered'; /** The name of the well-known symbol, such as `iterator`, or the registry key. */ name: string; } /** One `@JS func` on a module or shared object. */ export interface ExportedFunction extends ExportedAccess, ExportedAvailability { /** * The Swift declaration name. A function with `.withAsync("x")` has two entries with this name. */ name: string; /** * The JS name it binds under: the `@JS("x")` override, else `name`. The second entry of a function * with `.withAsync("x")` binds under `x`. Absent for a function bound under a symbol (see `symbol`). */ jsName?: string; /** * The symbol it binds under with `@JS(symbol: ...)`, absent when it binds under `jsName`. Exactly one * of `jsName` and `symbol` is present. */ symbol?: ExportedSymbol; parameters: ExportedParameter[]; /** Absent for a `Void` return. */ returns?: TypeNode; async: boolean; throws: boolean; static: boolean; /** * The `name` of the shared object superclass that declares the member. Present only on the members * that a shared object inherits. */ inheritedFrom?: string; } /** One `@JS var` on a module or shared object. */ export interface ExportedProperty extends ExportedAccess, ExportedAvailability { name: string; /** * The JS name it binds under: the `@JS("x")` override, else `name`. Absent for a property bound * under a symbol (see `symbol`). */ jsName?: string; /** * The symbol it binds under with `@JS(symbol: ...)`, absent when it binds under `jsName`. Exactly one * of `jsName` and `symbol` is present. */ symbol?: ExportedSymbol; /** Absent when the type isn't determinable syntactically; the macro binds it getter-only. */ type?: TypeNode; readonly: boolean; static: boolean; /** The initial value of a stored property as Swift source text, absent when none is written. */ defaultValue?: string; /** * The `name` of the shared object superclass that declares the member. Present only on the members * that a shared object inherits. */ inheritedFrom?: string; } /** One `@Record` property: a data slot, not a JS accessor. */ export interface ExportedRecordProperty extends ExportedAccess, ExportedAvailability { name: string; type: TypeNode; /** Optional-typed. */ optional: boolean; /** Whether JS must supply it: neither defaulted nor optional. */ required: boolean; /** The default value as Swift source text, absent when none is written. */ defaultValue?: string; } /** An `@ExpoModule` type and its `@JS` surface. */ export interface ExportedModule extends ExportedAccess, ExportedAvailability { /** The Swift class name. A module is always declared at file scope. */ name: string; /** The JS module name: `@ExpoModule("Foo")` override, else the class name. */ jsName: string; functions: ExportedFunction[]; properties: ExportedProperty[]; events: ExportedEvent[]; /** * The classes listed in `@ExpoModule(classes: [...])`, in source order. Each is reachable from JS * as a member of the module. */ classes: ExportedClass[]; /** Absolute source path. */ file: string; } /** One entry of `@ExpoModule(classes: [...])`. */ export interface ExportedClass { /** * The `name` of the matching shared object, which is qualified when the class is nested * (`Outer.Statement`). The Swift name as spelled in the argument when the scan found no shared * object with this name. */ name: string; /** * The name of the module member JS reads the class from: the matching shared object's `jsName`. * Absent when the scan found no shared object with this name, for example a class defined outside * the scanned paths. */ jsName?: string; } /** One `@Event var`: a typed event JS listens for by name, rather than calls. */ export interface ExportedEvent extends ExportedAccess, ExportedAvailability { /** The Swift property name, e.g. `onStatusChange`. */ name: string; /** * The name JS listens under: the `@Event("x")` override, else `name` with a conventional `on` * prefix stripped and decapitalized (`onStatusChange` -> `statusChange`). */ jsName: string; /** The payload type, absent for a no-payload `() -> Void` event. */ payload?: TypeNode; /** How the event is dispatched: the default `scheduled`, or the `.inline` or `.blocking` option. */ dispatch: 'scheduled' | 'inline' | 'blocking'; /** * The `name` of the shared object superclass that declares the event. Present only on the events * that a shared object inherits. */ inheritedFrom?: string; } /** The `@JS init` of a shared object: the constructor JS calls with `new`. */ export interface ExportedInitializer extends ExportedAccess, ExportedAvailability { parameters: ExportedParameter[]; } /** A `@SharedObject` type: a JS class with an optional constructor plus its `@JS` members. */ export interface ExportedSharedObject extends ExportedAccess, ExportedAvailability { /** The Swift class name, qualified with the types it is nested in (`Outer.Player`). */ name: string; /** * The JS class name: `@SharedObject("Foo")` override, else the class name without the enclosing * types. */ jsName: string; /** * The `@JS init`, or absent when there's none. At most one constructor. Not named `constructor`, * which every JS object inherits. */ initializer?: ExportedInitializer; /** * What the class inherits from `SharedRef`, directly or through its scanned superclasses, or * absent when it doesn't inherit `SharedRef`. */ sharedRef?: ExportedSharedRef; /** * The nearest superclass with `@SharedObject`, whose JS class is the parent of this one, also when * classes without the macro are between them. Absent when no superclass has the macro, so the JS * parent is the base `SharedObject` class. */ superclass?: ExportedSuperclass; /** * The class's `@JS` members include the ones it inherits from its `@SharedObject` superclasses, the * inherited ones first, with `inheritedFrom`. An own member replaces an inherited one with the same * JS name. When the superclass depends on the platform, an inherited member has only the platforms * that inherit it. */ functions: ExportedFunction[]; properties: ExportedProperty[]; events: ExportedEvent[]; file: string; } /** The superclass of a shared object: the nearest one with `@SharedObject`. */ export interface ExportedSuperclass { /** * The `name` of the superclass, which is qualified when the class is nested (`Media.Player`). The * name as written when the scan found no class with this name, for example a class in another * package. The first entry of an inheritance clause can also be a protocol, which the scan can't * tell from a class in another package. Also the name as written when the superclass depends on the * platform: a class without the macro between them is declared in `#if` branches that lead to * different superclasses. */ name: string; /** * The `jsName` of the superclass. Absent when the scan found no class with this name, or when the * superclass depends on the platform. */ jsName?: string; } /** * The `SharedRef` superclass of a shared object. A class that inherits `SharedRef` through its * superclasses reports the `T` of the nearest one that names it, also a class without the macro. A * class that inherits it through a class the scan doesn't find has none. */ export interface ExportedSharedRef { /** The `T` in `SharedRef`: the native type the object holds, which JS never sees. */ native: TypeNode; /** * The `nativeRefType` JS reads to tell refs apart, for example `image`. `unknown` (core's default) * when the class doesn't override it, and absent when the override isn't a plain string literal. */ nativeRefType?: string; } /** A `@Record` type and its properties. */ export interface ExportedRecord extends ExportedAccess, ExportedAvailability { /** The Swift type name, qualified with the types it is nested in (`Outer.Options`). */ name: string; properties: ExportedRecordProperty[]; file: string; } /** * One case of a reported enum. * * What `rawValue` carries depends on the enum's raw type: * - `String`: always present, and decoded (`case active = "act"` reports `act`, unquoted). A case * writing none takes its own name, so nothing is left to derive. * - an integer type: present only where written, as source text (`1`, `1 << 3`), since the value may * be an expression a syntactic scan cannot evaluate. Swift also continues from the preceding case's * value (`case a = 1; case b` makes `b` 2), and that carry is yours to apply. * - no raw type: always absent, since the enum has no raw values. */ export interface ExportedEnumCase extends ExportedAvailability { /** The case name as declared. */ name: string; /** The raw value, decoded for a string and verbatim source text otherwise, or absent per the rule above. */ rawValue?: string; } /** * An `Enumerable` enum: a type crossing the boundary as its raw value rather than as an object. * Detected by conformance, not by a macro attribute, so it carries no `jsName`. */ export interface ExportedEnum extends ExportedAccess, ExportedAvailability { /** The Swift enum name, qualified with the types it is nested in (`Options.Encoding`). */ name: string; /** The raw value type as written, absent for a bare `Enumerable` conformance with no raw type. */ rawType?: TypeNode; cases: ExportedEnumCase[]; file: string; } /** * One alternative a `@Union` may hold. Not a member in the sense a module or shared object has members * (functions, properties, events). */ export interface ExportedUnionMember extends ExportedAvailability { /** The Swift case name. Swift-side only: discrimination is structural, so it never reaches JS. */ name: string; /** The associated value's type: what this alternative decodes from. */ type: TypeNode; } /** * A `@Union` enum: a typed union of its members' payload types (`A | B | C`). * * `members` is ordered, and the order is part of the contract: decode takes the first payload that * succeeds, so where two shapes overlap (`Int` and `Double`, two compatible records) the earlier one * wins. Reordering them describes a different union than the one the module runs. */ export interface ExportedUnion extends ExportedAccess, ExportedAvailability { /** The Swift enum name, qualified with the types it is nested in (`Options.Value`). */ name: string; members: ExportedUnionMember[]; file: string; } /** * One value prop of a `@ViewProps` struct: a stored property that isn't function-typed. It has no * `required`: native code resets a prop that React leaves out to its default, so JS can always omit * one. */ export interface ExportedViewProp extends ExportedAccess, ExportedAvailability { name: string; type: TypeNode; /** Optional-typed: true exactly when `type` is an `optional` node. */ optional: boolean; /** The initial value as Swift source text, absent when none is written. */ defaultValue?: string; } /** * One event of a `@ViewProps` struct: a function-typed stored property. Its name is the React prop * name as written, with no `on` prefix stripped, so it has no `jsName`. */ export interface ExportedViewEvent extends ExportedAccess, ExportedAvailability { /** The Swift property name, e.g. `onTap`. */ name: string; /** * The type of the function's single parameter, absent when it takes none (`() -> Void`) or more * than one. */ payload?: TypeNode; } /** * An `@ExpoView` class with the props and events of the `@ViewProps` struct in its generic argument. * It is reported on its own rather than under a module. */ export interface ExportedView extends ExportedAccess, ExportedAvailability { /** The Swift class name. Only a view declared at file scope is reported. */ name: string; /** The name the view registers under: the `@ExpoView("Foo")` override, else the class name. */ jsName: string; /** * The props type: the generic argument of `@ExpoView`, as written without backticks * (`ExternalProps`), or the qualified name of the scanned `@ViewProps` struct it names * (`CardView.Props`). */ propsType: string; /** * The value props of the `@ViewProps` struct, in declaration order. Absent when the scan declares * no struct named `propsType` on a platform of the view, so unknown props differ from no props. A * struct declared in several `#if` branches contributes the props of each declaration whose * platforms overlap the view's, and each prop keeps its own `platforms`. The props of the struct * that `@ViewProps(extending:)` names follow, when the scan declares it. */ props?: ExportedViewProp[]; /** * The events of the `@ViewProps` struct, in declaration order, then those of the struct that it * extends. Absent when `props` is absent. */ events?: ExportedViewEvent[]; file: string; } /** The exported types grouped by kind. */ export interface ExportedSurface { modules: ExportedModule[]; sharedObjects: ExportedSharedObject[]; records: ExportedRecord[]; enums: ExportedEnum[]; unions: ExportedUnion[]; views: ExportedView[]; } /** A `#if` condition the scan couldn't answer statically. */ export interface ScanWarning { message: string; file: string; line: number; } /** Counts describing how much work a scan did. */ export interface ScanStats { /** `.swift` files the walk found and read. */ filesScanned: number; /** * Of those, how many were parsed: the ones that matched the pre-filter (a macro attribute or a * scanned conformance), and for `scanExports`, the ones that declare a class that a shared object * inherits through. */ filesParsed: number; /** Wall-clock duration of the scan, in milliseconds. */ durationMs: number; } /** * One class in the `scan-packages` output: an `@ExpoModule` class in `modules`, a `@SharedObject` * class in `sharedObjects`, or an `@ExpoView` class in `views`. */ export interface ScannedClass { name: string; /** * The resolved JS name: the `@ExpoModule("Foo")`, `@SharedObject("Foo")` or * `@ExpoView("Foo")` override, else the class name. */ jsName: string; /** * The spelled access level, or `internal` when none is written. The generated provider references * the class from the app target, so anything below `public` can't be registered. */ accessLevel: string; /** * The OSes whose builds include this class, resolved from the enclosing `#if` conditions. An * unconditional class lists every OS. Empty means no build is known to include it, so don't * register it. */ platforms: ScannedPlatform[]; file: string; } /** The `scan-packages` result. */ export interface ScanPackagesResult { schemaVersion: number; /** The top-level `@ExpoModule` classes. */ modules: ScannedClass[]; /** The top-level `@SharedObject` classes, with the same platform rules as `modules`. */ sharedObjects: ScannedClass[]; /** The top-level `@ExpoView` classes, with the same platform rules as `modules`. */ views: ScannedClass[]; warnings: ScanWarning[]; stats: ScanStats; } /** @deprecated Renamed to `ScanPackagesResult`. */ export type ScanModulesResult = ScanPackagesResult; /** The `scan-exports` result. */ export interface ScanExportsResult { schemaVersion: number; exports: ExportedSurface; stats: ScanStats; } /** A note attached to an `ExpansionDiagnostic`, at its own location. */ export interface ExpansionNote { message: string; line: number; column: number; } /** * A syntax error in a file or a diagnostic of a macro, at its location in the original file. `line` * and `column` are 1-based, and the column counts UTF-8 bytes, as in the compiler's output. */ export interface ExpansionDiagnostic { severity: 'error' | 'warning' | 'note' | 'remark'; message: string; line: number; column: number; notes: ExpansionNote[]; /** The messages of the Fix-Its, for example `replace 'var' with 'let'`. */ fixIts: string[]; } /** Expanded source code. */ export interface Expansion { /** The symbol this expansion is for, or absent for the whole file. */ symbol?: string; source: string; } /** What the macros generate for one file, and what they report about it. */ export interface ExpandedFile { /** The path as it was passed, or the absolute path of a file found in a directory. */ file: string; /** * Without symbols, one expansion of the whole file. With symbols, one per symbol that this file * declares, in the order they were passed. Empty with `diagnosticsOnly`. */ expansions: Expansion[]; /** In source order. With symbols, only those inside the declarations of the symbols. */ diagnostics: ExpansionDiagnostic[]; } /** The `expand --json` result. */ export interface ExpandResult { schemaVersion: number; /** One entry per expanded file: the files in the order they were passed, a directory's files sorted. */ files: ExpandedFile[]; } /** * The output schema versions this package was written against. The wrapper compares these to the * `schemaVersion` in each report and throws on a mismatch, so a binary/wrapper version skew surfaces * as a clear error instead of silently misread fields. */ export declare const SUPPORTED_SCAN_PACKAGES_SCHEMA_VERSION = 2; export declare const SUPPORTED_SCAN_EXPORTS_SCHEMA_VERSION = 12; export declare const SUPPORTED_EXPAND_SCHEMA_VERSION = 1; /** @deprecated Renamed to `SUPPORTED_SCAN_PACKAGES_SCHEMA_VERSION`. */ export declare const SUPPORTED_SCAN_MODULES_SCHEMA_VERSION = 2;