UNPKG

create-expo-module

Version:

The script to create the Expo module

117 lines (116 loc) 4.38 kB
import type { Platform } from './prompts'; import type { LocalSubstitutionData, SubstitutionData } from './types'; export declare const IGNORES_PATHS: string[]; export declare const LOCAL_EXCLUDED_FILES: Set<string>; export declare const LOCAL_EXCLUDED_DIRS: Set<string>; /** * Maps template top-level directory names to the platform name in `expo-module.config.json`. * Files under these directories are only copied when the corresponding platform is selected. */ export declare const TEMPLATE_DIR_TO_PLATFORM: Record<string, Platform>; export declare function getGeneratedWebStubSentinel(moduleName: string): string; export declare function handleSuffix(name: string, suffix: string): string; /** * Converts a slug to an Android package name. */ export declare function slugToAndroidPackage(slug: string): string; /** * Recursively scans for the files within the directory. Returned paths are relative to the `root` path. */ export declare function getFilesAsync(root: string, dir?: string | null): Promise<string[]>; /** * Resolves the template dist-tag targeted by a `create-expo-module` release from its own package * version. The CLI is published in lockstep with the SDK (e.g. `56.x.y` ships alongside SDK 56), so * its major version is the SDK major and maps to `sdk-<major>`. Falls back to `latest` for the * older, non-SDK-aligned versions. */ export declare function getTemplateDistTag(version: string | undefined): string; /** * Downloads the template from NPM registry. */ export declare function downloadPackageAsync(targetDir: string, isLocal?: boolean): Promise<string>; /** * Builds the augmented substitution data object by rendering all snippet slots. * Extracted from `createModuleFromTemplate` for reuse. */ export declare function buildAugmentedData(snippetsDir: string, data: SubstitutionData | LocalSubstitutionData): Promise<{ moduleSnippetsSwift: string; moduleSnippetsKt: string; viewSnippetsSwift: string; viewSnippetsKt: string; webEventImport: string; webEventType: string; webModuleSnippets: string; appModuleCombinedImport: string; appExternalImportSnippets: string; appReactImportSnippets: string; appHookSnippets: string; appJSXSnippets: string; usesSwiftUI: boolean; usesCompose: boolean; usesExpoUI: boolean; project: { slug: string; name: string; version: string; description: string; package: string; moduleName: string; viewName: string; swiftUIViewName: string; swiftUIModifierName: string; composeViewName: string; composeModifierName: string; sharedObjectName: string; platforms: Platform[]; features: import("./features").Feature[]; }; author: string; license: string; repo: string; type: "standalone"; } | { moduleSnippetsSwift: string; moduleSnippetsKt: string; viewSnippetsSwift: string; viewSnippetsKt: string; webEventImport: string; webEventType: string; webModuleSnippets: string; appModuleCombinedImport: string; appExternalImportSnippets: string; appReactImportSnippets: string; appHookSnippets: string; appJSXSnippets: string; usesSwiftUI: boolean; usesCompose: boolean; usesExpoUI: boolean; project: { slug: string; name: string; package: string; moduleName: string; viewName: string; swiftUIViewName: string; swiftUIModifierName: string; composeViewName: string; composeModifierName: string; sharedObjectName: string; platforms: Platform[]; features: import("./features").Feature[]; }; type: "local"; }>; /** * Copies template files to the target directory. */ export declare function copyTemplateFiles(templatePath: string, targetPath: string, augmentedData: Awaited<ReturnType<typeof buildAugmentedData>>, options: { platforms: Platform[]; platformsOnly?: boolean; moduleType: 'standalone' | 'local'; }): Promise<void>; /** * Re-renders the .web.ts stub as a full web implementation using the provided data. * Called when adding `web` to a module that already has native platforms. */ export declare function updateWebStub(templatePath: string, targetDir: string, data: SubstitutionData | LocalSubstitutionData): Promise<void>;