tt-minigame-ide-cli 1.0.2 → 2.0.0-alpha.1

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 (67) hide show
  1. package/README.md +5 -98
  2. package/bin/tmg.js +4 -161
  3. package/dist/cli.js +1 -0
  4. package/dist/index.js +1 -0
  5. package/dist/miniprogram-utils/src/constants/error.d.ts +41 -0
  6. package/dist/miniprogram-utils/src/constants/index.d.ts +217 -0
  7. package/dist/miniprogram-utils/src/constants/project.d.ts +3 -0
  8. package/dist/miniprogram-utils/src/constants/slardar-events/update-events.d.ts +24 -0
  9. package/dist/miniprogram-utils/src/data/app.d.ts +30 -0
  10. package/dist/miniprogram-utils/src/data/ext.d.ts +6 -0
  11. package/dist/miniprogram-utils/src/data/jsons.d.ts +23 -0
  12. package/dist/miniprogram-utils/src/data/project.d.ts +124 -0
  13. package/dist/miniprogram-utils/src/electron-monitor/common/tea-sdk.d.ts +17 -0
  14. package/dist/miniprogram-utils/src/formation.d.ts +17 -0
  15. package/dist/miniprogram-utils/src/network/axios.d.ts +28 -0
  16. package/dist/tt-ide-cli/src/features/audit.d.ts +9 -0
  17. package/dist/tt-ide-cli/src/features/cli-login.d.ts +1 -0
  18. package/dist/tt-ide-cli/src/features/config.d.ts +3 -0
  19. package/dist/tt-ide-cli/src/features/create.d.ts +7 -0
  20. package/dist/tt-ide-cli/src/features/login.d.ts +18 -0
  21. package/dist/tt-ide-cli/src/features/meta.d.ts +23 -0
  22. package/dist/tt-ide-cli/src/features/microgame/cloud-compile.d.ts +75 -0
  23. package/dist/tt-ide-cli/src/features/microgame/index.d.ts +3 -0
  24. package/dist/tt-ide-cli/src/features/microgame/meta.d.ts +1 -0
  25. package/dist/tt-ide-cli/src/features/microgame/utils/file-system.d.ts +13 -0
  26. package/dist/tt-ide-cli/src/features/microgame/utils/package.d.ts +22 -0
  27. package/dist/tt-ide-cli/src/features/microgame/utils/settings.d.ts +48 -0
  28. package/dist/tt-ide-cli/src/features/microgame/utils/source.type.d.ts +35 -0
  29. package/dist/tt-ide-cli/src/features/npm.d.ts +10 -0
  30. package/dist/tt-ide-cli/src/features/open.d.ts +3 -0
  31. package/dist/tt-ide-cli/src/features/packages.d.ts +53 -0
  32. package/dist/tt-ide-cli/src/features/preview.d.ts +80 -0
  33. package/dist/tt-ide-cli/src/features/third-party.d.ts +9 -0
  34. package/dist/tt-ide-cli/src/index.d.ts +22 -0
  35. package/dist/tt-ide-cli/src/monitor/cli-monitor.d.ts +15 -0
  36. package/dist/tt-ide-cli/src/monitor/constants.d.ts +7 -0
  37. package/dist/tt-ide-cli/src/monitor/index.d.ts +2 -0
  38. package/dist/tt-ide-cli/src/types.d.ts +44 -0
  39. package/dist/tt-ide-cli/src/utils/constants.d.ts +3 -0
  40. package/dist/tt-ide-cli/src/utils/cookie.d.ts +6 -0
  41. package/dist/tt-ide-cli/src/utils/logger.d.ts +19 -0
  42. package/dist/tt-ide-cli/src/utils/metrics.d.ts +67 -0
  43. package/dist/tt-ide-cli/src/utils/qrcode.d.ts +64 -0
  44. package/dist/tt-ide-cli/src/utils/util.d.ts +56 -0
  45. package/dist/tt-minigame-ide-cli/src/cli.d.ts +1 -0
  46. package/dist/tt-minigame-ide-cli/src/index.d.ts +1 -0
  47. package/dist/tt-minigame-ide-cli/src/types.d.ts +43 -0
  48. package/package.json +49 -26
  49. package/.yarnrc +0 -1
  50. package/LICENSE +0 -21
  51. package/README.en.md +0 -104
  52. package/lib/auth.js +0 -145
  53. package/lib/build-npm.js +0 -22
  54. package/lib/create.js +0 -106
  55. package/lib/index.d.ts +0 -23
  56. package/lib/index.js +0 -79
  57. package/lib/preview.js +0 -92
  58. package/lib/upload.js +0 -133
  59. package/lib/util/check.js +0 -84
  60. package/lib/util/config.js +0 -41
  61. package/lib/util/cookie.js +0 -36
  62. package/lib/util/helper.js +0 -245
  63. package/lib/util/logger.js +0 -54
  64. package/lib/util/qrcode.js +0 -34
  65. package/lib/util/request.js +0 -396
  66. package/lib/util/version.js +0 -27
  67. package/lib/version.js +0 -44
@@ -0,0 +1,75 @@
1
+ import { ServerSize } from '@byted/miniprogram-utils/typings/project';
2
+ import { ProjectInfo, QrcodeInfo } from '../../types';
3
+ import { IMetrics } from '../../utils/metrics';
4
+ import { IDEConfig, MakeSchemaOption } from '../../utils/qrcode';
5
+ export declare type ProjectQRCode = {
6
+ expireTime: number;
7
+ shortUrl: string;
8
+ originSchema: string;
9
+ qrcodeSVG?: string;
10
+ qrcodeFilePath?: string;
11
+ useCache: boolean;
12
+ } & Pick<CompileProgressResult, 'metrics' | 'passJson'>;
13
+ declare type CompileProgressResult = {
14
+ success: boolean;
15
+ /** error code */
16
+ error: number;
17
+ done: boolean;
18
+ msg: string;
19
+ metrics?: IMetrics;
20
+ errLink?: string;
21
+ passJson: {
22
+ packageSize?: ServerSize;
23
+ } & Record<string, any>;
24
+ };
25
+ export declare type PreviewOption = Pick<ProjectToQRCodeOption, 'project' | 'page' | 'qrcode' | 'cache' | 'copyToClipboard' | 'extraInfoJson' | 'localCompileVersion' | 'ideConfig'>;
26
+ /**
27
+ * 预览上传(功能入口)
28
+ * @param options
29
+ * @returns
30
+ */
31
+ export declare function preview(options: PreviewOption): Promise<ProjectQRCode>;
32
+ export declare type UploadOption = Pick<ProjectToQRCodeOption, 'project' | 'qrcode' | 'copyToClipboard' | 'extraInfoJson' | 'localCompileVersion' | 'ideConfig'> & {
33
+ version: string;
34
+ changeLog: string;
35
+ needUploadSourcemap?: boolean;
36
+ };
37
+ /**
38
+ * 发布上传(功能入口)
39
+ * @param options
40
+ * @returns
41
+ */
42
+ export declare function upload(options: UploadOption): Promise<ProjectQRCode>;
43
+ export declare type ProjectToQRCodeOption = {
44
+ project: ProjectInfo;
45
+ page: {
46
+ path: string;
47
+ query: string;
48
+ scene: string;
49
+ launchFrom: string;
50
+ location: string;
51
+ } & Pick<MakeSchemaOption, 'referrerInfo'>;
52
+ qrcode: QrcodeInfo;
53
+ cache: boolean;
54
+ copyToClipboard: boolean;
55
+ uploadOptions?: {
56
+ version: string;
57
+ changeLog: string;
58
+ needUploadSourcemap: boolean;
59
+ };
60
+ extraInfoJson?: string;
61
+ localCompileVersion?: string;
62
+ ideConfig?: IDEConfig;
63
+ debug?: {
64
+ query: {
65
+ gtoken: string;
66
+ roomid: string;
67
+ session: string;
68
+ };
69
+ };
70
+ uploadCache?: boolean;
71
+ supportSourcemap?: boolean;
72
+ enableHotRestartCache?: boolean;
73
+ };
74
+ export declare function projectToQRCode(options: ProjectToQRCodeOption): Promise<ProjectQRCode>;
75
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './cloud-compile';
2
+ export * from './utils/package';
3
+ export * from './meta';
@@ -0,0 +1 @@
1
+ export declare const getMeta: (appId: string) => Promise<any>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 文件系统相关
3
+ */
4
+ /** MB 转 Byte 数,即 mb * 1024 * 1024 */
5
+ export declare const mb2Byte: (mb: number) => number;
6
+ /** Byte size 转 MB,即 byte / 1024 / 1024,默认保留 4 位小数 */
7
+ export declare const byte2Mb: (byte: number, fixed?: number) => number;
8
+ /** 获取文件字节数体积,实际上文件夹也支持,获取的是文件夹本身占用的系统体积(测试为 128Byte) */
9
+ export declare const getFileByteSize: (path: string) => number;
10
+ /** 获取指定目录下所有文件体积和,支持 glob pattern ignore */
11
+ export declare const getDirByteSize: (path: string, ignore?: any[]) => Promise<number>;
12
+ /** 获取指定路径(兼容文件 / 整个目录)大小 Byte 数 */
13
+ export declare const getPathByteSize: (path: string, ignore?: any[]) => number | Promise<number>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 小游戏源码、打包相关
3
+ */
4
+ /** 不参与体积计算的 glob pattern */
5
+ export declare const PKG_SIZE_IGNORE_GLOBS: string[];
6
+ /** 计算包哈希时不参与计算的文件匹配规则 */
7
+ export declare const PKG_HASH_IGNORE_LIST: string[];
8
+ /**
9
+ * 校验包体大小,支持白名单逻辑,具体限制以 Settings 下发为准
10
+ * 默认:普通包最大 8MB,开放数据域 & 分包主包最大 4MB,子包不限制,总包 20MB
11
+ * 体积计算:忽略 dot 文件、node_modules、map 文件等,加上目录体积参与计算,计算结果一般和系统显示的不同
12
+ * 保持逻辑严谨,尽量给到用户足够详细、有信息量的检查结果提示
13
+ * @param root 小游戏路径
14
+ * @returns 错误信息,空串表示校验通过
15
+ */
16
+ export declare const verifyPkgSize: (root: string) => Promise<string>;
17
+ export declare const getDirHash: (dirPath: string) => Promise<string>;
18
+ export declare function compressZip(filePath: string, tempStoragePath: string, extraIgnore?: string[]): Promise<string>;
19
+ export declare const checkUCAppId: (appId: string) => boolean;
20
+ export declare const checkAppId: (appId: string) => boolean;
21
+ export declare const getAppId: (projectPath: string) => Promise<string>;
22
+ export declare const validateAppId: (appId: string) => Promise<void>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * AppSettings 相关逻辑封装
3
+ * https://site.bytedance.net/docs/428/3356/request_params/
4
+ */
5
+ import { SizeLimitConfig, TmgSdkInfo } from './source.type';
6
+ /**
7
+ * 网络请求相关相关的 typings 声明
8
+ */
9
+ declare type BaseResponse<T = any> = {
10
+ data: T;
11
+ message: string;
12
+ };
13
+ declare type Dict<T = any> = {
14
+ [key: string]: T;
15
+ };
16
+ export declare type SettingsResponse = BaseResponse<{
17
+ settings: {
18
+ compile_config?: {
19
+ limit: SizeLimitConfig;
20
+ };
21
+ tt_tma_sdk_config?: TmgSdkInfo[];
22
+ };
23
+ settings_time: number;
24
+ }>;
25
+ export declare const SETTINGS_URL = "https://is.snssdk.com/service/settings/v3/";
26
+ export declare const genDefault: (params: Dict) => {
27
+ caller_name: string;
28
+ channel: string;
29
+ device_platform: string;
30
+ device_id: any;
31
+ device_id_str: any;
32
+ version_code: any;
33
+ user_id: any;
34
+ };
35
+ /**
36
+ * 获取小游戏 IDE AppSettings 配置
37
+ * https://cloud.bytedance.net/appSettings-v2/detail/product/608/config/list
38
+ */
39
+ export declare const getIdeSettings: (params?: Dict) => Promise<{
40
+ settings: {
41
+ compile_config?: {
42
+ limit: SizeLimitConfig;
43
+ };
44
+ tt_tma_sdk_config?: TmgSdkInfo[];
45
+ };
46
+ settings_time: number;
47
+ }>;
48
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 跟小游戏源码包相关的 typings 声明
3
+ */
4
+ export declare type ProjectConfigInfo = {
5
+ /** 小游戏 AppId */
6
+ appid: string;
7
+ };
8
+ export declare type SubPackageInfo = {
9
+ root: string;
10
+ name: string;
11
+ };
12
+ export declare type GameInfo = {
13
+ /** 分包子包配置(兼容 subpackages) */
14
+ subPackages?: SubPackageInfo[];
15
+ /** 分包子包配置(兼容 subPackages) */
16
+ subpackages?: SubPackageInfo[];
17
+ /** 开放数据域配置 */
18
+ openDataContext?: string;
19
+ };
20
+ export declare type SizeLimitConfig = {
21
+ /** 普通非分包整包最大 MB 数 */
22
+ normalTotal: number;
23
+ /** 分包主包最大 MB 数 */
24
+ subMain: number;
25
+ /** 分包子包最大 MB 数 */
26
+ subPkg: number;
27
+ /** 分包整包最大 MB 数 */
28
+ subTotal: number;
29
+ /** 开放数据域包最大 MB 数 */
30
+ openData: number;
31
+ };
32
+ export declare type TmgSdkInfo = {
33
+ latestSDKUrl: string;
34
+ sdkUpdateVersion: string;
35
+ };
@@ -0,0 +1,10 @@
1
+ export declare type BuildNpmResult = {
2
+ success: false;
3
+ reason: string;
4
+ } | {
5
+ success: true;
6
+ reason: Record<string, any>;
7
+ };
8
+ export declare function buildNpm(options: {
9
+ projectPath: string;
10
+ }): Promise<BuildNpmResult>;
@@ -0,0 +1,3 @@
1
+ export default function openProject(options: {
2
+ projectPath: string;
3
+ }, remotePort?: number): Promise<void>;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Utils for microapp packages
3
+ */
4
+ import type { ProjectConfig } from '@byted/miniprogram-utils/dist/data/project';
5
+ import { ProjectSize } from '@byted/miniprogram-utils/typings/project';
6
+ import archiver from 'archiver';
7
+ import fg from 'fast-glob';
8
+ /**
9
+ * 计算给定文件夹下面的文件体积总值
10
+ * @param folderPath directory path
11
+ * @param useTypeScript typescript
12
+ * @param options pass to fast-glob
13
+ * @returns
14
+ */
15
+ export declare function getFolderSize(folderPath: string, useTypeScript: boolean, options?: fg.Options): Promise<number>;
16
+ /**
17
+ * 以文件夹为单位的包体积统计,不适用于依赖分析
18
+ *
19
+ * @param projectConfig
20
+ * @param appJson
21
+ * @param projectPath
22
+ * @param isGame
23
+ */
24
+ export declare function getProjectSize(projectConfig: ProjectConfig, appJson: any, projectPath: string, isGame: boolean): Promise<ProjectSize>;
25
+ /**
26
+ * 校验当前项目的分包体积是否符合要求
27
+ * 若有错误,会抛出 promise 异常
28
+ *
29
+ * @param projectConfig
30
+ */
31
+ export declare function verifySubPackageSize(projectConfig: ProjectConfig, type: 'preview' | 'upload'): Promise<void>;
32
+ declare type FolderToZipStreamOption = {
33
+ whiteList: string[];
34
+ useTypeScript: boolean;
35
+ };
36
+ /**
37
+ * Convert a folder to zipStream. A new stream is created at each invocation.
38
+ *
39
+ * @param dir path to folder
40
+ */
41
+ export declare function folderToZipStream(dir: string, { whiteList, useTypeScript }: FolderToZipStreamOption): Promise<archiver.Archiver>;
42
+ /**
43
+ *
44
+ * @param dir path to microapp project
45
+ * @returns
46
+ */
47
+ export declare function getProjectHash(dir: string): Promise<string>;
48
+ /**
49
+ * For cli only
50
+ * @param input
51
+ */
52
+ export declare function prettyProjectSize(input: ProjectSize): string;
53
+ export {};
@@ -0,0 +1,80 @@
1
+ import { ProjectConfig } from '@byted/miniprogram-utils/dist/data/project';
2
+ import { ServerSize } from '@byted/miniprogram-utils/typings/project';
3
+ import { ProjectInfo, QrcodeInfo } from '../types';
4
+ import { IMetrics } from '../utils/metrics';
5
+ import { IDEConfig, MakeSchemaOption } from '../utils/qrcode';
6
+ export declare type ProjectQRCode = {
7
+ expireTime: number;
8
+ shortUrl: string;
9
+ originSchema: string;
10
+ qrcodeSVG?: string;
11
+ qrcodeFilePath?: string;
12
+ useCache: boolean;
13
+ } & Pick<CompileProgressResult, 'metrics' | 'passJson'>;
14
+ declare type CompileProgressResult = {
15
+ success: boolean;
16
+ /** error code */
17
+ error: number;
18
+ done: boolean;
19
+ msg: string;
20
+ metrics?: IMetrics;
21
+ errLink?: string;
22
+ passJson: {
23
+ packageSize?: ServerSize;
24
+ } & Record<string, any>;
25
+ };
26
+ export declare function checkProjectMatchAppid(projectConfig: ProjectConfig, appid?: string): Promise<void>;
27
+ declare type PreviewOption = Pick<ProjectToQRCodeOption, 'project' | 'page' | 'qrcode' | 'cache' | 'copyToClipboard' | 'extraInfoJson' | 'localCompileVersion' | 'ideConfig' | 'interactGame'>;
28
+ /**
29
+ * 预览上传(功能入口)
30
+ * @param options
31
+ * @returns
32
+ */
33
+ export declare function preview(options: PreviewOption): Promise<ProjectQRCode>;
34
+ declare type UploadOption = Pick<ProjectToQRCodeOption, 'project' | 'qrcode' | 'copyToClipboard' | 'extraInfoJson' | 'localCompileVersion' | 'ideConfig' | 'interactGame'> & {
35
+ version: string;
36
+ changeLog: string;
37
+ needUploadSourcemap?: boolean;
38
+ };
39
+ /**
40
+ * 发布上传(功能入口)
41
+ * @param options
42
+ * @returns
43
+ */
44
+ export declare function upload(options: UploadOption): Promise<ProjectQRCode>;
45
+ export declare type ProjectToQRCodeOption = {
46
+ project: ProjectInfo;
47
+ page: {
48
+ path: string;
49
+ query: string;
50
+ scene: string;
51
+ launchFrom: string;
52
+ location: string;
53
+ } & Pick<MakeSchemaOption, 'referrerInfo'>;
54
+ qrcode: QrcodeInfo;
55
+ cache: boolean;
56
+ copyToClipboard: boolean;
57
+ uploadOptions?: {
58
+ version: string;
59
+ changeLog: string;
60
+ needUploadSourcemap: boolean;
61
+ };
62
+ extraInfoJson?: string;
63
+ localCompileVersion?: string;
64
+ ideConfig?: IDEConfig;
65
+ debug?: {
66
+ query: {
67
+ gtoken: string;
68
+ roomid: string;
69
+ session: string;
70
+ };
71
+ };
72
+ uploadCache?: boolean;
73
+ interactGame?: {
74
+ extra: string;
75
+ };
76
+ supportSourcemap?: boolean;
77
+ enableHotRestartCache?: boolean;
78
+ };
79
+ export declare function projectToQRCode(options: ProjectToQRCodeOption): Promise<ProjectQRCode>;
80
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare enum INVALID_EXTAPP_REASON {
2
+ INVALID_APPID_META = 0,
3
+ INVALID_EXTAPPID = 1,
4
+ EXT_DISABLED = 2,
5
+ INVALID_EXT_JSON = 3,
6
+ INVALID_AUTH = 4,
7
+ NULL = 5
8
+ }
9
+ export declare const detectValidExtApp: any;
@@ -0,0 +1,22 @@
1
+ import { audit, getAuditHostsList } from './features/audit';
2
+ import { getConfig, setConfig } from './features/config';
3
+ import { createProject } from './features/create';
4
+ import { checkSession, loginByEmail, loginByPhone, logout, sendVerificationCodeToPhone } from './features/login';
5
+ import { getProjectSize, verifySubPackageSize } from './features/packages';
6
+ import { checkProjectMatchAppid, ProjectToQRCodeOption, preview, ProjectQRCode, projectToQRCode, upload } from './features/preview';
7
+ import { detectValidExtApp, INVALID_EXTAPP_REASON } from './features/third-party';
8
+ import { ProjectInfo } from './types';
9
+ import { setCookieFn } from './utils/cookie';
10
+ import { IDEConfig, IDESandboxConfig, makeSchema, MakeSchemaOption, MakeSchemaResult } from './utils/qrcode';
11
+ declare function open(options: {
12
+ project: ProjectInfo;
13
+ remotePort?: number;
14
+ }): Promise<void>;
15
+ declare function buildNpmFunc(options: {
16
+ project: ProjectInfo;
17
+ }): Promise<import("./features/npm").BuildNpmResult>;
18
+ export { ProjectQRCode, ProjectToQRCodeOption };
19
+ export { open, setConfig, createProject as create, loginByEmail, loginByPhone, logout, sendVerificationCodeToPhone, checkSession, audit, getAuditHostsList, buildNpmFunc as buildNpm, preview, upload, projectToQRCode, setCookieFn, getConfig, detectValidExtApp, getProjectSize, verifySubPackageSize, checkProjectMatchAppid, INVALID_EXTAPP_REASON, IDEConfig, makeSchema, MakeSchemaOption, MakeSchemaResult, IDESandboxConfig, };
20
+ export * from './features/meta';
21
+ export * from './utils/metrics';
22
+ export * as microgame from './features/microgame';
@@ -0,0 +1,15 @@
1
+ interface CLIMonitorConfigOptions {
2
+ cliVersion: string;
3
+ cliName: string;
4
+ }
5
+ export declare class CliMonitor {
6
+ private static _instance;
7
+ private _didReportLaunch;
8
+ private readonly _commonParams;
9
+ private constructor();
10
+ static getInstance(config: CLIMonitorConfigOptions): CliMonitor;
11
+ shouldReport(eventName: string): boolean;
12
+ report(eventName: string, params?: Record<string, string | number | boolean>): void;
13
+ reportCommandCall(commandName: string): void;
14
+ }
15
+ export {};
@@ -0,0 +1,7 @@
1
+ export declare const CLI_EVENTS: {
2
+ IDE_CLI_LAUNCH: string;
3
+ IDE_CLI_COMMAND_CALL: string;
4
+ IDE_CLI_PREVIEW_FAIL: string;
5
+ IDE_CLI_UPLOAD_FAIL: string;
6
+ IDE_CLI_ERROR: string;
7
+ };
@@ -0,0 +1,2 @@
1
+ export { CliMonitor } from './cli-monitor';
2
+ export { CLI_EVENTS } from './constants';
@@ -0,0 +1,44 @@
1
+ export interface ProjectInfo {
2
+ path: string;
3
+ }
4
+ export interface TMACliConfig {
5
+ proxy: string | null;
6
+ tempFilePath: string | null;
7
+ storagePath: string;
8
+ url: {
9
+ makeSchema: string;
10
+ compileProgress: string;
11
+ preview: string;
12
+ upload: string;
13
+ emailLogin: string;
14
+ mobileLogin: string;
15
+ sendLoginCode: string;
16
+ getUserInfo: string;
17
+ };
18
+ interactGameUrl: {
19
+ makeSchema: string;
20
+ compileProgress: string;
21
+ preview: string;
22
+ upload: string;
23
+ };
24
+ microgameUrl: {
25
+ makeSchema: string;
26
+ compileProgress: string;
27
+ preview: string;
28
+ upload: string;
29
+ versionInfo: string;
30
+ };
31
+ env: {
32
+ type: 'online' | 'ppe' | 'boe';
33
+ channel: string;
34
+ };
35
+ allowReportEvent: boolean;
36
+ }
37
+ export interface QrcodeInfo {
38
+ format: 'imageFile' | 'terminal' | 'imageSVG' | 'plain' | null;
39
+ output?: string;
40
+ options?: {
41
+ small?: boolean;
42
+ };
43
+ }
44
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare const IDE_SCHEMA = "bytedanceide:";
2
+ export declare const TEMPLATE_DOWNLOAD_URL = "https://sf1-cdn-tos.douyinstatic.com/obj/microapp/frontend/ide/template/tma-demo-master.zip";
3
+ export declare const TS_TEMPLATE_DOWNLOAD_URL = "https://sf1-cdn-tos.douyinstatic.com/obj/microapp/frontend/ide/template/tma-demo-master-ts.zip";
@@ -0,0 +1,6 @@
1
+ declare type GetCookieFunction = () => Promise<string>;
2
+ export declare let getUserCookies: GetCookieFunction;
3
+ export declare function saveUserCookies(cookies: string[]): void;
4
+ export declare function removeUserCookies(): void;
5
+ export declare function setCookieFn(fn: GetCookieFunction): void;
6
+ export {};
@@ -0,0 +1,19 @@
1
+ import ora from 'ora';
2
+ declare abstract class BaseLogger {
3
+ info(...args: any[]): void;
4
+ warn(...args: any[]): void;
5
+ error(...args: any[]): void;
6
+ loading(text: string): Pick<ora.Ora, 'text' | 'color' | 'stop'>;
7
+ stopLoading(): void;
8
+ }
9
+ declare class Logger extends BaseLogger {
10
+ }
11
+ declare class CliLogger extends BaseLogger {
12
+ info(...args: any[]): void;
13
+ warn(...args: any[]): void;
14
+ error(...args: any[]): void;
15
+ loading(text: string): ora.Ora;
16
+ stopLoading(): void;
17
+ }
18
+ declare const logger: Logger | CliLogger;
19
+ export default logger;
@@ -0,0 +1,67 @@
1
+ export interface IMetrics {
2
+ nodes?: Array<{
3
+ node: string;
4
+ timestamp: number;
5
+ }>;
6
+ compiler?: string;
7
+ compilerVersion?: string;
8
+ [key: string]: any;
9
+ }
10
+ /**
11
+ * Push event node to metrics.
12
+ *
13
+ * Side-effected, shall mutate the `nodes` field in `metrics` object.
14
+ * @param metrics
15
+ * @param event
16
+ */
17
+ export declare function addNodeToMetrics(metrics: IMetrics, event: string): void;
18
+ /**
19
+ * Add field with to metrics.
20
+ *
21
+ * Side-effected, shall mutate the `metrics` object.
22
+ * @param metrics
23
+ * @param field
24
+ * @param value
25
+ */
26
+ export declare function addFieldToMetrics(metrics: IMetrics, field: string, value: any): void;
27
+ /**
28
+ * Merge a list of metrics, return a new metric.
29
+ *
30
+ * Non-side-effected.
31
+ * @param metrics
32
+ * @returns
33
+ */
34
+ export declare function mergeMetrics(...metrics: IMetrics[]): IMetrics;
35
+ /**
36
+ * Abstract for {@link IMetrics}
37
+ */
38
+ export declare class Metrics {
39
+ nodes: IMetrics['nodes'];
40
+ tags: Exclude<IMetrics, 'nodes'>;
41
+ /**
42
+ * Add node to {@link nodes}
43
+ * @param event
44
+ * @param timestamp
45
+ */
46
+ addNode(event: string, timestamp?: number): this;
47
+ /**
48
+ * Add node to {@link tags}
49
+ * @param field
50
+ * @param value
51
+ */
52
+ updateField(field: string, value: keyof Exclude<IMetrics, 'nodes'>): this;
53
+ /**
54
+ * Merge metrics, the order matters
55
+ */
56
+ merge(...others: IMetrics[]): this;
57
+ /**
58
+ * Settle the metrics
59
+ * @param clear whether to reset the metrics to empty.
60
+ * @returns
61
+ */
62
+ settle(clear?: boolean): IMetrics;
63
+ /**
64
+ * Clear the metrics.
65
+ */
66
+ clear(): this;
67
+ }
@@ -0,0 +1,64 @@
1
+ export interface MakeSchemaResult {
2
+ originSchema: string;
3
+ shortUrl: string;
4
+ expireTime: number;
5
+ }
6
+ interface RoomInfo {
7
+ gtoken: string;
8
+ roomid: string;
9
+ }
10
+ interface QRCodeQuery extends RoomInfo {
11
+ [k: string]: string;
12
+ }
13
+ interface BDPLog {
14
+ launch_from: string;
15
+ location: string;
16
+ }
17
+ export declare type IDEConfig = IDEBaseConfig & IDESandboxConfig;
18
+ export interface IDEBaseConfig {
19
+ previewScene: 'live' | 'default';
20
+ ideVersion: string;
21
+ ideOS: string;
22
+ ideDid: string;
23
+ ideUid: number;
24
+ skipDomainCheck?: boolean;
25
+ inspectPlatform?: DevicePlatform;
26
+ iOSDebugVersion?: string;
27
+ connectType?: 'push' | 'scan';
28
+ }
29
+ export interface IDESandboxConfig {
30
+ isSandbox?: boolean;
31
+ randomKey?: string;
32
+ accountName?: string;
33
+ appId?: string;
34
+ appName?: string;
35
+ expireTime?: string;
36
+ }
37
+ declare type DevicePlatform = 'Android' | 'iOS' | 'all';
38
+ export declare type MakeSchemaOption = {
39
+ devAppid: string;
40
+ extAppid: string;
41
+ startPage: string;
42
+ query: string;
43
+ qrcodeQuery?: QRCodeQuery;
44
+ scene: string;
45
+ bdpLog: BDPLog;
46
+ headers: object;
47
+ inspectPlatform?: DevicePlatform;
48
+ ideConfig?: IDEConfig;
49
+ referrerInfo?: {
50
+ appId: string;
51
+ extraData: Record<string, unknown>;
52
+ };
53
+ isInteractGame?: boolean;
54
+ hotRestartHash?: string;
55
+ type: string;
56
+ };
57
+ export declare function makeSchema(options: MakeSchemaOption): Promise<MakeSchemaResult>;
58
+ export declare function toQRCodeSVG(str: string): Promise<string>;
59
+ export declare function toQRCodeFile(text: string, filePath: string): Promise<any>;
60
+ export declare function generateTerminalQrCode(url: string, options: {
61
+ small?: boolean;
62
+ copy?: boolean;
63
+ }): void;
64
+ export {};