packager.d.ts 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /// <reference types="node" />
  2. import { Arch, DebugLogger, TmpDir } from "builder-util";
  3. import { CancellationToken } from "builder-util-runtime";
  4. import { EventEmitter } from "events";
  5. import { Lazy } from "lazy-val";
  6. import { AppInfo } from "./appInfo";
  7. import { AfterPackContext, Configuration } from "./configuration";
  8. import { Platform, SourceRepositoryInfo, Target } from "./core";
  9. import { Framework } from "./Framework";
  10. import { Metadata } from "./options/metadata";
  11. import { ArtifactBuildStarted, ArtifactCreated, PackagerOptions } from "./packagerApi";
  12. import { PlatformPackager } from "./platformPackager";
  13. import { NodeModuleDirInfo } from "./util/packageDependencies";
  14. export declare class Packager {
  15. readonly cancellationToken: CancellationToken;
  16. readonly projectDir: string;
  17. private _appDir;
  18. get appDir(): string;
  19. private _metadata;
  20. get metadata(): Metadata;
  21. private _nodeModulesHandledExternally;
  22. get areNodeModulesHandledExternally(): boolean;
  23. private _isPrepackedAppAsar;
  24. get isPrepackedAppAsar(): boolean;
  25. private _devMetadata;
  26. get devMetadata(): Metadata | null;
  27. private _configuration;
  28. get config(): Configuration;
  29. isTwoPackageJsonProjectLayoutUsed: boolean;
  30. readonly eventEmitter: EventEmitter;
  31. _appInfo: AppInfo | null;
  32. get appInfo(): AppInfo;
  33. readonly tempDirManager: TmpDir;
  34. private _repositoryInfo;
  35. private readonly afterPackHandlers;
  36. readonly options: PackagerOptions;
  37. readonly debugLogger: DebugLogger;
  38. get repositoryInfo(): Promise<SourceRepositoryInfo | null>;
  39. private nodeDependencyInfo;
  40. getNodeDependencyInfo(platform: Platform | null): Lazy<Array<NodeModuleDirInfo>>;
  41. stageDirPathCustomizer: (target: Target, packager: PlatformPackager<any>, arch: Arch) => string;
  42. private _buildResourcesDir;
  43. get buildResourcesDir(): string;
  44. get relativeBuildResourcesDirname(): string;
  45. private _framework;
  46. get framework(): Framework;
  47. private readonly toDispose;
  48. disposeOnBuildFinish(disposer: () => Promise<void>): void;
  49. constructor(options: PackagerOptions, cancellationToken?: CancellationToken);
  50. addAfterPackHandler(handler: (context: AfterPackContext) => Promise<any> | null): void;
  51. artifactCreated(handler: (event: ArtifactCreated) => void): Packager;
  52. callArtifactBuildStarted(event: ArtifactBuildStarted, logFields?: any): Promise<void>;
  53. /**
  54. * Only for sub artifacts (update info), for main artifacts use `callArtifactBuildCompleted`.
  55. */
  56. dispatchArtifactCreated(event: ArtifactCreated): void;
  57. callArtifactBuildCompleted(event: ArtifactCreated): Promise<void>;
  58. callAppxManifestCreated(path: string): Promise<void>;
  59. callMsiProjectCreated(path: string): Promise<void>;
  60. build(): Promise<BuildResult>;
  61. _build(configuration: Configuration, metadata: Metadata, devMetadata: Metadata | null, repositoryInfo?: SourceRepositoryInfo): Promise<BuildResult>;
  62. private readProjectMetadataIfTwoPackageStructureOrPrepacked;
  63. private doBuild;
  64. private createHelper;
  65. installAppDependencies(platform: Platform, arch: Arch): Promise<any>;
  66. afterPack(context: AfterPackContext): Promise<any>;
  67. }
  68. export interface BuildResult {
  69. readonly outDir: string;
  70. readonly artifactPaths: Array<string>;
  71. readonly platformToTargets: Map<Platform, Map<string, Target>>;
  72. readonly configuration: Configuration;
  73. }