/// /// import * as vite from 'vite'; import { HmrOptions, ViteDevServer, Plugin, Logger } from 'vite'; import * as rollup from 'rollup'; import Resumable, { File } from 'resumable'; interface ZaUITemplate { isBlank?: false; id: string; name: string; description: string; features: string[]; translations?: Translations; logo: string; banner: string; entrypoint: string; github: Github; categories: string[]; } interface Github { owner: string; repository: string; branch: string; } interface Translations { en?: Translation; } interface Translation { name?: string; description?: string; features?: string[]; } interface BlankTemplate { isBlank: true; id: string; name: string; github: Github; } type Template = ZaUITemplate | BlankTemplate; declare const COMMON_CONFIG: { TUNNEL_SERVER_HOST: string; DEVICE_MODE: { REQUIRED_SDK_VERSION: string; REQUIRED_ZAUI_VERSION: string; }; DEFAULT_APP_LOGO: string; ZAUI_TEMPLATES_JSON: string; ZDN_PREFIX: string; DEVELOPER_API_PREFIX: string; FILE_NAMES: { ZALO_MINI_APP_CONFIG: string; PACKAGE_JSON: string; DEFAULT_OUTPUT_DIR: string; }; LINKS: { VITE_2_TO_VITE_5_GUIDE: string; }; QUOTAS: { DEVELOPMENT: number; TESTING: number; }; SIZE_LIMIT_MB: { FILE: number; ZIP: number; }; }; declare const BLANK_TEMPLATES: BlankTemplate[]; interface InitProjectInput { cwd: string; template: { owner: string; repository: string; branch: string; }; folderName: string; projectName?: string; } declare function initProject({ cwd, template: { owner, branch, repository }, folderName, projectName, }: InitProjectInput): Promise; interface StartDeviceInput { appId: string; cwd: string; chiiUrl: string; subdomain?: string; localHost?: string; mode?: string; } declare function startDevice({ cwd, appId, chiiUrl, subdomain, localHost, mode }: StartDeviceInput): Promise<{ vite: typeof vite; server: vite.ViteDevServer; app: vite.ViteDevServer; }>; type HexColor = "" | `#${string}`; type TextColor = "white" | "black"; type TextAlign = "left" | "center"; type LeftButton = "none" | "back" | "home" | "both"; type StatusBar = "normal" | "hidden" | "transparent"; interface AppConfigApp { title: string; orientation?: string; headerTitle?: string; headerColor: HexColor | { light: HexColor; dark: HexColor; }; textColor: TextColor | { light: TextColor; dark: TextColor; }; textAlign: TextAlign; statusBarColor: HexColor | { light: HexColor; dark: HexColor; }; leftButton: LeftButton; statusBar?: StatusBar; actionBarHidden?: boolean; hideAndroidBottomNavigationBar?: boolean; hideIOSSafeAreaBottom?: boolean; selfControlLoading?: boolean; } interface AppConfig { app: AppConfigApp; debug: boolean; listCSS: any[]; listSyncJS: any[]; listAsyncJS: any[]; pages?: string[]; template?: Record; } interface StartConfigurations { launcher: "device" | "simulator" | "chrome" | "msedge" | "browser" | "none"; https: boolean; hostname: string; port: number; path: string; userAgent?: string; lan?: boolean; os?: "android" | "ios"; } interface StartLocalInput { chiiPort?: number; cwd: string; config: StartConfigurations; appConfig: AppConfig; hmr?: HmrOptions; mode?: string; } declare function startLocal({ cwd, config, chiiPort, appConfig, hmr, mode }: StartLocalInput): Promise<{ vite: typeof vite; server: vite.ViteDevServer; app: vite.ViteDevServer; }>; declare function stopServer(app: ViteDevServer): Promise; interface AppInfo { description: string; canBrowse: boolean; isActive: boolean; currentVersion: string; versionStatus: string; logoUrl: string; coverUrl: string; zaloAppId: string; latestVersion: number; qrCodeUrl: string; name: string; category: string; config: string; status: string; enableSettingPayment: boolean; deepLink: string; } interface PublicAppInfo { qrCodeUrl: string; name: string; description: string; appUrl: string; appStatus: "ENABLE" | "INVALID"; version: string; logoUrl?: string; } interface AppVersion { lastUpdated: number; id: number; versionId: number; size: number; description: string; entrypoint: string; status: "PRODUCTION" | "TESTING" | "READY_TO_PRODUCTION" | "WAITING_APPROVAL" | "REJECTED"; } interface DeployResult { appUrl: string; config: string; description: string; lastUpdated: 1712926472103; name: string; size: number; status: "DEVELOPMENT" | "TESTING"; versionId: string; } declare const enum DeployType { DEVELOPMENT = 0, TESTING = 2 } interface UploadConstraints { requiredBuildFiles: { requiredFiles: string[]; allowedFiles: string[]; }; currentUploadCount: { dev: number; test: number; }; } interface BuildAppInput { cwd: string; mode?: string; target?: DeployType; appId: string; nextVersion?: string | number; currentVersion?: number; appConfig: AppConfig; outDir: string; vite2RollupPlugins?: Plugin[]; customLogger?: Partial; } declare function buildApp({ cwd, mode, appId, nextVersion, currentVersion, appConfig, outDir, vite2RollupPlugins, customLogger, target, }: BuildAppInput): Promise<{ result: rollup.RollupOutput; appConfigJson: { listCSS: any[]; listSyncJS: any[]; listAsyncJS: any[]; app: AppConfigApp; debug: boolean; pages?: string[] | undefined; template?: Record | undefined; }; } | { result: rollup.RollupOutput | rollup.RollupOutput[] | rollup.RollupWatcher; appConfigJson?: undefined; } | undefined>; interface Result { msg: string; err: number; data: T; } type CoreRequester = (options: { method: "GET" | "POST" | "PUT" | "DELETE"; url: string; data?: unknown; }) => Promise; type HttpOperation = T & { request: CoreRequester; }; interface UploadAppInput { ResumableClass: typeof Resumable; FileClass: typeof File; uploadFolder: string; identifier: string; getToken: () => Promise; onProgress: ( /** * 0-100 */ progress: number) => void; } declare function uploadApp({ ResumableClass, FileClass, uploadFolder: outputDir, identifier, getToken, onProgress, }: UploadAppInput): Promise>; interface DeployZMPInput { isCustom: false; } interface DeployCustomProjectInput { isCustom: true; outputDir?: string; } type DeployInput = (DeployZMPInput | DeployCustomProjectInput) & { cwd: string; target: DeployType; description?: string; customLogger?: Partial; } & Pick; /** * Common deploy logic for all DevTools (CLI & Extension) to reuse. The purpose of this common logic is for further modifications to be made in 1 place. * IMPORTANT: Make sure the outputDir exists. So if it is a normal ZMP project (not a custom project), this function MUST only be called after a successful build. */ declare function deploy(options: HttpOperation): Promise>; interface RequestUploadPayload { name: string; desc: string; config: string; versionStatus: DeployType; frameworkVersions: string; } interface RequestUploadResponse { nextVersion: number; identifier: string; uploadConstraints: UploadConstraints; } /** * Before uploading an app, you need to request an upload. * This will return an identifier and the next version number. DevTools can use the next version number to config paths for resources. * @param {HttpOperation} payload The payload for the request upload operation. Requester MUST be authenticated, so the request should include a valid `Authorization: Bearer ` header with a valid token. * @returns {Promise} The response containing the next version number and identifier. */ declare function requestUpload({ request, ...data }: HttpOperation): Promise; type TranslationKey = "msg.please-install-vite" | "msg.folder-existed" | "msg.please-check-app-config" | "msg.please-check-package-json" | "msg.no-asset-defined" | "msg.missing-required-file" | "msg.vite-2-requires-next-version" | "msg.file-size-limit" | "msg.zip-size-limit"; declare class TranslatableError extends Error { message: TranslationKey; i18nData: any; constructor(message: TranslationKey, i18nData?: any); } /** * Get the app information. * @param {HttpOperation} request This API does not require any payload, as the Mini App ID will be derived from the authenticated headers. The requester must include a valid `Authorization: Bearer ` header with a valid token. * @returns {Promise} The app information, including the Mini App ID, name, description, and version status,... */ declare function getAppInfo({ request }: HttpOperation): Promise; /** * Load ZaUI templates from the official website. * @param {HttpOperation} request - The network requester. This requester does NOT need to be authenticated, so NO special headers are required. * @returns {Promise} The list of templates. */ declare function getTemplates({ request }: HttpOperation): Promise; interface GetVersionsPayload { start: number; count: number; } interface GetVersionsResponse { listVersions: AppVersion[]; total: number; } /** * Get the app versions. * @param {HttpOperation} request This API does not require any payload, as the Mini App ID will be derived from the authenticated headers. The requester must include a valid `Authorization: Bearer ` header with a valid token. * @param {GetVersionsPayload} data The payload for the request, which includes the start index and count of versions to retrieve. * @returns {Promise} The app versions, including a list of versions and the total count. */ declare function getVersions({ request, ...data }: HttpOperation): Promise; export { type AppInfo, type AppVersion, BLANK_TEMPLATES, type BuildAppInput, COMMON_CONFIG, type CoreRequester, type DeployCustomProjectInput, type DeployInput, type DeployResult, DeployType, type DeployZMPInput, type GetVersionsPayload, type GetVersionsResponse, type HttpOperation, type InitProjectInput, type PublicAppInfo, type RequestUploadPayload, type RequestUploadResponse, type Result, type StartDeviceInput, type StartLocalInput, type Template, TranslatableError, type TranslationKey, type UploadAppInput, type UploadConstraints, buildApp, deploy, getAppInfo, getTemplates, getVersions, initProject, requestUpload, startDevice, startLocal, stopServer, uploadApp };